Move function out of the class, as they should be global

This commit is contained in:
Stanislas Dolcini 2018-10-06 14:44:53 +02:00
parent 1a4cd29203
commit 436bfd0c36
3 changed files with 48 additions and 55 deletions

View file

@ -1,19 +1,12 @@
<?php <?php
error_reporting(E_ERROR | E_PARSE);
set_error_handler('err_callback');
// For error handling, buffer all output
ob_start('ob_callback_r2login');
include_once '../config.php';
include_once '../login_translations.php';
include_once '../../tools/nel_message.php';
include_once '../../tools/domain_info.php';
include_once '../login_service_itf.php';
include_once '../../ring/join_shard.php';
include_once './CWwwLog.php';
include_once './LoginCb.php'; include_once './LoginCb.php';
include_once './../tools/utils.php';
include_once './../config.php';
include_once './../login_translations.php';
include_once './../login_service_itf.php';
include_once './../../ring/join_shard.php';
include_once './../../tools/nel_message.php';
include_once './../../tools/domain_info.php';
class ConnectionHandler class ConnectionHandler
{ {
@ -238,35 +231,6 @@ class ConnectionHandler
// } // }
} }
public function errorMsgBlock($errNum = GENERIC_ERROR_NUM)
{
return '0:' . call_user_func_array('errorMsg', func_get_args());
}
/**
* Callback called on end of output buffering
*/
public function ob_callback_r2login($buffer)
{
// Log only in case of error or malformed result string
$blockHd = substr($buffer, 0, 2);
if ($blockHd != '1:') {
$logFile = new CWwwLog();
$logFile->logStr(str_replace("\n", '\n', $buffer));
}
return $buffer; // sent to output
}
/**
* Callback called on error
*/
public function err_callback($errno, $errmsg, $filename, $linenum, $vars)
{
$logFile = new CWwwLog();
$logFile->logStr('PHP ERROR/$errno $errmsg ($filename:$linenum)');
$logFile->logStr('PHP CALLSTACK/' . print_r(debug_backtrace(), true));
}
/** /**
* @param string * @param string
* the password to extract the salt from. * the password to extract the salt from.

View file

@ -1,19 +1,11 @@
<?php <?php
error_reporting(E_ERROR | E_PARSE); include_once './tools/utils.php';
set_error_handler('err_callback');
// For error handling, buffer all output
ob_start('ob_callback_r2login');
include_once 'config.php';
include_once 'login_translations.php';
include_once '../tools/nel_message.php';
include_once '../tools/domain_info.php';
include_once 'login_service_itf.php';
include_once '../ring/join_shard.php';
include_once './class/connection_handler.php'; include_once './class/connection_handler.php';
include_once './class/nel_command.php'; include_once './class/nel_command.php';
/**
* If there is no command, no point in going further.
*/
if (!isset($_GET['cmd'])) { if (!isset($_GET['cmd'])) {
die(errorMsgBlock(3002)); die(errorMsgBlock(3002));
} }

View file

@ -0,0 +1,37 @@
<?php
include_once './../class/CWwwLog.php';
error_reporting(E_ERROR | E_PARSE);
set_error_handler('err_callback');
// For error handling, buffer all output
ob_start('ob_callback_r2login');
function errorMsgBlock($errNum = GENERIC_ERROR_NUM)
{
return '0:' . call_user_func_array('errorMsg', func_get_args());
}
/**
* Callback called on end of output buffering
*/
function ob_callback_r2login($buffer)
{
// Log only in case of error or malformed result string
$blockHd = substr($buffer, 0, 2);
if ($blockHd != '1:') {
$logFile = new CWwwLog();
$logFile->logStr(str_replace("\n", '\n', $buffer));
}
return $buffer; // sent to output
}
/**
* Callback called on error
*/
function err_callback($errno, $errmsg, $filename, $linenum, $vars)
{
$logFile = new CWwwLog();
$logFile->logStr('PHP ERROR/$errno $errmsg ($filename:$linenum)');
$logFile->logStr('PHP CALLSTACK/' . print_r(debug_backtrace(), true));
}