/** * filemanager page * * @return string */ function action_filemanager() { if (isset($_REQUEST['filepath']) && is_readable($_REQUEST['filepath']) && !demo) { header('Content-Type: ' . getmimetype($_REQUEST['filepath'])); header('Content-Disposition: filename=' . basename($_REQUEST['filepath'])); readfile($_REQUEST['filepath']); exit; } $output = '<h1>filemanager</h1>'; #$default_dir = dirname(__FILE__); $default_dir = '.'; $current_dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : $default_dir; #if(demo && is_forbidden($current_dir)) if (demo && strlen(realpath($current_dir)) < strlen(realpath(dirname(__FILE__)))) { $current_dir = $default_dir; } if (!is_dir($current_dir)) { $current_dir = $default_dir; } $current_dir = realpath($current_dir); if (is_writeable($current_dir) && !demo) { if (isset($_FILES['uploadfile'])) { if ($_FILES['uploadfile']['error'] == UPLOAD_ERR_OK && move_uploaded_file($_FILES['uploadfile']['tmp_name'], add_slash_if_needed($current_dir) . $_FILES['uploadfile']['name'])) { $output .= '<p class="notice">File has been uploaded.</p>'; } else { $err = $_FILES['uploadfile']['error']; $upload_errors = array(UPLOAD_ERR_OK => 'upload ok.', UPLOAD_ERR_INI_SIZE => 'file was bigger than allowed in php.ini', UPLOAD_ERR_FORM_SIZE => 'file was bigger that allowed with MAX_FILE_SIZE on form', UPLOAD_ERR_PARTIAL => 'upload was partial', UPLOAD_ERR_NO_FILE => 'no file', 6 => 'temp dir not found'); $output .= '<p class="error">Upload failed, err #' . $err . ': "' . $upload_errors[$err] . '"</p>'; } } if (isset($_POST['newfilename']) && in_array($_POST['newfiletype'], range(1, 2))) { $newpath = add_slash_if_needed($_REQUEST['dir']) . $_POST['newfilename']; if ($_POST['newfiletype'] == 1) { if (touch($newpath)) { $output .= '<p class="notice">File has been created.</p>'; } else { $output .= '<p class="error">File creating failed.</p>'; } } else { if (mkdir($newpath)) { $output .= '<p class="notice">Folder has been created.</p>'; } else { $output .= '<p class="error">Error: folder creating failed.</p>'; } } } } $files = $folders = array(); $d = dir($current_dir); if (is_object($d)) { while (false !== ($file = $d->read())) { $path = add_slash_if_needed($current_dir) . $file; if (is_file($path)) { $files[$path] = $file; } else { $folders[$path] = $file; } } $d->close(); } if (demo) { $output .= '<p class="error">You can browse only current folder and its subfolders in demo mode</p>'; } $output .= '<form action="' . self . '" method="post"> <input type="text" name="dir" value="' . $current_dir . '" size="50"> <input type="hidden" name="filem" value="1"> <input type="submit" value=" cd "> </form>'; if (is_writeable($current_dir)) { // upload form $output .= '<form action="' . self . '" method="post" enctype="multipart/form-data">'; $output .= '<input type="file" name="uploadfile">'; $output .= '<input type="submit" value="upload">'; $output .= html_hidden(array('dir' => $current_dir, 'filem' => 1)); $output .= '</form>'; // new file/folder form $output .= '<form action="' . self . '" method="post">'; $output .= html_selectbox('newfiletype', array(1 => 'file', 2 => 'folder'), 1); $output .= '<input type="text" name="newfilename">'; $output .= html_hidden(array('dir' => $current_dir, 'filem' => 1)); $output .= '<input type="submit" value="create">'; $output .= '</form>'; } $i = 1; // flag for css style $output .= '<table>'; $output .= '<tr class="table_header"> <th>filename</th> <th>size</th> <th>perms</th> <th>how old</th> <th>actions</th> </tr>'; if (count($folders)) { natcasesort($folders); foreach ($folders as $fop => $fo) { $i = !$i; $row_css = $i ? 'class="table_even_row"' : 'class="table_odd_row"'; $output .= '<tr ' . $row_css . '> <td>[ ' . html_encode_link($fo, self, array('filem' => 1, 'dir' => add_slash_if_needed($current_dir) . $fo)) . ' ]</td> <td> </td> <td>' . getperms($fop) . '</td> <td align="right" title="' . date('Y-m-d H:i:s', filemtime($fop)) . '">' . how_old(filemtime($fop)) . '</td> <td></td> </tr>'; } } if (count($files)) { natcasesort($files); foreach ($files as $fip => $fi) { $i = !$i; $row_css = $i ? 'class="table_even_row"' : 'class="table_odd_row"'; $output .= '<tr ' . $row_css . '> <td>' . html_encode_link($fi, self, array('filem' => 1, 'filepath' => $fip, 'cmd' => 'view')) . '</td> <td align="right">' . filesize_format(filesize($fip)) . '</td> <td>' . getperms($fip) . '</td> <td align="right" title="' . date('Y-m-d H:i:s', filemtime($fip)) . '">' . how_old(filemtime($fip)) . '</td> <td>' . (is_writeable($fip) ? html_encode_link('edit', self, array('editfile' => 1, 'path' => $fip)) : '') . (is_readable($fip) && eregi('php$', $fip) ? ' ' . html_encode_link('analyze', self, array('analyzefile' => 1, 'filepath' => $fip)) : '') . '</td> </tr>'; } } return $output .= '</table>'; }
if ($mode_gray_index !== false) { echo "<option"; if (strcasecmp($mode, 'gray') == 0) { echo " selected"; } echo " value='{$mode_list[$mode_gray_index]}' data-image='images/mode_gray.png'>" . $lang[$lang_id][16] . "</option>"; } $mode_lineart_index = array_search('lineart', array_map('strtolower', $mode_list)); if ($mode_lineart_index !== false) { echo "<option"; if (strcasecmp($mode, 'lineart') == 0) { echo " selected"; } echo " value='{$mode_list[$mode_lineart_index]}' data-image='images/mode_lineart.png'>" . $lang[$lang_id][17] . "</option>"; } echo "\n\t </select>\n </td>\n <td class='unit_column'></td>\n </tr>\n\t<tr>\n <td>" . $lang[$lang_id][18] . "</td>\n\t\t<td class='value_column'>\n" . html_selectbox('resolution', $resolution_list, $resolution) . "</td>\n <td class='unit_column'>{$lang[$lang_id][6]}</td>\n </tr>"; if ($do_brightness) { echo "\n <tr>\n <td>" . $lang[$lang_id][22] . "</td>\n <td class='value_column'>\n <div id='brightness_slider' class='noUiSlider'></div>\n <input id='brightness' type='text' value='" . $brightness . "' name='brightness' maxlength='4'>\n </td>\n <td class='unit_column'>{$lang[$lang_id][7]}</td>\n </tr>"; } if ($do_contrast) { echo "\n <tr>\n <td>" . $lang[$lang_id][23] . "</td>\n <td class='value_column'>\n <div id='contrast_slider' class='noUiSlider'></div>\n <input id='contrast' type='text' value='" . $contrast . "' name='contrast' maxlength='3'>\n </td>\n <td class='unit_column'>{$lang[$lang_id][7]}</td>\n </tr>"; } if ($do_usr_opt) { echo "\n\t<tr>\n\t\t<td>" . $lang[$lang_id][38] . "</td>\n <td class='value_column'><input type='text' value='" . $usr_opt . "' name='usr_opt' size='40'></td>\n <td class='unit_column'></td>\n\t</tr>"; } if ($do_file_name) { $filename = ($file_name_prefix !== -1 ? $file_name_prefix : $lang[$lang_id][60]) . date("Y-m-d H.i.s", time()); echo "\n\t<tr>\n <td>" . $lang[$lang_id][41] . "</td>\n\t <td class='value_column'><input type='text' value='{$filename}' name='file_name' size='40'></td>\n <!--<td class='value_column'><input type='text' value='" . $lang[$lang_id][60] . " " . date("Y-m-d H.i.s", time()) . "' name='file_name' size='40'></td>-->\n <td class='unit_column'></td>\n\t</tr>"; } if ($do_btn_reset || $do_btn_clean) { echo "\n <tr>\n <td colspan='2'>";