Пример #1
0
/**
 * 得到一卡通余额信息
 * @param unknown $openid
 * @return multitype:unknown
 */
function getEcard($openid)
{
    require_once 'loginCookie.php';
    // 得到登录成功所需要的Cookie
    $personInfo_cookie = getLoginCookie($openid);
    $cookieFile = SAE_TMP_PATH . '/personInfo_cookie.txt';
    file_put_contents($cookieFile, $personInfo_cookie);
    $login_url = "http://my.hpu.edu.cn/pnull.portal?.p=Znxjb20ud2lzY29tLnBvcnRhbC5zaXRlLnYyLmltcGwuRnJhZ21lbnRXaW5kb3d8ZjEyMDd8dmlld3xub3JtYWx8&.nctp=true&.ll=true&.reqId=0d36df1d-f2f0-11e4-bb26-dbfc400d4458&.isTW=false";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $login_url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $content = curl_exec($ch);
    curl_close($ch);
    $pattern = '#<font color="red">([\\w\\W]*?)</font>#is';
    preg_match_all($pattern, $content, $out, PREG_SET_ORDER);
    //作业数量
    $saiKeNum = $out[2][1];
    //借书数量
    $bookNum = $out[3][1];
    //超期图书数量
    $outBookNum = $out[4][1];
    //饭卡余额
    $eCardMoney = $out[5][1];
    return array($saiKeNum, $bookNum, $outBookNum, $eCardMoney);
}
Пример #2
0
/**
 * 得到校园招聘信息
 * @param unknown $openid
 * @return multitype:multitype:multitype:unknown
 */
function getSchoolZhao($openid)
{
    require_once 'loginCookie.php';
    // 得到登录成功所需要的Cookie
    $personInfo_cookie = getLoginCookie($openid);
    $cookieFile = SAE_TMP_PATH . '/personInfo_cookie.txt';
    file_put_contents($cookieFile, $personInfo_cookie);
    $login_url = "http://my.hpu.edu.cn/alone.portal?.pen=pe921&.pmn=view";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $login_url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $content = curl_exec($ch);
    curl_close($ch);
    $pattern = '#<span class="allleft"><a href="(.*?)" target="_blank">(.*?)</a></span><span class="allright">(.*?)</span>#is';
    preg_match_all($pattern, $content, $out, PREG_SET_ORDER);
    $schoolInZhaoArr = array();
    $schoolOutZhaoArr = array();
    for ($i = 0; $i < 9; $i++) {
        //title
        $title = $out[$i][2];
        //url
        $url = $out[$i][1];
        //time
        $time = $out[$i][3];
        $schoolInZhaoArr[] = array($title, $url, $time);
    }
    for ($j = 10; $j < 19; $j++) {
        //title
        $title = $out[$j][2];
        //url
        $url = $out[$j][1];
        //time
        $time = $out[$j][3];
        $schoolOutZhaoArr[] = array($title, $url, $time);
    }
    $schoolZhaoArr = array($schoolInZhaoArr, $schoolOutZhaoArr);
    $mmc = memcache_init();
    //把最新公告数组存入缓存,并设置失效时间为1小时
    memcache_set($mmc, 'schoolZhaoArr', $schoolZhaoArr, 0, 3600);
    return $schoolZhaoArr;
}
Пример #3
0
function callService(&$reqTxt, $department, $transtype, $symbol, $shares, $limitprice, $orderid, $username, $password, $currentcash)
{
    global $behaviors;
    try {
        $reqTxt = "";
        if (!$behaviors[$transtype]) {
            return "Behavior not implemented: {$transtype}";
        }
        $postData = array("behavior" => $transtype, "token" => getLoginCookie(), "symbol" => $symbol, "shares" => $shares, "limitprice" => $limitprice, "orderid" => $orderid, "username" => $username, "password" => $password, "currentcash" => $currentcash);
        $ws = new WSRequestManager();
        $ws->setServiceAddress("{$department}");
        $respTxt = $ws->getData("jsondata=" . json_encode($postData));
        $reqTxt = $ws->getLastRequestDetails();
        return $respTxt;
    } catch (Exception $e) {
        header('HTTP/1.1 500 Internal Server Error');
        echo "Error: " . $e->getMessage();
        exit;
    }
}
Пример #4
0
function getProfileInfo()
{
    try {
        $retval = "";
        $reqTxt = "";
        $postData = array("behavior" => "getProfileInfo", "token" => getLoginCookie(), "symbol" => "", "shares" => "", "limitprice" => "", "username" => "", "password" => "", "currentcash" => "");
        $ws = new WSRequestManager();
        $ws->setServiceAddress("TE");
        $respTxt = $ws->getData("jsondata=" . json_encode($postData));
        $reqTxt = $ws->getLastRequestDetails();
        //return $respTxt;
        //$respTxt = '{"behavior":"getProfileInfo","success":true,"statuscode":0,"statusdesc":["Good to go"],"retval":{"currentcash":8000.00,"holdings":[{"symbol":"INTC","shares":7,"value":100.00},{"symbol":"GOOG","shares":5,"value":10.50},{"symbol":"MSFT","shares":5,"value":1.25}]}}';
        $obj = json_decode($respTxt);
        return $obj->retval;
    } catch (Exception $e) {
        header('HTTP/1.1 500 Internal Server Error');
        echo "Error: " . $e->getMessage();
        exit;
    }
}
Пример #5
0
/**
 * 得到学术讲座信息
 * @return multitype:multitype:unknown
 */
