Skip to content

Commit

Permalink
添加对已经毕业同学或没有成绩的时候的容错
Browse files Browse the repository at this point in the history
  • Loading branch information
ldustu committed Jan 20, 2015
1 parent 24aa9b0 commit 85a8b82
Show file tree
Hide file tree
Showing 104 changed files with 29,019 additions and 42 deletions.
4 changes: 3 additions & 1 deletion api/php/conn.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
mysql_select_db("cj", $con);

$sql = sprintf(
"SELECT * FROM '%s' where `from` = '%s'",
"SELECT * FROM %s where `from` = '%s'",
mysql_real_escape_string('site'),
mysql_real_escape_string($from)
);

$result = mysql_query($sql);

$row = mysql_fetch_array($result);

$siteData = array(
'from'=>$row['from'],
'appid'=>$row['appid'],
Expand Down
21 changes: 17 additions & 4 deletions api/php/score.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,31 @@
$data=curl_exec($ch);

$data = iconv('gbk', 'utf-8',$data);

$nodata="/\/img\/icon\/alert.gif/";
if (preg_match($nodata, $data)) {
$content = array(
'error'=> 7,
'data'=> 'password error or server error'
);

$json = json_encode($content);
echo $json;
return;
}
phpQuery::newDocumentHTML($data);
$i = 0;
do {
$i ++;
$tr[$i] = pq('table:eq(6) tr:eq(' . $i . ')');
}while($tr[$i] != '');


if(count($tr) == 1){

$content = array(
'error'=> 1,
'data'=> 'password error or server error'
'error'=> 8,
'data'=> 'no have list'
);

$json = json_encode($content);
Expand All @@ -137,11 +149,12 @@
'kch'=>trim($tr[$i]->find('td:eq(0)')->text()),
'kxh'=>trim($tr[$i]->find('td:eq(1)')->text()),
'kcm'=>trim($tr[$i]->find('td:eq(2)')->text()),
'ywkcm'=>trim($tr[$i]->find('td:eq(3)')->text())|'没有',
'ywkcm'=>trim($tr[$i]->find('td:eq(3)')->text()),
'xf'=>trim($tr[$i]->find('td:eq(4)')->text()),
'kcsx'=>trim($tr[$i]->find('td:eq(5)')->text()),
'cj'=>trim($tr[$i]->find('td:eq(6)')->text())|'还没出',
'cj'=>trim($tr[$i]->find('td:eq(6)')->text()),
);
if($item['cj'] == '') $item['cj'] = '还没出';
$score[$i-1] = $item;
}

Expand Down
4 changes: 2 additions & 2 deletions cha.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
error_reporting(E_ALL^E_NOTICE);

$userid=$_REQUEST['userid'];
$password=$_REQUEST['password'];
$userid=$_POST['userid'];
$password=$_POST['password'];

$url = 'http://cj.ldustu.com/api/score?userid='.$userid.'&password='.$password.'&from=ldsn&appid='.$_SERVER["CJ_APPID"].'&secret='.$_SERVER["CJ_SECRET"];

Expand Down
5 changes: 3 additions & 2 deletions css/css.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ a {
text-decoration:none;
}
.index{
top: 0; bottom: 0; position: absolute; left: 0; right: 0; background:url('../images/cja.jpg') 0px -73px;
top: 0; bottom: 0; position: absolute; left: 0; right: 0; background:url('../images/cja.jpg') center -73px;overflow: scroll;
}

