public function fetch($url)
    {
        global $_FANWE;
        $id = $this->getID($url);
        if (empty($id)) {
            return false;
        }
        $key = '360buy_' . $id;
        $share_goods = FDB::resultFirst('SELECT share_id,goods_id FROM ' . FDB::table('share_goods') . ' 
			WHERE uid = ' . $_FANWE['uid'] . " AND goods_key = '{$key}'");
        if ($share_goods) {
            $result['status'] = -1;
            $result['share_id'] = $share_goods['share_id'];
            $result['goods_id'] = $share_goods['goods_id'];
            return $result;
        }
        //请求数据
        $content = getUrlContent("http://www.360buy.com/product/" . $id . ".html");
        if (empty($content)) {
            return false;
        }
        $content = gbToUTF8($content);
        $content = preg_replace("/[\r\n]/", '', $content);
        @preg_match("/<h1>(.*?)<\\/h1>/", $content, $title);
        if (empty($title)) {
            return false;
        }
        @preg_match("/<div id=\"preview\".*?>.*?<img.*?src=\"(.*?)\".*?jqimg=\"(.*?)\"\\/><\\/div>/", $content, $img);
        if (empty($img)) {
            return false;
        }
        @preg_match("/<strong class=\"price\"><img.*?src =\"(.*?)\"\\/><\\/strong>/", $content, $price);
        if (empty($price)) {
            return false;
        } else {
            $price = $this->getPrice($price[1]);
            if ($price === false) {
                return false;
            }
        }
        if (FS("Image")->getIsServer()) {
            $args = array();
            $args['pic_url'] = $img[2];
            $server = FS("Image")->formatServer($_FANWE['request']['image_server'], 'DE');
            $server = FS("Image")->getImageUrlToken($args, $server, 1);
            $body = FS("Image")->sendRequest($server, 'savetemp', true);
            if (empty($body)) {
                return false;
            }
            $image = unserialize($body);
            $result['image_server'] = $server['image_server'];
        } else {
            $image = copyFile($img[2], "temp", false);
            if ($image === false) {
                return false;
            }
            $image['server_code'] = '';
        }
        $result['item']['key'] = $key;
        $result['item']['name'] = strip_tags(trim($title[1]));
        $result['item']['price'] = $price;
        $result['item']['img'] = $image['path'];
        $result['item']['server_code'] = $image['server_code'];
        $result['item']['pic_url'] = $img[1];
        $result['item']['url'] = "http://www.360buy.com/product/" . $id . ".html";
        $unionId = $_FANWE['cache']['business']['jdbuy']['unionId'];
        if (!empty($unionId)) {
            $result['item']['taoke_url'] = "http://click.union.360buy.com/JdClick/?unionId=" . $unionId . "&t=4&to=" . $result['item']['url'];
        }
        return $result;
    }
    public function fetch($url)
    {
        global $_FANWE;
        $id = $this->getID($url);
        if (empty($id)) {
            return false;
        }
        $key = 'dangdang_' . $id;
        $share_goods = FDB::resultFirst('SELECT share_id,goods_id FROM ' . FDB::table('share_goods') . ' 
			WHERE uid = ' . $_FANWE['uid'] . " AND goods_key = '{$key}'");
        if ($share_goods) {
            $result['status'] = -1;
            $result['share_id'] = $share_goods['share_id'];
            $result['goods_id'] = $share_goods['goods_id'];
            return $result;
        }
        //请求数据
        $content = getUrlContent("http://product.dangdang.com/product.aspx?product_id=" . $id);
        if (empty($content)) {
            return false;
        }
        $content = gbToUTF8($content);
        $content = preg_replace("/[\r\n]/", '', $content);
        @preg_match("/<h1>(.*?)<\\/h1>/", $content, $title);
        if (empty($title)) {
            return false;
        }
        @preg_match("/var oldimage \\= '(.*?)';/", $content, $img);
        if (empty($img)) {
            return false;
        }
        @preg_match("/<span class=\"promotions_price_d\">¥<b>(.*?)<\\/b><\\/span>/u", $content, $price);
        if (empty($price)) {
            @preg_match("/<span.*?id=\"salePriceTag\">¥(.*?)<\\/span>/u", $content, $price);
            if (empty($price)) {
                return false;
            } else {
                $price = (double) $price[1];
            }
        } else {
            $price = (double) $price[1];
        }
        if (FS("Image")->getIsServer()) {
            $args = array();
            $args['pic_url'] = $img[1];
            $server = FS("Image")->formatServer($_FANWE['request']['image_server'], 'DE');
            $server = FS("Image")->getImageUrlToken($args, $server, 1);
            $body = FS("Image")->sendRequest($server, 'savetemp', true);
            if (empty($body)) {
                return false;
            }
            $image = unserialize($body);
            $result['image_server'] = $server['image_server'];
        } else {
            $image = copyFile($img[1], "temp", false);
            if ($image === false) {
                return false;
            }
            $image['server_code'] = '';
        }
        $result['item']['key'] = $key;
        $result['item']['name'] = strip_tags(str_replace('[当当自营]', '', $title[1]));
        $result['item']['price'] = $price;
        $result['item']['img'] = $image['path'];
        $result['item']['server_code'] = $image['server_code'];
        $result['item']['pic_url'] = $img[1];
        $result['item']['url'] = "http://product.dangdang.com/product.aspx?product_id=" . $id;
        $from = $_FANWE['cache']['business']['dangdang']['from'];
        if (!empty($from)) {
            $result['item']['taoke_url'] = "http://union.dangdang.com/transfer.php?from=" . $from . "&ad_type=10&sys_id=1&backurl=" . $result['item']['url'];
        }
        @preg_match("/<div class=\"legend\"><a href=\"http:\\/\\/shop\\.dangdang\\.com\\/(.*?)\".*?>(.*?)<\\/a><a.*?>.*?<\\/a><\\/div>/", $content, $shop);
        if (!empty($shop)) {
            $result['shop']['name'] = $shop[2];
            $result['shop']['url'] = "http://shop.dangdang.com/" . $shop[1];
            if (!empty($from)) {
                $result['shop']['taoke_url'] = "http://union.dangdang.com/transfer.php?from=" . $from . "&ad_type=10&sys_id=1&backurl=" . $result['shop']['url'];
            }
            if (!FS("Shop")->getShopExistsByUrl($result['shop']['url'])) {
                $content = getUrlContent($result['shop']['url']);
                if (!empty($content)) {
                    $content = preg_replace("/[\r\n]/", '', $content);
                    @preg_match("/<dl.*?id=\"hslice_shop_basic_info_" . $shop[1] . "\">.*?<dt><a.*?><img src=\"(.*?)\".*?\\/><\\/a><\\/dt>/", $content, $shop_img);
                    if (!empty($shop_img)) {
                        if (FS("Image")->getIsServer()) {
                            $args = array();
                            $args['pic_url'] = $shop_img[1];
                            $server = FS("Image")->getImageUrlToken($args, '', 1);
                            $body = FS("Image")->sendRequest($server, 'savetemp', true);
                            if (!empty($body)) {
                                $image = unserialize($body);
                            } else {
                                $image = false;
                            }
                        } else {
                            $image = copyFile($shop_img[1], "temp", false);
                            if ($image === false) {
                                $image['server_code'] = '';
                            }
                        }
                        if ($image !== false) {
                            $result['shop']['logo'] = $image['path'];
                            $result['shop']['server_code'] = $image['server_code'];
                        }
                    }
                }
            }
        }
        return $result;
    }
Ejemplo n.º 3
0
 function updatepw($get, $post)
 {
     if (!API_UPDATEPW) {
         return API_RETURN_FORBIDDEN;
     }
     $username = $get['username'];
     $uid = intval($get['uid']);
     if ($this->charset == 'gbk') {
         $username = addslashes(gbToUTF8($username));
     }
     $newpw = md5(time() . rand(100000, 999999));
     FDB::query("UPDATE " . FDB::table('user') . " SET password='******' WHERE user_name='{$username}'  limit 1");
     return API_RETURN_SUCCEED;
 }
Ejemplo n.º 4
0
 /**
  * 
  * 检查email是否存在(或被其它用户占用)
  * @param string $email
  * @param string $uid 对方系统用户关键字 (如果$uid,不为空的话,则过滤$uid)
  * 
  * return true; //email不存在(或属于$username用户的),可用
  * return false;//email存在,或格式不对,不可用
  */
 function check_email($email, $uid = 0)
 {
     if ($this->charset == 'gbk') {
         $email = addslashes(utf8ToGB($email));
         //$username = addslashes(utf8ToGB($username));
     } else {
         $email = addslashes($email);
         //$username = addslashes($username);
     }
     /*
         	if ($this->charset == 'gbk'){
         		$uname = addslashes(gbToUTF8($uname));
         	}else{
         		$username = addslashes($uname);
         	}
     */
     $email_exist = uc_user_checkemail($email);
     //echo $email."<br>".$email_exist."<br>".$username;
     if ($email_exist == -4) {
         $this->error = '无效的email格式';
         return false;
     } else {
         if ($email_exist == -5) {
             $this->error = '限制注册的email';
             return false;
         } else {
             if ($email_exist == -6) {
                 //'email已经存在'
                 if ($uid > 0) {
                     list($uid, $uname, $email2) = uc_get_user($uid, 1);
                     //isuid:0:username; 1:uid
                     //print_r($status); exit;
                     if ($email2 == $email) {
                         //email已经存在,是属于$username这个用户的
                         return true;
                     }
                 }
                 if ($this->charset == 'gbk') {
                     $email = gbToUTF8($email);
                 }
                 $this->error = $email . ':邮件已经被其它用户占用';
                 return false;
             } else {
                 if ($email_exist == 1) {
                     //email不存在,可用
                     return true;
                 }
             }
         }
     }
 }