function doInit() { if (Config::$pass == null) { Config::$pass = trim(file_get_contents(getenv("HOME") . '/.cluebotng.password.only')); } API::init(); API::$a->login(Config::$user, Config::$pass); Globals::$mysql = false; checkMySQL(); Globals::$tfas = 0; Globals::$stdin = fopen('php://stdin', 'r'); Globals::$run = API::$q->getpage('User:'******'/Run'); Globals::$wl = API::$q->getpage('Wikipedia:Huggle/Whitelist'); Globals::$optin = API::$q->getpage('User:'******'/Optin'); Globals::$aoptin = API::$q->getpage('User:'******'/AngryOptin'); Globals::$stalk = array(); Globals::$edit = array(); $tmp = explode("\n", API::$q->getpage('User:'******'/CBAutostalk.js')); foreach ($tmp as $tmp2) { if (substr($tmp2, 0, 1) != '#') { $tmp3 = explode('|', $tmp2, 2); Globals::$stalk[$tmp3[0]] = trim($tmp3[1]); } } $tmp = explode("\n", API::$q->getpage('User:'******'/CBAutoedit.js')); foreach ($tmp as $tmp2) { if (substr($tmp2, 0, 1) != '#') { $tmp3 = explode('|', $tmp2, 2); Globals::$edit[$tmp3[0]] = trim($tmp3[1]); } } }
function api_zbp_load_pre() { // Check URL first global $bloghost; global $apiRealRouteUrl; global $zbp; $requestUri = str_replace('index.php?', '', GetVars('HTTP_HOST', 'SERVER') . GetVars('REQUEST_URI', 'SERVER')); $removedHttpHost = preg_replace('/^http.+\\/\\//', '', $bloghost) . 'zb_system/api/'; $apiRealRouteUrl = str_replace($removedHttpHost, '', $requestUri); // Now we know that this is API Request, so remove Cookie. // The verification shoule be in API Route. //$_COOKIE['username'] = ""; //$_COOKIE['password'] = ""; API::init(); }
$this->mysqli = new mysqli(self::DB_SERVER, self::DB_USER, self::DB_PASSWORD, self::DB); } private function parseQuery($query) { $r = $this->mysqli->query($query) or die($this->mysqli->error . __LINE__); if ($r->num_rows > 0) { $result = array(); while ($row = $r->fetch_assoc()) { $result[] = $row; } $this->response($this->jsonify($result), 200); } $this->response("", 204); } // API Functions private function login() { $this->check_request_method(); $query = "SELECT u.* FROM users u"; $this->parseQuery($query); } private function getClients() { $this->check_request_method(); $query = "SELECT c.*, e.employeeNumber, e.lastName AS 'em_lastName', e.firstName AS 'em_firstName', e.email AS 'em_email',\r\n\t\t\t\t\to.city AS 'o_city',\r\n\t\t\t\t\tps.*,\r\n\t\t\t\t\tos.*\r\n\t\t\t\tFROM customers c\r\n\t\t\t\tLEFT JOIN employees e ON e.employeeNumber = c.salesRepEmployeeNumber\r\n\t\t\t\tLEFT JOIN offices o ON o.officeCode = e.officeCode\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t(SELECT p.customerNumber AS p_customerNumber,\r\n\t\t\t\t\t\tGROUP_CONCAT(p.checkNumber) AS p_checks,\r\n\t\t\t\t\t\tGROUP_CONCAT(CONVERT(p.paymentDate, CHAR(16))) AS p_dates,\r\n\t\t\t\t\t\tGROUP_CONCAT(CONVERT(p.amount, CHAR(16))) AS p_amounts\r\n\t\t\t\t\t\tFROM payments p GROUP BY p.customerNumber) ps\r\n\t\t\t\t\tON ps.p_customerNumber = c.customerNumber\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t(SELECT o.customerNumber AS o_customerNumber,\r\n\t\t\t\t\t\tGROUP_CONCAT(CONVERT(o.orderNumber, CHAR(16))) AS o_orders,\r\n\t\t\t\t\t\tGROUP_CONCAT(CONVERT(o.orderDate, CHAR(16))) AS o_orderDates,\r\n\t\t\t\t\t\tGROUP_CONCAT(CONVERT(o.requiredDate, CHAR(16))) AS o_requiredDates,\r\n\t\t\t\t\t\tGROUP_CONCAT(CONVERT(o.shippedDate, CHAR(16))) AS o_shippedDates,\r\n\t\t\t\t\t\tGROUP_CONCAT(o.status) AS o_statuses,\r\n\t\t\t\t\t\tGROUP_CONCAT(o.comments) AS o_comments\r\n\t\t\t\t\t\tFROM orders o GROUP BY o.customerNumber) os\r\n\t\t\t\t\tON os.o_customerNumber = c.customerNumber"; $this->parseQuery($query); } } $api = new API(); $api->init();
<?php require_once __DIR__ . '/../API.php'; API::init(); if (!Config::get("realtime.enabled")) { http_response_code(403); API::printJSON(array('error' => 'Realtime disabled')); } try { $ts3 = new Ts3ServerQuery(Config::get("realtime.host"), Config::get("realtime.port", 10011), Config::get("realtime.username", "serveradmin"), Config::get("realtime.password")); $users = RealtimeUsers::getOnlineUsers($ts3); $channels = RealtimeChannels::getChannels($ts3); } catch (Exception $e) { http_response_code(500); API::printJSON(array('error' => 'Boh...')); } API::printJSON(RealtimeFormatter::getRealtime($users, $channels));
<?php /** * This is the main initiation file for the API. * * LICENSE: MIT (http://opensource.org/licenses/mit-license.html) * * @category XboxLeaders * @package XboxLiveAPI * @copyright Copyright (c) 2012 - 2014 XboxLeaders * @license http://xboxleaders.github.io/license/ MIT License * @version 2.0 * @link http://github.com/XboxLeaders/XboxLiveAPI * @since File available since Release 1.0 */ include 'classes/api.class.php'; $api = new API($cache); if (isset($_GET['callback']) && !empty($_GET['callback'])) { $api->format = 'jsonp'; $api->callback = preg_replace('/(<.*>)|(.*;)/g', '', $_GET['callback']); } else { $api->format = isset($_GET['format']) && in_array($_GET['format'], array('xml', 'json', 'php')) ? strtolower(trim($_GET['format'])) : 'json'; } $api->version = '2.0'; $api->debug = isset($_GET['debug']); $api->cookie_file = COOKIE_FILE; $api->debug_file = DEBUG_FILE; $api->stack_trace_file = STACK_TRACE_FILE; $api->init(XBOX_EMAIL, XBOX_PASSWORD);
<?php /* * 功 能: API启动文件,将调用所需API * 作 者: 刘海艇 * 修改日期: 2013-06-22 */ error_reporting(E_ERROR); include_once "api.config.php"; include_once "api.class.php"; include_once "api.functions.php"; include_once 'api.returnCode.php'; $api = API::init(); //token验证 if (!empty($_GET["echostr"])) { $api->check(); } //消息回复 $api->responseMsg();