Пример #1
0
 private function dwn($page = 1)
 {
     $data = array("pageIndex" => $page, "track" => true);
     $dataString = json_encode($data);
     $referer = 'http://www.centris.ca/fr/';
     $ip = '65.39.160.111';
     $ch = curl_init();
     $headers = array();
     $url = 'http://www.centris.ca/Services/PropertyService.asmx/GetPropertyViews';
     $userAgent = 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.6 (KHTML, like Gecko) Chrome/16.0.897.0 Safari/535.6';
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);
     // curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     curl_setopt($ch, CURLOPT_AUTOREFERER, false);
     curl_setopt($ch, CURLOPT_REFERER, 'http://www.centris.ca/fr');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_VERBOSE, true);
     curl_setopt($ch, CURLOPT_HEADER, true);
     $headers[] = "REMOTE_ADDR: {$ip}";
     $headers[] = "HTTP_X_FORWARDED_FOR: {$ip}";
     $headers[] = 'Cookie: ASP.NET_SessionId=gtxmbdtwbalnpvmcecg5mojf; path=/; HttpOnly';
     $headers[] = 'Cookie: Centris=Token=bc5b5528-9766-4291-b72a-c8c9c445d01c&Lang=fr&Reg=PROVPROVQC&PropertySearchView=List&PromotionVersion=0&PromotionPopupShownCount=2; domain=centris.ca; expires=Sun, 15-Jun-2014 13:33:24 GMT; path=/';
     $headers[] = 'Cookie: Centris.PropertySearchFavorites=; domain=centris.ca; expires=Sun, 15-Jun-2014 13:33:24 GMT; path=/';
     $headers[] = 'Cookie: Centris.PropertySearchRemoved=; domain=centris.ca; expires=Sun, 15-Jun-2014 13:33:24 GMT; path=/';
     $headers[] = 'Cookie: Centris.BrokerSearchFavorites=; domain=centris.ca; expires=Sun, 15-Jun-2014 13:33:24 GMT; path=/';
     $headers[] = 'Content-Type: application/json';
     $headers[] = 'Content-Length: ' . strlen($dataString);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     $result = curl_exec($ch);
     dieDump($result);
 }
Пример #2
0
 public function all()
 {
     $this->waitUnlock();
     $data = container()->redis()->get($this->dbName);
     dieDump($data);
     $data = strlen($data) ? $this->id(json_decode($data, true)) : array();
     return $data;
 }
Пример #3
0
 /**
  * @param array $content
  */
 public function arrayToXml($content)
 {
     $parentNode = $this->_getCurrentDom();
     if (!$content || !count($content)) {
         return $this;
     }
     foreach ($content as $_key => $_item) {
         try {
             $node = $this->getDom()->createElement($_key);
         } catch (\DOMException $e) {
             //  echo $e->getMessage();
             dieDump($_item);
         }
         $parentNode->appendChild($node);
         if (is_array($_item) && isset($_item['_attribute'])) {
             if (is_array($_item['_value'])) {
                 if (isset($_item['_value'][0])) {
                     foreach ($_item['_value'] as $_k => $_v) {
                         $this->_setCurrentDom($node)->arrayToXml($_v);
                     }
                 } else {
                     $this->_setCurrentDom($node)->arrayToXml($_item['_value']);
                 }
             } else {
                 $child = $this->getDom()->createTextNode($_item['_value']);
                 $node->appendChild($child);
             }
             foreach ($_item['_attribute'] as $_attributeKey => $_attributeValue) {
                 $node->setAttribute($_attributeKey, $_attributeValue);
             }
         } elseif (is_string($_item)) {
             $text = $this->getDom()->createTextNode($_item);
             $node->appendChild($text);
         } elseif (is_array($_item) && !isset($_item[0])) {
             $this->_setCurrentDom($node)->arrayToXml($_item);
         } elseif (is_array($_item) && isset($_item[0])) {
             foreach ($_item as $k => $v) {
                 $this->_setCurrentDom($node)->arrayToXml(array($this->_getIndexedArrayItemName() => $v));
             }
         }
     }
     return $this;
 }
Пример #4
0
 /**
  * Execute a command against the Redis database.
  *
  * <code>
  *      // Execute the GET command for the "name" key
  *      $name = Redis::db()->run('get', array('name'));
  *
  *      // Execute the LRANGE command for the "list" key
  *      $list = Redis::db()->run('lrange', array(0, 5));
  * </code>
  *
  * @param  string  $method
  * @param  array   $parameters
  * @return mixed
  */
 public function run($method, $parameters)
 {
     dieDump($method);
     fwrite($this->connect(), $this->command($method, (array) $parameters));
     $response = trim(fgets($this->connect()));
     return $this->parse($response);
 }
Пример #5
0
 private function makeTab($rows)
 {
     if (!empty($rows)) {
         $keyCache = sha1('tabDB_' . serialize($rows) . $this->entity);
         $cached = $this->cached($keyCache);
         if (empty($cached)) {
             $tab = array();
             $first = true;
             foreach ($rows as $row) {
                 if (!is_object($row)) {
                     dieDump($rows);
                 }
                 $row = $row->toArray();
                 if (true === $first) {
                     $tab['id'] = $row['thin_eav_entity_id'];
                 }
                 $attribute = $this->dbAttribute()->find($row['thin_eav_attribute_id'])->getName();
                 $value = $this->dbValue()->find($row['thin_eav_value_id'])->getName();
                 $tab[$attribute] = json_decode($value, true);
                 $first = false;
             }
             $this->cached($keyCache, $tab);
             return $tab;
         }
         return $cached;
     }
 }