예제 #1
0
 protected function sendAndReceive($request)
 {
     $f = new SaeFetchurl();
     $cookie = $this->getCookie();
     if ($cookie != '') {
         $f->setHeader("Cookie", $cookie);
     }
     if ($this->keepAlive) {
         $f->setHeader("Connection", "keep-alive");
         $f->setHeader("Keep-Alive", $this->keepAliveTimeout);
     } else {
         $f->setHeader("Connection", "close");
     }
     foreach ($this->header as $name => $value) {
         $f->setHeader($name, $value);
     }
     $f->setMethod("post");
     $f->setPostData($request);
     $f->setConnectTimeout($this->timeout);
     $f->setSendTimeout($this->timeout);
     $f->setReadTimeout($this->timeout);
     $response = $f->fetch($this->url);
     if ($f->errno()) {
         throw new Exception($f->errno() . ": " . $f->errmsg());
     }
     $http_response_header = $f->responseHeaders(false);
     $this->setCookie($http_response_header);
     return $response;
 }
예제 #2
0
function getName($stuID, $pwd)
{
    $f = new SaeFetchurl();
    $f->setMethod('post');
    $logindata['IPT_LOGINUSERNAME'] = $stuID;
    $logindata['IPT_LOGINPASSWORD'] = $pwd;
    $f->setPostData($logindata);
    $f->setAllowRedirect(false);
    $f->fetch('http://222.30.60.9/meol/homepage/common/login.jsp');
    if ($f->errno()) {
        $cookies = $f->responseCookies(false);
        $f->setCookies($cookies);
        $content = $f->fetch('http://222.30.60.9/meol/welcomepage/student/index.jsp');
        $name = substr($content, strlen('<li>' . '   ') + strpos($content, '<li>') + 3, (strlen($content) - strpos($content, '</li>')) * -1);
        return iconv('GBK', 'UTF-8//IGNORE', $name);
    } else {
        return false;
    }
}
예제 #3
0
 public function invoke($functionName, &$arguments = array(), $byRef = false, $resultMode = HproseResultMode::Normal)
 {
     $stream = new HproseStringStream(HproseTags::TagCall);
     $hproseWriter = new HproseWriter($stream);
     $hproseWriter->writeString($functionName, false);
     if (0 < count($arguments) || $byRef) {
         $hproseWriter->reset();
         $hproseWriter->writeList($arguments, false);
     }
     if ($byRef) {
         $hproseWriter->writeBoolean(true);
     }
     $stream->write(HproseTags::TagEnd);
     $request = $stream->toString();
     if ($this->filter) {
         $request = $this->filter->outputFilter($request);
     }
     $stream->close();
     $f = new SaeFetchurl();
     $cookie = $this->getCookie();
     if ($cookie != "") {
         $f->setHeader("Cookie", $cookie);
     }
     if ($this->keepAlive) {
         $f->setHeader("Connection", "keep-alive");
         $f->setHeader("Keep-Alive", $this->keepAliveTimeout);
     } else {
         $f->setHeader("Connection", "close");
     }
     foreach ($this->header as $name => $value) {
         $f->setHeader($name, $value);
     }
     $f->setMethod("post");
     $f->setPostData($request);
     $f->setConnectTimeout($this->timeout);
     $f->setSendTimeout($this->timeout);
     $f->setReadTimeout($this->timeout);
     $response = $f->fetch($this->url);
     if ($f->errno()) {
         throw new HproseException($f->errno() . ": " . $f->errmsg());
     }
     $http_response_header = $f->responseHeaders(false);
     $this->setCookie($http_response_header);
     if ($this->filter) {
         $response = $this->filter->inputFilter($response);
     }
     if ($resultMode == HproseResultMode::RawWithEndTag) {
         return $response;
     }
     if ($resultMode == HproseResultMode::Raw) {
         return substr($response, 0, -1);
     }
     $stream = new HproseStringStream($response);
     $hproseReader = new HproseReader($stream);
     $result = NULL;
     $error = NULL;
     while (($tag = $hproseReader->checkTags(array(HproseTags::TagResult, HproseTags::TagArgument, HproseTags::TagError, HproseTags::TagEnd))) !== HproseTags::TagEnd) {
         switch ($tag) {
             case HproseTags:
                 if ($resultMode == HproseResultMode::Serialized) {
                     $result = $hproseReader->readRaw()->toString();
                 } else {
                     $hproseReader->reset();
                     $result =& $hproseReader->unserialize();
                 }
                 break;
             case HproseTags:
                 $hproseReader->reset();
                 $args =& $hproseReader->readList();
                 for ($i = 0; $i < count($arguments); $i++) {
                     $arguments[$i] =& $args[$i];
                 }
                 break;
             case HproseTags:
                 $hproseReader->reset();
                 $error = new HproseException($hproseReader->readString());
                 break;
         }
     }
     if (!is_null($error)) {
         throw $error;
     }
     return $result;
 }
