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/team.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");


    //$request_url = "team.xml";
    // $xml = simplexml_load_file($request_url) or die("feed not loading");

    // $finale=  (xml2phpArray($xml,array()));
    $finale= xml2ary(file_get_contents('../component/team/team.xml'));
    //print_r ($finale); 
    $teamsize=count($finale['team']['_c']['item']);  

    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("../component/team/team.xml", "w");

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

        fwrite($fh, $last);
        fclose($fh);
        echo ("<h1>Team Edited!<br/><br/><br/><a href='team.php'>Back to team 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("../component/team/team.xml", "w");

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

        fwrite($fh, $last);
        fclose($fh);
        echo ("<h1>Team inserted!<br/><br/><br/><a href='team.php'>Back to team 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("../component/team/team.xml", "w");

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

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


        //////////////////////EDIT team///////////////////////////// 

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

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

        $selected= $_POST['itemnumber'];

        $filejpg=scan_directory_recursively('../component/team/img');
        $filejpgbig=scan_directory_recursively('../component/team/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='team.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('../component/team/img');
        $filejpgbig=scan_directory_recursively('../component/team/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='team.php' method='post'>";   

        // 
        echo "<tr>";
        echo "<td align='center' colspan='2'><br/><h1>ADD A NEW TEAM MEMBER</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("../component/team/team.xml", "w");

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

        fwrite($fh, $last);
        fclose($fh);
        //echo ("edit effettuata<a href='team.php'> torna all'elenco</a>");
        header("Location:team.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("../component/team/team.xml", "w");

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

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

    }





    else  
    {

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



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

        for($i=0;$i<$teamsize;$i++){ 
            echo "<form action='team.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.",'team','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> " ;





    }    



?>