Реформат в 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,25 +1,46 @@
<?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.
*/
function run_jobs($jobs)
{
global $bb_cfg, $tr_cfg, $datastore;
global $bb_cfg, $tr_cfg, $datastore;
define('IN_CRON', true);
define('IN_CRON', true);
$sql = "SELECT cron_script FROM " . BB_CRON ." WHERE cron_id IN ($jobs)";
if (!$result = DB()->sql_query($sql))
{
bb_die('Could not obtain cron script');
}
$sql = "SELECT cron_script FROM " . BB_CRON . " WHERE cron_id IN ($jobs)";
if (!$result = DB()->sql_query($sql)) {
bb_die('Could not obtain cron script');
}
while ($row = DB()->sql_fetchrow($result))
{
$job = $row['cron_script'];
$job_script = INC_DIR . 'cron/jobs/' . $job;
require($job_script);
}
DB()->query("
UPDATE ". BB_CRON ." SET
while ($row = DB()->sql_fetchrow($result)) {
$job = $row['cron_script'];
$job_script = INC_DIR . 'cron/jobs/' . $job;
require($job_script);
}
DB()->query("
UPDATE " . BB_CRON . " SET
last_run = NOW(),
run_counter = run_counter + 1,
next_run =
@ -41,102 +62,101 @@ function run_jobs($jobs)
END
WHERE cron_id IN ($jobs)
");
sleep(3);
return;
sleep(3);
return;
}
function delete_jobs($jobs)
{
DB()->query("DELETE FROM " . BB_CRON . " WHERE cron_id IN ($jobs)");
return;
DB()->query("DELETE FROM " . BB_CRON . " WHERE cron_id IN ($jobs)");
return;
}
function toggle_active($jobs, $cron_action)
{
$active = ($cron_action == 'disable') ? 0 : 1;
DB()->query("UPDATE " . BB_CRON . " SET cron_active = $active WHERE cron_id IN ($jobs)");
return;
$active = ($cron_action == 'disable') ? 0 : 1;
DB()->query("UPDATE " . BB_CRON . " SET cron_active = $active WHERE cron_id IN ($jobs)");
return;
}
function validate_cron_post($cron_arr) {
$errors = 'Errors in: ';
$errnum = 0;
if (!$cron_arr['cron_title']){
$errors .= 'cron title (empty value), ';
$errnum++;
}
if (!$cron_arr['cron_script']){
$errors .= 'cron script (empty value), ';
$errnum++;
}
if ($errnum > 0){
$result = $errors . ' total ' . $errnum . ' errors <br/> <a href="javascript:history.back(-1)">Back</a>';
}
else {
$result = 1;
}
return $result;
function validate_cron_post($cron_arr)
{
$errors = 'Errors in: ';
$errnum = 0;
if (!$cron_arr['cron_title']) {
$errors .= 'cron title (empty value), ';
$errnum++;
}
if (!$cron_arr['cron_script']) {
$errors .= 'cron script (empty value), ';
$errnum++;
}
if ($errnum > 0) {
$result = $errors . ' total ' . $errnum . ' errors <br/> <a href="javascript:history.back(-1)">Back</a>';
} else {
$result = 1;
}
return $result;
}
function insert_cron_job($cron_arr)
{
$row = DB()->fetch_row("SELECT cron_title, cron_script FROM ". BB_CRON ." WHERE cron_title = '". $_POST['cron_title'] ."' or cron_script = '". $_POST['cron_script'] ."' ");
$row = DB()->fetch_row("SELECT cron_title, cron_script FROM " . BB_CRON . " WHERE cron_title = '" . $_POST['cron_title'] . "' or cron_script = '" . $_POST['cron_script'] . "' ");
if ($row)
{
global $lang;
if ($row) {
global $lang;
if ($_POST['cron_script'] == $row['cron_script'])
{
$langmode = $lang['SCRIPT_DUPLICATE'];
}
else $langmode = $lang['TITLE_DUPLICATE'];
if ($_POST['cron_script'] == $row['cron_script']) {
$langmode = $lang['SCRIPT_DUPLICATE'];
} else {
$langmode = $lang['TITLE_DUPLICATE'];
}
$message = $langmode . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS_ADDED'], "<a href=\"javascript:history.back(-1)\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS'], "<a href=\"admin_cron.php?mode=list\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], "<a href=\"index.php?pane=right\">", "</a>");
$message = $langmode . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS_ADDED'], "<a href=\"javascript:history.back(-1)\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_JOBS'], "<a href=\"admin_cron.php?mode=list\">", "</a>") . "<br /><br />" . sprintf($lang['CLICK_RETURN_ADMIN_INDEX'], "<a href=\"index.php?pane=right\">", "</a>");
bb_die($message);
}
bb_die($message);
}
$cron_active = $cron_arr['cron_active'];
$cron_title = $cron_arr['cron_title'];
$cron_script = $cron_arr['cron_script'];
$schedule = $cron_arr['schedule'];
$run_day = $cron_arr['run_day'];
$run_time = $cron_arr['run_time'];
$run_order = $cron_arr['run_order'];
$last_run = $cron_arr['last_run'];
$next_run = $cron_arr['next_run'];
$run_interval = $cron_arr['run_interval'];
$log_enabled = $cron_arr['log_enabled'];
$log_file = $cron_arr['log_file'];
$log_sql_queries = $cron_arr['log_sql_queries'];
$disable_board = $cron_arr['disable_board'];
$run_counter = $cron_arr['run_counter'];
$cron_active = $cron_arr['cron_active'];
$cron_title = $cron_arr['cron_title'];
$cron_script = $cron_arr['cron_script'];
$schedule = $cron_arr['schedule'];
$run_day = $cron_arr['run_day'];
$run_time = $cron_arr['run_time'];
$run_order = $cron_arr['run_order'];
$last_run = $cron_arr['last_run'];
$next_run = $cron_arr['next_run'];
$run_interval = $cron_arr['run_interval'];
$log_enabled = $cron_arr['log_enabled'];
$log_file = $cron_arr['log_file'];
$log_sql_queries = $cron_arr['log_sql_queries'];
$disable_board = $cron_arr['disable_board'];
$run_counter = $cron_arr['run_counter'];
DB()->query("INSERT INTO ". BB_CRON ." (cron_active, cron_title, cron_script, schedule, run_day, run_time, run_order, last_run, next_run, run_interval, log_enabled, log_file, log_sql_queries, disable_board, run_counter) VALUES (
DB()->query("INSERT INTO " . BB_CRON . " (cron_active, cron_title, cron_script, schedule, run_day, run_time, run_order, last_run, next_run, run_interval, log_enabled, log_file, log_sql_queries, disable_board, run_counter) VALUES (
$cron_active, '$cron_title', '$cron_script', '$schedule', '$run_day', '$run_time', '$run_order', '$last_run', '$next_run', '$run_interval', $log_enabled, '$log_file', $log_sql_queries, $disable_board, '$run_counter')");
}
function update_cron_job($cron_arr)
{
$cron_id = $cron_arr['cron_id'];
$cron_active = $cron_arr['cron_active'];
$cron_title = DB()->escape($cron_arr['cron_title']);
$cron_script = DB()->escape($cron_arr['cron_script']);
$schedule = $cron_arr['schedule'];
$run_day = $cron_arr['run_day'];
$run_time = $cron_arr['run_time'];
$run_order = $cron_arr['run_order'];
$last_run = $cron_arr['last_run'];
$next_run = $cron_arr['next_run'];
$run_interval = $cron_arr['run_interval'];
$log_enabled = $cron_arr['log_enabled'];
$log_file = DB()->escape($cron_arr['log_file']);
$log_sql_queries = $cron_arr['log_sql_queries'];
$disable_board = $cron_arr['disable_board'];
$run_counter = $cron_arr['run_counter'];
$cron_id = $cron_arr['cron_id'];
$cron_active = $cron_arr['cron_active'];
$cron_title = DB()->escape($cron_arr['cron_title']);
$cron_script = DB()->escape($cron_arr['cron_script']);
$schedule = $cron_arr['schedule'];
$run_day = $cron_arr['run_day'];
$run_time = $cron_arr['run_time'];
$run_order = $cron_arr['run_order'];
$last_run = $cron_arr['last_run'];
$next_run = $cron_arr['next_run'];
$run_interval = $cron_arr['run_interval'];
$log_enabled = $cron_arr['log_enabled'];
$log_file = DB()->escape($cron_arr['log_file']);
$log_sql_queries = $cron_arr['log_sql_queries'];
$disable_board = $cron_arr['disable_board'];
$run_counter = $cron_arr['run_counter'];
DB()->query("UPDATE " . BB_CRON . " SET
DB()->query("UPDATE " . BB_CRON . " SET
cron_active = '$cron_active',
cron_title = '$cron_title',
cron_script = '$cron_script',
@ -154,4 +174,4 @@ function update_cron_job($cron_arr)
run_counter = '$run_counter'
WHERE cron_id = $cron_id
");
}
}