Index: trunk/themes/default/incs/inportal_main.css =================================================================== diff -u -N -r568 -r817 --- trunk/themes/default/incs/inportal_main.css (.../inportal_main.css) (revision 568) +++ trunk/themes/default/incs/inportal_main.css (.../inportal_main.css) (revision 817) @@ -799,27 +799,52 @@ /* debug output styles */ -.debug_table { - border: 1px solid green; +.flat_table TD { + border: 1px solid buttonface; + border-width: 1 1 0 0; + +} + +.debug_layer_table { + border: 1px solid red; border-width: 0 0 1 1; } -.debug_table TD, .debug_text { +.debug_text, .debug_row_even TD, .debug_row_odd TD { color: #000000; - font-family: Arial, Helvetica; - font-size: 13px; + font-family: Verdana; + font-size: 11px; } -.debug_table TD { - border: 1px solid green; +.debug_cell { + border: 1px solid red; border-width: 1 1 0 0; - } -.debug_layer { - position: relative; - overflow: auto; - - height: 300px; - width: 600px; +.debug_row_even { + background-color: #CCCCFF; +} + +.debug_row_odd { + background-color: #FFFFCC; +} + +.debug_layer_container { + left: 2px; + top: 1px; + width: 500px; + z-index: +10; + position: absolute; + overflow: auto; + border: 2px solid; + padding: 3px; + border-top-color: threedlightshadow; + border-left-color: threedlightshadow; + border-right-color: threeddarkshadow; + border-bottom-color: threeddarkshadow; + background-color: buttonface; +} + +.debug_error { + color: #FF0000; } \ No newline at end of file Index: trunk/globals.php =================================================================== diff -u -N -r809 -r817 --- trunk/globals.php (.../globals.php) (revision 809) +++ trunk/globals.php (.../globals.php) (revision 817) @@ -1407,11 +1407,16 @@ if($SFValue == 1 || $SFValue == 2) $list->Clear(); } -function GetElem(&$array, $index) +/** + * Returns array value if key exists + * + * @param Array $aArray + * @param int $aIndex + * @return string + */ +function getArrayValue(&$aArray, $aIndex) { - // returns array element by index if - // such index exists - return isset($array[$index]) ? $array[$index] : false; + return isset($aArray[$aIndex]) ? $aArray[$aIndex] : false; } function MakeHTMLTag($element, $attrib_prefix) Index: trunk/kernel/parser.php =================================================================== diff -u -N -r805 -r817 --- trunk/kernel/parser.php (.../parser.php) (revision 805) +++ trunk/kernel/parser.php (.../parser.php) (revision 817) @@ -2492,33 +2492,35 @@ { global $m_var_list_update, $var_list, $objCatList, $objConfig, $objModules; - $separator = GetElem($attribs, '_separator'); + $separator = getArrayValue($attribs, '_separator'); if(!$separator) $separator = " > "; - $admin = (int)GetElem($attribs, 'admin'); + $admin = (int)getArrayValue($attribs, 'admin'); - $t = GetElem($attribs, '_template'); - $LinkLeafNode = GetElem($attribs, '_linkcurrent'); - $catid = (int)GetElem($attribs, '_catid'); + $t = getArrayValue($attribs, '_template'); + $LinkLeafNode = getArrayValue($attribs, '_linkcurrent'); + $catid = (int)getArrayValue($attribs, '_catid'); - if( GetElem($attribs, '_root') ) + if( getArrayValue($attribs, '_root') ) { - $var = GetElem($attribs, '_root')."_Root"; + $var = getArrayValue($attribs, '_root')."_Root"; $Root = (int)$objConfig->Get($var); } else $Root = 0; - $RootTemplate = GetElem($attribs, '_roottemplate') ? GetElem($attribs, '_roottemplate') : ''; - $Module = GetElem($attribs, '_module'); + $RootTemplate = getArrayValue($attribs, '_roottemplate'); + if($RootTemplate === false) $RootTemplate = ''; + + $Module = getArrayValue($attribs, '_module'); $ModuleRootTemplate = ''; if($Module) { $ModuleRootCat = $objModules->GetModuleRoot($Module); if($ModuleRootCat>0) { $modkey = "_moduleroottemplate"; - $ModuleRootTemplate = GetElem($attribs, $modkey); + $ModuleRootTemplate = getArrayValue($attribs, $modkey); } else $ModuleRootTemplate=""; Index: trunk/kernel/include/parse.php =================================================================== diff -u -N -r720 -r817 --- trunk/kernel/include/parse.php (.../parse.php) (revision 720) +++ trunk/kernel/include/parse.php (.../parse.php) (revision 817) @@ -1,80 +1,89 @@ SetRawText($text); - if(strlen($text)) - $this->parse(); - } + function clsHtmlTag($text=null) + { + $this->SetRawText($text); + if(strlen($text)) $this->parse(); + } - function Clear() - { - $this->parsed = FALSE; - $this->rawtext = NULL; - $this->prefix = ""; - $this->name = ""; - $this->attributes = NULL; - $this->inner_html = ""; - } + function Clear() + { + $this->parsed = FALSE; + $this->rawtext = NULL; + $this->prefix = ""; + $this->name = ""; + $this->attributes = NULL; + $this->inner_html = ""; + } - function ValidTag() - { - return (strlen($this->prefix) && strlen($this->name)); - } + function ValidTag() + { + return (strlen($this->prefix) && strlen($this->name)); + } - function SetRawText($text) - { - $this->Clear(); - if($text != NULL) - $text = trim($text); - $this->rawtext = $text; - } + function SetRawText($text) + { + $this->Clear(); + if($text != NULL) $text = trim($text); + $this->rawtext = $text; + } - function GetAttributeByName($attr) - { - if(is_array($this->attributes)) - { - $attr = strtolower($attr); - if( array_key_exists($attr,$this->attributes)) - { - return $this->attributes[$attr]; - } - else - return FALSE; - } - else - return FALSE; - } + function GetAttributeByName($attr) + { + if(is_array($this->attributes)) + { + $attr = strtolower($attr); + if( array_key_exists($attr,$this->attributes)) + { + return $this->attributes[$attr]; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } + } - function SetAttributeByName($attr,$value) - { - if(!is_array($this->attributes)) - $this->attributes = array(); - $this->attributes[$attr] = $value; - } + function SetAttributeByName($attr,$value) + { + if(!is_array($this->attributes)) + { + $this->attributes = array(); + } + $this->attributes[$attr] = $value; + } function GetAttributeByIndex($index) { - if(is_array($this->attributes)) - { - if($index < count($this->attributes)) - { - return $this->attributes[$index]; - } - else - return FALSE; - } - else - return FALSE; + if(is_array($this->attributes)) + { + if($index < count($this->attributes)) + { + return $this->attributes[$index]; + } + else + { + return FALSE; + } + } + else + { + return FALSE; + } } + function ParseAttributes($attributes) { unset($output); @@ -189,51 +198,53 @@ return($output); } - function parse() - { - global $objSession; - - $html = $this->rawtext; - $html = substr($html,1,strlen($html)-2); - if(substr($html,strlen($html)-1,1)=="/") - { - $html = substr($html,0,strlen($html)-1); - } + function parse() + { + global $objSession; - $tagparts = explode(" ",$html,2); - $tagname = $tagparts[0]; - $attribs = array(); - if(count($tagparts)>0) - $attribs = $this->ParseAttributes( isset($tagparts[1]) ? $tagparts[1] : ''); + $html = $this->rawtext; + $html = substr($html,1,strlen($html)-2); + if(substr($html,strlen($html)-1,1)=="/") + { + $html = substr($html,0,strlen($html)-1); + } - if(is_object($objSession) && is_array($attribs)) - { - $referer = $objSession->GetVariable("Template_Referer"); - foreach($attribs as $key=>$value) - { - if($value=="_referer_") - $attribs[$key] = $referer; - } - } - $name = explode(":",$tagname); - $this->prefix = strtolower($name[0]); - $this->name = strtolower($name[1]); - if(is_array($attribs)) - { - foreach($attribs as $key=>$value) - { - if(!strlen($value)) - { - $attribs[$key]=1; - } - } - $this->attributes = $attribs; - } - else - $this->attributes = array(); - $this->parsed=TRUE; - } + $tagparts = explode(" ",$html,2); + $tagname = $tagparts[0]; + $attribs = array(); + if(count($tagparts)>0) + $attribs = $this->ParseAttributes( isset($tagparts[1]) ? $tagparts[1] : ''); + if(is_object($objSession) && is_array($attribs)) + { + $referer = $objSession->GetVariable("Template_Referer"); + foreach($attribs as $key=>$value) + { + if($value=="_referer_") + $attribs[$key] = $referer; + } + } + $name = explode(":",$tagname); + $this->prefix = strtolower($name[0]); + $this->name = strtolower($name[1]); + if(is_array($attribs)) + { + foreach($attribs as $key=>$value) + { + if(!strlen($value)) + { + $attribs[$key]=1; + } + } + $this->attributes = $attribs; + } + else + { + $this->attributes = array(); + } + $this->parsed=TRUE; + } + function Execute() { $func = $this->name; @@ -247,7 +258,13 @@ { if(function_exists($func)) { - $ret = @$func($this->attributes); + if( IsDebugMode() && !$GLOBALS['FrontEnd'] ) + { + global $debugger; + $debugger->dumpVars($this->name, $this->attributes); + $debugger->appendTrace(); + } + $ret = @$func($this->attributes); } else { @@ -389,132 +406,126 @@ class clsTemplateList { - var $templates; - var $root_dir; - var $ErrorStr; - var $ErrorNo; - var $stack; - var $SkipIncludes = 0; + var $templates; + var $root_dir; + var $ErrorStr; + var $ErrorNo; + var $stack; + var $SkipIncludes = 0; - function clsTemplateList($root_dir) - { - $this->templates = array(); - $this->root_dir = $root_dir; - $this->ErrorStr = ""; - $this->ErrorNo = 0; - $this->SkipIncludes = 0; - $this->stack = array(); - } + function clsTemplateList($root_dir) + { + $this->templates = array(); + $this->root_dir = $root_dir; + $this->ErrorStr = ""; + $this->ErrorNo = 0; + $this->SkipIncludes = 0; + $this->stack = array(); + } - function InStack($template) - { - if(in_array($template,$this->stack)) - { - return TRUE; - } - else - return FALSE; - } + function InStack($template) + { + return in_array($template,$this->stack) ? true : false; + } - function GetTemplate($name,$SupressError=FALSE) - { - if(!strlen($name)) - { - $ret = FALSE; - if(!$SupressError) - { - $this->ErrorNo = -2; - $this->ErrorStr=language("lu_template_error").":".language("lu_no_template_error"); - } - } - else - { - $ret = FALSE; - foreach($this->templates as $n => $t) - { - if($n == $name) - { - $ret=$t; - break; - } - } - if(!is_object($ret)) - { - $ret = new clsTemplate($name); - if($ret->LoadFile($this->root_dir,$SupressError)) - { - $this->templates[$name]=$ret; - } - else - { - if( IsDebugMode() ) - { - echo 'Template '.$name.' not found
'; - - } - if(!$SupressError) - { - $this->ErrorNo = -1; - $this->ErrorStr = language("lu_template_error").":".language($ret->error).":"."'$name'"; - LogEntry($this->ErrorStr); - } - } - } - } - return $ret; - } + function GetTemplate($name,$SupressError=FALSE) + { + if(!strlen($name)) + { + $ret = FALSE; + if(!$SupressError) + { + $this->ErrorNo = -2; + $this->ErrorStr=language("lu_template_error").":".language("lu_no_template_error"); + } + } + else + { + $ret = FALSE; + foreach($this->templates as $n => $t) + { + if($n == $name) + { + $ret=$t; + break; + } + } + if(!is_object($ret)) + { + $ret = new clsTemplate($name); + if($ret->LoadFile($this->root_dir,$SupressError)) + { + $this->templates[$name]=$ret; + } + else + { + if( IsDebugMode() ) + { + $GLOBALS['debugger']->appendHTML('Warning: Template '.$name.' not found'); + } + if(!$SupressError) + { + $this->ErrorNo = -1; + $this->ErrorStr = language("lu_template_error").":".language($ret->error).":"."'$name'"; + LogEntry($this->ErrorStr); + } + } + } + } + return $ret; + } - function GetTemplateCache($template,$SupressError=FALSE) - { - global $CurrentTheme, $pathtoroot; + function GetTemplateCache($template,$SupressError=FALSE) + { + global $CurrentTheme, $pathtoroot; $ret = ''; - if( $CurrentTheme->Get("CacheTimeout") > 0) - { - $id = $CurrentTheme->GetTemplateId($template); - if($id) - { - $exp = isset($CurrentTheme->ParseCacheDate[$id]) ? $CurrentTheme->ParseCacheDate[$id] : false; - if($exp) - { - //echo "$template Cache expires: ".date("m-d-Y h:m s",$exp)."
\n"; - if( $exp > time() ) - { - /* look for a cache file */ - $t = new clsTemplate($template); - $dir = $CurrentTheme->ThemeDirectory(); - if( $t->LoadFile($dir."/_cache/",$SupressError) ) $ret = $t->source; - } - } - } - } - return $ret; - } + if( $CurrentTheme->Get("CacheTimeout") > 0) + { + $id = $CurrentTheme->GetTemplateId($template); + if($id) + { + $exp = isset($CurrentTheme->ParseCacheDate[$id]) ? $CurrentTheme->ParseCacheDate[$id] : false; + if($exp) + { + //echo "$template Cache expires: ".date("m-d-Y h:m s",$exp)."
\n"; + if( $exp > time() ) + { + /* look for a cache file */ + $t = new clsTemplate($template); + $dir = $CurrentTheme->ThemeDirectory(); + if( $t->LoadFile($dir."/_cache/",$SupressError) ) $ret = $t->source; + } + } + } + } + return $ret; + } - function SaveTemplateCache($objTemplate) - { - global $CurrentTheme, $objThemes, $pathtoroot; + function SaveTemplateCache($objTemplate) + { + global $CurrentTheme, $objThemes, $pathtoroot; - if(!is_object($CurrentTheme)) - $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]); + if(!is_object($CurrentTheme)) + $CurrentTheme = $objThemes->GetItem($m_var_list["theme"]); - if($CurrentTheme->Get("CacheTimeout")>0) - { - $TemplateId = $CurrentTheme->GetTemplateId($objTemplate->name); - if($TemplateId) - { - if(isset($CurrentTheme->ParseCacheDate[$TemplateId])) - { - //echo "Writing Template ".$objTemplate->name."
\n"; - $interval = $CurrentTheme->ParseCacheTimeout[$TemplateId]; - $CurrentTheme->UpdateFileCacheData($TemplateId,time()+$interval); - $dir = $CurrentTheme->ThemeDirectory()."/_cache/"; - $objTemplate->WriteFile($dir); - } - } - } - - } + if($CurrentTheme->Get("CacheTimeout")>0) + { + $TemplateId = $CurrentTheme->GetTemplateId($objTemplate->name); + if($TemplateId) + { + if(isset($CurrentTheme->ParseCacheDate[$TemplateId])) + { + //echo "Writing Template ".$objTemplate->name."
\n"; + $interval = $CurrentTheme->ParseCacheTimeout[$TemplateId]; + $CurrentTheme->UpdateFileCacheData($TemplateId,time()+$interval); + $dir = $CurrentTheme->ThemeDirectory()."/_cache/"; + $objTemplate->WriteFile($dir); + } + } + } + } + function IncludeTemplate($tag, $SupressError=FALSE) { global $LogLevel, $objSession,$objLanguages; @@ -636,68 +647,68 @@ /* attributes = $tag->attributes; - $el->parsed=1; - $t = $tag->attributes["_template"]; - if(!strlen($t)) - $t = $var_list["t"]; - - $el->name = "perm_include"; - $tpath = GetModuleArray("template"); + global $var_list; - if(!strlen( $tag->GetAttributeByName('_modules') )) - { - $mods = array_keys($tpath); - } - else - $mods = explode(",",$tag->attributes["_modules"]); - - foreach($mods as $m) - { - if($t==$var_list["t"] && !strlen($tpath[$m])) - continue; - $el->attributes = $tag->attributes; - $el->attributes["_template"] = $tpath[$m].$t; - $el->attributes["_module"] = $m; - - if(strlen( $tag->GetAttributeByName('_nodatatemplate') )) - { - $el->attributes["_nodatatemplate"] = $tpath[$m].$tag->attributes["_nodatatemplate"]; - } + $o = ""; + $el = new clsHtmlTag(); + $el->attributes = $tag->attributes; + $el->parsed=1; + $t = $tag->attributes["_template"]; + if(!strlen($t)) + $t = $var_list["t"]; - //print_pre($el); - $o .= $this->IncludeTemplate($el,true); - } - if(!strlen($o) && strlen($tag->attributes["_nodatamaintemplate"])) - $o = $this->ParseTemplate($tag->attributes["_nodatamaintemplate"]); - return $o; + $el->name = "perm_include"; + $tpath = GetModuleArray("template"); + + if(!strlen( $tag->GetAttributeByName('_modules') )) + { + $mods = array_keys($tpath); + } + else + $mods = explode(",",$tag->attributes["_modules"]); + + foreach($mods as $m) + { + if($t==$var_list["t"] && !strlen($tpath[$m])) + continue; + $el->attributes = $tag->attributes; + $el->attributes["_template"] = $tpath[$m].$t; + $el->attributes["_module"] = $m; + + if(strlen( $tag->GetAttributeByName('_nodatatemplate') )) + { + $el->attributes["_nodatatemplate"] = $tpath[$m].$tag->attributes["_nodatatemplate"]; + } + + //print_pre($el); + $o .= $this->IncludeTemplate($el,true); + } + if(!strlen($o) && strlen($tag->attributes["_nodatamaintemplate"])) + $o = $this->ParseTemplate($tag->attributes["_nodatamaintemplate"]); + return $o; } function ParseTag($raw) { - $tag = new clsHtmlTag($raw); - $res = ""; - switch($tag->name) - { - case "lang_include": - case "include": - case "perm_include": - $res = $this->IncludeTemplate($tag); - break; - case "mod_include": - $res = $this->ModuleInclude($tag); - break; - default: - //print_pre($tag); - $res = $tag->Execute(); - break; - } - unset($tag); - return $res; + $tag = new clsHtmlTag($raw); + $res = ""; + switch($tag->name) + { + case "lang_include": + case "include": + case "perm_include": + $res = $this->IncludeTemplate($tag); + break; + case "mod_include": + $res = $this->ModuleInclude($tag); + break; + default: + //print_pre($tag); + $res = $tag->Execute(); + break; + } + unset($tag); + return $res; } function ParseTemplateText($text) Index: trunk/kernel/startup.php =================================================================== diff -u -N -r701 -r817 --- trunk/kernel/startup.php (.../startup.php) (revision 701) +++ trunk/kernel/startup.php (.../startup.php) (revision 817) @@ -53,6 +53,7 @@ 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'); LogEntry("Initalizing System..\n"); /* for 64 bit timestamps */ Index: trunk/admin/include/style.css =================================================================== diff -u -N -r269 -r817 --- trunk/admin/include/style.css (.../style.css) (revision 269) +++ trunk/admin/include/style.css (.../style.css) (revision 817) @@ -443,27 +443,53 @@ /* debug output styles */ -.debug_table { - border: 1px solid green; + +.flat_table TD { + border: 1px solid buttonface; + border-width: 1 1 0 0; + +} + +.debug_layer_table { + border: 1px solid red; border-width: 0 0 1 1; } -.debug_table TD, .debug_text { +.debug_text, .debug_row_even TD, .debug_row_odd TD { color: #000000; - font-family: Arial, Helvetica; - font-size: 13px; + font-family: Verdana; + font-size: 11px; } -.debug_table TD { - border: 1px solid green; +.debug_cell { + border: 1px solid red; border-width: 1 1 0 0; - } -.debug_layer { - position: relative; - overflow: auto; - - height: 300px; - width: 600px; +.debug_row_even { + background-color: #CCCCFF; +} + +.debug_row_odd { + background-color: #FFFFCC; +} + +.debug_layer_container { + left: 2px; + top: 1px; + width: 500px; + z-index: +10; + position: absolute; + overflow: auto; + border: 2px solid; + padding: 3px; + border-top-color: threedlightshadow; + border-left-color: threedlightshadow; + border-right-color: threeddarkshadow; + border-bottom-color: threeddarkshadow; + background-color: buttonface; +} + +.debug_error { + color: #FF0000; } \ No newline at end of file Index: trunk/kernel/include/tag-class.php =================================================================== diff -u -N -r429 -r817 --- trunk/kernel/include/tag-class.php (.../tag-class.php) (revision 429) +++ trunk/kernel/include/tag-class.php (.../tag-class.php) (revision 817) @@ -293,7 +293,7 @@ foreach($attribs as $field=>$desc) { $req = (substr($field,0,1)=="*"); - $t->AddAttribute($field, GetElem($attr_type,$field),$desc,GetElem($attr_default,$field),$req); + $t->AddAttribute($field, getArrayValue($attr_type,$field),$desc,getArrayValue($attr_default,$field),$req); } } } Index: trunk/kernel/frontaction.php =================================================================== diff -u -N -r679 -r817 --- trunk/kernel/frontaction.php (.../frontaction.php) (revision 679) +++ trunk/kernel/frontaction.php (.../frontaction.php) (revision 817) @@ -2,31 +2,34 @@ if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & FRONT_KERNEL_ACTIONS) == FRONT_KERNEL_ACTIONS ) { - if($Action) echo 'Front, Kernel Action ['.$Action."]
\n"; + if($Action) $debugger->appendHTML('Front Action: '.$Action.''); } if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & FRONT_SHOW_REQUEST) == FRONT_SHOW_REQUEST ) { // don't show debug output in tree & header of admin & while logging in $script = basename($_SERVER['PHP_SELF']); - - echo '
'; - echo "
ScriptName: $script (".dirname($_SERVER['PHP_SELF']).")

"; - $div_height = (count($_REQUEST)+1)*26; - if($div_height > 300) $div_height = 300; - echo '
'; - echo ''; - echo ''; - + $debugger->appendHTML('ScriptName: '.$script.' ('.dirname($_SERVER['PHP_SELF']).')'); + $requestTable = '
SrcNameValue
+ '; + foreach($_REQUEST as $key => $value) { - if( !is_array($value) && trim($value) == '' ) $value = ' '; - $src = isset($_GET[$key]) ? 'GE' : (isset($_POST[$key]) ? 'PO' : (isset($_COOKIE[$key]) ? 'CO' : '?') ); - echo ''; + if( !is_array($value) && trim($value) == '' ) + { + $value = 'no value'; + } + else + { + $value = htmlspecialchars(print_r($value, true)); + } + $src = isset($_GET[$key]) ? 'GE' : (isset($_POST[$key]) ? 'PO' : (isset($_COOKIE[$key]) ? 'CO' : '?') ); + $requestTable .= ''; } - echo '
SrcNameValue
'.$src.''.$key.''.print_r($value, true).'
'.$src.''.$key.''.$value.'
'; - echo '
'; - unset($script); + $requestTable .= ''; + $debugger->appendHTML($requestTable); + $debugger->dumpVars($_REQUEST); + unset($script, $requestTable); // echo "SID: ".$objSession->GetSessionKey().'
'; } Index: trunk/kernel/include/category.php =================================================================== diff -u -N -r701 -r817 --- trunk/kernel/include/category.php (.../category.php) (revision 701) +++ trunk/kernel/include/category.php (.../category.php) (revision 817) @@ -1405,24 +1405,28 @@ { global $objSession; - $cat = $attribs["_catid"]; + $cat = getArrayValue($attribs,'_catid'); if(!is_numeric($cat)) { $cat = $this->CurrentCategoryID(); } if((int)$cat>0) $c = $this->GetCategory($cat); - if($attribs["_subcats"] && $cat>0) + if( getArrayValue($attribs,'_subcats') && $cat>0) { $ParentWhere = "(ParentPath LIKE '".$c->Get("ParentPath")."%' AND ".$this->SourceTable.".CategoryId != $cat)"; } - if($attribs["_today"]) + if( getArrayValue($attribs,'_today') ) { $today = mktime(0,0,0,date("m"),date("d"),date("Y")); $TodayWhere = "(CreatedOn>=$today)"; } - if($attribs["_grouponly"]) + else + { + $TodayWhere = ''; + } + if( getArrayValue($attribs,'_grouponly') ) { $GroupList = $objSession->Get("GroupList"); } Index: trunk/kernel/action.php =================================================================== diff -u -N -r787 -r817 --- trunk/kernel/action.php (.../action.php) (revision 787) +++ trunk/kernel/action.php (.../action.php) (revision 817) @@ -5,7 +5,7 @@ $AdminLogin = admin_login(); if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & KERNEL_ACTIONS) == KERNEL_ACTIONS && $AdminLogin ) { - if($Action) echo 'Kernel Action ['.$Action."]
\n"; + if($Action) $debugger->appendHTML('Kernel Action: '.$Action.''); } if( defined('DEBUG_ACTIONS') && (DEBUG_ACTIONS & SHOW_REQUEST) == SHOW_REQUEST && $AdminLogin ) @@ -15,24 +15,28 @@ $skip_debug = Array('index.php','tree.php','head.php','credits.php'); if( !in_array($script, $skip_debug) ) { - //echo 'Open This File
'; - echo "ScriptName: $script (".dirname($_SERVER['PHP_SELF']).")

"; - $div_height = (count($_REQUEST)+1)*26; - if($div_height > 300) $div_height = 300; - echo '
'; - echo ''; - echo ''; + $debugger->appendHTML('ScriptName: '.$script.' ('.dirname($_SERVER['PHP_SELF']).')'); + $requestTable = '
SrcNameValue
+ '; foreach($_REQUEST as $key => $value) { - if( !is_array($value) && trim($value) == '' ) $value = ' '; + if( !is_array($value) && trim($value) == '' ) + { + $value = 'no value'; + } + else + { + $value = htmlspecialchars(print_r($value, true)); + } $src = isset($_GET[$key]) ? 'GE' : (isset($_POST[$key]) ? 'PO' : (isset($_COOKIE[$key]) ? 'CO' : '?') ); - echo ''; + $requestTable .= ''; } - echo '
SrcNameValue
'.$src.''.$key.''.print_r($value, true).'
'.$src.''.$key.''.$value.'
'; + $requestTable .= ''; + $debugger->appendHTML($requestTable); echo 'Reload Frame
'; } - unset($script, $skip_debug); + unset($script, $skip_debug, $requestTable); } switch($Action) Index: trunk/kernel/include/debugger.php =================================================================== diff -u -N --- trunk/kernel/include/debugger.php (revision 0) +++ trunk/kernel/include/debugger.php (revision 817) @@ -0,0 +1,267 @@ +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']); + $ret = ''.$this->getErrorNameByCode($Data['no']).': '.$Data['str']; + $ret .= ' in '.$fileLink.' on line '.$Data['line'].''; + return $ret; + break; + + case 'var_dump': + $ret = highlight_string('', true); + $ret = preg_replace('/<\?php (.*)\?>/s','$1',$ret); + return $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 .= 'Function: '.$this->getFileLink($traceRec['file'],$traceRec['class'].$traceRec['type'].$traceRec['function']).''; + $ret .= ' in '.basename($traceRec['file']).' on line '.$traceRec['line'].'
'; + + // ensure parameter value is not longer then 200 symbols + foreach ($traceRec['args'] as $argID => $argValue) + { + if( strlen($argValue) > 200 ) $traceRec['args'][$argID] = substr($argValue,0,50).' ...'; + } + $args = highlight_string('', true); + $args = preg_replace('/<\?php (.*)\?>/s','$1',$args); + $ret .= ''; + + $i++; + } + /*$ret = highlight_string('', true); + $ret = preg_replace('/<\?php (.*)\?>/s','$1',$ret);*/ + return $ret; + break; + + default: + return 'incorrect debug data'; + break; + } + } + + function getFileLink($file, $title = '') + { + if(!$title) $title = $file; + return ''.$title.''; + } + + 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 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); + ?> +