public function actionSocial()
 {
     $req = Yii::$app->request;
     $i = $req->get('i');
     $c = $req->get('c');
     $a = $req->get('a');
     //se inicia sesion en el ampache
     $Conexion = BaseJson::decode($this->actionConnectionParams());
     $datos = "";
     $peticionAmpache = http_post_data($Conexion["url"] . 'action=' . $Conexion['action'] . "&auth=" . $Conexion['auth'] . "&timestamp=" . $Conexion['timestamp'] . "&version=" . $Conexion['version'] . "&user="******"timeout" => 1, "useragent" => ""));
     $peticionAmpache = substr($peticionAmpache, strpos($peticionAmpache, '<'));
     $peticionAmpache = substr($peticionAmpache, 0, -5);
     //return $peticionAmpache;
     $xml = simplexml_load_string($peticionAmpache);
     $token = $xml->auth;
     //se pide la informacion del album
     $peticionAmpache = http_post_data($Conexion["url"] . "auth=" . $token . "&action=album_songs&filter=" . $a, $datos);
     //return $peticionAmpache;
     $peticionAmpache = substr(substr($peticionAmpache, strpos($peticionAmpache, '<')), 0, -5);
     $xml = simplexml_load_string($peticionAmpache);
     //"renderizamos la vista"
     $salida = $this->render('index', ['urlimg' => $xml->song[0]->art, 'descripcion' => 'Escuchando ' . $xml->song[0]->album . ' en Radio Album!']);
     //le agregamos los parametros necesarios
     $salida .= '<div id="parametros" data-skin="' . $i . 'vplayer" data-album="' . $a . '" data-channel="' . $c . '"></div>' . $peticionAmpache;
     //mostramos la vista
     return $salida;
 }
Exemple #2
0
 public function find($email)
 {
     $data = array('EMAIL' => rawurldecode($email));
     $return_content = http_post_data("http://itandroidbalance.miyigame.com/getbaseurl2.php", json_encode(array('email' => $email, 'platform' => 'xiaomi')));
     $return = json_decode($return_content, true);
     $baseurl = $return["baseurl"];
     $db_group_var = "db1";
     if ($baseurl == "itofdp4.miyigame.com:40002") {
         $db_group_var = "db1";
     } elseif ($baseurl == "itofdp5.miyigame.com:40003") {
         $db_group_var = "db2";
     } elseif ($baseurl == "itofdp6.miyigame.com:40004") {
         $db_group_var = "db3";
     }
     $this->session->set_tempdata('db_group', $db_group_var, 600);
     $this->load->model(array('User_data', 'Character_data', 'Skill_data', 'Treasure_data', 'Game_data', 'Item_data', 'Shop_data', 'Message_data'));
     $userRows = $this->User_data->selectUser($data);
     if (count($userRows) == 0) {
         js_alert_back('Empty no data.');
     } else {
         if (count($userRows) == 1) {
             js_redirect(site_url(array('user', 'view', $userRows[0]['USER_ID'])));
         } else {
             $data['USER_ROWS'] = $userRows;
             $this->viewer->all('user/find', $data);
         }
     }
 }
 function post($url, $fields = array(), $http_options = array())
 {
     $http_options = array_merge($this->http_options, $http_options);
     $res = is_array($fields) ? http_post_fields($url, $fields, array(), $http_options, $this->response_info) : http_post_data($url, $fields, $http_options, $this->response_info);
     $this->http_parse_message($res);
     return $this->response_object->body;
 }
Exemple #4
0
 protected function fetchData(Request $request)
 {
     $this->request = $request;
     include "getUA.php";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $id = preg_replace("/.*?(\\d.*)/smi", "\\1", $request->getVehicleId());
     $this->scrapeURL .= "?l=" . $request->getLang() . "&s=1&tid=" . $id . "&da=D&p=2";
     $post = http_post_data($this->scrapeURL, "", $request_options) or die("");
     $body = http_parse_message($post)->body;
     return $body;
 }
 private static function httpcall($url)
 {
     //maybe we should add the method to the config. Some servers have curl, some have this method:
     include "config.php";
     $request_options = array("referer" => "http://iRail.be/", "timeout" => "30", "useragent" => $iRailAgent);
     //echo $url;
     $post = http_post_data($url, "", $request_options) or die("");
     if ($post == "") {
         throw new Exception("Failed to contact the server");
     }
     return http_parse_message($post)->body;
 }
