Вход Регистрация
Файл: id2759/PHP Version/fileman/edit.php
Строк: 240
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | Aquonics File Manager                                                |
// +----------------------------------------------------------------------+
// | Copyright (c) 2001 Aquonics Scripting                                |
// +----------------------------------------------------------------------+
// | You may not remove the copyright or redistribute the script in any   |
// | form. This program is Freeware, please read the license at           |
// | http://www.aquonics.com/license.php                                  |
// |                                                                      |
// | Visit www.aquonics.com for more top scripts, free and custom.        |
// +----------------------------------------------------------------------+
// | Authors: Stephen Ball <stephen@aquonics.com>                         |
// +----------------------------------------------------------------------+
//
// $Id$

error_reporting(0); /* Turn off ugly error messages */
set_time_limit(60); /* Ensure the script doesn't time out */

// Try to include important files
// or die with an error message
if (!(include("./common.lib.php"))) {
    die(
"<html><head><title>Error!</title></head><body bgcolor="#FFFFFF"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><center><b>There was an error loading the library file.</b></center></font></body></html>");
}
if (!(include(
"./settings.inc.php"))) {
    die(
"<html><head><title>Error!</title></head><body bgcolor="#FFFFFF"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><center><b>There was an error loading the settings file.</b></center></font></body></html>");
}
if (!(include(
"./templates.inc.php"))) {
    die(
"<html><head><title>Error!</title></head><body bgcolor="#FFFFFF"><font size="2" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000"><center><b>There was an error loading the templates list.</b></center></font></body></html>");
}

$username $HTTP_COOKIE_VARS["username"];
$password $HTTP_COOKIE_VARS["password"];

// Find out the starttime
$starttime starttime();

// Ensure the user is valid
if (validate_user($username$password) == 0) {
    
header("Location: ./" $login_script "");
    exit;
}
else if (
user_level($username$password) > 2) {
        
header("Location: ./" $main_script "?m=29");
        exit;
}

$dir rawurldecode($dir);
$fulldir $root_dir $dir "/";

if (empty(
$file)) {
    if (isset(
$i)) {
        
$tmpname "./templates/" $template[$i] . ".tmp";
        
$fp fopen($tmpname"r");
        
$fdata fread($fpfilesize($tmpname));
        
fclose($fp);
        
$file $new_file "." $extension[$i];
    }
    else {
        
$fdata "";
        
$file $new_file ".txt";
    }

    
$title "New File";
    
$isnew 1;
}
else {
    
$fullpath $fulldir $file;

    
$fp fopen($fullpath"r");
    
$fdata fread($fpfilesize($fullpath));
    
fclose($fp);

    
$title "Editing &quot;$file&quot;";
    
$isnew 0;
    
$fdata str_replace("</textarea>""</text-area>"$fdata);
}

// Find out the file extension
$ext getext($file);

if (empty(
$op)) {
    
$op "";
}

if (
$op == "save") {
    if (
file_exists($root_dir $dir "/" $filename) && ($fileisnew == "0" && $oldname != $filename)) {
        
header("Location: ./" $main_script "?dir=" encoded($dir) . "&m=14");
        exit;
    }
    else if (
file_exists($root_dir $dir "/" $filename) && $fileisnew == "1") {
        
header("Location: ./" $main_script "?dir=" encoded($dir) . "&m=14");
        exit;
    }
    elseif (!(
$fp fopen($root_dir $dir "/" $filename"w"))) {
        
header("Location: ./" $main_script "?dir=" encoded($dir) . "&m=5");
        exit;
   }
   else {
        
$filecontent str_replace("</text-area>""</textarea>"$filecontent);
        
$filecontent stripslashes($filecontent);
        
fwrite($fp$filecontent);
        
fclose($fp);
        
header("Location: ./" $main_script "?dir=" encoded($dir));
        exit;
    }
}
else if (
$op == "edit") {
    
$page_code "       <form action="$PHP_SELF" method="post" style="margin0" name="edit">rn";
    
$page_code .= "       <input type="hidden" name="op" value="save">rn";
    
$page_code .= "       <input type="hidden" name="dir" value="$dir">rn";
    
$page_code .= "       <input type="hidden" name="fileisnew" value="$isnew">rn";
    
$page_code .= "       <input type="hidden" name="oldname" value="$file">rn";
    
$page_code .= "       <table border="0" width="100%">rn";
    
$page_code .= "           <tr>rn";
    
$page_code .= "               <td align="center" bgcolor="#F5F5F5" valign="middle"><textarea wrap="virtual" name="filecontent" cols="100" rows="20">$fdata</textarea></td>rn";
    
$page_code .= "           </tr>rn";
    
$page_code .= "           <tr>rn";
    
$page_code .= "               <td align="center" bgcolor="#F5F5F5" valign="middle"><font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#000000">File Name</font> <input type="text" name="filename" value="$file" size="45"></td>rn";
    
$page_code .= "           </tr>rn";
    
$page_code .= "           <tr>rn";
    
$page_code .= "               <td align="center" bgcolor="#F5F5F5" valign="middle"><input type="submit" onclick="JavaScript:return isValid(edit.filename.value)" value="Save File"></td>rn";
    
$page_code .= "           </tr>rn";
    
$page_code .= "       </table>rn";
    
$page_code .= "       </form>rn";
}
else {
    
    
$langhtml "<option>No Template</option>";

    foreach (
$description as $key => $var) {
        
$langhtml .= "<option value="$key">$var</option>";
    }

    
$page_code "       <form action="$PHP_SELF" method="post" style="margin0" name="edit">rn";
    
$page_code .= "       <input type="hidden" name="op" value="edit">rn";
    
$page_code .= "       <input type="hidden" name="dir" value="$dir">rn";
    
$page_code .= "       <input type="hidden" name="isnew" value="$isnew">rn";
    
$page_code .= "       <input type="hidden" name="oldname" value="$file">rn";
    
$page_code .= "       <table border="0" width="100%">rn";
    
$page_code .= "           <tr>rn";
    
$page_code .= "               <td align="center" bgcolor="#F5F5F5" valign="middle"><select name="i">$langhtml</select></td>rn";
    
$page_code .= "           </tr>rn";
    
$page_code .= "           <tr>rn";
    
$page_code .= "               <td align="center" bgcolor="#F5F5F5" valign="middle"><input type="submit" value="Create New File"></td>rn";
    
$page_code .= "           </tr>rn";
    
$page_code .= "       </table>rn";
    
$page_code .= "       </form>rn";
}

// Print the page header
html_header("Edit File");

// Print the form
?>
    <tr>
        <td align="left" bgcolor="#4682B4">
        <table border="0" width="100%">
            <tr>
                <th align="left" bgcolor="#4682B4" valign="middle" width="99%"><img src="images/<?php echo get_icon($ext); ?>" alt="<?=$file;?>" border="0" /> <font size="1" face="Verdana, Geneva, Arial, Helvetica, Sans-Serif" color="#FFFFFF"><?=$title;?></font></th>
                <td align="right" bgcolor="#4682B4" valign="middle" width="1%" nowrap="nowrap"><a href="<?=$main_script;?>"><img src="images/home.gif" alt="Home" border="0" /></a> <a href="<?=$space_script;?>"><img src="images/space.gif" alt="Server Space" border="0" /></a> <a href="<?=$login_script;?>?op=out"><img src="images/logout.gif" alt="Logout" border="0" /></a></td>
            </tr>
        </table>
        </td>
    </tr>
    <tr>
        <td align="left" bgcolor="#F5F5F5">
<?=$page_code;?>
        </td>
    </tr>
</table>
<?php
// Print out the page footer
html_footer($starttime);
?>
Онлайн: 1
Реклама