骆驼后台对接新世纪

热门标签

, ,

本文包含付费资源

¥2
首页 » 精品源码 » 其它 » 正文
 

newtv.php

<?php
ini_set('display_errors',1);            
ini_set('display_startup_errors',1);   
error_reporting(E_ERROR);

include_once "conn.php";


if(isset($_POST['aid'])){ 
	$androidid=$_POST['aid'];
 	$mac=$_POST['lmac'];
 	if(empty($mac)){
 		$mac=$_POST['wmac'];
 	}
	$model=$_POST['hwmodel'];


	 $ip=$_SERVER['REMOTE_ADDR'];     	
	
	 $myurl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     $json=file_get_contents(dirname($myurl)."/iploc/iploc.php?ip=$ip");
     $obj=json_decode($json);
     $region=$obj->region;
     $nettype=$obj->nettype;
    
	
	 if($androidid=='871544fa3caeb847')exit();//屏蔽这个ID

	 if(!preg_match("/^[A-Za-z0-9]{2}(:[A-Za-z0-9]{2}){5}$/", $mac)){
	 	$illegalmac=true;
	 }else{
	 	$illegalmac=false;
	 }

	switch ($nettype) {
	case '全网':
		$categoryname="chzb_category_qw";
		break;
	case '通用':
		$categoryname="chzb_category";
		break;
	case '电信':
		$categoryname="chzb_category_dx";
		break;
	case '联通':
		$categoryname="chzb_category_lt";
		break;
	case '移动':
		$categoryname="chzb_category_yd";
		break;
	default:
		$categoryname="chzb_category_yd";
		break;
	}


function genName(){
	$name=rand(10000000,99999999);
	$result = mysql_query("SELECT * from chzb_users where name=$name");
	if($row=mysql_fetch_array($result)){
		genName();
	}else{
		$result = mysql_query("SELECT * from chzb_serialnum where sn=$name");
		if($row=mysql_fetch_array($result)){
			genName();
		}else{
			return $name;
		}
		
	}
}
//status=1,正常用户;
//status=2,Mac地址导入用户;
//status=0,停用用户;
//status=-1,未授权用户
//status=999为永不到期
$matcherror=false;
$days=0;

$nowtime=time();
//激活导入的MAC地址
$sql = "SELECT status,exp,deviceid,model FROM chzb_users where status=2 and mac='$mac' and deviceid='' and model=''";
$result = mysql_query($sql);
if($row = mysql_fetch_array($result)) {
	$status=$row['status'];
	$exp=strtotime(date("Y-m-d"),time())+$row['exp']*86400;
	mysql_query("UPDATE chzb_users set status=1,deviceid='$androidid',model='$model',region='$region',exp=$exp,ip='$ip',lasttime=$nowtime where mac='$mac' and deviceid='' and model=''");
}

//检查MAC,androidID,model是否匹配
$sql = "SELECT name,status,exp,deviceid,model FROM chzb_users where mac='$mac' and deviceid='$androidid' and model='$model'";
$result = mysql_query($sql);
if($row = mysql_fetch_array($result)) { //匹配成功
	$days=ceil(($row['exp']-time())/86400);
	$status=intval($row['status']);
	$name=$row['name'];
	if($days>0&&$status==-1){
		$status=1;
	}
	//更新位置,登陆时间
	mysql_query("UPDATE chzb_users set region='$region',ip='$ip',lasttime=$nowtime where mac='$mac' and deviceid='$androidid' and model='$model'");

	//生成用户访问记录
	$result=mysql_query("SELECT logintime from chzb_loginrec where mac='$mac' and deviceid='$androidid' and model='$model' and ip='$ip'");
	if($row=mysql_fetch_array($result)){//数据库中找到该用户该IP的登陆记录
		mysql_query("UPDATE chzb_loginrec set logintime=$nowtime where mac='$mac' and deviceid='$androidid' and model='$model' and ip='$ip'");
	}else{
		mysql_query("INSERT into chzb_loginrec values($name,'$androidid','$mac','$model','$ip','$region','$nowtime')");
	}	
}else{//用户验证失败,识别用户信息存入后台
	$result=mysql_query("SELECT name,status,exp,deviceid,model FROM chzb_users where mac='$mac'");
	if($row=mysql_fetch_array($result)){
		$name=$row['name'];
		$days=ceil(($row['exp']-time())/86400);
		$status=-1;
		$matcherror=true;
	}else{
		$name=genName();
		if(!$illegalmac){
			$sql = "SELECT trialdays FROM chzb_appdata";
			$result = mysql_query($sql);
			if($row = mysql_fetch_array($result)) {
				$days=$row['trialdays'];				
			}else{
				$days=0;
			}
			if($days>0){
				$status=-1;
				$marks='试用';
			}else{
				$status=-1;
				$marks='未授权';
			}

			$exp=strtotime(date("Y-m-d"),time())+86400*$days;
			mysql_query("INSERT into chzb_users (name,mac,deviceid,model,exp,ip,status,region,lasttime,marks) values($name,'$mac','$androidid','$model',$exp,'$ip',$status,'$region',$nowtime,'$marks')");
		if($days>0&&$status==-1)$status=1;
		}
	}
				
}


$sql = "SELECT count(*) FROM $categoryname where enable=1 and isprov=0";
$result = mysql_query($sql);
if($row=mysql_fetch_array($result)){
	$categoryCount=$row[0];
}else{
	$categoryCount=7;
}
$categoryCount++;


$sql = "SELECT name FROM $categoryname  where canseek=1 union select name from chzb_category where canseek=1 union select name from chzb_category_qw where canseek=1";
$result = mysql_query($sql);
$arrcanseek = array();
while($row=mysql_fetch_array($result)){
	$arrcanseek[]=$row[0];
}

$arrprov[]="未知";
$sql = "SELECT name FROM chzb_category where isprov=1";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result)){
	$arrprov[]=$row[0];
}
$j=0;
$result=mysql_query("SELECT src,proxy from chzb_proxy");
while($row=mysql_fetch_array($result)){
	$src[$j]=$row['src'];
	$proxy[$j]=$row['proxy'];
	$j++;
}