Exemple #6
0
     private static function getServerData($id,$lang){
	  include_once("../includes/getUA.php");
	  $request_options = array(
	       "referer" => "http://api.irail.be/",
	       "timeout" => "30",
	       "useragent" => $irailAgent,
	       );
	  $scrapeURL = "http://www.railtime.be/mobile/HTML/TrainDetail.aspx";
	  $id = preg_replace("/.*?(\d.*)/smi", "\\1", $id);
	  $scrapeURL .= "?l=" . $lang . "&tid=" . $id . "&dt=" . date( 'd%2fm%2fY' );
	  $post = http_post_data($scrapeURL, "", $request_options) or die("");
	  return http_parse_message($post)->body;	  
     }
 /** Send a query using a specified request-method.
  *
  * @param	string	$query			Query to send. (Required)
  * @param	string	$requestMethod	Request-method for calling (defaults to 'GET'). (Optional)
  * @return	SimpleXMLElement		A SimpleXMLElement object.
  *
  * @access	protected
  * @internal
  */
 protected function internalCall($params, $requestMethod = 'GET')
 {
     /* Create caching hash. */
     $hash = Cache::createHash($params);
     /* Check if response is cached. */
     if ($this->cache != null && $this->cache->contains($hash) && !$this->cache->isExpired($hash)) {
         /* Get cached response. */
         $response = $this->cache->load($hash);
     } else {
         /* Build request query. */
         $query = http_build_str($params, '', '&');
         /* Set request options. */
         $options = array('useragent' => 'PHP last.fm API (PHP/' . phpversion() . ')');
         /* Clear response headers. */
         $this->headers = array();
         /* Get response */
         if ($requestMethod === 'POST') {
             $response = http_post_data(self::API_URL, $query, $options, $info);
         } else {
             $response = http_get(self::API_URL . '?' . $query, $options, $info);
         }
         $response = http_parse_message($response);
         foreach ($response->headers as $header => $value) {
             $this->headers[$header] = $value;
         }
         $response = $response->body;
         /* Cache it. */
         if ($this->cache != null) {
             if (array_key_exists('Expires', $this->headers)) {
                 $this->cache->store($hash, $response, strtotime($this->headers['Expires']));
             } else {
                 $expiration = $this->cache->getPolicy()->getExpirationTime($params);
                 if ($expiration > 0) {
                     $this->cache->store($hash, $response, time() + $expiration);
                 }
             }
         }
     }
     /* Create SimpleXMLElement from response. */
     $response = new SimpleXMLElement($response);
     /* Return response or throw an error. */
     if (Util::toString($response['status']) === 'ok') {
         if ($response->children()->{0}) {
             return $response->children()->{0};
         }
     } else {
         throw new Error(Util::toString($response->error), Util::toInteger($response->error['code']));
     }
 }
Exemple #8
0
 private static function fetchData($station, $time, $lang, $timeSel)
 {
     include "../includes/getUA.php";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $body = "";
     //we want data for 1 hour. But we can only retrieve 15 minutes per request
     for ($i = 0; $i < 4; $i++) {
         $scrapeUrl = "http://www.railtime.be/mobile/SearchStation.aspx";
         $scrapeUrl .= "?l=EN&tr=" . $time . "-15&s=1&sid=" . stations::getRTID($station, $lang) . "&da=" . $timeSel . "&p=2";
         $post = http_post_data($scrapeUrl, "", $request_options) or die("");
         $body .= http_parse_message($post)->body;
         $time = tools::addQuarter($time);
     }
     return $body;
 }
Exemple #9
0
 public static function fetchData($station, $time, $lang, $arrdep)
 {
     include "../includes/getUA.php";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     if ($arrdep == "A") {
         throw new Exception("Not yet implemented. If you really need this function you can try to implement it yourself in http://github.com/iRail/iRail or you can ask on the mailinglist list.iRail.be", 500);
     }
     //	  $MIVBMODES = array("M", "N", "T", "B");
     $s = explode(".", $station->id);
     $stid = $s[2];
     //stibrt server wants lang in lowercase
     $lang = strtolower($lang);
     $scrapeUrl = "http://stibrt.be/labs/stib/service/getwaitingtimes.php?1=1&iti=1&halt={$stid}&lang={$lang}";
     //	  echo $scrapeUrl . "\n";
     $post = http_post_data($scrapeUrl, "", $request_options) or die("");
     return http_parse_message($post)->body;
 }
Exemple #10
0
 private static function fetchData($station, $time, $lang, $timeSel)
 {
     include "../includes/getUA.php";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $body = "";
     //we want data for 1 hour. But we can only retrieve 15 minutes per request
     for ($i = 0; $i < 4; $i++) {
         $scrapeUrl = "http://www.railtime.be/mobile/HTML/StationDetail.aspx";
         $rt = stations::getRTID($station, $lang);
         $rtname = $rt->rtname;
         $rtid = $rt->rtid;
         $scrapeUrl .= "?sn=" . urlencode($rtname) . "&sid=" . urlencode($rtid) . "&ti=" . urlencode($time) . "&da=" . urlencode($timeSel) . "&l=EN&s=1";
         $post = http_post_data($scrapeUrl, "", $request_options) or die("");
         $body .= http_parse_message($post)->body;
         $time = tools::addQuarter($time);
     }
     return $body;
 }
