Edit File by line
/home/barbar84/www/extracte.../filemang...
File: index.php
<?php
[0] Fix | Delete
[1] Fix | Delete
const ACCESS = true;
[2] Fix | Delete
const INDEX = true;
[3] Fix | Delete
[4] Fix | Delete
include_once 'function.php';
[5] Fix | Delete
[6] Fix | Delete
[7] Fix | Delete
[8] Fix | Delete
$title = !IS_INSTALL_ROOT_DIRECTORY ? 'List' : 'File Manager error';
[9] Fix | Delete
$dir = NOT_PERMISSION == false && isset($_GET['dir']) && empty($_GET['dir']) == false ? rawurldecode($_GET['dir']) : $_SERVER['DOCUMENT_ROOT'];
[10] Fix | Delete
$dir = processDirectory($dir);
[11] Fix | Delete
$handler = null;
[12] Fix | Delete
[13] Fix | Delete
include_once 'header.php';
[14] Fix | Delete
[15] Fix | Delete
if (!IS_INSTALL_ROOT_DIRECTORY) {
[16] Fix | Delete
$handler = @scandir($dir);
[17] Fix | Delete
[18] Fix | Delete
if ($handler === false) {
[19] Fix | Delete
$dir = $_SERVER['DOCUMENT_ROOT'];
[20] Fix | Delete
$dir = processDirectory($dir);
[21] Fix | Delete
[22] Fix | Delete
$handler = @scandir($dir);
[23] Fix | Delete
}
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
if (!is_array($handler))
[27] Fix | Delete
$handler = array();
[28] Fix | Delete
[29] Fix | Delete
$dirEncode = rawurlencode($dir);
[30] Fix | Delete
$count = count($handler);
[31] Fix | Delete
$lists = array();
[32] Fix | Delete
[33] Fix | Delete
if (!IS_INSTALL_ROOT_DIRECTORY && $count > 0) {
[34] Fix | Delete
$folders = array();
[35] Fix | Delete
$files = array();
[36] Fix | Delete
[37] Fix | Delete
foreach ($handler as $entry) {
[38] Fix | Delete
if ($entry != '.' && $entry != '..') {
[39] Fix | Delete
if ($entry == DIRECTORY_FILE_MANAGER && IS_ACCESS_PARENT_PATH_FILE_MANAGER) ;
[40] Fix | Delete
/* Is hide directory File Manager */
[41] Fix | Delete
elseif (is_dir($dir . '/' . $entry))
[42] Fix | Delete
$folders[] = $entry;
[43] Fix | Delete
else
[44] Fix | Delete
$files[] = $entry;
[45] Fix | Delete
}
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
if (count($folders) > 0) {
[49] Fix | Delete
asort($folders);
[50] Fix | Delete
[51] Fix | Delete
foreach ($folders as $entry)
[52] Fix | Delete
$lists[] = array('name' => $entry, 'is_directory' => true);
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
if (count($files) > 0) {
[56] Fix | Delete
asort($files);
[57] Fix | Delete
[58] Fix | Delete
foreach ($files as $entry)
[59] Fix | Delete
$lists[] = array('name' => $entry, 'is_directory' => false);
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
$count = count($lists);
[64] Fix | Delete
$html = null;
[65] Fix | Delete
[66] Fix | Delete
if (!IS_INSTALL_ROOT_DIRECTORY && $dir != '/' && strpos($dir, '/') !== false) {
[67] Fix | Delete
$array = explode('/', preg_replace('|^/(.*?)$|', '\1', $dir));
[68] Fix | Delete
$html = null;
[69] Fix | Delete
$item = null;
[70] Fix | Delete
$url = null;
[71] Fix | Delete
[72] Fix | Delete
foreach ($array as $key => $entry) {
[73] Fix | Delete
if ($key === 0) {
[74] Fix | Delete
$seperator = preg_match('|^\/(.*?)$|', $dir) ? '/' : null;
[75] Fix | Delete
$item = $seperator . $entry;
[76] Fix | Delete
} else {
[77] Fix | Delete
$item = '/' . $entry;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
if ($key < count($array) - 1)
[81] Fix | Delete
$html .= '/<a href="index.php?dir=' . rawurlencode($url . $item) . '">';
[82] Fix | Delete
else
[83] Fix | Delete
$html .= '/';
[84] Fix | Delete
[85] Fix | Delete
$url .= $item;
[86] Fix | Delete
$html .= substring($entry, 0, NAME_SUBSTR, NAME_SUBSTR_ELLIPSIS);
[87] Fix | Delete
[88] Fix | Delete
if ($key < count($array) - 1)
[89] Fix | Delete
$html .= '</a>';
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
if (!IS_INSTALL_ROOT_DIRECTORY) {
[94] Fix | Delete
echo '<script language="javascript" src="checkbox.js"></script>';
[95] Fix | Delete
echo '<div class="title">' . $html . '</div>';
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
if (NOT_PERMISSION) {
[99] Fix | Delete
if (IS_INSTALL_ROOT_DIRECTORY) {
[100] Fix | Delete
echo '<div class="title">File Manager error</div>
[101] Fix | Delete
<div class="list">You are Setting File Manager on the original Folder, please move it to a Folder</div>';
[102] Fix | Delete
} elseif (IS_ACCESS_FILE_IN_FILE_MANAGER) {
[103] Fix | Delete
echo '<div class="notice_info">You cannot See File of File Manager it has been blocked</div>';
[104] Fix | Delete
} else {
[105] Fix | Delete
echo '<div class="notice_info">You cannot view the folder of File Manager it has been blocked</div>';
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
if (!IS_INSTALL_ROOT_DIRECTORY) {
[110] Fix | Delete
echo '<form action="action.php?dir=' . $dirEncode . $pages['paramater_1'] . '" method="post" name="form"><ul class="list_file">';
[111] Fix | Delete
[112] Fix | Delete
if (preg_replace('|[a-zA-Z]+:|', '', str_replace('\\', '/', $dir)) != '/') {
[113] Fix | Delete
$path = strrchr($dir, '/');
[114] Fix | Delete
[115] Fix | Delete
if ($path !== false)
[116] Fix | Delete
$path = 'index.php?dir=' . rawurlencode(substr($dir, 0, strlen($dir) - strlen($path)));
[117] Fix | Delete
else
[118] Fix | Delete
$path = 'index.php';
[119] Fix | Delete
[120] Fix | Delete
echo '<li class="normal">
[121] Fix | Delete
<img src="icon/back.png" style="margin-left: 5px; margin-right: 5px"/>
[122] Fix | Delete
<a href="' . $path . '">
[123] Fix | Delete
<strong class="back">...</strong>
[124] Fix | Delete
</a>
[125] Fix | Delete
</li>';
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
if ($count <= 0) {
[129] Fix | Delete
echo '<li class="normal"><img src="icon/empty.png"/> <span class="empty">No Folders or Files</span></li>';
[130] Fix | Delete
} else {
[131] Fix | Delete
$start = 0;
[132] Fix | Delete
$end = $count;
[133] Fix | Delete
[134] Fix | Delete
if (isset($configs['page_list']) && $configs['page_list'] > 0 && $count > $configs['page_list']) {
[135] Fix | Delete
$pages['total'] = ceil($count / $configs['page_list']);
[136] Fix | Delete
[137] Fix | Delete
if ($pages['total'] <= 0 || $pages['current'] > $pages['total'])
[138] Fix | Delete
goURL('index.php?dir=' . $dirEncode . ($pages['total'] <= 0 ? null : '&page_list=' . $pages['total']));
[139] Fix | Delete
[140] Fix | Delete
$start = ($pages['current'] * $configs['page_list']) - $configs['page_list'];
[141] Fix | Delete
$end = $start + $configs['page_list'] >= $count ? $count : $start + $configs['page_list'];
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
for ($i = $start; $i < $end; ++$i) {
[145] Fix | Delete
$name = $lists[$i]['name'];
[146] Fix | Delete
$path = $dir . '/' . $name;
[147] Fix | Delete
$perms = getChmod($path);
[148] Fix | Delete
[149] Fix | Delete
if ($lists[$i]['is_directory']) {
[150] Fix | Delete
echo '<li class="folder">
[151] Fix | Delete
<div>
[152] Fix | Delete
<input type="checkbox" name="entry[]" value="' . $name . '"/>
[153] Fix | Delete
<a href="folder_edit.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">
[154] Fix | Delete
<img src="icon/folder.png"/>
[155] Fix | Delete
</a>
[156] Fix | Delete
<a href="index.php?dir=' . rawurlencode($path) . '">' . $name . '</a>
[157] Fix | Delete
<div class="perms">
[158] Fix | Delete
<a href="folder_chmod.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '" class="chmod">' . $perms . '</a>
[159] Fix | Delete
</div>
[160] Fix | Delete
</div>
[161] Fix | Delete
</li>';
[162] Fix | Delete
} else {
[163] Fix | Delete
$edit = array(null, '</a>');
[164] Fix | Delete
$icon = 'unknown';
[165] Fix | Delete
$type = getFormat($name);
[166] Fix | Delete
$isEdit = false;
[167] Fix | Delete
[168] Fix | Delete
if (in_array($type, $formats['other'])) {
[169] Fix | Delete
$icon = $type;
[170] Fix | Delete
} elseif (in_array($type, $formats['text'])) {
[171] Fix | Delete
$icon = $type;
[172] Fix | Delete
$isEdit = true;
[173] Fix | Delete
} elseif (in_array($type, $formats['archive'])) {
[174] Fix | Delete
$icon = $type;
[175] Fix | Delete
} elseif (in_array($type, $formats['audio'])) {
[176] Fix | Delete
$icon = $type;
[177] Fix | Delete
} elseif (in_array($type, $formats['font'])) {
[178] Fix | Delete
$icon = $type;
[179] Fix | Delete
} elseif (in_array($type, $formats['binary'])) {
[180] Fix | Delete
$icon = $type;
[181] Fix | Delete
} elseif (in_array($type, $formats['document'])) {
[182] Fix | Delete
$icon = $type;
[183] Fix | Delete
} elseif (in_array($type, $formats['image'])) {
[184] Fix | Delete
$icon = 'image';
[185] Fix | Delete
} elseif (in_array(strtolower(strpos($name, '.') !== false ? substr($name, 0, strpos($name, '.')) : $name), $formats['source'])) {
[186] Fix | Delete
$icon = strtolower(strpos($name, '.') !== false ? substr($name, 0, strpos($name, '.')) : $name);
[187] Fix | Delete
$isEdit = true;
[188] Fix | Delete
} elseif (isFormatUnknown($name)) {
[189] Fix | Delete
$icon = 'unknown';
[190] Fix | Delete
$isEdit = true;
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
if (strtolower($name) == 'error_log' || $isEdit)
[194] Fix | Delete
$edit[0] = '<a href="edit_text.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">';
[195] Fix | Delete
elseif (in_array($type, $formats['zip']))
[196] Fix | Delete
$edit[0] = '<a href="file_unzip.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">';
[197] Fix | Delete
else
[198] Fix | Delete
$edit[0] = '<a href="file_rename.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">';
[199] Fix | Delete
[200] Fix | Delete
echo '<li class="file">
[201] Fix | Delete
<p>
[202] Fix | Delete
<input type="checkbox" name="entry[]" value="' . $name . '"/>
[203] Fix | Delete
' . $edit[0] . '<img src="icon/mime/' . $icon . '.png"/>' . $edit[1] . '
[204] Fix | Delete
<a href="file.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">' . $name . '</a>
[205] Fix | Delete
</p>
[206] Fix | Delete
<p>
[207] Fix | Delete
<span class="size">' . size(filesize($dir . '/' . $name)) . '</span>,
[208] Fix | Delete
<a href="file_chmod.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '" class="chmod">' . $perms . '</a>
[209] Fix | Delete
</p>
[210] Fix | Delete
</li>';
[211] Fix | Delete
}
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
echo '<li class="normal"><input type="checkbox" name="all" value="1" onClick="javascript:onCheckItem();"/> <strong class="form_checkbox_all"> Select all</strong></li>';
[215] Fix | Delete
[216] Fix | Delete
if (isset($configs['page_list']) && $configs['page_list'] > 0 && $pages['total'] > 1)
[217] Fix | Delete
echo '<li class="normal">' . page($pages['current'], $pages['total'], array(PAGE_URL_DEFAULT => 'index.php?dir=' . $dirEncode, PAGE_URL_START => 'index.php?dir=' . $dirEncode . '&page_list=')) . '</li>';
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
echo '</ul>';
[221] Fix | Delete
[222] Fix | Delete
if ($count > 0) {
[223] Fix | Delete
echo '<div class="list">
[224] Fix | Delete
<select name="option">
[225] Fix | Delete
<option value="0">Copy</option>
[226] Fix | Delete
<option value="1">Move</option>
[227] Fix | Delete
<option value="2">Delete</option>
[228] Fix | Delete
[229] Fix | Delete
<option value="4">Chmod</option>
[230] Fix | Delete
<option value="5">Rename</option>
[231] Fix | Delete
</select>
[232] Fix | Delete
<input type="submit" name="submit" value="Go"/>
[233] Fix | Delete
</div>';
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
echo '</form>
[237] Fix | Delete
<div class="title">Function</div>
[238] Fix | Delete
<ul class="list">
[239] Fix | Delete
<li><img src="icon/create.png"/> <a href="create.php?dir=' . $dirEncode . $pages['paramater_1'] . '">Create new</a></li>
[240] Fix | Delete
<li><img src="icon/upload.png"/> <a href="upload.php?dir=' . $dirEncode . $pages['paramater_1'] . '">Upload files</a></li>
[241] Fix | Delete
<li><img src="icon/import.png"/> <a href="import.php?dir=' . $dirEncode . $pages['paramater_1'] . '">Import files</a></li>
[242] Fix | Delete
</ul>';
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
include_once 'footer.php';
[246] Fix | Delete
[247] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function