<?php 
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pan extends CI_Controller {

	function __construct(){
		parent::__construct();
	        $this->load->model('CsdjDB');
	        $this->load->model('CsdjAdmin');
	}

        //威盘地址解析
	public function vdisk()
	{
            $id = $this->uri->segment(3);   //ID
            $id =str_replace('.mp3','',$id);

            $url='http://www.vdisk.cn/down/index/'.$id;
            $str=$this->CsdjAdmin->HtmlAll($url,'utf-8');
            $durl=$this->CsdjAdmin->str_substr('="httpfileurl" content="', '"', $str);

            $UA = strtoupper(@$_SERVER['HTTP_USER_AGENT']);
            if(preg_match("/(iPhone|iPad|iPod|Android)/i", $UA)){
                  $durl="http://www.boanniu.com/".$id."/cscms.mp3";
            }
            Header("Location: ".$durl);
	}

        //官方盘地址解析
	public function csdjso()
	{
            $id = $this->uri->segment(3);   //ID
            $id =str_replace('.mp3','',$id);
            $Arr=explode('_',$id);
            $user=$Arr[0];
            $uid=$Arr[1];
            $durl='http://up.chshcms.com/wl/url/'.$user.'/'.$uid.'/yuedisk.mp3';

            $UA = strtoupper(@$_SERVER['HTTP_USER_AGENT']);
            if(preg_match("/(iPhone|iPad|iPod|Android)/i", $UA)){
                  $durl='http://up.chshcms.com/m.php/'.$user.'/'.$uid.'/yuedisk.mp3';
            }
            Header("Location: ".$durl);
	}

        //威盘上传返回
	public function vdisk_return_url()
	{
                $fhurl=$this->input->get('fhurl', TRUE);
                $durl=$this->input->get('downurl', TRUE);
		$name=$this->input->get('name', TRUE);
		$url = "_weipan_".substr($durl,31);
		$name = substr(iconv('utf-8','gbk',$name),0,-4);

		exit("<script type=\"text/javascript\">
			opener.document.getElementById('".$fhurl."').value= '".$url."';
                        alert('文件上传成功!');
			window.close();
		</script>");
        }

        //官方网盘上传返回
	public function csdj_return_url()
	{
                $fhurl=$this->input->get('fhurl', TRUE);
                $durl=$this->input->get('downurl', TRUE);
		$name=$this->input->get('name', TRUE);
		$user=$this->input->get('user', TRUE);
		$url = "_csdjso_".$user."_".substr($durl,33);
		$name = substr($name,0,-4);

		exit("<script type=\"text/javascript\">
			opener.document.getElementById('".$fhurl."').value= '".$url."';
                        alert('文件上传成功!');
			window.close();
		</script>");
        }
}

