forked from nomagick/URP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.php
70 lines (65 loc) · 2.45 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*$config['ip'] = "202.204.193.249";
$config['port'] = "8889";
$config['dictionary'] = "/";*/
function getcookie($config,$zjh,$mm)
{
// if ($config['ip'] == "202.204.208.73" && $config['port'] == "8033") $mm = md5($mm,false);
$link = fsockopen($config['ip'],$config['port'],$errno,$errstr,30);
if (!$link) exit ( $errstr . " ==> " . $errno);
$seekcookie = 0;
$cookie = 0;
$out = "GET " . $config['dictionary'] . "loginAction.do?zjh=" . $zjh . "&mm=" . $mm . " HTTP/1.1\r\n";
$out .= "Host: " . $config['ip'] . ":" . $config['port'] . "\r\n";
$out .= "Connection: close\r\n\r\n";
fwrite($link, $out);
while (!feof($link))
{
$seekcookie = fgets($link, 128);
$seekcookie = explode(" ",$seekcookie);
if (strncasecmp($seekcookie[1],"JSESSIONID",10) == 0)
{
$cookie = $seekcookie[1];
// $cookie = str_replace(";","",$cookie);
$cookie = chop($cookie,";");
// echo $cookie;
break;
}
}
fclose($link);
return $cookie;
}
function doaction($config,$url,$cookie)
{
$link = fsockopen($config['ip'],$config['port'],$errno,$errstr,30);
$out = "GET " . $config['dictionary'] . $url . " HTTP/1.1\r\n";
$out .= "Host: " . $config['ip'] . ":" . $config['port'] . "\r\n";
$out .= "Cookie: " . "$cookie" . "\r\n";
$out .= "Connection: close\r\n\r\n";
fwrite($link, $out);
$backstr = "";
while (!feof($link))
{
$backstr .= fgets($link, 2048);
}
fclose($link);
return mb_convert_encoding($backstr,'utf-8','gbk');
}
function picksinglecourse($config,$kcid,$kcbj,$cookie)
{
doaction($config,"xkAction.do?actionType=6",$cookie);
doaction($config,"xkAction.do?actionType=5&skxq=&skjc=&pageNumber=-2&kch=" . $kcid . "&cxkxh=" . $kcbj,$cookie);
return doaction($config,"xkAction.do?actionType=9&preActionType=5&kcId=" . $kcid . "_" . $kcbj,$cookie);
}
function check_success ($backstr)
{
$backstr = substr($backstr,0,4000);
$backstr = str_replace("\t","",$backstr);
if (!((stripos($backstr,"上课时间冲突",0)) || (stripos($backstr,"已经选择了",0)) || (stripos($backstr,"选课成功",0)))) return false; else return true;
}
function build_repick ($zjh,$mm,$profile,$kcid,$bjid,$backstr)
{
echo "<html><head><META HTTP-EQUIV=\"Refresh\" CONTENT=\"10; URL=action.php?zjh=$zjh&mm=$mm&profile=$profile&action=7&kcid=$kcid&bjid=$bjid\"><meta http-equiv=\"pragma\" content=\"no-cache\"></HEAD><body><h1>Operation Considered Unsuccessful , Retry After 10 Seconds.</h1><h2>未检测到选课成功迹象,10秒后重试。</h2></br>";
echo $backstr;
}
?>