コード例 #1
10
 private function init()
 {
     if ($this->type == 'xtu' || $this->type == 'xx') {
         $url = $this->baseUrl[$this->type] . '?TXTXH=' . $this->sid . '&TXTXM=' . urlencode(iconv("utf-8", "gbk", $this->name)) . '&TXTZH=' . $this->card . '&CmdFind=' . urlencode(iconv("utf-8", "gbk", " 查 询 "));
     } else {
         return $this->setMsg(5);
     }
     $snoopy = new Snoopy();
     $snoopy->agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36';
     $snoopy->referer = $this->type == 'xtu' ? $this->baseUrl['xtu'] : $this->baseUrl['xx'];
     $snoopy->rawheaders["Pragma"] = "no-cache";
     $snoopy->cookies["ASPSESSIONIDSSQCTSQS"] = 'BNIHIILBELEAJGBFGFNHGCME';
     $snoopy->fetch($url);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     $data = iconv('gbk', 'utf-8', $snoopy->results);
     if (!preg_match('/湘潭大学/', $data)) {
         return $this->setMsg(2);
     } else {
         if (preg_match('/对不起/', $data)) {
             return $this->setMsg(5);
         } else {
             if (preg_match('/班级代码/', $data)) {
                 $this->processData($data);
             } else {
                 return $this->setMsg(4);
             }
         }
     }
 }
コード例 #2
0
ファイル: update.php プロジェクト: uuking/test
function get_read($url = '', $key, $uid = 1)
{
    $wzurl = "{$url}&key={$key}&ascene=1&uin=Nzc5OTI2MTIx&pass_ticket=kzTtalLseTrEcwKVHswOVecGMByySYu94gRKdAXokFv2jg4UAOt%2FkrZHb0IwUlSB";
    $bsurl = "http://mp.weixin.qq.com/s?{$url}";
    require_once "Snoopy.class.php";
    $snoopy = new Snoopy();
    $snoopy->agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
    //伪装浏览器
    $snoopy->fetch($wzurl);
    //获取所有内容
    $content = $snoopy->results;
    //显示结果
    preg_match('/<span id="readNum">([^<]*)<\\/span>/si', $content, $read);
    preg_match('/var likeNum = \'([^<]*)\';/si', $content, $suport);
    // $content = htmlspecialchars($content);
    $wz['content'] = str_replace(array("'", "\""), array("\\'", "\\\""), $content);
    if ($suport[1] == "赞" || $suport[1] == '') {
        $wz['suport'] = 0;
    } else {
        $wz['suport'] = (int) $suport[1];
    }
    if ($read[1] == '') {
        $wz['read'] = 0;
    } else {
        $wz['read'] = (int) $read[1];
    }
    return $wz;
}
コード例 #3
0
ファイル: ajax.mo.php プロジェクト: idreamsoft/iCMS5.0
 function doTag()
 {
     require_once iPATH . 'include/cn.class.php';
     require_once iPATH . 'include/snoopy.class.php';
     $title = urlencode(CN::u2g($_POST['title']));
     $Snoopy = new Snoopy();
     $Snoopy->agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5";
     $Snoopy->accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
     $baidu = 'http://www.baidu.com/s?wd=' . $title;
     $Snoopy->fetch($baidu);
     preg_match_all("/<td\\s*nowrap\\s*class=\"f14\"><a\\s*href=\".*?\">(.*?)<\\/a><\\/td>/is", CN::g2u($Snoopy->results), $match);
     $baiduTag = (array) array_unique($match[1]);
     $google = 'http://www.google.com.hk/search?hl=zh-CN&source=hp&q=' . $title . '&aq=f&aqi=&aql=&oq=&gs_rfai=';
     $Snoopy->fetch($google);
     preg_match_all("/<p><a\\s*href=\".*?\">(.*?)<\\/a><\\/p>/is", $Snoopy->results, $match);
     $googleTag = (array) array_unique($match[1]);
     $tagArray = array_merge($baiduTag, $googleTag);
     $tagArray = array_unique($tagArray);
     $ul = '<ul style="margin:0; padding:0;">';
     foreach ((array) $tagArray as $key => $tag) {
         $ul .= "<li><input onclick=\"inTag('{$tag}',{$key})\" id=\"gt_{$key}\" class='checkbox' type=\"checkbox\" value=\"{$tag}\" />{$tag}</li>\n";
     }
     $ul .= "</ul>";
     echo $ul;
 }
