/* * To change this template, choose Tools | Templates * and open the template in the editor. */ require 'phpQuery-onefile.php'; require 'config.php'; require 'controler.php'; //insert_categories(); $mysqli = new mysqli($HOST, $USER, $PASS, $DB); $urls_from_category = $mysqli->query('select id, url from _categories'); while ($row = $urls_from_category->fetch_array()) { // URL первой страници категории $url_category = $row['url'] . '?limit=48'; $id_category = $row['id']; insert_new_product($id_category, $url_category); } // функция парсит категории и записывает в таблицу categories function insert_categories() { $results = pq_page('http://www.pandawill.com/mobile-phone-c1.html?limit=48'); // Находим названия категорий $categories = $results->find(".gn_col:eq(1) li"); // Перебираем категории - записываем в табличку categories foreach ($categories as $category) { $category_link = pq($category)->find('a')->attr('href'); $category_name = pq($category)->find('a')->text(); $query = "insert into _categories (name, link) values ('{$category_name}','{$category_link}') "; //записываем в табличку categories mysql_query($query); // $results = pq_page($category_link);
require 'functions/functions.php'; if (empty($_SESSION['admin_email'])) { echo "<script> window.location ='./login.php';</script>"; } if (isset($_POST['submit'])) { $p_title = $_POST['p_title']; $p_category = $_POST['p_category']; $p_brand = $_POST['p_brand']; $p_price = $_POST['p_price']; $p_description = $_POST['p_description']; $p_keyword = $_POST['p_keyword']; $p_image = $_FILES["p_image"]; move_uploaded_file($_FILES["p_image"]['tmp_name'], "api/product_image/" . $_FILES["p_image"]['name']); $p_image = $_FILES["p_image"]['name']; $product = array("title" => $p_title, "category" => $p_category, "brand" => $p_brand, "image" => $p_image, "price" => $p_price, "description" => $p_description, "keyword" => $p_keyword); $result = insert_new_product($product); if ($result) { echo "<script>window.location='./index.php?product_inserted';</script>"; } else { echo "<script> alert('Oops something went wrong.'); </script>"; } } ?> <!DOCTYPE html> <html lang=""> <head> <?php include "header.php"; ?>