Ejemplo n.º 1
0
/**
 * function getName($stu_number,$pwd)
 * 获取
 * 			string name 验证成功返回姓名
 * 			bool false /null 验证失败返回false或空值
 *
 * @author 梁崇军
 *
 * @param  string  $stu_number 学号
 * @param  string  $pwd        登陆密码
 * @return mixed
 */
function getName($stu_number, $pwd)
{
    /*验证地址--urp密码验证页*/
    $action_url = 'http://urp.nankai.edu.cn/userPasswordValidate1.portal';
    $snoopy = new Snoopy();
    $snoopy->rawheaders['Pragma'] = 'no-cache';
    $snoopy->rawheaders['X_FORWARDED_FOR'] = get_client_ip();
    $success_words = '<script type="text/javascript">location.href = \'http://urp.nankai.edu.cn/index.portal\';</script>';
    $error_key = '密码错误';
    $snoopy->referer = 'http://urp.nku.cn';
    /*用户学号和密码*/
    $input['Login.Token1'] = $stu_number;
    $input['Login.Token2'] = $pwd;
    $snoopy->submit($action_url, $input);
    //模拟登陆
    $result = $snoopy->results;
    //登录结果页面
    if (strpos($result, $error_key) !== false) {
        return false;
    } elseif (strpos($result, $success_words) !== false) {
        /*登录成功,保存cookie信息页面抓取信息*/
        $snoopy->setcookies();
        $snoopy->fetchtext('http://urp.nankai.edu.cn/index.portal');
        $text = $snoopy->results;
        // $substr   = substr($input, strlen($start) + strpos($input, $start) , (strlen($input) - strpos($input, $end)) * (-1));
        $get_name = function ($input, $start, $end) {
            return substr($input, strlen($start) + strpos($input, $start), (strlen($input) - strpos($input, $end)) * -1);
        };
        $name = $get_name($text, '您好,', ' 欢迎来到南开大学');
        return $name;
    } else {
        $error = '未知错误[可能信息门户已经改版]返回信息:' . htmlspecialchars($result);
        E($error);
        return false;
    }
}
function laecho_socialstats_http($link)
{
    if (!$link) {
        return array(500, 'invalid url');
    }
    require_once ABSPATH . WPINC . '/class-snoopy.php';
    $snoop = new Snoopy();
    $snoop->agent = WIDGET_NAME . ' - ' . get_option('siteurl');
    if ($snoop->fetchtext($link)) {
        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, 'internal error');
    }
    $request = new WP_Http();
    $headers = array('Agent' => WIDGET_NAME . ' - ' . get_option('siteurl'));
    $response_full = $request->request($link);
    if (isset($response_full->errors)) {
        return array(500, 'internal 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);
}
Ejemplo n.º 3
0
 function fetch_metar($station)
 {
     global $wpdb;
     $metar = "";
     $cached = FALSE;
     $station = strtoupper($station);
     // Check the cache
     $cache = $wpdb->get_row("SELECT metar, expiry FROM `" . $wpdb->prefix . "metar_cache` WHERE station = '{$station}'", ARRAY_A);
     if ($cache) {
         // check to see if it is valid
         if ($cache['expiry'] >= gmdate("Y-m-d H:i:s", time())) {
             // record status (for debugging)
             $this->status[] = $this->gmtime() . " Cache valid, retrieved metar " . $cache['metar'];
             return $cache['metar'];
         } else {
             $this->status[] = $this->gmtime() . " Cache expired";
         }
         $cached = TRUE;
     } else {
         $this->status[] = $this->gmtime() . " No cached metar for station {$station}";
     }
     $client = new Snoopy();
     $client->rawheaders["Pragma"] = "no-cache";
     $client->read_timeout = 15;
     if (WIuseNOAA) {
         // Fetch from NOAA (IWS) -- Internet Weather Service
         // See http://weather.noaa.gov/weather/metar.shtml
         if ($client->fetchtext("http://weather.noaa.gov/pub/data/observations/metar/stations/{$station}.TXT")) {
             $this->status[] = $this->gmtime() . " NOAA (IWS) responded " . trim($client->response_code);
             $this->status[] = $this->gmtime() . " NOAA (IWS) response data\n" . trim($client->results);
             // We got a good response, let's parse it and hope everything is good
             if (strpos($client->response_code, '200 ')) {
                 // annoyingly one can not do just do
                 //	 explode("\n", $client->results)[1]
                 $tmp = explode("\n", $client->results);
                 $metar = $this->cache_metar($station, $tmp[1], $cached);
                 // if valid, return
                 if ($metar) {
                     return $metar;
                 }
             }
         } else {
             $this->status[] = $this->gmtime() . " Snoopy error while fetching metar from NOAA (IWS) " . $client->error;
         }
     }
     // We don't have a metar, let's try ADDS.
     $this->status[] = $this->gmtime() . " Trying NOAA's ADDS metar repository.";
     if (WIuseADDS) {
         // Fetch from NOAA (ADDS) -- Aviation Digital Data Service
         // See http://adds.aviationweather.gov/metars/
         if ($client->fetchtext("http://adds.aviationweather.gov/metars/index.php?station_ids={$station}&std_trans=standard&chk_metars=on&hoursStr=most+recent+only&submitmet=Submit")) {
             $this->status[] = $this->gmtime() . " NOAA (ADDS) responded " . trim($client->response_code);
             $this->status[] = $this->gmtime() . " NOAA (ADDS) response data:\n" . trim($client->results);
             // annoyingly one can not do just do
             //	 explode("\n", $client->results)[5]
             $tmp = explode("\n", $client->results);
             $metar = $this->cache_metar($station, $tmp[5], $cached);
             // if valid, return
             if ($metar) {
                 return $metar;
             }
         } else {
             $this->status[] = $this->gmtime() . " Snoopy error while fetching metar from NOAA (ADDS) " . $client->error;
         }
     }
     // If we are here ... bad things have happened
     if ($cached) {
         // Thank god we have cached data!  Use it!
         $this->status[] = $this->gmtime() . " No valid metar data avaliable, using expired cache. METAR " . $cache['metar'];
         return $cache['metar'];
     } else {
         $this->status[] = $this->gmtime() . " FATAL ERROR!  NO METAR AVAILABLE!";
         return FALSE;
     }
 }
Ejemplo n.º 4
0
function networkpub_http($link)
{
    if (!$link) {
        return array(500, 'invalid url');
    }
    if (!class_exists('WP_Http')) {
        include_once ABSPATH . WPINC . '/class-http.php';
    }
    if (class_exists('WP_Http')) {
        $request = new WP_Http();
        $headers = array('Agent' => NETWORKPUB_WIDGET_NAME . ' - ' . get_bloginfo('url'));
        $response_full = $request->request($link, array('method' => 'GET', 'headers' => $headers, 'timeout' => 60));
        if (isset($response_full->errors)) {
            return array(500, 'internal error');
        }
        if (!is_array($response_full['response'])) {
            return array(500, 'internal 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);
    }
    require_once ABSPATH . WPINC . '/class-snoopy.php';
    $snoop = new Snoopy();
    $snoop->agent = NETWORKPUB_WIDGET_NAME . ' - ' . get_bloginfo('url');
    if ($snoop->fetchtext($link)) {
        if (strpos($snoop->response_code, '200')) {
            $response = $snoop->results;
            return array(200, $response);
        }
    }
    return array(500, 'internal error');
}
Ejemplo n.º 5
0
function lic_comment_post($comment_ID)
{
    global $lic_local;
    if (!isset($_REQUEST["lic_share_this"])) {
        return;
    }
    $liclient = unserialize($_SESSION['linkedin_client']);
    /*
    $lic_consumer_key = get_option('lic_consumer_key');
    $lic_consumer_secret = get_option('lic_consumer_secret');
    */
    $comment = get_comment($comment_ID);
    $post_title = strip_tags(get_the_title($comment->comment_post_ID));
    $blog_title = get_bloginfo('name');
    $permalink = '';
    //Use the comment link if it is approved, otherwise use the post link.
    if ($comment->comment_approved == 1) {
        $permalink = get_comment_link($comment);
    } else {
        $permalink = get_permalink($comment->comment_post_ID);
    }
    $shortlink = '';
    if (!empty($permalink)) {
        $url = 'http://is.gd/api.php?longurl=' . urlencode($permalink);
        //Shorten the link.
        if (!class_exists('Snoopy')) {
            include_once ABSPATH . WPINC . '/class-snoopy.php';
        }
        $snoopy = new Snoopy();
        $snoopy->agent = 'LinkedIn Connect (Snoopy)';
        $snoopy->host = $_SERVER['HTTP_HOST'];
        $snoopy->read_timeout = "180";
        if (@$snoopy->fetchtext($url)) {
            $shortlink = $snoopy->results;
        } else {
            $results = "Your comment was submitted, but it could not be sent to LinkedIn.  There was an error shortening the url: " . $snoopy->error . "\n";
            wp_die($results);
        }
    }
    if (!empty($shortlink)) {
        //Get the template for the update.
        $update = get_option("lic_share_this_text");
        //Determine characters available for post and blog title.
        $temp_update = $update;
        $temp_update = str_replace('%%post_title%%', '', $temp_update);
        $temp_update = str_replace('%%blog_title%%', '', $temp_update);
        $temp_update = str_replace('%%shortlink%%', '', $temp_update);
        $update_len = strlen($temp_update);
        if (strlen($post_title) + strlen($blog_title) + strlen($shortlink) + $update_len > 140) {
            //Shorten the blog title.
            $ctr = strlen($blog_title) - 1;
            $shorter = false;
            while (strlen($blog_title) > 10 && 140 < strlen($post_title) + strlen($blog_title) + 3 + strlen($shortlink) + $update_len) {
                $blog_title = substr($blog_title, 0, $ctr--);
                $shorter = true;
            }
            if ($shorter) {
                $blog_title .= '...';
            }
            $ctr = strlen($post_title) - 1;
            $shorter = false;
            while (strlen($post_title) > 10 && 140 < strlen($post_title) + 3 + strlen($blog_title) + strlen($shortlink) + $update_len) {
                $post_title = substr($post_title, 0, $ctr--);
                $shorter = true;
            }
            if ($shorter) {
                $post_title .= '...';
            }
        }
        $temp_update = $update;
        $temp_update = str_replace('%%post_title%%', $post_title, $temp_update);
        $temp_update = str_replace('%%blog_title%%', $blog_title, $temp_update);
        $temp_update = str_replace('%%shortlink%%', $shortlink, $temp_update);
        $update = $temp_update;
        if (strlen($update) <= 140) {
            $content = $liclient->setStatus($update);
            //Run request on linkedin API as user.
            //$content = $to->OAuthRequest('https://linkedin.com/statuses/update.xml', array('status' => $update), 'POST');
            if (strpos($content, 'status') === false && strpos($content, $update) === false) {
                wp_die('Your comment was submitted, but it could not be posted to LinkedIn.  ' . $content);
            }
        }
    }
}
Ejemplo n.º 6
0
function Update_link($url)
{
    global $db, $bug_url;
    $is_success = FALSE;
    $is_shoulu = FALSE;
    /*$spider=new spider;
      $spider->url($url);
      $title=$spider->title;
      $fulltxt=$spider->fulltxt;
      $lrymd5=md5($spider->fulltxt);
      $pagesize=$spider->pagesize;
      $keywords=$spider->keywords;
      $htmlcode=$spider->htmlcode;
      $description=$spider->description;*/
    $snoopy = new Snoopy();
    //国外snoopy程序
    $snoopy->fetchtext($url);
    $title = $snoopy->title;
    $fulltxt = $snoopy->fulltxt;
    $lrymd5 = md5($fulltxt);
    $pagesize = $snoopy->pagesize;
    $description = $snoopy->description;
    $keywords = $snoopy->keywords;
    //echo "fulltxt=".$fulltxt."<br>";
    $updatetime = time();
    //$site_url=GetSiteUrl($url);
    //$site=$db->get_one("select * from ve123_sites where url='".$site_url."'");
    //$site_id=$site["site_id"];
    //echo "site_id".$site["site_id"]."<br>";
    if ($title == "") {
        $title = str_cut($fulltxt, 65);
    }
    echo "<b><font color=#0Ae600>已更新</font></b>";
    echo $title;
    $array = array('lrymd5' => $lrymd5, 'title' => $title, 'fulltxt' => $fulltxt, 'description' => $description, 'keywords' => $keywords, 'pagesize' => $pagesize, 'updatetime' => $updatetime);
    //$db->query("update ve123_links set updatetime='".time()."' where url='".$url."'"); //更新时间
    //$s=array();
    //$s=explode("?",$title);
    //$domain=GetSiteUrl($url);
    //$site=$db->get_one("select * from ve123_sites where url='".$domain."'");
    $db->update("ve123_links", $array, "url='" . $url . "'");
    $is_success = TRUE;
    if (empty($bug_url)) {
        exit;
    }
    return $is_success;
}
Ejemplo n.º 7
0
            header('HTTP/1.1 202 Accepted', true, 202);
            foreach ($pixel_urls as $pixel_url) {
                if (isset($pixel_url)) {
                    $pixel_url = replaceTokens($pixel_url, $tokens);
                }
                echo "<script async src='{$pixel_url}'></script>\n";
            }
            break;
        case 4:
            $snoopy = new Snoopy();
            $snoopy->agent = "Mozilla/5.0 Postback202-Bot v1.8";
            foreach ($pixel_urls as $pixel_url) {
                if (isset($pixel_url)) {
                    $pixel_url = replaceTokens($pixel_url, $tokens);
                }
                $snoopy->fetchtext($pixel_url);
                header('HTTP/1.1 202 Accepted', true, 202);
                header('Content-Type: application/json');
                $response = array('error' => false, 'code' => 202, 'msg' => 'Postback successful');
                print_r(json_encode($response));
            }
            break;
        case 5:
            echo $mysql['pixel_code'];
            break;
    }
}
if (is_numeric($mysql['click_id'])) {
    if ($_GET['amount'] && is_numeric($_GET['amount'])) {
        $mysql['use_pixel_payout'] = 1;
        $mysql['click_payout'] = $db->real_escape_string($_GET['amount']);
Ejemplo n.º 8
0
<?php

$taoUrl = 'http://item.taobao.com/item.htm?spm=a219r.lm5082.14.1.0OaavE&id=23636544056&ns=1&abbucket=15#detail';
include 'snoopy.class.php';
$snoopy = new Snoopy();
$url = $taoUrl;
$snoopy->proxy_host = "http://www.jb51.net";
$snoopy->proxy_port = "80";
$snoopy->agent = "(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)";
$snoopy->referer = "http://www.jb51.net";
$snoopy->cookies["SessionID"] = "238472834723489l";
$snoopy->cookies["favoriteColor"] = "RED";
$snoopy->rawheaders["Pragma"] = "no-cache";
$snoopy->maxredirs = 2;
$snoopy->offsiteok = false;
$snoopy->expandlinks = false;
$snoopy->user = "******";
$snoopy->pass = "******";
if ($snoopy->fetchtext($url)) {
    echo "<PRE>" . htmlspecialchars($snoopy->results) . "</PRE>\n";
} else {
    echo "error fetching document: " . $snoopy->error . "\n";
}