Реформат в PSR-2 + добавление заголовков лицензии MIT в файлы

This commit is contained in:
Yuriy Pikhtarev 2017-01-13 01:20:43 +03:00
commit 3730bed000
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
207 changed files with 44327 additions and 43119 deletions

View file

@ -1,6 +1,31 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
if (!defined('BB_ROOT')) die(basename(__FILE__));
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
define('IN_CRON', true);
@ -31,66 +56,59 @@ DB()->add_shutdown_query("
");
// $cron_jobs obtained in cron_check.php
foreach ($cron_jobs as $job)
{
$job_script = CRON_JOB_DIR . basename($job['cron_script']);
foreach ($cron_jobs as $job) {
$job_script = CRON_JOB_DIR . basename($job['cron_script']);
if (file_exists($job_script))
{
$cron_start_time = utime();
$cron_runtime_log = '';
$cron_write_log = (CRON_LOG_ENABLED && (CRON_FORCE_LOG || $job['log_enabled'] >= 1));
$cron_sql_log_file = CRON_LOG_DIR .'SQL-'. basename($job['cron_script']);
if (file_exists($job_script)) {
$cron_start_time = utime();
$cron_runtime_log = '';
$cron_write_log = (CRON_LOG_ENABLED && (CRON_FORCE_LOG || $job['log_enabled'] >= 1));
$cron_sql_log_file = CRON_LOG_DIR . 'SQL-' . basename($job['cron_script']);
if ($cron_write_log)
{
$msg = array();
$msg[] = 'start';
$msg[] = date('m-d');
$msg[] = date('H:i:s');
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid());
$msg[] = $job['cron_title'];
$msg = join(LOG_SEPR, $msg);
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
}
if ($cron_write_log) {
$msg = array();
$msg[] = 'start';
$msg[] = date('m-d');
$msg[] = date('H:i:s');
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid());
$msg[] = $job['cron_title'];
$msg = join(LOG_SEPR, $msg);
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
}
if ($job['log_sql_queries'])
{
DB()->log_next_query(100000, $cron_sql_log_file);
}
if ($job['log_sql_queries']) {
DB()->log_next_query(100000, $cron_sql_log_file);
}
set_time_limit(600);
require($job_script);
set_time_limit(600);
require($job_script);
if ($job['log_sql_queries'])
{
DB()->log_next_query(0);
bb_log(LOG_LF, $cron_sql_log_file);
}
if ($job['log_sql_queries']) {
DB()->log_next_query(0);
bb_log(LOG_LF, $cron_sql_log_file);
}
if ($cron_write_log)
{
$msg = array();
$msg[] = ' end';
$msg[] = date('m-d');
$msg[] = date('H:i:s');
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid());
$msg[] = round(utime() - $cron_start_time) .'/'. round(utime() - TIMESTART) . ' sec';
$msg = join(LOG_SEPR, $msg);
$msg .= LOG_LF .'------=-------=----------=------=-------=----------';
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
if ($cron_write_log) {
$msg = array();
$msg[] = ' end';
$msg[] = date('m-d');
$msg[] = date('H:i:s');
$msg[] = sprintf('%-4s', round(sys('la'), 1));
$msg[] = sprintf('%05d', getmypid());
$msg[] = round(utime() - $cron_start_time) . '/' . round(utime() - TIMESTART) . ' sec';
$msg = join(LOG_SEPR, $msg);
$msg .= LOG_LF . '------=-------=----------=------=-------=----------';
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
if ($cron_runtime_log)
{
$runtime_log_file = ($job['log_file']) ? $job['log_file'] : $job['cron_script'];
bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . basename($runtime_log_file));
}
}
if ($cron_runtime_log) {
$runtime_log_file = ($job['log_file']) ? $job['log_file'] : $job['cron_script'];
bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . basename($runtime_log_file));
}
}
DB()->query("
UPDATE ". BB_CRON ." SET
DB()->query("
UPDATE " . BB_CRON . " SET
last_run = NOW(),
run_counter = run_counter + 1,
next_run =
@ -114,16 +132,13 @@ foreach ($cron_jobs as $job)
LIMIT 1
");
sleep(1);
sleep(1);
if (utime() - TIMESTART > 600)
{
return; // чтобы daily скрипты не блокировали надолго interval'ные
}
}
else
{
$cron_err_msg = "Can not run \"{$job['cron_title']}\" : file \"$job_script\" not found". LOG_LF;
bb_log($cron_err_msg, 'cron_error');
}
}
if (utime() - TIMESTART > 600) {
return; // чтобы daily скрипты не блокировали надолго interval'ные
}
} else {
$cron_err_msg = "Can not run \"{$job['cron_title']}\" : file \"$job_script\" not found" . LOG_LF;
bb_log($cron_err_msg, 'cron_error');
}
}