wp/wp-content/plugins/wp-filemanager/incl/edit.inc.php
changeset 14 00ac8f60d73f
parent 13 d255fe9cd479
child 15 3d4e9c994f10
equal deleted inserted replaced
13:d255fe9cd479 14:00ac8f60d73f
     1 <?php
       
     2 if ( ! defined( 'ABSPATH' ) )
       
     3 	die();
       
     4 if (!@include_once(WP_CONTENT_DIR . "/plugins/wp-filemanager/incl/auth.inc.php"))
       
     5 {
       
     6  include_once(WP_CONTENT_DIR . "/plugins/wp-filemanager/incl/auth.inc.php");
       
     7 }
       
     8 //echo "save called with path";
       
     9 if ($AllowEdit && isset($_GET['save']) && isset($_POST['filename']))
       
    10 {
       
    11 	//echo "Save Edited file";
       
    12 	$text = stripslashes($_POST['text']);
       
    13 	if (!wp_fileman_is_valid_name(stripslashes($_POST['filename']))) 
       
    14 	{
       
    15 	print "<font color='#CC0000'>$StrFileInvalidName</font>";
       
    16 	}
       
    17 	else if ($fp = @fopen ($home_directory.$wp_fileman_path.stripslashes($_POST['filename']), "wb"))
       
    18 	{
       
    19 		@fwrite($fp, $text);
       
    20 		@fclose($fp);
       
    21 		print "<font color='#009900'>$StrSaveFileSuccess</font>";
       
    22 	}
       
    23 	else
       
    24 		print "<font color='#CC0000'>$StrSaveFileFail</font>";
       
    25 }
       
    26 else if ($AllowEdit && isset($_GET['filename']))
       
    27 {
       
    28 	$file_name = explode('.',$_GET['filename']);
       
    29 	if ($file_name[1] == 'js')
       
    30 	{
       
    31 		$file_name[1] = 'javascript';
       
    32 	}
       
    33 //	wp_enqueue_script('jquery');
       
    34 //	wp_enqueue_script('codepress');
       
    35 
       
    36 /*	<script type="text/javascript">
       
    37 	var language = '<?php echo $file_name[1]; ?>';
       
    38 	var engine = 'older';
       
    39 	var ua = navigator.userAgent;
       
    40 	var ts = (new Date).getTime(); // timestamp to avoid cache
       
    41 
       
    42 	if(ua.match('MSIE')) engine = 'msie';
       
    43 	else if(ua.match('KHTML')) engine = 'khtml'; 
       
    44 	else if(ua.match('Opera')) engine = 'opera'; 
       
    45 	else if(ua.match('Gecko')) engine = 'gecko';
       
    46 
       
    47 
       
    48 	document.write('<link type="text/css" href="<?php echo bloginfo('url') . "/wp-includes/js/codepress/"  ?>codepress.css?ts='+ts+'" rel="stylesheet" />');
       
    49 	document.write('<link type="text/css" href="<?php echo bloginfo('url') . "/wp-includes/js/codepress/"  ?>languages/'+language+'.css?ts='+ts+'" rel="stylesheet" id="cp-lang-style" />');
       
    50 	document.write('<scr'+'ipt type="text/javascript" src="<?php echo bloginfo('url') . "/wp-includes/js/codepress/"  ?>engines/'+engine+'.js?ts='+ts+'"></scr'+'ipt>');
       
    51 	document.write('<scr'+'ipt type="text/javascript" src="<?php echo bloginfo('url') . "/wp-includes/js/codepress/"  ?>languages/'+language+'.js?ts='+ts+'"></scr'+'ipt>');
       
    52 	</script>
       
    53 
       
    54 
       
    55 	<script type="text/javascript">
       
    56 		codepress_path = "<?php echo includes_url('/js/codepress/'); ?>";
       
    57 		jQuery(document).ready(function($){
       
    58         $('#edit_file').submit(function(){
       
    59           if ($('#text_cp').length)
       
    60           $('#text_cp').val(text.getCode()).removeAttr('disabled');
       
    61           });
       
    62         $('#reset').click(function(){
       
    63           if ($('#text_cp').length)
       
    64           $('#text_cp').val(text.getCode()).removeAttr('disabled');
       
    65 		  $('#edit_file').clearForm();
       
    66           });
       
    67 		});
       
    68 
       
    69 	</script>
       
    70 */
       
    71 	print "<table class='index' width=800 cellpadding=0 cellspacing=0>";
       
    72 	print "<tr>";
       
    73 	print "<td class='iheadline' height=21>";
       
    74 	print "<font class='iheadline'>&nbsp;$StrEditing \"".htmlentities($filename)."\"</font>";
       
    75 	print "</td>";
       
    76 	print "<td class='iheadline' align='right' height=21>";
       
    77 	print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($wp_fileman_path))."'><img src='" . WP_CONTENT_URL . "/plugins/wp-filemanager/icon/back.gif' border=0 alt='$StrBack'></a></font>";
       
    78 	print "</td>";
       
    79 	print "</tr>";
       
    80 	print "<tr>";
       
    81 	print "<td valign='top' colspan=2>";
       
    82 
       
    83 	print "<center><br />";
       
    84 
       
    85 	if ($fp = @fopen($home_directory.$wp_fileman_path.$filename, "rb"))
       
    86 	{
       
    87 		print "<form action='$base_url&amp;output=edit&amp;save=true' method='post' id='edit_file'>";
       
    88 //		print "<form method='post' name='edit_file' id='edit_file'>";
       
    89 		//print "<a class='button' href='javascript:text.toggleEditor();' style='float:right'>Code Editor</a>";
       
    90 		print "\n<textarea cols=120 rows=20 name='text' id='text' class='codepress " . $file_name[1] . "'>";
       
    91 //		print "\n<textarea cols=120 rows=20 name='text' class='codepress " . $file_name[1] . "'>";
       
    92 		if (filesize($home_directory.$wp_fileman_path.$filename) > 0 )
       
    93 		{
       
    94 			print htmlentities(fread($fp, filesize($home_directory.$wp_fileman_path.$filename)));
       
    95 			@fclose ($fp);
       
    96 		}
       
    97 		print "</textarea>";
       
    98 
       
    99 		print "<br /><br />";
       
   100 		print "$StrFilename <input size=40 name='filename' value=\"".htmlentities($filename)."\">";
       
   101 
       
   102 		print "<br /><br />";
       
   103 		print "<input class='bigbutton' id='reset' type='reset' value='$StrRestoreOriginal'>&nbsp;<input class='bigbutton' type='submit' value='$StrSaveAndExit'>";
       
   104 
       
   105 		print "<input type='hidden' name='path' value=\"".htmlentities($wp_fileman_path)."\">";
       
   106 		print "</form>";
       
   107 	}
       
   108 	else
       
   109 		print "<font color='#CC0000'>$StrErrorOpeningFile</font>";
       
   110 
       
   111 	print "<br /><br /></center>";
       
   112 
       
   113 	print "</td>";
       
   114 	print "</tr>";
       
   115 	print "</table>";
       
   116 }
       
   117 else
       
   118 	print "<font color='#CC0000'>$StrAccessDenied</font>";
       
   119 ?>