コード例 #1
0
 public static function getProblemInfo($problemId)
 {
     // 新建一个curl
     $ch = new Curl();
     $url = 'http://poj.org/problem?id=' . $problemId;
     $html = $ch->get($url);
     if (empty($html) || $ch->error()) {
         $ch->close();
         return false;
     }
     $ch->close();
     $problemInfo = array();
     $matches = array();
     // 获取标题
     preg_match('/<div class="ptt" lang="en-US">(.*)<\\/div>/sU', $html, $matches);
     $problemInfo['title'] = '';
     if (!empty($matches[1])) {
         $problemInfo['title'] = trim($matches[1]);
     }
     // 获取来源
     preg_match('/<a href="searchproblem\\?field=source.*>(.*)<\\/a>/sU', $html, $matches);
     $problemInfo['source'] = '';
     if (!empty($matches[1])) {
         $problemInfo['source'] = trim($matches[1]);
     }
     $problemInfo['problem_id'] = $problemId;
     $problemInfo['problem_code'] = $problemId;
     return $problemInfo;
 }
コード例 #2
0
 public static function getProblemInfo($problemId)
 {
     // 新建一个curl
     $ch = new Curl();
     $url = 'http://acm.hdu.edu.cn/showproblem.php?pid=' . $problemId;
     $html = $ch->get($url);
     if (empty($html) || $ch->error()) {
         $ch->close();
         return false;
     }
     $ch->close();
     $problemInfo = array();
     $matches = array();
     // 获取标题
     preg_match('/<td align=center><h1 style=\'color:#1A5CC8\'>(.*)<\\/h1>/sU', $html, $matches);
     $problemInfo['title'] = '';
     if (!empty($matches[1])) {
         $problemInfo['title'] = trim($matches[1]);
         $problemInfo['title'] = iconv('GBK', 'UTF-8', $problemInfo['title']);
     }
     // 获取来源
     preg_match('/>Source.*<a.*\\/search.php.*>(.*)<\\/a>/sU', $html, $matches);
     $problemInfo['source'] = '';
     if (!empty($matches[1])) {
         $problemInfo['source'] = trim($matches[1]);
         $problemInfo['source'] = iconv('GBK', 'UTF-8', $problemInfo['source']);
     }
     $problemInfo['problem_id'] = $problemId;
     $problemInfo['problem_code'] = $problemId;
     return $problemInfo;
 }
コード例 #3
0
ファイル: Vk.class.php プロジェクト: lunavod/bunker_stable
 /**
  * Вызов метода ApiVK
  * @param $sMethod
  * @param $mParams
  * @return bool|mixed
  */
 private function CallMethod($sMethod, $mParams)
 {
     if (is_array($mParams)) {
         if (!isset($mParams['access_token'])) {
             if (!$this->sAccessToken) {
                 return false;
             }
             $mParams['access_token'] = $this->sAccessToken;
         }
         $oCurl = new Curl();
         $oCurl->SetUrl('https://api.vk.com/method/' . $sMethod);
         $oCurl->SetPostfields($mParams);
         $sResult = $oCurl->GetResponseBody(true);
     } else {
         $sParams = $mParams;
         if (!strpos($mParams, 'access_token')) {
             if (!$this->sAccessToken) {
                 return false;
             }
             $sParams = $mParams . '&access_token=' . $this->sAccessToken;
         }
         $oCurl = new Curl();
         $oCurl->SetUrl('https://api.vk.com/method/' . $sMethod . '?' . $sParams);
         $sResult = $oCurl->GetResponseBody(true);
     }
     if ($sResult === false) {
         throw new Exception($oCurl->Error());
     }
     $oCurl->close();
     return json_decode($sResult);
 }
コード例 #4
0
ファイル: CurlTest.php プロジェクト: schwarer2006/wikia
 function testCurlWrapperCanDoHttpQueries()
 {
     $curl = new Curl(self::TEST_VALID_URL);
     $curl->setopt(CURLOPT_PROXY, $this->proxy);
     $this->assertTrue($curl->setopt(CURLOPT_RETURNTRANSFER, 1));
     $this->assertTrue($curl->setopt_array(array(CURLOPT_TIMEOUT => self::CURL_TIMEOUT, CURLOPT_FOLLOWLOCATION => true)));
     $result = $curl->exec();
     $this->assertStringStartsWith('<!doctype html>', $result);
     $curl->close();
     $this->assertFalse($curl->hasHandle());
 }
