Пример #1
0
    curl_setopt($ch, CURLOPT_REFERER, "http://jw.jxust.cn/xskbcx.aspx?xh=''&xm=''&gnmkdm=N121603");
    $rs = curl_exec($ch);
    //执行cURL抓取页面内容
    curl_close($ch);
    $pattern = '/<input type="hidden" name="__VIEWSTATE" value="(.*?)" \\/>/is';
    preg_match_all($pattern, $rs, $matches);
    $res[0] = $matches[1][0];
    return $res;
}
//获得前端提交的数据
//设置post的数据
$post = array('__VIEWSTATE' => $view[0], 'tname' => 'bt1', 'tbtns' => 'bt1', 'tnameXw' => 'yhdl', 'tbtnsXw' => 'yhdl|xwxsdl', 'txtYhm' => $username, 'txtXm' => '', 'txtMm' => $password, 'rblJs' => '学生', 'btnDl' => '登 录');
//模拟登录
login_post($url, $cookie, $post);
//获取登录页的信息
$ress = get_res($url2, $cookie);
//$data 是查询课表所需要提交的数据
$data = array('__EVENTTARGET' => 'xnd', '__EVENTARGUMENT' => '', '__VIEWSTATE' => $ress[0], 'xnd' => $term, 'xqd' => $num);
$kebiao = get_content($url2, $cookie, "http://jw.jxust.cn/xskbcx.aspx?xh={$username}&xm=''&gnmkdm=N121603", $data);
preg_match_all('/<table id="Table1"[\\w\\W]*?>([\\w\\W]*?)<\\/table>/', $kebiao, $out);
$table = $out[0][0];
//获取整个课表
preg_match_all('/<td [\\w\\W]*?>([\\w\\W]*?)<\\/td>/', $table, $out);
$td = $out[1];
$length = count($td);
//获得课程列表
for ($i = 0; $i < $length; $i++) {
    //$td[$i] = str_replace("<br>", "", $td[$i]);
    $reg = "/{(.*)}/";
    if (!preg_match_all($reg, $td[$i], $matches)) {
        unset($td[$i]);
Пример #2
0
<?php

function res_url($res)
{
    return $_SERVER['PHP_SELF'] . '?resource=' . $res;
}
function get_res($res)
{
    if (file_exists('resources/' . $res)) {
        return file_get_contents('resources/' . $res);
    } else {
        return !isset($GLOBALS['resources'][$res]) ? false : gzuncompress(base64_decode($GLOBALS['resources'][$res]));
    }
}
if (!empty($_REQUEST['resource'])) {
    $type = preg_replace('|.+\\.(\\w+)$|', '$1', $_REQUEST['resource']);
    if ('css' == $type) {
        $type = 'text/css';
    } elseif ('js' == $type) {
        $type = 'text/javascript';
    } elseif (in_array($type, array('jpg', 'png'))) {
        $type = 'image/' . $type;
    }
    header("Content-Type: {$type}");
    echo get_res($_REQUEST['resource']);
    exit;
}
Пример #3
0
        $res[0] = $arr[1];
    } else {
        $res[0] = 'Success';
    }
    preg_match('#(Vip|Premium)\\:\\s+([\\.\\d]+)#', $postResult, $arr);
    $res[1][0] = $arr[1];
    $res[1][1] = $arr[2];
    preg_match_all('#[\\w\\!\\-\\+]#', $avers, $arr);
    for ($i = 0; $i < count($arr[0]); $i++) {
        preg_match('#' . $avers_arr[$arr[0][$i]] . '(.+)#', $postResult, $arr1);
        $res[2][$i] = $arr1[0];
    }
    return $res;
}
//выведем для наглядности результат
$res = get_res($username, $password, $avers, $file);
$err = "";
if (!strlen($res[1][0])) {
    $err = "<font class='error'>Plz, check your balance</font>";
} else {
    if (strpos($res[0], 'often') !== false) {
        $err = "<font class='error'>You can't scan that often</font>";
    }
}
if (strlen($err)) {
    echo $err;
    unlink($file_upload);
    exit;
}
$smarty->assign(array('RES_0' => $res[0], 'RES_1_0' => $res[1][0], 'RES_1_1' => $res[1][1]));
$f**k = 0;