Example #1
0
 protected function get($path = "")
 {
     $path = realpath($path);
     $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST);
     $collect = new collect();
     foreach ($objects as $name => $object) {
         $collect->pu($name);
     }
 }
 /**
  * 添加或取消关注
  */
 public function toggleCollect($userId)
 {
     $owner = $this->getOwner();
     $collect = Collect::model()->findByAttributes(array('userId' => $userId, 'collectableEntityId' => $owner->entityId));
     if ($collect) {
         $collect->delete();
         return false;
     } else {
         $collect = new collect();
         $collect->userId = $userId;
         $collect->collectableEntityId = $owner->entityId;
         $collect->addTime = time();
         $collect->save();
         return true;
     }
 }
 /**
  * 直接入库 array $html(cid)+string content.url   
  * 先检测 ——>组合数据——>添加/更新 
  * @param string $url
  * @param array  $html
  */
 function videoImport($url, $html, $nid = '')
 {
     foreach ($html['playurl'] as $v) {
         $playurl .= $v . "\r\n";
     }
     $html['playurl'] = trim($playurl);
     $check = $this->UpCheck($url, $html, $nid);
     if (!$check) {
         $this->error = $this->getError();
         return false;
     } else {
         //组合数据
         if (!empty($html['cname']) && (empty($html['cid']) || $html['cid'] == 999)) {
             if ($html['cid'] == 999) {
                 //采集时未匹配到系统分类的
                 $cid = collect::get_Autochannel_id($html['cname'], $nid);
                 //再次检测是否有对应自定义分类
                 if ($cid) {
                     $html['cid'] = $cid;
                 }
             } else {
                 $html['cid'] = collect::get_syschannel_id($html['cname']);
                 //cname 转换为系统栏目id
             }
             if (!$html['cid'] || $html['cid'] == 999) {
                 $this->error = '没找到对应栏目,入库失败!';
                 return false;
             }
             unset($html['cname']);
         }
         $html['reurl'] = $url;
         if ($check != 'add' && $check != 'status') {
             //返回id更新数据
             return $this->VideoSave($html, $nid, $check);
         } else {
             //新增
             if ($check === 'status') {
                 $html['status'] = -1;
             }
             return $this->VideoSave($html, $nid);
         }
     }
 }
Example #4
0
 /**
  * 根据正则获取指定数据 单个
  *
  * @param mixed $pregArr 正则
  * @param string $code    源内容
  * @return bool|string
  */
 public static function getMatch($pregArr, $code)
 {
     if (is_string($pregArr)) {
         $pregArr = array('rule' => $pregArr);
     } elseif (empty($pregArr['rule'])) {
         return '';
     }
     $pregstr = '{' . $pregArr['rule'] . '}';
     if (!empty($pregArr['option'])) {
         $pregstr .= $pregArr['option'];
     }
     preg_match($pregstr, $code, $match);
     if (isset($match['1'])) {
         if (empty($pregArr['replace'])) {
             return $match['1'];
         } else {
             return collect::replace($match[1], $pregArr['replace']);
         }
     }
     return false;
 }
Example #5
0
 /**
  * 采集影片入库管理
  * @param $act
  */
 function Inflow($act)
 {
     if ($act == 'inflow') {
         if (empty($_POST['ids'])) {
             $this->error = '请选择需入库影片!';
             return false;
         }
         $ArrID = $_POST['ids'];
     } else {
         $where['status'] = array('neq', 0);
         if ($act == 'today') {
             $where['addtime'] = array('gt', xtime(1));
         }
         if ($act == 'allunused') {
             $where['status'] = 1;
         }
         if ($act == 'allinflow') {
             $where = '';
         }
         $All = $this->ContDB->field('id')->where($where)->select();
         foreach ($All as $k => $v) {
             $ArrID[$k] = $v['id'];
         }
     }
     foreach ($ArrID as $key => $val) {
         $Cont = $this->ContDB->field('nid,url,data')->where('id=' . $val)->find();
         $data = collect::string2array(stripslashes($Cont['data']));
         $result .= '[' . $data['cname'] . ']<strong>' . $data['title'] . '</strong>';
         if (!$this->CModel->videoImport($Cont['url'], $data, $Cont['nid'])) {
             $result .= $this->CModel->getError() . "\n\r";
             continue;
         } else {
             $UpCont = array('status' => 2);
             /*if($data['cid']==999){
             			unset($data['cid']);
             			$UpCont['data']=collect::array2string($data);
             		}*/
             $Update = $this->ContDB->where('id=' . $val)->save($UpCont);
             $result .= "入库成功!\n\r";
         }
     }
     $result = explode("\n\r", $result);
     return $result;
     //if(!empty($this->error)) return false;
     //return true;
 }