/** * 页面导航模型 * Enter description here ... */ private function NavUrl() { if (!empty($_SERVER['PATH_INFO'])) { $parray = $_SERVER['PATH_INFO']; $url = $_SERVER['REQUEST_URI']; $str = explode("/", trim($parray, "\\/")); $controller = ucfirst(empty($str[0]) ? "Index" : $str[0]) . "Controller"; $model = ucfirst(empty($str[1]) ? "Index" : $str[1]); } else { $controller = isset($_GET["m"]) ? ucfirst($_GET["m"]) . "Controller" : "IndexController"; $model = isset($_GET["a"]) ? ucfirst($_GET["a"]) : "Index"; } if (@(!class_exists($controller))) { exit($controller . "控制器不存在"); } $this->controller = $controller; $model = empty($model) ? "Index" : $model; $this->model = ucfirst($model); $controllerClass = new $controller(); $ur = url_parse(); $controllerClass->{$model}(); }
//shoddy way of setting the form target $r["url"] = "http://"; } elseif (url_id()) { $action = getString('edit'); echo drawTop(); $r = db_grab("SELECT id, title, url, publication, pub_date, description, type_id from press_clips WHERE id = " . $_GET["id"]); $r["title"] = format_title($r["title"], "US"); } else { $action = getString('add_new'); echo drawTop(); if (isset($_GET["title"])) { $r["title"] = format_title($_GET["title"], "US"); } if (isset($_GET["url"])) { $r["url"] = $_GET["url"]; $url = url_parse($r["url"]); if ($url["domainname"] == "nytimes") { $r["publication"] = "NY Times"; $r["title"] = str_replace("- Nytimes.com", "", $r["title"]); } elseif ($url["domainname"] == "latimes") { $r["publication"] = "LA Times"; $r["title"] = str_replace(" - Los Angeles Times", "", $r["title"]); } elseif ($url["domainname"] == "washingtonpost") { $r["publication"] = "Washington Post"; //$r["title"] = str_replace("The Associated Press: ", "", $r["title"]); } elseif ($url["domainname"] == "reuters") { $r["publication"] = "Reuters"; //$r["title"] = str_replace("The Associated Press: ", "", $r["title"]); } elseif ($url["domainname"] == "google" && $url["subfolder"] == "afp") { $r["publication"] = "AFP"; $r["title"] = str_replace("Afp: ", "", $r["title"]);
$rebuild = true; $attrs['archive'] = implode(',', array_map('complete_url', preg_split('#\\s*,\\s*#', $attrs['archive']))); } if (!empty($temp)) { $_base = $temp; } break; case 'object': if (isset($attrs['usemap'])) { $rebuild = true; $attrs['usemap'] = complete_url($attrs['usemap']); } if (isset($attrs['codebase'])) { $rebuild = true; $temp = $_base; url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $_base); unset($attrs['codebase']); } if (isset($attrs['data'])) { $rebuild = true; $attrs['data'] = complete_url($attrs['data']); } if (isset($attrs['classid']) && !preg_match('#^clsid:#i', $attrs['classid'])) { $rebuild = true; $attrs['classid'] = complete_url($attrs['classid']); } if (isset($attrs['archive'])) { $rebuild = true; $attrs['archive'] = implode(' ', array_map('complete_url', explode(' ', $attrs['archive']))); } if (!empty($temp)) {
function items_collect() { $this->uc_login_check(); //检测用户是否登录 $itemcollect_mod = D('itemcollect'); $items_cate_mod = D('items_cate'); $items_tags_mod = D('items_tags'); $items_mod = D('items'); $items_user_mod = D('items_user'); $url = isset($_REQUEST['url']) ? trim($_REQUEST['url']) : ''; $url = url_parse($url); if (strpos($url, 'tmall.com') !== false || strpos($url, 'taobao.com') !== false) { //说明此商品是淘宝的商品 $num_iid = get_id($url); $key = 'taobao_' . $num_iid; //item_key $tb_top = $this->taobao_client(); $req = $tb_top->load_api('TaobaokeItemsDetailGetRequest'); $req->setFields("num_iid,detail_url,title,nick,pic_url,price,click_url "); $req->setPid($this->setting['taobao_pid']); $req->setNick($this->setting['taobao_usernick']); $req->setNumIids($num_iid); $resp = get_object_vars_final($tb_top->execute($req)); if (!is_array($resp)) { $this->ajaxReturn(array('err' => 'remote_not_exist')); } else { $data = $resp['taobaoke_item_details']['taobaoke_item_detail']; } if (!is_array($data)) { $this->ajaxReturn(array('err' => 'remote_not_exist')); } $commission = $this->get_commission($data['item']['title'], $data['item']['num_iid'], $p = 'commission'); $data['title'] = $data['item']['title']; $data['price'] = $data['item']['price']; $data['img'] = $data['item']['pic_url'] . '_210x1000.jpg'; $data['simg'] = $data['item']['pic_url'] . '_64x64.jpg'; $data['bimg'] = $data['item']['pic_url']; $data['seller_name'] = $data['item']['nick']; //返现金额 if (empty($commission)) { $commission = 0; } $data['cash_back_rate'] = $commission . '元'; $data['url'] = $data['click_url']; $data['author'] = 'taobao'; $data['item_key'] = 'taobao_' . $num_iid; $tags = $items_tags_mod->get_tags_by_title($data['item']['title']); $data['cid'] = $items_cate_mod->get_cid_by_tags($tags); $data['tags'] = implode(' ', $tags); $item_user_id = $items_user_mod->where("iid='{$num_iid}' AND uid='{$_COOKIE['user']['id']}'")->getField('id'); //此人已经分享过此商品了 if ($item_user_id) { $this->ajaxReturn(array('err' => 'yet_exist')); } //此人没有分享过这个商品 //如果这个商品存在,则不弹窗 $items_data = $items_mod->where("item_key='{$data['item_key']}'")->find(); if ($items_data) { $item_user_data = array('iid' => substr($items_data['item_key'], 7), 'item_id' => $items_data['id'], 'uid' => $_COOKIE['user']['id'], 'add_time' => time()); $items_user_rel = $items_user_mod->add($item_user_data); if ($items_user_rel) { //分享成功赠送积分 $map['uid'] = $_COOKIE['user']['id']; M('userInfo')->where($map)->setInc("integral", $this->setting['share_goods_score']); $this->ajaxReturn(array('err' => 'share_yes')); } } } else { //59miao 的商品开始 $miao_api = $this->miao_client(); //获取59秒api设置信息 $data = $miao_api->ListItemsDetail('', $url); if (!is_array($data)) { $this->ajaxReturn(array('err' => 'remote_not_exist')); } else { $data = $data['items']['item']; } if (!is_array($data)) { $this->ajaxReturn(array('err' => 'remote_not_exist')); } $data['price'] = $data['price']; if (strpos($data['pic_url'], 'taobao') !== false) { $data['img'] = $data['pic_url'] . '_210x1000.jpg'; $data['simg'] = $data['pic_url'] . '_64x64.jpg'; //$data['bimg'] = $data['pic_url'].'_460x460.jpg'; $data['bimg'] = $data['pic_url']; } else { $data['img'] = str_replace('.jpg', '_210x1000.jpg', $data['pic_url']); $data['simg'] = str_replace('.jpg', '_60x60.jpg', $data['pic_url']); //$data['bimg'] = str_replace('.jpg', '_460x460.jpg', $data['pic_url']); $data['bimg'] = $data['pic_url']; } $data['seller_name'] = $data['seller_name']; $data['cash_back_rate'] = $data['cashback_scope']; $data['url'] = $data['click_url']; $data['author'] = 'miao'; $data['item_key'] = 'miao_' . $data['iid']; $tags = $items_tags_mod->get_tags_by_title($data['title']); $data['cid'] = $items_cate_mod->get_cid_by_tags($tags); $data['tags'] = implode(' ', $tags); $item_user_id = $items_user_mod->where("iid='{$data['iid']}' AND uid='{$_COOKIE['user']['id']}'")->getField('id'); //此人已经分享过此商品了 if ($item_user_id) { $this->ajaxReturn(array('err' => 'yet_exist')); } //此人没有分享过这个商品 //如果这个商品存在,则不弹窗 $items_data = $items_mod->where("item_key='{$data['item_key']}'")->find(); if ($items_data) { $item_user_data = array('iid' => substr($items_data['item_key'], 5), 'item_id' => $items_data['id'], 'uid' => $_COOKIE['user']['id'], 'add_time' => time()); $items_user_rel = $items_user_mod->add($item_user_data); if ($items_user_rel) { //分享成功赠送积分 $map['uid'] = $_COOKIE['user']['id']; M('userInfo')->where($map)->setInc("integral", $this->setting['share_goods_score']); $this->ajaxReturn(array('err' => 'share_yes')); } } //59miao 的商品结束 } $this->ajaxReturn($data); }
//for counting trips to the database //get library files require "error.php"; require "array.php"; require "db.php"; require "draw.php"; require "email.php"; require "file.php"; require "format.php"; require "htmLawed.php"; require "url.php"; //hook up error.php set_error_handler("error_handle_php"); //find out about environment (you can use draw_array($array, false) to display these arrays for debugging -- see line 75 below) $_josh["request"] = $_josh["server"]["host"] ? url_parse($_josh["server"]["protocol"] . "://" . $_josh["server"]["host"] . $_josh["server"]["request"] . "?" . $_josh["server"]["query"]) : false; $_josh["referrer"] = $_josh["server"]["refer"] ? url_parse($_josh["server"]["refer"]) : false; //get configuration variables configure(); //set error reporting level by determining whether this is a dev or live situation if (isset($_josh["mode"]) && $_josh["mode"] == "dev") { //1: you can set the option manually error_reporting(E_ALL); } elseif (format_text_starts("dev-", $_SERVER["HTTP_HOST"]) || format_text_starts("beta.", $_SERVER["HTTP_HOST"]) || format_text_ends(".site", $_SERVER["HTTP_HOST"])) { //2: urls start with dev- or end with .site are automatically considered dev sites $_josh["mode"] = "dev"; error_reporting(E_ALL); } else { $_josh["mode"] = "live"; error_reporting(0); } //handle https
function batch_add() { $items_cate_mod = D('items_cate'); $cate_list = $items_cate_mod->get_top2_list(); $this->assign('cate_list', $cate_list); if (isset($_POST['dosubmit'])) { $data = array(); $success_update_list = ''; $success_insert_list = ''; $fail_list = ''; $cid = $_POST['cid']; $items_mod = M('items'); $items_site_mod = D('items_site'); $itemcollect_mod = D('itemcollect'); $items_tags_mod = D('items_tags'); $items_tags_item_mod = D('items_tags_item'); $urls = preg_split('/[\\r\\n]/', $_POST['urls']); $items_nums = 0; foreach ($urls as $url) { $url = url_parse(urldecode(trim($url))); //淘宝 if (strpos($url, 'tmall.com') !== false || strpos($url, 'taobao.com') !== false) { //说明此商品是淘宝的商品 $num_iid = get_id($url); $key = 'taobao_' . $num_iid; //item_key $tb_top = $this->taobao_client(); $req = $tb_top->load_api('TaobaokeItemsDetailGetRequest'); $req->setFields("num_iid,detail_url,title,nick,pic_url,price,click_url "); $req->setPid($this->setting['taobao_pid']); $req->setNick($this->setting['taobao_usernick']); $req->setNumIids($num_iid); $resp = get_object_vars_final($tb_top->execute($req)); if (is_array($resp)) { $data = $resp['taobaoke_item_details']['taobaoke_item_detail']; if (is_array($data)) { $commission = $this->get_commission($data['item']['title'], $data['item']['num_iid'], $p = 'commission'); $data['title'] = $data['item']['title']; $data['price'] = $data['item']['price']; $data['img'] = $data['item']['pic_url'] . '_210x1000.jpg'; $data['simg'] = $data['item']['pic_url'] . '_64x64.jpg'; $data['bimg'] = $data['item']['pic_url']; $data['seller_name'] = $data['item']['nick']; $data['add_time'] = time(); //返现金额 if (empty($commission)) { $commission = 0; } $data['cash_back_rate'] = $commission . '元'; $data['url'] = $data['click_url']; $data['author'] = 'taobao'; $data['item_key'] = 'taobao_' . $num_iid; $data['cid'] = $cid; $data['sid'] = $items_site_mod->where("alias='" . $data['author'] . "'")->getField('id'); $item_id = $items_mod->where("item_key='" . $data['item_key'] . "'")->getField('id'); if ($item_id) { //update $item_id = $items_mod->where("id={$item_id}")->save($data); $success_update_list .= $url . "<br/>"; } else { //insert $item_id = $items_mod->add($data); $success_insert_list .= $url . "<br/>"; } $tags = $items_tags_mod->get_tags_by_title($data['title']); if ($tags) { $tags_arr = array_unique($tags); foreach ($tags_arr as $tag) { $isset_id = $items_tags_mod->where("name='" . $tag . "'")->getField('id'); if ($isset_id) { $items_tags_mod->where('id=' . $isset_id)->setInc('item_nums'); $items_tags_item_mod->add(array('item_id' => $item_id, 'tag_id' => $isset_id)); } else { $tag_id = $items_tags_mod->add(array('name' => $tag)); $items_tags_item_mod->add(array('item_id' => $item_id, 'tag_id' => $tag_id)); } } } $items_nums++; } else { //如果没有数据 $fail_list .= $url . "<br/>"; } } else { //如果没有数据 $fail_list .= $url . "<br/>"; } } else { //59秒 /*获取数据*/ $miao_api = $this->miao_client(); //获取59秒api设置信息 $data = $miao_api->ListItemsDetail('', $url); $data = $data['items']['item']; $data['img'] = str_replace('.jpg', '_210x1000.jpg', $data['pic_url']); $data['simg'] = str_replace('.jpg', '_60x60.jpg', $data['pic_url']); $data['bimg'] = $data['pic_url']; /*结束*/ if (is_array($data)) { $data['price'] = $data['price']; $data['img'] = $data['img']; $data['simg'] = $data['simg']; $data['bimg'] = $data['bimg']; $data['url'] = $data['click_url']; $data['author'] = 'miao'; $data['item_key'] = 'miao_' . $data['iid']; $data['cid'] = $cid; $data['seller_name'] = $data['seller_name']; $data['cash_back_rate'] = $data['cashback_scope']; $data['add_time'] = time(); $data['sid'] = $items_site_mod->where("alias='" . $data['author'] . "'")->getField('id'); $item_id = $items_mod->where("item_key='" . $data['item_key'] . "'")->getField('id'); if ($item_id) { //update $item_id = $items_mod->where("id={$item_id}")->save($data); $success_update_list .= $url . "<br/>"; } else { //insert $item_id = $items_mod->add($data); $success_insert_list .= $url . "<br/>"; } $tags = $items_tags_mod->get_tags_by_title($data['title']); if ($tags) { $tags_arr = array_unique($tags); foreach ($tags_arr as $tag) { $isset_id = $items_tags_mod->where("name='" . $tag . "'")->getField('id'); if ($isset_id) { $items_tags_mod->where('id=' . $isset_id)->setInc('item_nums'); $items_tags_item_mod->add(array('item_id' => $item_id, 'tag_id' => $isset_id)); } else { $tag_id = $items_tags_mod->add(array('name' => $tag)); $items_tags_item_mod->add(array('item_id' => $item_id, 'tag_id' => $tag_id)); } } } $items_nums++; } else { $fail_list .= $url . "<br/>"; } } //获取59秒数据完成 } //foreach 完成 //更新分类表商品数 if ($items_nums > 0) { $items_cate_mod->where('id=' . $cid)->setInc('item_nums', $items_nums); } $this->ajaxReturn(array('success_update_list' => $success_update_list, 'success_insert_list' => $success_insert_list, 'fail_list' => $fail_list)); } else { $this->display(); } }
$rebuild = true; $attrs['archive'] = implode(',', array_map('complete_url', preg_split('#\\s*,\\s*#', $attrs['archive']))); } if (!empty($temp)) { $GLOBALS['_base'] = $temp; } break; case 'object': if (isset($attrs['usemap'])) { $rebuild = true; $attrs['usemap'] = complete_url($attrs['usemap']); } if (isset($attrs['codebase'])) { $rebuild = true; $temp = $GLOBALS['_base']; url_parse(complete_url(rtrim($attrs['codebase'], '/') . '/', false), $GLOBALS['_base']); unset($attrs['codebase']); } if (isset($attrs['data'])) { $rebuild = true; $attrs['data'] = complete_url($attrs['data']); } if (isset($attrs['classid']) && !preg_match('#^clsid:#i', $attrs['classid'])) { $rebuild = true; $attrs['classid'] = complete_url($attrs['classid']); } if (isset($attrs['archive'])) { $rebuild = true; $attrs['archive'] = implode(' ', array_map('complete_url', explode(' ', $attrs['archive']))); } if (!empty($temp)) {