public function analyze()
 {
     if (!Storage::getInstance()->containsPage($this->url)) {
         $title = $this->getDom()->getElementsByTagName("title")->item(0)->textContent;
         Storage::getInstance()->addPage($title, $this->url);
     }
 }
 public function analyze()
 {
     if (!Storage::getInstance()->containsImage($this->url)) {
         if ($this->isValid()) {
             Storage::getInstance()->addImage($this->url);
         }
     }
 }
Esempio n. 3
0
 public static function __callstatic($method, $args)
 {
     if (self::$handler === null) {
         Storage::getInstance(C('STORAGE_DRIVER', null, 'file'));
     }
     //调用缓存驱动的方法
     if (method_exists(self::$handler, $method)) {
         return call_user_func_array(array(self::$handler, $method), $args);
     }
 }
Esempio n. 4
0
 public function __construct()
 {
     $this->session = Session::getInstance();
     $this->log = Log::getInstance();
     $this->user = User::getInstance();
     $this->storage = Storage::getInstance();
     $this->webDBUtils = WebDBUtils::getInstance();
     $this->dpUtils = DataProviderUtils::getInstance();
     $this->screen = false;
     $this->availableFeatures = false;
 }
Esempio n. 5
0
 /**
  * Do Search
  *
  * @var $title_array
  * @var $url_array
  * @var $description_array
  *
  * ! REDIRECT
  */
 private function actionSearch()
 {
     $this->actionGetLanguage();
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     $sql_stmt = $mysqli->prepare("set names 'utf8'");
     $sql_stmt->execute();
     if (isset($_GET['generalnav'])) {
         $search = $_GET['generalnav'];
         $sql_query = "SELECT * FROM search WHERE description LIKE '%{$search}%' ORDER BY CHAR_LENGTH(description) DESC";
         $result = $mysqli->query($sql_query);
         $title_array = array();
         $url_array = array();
         $description_array = array();
         if ($result->num_rows > 0) {
             while ($row = $result->fetch_assoc()) {
                 array_push($title_array, $row['title']);
                 array_push($url_array, $row['url']);
                 array_push($description_array, $row['description']);
             }
         }
         $this->model->setTitle($title_array);
         $this->model->setUrl($url_array);
         $this->model->setDescription($description_array);
         $this->model->setCountResults($result->num_rows);
         if (isset($_GET['page'])) {
             if ($this->model->getCountPages() != 0) {
                 if ($_GET['page'] > $this->model->getCountPages()) {
                     if ($_SESSION['language'] !== 'us') {
                         header("Location: /" . $_SESSION['language'] . "/search/result?generalnav=" . $_GET['generalnav'] . "&page=" . $this->model->getCountPages());
                     } else {
                         header("Location: /search/result?generalnav=" . $_GET['generalnav'] . "&page=" . $this->model->getCountPages());
                     }
                 } elseif ($_GET['page'] < 1) {
                     if ($_SESSION['language'] !== 'us') {
                         header("Location: /" . $_SESSION['language'] . "/search/result?generalnav=" . $_GET['generalnav'] . "&page=1");
                     } else {
                         header("Location: /search/result?generalnav=" . $_GET['generalnav'] . "&page=1");
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
0
 function createTokenRoute($dummy, $description)
 {
     $this->description = trim($description);
     $this->message = null;
     $this->errorMessage = null;
     if (strlen($this->description) < 1) {
         $this->errorMessage = l("Enter a valid description");
     } else {
         $tokenHash = sha1(sha1(sprintf("%d,%s,%d", time(), $this->description, rand())));
         $storage = Storage::getInstance();
         if (!$storage->addWelcomeToken($tokenHash, $this->description, $this->user)) {
             $this->errorMessage = l("Error generating a new token. Try again");
         } else {
             $this->message = l("Token successfully created");
             $this->description = null;
         }
     }
 }
Esempio n. 7
0
 /**
  * Adding Billing Data to the DB
  * @var $table : billing
  */
 private function actionInsertBillingData()
 {
     $this->actionGetLanguage();
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     session_start();
     if (isset($_SESSION['login_user'])) {
         $user = $_SESSION['login_user'];
     }
     if (isset($_POST['name'])) {
         $name = $_POST['name'];
     }
     if (isset($_POST['street'])) {
         $street = $_POST['street'];
     }
     if (isset($_POST['city'])) {
         $city = $_POST['city'];
     }
     if (isset($_POST['state'])) {
         $state = $_POST['state'];
     }
     if (isset($_POST['zip'])) {
         $zip = $_POST['zip'];
     }
     if (isset($_POST['country'])) {
         $country = $_POST['country'];
     }
     if (isset($_POST['giftwrap'])) {
         $giftwrap = $_POST['giftwrap'];
     } else {
         $giftwrap = 0;
     }
     if (isset($name) && isset($street) && isset($city) && isset($state) && isset($zip) && isset($country) && isset($giftwrap) && isset($user)) {
         $sql_query = $mysqli->prepare("INSERT INTO billing VALUES ('{$user}', '{$name}', '{$street}', '{$city}', '{$state}', '{$zip}', '{$country}',\n                                          {$giftwrap})");
         $sql_query->execute();
     } else {
         header('HTTP/1.0 403 Forbidden');
     }
 }
Esempio n. 8
0
 function completedRoute($feedsJson)
 {
     $this->feeds = json_decode($feedsJson, true);
     if ($this->feeds === false) {
         $this->redirectTo("import");
         return;
     }
     $this->selection = $_POST["selection"];
     if (!$this->selection || !is_array($this->selection)) {
         $this->selection = array();
     }
     if (($this->errorMessage = $this->isSelectionValid($this->feeds, $this->selection)) !== true) {
         $this->setTemplate("selectFeeds");
     } else {
         $storage = Storage::getInstance();
         $this->rowsImported = $storage->importFeeds($this->user->id, $this->feeds, $this->selection);
         if ($this->rowsImported === false) {
             $this->errorMessage = l("An error occurred while importing feeds");
             $this->setTemplate("selectFeeds");
             return;
         }
     }
 }
Esempio n. 9
0
 public function SubmittedPatientAdd(AppForm $form)
 {
     Storage::getInstance()->createPatient($form->values);
     Graphs::model()->clearAll();
     $this->flashMessage('Novy pacient bol úspešne pridaný', 'info');
     $this->redirect('default');
     // redirect to listing
 }
Esempio n. 10
0
 /**
  * Get Default Billing Data
  * for Account
  *
  * @var $name
  * @var $street
  * @var $city
  * @var $state
  * @var $zip
  * @var $country
  * @var $wrap
  */
 protected function actionGetBilling()
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     if (isset($_SESSION['login_user'])) {
         $user = $_SESSION['login_user'];
     }
     $sql_query = "SELECT name, street, city, state, zip, country, wrap FROM billing WHERE user='******'";
     $result = $mysqli->query($sql_query);
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             $name = $row['name'];
             $street = $row['street'];
             $city = $row['city'];
             $state = $row['state'];
             $zip = $row['zip'];
             $country = $row['country'];
             $wrap = $row['wrap'];
         }
     }
     if ($result->num_rows !== 0) {
         $this->model->setBillingName($name);
         $this->model->setBillingStreet($street);
         $this->model->setBillingCity($city);
         $this->model->setBillingState($state);
         $this->model->setBillingZip($zip);
         $this->model->setBillingCountry($country);
         $this->model->setBillingWrap($wrap);
         $this->model->setBillingNotFound(0);
     } else {
         $this->model->setBillingNotFound(1);
     }
 }
Esempio n. 11
0
 /**
  * Getting Data of Order
  *
  * (items) Sum, quantity, original_name, shipping, photo, price
  * category
  */
 private function actionGetOrderedItems()
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     if (isset($_GET['order_number'])) {
         $order_number = $_GET['order_number'];
     }
     if (isset($_GET['order_email'])) {
         $order_email = $_GET['order_email'];
     }
     if ($this->model->getStatus() == 'done') {
         $status = 'doneorders';
     } else {
         if ($this->model->getStatus() == 'wait') {
             $status = 'completeorders';
         }
     }
     if (isset($status)) {
         $sql_stmt = "SELECT product_table, id FROM {$status} WHERE order_id='{$order_number}'";
         $result_stmt = $mysqli->query($sql_stmt);
         $product_table_array = array();
         $id_array = array();
         if ($result_stmt->num_rows > 0) {
             while ($row = $result_stmt->fetch_assoc()) {
                 $product_table_array = array_merge($product_table_array, array_map('trim', explode(",", $row['product_table'])));
                 $id_array = array_merge($id_array, array_map('trim', explode(",", $row['id'])));
             }
         }
         $i = 0;
         $original_name_array = array();
         $photo_array = array();
         $shipping_array = array();
         $price_array = array();
         $category_array = array();
         $product_name_array = array();
         while ($i < count($id_array)) {
             $sql_query = "SELECT {$product_table_array[$i]}.original_name, {$product_table_array[$i]}.photo, {$product_table_array[$i]}.shipping,\n                              {$status}.price, {$status}.category, {$status}.id, {$product_table_array[$i]}.product_name FROM\n                              {$product_table_array[$i]} INNER JOIN {$status} WHERE {$status}.id = {$product_table_array[$i]}.id AND {$status}.id = {$id_array[$i]}\n                              AND {$status}.order_id = '{$order_number}' LIMIT 1";
             $result = $mysqli->query($sql_query);
             if ($result->num_rows > 0) {
                 while ($row = $result->fetch_assoc()) {
                     $original_name_array = array_merge($original_name_array, array_map('trim', explode(",", $row['original_name'])));
                     $photo_array = array_merge($photo_array, array_map('trim', explode(",", $row['photo'])));
                     $shipping_array = array_merge($shipping_array, array_map('trim', explode(",", $row['shipping'])));
                     $price_array = array_merge($price_array, array_map('trim', explode(",", $row['price'])));
                     $category_array = array_merge($category_array, array_map('trim', explode(",", $row['category'])));
                     $product_name_array = array_merge($product_name_array, array_map('trim', explode(",", $row['product_name'])));
                 }
             }
             $i++;
         }
         $count_price = 0;
         $i = 0;
         while ($i < count($category_array)) {
             if ($category_array[$i] == 'AppleTV' || $category_array[$i] == 'IMac') {
                 $category_array[$i] = 'Apple';
             } else {
                 if ($category_array[$i] == 'ShowTop') {
                     $category_array[$i] = 'Amazon';
                 }
             }
             $count_price += $price_array[$i];
             $i++;
         }
         $this->model->setId($id_array);
         $this->model->setTable($product_table_array);
         $this->model->setOriginalName($original_name_array);
         $this->model->setPhoto($photo_array);
         $this->model->setShipping($shipping_array);
         $this->model->setPrice($price_array);
         $this->model->setCategory($category_array);
         $this->model->setProductName($product_name_array);
         $this->model->setCountItems($original_name_array);
         $this->model->setCountPrice($count_price);
     }
 }
Esempio n. 12
0
 function action_index()
 {
     $posts = Storage::getInstance()->read_posts();
 }
Esempio n. 13
0
 /**
  * Method for deleting data from
  * Products page
  *
  * @var $id
  *
  * ! REDIRECTION
  */
 public function actionDeleteData()
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     if (isset($_POST['edit_id'])) {
         $id = $_POST['edit_id'];
     }
     $sql_stmt = $mysqli->prepare("DELETE FROM phones WHERE id='{$id}'");
     $sql_stmt->execute();
     header('Location: admin-products');
 }
Esempio n. 14
0
 function action_delete($id)
 {
     Storage::getInstance()->removeData($id);
     header('Location: /blog');
 }
Esempio n. 15
0
    $url = $page->getBody();
    echo "Scanning: {$url}\n";
    $scanner = new WebScanner($url);
    $links = $scanner->getAllLinks();
    foreach ($links as $link) {
        /**
         * Если страница относится к указанному домену и еще не была проиндексирована -- добавляем ее в очередь на индексацию
         */
        if (strpos($link, $domain) !== FALSE && !Storage::getInstance()->containsPage($link)) {
            $queue->publish($link, 'scan');
        }
    }
    /**
     * Также если на странице есть картинки добавляем их для анализа
     */
    $images = $scanner->getAllImages();
    foreach ($images as $image) {
        /**
         * Если картинка относится к указанному домену и еще не была проанализирована -- добавляем ее в очередь
         */
        if (strpos($image, $imageDomain) !== FALSE && !Storage::getInstance()->containsImage($image)) {
            $queue->publish($image, 'analyze_image');
        }
    }
    /**
     * Текущую страницу тоже в очередь для анализации
     */
    $queue->publish($url, 'analyze_page');
    $q->ack($page->getDeliveryTag());
}
$rabbit->disconnect();
Esempio n. 16
0
 /**
  * Return list of images in graphs storage directory
  * Also generates missing graphs
  *
  * @return array
  */
 public function getGraphs()
 {
     // see what graphs are needed
     $fields = Storage::getInstance()->getStoredFields();
     foreach ($fields as $field => $props) {
         if (in_array('graph', $props['classes'])) {
             $grapedhProps[] = $field;
         }
     }
     $iterator = 0;
     do {
         $iterator++;
         if ($iterator > 3) {
             throw new AbortException('Generating of missing graphs failed!');
         }
         // get list of already generated graphs
         $imageFiles = $this->getGeneratedGraphs();
         $alreadyGenerated = array_intersect($grapedhProps, $imageFiles);
         $needToGenerate = array_diff($grapedhProps, $alreadyGenerated);
         foreach ($needToGenerate as $file) {
             $this->generateGraph($file);
         }
     } while (!empty($needToGenerate));
     return $imageFiles;
 }
