public function __construct(array $options) { $this->name = $options['name']; $this->client = isset($options['client']) ? $options['client'] : Client::getInstance(); $this->segments = 'collection/' . $this->name; $this->reset(); }
public function onReceive($serv, $fd, $from_id, $rdata) { $client = Client::getInstance($fd); $data = $client->cryptor->decrypt($rdata); Trace::debug("\n\n\n\n" . str_repeat('#', 20) . "\nquerytimes:" . ++$this->querytimes . "\n" . str_repeat('#', 20) . "\n=======================\nonReceive {$from_id} : {$fd} lenght:" . strlen($data) . " content:\n=======================\n" . substr($data, 0, 50) . "...\n======================="); if (false === $client->hasInit()) { $header = Sock5::parseHeader($data); if (!$header) { return $serv->close($fd); } $client->init($header['addr']); if (strlen($data) > $header['length']) { $data = substr($data, $header['length']); $client->send($data); } swoole_async_dns_lookup($header['addr'], function ($host, $ip) use($header, $client, $fd) { Trace::debug("dnslookup >{$fd}, {$host}, {$ip} "); $client->connect(ip2long($ip), $header['port']); }); } else { $client->send($data); } }
/** * @return the exchange rates */ public static function getExchangeRates() { return Client::getInstance()->get_xrate(); }
/** * Returm Client class instance * * @return Client */ public static function Client() { return Client::getInstance(); }
/** * @return the result of deleting a user from a merchant account */ public static function deleteMerchantUser($token, $merchant_id, $user_id) { $client = Client::getInstance($token); $result = $client->api->merchant_users->deleteMerchantUser($merchant_id, $user_id); if ($result === FALSE) { throw new Exception($client->getError()); } else { return $result; } }
<?php require_once "res/utils.php"; session_start(); $res = Client::installResult(); if (!isset($_SESSION["client"])) { $_SESSION["client"] = Client::getInstance(); session_write_close(); } if (isset($_POST["logorsign"]) && isset($_POST["usernametxt"]) && isset($_POST["userpasstxt"])) { $client = $_SESSION["client"]; if ($_POST["logorsign"] == 'log') { $res = $client->authenticate($_POST["usernametxt"], $_POST["userpasstxt"], $_POST["keeplogged"]); if ($res["code"] == Client::CODE_SUCCESS) { header("Location: panel.php"); } } elseif (isset($_POST["usercnfmtxt"]) && ($_POST["logorsign"] = 'sign')) { $res = $client->signup($_POST["usernametxt"], $_POST["userpasstxt"], $_POST["usercnfmtxt"]); } } elseif (isset($_REQUEST["signout"]) && $_REQUEST["signout"] == "true" && session_status() != PHP_SESSION_NONE) { $_SESSION = array(); $_COOKIE = array(); Client::removeLoggedinSettings(); session_destroy(); session_write_close(); header("Location: index.php"); } elseif (isset($_COOKIE['logged_in_flag'])) { if ($_SESSION["client"]->verifyKeepLogged($_COOKIE['logged_in_flag'])) { header("Location: panel.php"); } }
$loader = new \AutoloaderPsr4(); $loader->register(); $loader->addNamespace('BudgetMailer\\Api', PHP_BM_ROOT . 'src/BudgetMailer/Api'); # # 2. GET CONFIGURATION (also optional, you may use Client::getInstance(array $config)) # $configFile = __DIR__ . '/config.php'; $configData = (include $configFile); unset($configFile); if (!is_array($configData) || !count($configData)) { die('Config not found.'); } # # 3. a) INITIATE CLIENT as singleton # $client = Client::getInstance(array('key' => '', 'list' => '', 'secret' => '')); // later you can get client again without config param # # 3. b) INITIATE CLIENT # $config = new Config($configData); unset($configData); $cache = new Cache($config); $client = new Client($cache, $config); # # 4. GET ALL LISTS # $lists = $client->getLists(); //var_dump($lists); # #