public function import()
 {
     $type = input('post.type', 'trim', 'input');
     $auid = input('post.auid', 'intval');
     !$auid && $this->error('auto_user_error');
     switch ($type) {
         case 'input':
             $url_list = input('post.url_list', 'urldecode');
             break;
         case 'file':
             $url_file = $_FILES['url_file'];
             $url_list = file_get_contents($url_file['tmp_name']);
             break;
     }
     $url_list = split(PHP_EOL, $url_list);
     //获取马甲
     $auto_user_mod = M('auto_user');
     $user_mod = M('user');
     $unames = $auto_user_mod->where(array('id' => $auid))->getField('users');
     $unamea = explode(',', $unames);
     $users = $user_mod->field('id,username')->where(array('username' => array('in', $unamea)))->select();
     !$users && $this->error('auto_user_error');
     //开始处理
     $item_mod = D('item');
     foreach ($url_list as $url) {
         if (!$url) {
             continue;
         }
         //获取商品信息
         $itemcollect = new itemcollect();
         $itemcollect->url_parse($url);
         $item = $itemcollect->fetch();
         if (!($item = $itemcollect->fetch())) {
             continue;
         }
         $item = $item['item'];
         //判断是否已经存在(避免后期修改过商品信息,如果存在则不处理)
         $item_id = $item_mod->where(array('key_id' => $item['key_id']))->getField('id');
         if ($item_id) {
             continue;
         }
         //随机取一个马甲
         $user_rand = array_rand($users);
         //整理商品数据
         $item['uid'] = $users[$user_rand]['id'];
         $item['uname'] = $users[$user_rand]['username'];
         //添加商品
         $result = $item_mod->publish($item);
     }
     $this->success(L('operation_success'));
 }
Example #2
0
 public function fetch_item() {
     $url = $this->_get('url', 'trim');
     $url == '' && $this->ajaxReturn(0, L('please_input') . L('correct_itemurl'));
     $aid = $this->_get('aid', 'intval');
     //获取商品信息
     $itemcollect = new itemcollect();
     !$itemcollect->url_parse($url) && $this->ajaxReturn(0, L('please_input') . L('correct_itemurl'));
     if (!$info = $itemcollect->fetch()) {
         $this->ajaxReturn(0, L('fetch_item_failed'));
     }
     $this->assign('item', $info['item']);
     $data = array();
     if ($aid) {
         $this->assign('aid', $aid);
     } else {
         //用户的专辑
         $album_list = M('album')->field('id,title')->where(array('uid' => $this->visitor->info['id']))->select();
         //专辑分类
         if (false === $album_cate_list = F('album_cate_list')) {
             $album_cate_list = D('album_cate')->cate_cache();
         }
         $this->assign('album_cate_list', $album_cate_list);
         $this->assign('album_list', $album_list);
     }
     //专辑分类
     $data['html'] = $this->fetch('dialog:fetch_item');
     $data['item'] = serialize($info['item']);
     $this->ajaxReturn(1, L('fetch_item_success'), $data);
 }
Example #3
0
 public function ajax_getclick_url()
 {
     $iid = $this->_get("iid", "trim");
     $url = "http://item.taobao.com/item.htm?id=" . $iid;
     $itemcollect = new itemcollect();
     $itemcollect->url_parse($url);
     $item = $itemcollect->fetch_tb();
     if ($item) {
         $this->ajaxReturn(1, l("operation_success"), $item['click_url']);
     }
     $this->ajaxReturn(0, l("operation_failure"));
 }
Example #4
0
 public function ajax_getclick_url()
 {
     $iid = $this->_get('iid', 'trim');
     $url = 'http://item.taobao.com/item.htm?id=' . $iid;
     $itemcollect = new itemcollect();
     $itemcollect->url_parse($url);
     $item = $itemcollect->fetch_tb();
     if ($item = $itemcollect->fetch_tb()) {
         $this->ajaxReturn(1, L('operation_success'), $item['click_url']);
     }
     $this->ajaxReturn(0, L('operation_failure'));
 }
Example #5
0
 public function ajaxgetdesc()
 {
     $url = $this->_get("url", "trim");
     if ($url == "") {
         $this->ajaxReturn(0, l("please_input") . l("correct_itemurl"));
     }
     if (!$this->get_id($url)) {
         $this->ajaxReturn(0, l("please_input") . l("correct_itemurl"));
     }
     $itemcollect = new itemcollect();
     $itemcollect->url_parse($url);
     if ($item = $itemcollect->get_desc()) {
         $this->ajaxReturn(1, "", $item);
     }
     $this->ajaxReturn(0, l("item_not_excute"));
 }