Esempio n. 17
0
 /**
  * Search method for Selling
  * page for adding items in your Cart
  * Products page
  *
  * @param $category
  *
  * @var $timer
  * @var $min
  * @var $max
  * @var $sort_by_price
  * @var $sort_by_time
  * @var $sort_by_shipping
  *
  * Getting DATA
  *
  * @var $result
  * @var $product_name_array
  * @var $photo_array
  * @var $description_array
  * @var $category_array
  * @var $price_array
  * @var $previous_price_array
  * @var $time_of_adding_array
  * @var $features_array
  * @var $id_array
  * @var $quantity_array
  * @var $shipping_array
  * @var $average_price_array
  *
  * ! REDIRECT
  */
 private function actionGetCategories($category, $table, $sort)
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     $_SESSION['status'] = 0;
     if ($category == 'Phones') {
         $sql_query = "SELECT * FROM phones";
     } else {
         if ($category == 'Notebooks') {
             $sql_query = "SELECT * FROM notebooks";
         } else {
             if ($category == 'Television') {
                 $sql_query = "SELECT * FROM television";
             } else {
                 if ($category == 'Gadgets') {
                     $sql_query = "SELECT * FROM gadgets";
                 } else {
                     $sql_query = "SELECT * FROM " . strtolower($table) . " WHERE category='{$category}'";
                     $_SESSION['status'] = 1;
                 }
             }
         }
     }
     $timer = 0;
     $array = array();
     while ($timer < 11) {
         if (isset($_GET['selected_item_' . $timer])) {
             array_push($array, $_GET['selected_item_' . $timer]);
         }
         $timer++;
     }
     if (isset($_GET['min'])) {
         $min = $_GET['min'];
     }
     if (isset($_GET['max'])) {
         $max = $_GET["max"];
     }
     if (isset($_GET['sort_by_price'])) {
         $sort_by_price = $_GET["sort_by_price"];
     }
     if (isset($_GET['sort_by_time'])) {
         $sort_by_time = $_GET["sort_by_time"];
     }
     if (isset($_GET['sort_by_shipping'])) {
         $sort_by_shipping = $_GET["sort_by_shipping"];
     }
     if ((isset($min) || isset($max)) && count($array) === 0) {
         if ($min == '' && $max == '') {
         } else {
             if ($_SESSION['status'] == 1) {
                 $sql_query .= ' AND';
             } else {
                 $sql_query .= ' WHERE';
             }
         }
     }
     if (isset($array)) {
         if (count($array) !== 0) {
             if ($_SESSION['status'] == 1) {
                 $sql_query .= ' AND';
             } else {
                 $sql_query .= ' WHERE';
             }
         }
     }
     if (isset($array)) {
         if (count($array) !== 0) {
             $i = 0;
             $sql_query .= '(';
             while ($i < count($array)) {
                 $sql_query .= " product_name='" . $array[$i] . "' OR ";
                 $i++;
             }
         }
         if (count($array) !== 0) {
             $sql_query = substr($sql_query, 0, -3);
             if (isset($min) || isset($max)) {
                 if ($min !== '' || $max !== '') {
                     $sql_query .= ") AND";
                 }
             }
         }
         if (count($array) === 1 && !isset($max) && !isset($min)) {
             $sql_query .= ')';
         }
         if (isset($max) && isset($min)) {
             if ($max == '' && $min == '' && count($array) !== 0) {
                 $sql_query .= ')';
             }
         }
     }
     if (isset($min) && isset($max)) {
         if ($min !== '') {
             $sql_query .= " (price > " . $min;
             if (isset($max)) {
                 if ($max !== '') {
                     $sql_query .= " AND";
                 }
             }
         }
     }
     if (isset($max)) {
         if ($max === '') {
         } else {
             $sql_query .= " price < " . $max;
         }
         if (isset($min) && $min !== '') {
             $sql_query .= ' )';
         }
     }
     $order_array = array();
     if (isset($sort_by_price)) {
         array_push($order_array, $sort_by_price);
     }
     if (isset($sort_by_time)) {
         array_push($order_array, $sort_by_time);
     }
     if (isset($sort_by_shipping)) {
         array_push($order_array, $sort_by_shipping);
     }
     if (isset($sort_by_price) || isset($sort_by_time) || isset($sort_by_shipping)) {
         $sql_query .= " ORDER BY ";
         if (count($order_array) === 3) {
             $sql_query .= $order_array[0] . ", " . $order_array[1] . ", " . $order_array[2];
         }
         if (count($order_array) === 2) {
             $sql_query .= $order_array[0] . ", " . $order_array[1];
         }
         if (count($order_array) === 1) {
             $sql_query .= $order_array[0];
         }
     }
     $result = $mysqli->query($sql_query);
     $product_name_array = array();
     $original_name_array = array();
     $photo_array = array();
     $description_array = array();
     $category_array = array();
     $price_array = array();
     $previous_price_array = array();
     $time_of_adding_array = array();
     $features_array = array();
     $id_array = array();
     $quantity_array = array();
     $shipping_array = array();
     $average_price_array = array();
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             $id_array = array_merge($id_array, array_map('trim', explode(",", $row['id'])));
             $product_name_array = array_merge($product_name_array, array_map('trim', explode(",", $row['product_name'])));
             $original_name_array = array_merge($original_name_array, array_map('trim', explode(",", $row['original_name'])));
             $photo_array = array_merge($photo_array, array_map('trim', explode(",", $row['photo'])));
             $description_array = array_merge($description_array, array_map('trim', explode(",", $row['description'])));
             $category_array = array_merge($category_array, array_map('trim', explode(",", $row['category'])));
             $price_array = array_merge($price_array, array_map('trim', explode(",", $row['price'])));
             $previous_price_array = array_merge($previous_price_array, array_map('trim', explode(",", $row['previous_price'])));
             $time_of_adding_array = array_merge($time_of_adding_array, array_map('trim', explode(",", $row['time_of_adding'])));
             $features_array = array_merge($features_array, array_map('trim', explode(",", $row['features'])));
             $quantity_array = array_merge($quantity_array, array_map('trim', explode(",", $row['quantity'])));
             $shipping_array = array_merge($shipping_array, array_map('trim', explode(",", $row['shipping'])));
             $average_price_array = array_merge($average_price_array, array_map('trim', explode(",", $row['average_price'])));
         }
         $all_product_names = array();
         if ($sort === 'All') {
             $sql_num = "SELECT DISTINCT product_name FROM " . strtolower($table);
         } else {
             $sql_num = "SELECT DISTINCT product_name FROM " . strtolower($table) . " WHERE category='{$sort}'";
         }
         $result_num = $mysqli->query($sql_num);
         $num = $result_num->num_rows;
         if ($result_num->num_rows > 0) {
             while ($row = $result_num->fetch_assoc()) {
                 $all_product_names = array_merge($all_product_names, array_map('trim', explode(",", $row['product_name'])));
             }
         }
         $amount_array = array($num);
         $g = 0;
         while ($g < $num) {
             $amount_array[$all_product_names[$g]] = 0;
             $g++;
         }
         array_shift($amount_array);
         $k = 0;
         while ($k < count($product_name_array)) {
             if (isset($min) && (!isset($max) || $max == '') && $min !== '') {
                 $amount_sql = "SELECT COUNT(*) as amount FROM " . strtolower($table) . " WHERE product_name='{$product_name_array[$k]}' AND price > {$min}";
             } else {
                 if ((!isset($min) || $min == '') && isset($max) && $max !== '') {
                     $amount_sql = "SELECT COUNT(*) as amount FROM " . strtolower($table) . " WHERE product_name='{$product_name_array[$k]}' AND price < {$max}";
                 } else {
                     if (isset($max) && isset($min) && $max !== '' && $min !== '') {
                         $amount_sql = "SELECT COUNT(*) as amount FROM " . strtolower($table) . " WHERE product_name='{$product_name_array[$k]}' AND price > {$min} AND price < {$max}";
                     } else {
                         $amount_sql = "SELECT COUNT(*) as amount FROM " . strtolower($table) . " WHERE product_name='{$product_name_array[$k]}'";
                     }
                 }
             }
             $result_sql = $mysqli->query($amount_sql);
             if ($result_sql->num_rows > 0) {
                 while ($row = $result_sql->fetch_assoc()) {
                     $amount = $row['amount'];
                     $amount_array[$product_name_array[$k]] = $amount;
                 }
             }
             $k++;
         }
         $result_products = array();
         foreach ($amount_array as $num => $ass) {
             array_push($result_products, $ass);
         }
         $this->model->setNoDataFound(0);
         $this->model->setProductName($product_name_array);
         $this->model->setOriginalName($original_name_array);
         $this->model->setPhoto($photo_array);
         $this->model->setDescription($description_array);
         $this->model->setCategory($category_array);
         $this->model->setPrice($price_array);
         $this->model->setPreviousPrice($previous_price_array);
         $this->model->setTimeOfAdding($time_of_adding_array);
         $this->model->setFeatures($features_array);
         $this->model->setId($id_array);
         $this->model->setQuantity($quantity_array);
         $this->model->setShipping($shipping_array);
         $this->model->setAverage($average_price_array);
         $this->model->setQuantityOfItems($result_products);
     } else {
         $this->model->setNoDataFound(1);
     }
     if (isset($_GET['page'])) {
         $uri_parts = explode('?', $_SERVER['REQUEST_URI'], 2);
         if ($this->model->getPages() != 0) {
             if ($_GET['page'] > $this->model->getPages()) {
                 header('Location: ' . $uri_parts[0] . '?page=' . $this->model->getPages());
             } elseif ($_GET['page'] < 1) {
                 header('Location: ' . $uri_parts[0] . '?page=1');
             }
         }
     }
 }
