public function updateMail() { $id = $this->rcpt; $http = new Http(); $url = "http://services.ukrposhta.com/barcodesingle/default.aspx?ctl00%24centerContent%24scriptManager=ctl00%24centerContent%24scriptManager%7Cctl00%24centerContent%24btnFindBarcodeInfo&__EVENTTARGET=&__EVENTARGUMENT=&ctl00%24centerContent%24txtBarcode={$id}&__ASYNCPOST=true&ctl00%24centerContent%24btnFindBarcodeInfo=%D0%9F%D0%BE%D1%88%D1%83%D0%BA"; $data = $http->http_request(array('url' => $url, 'cookie' => true, 'redirect' => true)); $page = split("\n", $data); $print = 0; foreach ($page as $line) { if ($print) { $result = strip_tags($line) . "\n"; $print = 0; } if (strstr("{$line}", "divInfo")) { if (strstr("{$line}", "</div>")) { $result = strip_tags($line) . "\n"; } else { $print = 1; } } } if (strstr($result, "вручене за довіреністю")) { $this->ddate = date("Y-m-d", strtotime(mb_substr(strstr($result, "вручене за довіреністю "), 23, 10, 'UTF-8'))); $this->status = 1; $this->update(); } elseif (strstr($result, "вручене адресату (одержувачу) особисто")) { $this->ddate = date("Y-m-d", strtotime(mb_substr(strstr($result, "особисто "), 9, 10, 'UTF-8'))); $this->status = 1; $this->update(); } else { return 0; } }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ try { $Customer = new CustomerModel(); $verifEmail = $Customer->sameMail($formFields['Email']); if ($verifEmail && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && $formFields['password2'] == $formFields['password'] && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) { $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day']; //var_dump($Birthdate); $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']); //var_dump($Customer_id); $user = $Customer->findCustomer($Customer_id); $UserSession = new UserSession(); $UserSession->create($user); $http->redirectTo(''); } else { $http->redirectTo('Exception?Error=3'); } } catch (DomainException $event) { $form = new RegisterForm(); $form->bind($formFields); $form->setErrorMessage($event->getMessage()); return ['_form' => $form]; } }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ /*var_dump($formFields['bookingDate']); var_dump($date); var_dump($date > $formFields['bookingDate']); die();*/ $date = new DateTime(); $userSession = new UserSession(); $bookingModel = new BookingModel(); $customerId = intval($userSession->getId()); if ($userSession->isAuthenticated()) { $customerId = intval($userSession->getId()); $checkBookingById = $bookingModel->checkBookingById($customerId, intval($formFields['bookingId']), $formFields['bookingDate']); if (ctype_digit($formFields['bookingId']) && $date < new DateTime($formFields['bookingDate']) && $checkBookingById) { $bookingModel->DeletBooking($formFields['bookingId']); $flashBag = new FlashBag(); $flashBag->add('Réservation ' . $formFields["bookingId"] . ' bien supprimée'); $http->redirectTo('/'); } $flashBag = new FlashBag(); $flashBag->add('Problème lors de la suppression de la réservation (Vous ne pouvez supprimer des réservations posterieur à aujourd\'hui)'); $http->redirectTo('/Booking'); } }
public function httpGetMethod(Http $http, array $queryFields) { /* * Méthode appelée en cas de requête HTTP GET * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $queryFields contient l'équivalent de $_GET en PHP natif. */ //var_dump(intval($queryFields['produit_id'])); if (array_key_exists('produit_id', $queryFields)) { if (ctype_digit($queryFields['produit_id'])) { $meal = new MealModel(); $listMeal = $meal->find(intval($queryFields['produit_id'])); if ($listMeal) { return ['listMeal' => $listMeal]; } else { $http->redirectTo('Exception?Error=1'); } } else { $http->redirectTo('Exception?Error=2'); } } else { $http->redirectTo('Exception?Error=2'); //'On ne hack pas mon site !!!!!!!!!!!!!!!!', 'Image' => 'http://iletaitungeek.com/wp-content/uploads/2015/08/dark-vador-aura-sa-ps4-collector-une.jpg']; } }
function refresh($force = false) { // How often to check for updates $interval = $this->hook->apply('product_info_refresh_interval', 60 * 60 * 12); if (!$force && isset($this->data['last_refresh']) && $this->data['last_refresh'] > time() - $interval) { return false; } $http = new Http($this->config, $this->hook, $this->router); $response = $http->get($this->config->leeflets_api_url . '/product-info?slugs=core'); if (Error::is_a($response)) { return $response; } if ((int) $response['response']['code'] < 200 || (int) $response['response']['code'] > 399) { return new Error('product_info_refresh_fail_http_status', 'Failed to refresh product info from leeflets.com. Received response ' . $response['response']['code'] . ' ' . $response['response']['message'] . '.', $response); } if (!($response_data = json_decode($response['body'], true))) { return new Error('product_info_refresh_fail_json_decode', 'Failed to refresh product info from leeflets.com. Error decoding the JSON response received from the server.', $response['body']); } $this->data = array(); $this->data['last_refresh'] = time(); $this->data['products'] = $response_data; $this->write(); $this->load(); return true; }
public function testGetParameters() { $_SERVER['REQUEST_METHOD'] = 'GET'; $_GET['captain'] = 'kirk'; $request = new Http(); $this->assertEquals('kirk', $request->getParameter('captain')); }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ $userSession = new UserSession(); if ($userSession->isAdminAuthenticated() == false) { $http->redirectTo('/'); } //var_dump($formFields); //var_dump($_FILES); if (array_key_exists('Modification', $formFields)) { if ($http->hasUploadedFile('Photo')) { $pathinfo = $http->moveUploadedFile('Photo', '/images/meals'); var_dump($pathinfo); $mealModel = new MealModel(); $mealModel->modifyPicture($pathinfo, $formFields['Id']); } $mealModel = new MealModel(); $result = $mealModel->modifyMeal($formFields['Name'], $formFields['Description'], $formFields['QuantityInStock'], $formFields['BuyPrice'], $formFields['SalePrice'], $formFields['Id']); $http->redirectTo('/Admin/List'); } elseif (ctype_digit($formFields['meal_Id'])) { $mealModel = new MealModel(); $meal = $mealModel->find($formFields['meal_Id']); return ['meal' => $meal]; } }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ /*$date = new DateModel(); var_dump($date->testDate($formFields['dateResa'])); //0 FAUX - 1 VRAI REJEX */ $userSession = new UserSession(); if ($userSession->isAuthenticated()) { $dateTime = date_create($formFields['dateResa'] . ' ' . $formFields['timeResa']); $now = new DateTime("now"); $resaDate = date_format($dateTime, 'Y-m-d'); $resaTime = date_format($dateTime, 'H:i:s'); //var_dump($formFields); if (!empty($formFields['dateResa']) && !empty($formFields['timeResa']) && !empty($formFields['NumberOfSeats']) && $dateTime > $now && ctype_digit($formFields['NumberOfSeats'])) { $userId = $userSession->getId(); $Booking = new BookingModel(); $resultat = $Booking->register($userId, $resaDate, $resaTime, $formFields['NumberOfSeats']); return ['resultat' => $resultat]; } elseif ($dateTime < $now) { return ['Error' => 'Nous ne pouvons vous réserver une table pour une date antérieur à aujourd\'hui']; } else { return ['Error' => 'Un champ n\'a pas était remplie correctement']; } } else { echo 'lu'; die; $http->redirectTo('/'); } }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ $Customer = new CustomerModel(); $verifEmail = $Customer->sameMail($formFields['Email']); //var_dump(strlen($_POST['Phone'])); //var_dump(strlen($_POST['ZipCode'])); if ($verifEmail['result'] === '0' && ctype_digit($formFields['Year']) && ctype_digit($formFields['Month']) && ctype_digit($formFields['Day']) && ctype_digit($formFields['Phone']) && strlen($formFields['Phone']) === 10 && ctype_digit($formFields['ZipCode']) && strlen($formFields['ZipCode']) === 5 && isset($formFields['password']) && isset($formFields['Email']) && filter_var($formFields['Email'], FILTER_VALIDATE_EMAIL) != false) { $password = password_hash($formFields['password'], PASSWORD_DEFAULT); //var_dump($password); $Birthdate = $formFields['Year'] . '-' . $formFields['Month'] . '-' . $formFields['Day']; //var_dump($Birthdate); $Customer_id = $Customer->registerCustomer($formFields['FirstName'], $formFields['LastName'], $Birthdate, $formFields['Phone'], $formFields['Address'], $formFields['Address2'], $formFields['City'], $formFields['ZipCode'], $formFields['Email'], $formFields['password']); //var_dump($Customer_id); $user = $Customer->findCustomer($Customer_id); $UserSession = new UserSession(); $UserSession->create($user); $http->redirectTo(''); } elseif ($verifEmail != '0') { $http->redirectTo('Exception?Error=3'); } }
function isNewBrowscapVersion() { if (!isset($_SESSION['user_browscap_version'])) { $_SESSION['user_browscap_version'] = getCurrentBrowscapRelease(); } if (!isset($_SESSION['server_browscap_version'])) { $server_browscap_version = ""; if (extension_loaded('soap')) { $http = new Http(); $http->setTimeout(2); $http->execute("http://www.website-php.com/en/webservices/wsp-information-server.wsdl?wsdl"); $wsdl = $http->getResult(); if ($wsdl != "" && find($wsdl, "<?xml", 1) > 0) { $client = new WebSitePhpSoapClient("http://www.website-php.com/en/webservices/wsp-information-server.wsdl?wsdl"); $server_browscap_version = $client->getBrowscapVersionNumber(); } } else { /*$http = new Http(); $http->setTimeout(2); $http->execute("http://browsers.garykeith.com/versions/version-number.asp"); $server_browscap_version = $http->getResult();*/ $server_browscap_version = ""; } if (trim($server_browscap_version) != "") { $_SESSION['server_browscap_version'] = $server_browscap_version; } } if (trim($_SESSION['user_browscap_version']) != trim($_SESSION['server_browscap_version'])) { return trim($_SESSION['server_browscap_version']); } return false; }
/** * * @return AddOn[] */ public function all() { $path = $this->_config->merchantPath() . '/add_ons'; $response = $this->_http->get($path); $addOns = ["addOn" => $response['addOns']]; return Util::extractAttributeAsArray($addOns, 'addOn'); }
public function httpGetMethod(Http $http, array $queryFields) { if (isset($_GET['logout']) && $_GET['logout'] == 'out') { $userSession = new UserSession(); $userSession->destroy(); $http->redirectTo('/'); } }
public function actionGetAddress() { header('Access-Control-Allow-Origin: *'); $lat = $_POST['lat']; $lng = $_POST['lng']; $uri = "http://maps.googleapis.com/maps/api/geocode/json?latlng={$lat},{$lng}&language=uk&sensor=false"; $r = new Http(); echo $r->http_request($uri); }
/** * 上传媒体文件. * * @param string $path * * @return string */ public function upload($path) { if (!file_exists($path) || !is_readable($path)) { throw new Exception("文件不存在或不可读 '{$path}'"); } $options = array('files' => array('media' => $path)); $contents = $this->http->post(self::API_UPLOAD, array(), $options); return $contents['url']; }
/** * 获取jsticket * * @return string */ public function getTicket() { $key = 'overtrue.wechat.jsapi_ticket' . $this->appId; return $this->cache->get($key, function ($key) { $http = new Http(new AccessToken($this->appId, $this->appSecret)); $result = $http->get(self::API_TICKET); $this->cache->set($key, $result['ticket'], $result['expires_in']); return $result['ticket']; }); }
/** * 获取颜色列表 * * @return array */ public function lists() { $key = 'overtrue.wechat.colors'; return $this->cache->get($key, function ($key) { $result = $this->http->get(self::API_LIST); $this->cache->set($key, $result['colors'], 86400); // 1 day return $result['colors']; }); }
function post_func($url, $params, $files) { $http = new Http($this->key); if ($http->upload($url, $params, $files)) { //var_export($http->get_data()); return json_decode($http->get_data(), true); } else { return array('result' => false, 'error' => 7.1); } }
public function httpGetMethod(Http $http, array $queryFields) { /* * Méthode appelée en cas de requête HTTP GET * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $queryFields contient l'équivalent de $_GET en PHP natif. */ $http->refreshTo(10, ''); return ['Error' => $queryFields['Error']]; }
public function httpGetMethod(Http $http, array $queryFields) { /* * Méthode appelée en cas de requête HTTP GET * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $queryFields contient l'équivalent de $_GET en PHP natif. */ $userSession = new UserSession(); if ($userSession->isAdminAuthenticated() == false) { $http->redirectTo('/'); } }
public function uploadIndexPic() { if (!$_FILES) { $this->ReportError('请选择文件'); } if ($this->settings['App_publishsys']) { $postFields = array('a' => 'uploadIndexPic', 'file' => $_FILES, 'request' => 'admin/magic_update.php'); $objHttp = new Http($this->settings['App_publishsys']['host'], $this->settings['App_publishsys']['dir']); $hgDataReturn = $objHttp->http($postFields); echo json_encode($hgDataReturn); } else { $this->ReportError('此系统未安装'); } }
private static function trans($message, $mode) { $http = new Http(); $http->vars("v", $mode); $http->vars("text", $message); if (Tag::setof($tag, $http->do_post("http://lou5.jp/")->body(), "body")) { foreach ($tag->in('p') as $p) { if ($p->inParam("class") == "large align-left box") { $message = $p->value(); } } } return $message; }
public function download() { import('ORG.Net.Http'); header("Content-Type:text/html;charset=UTF-8"); $title = I('get.title'); $file_dir = './Public/upload/'; $Resource = D('Resource'); $map['id'] = I('get.id'); $list = $Resource->where($map)->order('id desc')->find(); $name = $list['content']; $filename = $file_dir . $name; $download = new Http(); $download->download($filename, $showtitle); }
/** * 获取Token * * @return string */ public function getToken() { if ($this->token) { return $this->token; } $thisObj = $this; return $this->cache->get($this->cacheKey, function () use($thisObj) { $params = array('appid' => $thisObj->appId, 'secret' => $thisObj->appSecret, 'grant_type' => 'client_credential'); $http = new Http(); $token = $http->get($thisObj::API_TOKEN_GET, $params); $thisObj->cache->set($thisObj->cacheKey, $token['access_token'], $token['expires_in']); return $thisObj->token = $token['access_token']; }); }
/** * * @param string $settlement_date * @param string $groupByCustomField * @return SettlementBatchSummary|Result\Error */ public function generate($settlement_date, $groupByCustomField = NULL) { $criteria = ['settlement_date' => $settlement_date]; if (isset($groupByCustomField)) { $criteria['group_by_custom_field'] = $groupByCustomField; } $params = ['settlement_batch_summary' => $criteria]; $path = $this->_config->merchantPath() . '/settlement_batch_summary'; $response = $this->_http->post($path, $params); if (isset($groupByCustomField)) { $response['settlementBatchSummary']['records'] = $this->_underscoreCustomField($groupByCustomField, $response['settlementBatchSummary']['records']); } return $this->_verifyGatewayResponse($response); }
/** * 完善daemon处理函数,此函数必备 * * */ function daemonFunc() { require dirname(__FILE__) . '/../../config/testUI/config.php'; $redis = new Predis\Client($_config['redis_server']); $http = new Http(); while ($this->subProcessCheck()) { //处理队列 $case_data = $redis->lpop($_config['queue_name']); if (empty($case_data)) { break; } else { $arr = json_decode($case_data, true); $url = $arr['host'] . $arr['url']; $query = $arr['param']; $method = strtoupper($arr['method']); //拼装表单提交数据 $formdata = array(); $temp_arry = explode('&', $query); foreach ($temp_arry as $item) { list($k, $v) = explode('=', $item); $formdata[$k] = $v; } //判断是否需要token if (isset($arr['token'])) { $formdata['token'] = $arr['token']; } if ($method == 'GET') { $http->get($url, $formdata); } else { $http->post($url, $formdata); } $res = $http->getContent(); //此处增加返回结果的判断 $result = $arr['result']; if ($result == $res) { $res_test = 1; } else { $res_test = 0; } // $req['url'] = $url; // $req['data'] = $formdata; //$result =array(); file_put_contents(realpath(dirname(__FILE__)) . '/../../output/testUI.log', $res_test . '|' . $result . '|' . $res . '|' . $url . '|' . json_encode($formdata) . "\n", FILE_APPEND); } //增加处理数,不增加处理数,就需要子进程本身有退出机制。 //$this->requestCount++; //释放时间片 usleep(5000); } }
public function httpPostMethod(Http $http, array $formFields) { $dateTime = date_create($formFields['resaDate']); $resaDate = date_format($dateTime, 'Y-m-d'); //var_dump($_POST, $resaDate); $booking = new Database(); $userSession = new UserSession(); $userId = $userSession->getId(); //var_dump($userId); if (ctype_digit($userId)) { $bookingList = $booking->queryOne('SELECT COUNT(Id) AS count FROM Booking WHERE Customer_Id = ? AND BookingDate = ?', [$userId, $resaDate]); /*var_dump(json_encode($bookingList['count']));*/ $http->sendJsonResponse($bookingList); } }
public function httpPostMethod(Http $http, array $formFields) { /* * Méthode appelée en cas de requête HTTP POST * * L'argument $http est un objet permettant de faire des redirections etc. * L'argument $formFields contient l'équivalent de $_POST en PHP natif. */ $userSession = new UserSession(); if ($userSession->isAuthenticated() == false) { $http->redirectTo('/User/Login'); } //TODO : API BANCAIRE $http->redirectTo('/Order/Payment/Success'); }
/** * Efetua a requisição de um arquivo ao servidor. * * @param string * * @return string Arquivo ou link para o arquivo */ public function download($filename = null) { $http = new Http(); list($file, $info, $header) = $http->httpRequest("http://legendas.tv/downloadarquivo/{$this->id}"); if ($filename === null) { preg_match('/Location: http:\\/\\/f\\.legendas\\.tv\\/\\w+\\/(.*)/', $header, $filename); // O formato abaixo é o nome de retorno do arquivo do legendas.tv, que não diz muita coisa $filename = trim($filename[1]); // Alteramos para o nome de arquivo refletir o nome completo da legenda $filename = $this->data['arquivo'] . substr($filename, strrpos($filename, '.')); } $filename = str_replace(array('/', '\\'), '_', $filename); file_put_contents($filename, $file); return $filename; }
public function request($request_type, $request_info, $network_ids, $backfill) { /*F:START*/ error_reporting(0); /*Catch XML Exceptions*/ global $zone_detail; $httpConfig['method'] = 'POST'; $httpConfig['timeout'] = '1'; $http = new Http(); $http->initialize($httpConfig); if ($request_type == 'banner') { $request_url = 'http://rq.vserv.mobi/delivery/adapi.php?'; $http->addParam('zoneid', $network_ids['p_1']); $http->addParam('vr', '1.1.0-phpcurl-20100726'); $http->addParam('ml', 'xhtml'); $http->addParam('ip', $request_info['ip_address']); $http->addParam('ru', urlencode($request_info['referer'])); $http->addParam('ua', $request_info['user_agent']); $http->addParam('tm', false); } else { return false; } $http->execute($request_url); if ($http->error) { return false; } if (preg_match("/href='([^']*)'/i", $http->result, $regs)) { $tempad['url'] = $regs[1]; } else { if (preg_match('/href="([^"]*)"/i', $http->result, $regsx)) { $tempad['url'] = $regsx[1]; } else { return false; } } $ad = array(); $ad['main_type'] = 'display'; $ad['type'] = 'markup'; $ad['click_url'] = $tempad['url']; $ad['html_markup'] = $http->result; $ad['trackingpixel'] = ''; $ad['image_url'] = ''; $ad['clicktype'] = 'safari'; $ad['skipoverlay'] = 0; $ad['skippreflight'] = 'yes'; return $ad; /*F:END*/ }
protected function getExternalData() { global $wgCityId; // Prevent recursive loop if ($wgCityId == self::EXTERNAL_DATA_SOURCE_WIKI_ID) { return array(); } if (self::$externalData === false) { global $wgLang, $wgMemc; $code = $wgLang->getCode(); $key = wfSharedMemcKey('user-command-special-page', 'lang', $code); $data = $wgMemc->get($key); if (empty($data)) { $data = array(); $external = Http::get($this->getExternalDataUrl($code)); $external = json_decode($external, true); if (is_array($external) && !empty($external['allOptions']) && is_array($external['allOptions'])) { foreach ($external['allOptions'] as $option) { $data[$option['id']] = $option; } } $wgMemc->set($key, $data, self::EXTERNAL_DATA_CACHE_TTL); } self::$externalData = $data; } return self::$externalData; }