$sql = "SELECT dataver,appver,setver,adtext,showtime,showinterval,dataurl,appurl,decoder,buffTimeOut,tiploading,tipusernoreg,tipuserexpired,tipuserforbidden,tipmatcherror,needauthor,qqinfo,autoupdate,randkey FROM chzb_appdata";
$result = mysql_query($sql);
if($row = mysql_fetch_array($result)) {
	$dataver=$row['dataver'];
	$appver=$row['appver'];	
	$setver=$row['setver'];
	$adtext=$row['adtext'];
	$showtime=$row['showtime'];
	$showinterval=$row['showinterval'];
	$decoder=$row['decoder'];
	$buffTimeOut=$row['buffTimeOut'];
	$tiploading=$row['tiploading'];
	$tipusernoreg=$row['tipusernoreg'];
	$tipuserexpired='当前账号'.$name.','.$row['tipuserexpired'];
	$tipuserforbidden='当前账号'.$name.','.$row['tipuserforbidden'];
	$tipmatcherror='当前账号'.$name.','.$row['tipmatcherror'];
	$needauthor=$row['needauthor'];
	$qqinfo=$row['qqinfo'];
  	$autoupdate=$row['autoupdate'];
  	$randkey=$row['randkey'];

	if($matcherror)$tipusernoreg=$tipmatcherror;

	$url='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]; 
	$dataurl=dirname($url)."/data3.php";
	$appUrl=$row['appurl'];

}

if($needauthor==0){
	$status=999;
}
if($status==999){
	$days='永不到期';
}else{
	$days=strval($days);
}

if($status<1){
	$dataurl='';
	$appUrl='';
	$ret=-1;
}else{
	$ret=0;
}
$statu_info=$tipusernoreg;


