Index: trunk/core/kernel/session/session.php =================================================================== diff -u -N -r4758 -r4821 --- trunk/core/kernel/session/session.php (.../session.php) (revision 4758) +++ trunk/core/kernel/session/session.php (.../session.php) (revision 4821) @@ -233,6 +233,14 @@ $sql = 'DELETE FROM '.$this->TableName.$where_clause; $this->Conn->Query($sql); + + // delete debugger ouputs left of expired sessions + foreach ($expired_sids as $expired_sid) { + $debug_file = KERNEL_PATH.'/../cache/debug_@'.$expired_sid.'@.txt'; + if (file_exists($debug_file)) { + @unlink($debug_file); + } + } } return $expired_sids; } Index: trunk/kernel/admin_templates/index.tpl =================================================================== diff -u -N -r4490 -r4821 --- trunk/kernel/admin_templates/index.tpl (.../index.tpl) (revision 4490) +++ trunk/kernel/admin_templates/index.tpl (.../index.tpl) (revision 4821) @@ -1,4 +1,5 @@ + Index: trunk/core/kernel/utility/debugger/debugger.js =================================================================== diff -u -N --- trunk/core/kernel/utility/debugger/debugger.js (revision 0) +++ trunk/core/kernel/utility/debugger/debugger.js (revision 4821) @@ -0,0 +1,257 @@ +function Req() {} + +Req.timeout = 5000; //5 seconds + +Req.makeRequest = function(p_url, p_busyReq, p_progId, p_successCallBack, p_errorCallBack, p_pass) { + //p_url: the web service url + //p_busyReq: is a request for this object currently in progress? + //p_progId: element id where progress HTML should be shown + //p_successCallBack: callback function for successful response + //p_errorCallBack: callback function for erroneous response + //p_pass: string of params to pass to callback functions + if (p_busyReq) return; + var req = Req.getRequest(); + if (req != null) { + p_busyReq = true; + Req.showProgress(p_progId); + req.onreadystatechange = function() { + if (req.readyState == 4) { + p_busyReq = false; + window.clearTimeout(toId); + if (req.status == 200) { + p_successCallBack(req,p_pass); + } else { + p_errorCallBack(req,p_pass); + } + } + } + req.open('GET', p_url, true); + req.send(null); + var toId = window.setTimeout( function() {if (p_busyReq) req.abort();}, Req.timeout ); + } +} + +Req.getRequest = function() { + var xmlHttp; + try { xmlHttp = new ActiveXObject('MSXML2.XMLHTTP'); return xmlHttp; } catch (e) {} + try { xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); return xmlHttp; } catch (e) {} + try { xmlHttp = new XMLHttpRequest(); return xmlHttp; } catch(e) {} + return null; +} + +Req.showProgress = function(p_id) { + $Debugger.AppendRow(Req.getProgressHtml()); +} + +Req.getProgressHtml = function() { + return 'Loading ...'; +} + +Req.getErrorHtml = function(p_req) { + //TODO: implement accepted way to handle request error + return "

" + "(" + p_req.status + ") " + p_req.statusText + "

