Пример #1
0
 static function Login($user, $passwd, &$error)
 {
     $error = "";
     $times = 3;
     $curDate = date("Ymdhis");
     $cookies = dirname(dirname(__FILE__)) . "/cookies/stadium.login." . $curDate . ".cookie";
     // 将登錄界面的cookie写入文件中
     $Home = "http://113.106.49.136:860/bs/index.htm";
     $html = curl::Cookies($Home, $cookies, "");
     CAPTCHA:
     // 利用登錄界面的cookie获取验证码圖片
     $url = "http://113.106.49.136:860/bs/images/Image.jsp";
     $captchaFile = dirname(__FILE__) . "\\" . $curDate . "captcha.jpg";
     $file = fopen($captchaFile, "w");
     fwrite($file, curl::Get($url, $cookies));
     fclose($file);
     if (!file_exists($captchaFile)) {
         $error = "captcha file save failed.";
         return "";
     }
     // 使用captcha.exe破解驗證碼
     $verCode = exec(dirname(dirname(__FILE__)) . "\\bin\\captcha.exe " . $captchaFile);
     unlink($captchaFile);
     // 獲取登錄賬號基本信息
     $CallBack = "http://113.106.49.136:861/SUReader/page/InitqAcc.jsp?pacc=" . $user . "&callback=";
     $jsonBack = trim(trim(curl::Get($CallBack, $cookies)), "()");
     $jsonBack = json_decode($jsonBack);
     // 生成登錄請求Post數據
     /*member_no=1201260241&password=123456&verCode=5555&workstation_no=&name=%D1%EE%D3%C0%C7%E0&sexNo=1&deptCode=001124101106&cardNo=3408270927&accountNo=3408270927&studentCode=1201260241&idCard=441521199207211132&pid=01&balance=15030&idNo=000000006495&expireDate=330405*/
     $PostArray = array("member_no" => $user, "password" => $passwd, "verCode" => $verCode, "workstation_no" => "", "name" => urlencode(mb_convert_encoding($jsonBack->name, 'gb2312')), "sexNo" => $jsonBack->sexNo, "deptCode" => $jsonBack->deptCode, "cardNo" => $jsonBack->cardNo, "accountNo" => $jsonBack->accountNo, "studentCode" => $jsonBack->studentCode, "idCard" => $jsonBack->idCard, "pid" => $jsonBack->pid, "balance" => $jsonBack->balance, "idNo" => $jsonBack->idNo, "expireDate" => $jsonBack->expireDate);
     $data = "";
     foreach ($PostArray as $key => $v) {
         $data .= $key . "=" . $v . "&";
     }
     $data = trim($data, "&");
     // 發出登錄請求,
     $url = "http://113.106.49.136:860/bs/system_operator_Signon.htm";
     $html = curl::encoding(curl::Post($url, $cookies, $data), "gbk");
     // 判斷驗證碼是否解析有誤
     if (stadium::isCaptcha($html)) {
         if ($times-- > 0) {
             goto CAPTCHA;
         }
         // 返回重新取得驗證碼
         $error = "captcha read failed.";
         return "";
     }
     // 判斷是否登錄成功
     if (!stadium::isLogin($html)) {
         $error = "login failed.";
         return "";
     }
     return $cookies;
 }
Пример #2
0
 static function Login($user, $passwd, &$error)
 {
     $error = "";
     $cookies = dirname(dirname(__FILE__)) . "/cookies/zfxk2.login." . date("Ymdhis") . ".cookie";
     $data = '__VIEWSTATE=dDwxOTA0NTQ3NDgwO3Q8O2w8aTwxPjs%2BO2w8dDw7bDxpPDg%2BO2k8MTM%2BO2k8MTU%2BOz47bDx0PHA8O3A8bDxvbmNsaWNrOz47bDx3aW5kb3cuY2xvc2UoKVw7Oz4%2BPjs7Pjt0PHA8bDxWaXNpYmxlOz47bDxvPGY%2BOz4%2BOzs%2BO3Q8cDxsPFZpc2libGU7PjtsPG88Zj47Pj47Oz47Pj47Pj47bDxpbWdETDtpbWdUQztpbWdRTU07Pj7x6PjbnkVn3z9hXf5cLw0NJt%2FfaQ%3D%3D&tbYHM=' . $user . '&tbPSW=' . $passwd . '&ddlSF=%D1%A7%C9%FA&imgDL.x=25&imgDL.y=12';
     $url = "http://113.106.49.220/zfxk2/default3.aspx";
     $html = curl::encoding(curl::Cookies($url, $cookies, $data), "gbk");
     // 取得cookies
     if (strpos($html, "密码不正确,若密码忘记请到各系教务办初始化密码!!")) {
         $error = "password or user is wrong.";
         return "";
     } else {
         if (strpos($html, "用户不存在或者学籍状态为空!请查证后再试!")) {
             $error = "user not found.";
             return "";
         } else {
             if (strpos($html, "学籍状态为毕业!无法登陆系统")) {
                 $error = "user has graduated.";
                 return "";
             }
         }
     }
     return $cookies;
 }