MSV FM

dot.antimicrobial@66.96.161.157: ~ $
Path : /hermes/sb_web/b2920/hilmajohnson.com/admin/
File Upload :
Current < : /hermes/sb_web/b2920/hilmajohnson.com/admin/video.php

<?php
    ////////////////////////////////
    ob_start();
    session_start(); /// initialize session 
    include("./inc/pw.php"); 
    check_logged();
    include("./inc/dirscan.php");
    include("./inc/array_xml.php");
    include("./inc/jscript.php");


    $module= xml2ary(file_get_contents('tmp/module.xml'));
    $modulesize=count($module['module']['_c']['item']); 
    if (isset($_SESSION['pathvideo'])){
        $finale= xml2ary(file_get_contents($_SESSION['pathvideo']."/gallery.xml"));
        $catsize=count($finale['items']['_c']['item']);
        // print_r($finale);
    }
    $tmpcat=xml2ary(file_get_contents('tmp/template/photo/categories.xml'));


    if (isset($_POST['editvideo']))
    { 

$_SESSION['pathvideo'] =$_POST['videoname'];




        echo ("<h1>YOU ARE EDITING VIDEOGALLERY FROM ".$_POST['videoname']." FOLDER.<br/><br/><br/><a href='video.php' >GO EDIT</a></h1>");

    }

    else if (isset($_POST['deletevideo']))
    { 


        echo" <SCRIPT LANGUAGE='javascript'>submitFormVideo('".$_POST['videoname']."','video','deletefolder');</SCRIPT>";





    } else if (isset($_GET['deletevideo'])=='deletefolder')
    { 


        $directory=$_GET['name'];
        // echo $directory;
        for($i=0;$i<$modulesize;$i++){

            if($i>1 && $module['module']['_c']['item'][$i]['_c']['path']['_v'] == $directory){

                unset($_SESSION['pathvideo']);
                unset($module['module']['_c']['item'][$i]);
                $last= ary2xml($module);
                //write();
                $fh = fopen("tmp/module.xml", "w");

                if($fh==false)
                die("unable to create file");

                fwrite($fh, $last);
                fclose($fh);
            }

        }


        // Delete it
        if (recursive_remove_directory($directory))
        {
            //echo "{$directory} has been deleted";

            echo ("<h1>Videogallery folder deleted!<br/><br/><br/><a href='index.php' target='_top'>Close</a></h1>");
        }
        else
        {
            echo "{$directory} could not be deleted";
        }  




    }

    /////////////DELETE SINGLE VIDEO
    
 else  if ($_GET['deletevideos']=='delete')
    { 
        //  echo("delete".$_POST['itemnumber']);
        $selected= $_GET['name'];
        // print_r ($finale['item'][$numdamod]);
        if ($selected==0){
            //   echo("number 0");
            array_shift($finale['items']['_c']['item']);
            $last= ary2xml($finale);

        }else{

            
            unset($finale['items']['_c']['item'][$selected]);
           
            $last= ary2xml($finale);
        }


        //write();
        $fh = fopen($_SESSION['pathvideo']."/gallery.xml", "w");

        if($fh==false)
        die("unable to create file");

        fwrite($fh, $last);
        fclose($fh);
        echo ("<h1>Video deleted!!<br/><br/><br/><a href='video.php'>Back to Pictures</a></h1>");




    } 

 //////////////////////EDIT pictures///////////////////////////// 




    else  if (isset($_POST['edit'])) 

    {
        

        $selected= $_POST['itemnumber'];

        $filejpg=scan_directory_recursively($_SESSION['pathvideo'].'/assets/thumbs');
        $filejpgbig=scan_directory_recursively($_SESSION['pathvideo'].'/assets','flv');
        // 
        $filenumber= sizeof($filejpg);
        $filenumberbig= sizeof($filejpgbig);



        /////edit
        echo "<table width='700' border='0' cellspacing='0' cellpadding='2'>"  ;
        echo "<form action='video.php' method='post'>";   

        // 
        echo "<tr>";
        echo "<td align='center' colspan='2'><br/><h1>EDIT team</h1><br/></td>";
        echo "</tr>";

        // 
        $valuethumb=substr($finale['items']['_c']['item'][$selected]['_c']['thumb']['_v'],7);


        echo "<tr>";    
        echo "<td><p>Caption:</p> </td><td> <textarea name='title' cols='40' rows='3'>".$finale['items']['_c']['item'][$selected]['_c']['title']['_v']."</textarea></td>";
        echo "</tr>";   
        echo  "<td><p>Thumbnail</p></td><td><select name='thumb' id='thumb'>";
        echo "<option value='".$valuethumb."'>".$valuethumb."</option>";
        for ($i=0;$i<$filenumber;$i++){

            if ($filejpg[$i]['kind']=="file"){
                echo "<option value='".$filejpg[$i]['name']."'>".$filejpg[$i]['name']."</option>";
            }
        }
        echo "</select></td>" ;
        echo "</tr>";
        echo "<tr>";
        echo  "<td><p>Video </p></td><td><select name='link' id='link'>";
        echo "<option value='".$finale['items']['_c']['item'][$selected]['_c']['link']['_v']."'>".$finale['items']['_c']['item'][$selected]['_c']['link']['_v']."</option>";
        for ($i=0;$i<$filenumberbig;$i++){

            if ($filejpgbig[$i]['kind']=="file"){
                echo "<option value='".$filejpgbig[$i]['name']."'>".$filejpgbig[$i]['name']."</option>";
            }
        }
        echo "</select></td>" ;
        echo "</tr>";
        echo "<tr>";

        echo "<input name='number' type='hidden' value='".$selected."' />";
        echo "<td colspan='2' align='center'><input name='save' type='submit' value='save' /><input name='cancel' type='submit' value='cancel' ></td>";

        echo "</form>";
        echo "</tr>";
        echo "</table>";
        /////fine edit

}
///// SAVE AFTER EDIT /////////////////////
 else if (isset($_POST['save']))
    { 
        $numdamod= $_POST['number'];
        

        //cambio i dati

        $finale['items']['_c']['item'][$numdamod]['_c']['title']['_v']=  $_POST['title'];  
        $finale['items']['_c']['item'][$numdamod]['_c']['link']['_v']=  $_POST['link'];  
        $finale['items']['_c']['item'][$numdamod]['_c']['thumb']['_v']=  "thumbs/".$_POST['thumb'];  
       
        
        $last= ary2xml($finale);
        //write();
        $fh = fopen($_SESSION['pathvideo']."/gallery.xml", "w");

        if($fh==false)
        die("unable to create file");

        fwrite($fh, $last);
        fclose($fh);
        echo ("<h1>Video data Edited!<br/><br/><br/><a href='video.php'>Back to VIDEO LIST</a></h1>");


    }


        //////////////////////ADD NEW///////////////////////////// 

     else  if (isset($_POST['new'])) 

    {

        $filejpg=scan_directory_recursively($_SESSION['pathvideo'].'/assets/thumbs');
        $filejpgbig=scan_directory_recursively($_SESSION['pathvideo'].'/assets','flv');
        // 
        $filenumber= sizeof($filejpg);
        $filenumberbig= sizeof($filejpgbig);


        echo "<table width='700' border='0' cellspacing='0' cellpadding='2'>"  ;
        echo "<form action='video.php' method='post'>";   

        // 
        echo "<tr>";
        echo "<td align='center' colspan='2'><br/><h1>ADD A NEW VIDEO</h1><br/></td>";
        echo "</tr>";


        echo "<tr>";
        echo "<td><p>Caption:</p> </td><td><textarea name='title' cols='40' rows='3'></textarea></td>";

        echo "</tr>"; 
        echo "<tr>";
        echo  "<td><p>Thumbnail</p></td> <td><select name='thumb' id='thumb'>";
        for ($i=0;$i<$filenumber;$i++){

            if ($filejpg[$i]['kind']=="file"){
                echo "<option value='".$filejpg[$i]['name']."'>".$filejpg[$i]['name']."</option>";
            }
        }
        echo "</select></td>" ;
        echo "</tr>";
        echo "<tr>";
        echo  "<td><p>Video </p></td> <td><select name='link' id='link'>";
        for ($i=0;$i<$filenumberbig;$i++){

            if ($filejpgbig[$i]['kind']=="file"){
                echo "<option value='".$filejpgbig[$i]['name']."'>".$filejpgbig[$i]['name']."</option>";
            }
        }
        echo "</select></td>" ;
        echo "</tr>";

        echo "<tr>";
        echo "<td colspan='2' align='center'><input name='savenew' type='submit' value='save new' /><input name='cancel' type='submit' value='cancel' ></td>";

        echo "</form>";
        echo "</tr>";
        echo "</table>";
        /////fine new
    }

    

    else if (isset($_POST['savenew']))
    { 

        $newdata=$finale['items']['_c']['item'][0];
        //cambio i dati


        $newdata['_c']['title']['_v']=  $_POST['title'];
        $newdata['_c']['link']['_v']=  $_POST['link'];
        $newdata['_c']['thumb']['_v']=  "thumbs/".$_POST['thumb'];
        
        

        ins2ary($finale['items']['_c']['item'],$newdata,$catsize+1);

        $last= ary2xml($finale);
        //write();
        $fh = fopen($_SESSION['pathvideo']."/gallery.xml", "w");

        if($fh==false)
        die("unable to create file");

        fwrite($fh, $last);
        fclose($fh);
        echo ("<h1>Video inserted!<br/><br/><br/><a href='video.php'>Back to VIDEO LIST</a></h1>");


    } 
   
        //////////////////////MOVE UP///////////////////////////// 

    else  if (isset($_POST['up'])) 

    {
        $selected= $_POST['itemnumber'];



        $temp = $finale['items']['_c']['item'][$selected-1];
        $finale['items']['_c']['item'][$selected-1] = $finale['items']['_c']['item'][$selected];
        $finale['items']['_c']['item'][$selected] = $temp; 
        $last= ary2xml($finale);




        //write();
        $fh = fopen($_SESSION['pathvideo']."/gallery.xml", "w");

        if($fh==false)
        die("unable to create file");

        fwrite($fh, $last);
        fclose($fh);
        
        header("Location:video.php");

        //////////////////////MOVE DOWN///////////////////////////// 


    }
    else  if (isset($_POST['down'])) 

    {
     
        $selected= $_POST['itemnumber'];



        $temp = $finale['items']['_c']['item'][$selected+1];
        $finale['items']['_c']['item'][$selected+1] = $finale['items']['_c']['item'][$selected];
        $finale['items']['_c']['item'][$selected] = $temp; 
        $last= ary2xml($finale);




        //write();
        $fh = fopen($_SESSION['pathvideo']."/gallery.xml", "w");

        if($fh==false)
        die("unable to create file");

        fwrite($fh, $last);
        fclose($fh);
       
        header("Location:video.php");

    }





    else  
    {

       
        echo "<table width='700' border='0' cellspacing='0' cellpadding='2'>"  ;



        echo "<tr><td colspan='2'><h1>VIDEOGALLERY ADMIN PANEL</h1></td><td colspan='4' align='center'><form action='video.php' method='post'>"; 
        echo   "<br/><input name='new' type='submit' value='ADD A VIDEO' /><br/><br/>" ;
        echo "</form></td>"; 

        for($i=0;$i<$catsize;$i++){ 
            echo "<form action='video.php' method='post'>";   
            echo "<tr>"       ;





            echo   "<td width='100' align='center'><img src='".$_SESSION['pathvideo']."/assets/".$finale['items']['_c']['item'][$i]['_c']['thumb']['_v']."'></td>" ; 

             echo   "<td width='100' align='center'><p>".$finale['items']['_c']['item'][$i]['_c']['link']['_v']."</p></td>" ; 

            echo   "<td>".$finale['items']['_c']['item'][$i]['_c']['title']['_v']." <input name='itemnumber' type='hidden' value='".$i."' /></td>" ; 



            echo   "<td align='center'><input name='edit' type='submit' value='edit' />";

            if($catsize>2){
                echo"<input name='delete'  onClick=\"submitFormVideov(".$i.",'video','delete');\"  type='button' value='delete' /></td>";  
            }         

            echo "<td align='center'>";
            if ($i!=0){

                echo "<input name='up' type='submit' value='move up' />" ;
            }
            if ($i!=$catsize-1){
                echo "<input name='down' type='submit' value='move down' />" ;    
            }
            echo "</td>";



            echo "</tr> "  ;


            echo "</form>";
        }
       
        echo "</table> " ;





    }    


?>