Edit File by line
/home/barbar84/www/extracte.../filemang...
File: development.inc.php
<?php
[0] Fix | Delete
[1] Fix | Delete
[2] Fix | Delete
[3] Fix | Delete
[4] Fix | Delete
const DEVELOPMENT_FILE = 'development.count';
[5] Fix | Delete
const DEVELOPMENT_INC = 'development.inc.php';
[6] Fix | Delete
const VERSION_INC = 'version.inc.php';
[7] Fix | Delete
[8] Fix | Delete
$files = array();
[9] Fix | Delete
$times = array();
[10] Fix | Delete
$count = 1;
[11] Fix | Delete
$version = '0.0.1';
[12] Fix | Delete
$isCreator = true;
[13] Fix | Delete
$isModifier = false;
[14] Fix | Delete
[15] Fix | Delete
if (DEVELOPMENT) {
[16] Fix | Delete
$handler = @scandir(REALPATH);
[17] Fix | Delete
[18] Fix | Delete
foreach ($handler as $entry) {
[19] Fix | Delete
if ($entry != '.' &&
[20] Fix | Delete
$entry != '..' &&
[21] Fix | Delete
$entry != basename(PATH_CONFIG) &&
[22] Fix | Delete
$entry != basename(DEVELOPMENT_FILE) &&
[23] Fix | Delete
$entry != basename(DEVELOPMENT_INC) &&
[24] Fix | Delete
$entry != basename(VERSION_INC) && is_file(REALPATH . '/' . $entry)) {
[25] Fix | Delete
$files[] = $entry;
[26] Fix | Delete
$times[] = filemtime(REALPATH . '/' . $entry);
[27] Fix | Delete
}
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
unset($handler);
[31] Fix | Delete
[32] Fix | Delete
if (is_file(REALPATH . '/' . DEVELOPMENT_FILE)) {
[33] Fix | Delete
$json = jsonDecode(file_get_contents(DEVELOPMENT_FILE), true);
[34] Fix | Delete
[35] Fix | Delete
if ($json !== null) {
[36] Fix | Delete
$entryFiles = $json['files'];
[37] Fix | Delete
$entryTimes = $json['times'];
[38] Fix | Delete
$count = intval($json['count']);
[39] Fix | Delete
$version = $json['version'];
[40] Fix | Delete
$isCreator = false;
[41] Fix | Delete
[42] Fix | Delete
if (count($files) != count($entryFiles) || count($times) != count($entryTimes)) {
[43] Fix | Delete
$isModifier = true;
[44] Fix | Delete
} else {
[45] Fix | Delete
for ($i = 0; $i < count($entryFiles); ++$i) {
[46] Fix | Delete
$file = $entryFiles[$i];
[47] Fix | Delete
$time = intval($entryTimes[$i]);
[48] Fix | Delete
[49] Fix | Delete
if (!in_array($file, $files) || intval($times[array_search($file, $files)]) > intval($time)) {
[50] Fix | Delete
$isModifier = true;
[51] Fix | Delete
break;
[52] Fix | Delete
}
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
if ($isModifier) {
[57] Fix | Delete
$count += 1;
[58] Fix | Delete
$length = strlen($count);
[59] Fix | Delete
$version = null;
[60] Fix | Delete
$isCreator = true;
[61] Fix | Delete
[62] Fix | Delete
if ($length > 4)
[63] Fix | Delete
$version = intval(substr($count, 0, $length - 4));
[64] Fix | Delete
else
[65] Fix | Delete
$version = 0;
[66] Fix | Delete
[67] Fix | Delete
if ($length > 2)
[68] Fix | Delete
$version .= '.' . intval(substr($count, $length == 3 ? 0 : $length - 4, $length > 3 ? 2 : 1));
[69] Fix | Delete
else
[70] Fix | Delete
$version .= '.' . 0;
[71] Fix | Delete
[72] Fix | Delete
$version .= '.' . intval(substr($count, $length == 1 ? 0 : $length - 2, 2));
[73] Fix | Delete
} else if (!is_file(VERSION_INC)) {
[74] Fix | Delete
$isModifier = true;
[75] Fix | Delete
}
[76] Fix | Delete
}
[77] Fix | Delete
} else if (is_file(VERSION_INC)) {
[78] Fix | Delete
require_once VERSION_INC;
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
if ($isCreator)
[82] Fix | Delete
file_put_contents(REALPATH . '/' . DEVELOPMENT_FILE, jsonEncode(array('files' => $files, 'times' => $times, 'count' => $count, 'version' => $version)));
[83] Fix | Delete
[84] Fix | Delete
if ($isCreator || $isModifier)
[85] Fix | Delete
file_put_contents(REALPATH . '/' . VERSION_INC, '<?php $count = ' . $count . '; $version = \'' . $version . '\'; ?>');
[86] Fix | Delete
} else if (is_file(VERSION_INC)) {
[87] Fix | Delete
require_once VERSION_INC;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
if (!DEVELOPMENT && is_file(REALPATH . '/' . DEVELOPMENT_FILE))
[91] Fix | Delete
@unlink(REALPATH . '/' . DEVELOPMENT_FILE);
[92] Fix | Delete
[93] Fix | Delete
const AUTHOR = 'Izero';
[94] Fix | Delete
define('VERSION', $version);
[95] Fix | Delete
[96] Fix | Delete
unset($files);
[97] Fix | Delete
unset($times);
[98] Fix | Delete
unset($count);
[99] Fix | Delete
unset($version);
[100] Fix | Delete
[101] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function