コード例 #5
0
ファイル: IpType.php プロジェクト: oyoy8629/test
 public static function ip($ip)
 {
     $url = 'http://apis.baidu.com/rtbasia/ip_type/ip_type?ip=' . $ip;
     $curl = new Curl();
     $curl->setHeader("apikey", "29ddcb64dbe2f42764115b28941d2154");
     $curl->get($url);
     $curl->close();
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
     } else {
         return $curl->response;
     }
 }
コード例 #6
0
 public static function getProblemInfo($problemCode)
 {
     // 新建一个curl
     $ch = new Curl();
     $url = 'http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=' . $problemCode;
     $html = $ch->get($url);
     if (empty($html) || $ch->error()) {
         $ch->close();
         return false;
     }
     $ch->close();
     $problemInfo = array();
     $matches = array();
     // 获取标题
     preg_match('/<span class="bigProblemTitle">(.*)<\\/span>/sU', $html, $matches);
     $problemInfo['title'] = '';
     if (!empty($matches[1])) {
         $problemInfo['title'] = trim($matches[1]);
     }
     // 获取来源
     preg_match('/Source:.*<strong>(.*)<\\/strong>/sU', $html, $matches);
     if (empty($matches[1])) {
         preg_match('/Contest:.*<strong>(.*)<\\/strong>/sU', $html, $matches);
     }
     $problemInfo['source'] = '';
     if (!empty($matches[1])) {
         $problemInfo['source'] = trim($matches[1]);
     }
     // 获取$problemId
     preg_match('/"\\/onlinejudge\\/submit.do\\?problemId=(\\d+)"/sU', $html, $matches);
     $problemInfo['problem_id'] = 0;
     if (!empty($matches[1])) {
         $problemInfo['problem_id'] = $matches[1];
     }
     $problemInfo['problem_code'] = $problemCode;
     $problemInfo['remote'] = StatusVars::REMOTE_ZOJ;
     return $problemInfo;
 }
コード例 #7
0
ファイル: SmsGateway.php プロジェクト: terenaa/sms-gateway
 /**
  * Sends single text message.
  *
  * @param string $number recipient's phone number
  * @param string $message the message
  * @param null $signature sender's signature
  * @param null $phoneback sender's phone number
  * @return bool
  * @throws SmsGatewayException
  */
 public function send($number, $message, $signature = null, $phoneback = null)
 {
     $curl = new Curl();
     // Step 2
     $responseStep2 = $curl->sendRequest(self::ENDPOINT . '?page=sendsms', array('phoneno' => $number, 'message' => $message, 'signature' => $signature, 'phoneback' => $phoneback, 'action' => 'verify', 'ads_check1' => 'js_off', 'ads_check2' => 'js_off'));
     $phpsessid = $curl->getHtmlProperty($responseStep2, 'PHPSESSID');
     // Step 3
     $curl->sendRequest(self::ENDPOINT, array('PHPSESSID' => $phpsessid, 'action' => 'confirmbyuser'));
     // Step 4
     $responseStep4 = $curl->sendRequest(self::ENDPOINT, array('operator' => 'donotknow', 'action' => 'confirmprovider'));
     $imagecode = $curl->getHtmlProperty($responseStep4, 'imgcode');
     // Step 5
     $curl->sendRequest(self::ENDPOINT . '?a=sent', array('imgcode' => $imagecode, 'action' => 'useraccepted'));
     $curl->close();
     return true;
 }
コード例 #8
0
ファイル: curl_share_init.php プロジェクト: seebz/oo-curl
<?php

include '../lib/Curl.php';
include '../lib/Curl/Share.php';
/**
 * curl_share_init() example
 *
 * http://php.net/manual/en/function.curl-share-init.php#refsect1-function.curl-share-init-examples
 */