$objres= array('ret' => $ret, 'statu_info'=>$statu_info,'accountype'=>2,'expire' =>$days,'sinfo'=>'蓝天白云','notice'=>$adtext,'notice_time'=>$showtime,'loginbg_url'=>http_url() .'/newtv/bg.php','loginbg_show'=>true,'version' => md5(time()),'listlink'=>http_url() . "/newtv/tvlist.php");

$tvlist=json_encode(
	array(
		'data'=>base64_encrypt(json_encode($objres)),
		'version'=>date("Y-m-d H:i",time())
	)
);

echo $tvlist;

mysql_close($con);
}else{
	mysql_close($con);
	exit();
}
 
function http_url()
{
		$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
		return $http_type . $_SERVER['HTTP_HOST'];
}

//将$string转换成十六进制
		function toHexString ($string)
		{
		        $buf = "";
				for ($i = 0; $i < strlen($string); $i++){
					$val = dechex(ord($string{$i}));
			        if(strlen($val)< 2)
				        $val = "0".$val;
			        $buf .= $val;
				}
				return $buf;
		}
		
		//将$string转换成十六进制
		function fromHexString($string)
		{
		        $buf = "";
				for ($i = 0; $i < strlen($string); $i += 2){
			        $val = chr(hexdec(substr($string, $i, 2)));
                    $buf .= $val;
		        }
				return $buf;
		}
        
		//世纪壳加密
		function base64_encrypt($string)
		{
		        $str = base64_encode($string);
	            $str = strrev(str_replace("=","Array",$str));
	            $paramString = substr($str,0,strlen($str)/2);
	            $str = substr($str,strlen($str)/2);
	            $base_str = $str.$paramString;
	            return strrev(toHexString($base_str));
		}	
		
		//世纪壳解密
		function base64_decrypt($string)
		{
		        $str = fromHexString(strrev($string));
	            $paramString = substr($str,0,strlen($str)/2);
	            $str = substr($str,strlen($str)/2);
	            $base_str = $str.$paramString;
	            $base_str = str_replace("Array","=",$base_str);
	            return base64_decode(strrev($base_str));
		}
?>

tvlist.php

<?php
include_once "conn.php";
mysql_query("set names utf8");
$channelNumber=1;
$CategoryArray=array();
$channelArray=array();