function getXueshu($openid)
{
    require_once 'loginCookie.php';
    // 得到登录成功所需要的Cookie
    $personInfo_cookie = getLoginCookie($openid);
    $cookieFile = SAE_TMP_PATH . '/personInfo_cookie.txt';
    file_put_contents($cookieFile, $personInfo_cookie);
    $login_url = "http://my.hpu.edu.cn/AcademicReportList_new.jsp";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $login_url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $content = curl_exec($ch);
    curl_close($ch);
    $pattern = '#<a href="(.*?)" style="font-size: 14px; font-weight:bold; color:\\#C7A014; line-height:25px;" target="_blank">(.*?)</a>#is';
    preg_match_all($pattern, $content, $out1, PREG_SET_ORDER);
    $pattern = '#<li>(.*?)</li>#is';
    preg_match_all($pattern, $content, $out2, PREG_SET_ORDER);
    $xueShuInfoArr = array();
    for ($i = 0, $j = 0; $i < count($out2), $j < count($out1); $i += 4, $j++) {
        //主讲人
        $teacher = $out2[$i + 1][1];
        //时间
        $time = $out2[$i + 2][1];
        //地点
        $place = $out2[$i + 3][1];
        //题目
        $title = $out1[$j][2];
        //url
        $url = $out1[$j][1];
        //封装成数组
        $xueShuInfoArr[] = array($title, $url, $teacher, $time, $place);
    }
    $mmc = memcache_init();
    //把最新公告数组存入缓存,并设置失效时间为1小时
    memcache_set($mmc, 'xueShuInfoArr', $xueShuInfoArr, 0, 3600);
    return $xueShuInfoArr;
}
Пример #6
0
/**
 * 取得学校最新公告信息
 * @return 数组 tile/url/time
 */