コード例 #4
0
function price_book($book)
{
    $amazon_url = "http://www.amazon.fr/gp/search/ref=sr_adv_b/?search-alias=stripbooks&__mk_fr_FR=%C5M%C5Z%D5%D1&unfiltered=1&field-author=&field-title=&field-isbn=&field-publisher=&field-collection=&node=&field-binding_browse-bin=492481011&field-dateop=&field-datemod=&field-dateyear=&sort=relevancerank&Adv-Srch-Books-Submit.x=0&Adv-Srch-Books-Submit.y=0";
    $amazon_url .= "&field-keywords=" . $book;
    $snoopy = new Snoopy();
    $snoopy->fetch($amazon_url);
    $html = $snoopy->results;
    $html = str_get_html($html);
    $prices = null;
    $results = $html->find('#atfResults', 0);
    if (isset($results)) {
        // book url
        $book_url = $results->find('.productTitle', 0);
        $book_url = $book_url->find('a', 0)->href;
        $ISBN = get_ISBN($book_url);
        $prices = get_best_price($ISBN);
    } else {
        $prices[0] = 0;
        $prices[1] = 0;
        $ISBN = -1;
        $book_url = 'http://www.amazon.fr';
    }
    $html->clear();
    unset($html);
    return array($prices[0], $prices[1], '2.99', $ISBN, $book_url);
}
コード例 #5
0
 public function getGradeDetails()
 {
     $studentData;
     $url = 'http://202.197.224.134:8083/jwgl/cj/cj1_cjLiebiao.jsp?xq=0&xkjc=&type=null&xkdl2=&xh=' . $this->sid . '&bh=null';
     $snoopy = new Snoopy();
     $snoopy->rawheaders['Cookie'] = $this->cookies;
     $snoopy->fetch($url);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     $data = iconv('gbk', 'utf-8', $snoopy->results);
     $data = str_replace('   style="color:red"', '', $data);
     $data = str_replace('&nbsp;', '', $data);
     preg_match_all('/\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches);
     $num = count($matches[1]);
     for ($i = 1; $i < $num; $i++) {
         $studentData[$i - 1]['course'] = urlencode($matches[1][$i]);
         $studentData[$i - 1]['type'] = urlencode($matches[2][$i]);
         $studentData[$i - 1]['credit'] = urlencode($matches[3][$i]);
         $studentData[$i - 1]['daily_grade'] = urlencode($matches[4][$i]);
         $studentData[$i - 1]['exam_grade'] = urlencode($matches[5][$i]);
         $studentData[$i - 1]['comp_grade'] = urlencode($matches[6][$i]);
         $studentData[$i - 1]['term'] = urlencode($matches[7][$i]);
     }
     $this->studentData = $studentData;
 }
コード例 #6
0
ファイル: addURL.php プロジェクト: uuking/test
function get_read($url = '', $key, $uid = 1)
{
    $wzurl = "http://mp.weixin.qq.com/s?{$url}&key={$key}&ascene=1&uin=Nzc5OTI2MTIx&pass_ticket=kzTtalLseTrEcwKVHswOVecGMByySYu94gRKdAXokFv2jg4UAOt%2FkrZHb0IwUlSB";
    $bsurl = "http://mp.weixin.qq.com/s?{$url}";
    require_once "Snoopy.class.php";
    $snoopy = new Snoopy();
    $snoopy->agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16";
    //伪装浏览器
    $snoopy->fetch($wzurl);
    //获取所有内容
    $content = $snoopy->results;
    //显示结果
    preg_match('/<span id="readNum">([^<]*)<\\/span>/si', $content, $read);
    preg_match('/var likeNum = \'([^<]*)\';/si', $content, $suport);
    // $content = htmlspecialchars($content);
    $content = str_replace(array("'", "\""), array("\\'", "\\\""), $content);
    if ($suport[1] == "赞") {
        $suprot = 0;
    }
    $read = (int) $read[1];
    $suport = (int) $suport[1];
    $connect = mysqli_connect("127.0.0.1", "root", "root") or die("链接数据库失败!");
    mysqli_select_db($connect, "wx_read") or die(mysqli_errno($connect));
    mysqli_query($connect, "SET NAMES 'utf8'");
    $sql = mysqli_query($connect, "INSERT INTO `wx_article` (`uid`, `url`, `content`, `reads`, `suports`) VALUES ('{$uid}','{$bsurl}','{$content}','{$read}','{$suport}');");
    echo "INSERT INTO `wx_article` (`uid`, `url`, `content`, `reads`, `suports`) VALUES ('{$uid}','{$bsurl}','{$content}','{$read}','{$suport}');";
}
コード例 #7
0
 public function getRank()
 {
     $studentData;
     $url = $this->generateUrl();
     $snoopy = new Snoopy();
     $snoopy->rawheaders['Cookie'] = $this->cookies;
     $snoopy->fetch($url);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     $data = iconv('gbk', 'utf-8', $snoopy->results);
     if (preg_match('/\\<td\\>\\s+平均绩点(必修)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['gpa'] = $matches[1];
     }
     if (preg_match('/\\<td\\>\\s+平均成绩(必修)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['average_grade'] = $matches[1];
     }
     if (preg_match('/\\<td\\>\\s+绩点班级排名(必修)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['gpa_class_rank'] = $matches[1];
     }
     if (preg_match('/\\<td\\>\\s+绩点专业排名(必修)\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['gpa_major_rank'] = $matches[1];
     }
     $this->studentData = $studentData;
 }
コード例 #8
0
 /**
  * Logic for the Update Check
  *
  * @access public
  * @return object
  * @since 0.9
  */
 function getUpdatedata()
 {
     $elsettings = ELAdmin::config();
     include_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'Snoopy.class.php';
     $snoopy = new Snoopy();
     //set the source file
     $file = 'http://update.schlu.net/elupdate.php';
     $snoopy->read_timeout = 30;
     $snoopy->agent = "Mozilla/5.0 (compatible; Konqueror/3.2; Linux 2.6.2) (KHTML, like Gecko)";
     $snoopy->fetch($file);
     $_updatedata = null;
     if ($snoopy->status != 200 || $snoopy->error) {
         $_updatedata->failed = 1;
     } else {
         $data = explode('|', $snoopy->results);
         $_updatedata->version = $data[0];
         $_updatedata->versiondetail = $data[1];
         $_updatedata->date = strftime($elsettings->formatdate, strtotime($data[2]));
         $_updatedata->info = $data[3];
         $_updatedata->download = $data[4];
         $_updatedata->notes = $data[5];
         $_updatedata->changes = explode(';', $data[6]);
         $_updatedata->failed = 0;
         $_updatedata->current = version_compare('0.9.0.0.alpha', $_updatedata->version);
     }
     return $_updatedata;
 }
コード例 #9
0
function wpupdate_themeswordpressnet_search($args)
{
    $url = wpupdate_themeswordpressnet_searchCreate($args['info']);
    $url = 'http://themes.wordpress.net/?' . $url . '&submit=Show';
    if ($args['info']['page'] > 1) {
        $url .= '&paged=' . $args['info']['page'];
    }
    $results = wp_cache_get('wpupdate_searchThemesThemesWordpressNet_' . md5($url), 'wpupdate');
    if (!$results) {
        $results = array('results' => array(), 'pages' => 0);
        $snoopy = new Snoopy();
        $snoopy->fetch($url);
        preg_match_all('#<a href="(.*?)" rel="bookmark" title="(.*?)"><img src=".*/snapshots/(\\d+?)-thumb.jpg"#i', $snoopy->results, $mat1);
        if (!$mat1) {
            return $args;
        }
        for ($i = 0; $i < count($mat1[1]); $i++) {
            $id = $mat1[3][$i];
            $results['results'][] = array('name' => $mat1[2][$i], 'url' => $mat1[1][$i], 'id' => $id, 'download' => 'http://themes.wordpress.net/download.php?theme=' . $id, 'snapshot' => array('thumb' => 'http://s.themes.wordpress.net/snapshots/' . $id . '-thumb.jpg', 'medium' => 'http://s.themes.wordpress.net/snapshots/' . $id . '-medium.jpg', 'big' => 'http://s.themes.wordpress.net/snapshots/' . $id . '-big.jpg'), 'testrun' => 'http://themes.wordpress.net/testrun/?wptheme=' . $id);
        }
        //Check the number of pages, If this isnt the last page, change it.
        if (preg_match('#title="Last &raquo;">(\\d+)</a>#', $snoopy->results, $pages)) {
            $results['pages'] = (int) $pages[1];
        }
        wp_cache_add('wpupdate_searchThemesThemesWordpressNet_' . md5($url), $results, 'wpupdate', 21600);
    }
    //end if ( ! $results )
    //Merge Result set
    $args['results'] = array_merge($args['results'], $results['results']);
    //Check if theres more pages than set
    if ($results['pages'] > $args['info']['pages']) {
        $args['info']['pages'] = $results['pages'];
    }
    return $args;
}
コード例 #10
0
ファイル: tifert_jw.php プロジェクト: noikiy/print
/**
 * 学校验证
 * @method getName
 * @param  [type]  $stu_number [学号]
 * @param  [type]  $pwd        [密码]
 * @return [string/bool]              [验证成功返回姓名,验证失败返回false]
 * @author NewFuture[newfuture@yunyin.org]
 */
function getName($stu_number, $pwd)
{
    /*基本信息*/
    $ACTION_URL = 'http://jw.tifert.edu.cn/2003/Logon.do?method=logon';
    $INFO_URL = 'http://jw.tifert.edu.cn/2003/framework/main.jsp';
    $SUCCESS_KEY = '<script language=\'javascript\'>window.location.href=\'http://jw.tifert.edu.cn/2003/framework/main.jsp\';</script>';
    $START_FALG = '当前用户:';
    $END_FLAG = '</td>';
    $snoopy = new Snoopy();
    /*设置请求头,非必需 */
    $snoopy->referer = 'http://jw.tifert.edu.cn/2003/';
    $snoopy->rawheaders['Pragma'] = 'no-cache';
    $snoopy->rawheaders['X_FORWARDED_FOR'] = get_client_ip();
    /*用户学号和密码*/
    $input['USERNAME'] = $stu_number;
    $input['PASSWORD'] = $pwd;
    //模拟登陆
    $snoopy->submit($ACTION_URL, $input);
    $result = $snoopy->results;
    //登录结果页面
    if (strpos($result, $SUCCESS_KEY) === false) {
        /*验证失败*/
        return false;
    } else {
        /*登录成功,保存cookie信息页面抓取信息*/
        $snoopy->setcookies();
        $snoopy->fetch($INFO_URL);
        $results = $snoopy->results;
        $s = strpos($results, $START_FALG) + strlen($START_FALG);
        //起始位置
        $e = strpos($results, $END_FLAG, $s);
        $name = substr($results, $s, $e - $s);
        return trim($name);
    }
}
コード例 #11
0
 private function renew()
 {
     $postArray = array('action' => 'Renew', 'book_barcode' => preg_match('/\\//', $this->bookID) ? $this->bookID : urlencode($this->bookID), 'department_id' => $this->deptID, 'library_id' => $this->libraryID);
     print_r($postArray);
     $studentData;
     $url = 'http://202.197.232.4:8081/opac_two/reader/jieshuxinxi.jsp';
     $snoopy = new Snoopy();
     $snoopy->rawheaders['Cookie'] = $this->cookies;
     $snoopy->submit($url, $postArray);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     $data = iconv('gbk', 'utf-8', $snoopy->results);
     if (preg_match('/续借成功/', $data)) {
         return $this->setMsg(0);
     } else {
         if (preg_match('/现已续借/', $data)) {
             return $this->setMsg(6);
         } else {
             if (preg_match('/读取续借规则错误/', $data)) {
                 return $this->setMsg(7);
             } else {
                 return $this->setMsg(4);
             }
         }
     }
 }
コード例 #12
0
 private function getReaderInfo()
 {
     $studentData;
     $url = 'http://202.197.232.4:8081/opac_two/reader/reader_set.jsp';
     $snoopy = new Snoopy();
     $snoopy->rawheaders['Cookie'] = $this->cookies;
     $snoopy->fetch($url);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     $data = iconv('gbk', 'utf-8', $snoopy->results);
     if (preg_match('/\\<TD\\>读者姓名\\:\\<\\/TD\\>\\s+\\<TD\\>\\s+(.*?)\\s+\\<\\/TD\\>/', $data, $matches)) {
         $studentData['name'] = urlencode($matches[1]);
     }
     if (preg_match('/\\<TD\\>办证日期\\:\\<\\/TD\\>\\s+\\<TD\\>\\s+(.*?)\\s+\\<\\/TD\\>/', $data, $matches)) {
         $studentData['valid_date_start'] = urlencode($matches[1]);
     }
     if (preg_match('/\\<TD\\>到期日期\\:\\<\\/TD\\>\\s+\\<TD\\>\\s+(.*?)\\s+\\<\\/TD\\>/', $data, $matches)) {
         $studentData['valid_date_end'] = urlencode($matches[1]);
     }
     if (preg_match('/\\<TD\\>读者欠款\\:\\<\\/TD\\>\\s+\\<TD\\>\\s+(.*?)\\s+\\<\\/TD\\>/', $data, $matches)) {
         $studentData['debt'] = urlencode($matches[1] == 0 ? '0.00' : $matches[1] * 10 % 10 == 0 ? $matches[1] . '.00' : $matches[1] . '0');
     }
     $this->studentData = $studentData;
 }
コード例 #13
0
ファイル: getDomainLinks.php プロジェクト: yangliGit/MyWorks
function getDomainLinks($url, $domain)
{
    global $domainLinks;
    $snoopy = new Snoopy();
    $snoopy->agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17";
    $snoopy->rawheaders['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
    $snoopy->rawheaders['Accept-Charset'] = 'GBK,utf-8;q=0.7,*;q=0.3';
    $snoopy->rawheaders['Connection'] = 'keep-alive';
    $snoopy->rawheaders['Accept-Language'] = 'zh-CN,zh;q=0.8';
    $snoopy->rawheaders['Cache-Control'] = 'max-age=0';
    $links = array();
    if ($snoopy->fetchlinks($url)) {
        foreach ($snoopy->results as $link) {
            if (stripos($link, $domain) === false) {
                continue;
            }
            if (in_array($link, $domainLinks)) {
                continue;
            }
            $domainLinks[] = $link;
            echo $link . "\r\n";
            getDomainLinks($link, $domain);
        }
    }
}
コード例 #14
0
ファイル: lyricwiki.php プロジェクト: seanfbrown/jinzora
function SERVICE_GETLYRICS_lyricwiki($track)
{
    global $include_path;
    include_once $include_path . "lib/snoopy.class.php";
    $meta = $track->getMeta();
    $artist = $meta['artist'];
    $name = $meta['title'];
    // Let's up the max execution time here
    ini_set('max_execution_time', '60000');
    // Now let's see if we can get close...
    $snoopy = new Snoopy();
    $snoopy->fetch("http://lyricwiki.org/api.php?artist=" . urlencode($artist) . '&song=' . urlencode($name) . '&fmt=xml');
    $contents = $snoopy->results;
    unset($snoopy);
    // Now let's see if we got an exact match
    if (!stristr($contents, '<lyrics>Not found') and (stristr($contents, iconv("UTF-8", "ISO-8859-1", $artist)) and stristr($contents, iconv("UTF-8", "ISO-8859-1", $name)))) {
        $lyrics = "";
        // Ok, now let's get the ID number
        $lyrics = substr($contents, strpos($contents, "<lyrics>") + 8, 999999);
        $lyrics = stripslashes(substr($lyrics, 0, strpos($lyrics, "</lyrics>")));
    }
    if ($lyrics == "") {
        return false;
    }
    $lyrics2 = iconv("ISO-8859-1", "UTF-8", $lyrics);
    return $lyrics2;
}
コード例 #15
0
ファイル: HttpLib.php プロジェクト: kl0428/admin
 /**
  * @param $url
  * @param string $post_data
  * @return mixed|null
  */
 public static function get($url, $post_data = '')
 {
     $host2 = array('account/register.json', 'bankBranch/select/branch.json', 'account/bank/list.json', 'account/bankcard/bind.json', 'user/identity/auth.json', 'loginRest/getUserCenterInfo.json', 'account/bankcard/modify.json');
     $str = '';
     if (is_array($post_data)) {
         $post_data['_ts'] = time();
         $post_data['token'] = self::TOKEN;
         foreach ($post_data as $key => $value) {
             $str .= '&' . $key . '=' . urlencode(trim($value));
         }
     }
     try {
         $_snoopy = new Snoopy();
         if (in_array($url, $host2)) {
             $furl = Yii::app()->params['back_host2'] . $url . '?' . substr($str, 1, strlen($str));
         } else {
             $furl = Yii::app()->params['back_host'] . $url . '?' . substr($str, 1, strlen($str));
         }
         $_snoopy->fetch($furl);
         if ($_snoopy->results != '') {
             $data = json_decode($_snoopy->results, false);
         }
         self::json_log($_snoopy->results);
         return $data;
     } catch (Exception $ex) {
         return null;
     }
     return null;
 }
コード例 #16
0
 public function getStudentInfo()
 {
     $studentData;
     $url = 'http://202.197.224.134:8083/jwgl/detail_zp.jsp?funcId=0&zzd=XJB.XH&zzdValue=' . $this->sid;
     $snoopy = new Snoopy();
     $snoopy->rawheaders['Cookie'] = $this->cookies;
     $snoopy->fetch($url);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     $data = iconv('GBK//IGNORE', 'utf-8//IGNORE', $snoopy->results);
     $data = str_replace('&nbsp;', '', $data);
     if (preg_match_all('/\\<td align="right"\\>\\s+姓名\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['name'] = urlencode($matches[1][0]);
     }
     if (preg_match_all('/\\<td align="right"\\>\\s+性别\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['sex'] = urlencode($matches[1][0]);
     }
     if (preg_match_all('/\\<td align="right"\\>\\s+出生日期\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['date_of_birth'] = urlencode($matches[1][0]);
     }
     if (preg_match_all('/\\<td align="right"\\>\\s+籍贯码\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['location'] = urlencode($matches[1][0]);
     }
     if (preg_match_all('/\\<td align="right"\\>\\s+院系所部\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['college'] = urlencode($matches[1][0]);
     }
     if (preg_match_all('/\\<td align="right"\\>\\s+校内专业\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['major'] = urlencode($matches[1][0]);
     }
     if (preg_match_all('/\\<td align="right"\\>\\s+班级\\s+\\<\\/td\\>\\s+\\<td\\>\\s+(.*?)\\s+\\<\\/td\\>/', $data, $matches)) {
         $studentData['class'] = urlencode($matches[1][0]);
     }
     $this->studentData = $studentData;
 }
コード例 #17
0
 function get_content($url)
 {
     require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
     if ($url) {
         $this->url = preg_replace('|/+$|', '', $url);
         $this->url = preg_replace('|#.*$|', '', $this->url);
     }
     $snoopy = new Snoopy();
     if ($snoopy->fetch($this->url)) {
         $tb_contents = $snoopy->results;
         if (function_exists('mb_detect_encoding')) {
             $this->charset = mb_detect_encoding($tb_contents, "auto");
         }
         if (preg_match_all('#<rdf:RDF[^>]*>(.*?)</rdf:RDF>#si', $tb_contents, $matches, PREG_PATTERN_ORDER)) {
             foreach ($matches[1] as $tb_body) {
                 //thanks  kenken
                 $this->xml_parts[] = preg_replace('|dc:description=\\"[^\\"]*\\"|', '', $tb_body);
             }
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #18
0
 protected function init()
 {
     $verifyUrl = 'http://ecard.xtu.edu.cn/loginstudent.action?name=' . $this->sid . '&userType=1&passwd=' . $this->password . '&loginType=2';
     $snoopy = new Snoopy();
     $snoopy->fetch($verifyUrl);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     $data = iconv('gbk', 'utf-8', $snoopy->results);
     if (!preg_match('/信息提示/', $data) && !preg_match('/校园卡/', $data)) {
         return $this->setMsg(2);
     } else {
         if (preg_match('/密码错误/', $data)) {
             return $this->setMsg(1);
         } else {
             if (preg_match('/无此用户名称/', $data)) {
                 return $this->setMsg(5);
             } else {
                 if (preg_match('/持卡人查询界面/', $data)) {
                     if ($this->processCookies($snoopy->headers) != 0) {
                         return 0;
                     }
                     $this->loginStatus = 1;
                     return $this->setMsg(0);
                 } else {
                     return $this->setMsg(4);
                 }
             }
         }
     }
 }
コード例 #19
0
function socialdiscuss_http_post($link, $body)
{
    if (!$link) {
        return array(500, 'Invalid Link');
    }
    require_once ABSPATH . WPINC . '/class-snoopy.php';
    $snoop = new Snoopy();
    if ($snoop->submit($link, $body)) {
        if (strpos($snoop->response_code, '200')) {
            $response = $snoop->results;
            return array(200, $response);
        }
    }
    if (!class_exists('WP_Http')) {
        include_once ABSPATH . WPINC . '/class-http.php';
    }
    if (!class_exists('WP_Http')) {
        return array(500, $snoop->response_code);
    }
    $request = new WP_Http();
    $response_full = $request->request($link, array('method' => 'POST', 'body' => $body, 'headers' => $headers));
    if (isset($response_full->errors)) {
        return array(500, 'Unknown Error');
    }
    $response_code = $response_full['response']['code'];
    if ($response_code === 200) {
        $response = $response_full['body'];
        return array($response_code, $response);
    }
    $response_msg = $response_full['response']['message'];
    return array($response_code, $response_msg);
}
コード例 #20
0
ファイル: check.php プロジェクト: anthonyryan1/ruTorrent
 public static function makeClient($url, $method = "GET", $content_type = "", $body = "")
 {
     $client = new Snoopy();
     $client->read_timeout = 5;
     $client->_fp_timeout = 5;
     @$client->fetchComplex($url, $method, $content_type, $body);
     return $client;
 }
コード例 #21
0
ファイル: Cidades.class.php プロジェクト: astiazara/sidist
 public static function buscarRemoto($idEstado)
 {
     $arquivo = "http://ws.geonames.org/children?style=short&maxRows=1000&lang=en&geonameId=" . $idEstado;
     $snoopy = new Snoopy();
     $snoopy->fetch($arquivo);
     $xml = simplexml_load_string($snoopy->results);
     return Cidades::materializar($xml);
 }
コード例 #22
0
ファイル: Paises.class.php プロジェクト: astiazara/sidist
 public static function buscarTodosRemoto()
 {
     $arquivo = "http://ws.geonames.org/countryInfo?style=short&lang=en";
     $snoopy = new Snoopy();
     $snoopy->fetch($arquivo);
     $xml = simplexml_load_string($snoopy->results);
     return Paises::materializar($xml);
 }
コード例 #23
0
 private function init()
 {
     $snoopy = new Snoopy();
     //Get Viewstate First
     $snoopy->fetch('http://202.197.224.66:8084/pyxx/login.aspx');
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     if (preg_match('/value="(.*?)"/', $snoopy->results, $viewstate)) {
         $this->postArray['__VIEWSTATE'] = $viewstate[1];
     } else {
         return $this->setMsg(3);
     }
     //Set SessionId
     $snoopy->cookies['ASP.NET_SessionId'] = $this->sessionId;
     //Submit Form
     $snoopy->submit('http://202.197.224.66:8084/pyxx/login.aspx', $this->postArray);
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     if (preg_match('/密码错误/', $snoopy->results)) {
         return $this->setMsg(1);
     }
     if (!preg_match('/html/', $snoopy->results)) {
         return $this->setMsg(4);
     }
     //Get Student Info
     $snoopy->fetch('http://202.197.224.66:8084/pyxx/grgl/xsinfoshow.aspx');
     if ($snoopy->status != 200) {
         return $this->setMsg(3);
     }
     //echo $snoopy->results;
     if (!preg_match('/个人基本信息/', $snoopy->results)) {
         return $this->setMsg(4);
     }
     if (preg_match('/<span id="lblxm1">(.*?)<\\/span>/', $snoopy->results, $matches)) {
         $studentData['name'] = urlencode($matches[1]);
     } else {
         return $this->setMsg(4);
     }
     if (preg_match('/<span id="lblxb">(.*?)<\\/span>/', $snoopy->results, $matches)) {
         $studentData['sex'] = urlencode($matches[1]);
     }
     if (preg_match('/<span id="lblcsrq">(.*?)<\\/span>/', $snoopy->results, $matches)) {
         $studentData['date_of_birth'] = urlencode($matches[1]);
     }
     if (preg_match('/<span id="lbljtdq">(.*?)<\\/span>/', $snoopy->results, $matches)) {
         $studentData['location'] = urlencode($matches[1]);
     }
     if (preg_match('/<span id="lblyxzy">(.*?)<\\/span>/', $snoopy->results, $matches)) {
         $arr = explode('_', $matches[1]);
         $studentData['college'] = urlencode($arr[0]);
         $studentData['major'] = urlencode($arr[1]);
     }
     $this->studentData = $studentData;
     return $this->setMsg(0);
 }
コード例 #24
0
ファイル: Util.php プロジェクト: wpp8909/findzhibo
 public static function getBaiduAd($uuid, $imei, $ad_list)
 {
     if (!$imei) {
         if ($uuid) {
             $user_info = DreamDeviceUuid::model()->find('uuid =:uuid', array(':uuid' => $uuid));
             if ($user_info) {
                 $device_id = $user_info->device_id;
                 $device_info = DreamDevice::model()->find('id =:id', array(':id' => $device_id));
                 $imei = isset($device_info->imei) ? $device_info->imei : false;
             }
         }
     }
     if ($imei) {
         $host = 'http://m.baidu.com/api?';
         $api_key = 'cea6fbb9e862233e3dbe6fcc6cad3bcf';
         $param = array();
         $param['action'] = 'board';
         $param['from'] = '1014104g';
         $param['token'] = 'wifi_check';
         $param['api_key'] = $api_key;
         $param['imei'] = $imei;
         $param['type'] = 'app';
         $param['id'] = 2;
         $param['pn'] = 0;
         $param['rn'] = 60;
         $param['apilevel'] = 19;
         $param['dpi'] = '720_1280';
         $param['format'] = 'json';
         $snoopy = new Snoopy();
         $snoopy->fetch($host . http_build_query($param));
         $ad_info = json_decode($snoopy->results, true);
         if ($ad_info) {
             $num = count($ad_list);
             foreach ($ad_info['result']['apps'] as $value) {
                 if ($value['sname'] != '百度手机卫士') {
                     $download = $value['download_url'];
                     if (strpos($download, 'source+MBUADP')) {
                         $screen_shots = explode(';', $value['screenshot']);
                         $ad_list[$num]['app_name'] = $value['sname'];
                         $ad_list[$num]['type'] = 'baidu';
                         $brief = $value['manual_brief'] ? $value['manual_brief'] : $value['sname'];
                         $ad_list[$num]['title'] = $brief;
                         $ad_list[$num]['content'] = $value['manual_short_brief'] ? $value['manual_short_brief'] : $brief;
                         $ad_list[$num]['package_name'] = $value['package'];
                         $ad_list[$num]['icon_url'] = $value['icon'];
                         $ad_list[$num]['cover_url'] = $screen_shots[0];
                         $ad_list[$num]['download_url'] = $value['download_url'] . '&imei=' . $imei . '&api_key=' . $api_key;
                         $num++;
                     }
                 }
             }
         }
         shuffle($ad_list);
     }
     return $ad_list;
 }
コード例 #25
0
/**
 *                    Jojo CMS
 *                ================
 *
 * Copyright 2007 Harvey Kane <*****@*****.**>
 * Copyright 2007 Michael Holt <*****@*****.**>
 * Copyright 2007 Melanie Schulz <*****@*****.**>
 *
 * See the enclosed file license.txt for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  Harvey Kane <*****@*****.**>
 * @author  Michael Cochrane <*****@*****.**>
 * @author  Melanie Schulz <*****@*****.**>
 * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
 * @link    http://www.jojocms.org JojoCMS
 */
function pingGoogleSitemaps($url = '')
{
    if ($url == '') {
        $url = _SITEURL . '/sitemap.xml';
    }
    $googleurl = "http://www.google.com/webmasters/sitemaps/ping?sitemap=" . urlencode($url);
    require_once _BASEDIR . '/external/snoopy/Snoopy.class.php';
    $snoopy = new Snoopy();
    return $snoopy->fetch($googleurl);
}
コード例 #26
0
 function snoopyFetch()
 {
     $spy = new \Snoopy();
     $spy->fetch($this->url);
     $txt = $spy->results;
     $html_file = fopen($GLOBALS["CONTENTS_HTML_PATH"], "w");
     fwrite($html_file, $txt . "\r\n");
     fclose($html_file);
     $this->html = file_get_html($GLOBALS["CONTENTS_HTML_PATH"]);
 }
コード例 #27
0
ファイル: wiki_base.php プロジェクト: apelon-ohie/ihris-site
function wikiLogin()
{
    global $login;
    global $wikilogin;
    global $snoopy;
    global $wikiapi_url;
    while (!$login) {
        $wikilogin['action'] = 'login';
        $wikilogin['lgname'] = trim(ask('wiki user name'));
        $wikilogin['lgpassword'] = getPassword('wikis');
        $wikilogin['format'] = 'php';
        if (!$snoopy instanceof Snoopy) {
            $snoopy = new Snoopy();
        }
        if (!$snoopy->submit($wikiapi_url, $wikilogin)) {
            I2CE::raiseError("Could not log in to {$wikiapi_url}");
            continue;
        }
        $res = unserialize($snoopy->results);
        if (array_key_exists('error', $res)) {
            I2CE::raiseError("Could not login:\n" . print_r($res['error'], true));
            continue;
        }
        if (!array_key_exists('login', $res) || !is_array($res['login']) || !array_key_exists('result', $res['login'])) {
            I2CE::raiseError("Error logging in:" . print_r($res, true));
            continue;
        }
        if ($res['login']['result'] == 'NeedToken' && array_key_exists('token', $res['login']) && $res['login']['token']) {
            $wikilogin['lgtoken'] = $res['login']['token'];
            $snoopy->setcookies();
            if (!$snoopy->submit($wikiapi_url, $wikilogin)) {
                I2CE::raiseError("Could not log in to {$wikiapi_url}");
                continue;
            }
            $res = unserialize($snoopy->results);
            if (array_key_exists('error', $res)) {
                I2CE::raiseError("Could not login:\n" . print_r($res['error'], true));
                continue;
            }
            if (!array_key_exists('login', $res) || !is_array($res['login']) || !array_key_exists('result', $res['login'])) {
                I2CE::raiseError("Error logging in");
                continue;
            }
        }
        if ($res['login']['result'] != 'Success') {
            I2CE::raiseError("No success logging in:" . print_r($res, true));
            continue;
        }
        I2CE::raiseError("Logged into {$wikiapi_url} as " . $wikilogin['lgname']);
        $snoopy->setcookies();
        $login = true;
    }
    return $login;
}
コード例 #28
0
 function user_get()
 {
     $snoopy = new Snoopy();
     //$snoopy->fetch("http://am0100.com/");
     //preg_match('/<ul id="restaurants">(.*?)<\/ul>/is', $snoopy->results, $text);
     $snoopy->fetch("https://www.yogiyo.co.kr/%EB%8C%80%EA%B5%AC/701021/");
     $regexp = '/<ul id="restaurants">(.*?)<\\/ul>/is';
     //'/<ul class="list_type_1 search_list">(.*?)<\/ul>/is'
     preg_match($regexp, $snoopy->results, $text);
     //var_dump($snoopy->results);
     var_dump($text);
     echo '</br>';
     echo '</br>';
     echo '</br>';
     echo '</br>';
     echo '</br>';
     var_dump($snoopy->scheme);
     echo '</br>';
     var_dump($snoopy->host);
     echo '</br>';
     /*
     for($i=0; $i<count($snoopy); $i++) {
         var_dump($snoopy[$i]);
     }
     */
     /*
         	echo "test";
     if (!$this->get('id'))
     {
     	echo "id null";
         $this->response(NULL, 400);
     }
     
     // $user = $this->some_model->getSomething( $this->get('id') );
     $users = [
         1 => ['id' => 1, 'name' => 'John', 'email' => '*****@*****.**', 'fact' => 'Loves coding'],
         2 => ['id' => 2, 'name' => 'Jim', 'email' => '*****@*****.**', 'fact' => 'Developed on CodeIgniter'],
         3 => ['id' => 3, 'name' => 'Jane', 'email' => '*****@*****.**', 'fact' => 'Lives in the USA', ['hobbies' => ['guitar', 'cycling']]],
     ];
     
     $user = @$users[$this->get('id')];
     
     if ($user)
     {
         $this->response($user, 200); // 200 being the HTTP response code
     }
     
     else
     {
         $this->response(['error' => 'User could not be found'], 404);
     }
     */
 }
コード例 #29
0
ファイル: lib.php プロジェクト: JackCanada/moodle-hacks
function sso_user_login($username, $password)
{
    global $CFG, $SESSION;
    include $CFG->libdir . '/snoopy/Snoopy.class.inc';
    if (empty($CFG->hivehost)) {
        return false;
        // Hive config variables not configured yet
    }
    /// Set up Snoopy
    $snoopy = new Snoopy();
    $submit_url = $CFG->hiveprotocol . '://' . $CFG->hivehost . ':' . $CFG->hiveport . '' . $CFG->hivepath;
    $submit_vars['HIVE_UNAME'] = $username;
    $submit_vars['HIVE_UPASS'] = $password;
    $submit_vars['HIVE_ENDUSER'] = $username;
    $submit_vars['HIVE_REQ'] = '2112';
    $submit_vars['HIVE_REF'] = 'hin:hive@API Login 3';
    $submit_vars['HIVE_RET'] = 'ORG';
    $submit_vars['HIVE_REM'] = '';
    $submit_vars['HIVE_PROD'] = '0';
    $submit_vars['HIVE_USERIP'] = getremoteaddr();
    /// We use POST to call Hive with a bit more security
    $snoopy->submit($submit_url, $submit_vars);
    /// Extract HIVE_SESSION from headers
    foreach ($snoopy->headers as $header) {
        if (strpos($header, 'HIVE_SESSION=') !== false) {
            $header = explode('HIVE_SESSION=', $header);
            if (count($header) > 1) {
                $cookie = explode(';', $header[1]);
                $cookie = $cookie[0];
                $SESSION->HIVE_SESSION = $cookie;
                return true;
            }
        }
    }
    /// Try again with the guest username and password
    $submit_vars['HIVE_UNAME'] = $CFG->hiveusername;
    $submit_vars['HIVE_UPASS'] = $CFG->hivepassword;
    $submit_vars['HIVE_ENDUSER'] = $CFG->hiveusername;
    $snoopy->submit($submit_url, $submit_vars);
    foreach ($snoopy->headers as $header) {
        if (strpos($header, 'HIVE_SESSION=') !== false) {
            $header = explode('HIVE_SESSION=', $header);
            if (count($header) > 1) {
                $cookie = explode(';', $header[1]);
                $cookie = $cookie[0];
                $SESSION->HIVE_SESSION = $cookie;
                return true;
            }
        }
    }
    return false;
    // No cookie found
}
コード例 #30
0
 function execute($dummy = '', $max_entries = '')
 {
     $this->cache_life_time = max($this->cache_life_time, $this->mod_configs['fetch_cache_life_time']);
     $xml_source = '';
     if (!strstr($this->url, '://')) {
         $this->errors[] = _MD_D3PIPES_ERR_INVALIDURIINFETCH . "\n({$this->pipe_id})";
         return '';
     }
     $cache_result = $this->fetchCache();
     if ($cache_result !== false) {
         list($cached_time, $xml_source) = $cache_result;
         if ($cached_time + $this->cache_life_time > time()) {
             return $xml_source;
         }
     }
     require_once XOOPS_ROOT_PATH . '/class/snoopy.php';
     $snoopy = new Snoopy();
     $snoopy->maxredirs = 0;
     $snoopy->offsiteok = true;
     $snoopy->proxy_host = $this->mod_configs['snoopy_proxy_host'];
     $snoopy->proxy_port = $this->mod_configs['snoopy_proxy_port'];
     $snoopy->proxy_user = $this->mod_configs['snoopy_proxy_user'];
     $snoopy->proxy_pass = $this->mod_configs['snoopy_proxy_pass'];
     $snoopy->curl_path = $this->mod_configs['snoopy_curl_path'];
     $fetch_result = $snoopy->fetch($this->url);
     // check redirect
     if ($fetch_result && $snoopy->_redirectaddr && $this->mod_configs['snoopy_maxredirs'] > 0) {
         if (!empty($this->mod_configs['redirect_warning'])) {
             $this->errors[] = _MD_D3PIPES_ERR_REDIRECTED . "\n(" . $this->pipe_id . ")\n" . $this->url . " ->\n" . $snoopy->_redirectaddr;
         }
         $snoopy->maxredirs = $this->mod_configs['snoopy_maxredirs'];
         $fetch_result = $snoopy->fetch($this->url);
     }
     // check fetch error
     if (!$fetch_result || !($xml_source = $snoopy->results)) {
         $this->touchCache();
         $message = _MD_D3PIPES_ERR_CANTCONNECTINFETCH . "\n";
         if (!empty($snoopy->proxy_host)) {
             $message .= _MD_D3PIPES_ERR_DOUBTFULPROXY . "\n";
         }
         if (substr($this->url, 0, 5) == 'https') {
             $message .= _MD_D3PIPES_ERR_DOUBTFULCURLPATH . "\n";
         }
         $this->errors[] = $message . "({$this->pipe_id})";
         return '';
     }
     // check cache folder is writable
     if (!$this->storeCache($xml_source)) {
         $this->errors[] = _MD_D3PIPES_ERR_CACHEFOLDERNOTWRITABLE . "\nXOOPS_TRUST_PATH/cache ({$this->pipe_id})";
         return '';
     }
     return $xml_source;
 }