private static function execute($search_string)
 {
     self::$error_msg = false;
     if (Controller::$debug) {
         var_dump(self::$url . '?' . $search_string);
     }
     $returned = curl_request(self::$url . '?' . $search_string);
     if (!$returned) {
         self::$error_msg = 'Invalid Twitter API request';
         if (Controller::$debug) {
             var_dump(self::$url . '?' . $search_string);
         }
         return false;
     } else {
         if (!($result = json_decode($returned))) {
             self::$error_msg = 'Invalid JSON returned: ' . $returned;
             return false;
         }
     }
     if (array_key_exists('error', $result)) {
         self::$error_msg = $result->error;
     } else {
         return is_object($result) && isset($result->results) ? $result->results : false;
     }
     if (!empty(self::$error_msg) && Controller::$debug) {
         Backend::addError('TwitterSearch: ' . self::$error_msg);
     }
     return false;
 }
function get_itunes_info_native($trackid, $store = 'us')
{
    if (!$store) {
        $store = 'us';
    }
    $return = curl_request("https://itunes.apple.com/lookup?id={$trackid}&country={$store}&lang=en_us");
    return json_decode($return, true);
}
Beispiel #3
0
function getView()
{
    $res;
    $url = 'http://jw.jxust.cn/default6.aspx';
    $result = curl_request($url);
    $pattern = '/<input type="hidden" name="__VIEWSTATE" value="(.*?)" \\/>/is';
    preg_match_all($pattern, $result, $matches);
    $res[0] = $matches[1][0];
    return $res;
}
Beispiel #4
0
function YahooPlacemakerRequest($location, $appid)
{
    $encodedLocation = \urlencode($location);
    $url = BASE_URL . "v1/document";
    $postvars = "documentContent={$encodedLocation}&documentType=text/plain&appid={$appid}";
    $return = curl_request($url, $postvars);
    $xml = new \SimpleXMLElement($return);
    $long = (double) $xml->document->placeDetails->place->centroid->longitude;
    $latt = (double) $xml->document->placeDetails->place->centroid->latitude;
    $gis = array('lon' => $long, 'lat' => $latt, 'location' => $location);
    return $gis;
}
Beispiel #5
0
function generate_short_link($link)
{
    global $API;
    $return = curl_request("https://s.appaddict.org/index.php?k=aa_shorten&l=" . urlencode($link));
    if (!$return) {
        return false;
    }
    return $return;
    /*
          require_once('classes/GoogleUrlApi.class.php');
          $gapi = new GoogleUrlApi($API->CONFIG['GOOGLE_API_KEY']);
          $link = $gapi->shorten($link);
          return $link; */
}
Beispiel #6
0
function getVcInfo($cookiefile)
{
    $url = 'http://check.ptlogin2.qq.com/check';
    $params = array('appid' => '549000912', 'js_type' => '1', 'js_ver' => '10136', 'login_sig' => '', 'pt_tea' => '1', 'pt_vcode' => '1', 'regmaster' => '', 'u1' => 'http://qzs.qq.com/qzone/v5/loginsucc.html?para=izone');
    $params['uin'] = '2716682718';
    $params['r'] = '0.' . mt_rand();
    $result = curl_request($url . '?' . http_build_query($params), array(), $cookiefile);
    $match = array();
    $ret = preg_match('#(?<=\\().*(?=\\))#', $result, $match);
    $match = explode(',', str_replace('\'', '', $match[0]));
    if ($match[0] == 0) {
        return array('vcode' => $match[1], 'pt_verifysession_v1' => $match[3]);
        return $match[1];
    }
    return false;
}
 function __construct($location)
 {
     parent::__construct('WeatherWidget');
     $this->location = $location;
     $weather = curl_request('http://www.google.co.za/ig/api', array('weather' => $this->location, 'hl' => 'af', 'C' => 1), array('cache' => 60 * 60));
     $weather = simplexml_load_string($weather);
     if (!empty($weather->weather->current_conditions)) {
         foreach ($weather->weather->current_conditions->children() as $condition => $value) {
             $this->current[$condition] = (string) $value['data'];
         }
     }
     if (!empty($weather->weather->forecast_conditions)) {
         foreach ($weather->weather->forecast_conditions as $forecast) {
             $this->forecast[(string) $forecast->day_of_week['data']] = array('low' => (int) $forecast->low['data'], 'high' => (int) $forecast->high['data'], 'icon' => (string) $forecast->icon['data'], 'condition' => (string) $forecast->condition['data']);
         }
     }
 }
Beispiel #8
0
 public function request($url, array $parameters = array(), $method = 'GET')
 {
     $request = $this->get_request($url, $parameters, $method);
     $options = array('method' => $method, 'headers' => array('Expect:'), 'callback' => array(__CLASS__, 'handleRequest'));
     switch (strtoupper($method)) {
         case 'GET':
             $returned = curl_request($request, array(), $options);
             break;
         default:
             $returned = curl_request($request, $parameters, $options);
             break;
     }
     if (Controller::$debug >= 2) {
         var_dump('Returned', $returned);
     }
     return $returned;
 }
