Exemple #1
0
 public function load($id = 0)
 {
     @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     @header("Cache-Control: no-cache, must-revalidate");
     @header("Pragma: no-cache");
     $this->load->model('CsdjUser');
     $login = '******';
     $id = (int) $id;
     //ID
     //判断ID
     if ($id == 0) {
         msg_url(L('dance_12'), Web_Path);
     }
     //获取数据
     $row = $this->CsdjDB->get_row_arr('dance', 'id,cid,name,durl,fid,uid,cion,vip,level', $id);
     if (!$row) {
         msg_url(L('dance_12'), Web_Path);
     }
     if (empty($row['durl'])) {
         msg_url(L('dance_12'), Web_Path);
     }
     $durl = $row['durl'];
     if ($row['fid'] > 0) {
         $rowf = $this->db->query("Select durl from " . CS_SqlPrefix . "dance_server where id=" . $row['fid'] . "")->row_array();
         if ($rowf) {
             $durl = $rowf['durl'] . $row['durl'];
         }
     }
     //自动补上完整路径
     $durl = annexlink($durl);
     if (substr($durl, 0, 7) != 'http://') {
         $durl = "http://" . Web_Url . Web_Path . $durl;
     }
     //判断收费
     if ($row['vip'] > 0 || $row['level'] > 0 || $row['cion'] > 0 || User_YkDown == 0) {
         $this->CsdjUser->User_Login();
         $rowu = $this->CsdjDB->get_row_arr('user', 'vip,level,cion,zid', $_SESSION['cscms__id']);
     }
     //判断会员组下载权限
     if ($row['vip'] > 0 && $row['uid'] != $_SESSION['cscms__id'] && $rowu['vip'] == 0) {
         if ($row['vip'] > $rowu['zid']) {
             msg_url(L('dance_13'), 'javascript:window.close();');
         }
     }
     //判断会员等级下载权限
     if ($row['level'] > 0 && $row['uid'] != $_SESSION['cscms__id']) {
         if ($row['level'] > $rowu['level']) {
             msg_url(L('dance_14'), 'javascript:window.close();');
         }
     }
     //判断金币下载
     $down = 0;
     if ($row['cion'] > 0 && $row['uid'] != $_SESSION['cscms__id']) {
         //判断是否下载过
         $rowd = $this->db->query("SELECT id,addtime FROM " . CS_SqlPrefix . "dance_down where did='" . $id . "' and uid='" . $_SESSION['cscms__id'] . "'")->row_array();
         if ($rowd) {
             $down = 1;
             //数据已经存在
             $downtime = User_Downtime * 3600 + $rowd['addtime'];
             if ($downtime > time()) {
                 $down = 2;
                 //在多少时间内不重复扣币
             }
         }
         //判断会员组下载权限
         $rowz = $this->db->query("SELECT id,did FROM " . CS_SqlPrefix . "userzu where id='" . $rowu['vip'] . "'")->row_array();
         if ($rowz && $rowz['did'] == 1) {
             //有免费下载权限
             $down = 2;
             //该会员下载不收费
         }
         if ($down < 2) {
             //判断扣币
             if ($row['cion'] > $rowu['cion']) {
                 msg_url(vsprintf(L('dance_15'), array($row['cion'])), 'javascript:window.close();');
             } else {
                 //扣币
                 $edit['cion'] = $rowu['cion'] - $row['cion'];
                 $this->CsdjDB->get_update('user', $_SESSION['cscms__id'], $edit);
                 //写入消费记录
                 $add2['title'] = L('dance_16') . '《' . $row['name'] . '》';
                 $add2['uid'] = $_SESSION['cscms__id'];
                 $add2['dir'] = 'dance';
                 $add2['nums'] = $row['cion'];
                 $add2['ip'] = getip();
                 $add2['addtime'] = time();
                 $this->CsdjDB->get_insert('spend', $add2);
                 //判断分成
                 if (User_DownFun == 1 && $row['uid'] > 0) {
                     //分成比例
                     $bi = User_Downcion < 10 ? '0.0' . User_Downcion : '0.' . User_Downcion;
                     $scion = intval($row['cion'] * $bi);
                     if ($scion > 0) {
                         $this->db->query("update " . CS_SqlPrefix . "user set cion=cion+" . $scion . " where id=" . $row['uid'] . "");
                         //写入分成记录
                         $add3['title'] = vsprintf(L('dance_17'), array($row['name']));
                         $add3['uid'] = $row['uid'];
                         $add3['dir'] = 'dance';
                         $add3['nums'] = $scion;
                         $add3['ip'] = getip();
                         $add3['addtime'] = time();
                         $this->CsdjDB->get_insert('income', $add3);
                     }
                 }
             }
         }
         //增加下载记录
         if ($down == 0) {
             $add['name'] = $row['name'];
             $add['cid'] = $row['cid'];
             $add['did'] = $id;
             $add['ip'] = getip();
             $add['uid'] = $_SESSION['cscms__id'];
             $add['cion'] = $row['cion'];
             $add['addtime'] = time();
             $this->CsdjDB->get_insert('dance_down', $add);
         }
     }
     //同一数据24小时内只增加下载动态
     if ($this->cookie->get_cookie('down_dance_' . $id) != 'ok') {
         $dt['dir'] = 'dance';
         $dt['uid'] = $_SESSION['cscms__id'];
         $dt['did'] = $id;
         $dt['name'] = $row['name'];
         $dt['link'] = linkurl('play', 'id', $id, 0, 'dance');
         $dt['title'] = L('dance_16');
         $dt['addtime'] = time();
         $this->CsdjDB->get_insert('dt', $dt);
         $this->cookie->set_cookie("down_dance_" . $id, "ok", time() + 86400);
     }
     //增加下载人气
     $this->db->query("update " . CS_SqlPrefix . "dance set xhits=xhits+1 where id=" . $id . "");
     //------------------开始下载文件操作--------------------------------------
     //判断是否支持CURL
     if (!function_exists('curl_init')) {
         //不支持CURL
         header("Location: " . $durl);
     } else {
         //判断302跳转
         $a_array = get_headers($durl, true);
         if (strpos($a_array[0], '302') === FALSE) {
             //302跳转
             header("Location: " . $durl);
             exit;
         }
         //文件大小
         $filesize = $a_array['Content-Length'];
         //后缀
         $file_ext = strtolower(trim(substr(strrchr($durl, '.'), 1)));
         //名称
         $filename = $row['name'] . '.' . $file_ext;
         //大小
         $fsize = sprintf("%u", $filesize);
         //下载
         $file_path = $durl;
         if (ob_get_length() !== false) {
             @ob_end_clean();
         }
         header('Pragma: public');
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
         header('Cache-Control: no-store, no-cache, must-revalidate');
         header('Cache-Control: pre-check=0, post-check=0, max-age=0');
         header('Content-Transfer-Encoding: binary');
         header('Content-Encoding: none');
         header('Content-type: application/force-download');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Content-length: ' . $filesize);
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, $file_path);
         curl_exec($curl);
         curl_close($curl);
     }
 }
