protected function _prepareTpl() { // Get the project and repository params $project = $this->param('project'); $repository = $this->param('repository'); // Get lizmapProject class $assign = array("edition" => false, "measure" => false, "locate" => false, "geolocation" => false, "timemanager" => false, "print" => false, "attributeLayers" => false); try { $lproj = lizmap::getProject($repository . '~' . $project); $configOptions = $lproj->getOptions(); if (property_exists($configOptions, 'measure') && $configOptions->measure == 'True') { $assign['measure'] = true; } $assign['locate'] = $lproj->hasLocateByLayer(); if (property_exists($configOptions, 'print') && $configOptions->print == 'True') { $assign['print'] = true; } $assign['edition'] = $lproj->hasEditionLayers(); if (property_exists($configOptions, 'geolocation') && $configOptions->geolocation == 'True') { $assign['geolocation'] = true; } $assign['timemanager'] = $lproj->hasTimemanagerLayers(); $assign['attributeLayers'] = $lproj->hasAttributeLayers(); } catch (UnknownLizmapProjectException $e) { jLog::logEx($e, 'error'); } $this->_tpl->assign($assign); }
function show($debugbar) { $info = new debugbarItemInfo('soaplog', 'Soap logs'); $info->htmlLabel = 'Soap '; $messages = jLog::getMessages(array('soap')); $c = count($messages); $info->htmlLabel .= $c; if ($c == 0) { $info->label = 'no message'; } else { $c = jLog::getMessagesCount('soap'); if ($c > count($messages)) { $info->popupContent .= '<p class="jxdb-msg-warning">There are ' . $c . ' soap requests. Only ' . count($messages) . ' first of them are shown.</p>'; } $info->popupContent .= '<ul id="jxdb-soaplog" class="jxdb-list">'; foreach ($messages as $msg) { if (get_class($msg) != 'jLogSoapMessage') { continue; } $info->popupContent .= '<li> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($msg->getMessage()) . '</span></a></h5> <div>'; $info->popupContent .= "<h6>Headers</h6><pre>" . $msg->getHeaders() . "</pre>"; $info->popupContent .= "<h6>Request</h6><pre>" . $this->xmlprettyprint($msg->getRequest()) . "</pre>"; $info->popupContent .= "<h6>Response</h6><pre>" . $this->xmlprettyprint($msg->getResponse()) . "</pre>"; $info->popupContent .= '</div></li>'; } $info->popupContent .= '</ul>'; } $debugbar->addInfo($info); }
protected function _prepareTpl() { // Get the project and repository params $project = $this->param('project'); $repository = $this->param('repository'); $auth_url_return = $this->param('auth_url_return'); if (!$auth_url_return) { $auth_url_return = jUrl::get('view~map:index', array("repository" => $repository, "project" => $project)); } // Get lizmapProject class $assign = array('isConnected' => jAuth::isConnected(), 'user' => jAuth::getUserSession(), 'auth_url_return' => $auth_url_return, "externalSearch" => "", "edition" => false, "measure" => false, "locate" => false, "geolocation" => false, "timemanager" => false, "print" => false, "attributeLayers" => false); try { $lproj = lizmap::getProject($repository . '~' . $project); $configOptions = $lproj->getOptions(); if (property_exists($configOptions, 'externalSearch')) { $assign['externalSearch'] = $configOptions->externalSearch; } } catch (UnknownLizmapProjectException $e) { jLog::logEx($e, 'error'); } $this->_tpl->assign($assign); // Get lizmap services $services = lizmap::getServices(); if ($services->allowUserAccountRequests) { $this->_tpl->assign('allowUserAccountRequests', True); } }
public function __soapCall($function_name, $arguments, $options = array(), $input_headers = null, &$output_headers = null) { $result = parent::__soapCall($function_name, $arguments, $options, $input_headers, $output_headers); $log = new jLogSoapMessage($function_name, $this, 'soap'); jLog::log($log, 'soap'); return $result; }
public function beforeAction($params) { if (isset($params['traceexec.log_session'])) { $this->config['log_session'] = $params['traceexec.log_session']; } if (isset($params['traceexec.enabled'])) { $this->config['enable_trace'] = $params['traceexec.enabled']; } if (isset($this->config['enable_trace']) && $this->config['enable_trace'] == true) { $coord = jApp::coord(); $moduleName = $coord->moduleName; $actionName = $coord->actionName; $message = $moduleName . '~' . $actionName; //Url $message .= "\nUrl : " . $_SERVER['REQUEST_URI']; //Module & action $message .= "\nModule : " . $moduleName; $message .= "\nAction : " . $actionName; //Params $r_params = $coord->request->params; unset($r_params['module']); unset($r_params['action']); if (empty($r_params)) { $message .= "\nNo params"; } else { $message .= "\nParams : " . var_export($r_params, true); } //Session if (isset($this->config['log_session']) && $this->config['log_session'] == true) { $message .= "\nSession : " . var_export($_SESSION, true); } $message .= "\n"; jLog::log($message, 'trace'); } }
public function exec($query) { $log = new jSQLLogMessage($query); $result = parent::exec($query); $log->endQuery(); jLog::log($log, 'sql'); return $result; }
protected function debug($msg, $object = false) { if ($this->debug) { if ($object) { jLog::dump($object, 'jhttp debug, ' . $msg); } else { jLog::log('jhttp debug, ' . $msg); } } }
function show($debugbarPlugin) { $info = new debugbarItemInfo('errors', 'Errors'); $messages = jLog::getMessages(array('error', 'warning', 'notice', 'deprecated', 'strict')); if (!jLog::isPluginActivated('memory', 'error')) { array_unshift($messages, new jLogErrorMessage('warning', 0, "Memory logger is not activated in jLog for errors, You cannot see them", '', 0, array())); } if (!jLog::isPluginActivated('memory', 'warning')) { array_unshift($messages, new jLogErrorMessage('warning', 0, "Memory logger is not activated in jLog for warnings, You cannot see them", '', 0, array())); } if (!jLog::isPluginActivated('memory', 'notice')) { array_unshift($messages, new jLogErrorMessage('notice', 0, "Memory logger is not activated in jLog for notices, You cannot see them", '', 0, array())); } $c = count($messages); if ($c == 0) { $info->label = 'no error'; #expand $info->htmlLabel = '<img src="data:image/png;base64,__LOGONOERROR__" alt="no errors" title="no errors"/> 0'; } else { $info->popupContent = '<ul id="jxdb-errors" class="jxdb-list">'; $maxLevel = 0; $currentCount = array('error' => 0, 'warning' => 0, 'notice' => 0, 'deprecated' => 0, 'strict' => 0); foreach ($messages as $msg) { if ($msg instanceof jLogErrorMessage) { $cat = $msg->getCategory(); $currentCount[$cat]++; if ($cat == 'error') { $maxLevel = 1; } // careful: if you change the position of the div, update debugbar.js $info->popupContent .= '<li class="jxdb-msg-' . $cat . '"> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($msg->getMessage()) . '</span></a></h5> <div><p>Code: ' . $msg->getCode() . '<br/> File: ' . htmlspecialchars($msg->getFile()) . ' ' . htmlspecialchars($msg->getLine()) . '</p>'; $info->popupContent .= $debugbarPlugin->formatTrace($msg->getTrace()); $info->popupContent .= '</div></li>'; } } if ($maxLevel) { $info->htmlLabel = '<img src="' . $this->getErrorIcon() . '" alt="Errors" title="' . $c . ' errors"/> ' . $c; $info->popupOpened = true; } else { $info->htmlLabel = '<img src="' . $this->getWarningIcon() . '" alt="Warnings" title="There are ' . $c . ' warnings" /> ' . $c; } $info->popupContent .= '</ul>'; foreach ($currentCount as $type => $count) { if (($c = jLog::getMessagesCount($type)) > $count) { $info->popupContent .= '<p class="jxdb-msg-warning">There are ' . $c . ' ' . $type . ' messages. Only first ' . $count . ' messages are shown.</p>'; } } } $debugbarPlugin->addInfo($info); }
function show($debugbarPlugin) { $info = new debugbarItemInfo('errors', 'Errors'); $messages = jLog::getMessages(array('error', 'warning', 'notice', 'deprecated', 'strict')); if (!jLog::isPluginActivated('memory', 'error')) { array_unshift($messages, new jLogErrorMessage('warning', 0, "Memory logger is not activated in jLog for errors, You cannot see them", '', 0, array())); } if (!jLog::isPluginActivated('memory', 'warning')) { array_unshift($messages, new jLogErrorMessage('warning', 0, "Memory logger is not activated in jLog for warnings, You cannot see them", '', 0, array())); } if (!jLog::isPluginActivated('memory', 'notice')) { array_unshift($messages, new jLogErrorMessage('notice', 0, "Memory logger is not activated in jLog for notices, You cannot see them", '', 0, array())); } $c = count($messages); if ($c == 0) { $info->label = 'no error'; $info->htmlLabel = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAKfSURBVDjLpZPrS1NhHMf9O3bOdmwDCWREIYKEUHsVJBI7mg3FvCxL09290jZj2EyLMnJexkgpLbPUanNOberU5taUMnHZUULMvelCtWF0sW/n7MVMEiN64AsPD8/n83uucQDi/id/DBT4Dolypw/qsz0pTMbj/WHpiDgsdSUyUmeiPt2+V7SrIM+bSss8ySGdR4abQQv6lrui6VxsRonrGCS9VEjSQ9E7CtiqdOZ4UuTqnBHO1X7YXl6Daa4yGq7vWO1D40wVDtj4kWQbn94myPGkCDPdSesczE2sCZShwl8CzcwZ6NiUs6n2nYX99T1cnKqA2EKui6+TwphA5k4yqMayopU5mANV3lNQTBdCMVUA9VQh3GuDMHiVcLCS3J4jSLhCGmKCjBEx0xlshjXYhApfMZRP5CyYD+UkG08+xt+4wLVQZA1tzxthm2tEfD3JxARH7QkbD1ZuozaggdZbxK5kAIsf5qGaKMTY2lAU/rH5HW3PLsEwUYy+YCcERmIjJpDcpzb6l7th9KtQ69fi09ePUej9l7cx2DJbD7UrG3r3afQHOyCo+V3QQzE35pvQvnAZukk5zL5qRL59jsKbPzdheXoBZc4saFhBS6AO7V4zqCpiawuptwQG+UAa7Ct3UT0hh9p9EnXT5Vh6t4C22QaUDh6HwnECOmcO7K+6kW49DKqS2DrEZCtfuI+9GrNHg4fMHVSO5kE7nAPVkAxKBxcOzsajpS4Yh4ohUPPWKTUh3PaQEptIOr6BiJjcZXCwktaAGfrRIpwblqOV3YKdhfXOIvBLeREWpnd8ynsaSJoyESFphwTtfjN6X1jRO2+FxWtCWksqBApeiFIR9K6fiTpPiigDoadqCEag5YUFKl6Yrciw0VOlhOivv/Ff8wtn0KzlebrUYwAAAABJRU5ErkJggg==" alt="no errors" title="no errors"/> 0'; } else { $info->popupContent = '<ul id="jxdb-errors" class="jxdb-list">'; $maxLevel = 0; $currentCount = array('error' => 0, 'warning' => 0, 'notice' => 0, 'deprecated' => 0, 'strict' => 0); foreach ($messages as $msg) { if ($msg instanceof jLogErrorMessage) { $cat = $msg->getCategory(); $currentCount[$cat]++; if ($cat == 'error') { $maxLevel = 1; } $info->popupContent .= '<li class="jxdb-msg-' . $cat . '"> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($msg->getMessage()) . '</span></a></h5> <div><p>Code: ' . $msg->getCode() . '<br/> File: ' . htmlspecialchars($msg->getFile()) . ' ' . htmlspecialchars($msg->getLine()) . '</p>'; $info->popupContent .= $debugbarPlugin->formatTrace($msg->getTrace()); $info->popupContent .= '</div></li>'; } } if ($maxLevel) { $info->htmlLabel = '<img src="' . $this->getErrorIcon() . '" alt="Errors" title="' . $c . ' errors"/> ' . $c; $info->popupOpened = true; } else { $info->htmlLabel = '<img src="' . $this->getWarningIcon() . '" alt="Warnings" title="There are ' . $c . ' warnings" /> ' . $c; } $info->popupContent .= '</ul>'; foreach ($currentCount as $type => $count) { if (($c = jLog::getMessagesCount($type)) > $count) { $info->popupContent .= '<p class="jxdb-msg-warning">There are ' . $c . ' ' . $type . ' messages. Only first ' . $count . ' messages are shown.</p>'; } } } $debugbarPlugin->addInfo($info); }
function module() { $rep = $this->getResponse('htmlfragment'); $app = $this->param('app', null, true); jLog::dump($app); $rep->tplname = $app . "~param"; $tb = jDao::get("param"); $conditions = jDao::createConditions(); if (!empty($app)) { $conditions->addCondition('app', '=', $app); } $config = $tb->findBy($conditions)->fetch(); $rep->tpl->assign('config', $config); return $rep; }
/** * it should adds content or set some properties on the debugbar * to displays some contents. * @param debugbarHTMLResponsePlugin $debugbar the debugbar */ function show($debugbar) { $info = new debugbarItemInfo('sqllog', 'SQL queries'); $messages = jLog::getMessages('sql'); $info->htmlLabel = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAEYSURBVBgZBcHPio5hGAfg6/2+R980k6wmJgsJ5U/ZOAqbSc2GnXOwUg7BESgLUeIQ1GSjLFnMwsKGGg1qxJRmPM97/1zXFAAAAEADdlfZzr26miup2svnelq7d2aYgt3rebl585wN6+K3I1/9fJe7O/uIePP2SypJkiRJ0vMhr55FLCA3zgIAOK9uQ4MS361ZOSX+OrTvkgINSjS/HIvhjxNNFGgQsbSmabohKDNoUGLohsls6BaiQIMSs2FYmnXdUsygQYmumy3Nhi6igwalDEOJEjPKP7CA2aFNK8Bkyy3fdNCg7r9/fW3jgpVJbDmy5+PB2IYp4MXFelQ7izPrhkPHB+P5/PjhD5gCgCenx+VR/dODEwD+A3T7nqbxwf1HAAAAAElFTkSuQmCC" alt="SQL queries" title="SQL queries"/> '; if (!jLog::isPluginActivated('memory', 'sql')) { $info->htmlLabel .= '?'; $info->label .= 'memory logger is not active'; } else { $realCount = jLog::getMessagesCount('sql'); $currentCount = count($messages); $info->htmlLabel .= $realCount; if ($realCount) { if ($realCount > $currentCount) { $info->popupContent = '<p class="jxdb-msg-warning">Too many queries (' . $realCount . '). Only first ' . $currentCount . ' queries are shown.</p>'; } $sqlDetailsContent = '<ul id="jxdb-sqllog" class="jxdb-list">'; $totalTime = 0; foreach ($messages as $msg) { if (get_class($msg) != 'jSQLLogMessage') { continue; } $dao = $msg->getDao(); if ($dao) { $m = 'DAO ' . $dao; } else { $m = substr($msg->getMessage(), 0, 50) . ' [...]'; } $msgTime = $msg->getTime(); $totalTime += $msgTime; $sqlDetailsContent .= '<li> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($m) . '</span></a></h5> <div> <p>Time: ' . $msgTime . 's</p>'; $sqlDetailsContent .= '<pre style="white-space:pre-wrap">' . htmlspecialchars($msg->getMessage()) . '</pre>'; if ($msg->getMessage() != $msg->originalQuery) { $sqlDetailsContent .= '<p>Original query: </p><pre style="white-space:pre-wrap">' . htmlspecialchars($msg->originalQuery) . '</pre>'; } $sqlDetailsContent .= $debugbar->formatTrace($msg->getTrace()); $sqlDetailsContent .= '</div></li>'; } $sqlDetailsContent .= '</ul>'; $info->popupContent .= '<div>Total SQL time : ' . $totalTime . 's</div>'; $info->popupContent .= $sqlDetailsContent; } } $debugbar->addInfo($info); }
/** * it should adds content or set some properties on the debugbar * to displays some contents. * @param debugbarHTMLResponsePlugin $debugbar the debugbar */ function show($debugbar) { $info = new debugbarItemInfo('sqllog', 'SQL queries'); $messages = jLog::getMessages('sql'); $info->htmlLabel = '<img src="data:image/png;base64,' . base64_encode(file_get_contents(__DIR__ . '/../../htmlresponse/debugbar/icons/database.png')) . '" alt="SQL queries" title="SQL queries"/> '; if (!jLog::isPluginActivated('memory', 'sql')) { $info->htmlLabel .= '?'; $info->label .= 'memory logger is not active'; } else { $realCount = jLog::getMessagesCount('sql'); $currentCount = count($messages); $info->htmlLabel .= $realCount; if ($realCount) { if ($realCount > $currentCount) { $info->popupContent = '<p class="jxdb-msg-warning">Too many queries (' . $realCount . '). Only first ' . $currentCount . ' queries are shown.</p>'; } $sqlDetailsContent = '<ul id="jxdb-sqllog" class="jxdb-list">'; $totalTime = 0; foreach ($messages as $msg) { if (get_class($msg) != 'jSQLLogMessage') { continue; } $dao = $msg->getDao(); if ($dao) { $m = 'DAO ' . $dao; } else { $m = substr($msg->getMessage(), 0, 50) . ' [...]'; } $msgTime = $msg->getTime(); $totalTime += $msgTime; $sqlDetailsContent .= '<li> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($m) . '</span></a></h5> <div> <p>Time: ' . $msgTime . 's</p>'; $sqlDetailsContent .= '<pre style="white-space:pre-wrap">' . htmlspecialchars($msg->getMessage()) . '</pre>'; if ($msg->getMessage() != $msg->originalQuery) { $sqlDetailsContent .= '<p>Original query: </p><pre style="white-space:pre-wrap">' . htmlspecialchars($msg->originalQuery) . '</pre>'; } $sqlDetailsContent .= $debugbar->formatTrace($msg->getTrace()); $sqlDetailsContent .= '</div></li>'; } $sqlDetailsContent .= '</ul>'; $info->popupContent .= '<div>Total SQL time : ' . $totalTime . 's</div>'; $info->popupContent .= $sqlDetailsContent; } } $debugbar->addInfo($info); }
public function getLabel2($key, $form) { $criteria = $form->getData($this->criteriaFrom[0]); if ($criteria && array_key_exists($criteria, $this->data)) { try { $p = lizmap::getProject($criteria . '~' . $key); if ($p) { return (string) $p->getData('title'); } } catch (UnknownLizmapProjectException $e) { jLog::logEx($e, 'error'); return null; } } return null; }
public function testLogFile() { $file = jApp::logPath('test.log'); if (file_exists($file)) { file_put_contents($file, ''); } global $gJConfig; $gJConfig->logger['test'] = 'file'; $gJConfig->fileLogger['test'] = 'test.log'; jLog::log('aaa', 'test'); $this->assertTrue(file_exists($file)); $this->assertTrue(strpos(file_get_contents($file), 'aaa') !== false); jLog::log('bbb', 'test'); $this->assertTrue(strpos(file_get_contents($file), 'aaa') !== false); $this->assertTrue(strpos(file_get_contents($file), 'bbb') !== false); }
function unpackUpdate($file) { $zip = new ZipArchive(); $zip->open($file); //$zip->extractTo(jApp::appPath()); jLog::dump(jApp::appPath()); $src = jApp::appPath() . 'var/uploads/' . uniqid(); $zip->extractTo($src); //modules bos copy($src . '/project.xml', jApp::appPath() . 'project.xml'); copy($src . '/responses/myHtmlResponse.class.php', jApp::appPath() . 'responses/myHtmlResponse.class.php'); copy($src . '/responses/myJsResponse.class.php', jApp::appPath() . 'responses/myJsResponse.class.php'); copy($src . '/modules/extension/', jApp::appPath() . 'modules/extension/'); copy($src . '/modules/user/', jApp::appPath() . 'modules/user/'); copy($src . '/modules/bos/', jApp::appPath() . 'modules/bos/'); copy($src . '/modules/chat/', jApp::appPath() . 'modules/chat/'); }
/** * The rules of the forum */ function rules() { $gJConfig = jApp::config(); $tpl = new jTpl(); if ($gJConfig->havefnubb['rules'] != '') { $rep = $this->getResponse('html'); $tpl->assign('rules', $gJConfig->havefnubb['rules']); $rep->body->assign('MAIN', $tpl->fetch('havefnubb~rules')); } else { jLog::log(__METHOD__ . ' line : ' . __LINE__ . ' [this action should not be used] rules are empty', 'DEBUG'); $rep = $this->getResponse('html', true); $rep->bodyTpl = 'havefnubb~404.html'; $rep->setHttpStatus('404', 'Not Found'); return $rep; } return $rep; }
/** * Use DynamicLayers python plugin to get a child project * And redirect to Lizmap view map controller with changed project parameter */ function index() { // Set up redirect response $rep = $this->getResponse('redirect'); $rep->action = 'view~map:index'; $params = jApp::coord()->request->params; $rep->params = $params; // Redirect to normal map if no suitable parameters if (!$params['dlsourcelayer'] or !$params['dlexpression']) { jLog::log('Dynamic layers - no parameters DLSOURCELAYER or DLEXPRESSION'); return $rep; } // Get project path $project = $params['project']; $repository = $params['repository']; $lrep = lizmap::getRepository($repository); $projectTemplatePath = realpath($lrep->getPath()) . '/' . $project . ".qgs"; // Use QGIS python plugins dynamicLayers to get child project $lizmapServices = lizmap::getServices(); $url = $lizmapServices->wmsServerURL . '?'; $qparams = array(); $qparams['service'] = 'dynamicLayers'; $qparams['map'] = $projectTemplatePath; $qparams['dlsourcelayer'] = $params['dlsourcelayer']; $qparams['dlexpression'] = $params['dlexpression']; $rparams = http_build_query($qparams); $querystring = $url . $rparams; // Get remote data $lizmapCache = jClasses::getService('lizmap~lizmapCache'); $getRemoteData = $lizmapCache->getRemoteData($querystring, $this->services->proxyMethod, $this->services->debugMode); $data = $getRemoteData[0]; $mime = $getRemoteData[1]; // Get returned response and redirect to appropriate project page $json = json_decode($data); if ($json->status == 0) { jLog::log('DynamicLayers error : ' . $json->message); } else { $params['project'] = preg_replace('#\\.qgs$#', '', $json->childProject); unset($params['dlsourcelayer']); unset($params['dlexpression']); $rep->params = $params; jLog::log('DynamicLayers message : ' . $json->message . ' - ' . $json->childProject); } return $rep; }
/** * */ function view() { $lang = jLocale::getCurrentLang(); $name = $this->param('name'); jLog::log("lang: {$lang} / name: {$name}"); $rep = $this->getResponse('html'); jLog::log("Name of fame: " . $this->param('name')); $articles = jClasses::getService('amigatlk~articles'); jLog::log(" " . get_class($articles)); $article = $articles->getArticle($this->param('name')); if (empty($article)) { $rep->body->assignZone('MAIN', 'amigatlk~notFound404'); $rep->setHttpStatus('404', 'Not Found'); return $rep; } $rep->title = $article->title; $rep->body->assignZone('MAIN', 'amigatlk~viewArticle', array('article' => $article)); return $rep; }
public function getContent($name) { $tpl = new jTpl(); $tpl->assign('lang', jLocale::getCurrentLang()); $name = str_replace('-', '_', $name); $tplName = 'amigatlk~' . $name; try { $content = $tpl->fetch($tplName, 'text', true, false); } catch (Exception $e) { jLog::log("fetch() return: " . $e->getMessage()); return; } $lines = explode("\n", $content); $item = new stdClass(); $item->title = trim(array_shift($lines)); $item->content = $lines; //jLog::dump($item); return $item; }
/** * it should adds content or set some properties on the debugbar * to displays some contents. * @param debugbarHTMLResponsePlugin $debugbar the debugbar */ function show($debugbar) { $info = new debugbarItemInfo('defaultlog', 'General logs'); $info->htmlLabel = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAIASURBVDjLpVPPaxNREJ6Vt01caH4oWk1T0ZKlGIo9RG+BUsEK4kEP/Q8qPXnpqRdPBf8A8Wahhx7FQ0GF9FJ6UksqwfTSBDGyB5HkkphC9tfb7jfbtyQQTx142byZ75v5ZnZWC4KALmICPy+2DkvKIX2f/POz83LxCL7nrz+WPNcll49DrhM9v7xdO9JW330DuXrrqkFSgig5iR2Cfv3t3gNxOnv5BwU+eZ5HuON5/PMPJZKJ+yKQfpW0S7TxdC6WJaWkyvff1LDaFRAeLZj05MHsiPTS6hua0PUqtwC5sHq9zv9RYWl+nu5cETcnJ1M0M5WlWq3GsX6/T+VymRzHDluZiGYAAsw0TQahV8uyyGq1qFgskm0bHIO/1+sx1rFtchJhArwEyIQ1Gg2WD2A6nWawHQJVDIWgIJfLhQowTIeE9D0mKAU8qPC0220afsWFQoH93W6X7yCDJ+DEBeBmsxnPIJVKxWQVUwry+XyUwBlKMKwA8jqdDhOVCqVAzQDVvXAXhOdGBFgymYwrGoZBmUyGjxCCdF0fSahaFdgoTHRxfTveMCXvWfkuE3Y+f40qhgT/nMitupzApdvT18bu+YeDQwY9Xl4aG9/d/URiMBhQq/dvZMeVghtT17lSZW9/rAKsvPa/r9Fc2dw+Pe0/xI6kM9mT5vtXy+Nw2kU/5zOGRpvuMIu0YAAAAABJRU5ErkJggg==" alt="General logs" title="General logs"/> '; $messages = jLog::getMessages(array('default', 'debug')); $c = count($messages); $info->htmlLabel .= $c; if ($c == 0) { $info->label = 'no message'; } else { $info->popupContent = '<ul id="jxdb-defaultlog" class="jxdb-list">'; $currentCount = array('default' => 0, 'debug' => 0); foreach ($messages as $msg) { $cat = $msg->getCategory(); $currentCount[$cat]++; $title = $msg->getFormatedMessage(); $truncated = false; if (strlen($title) > 60) { $truncated = true; $title = substr($title, 0, 60) . '...'; } $info->popupContent .= '<li> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($title) . '</span></a></h5> <div>'; if ($truncated) { if ($msg instanceof jLogDumpMessage) { $info->popupContent .= "<pre>" . htmlspecialchars($msg->getMessage()) . '</pre>'; } else { $info->popupContent .= htmlspecialchars($msg->getMessage()); } } $info->popupContent .= '</div></li>'; } $info->popupContent .= '</ul>'; foreach ($currentCount as $type => $count) { if (($c = jLog::getMessagesCount($type)) > $count) { $info->popupContent .= '<p class="jxdb-msg-warning">There are ' . $c . ' ' . ($type == 'default' ? '' : $type) . ' messages. Only first ' . $count . ' messages are shown.</p>'; } } } $debugbar->addInfo($info); }
/** * it should adds content or set some properties on the debugbar * to displays some contents. * @param debugbarHTMLResponsePlugin $debugbar the debugbar */ function show($debugbar) { $info = new debugbarItemInfo('defaultlog', 'General logs'); $info->htmlLabel = '<img src="data:image/png;base64,' . base64_encode(file_get_contents(__DIR__ . '/../../htmlresponse/debugbar/icons/book_open.png')) . '" alt="General logs" title="General logs"/> '; $messages = jLog::getMessages(array('default', 'debug')); $c = count($messages); $info->htmlLabel .= $c; if ($c == 0) { $info->label = 'no message'; } else { $info->popupContent = '<ul id="jxdb-defaultlog" class="jxdb-list">'; $currentCount = array('default' => 0, 'debug' => 0); foreach ($messages as $msg) { $cat = $msg->getCategory(); $currentCount[$cat]++; $title = $msg->getFormatedMessage(); $truncated = false; if (strlen($title) > 60) { $truncated = true; $title = substr($title, 0, 60) . '...'; } $info->popupContent .= '<li> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($title) . '</span></a></h5> <div>'; if ($truncated) { if ($msg instanceof jLogDumpMessage) { $info->popupContent .= "<pre>" . htmlspecialchars($msg->getMessage()) . '</pre>'; } else { $info->popupContent .= htmlspecialchars($msg->getMessage()); } } $info->popupContent .= '</div></li>'; } $info->popupContent .= '</ul>'; foreach ($currentCount as $type => $count) { if (($c = jLog::getMessagesCount($type)) > $count) { $info->popupContent .= '<p class="jxdb-msg-warning">There are ' . $c . ' ' . ($type == 'default' ? '' : $type) . ' messages. Only first ' . $count . ' messages are shown.</p>'; } } } $debugbar->addInfo($info); }
/** * Handle an error event. Called by error handler and exception handler. * @param string $type error type : 'error', 'warning', 'notice' * @param integer $code error code * @param string $message error message * @param string $file the file name where the error appear * @param integer $line the line number where the error appear * @param array $trace the stack trace * @since 1.1 */ public function handleError($type, $code, $message, $file, $line, $trace) { global $gJConfig; $errorLog = new jLogErrorMessage($type, $code, $message, $file, $line, $trace); if ($this->request) { // we have config, so we can process "normally" $errorLog->setFormat($gJConfig->error_handling['messageLogFormat']); jLog::log($errorLog, $type); $this->allErrorMessages[] = $errorLog; // if non fatal error, it is finished if ($type != 'error') { return; } $this->errorMessage = $errorLog; while (ob_get_level()) { ob_end_clean(); } if ($this->response) { $resp = $this->response; } else { $resp = $this->response = new jResponseCmdline(); } $resp->outputErrors(); jSession::end(); } elseif ($type != 'error') { $this->allErrorMessages[] = $errorLog; $this->initErrorMessages[] = $errorLog; return; } else { // fatal error appeared during init, let's display a single message while (ob_get_level()) { ob_end_clean(); } // log into file @error_log($errorLog->getFormatedMessage(), 3, jApp::logPath('errors.log')); // output text response echo 'Error during initialization: ' . $message . ' (' . $file . ' ' . $line . ")\n"; } exit(1); }
/** * */ function view() { //$lang = jApp::config()->locale; //$lang = jLocale::getCurrentLang(); $name = $this->param('name'); jLog::log("lang: {$lang} / name: {$name}"); $rep = $this->getResponse('html'); jLog::log("Name of fame: " . $this->param('name')); $games = jClasses::getService('amigatlk~games'); $game = $games->getProduct($this->param('name')); if (empty($game)) { $rep->body->assignZone('MAIN', 'amigatlk~notFound404'); $rep->setHttpStatus('404', 'Not Found'); return $rep; } $rep->title = $game->title; $rep->body->assignZone('MAIN', 'amigatlk~viewGame', array('game' => $game)); // this is a call for the 'welcome' zone after creating a new application // remove this line ! //$rep->body->assignZone('MAIN', 'jelix~check_install'); return $rep; }
public function handleError($type, $code, $message, $file, $line, $trace) { $errorLog = new jLogErrorMessage($type, $code, $message, $file, $line, $trace); $errorLog->setFormat(jApp::config()->error_handling['messageLogFormat']); jLog::log($errorLog, $type); $this->allErrorMessages[] = $errorLog; if ($type != 'error') { return; } $this->errorMessage = $errorLog; while (ob_get_level() && @ob_end_clean()) { } if ($this->response) { $resp = $this->response; } else { require_once JELIX_LIB_CORE_PATH . 'response/jResponseCmdline.class.php'; $resp = $this->response = new jResponseCmdline(); } $resp->outputErrors(); jSession::end(); exit(1); }
public function output() { if ($this->_outputOnlyHeaders) { $this->sendHttpHeaders(); return true; } foreach ($this->plugins as $name => $plugin) { $plugin->afterAction(); } $this->doAfterActions(); $this->setContentType(); if ($this->bodyTpl != '') { $this->body->meta($this->bodyTpl); $content = $this->body->fetch($this->bodyTpl, 'html', true, false); } else { $content = ''; } jLog::outputLog($this); foreach ($this->plugins as $name => $plugin) { $plugin->beforeOutput(); } $this->sendHttpHeaders(); $this->outputDoctype(); $this->outputHtmlHeader(); echo '<body '; foreach ($this->bodyTagAttributes as $attr => $value) { echo $attr, '="', htmlspecialchars($value), '" '; } echo ">\n"; echo implode("\n", $this->_bodyTop); echo $content; echo implode("\n", $this->_bodyBottom); foreach ($this->plugins as $name => $plugin) { $plugin->atBottom(); } echo '</body></html>'; return true; }
public function output() { if ($this->_outputOnlyHeaders) { $this->sendHttpHeaders(); return true; } $this->doAfterActions(); if ($this->bodyTpl != '') { $this->body->meta($this->bodyTpl); $content = $this->body->fetch($this->bodyTpl, 'xul', true, false); } else { $content = ''; } jLog::outputLog($this); $this->_httpHeaders['Content-Type'] = 'application/vnd.mozilla.xul+xml;charset=' . jApp::config()->charset; $this->sendHttpHeaders(); $this->outputHeader(); echo implode('', $this->_bodyTop); echo $content; echo implode('', $this->_bodyBottom); echo '</', $this->_root, '>'; return true; }
/** * it should adds content or set some properties on the debugbar * to displays some contents. * @param debugbarHTMLResponsePlugin $debugbar the debugbar */ function show($debugbar) { $info = new debugbarItemInfo('sqllog', 'SQL queries'); $messages = jLog::getMessages('sql'); #expand $info->htmlLabel = '<img src="data:image/png;base64,__LOGOSQLLOG__" alt="SQL queries" title="SQL queries"/> '; if (!jLog::isPluginActivated('memory', 'sql')) { $info->htmlLabel .= '?'; $info->label .= 'memory logger is not active'; } else { $realCount = jLog::getMessagesCount('sql'); $currentCount = count($messages); $info->htmlLabel .= $realCount; if ($realCount) { if ($realCount > $currentCount) { $info->popupContent = '<p class="jxdb-msg-warning">Too many queries (' . $realCount . '). Only first ' . $currentCount . ' queries are shown.</p>'; } $info->popupContent .= '<ul id="jxdb-sqllog" class="jxdb-list">'; foreach ($messages as $msg) { $dao = $msg->getDao(); if ($dao) { $m = 'DAO ' . $dao; } else { $m = substr($msg->getMessage(), 0, 50) . ' [...]'; } $info->popupContent .= '<li> <h5><a href="#" onclick="jxdb.toggleDetails(this);return false;"><span>' . htmlspecialchars($m) . '</span></a></h5> <div> <p>Time: ' . $msg->getTime() . 's</p>'; $info->popupContent .= '<pre style="white-space:pre-wrap">' . htmlspecialchars($msg->getMessage()) . '</pre>'; $info->popupContent .= $debugbar->formatTrace($msg->getTrace()); $info->popupContent .= '</div></li>'; } $info->popupContent .= '</ul>'; } } $debugbar->addInfo($info); }
/** * output errors */ public function outputErrors() { if (file_exists(jApp::appPath('app/responses/error.en_US.php'))) { $file = jApp::appPath('app/responses/error.en_US.php'); } else { $file = JELIX_LIB_CORE_PATH . 'response/error.en_US.php'; } // we erase already generated content $this->_headTop = array(); $this->_headBottom = array(); $this->_bodyBottom = array(); $this->_bodyTop = array(); jLog::outputLog($this); foreach ($this->plugins as $name => $plugin) { $plugin->beforeOutputError(); } $HEADTOP = implode("\n", $this->_headTop); $HEADBOTTOM = implode("\n", $this->_headBottom); $BODYTOP = implode("\n", $this->_bodyTop); $BODYBOTTOM = implode("\n", $this->_bodyBottom); $BASEPATH = jApp::urlBasePath(); header("HTTP/{$this->httpVersion} 500 Internal jelix error"); header('Content-Type: text/html;charset=' . $this->_charset); include $file; }
/** * Empty a map service cache * @param string $repository Repository for which to remove all tile cache * @return Redirection to the index */ function removeLayerCache() { // Create response to redirect to the index $rep = $this->getResponse("redirect"); $rep->action = "admin~config:index"; $repository = $this->param('repository'); $lrep = lizmap::getRepository($repository); if (!$lrep) { jMessage::add('The repository ' . strtoupper($repository) . ' does not exist !', 'error'); return $rep; } $project = $this->param('project'); try { $lproj = lizmap::getProject($lrep->getKey() . '~' . $project); if (!$lproj) { jMessage::add('The lizmapProject ' . strtoupper($project) . ' does not exist !', 'error'); return $rep; } $layer = $this->param('layer'); // Remove project cache $lproj->clearCache(); // Remove the cache for the layer lizmapProxy::clearLayerCache($repository, $project, $layer); jMessage::add(jLocale::get("admin~admin.cache.layer.removed", array($layer))); return $rep; } catch (UnknownLizmapProjectException $e) { jLog::logEx($e, 'error'); jMessage::add('The lizmapProject ' . strtoupper($project) . ' does not exist !', 'error'); return $rep; } return $rep; }
/** * output the html content * * @return boolean true if the generated content is ok */ public function output() { foreach ($this->plugins as $name => $plugin) { $plugin->afterAction(); } $this->doAfterActions(); $this->setContentType(); // let's get the main content for the body // we don't output yet <head> and other things, to have the // opportunity for any components called during the output, // to add things in the <head> if ($this->bodyTpl != '') { $this->body->meta($this->bodyTpl); $content = $this->body->fetch($this->bodyTpl, 'html'); } else { $content = ''; } // retrieve errors messages and log messages jLog::outputLog($this); foreach ($this->plugins as $name => $plugin) { $plugin->beforeOutput(); } // now let's output the html content $this->sendHttpHeaders(); $this->outputDoctype(); $this->outputHtmlHeader(); echo '<body '; foreach ($this->bodyTagAttributes as $attr => $value) { echo $attr, '="', htmlspecialchars($value), '" '; } echo ">\n"; echo implode("\n", $this->_bodyTop); echo $content; echo implode("\n", $this->_bodyBottom); foreach ($this->plugins as $name => $plugin) { $plugin->atBottom(); } echo '</body></html>'; return true; }