// Create cURL share handle and set it to share cookie data
$sh = new Curl\Share();
$sh->setopt(CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
// Initialize the first cURL handle and assign the share handle to it
$ch1 = new Curl("http://example.com/");
$ch1->setopt(CURLOPT_SHARE, $sh);
// Execute the first cURL handle
$ch1->exec();
// Initialize the second cURL handle and assign the share handle to it
$ch2 = new Curl("http://php.net/");
$ch2->setopt(CURLOPT_SHARE, $sh);
// Execute the second cURL handle
//  all cookies from $ch1 handle are shared with $ch2 handle
$ch2->exec();
// Close the cURL share handle
$sh->close();
// Close the cURL handles
$ch1->close();
$ch2->close();
コード例 #9
0
ファイル: M_net.php プロジェクト: urangawak/minangcms
 function curlNet2($method, $url, $param = array(), $ssl = FALSE)
 {
     require dirname(__FILE__) . '/ext/curl.php';
     $curl = new Curl();
     $exMethod = strtolower($method);
     if ($ssl == TRUE) {
         $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     }
     $curl->{$exMethod}($url, $param);
     if ($curl->error) {
         echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage;
         $curl->close();
     } else {
         return $curl->response;
         $curl->close();
         unset($curl);
     }
 }
コード例 #10
0
ファイル: API.php プロジェクト: khalid9th/ocAds
 /**
  * 
  * @static
  * @param string $id
  * @return object|null
  */
 public static function item($id)
 {
     self::$_params = 'key=' . self::$_apiKey . '&id=' . $id;
     Curl::init();
     $jsonGet = Curl::get(self::$_apiUrl . '/item?' . self::$_params);
     Curl::close();
     if ($jsonGet) {
         $jsonData = json_decode($jsonGet);
         if (isset($jsonData->error)) {
             showError($jsonData->error, 'API Error', 500);
         } else {
             return $jsonData;
         }
     }
     return NULL;
 }
コード例 #11
0
ファイル: Client.php プロジェクト: chenshuhao/BeginShake
 public function close()
 {
     $this->curl->close();
 }
コード例 #12
0
ファイル: metrics.php プロジェクト: tsing/commando
# limitations under the License.
*/
require_once dirname(__DIR__) . "/classes/Requires.php";
//Get settings
$result = MySQLQueries::get_settings();
$row = MySQLConnection::fetch_object($result);
$instance_key = null;
if (isset($row->data)) {
    $row->data = json_decode($row->data);
    if (isset($row->data->instance_key) && !empty($row->data->instance_key)) {
        $instance_key = $row->data->instance_key;
    } else {
        $instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
        $data = array("instance_key" => $instance_key, "default_ssh_username" => $row->data->default_ssh_username, "default_ssh_port" => $row->data->default_ssh_port, "default_interpreter" => $row->data->default_interpreter, "timezone_offset" => $row->data->timezone_offset, "timezone_daylight_savings" => $row->data->timezone_daylight_savings);
        MySQLQueries::edit_settings(json_encode((object) $data));
    }
} else {
    $instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
    $data = array("instance_key" => $instance_key);
    MySQLQueries::edit_settings(json_encode((object) $data));
}
$servers = array();
$result = MySQLQueries::get_servers();
while ($row = MySQLConnection::fetch_object($result)) {
    $servers[] = $row;
}
$payload = '{"event":"' . $instance_key . '","properties":{"token":"678f0669ff58d890eeb50633c91a633d","distinct_id":"' . $instance_key . '","ip":"' . Functions::get_remote_ip() . '","servers":"' . count($servers) . '","version":"' . Version::app . '","ip-address":"' . Functions::get_remote_ip() . '","mp_name_tag":"' . $instance_key . '","time":"' . time() . '"}}';
$curl = new Curl();
$curl->get_request("https://api.mixpanel.com/track/?data=" . base64_encode($payload));
$curl->close();
echo '{"instance_key":"' . $instance_key . '"}';
コード例 #13
0
ファイル: Dogpatch.php プロジェクト: love254443233/dogpatch
 public function close()
 {
     parent::close();
     $this->unsetClassVars();
 }
コード例 #14
0
ファイル: curl_init.php プロジェクト: seebz/oo-curl
<?php

include '../lib/Curl.php';
/**
 * curl_init() example
 *
 * http://php.net/manual/en/function.curl-init.php#refsect1-function.curl-init-examples
 */
// create a new cURL resource
$ch = new Curl();
// set URL and other appropriate options
$ch->setopt(CURLOPT_URL, "http://www.example.com/");
$ch->setopt(CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$ch->exec();
// close cURL resource, and free up system resources
$ch->close();