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/list.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['pathlist'])){
     $finale= xml2ary(file_get_contents($_SESSION['pathlist']."/team.xml"));
     $teamsize=count($finale['team']['_c']['item']);
     
   }


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

         $_SESSION['pathlist'] =$_POST['listname'];




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

    }
    
    else if (isset($_POST['deletelist']))
    { 


        echo" <SCRIPT LANGUAGE='javascript'>submitFormList('".$_POST['listname']."','list','deletefolder');</SCRIPT>";





    } else if (isset($_GET['deletelist'])=='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['pathlist']);
                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>Custom list folder deleted!<br/><br/><br/><a href='index.php' target='_top'>Close</a></h1>");
        }
        else
        {
            echo "{$directory} could not be deleted";
        }  




    }





    else if (isset($_POST['save']))
    { 
        //echo("inviato".$_POST['number']);
        $numdamod= $_POST['number'];
        // print_r ($finale['item'][$numdamod]);

        //cambio i dati

        $finale['team']['_c']['item'][$numdamod]['_c'][txt]['_v']=  $_POST['txt'];  
        $finale['team']['_c']['item'][$numdamod]['_c'][txtbig]['_v']=  $_POST['txtbig'];  
        $finale['team']['_c']['item'][$numdamod]['_c'][link]['_v']=  $_POST['link'];  
        $finale['team']['_c']['item'][$numdamod]['_c'][img]['_v']=  $_POST['img'];  
        $finale['team']['_c']['item'][$numdamod]['_c'][imgbig]['_v']=  $_POST['imgbig'];  
        //print_r ($finale['team']['_c']['item'][$numdamod]);
        $last= ary2xml($finale);
        //write();
        $fh = fopen($_SESSION['pathlist']."/team.xml", "w");

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

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


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

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


        $newdata['_c'][txt]['_v']=  $_POST['txt'];
        $newdata['_c'][txtbig]['_v']=  $_POST['txtbig'];
        $newdata['_c'][link]['_v']=  $_POST['link'];
        $newdata['_c'][img]['_v']=  $_POST['img'];
        $newdata['_c'][imgbig]['_v']=  $_POST['imgbig'];


        //  print_r ($newdata);
        //print_r ($finale['team']['_c']['item'][0]);

        ins2ary($finale['team']['_c']['item'],$newdata,$teamsize+1);

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

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

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


    } 
    else  if ($_GET['delete']=='delete')
    { 
        //  echo("delete".$_POST['itemnumber']);
        $selected= $_GET['itemnumber'];
        // print_r ($finale['item'][$numdamod]);
        if ($selected==0){
            //   echo("number 0");
            array_shift($finale['team']['_c']['item']);
            $last= ary2xml($finale);

        }else{

            // print_r ($finale['team']['_c']['item'][$selected]);
            unset($finale['team']['_c']['item'][$selected]);
            //  print_r ($finale);

            $last= ary2xml($finale);
        }


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

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

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


        //////////////////////EDIT list///////////////////////////// 

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

    {
        // echo("edit ".$_POST['itemnumber']);

        $selected= $_POST['itemnumber'];

        $filejpg=scan_directory_recursively($_SESSION['pathlist'].'/img');
        $filejpgbig=scan_directory_recursively($_SESSION['pathlist'].'/img/big');
        // print_r($filejpg) ;
        $filenumber= sizeof($filejpg);
        $filenumberbig= sizeof($filejpgbig);
        // echo $filenumber;


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

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

        // 



        echo "<tr>";    
        echo "<td><p>txt:</p> </td><td> <textarea name='txt' cols='40' rows='3'>".$finale['team']['_c']['item'][$selected]['_c'][txt]['_v']."</textarea></td>";
        echo "<tr>";   
        echo "<td><p>txtbig:</p> </td><td> <textarea name='txtbig' cols='40' rows='10' >".$finale['team']['_c']['item'][$selected]['_c'][txtbig]['_v']."</textarea><br/>";
        echo "</tr>";
        echo "<tr>"; 
        echo "<td><p>link:</p> </td><td><input name='link' type='text' value='".$finale['team']['_c']['item'][$selected]['_c'][link]['_v']."' size='50' maxlength='50' /> </td>";
        echo "</tr>";
        echo "<tr>"; 
        echo  "<td><p>img </p></td><td><select name='img' id='img'>";
        echo "<option value='".$finale['team']['_c']['item'][$selected]['_c'][img]['_v']."'>".$finale['team']['_c']['item'][$selected]['_c'][img]['_v']."</option>";
        for ($i=0;$i<$filenumber;$i++){

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

            if ($filejpgbig[$i]['kind']=="file"){
                echo "<option value='".$filejpgbig[$i]['path']."'>".$filejpgbig[$i]['path']."</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


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

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

    {

        $filejpg=scan_directory_recursively($_SESSION['pathlist'].'/img');
        $filejpgbig=scan_directory_recursively($_SESSION['pathlist'].'/img/big');
        // print_r($filejpg) ;
        $filenumber= sizeof($filejpg);
        $filenumberbig= sizeof($filejpgbig);
        // echo $filenumber;
        /////edit

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

        // 
        echo "<tr>";
        echo "<td align='center' colspan='2'><br/><h1>ADD A NEW ITEM</h1><br/><h1>replace sample data with yours</h1></td>";
        echo "</tr>";


        echo "<tr>";
        echo "<td><p>txt:</p> </td><td><textarea name='txt' cols='40' rows='3'>".$finale['team']['_c']['item'][0]['_c'][txt]['_v']."</textarea></td>";

        echo "</tr>"; 
        echo "<tr>";
        echo "<td><p>txtbig: </p></td><td><textarea name='txtbig' cols='40' rows='10' >".$finale['team']['_c']['item'][0]['_c'][txtbig]['_v']."</textarea></td>";
        echo "</tr>";
        echo "<tr>"; 

        echo "<td><p>link:</p></td><td><input name='link' type='text' value='x' size='50' maxlength='50' /> </td>";
        echo "</tr>";
        echo "<tr>";
        echo  "<td><p>img</p></td> <td><select name='img' id='img'>";
        echo "<option value='".$finale['team']['_c']['item'][$selected]['_c'][img]['_v']."'>".$finale['team']['_c']['item'][$selected]['_c'][img]['_v']."</option>";
        for ($i=0;$i<$filenumber;$i++){

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

            if ($filejpgbig[$i]['kind']=="file"){
                echo "<option value='".$filejpgbig[$i]['path']."'>".$filejpgbig[$i]['path']."</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


        //////////////////////MOVE UP///////////////////////////// 

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

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



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




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

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

        fwrite($fh, $last);
        fclose($fh);
        //echo ("edit effettuata<a href='list.php'> torna all'elenco</a>");
        header("Location:list.php");

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


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

    {
        // echo("up".$_POST['itemnumber']);
        $selected= $_POST['itemnumber'];



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




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

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

        fwrite($fh, $last);
        fclose($fh);
        //echo ("edit effettuata<a href='list.php'> torna all'elenco</a>");
        header("Location:list.php");

    }





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



        echo "<tr><td colspan='2'><h1>CUSTOM LIST ADMIN PANEL</h1></td><td colspan='3' align='center'><form action='list.php' method='post'>"; 
        echo   "<br/><input name='new' type='submit' value='ADD A LIST ITEM' /><br/><br/>" ;
        echo "</form></td>"; 

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





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


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



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

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

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

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



            echo "</tr> "  ;

            echo "</form>";
        }


        echo "</table> " ;





    }    



?>