_db);
$methdArr = get_class_methods($args[$i]);
if(in_array('unsetForDebug', $methdArr) ){
//echo 'call unsest for debug';
$args[$i]->unsetForDebug();
$reset = true;
}
if(!empty($methdArr) and is_array($methdArr) and count($methdArr)>0){
$methods = print_r($methdArr,1);
$methods = '
'.$methods;
}
}
$debugdescr .= ' Var'.$i.':
'.print_r($args[$i],1).$methods.''."\n"; if($reset and in_array('resetForDebug', $methdArr) ){ $args[$i]->resetForDebug(); } } } return $debugdescr; } } function vmInfo($publicdescr,$value=NULL){ $app = JFactory::getApplication(); $msg = ''; $type = vmEcho::$mType;//'info'; if(vmEcho::$maxMessageCount
'; debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,$trace); echo ''; $body = ob_get_contents(); ob_end_clean(); } logInfo($adminmsg.$body,'error'); if(vmEcho::$maxMessageCount< (vmEcho::$maxMessage+5)){ if(vmEcho::$echoAdmin){ $msg = $adminmsg; } else { if(!empty($publicdescr)){ $msg = $lang->_($publicdescr); } } } else { if (vmEcho::$maxMessageCount == (vmEcho::$maxMessage+5)) { $msg = 'Max messages reached'; vmEcho::$maxMessageCount++; } else { return false; } } if(!empty($msg)){ vmEcho::$maxMessageCount++; if(vmEcho::$echoDebug){ vmEcho::$maxMessageCount++; echo $msg."\n"; }else { vmEcho::$maxMessageCount++; $app = JFactory::getApplication(); $app ->enqueueMessage($msg,'error'); } return $msg; } return $msg; } /** * A debug dumper for VM, it is only shown to backend users. * * @author Max Milbers * @param String $descr * @param various $values */ function vmdebug($debugdescr,$debugvalues=NULL){ if(vmEcho::$_debug){ if(vmEcho::$maxMessageCount
'; debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,$args); echo ''; $body = ob_get_contents(); ob_end_clean(); if(vmEcho::$logDebug){ logInfo($body,$notice); } if(vmEcho::$_debug){ if(vmEcho::$echoDebug){ echo $notice.'
'.$body.''; } $app = JFactory::getApplication(); $app ->enqueueMessage(''.vmEcho::$maxMessageCount.' vmTrace '.$notice.' '.$body.''); } } } function vmRam($notice,$value=NULL){ vmdebug($notice.' used Ram '.round(memory_get_usage(TRUE)/(1024*1024),2).'M ',$value); } function vmRamPeak($notice,$value=NULL){ vmdebug($notice.' memory peak '.round(memory_get_peak_usage(TRUE)/(1024*1024),2).'M ',$value); } function vmStartTimer($n='cur'){ vmEcho::$_starttime[$n]['t'] = microtime(TRUE); } function vmSetStartTime($n='cur', $t = 0){ if($t === 0){ vmEcho::$_starttime[$n]['t'] = microtime(TRUE); } else { vmEcho::$_starttime[$n]['t'] = $t; } } function vmTime( $descr, $name='cur', $sum = true, $output = true){ static $dt = 0.0; if (empty($descr)) { $descr = $name; } //$starttime = vmEcho::$_starttime ; if(empty(vmEcho::$_starttime[$name]['t'])){ vmdebug('vmTime: '.$descr.' starting '.microtime(TRUE)); vmEcho::$_starttime[$name] = array(); vmEcho::$_starttime[$name]['t'] = microtime(TRUE); } else { $t = microtime (TRUE); $dt = ( $t - vmEcho::$_starttime[$name]['t'] ); if(!isset(vmEcho::$_starttime[$name]['Z'])){ vmEcho::$_starttime[$name]['Z'] = $dt; } else { vmEcho::$_starttime[$name]['Z'] += $dt; } if($sum) $dt = vmEcho::$_starttime[$name]['Z']; if ($name == 'cur') { if($output) vmdebug ('vmTime: ' . $descr . ' time consumed ' . $dt); vmEcho::$_starttime[$name]['t'] = microtime (TRUE); } else { $tmp = 'vmTime: ' . $descr . ': ' . $dt; if($output) vmdebug ($tmp); //if($reset) vmEcho::$_starttime[$name]['t'] = $t; } } return $dt; } /** * logInfo * to help debugging Payment notification for example */ function logInfo ($text, $type = 'message') { static $file = null; //vmSetStartTime('logInfo'); $head = false; if($file===null){ $config = JFactory::getConfig(); $log_path = $config->get('log_path', VMPATH_ROOT . "/log" ); $file = $log_path . "/" . vmEcho::$logFileName . vmEcho::LOGFILEEXT; if (!is_dir($log_path)) { jimport('joomla.filesystem.folder'); if (!JFolder::create($log_path)) { if (vmEcho::$echoAdmin){ $msg = 'Could not create path ' . $log_path . ' to store log information. Check your folder ' . $log_path . ' permissions.'; $app = JFactory::getApplication(); $app->enqueueMessage($msg, 'error'); } return; } } if (!is_writable($log_path)) { if (vmEcho::$echoAdmin){ $msg = 'Path ' . $log_path . ' to store log information is not writable. Check your folder ' . $log_path . ' permissions.'; $app = JFactory::getApplication(); $app->enqueueMessage($msg, 'error'); } return; } if (!JFile::exists($file)) { // blank line to prevent information disclose: https://bugs.php.net/bug.php?id=60677 // from Joomla log file $head = "#\n"; $head .= '#'."\n"; } } // Initialise variables. /*if(!class_exists('JClientHelper')) require(VMPATH_LIBS.'/joomla/client/helper.php'); $FTPOptions = JClientHelper::getCredentials('ftp'); if (!empty($FTPOptions['enabled'] == 0)){ //For logging we do not support FTP. For loggin without file permissions using FTP, we need to load the file,.. //append the text and replace the file. This cannot be fast per FTP and therefore we disable it. } else {*/ $fp = fopen ($file, 'a'); if ($fp) { if ($head) { fwrite ($fp, $head); } fwrite ($fp, "\n" . JFactory::getDate()->format ('Y-m-d H:i:s')); fwrite ($fp, " ".strtoupper($type) . ' ' . vRequest::vmSpecialChars($text)); fclose ($fp); } else { if (vmEcho::$echoAdmin){ $msg = 'Could not write in file ' . $file . ' to store log information. Check your file ' . $file . ' permissions.'; $app = JFactory::getApplication(); $app->enqueueMessage($msg, 'error'); } } //} //vmTime('time','logInfo'); return; }