Example #1
0
function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message, $file_ENC)
{
    global $_, $ONESCRIPT, $param1, $param2, $param3, $filename, $itypes, $INPUT_NUONCE, $EX, $raw_contents, $WYSIWYG_VALID, $EDIT_MODE;
    $load_Edit_Page_scripts = false;
    //Don't load if not needed.
    ?>
	<form id="edit_form" name="edit_form" method="post" action="<?php 
    echo $ONESCRIPT . $param1 . $param2 . $param3;
    ?>
">
<?php 
    echo $INPUT_NUONCE;
    Edit_Page_buttons_top($text_editable, $file_ENC);
    if (!in_array(strtolower($ext), $itypes)) {
        //If non-image...
        if (!$text_editable) {
            // If non-text file...
            echo '<p class="edit_disabled">' . hsc($_['edit_txt_01']) . '<br><br></p>';
        } elseif ($too_large_to_edit) {
            echo '<p class="edit_disabled">' . $too_large_to_edit_message . '</p>';
        } else {
            //Load Edit_Page_scripts() only if not in wysiwyg mode and an editable file.
            //They don't work when a wysiwyg editor is loaded. (loaded after </form>)
            $load_Edit_Page_scripts = !$WYSIWYG_VALID || !$EDIT_MODE;
            if (PHP_VERSION_ID < 50400) {
                // 5.4.0
                $filecontents = hsc($raw_contents);
            } else {
                $filecontents = htmlspecialchars($raw_contents, ENT_SUBSTITUTE | ENT_QUOTES, 'UTF-8');
            }
            //Did htmlspecialchars return an empty string from a non-empty file?
            $bad_chars = $filecontents == "" && filesize($filename) > 0;
            if ($bad_chars) {
                echo '<pre class="edit_disabled">' . $EX . hsc($_['edit_txt_02']) . '<br>';
                echo hsc($_['edit_txt_03']) . '<br>';
                echo hsc($_['edit_txt_04']) . '<br></pre>';
            } else {
                echo '<input type="hidden" name="filename" value="' . hsc($filename) . '">';
                echo '<textarea id="file_editor" name="contents" cols="70" rows="25" ';
                echo 'onkeyup="Check_for_changes(event);">' . $filecontents . '</textarea>' . PHP_EOL;
            }
        }
        //end if/else non-text file...
    }
    //end if non-image
    Edit_Page_buttons($text_editable, $too_large_to_edit);
    echo '</form>';
    if ($load_Edit_Page_scripts) {
        Edit_Page_scripts();
    }
    if ($text_editable && !$too_large_to_edit && !$bad_chars) {
        Edit_Page_Notes();
    }
}
Example #2
0
function Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_view, $file_ENC)
{
    global $_, $ONESCRIPT, $param1, $param2, $param3, $filename, $filename_OS, $itypes, $INPUT_NUONCE, $EX, $message, $FILECONTENTS, $WYSIWYG_VALID, $EDIT_WYSIWYG, $IS_OFCMS, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE;
    $too_large_to_edit_message = '<b>' . hsc($_['too_large_to_edit_01']) . ' ' . number_format($MAX_EDIT_SIZE) . ' ' . hsc($_['bytes']) . '</b><br>' . hsc($_['too_large_to_edit_02']) . '<br>' . hsc($_['too_large_to_edit_03']) . '<br>' . hsc($_['too_large_to_edit_04']);
    $too_large_to_view_message = '<b>' . hsc($_['too_large_to_view_01']) . ' ' . number_format($MAX_VIEW_SIZE) . ' ' . hsc($_['bytes']) . '</b><br>' . hsc($_['too_large_to_view_02']) . '<br>' . hsc($_['too_large_to_view_03']) . '<br>';
    echo '<form id="edit_form" name="edit_form" method="post" action="' . $ONESCRIPT . $param1 . $param2 . $param3 . '">';
    echo $INPUT_NUONCE;
    Edit_Page_buttons_top($text_editable, $file_ENC);
    if (!in_array(mb_strtolower($ext), $itypes)) {
        //If non-image...
        if (!$text_editable) {
            $message .= hsc($_['edit_txt_01']) . '<br><br>';
        } elseif ($too_large_to_edit) {
            $message .= $too_large_to_edit_message;
        } elseif (!$IS_OFCMS) {
            //Did htmlspecialchars return an empty string from a non-empty file?
            $bad_chars = $FILECONTENTS == "" && filesize($filename_OS) > 0;
            if ($bad_chars) {
                //Show message: may be a bad character in file
                echo '<pre class="edit_disabled">' . $EX . hsc($_['edit_txt_02']) . '<br>';
                echo hsc($_['edit_txt_03']) . '<br>';
                echo hsc($_['edit_txt_04']) . '<br></pre>' . "\n";
            } else {
                //show editable <textarea>
                //<input name=filename> is used only to signal an Edit_response().
                echo '<input type="hidden" name="filename" value="' . rawurlencode($filename) . '">';
                echo '<textarea id=file_editor name=contents cols=70 rows=25>';
                echo $FILECONTENTS . '</textarea>' . "\n";
            }
        }
        //end if/elseif...
        if ($text_editable && $too_large_to_view) {
            echo '<p class="message_box_contents">' . $too_large_to_view_message . '</p>';
        } elseif ($IS_OFCMS || $too_large_to_edit) {
            echo '<pre class="edit_disabled view_file">' . $FILECONTENTS . '</pre>' . "\n";
        }
    }
    //end if non-image
    Edit_Page_buttons($text_editable, $too_large_to_edit);
    echo '</form>';
    Edit_Page_scripts();
    if (!$IS_OFCMS && $text_editable && !$too_large_to_edit && !$bad_chars) {
        Edit_Page_Notes();
    }
}