コード例 #1
0
ファイル: checkformedia.php プロジェクト: gaoerjun/Web
//更新“圣言及反思”音频
$tmNow = time();
$base = intval(date('H', $tmNow)) % 12;
$i = 0;
while ($i < 2) {
    $tmNow = time() + ($base + $i * 12) * 3600 * 24;
    $strDate = date('Y-m-d', $tmNow);
    $link = 'http://apps.thomasluk.idv.hk/apps/themes/read_bible/' . date('Ymd', $tmNow) . 'p.mp3';
    $lmp3 = './thought/mp3/' . date('Y-m-d', $tmNow) . '.mp3';
    if (!file_exists($lmp3)) {
        $cxdate = date("Y-n-j", $tmNow);
        $cxradio = 'http://radio.cxsm.org/playlist/' . $cxdate . '.txt';
        $cxlist = explode("\n", file_get_contents($cxradio));
        //或是url list
        if (count($cxlist) > 1) {
            $link = cn_urlencode(trim($cxlist[1]));
            echo "Use cxradio mp3<br/>";
        }
        echo "check link:" . $link . "<br/>";
        if (url_exists($link)) {
            $bname = basename($link);
            echo "base name:" . $bname . '<br/>';
            $local = './objs/' . time() . '_' . $bname;
            curl_download($link, $local);
            echo "download from:" . $link . "<br/>";
            if (!rename($local, $lmp3)) {
                echo "rename false<br/>";
            }
        }
    }
    $i++;
コード例 #2
0
ファイル: updatedata.php プロジェクト: gaoerjun/Web
    $cxdate = date("Y-n-j", $date);
    $cxradio = 'http://211.149.237.175/playlist/' . $cxdate . '.txt';
    if (url_exists($cxradio)) {
        $cxlist = explode("\n", file_get_contents($cxradio));
        //或是url list
        $cnpreg = "/[\\x{4e00}-\\x{9fa5}]+/u";
        $cxjson["title"] = "晨星生命之音";
        $cxjson["date"] = $strDate;
        $cxjson["logo"] = "http://www.cathassist.org/radio/logos/cx.png";
        $i = 0;
        foreach ($cxlist as $v) {
            $v = iconv("GB2312", "UTF-8//IGNORE", trim($v));
            $title = "";
            preg_match_all($cnpreg, substr($v, strrpos($v, '/')), $title);
            $title = implode("", $title[0]);
            $cxjson['items'][$i] = array('title' => $title, 'src' => cn_urlencode($v));
            ++$i;
        }
        file_put_contents($cxfile, json_encode($cxjson));
        append2All("cx", $cxjson);
    } else {
        echo "Can't update cxradio...<br/>";
    }
}
$vafile = './vacn/' . $strDate;
$vajson = null;
if (!file_exists($vafile)) {
    $vajson["title"] = "梵蒂冈中文广播";
    $vajson["date"] = $strDate;
    $vajson["logo"] = "http://www.cathassist.org/radio/logos/vacn.jpg";
    $itemsrc = "http://media.cathassist.org/vaticanradio/cn/mp3/" . $strDate . ".mp3";
コード例 #3
0
ファイル: Ftp.class.php プロジェクト: gzwyufei/hp
 /**
  * 远程保存
  * @param $value 传入下载内容
  * @param $watermark 是否加入水印
  * @param $ext 下载扩展名
  */
 public function download($value, $watermark = null, $ext = 'gif|jpg|jpeg|bmp|png')
 {
     //检查是否有开启CURL
     if (!function_exists('curl_init')) {
         return $value;
     }
     $this->handlerLocal = new \UploadFile();
     //水印开关
     if (is_null($watermark)) {
         if ($this->config['watermarkenable']) {
             $watermark = true;
         }
     }
     $curl = curl_init();
     //正则匹配是否有符合数据
     if (!preg_match_all("/(href|src)=([\"|']?)([^ \"'>]+\\.({$ext}))\\2/i", $value, $matches)) {
         return $value;
     }
     $remotefileurls = array();
     //过滤域名
     $NoDomain = explode("|", $this->config['fileexclude']);
     //当前程序所在域名地址
     $NoDomain[] = urlDomain(get_url());
     //附件地址
     $upload_url = urlDomain($this->options['sitefileurl']);
     foreach ($matches[3] as $matche) {
         //过滤远程地址
         if (strpos($matche, '://') === false) {
             continue;
         }
         //过滤后台设置的域名,和本站域名
         if (in_array(urlDomain($matche), $NoDomain)) {
             continue;
         }
         $remotefileurls[] = $matche;
     }
     $oldpath = $newpath = array();
     foreach ($remotefileurls as $k => $file) {
         if (strpos($file, '://') === false || strpos($file, $upload_url) !== false) {
             continue;
         }
         //取得文件扩展
         $file_fileext = fileext($file);
         //取得文件名
         $file_name = basename($file);
         //保存文件名
         $filename = $this->handlerLocal->getSaveName(array('name' => $file_name, 'extension' => $file_fileext, 'savename' => $this->options['savePath']));
         // 设置你需要抓取的URL
         curl_setopt($curl, CURLOPT_URL, cn_urlencode($file));
         // 设置header
         curl_setopt($curl, CURLOPT_HEADER, 0);
         // 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         //超时设置
         curl_setopt($curl, CURLOPT_TIMEOUT, 10);
         // 运行cURL,请求网页
         $filedata = curl_exec($curl);
         //保存图片
         $status = $this->build_file($filedata, $this->options['savePath'] . $filename);
         if ($status) {
             //加水印
             if ($watermark) {
                 $this->water($this->options['savePath'] . $filename, "", $this->options['savePath'] . $filename);
             }
             $oldpath[] = $file;
             $newpath[] = str_replace($this->options['uploadfilepath'], $this->options['sitefileurl'], $this->options['savePath'] . $filename);
             $info = array("name" => $file_name, "type" => "", "size" => filesize($this->options['savePath'] . $filename), "key" => "", "extension" => $file_fileext, "savepath" => $this->options['savePath'], "savename" => $filename, "hash" => md5(str_replace($this->options['uploadfilepath'], "", $this->options['savePath'] . $filename)));
             $info['url'] = $this->options['sitefileurl'] . str_replace($this->options['uploadfilepath'], '', $info['savepath'] . $info['savename']);
             $aid = D('Attachment/Attachment')->fileInfoAdd($info, $this->options['module'], $this->options['catid'], $this->options['thumb'], $this->options['isadmin'], $this->options['userid'], $this->options['time']);
             //上传到FTP
             $filePath = $info['savepath'] . $info['savename'];
             if ($this->FTPuplode($filePath, $filePath)) {
                 //上传成功
                 if ($this->options['isupftpdel']) {
                     try {
                         unlink($info[$i]['savepath'] . $info[$i]['savename']);
                     } catch (Exception $exc) {
                     }
                 }
             } else {
                 $this->error = $this->handler->get_error();
                 try {
                     unlink($info[$i]['savepath'] . $info[$i]['savename']);
                 } catch (Exception $exc) {
                 }
             }
             //设置标识
             $this->upload_json($aid, $info['url'], $filename);
         }
     }
     // 关闭URL请求
     curl_close($curl);
     $value = str_replace($oldpath, $newpath, $value);
     return $value;
 }
コード例 #4
0
ファイル: getradio.php プロジェクト: gaoerjun/Web
 function getRadio($date)
 {
     global $refresh;
     $strDate = gmdate('Y-m-d', $date);
     $cxfile = './cx/' . $strDate;
     $cxjson = null;
     if (!file_exists($cxfile) or $refresh) {
         $cxdate = gmdate("Y-n-j", $date);
         $cxradio = 'http://211.149.237.175//playlist/' . $cxdate . '.txt';
         $cxlist = explode("\n", file_get_contents($cxradio));
         //或是url list
         $cnpreg = "/[\\x{4e00}-\\x{9fa5}]+/u";
         $cxjson["title"] = "晨星生命之音";
         $cxjson["date"] = $strDate;
         $cxjson["logo"] = "http://www.cathassist.org/radio/logos/cx.png";
         $cxjson["desc"] = "我们因爱而相聚";
         $i = 0;
         foreach ($cxlist as $v) {
             $v = iconv("GB2312", "UTF-8//IGNORE", trim($v));
             $title = "";
             preg_match_all($cnpreg, substr($v, strrpos($v, '/')), $title);
             $title = implode("", $title[0]);
             $cxjson['items'][$i] = array('title' => $title, 'src' => cn_urlencode($v));
             ++$i;
         }
         if ($i < 1) {
             return null;
         }
         file_put_contents($cxfile, json_encode($cxjson));
         BaseChannel::append2All("cx", $cxjson);
     } else {
         $cxjson = json_decode(file_get_contents($cxfile), true);
     }
     unset($cxjson["desc"]);
     return $cxjson;
 }
コード例 #5
0
ファイル: NewsController.class.php プロジェクト: gzwyufei/hp
 public function edit()
 {
     if (IS_POST) {
         /*
          * 跳转方法已修改成SESSION
         $backurl=I('post.backUrl');
         $backurlarr=explode("&",$backurl);
         for($i=2;$i<count($backurlarr);$i++){
             $backarr[]=$backurlarr[$i];
         }
         $backarr=str_replace("amp;","",$backarr);
         $backarr=str_replace("=","/",$backarr);
         
         foreach($backarr as $v){
             $backurls.=$v."/";
         }
         $goback=substr($backurls,0,strlen($backurls)-1);
         $goback='Admins/News/index/'.$goback;
         */
         if (false !== D('Admins/News')->editModel($_POST)) {
             //$this->success("信息更新成功!",U($goback));
             $backurl = session('backurl');
             session('backurl', null);
             $this->success("信息更新成功!", $backurl);
         } else {
             $error = D('Admins/News')->getError();
             $this->error($error ? $error : '信息修改失败!');
         }
     } else {
         $this->assign('linkarr', cn_urlencode(getSearchArr(I('get.'))));
         $id = I('get.id', 0, 'intval');
         $where = array('id' => $id);
         $this->info = M('News')->where($where)->find();
         $this->catelist = M('NewsCate')->where(array('status' => true))->select();
         $this->display();
     }
 }