Edit File by line
/home/barbar84/www/extracte.../filemang...
File: edit_text_line.php
<?php
[0] Fix | Delete
[1] Fix | Delete
[2] Fix | Delete
[3] Fix | Delete
define('ACCESS', true);
[4] Fix | Delete
[5] Fix | Delete
include_once 'function.php';
[6] Fix | Delete
[7] Fix | Delete
[8] Fix | Delete
$title = 'Edit File by line';
[9] Fix | Delete
$page = array('current' => 0, 'total' => 1, 'paramater_0' => null, 'paramater_1' => null);
[10] Fix | Delete
$page['current'] = isset($_GET['page']) ? intval($_GET['page']) : 1;
[11] Fix | Delete
$page['current'] = $page['current'] <= 0 ? 1 : $page['current'];
[12] Fix | Delete
[13] Fix | Delete
include_once 'header.php';
[14] Fix | Delete
[15] Fix | Delete
echo '<div class="title">' . $title . '</div>';
[16] Fix | Delete
[17] Fix | Delete
if ($dir == null || $name == null || !is_file(processDirectory($dir . '/' . $name))) {
[18] Fix | Delete
echo '<div class="list"><span>The path does not exist</span></div>
[19] Fix | Delete
<div class="title">Function</div>
[20] Fix | Delete
<ul class="list">
[21] Fix | Delete
<li><img src="icon/list.png"/> <a href="index.php' . $pages['paramater_0'] . '">List</a></li>
[22] Fix | Delete
</ul>';
[23] Fix | Delete
} else if (!isFormatText($name) && !isFormatUnknown($name)) {
[24] Fix | Delete
echo '<div class="list"><span>This file is not in text format</span></div>
[25] Fix | Delete
<div class="title">Function</div>
[26] Fix | Delete
<ul class="list">
[27] Fix | Delete
<li><img src="icon/list.png"/> <a href="index.php?dir=' . $dirEncode . $pages['paramater_1'] . '">List</a></li>
[28] Fix | Delete
</ul>';
[29] Fix | Delete
} else {
[30] Fix | Delete
if ($page['current'] > 1 && $configs['page_file_edit_line'] > 0) {
[31] Fix | Delete
$page['paramater_0'] = '?page=' . $page['current'];
[32] Fix | Delete
$page['paramater_1'] = '&page=' . $page['current'];
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
$path = $dir . '/' . $name;
[36] Fix | Delete
$content = file_get_contents($path);
[37] Fix | Delete
$lines = array();
[38] Fix | Delete
$count = 0;
[39] Fix | Delete
$start = 0;
[40] Fix | Delete
$end = 0;
[41] Fix | Delete
[42] Fix | Delete
if (strlen($content) > 0) {
[43] Fix | Delete
$content = str_replace("\r\n", "\n", $content);
[44] Fix | Delete
$content = str_replace("\r", "\n", $content);
[45] Fix | Delete
[46] Fix | Delete
if (strpos($content, "\n") !== false) {
[47] Fix | Delete
$lines = explode("\n", $content);
[48] Fix | Delete
$count = count($lines);
[49] Fix | Delete
$configs = array('page_file_edit_line' => 500);
[50] Fix | Delete
if ($configs['page_file_edit_line'] > 0)
[51] Fix | Delete
$page['total'] = ceil($count / $configs['page_file_edit_line']);
[52] Fix | Delete
} else {
[53] Fix | Delete
$lines[] = $content;
[54] Fix | Delete
$count = 1;
[55] Fix | Delete
}
[56] Fix | Delete
} else {
[57] Fix | Delete
$lines[] = $content;
[58] Fix | Delete
$count = 1;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
if ($configs['page_file_edit_line'] > 0) {
[62] Fix | Delete
$start = ($page['current'] * $configs['page_file_edit_line']) - $configs['page_file_edit_line'];
[63] Fix | Delete
$end = $start + $configs['page_file_edit_line'] > $count - 1 ? $count : $start + $configs['page_file_edit_line'];
[64] Fix | Delete
} else {
[65] Fix | Delete
$start = 0;
[66] Fix | Delete
$end = $count;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
if ($page['current'] < 0 && $configs['page_file_edit_line'] > 0)
[70] Fix | Delete
goURL('edit_text_line.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1']);
[71] Fix | Delete
[72] Fix | Delete
if ($page['current'] > $page['total'] && $configs['page_file_edit_line'] > 0)
[73] Fix | Delete
goURL('edit_text_line.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . ($page['total'] > 1 ? '&page=' . $page['total'] : null));
[74] Fix | Delete
[75] Fix | Delete
echo '<div class="list">
[76] Fix | Delete
<span class="bull">&bull; </span><span>' . printPath($dir, true) . '</span><hr/>
[77] Fix | Delete
<div class="ellipsis break-word">
[78] Fix | Delete
<span class="bull">&bull; </span>File: <strong class="file_name_edit">' . $name . '</strong>
[79] Fix | Delete
</div>
[80] Fix | Delete
</div>
[81] Fix | Delete
<div class="list_line">';
[82] Fix | Delete
[83] Fix | Delete
for ($i = $start; $i < $end; ++$i) {
[84] Fix | Delete
echo '<div id="line">
[85] Fix | Delete
<div id="line_number_' . $i . '">' . htmlspecialchars($lines[$i]) . '</div>
[86] Fix | Delete
<div>
[87] Fix | Delete
<span id="line_number">[<span>' . $i . '</span>]</span>
[88] Fix | Delete
<a href="edit_line.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '&line=' . $i . $page['paramater_1'] . '">Fix</a>
[89] Fix | Delete
<span> | </span>
[90] Fix | Delete
<a href="delete_line.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '&line=' . $i . $page['paramater_1'] . '">Delete</a>
[91] Fix | Delete
</div>
[92] Fix | Delete
</div>';
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
if ($page['total'] > 1 && $configs['page_file_edit_line'] > 0)
[96] Fix | Delete
echo page($page['current'], $page['total'], array(PAGE_URL_DEFAULT => 'edit_text_line.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'], PAGE_URL_START => 'edit_text_line.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '&page='));
[97] Fix | Delete
[98] Fix | Delete
echo '</div>
[99] Fix | Delete
<div class="tips">
[100] Fix | Delete
<img src="icon/tips.png"/>
[101] Fix | Delete
<span>It is recommended that you Edit text format, this type of Fix handles quite a lot in one request</span>
[102] Fix | Delete
</div>
[103] Fix | Delete
<div class="title">Function</div>
[104] Fix | Delete
<ul class="list">
[105] Fix | Delete
<li><img src="icon/edit.png"/> <a href="edit_text.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Edit text</a></li>
[106] Fix | Delete
<li><img src="icon/download.png"/> <a href="file_download.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Download</a></li>
[107] Fix | Delete
<li><img src="icon/info.png"/> <a href="file.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Information</a></li>
[108] Fix | Delete
<li><img src="icon/rename.png"/> <a href="file_rename.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Rename</a></li>
[109] Fix | Delete
<li><img src="icon/copy.png"/> <a href="file_copy.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Copy</a></li>
[110] Fix | Delete
<li><img src="icon/Copy.png"/> <a href="file_Copy.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Move</a></li>
[111] Fix | Delete
<li><img src="icon/delete.png"/> <a href="file_delete.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Delete</a></li>
[112] Fix | Delete
<li><img src="icon/access.png"/> <a href="file_chmod.php?dir=' . $dirEncode . '&name=' . $name . $pages['paramater_1'] . '">Chmod</a></li>
[113] Fix | Delete
<li><img src="icon/list.png"/> <a href="index.php?dir=' . $dirEncode . $pages['paramater_1'] . '">List</a></li>
[114] Fix | Delete
</ul>';
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
include_once 'footer.php';
[118] Fix | Delete
[119] Fix | Delete
[120] Fix | Delete
?>
[121] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function