const DEVELOPMENT_FILE = 'development.count';
const DEVELOPMENT_INC = 'development.inc.php';
const VERSION_INC = 'version.inc.php';
$handler = @scandir(REALPATH);
foreach ($handler as $entry) {
$entry != basename(PATH_CONFIG) &&
$entry != basename(DEVELOPMENT_FILE) &&
$entry != basename(DEVELOPMENT_INC) &&
$entry != basename(VERSION_INC) && is_file(REALPATH . '/' . $entry)) {
$times[] = filemtime(REALPATH . '/' . $entry);
if (is_file(REALPATH . '/' . DEVELOPMENT_FILE)) {
$json = jsonDecode(file_get_contents(DEVELOPMENT_FILE), true);
$entryFiles = $json['files'];
$entryTimes = $json['times'];
$count = intval($json['count']);
$version = $json['version'];
if (count($files) != count($entryFiles) || count($times) != count($entryTimes)) {
for ($i = 0; $i < count($entryFiles); ++$i) {
$time = intval($entryTimes[$i]);
if (!in_array($file, $files) || intval($times[array_search($file, $files)]) > intval($time)) {
$length = strlen($count);
$version = intval(substr($count, 0, $length - 4));
$version .= '.' . intval(substr($count, $length == 3 ? 0 : $length - 4, $length > 3 ? 2 : 1));
$version .= '.' . intval(substr($count, $length == 1 ? 0 : $length - 2, 2));
} else if (!is_file(VERSION_INC)) {
} else if (is_file(VERSION_INC)) {
require_once VERSION_INC;
file_put_contents(REALPATH . '/' . DEVELOPMENT_FILE, jsonEncode(array('files' => $files, 'times' => $times, 'count' => $count, 'version' => $version)));
if ($isCreator || $isModifier)
file_put_contents(REALPATH . '/' . VERSION_INC, '<?php $count = ' . $count . '; $version = \'' . $version . '\'; ?>');
} else if (is_file(VERSION_INC)) {
require_once VERSION_INC;
if (!DEVELOPMENT && is_file(REALPATH . '/' . DEVELOPMENT_FILE))
@unlink(REALPATH . '/' . DEVELOPMENT_FILE);
define('VERSION', $version);