Exemplo n.º 1
0
 /**
  * Dinamic error, if the error is not defined it generate one default
  */
 public function __call($name, $arguments)
 {
     // Dyanmic auto error
     $this->view = 'errors';
     // Important! No put this in __construct method or with "public $view = 'errors'" because it will be ignored by KWController constructor
     $this->error = Stringer::getStringBetween($name, 'e', '');
     $this->errorMessage .= $this->error;
 }
Exemplo n.º 2
0
 private function analizeProduct($html)
 {
     $name = trim(Stringer::getStringBetween($html, "<h1>", "</h1>", 0, ''));
     echo $name;
     if ($name != '') {
         $price = intval(trim(Stringer::getStringBetween($html, '<span class="price" data-price="', '  EUR')));
         $prodToSave = new MySQL();
         // Product exists?
         $prod = $prodToSave->doQuery("SELECT id FROM product WHERE url = '" . $this->tmp_data['url'] . "'")->nextRow();
         if (isset($prod['id']) and is_numeric($prod['id'])) {
             // UPDATE
             $query = "REPLACE product(id, id_category, website, url, item_p, price, tags)\n\t\t\t\tVALUES (" . $prod['id'] . ",\n\t\t\t\t\t" . $this->tmp_data['id_category'] . ",\n\t\t\t\t\t" . $this->tmp_data['id_website'] . ",\n\t\t\t\t\t'" . $this->tmp_data['url'] . "',\n\t\t\t\t\t'{$name}',\n\t\t\t\t\t{$price},\n\t\t\t\t\t'" . $this->tmp_data['tags'] . "'\n\t\t\t\t)";
         } else {
             // INSERT
             // Save products
             $query = "INSERT INTO product(id_category, website, url, item_p, price, tags)\n\t\t\t\tVALUES (" . $this->tmp_data['id_category'] . ",\n\t\t\t\t\t" . $this->tmp_data['id_website'] . ",\n\t\t\t\t\t'" . $this->tmp_data['url'] . "',\n\t\t\t\t\t'{$name}',\n\t\t\t\t\t{$price},\n\t\t\t\t\t'" . $this->tmp_data['tags'] . "'\n\t\t\t\t)";
         }
         // Executing query
         $prodToSave->doQuery($query);
     }
 }
Exemplo n.º 3
0
 public static function create($string = null)
 {
     @trigger_error('Class BCC\\EnumerableUtility\\String is deprecated. Please use BCC\\EnumerableUtility\\Stringer instead.', E_USER_DEPRECATED);
     return parent::create($string);
 }
Exemplo n.º 4
0
 /**
  * Generic function to read all links
  * @param unknown $html
  * @return unknown
  */
 protected function readAllLinks($html, $tagStart, $tagEnd)
 {
     $html = Stringer::getStringBetween($html, $tagStart, $tagEnd);
     preg_match_all('~<a.*?href="(.*?)".*?>~', $html, $matches);
     return $matches[1];
 }
Exemplo n.º 5
0
 /**
  * @name encode This function decode a file
  * @param string $file Full path to the file (without $source or $dest)
  */
 private function decode($file)
 {
     // Saving file in new file decodificated
     $data = file_get_contents($this->source . $file);
     // Only decode if it have '<?php eval(base64_decode'
     if (strpos($data, '<?php eval(base64_decode(') !== FALSE) {
         // obtaining text withouth eval and decode
         $data = base64_decode(Stringer::getStringBetween($data, '<?php eval(base64_decode("', '")); ?>'));
         // Recovering <?php
         $data = str_replace('/*-<?php-*/', '<?php', $data);
     }
     // Saving file (codified or uncodefied)
     file_put_contents($this->dest . $file, $data);
 }