function get_dyn_pois($fw_dynamic)
{
    $conf_data = file_get_contents("poi_dp_dyn_conf.json");
    $conf = json_decode($conf_data, true);
    $sources = $fw_dynamic["sources"];
    $dyn_data = array();
    $n_sources = count($sources);
    for ($i = 0; $i < $n_sources; $i++) {
        $source = $sources[$i];
        $host = $source["host_type"];
        $type = $source["data_type"];
        if (array_key_exists('host_id', $source)) {
            $ids = $source["host_id"];
            $id = $source["host_id"][0];
        } else {
            $ids = array();
            $id = '';
        }
        switch ($conf["host_type"][$host]["method"]) {
            case "REST_GET":
                $url = $conf["host_type"][$host]["params"]["url"] . $id . $conf["host_type"][$host]["params"]["params"];
                $options = array('headers' => $conf["host_type"][$host]["params"]["headers"]);
                $output = http_get($url, $options);
                break;
            case "REST_POST":
                $i = 0;
                $data = $conf["host_type"][$host]["params"]["params"];
                foreach ($ids as $id) {
                    $data = str_replace('$' . $i++, $id, $data);
                }
                if (is_array($data)) {
                    $data = json_encode($data);
                }
                $output = http_post_data($conf["host_type"][$host]["params"]["url"], $data, array('headers' => $conf["host_type"][$host]["params"]["headers"]));
                break;
        }
        $data = http_parse_message($output)->body;
        // merge separate sources
        $mapped_data = map_data($conf["data_mapping"][$type], $data);
        $dyn_data = array_merge_r2($dyn_data, $mapped_data);
    }
    return $dyn_data;
}
 /**
  * Refreshes a user's session.
  *
  * @return true if refreshSession is successful
  */
 protected function refreshSession()
 {
     global $databaseURI;
     $_SESSION['SESSION'] = $this->hashData("md5", session_id() . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']);
     // create Session in DB
     $sessionbody = array('user' => $_SESSION['UID'], 'session' => $_SESSION['SESSION']);
     $sessionbody = json_encode($sessionbody);
     $url = "{$databaseURI}/session";
     http_post_data($url, $sessionbody, false, $message);
     // only true if session is created in DB
     if ($message == "201") {
         $_SESSION['SIGNED'] = true;
         $_SESSION['LASTACTIVE'] = $_SERVER['REQUEST_TIME'];
         $_SESSION['HTTP_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
         $_SESSION['IP'] = $_SERVER['REMOTE_ADDR'];
         return true;
     } else {
         return false;
     }
 }
 protected function fetchData(Request $request)
 {
     include "getUA.php";
     $this->request = $request;
     $scrapeUrl = "http://www.railtime.be/mobile/SearchStation.aspx";
     $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
     $stationname = strtoupper($request->getStation());
     include "includes/railtimeids.php";
     if (array_key_exists($stationname, $railtimeids)) {
         $rtid = $railtimeids[$stationname];
     } else {
         throw new Exception("Station not available for liveboard", 3);
     }
     $this->arrdep = $request->getArrdep();
     $this->name = $request->getStation();
     $scrapeUrl .= "?l=" . $request->getLang() . "&s=1&sid=" . $rtid . "&da=" . substr($request->getArrdep(), 0, 1) . "&p=2";
     $post = http_post_data($scrapeUrl, "", $request_options) or die("");
     $body = http_parse_message($post)->body;
     return $body;
 }
     $f = new FormEvaluator($_POST);
     $f->checkStringForKey('userName', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidUserName', $langTemplate), array('min' => 1));
     $f->checkIntegerForKey('rights', FormEvaluator::REQUIRED, 'warning', Language::Get('main', 'invalidCourseStatus', $langTemplate), array('min' => 0, 'max' => 2));
     if ($f->evaluate(true)) {
         $foundValues = $f->foundValues;
         $userName = $foundValues['userName'];
         $rights = $foundValues['rights'];
         $URL = $databaseURI . '/user/user/' . $userName;
         $user = http_get($URL, true);
         $user = json_decode($user, true);
         if (isset($user['id'])) {
             $userId = $user['id'];
             $newUser = User::createCourseStatus($userId, $cid, $rights);
             $newUser = User::encodeUser($newUser);
             $URL = $databaseURI . '/coursestatus';
             http_post_data($URL, $newUser, true, $message);
             if ($message == "201") {
                 $addUserNotifications[] = MakeNotification('success', Language::Get('main', 'successAddUser', $langTemplate));
             } else {
                 $addUserNotifications[] = MakeNotification('error', Language::Get('main', 'errorAddUser', $langTemplate));
             }
         } else {
             $addUserNotifications[] = MakeNotification('error', Language::Get('main', 'invalidUserId', $langTemplate));
         }
     } else {
         if (!isset($addUserNotifications)) {
             $addUserNotifications = array();
         }
         $addUserNotifications = $addUserNotifications + $f->notifications;
     }
 } else {
Exemple #15
0
    public static function getStationFromName($name, $lang)
    {
        //We can do a couple of things here:
        // * Match the name with something in the DB
        // * Give the name to hafas so that it returns us an ID which we can reuse - Doesn't work for external stations
        // * Do a hybrid mode
        // * match from location
        // * match railtime name
        //Let's go wih the hafas solution and get the location from it
        //fallback for wrong hafas information
        if (strtolower($name) == "brussels north" || strtolower($name) == "brussel noord" || strtolower($name) == "bruxelles nord") {
            return stations::getStationFromLocation(4.360854, 50.859658, $lang);
        }
        if (strtolower($name) == "vorst zuid") {
            return stations::getStationFromLocation(4.310025, 50.810158, $lang);
        }
        include "../includes/getUA.php";
        $url = "http://hari.b-rail.be/Hafas/bin/extxml.exe";
        $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
        $postdata = '<?xml version="1.0 encoding="iso-8859-1"?>
<ReqC ver="1.1" prod="iRail API v1.0" lang="' . $lang . '">
<LocValReq id="stat1" maxNr="1">
<ReqLoc match="' . $name . '" type="ST"/>
</LocValReq>
</ReqC>';
        $post = http_post_data($url, $postdata, $request_options) or die("");
        $idbody = http_parse_message($post)->body;
        preg_match("/x=\"(.*?)\".*?y=\"(.*?)\"/si", $idbody, $matches);
        $x = $matches[1];
        $y = $matches[2];
        preg_match("/(.)(.*)/", $x, $m);
        $x = $m[1] . "." . $m[2];
        preg_match("/(..)(.*)/", $y, $m);
        $y = $m[1] . "." . $m[2];
        return stations::getStationFromLocation($x, $y, $lang);
    }
Exemple #16
0
//echo $url . "<br>";
//echo $data . "<br>";
//echo $request_options . "<br>";
$body = http_parse_message($post)->body;
//This code fixes most hated issue #2 →→ You can buy me a beer in Ghent at anytime if you leave me a message at +32484155429
$dummy = preg_match("/(query\\.exe\\/..\\?seqnr=1&ident=.*?).OK.focus\" id=\"formular\"/si", $body, $matches);
if ($matches[1] != "") {
    //DEBUG:echo $matches[1];
    //scrape the date & time layout from $body
    preg_match("/value=\"(.., ..\\/..\\/..)\" onblur=\"checkWeekday/si", $body, $datelay);
    $datelay[1] = urlencode($datelay[1]);
    preg_match("/name=\"REQ0JourneyTime\" value=\"(..:..)\"/si", $body, $timelay);
    $timelay[1] = urlencode($timelay[1]);
    $passthrough_url = "http://hari.b-rail.be/HAFAS/bin/" . $matches[1] . "&queryPageDisplayed=yes&REQ0JourneyStopsS0A=1%26fromTypeStation%3Dhidden&REQ0JourneyStopsS0K=S-0N1&REQ0JourneyStopsZ0A=1%26toTypeStation%3Dhidden&REQ0JourneyStopsZ0K=S-1N1&REQ0JourneyDate=" . $datelay[1] . "&wDayExt0=Ma|Di|Wo|Do|Vr|Za|Zo&REQ0JourneyTime=" . $timelay[1] . "&REQ0HafasSearchForw=1&REQ0JourneyProduct_prod_list=" . $trainsonly . "&start=Submit";
    //DEBUG:echo "\n". $passthrough_url;
    $post = http_post_data($passthrough_url, null, $request_options);
    $body = http_parse_message($post)->body;
}
// check if nmbs planner is down
if (strstr($body, "[Serverconnection]") && strstr($body, "[Server]")) {
    $down = 1;
} else {
    $down = 0;
}
$body = strstr($body, '<table CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%" BGCOLOR="#FFFFFF">');
if ($body == "" && $down == 0) {
    header('Location: noresults');
} else {
    $body = str_replace('<table CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="100%" BGCOLOR="#FFFFFF">', '<table CELLSPACING="0" CELLPADDING="0" BORDER="0" BGCOLOR="#FFFFFF">', $body);
    $body = str_replace("<img ", "<img border=\"0\" ", $body);
    $body = str_replace("<td ", "<td NOWRAP ", $body);
    $baseurl = "";
    $return_content = http_post_data("http://itandroidbalance.miyigame.com:35001/getbaseurl2.php", json_encode(array('email' => $user_row["email"], 'platform' => 'xiaomi')));
    $ret = json_decode($return_content, true);
    $baseurl = $ret['baseurl'];
    $user3["baseurl"] = $baseurl;
    // 2. register user
    $data = array('email' => $user_row['email'], 'password' => '1003');
    $json_data = json_encode($data);
    $url = $baseurl . "/index.php/v22/user/Join";
    print_r($url . "\r\n");
    print_r($json_data . "\r\n");
    $return_content = http_post_data($url, encrypt_rc4($json_data));
    //print_r(decrypt_rc4($return_content));
    print_r("\r\n");
    print_r("\r\n");
    // 3. login
    $data = array('email' => $user_row['email'], 'password' => '1003', 'device' => 'php', 'os' => 'mac');
    $json_data = json_encode($data);
    $url = $baseurl . "/index.php/v22/user/Login";
    print_r($url . "\r\n");
    print_r($json_data . "\r\n");
    $return_content = http_post_data($url, encrypt_rc4($json_data));
    //print_r(decrypt_rc4($return_content));
    print_r("\r\n");
    print_r("\r\n");
    $user_info = json_decode(decrypt_rc4($return_content), true);
    $user_id = $user_info["userID"];
    $user3["user_id"] = $user_id;
    array_push($pay_user3, $user3);
}
file_put_contents("pay_user3.json", json_encode($pay_user3));
<?php

$clientId = Symphony::Configuration()->get('client_id', 'githuboauth');
$secret = Symphony::Configuration()->get('secret', 'githuboauth');
$redirectUrl = Symphony::Configuration()->get('token_redirect', 'githuboauth');
if (isset($_REQUEST['code'])) {
    $code = $_REQUEST['code'];
    $url = 'https://github.com/login/oauth/access_token';
    $post = 'client_id=' . $clientId . '&client_secret=' . $secret . '&code=' . $code;
    if (function_exists('http_post_data')) {
        $result = http_post_data($url, $post);
        $result = http_parse_message($result);
        $result = $result->body;
    } else {
        if (function_exists('curl_version')) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            $result = curl_exec($ch);
            curl_close($ch);
        } else {
            echo 'Failed to post HTTP.';
            exit;
        }
    }
    $headers = explode('&', trim($result));
    foreach ($headers as $item) {
        $header = explode('=', $item);
        if ($header[0] == 'access_token') {
            $token = $header[1];
<br>
<br>
<?php 
echo $method;
?>
 Host Response:<br>
</b>
<pre>
<?php 
// Main function:
switch ($method) {
    case "GET":
        $response = http_get($url);
        break;
    case "POST":
        $response = http_post_data($url, $data);
        break;
    case "PUT":
        $response = http_put_data($url, $data);
        break;
    case "DELETE":
        echo "DELETE NOT SUPPORTED: {$url}";
        exit;
}
//list($head,$body) = explode("{",$response);
echo $response;
echo "<b><h3><br>JSon pretty print:<br></h3></b>";
$json = http_parse_message($response)->body;
echo json_encode(json_decode($json), JSON_PRETTY_PRINT);
?>
</pre>
Exemple #20
0
// print_r("\r\n");
// print_r("api login ...\r\n");
// $url = "http://127.0.0.1/ramboat/login.php";
// $msg = array (
// 	"userId" => "frankyuan",
// );
// $data = json_encode($msg);
// list($return_code, $return_content) = http_post_data($url, $data);
// print_r($return_code);
// print_r($return_content);
// print_r("\r\n");
// print_r("api modify ...\r\n");
// $url = "http://127.0.0.1/ramboat/modify.php";
// $msg = array (
// 	"userId" => "sjy0079",
// 	"name" => "HuangCe",
// 	"icon" => "icon3"
// );
// $data = json_encode($msg);
// list($return_code, $return_content) = http_post_data($url, $data);
// print_r($return_code);
// print_r($return_content);
// print_r("\r\n");
print_r("api update api ...\r\n");
$url = "http://localhost/v2/register.php";
$msg = array("userId" => "RamboatRamboatRamboat30", "name" => "TestUserFromBBS_004", "pw" => "1234", "icon" => "0", "score" => 2012, "military" => 1, "ship" => 0);
$data = json_encode($msg);
list($return_code, $return_content) = http_post_data($url, $data);
print_r($return_code);
print_r($return_content);
print_r("\r\n");
 /**
  * 微信预授权码的获取与过期检查
  * Created by Jh.
  * User: jh
  * Date: 15-06-08 9:45 AM
  * Modify Date: 15-06-15 
  * Mail: blackcocwhite@gmail.com
  */
 public static function preauthcode()
 {
     $db = M('account');
     $result = $db->where('id=1')->find();
     // if(time()-$result['preauthcode_c_time']>$result['preauthcode_e_time']-10 || empty($result['preauthcode'])){
     $data['component_appid'] = 'wxef0739105b12ff8d';
     $data = json_encode($data);
     $token = self::access_token();
     $url = 'https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode?component_access_token=' . $token;
     //echo $url;die;
     $result = http_post_data($url, $data);
     $preauthcode = json_decode($result[1], true);
     $t['preauthcode'] = $preauthcode['pre_auth_code'];
     $t['preauthcode_c_time'] = time();
     $t['preauthcode_e_time'] = $preauthcode['expires_in'];
     M('account')->where('id=1')->save($t);
     return $t['preauthcode'];
     // }else{
     //    return $result['preauthcode'];
     // }
 }
Exemple #22
0
            }
            // attachments
            if (isset($attachments[$exerciseId])) {
                foreach ($attachments[$exerciseId] as $attachment) {
                    if (isset($attachment['file']['address'])) {
                        $attachment['file']['displayName'] = "{$namesOfExercises[$exerciseId]}/A_{$attachment['file']['hash']}_{$attachment['file']['displayName']}";
                        $files[] = $attachment['file'];
                    }
                }
            }
        }
    }
    unset($attachments, $markings, $exercises);
    // sheetFile
    if (isset($sheet['sheetFile']['address'])) {
        $sheet['sheetFile']['displayName'] = "{$sheet['sheetFile']['displayName']}";
        $files[] = $sheet['sheetFile'];
    }
    // sampleSolution
    if (isset($sheet['sampleSolution']['address'])) {
        $sheet['sampleSolution']['displayName'] = "{$sheet['sampleSolution']['displayName']}";
        $files[] = $sheet['sampleSolution'];
    }
    $fileString = json_encode($files);
    $zipfile = http_post_data($filesystemURI . '/zip', $fileString, true);
    $zipfile = File::decodeFile($zipfile);
    $zipfile->setDisplayName('markings.zip');
    $zipfile = File::encodeFile($zipfile);
    echo $zipfile;
    exit(0);
}
    /**
     * This function will get the data from nmbs we need.
     * @param Request $request
     * @return <type>
     */
    protected function fetchData(Request $request)
    {
        $this->request = $request;
        include "getUA.php";
        $url = "http://hari.b-rail.be/Hafas/bin/extxml.exe";
        $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
        //first request: Getting the id of the right stations
        $postdata = '<?xml version="1.0 encoding="iso-8859-1"?>
<ReqC ver="1.1" prod="iRail API v1.0" lang="EN">
<LocValReq id="from" maxNr="1">
<ReqLoc match="' . $request->getFrom() . '" type="ST"/>
</LocValReq>
<LocValReq id="to" maxNr="1">
<ReqLoc match="' . $request->getTo() . '" type="ST"/>
</LocValReq>
</ReqC>';
        $post = http_post_data($url, $postdata, $request_options) or die("");
        $idbody = http_parse_message($post)->body;
        preg_match_all("/externalId=\"(.*?)\"/si", $idbody, $matches);
        $idfrom = $matches[1][0];
        $idto = $matches[1][1];
        //for now
        $trainsonly = "1111111111111111";
        $timeSel = 0;
        if ($request->getTimeSel() == "depart") {
            $timeSel = 0;
        } else {
            if (strcmp($request->getTimeSel(), "arrive") == 0) {
                $timeSel = 1;
            }
        }
        //now we're going to get the real data
        $postdata = '<?xml version="1.0 encoding="iso-8859-1"?>
<ReqC ver="1.1" prod="irail" lang="' . $request->getLang() . '">
<ConReq>
<Start min="0">
<Station externalId="' . $idfrom . '" distance="0">
</Station>
<Prod prod="' . $trainsonly . '">
</Prod>
</Start>
<Dest min="0">
<Station externalId="' . $idto . '" distance="0">
</Station>
</Dest>
<Via>
</Via>
<ReqT time="' . $request->getTime() . '" date="' . $request->getDate() . '" a="' . $timeSel . '">
</ReqT>
<RFlags b="' . $request->getResults() * $timeSel . '" f="' . $request->getResults() * -($timeSel - 1) . '">
</RFlags>
<GISParameters>
<Front>
</Front>
<Back>
</Back>
</GISParameters>
</ConReq>
</ReqC>';
        $post = http_post_data($url, $postdata, $request_options) or die("<br />NMBS/SNCB website timeout. Please <a href='..'>refresh</a>.");
        return http_parse_message($post)->body;
    }
Exemple #24
0
    return $output;
}
if (!empty($_POST['appid'])) {
    //点击提交按钮后才执行
    $appid = $_POST['appid'];
    $secret = $_POST['secret'];
    $mark = $_POST['mark'];
    $appidurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
    $html = file_get_contents($appidurl);
    $html = stripslashes($html);
    $html = json_decode($html, true);
    //var_dump
    $token = $html["access_token"];
    $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={$token} ";
    $data = json_encode(array('action_name' => 'QR_LIMIT_SCENE', 'action_info' => array('scene' => array('scene_id' => $mark))));
    $ch = http_post_data($url, $data);
    $ch = json_decode($ch, true);
    $ticket = $ch["ticket"];
    $src = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$ticket}";
    echo "<img src='{$src}' />";
}
?>
<html>
<body>


