Example #1
0
 public function save()
 {
     $token = $this->input->post('token', TRUE);
     if ($token != $_SESSION['token']) {
         msg_url('非法提交~!', 'javascript:history.back();');
     }
     //检测发表权限
     $zuid = getzd('user', 'zid', $_SESSION['cscms__id']);
     $rowu = $this->CsdjDB->get_row('userzu', 'aid,sid', $zuid);
     if (!$rowu || $rowu->aid == 0) {
         msg_url('您所在会员组没有权限发表视频~!', 'javascript:history.back();');
     }
     //检测发表数据是否需要审核
     $vod['yid'] = $rowu->sid == 1 ? 0 : 1;
     //选填字段
     $vod['cion'] = intval($this->input->post('cion'));
     $vod['dcion'] = intval($this->input->post('dcion'));
     $vod['text'] = str_replace("\r\n", "<br>", str_encode($_POST['text']));
     $vod['pic'] = $this->input->post('pic', TRUE, TRUE);
     $vod['tags'] = $this->input->post('tags', TRUE, TRUE);
     $vod['daoyan'] = $this->input->post('daoyan', TRUE, TRUE);
     $vod['zhuyan'] = $this->input->post('zhuyan', TRUE, TRUE);
     $vod['yuyan'] = $this->input->post('yuyan', TRUE, TRUE);
     $vod['diqu'] = $this->input->post('diqu', TRUE, TRUE);
     $vod['year'] = $this->input->post('year', TRUE, TRUE);
     $vod['info'] = $this->input->post('info', TRUE, TRUE);
     $vod['uid'] = $_SESSION['cscms__id'];
     $vod['addtime'] = time();
     $down = $this->input->post('down', TRUE, TRUE);
     $durl = $this->input->post('durl', TRUE, TRUE);
     //必填字段
     $vod['name'] = $this->input->post('name', TRUE, TRUE);
     $vod['cid'] = intval($this->input->post('cid'));
     $play = $this->input->post('play', TRUE, TRUE);
     $purl = $this->input->post('purl', TRUE, TRUE);
     //检测必须字段
     if ($vod['cid'] == 0) {
         msg_url('请选择视频分类~!', 'javascript:history.back();');
     }
     if (empty($vod['name'])) {
         msg_url('视频名称不能为空~!', 'javascript:history.back();');
     }
     if (empty($play)) {
         msg_url('视频播放来源不能为空~!', 'javascript:history.back();');
     }
     if (empty($purl)) {
         msg_url('视频播放地址不能为空~!', 'javascript:history.back();');
     }
     //播放地址组合
     if ($play != 'flv' && $play != 'media') {
         if (substr($purl, 0, 7) != 'http://') {
             msg_url('视频播放地址不正确~!', 'javascript:history.back();');
         }
         $arr = caiji($purl, 1);
         $form = $arr['laiy'];
         $purl = $arr['url'];
         if (empty($vod['pic'])) {
             $vod['pic'] = $arr['pic'];
         }
         $vod['purl'] = '第01集$' . $purl . '$' . $form;
     } else {
         $vod['purl'] = '第01集$' . $purl . '$' . $play;
     }
     //下载地址组合
     if (!empty($down) && !empty($durl)) {
         $vod['durl'] = '第01集$' . $durl . '$' . $down;
     }
     $singer = $this->input->post('singer', TRUE, TRUE);
     //判断歌手是否存在
     if (!empty($singer)) {
         $row = $this->CsdjDB->get_row('singer', 'id', $singer, 'name');
         if ($row) {
             $vod['singerid'] = $row->id;
         }
     }
     //增加到数据库
     $did = $this->CsdjDB->get_insert('vod', $vod);
     if (intval($did) == 0) {
         msg_url('视频发布失败,请稍候再试~!', 'javascript:history.back();');
     }
     //摧毁token
     unset($_SESSION['token']);
     //增加动态
     $dt['dir'] = 'vod';
     $dt['uid'] = $_SESSION['cscms__id'];
     $dt['did'] = $did;
     $dt['yid'] = $vod['yid'];
     $dt['title'] = '发布了视频';
     $dt['name'] = $vod['name'];
     $dt['link'] = linkurl('show', 'id', $did, 1, 'vod');
     $dt['addtime'] = time();
     $this->CsdjDB->get_insert('dt', $dt);
     //如果免审核,则给会员增加相应金币、积分
     if ($vod['yid'] == 0) {
         $addhits = getzd('user', 'addhits', $_SESSION['cscms__id']);
         if ($addhits < User_Nums_Add) {
             $this->db->query("update " . CS_SqlPrefix . "user set cion=cion+" . User_Cion_Add . ",jinyan=jinyan+" . User_Jinyan_Add . ",addhits=addhits+1 where id=" . $_SESSION['cscms__id'] . "");
         }
         msg_url('恭喜您,视频发布成功~!', spacelink('vod', 'vod'));
     } else {
         msg_url('恭喜您,视频发布成功,请等待管理员审核~!', spacelink('vod/verify', 'vod'));
     }
 }
Example #2
0
 public function caiji()
 {
     $vodurl = $this->input->get('vodurl', true);
     if (empty($vodurl)) {
         $data['id'] = intval($this->input->get_post('id'));
         $data['sid'] = intval($this->input->get_post('sid'));
         $data['check'] = $data['id'] == 1 ? 'checked' : '';
         $this->load->view('vod_caiji.html', $data);
     } else {
         echo caiji($vodurl);
     }
 }
Example #3
-1
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $content = curl_exec($ch);
    curl_close($ch);
    $little = stripos($content, '一般全文 start');
    $content = substr($content, $little);
    $last = stripos($content, '一般全文 end');
    $content = substr($content, 0, $last);
    $content = str_replace("\n", "", $content);
    $content = str_replace("\r", "", $content);
    preg_match("/<div class=\"artical-content-read\">(.*?)<span id=\"editor_baidu/", $content, $arr);
    return $arr[1];
}
$newsurl = "http://voice.hupu.com/soccer/newslist";
$newsarr = caiji($newsurl);
$newnewsarr = array();
$i = 0;
foreach ($newsarr as $key => $value) {
    $content = str_replace("div", "p", once($value['link']));
    //虎扑的图片是禁止外站调用的,所以你要把图片下载到本地
    preg_match("/src=\"(.*?)((.jpg)|(.png)|(.jpeg))(.*?)\"/", $content, $img);
    $imgstr = file_get_contents($img[1] . $img[2]);
    $dir = "./Yourdir/";
    if (!file_exists($dir)) {
        mkdir($dir);
    }
    $tempdir = $dir . date("Ymdhis") . "_" . rand(10000, 99999) . $img[2];
    //下载图片并保持到本地---END
    file_put_contents($tempdir, $imgstr);
    $tempdir = substr($tempdir, 1);