functions.php
资源名称:p2p_vod.rar [点击查看]
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:3k
源码类别:
P2P编程
开发平台:
Visual C++
- <?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(){
- $channelList = array();
- if ($handle = opendir(CHANNEL_DIR)) {
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != "..") {
- $filename = CHANNEL_DIR . "/" . $file;
- $array_tmp = file($filename);
- $channelList[$file]=$array_tmp;
- }
- }
- closedir($handle);
- }
- return $channelList;
- }
- //得到program目录名列表
- function getPromd5list(){
- $pronamelist = array();
- if ($handle = opendir(PROGRAM_DIR)) {
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != "..") {
- $pronamelist[]=$file;
- }
- }
- closedir($handle);
- }
- return $pronamelist;
- }
- //得到program列表 md5对应name 的hashtable形式
- function getProgramTable(){
- $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["ChannelName"];
- }
- asort($programlist);
- 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');
- ?>