Esempio n. 18
0
 /**
  * Getting Questions and Answers
  * associated to the related product
  *
  * Finding any matches up.
  *
  * Any word that length bigger than 2
  *
  * @var $ask_person_array
  * @var $last_question_array
  * @var $last_answer_array
  * @var $answer_person_array
  * @var $created_array
  *
  * @param $original_name
  *
  * ! REDIRECT
  *
  */
 public function actionGetQuestionsAndAnswers($original_name)
 {
     $this->actionGetLanguage();
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     $items = explode(" ", $original_name);
     $u = 0;
     while ($u < count($items)) {
         if (strlen($items[$u]) < 3 || strtolower($items[$u]) == 'with') {
             unset($items[$u]);
         }
         $u++;
     }
     sort($items);
     $result_items = array();
     $i = 0;
     while ($i < count($items)) {
         $sql_id = "SELECT id FROM questions WHERE product LIKE '%{$items[$i]}%' OR question LIKE '%{$items[$i]}%' OR answer LIKE '%{$items[$i]}%'";
         $res_id = $mysqli->query($sql_id);
         if ($res_id->num_rows > 0) {
             // output data of each row
             while ($row = $res_id->fetch_assoc()) {
                 $result_items = array_merge($result_items, array_map('trim', explode(",", $row['id'])));
             }
         }
         $i++;
     }
     $unique_result_items = array_unique($result_items);
     if (count($unique_result_items) == 0) {
         $this->model->setNoItems('1');
         //echo '1';
     } else {
         $this->model->setNoItems('0');
     }
     if (count($unique_result_items) !== 0) {
         sort($unique_result_items);
         /*
          * FROM ID
          * GETTING DATA
          */
         $products_array = array();
         $ask_person_array = array();
         $question_array = array();
         $answer_array = array();
         $answer_person_array = array();
         $created_array = array();
         $i = 0;
         $count_of_result_items = count($unique_result_items);
         while ($i < $count_of_result_items) {
             $sql_query = "SELECT product, ask_person, question, answer, answer_person, unix_timestamp(created) as created FROM questions WHERE id={$unique_result_items[$i]}";
             $result_query = $mysqli->query($sql_query);
             if ($result_query->num_rows > 0) {
                 // output data of each row
                 while ($row = $result_query->fetch_assoc()) {
                     array_push($products_array, $row['product']);
                     array_push($ask_person_array, $row['ask_person']);
                     array_push($question_array, $row['question']);
                     array_push($answer_array, $row['answer']);
                     array_push($answer_person_array, $row['answer_person']);
                     array_push($created_array, $row['created']);
                 }
             }
             $i++;
         }
         /*
          * items - array()
          * question - array()
          */
         $found_question_array_non = array();
         $i = 0;
         while ($i < count($question_array)) {
             $u = 0;
             $k = 0;
             while ($k < count($question_array)) {
                 $item[$k] = strtolower($question_array[$k]);
                 $k++;
             }
             while ($u < count($items)) {
                 $j = 0;
                 while ($j < count($items)) {
                     $items[$j] = strtolower($items[$j]);
                     $j++;
                 }
                 $item = str_replace("{$items[$u]}", "<span id='found'>{$items[$u]}</span>", $item, $count);
                 $s = 0;
                 while ($s < count($items)) {
                     $items_lc[$s] = ucfirst($items[$s]);
                     $s++;
                 }
                 $item = str_replace("<span id='found'>{$items[$u]}</span>", "<span id='found'>{$items_lc[$u]}</span>", $item, $count);
                 $m = 0;
                 while ($m < count($item)) {
                     $item[$m] = ucfirst($item[$m]);
                     $m++;
                 }
                 $u++;
             }
             array_push($found_question_array_non, $item);
             $i++;
         }
         $found_question_array = $found_question_array_non[0];
         $count_question_array = array();
         $i = 0;
         while ($i < count($question_array)) {
             $string = str_replace("<span id='found'>", "", $found_question_array[$i], $count);
             array_push($count_question_array, $count);
             $i++;
         }
         $found_answer_array_non = array();
         $i = 0;
         while ($i < count($answer_array)) {
             $u = 0;
             $item = $answer_array;
             while ($u < count($items)) {
                 $item = str_replace("{$items[$u]}", "<span id='found'>{$items[$u]}</span>", $item, $count);
                 $u++;
             }
             array_push($found_answer_array_non, $item);
             $i++;
         }
         $found_answer_array = $found_answer_array_non[0];
         $count_answer_array = array();
         $i = 0;
         while ($i < count($answer_array)) {
             $string = str_replace("<span id='found'>", "", $found_answer_array[$i], $count);
             array_push($count_answer_array, $count);
             $i++;
         }
         $result_q_and_a = array();
         $i = 0;
         while ($i < count($count_question_array)) {
             $result_q_and_a[$i] = $count_question_array[$i] + $count_answer_array[$i];
             $i++;
         }
         $last_question_array = array();
         $last_answer_array = array();
         $i = 0;
         $count_q_and_a = count($result_q_and_a);
         while ($i < $count_q_and_a) {
             $max = max($result_q_and_a);
             $key = array_search($max, $result_q_and_a);
             array_push($last_question_array, $found_question_array[$key]);
             array_push($last_answer_array, $found_answer_array[$key]);
             unset($result_q_and_a[$key]);
             $i++;
         }
         $this->model->setAskPerson($ask_person_array);
         $this->model->setQuestion($last_question_array);
         $this->model->setAnswer($last_answer_array);
         $this->model->setAnswerPerson($answer_person_array);
         $this->model->setAnswerTime($created_array);
         if (isset($_GET['page'])) {
             if ($this->model->countPages() != 0) {
                 if ($_GET['page'] > $this->model->countPages()) {
                     if (isset($_GET['q'])) {
                         if ($_SESSION['language'] !== 'us') {
                             header('Location: /' . $_SESSION['language'] . '/FAQ/?q=' . $_GET['q'] . '&page=' . $this->model->countPages());
                         } else {
                             header('Location: /FAQ/?q=' . $_GET['q'] . '&page=' . $this->model->countPages());
                         }
                     }
                 } else {
                     if ($_GET['page'] < 1) {
                         if (isset($_GET['q'])) {
                             if ($_SESSION['language'] !== 'us') {
                                 header('Location: /' . $_SESSION['language'] . '/FAQ/?q=' . $_GET['q'] . '&page=1');
                             } else {
                                 header('Location: /FAQ/?q=' . $_GET['q'] . '&page=1');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 19
0
 protected function missingAdminAccounts()
 {
     $storage = Storage::getInstance();
     $adminCount = $storage->getAdminCount();
     return $adminCount !== false && $adminCount < 1;
 }
Esempio n. 20
0
 public function SubmittedGraphsSettings(AppForm $form)
 {
     Storage::getInstance()->saveGraphsSettings($form->values);
     $this->flashMessage('Parametre grafov boli úspešne uložené', 'info');
     $this->redirect('default');
 }
Esempio n. 21
0
                  </div>
                  <div class="form-group">
                    <label for="comment">Comment:</label>
                    <textarea class="form-control" rows="5" id="comment" name="content"></textarea>
                  </div>
                  <input type="submit" value="Post" class="btn btn-primary-outline btn-sm">
                </form>
              </div>
            </div>
            <div class="col-md-4">

            </div>

          </div>
          <?php 
$posts = Storage::getInstance()->read_data();
foreach ($posts as $p) {
    ?>
            <div class="row">
              <div class="col-md-3">

              </div>
              <div class="col-md-7">
                <div class="container">
                  <div class="post">
                    <h3><?php 
    echo nl2br($p->get_title());
    ?>
</h3>
                    <h6><em>Published: <?php 
    echo $p->get_date();
Esempio n. 22
0
 private function shouldThrottleLogin()
 {
     if (LOGIN_THROTTLING_WINDOW === false) {
         return false;
     }
     // Get number of recent failed logins
     $storage = Storage::getInstance();
     $failedLogin = $storage->getFailedLoginStatistics($_SERVER["REMOTE_ADDR"], LOGIN_THROTTLING_WINDOW);
     if ($failedLogin == null) {
         return false;
     }
     if ($failedLogin->failedLoginCount < 2) {
         return false;
     }
     $delay = pow(2, $failedLogin->failedLoginCount - 2);
     return time() < $failedLogin->lastFailedAttempt + $delay;
 }
Esempio n. 23
0
function uploadProfileImage()
{
    $session = Session::getInstance();
    $user = User::getInstance();
    $storage = Storage::getInstance();
    $upload = Upload::getInstance();
    $res = $upload->writeProfileImage();
    $err = false == $res ? '' : $session->flushError();
    $res = false == $res ? 'false' : $res;
    $res = array('req' => 'profileImageUpload', 'res' => $res);
    return $res;
}
Esempio n. 24
0
 function defaultRoute()
 {
     $storage = Storage::getInstance();
     return array("allItems" => $storage->getUserFeeds($this->user));
 }
Esempio n. 25
0
 /**
  * Getting Data from Done Orders
  * id, original_name, category, price, quantity, table
  *
  * Photo from Product Table
  * Doing multi-array with associations like a[1][n] has k items in row
  * print them all -> go next
  */
 private function getDoneOrders()
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     if (isset($_SESSION['login_user'])) {
         $user = $_SESSION['login_user'];
         /*
          * GETTING DATA FOR EACH ORDER ( COMPLETED )
          */
         $complete_id = array();
         $complete_original_name = array();
         $complete_category = array();
         $complete_price = array();
         $complete_quantity = array();
         $complete_product_table = array();
         $i = 0;
         while ($i < count($this->model->getDoneOrderIds())) {
             $sql_stmt = "SELECT id, product_name, category, price, quantity, product_table FROM doneorders WHERE order_id='{$this->model->getDoneOrderIdsIteration($i)}'";
             $sql_result = $mysqli->query($sql_stmt);
             if ($sql_result->num_rows > 0) {
                 // output data of each row
                 while ($row = $sql_result->fetch_assoc()) {
                     array_push($complete_id, $row['id']);
                     array_push($complete_original_name, $row['product_name']);
                     array_push($complete_category, $row['category']);
                     array_push($complete_price, $row['price']);
                     array_push($complete_quantity, $row['quantity']);
                     array_push($complete_product_table, $row['product_table']);
                 }
             }
             $i++;
         }
         /**
          * GETTING PHOTOS FOR EACH
          * PRODUCT FOR THE ORDER
          * ******* COMPLETE ORDERS TABLE *****
          */
         $complete_photo = array();
         $complete_product_name = array();
         $k = 0;
         while ($k < count($complete_original_name)) {
             $sql_stmt = "SELECT photo, product_name FROM {$complete_product_table[$k]} WHERE id='{$complete_id[$k]}'";
             $sql_result = $mysqli->query($sql_stmt);
             if ($sql_result->num_rows > 0) {
                 // output data of each row
                 while ($row = $sql_result->fetch_assoc()) {
                     array_push($complete_photo, $row['photo']);
                     array_push($complete_product_name, $row['product_name']);
                 }
             }
             $k++;
         }
         /*
          * COUNTING OF EACH ORDER
          */
         $complete_order_count = array();
         $k = 0;
         while ($k < count($this->model->getDoneOrderIds())) {
             $sql_stmt = "SELECT COUNT(*) as items FROM doneorders WHERE order_id='{$this->model->getDoneOrderIdsIteration($k)}'";
             $sql_result = $mysqli->query($sql_stmt);
             if ($sql_result->num_rows > 0) {
                 // output data of each row
                 while ($row = $sql_result->fetch_assoc()) {
                     array_push($complete_order_count, $row['items']);
                 }
             }
             $k++;
         }
         /*
          * DIVIDING ARRAY FOR MULTI ONE
          * ACCORDING TO QUANTITY
          * OF ITEMS FOR EACH ORDER
          * ******* COMPLETE ORDER TABLE ********
          */
         $final_complete_id = array();
         $final_complete_product_tables = array();
         $final_complete_order = $this->model->getDoneOrderIds();
         $final_complete_original_name = array();
         $final_complete_product_name = array();
         $final_complete_category = array();
         $final_complete_price = array();
         $final_complete_quantity = array();
         $final_complete_photo = array();
         $complete_count = count($complete_order_count);
         $i = 0;
         while ($i < $complete_count) {
             $complete_id_for_each = array_splice($complete_id, 0, $complete_order_count[$i]);
             array_push($final_complete_id, $complete_id_for_each);
             $complete_product_tables_for_each = array_splice($complete_product_table, 0, $complete_order_count[$i]);
             array_push($final_complete_product_tables, $complete_product_tables_for_each);
             $complete_original_name_for_each = array_splice($complete_original_name, 0, $complete_order_count[$i]);
             array_push($final_complete_original_name, $complete_original_name_for_each);
             $complete_product_name_for_each = array_splice($complete_product_name, 0, $complete_order_count[$i]);
             array_push($final_complete_product_name, $complete_product_name_for_each);
             $complete_category_for_each = array_splice($complete_category, 0, $complete_order_count[$i]);
             array_push($final_complete_category, $complete_category_for_each);
             $complete_price_for_each = array_splice($complete_price, 0, $complete_order_count[$i]);
             array_push($final_complete_price, $complete_price_for_each);
             $complete_quantity_for_each = array_splice($complete_quantity, 0, $complete_order_count[$i]);
             array_push($final_complete_quantity, $complete_quantity_for_each);
             $complete_photo_for_each = array_splice($complete_photo, 0, $complete_order_count[$i]);
             array_push($final_complete_photo, $complete_photo_for_each);
             $i++;
         }
         $this->model->setDoneId($final_complete_id);
         $this->model->setDoneProductTable($final_complete_product_tables);
         $this->model->setDoneOriginalName($final_complete_original_name);
         $this->model->setDoneCategory($final_complete_category);
         $this->model->setDoneQuantity($final_complete_quantity);
         $this->model->setDonePrice($final_complete_price);
         $this->model->setDoneOrder($final_complete_order);
         $this->model->setDonePhoto($final_complete_photo);
         $this->model->setDoneProductName($final_complete_product_name);
     }
 }
Esempio n. 26
0
 public function __construct()
 {
     $this->user = User::getInstance();
     $this->storage = Storage::getInstance();
     $this->webDBUtils = WebDBUtils::getInstance();
 }
Esempio n. 27
0
 protected static function loadObjectData($b_Object)
 {
     self::$storage = Storage::getInstance();
     self::$storage->loadObject($b_Object);
     return;
 }
Esempio n. 28
0
 function fetchPageRoute($subscriptionId, $filter, $continueAfterId = null)
 {
     $storage = Storage::getInstance();
     $articles = $storage->getArticlePage($this->user->id, $subscriptionId, $filter, PAGE_SIZE, $continueAfterId);
     $response = array("entries" => $articles);
     if (count($articles) >= PAGE_SIZE) {
         $last = end($articles);
         $response["continue"] = $last["id"];
     }
     return $response;
 }
Esempio n. 29
0
 /**
  * Method for adding data to the Cart
  * If exists product in the User's Cart
  * add Quantity plus one
  * otherwise Add item
  *
  * @var $id
  * @var $product_name
  * @var $category
  * @var $photo
  * @var $price
  *
  * @var $idQ
  * @var $quantity
  */
 private function actionAddItems()
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . '/Storage.php';
     $db = Storage::getInstance();
     $mysqli = $db->getConnection();
     if (isset($_POST['id'])) {
         $id = $_POST['id'];
     }
     if (isset($_POST['original_name'])) {
         $original_name = $_POST['original_name'];
     }
     if (isset($_POST['category'])) {
         $category = $_POST['category'];
     }
     if (isset($_POST['photo'])) {
         $photo = $_POST['photo'];
     }
     if (isset($_POST['price'])) {
         $price = $_POST['price'];
     }
     if (isset($_POST['table'])) {
         $table = $_POST['table'];
     }
     if (isset($_POST['item_quantity'])) {
         $post_quantity = $_POST['item_quantity'];
     }
     $user = $_SESSION['login_user'];
     $sql_stmt = "SELECT id,quantity FROM orderedItems WHERE id={$id} AND product_name='{$original_name}' AND category='{$category}'\n                      AND price={$price} AND user='******'";
     //echo $sql_stmt;
     $result = $mysqli->query($sql_stmt);
     if ($result->num_rows > 0) {
         while ($row = $result->fetch_assoc()) {
             $quantity = $row['quantity'];
             $idQ = $row['id'];
         }
     }
     if (isset($post_quantity) && !isset($idQ)) {
         $sql_query = "INSERT INTO orderedItems VALUES ('{$id}', '{$original_name}', '{$category}', '{$price}', '{$user}', '{$post_quantity}', '{$table}', '')";
         $stmt = $mysqli->prepare($sql_query);
         $stmt->execute();
     } else {
         if (!isset($idQ)) {
             $sql_query = "INSERT INTO orderedItems VALUES ('{$id}', '{$original_name}', '{$category}', '{$price}', '{$user}', 1, '{$table}', '')";
             $stmt = $mysqli->prepare($sql_query);
             $stmt->execute();
         }
     }
     if (isset($quantity)) {
         if (isset($post_quantity)) {
             $res_quantity = $quantity + $post_quantity;
             $sql_res = $mysqli->prepare("UPDATE orderedItems SET quantity={$res_quantity} WHERE user='******' AND price={$price}\n                            AND product_name='{$original_name}' AND category='{$category}'");
             $sql_res->execute();
         } else {
             if ($quantity !== 1) {
                 $quantity++;
                 $sql_res = $mysqli->prepare("UPDATE orderedItems SET quantity={$quantity} WHERE user='******' AND price={$price}\n                            AND product_name='{$original_name}' AND category='{$category}'");
                 $sql_res->execute();
             }
         }
     }
     session_start();
     $_SESSION['photo'] = $photo;
     session_write_close();
 }
Esempio n. 30
0
 public function __construct()
 {
     $this->storage = Storage::getInstance();
 }