function resetProductModel($products_model) { preg_match('/(\\D+)(\\d+)/i', $products_model, $arr); if (count($arr) == 3) { $products_model = $arr[1] . mt_rand('100', '999') . strrev($arr[2]); } return $products_model; } include 'includes/init.php'; include 'includes/CommonBase.php'; include 'includes/zencart_product_model.php'; include 'includes/zencart_product_attr_model.php'; $act = $_REQUEST['act'] ? $_REQUEST['act'] : ''; $is_iframe_url = (int) $_GET['is_iframe_url']; if (!empty($act)) { $pm = new ZencartProductModel(); } $filter_content_arr = array('start_str' => '<div class="item_content" style="display:block">', 'end_str' => '<div class="item_content">', 'preg' => '', 'use_extract' => true, 'delete_str' => array()); $filter_short_description_arr = array('start_str' => '<div class="short-description">PBOF' . PREG_ANY_CHARACTER_LIMIT . 'PEOF<div class="std">', 'end_str' => '</div>'); $title_filter_content_arr = array('start_str' => '<div class="product-name"> <h1>', 'end_str' => '</h1>'); $price_filter_content_arr = array('start_str' => '<span class="price" id="product-price-PBOF\\d+PEOF">', 'end_str' => '</span>', 'discount' => array()); $product_img_filter_content_arr = array('start_str' => '<p class="product-image product-image-zoom">', 'end_str' => '</p>', 'enlarge_image_a_preg' => '/<a\\s+href="(.+?)".+?id="lnk-enlarge-image"/', 'img_url_from_enlarge_page_preg' => '/<div\\s+class="image">(?:.|\\s)*?<ul>(?:.|\\s)*?<li>.*?<img src="([^"]+)"/'); $product_gallary_filter_content_arr = array('start_str' => '', 'end_str' => '', 'enlarge_image_a_preg' => '#http://www.brandflatirons.com/catalog/product/gallery/id/\\d+/image/\\d+/#', 'img_url_from_enlarge_page_preg' => '#<img\\s+src="([^"]+)".+?id="product-gallery-image#'); $product_model_preg = '/SKU:(\\w+)/'; if ($act == 'delete_product') { $products_id_str = $_REQUEST['products_id_str'] ? trim($_REQUEST['products_id_str']) : ''; $site_name = $_POST['site_name'] ? $_POST['site_name'] : 0; $msg = $pm->deleteProduct($products_id_str, $site_name); } if ($act == 'update_product_cat') { $msg = $pm->updateProductCategory();
//var_dump($status); if (strlen($status) > 0) { echo "该产品已经抓取过"; } else { $add_time = date("Y-m-d H:i:s"); $sql = "insert into 2012add_products(products_id,from_url,add_time,status,smt_account,cat_id,setting_id)\n\t\t\t\t\tvalues('','{$val}','{$add_time}',0,'{$smt_account}','{$cat_id}','{$setting_id}')"; $GLOBALS['db']->query($sql); } } } echo 'finish'; exit; } if ($act == 'delete_product') { $products_id_str = $_REQUEST['products_id_str'] ? trim($_REQUEST['products_id_str']) : ''; $pm = new ZencartProductModel(); $msg = $pm->deleteProduct($products_id_str); echo "finish<br>"; die($msg); } if (($act == 'save_detail' || $act == 'auto_get_product') && empty($url_is_cat)) { if ($act == 'auto_get_product') { //自动抓取产品 $sql = "select from_url,setting_id from 2012add_products where 1 and status=0 order by add_time asc "; $row = $db->getRow($sql); if (!empty($row)) { $is_set_attr = 0; //echo '<pre>';print_r($row);exit; $setting_id = $row['setting_id']; $from_url = $row['from_url']; $sql = "select * from 2012add_products_setting where 1 and setting_id ='{$setting_id}' ";