Exemplo n.º 1
0
function Edit_Page()
{
    //*******************************************************
    global $_, $filename, $filecontents, $raw_contents, $etypes, $itypes, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE, $WYSIWYG_VALID;
    clearstatcache();
    //Determine if a text editable file type
    $filename_parts = explode(".", strtolower($filename));
    $ext = end($filename_parts);
    if (in_array($ext, $etypes)) {
        $text_editable = TRUE;
    } else {
        $text_editable = FALSE;
    }
    $too_large_to_edit = filesize($filename) > $MAX_EDIT_SIZE;
    $too_large_to_view = filesize($filename) > $MAX_VIEW_SIZE;
    //Don't load $WYSIWYG_PLUGIN if not needed
    if (!$text_editable || $too_large_to_edit) {
        $WYSIWYG_VALID = 0;
    }
    if ($text_editable && !$too_large_to_view) {
        $raw_contents = file_get_contents($filename);
        $file_ENC = mb_detect_encoding($raw_contents);
        //ASCII, UTF-8, etc...
    } else {
        $file_ENC = "";
        $raw_contents = "";
    }
    if ($too_large_to_edit) {
        $header2 = hsc($_['edit_h2_1']);
    } else {
        $header2 = hsc($_['edit_h2_2']);
    }
    $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>';
    //.hsc($_['too_large_to_view_04']);
    //Preserves vertical spacing when message is closed, so edit area doesn't jump as much.
    echo '<style>#message_box { min-height: 1.88em; }</style>';
    echo '<h2 id="edit_header">' . $header2 . ' ';
    echo '<a class="h2_filename" href="/' . URLencode_path($filename) . '" target="_blank" title="' . $_['Open_View'] . '">';
    echo hte(basename($filename)) . '</a>';
    echo '</h2>' . PHP_EOL;
    Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_edit_message, $file_ENC);
    if (in_array($ext, $itypes)) {
        show_image();
    }
    echo '<div class=clear></div>';
    if ($text_editable && $too_large_to_view) {
        echo '<p class="edit_disabled">' . $too_large_to_view_message . '</p>';
    } elseif ($text_editable && $too_large_to_edit) {
        $filecontents = hsc(file_get_contents($filename), ENT_COMPAT, 'UTF-8');
        echo '<pre class="edit_disabled view_file">' . $filecontents . '</pre>';
    }
}
Exemplo n.º 2
0
function Edit_Page()
{
    //********************************************************
    global $_, $filename, $filename_OS, $FILECONTENTS, $etypes, $itypes, $EX, $message, $page, $MAX_EDIT_SIZE, $MAX_VIEW_SIZE, $WYSIWYG_VALID, $IS_OFCMS;
    $filename_parts = explode(".", mb_strtolower($filename));
    $ext = end($filename_parts);
    //Determine if a text editable file type
    if (in_array($ext, $etypes)) {
        $text_editable = TRUE;
    } else {
        $text_editable = FALSE;
    }
    $too_large_to_edit = filesize($filename_OS) > $MAX_EDIT_SIZE;
    $too_large_to_view = filesize($filename_OS) > $MAX_VIEW_SIZE;
    //Don't load $WYSIWYG_PLUGIN if not needed
    if (!$text_editable || $too_large_to_edit) {
        $WYSIWYG_VALID = 0;
    }
    //Get file contents
    if ($text_editable && !$too_large_to_view || $IS_OFCMS) {
        $raw_contents = file_get_contents($filename_OS);
        $file_ENC = mb_detect_encoding($raw_contents);
        //ASCII, UTF-8, ISO-8859-1, etc...
        if ($file_ENC != 'UTF-8') {
            $raw_contents = mb_convert_encoding($raw_contents, 'UTF-8', $file_ENC);
        }
    } else {
        $file_ENC = "";
        $raw_contents = "";
    }
    if (PHP_VERSION_ID < 50400) {
        $FILECONTENTS = hsc($raw_contents);
    } else {
        $FILECONTENTS = htmlspecialchars($raw_contents, ENT_SUBSTITUTE | ENT_QUOTES, 'UTF-8');
    }
    if ($too_large_to_view || !$text_editable) {
        $header2 = "";
    } elseif ($text_editable && !$too_large_to_edit && !$IS_OFCMS) {
        $header2 = hsc($_['edit_h2_2']);
    } else {
        $header2 = hsc($_['edit_h2_1']);
    }
    echo '<h2 id="edit_header">' . $header2 . ' ';
    echo '<a class="h2_filename" href="/' . URLencode_path($filename) . '" target="_blank" title="' . hsc($_['Open_View']) . '">';
    echo hsc(basename($filename)) . '</a>';
    echo '</h2>' . "\n";
    Edit_Page_form($ext, $text_editable, $too_large_to_edit, $too_large_to_view, $file_ENC);
    if (in_array($ext, $itypes)) {
        show_image();
    }
    //If image, show below the [Rename/Move] [Copy] [Delete] buttons
    echo '<div class=clear></div>';
    //If viewing OneFileCMS itself, show Edit Disabled message.
    if ($IS_OFCMS && $page == "edit") {
        $message .= '<style>.message_box_contents {background: red;}</style>';
        $message .= '<style>#message_box          {color: white;}   </style>';
        $message .= '<b>' . $EX . hsc($_['edit_caution_02']) . ' &nbsp; ' . $_['edit_txt_00'] . '</b><br>';
    }
}