www.gusucode.com > 网猫影视系统NetMao Movie 4.6.6 开源版源码程序 > upload/admin/part4.inc.php

    <?php
/*
*######################################
* Netmao Movie 4.x - NetMao Movie System
* Copyright (c) 2007-2008 NetMao.cn
* For further information go to http://www.netmao.cn/
* This copyright notice must stay intact for use.
*######################################
*/
if(!defined('IN_NetMao') || !isset($PHP_SELF) || !preg_match("/[\/\\\\]nmadmin\.php$/", $PHP_SELF)) exit('Access Denied');

switch($action){
    case 'movie_p_add' :
        if(!$submit){
            if(is_array($_NCACHE['categorys'])) foreach($_NCACHE['categorys'] as $cate){$cateopt = $cateopt. "<option value=$cate[cid]>$cate[cid]|$cate[name]</option>";}
            if(is_array($_NCACHE['settings'][m_areas])) foreach($_NCACHE['settings'][m_areas] as $area){$areaopt = $areaopt. "<option value=$area>$area</option>";}
            if(is_array($_NCACHE['settings'][m_languages])) foreach($_NCACHE['settings'][m_languages] as $lang){$langopt = $langopt. "<option>$lang</option>";}
            if(is_array($_NCACHE['settings'][m_actors])) foreach($_NCACHE['settings'][m_actors] as $acto){$actoopt = $actoopt. "<option value=$acto>$acto</option>";}
            if(is_array($_NCACHE['settings'][m_directors])) foreach($_NCACHE['settings'][m_directors] as $dire){$direopt = $direopt. "<option value=$dire>$dire</option>";}
            if(is_array($_NCACHE['settings'][m_keywords])) foreach($_NCACHE['settings'][m_keywords] as $keyw){$keywopt = $keywopt. "<option value=$keyw>$keyw</option>";}
            if(is_array($_NCACHE['servers'])) foreach($_NCACHE['servers'] as $serv){$servopt = $servopt. "<option value=\"$serv[identifier]\">$serv[identifier]|$serv[name]</option>";}
            if(is_array($_NCACHE['players'])) foreach($_NCACHE['players'] as $play){$playopt = $playopt. "<option value=\"$play[identifier]\">$play[identifier]|$play[name]</option>";}
            $theurl="?action=movie_add&pmid=$pmid";
			nmcptpl('movie_p');
        }else{
            if(!$name || strlen($name) > 50 || strlen($language) > 50 || strlen($area) > 50 || strlen($actor) > 255 || strlen($director) > 255 || strlen($picture) > 255 || strlen($keyword) > 255 || strlen($description) > 255) {nmsg('info_invalid','','back');}
            $db->query("INSERT INTO {$tablepre}movies_p(name,cid,area,language,actor,director,picture,content,adsense,description,keyword,isrun,isindex,ismlist,isshow,hits,server,player,model,filename,pfrom,pto,pfile,pextend) VALUES('$name','$cid','$area','$language','$actor','$director','$picture','$content','$adsense','$description','$keyword','$isrun','$isindex','$ismlist','$isshow','$hits','$server','$player','$model','$filename','$pfrom','$pto','$pfile','$pextend')");
            nmsg('operate_succeed',"?action=movie_add");
        }
    break;
//***
	case 'movie_p_mod' :
        $r1=$db->query("SELECT * FROM {$tablepre}movies_p WHERE mid='$pmid'");
        $nmov=$db->fetch_array($r1);
        if(!$submit){
            if(is_array($_NCACHE['categorys'])) foreach($_NCACHE['categorys'] as $cate){
                if($nmov[cid] == $cate[cid]){ $N_select = " selected"; }else{ $N_select = ""; }
                $cateopt = $cateopt. "<option value=\"$cate[cid]\" $N_select>$cate[cid]|$cate[name]</option>";
            }
            if(is_array($_NCACHE['servers'])) foreach($_NCACHE['servers'] as $serv){
                if($nmov[server] == $serv[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                $servopt = $servopt. "<option value=\"$serv[identifier]\" $N_select>$serv[identifier]|$serv[name]</option>";
            }
            if(is_array($_NCACHE['players'])) foreach($_NCACHE['players'] as $play){
                if($nmov[player] == $play[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                $playopt = $playopt. "<option value=\"$play[identifier]\" $N_select>$play[identifier]|$play[name]</option>";
			}
            if(is_array($_NCACHE['settings'][m_areas])) foreach($_NCACHE['settings'][m_areas] as $area){
			    if($nmov[area] == $area){ $NC_select = " selected"; }else{ $NC_select = ""; }
			    $areaopt = $areaopt. "<option value=$area $NC_select>$area</option>";
			}
            if(is_array($_NCACHE['settings'][m_languages])) foreach($_NCACHE['settings'][m_languages] as $lang){
			    if($nmov[language] == $lang){ $NB_select = " selected"; }else{ $NB_select = ""; }
				$langopt = $langopt. "<option value=$lang $NB_select>$lang</option>";
			}
            if(is_array($_NCACHE['settings'][m_actors])) foreach($_NCACHE['settings'][m_actors] as $acto){$actoopt = $actoopt. "<option value=$acto>$acto</option>";}
            if(is_array($_NCACHE['settings'][m_directors])) foreach($_NCACHE['settings'][m_directors] as $dire){$direopt = $direopt. "<option value=$dire>$dire</option>";}
            if(is_array($_NCACHE['settings'][m_keywords])) foreach($_NCACHE['settings'][m_keywords] as $keyw){$keywopt = $keywopt. "<option value=$keyw>$keyw</option>";}
            nmcptpl('movie_p');
        }else{
            if(!$name || strlen($name) > 50 || strlen($language) > 50 || strlen($area) > 50 || strlen($actor) > 255 || strlen($director) > 255 || strlen($picture) > 255 || strlen($keyword) > 255 || strlen($description) > 255) {nmsg('info_invalid','','back');}
            $db->query("UPDATE {$tablepre}movies_p SET name='$name',cid='$cid',area='$area',language='$language',actor='$actor',director='$director',picture='$picture',content='$content',adsense='$adsense',description='$description',keyword='$keyword',isrun='$isrun',isindex='$isindex',ismlist='$ismlist',isshow='$isshow',hits='$hits',server='$server',player='$player',model='$model',filename='$filename',pfrom='$pfrom',pto='$pto',pfile='$pfile',pextend='$pextend' WHERE mid='$pmid'");
            nmsg('operate_succeed','?action=movie_add');
        }
    break;
//***
    case 'movie_p_del' :
        if(!$confirmed) {
            nmsg('operate_duplicate', "?action=movie_p_del&pmid=$pmid", 'form');						
        }else{
            $db->query("DELETE FROM {$tablepre}movies_p WHERE mid='$pmid'");
            nmsg('operate_succeed',"?action=movie_add");
        }
    break;
//***
    case 'movie_add' :
		if(!$pmid && !$submit){
            $perpage='30';
            $page=$page ? $page : 1;
            $mpurl = "?action=movie_add";
            $offset=$page ? ($page-1)*$perpage : 0;
            $query1="SELECT count(*) AS num FROM {$tablepre}movies_p where 1 order by mid desc";
            $result1=$db->query($query1);
            $r1=$db->fetch_array($result1);
            $num=$r1["num"];
            $pages=phppage($num,$perpage,$page,$mpurl);
            $query2="SELECT * FROM {$tablepre}movies_p where 1 order by mid desc LIMIT $offset,$perpage";
            $result2=$db->query($query2);
            while($nmov=$db->fetch_array($result2)){
			    $nmov[theurl]="?action=movie_add&pmid=$nmov[mid]";
                $nmovs[]=$nmov;
            }
            nmcptpl('movie_p');
	    }else{
		    if(!$submit){
                $r3=$db->query("SELECT * FROM {$tablepre}movies_p WHERE mid='$pmid'");
                $nmov=$db->fetch_array($r3);
                if(is_array($_NCACHE['categorys'])) foreach($_NCACHE['categorys'] as $cate){
                    if($nmov[cid] == $cate[cid]){ $N_select = " selected"; }else{ $N_select = ""; }
                    $cateopt = $cateopt. "<option value=\"$cate[cid]\" $N_select>$cate[cid]|$cate[name]</option>";
                }
                if(is_array($_NCACHE['servers'])) foreach($_NCACHE['servers'] as $serv){
                    if($nmov[server] == $serv[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                    $servopt = $servopt. "<option value=\"$serv[identifier]\" $N_select>$serv[identifier]|$serv[name]</option>";
                }
                if(is_array($_NCACHE['players'])) foreach($_NCACHE['players'] as $play){
                    if($nmov[player] == $play[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                    $playopt = $playopt. "<option value=\"$play[identifier]\" $N_select>$play[identifier]|$play[name]</option>";
			    }
                if(is_array($_NCACHE['settings'][m_areas])) foreach($_NCACHE['settings'][m_areas] as $area){
			        if($nmov[area] == $area){ $NC_select = " selected"; }else{ $NC_select = ""; }
			        $areaopt = $areaopt. "<option value=$area $NC_select>$area</option>";
			    }
                if(is_array($_NCACHE['settings'][m_languages])) foreach($_NCACHE['settings'][m_languages] as $lang){
			        if($nmov[language] == $lang){ $NB_select = " selected"; }else{ $NB_select = ""; }
				    $langopt = $langopt. "<option value=$lang $NB_select>$lang</option>";
			    }
                if(is_array($_NCACHE['settings'][m_actors])) foreach($_NCACHE['settings'][m_actors] as $acto){$actoopt = $actoopt. "<option value=$acto>$acto</option>";}
                if(is_array($_NCACHE['settings'][m_directors])) foreach($_NCACHE['settings'][m_directors] as $dire){$direopt = $direopt. "<option value=$dire>$dire</option>";}
                if(is_array($_NCACHE['settings'][m_keywords])) foreach($_NCACHE['settings'][m_keywords] as $keyw){$keywopt = $keywopt. "<option value=$keyw>$keyw</option>";}
                nmcptpl('movie');
            }else{
                if(!$name || strlen($name) > 50 || strlen($language) > 50 || strlen($area) > 50 || strlen($actor) > 255 || strlen($director) > 255 || strlen($picture) > 255 || strlen($keyword) > 255 || strlen($description) > 255) {nmsg('info_invalid','','back');}
			    $author=$_SESSION[auser];
			    $addtime=$timestamp;
				$db->query("INSERT INTO {$tablepre}movies(author,addtime,name,cid,area,language,actor,director,picture,content,adsense,description,keyword,isrun,isindex,ismlist,isshow,hits) VALUES('$author','$addtime','$name','$cid','$area','$language','$actor','$director','$picture','$content','$adsense','$description','$keyword','$isrun','$isindex','$ismlist','$isshow','$hits')");
                $mid=$db->insert_id();

			    $filecontent=trim($filecontent);
			    if($filecontent!=''){
			        $xfilecontents=explode("\r",$filecontent);
			        foreach($xfilecontents as $i=>$xfilecontent){
				    if($xfilecontent!=''){
			            $xfiles=explode("|",trim($xfilecontent));
						if($model==1){
						    $fcontent=$xfiles[0]; $fserver=$server; $fplayer=$player;
							if($filename){$fname=str_replace("i",$i+1,$filename);}else{$fname=$i+1;}
						}elseif($model==2){
						    $fcontent=$xfiles[0]; $fname=$xfiles[1]; $fserver=$server; $fplayer=$player;
						}elseif($model==3){
						    $fcontent=$xfiles[0]; $fname=$xfiles[1]; $fserver=$xfiles[2]; $fplayer=$player;
						}else{
						    $fcontent=$xfiles[0]; $fname=$xfiles[1]; $fserver=$xfiles[2]; $fplayer=$xfiles[3];
						}
                        $db->query("INSERT INTO {$tablepre}files(mid,name,content,server,player) VALUES('$mid','$fname','$fcontent','$fserver','$fplayer')");
			        }
			        }
			    }

                if($isshow > 0){
                    require control('movie');
                    nmsg('operate_succeed',"?action=movie_add");
                }else{
                    nmsg('operate_succeed',"?action=movie_add");
                }

            }
		}
    break;
//***
    case 'movie_mod' :
		if(!$pmid && !$submit){
            $perpage='30';
            $page=$page ? $page : 1;
            $mpurl = "?action=movie_add";
            $offset=$page ? ($page-1)*$perpage : 0;
            $query1="SELECT count(*) AS num FROM {$tablepre}movies_p where 1 order by mid desc";
            $result1=$db->query($query1);
            $r=$db->fetch_array($result1);
            $num=$r["num"];
            $pages=phppage($num,$perpage,$page,$mpurl);
            $query2="SELECT * FROM {$tablepre}movies_p where 1 order by mid desc LIMIT $offset,$perpage";
            $result2=$db->query($query2);
            while($nmov=$db->fetch_array($result2)){
			    $nmov[theurl]="?action=movie_mod&pmid=$nmov[mid]&mid=$mid";
                $nmovs[]=$nmov;
            }
            nmcptpl('movie_p');
	    }else{
		    $rm=$db->query("SELECT * FROM {$tablepre}movies WHERE mid='$mid'");
            $nmov=$db->fetch_array($rm);

            $rp=$db->query("SELECT server,player,model,filename,pfrom,pto,pfile,pextend FROM {$tablepre}movies_p WHERE mid='$pmid'");
			$pmov=$db->fetch_array($rp);

            $rf=$db->query("SELECT * FROM {$tablepre}files WHERE mid='$mid' ORDER BY server DESC, fid ASC");
            while($r=$db->fetch_array($rf)){
                $oldfiles[]=$r;	
            }

            if(!$submit){
                if(is_array($_NCACHE['categorys'])) foreach($_NCACHE['categorys'] as $cate){
                    if($nmov[cid] == $cate[cid]){ $N_select = " selected"; }else{ $N_select = ""; }
                    $cateopt = $cateopt. "<option value=\"$cate[cid]\" $N_select>$cate[cid]|$cate[name]</option>";
                }
                if(is_array($_NCACHE['servers'])) foreach($_NCACHE['servers'] as $serv){
                    if($pmov[server] == $serv[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                    $servopt = $servopt. "<option value=\"$serv[identifier]\" $N_select>$serv[identifier]|$serv[name]</option>";
                }
                if(is_array($_NCACHE['players'])) foreach($_NCACHE['players'] as $play){
                    if($pmov[player] == $play[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                    $playopt = $playopt. "<option value=\"$play[identifier]\" $N_select>$play[identifier]|$play[name]</option>";
			    }
                if(is_array($_NCACHE['settings'][m_areas])) foreach($_NCACHE['settings'][m_areas] as $area){
			        if($nmov[area] == $area){ $NC_select = " selected"; }else{ $NC_select = ""; }
			        $areaopt = $areaopt. "<option value=$area $NC_select>$area</option>";
			    }
                if(is_array($_NCACHE['settings'][m_languages])) foreach($_NCACHE['settings'][m_languages] as $lang){
			        if($nmov[language] == $lang){ $NB_select = " selected"; }else{ $NB_select = ""; }
				    $langopt = $langopt. "<option value=$lang $NB_select>$lang</option>";
			    }
                if(is_array($_NCACHE['settings'][m_actors])) foreach($_NCACHE['settings'][m_actors] as $acto){$actoopt = $actoopt. "<option value=$acto>$acto</option>";}
                if(is_array($_NCACHE['settings'][m_directors])) foreach($_NCACHE['settings'][m_directors] as $dire){$direopt = $direopt. "<option value=$dire>$dire</option>";}
                if(is_array($_NCACHE['settings'][m_keywords])) foreach($_NCACHE['settings'][m_keywords] as $keyw){$keywopt = $keywopt. "<option value=$keyw>$keyw</option>";}
                nmcptpl('movie');
            }else{
                if(!$name || strlen($name) > 50 || strlen($language) > 50 || strlen($area) > 50 || strlen($actor) > 255 || strlen($director) > 255 || strlen($picture) > 255 || strlen($keyword) > 255 || strlen($description) > 255) {nmsg('info_invalid','','back');}
			    $author=$reauthor ? $_SESSION[auser] : $nmov[author];
			    $addtime=$readdtime ? $timestamp : $nmov[addtime];
                $db->query("UPDATE {$tablepre}movies SET author='$author',addtime='$addtime',name='$name',cid='$cid',area='$area',language='$language',actor='$actor',director='$director',picture='$picture',content='$content',adsense='$adsense',description='$description',keyword='$keyword',isrun='$isrun',isindex='$isindex',ismlist='$ismlist',isshow='$isshow',hits='$hits' WHERE mid='$mid'");

			    if($filefidold){
                    for($i = 0; $i < count($filefidold); $i++){
				        if($fileolddel[$i] == 'x'){
					        $db->query("DELETE FROM {$tablepre}files WHERE fid='$filefidold[$i]'");
					    }else{
                            $db->query("UPDATE {$tablepre}files SET name='$filenameold[$i]', content='$filecontentold[$i]', server='$fileserverold[$i]', player='$fileplayerold[$i]' WHERE fid=$filefidold[$i]");
					    }
                    }
			    }

			    $filecontent=trim($filecontent);
			    if($filecontent!=''){
			        $xfilecontents=explode("\r",$filecontent);
			        foreach($xfilecontents as $i=>$xfilecontent){
			            $xfiles=explode("|",trim($xfilecontent));
			            if($model==1){
						    $fcontent=$xfiles[0]; $fserver=$server; $fplayer=$player;
						    if($filename){$fname=str_replace("i",$i+1,$filename);}else{$fname=$i+1;}
			            }elseif($model==2){
						    $fcontent=$xfiles[0]; $fname=$xfiles[1]; $fserver=$server; $fplayer=$player;
			            }elseif($model==3){
						    $fcontent=$xfiles[0]; $fname=$xfiles[1]; $fserver=$xfiles[2]; $fplayer=$player;
			            }else{
						    $fcontent=$xfiles[0]; $fname=$xfiles[1]; $fserver=$xfiles[2]; $fplayer=$xfiles[3];
			            }
			            $db->query("INSERT INTO {$tablepre}files(mid,name,content,server,player) VALUES('$mid','$fname','$fcontent','$fserver','$fplayer')");
			        }
			    }

                if($isshow>0){
                    require control('movie');
                    nmsg('operate_succeed','?action=movie_manage');
                }else{
                    $delfilename = movieurl($mid);
                    $delhtmlfile = $delfilename.'.htm';
				    $delcachefile = $delfilename.'.php';
                    del_file($delhtmlfile);
			    	del_file($delcachefile);
                    nmsg('operate_succeed','?action=movie_manage');
                }
            }
	    }
    break;
//***
    case 'movie_del' :
        if(!$confirmed) {
            nmsg('operate_duplicate', "?action=movie_del&mid=$mid", 'form');						
        }else{
            $result=$db->query("SELECT mid,addtime,picture FROM {$tablepre}movies WHERE mid='$mid'");
            $delmovie=$db->fetch_array($result);            
            $delfilename = movieurl($mid);
            $delhtmlfile = $delfilename.'.htm';
			$delcachefile = $delfilename.'.php';
            $delpicture=$delmovie['picture'];
            del_file($delhtmlfile);
			del_file($delcachefile);
            del_file($delpicture);
            $db->query("DELETE FROM {$tablepre}files WHERE mid='$mid'");
            $db->query("DELETE FROM {$tablepre}movies WHERE mid='$mid'");
            nmsg('operate_succeed',"?action=movie_manage");	   
        }
    break;
//***
    case 'movie_manage' :
        if(is_array($_NCACHE['categorys'])) foreach($_NCACHE['categorys'] as $cate){
            if($cid == $cate[cid]){ $N_select = " selected"; }else{ $N_select = ""; }
            $cateopt = $cateopt. "<option value=$cate[cid] $N_select>$cate[cid]|$cate[name]</option>";
        }
        if(is_array($_NCACHE['servers'])) foreach($_NCACHE['servers'] as $serv){
            if($sid == $serv[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
            $servopt = $servopt. "<option value=\"$serv[identifier]\" $N_select>$serv[identifier]|$serv[name]</option>";
        }
        $perpage='50';
        $page=$page ? $page : 1;
        $mpurl = "?action=movie_manage&o=$o&p=$p&cid=$cid&pid=$pid&sid=$sid&type=$type&ordertype=$ordertype&keyword=$keyword";
        $offset=$page ? ($page-1)*$perpage : 0;

		$ordertypes = array('1'=>'order by addtime DESC ','2'=>'order by addtime ASC ','3'=>'order by hits DESC ','4'=>'order by hits ASC ');
		$otype = $ordertype ? $ordertypes[$ordertype] : $ordertypes[1];
        switch($o){
            case 1:
                switch($p){
                    case 'isindex' : $WHERE='WHERE isindex>0'; break;
                    case 'noindex' : $WHERE='WHERE isindex<1'; break;
					case 'isrun' : $WHERE='WHERE isrun>0 and isrun<999'; break;
					case 'run' : $WHERE='WHERE isrun>998'; break;
					case 'norun' : $WHERE='WHERE isrun<1'; break;
					case 'ads' : $WHERE="WHERE adsense!=''"; break;
					case 'noads' : $WHERE="WHERE adsense=''"; break;
                    case 'ismlist' : $WHERE='WHERE ismlist>0'; break;
                    case 'nomlist' : $WHERE='WHERE ismlist<1'; break;
                    case 'isshow' : $WHERE='WHERE isshow>0'; break;
                    case 'noshow' : $WHERE='WHERE isshow<1'; break;
					case 'iscat' :
						if(is_array($_NCACHE['categorys'])){foreach($_NCACHE['categorys'] as $C_category){$cids .= $comma.$C_category[cid]; $comma = ',';}}
					    $WHERE = empty($cids) ? 'WHERE 1' : "WHERE cid in ($cids)";
					break;
					case 'nocat' :
						if(is_array($_NCACHE['categorys'])){foreach($_NCACHE['categorys'] as $C_category){$cids .= $comma.$C_category[cid]; $comma = ',';}}
					    $WHERE = empty($cids) ? 'WHERE 1' : "WHERE cid not in ($cids)";
					break;
                    default : $WHERE='WHERE 1'; break;
                }
            break;
			case 2 :
                if($sid==''){
				    $WHERE="WHERE 1";
				}else{
				    $WHERE ="INNER JOIN {$tablepre}files f ON m.mid=f.mid WHERE f.server='$sid'";
				}
			break;
            case 3 :
                if($cid>0){$WHERE ='WHERE cid='.$cid;}else{$WHERE='WHERE 1';}
                if($keyword!=''){
                    switch($type){
                        case 'name' : $ANDWHERE ="and name like '%$keyword%'"; break;
                        case 'language' : $ANDWHERE ="and language like '%$keyword%'"; break;
                        case 'area' : $ANDWHERE ="and area like '%$keyword%'"; break;
                        case 'actor' : $ANDWHERE ="and actor like '%$keyword%'"; break;
                        case 'director' : $ANDWHERE ="and director like '%$keyword%'"; break;
						case 'keyword' : $ANDWHERE ="and keyword like '%$keyword%'"; break;
                        case 'description' : $ANDWHERE ="and description like '%$keyword%'"; break;
                        case 'content' : $ANDWHERE ="and content like '%$keyword%'"; break;
                        case 'mid' : $ANDWHERE ="and mid='".$keyword."'"; break;
                        default : $ANDWHERE =""; break;
                    }
                }else{
                   $ANDWHERE ="";
                }
            break;
        }

        $query1="SELECT count(DISTINCT m.mid) AS num FROM {$tablepre}movies m $WHERE $ANDWHERE";
        $result1=$db->query($query1);
        $r1=$db->fetch_array($result1);
        $num=$r1["num"];
        $pages=phppage($num,$perpage,$page,$mpurl);
        $query2="SELECT DISTINCT m.* FROM {$tablepre}movies m $WHERE $ANDWHERE $otype LIMIT $offset,$perpage";
        $result2=$db->query($query2);
        while($nmov=$db->fetch_array($result2)){
            $movieurl = movieurl($nmov[mid]);
            $htmlfile = $movieurl.'.htm';
			$cachefile = $movieurl.'.php';
            $nmov[htmlfile]=$htmlfile;
            if(!file_exists($htmlfile) || !file_exists($cachefile)){ $nmov[htmlexist]=0; }else{ $nmov[htmlexist]=1; }
            @clearstatcache($htmlfile);
            $nmov[catname]=$_NCACHE['categorys'][$nmov[cid]][name];
            $nmov[catcontent]=$_NCACHE['categorys'][$nmov[cid]][content];
			$nmov[srun]=movierun($nmov[isrun]);
			$nmov[stime]=date("y-m-d",$nmov[addtime]);
            $nmovs[]=$nmov;
        }
        nmcptpl('movie');
    break;
//***
    case 'movie_from' :
        if($xgsubmit) {
            $comma = '';
            if(!$mid){nmsg('operate_invalid','?action=movie_manage'); }
            if(is_array($mid)){foreach($mid as $m_id){$mids .= $comma.$m_id; $comma = ',';}}else{$mids = $mid;}
            if(is_array($_NCACHE['categorys'])) foreach($_NCACHE['categorys'] as $cate){
                if($cid == $cate[cid]){ $N_select = " selected"; }else{ $N_select = ""; }
                $cateopt = $cateopt. "<option value=$cate[cid] $N_select>$cate[cid]|$cate[name]</option>";
			}
            nmcptpl('movie');
        }elseif($fbsubmit){
            $comma = '';
            if(!$mid){nmsg('operate_invalid','?action=movie_manage'); }
            if(is_array($mid)){foreach($mid as $m_id){$mids .= $comma.$m_id; $comma = '_';}}else{$mids = $mid;}
            nmsg('operate_duplicate',"?action=movie_to&mids=$mids&fbsubmit=yes",'form');
        }elseif($jzsubmit){
            $comma = '';
            if(!$mid){nmsg('operate_invalid','?action=movie_manage'); }
            if(is_array($mid)){foreach($mid as $m_id){$mids .= $comma.$m_id; $comma = '_';}}else{$mids = $mid;}
            nmsg('operate_duplicate',"?action=movie_to&mids=$mids&jzsubmit=yes",'form');
        }elseif($scsubmit){
            $comma = '';
            if(!$mid){nmsg('operate_invalid','?action=movie_manage'); }
            if(is_array($mid)){foreach($mid as $m_id){$mids .= $comma.$m_id; $comma = '_';}}else{$mids = $mid;}
            nmsg('operate_duplicate',"?action=movie_to&mids=$mids&scsubmit=yes",'form');
        }elseif($fxxsubmit) {
            $comma = '';
            if(!$fid){nmsg('operate_invalid','?action=movie_file'); }
            if(is_array($fid)){foreach($fid as $f_id){$fids .= $comma."'".$f_id."'"; $comma = ',';}}else{$fids = "'".$fid."'";}
            $result1=$db->query("SELECT * FROM {$tablepre}files WHERE fid in ($fids) ORDER BY server DESC, fid ASC");
            while($r1=$db->fetch_array($result1)){
                $oldfiles[]=$r1;	
            }
            nmcptpl('movie');
        }elseif($fxgsubmit) {
            $comma = '';
            if(!$fid){nmsg('operate_invalid','?action=movie_file'); }
            if(is_array($fid)){foreach($fid as $f_id){$fids .= $comma.$f_id; $comma = ',';}}else{$fids = $fid;}
            if(is_array($_NCACHE['players'])) foreach($_NCACHE['players'] as $play){
                if($npid == $play[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                $playopt = $playopt. "<option value=\"$play[identifier]\" $N_select>$play[identifier]|$play[name]</option>";
			}
            if(is_array($_NCACHE['servers'])) foreach($_NCACHE['servers'] as $serv){
                if($nsid == $serv[identifier]){ $N_select = " selected"; }else{ $N_select = ""; }
                $servopt = $servopt. "<option value=\"$serv[identifier]\" $N_select>$serv[identifier]|$serv[name]</option>";
            }
            nmcptpl('movie');
        }elseif($fscsubmit){
            $comma = '';
            if(!$fid){nmsg('operate_invalid','?action=movie_file'); }
            if(is_array($fid)){foreach($fid as $f_id){$mids .= $comma.$f_id; $comma = '_';}}else{$fids = $fid;}
            nmsg('operate_duplicate',"?action=movie_to&fids=$mids&fscsubmit=yes",'form');
        }else{
            nmsg('operate_invalid',"?action=movie_manage"); 
        }
    break;
//***
    case 'movie_to' :
        if($xgsubmit) {
            if(!$mids){
                nmsg('operate_invalid','?action=movie_manage'); 
            }else{
                if(!$o){ nmsg('operate_invalid','?action=movie_manage'); }
                switch($o){
                    case 'cat' : $s = "cid='$cid'"; break;
                    case 'index' : $s = "isindex='$isindex'"; break;
                    case 'mlist' : $s = "ismlist='$ismlist'"; break;
                    default : $s=''; break;
                }
                if($s){
                    $db->query("update {$tablepre}movies set $s where mid in ($mids)"); 
                    $mids=explode(',', $mids);
                    foreach($mids as $mid){
                        if($db->num_rows($db->query("select * from {$tablepre}movies where mid='$mid' and isshow>0"))>0){
                            require control('movie');
                        }
                    }
                    nmsg('operate_succeed','?action=movie_manage'); 
                }else{
                    nmsg('operate_invalid','?action_manage'); 
                }
            }
        }elseif($fbsubmit){
            if(!$mids){nmsg('operate_invalid','?action=movie_manage'); }
            $mids=explode('_', $mids);
            if(is_array($mids)){
                foreach($mids as $mid){
				    $db->query("UPDATE {$tablepre}movies SET isshow='1' WHERE mid='$mid'");
                    require control('movie');
                }
                nmsg('operate_succeed','?action=movie_manage');
            }else{
                nmsg('operate_invalid','?action=movie_manage');
            }
        }elseif($jzsubmit){
            if(!$mids){nmsg('operate_invalid','?action=movie_manage'); }
            $mids=explode('_', $mids);
            if(is_array($mids)){
                foreach($mids as $mid){
                    $delfilename = movieurl($mid);
                    $delhtmlfile = $delfilename.'.htm';
					$delcachefile = $delfilename.'.php';
					del_file($delcachefile);
                    del_file($delhtmlfile);
				    $db->query("UPDATE {$tablepre}movies SET isshow='0' WHERE mid='$mid'");
                }
                nmsg('operate_succeed','?action=movie_manage');
            }else{
                nmsg('operate_invalid','?action=movie_manage');
            }
        }elseif($scsubmit){
            if(!$mids){nmsg('operate_invalid','?action=movie_manage'); }
            $mids=explode('_', $mids);
            if(is_array($mids)){
                foreach($mids as $mid){
                    $result=$db->query("SELECT mid,addtime,picture FROM {$tablepre}movies WHERE mid='$mid'");
                    $delmovie=$db->fetch_array($result);
                    $delfilename = movieurl($mid);
                    $delhtmlfile = $delfilename.'.htm';
					$delcachefile = $delfilename.'.php';
                    $delpicture = $delmovie['picture'];
                    del_file($delhtmlfile);
					del_file($delcachefile);
                    del_file($delpicture);
                    $db->query("DELETE FROM {$tablepre}files WHERE mid='$mid'");
                    $db->query("DELETE FROM {$tablepre}movies WHERE mid='$mid'");
                }
                nmsg('operate_succeed','?action=movie_manage');
            }else{
                nmsg('operate_invalid','?action=movie_manage');
            }
        }elseif($fxxsubmit) {
            if(!$filefidold){
                nmsg('operate_invalid','?action=movie_file'); 
            }else{
			    if($filefidold){
                    for($i = 0; $i < count($filefidold); $i++){
				        if($fileolddel[$i] == 'x'){
					        $db->query("DELETE FROM {$tablepre}files WHERE fid='$filefidold[$i]'");
					    }else{
                            $db->query("UPDATE {$tablepre}files SET name='$filenameold[$i]', content='$filecontentold[$i]', server='$fileserverold[$i]', player='$fileplayerold[$i]' WHERE fid=$filefidold[$i]");
					    }
                    }
			    }
				nmsg('operate_succeed','?action=movie_file');
			}
        }elseif($fxgsubmit) {
            if(!$fids){
                nmsg('operate_invalid','?action=movie_file'); 
            }else{
                if(!$o){ nmsg('operate_invalid','?action=movie_file'); }
                switch($o){
                    case 'server' : $s = "server='$sid'"; break;
                    case 'player' : $s = "player='$pid'"; break;
                    case 'movie' : $s = "mid='$movie'"; break;
					case 'error' : $s = "extend3='$error'"; break;
                    default : $s=''; break;
                }
                if($s){
                    $db->query("update {$tablepre}files set $s where fid in ($fids)"); 
                    nmsg('operate_succeed','?action=movie_file'); 
                }else{
                    nmsg('operate_invalid','?action=movie_file'); 
                }
            }
        }elseif($fscsubmit){
            if(!$fids){nmsg('operate_invalid','?action=movie_file'); }
			$fids=str_replace('_',',',$fids);
            $db->query("DELETE FROM {$tablepre}files WHERE fid in ($fids)");
            nmsg('operate_succeed','?action=movie_file');
        }else{
            nmsg('operate_invalid','?action=movie_file'); 
        }
    break;
}
?>