⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functions.php

📁 mysee网络直播源代码Mysee Lite是Mysee独立研发的网络视频流媒体播放系统。在应有了P2P技术和一系列先进流媒体技术之后
💻 PHP
字号:
<?php
define("PROCESS_FILE",    "/var/run/spnew.pid");
define("PROGRAM_DIR",    "/data/sp/program");
define("PROGRAM_CONFIG",    "/config");
define("CHANNEL_DIR",    "/data/sp/playlist");
define("SP_ID",    "/var/run/spnew.pid");

//得到channel文件名列表
function getChannelList(){
	$channelList = array();
	
	if ($handle = opendir(CHANNEL_DIR)) {
	   while (false !== ($file = readdir($handle))) {
	       if ($file != "." && $file != ".." && strstr($file, ".swap")!=false ) {
	           $channelList[]=$file;
	       }
	   }
	   closedir($handle);
	}
	return $channelList;
}

//得到channel列表 md5对应文件行数组 的hashtable形式
function getChannelTable($sort = true){
	$channelList = array();
	
	if ($handle = opendir(CHANNEL_DIR)) {
	   while (false !== ($file = readdir($handle))) {
	       if ($file != "." && $file != "..") {
		   $filename = CHANNEL_DIR . "/" . $file;
		   $array_tmp = file($filename);
		   $filemtime = filemtime($filename);
		   //$channelList[$file]=$array_tmp;
	       $channelList[$filemtime] = array($file,$array_tmp);
		   }
	   }
	   closedir($handle);
	}
	if($sort) krsort($channelList, SORT_NUMERIC);
	foreach($channelList as $array_tmp) {
			$_channelList[$array_tmp[0]] = $array_tmp[1];
	}
	unset($channelList);
	return $_channelList;
}

//得到program目录名列表
function getPromd5list($sort = 1){
	$pronamelist = array();
	
	if ($handle = opendir(PROGRAM_DIR)) {
	   while (false !== ($file = readdir($handle))) {
	       if ($file != "." && $file != "..") {
			   $filemtime = filemtime(PROGRAM_DIR.'/'.$file.'/config');
	           $pronamelist[$filemtime]=$file;
	       }
	   }
	   closedir($handle);
	}
	if($sort==1) krsort($pronamelist, SORT_NUMERIC);
	return $pronamelist;
}

//得到program列表 md5对应name 的hashtable形式
function getProgramTable($sort = 1){
	$programlist = array();
	$pronamelist = getPromd5list($sort);
	
	foreach ($pronamelist as $promd5) {
		$profilename = PROGRAM_DIR . "/" . $promd5 . PROGRAM_CONFIG;
	
		$config = array();
	   	$array_tmp = file($profilename);
	   	foreach($array_tmp as $v){
	       		if ((substr(trim($v),0,1)!=';') && (substr_count($v,'=')>=1)){
	       			//Line mustn't start with a ';' and must contain at least one '=' symbol.
	           		$pos = strpos($v, '=');
	           		$config[trim(substr($v,0,$pos))] = trim(substr($v, $pos+1));
	       		}
	   	}
	   	unset($array_tmp);
		$programlist[$promd5]=$config["ChannelName"];
	}
	//asort($programlist);
	if($sort==2) {
		$programlist_sort = array();
		foreach ($programlist as $md5 => $name){
			$programlist_sort[$name . $md5] = $md5;
		}
			ksort($programlist_sort, SORT_STRING);
		$programlist2 = array();
		foreach ($programlist_sort as $name_md5_sort => $md5_sort){
			$programlist2[$md5_sort] = $programlist[$md5_sort];		
		}
		return $programlist2;
	}
	return $programlist;
}

//得到program information列表 md5对应array 的hashtable形式
function getProgramInfoTable(){	
	$programlist = array();
	$pronamelist = getPromd5list();
	
	foreach ($pronamelist as $promd5) {
		$profilename = PROGRAM_DIR . "/" . $promd5 . PROGRAM_CONFIG;
	
		$config = array();
	   	$array_tmp = file($profilename);
	   	foreach($array_tmp as $v){
	       		if ((substr(trim($v),0,1)!=';') && (substr_count($v,'=')>=1)){
	       			//Line mustn't start with a ';' and must contain at least one '=' symbol.
	           		$pos = strpos($v, '=');
	           		$config[trim(substr($v,0,$pos))] = trim(substr($v, $pos+1));
	       		}
	   	}
	   	unset($array_tmp);
		$programlist[$promd5]=$config;
	}

	return $programlist;
}

function infoSp(){
	$spid = file(SP_ID);
	$command = "/usr/bin/sudo -u root kill -HUP ".$spid[0];
	exec($command);
}

function shelldel($dir){
	$command = "rm -rf ".$dir;
	echo $command;
	echo exec($command);
}

@header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
@header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
@header('Cache-Control: no-store, no-cache, must-revalidate');
@header('Cache-Control: post-check=0, pre-check=0', false);
@header('Pragma: no-cache');
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -