Реформат в 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,68 +1,84 @@
<?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__));
function get_sql_log ()
{
global $DBS, $CACHES, $sphinx, $datastore;
$log = '';
foreach ($DBS->srv as $srv_name => $db_obj)
{
$log .= !empty($db_obj) ? get_sql_log_html($db_obj, "$srv_name [MySQL]") : '';
}
foreach ($CACHES->obj as $cache_name => $cache_obj)
{
if (!empty($cache_obj->db))
{
$log .= get_sql_log_html($cache_obj->db, "cache: $cache_name [{$cache_obj->db->engine}]");
}
elseif (!empty($cache_obj->engine))
{
$log .= get_sql_log_html($cache_obj, "cache: $cache_name [{$cache_obj->engine}]");
}
}
$log .= !empty($sphinx) ? get_sql_log_html($sphinx, '$sphinx') : '';
if (!empty($datastore->db->dbg))
{
$log .= get_sql_log_html($datastore->db, 'cache: datastore ['.$datastore->engine.']');
}
else if(!empty($datastore->dbg))
{
$log .= get_sql_log_html($datastore, 'cache: datastore ['.$datastore->engine.']');
}
return $log;
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
function get_sql_log_html ($db_obj, $log_name)
function get_sql_log()
{
$log = '';
global $DBS, $CACHES, $sphinx, $datastore;
foreach ($db_obj->dbg as $i => $dbg)
{
$id = "sql_{$i}_". mt_rand();
$sql = short_query($dbg['sql'], true);
$time = sprintf('%.4f', $dbg['time']);
$perc = @sprintf('[%2d]', $dbg['time']*100/$db_obj->sql_timetotal);
$info = !empty($dbg['info']) ? $dbg['info'] .' ['. $dbg['src'] .']' : $dbg['src'];
$log = '';
$log .= ''
. '<div class="sqlLogRow" title="'. $info .'">'
. '<span style="letter-spacing: -1px;">'. $time .' </span>'
. '<span title="Copy to clipboard" onclick="$.copyToClipboard( $(\'#'. $id .'\').text() );" style="color: gray; letter-spacing: -1px;">'. $perc .'</span>'
. ' '
. '<span style="letter-spacing: 0px;" id="'. $id .'">'. $sql .'</span>'
. '<span style="color: gray"> # '. $info .' </span>'
. '</div>'
. "\n";
}
return '
<div class="sqlLogTitle">'. $log_name .'</div>
'. $log .'
foreach ($DBS->srv as $srv_name => $db_obj) {
$log .= !empty($db_obj) ? get_sql_log_html($db_obj, "$srv_name [MySQL]") : '';
}
foreach ($CACHES->obj as $cache_name => $cache_obj) {
if (!empty($cache_obj->db)) {
$log .= get_sql_log_html($cache_obj->db, "cache: $cache_name [{$cache_obj->db->engine}]");
} elseif (!empty($cache_obj->engine)) {
$log .= get_sql_log_html($cache_obj, "cache: $cache_name [{$cache_obj->engine}]");
}
}
$log .= !empty($sphinx) ? get_sql_log_html($sphinx, '$sphinx') : '';
if (!empty($datastore->db->dbg)) {
$log .= get_sql_log_html($datastore->db, 'cache: datastore [' . $datastore->engine . ']');
} elseif (!empty($datastore->dbg)) {
$log .= get_sql_log_html($datastore, 'cache: datastore [' . $datastore->engine . ']');
}
return $log;
}
function get_sql_log_html($db_obj, $log_name)
{
$log = '';
foreach ($db_obj->dbg as $i => $dbg) {
$id = "sql_{$i}_" . mt_rand();
$sql = short_query($dbg['sql'], true);
$time = sprintf('%.4f', $dbg['time']);
$perc = @sprintf('[%2d]', $dbg['time'] * 100 / $db_obj->sql_timetotal);
$info = !empty($dbg['info']) ? $dbg['info'] . ' [' . $dbg['src'] . ']' : $dbg['src'];
$log .= ''
. '<div class="sqlLogRow" title="' . $info . '">'
. '<span style="letter-spacing: -1px;">' . $time . ' </span>'
. '<span title="Copy to clipboard" onclick="$.copyToClipboard( $(\'#' . $id . '\').text() );" style="color: gray; letter-spacing: -1px;">' . $perc . '</span>'
. ' '
. '<span style="letter-spacing: 0px;" id="' . $id . '">' . $sql . '</span>'
. '<span style="color: gray"> # ' . $info . ' </span>'
. '</div>'
. "\n";
}
return '
<div class="sqlLogTitle">' . $log_name . '</div>
' . $log . '
';
}
}