" +} + +// Debugger +function Debugger() { + this.IsQueried = false; + this.IsVisible = false; + /*this.DOMViewerURL = ''; + this.EditorPath = '';*/ + this.DebuggerDIV = document.getElementById('debug_layer'); + this.DebuggerTable = document.getElementById('debug_table'); + this.RowCount = 0; + /*this.RowSeparator = 'rowSeparator; ?>'; + this.DebugURL = '';*/ + +// window.$Debugger = this; // this should be uncommented in case if debugger variable is not $Debugger + window.onscroll = function(ev) { window.$Debugger.Resize(ev); } + window.onresize = function(ev) { window.$Debugger.Resize(ev); } + document.onkeydown = function(ev) { window.$Debugger.KeyDown(ev); } +} + +Debugger.prototype.AppendRow = function($html) { + this.RowCount++; + var $tr = document.createElement('TR'); + this.DebuggerTable.appendChild($tr); + $tr.className = 'debug_row_' + (this.RowCount % 2 ? 'odd' : 'even'); + $tr.id = 'debug_row_' + this.RowCount; + var $td = document.createElement('TD'); + $tr.appendChild($td); + $td.className = 'debug_cell'; + $td.innerHTML = $html; +} + +Debugger.prototype.KeyDown = function($e) { + var $KeyCode = this.GetKeyCode($e); + if ($KeyCode == 123 || $KeyCode == 27) {// F12 or ESC + this.Toggle($KeyCode); + this.StopEvent($e); + } +} + +Debugger.prototype.OpenDOMViewer = function() { + var $value = document.getElementById('dbg_domviewer').value; + DOMViewerObj = ($value.indexOf('"') != -1) ? document.getElementById( $value.substring(1,$value.length-1) ) : eval($value); + window.open(this.DOMViewerURL); + return false; +} + +Debugger.prototype.GetKeyCode = function($e) { + $e = ($e) ? $e : event; + var target = ($e.target) ? $e.target : $e.scrElement; + var charCode = ($e.charCode) ? $e.charCode : (($e.which) ? $e.which : $e.keyCode); + return charCode; +} + +Debugger.prototype.StopEvent = function($e) { + $e = ($e) ? $e : event; + $e.cancelBubble = true; + if ($e.stopPropagation) $e.stopPropagation(); +} + +Debugger.prototype.Toggle = function($KeyCode) { + if(!this.DebuggerDIV) return false; + + this.IsVisible = this.DebuggerDIV.style.display == 'none' ? false : true; + if (!this.IsVisible && $KeyCode == 27) { + return false; + } + + this.Resize(null); + if (!this.IsQueried) { + this.Query(); + } + + this.DebuggerDIV.style.display = this.IsVisible ? 'none' : 'block'; +} + +Debugger.prototype.Query = function() { + Req.makeRequest(this.DebugURL, this.busyReq, '', this.successCallback, this.errorCallback, ''); +} + +Debugger.prototype.successCallback = function(p_req, p_pass) { + var contents = p_req.responseText; + + contents = contents.split($Debugger.RowSeparator); + if (contents.length == 1) { + alert('error: '+p_req.responseText); + $Debugger.IsQueried = true; + return ; + } + + for (var $i = 0; $i < contents.length - 1; $i++) { + $Debugger.AppendRow(contents[$i]); + } + + // where progress mether is + document.getElementById('debug_row_1').style.display = 'none'; + $Debugger.IsQueried = true; + $Debugger.Refresh(); +} + +Debugger.prototype.Refresh = function() { + this.DebuggerDIV.scrollTop = this.IsFatalError ? 10000000 : 0; +} + +Debugger.prototype.errorCallback = function(p_req, p_pass) { + alert('AJAX ERROR: '+Req.getErrorHtml(p_req)); +} + +Debugger.prototype.Resize = function($e) { + if (!this.DebuggerDIV) return false; + var $pageTop = document.all ? document.body.offsetTop + document.body.scrollTop : window.scrollY; + + this.DebuggerDIV.style.top = $pageTop + 'px'; + this.DebuggerDIV.style.height = GetWindowHeight() + 'px'; + return true; +} + +function GetWindowHeight() { + var currWinHeight; + if (window.innerHeight) {//FireFox with correction for status bar at bottom of window + currWinHeight = window.innerHeight - 10; + } else if (document.documentElement.clientHeight) {//IE 7 with correction for address bar + currWinHeight = document.documentElement.clientHeight - 10; + } else if (document.body.offsetHeight) {//IE 4+ + currWinHeight = document.body.offsetHeight - 5 + 15 - 10; // + 10 + } + return currWinHeight; +} + + +/*function GetWinHeight() { + if (window.innerHeight) return window.innerHeight; + else if (document.documentElement.clientHeight) return document.documentElement.clientHeight; + else if (document.body.offsetHeight) return document.body.offsetHeight; + else return _winHeight; +}*/ + +Debugger.prototype.SetClipboard = function(copyText) { + if (window.clipboardData) { + // IE send-to-clipboard method. + window.clipboardData.setData('Text', copyText); + } + else if (window.netscape) { + // You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true); + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + + // Store support string in an object. + var str = Components.classes['@mozilla.org/supports-string;1'].createInstance(Components.interfaces.nsISupportsString); + if (!str) { + return false; + } + str.data = copyText; + + // Make transferable. + var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); + if (!trans) { + return false; + } + + // Specify what datatypes we want to obtain, which is text in this case. + trans.addDataFlavor('text/unicode'); + trans.setTransferData('text/unicode', str, copyText.length * 2); + + var clipid = Components.interfaces.nsIClipboard; + var clip = Components.classes['@mozilla.org/widget/clipboard;1'].getService(clipid); + if (!clip) { + return false; + } + + clip.setData(trans, null, clipid.kGlobalClipboard); + } +} + +Debugger.prototype.ShowProps = function($Obj, $Name) { + var $ret = ''; + for ($Prop in $Obj) { + $ret += $Name + '.' + $Prop + ' = ' + $Obj[$Prop] + "\n"; + } + return alert($ret); +} + +Debugger.prototype.editFile = function($fileName, $lineNo) { + if (!document.all) { + alert('Only works in IE'); + return; + } + + if (!this.EditorPath) { + alert('Editor path not defined!'); + return; + } + + var $launch_object = new ActiveXObject('LaunchinIE.Launch'); + var $editor_path = this.EditorPath; + $editor_path = $editor_path.replace('%F', $fileName); + $editor_path = $editor_path.replace('%L',$lineNo); + $launch_object.LaunchApplication($editor_path); +} + +Debugger.prototype.ToggleTraceArgs = function($arguments_layer_id) { + var $arguments_layer = document.getElementById($arguments_layer_id); + $arguments_layer.style.display = ($arguments_layer.style.display == 'none') ? 'block' : 'none'; +} + + \ No newline at end of file Index: trunk/core/kernel/utility/debugger.php =================================================================== diff -u -N -r4819 -r4821 --- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 4819) +++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 4821) @@ -96,10 +96,32 @@ var $reportDone = false; var $dummyImage = ''; - + + /** + * Folder for holding AJAX temporary file + * + * @var string + */ + var $tempFolder = ''; + + /** + * Debug rows will be separated using this string before writing to debug file + * + * @var string + */ + var $rowSeparator = '@@'; + + /** + * Base URL for debugger includes + * + * @var string + */ + var $baseURL = ''; + function Debugger() { $this->dummyImage = PROTOCOL.SERVER_NAME.(defined('PORT')?':'.PORT : '').rtrim(BASE_PATH, '/').'/'.'kernel/admin_templates/img/spacer.gif'; + $this->tempFolder = FULL_PATH.'/kernel/cache'; global $start; $this->profileStart('kernel4_startup', 'Startup and Initialization of kernel4', $start); @@ -112,6 +134,18 @@ $this->appendRequest(); } + function InitReport() + { + if (!class_exists('kApplication')) return false; + + $application =& kApplication::Instance(); + $this->rowSeparator = '@'.$application->GetSID().'@'; + + $reg_exp = '/^'.preg_quote(FULL_PATH, '/').'/'; + $kernel_path = preg_replace($reg_exp, '', KERNEL_PATH, 1); + $this->baseURL = PROTOCOL.SERVER_NAME.rtrim(BASE_PATH, '/').$kernel_path.'/utility/debugger'; + } + function mapLongError($msg) { $key = $this->generateID(); @@ -572,7 +606,7 @@ break; } } - + /** * Generates report * @@ -588,6 +622,9 @@ if (defined('SPACER_URL')) { $this->dummyImage = SPACER_URL; } + + $this->InitReport(); + dbg_safeDefine('DBG_RAISE_ON_WARNINGS', 0); $this->memoryUsage['debugger_start'] = memory_get_usage(); @@ -610,7 +647,7 @@ if (dbg_ConstOn('DBG_PROFILE_MEMORY')) { $this->appendHTML('Memory used by Objects: '.round($this->ProfilerTotals['objects']/1024, 2).'Kb'); } - + /*if( dbg_ConstOn('DBG_INCLUDED_FILES') ) { $files = get_included_files(); @@ -647,268 +684,40 @@ } }*/ + + $i = 0; + $lineCount = count($this->Data); + + $debug_file = $this->tempFolder.'/debug_'.$this->rowSeparator.'.txt'; + if (file_exists($debug_file)) unlink($debug_file); + + $fp = fopen($debug_file, 'a'); + while ($i < $lineCount) { + fwrite($fp, $this->prepareHTML($i).$this->rowSeparator); + $i++; + } + fclose($fp); + + ob_start(); - ?> - - -