예제 #4
0
<?php

$con = mysql_connect(SAE_MYSQL_HOST_M . ":" . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS);
if (!$con) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db(SAE_MYSQL_DB, $con);
$result = mysql_query("SELECT * FROM Email");
while ($row = mysql_fetch_array($result)) {
    if ($row['Time'] == date(H)) {
        $id = $row['City'];
        $url = "http://m.weather.com.cn/data/" . $id . ".html";
        $f = new SaeFetchurl();
        $f->setMethod('get');
        $data = $f->fetch($url);
        $json = json_decode($data, TRUE);
        $mbody[1] = '今天是' . $json['weatherinfo']['date_y'] . '' . $json['weatherinfo']['week'];
        $mbody[2] = '1天后:' . $json['weatherinfo']['temp1'] . ' ' . $json['weatherinfo']['weather1'] . ' ' . $json['weatherinfo']['wind1'] . $json['weatherinfo']['fl1'];
        $mbody[3] = '2天后:' . $json['weatherinfo']['temp2'] . ' ' . $json['weatherinfo']['weather2'] . ' ' . $json['weatherinfo']['wind2'] . $json['weatherinfo']['fl2'];
        $mbody[4] = '3天后:' . $json['weatherinfo']['temp3'] . ' ' . $json['weatherinfo']['weather3'] . ' ' . $json['weatherinfo']['wind3'] . $json['weatherinfo']['fl3'];
        $mbody[5] = '4天后:' . $json['weatherinfo']['temp4'] . ' ' . $json['weatherinfo']['weather4'] . ' ' . $json['weatherinfo']['wind4'] . $json['weatherinfo']['fl4'];
        $mbody[6] = '5天后:' . $json['weatherinfo']['temp5'] . ' ' . $json['weatherinfo']['weather5'] . ' ' . $json['weatherinfo']['wind5'] . $json['weatherinfo']['fl5'];
        $mbody[7] = '6天后:' . $json['weatherinfo']['temp6'] . ' ' . $json['weatherinfo']['weather6'] . ' ' . $json['weatherinfo']['wind6'] . $json['weatherinfo']['fl6'];
        $mbody[17] = '微博:' . '淡淡清香弥漫世界';
        $mopt['from'] = '用户名密码@gmail.com';
        $mopt['smtp_host'] = 'smtp.gmail.com';
        $mopt['smtp_port'] = 587;
        $mopt['smtp_username'] = '******';
        $mopt['smtp_password'] = '******';
        $mopt['subject'] = $json['weatherinfo']['city'] . '天气预报';
        $mopt['content'] = $mbody[1] . '<br />' . $mbody[2] . '<br />' . $mbody[3] . '<br />' . $mbody[4] . '<br />' . $mbody[5] . '<br />' . $mbody[6] . '<br />' . $mbody[7] . '<br />' . $mbody[17];
예제 #5
0
function sign($cookie, $tiebaname, $fid, $urlname)
{
    $f = new SaeFetchurl();
    $f->setMethod("post");
    $f->setCookie("BDUSS", $cookie);
    $tbs = tbs($cookie);
    curl_get2("http://tieba.baidu.com/f/user/json_userinfo", $cookie, $rescookie);
    $cookieT = "TIEBA_USERTYPE=" . $rescookie['TIEBA_USERTYPE'] . ";TIEBAUID=" . $rescookie['TIEBAUID'] . ";BAIDUID=" . $rescookie['BAIDUID'] . "=1;BDUSS=" . $cookie;
    $poststr = $cookieT . "fid=" . $fid . "from=tiebakw=" . $tiebaname . "net_type=1tbs=" . $tbs;
    $sign = md5($poststr . "tiebaclient!!!");
    $poststr = $cookieT . "&fid=" . $fid . "&from=tieba&kw=" . $urlname . "&net_type=1&tbs=" . $tbs . "&sign=" . $sign;
    $f->setPostData($poststr);
    $text = $f->fetch("http://c.tieba.baidu.com/c/c/forum/sign");
    if ($f->errno() == 0) {
        return $text;
    } else {
        return false;
    }
}