action_touch_file.php
Upload User: feiyaoda
Upload Date: 2016-11-21
Package Size: 9556k
Code Size: 2k
Category:

WEB Mail

Development Platform:

PHP

  1. <?php
  2. if ($_POST['touch_file_name'])
  3. {
  4.     $new_file = realpath_alternative($target_folder.$_POST['touch_file_name']);
  5.     if (FALSE == is_file($new_file))
  6.     {
  7.         // from windows browser fix
  8.         $content = str_replace("r",'',$_POST['filecontent']);
  9.         $fp = @fopen($new_file,'w');
  10.         if ($fp)
  11.         {
  12.             fwrite($fp,stripslashes($content));
  13.             fclose($fp);
  14.             echo "<body  bgcolor='#CFE3E3'><div class="success_box"><i>Action successfull. file </i>".$_POST['touch_file_name']."<i> has been created</i></div>n";
  15.         }
  16.         else
  17.             echo "<div class="error_box">ERROR! file ".$_POST['touch_file_name']." can't be created</div>n";
  18.     }
  19.     else
  20.         echo "<div class="error_box">ERROR! file ".$_POST['touch_file_name']." already exists</div>n";
  21.     
  22.     echo "<br><br>n";
  23. }
  24. else
  25. {
  26.     
  27.     echo "<form action=execute.php method=POST>n";
  28.     echo "<input type=hidden name=action value="".$_POST['action']."">n";
  29.     echo "<input type=hidden name=target_folder value="".$_POST['target_folder']."">n";
  30.     echo "<input type=hidden name=target_type value="".$_POST['target_type']."">n";
  31.     
  32.     echo "<table border=0>n";
  33.     
  34.     echo "<tr><th>current folder</th><td>".realpath_alternative($target_folder,true)."</td></tr>n";
  35.     echo "<tr><th>file name</th><td><input type=text name="touch_file_name" value=""></td></tr>n";
  36.     echo "<tr><th>file content</th><td><textarea name=filecontent></textarea></td></tr>n";
  37.     echo "</table>n";
  38.     echo "<input type=submit name=submit value="Create">n";
  39.     echo "</form>n";
  40. }