function getNewInfo($openid)
{
    require_once 'loginCookie.php';
    // 得到登录成功所需要的Cookie
    $personInfo_cookie = getLoginCookie($openid);
    $cookieFile = SAE_TMP_PATH . '/personInfo_cookie.txt';
    file_put_contents($cookieFile, $personInfo_cookie);
    $login_url = "http://my.hpu.edu.cn/LatestNewsList_3.jsp";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $login_url);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $content = curl_exec($ch);
    curl_close($ch);
    // 正则 tile 与 url
    $pattern = '#<a href="([\\w\\W]*?)" title="([\\w\\W]*?)"target="_blank">([\\w\\W]*?)<\\/a>#is';
    preg_match_all($pattern, $content, $out1, PREG_SET_ORDER);
    // 正则出发布时间
    $pattern = '#<span>([\\w\\W]*?)</span>#is';
    preg_match_all($pattern, $content, $out2, PREG_SET_ORDER);
    $newInfoArr = array();
    $num = 9;
    if (count($out1) < 9) {
        $num = count($out1);
    }
    for ($i = 0; $i < $num; $i++) {
        $tile = $out1[$i][3];
        $url = $out1[$i][1];
        $time = $out2[$i][1];
        $newInfoArr[] = array("title" => $tile, "url" => $url, "time" => $time);
    }
    $mmc = memcache_init();
    //把最新公告数组存入缓存,并设置失效时间为1小时
    memcache_set($mmc, 'newInfoArr', $newInfoArr, 0, 3600);
    return $newInfoArr;
}
Пример #7
0
    $encryptedData = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, getSecret(), $cookieData, MCRYPT_MODE_CBC, $iv);
    setcookie("usr", base64_encode($encryptedData) . ":" . $iv, $exptimestamp);
}
//get and decrypt encrypted cookies from user-agent
function getLoginCookie()
{
    //voodoo
    list($encryptedData, $iv) = explode(":", $_COOKIE["usr"]);
    $rawData = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, getSecret(), base64_decode($encryptedData), MCRYPT_MODE_CBC, $iv);
    return unserialize($rawData);
}
//If logged in, continue. Otherwise, go back to login page.
//ASSUMES the basename of the login page is login.php
$loginPageBasename = "login.php";
echo "login.include.php: (pathinfo(\$_SERVER['PHP_SELF'], PATHINFO_BASENAME) <br/>";
echo pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME) . " <br/>";
echo "login.include.php: (pathinfo(\$_SERVER['PHP_SELF'], PATHINFO_DIRNAME) <br/>";
echo pathinfo($_SERVER['PHP_SELF'], PATHINFO_DIRNAME) . " <br/>";
//this script is included by all pages that require login
//if we're sitting on the login page itself,
//  keep us from doing an infinite redirect
//otherwise, redirect to login if the cookie is not valid
//do we need a function that checks the database to see if the token is valid?
//if (pathinfo(htmlentities($_SERVER['PHP_SELF']), PATHINFO_BASENAME) !=
//if (pathinfo($_SERVER['PHP_SELF'], PATHINFO_BASENAME) !=
echo $_SERVER['PHP_SELF'];
echo " <br/>";
echo "\$loginpage == {$loginpage}" . " <br/>";
if ($_SERVER['PHP_SELF'] != $loginpage && strlen(getLoginCookie()) != 32) {
    header("Location: {$loginPage}?jumpto={$_SERVER['PHP_SELF']}");
}
Пример #8
0
define('A_ChangeThread', 'changethread');
define('A_ShowThread', 'showthread');
define('A_ShowForum', 'showforum');
// Änderungen auch in forum_inc.php erledigen:
define('P_ForumSearch', 'forumsearch');
define('P_ForumHome', 'forumhome');
define('P_Forum', 'forum');
define('P_Thread', 'thread');
// Im Basismodul:
define('P_Home', '!home');
// ----------- Program
$session = new Session($start_time);
// All requests require the database
dbOpen($session);
//p ('User,Id,Login: '******'') {
    $session->trace(TC_Init, 'index.php: Cookie erfolgreich gelesen');
}
$rc = dbCheckSession($session);
$do_login = false;
if (!empty($rc)) {
    // p ("Keine Session gefunden: $session_id / $session_user ($rc)");
    if (!empty($login_user)) {
        baseLoginAnswer($session);
    } else {
        $do_login = true;
    }
} else {
    if (isset($login_user)) {
        baseLoginAnswer($session);
    }
Пример #9
0
define('CURL_TIMEOUT_SET', 5);
define('HOSTNAME', 'josephjiang.com');
define('HTTPHOST', 'http://josephjiang.com/');
define('STATICHOST', 'http://img.josephjiang.com/');
function getLoginCookie()
{
    if (!isset($_COOKIE['user']) || empty($_COOKIE['user'])) {
        return false;
    }
    return $_COOKIE['user'];
}
function setLoginCookie($user)
{
    setcookie('user', $user, time() + 86400 * 7);
}
$global_user = getLoginCookie();
function getBlogArticleRecentList()
{
    $result = '';
    $dbh = mysql_connect('localhost', 'root', '');
    mysql_select_db('josephjiang', $dbh);
    $res = mysql_query('SELECT * FROM blog_article WHERE is_show = "y" ORDER BY last_update DESC LIMIT 10', $dbh);
    while ($row = mysql_fetch_assoc($res)) {
        $result[] = $row;
    }
    return $result;
}
function getBlogArticleColumns()
{
    return array('background', 'blog_article_id', 'blog_category_id', 'blog_category_title', 'blog_comment_total', 'content', 'is_show', 'is_nl2br', 'keyword', 'last_update', 'selected_date', 'summary', 'title');
}
Пример #10
0
<?php

/******************************************************************
* trade.php
* By: Jeff Miller (millerj3@students.sou.edu), 2012-10-24
* Description: Example of a page that requires login to access.
******************************************************************/
include "login.include.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome</title>
</head>
<body>
<div><strong>You must be logged in to access this page.</strong></div>
<div><em>Your token was: <?php 
echo getLoginCookie();
?>
</em></div>
<a href="javascript:alert(document.cookie)">Show Cookie</a>
</body>
</html>


Пример #11
0
function successfullLogin(&$session)
{
    dbOpen($session);
    if (empty($session_user) && getLoginCookie($session, $user, $code) && dbCheckUser($session, $user, $code) == '') {
        $session->trace(TC_Init, 'index.php: Cookie erfolgreich gelesen');
    }
    $rc = dbCheckSession($session);
    $do_login = false;
    #$session->dumpVars ("Init");
    if ($rc != null) {
        $session->trace(TC_Init, 'keine Session gefunden: ' . $rc . ' ' . (empty($_POST['login_user']) ? "-" : '>' . $_POST['login_user']));
        $do_login = true;
    } else {
        $session->trace(TC_Init, 'login_user: '******'login_user'));
        if (isset($_POST['login_user'])) {
            $do_login = guiLoginAnswer($session, $rc);
        } else {
            $known_user = $session->fSessionUser != null && $session->fSessionUser > 0;
            $do_login = $session->fPageURL == P_Login || !$known_user;
            $session->trace(TC_Init, 'known_user: '******'t' : 'f'));
        }
    }
    $session->trace(TC_Init, "session_no: do_login: "******"t" : "f"));
    if ($do_login) {
        clearLoginCookie($session);
        guiLogin($session, $rc);
    } else {
        $session->storeSession();
    }
    return !$do_login;
}