Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 6:02 AM

in-portal

Index: trunk/kernel/include/debugger_dummy.php
===================================================================
--- trunk/kernel/include/debugger_dummy.php (nonexistent)
+++ trunk/kernel/include/debugger_dummy.php (revision 861)
@@ -0,0 +1,64 @@
+<?php
+
+ class DebuggerDummy
+ {
+
+ function dumpVars()
+ {
+
+ }
+
+ function formatSQL($sql)
+ {
+
+ }
+
+ function highlightString($string)
+ {
+
+ }
+
+ function getFileLink($file, $lineno = 1, $title = '')
+ {
+
+ }
+
+ function appendTrace()
+ {
+
+ }
+
+ function appendHTML($html)
+ {
+
+ }
+
+ function profileStart($key, $description)
+ {
+
+ }
+
+ function profileFinish($key)
+ {
+
+ }
+
+ function generateID()
+ {
+
+ }
+
+ function printReport()
+ {
+
+ }
+
+ function saveToFile($msg)
+ {
+
+ }
+
+ }
+
+ $debugger = new DebuggerDummy();
+?>
\ No newline at end of file
Property changes on: trunk/kernel/include/debugger_dummy.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/kernel/include/debugger.php
===================================================================
--- trunk/kernel/include/debugger.php (revision 860)
+++ trunk/kernel/include/debugger.php (revision 861)
@@ -1,430 +1,429 @@
<?php
define('DBG_USE_HIGHLIGHT', 1);
define('DBG_USE_SHUTDOWN_FUNC', 1);
class Debugger
{
/**
* Debugger data for building report
*
* @var Array
*/
var $Data = Array();
var $ProfilerData = Array();
var $RecursionStack = Array(); // prevent recursion when processing debug_backtrace() function results
function dumpVars()
{
$dumpVars = func_get_args();
foreach($dumpVars as $varValue)
{
$this->Data[] = Array('value' => $varValue, 'debug_type' => 'var_dump');
}
}
function prepareHTML($dataIndex)
{
$Data =& $this->Data[$dataIndex];
if($Data['debug_type'] == 'html') return $Data['html'];
switch($Data['debug_type'])
{
case 'error':
$fileLink = $this->getFileLink($Data['file'],$Data['line']);
$ret = '<b class="debug_error">'.$this->getErrorNameByCode($Data['no']).'</b>: '.$Data['str'];
$ret .= ' in <b>'.$fileLink.'</b> on line <b>'.$Data['line'].'</b>';
return $ret;
break;
case 'var_dump':
$ret = highlight_string('<?php '.print_r($Data['value'], true).'?>', true);
$ret = preg_replace('/&lt;\?php (.*)\?&gt;/s','$1',$ret);
return addslashes($ret);
break;
case 'trace':
$trace =& $Data['trace'];
$i = 0; $traceCount = count($trace);
$ret = '';
while($i < $traceCount)
{
$traceRec =& $trace[$i];
$argsID = 'trace_args_'.$dataIndex.'_'.$i;
$ret .= '<a href="javascript:toggleTraceArgs(\''.$argsID.'\');" title="Show/Hide Function Arguments"><b>Function</b></a>: '.$this->getFileLink($traceRec['file'],$traceRec['line'],$traceRec['class'].$traceRec['type'].$traceRec['function']).'';
$ret .= ' in <b>'.basename($traceRec['file']).'</b> on line <b>'.$traceRec['line'].'</b><br>';
// ensure parameter value is not longer then 200 symbols
$this->processTraceArguments($traceRec['args']);
$args = $this->highlightString(print_r($traceRec['args'], true));
$ret .= '<div id="'.$argsID.'" style="display: none;">'.$args.'</div>';
$i++;
}
return $ret;
break;
case 'profiler':
$profileKey = $Data['profile_key'];
$Data =& $this->ProfilerData[$profileKey];
$runtime = ($Data['ends'] - $Data['begins']); // in seconds
return '<b>Name</b>: '.$Data['description'].'<br><b>Runtime</b>: '.$runtime.'s';
break;
default:
return 'incorrect debug data';
break;
}
}
function processTraceArguments(&$traceArgs)
{
foreach ($traceArgs as $argID => $argValue)
{
if( is_array($argValue) || is_object($argValue) )
{
if(is_object($argValue) && !in_array(get_class($argValue),$this->RecursionStack) )
{
// object & not in stack - ok
array_push($this->RecursionStack, get_class($argValue));
settype($argValue,'array');
$this->processTraceArguments($argValue);
array_pop($this->RecursionStack);
}
elseif(is_object($argValue) && in_array(get_class($argValue),$this->RecursionStack) )
{
// object & in stack - recursion
$traceArgs[$argID] = '**** RECURSION ***';
}
else
{
// normal array here
$this->processTraceArguments($argValue);
}
}
else
{
$traceArgs[$argID] = $this->cutStringForHTML($traceArgs[$argID]);
}
}
}
function cutStringForHTML($string)
{
if( strlen($string) > 200 ) $string = substr($string,0,50).' ...';
return $string;
-
}
/**
* Format SQL Query using predefined formatting
* and highlighting techniques
*
* @param string $sql
* @return string
*/
function formatSQL($sql)
{
$sql = preg_replace('/(\n|\t| )+/is',' ',$sql);
$sql = preg_replace('/(SELECT|UPDATE|REPLACE|INSERT|DELETE|VALUES|FROM|LEFT JOIN|WHERE|HAVING|GROUP BY|ORDER BY) /is', "\n\t$1 ",$sql);
return $this->highlightString($sql);
}
function highlightString($string)
{
if( defined('DBG_USE_HIGHLIGHT')&&DBG_USE_HIGHLIGHT )
{
$string = highlight_string('<?php '.$string.'?>', true);
return preg_replace('/&lt;\?(.*)php (.*)\?&gt;/s','$2',$string);
}
else
{
- return $string;
+ return $string;
}
}
function getFileLink($file, $lineno = 1, $title = '')
{
if(!$title) $title = $file;
return '<a href="javascript:editFile(\''.$this->getLocalFile($file).'\','.$lineno.');" title="'.$file.'">'.$title.'</a>';
}
function getLocalFile($remoteFile)
{
return str_replace(DOC_ROOT, WINDOWS_ROOT, $remoteFile);
}
function appendTrace()
{
$trace = debug_backtrace();
array_shift($trace);
$this->Data[] = Array('trace' => $trace, 'debug_type' => 'trace');
}
function appendHTML($html)
{
$this->Data[] = Array('html' => $html,'debug_type' => 'html');
}
function profileStart($key, $description)
{
$timeStamp = $this->getMoment();
$this->ProfilerData[$key] = Array('begins' => $timeStamp, 'ends' => 5000, 'debuggerRowID' => count($this->Data), 'description' => $description);
$this->Data[] = array('profile_key' => $key, 'debug_type' => 'profiler');
}
function profileFinish($key)
{
$this->ProfilerData[$key]['ends'] = $this->getMoment();
}
function getMoment()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function generateID()
{
list($usec, $sec) = explode(" ",microtime());
$id_part_1 = substr($usec, 4, 4);
$id_part_2 = mt_rand(1,9);
$id_part_3 = substr($sec, 6, 4);
$digit_one = substr($id_part_1, 0, 1);
if ($digit_one == 0) {
$digit_one = mt_rand(1,9);
$id_part_1 = ereg_replace("^0","",$id_part_1);
$id_part_1=$digit_one.$id_part_1;
}
return $id_part_1.$id_part_2.$id_part_3;
}
function getErrorNameByCode($errorCode)
{
switch($errorCode)
{
case E_USER_ERROR:
return 'Fatal Error';
break;
case E_WARNING:
case E_USER_WARNING:
return 'Warning';
break;
case E_NOTICE:
case E_USER_NOTICE:
return 'Notice';
break;
default:
return '';
break;
}
}
/**
* Generates report
*
*/
function printReport()
{
$i = 0; $lineCount = count($this->Data);
?>
<link rel="stylesheet" type="text/css" href="<?php echo DBG_STYLESHEET; ?>">
<div id="debug_layer" class="debug_layer_container" style="display: none;">
<div class="debug_layer">
<table width="100%" cellpadding="0" cellspacing="1" border="0" class="debug_layer_table">
<?php
while ($i < $lineCount)
{
echo '<tr class="debug_row_'.(($i % 2) ? 'odd' : 'even').'"><td class="debug_cell">'.$this->prepareHTML($i).'</td></tr>';
$i++;
}
?>
</table>
</div>
</div>
<script language="javascript">
function getEventKeyCode($e)
{
var $KeyCode = 0;
if($e.keyCode) $KeyCode = $e.keyCode;
else if($e.which) $KeyCode = $e.which;
return $KeyCode;
}
function keyProcessor($e)
{
if(!$e) $e = window.event;
var $KeyCode = getEventKeyCode($e);
//alert(showProps($e));
if($KeyCode == 123 || $KeyCode == 68 && $e.shiftKey) // F12 (for Maxthon) or Ctrl+F2 (for Other Browsers)
{
toggleDebugLayer();
$e.cancelBubble = true;
if($e.stopPropagation) $e.stopPropagation();
}
}
function toggleDebugLayer()
{
var $DebugLayer = document.getElementById('debug_layer');
if( typeof($DebugLayer) != 'undefined' )
{
resizeDebugLayer(null);
$DebugLayer.style.display = ($DebugLayer.style.display == 'none') ? 'block' : 'none';
}
}
function prepareSizes($Prefix)
{
var $ret = '';
$ret = eval('document.body.'+$Prefix+'Top')+'; ';
$ret += eval('document.body.'+$Prefix+'Left')+'; ';
$ret += eval('document.body.'+$Prefix+'Height')+'; ';
$ret += eval('document.body.'+$Prefix+'Width')+'; ';
return $ret;
}
function resizeDebugLayer($e)
{
if(!$e) $e = window.event;
var $DebugLayer = document.getElementById('debug_layer');
var $TopMargin = 1;
if( typeof($DebugLayer) != 'undefined' )
{
$DebugLayer.style.top = parseInt(document.body.offsetTop + document.body.scrollTop) + $TopMargin;
$DebugLayer.style.height = document.body.clientHeight - $TopMargin - 5;
}
window.parent.status = 'OFFSET: '+prepareSizes('offset')+' | SCROLL: '+prepareSizes('scroll')+' | CLIENT: '+prepareSizes('client');
window.parent.status += 'DL Info: '+$DebugLayer.style.top+'; S.AH: '+screen.availHeight;
return true;
}
function SetClipboard($data)
{
if (window.clipboardData)
{
window.clipboardData.setData('Text', $data);
}
else if (window.netscape)
{
//netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
trans.addDataFlavor('text/unicode');
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
var $copytext=$data;
str.data=$copytext;
trans.setTransferData("text/unicode",str,$copytext.length*2);
var clipid=Components.interfaces.nsIClipboard;
if (!clip) return false;
clip.setData(trans,null,clipid.kGlobalClipboard);
}
}
function showProps($Obj, $Name)
{
var $ret = '';
for($Prop in $Obj)
{
$ret += $Name+'.'+$Prop+' = '+$Obj[$Prop]+"\n";
}
return $ret;
}
function editFile($fileName,$lineNo)
{
var $editorPath = '<?php echo defined('WINDOWS_EDITOR') ? addslashes(WINDOWS_EDITOR) : '' ?>';
if($editorPath)
{
var $obj = new ActiveXObject("LaunchinIE.Launch");
$editorPath = $editorPath.replace('%F',$fileName);
$editorPath = $editorPath.replace('%L',$lineNo);
$obj.LaunchApplication($editorPath);
}
else
{
alert('Editor path not defined!');
}
}
function toggleTraceArgs($ArgsLayerID)
{
var $ArgsLayer = document.getElementById($ArgsLayerID);
$ArgsLayer.style.display = ($ArgsLayer.style.display == 'none') ? 'block' : 'none';
}
document.onkeydown = keyProcessor;
window.onresize = resizeDebugLayer;
window.onscroll = resizeDebugLayer;
window.focus();
if( typeof($isFatalError) != 'undefined' && $isFatalError == 1 )
{
toggleDebugLayer();
document.getElementById('debug_layer').scrollTop = 10000000;
}
</script>
<?php
}
/**
* User-defined error handler
*
* @param int $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param array $errcontext
*/
function saveError($errno, $errstr, $errfile = '', $errline = '', $errcontext = '')
{
//echo '<b>error</b> ['.$errno.'] = ['.$errstr.']<br>';
$errorType = $this->getErrorNameByCode($errno);
if(!$errorType)
{
trigger_error('Unknown error type ['.$errno.']', E_USER_ERROR);
return false;
}
$this->Data[] = Array('no' => $errno, 'str' => $errstr, 'file' => $errfile, 'line' => $errline, 'context' => $errcontext, 'debug_type' => 'error');
if( substr($errorType,0,5) == 'Fatal')
{
echo '<script language="javascript">var $isFatalError = 1;</script>';
exit;
}
}
function saveToFile($msg)
{
$fp = fopen($_SERVER['DOCUMENT_ROOT'].'/vb_debug.txt', 'a');
fwrite($fp,$msg."\n");
fclose($fp);
}
}
$debugger = new Debugger();
$debugger->appendHTML('<a href="javascript:toggleDebugLayer();">Hide Debugger</a>');
set_error_handler( array(&$debugger,'saveError') );
if(defined('DBG_USE_SHUTDOWN_FUNC')&&DBG_USE_SHUTDOWN_FUNC)
{
register_shutdown_function( array(&$debugger,'printReport') );
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/include/debugger.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.9
\ No newline at end of property
+1.10
\ No newline at end of property
Index: trunk/kernel/startup.php
===================================================================
--- trunk/kernel/startup.php (revision 860)
+++ trunk/kernel/startup.php (revision 861)
@@ -1,185 +1,185 @@
<?php
//if(get_magic_quotes_gpc())
//{
// function stripSlashesA($a)
// {
// foreach($a as $k=>$v)
// $a[$k]=is_array($v)?stripSlashesA($v):stripslashes($v);
// return $a;
// }
// foreach(Array(
// 'HTTP_GET_VARS','HTTP_POST_VARS','HTTP_COOKIE_VARS','HTTP_SESSION_VARS','HTTP_SERVER_VARS','$HTTP_POST_FILES',
// '_POST','_GET','_COOKIE','_SESSION','_SERVER','_FILES','_REQUEST') as $_)
// if(isset($GLOBALS[$_]))
// $GLOBALS[$_]=stripSlashesA($GLOBALS[$_]);
//}
if(!get_magic_quotes_gpc())
{
function addSlashesA($a)
{
foreach($a as $k=>$v)
$a[$k]=is_array($v)?addSlashesA($v):addslashes($v);
return $a;
}
foreach(Array(
'HTTP_GET_VARS','HTTP_POST_VARS','HTTP_COOKIE_VARS','HTTP_SESSION_VARS','HTTP_SERVER_VARS',
'_POST','_GET','_COOKIE','_SESSION','_SERVER','_REQUEST') as $_)
if(isset($GLOBALS[$_]))
$GLOBALS[$_]=addSlashesA($GLOBALS[$_]);
}
function inp_htmlize($var,$strip=0)
{
if(is_array($var))
foreach($var as $k=>$v)
$var[$k]=inp_htmlize($v,$strip);
else
$var=htmlspecialchars($strip?stripslashes($var):$var);
return $var;
}
/*
startup.php: this is the primary startup sequence for in-portal services
*/
if( file_exists($pathtoroot.'debug.php') && !defined('DEBUG_MODE') ) include_once($pathtoroot.'debug.php');
if( !defined('DEBUG_MODE') ) error_reporting(0);
ini_set('memory_limit', '16M');
ini_set('include_path', '.');
$kernel_version = "1.0.0";
$FormError = array();
$FormValues = array();
/* include PHP version compatibility functions */
require_once($pathtoroot."compat.php");
/* set global variables and module lists */
require_once($pathtoroot."globals.php");
-if( IsDebugMode() ) include_once($pathtoroot.'kernel/include/debugger.php');
+include_once($pathtoroot.'kernel/include/'.( IsDebugMode() ? 'debugger.php' : 'debugger_dummy.php') );
LogEntry("Initalizing System..\n");
/* for 64 bit timestamps */
require_once($pathtoroot."kernel/include/adodb/adodb-time.inc.php");
require_once($pathtoroot."kernel/include/dates.php");
/* create the global error object */
require_once($pathtoroot."kernel/include/error.php");
$Errors = new clsErrorManager();
require_once($pathtoroot."kernel/include/itemdb.php");
require_once($pathtoroot."kernel/include/config.php");
/* create the global configuration object */
LogEntry("Creating Config Object..\n");
$objConfig = new clsConfig();
$objConfig->Load(); /* Populate our configuration data */
LogEntry("Done Loading Configuration\n");
if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 )
LogEntry("ADO Extension: ".ADODB_EXTENSION."\n");
require_once($pathtoroot."kernel/include/parseditem.php");
require_once($pathtoroot."kernel/include/item.php");
require_once($pathtoroot."kernel/include/syscache.php");
require_once($pathtoroot."kernel/include/modlist.php");
require_once($pathtoroot."kernel/include/searchconfig.php");
require_once($pathtoroot."kernel/include/banrules.php");
$objModules = new clsModList();
$objSystemCache = new clsSysCacheList();
$objSystemCache->PurgeExpired();
$objBanList = new clsBanRuleList();
require_once($pathtoroot."kernel/include/image.php");
require_once($pathtoroot."kernel/include/itemtypes.php");
$objItemTypes = new clsItemTypeList();
require_once($pathtoroot."kernel/include/theme.php");
$objThemes = new clsThemeList();
require_once($pathtoroot."kernel/include/language.php");
$objLanguages = new clsLanguageList();
$objImageList = new clsImageList();
/* Load session and user class definitions */
//require_once("include/customfield.php");
//require_once("include/custommetadata.php");
require_once($pathtoroot."kernel/include/usersession.php");
require_once($pathtoroot."kernel/include/favorites.php");
require_once($pathtoroot."kernel/include/portaluser.php");
require_once($pathtoroot."kernel/include/portalgroup.php");
/* create the user management class */
$objFavorites = new clsFavoriteList();
$objUsers = new clsUserManager();
$objGroups = new clsGroupList();
require_once($pathtoroot."kernel/include/cachecount.php");
require_once($pathtoroot."kernel/include/customfield.php");
require_once($pathtoroot."kernel/include/custommetadata.php");
require_once($pathtoroot."kernel/include/permissions.php");
require_once($pathtoroot."kernel/include/relationship.php");
require_once($pathtoroot."kernel/include/category.php");
require_once($pathtoroot."kernel/include/statitem.php");
/* category base class, used by all the modules at some point */
$objPermissions = new clsPermList();
$objPermCache = new clsPermCacheList();
$objCatList = new clsCatList();
$objCustomFieldList = new clsCustomFieldList();
$objCustomDataList = new clsCustomDataList();
$objCountCache = new clsCacheCountList();
require_once($pathtoroot."kernel/include/smtp.php");
require_once($pathtoroot."kernel/include/emailmessage.php");
require_once($pathtoroot."kernel/include/events.php");
LogEntry("Creating Mail Queue..\n");
$objMessageList = new clsEmailMessageList();
$objEmailQueue = new clsEmailQueue();
LogEntry("Done creating Mail Queue Objects\n");
require_once($pathtoroot."kernel/include/searchitems.php");
require_once($pathtoroot."kernel/include/advsearch.php");
require_once($pathtoroot."kernel/include/parse.php");
require_once($pathtoroot."kernel/include/socket.php");
/* responsible for including module code as required
This script also creates an instance of the user session onject and
handles all session management. The global session object is created
and populated, then the global user object is created and populated
each module's parser functions and action code is included here
*/
LogEntry("Startup complete\n");
include_once("include/modules.php");
if( defined('DEBUG_MODE') && constant('DEBUG_MODE') == 1 && function_exists('DebugByFile') ) DebugByFile();
/* startup is complete, so now check the mail queue to see if there's anything that needs to be sent*/
$objEmailQueue->SendMailQeue();
$ado=&GetADODBConnection();
$rs = $ado->Execute("SELECT * FROM ".GetTablePrefix()."Modules WHERE LoadOrder = 0");
$kernel_version = $rs->fields['Version'];
$adminDir = $objConfig->Get("AdminDirectory");
if ($adminDir == '') {
$adminDir = 'admin';
}
if (strstr(__FILE__, $adminDir) && !GetVar('logout') && !strstr(__FILE__, "install") && !strstr(__FILE__, "index")) {
//echo "testz [".admin_login()."]<br>";
if (!admin_login())
{
if( !headers_sent() ) setcookie("sid"," ",time()-3600);
$objSession->Logout();
$url_add = isset($_GET['expired']) && $_GET['expired'] ? '?expired=1' : '';
header("Location: ".$adminURL.'/login.php'.$url_add);
die();
//require_once($pathtoroot."admin/login.php");
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/startup.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.19
\ No newline at end of property
+1.20
\ No newline at end of property

Event Timeline