Exemple #2
0
 public function url($op = 'cmp', $id = 0)
 {
     @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     @header("Cache-Control: no-cache, must-revalidate");
     @header("Pragma: no-cache");
     $id = intval($id);
     //ID
     //判断ID
     if ($id == 0) {
         exit;
     }
     //获取数据
     $row = $this->CsdjDB->get_row_arr('dance', 'name,purl,fid,lrc', $id);
     if (!$row) {
         exit;
     }
     $purl = $row['purl'];
     if ($row['fid'] > 0) {
         $rowf = $this->db->query("Select purl from " . CS_SqlPrefix . "dance_server where id=" . $row['fid'] . "")->row_array();
         if ($rowf) {
             $purl = $rowf['purl'] . $row['purl'];
         }
     }
     $purl = annexlink($purl);
     if ($op == 'cmp') {
         echo '<list><m type="" src="' . $purl . '" lrc="' . Web_Path . 'index.php/dance/play/lrc/' . $id . '" label="' . $row['name'] . '" opened="1"></m></list>';
     } elseif ($op == 'wap') {
         header("location:" . $purl);
     } else {
         echo 'var mp3_u="' . $purl . '";';
         echo 'var mp3_l="' . str_replace("'", "", $row['lrc']) . '";';
     }
 }
Exemple #3
0
 public function down_save()
 {
     if ($this->huri['down']['check'] == 0) {
         admin_msg(L('plub_47'), 'javascript:history.back();', 'no');
     }
     $day = intval($this->input->get_post('day', true));
     //最近几天
     $ids = $this->input->get_post('ids', true);
     //需要生成的数据ID
     $cid = $this->input->get_post('cid', true);
     //需要生成的分类ID
     $newid = intval($this->input->get_post('newid'));
     //最新个数
     $ksid = intval($this->input->get_post('ksid'));
     //开始ID
     $jsid = intval($this->input->get_post('jsid'));
     //结束ID
     $kstime = $this->input->get_post('kstime', true);
     //开始日期
     $jstime = $this->input->get_post('jstime', true);
     //结束日期
     $pagesize = intval($this->input->get('pagesize'));
     //每页多少条
     $pagejs = intval($this->input->get('pagejs'));
     //总页数
     $datacount = intval($this->input->get('datacount'));
     //数据总数
     $page = intval($this->input->get('page'));
     //当前页
     if ($page == 0) {
         $page = 1;
     }
     $str = '';
     //将数组转换成字符
     if (is_array($cid)) {
         $cid = implode(',', $cid);
     }
     if (is_array($ids)) {
         $ids = implode(',', $ids);
     }
     if ($day > 0) {
         $times = time() - 86400 * $day;
         $str .= ' and addtime>' . $times . '';
     }
     if (!empty($cid)) {
         $str .= ' and cid in (' . $cid . ')';
     }
     if (!empty($ids)) {
         $str .= ' and id in (' . $ids . ')';
     }
     if ($ksid > 0 && $jsid > 0) {
         $str .= ' and id>' . ($ksid - 1) . ' and id<' . ($jsid + 1) . '';
     }
     if (!empty($kstime) && !empty($jstime)) {
         $ktime = strtotime($kstime) - 86400;
         $jtime = strtotime($jstime) + 86400;
         $str .= ' and addtime>' . $ktime . ' and addtime<' . $jtime . '';
     }
     $limit = '';
     if ($newid > 0) {
         $limit = ' order by id desc limit ' . $newid;
     }
     if ($datacount == 0) {
         $sqlstr = "select id from " . CS_SqlPrefix . "dance where yid=0 and hid=0 " . $str . $limit;
         $datacount = $this->db->query($sqlstr)->num_rows();
         //总数量
         $pagejs = ceil($datacount / Html_PageNum);
     }
     if ($datacount == 0) {
         $pagejs = 1;
     }
     $pagesize = Html_PageNum;
     if ($datacount < $pagesize) {
         $pagesize = $datacount;
     }
     //全部生成完毕
     if ($page > $pagejs) {
         admin_msg(L('plub_48'), site_url('dance/admin/html/down'));
     }
     //公众URI
     $uri = '?day=' . $day . '&cid=' . $cid . '&ids=' . $ids . '&newid=' . $newid . '&ksid=' . $ksid . '&jsid=' . $jsid . '&kstime=' . $kstime . '&jstime=' . $jstime . '&pagesize=' . $pagesize . '&pagejs=' . $pagejs . '&datacount=' . $datacount;
     //重新定义模板路径
     $this->load->get_templates('dance', 2);
     echo '<LINK href="' . base_url() . 'packs/admin/css/style.css" type="text/css" rel="stylesheet"><br>';
     echo vsprintf(L('plub_49'), array($pagejs, $page));
     $sql_string = "select * from " . CS_SqlPrefix . "dance where yid=0 and hid=0 " . $str . " order by id desc";
     $sql_string .= ' limit ' . $pagesize * ($page - 1) . ',' . $pagesize;
     $query = $this->db->query($sql_string);
     //获取下载页是否需要生成
     $html = config('Html_Uri', 'dance');
     foreach ($query->result_array() as $row) {
         ob_end_flush();
         //关闭缓存
         $id = $row['id'];
         //获取静态路径
         $Htmllinks = LinkUrl('down', 'id', $row['id'], 0, 'dance', $row['name']);
         //转换成生成路径
         $Htmllink = adminhtml($Htmllinks, 'dance');
         //摧毁部分需要超级链接字段数组
         $rows = $row;
         //先保存数组保留下面使用
         unset($row['tags']);
         unset($row['hits']);
         unset($row['yhits']);
         unset($row['zhits']);
         unset($row['rhits']);
         unset($row['dhits']);
         unset($row['chits']);
         unset($row['shits']);
         unset($row['xhits']);
         //获取当前分类下二级分类ID
         $arr['cid'] = getChild($row['cid']);
         $arr['uid'] = $row['uid'];
         $arr['did'] = $row['id'];
         $arr['singerid'] = $row['singerid'];
         $arr['tags'] = $rows['tags'];
         //装载模板并输出
         $Mark_Text = $this->CsdjTpl->plub_show('dance', $row, $arr, TRUE, 'down.html', $row['name'], $row['name']);
         //评论
         $Mark_Text = str_replace("[dance:pl]", get_pl('dance', $id), $Mark_Text);
         //分类地址、名称
         $Mark_Text = str_replace("[dance:link]", LinkUrl('play', 'id', $row['id'], 1, 'dance'), $Mark_Text);
         $Mark_Text = str_replace("[dance:classlink]", LinkUrl('lists', 'id', $row['cid'], 1, 'dance'), $Mark_Text);
         $Mark_Text = str_replace("[dance:classname]", $this->CsdjDB->getzd('dance_list', 'name', $row['cid']), $Mark_Text);
         //专辑
         if ($row['tid'] == 0) {
             $Mark_Text = str_replace("[dance:topiclink]", "###", $Mark_Text);
             $Mark_Text = str_replace("[dance:topicname]", "未加入", $Mark_Text);
         } else {
             $Mark_Text = str_replace("[dance:topiclink]", LinkUrl('topic', 'show', $row['tid'], 1, 'dance'), $Mark_Text);
             $Mark_Text = str_replace("[dance:topicname]", $this->CsdjDB->getzd('dance_topic', 'name', $row['tid']), $Mark_Text);
         }
         //获取上下曲
         preg_match_all('/[dance:slink]/', $Mark_Text, $arr);
         if (!empty($arr[0]) && !empty($arr[0][0])) {
             $rowd = $this->db->query("Select id,cid,name from " . CS_SqlPrefix . "dance where yid=0 and hid=0 and id<" . $id . " order by id desc limit 1")->row();
             if ($rowd) {
                 $Mark_Text = str_replace("[dance:slink]", LinkUrl('play', 'id', $rowd->id, 1, 'dance'), $Mark_Text);
                 $Mark_Text = str_replace("[dance:sname]", $rowd->name, $Mark_Text);
                 $Mark_Text = str_replace("[dance:sid]", $rowd->id, $Mark_Text);
             } else {
                 $Mark_Text = str_replace("[dance:slink]", "#", $Mark_Text);
                 $Mark_Text = str_replace("[dance:sname]", L('plub_45'), $Mark_Text);
                 $Mark_Text = str_replace("[dance:sid]", 0, $Mark_Text);
             }
         }
         unset($arr);
         preg_match_all('/[dance:xlink]/', $Mark_Text, $arr);
         if (!empty($arr[0]) && !empty($arr[0][0])) {
             $rowd = $this->db->query("Select id,cid,name from " . CS_SqlPrefix . "dance where yid=0 and hid=0 and id>" . $id . " order by id asc limit 1")->row();
             if ($rowd) {
                 $Mark_Text = str_replace("[dance:xlink]", LinkUrl('play', 'id', $rowd->id, 1, 'dance'), $Mark_Text);
                 $Mark_Text = str_replace("[dance:xname]", $rowd->name, $Mark_Text);
                 $Mark_Text = str_replace("[dance:xid]", $rowd->id, $Mark_Text);
             } else {
                 $Mark_Text = str_replace("[dance:xlink]", "#", $Mark_Text);
                 $Mark_Text = str_replace("[dance:xname]", L('plub_45'), $Mark_Text);
                 $Mark_Text = str_replace("[dance:xid]", 0, $Mark_Text);
             }
         }
         unset($arr);
         //标签加超级连接
         $Mark_Text = str_replace("[dance:tags]", SearchLink($rows['tags']), $Mark_Text);
         //动态人气
         $Mark_Text = str_replace("[dance:hits]", "<script src='" . hitslink('hits/dt/hits/' . $id, 'dance') . "'></script>", $Mark_Text);
         $Mark_Text = str_replace("[dance:yhits]", "<script src='" . hitslink('hits/dt/yhits/' . $id, 'dance') . "'></script>", $Mark_Text);
         $Mark_Text = str_replace("[dance:zhits]", "<script src='" . hitslink('hits/dt/zhits/' . $id, 'dance') . "'></script>", $Mark_Text);
         $Mark_Text = str_replace("[dance:rhits]", "<script src='" . hitslink('hits/dt/rhits/' . $id, 'dance') . "'></script>", $Mark_Text);
         $Mark_Text = str_replace("[dance:dhits]", "<script src='" . hitslink('hits/dt/dhits/' . $id, 'dance') . "'></script>", $Mark_Text);
         $Mark_Text = str_replace("[dance:chits]", "<script src='" . hitslink('hits/dt/chits/' . $id, 'dance') . "'></script>", $Mark_Text);
         $Mark_Text = str_replace("[dance:shits]", "<script src='" . hitslink('hits/dt/shits/' . $id, 'dance') . "'></script>", $Mark_Text);
         $Mark_Text = str_replace("[dance:xhits]", "<script src='" . hitslink('hits/dt/xhits/' . $id, 'dance') . "'></script>", $Mark_Text);
         //歌曲完整试听、下载地址
         preg_match_all('/[dance:qurl]/', $Mark_Text, $arr);
         if (!empty($arr[0]) && !empty($arr[0][0])) {
             $purl = $row['purl'];
             $durl = $row['durl'];
             if ($row['fid'] > 0) {
                 $rowf = $this->db->query("Select purl,durl from " . CS_SqlPrefix . "dance_server where id=" . $row['fid'] . "")->row_array();
                 if ($rowf) {
                     $purl = $rowf['purl'] . $row['purl'];
                     $durl = $rowf['durl'] . $row['durl'];
                 }
             }
             $purl = annexlink($purl);
             $durl = annexlink($durl);
             $Mark_Text = str_replace("[dance:qurl]", $purl, $Mark_Text);
             $Mark_Text = str_replace("[dance:qxurl]", $durl, $Mark_Text);
         }
         unset($arr);
         //生成
         write_file(FCPATH . $Htmllink, $Mark_Text);
         echo "&nbsp;<font style=font-size:10pt;>" . L('plub_50') . "<font color=red>" . $row['name'] . "</font>" . L('plub_36') . "<a href=" . $Htmllinks . " target=_blank>" . $Htmllinks . "</a></font><br/>";
         ob_flush();
         flush();
     }
     if (!empty($ids)) {
         $url = 'javascript:history.back();';
         $str = "&nbsp;&nbsp;<b>" . L('plub_66') . "&nbsp;>>>>&nbsp;&nbsp;<a href='" . $url . "'>" . L('plub_28') . "</a></b>";
     } else {
         $url = site_url('dance/admin/html/down_save') . $uri . '&page=' . ($page + 1);
         $str = "&nbsp;&nbsp;<b>" . vsprintf(L('plub_27'), array(Html_StopTime)) . "&nbsp;>>>>&nbsp;&nbsp;<a href='" . $url . "'>" . L('plub_28') . "</a></b>";
     }
     echo "</br>" . $str . "<script>setTimeout('updatenext();'," . Html_StopTime . "000);function updatenext(){location.href='" . $url . "';}</script>";
 }