Beispiel #9
0
function get_received_by_address($address, $txid, $after_unixtime)
{
    if (!preg_match('/[0-9a-zA-Z]{64}/', $txid)) {
        return false;
    }
    $data = json_decode(curl_request('https://blockchain.info/rawtx/' . $txid), true);
    if (!$data['out']) {
        return false;
    }
    if ($data['time'] < $after_unixtime) {
        return false;
    }
    foreach ($data['out'] as $out) {
        if ($out['addr'] == $address) {
            return number_format($out['value'] / 100000000, 8, '.', '');
        }
    }
    return false;
}
Beispiel #10
0
 public static function check($challenge, $response)
 {
     self::$error_msg = false;
     if (empty($challenge) || empty($response)) {
         self::$error_msg = 'Invalid challenge or response';
         return false;
     }
     $params = array('privatekey' => ConfigValue::get('recaptcha.PrivateKey'), 'remoteip' => $_SERVER['REMOTE_ADDR'], 'challenge' => $challenge, 'response' => $response);
     $result = curl_request('http://api-verify.recaptcha.net/verify', $params, array('method' => 'post'));
     if (!$result) {
         self::$error_msg = 'Could not contact reCAPTCHA server';
         return false;
     }
     $result = explode("\n", $result);
     if ($result[0] != 'true') {
         self::$error_msg = $result[1];
         return false;
     }
     return true;
 }
Beispiel #11
0
 /**
  * @todo We need to find a way to tag files with it's revision
  * @todo update overrides TableCtl::update
  */
 function action_update()
 {
     $location = Backend::getConfig('application.file_provider.location', false);
     if (!$location) {
         Backend::addError('No File Provider Location');
         return false;
     }
     $files = Component::fromFolder();
     foreach ($files as $file) {
         $rev_id = self::getRevisionFromFile($file);
         $result = curl_request($location, array('q' => 'backend_file/read/' . urlencode($file), 'mode' => 'json'));
         if ($result && ($result = @json_decode($result, true))) {
             $info = $result['result'];
             if ($info['version'] != $rev_id) {
                 //File is out old
             }
         } else {
             Backend::addError('Could not check status for ' . $file);
         }
     }
 }