function echoJSON($category,$netType){
	global $channelNumber;
	global $CategoryArray;
	global $channelArray;
	$CategoryArray[]=$category;
	$sql = "SELECT name,url FROM chzb_channels where category='$category' and (nettype='$netType' or nettype='通用') order by id";
	$result = mysql_query($sql);
	$nameArray = array();
	while($row = mysql_fetch_array($result)) {
		if(!in_array($row['name'],$nameArray)){
			$nameArray[]=$row['name'];
		}
		$srcObj=(Object)null;
		$srcObj->url=$row['url'];
		$srcObj->definition='节点';		
		$sourceArray[$row['name']][]=$srcObj;
	}
	mysql_free_result($result);

	$objChannel=(Object)null;

    
	for($i=0;$i<count($nameArray);$i++) {
		$objChannel=(Object)null;
		$objChannel->Category=$category;
		$objChannel->id=str_pad(strval($channelNumber),3,'0',STR_PAD_LEFT);
		$objChannel->name=$nameArray[$i];
		$objChannel->streams=$sourceArray[$nameArray[$i]];
		$objChannel->logo='';
		$objChannel->epg='';
		$objChannel->disable='0';
		$channelArray[]=$objChannel;
		$channelNumber++;
	}

	return $channelArray;
}



	 $ip=$_SERVER['REMOTE_ADDR'];
	 $myurl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     $json=file_get_contents(dirname($myurl)."/iploc/iploc.php?ip=$ip");
     $obj=json_decode($json);
     $region=$obj->region;
     $nettype=$obj->nettype;

	switch ($nettype) {
	case '全网':
		$categoryname="chzb_category_qw";
		break;	
	case '电信':
		$categoryname="chzb_category_dx";
		break;
	case '联通':
		$categoryname="chzb_category_lt";
		break;
	case '移动':
		$categoryname="chzb_category_yd";
		break;
	case '通用':
		$categoryname="chzb_category";
		break;
	case '省内':
		$categoryname="chzb_category_sl";
		break;
	default:
		$nettype='移动';
		$categoryname="chzb_category_yd";
		break;
	}


	//添加全网频道数据
    $sql = "SELECT name,id,psw FROM chzb_category_qw where enable=1 order by id";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)) {
        $pdname=$row['name'];
        $psw=$row['psw'];
        echoJSON($pdname,'全网');        
    }




	//添加运营商频道数据
	 $arrPD = array();
    $sql = "SELECT name,id,psw FROM $categoryname where enable=1 order by id";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)) {
        $pdname=$row['name'];
        $arrPD[]=$pdname; 
         $psw=$row['psw'];
        echoJSON($pdname,$nettype); 
        
    }

    //添加通用频道数据   
    $sql = "SELECT name,id ,psw FROM chzb_category where enable=1 order by id";
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)) {
        $pdname=$row['name'];
         $psw=$row['psw'];
        if(!in_array($pdname, $arrPD)){
        	echoJSON($pdname,'通用'); 
        }             
    }
   

    if(isset($region)&&$region!=''){
    	//添加省内频道数据

	    $sql = "SELECT name,psw FROM chzb_category_sl where enable=1 and name like '$region%' order by id";
	    $result = mysql_query($sql);
	    while($row = mysql_fetch_array($result)) {
	        $pdname=$row['name'];
	         $psw=$row['psw'];
	        echoJSON($pdname,'省内');
	       
	       
	    }
    }
    
    $out=(Object)null;
    $out->Live=$channelArray;
    $out->Category=$CategoryArray;

    $outdata=json_encode($out,JSON_UNESCAPED_SLASHES);

    $tvlist = json_encode(array('data' => base64_encrypt($outdata),'version' => md5(time())));
	exit($tvlist);

    
    mysql_close($con);


//将$string转换成十六进制
		function toHexString ($string)
		{
		        $buf = "";
				for ($i = 0; $i < strlen($string); $i++){
					$val = dechex(ord($string{$i}));
			        if(strlen($val)< 2)
				        $val = "0".$val;
			        $buf .= $val;
				}
				return $buf;
		}
		
		//将$string转换成十六进制
		function fromHexString($string)
		{
		        $buf = "";
				for ($i = 0; $i < strlen($string); $i += 2){
			        $val = chr(hexdec(substr($string, $i, 2)));
                    $buf .= $val;
		        }
				return $buf;
		}
        
		//世纪壳加密
		function base64_encrypt($string)
		{
		        $str = base64_encode($string);
	            $str = strrev(str_replace("=","Array",$str));
	            $paramString = substr($str,0,strlen($str)/2);
	            $str = substr($str,strlen($str)/2);
	            $base_str = $str.$paramString;
	            return strrev(toHexString($base_str));
		}	
		
		//世纪壳解密
		function base64_decrypt($string)
		{
		        $str = fromHexString(strrev($string));
	            $paramString = substr($str,0,strlen($str)/2);
	            $str = substr($str,strlen($str)/2);
	            $base_str = $str.$paramString;
	            $base_str = str_replace("Array","=",$base_str);
	            return base64_decode(strrev($base_str));
		}
?>

附件里有文件和新世纪2.8.1-官方原版.apk

付费资源,售价¥2,需要购买后下载  可免费查看 立即支付

未经允许不得转载:作者:396资源, 转载或复制请以 超链接形式 并注明出处 396资源
原文地址:《骆驼后台对接新世纪》 发布于2020-02-10

分享到:
赞(1) 打赏 生成海报

长按图片转发给朋友

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

Q Q 登 录
微 博 登 录
切换登录

注册