function getInfo($url) { $u = parse_url($url); //解析get参数 $param = convertUrlQuery($u['query']); $test['param'] = $param; //var_dump($param);exit; if (!stripos('taobao.com', $u['host'])) { $shopUrl = "http://hws.m.taobao.com/cache/wdetail/5.0/?id=" . $param['id']; } else { $shopUrl = "http://detail.m.tmall.com/item.htm?id=" . $param['id']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $shopUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); $file_contents = curl_exec($ch); curl_close($ch); if (!$file_contents) { $file_contents = file_get_contents($shopUrl); } if (!stripos('taobao.com', $u['host'] === false)) { $data = getTaobaoShopInfo($file_contents); } else { $data = getTmallShopInfo($file_contents); } $data['num_iid'] = $param['id']; return $data; }
foreach ($queryParts as $param) { $item = explode('=', $param); $params[$item[0]] = $item[1]; } return $params; } for ($i = 957; $i < 1541;) { $data = getdata("http://www.flipkart.com/home-kitchen/pr?p%5B%5D=sort%3Dprice_desc&sid=j9e&layout=grid&start=" . $i . "&ajax=true"); $data = str_replace("<textarea id='ajax'>", "", $data); $data = str_replace("</textarea>", "", $data); $data = html_entity_decode($data); $html = str_get_html($data); foreach ($html->find('.fk-anchor-link') as $element) { $link = 'http://www.flipkart.com' . $element->href; if ($url = parse_url($link)) { $urlquery = convertUrlQuery($url['query']); $url = $url['scheme'] . '://' . $url['host'] . $url['path'] . '?pid=' . $urlquery['pid']; // put all your logic here $itemdata = getdata($url); $product_url = (string) $url; //sqlite save command scraperwiki::sqliteexecute("insert into flipkart_home_and_kitchen_dump values (?,?)", array($product_url, $itemdata)); //sqlite save command scraperwiki::sqlitecommit(); } } // ending for loop if ($i > 20) { $i = $i + 20; } else { $i = $i + 21;
function stats() { $from = date('d/m/y'); $daysInterval = 1; $data['from'] = $from; $data['daysInterval'] = $daysInterval; $data['current'] = 'stats'; $data['view'] = 'stats'; $data['title'] = 'Statistiques'; $data['connected'] = $this->db->where('isRobot', 0)->where('online', 1)->count_all_results('users'); $data['robotsConnected'] = $this->db->where('isRobot', 1)->where('online', 1)->count_all_results('users'); $data['membersConnected'] = $this->db->where('isAnonymous', 0)->where('online', 1)->count_all_results('users'); $data['members'] = $this->db->where('isAnonymous', 0)->count_all_results('users'); $data['news'] = $this->db->where('type', 1)->where('isCurrent', 1)->count_all_results('contents'); $data['rubriques'] = $this->db->where('type', 2)->where('isCurrent', 1)->count_all_results('contents'); $data['articles'] = $this->db->where('type', 3)->where('isCurrent', 1)->count_all_results('contents'); $data['chatbox'] = $this->db->count_all_results('chatbox_messages'); $data['mpSubject'] = $this->db->count_all_results('messaging'); $data['mp'] = $this->db->where('table', 'messaging')->count_all_results('comments'); $data['forumMessages'] = $this->db->where('table', 'forum')->count_all_results('comments'); $data['coms'] = $this->db->where('table', 'contents')->count_all_results('comments'); $data['topics'] = $this->db->count_all_results('topics'); $data['sondages'] = $this->db->where('sondage', 1)->count_all_results('topics'); $data['images'] = $this->db->count_all_results('images'); $data['galery'] = $this->db->where('inGallery', 1)->count_all_results('images'); $data['gils'] = $this->db->select_sum('gils')->get('users')->row_array(); $data['externSources'] = $this->db->select('v.referrer,v.date,v.user,u.username,u.color')->join('users u', 'u.id = v.user')->not_like('v.referrer', 'univers.com')->not_like('v.referrer', 'google')->not_like('v.referrer', 'bing')->not_like('v.referrer', 'ask')->not_like('v.referrer', 'search')->where('v.referrer !=', '')->where('v.referrer !=', '0')->order_by('v.id desc')->limit(100)->get('visites v')->result_array(); $data['search'] = $this->db->select('v.referrer,v.date,v.user,u.username,u.color')->join('users u', 'u.id = v.user')->like('v.referrer', 'google')->or_like('v.referrer', 'bing')->or_like('v.referrer', 'ask')->or_like('v.referrer', 'search')->order_by('v.id desc')->limit(100)->get('visites v')->result_array(); foreach ($data['search'] as $key => $search) { $query = convertUrlQuery($search['referrer']); if (!isset($query['q']) || trim($query['q']) == '') { $data['search'][$key]['keywords'] = '<em style="color:darkorange">Mots clefs introuvables</em>'; } else { $data['search'][$key]['keywords'] = htmlspecialchars(urldecode($query['q'])); } } $data['title'] = 'Statistiques'; $this->load->view('design.php', $data); }
function getInfo($url) { $u = parse_url($url); $param = convertUrlQuery($u['query']); if (!stripos('taobao.com', $u['host'])) { //$shopUrl = "http://a.m.taobao.com/i".$param['id'].".htm"; $shopUrl = "http://hws.m.taobao.com/cache/wdetail/5.0/?id=" . $param['id']; } else { //$shopUrl = "http://a.m.tmall.com/i".$param['id'].".htm"; $shopUrl = "http://detail.m.tmall.com/item.htm?id=" . $param['id']; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $shopUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); $file_contents = curl_exec($ch); //echo $file_contents;die; //echo curl_error($ch); //echo curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch); if (!$file_contents) { $file_contents = file_get_contents($shopUrl); } if (stripos('taobao.com', $u['host']) === false) { $data = getTaobaoShopInfo($file_contents); } else { $data = getTmallShopInfo($file_contents); } $data['num_iid'] = $param['id']; return $data; }
$cityID = $fn->get('cityID'); $add_soldier = $fn->get('add_soldier'); $stolen_goods = $fn->get('stolen_goods'); $blackmarket_goods = $fn->get('blackmarket_goods'); $updateDiamond = $fn->get('update_diamond'); $request_quantity = $fn->get('request_quantity'); $quantity = $fn->get('quantity'); $previousQuanity = $fn->get('previousQuanity'); $purchasePrice = $fn->get('purchasePrice'); //$page = $fn-> get('page'); $from = $fn->get('from'); //print_r($_REQUEST); if ($from == "google") { $page = base64_decode($fn->get('page')); $queryStringArr = parse_url($page); $queryParams = convertUrlQuery($queryStringArr['query']); //$fn->printArray($queryParams); $diamonds = $queryParams['diamonds']; $cityID = $queryParams['cityID']; $missionID = $queryParams['missionID']; if (isset($queryParams['diamonds'])) { $diamonds = $queryParams['diamonds']; } if (isset($queryParams['cityID'])) { $cityID = $queryParams['cityID']; } if (isset($queryParams['missionID'])) { $missionID = $queryParams['missionID']; } if (isset($queryParams['attack_type'])) { $attack_type = $queryParams['attack_type'];
function fetch_twitter_rss($link, $url, $owner_uid) { require_once 'lib/tmhoauth/tmhOAuth.php'; require_once "lib/magpierss/rss_fetch.inc"; require_once 'lib/magpierss/rss_utils.inc'; $result = db_query($link, "SELECT twitter_oauth FROM ttrss_users\n\t\t\tWHERE id = {$owner_uid}"); $access_token = json_decode(db_fetch_result($result, 0, 'twitter_oauth'), true); $url_escaped = db_escape_string($url); if ($access_token) { $tmhOAuth = new tmhOAuth(array('consumer_key' => CONSUMER_KEY, 'consumer_secret' => CONSUMER_SECRET, 'user_token' => $access_token['oauth_token'], 'user_secret' => $access_token['oauth_token_secret'])); $code = $tmhOAuth->request('GET', $url, convertUrlQuery(parse_url($url, PHP_URL_QUERY))); if ($code == 200) { $content = $tmhOAuth->response['response']; define('MAGPIE_CACHE_ON', false); $rss = new MagpieRSS($content, MAGPIE_OUTPUT_ENCODING, MAGPIE_INPUT_ENCODING, MAGPIE_DETECT_ENCODING); return $rss; } else { db_query($link, "UPDATE ttrss_feeds\n\t\t\t\t\tSET last_error = 'OAuth authorization failed ({$code}).'\n\t\t\t\t\tWHERE feed_url = '{$url_escaped}' AND owner_uid = {$owner_uid}"); } } else { db_query($link, "UPDATE ttrss_feeds\n\t\t\t\tSET last_error = 'OAuth information not found.'\n\t\t\t\tWHERE feed_url = '{$url_escaped}' AND owner_uid = {$owner_uid}"); return false; } }
/** * @param $store_id * @param $supplier * @param $page_id * @param $group_ids * @param $fx_products * @return bool|int|string */ function copyHomePage($store_id, $supplier, $page_id, $group_ids, $fx_products) { //供货商微页面 $homePage = D('Wei_page')->where(array('is_home' => 1, 'store_id' => $supplier['store_id']))->find(); //微杂志的自定义字段 if ($homePage['has_custom']) { $field_list = M('Custom_field')->get_field($supplier['store_id'], 'page', $homePage['page_id']); if (!empty($field_list)) { $data_fields = array(); foreach ($field_list as $key => $field) { switch ($field['field_type']) { case 'title': //标题 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = serialize($field['content']); break; case 'rich_text': //富文本 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = serialize($field['content']); break; case 'notice': //公告 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = serialize($field['content']); break; case 'line': //辅助线 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = serialize($field['content']); break; case 'white': //辅助空白 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = serialize($field['content']); break; case 'search': //商品搜索 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = serialize($field['content']); break; case 'store': //进入店铺 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = serialize($field['content']); break; case 'text_nav': //文本导航 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = array(); $text_navs = array(); foreach ($field['content'] as $nav) { switch ($nav['prefix']) { case '商品分组': $params = convertUrlQuery($nav['url']); $group_id = !empty($params['id']) ? $params['id'] : ''; if (!empty($group_id) && !empty($group_ids[$group_id])) { //分组id $my_group_id = $group_ids[$group_id]; $nav['url'] = preg_replace('/goodcat\\.php\\?id=(\\d+)/is', 'goodcat.php?id=' . $my_group_id, $nav['url']); } else { continue 2; } break; case '商品': $params = convertUrlQuery($nav['url']); if (!empty($params['id'])) { //商品id $product_id = $params['id']; if (empty($fx_products[$product_id])) { $my_product_id = $fx_products[$product_id]; $nav['url'] = preg_replace('/good\\.php\\?id=(\\d+)/is', 'good.php?id=' . $my_product_id, $nav['url']); } else { //商品不存在或非分销商品 //$nav['url'] = '#'; continue 2; } } break; case '店铺主页': $nav['url'] = preg_replace('/home\\.php\\?id=(\\d+)/is', 'home.php?id=' . $store_id, $nav['url']); break; case '会员主页': $nav['url'] = preg_replace('/ucenter\\.php\\?id=(\\d+)/is', 'ucenter.php?id=' . $store_id, $nav['url']); break; case '外链': //过滤站内链接 if (stripos($nav['url'], option('config.site_url')) !== false) { //$nav['url'] = '#'; continue 2; } break; case '微页面': //$nav['url'] = '#'; continue 2; break; case '微页面分类': //$nav['url'] = '#'; continue 2; break; } $text_navs[] = array('title' => $nav['title'], 'name' => htmlspecialchars($nav['name'], ENT_QUOTES), 'prefix' => $nav['prefix'], 'url' => $nav['url']); } $data_fields[$key]['content'] = serialize($text_navs); break; case 'image_nav': //图片导航 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = array(); $image_navs = array(); foreach ($field['content'] as $nav) { switch ($nav['prefix']) { case '商品分组': $params = convertUrlQuery($nav['url']); $group_id = !empty($params['id']) ? $params['id'] : ''; if (!empty($group_id) && !empty($group_ids[$group_id])) { //分组id $my_group_id = $group_ids[$group_id]; $nav['url'] = preg_replace('/goodcat\\.php\\?id=(\\d+)/is', 'goodcat.php?id=' . $my_group_id, $nav['url']); } else { $nav['url'] = '#'; } break; case '商品': $params = convertUrlQuery($nav['url']); if (!empty($params['id'])) { //商品id $product_id = $params['id']; if (empty($fx_products[$product_id])) { $my_product_id = $fx_products[$product_id]; $nav['url'] = preg_replace('/good\\.php\\?id=(\\d+)/is', 'good.php?id=' . $my_product_id, $nav['url']); } else { //商品不存在或非分销商品 $nav['url'] = '#'; } } break; case '店铺主页': $nav['url'] = preg_replace('/home\\.php\\?id=(\\d+)/is', 'home.php?id=' . $store_id, $nav['url']); break; case '会员主页': $nav['url'] = preg_replace('/ucenter\\.php\\?id=(\\d+)/is', 'ucenter.php?id=' . $store_id, $nav['url']); break; case '外链': //过滤站内链接 if (stripos($nav['url'], option('config.site_url')) !== false) { $nav['url'] = '#'; } break; case '微页面': $nav['url'] = '#'; break; case '微页面分类': $nav['url'] = '#'; break; } $image_navs[] = array('title' => $nav['title'], 'name' => htmlspecialchars($nav['name'], ENT_QUOTES), 'prefix' => $nav['prefix'], 'url' => $nav['url'], 'image' => $nav['image']); } $data_fields[$key]['content'] = serialize($image_navs); break; case 'link': //关联链接 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = array(); $links = array(); foreach ($field['content'] as $link) { switch ($link['prefix']) { case '微页面分类': $links[] = array('id' => $store_id, 'number' => $link['number'], 'name' => $link['name'], 'url' => '#', 'prefix' => $link['prefix'], 'type' => $link['type'], 'widget' => $link['widget'], 'title' => $link['title']); break; case '商品分组': if (!empty($group_ids[$link['id']])) { $link['id'] = $group_ids[$link['id']]; $link['url'] = preg_replace('/goodcat\\.php\\?id=(\\d+)/is', 'goodcat.php?id=' . $link['id'], $link['url']); } else { $link['id'] = $store_id; $link['url'] = '#'; } $links[] = array('id' => $link['id'], 'number' => $link['number'], 'name' => $link['name'], 'url' => $link['url'], 'prefix' => $link['prefix'], 'type' => $link['type'], 'widget' => $link['widget'], 'title' => $link['title']); break; case '外链': if (stripos($link['url'], option('config.site_url')) !== false) { $link['url'] = '#'; } $links[] = array('name' => $link['name'], 'url' => $link['url'], 'prefix' => $link['prefix'], 'type' => $link['type'], 'title' => $link['title']); break; case '': $links[] = array('name' => $link['name'], 'url' => $link['url'], 'prefix' => $link['prefix'], 'title' => $link['title']); break; } } $data_fields[$key]['content'] = serialize($links); break; case 'image_ad': //图片广告 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = array(); $image_ads = array(); $image_ads['max_height'] = $field['content']['max_height']; $image_ads['max_width'] = $field['content']['max_width']; $image_ads['nav_list'] = array(); foreach ($field['content']['nav_list'] as $nav) { switch ($nav['prefix']) { case '商品分组': $params = convertUrlQuery($nav['url']); $group_id = !empty($params['id']) ? $params['id'] : ''; if (!empty($group_id) && !empty($group_ids[$group_id])) { //分组id $my_group_id = $group_ids[$group_id]; $nav['url'] = preg_replace('/goodcat\\.php\\?id=(\\d+)/is', 'goodcat.php?id=' . $my_group_id, $nav['url']); } else { $nav['url'] = '#'; } break; case '商品': $params = convertUrlQuery($nav['url']); if (!empty($params['id'])) { //商品id $product_id = $params['id']; if (empty($fx_products[$product_id])) { $my_product_id = $fx_products[$product_id]; $nav['url'] = preg_replace('/good\\.php\\?id=(\\d+)/is', 'good.php?id=' . $my_product_id, $nav['url']); } else { //商品不存在或非分销商品 $nav['url'] = '#'; } } break; case '店铺主页': $nav['url'] = preg_replace('/home\\.php\\?id=(\\d+)/is', 'home.php?id=' . $store_id, $nav['url']); break; case '会员主页': $nav['url'] = preg_replace('/ucenter\\.php\\?id=(\\d+)/is', 'ucenter.php?id=' . $store_id, $nav['url']); break; case '微页面': $nav['url'] = '#'; break; case '微页面分类': $nav['url'] = '#'; break; case '外链': if (stripos($nav['url'], option('config.site_url')) !== false) { $nav['url'] = '#'; } break; } $image_ads['nav_list'][] = $nav; } $data_fields[$key]['content'] = serialize($image_ads); break; case 'goods': //商品 $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $page_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = array(); $content = array(); $content['size'] = $field['content']['size']; //大小 $content['buy_btn'] = $field['content']['buy_btn']; //是否显示购买按钮 $content['buy_btn_type'] = $field['content']['buy_btn_type']; //购买按钮样式 $content['price'] = $field['content']['price']; //是否显示价格 $goods = array(); if (!empty($field['content']['goods'])) { $good_qty = count($field['content']['goods']); //首页商品数量 $not_fx_goods = array(); //首页非分销商品 $is_fx_goods = array(); //所有分销商品 $i = 0; foreach ($field['content']['goods'] as $key2 => $good) { if (!empty($fx_products[$good['id']])) { //分销商品 $goods[$i]['id'] = $fx_products[$good['id']]; $goods[$i]['title'] = htmlspecialchars($good['title'], ENT_QUOTES); $goods[$i]['image'] = $good['image']; $tmp_product = M('Product')->get(array('product_id' => $fx_products[$good['id']]), 'price'); $goods[$i]['price'] = !empty($tmp_product['price']) ? $tmp_product['price'] : $good['price']; $goods[$i]['url'] = preg_replace('/good\\.php\\?id=(\\d+)/is', 'good.php?id=' . $fx_products[$good['id']], $good['url']); $is_fx_goods = $fx_products; unset($is_fx_goods[$good['id']]); $i++; } else { //首页非分销商品 $not_fx_goods[] = $good['id']; } } if (!empty($not_fx_goods) && !empty($is_fx_goods)) { //首页有非分销商品 $not_fx_good_qty = count($not_fx_goods); //首页非分销商品数量 $j = 0; foreach ($is_fx_goods as $good) { if ($j < $not_fx_good_qty) { //首页非分销商品所占位置使用非首页分销商品替换,同时保持首页原商品个数 $tmp_product = M('Product')->get(array('product_id' => $good), 'price,name,image'); if ($tmp_product) { $goods[$i]['id'] = $good; $goods[$i]['title'] = htmlspecialchars($tmp_product['name'], ENT_QUOTES); $goods[$i]['image'] = $tmp_product['image']; $goods[$i]['price'] = $tmp_product['price']; $goods[$i]['url'] = option('config.wap_site_url') . '/good.php?id=' . $good; $i++; } } $j++; } } } $content['goods'] = $goods; $data_fields[$key]['content'] = serialize($content); break; case 'component': //自定义模块 //暂不支持 break; } } $result = false; if (!empty($data_fields)) { $result = D('Custom_field')->data($data_fields)->addAll(); } $data_fields = array(); //公共广告(仅支持图片广告) if (!empty($supplier['open_ad'])) { $ad_list = M('Custom_field')->get_field($supplier['store_id'], 'common_ad', $supplier['store_id']); if (!empty($ad_list)) { foreach ($ad_list as $key => $field) { switch ($field['field_type']) { case 'image_ad': $data_fields[$key]['store_id'] = $store_id; $data_fields[$key]['module_name'] = htmlspecialchars($field['module_name'], ENT_QUOTES); $data_fields[$key]['module_id'] = $store_id; $data_fields[$key]['field_type'] = $field['field_type']; $data_fields[$key]['content'] = array(); $image_ads = array(); $image_ads['max_height'] = $field['content']['max_height']; $image_ads['max_width'] = $field['content']['max_width']; $image_ads['nav_list'] = array(); foreach ($field['content']['nav_list'] as $nav) { $nav['name'] = htmlspecialchars($nav['name'], ENT_QUOTES); switch ($nav['prefix']) { case '商品分组': $params = convertUrlQuery($nav['url']); $group_id = !empty($params['id']) ? $params['id'] : ''; if (!empty($group_id) && !empty($group_ids[$group_id])) { //分组id $my_group_id = $group_ids[$group_id]; $nav['url'] = preg_replace('/goodcat\\.php\\?id=(\\d+)/is', 'goodcat.php?id=' . $my_group_id, $nav['url']); } else { $nav['url'] = '#'; } break; case '商品': $params = convertUrlQuery($nav['url']); if (!empty($params['id'])) { //商品id $product_id = $params['id']; if (empty($fx_products[$product_id])) { $my_product_id = $fx_products[$product_id]; $nav['url'] = preg_replace('/good\\.php\\?id=(\\d+)/is', 'good.php?id=' . $my_product_id, $nav['url']); } else { //商品不存在或非分销商品 $nav['url'] = '#'; } } break; case '店铺主页': $nav['url'] = preg_replace('/home\\.php\\?id=(\\d+)/is', 'home.php?id=' . $store_id, $nav['url']); break; case '会员主页': $nav['url'] = preg_replace('/ucenter\\.php\\?id=(\\d+)/is', 'ucenter.php?id=' . $store_id, $nav['url']); break; case '微页面': $nav['url'] = '#'; break; case '微页面分类': $nav['url'] = '#'; break; case '外链': if (stripos($nav['url'], option('config.site_url')) !== false) { $nav['url'] = '#'; } break; } $image_ads['nav_list'][] = $nav; } $data_fields[$key]['content'] = serialize($image_ads); break; } } if (!empty($data_fields)) { if (D('Custom_field')->data($data_fields)->addAll()) { D('Store')->where(array('store_id' => $store_id))->data(array('open_ad' => 1, 'use_ad_pages' => $supplier['use_ad_pages']))->save(); } } } } return $result; } } }
<?php require_once 'idd.php'; require_once 'logic.php'; $str_query = $_SERVER["QUERY_STRING"]; $arr_query = convertUrlQuery($str_query); function convertUrlQuery($string) { $queryParts = explode('&', $string); $params = array(); foreach ($queryParts as $param) { $item = explode('=', $param); $params[$item[0]] = $item[1]; } return $params; } $p_cmd = $arr_query['cmd']; $p_sid = $arr_query['sid']; $p_pwd = $arr_query['pwd']; $p_key = $arr_query['key']; $p_val = $arr_query['val']; //if ($p_cmd != 'play'){ // print 'cmd => '.$p_cmd.'<br>'; // print 'sid => '.$p_sid.'<br>'; // print 'key => '.$p_key.'<br>'; // print 'val => '.$p_val.'<br>'; //} $db = new IdoDB(); if ($p_cmd == 'play') { $ret = array('empty', 'err.html'); $lg = new Logic();
function getInfo($url) { $u = parse_url($url); //解析get参数 $param = convertUrlQuery($u['query']); //var_dump($param);exit; if (!stripos('taobao.com', $u['host'])) { $shopUrl = "http://a.m.taobao.com/i" . $param['id'] . ".htm"; } else { $shopUrl = "http://a.m.tmall.com/i" . $param['id'] . ".htm"; } //echo $shopUrl;exit; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $shopUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 2); $file_contents = curl_exec($ch); //echo $file_contents;die; //echo curl_error($ch); //echo curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch); if (stripos('taobao.com', $u['host'] === false)) { $data = getTaobaoShopInfo($file_contents); } else { $data = getTmallShopInfo($file_contents); } $data['num_iid'] = $param['id']; return $data; }
public function view_getAmazonMessageListByConditions() { $sender = isset($_GET['sender']) ? trim($_GET['sender']) : ''; //关键字 $sender = mysql_real_escape_string($sender); $status = isset($_GET['status']) ? $_GET['status'] : FALSE; //回复状态 $category = isset($_GET['catid']) ? intval($_GET['catid']) : FALSE; //分类 $from = isset($_GET['from']) ? $_GET['from'] : FALSE; $overtime = isset($_GET['overtime']) ? intval($_GET['overtime']) : FALSE; //发送者 $name = isset($_GET['name']) ? trim($_GET['name']) : FALSE; $pagesize = isset($_SESSION['pagesize']) ? intval($_SESSION['pagesize']) : 200; $pagesize = isset($_GET['pagesize']) ? intval($_GET['pagesize']) : $pagesize; //每页数量 $cat_obj = new amazonmessagecategoryModel(); /*----- 获得用户能够浏览的邮件目录 -----*/ $Lp_obj = new LocalPowerAmazonModel(); $fieldid = $Lp_obj->getAmazonPowerlist($_SESSION['userId']); //获得当前用户所属的邮件目录id $fieldid = empty($fieldid) ? array(-10) : explode(',', $fieldid); $category = in_array($category, $fieldid) ? $category : FALSE; if (empty($category)) { $catList = $fieldid; //在未输入搜索条件时列出该用户所有有权限的浏览的邮件目录id(数组形式) } else { $catList = array($category); } /*----- 获得用户所属文件夹 -----*/ if (!empty($fieldid)) { $powerlist = $cat_obj->getFieldInfoByIds($fieldid, ' order by category_name'); //通过目录id获得相关目录信息 } else { $powerlist = array(); } $wheresql = ''; if (!empty($sender)) { //是否指定sender $wheresql .= " and sendid like '%{$sender}%' "; } if ($overtime == 24) { $status = FALSE; } if ($status !== FALSE) { //指定状态 switch ($status) { case 1: //回复完成 $wheresql .= " and status in (2,3)"; break; case 2: //未回复 $wheresql .= " and status=0 "; break; case 3: //回复中 $wheresql .= " and status=1 "; break; case 4: //回复失败 $wheresql .= " and status=4 "; break; default: $wheresql .= ""; break; } } if ($from !== FALSE) { //url中包含from参数 if ($from !== '') { //from参数不为空值 $wheresql .= " and from_platform={$from} "; } else { $from = FALSE; } } //查询超过24小时还未回复的邮件 if ($overtime == 24) { $time = time() - 86400; $wheresql .= " and recievetimestamp < {$time} and status =0 "; } //如果是选择From Member if ($from === FALSE && $overtime === FALSE) { $time = time() - 86400; $wheresql .= " and from_platform = '-1' and recievetimestamp > {$time} "; } $class_sql = implode(', ', $catList); $wheresql .= " and classid in ({$class_sql}) and is_delete=0"; //最终展示的是:登录的用户能够看到目录中的邮件 $msg_obj = new amazonmessageModel(); $mount = $msg_obj->getAmazonCountNumberByConditions($wheresql); //获得能够浏览的邮件数 $page_obj = new Page($mount, $pagesize); $usercache = new UserCacheModel(); if ($name !== FALSE) { if ($name == 'asc') { $orderby = ' order by sendid asc '; } else { $orderby = ' order by sendid desc '; } } else { $orderby = ' order by sendtime '; } $msglist = $msg_obj->getAmazonMessageListByConditions($wheresql . $orderby . $page_obj->limit); /* --- 格式化数据 ---*/ foreach ($msglist as &$msgitem) { $msgitem['subject'] = urldecode($msgitem['subject']); if (strlen($msgitem['subject']) > 100) { $msgitem['subjectfm'] = mb_substr($msgitem['subject'], 0, 100) . '...'; } else { $msgitem['subjectfm'] = $msgitem['subject']; } $msgitem['revtime'] = empty($msgitem['sendtime']) ? '' : date("Y 年 m 月 d 日 ", $msgitem['sendtime']) . ' ' . date("H时:i分:s秒", $msgitem['sendtime']); $catinfo = $cat_obj->getCategoryInfoById($msgitem['classid']); $msgitem['classname'] = $catinfo['category_name']; $userinfo = empty($msgitem['replyuser_id']) ? array('userName' => '') : $usercache->getUserInfoBySysId($msgitem['replyuser_id'], 0); $msgitem['username'] = $userinfo['userName']; $msgitem['retime'] = $msgitem['replytime'] ? date("Y-m-d \n H:i:s", $msgitem['replytime']) : ''; } if ($mount > $pagesize) { //分页 $pagestr = $page_obj->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $pagestr = $page_obj->fpage(array(0, 2, 3)); } /*----- 获得分类文件夹列表 -----*/ $categorylist = $cat_obj->getAllCategoryInfoList(); // print_r($categorylist); $this->smarty->assign('catlist', $categorylist); /*----- 获得分类列表 -----*/ if ($from === FALSE) { $this->smarty->assign('third_menue', 1); } elseif ($from === '0') { $this->smarty->assign('third_menue', 2); } elseif ($from == 1) { $this->smarty->assign('third_menue', 3); } elseif ($from == 2) { $this->smarty->assign('third_menue', 4); } if ($overtime == 24) { $this->smarty->assign('third_menue', 5); } $urlquery = convertUrlQuery($_SERVER['QUERY_STRING']); unset($urlquery['name']); if ($name == 'asc') { $urlquery['name'] = 'desc'; } else { $urlquery['name'] = 'asc'; } $url = getUrlQuery($urlquery); // echo $url, "\n"; // var_dump($urlquery); //print_r($msglist); $this->smarty->assign('url', $url); $this->smarty->assign('powerlist', $powerlist); $this->smarty->assign('from', $from); $this->smarty->assign('overtime', $overtime); $this->smarty->assign('sec_menue', 5); $this->smarty->assign('toplevel', 0); $this->smarty->assign('sender', $sender); $this->smarty->assign('category', $category); $this->smarty->assign('status', $status); $this->smarty->assign('pagestr', $pagestr); $this->smarty->assign('msglist', $msglist); $this->smarty->assign('categorylist', $arrlist); $this->smarty->assign('toptitle', 'message列表'); $this->smarty->display('msglistAmazon.htm'); }
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2016/11/17 * Time: 18:28 */ $str = 'http://test.com/testdir/index.php?param1=10¶m2=20¶m3=30¶m4=40¶m5=50¶m6=60'; $arr = parse_url($str); var_dump($arr); $arr_query = convertUrlQuery($arr['query']); var_dump($arr_query); var_dump(getUrlQuery($arr_query)); function convertUrlQuery($query) { $queryParts = explode('&', $query); $params = array(); foreach ($queryParts as $param) { $item = explode('=', $param); $params[$item[0]] = $item[1]; } return $params; } function getUrlQuery($array_query) { $tmp = array(); foreach ($array_query as $k => $param) { $tmp[] = $k . '=' . $param; } $params = implode('&', $tmp);
public function view_getAliSiteList() { $keywords = isset($_GET['keywords']) ? trim($_GET['keywords']) : ''; //关键字 $keywords = mysql_real_escape_string($keywords); $status = isset($_GET['status']) ? $_GET['status'] : FALSE; //回复状态 $category = isset($_GET['catid']) ? intval($_GET['catid']) : FALSE; //分类 $orderstatus = isset($_GET['orderstatus']) ? trim($_GET['orderstatus']) : false; //订单状态 $senderId = isset($_GET['senderid']) ? trim($_GET['senderid']) : FALSE; //发送人id $orderId = isset($_GET['orderid']) ? trim($_GET['orderid']) : FALSE; //订单号 $prodname = isset($_GET['prodname']) ? trim($_GET['prodname']) : FALSE; //产品名称 $sellerId = isset($_GET['sellerId']) ? trim($_GET['sellerId']) : FALSE; //卖家账号 $sortName = isset($_GET['sortname']) ? trim($_GET['sortname']) : FALSE; $sort = isset($_GET['sort']) ? trim($_GET['sort']) : FALSE; $isscroll = isset($_GET['isscroll']) ? intval($_GET['isscroll']) : 1; //设置是否收缩 1表示收缩 2表示不收缩 默认收缩 if ($status == 2 && ($isscroll = 1)) { //只有当查看未回复订单留言时才进行收缩 $isscroll = 1; } else { $isscroll = 2; } $cat_obj = new messagecategoryModel(); /*----- 获得用户所属文件夹 -----*/ $Lp_obj = new LocalPowerModel(); $fieldid = $Lp_obj->getAliPowerlist($_SESSION['userId']); //获得当前用户所属的id $fieldid = isset($fieldid['field']) ? $fieldid['field'] : array(-1); $category = in_array($category, $fieldid) ? $category : -1; /*----- 获得用户所属文件夹 -----*/ if (!empty($fieldid)) { $powerlist = $cat_obj->getFieldInfoByIds($fieldid, ' order by category_name'); } else { $powerlist = array(); } $wheresql = ''; if (!empty($keywords)) { //是否指定keywords $wheresql .= " and sendername='{$keywords}' "; } if ($status !== FALSE) { //指定状态 switch ($status) { case 1: //已读 $wheresql .= " and hasread=1"; break; case 2: //未读 $wheresql .= " and hasread=0 "; break; default: $wheresql .= ""; break; } } if ($category !== false) { if ($category == -1) { $class_sql = implode(', ', $fieldid); if (!empty($class_sql)) { $wheresql .= " and fieldId in ({$class_sql})"; } else { $wheresql .= 'and fieldId in (-1)'; } } else { $wheresql .= " and fieldId={$category}"; } } else { $class_sql = implode(', ', $fieldid); $wheresql .= " and fieldId in ({$class_sql})"; } if (FALSE !== $orderstatus && '0' != $orderstatus) { //设置的订单状态过滤条件 $orderstatus = strtoupper($orderstatus); $orderstatus = mysql_real_escape_string($orderstatus); $wheresql .= " and orderstatus='{$orderstatus}'"; } if (!empty($senderId)) { //搜索用户id $tempsender = mysql_real_escape_string($senderId); $wheresql .= " and senderid='{$tempsender}'"; } if (!empty($orderId)) { //搜索订单号 $temporderid = mysql_real_escape_string($orderId); $wheresql .= " and orderId='{$temporderid}' "; } if (!empty($prodname)) { $emppro = mysql_real_escape_string($prodname); $wheresql .= " and content like '%{$emppro}%'"; } if (!empty($sellerId)) { $temAcc = mysql_real_escape_string($sellerId); $wheresql .= " and receiverid = '{$temAcc}' "; } $urlquery = convertUrlQuery($_SERVER['QUERY_STRING']); unset($urlquery['sortname']); unset($urlquery['sort']); $orderbysql = ''; $sort = $sort == 'asc' ? 'asc' : 'desc'; $resort = $sort == 'asc' ? 'desc' : 'asc'; switch ($sortName) { case 'orderstatus': //按订单状态排序 $orderbysql = ' order by orderstatus ' . $sort; break; default: $orderbysql = ' order by createtimestamp ' . $sort; } $url = getUrlQuery($urlquery); $this->smarty->assign('url', $url); $this->smarty->assign('resort', $resort); // echo $wheresql;exit; $pagesize = 100; $msg_obj = new messageModel(); $groupBySql = ''; if (1 == $isscroll) { $groupBySql = ' group by relationId '; $mount = $msg_obj->getCountNumberByConditions_aliSite_groupby($wheresql . $groupBySql); } else { $mount = $msg_obj->getCountNumberByConditions_aliSite($wheresql); } $page_obj = new Page($mount, $pagesize); $usercache = new UserCacheModel(); $aliAcc_ojb = new AliAccountModel(); if (1 == $isscroll) { $msglist = $msg_obj->getMessageListByConditions_alisite_groupby($wheresql . $groupBySql . ' ' . $orderbysql . ' ' . $page_obj->limit); } else { $msglist = $msg_obj->getMessageListByConditions_alisite($wheresql . ' ' . $orderbysql . ' ' . $page_obj->limit); } /* --- 格式化数据 ---*/ foreach ($msglist as &$msgitem) { $catinfo = $cat_obj->getCategoryInfoById($msgitem['fieldId']); $msgitem['classname'] = $catinfo['category_name']; $userinfo = empty($msgitem['replyUser']) ? array('userName' => '') : $usercache->getUserInfoBySysId($msgitem['replyUser'], 0); $msgitem['username'] = $userinfo['userName']; // $msgitem['retime'] = $msgitem['replytime'] ? date("Y-m-d \n H:i:s", $msgitem['replytime']) : ''; $msgitem['content'] = mb_substr($msgitem['content'], 0, 80); $msgitem['content'] .= '...'; $msgitem['replytime'] = empty($msgitem['replytime']) ? '' : date("Y-m-d \n H:i:s", $msgitem['replytime']); $msgitem['gmtCreate'] = formateAliTime($msgitem['gmtCreate']); $msgitem['accname'] = $aliAcc_ojb->accountId2Name($msgitem['receiverid']); $msgitem['statusname'] = AliMessageModel::orderStatusToStr($msgitem['orderstatus']); } if ($mount > $pagesize) { //分页 $pagestr = $page_obj->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $pagestr = $page_obj->fpage(array(0, 2, 3)); } // print_r($msglist);exit; /*----- 获得分类文件夹列表 -----*/ $categorylist = $cat_obj->getAllCategoryInfoList(' and is_delete=0', 2); // print_r($categorylist); $this->smarty->assign('catlist', $categorylist); $this->smarty->assign('orderstatus', $orderstatus); /*----- 获得分类列表 -----*/ $aliAccount_obj = new AliAccountModel(); $accountlist = $aliAccount_obj->getAllAliAccountList('name', 'asc'); $this->smarty->assign('accountlist', $accountlist); $this->smarty->assign('sellerId', $sellerId); $this->smarty->assign('senderId', $senderId); $this->smarty->assign('orderId', $orderId); $this->smarty->assign('prodname', $prodname); // print_r($msglist);exit; $this->smarty->assign('third_menue', 2); $this->smarty->assign('powerlist', $powerlist); $this->smarty->assign('from', $from); $this->smarty->assign('sec_menue', 4); $this->smarty->assign('toplevel', 0); $this->smarty->assign('keywords', $keywords); $this->smarty->assign('category', $category); $this->smarty->assign('status', $status); $this->smarty->assign('pagestr', $pagestr); $this->smarty->assign('msglist', $msglist); $this->smarty->assign('categorylist', $arrlist); $this->smarty->assign('toptitle', 'message列表'); $this->smarty->display('msglistalisite.htm'); }