Beispiel #12
0
function get_itunes_info2($trackid, $type = 'app', $store = 'us', $no_recursion = false)
{
    // proxy https://itunes.apple.com
    if (!$store) {
        $store = 'us';
    }
    if (!$type) {
        $type = 'app';
    }
    $proxies = array('http://127.0.0.1:81', 'http://188.165.24.108', 'http://94.23.169.52:81');
    //if ($_COOKIE['test']) var_dump("{$store}/{$type}/id{$trackid}/?l=en");
    $data = curl_request("https://itunes.apple.com/{$store}/{$type}/id{$trackid}/?l=en", 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)');
    //try_itunes_proxy("{$store}/{$type}/id{$trackid}/?l=en", $proxies);
    //var_Dump($data);
    $app['type'] = $type;
    $app['trackid'] = $trackid;
    $app['store'] = $store;
    if ($type == 'book') {
        preg_match("#its.serverData=(.*?)</script>#si", $data, $matches);
        $data = json_decode($matches[1], true);
        $data = $data['pageData']['productData'];
        $data['_reviews_']['current'] = json_decode(curl_request($data['reviews-url'], 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)'), true);
    } elseif ($type == 'app') {
        $data = json_decode($data, true);
        $data['_reviews']['current'] = json_decode(curl_request($data['reviewsUrlsData']['currentVersionUrl'], 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)'), true);
        $data['_reviews']['all'] = json_decode(curl_request($data['reviewsUrlsData']['allVersionsUrl'], 'AppStore/2.0 iOS/7.1 model/iPad4,1 build/11B554a (5; dt:94)'), true);
        if ($data['customersAlsoBought']['childrenIds']) {
            foreach ($data['customersAlsoBought']['childrenIds'] as $cid) {
                if (!$no_recursion) {
                    $data['_alsobought'][$cid] = get_itunes_info2($cid, $type, $store);
                }
            }
        }
    }
    if (!$data) {
        return false;
    }
    return $data;
}
Beispiel #13
0
function process_object($data, $tag, $propery, $value, $class = false)
{
    $headers = '';
    $url = html_entity_decode($data['url']);
    $page = curl_request($url, $headers);
    $dom = new simple_html_dom();
    $dom->load($page);
    $iframe = '';
    if (!$class) {
        $iframe = $dom->find("{$tag}[{$propery}={$value}] object");
    } else {
        $iframe = $dom->find("{$tag}.{$value} object");
    }
    if (!isset($iframe[0]->outertext)) {
        return null;
    }
    preg_match("/(<object.*? <\\/object>)/", $iframe[0]->outertext, $matches);
    $iframe = $matches[0];
    $patterns = [0 => '/width=["|\'].*?["|\']/', 1 => '/height=["|\'].*?["|\']/'];
    $replacements = [0 => 'width="640"', 1 => 'height="390"'];
    $frame = preg_replace($patterns, $replacements, $iframe);
    $result = ['data' => $data, 'embed' => $frame];
    return $result;
}
Beispiel #14
0
function getCNOrderDetails($source_data)
{
    $data = array();
    $headers = build_http_headers('order', 'getOrderDetails');
    $source_data = array('CN100000204', 'CN100000398', 'CN100000407', 'CN100000411', 'CN100000420', 'CN100000422');
    $pagination_data = array('PerPage' => 2, 'CurrPage' => 1);
    while (true) {
        $data['pagination'] = $pagination_data;
        $data['data'] = $source_data;
        $return_data = curl_request($headers, array('erp_data' => json_encode($data)));
        //print_r($return_data);die;
        $return_data = json_decode($return_data, true);
        //echo $return_data->HasMoreOrders;
        print_r($return_data);
        $return[] = $return_data;
        $HasMoreOrders = $return_data['HasMoreOrders'];
        $CurrPage = $return_data['PaginationResult']['CurrPage'];
        if ($HasMoreOrders == false || $HasMoreOrders == 0) {
            break;
        }
        $pagination_data['CurrPage'] = $CurrPage + 1;
    }
    return $return;
}
 /**
  * 获取今天天气,分别使用了Taobao的IP查询接口、百度的LBS的简易天气接口
  * @return array|mixed
  * @author Mr.Cong <*****@*****.**>
  */
 public function weather()
 {
     //新从缓存去检查,如果有则取缓存的数据
     $weatherCached = S('weather');
     if ($weatherCached != false) {
         return $weatherCached;
     }
     //获取客户端IP
     $client_ip = get_client_ip();
     //如果是本地,且是DEBUG是TRUE,则把IP替换一下,让其正常显示数据
     if ('127.0.0.1' === $client_ip) {
         $client_ip = '116.10.197.226';
     }
     //根据IP来获取所在城市
     $ip_api = sprintf(C('IPADDR_API'), $client_ip);
     $ipData = curl_request($ip_api);
     $enIpData = json_decode($ipData, true);
     //根据城市来获取天气
     $city = $enIpData['data']['city'];
     $weather_api = C('WEATHER_API') . $city;
     $weatherData = curl_request($weather_api);
     $data = json_decode($weatherData, true);
     $SourceWeather = $data['results'][0]['weather_data'][0];
     //筛选和重组数据
     $weather = array('date' => $SourceWeather['date'], 'dayPictureUrl' => $SourceWeather['dayPictureUrl'], 'nightPictureUrl' => $SourceWeather['nightPictureUrl'], 'weather' => $SourceWeather['weather'], 'wind' => $SourceWeather['wind'], 'temperature' => $SourceWeather['temperature']);
     S('weather', $weather, $this->cachedOptionsWithRedis);
     $this->response($weather, 'json');
 }
Beispiel #16
0
<?php

/*
 * 引入配置
 */
require 'lib/inc.config.php';
//设置页面标题
$view->setAttr("title", "用户中心");
/*
 * 数据处理
 */
//检测是否登录
isLogin('PHPSESSID', 'login.php', null);
$url = 'http://120.25.205.100:88/opencart/index.php?route=moblie';
//$cookie = "PHPSESSID=".$_COOKIE['PHPSESSID'];
//$data = curl_request($url.'/index',null,$cookie);
$data = curl_request($url . '/index');
$result = json_decode($data, true);
echo '<pre>';
var_dump($result);
exit;
//未登录
if (isset($result->tip) && $result->tip == 'nologin') {
    var_dump($result->tip);
}
/*
 * 渲染页面
 */
$view->userDetails = $result;
//输入页头、内容、页脚
$view->display("header.php")->display('user.php')->display('footer.php')->render();
Beispiel #17
0
<?php

/*
 * 引入配置
 */
require 'lib/inc.config.php';
//设置页面标题
$view->setAttr("title", "景区列表");
/*
 * 数据处理
 */
$url = 'http://120.25.205.100:88/opencart/index.php?route=moblie';
//获取列表无需带cookie
//$cookie = "PHPSESSID=".$_COOKIE['PHPSESSID'];
$data = curl_request($url . '/productList&path=59');
$result = json_decode($data, true);
//var_dump($result);exit;
/*
 * 渲染页面
 */
$view->viewList = $result['products'];
//echo '<pre>';var_dump($result['products']);exit;
//输入页头、内容、页脚
$view->display("header.php")->display('viewlist.php')->display('footer.php')->render();
 /**
  * 获取微博头像,并缓存
  * @param $uid
  * @param $url
  * @return bool|string
  * @author Mr.Cong <*****@*****.**>
  */
 private function get_avatar($uid, $url)
 {
     if (strpos($url, 'http://') !== false) {
         $f = md5($uid);
         $e = './Public/avatar/' . $f . '.jpg';
         $t = 1209600;
         //設定14天, 單位:秒
         if (!is_file($e) || time() - filemtime($e) > $t) {
             //當頭像不存在或文件超過14天才更新
             $stream = curl_request($url);
             file_put_contents($e, $stream);
         } else {
             $avatar = '/Public/avatar/' . $f . '.jpg';
         }
         if (filesize($e) < 500) {
             $avatar = '/Public/avatar/default.jpg';
         }
         return $avatar;
     }
     return false;
 }
Beispiel #19
0
function get_sched($group, $year, $week)
{
    // Détection d'erreurs dans les paramètres indiqués
    if ($group != 'MMI' && $group != 'PUB' && $group != 'LP') {
        return error('Le groupe indiqué n\'existe pas.');
    }
    if ($year != 1 && $year != 2 || $year == 2 && $group == 'LP') {
        return error('L\'année d\'enseignement indiquée n\'existe pas.');
    }
    if ($week > 53 || $week < 1) {
        return error('La semaine indiquée n\'existe pas.');
    }
    // Correspondance entre les paramètres fournis et les numéros des semestres
    $semesters = [['semester' => '1', 'year' => 1, 'begin' => 38, 'end' => 53, 'value' => 1], ['semester' => '2', 'year' => 1, 'begin' => 2, 'end' => 15], ['semester' => '3', 'year' => 2, 'begin' => 38, 'end' => 53, 'value' => 1], ['semester' => '4', 'year' => 2, 'begin' => 2, 'end' => 15]];
    // Association du semestre correspondant aux paramètres
    foreach ($semesters as $s) {
        if ($s['year'] == $year && ($week >= $s['begin'] && $week <= $s['end'] || array_key_exists('value', $s) && $week == $s['value'])) {
            $group .= '_S' . $s['semester'];
            break;
        }
    }
    // Paramètres POST de connexion
    $signin_param = ['modeglobal' => '', 'modeconnect' => 'connect', 'util' => SIGNIN_USERNAME, 'acct_pass' => SIGNIN_PASSWORD];
    // Paramètres POST de récupération de l'emploi du temps
    $sched_param = ['mode' => 'edt', 'idee' => '', 'aller' => '', 'semaine' => strval($week), 'liste' => '-1', 'aff_edtabs' => '-1', 'ansemaine' => $week < 38 ? '2016' : '2015', 'idedtselect' => '0', 'jouredt' => '', 'debutedt' => '', 'copiercouper' => '', 'left' => '0', 'top' => '0', 'taillepolice' => '10', 'onglet_actif' => '1', 'filiere' => $group];
    // Connexion
    $result = curl_request(SIGNIN_URL, $signin_param);
    if (strpos($result['output'], SIGNIN_MESSAGE) === false) {
        return error('Erreur lors de la connexion.');
    }
    // Requête vers la page GPU (actualisation des cookies)
    $result = curl_request(GPU_URL, [], $result['handle']);
    // Requête vers la page d'accueil de l'emploi du temps (actualisation des cookies + actualisation manuelle des cookies avec le groupe indiqué)
    $result = curl_request(HOMESCHED_URL, [], $result['handle']);
    $result['handle']['cookies'] .= 'filiere=' . $group . ';';
    // Récupération de l'emploi du temps
    $result = curl_request(SCHED_URL, $sched_param, $result['handle']);
    if (strpos($result['output'], SCHED_MESSAGE) === false) {
        return error('Erreur lors de la récupération de l\'emploi du temps.');
    }
    // Fermeture de la ressource cURL
    curl_close($result['handle']['curl']);
    // Tableau de l'emploi du temps
    $sched = ['Lundi' => [], 'Mardi' => [], 'Mercredi' => [], 'Jeudi' => [], 'Vendredi' => [], 'Samedi' => []];
    // Parsing du document html
    $document = new DOMDocument();
    @$document->loadHTML($result['output']);
    $sched_table = $document->getElementsByTagName('table')->item(3);
    for ($i = 0; $i < $sched_table->childNodes->length; $i++) {
        // Toute les 5 lignes du tableau, il ne s'agit que de l'affichage de l'heure donc inutile d'en prendre compte
        if ($i % 5 !== 0) {
            $tr = $sched_table->childNodes->item($i);
            for ($j = 0; $j < $tr->childNodes->length; $j++) {
                $td = $tr->childNodes->item($j);
                // Vérification qu'il s'agit bien d'un nœud élément (et pas texte par exemple)
                if ($td->nodeType == XML_ELEMENT_NODE) {
                    $h = $td->getElementsByTagName('table');
                    if ($h->length > 0) {
                        $data = [];
                        // Récupération du nom du cours, suppression des informations inutiles
                        $content = $td->getElementsByTagName('font')->item(0)->nodeValue;
                        $content = preg_replace('#^[\\s\\n]+#', '', $content);
                        $content = preg_replace('#[\\s\\n]+$#', '', $content);
                        $content = preg_replace('#^MMI\\s#', '', $content);
                        $content = preg_replace('#^[Ss]emestre\\s\\d\\s#', '', $content);
                        while (preg_match('#\\s\\((cours|TP|\\d+ PC|LP|multimédia)\\)\\s?\\d?$#', $content) || preg_match('#\\sSalle [\\d-]+\\s?\\d?$#', $content)) {
                            $content = preg_replace('#\\s\\((cours|TP|\\d+ PC|LP|multimédia)\\)\\s?\\d?$#', '', $content);
                            $content = preg_replace('#\\sSalle [\\d-]+\\s?\\d?$#', '', $content);
                        }
                        $content = preg_replace('#[A-Z\\s]+\\d?$#', '', $content);
                        // Correction des troncatures
                        $content = preg_replace('#informatio$#', 'information', $content);
                        // Majuscule à la première lettre et enregistrement
                        $data['content'] = ucfirst($content);
                        $h = $h->item(0)->getElementsByTagName('tr');
                        for ($k = 1; $k < $h->length; $k++) {
                            $d = $h->item($k)->getElementsByTagName('td');
                            if ($d->length >= 2) {
                                $key = $d->item(0)->nodeValue;
                                $value = $d->item(1)->nodeValue;
                                // Récupération de la date
                                if (preg_match('#^\\s*(lundi|mardi|mercredi|jeudi|vendredi|samedi)\\s+(\\d+)\\s+(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)\\s+(\\d+)\\s*$#i', $value, $match)) {
                                    $data['day'] = $match[1];
                                    $data['daynumber'] = $match[2];
                                    $data['month'] = $match[3];
                                    $data['year'] = $match[4];
                                } elseif (preg_match('#^\\s*(\\d+h\\d+)\\s+a\\s+(\\d+h\\d+)\\s*$#i', $value, $match)) {
                                    $data['beginhour'] = $match[1];
                                    $data['endhour'] = $match[2];
                                } elseif (preg_match('#^\\s*Enseignant\\(s\\)\\s*$#', $key)) {
                                    $professor = explode('-', preg_replace('#-+$#', '', $value));
                                    $data['professor'] = '';
                                    foreach ($professor as $p) {
                                        $data['professor'] .= strtoupper(substr($p, 0, 1)) . '. ' . ucfirst(strtolower(substr($p, 1))) . ', ';
                                    }
                                    if ($data['professor'] == '. , ') {
                                        $data['professor'] = 'Inconnu';
                                    } else {
                                        $data['professor'] = substr($data['professor'], 0, -2);
                                    }
                                } elseif (preg_match('#^\\s*Salle\\(s\\)\\s*$#', $key)) {
                                    $data['classroom'] = preg_replace('#-+$#', '', $value);
                                    if ($data['classroom'] == '') {
                                        $data['classroom'] = 'Inconnue';
                                    }
                                }
                            }
                        }
                        // Remplissage du tableau de l'emploi du temps avec les données récupérées
                        if (array_key_exists('day', $data) && array_key_exists('daynumber', $data) && array_key_exists('month', $data) && array_key_exists('year', $data) && array_key_exists('beginhour', $data) && array_key_exists('endhour', $data) && array_key_exists('professor', $data) && array_key_exists('classroom', $data)) {
                            array_push($sched[$data['day']], $data);
                        }
                    }
                }
            }
        }
    }
    // Retour de l'emploi du temps
    return $sched;
}
Beispiel #20
0
<?php

/*
 * 引入配置
 */
require 'lib/inc.config.php';
//设置页面标题
$view->setAttr("title", "景区详情");
/*
 * 数据处理
 */
$url = 'http://120.25.205.100:88/opencart/index.php?route=moblie';
//$cookie = "PHPSESSID=".$_COOKIE['PHPSESSID'];
$id = $_GET['id'];
$data = curl_request($url . '/product&product_id=' . $id);
$result = json_decode($data, true);
/*
 * 渲染页面
 */
$view->featureService = $result['featureService'];
foreach ($result as $key => $value) {
    if (!is_array($value)) {
        $tempArr[$key] = $value;
    }
}
$view->info = $tempArr;
//foreach($result)
//echo '<pre>';var_dump($view->featureService);exit;
//echo '<pre>';var_dump($result['products']);exit;
//输入页头、内容、页脚
//这里采用不规范命名是因为避免和view类冲突
 /**
  * 根据网址创建缩略图
  * @author Mr.Cong <*****@*****.**>
  */
 public function createThumb()
 {
     $id = I('id', 0);
     $target_url = I('target_url', '');
     $parse_url = parse_url($target_url);
     $newFileName = $parse_url['host'] . '@' . time() . '.jpg';
     $path = './Public/fav-thumb/' . date('Ym') . '/';
     if (!is_dir($path)) {
         mkdir($path);
     }
     $snapshot = $this->model->createThumbByPage2imageApi($target_url);
     if ($snapshot == false) {
         echo $this->model->getError();
     }
     $content = curl_request($snapshot->image_url);
     $fileName = $path . $newFileName;
     file_put_contents($fileName, $content);
     $map = array('id' => array('eq', $id));
     $this->model->where($map)->setField('thumb', $fileName);
     echo '0';
 }
Beispiel #22
0
function update_record($record_line)
{
    // create update record query
    $query = "/json-api/editzonerecord?zone=" . $GLOBALS['record_zone'] . "&Line=" . $record_line . "&address=" . $GLOBALS['record_address'] . "&type=A&class=IN&ttl=" . $GLOBALS['record_TTL'];
    // process query
    if (curl_request($query)) {
        echo "RECORD_UPDATED\n";
    }
}
Beispiel #23
0
<?php

/*
 * 引入配置
 */
require 'lib/inc.config.php';
//设置页面标题
$view->setAttr("title", "修改用户资料");
/*
 * 数据处理
 */
//检测是否登录
isLogin('PHPSESSID', 'login.php', null);
$url = 'http://120.25.205.100:88/opencart/index.php?route=moblie';
$cookie = "PHPSESSID=" . $_COOKIE['PHPSESSID'];
$data = curl_request($url . '/account/edit', null, $cookie);
$result = json_decode($data);
//未登录
if (isset($result->tip) && $result->tip == 'nologin') {
    var_dump($result->tip);
}
/*
 * 渲染页面
 */
foreach ($result as $key => $value) {
    $userDetails[$key] = $value;
}
$view->userDetails = $userDetails;
//输入页头、内容、页脚
$view->display("header.php")->display('edit.php')->display('footer.php')->render();
Beispiel #24
0
 public static function hook_output($output)
 {
     //TODO Attach HTTP Error codes and descriptions to these errors
     if (!is_array($output)) {
         BackendError::add('Google Chart Error', 'Invalid Output');
         return false;
     }
     $type = array_key_exists('type', $output) ? $output['type'] : Backend::get('ChartType', 'simple_line');
     if (!method_exists('GChartView', $type)) {
         BackendError::add('Google Chart Error', 'Invalid Chart Type');
         return false;
     }
     if (!array_key_exists('data', $output)) {
         $output = array('data' => $output);
     }
     if (!is_array($output['data']) || !count($output['data'])) {
         BackendError::add('Google Chart Error', 'Invalid Output Data');
         return false;
     }
     $params = array();
     $title = array_key_exists('title', $output) ? $output['title'] : Backend::get('ChartTitle', false);
     if ($title) {
         $params['chtt'] = $title;
     }
     $url = self::$type($output, $params);
     if (Controller::$debug) {
         echo '<img src="' . $url . '">';
         var_dump($params);
         var_dump($output);
         $dont_kill = Controller::getVar('dont_kill');
         if (empty($dont_kill)) {
             die;
         }
     }
     $recache = Controller::getVar('recache') ? true : false;
     debug_header('Recache - ' . $recache);
     $image = curl_request($url, array(), array('cache' => $recache ? 1 : 60 * 60, 'bypass_ssl' => 1));
     if (Controller::$debug) {
         var_dump('Image:', $image);
     }
     if (!$image) {
         BackendError::add('Google Chart Error', 'Could not get image');
         return false;
     }
     $filename = Backend::get('ChartFilename', false);
     if (!$filename) {
         $filename = class_name(Controller::$area) . class_name(Controller::$action);
         if (Controller::$action == 'read' && !empty(Controller::$parameters[0])) {
             $filename .= Controller::$parameters[0];
         }
     }
     if (Controller::$debug) {
         var_dump('Filename:', $filename);
     }
     header('Content-Disposition: inline; filename="' . $filename . '.png"');
     return $image;
 }
Beispiel #25
0
 public function course($aArgInput = false)
 {
     if (!$aArgInput) {
         echo 'The method ' . __FUNCTION__ . '() required an argument to be array, ' . (!$aArgInput ? 'none' : gettype($aArgInput)) . ' given.';
         return false;
     }
     $aDefault = array('url' => '', 'path' => '', 'method' => 'get', 'cookie' => '', 'course' => '', 'type' => '', 'campus' => '', 'checked' => '');
     $aArg = array_merge($aDefault, $aArgInput);
     // 合并 $aDefault 和 $aArg 两个数组,后者将替换前者中同名键的值;
     $this->aArg['url'] = ($aArg['url'] ?: $this->baseUrl) . $aArg['path'];
     // 拼合 url 地址;
     $this->aArg['method'] = $aArg['method'];
     $this->aArg['cookie'] = $aArg['cookie'] ?: $this->cookie;
     $sType = '';
     if ($aArg['type']) {
         preg_match('/tb|bsc|公共|kb|sb|zb|req|必修|kx|zx|lct|选修|tw|hs|人文|社科|ti|ns|自然|科学|ty|as|艺术|体育|tq|os|其他|专项/i', $aArg['type'], $aType);
     } elseif ($aArg['course']) {
         preg_match('/tb|kb|sb|zb|kx|zx|tw|ti|ty|tq/i', $aArg['course'], $aType);
     }
     if (!empty($aType)) {
         $sType = strtolower($aType[0]);
         switch ($sType) {
             case 'tb':
             case '公共':
                 $sType = 'bsc';
                 break;
             case 'kb':
             case 'sb':
             case 'zb':
             case '必修':
                 $sType = 'req';
                 break;
             case 'kx':
             case 'zx':
             case '选修':
                 $sType = 'lct';
                 break;
             case 'tw':
             case '人文':
             case '社科':
                 $sType = 'hs';
                 break;
             case 'ti':
             case '自然':
             case '科学':
                 $sType = 'ns';
                 break;
             case 'ty':
             case '艺术':
             case '体育':
                 $sType = 'as';
                 break;
             case 'tq':
             case '其他':
             case '专项':
                 $sType = 'os';
                 break;
         }
     }
     if (preg_match('/course\\/listing/i', $aArg['path'])) {
         $this->aArg['url'] .= '/' . $sType;
     }
     if (isset($aArgInput['checked'])) {
         $this->aArg['url'] = $this->baseUrl . 'course/select';
         $this->aArg['method'] = 'post';
         $this->aArg['data']['course'] = $aArg['course'];
         $this->aArg['data']['type'] = $sType;
         $this->aArg['data']['checked'] = $aArg['checked'] === false || $aArg['checked'] === 'false' ? 'false' : 'true';
         // 将 $aArg 参数中 checked 键的值转为字符串;
     }
     $reCourse = $aArg['course'] ?: '(.*?)';
     // 正则表达式中的课程序号;
     $reCourseRow = '/<td.*?>' . $reCourse . '<\\/td>(([^\\<]*\\n[^\\<]*)*<td.*?>(.*?)<\\/td>|([^\\<]*\\n[^\\<]*)*<td>(.*?)<\\/td>)+/i';
     // 正则表达式匹配课程列表行;
     $reReplace = '/<\\/td>([^\\<]*\\n[^\\<]*)*<td.*?>|<\\/td>([^\\<]*\\n[^\\<]*)*<td>/i';
     // 正则表达式匹配需要替换的行内容;
     if (!empty($aArg['campus'])) {
         preg_match('/雁山|育才|王城|未知/', $aArg['campus'], $aCampus);
         $sCampus = $aCampus[0];
     }
     /* 循环提交请求,直至返回积极信息 */
     for ($i = 0; $i < 10; $i++) {
         $this->data = curl_request($this->aArg);
         if (preg_match('/error/i', $this->data)) {
             $this->msg = 'error: 服务器发生错误!请重试。';
         } elseif (preg_match('/Location: http.*\\/course\\/listing/i', $this->data)) {
             if (preg_match('/true/i', $this->aArg['data']['checked'])) {
                 $this->msg = 'success: 选课成功!';
             } else {
                 $this->msg = 'success: 退课成功!';
             }
         } elseif (preg_match('/该门课程选课人数超限/', $this->data)) {
             $this->msg = 'sorry: 选课失败!该门课程人数已达限制。';
         } elseif (preg_match('/已达限制门数/', $this->data)) {
             $this->msg = 'sorry: 选课失败!该类课程已达限制门数。';
         } elseif (preg_match('/未到选课时间/', $this->data)) {
             $this->msg = 'sorry: 选课失败!现在未开放选课。';
         } elseif (preg_match('/<tbody>([^\\<]*\\n[^\\<]*)*<\\/tbody>|现在无国家考试成绩/i', $this->data)) {
             $this->msg = 'sorry: 抱歉!所查询的目录没有提供可用的数据。';
         } elseif (preg_match_all($reCourseRow, $this->data, $data)) {
             $this->msg = "success: 课程操作成功!\n";
             /* 循环罗列获取到的课程列表 */
             for ($n = 0; $n < count($data[0]); $n++) {
                 $course = preg_replace('/<td.*?>|<\\/td>|\\s{3}/i', '', preg_replace($reReplace, '->', $data[0][$n]));
                 if ($aArg['campus']) {
                     preg_match('/.*-\\>' . $sCampus . '-\\>.*/i', $course, $aCourse);
                     if (empty($aCourse)) {
                         continue;
                     } else {
                         $this->msg .= "[{$n}] => " . $aCourse[0] . "\n";
                     }
                 } else {
                     $this->msg .= "[{$n}] => " . $course . "\n";
                 }
             }
         } elseif (preg_match('/Location: http.*\\/login/i', $this->data)) {
             $this->msg = 'sorry: 抱歉!你还未登录,请登录后再操作。';
         }
         if (preg_match('/success|sorry/i', $this->msg)) {
             break;
         }
     }
     return $this->msg;
 }
Beispiel #26
0
function curl_post($url, $params = null, array $options = array())
{
    $options[CURLOPT_POST] = true;
    $options[CURLOPT_POSTFIELDS] = $params;
    return curl_request($url, $options);
}
Beispiel #27
0
<?php

error_reporting(E_ALL);
define('REQUEST_URL', 'https://test.api.dresslink.com/api.php');
define('DEV_ID', "cba7fa76-bd45-474a-8455-5852bacb51ad");
define('APP_ID', "SHENZHEN-3d95-4c0c-a609-7f3201df721f");
define('CERT_ID', "c7f4a4ed-7daa-48b9-87c4-a7d5d3c28eb9");
#######Begin 订单状态接口########
$headers = build_http_headers('order', 'getOrderStatus');
$source_data = array('DL00013250' => '4', 'DL00013269' => '3');
$data = json_encode($source_data);
$list_data = array('data' => $data);
$return_data = curl_request($headers, $list_data);
print_r($return_data);
#######End 订单状态接口########
function curl_request($headers, $list_data)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, REQUEST_URL);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $list_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}
function build_http_headers($service, $action)
{
Beispiel #28
0
function adjustSkuStock($source_data)
{
    $headers = build_http_headers('item', 'stock');
    //$source_data=array('15836_DBL'=>'1','15836_R'=>'1','15836_G'=>'1');
    //$source_data=array('15836'=>'T');
    $data = json_encode($source_data);
    $list_data = array('data' => $data);
    $return_data = curl_request($headers, $list_data);
    return $return_data;
}
function get_gallery_shortcode($atts)
{
    global $adi_fbook_page_id, $access_token;
    $limit_count = 100;
    $defaults = array('thumb_size' => 3);
    extract(shortcode_atts(array('album_id' => null, 'thumb_size' => null, 'title' => null), $atts));
    if (empty($atts)) {
        print '<p><b><i>Enter an album id using album_id attribute</i></b></p>';
        return;
    }
    $newDefs = array_merge($defaults, $atts);
    if ($newDefs['album_id'] == null) {
        print 'Enter an album id';
        return;
    }
    $album_id = $newDefs['album_id'];
    if (!empty($atts['title'])) {
        print "<h2 class=\"adi-facebook-gallery-title\">" . htmlentities($atts['title']) . "</h2>\n";
    }
    $url2 = 'https://graph.facebook.com/' . $album_id . '/photos?limit=' . $limit_count . '&offset=0&access_token=' . $access_token;
    $response2 = curl_request($url2);
    $arr2 = json_decode($response2);
    // if you want an array.
    if (isset($arr2->paging->next)) {
        $next_link = $arr2->paging->next;
    }
    if (isset($arr2->paging->previous)) {
        $prev_link = $arr2->paging->previous;
    }
    print '<div>';
    $count2 = count($arr2->data);
    for ($i2 = 0; $i2 < $count2; $i2++) {
        $img_title = $arr2->data[$i2]->name;
        //var_dump($arr2 -> data[$i2]);
        $img_src = $arr2->data[$i2]->images[1]->source;
        $img_h = ceil($arr2->data[$i2]->images[$newDefs['thumb_size']]->height / 2);
        $img_w = ceil($arr2->data[$i2]->images[$newDefs['thumb_size']]->width / 2);
        print '<div class="adi-facebook-photo-wrapper">';
        print '<a href="' . $arr2->data[$i2]->source . '" rel="gallery-photos" class="thickbox" ><img src="' . $img_src . '" height="' . $img_h . '" width="' . $img_w . '"  title="' . $img_title . '"/></a>';
        print '</div>';
    }
    print '</div>';
}
            //die(var_dump($to_links));
            $API->DB->query("INSERT INTO links {$API->DB->build_insert_query($to_links)}");
        }
    }
    print "{$percentage}% {$tid['trackid']} : {$count} inserted, {$skipcount} skipped\n";
    ob_flush();
}
print "ROUND 2 - links checking...\n\n";
$links = $API->DB->query_return("SELECT id,link FROM links ORDER BY id DESC");
$total = count($links);
print "{$total} total links...\n";
ob_flush();
$current = 0;
foreach ($links as $l) {
    $current++;
    $percentage = round($current / $total, 5) * 100;
    if (!preg_match('#(filepup|ul\\.to|uploaded\\.net|thefilebay\\.com|mega\\.co\\.nz|turbobit\\.net)#si', $l['link'])) {
        print "{$percentage}% {$l['link']} {$l['id']} skippping\n";
        ob_flush();
        continue;
    }
    $check = curl_request('https://dev.appaddict.org/assets/org_appaddict_imperator/linksChecker/?link=' . urlencode($l['link']));
    if ($check == 'dead') {
        $API->DB->query("UPDATE links SET state='dead' WHERE id={$l['id']}");
        print "{$percentage} %, {$l['link']} {$l['id']} is {$check}\n";
    } else {
        print "{$percentage} %, {$l['link']} {$l['id']} is {$check}\n";
    }
    ob_flush();
}
print "DONE \n\n\n";