function test_table() { $input = <<<EOF ^ H 1 ^ H 2 ^ H 3 ^ ** H 4 ** ^ | R 1 C 1 | R 1 C 2 || R 1 Col 4 | | R 2 C 1 | ::: || R 2 Col 4 | | R 3 C 1 | R 3 C 2 | R 3 C 3 | R 3 Col 4 | EOF; $data = array(array('H 1', 'H 2', 'H 3', '** H 4 **'), array('R 1 C 1', 'R 1 C 2', '', 'R 1 Col 4'), array('R 2 C 1', ':::', '', 'R 2 Col 4'), array('R 3 C 1', 'R 3 C 2', 'R 3 C 3', 'R 3 Col 4')); $meta = array(array(array('align' => 'left', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'th'), array('align' => 'center', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'th'), array('align' => 'right', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'th'), array('align' => 'left', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'th')), array(array('align' => 'left', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td'), array('align' => 'left', 'colspan' => 2, 'rowspan' => 2, 'tag' => 'td'), array('hide' => true, 'rowspan' => 1, 'colspan' => 1), array('align' => null, 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td')), array(array('align' => 'left', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td'), array('hide' => true, 'rowspan' => 1, 'colspan' => 1), array('hide' => true, 'rowspan' => 1, 'colspan' => 1), array('align' => null, 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td')), array(array('align' => 'left', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td'), array('align' => 'left', 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td'), array('align' => null, 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td'), array('align' => null, 'colspan' => 1, 'rowspan' => 1, 'tag' => 'td'))); $renderer = $this->render($input); $json = new JSON(JSON_LOOSE_TYPE); $this->assertEquals($data, $json->decode($renderer->getDataJSON())); $this->assertEquals($meta, $json->decode($renderer->getMetaJSON())); }
private function processTen() { $prepared = $this->db->prepare(' SELECT * FROM `jobs` WHERE `status` = :status ORDER BY `created_at` LIMIT 10 '); $prepared->execute([':status' => self::QUEUED]); foreach ($prepared->fetchAll(PDO::FETCH_ASSOC) as $row) { if (isset(self::$handlers[$row['handler']])) { $class = self::$handlers[$row['handler']]; $worker = new $class(); $this->db->beginTransaction(); try { $this->setStatus($row['id'], self::PROCESSING); $worker->work(JSON::decode($row['message'])); $this->setStatus($row['id'], self::FINISHED); $this->db->commit(); } catch (Exception $e) { echo $e; $this->db->rollBack(); error_log('job_log: ' . $e); } } } }
public static function get() { $rmFile = preg_replace("/\\/\\*([^x00]*)\\*?\\/?\\*\\//U", "", Filesystem::getFileContent(Config::ROADMAP)); $roadMap = JSON::decode($rmFile, true); $tmpl = self::$_attr; $cnt = 0; $good = is_array($roadMap); //print_r( $roadMap ); die; for ($i = 0; $good && is_array($roadMap) && $i < count($roadMap); $i++) { $el = $roadMap[$i]; foreach ($el as $k => $v) { if (($pos = array_search($k, $tmpl)) !== FALSE) { $tmpl[$pos] = "asnfcjrwpht984fh9prewgf84fds"; $cnt++; } } $good = $cnt == count(self::$_attr); } if ($good) { return $roadMap; } else { self::raiseException(ERR_ROADMAP); return NULL; } }
public function testDecoding() { $formatter = new JSON(); $data = (object) array('name' => 'Joe', 'age' => 21, 'employed' => true); $raw = '{"name":"Joe","age":21,"employed":true}'; $this->assertEquals($data, $formatter->decode($raw)); }
/** * 下载文件 * @param string|array $file_name 文件名,可以为数组 */ public function download($from_version, $to_version = null) { if ($to_version == null) { $to_version = $this->version; } $url = self::URL . "file.php?name={$this->name}&from={$from_version}&to={$to_version}"; $fileinfo = self::get($url); if (trim($fileinfo) == "") { return false; } $fileinfo = JSON::decode($fileinfo); $bak_path = $this->init_bak_path(); $bak_zip = new ZipArchive(); $bak_zip->open($bak_path, ZIPARCHIVE::CREATE); foreach ($fileinfo as $key => $value) { $tmp_path = ltrim($value['path'], "./\\"); if (file_exists($tmp_path)) { $bak_zip->addFile($tmp_path); } } $bak_zip->close(); $url = self::URL . "download.php?name={$this->name}&from={$from_version}&to={$to_version}"; $content = self::get($url); $tmp_path = microtime(true) . mt_rand(1, 10000) . ".zip"; file_put_contents($tmp_path, $content); /* $bak_zip->open($tmp_path,ZIPARCHIVE::CREATE); $bak_zip->extractTo("./"); $bak_zip->close(); unlink($tmp_path); return true; */ return $tmp_path; }
/** * 针对notify_url验证消息是否是连连支付发出的合法消息 * @return 验证结果 */ function verifyNotify() { //生成签名结果 $is_notify = true; include_once 'llpay_cls_json.php'; $json = new JSON(); $str = file_get_contents("php://input"); $val = $json->decode($str); $oid_partner = trim($val->{'oid_partner'}); $sign_type = trim($val->{'sign_type'}); $sign = trim($val->{'sign'}); $dt_order = trim($val->{'dt_order'}); $no_order = trim($val->{'no_order'}); $oid_paybill = trim($val->{'oid_paybill'}); $money_order = trim($val->{'money_order'}); $result_pay = trim($val->{'result_pay'}); $settle_date = trim($val->{'settle_date'}); $info_order = trim($val->{'info_order'}); $pay_type = trim($val->{'pay_type'}); $bank_code = trim($val->{'bank_code'}); $no_agree = trim($val->{'no_agree'}); $id_type = trim($val->{'id_type'}); $id_no = trim($val->{'id_no'}); $acct_name = trim($val->{'acct_name'}); //首先对获得的商户号进行比对 if ($oid_partner != $this->llpay_config['oid_partner']) { //商户号错误 return false; } $parameter = array('oid_partner' => $oid_partner, 'sign_type' => $sign_type, 'dt_order' => $dt_order, 'no_order' => $no_order, 'oid_paybill' => $oid_paybill, 'money_order' => $money_order, 'result_pay' => $result_pay, 'settle_date' => $settle_date, 'info_order' => $info_order, 'pay_type' => $pay_type, 'bank_code' => $bank_code, 'no_agree' => $no_agree, 'id_type' => $id_type, 'id_no' => $id_no, 'acct_name' => $acct_name); if (!$this->getSignVeryfy($parameter, $sign)) { return false; } return true; }
/** * 针对return_url验证消息是否是连连支付发出的合法消息 * @return 验证结果 */ function verifyReturn() { if (empty($_POST)) { //判断POST来的数组是否为空 return false; } else { $res_data = $_POST["res_data"]; // file_put_contents("log.txt", "返回结果:" . $res_data . "\n", FILE_APPEND); $json = new JSON(); //error_reporting(3); //商户编号 $oid_partner = $json->decode($res_data)->{'oid_partner'}; //首先对获得的商户号进行比对 if (trim($oid_partner) != $this->llpay_config['oid_partner']) { //商户号错误 return false; } //生成签名结果 $parameter = array('oid_partner' => $oid_partner, 'sign_type' => $json->decode($res_data)->{'sign_type'}, 'dt_order' => $json->decode($res_data)->{'dt_order'}, 'no_order' => $json->decode($res_data)->{'no_order'}, 'oid_paybill' => $json->decode($res_data)->{'oid_paybill'}, 'money_order' => $json->decode($res_data)->{'money_order'}, 'result_pay' => $json->decode($res_data)->{'result_pay'}, 'settle_date' => $json->decode($res_data)->{'settle_date'}, 'info_order' => $json->decode($res_data)->{'info_order'}, 'pay_type' => $json->decode($res_data)->{'pay_type'}, 'bank_code' => $json->decode($res_data)->{'bank_code'}); if (!$this->getSignVeryfy($parameter, $json->decode($res_data)->{'sign'})) { return false; } return true; } }
/** * @see Page::readParameters() */ public function readParameters() { parent::readParameters(); if (!WCF::getUser()->getPermission('user.source.profiles.canManageProfiles')) { throw new PermissionDeniedException(); } if (isset($_POST['packages'])) { $packages = JSON::decode($_POST['packages']); if (!is_array($packages)) { $this->sendResponse('pb.build.profile.error.packages.empty', true); } $this->packages = $packages; } if (isset($_POST['packageHash'])) { $this->packageHash = StringUtil::trim($_POST['packageHash']); } if (isset($_POST['packageName'])) { $this->packageName = StringUtil::trim($_POST['packageName']); } if (isset($_POST['profileName'])) { $this->profileName = StringUtil::trim($_POST['profileName']); if (empty($this->profileName)) { $this->sendResponse('wcf.global.error.empty', true); } } if (isset($_POST['resource'])) { $this->resource = StringUtil::trim($_POST['resource']); } }
/** * Retrieve the user's data * * The array needs to contain at least 'user', 'email', 'name' and optional 'grps' * * @return array */ public function getUser() { $JSON = new \JSON(JSON_LOOSE_TYPE); $data = array(); $result = $JSON->decode($this->oAuth->request('user')); $data['user'] = $result['login']; $data['name'] = $result['name']; $result = $JSON->decode($this->oAuth->request('user/emails')); foreach ($result as $row) { if ($row['primary']) { $data['mail'] = $row['email']; break; } } return $data; }
/** * 功能:与 ECShop 交换数据 * * @param array $certi 登录参数 * @param array $license 网店license信息 * @param bool $use_lib 使用哪一个json库,0为ec,1为shopex * @return array */ function exchange_shop_license($certi, $license, $use_lib = 0) { if (!is_array($certi)) { return array(); } include_once ROOT_PATH . 'includes/cls_transport.php'; include_once ROOT_PATH . 'includes/cls_json.php'; $params = ''; foreach ($certi as $key => $value) { $params .= '&' . $key . '=' . $value; } $params = trim($params, '&'); $transport = new transport(); //$transport->connect_timeout = 1; $request = $transport->request($license['certi'], $params, 'POST'); $request_str = json_str_iconv($request['body']); if (empty($use_lib)) { $json = new JSON(); $request_arr = $json->decode($request_str, 1); } else { include_once ROOT_PATH . 'includes/shopex_json.php'; $request_arr = json_decode($request_str, 1); } return $request_arr; }
/** * 与远程服务器发送数据 * @param string $query 查询字符串 * @return array */ private static function send($query = '') { $url = self::UPDATE_URL . $query; if (($return = file_get_contents($url)) && ($return = JSON::decode($return))) { return $return; } }
/** * @brief 获取物流轨迹线路 * @param $ShipperCode string 物流公司代号 * @param $LogisticCode string 物流单号 * @return string array 轨迹数据 */ public function line($ShipperCode, $LogisticCode) { $params = array('ShipperCode' => $ShipperCode, 'LogisticCode' => $LogisticCode); $sendData = JSON::encode($params); $curlData = array('RequestData' => $sendData, 'EBusinessID' => $this->appid, 'RequestType' => '1002', 'DataType' => 2, 'DataSign' => base64_encode(md5($sendData . $this->appkey))); $result = $this->curlSend($this->getSubmitUrl(), $curlData); return $this->response(JSON::decode($result)); }
/** * Read config * * @return bool|mixed */ protected function loadCBData() { $json = new JSON(JSON_LOOSE_TYPE); $file = @file_get_contents(DOKU_PLUGIN . "custombuttons/config.json"); if (!$file) { return false; } return $json->decode($file); }
function authorstatsReadJSON() { $json = new JSON(JSON_LOOSE_TYPE); $file = @file_get_contents(DOKU_PLUGIN . "authorstats/authorstats.json"); if (!$file) { return array(); } return $json->decode($file); }
/** * @param string $data * @param string $headstr * @return \stdClass|false */ public function validate($data, $headstr) { sscanf($headstr, "sha1=%s", $headsig); if (hash_equals(hash_hmac('sha1', $data, self::$secret), $headsig)) { return \JSON::decode($data); } else { return false; } }
function showpageafterlogin_read_json() { $json = new JSON(JSON_LOOSE_TYPE); $file = @file_get_contents(DOKU_PLUGIN . "showpageafterlogin/showpageafterlogincount.json"); if (!$file) { return array(); } return $json->decode($file); }
/** * @param string $template */ public function __construct($template) { $setup = new File(HOME_DIR . '/templates/' . $template . '/setup.json'); if ($setup->exists()) { $this->data = \JSON::decode($setup->get()); } else { $this->data = new stdClass(); } }
private function loadCache() { if (!file_exists(self::$cache)) { return; } $cached = JSON::decode(file_get_contents(self::$cache)); $this->current = $cached['price']; $this->cacheTime = intval($cached['time']); }
/** * Retrieve the user's data * * The array needs to contain at least 'user', 'email', 'name' and optional 'grps' * * @return array */ public function getUser() { $JSON = new \JSON(JSON_LOOSE_TYPE); $data = array(); $result = $JSON->decode($this->oAuth->request('https://www.googleapis.com/oauth2/v1/userinfo')); $data['user'] = $result['name']; $data['name'] = $result['name']; $data['mail'] = $result['email']; return $data; }
/** * Retrieve the user's data * * The array needs to contain at least 'user', 'mail', 'name' and optional 'grps' * * @return array */ public function getUser() { $JSON = new \JSON(JSON_LOOSE_TYPE); $data = array(); $result = $JSON->decode($this->oAuth->request('https://kelder.zeus.ugent.be/oauth/api/current_user?format=json')); $data['user'] = $result['username']; $data['name'] = $result['username']; $data['mail'] = $result['username'] . '@zeus.ugent.be'; return $data; }
/** * Retrieve the user's data * * The array needs to contain at least 'user', 'email', 'name' and optional 'grps' * * @return array */ public function getUser() { $JSON = new \JSON(JSON_LOOSE_TYPE); $data = array(); $result = $JSON->decode($this->oAuth->request('me/guid')); $guid = $result['guid']['value']; $result = $JSON->decode($this->oAuth->request('users.guid(' . $guid . ')/profile')); foreach ($result['profiles']['profile'][0]['emails'] as $email) { if (isset($email['primary'])) { $data['mail'] = $email['handle']; break; } } $data['name'] = trim($result['profiles']['profile'][0]['givenName'] . ' ' . $result['profiles']['profile'][0]['familyName']); if (!$data['name']) { $data['name'] = $result['profiles']['profile'][0]['nickname']; } $data['user'] = $data['name']; return $data; }
/** * Retrieve the user's data * * The array needs to contain at least 'user', 'mail', 'name' and optional 'grps' * * @return array */ public function getUser() { $JSON = new \JSON(JSON_LOOSE_TYPE); $data = array(); /** var OAuth\OAuth2\Service\Generic $this->oAuth */ $result = $JSON->decode($this->oAuth->request('https://doorkeeper-provider.herokuapp.com/api/v1/me.json')); $data['user'] = '******' . $result['id']; $data['name'] = 'doorkeeper-' . $result['id']; $data['mail'] = $result['email']; return $data; }
public static function run($title, $key) { set_time_limit(0); $data = array("data" => $title, "respond" => "json", "ignore" => 'yes'); $data = http_build_query($data); $re = IFile::socket("http://www.ftphp.com/scws/api.php", 0, $data); if (!$re) { return array('words' => array()); } return JSON::decode($re); }
public function getUserInfo() { //获取用户信息的接口地址, 不要更改!! $url = "http://openapi.qzone.qq.com/user/get_user_info"; $info = $this->do_get($url, $this->apiId, $this->apiKey, ISession::get('token'), ISession::get('secret'), ISession::get('openid')); $arr = JSON::decode($info); $userInfo = array(); $userInfo['id'] = ISession::get('openid'); $userInfo['name'] = isset($arr['nickname']) ? $arr['nickname'] : ''; return $userInfo; }
function display() { global $app_strings, $current_user, $mod_strings, $theme, $beanList, $beanFiles; $smarty = new Sugar_Smarty(); $json = new JSON(); require_once 'include/JSON.php'; //Load the field list from the target module if (!empty($_REQUEST['targetModule']) && $_REQUEST['targetModule'] != 'undefined') { $module = $_REQUEST['targetModule']; if (isset($_REQUEST['package']) && $_REQUEST['package'] != 'studio' && $_REQUEST['package'] != '') { //Get the MB Parsers require_once 'modules/ModuleBuilder/MB/MBPackage.php'; $pak = new MBPackage($_REQUEST['package']); $defs = $pak->modules[$module]->getVardefs(); $fields = FormulaHelper::cleanFields(array_merge($pak->modules[$module]->getLinkFields(), $defs['fields'])); } else { $seed = BeanFactory::getBean($module); $fields = FormulaHelper::cleanFields($seed->field_defs); } $smarty->assign('Field_Array', $json->encode($fields)); } else { $fields = array(array('income', 'number'), array('employed', 'boolean'), array('first_name', 'string'), array('last_name', 'string')); $smarty->assign('Field_Array', $json->encode($fields)); } if (!empty($_REQUEST['targetField'])) { $smarty->assign("target", $_REQUEST['targetField']); } if (isset($_REQUEST['returnType'])) { $smarty->assign("returnType", $_REQUEST['returnType']); } //Assign any requested Javascript event actions foreach (array('onSave', 'onLoad', 'onClose') as $e) { if (!empty($_REQUEST[$e])) { $smarty->assign($e, html_entity_decode($_REQUEST[$e], ENT_QUOTES)); } else { $smarty->assign($e, 'function(){}'); } } //Check if we need to load Ext ourselves if (!isset($_REQUEST['loadExt']) || $_REQUEST['loadExt'] && $_REQUEST['loadExt'] != "false") { $smarty->assign('loadExt', true); } else { $smarty->assign('loadExt', false); } if (!empty($_REQUEST['formula'])) { $smarty->assign('formula', $json->decode(htmlspecialchars_decode($_REQUEST['formula']))); } if (isset($_REQUEST['returnType'])) { $smarty->assign('returnType', $_REQUEST['returnType']); } $smarty->assign('app_strings', $app_strings); $smarty->assign('mod', $mod_strings); $smarty->display('modules/ExpressionEngine/tpls/formulaBuilder.tpl'); }
/** * Retrieve the user's data * * The array needs to contain at least 'user', 'mail', 'name' and optional 'grps' * * @return array */ public function getUser() { $JSON = new \JSON(JSON_LOOSE_TYPE); $data = array(); /** var OAuth\OAuth2\Service\Generic $this->oAuth */ $result = $JSON->decode($this->oAuth->request($this->hlp->conf['custom-meurl'])); foreach (explode(" ", $this->hlp->conf['custom-mapping']) as $map) { $smap = explode("=", $map, 2); $data[$smap[0]] = $result[$smap[1]]; } return $data; }
public static function show_spec($specJson) { $specArray = JSON::decode($specJson); $spec = array(); foreach ($specArray as $val) { if ($val['type'] == 1) { $spec[$val['name']] = $val['value']; } else { $spec[$val['name']] = '<img src="' . IUrl::creatUrl() . $val['value'] . '" class="img_border" style="width:15px;height:15px;" />'; } } return $spec; }
function verifyNotify() { $is_notify = true; include_once ('llpay_cls_json.php'); $json = new JSON; $str = file_get_contents("php:/" . "/input"); $val = $json->decode($str); $oid_partner = getJsonVal($val,'oid_partner' ); $sign_type = getJsonVal($val,'sign_type' ); $sign = getJsonVal($val,'sign' ); $dt_order = getJsonVal($val,'dt_order' ); $no_order = getJsonVal($val,'no_order' ); $oid_paybill = getJsonVal($val,'oid_paybill' ); $money_order = getJsonVal($val,'money_order' ); $result_pay = getJsonVal($val,'result_pay' ); $settle_date = getJsonVal($val,'settle_date' ); $info_order = getJsonVal($val,'info_order'); $pay_type = getJsonVal($val,'pay_type' ); $bank_code = getJsonVal($val,'bank_code' ); $no_agree = getJsonVal($val,'no_agree' ); $id_type = getJsonVal($val,'id_type' ); $id_no = getJsonVal($val,'id_no' ); $acct_name = getJsonVal($val,'acct_name' ); if ($oid_partner != $this->llpay_config['oid_partner']) { return; } $parameter = array ( 'oid_partner' => $oid_partner, 'sign_type' => $sign_type, 'dt_order' => $dt_order, 'no_order' => $no_order, 'oid_paybill' => $oid_paybill, 'money_order' => $money_order, 'result_pay' => $result_pay, 'settle_date' => $settle_date, 'info_order' => $info_order, 'pay_type' => $pay_type, 'bank_code' => $bank_code, 'no_agree' => $no_agree, 'id_type' => $id_type, 'id_no' => $id_no, 'acct_name' => $acct_name ); if (!$this->getSignVeryfy($parameter, $sign)) { return; } $this->notifyResp = $parameter; $this->result = true; return true; }
/** * Retrieve the user's data * * The array needs to contain at least 'user', 'email', 'name' and optional 'grps' * * @return array */ public function getUser() { $JSON = new \JSON(JSON_LOOSE_TYPE); $data = array(); $result = $JSON->decode($this->oAuth->request('/me')); if (!empty($result['username'])) { $data['user'] = $result['username']; } else { $data['user'] = $result['name']; } $data['name'] = $result['name']; $data['mail'] = $result['email']; return $data; }
function fix_temp_data($data) { if (strlen($data) == 0) { return ""; } $data .= "}"; while (JSON::decode($data) === null) { // Remove last two characters $data = substr($data, 0, -2); // Add the end of the temperature data $data .= "}"; } return $data; }