<form action="" method="post">
Appid:<input type="text" name="appid" value="" /><br />
Secret:<input type="text" name="secret" value="" /><br />
标识:<input type="text" name="mark" value="" /><br />
<input type="submit" name="button" value="获取二维码" />
Exemple #25
0
         }
     }
     $notifications[] = MakeNotification('error', $errormsg);
     continue;
 } else {
     $result = Submission::decodeSubmission($result);
     // if using forms, upload user input
     if (isset($exercise['choices'])) {
         $i = 0;
         foreach ($formdata as &$form) {
             $choices = $form->getChoices();
             foreach ($choices as &$choice) {
                 $choice->setSubmissionId($result->getId());
             }
             $URL = $serverURI . '/DB/DBChoice/formResult/choice';
             $result2 = http_post_data($URL, Choice::encodeChoice($choices), true, $message);
             if ($message != "201") {
                 $result2 = Choice::decodeChoice($result2);
                 $exercise = $key + 1;
                 $errormsg = Language::Get('main', 'errorUploadSubmission', $langTemplate, array('status' => $message, 'exerciseName' => $exercise['name']));
                 if ($result2 !== null) {
                     $errormsg .= "<br><br>";
                     $messages2 = $result2->getMessages();
                     foreach ($messages2 as $message) {
                         $errormsg .= str_replace("\n", '<br>', $message) . '<br>';
                     }
                 }
                 $notifications[] = MakeNotification('error', $errormsg);
                 continue;
             }
             $i++;
 public function getInfo($appid, $id)
 {
     //auth_code会失效 60分钟
     //if(!$appid){$this->error('参数错误','/');}
     //$appid ? $appid : $appid = M('pub_account')->where('id = 1')->getField('account_appid');
     $log = wx_opera_log(session('username'), '订阅号管理', '订阅号授权', '', 'getInfo');
     $token = R('Receive/access_token');
     $url = 'https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=' . $token;
     $data['component_appid'] = C('WECHAT_APPID');
     $data['authorizer_appid'] = $appid;
     $data = json_encode($data);
     $result = http_post_data($url, $data);
     $result = json_decode($result[1], true);
     if (isset($result['errcode'])) {
         \Think\Log::record($result['errmsg'] . "错误码:" . $result['errcode'], 'ERR');
         $this->error('参数错误,请查看错误日志');
     }
     $authorizer_info = $result['authorizer_info'];
     $info['nick_name'] = $authorizer_info['nick_name'];
     $info['head_img'] = $authorizer_info['head_img'];
     $info['service_type_info'] = implode($authorizer_info['service_type_info']);
     $info['verify_type_info'] = implode($authorizer_info['verify_type_info']);
     $info['user_name'] = $authorizer_info['user_name'];
     $info['alias'] = $authorizer_info['alias'];
     $info['qrcode_url'] = $authorizer_info['qrcode_url'];
     $info['create_time'] = time();
     $info['create_person'] = session('username');
     $info['create_person_id'] = session('uid');
     if (M('pub_account')->where(array('account_appid' => $appid))->save($info)) {
         $this->success('授权成功,请返回完善授权公众号资料', U('com_info', "id=" . $id));
     } else {
         $this->error('授权失败,请刷新网页重试', '/');
     }
 }
Exemple #27
0
    private static function requestHafasXml($idfrom, $idto, $lang, $time, $date, $results, $timeSel, $typeOfTransport)
    {
        include "../includes/getUA.php";
        $url = "http://hari.b-rail.be/Hafas/bin/extxml.exe";
        $request_options = array("referer" => "http://api.irail.be/", "timeout" => "30", "useragent" => $irailAgent);
        if ($typeOfTransport == "trains") {
            $trainsonly = "0111111000000000";
        } else {
            if ($typeOfTransport == "all") {
                $trainsonly = "1111111111111111";
            } else {
                $trainsonly = "0111111000000000";
            }
        }
        if ($timeSel == "depart") {
            $timeSel = 0;
        } else {
            if ($timeSel == "arrive") {
                $timeSel = 1;
            } else {
                $timeSel = 1;
            }
        }
        //now we're going to get the real data
        $postdata = '<?xml version="1.0 encoding="iso-8859-1"?>
<ReqC ver="1.1" prod="iRail" lang="' . $lang . '">
<ConReq>
<Start min="0">
<Station externalId="' . $idfrom . '" distance="0">
</Station>
<Prod prod="' . $trainsonly . '">
</Prod>
</Start>
<Dest min="0">
<Station externalId="' . $idto . '" distance="0">
</Station>
</Dest>
<Via>
</Via>
<ReqT time="' . $time . '" date="' . $date . '" a="' . $timeSel . '">
</ReqT>
<RFlags b="' . $results * $timeSel . '" f="' . $results * -($timeSel - 1) . '">
</RFlags>
<GISParameters>
<Front>
</Front>
<Back>
</Back>
</GISParameters>
</ConReq>
</ReqC>';
        $post = http_post_data($url, $postdata, $request_options) or die("<br />NMBS/SNCB website timeout. Please <a href='..'>refresh</a>.");
        return http_parse_message($post)->body;
    }
Exemple #28
0
</Dest>
<Via>
</Via>
<ReqT time="' . $time . '" date="' . $date . '" a="0">
</ReqT>
<RFlags b="0" f="' . $results . '">
</RFlags>
<GISParameters>
<Front>
</Front>
<Back>
</Back>
</GISParameters>
</ConReq>
</ReqC>';
$post = http_post_data($url, $postdata, $request_options) or die("<br />NMBS/SNCB website timeout. Please <a href='..'>refresh</a>.");
$body = http_parse_message($post)->body;
//DBG: echo $body;
//output
preg_match("/..(..)(..)(..)/si", $date, $m);
$date = $m[3] . $m[2] . $m[1];
// Find connections
$connectionnumber = 0;
preg_match_all("/<Connection .*?>(.*?)<\\/Connection>/si", $body, $matches);
$connections = $matches[1];
echo "<connections>";
foreach ($connections as $i => $value) {
    preg_match("/<Dep getIn=\"YES\">\\s*<Time>00d(..:..):00<\\/Time>/si", $value, $m);
    $time_dep = $m[1];
    preg_match("/<Arr getOut=\"YES\">\\s*<Time>00d(..:..):00<\\/Time>/si", $value, $m);
    $time_arr = $m[1];
Exemple #29
0
            }
            if ($key == 0) {
                $text .= '</tr>';
            } else {
                $text .= '</tr>';
            }
        }
        $text .= '</table>';
        $pdf = Pdf::createPdf($text, 'L');
        $file = http_post_data($filesystemURI . '/pdf', Pdf::encodePdf($pdf), true);
        $file = File::decodeFile($file);
        $file->setDisplayName('conditions.pdf');
        $file = File::encodeFile($file);
    } elseif (isset($_GET['downloadConditionCsv'])) {
        $csv = Csv::createCsv($rows);
        $file = http_post_data($filesystemURI . '/csv', Csv::encodeCsv($csv), true);
        $file = File::decodeFile($file);
        $file->setDisplayName('conditions.csv');
        $file = File::encodeFile($file);
    }
    echo $file;
    exit(0);
}
if (isset($_GET['sortby'])) {
    $condition_data['sortby'] = $_GET['sortby'];
}
if (isset($_GET['sortId'])) {
    $condition_data['sortId'] = $_GET['sortId'];
}
// construct a new header
$h = Template::WithTemplateFile('include/Header/Header.template.html');
Exemple #30
0
 $error = $file['error'];
 if ($error == 0) {
     $filePath = $file['tmp_name'];
     $displayName = $file['name'];
     $type = $file["type"];
     // checks file ending
     if (MimeReader::get_mime($filePath) == "application/zip") {
         // creates the JSON object containing the file
         $file = new File();
         $file->setBody(Reference::createReference($filePath));
         $file->setTimeStamp(time());
         $file->setDisplayName($displayName);
         $file = File::encodeFile($file);
         // sends the JSON object to the logic
         $URI = $logicURI . "/tutor/user/{$uid}/course/{$cid}";
         $error = http_post_data($URI, $file, true, $message);
         if ($message == "201" || $message == "200") {
             $successmsg = Language::Get('main', 'sucessFileUpload', $langTemplate);
             $notifications[] = MakeNotification('success', $successmsg);
         } else {
             $errors = @json_decode($error);
             if ($errors !== null) {
                 foreach ($errors as $err) {
                     $notifications[] = MakeNotification('error', $err);
                 }
             } else {
                 $errormsg = Language::Get('main', 'unknownError', $langTemplate);
                 $notifications[] = MakeNotification('error', $errormsg);
             }
         }
     } else {