.arc_content{
Expand All @@ -35,7 +35,7 @@ padding-top: 20px;
box-shadow: 1px 3px 7px 3px #000;
padding-bottom: 20px;
}
.title {
.fr-title {
text-align: center;
font-size: 23px;
color: #fff;
Expand Down Expand Up @@ -222,6 +222,7 @@ body {
text-align: center;
display: block;
}

/* @group styles
-----------------------------------------------------*/

Expand Down
47 changes: 33 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<body >
<div class="index" id="first">
<div class="center">
<h1 class="title">
<h1 class="fr-title">
鲁东大学成绩查询系统
</h1>
<img src="./images/logo.png" class="logo" />
Expand All @@ -25,7 +25,7 @@ <h1 class="title">
<input type="text" name="zjh" class="textbox" placeholder="学号" />
<input type="password" name="mm" class="textbox" placeholder="密码" />
</div>
<a href="javascript:cha();" class="submit_btn">
<a href="javascript:;" class="submit_btn">
<span>
查询
</span>
Expand All @@ -41,14 +41,6 @@ <h1 class="title">
</a>
</div>
</div>
<!-- Adsense -->
<div>
<!-- ldsn_cj -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7536831447654223"
data-ad-slot="8126317375" data-ad-format="auto">
</ins>
</div>
<!-- adsense -->
</div>
<div class="cj-wrap cj-second" id="second">
<h1 class="cj-title">
Expand All @@ -64,20 +56,47 @@ <h1 class="cj-title">
<ul class="cj-box">
</ul>
<p class="cj-tip3">
<a href="index.php">
<a href="javascript:;" id="restart">
点击这里再次查询
</a>
关注"鲁大学生网"官方微信,把成绩放进口袋,获取更多内容!
<br>
我们的微信号:LDSN001
</p>
<!-- Adsense -->
<div>
<!-- ldsn_cj -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7536831447654223"
data-ad-slot="8126317375" data-ad-format="auto">
</ins>
</div>
<!-- adsense -->

<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread" data-thread-key="3769" data-title="成绩单">
<div class="ds-thread" data-thread-key="3769" data-title="成绩单" style="display: none;">
</div>
<!-- Duoshuo Comment END -->
</div>
<script src="./js/jquery.js"></script>
<script src="./js/cj.js"></script>
<script src="./js/cj.js"></script>

<div style="display:none"><script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_5796710'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s13.cnzz.com/stat.php%3Fid%3D5796710' type='text/javascript'%3E%3C/script%3E"));</script></div>

<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"ldu"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- Duoshuo Comment END -->



</body>

</html>
145 changes: 126 additions & 19 deletions js/cj.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//(function () {

var data = {};
var data.user = {};
var data.score = {};
data.user = {};
data.score = {};

var check = function () {
var zjh = $('input[name="zjh"]').val();
Expand All @@ -15,44 +15,137 @@
alert('请填写密码。');
return 0;
}
data.user.zjh = zjh;
data.user.mm = mm;
data.user.userid = zjh;
data.user.password = mm;
};

var changePage = function () {
if ($('#second').css('display').toLowerCase() === 'block') {
$('#second').css('display','none');
$('#first').css('display','block');
if ($('#second').css('display') === 'block') {
$('.adsbygoogle').css('display','none');
$('.ds-thread').css('display','none');
$('#second').slideToggle();
$('#first').slideToggle('normal',function(){
data = {};
data.user = {};
data.score = {};
});

} else {
$('#second').css('display','block');
$('#first').css('display','none');
$('#second').slideToggle();
$('#first').slideToggle("normal",function(){
$('.adsbygoogle').css('display','block');
$('.ds-thread').css('display','block');
});
}

};

var addGoogle = function () {
if (!$('script[src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"]'){
if ($('script[src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"]').length == 0){
var adg = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>';
$(adg).appendTo('body');
}
};

var loading = function () {
if($('loading').css('display').toLowerCase() === 'none') {
$('loading').css('display','block');
var loading = function (flag) {
if(flag) {
$('.loading').css('display','block');
} else {
$('loading').css('display','none');
$('.loading').css('display','none');
}
}

var setData = function () {
};

}
var getScore = function () {
$.ajax({
type:'POST',
url:'cha.php',
data:'userid=' + data.user.userid + '&password=' + data.user.password,
success:function(d){
var result;
try {
result = $.parseJSON(d);
} catch (e) {
result = d;
}
data.score = result;
$('.cj-box').empty();
getScoreSuccess();
},
error:function(){
alert('出现未知链接错误,请联系管理员或重试!');
changePage();
return;
}
});
};

var cha = function () {
check();
loading(true);
changePage();
loading();
getScore();
};

var getScoreSuccess = function () {
loading(false);
if (data.score.error > 0) {
if (data.score.error == 7){
alert('密码错误或教务系统服务器出现问题,请重试!');
changePage();
return;
} else if (data.score.error == 8) {
alert('本学习成绩查询还没有开始,或者你已经没有考试科目了!');
changePage();
return;
} else {
alert('出现未知错误,请联系管理员或重试!');
changePage();
return;
}
}

setData();
addGoogle();
}

var restart = function () {
changePage();
}

var setData = function () {
var text = '';
for ( var i = 0; i < data.score.score.length; i++ ){
text += '<li class="cj-item">'
+ '<div class="cj-top clearfix">'
+ '<div class="title">' + data.score.score[i].kcm + '</div>'
+ '<div class="content">' + data.score.score[i].cj + '</div>'
+ '</div>'
+ '<ul class="cj-info">'
+ '<li class="cj-td clearfix">'
+ '<div class="title">课程号</div>'
+ '<div class="content">' + data.score.score[i].kch + '</div>'
+ '</li>'
+ '<li class="cj-td clearfix">'
+ '<div class="title">课序号</div>'
+ '<div class="content">' + data.score.score[i].kxh + '</div>'
+ '</li>'
+ '<li class="cj-td clearfix">'
+ '<div class="title">英文名</div>'
+ '<div class="content">' + data.score.score[i].ywkcm + '</div>'
+ '</li>'
+ '<li class="cj-td clearfix">'
+ '<div class="title">学分</div>'
+ '<div class="content">' + data.score.score[i].xf + '</div>'
+ '</li>'
+ '<li class="cj-td clearfix">'
+ '<div class="title">课程属性</div>'
+ '<div class="content">' + data.score.score[i].kcsx + '</div>'
+ '</li>'
+ '</ul>'
+ '</li>';
}
$(text).appendTo('.cj-box');
}



Expand All @@ -62,7 +155,21 @@
cha();
}
});
$('.submit_btn').click(function() {
cha();
});
$('#restart').click(function () {
restart();
});
$('.cj-box').on('click', '.cj-item', function(e){
$(this).find('.cj-info').slideToggle();
});
}

var init = function () {
bindEvent();
}
init();


//})()
Expand Down
11 changes: 11 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cj
==

校外查成绩v1.0 2013.01.10
查询系统

校外查成绩v1.1 2013.01.10
更换手机版模板

校外查成绩v2.0 2013.01.10
正在研发,提供成绩查询api
Loading

0 comments on commit 85a8b82

Please sign in to comment.