private function execute($action) { if (!method_exists($action, 'getFile')) { return '[could not execute this action]'; } if (file_exists($action->getFile())) { Sumo\Logger::info('Executing ' . $action->getClass() . '->' . $action->getMethod()); require_once $action->getFile(); $class = $action->getClass(); try { if (!class_exists($class)) { throw new \Exception('File not found for class ' . $class); } $controller = new $class($this->registry); } catch (\Exception $e) { trigger_error('Could not execute ' . $class . ', something is wrong.', E_USER_ERROR); } if (is_callable(array($controller, $action->getMethod()))) { $return = call_user_func_array(array($controller, $action->getMethod()), $action->getArgs()); } else { trigger_error('Could not execute ' . $action->getClass() . '->' . $action->getMethod(), E_USER_ERROR); $return = $this->error; $this->error = ''; } } else { $file = $action->getFile(); if (empty($file)) { Sumo\Logger::warning('$action does not have method $action->getFile(): ' . print_r($action, true)); } Sumo\Logger::warning('Could not load file ' . $action->getFile() . ' to call ' . $action->getClass() . '->' . $action->getMethod()); $return = $this->error; $this->error = ''; } return $return; }
public function query($sql) { $this->count++; $this->tmpQueries[] = $sql; Sumo\Logger::warning('[OLD DB] Warning, query through the old DB interface. Switch to the new Database class'); return $this->driver->query($sql); }
public function get($key) { $this->count++; $value = isset($this->data[$key]) ? $this->data[$key] : $key; $this->keys[] = array($key => $value); Sumo\Logger::warning('[OLD LANGUAGE] ' . $key . ' requested'); return $value; }
$goToInstall = '<a href="install/?language=nl">Klik hier om door te gaan</a> - <a href="install/?language=en">Click to continue</a>'; if (file_exists('config.mysql.php')) { require 'config.mysql.php'; if (!defined('DB_HOSTNAME') || !defined('DB_USERNAME') || !defined('DB_PASSWORD') || !defined('DB_DATABASE')) { exit($goToInstall); } define('DIR_HOME', str_replace('\\', '/', realpath(dirname(__FILE__))) . '/'); define('DIR_SYSTEM', DIR_HOME . 'system/'); define('DIR_IMAGE', DIR_HOME . 'image/'); define('DIR_CACHE', DIR_SYSTEM . 'cache/'); define('DIR_DOWNLOAD', DIR_HOME . 'download/'); define('DIR_LOGS', DIR_SYSTEM . 'logs/'); // Startup require DIR_SYSTEM . 'engine/singleton.php'; require DIR_SYSTEM . 'library/logger.php'; Sumo\Logger::getInstance(); require DIR_SYSTEM . 'engine/error.php'; require DIR_SYSTEM . 'startup.php'; define('ABS_START', microtime(true)); // Registry $registry = new Registry(); // Loader $loader = new Loader($registry); $registry->set('load', $loader); // Config $config = new Config(); $registry->set('config', $config); // Database *legacy* //$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE); Sumo\Database::setup(array('hostname' => DB_HOSTNAME, 'username' => DB_USERNAME, 'password' => DB_PASSWORD, 'database' => DB_DATABASE, 'prefix' => DB_PREFIX)); //$registry->set('db', Sumo);
function development_debug($content, $fatal = false) { $extra = ''; $debug_text = ''; $errors = Sumo\Logger::get('total'); $total = ''; foreach ($errors as $level) { $total .= count($level) . '/'; } $total = rtrim($total, '/'); if (!$fatal) { $content = str_replace('id="debug"></span>', 'id="debug" style="cursor:pointer;" data-toggle="modal" data-target="#footerdebug">' . Sumo\Logger::get('runtime') . 's, ' . $total . ' logs</span>', $content); } else { $extra .= '<button data-toggle="modal" data-target="#footerdebug" type="button" class="btn btn-danger btn-flat" id="error" style="margin-left: 50%;"><i class="fa fa-times-circle"></i> Error</button>'; } if (defined('DEVELOPMENT') || $fatal) { $extra .= '<div id="footerdebug" class="modal fade colored-header ' . ($fatal ? 'info' : 'info') . '" tabindex="-1" role="dialog">'; $extra .= '<div class="modal-dialog" style="width: 80%"><div class="modal-content">'; $extra .= '<div class="modal-header">'; if (!$fatal) { $extra .= '<h4 class="text-center">Developer mode<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button></h4>'; } else { $extra .= '<h4 class="text-center">Heerle, we\'ve got a problem..</h4>'; } $extra .= '</div><div class="modal-body" style="height: 600px; overflow: auto;">'; if ($fatal) { $extra .= '<p class="text-center">The system has generated a fatal error. Good thing is: you\'re getting a full trace!</p>'; } $extra .= '<p>Current runtime: ' . Sumo\Logger::get('runtime') . '</p>'; $extra .= '<p>Memory usage: ' . Sumo\Logger::get('memory') . '</p>'; $extra .= '<p>'; if (empty($content)) { $extra .= 'Empty output. '; } if ($total) { $i = 0; $collapsed = false; $extra .= $total . ' log lines available.</p><div id="accordion" class="panel-group accordion accordion-semi">'; $sorted = array(); if (isset($errors['error'])) { $sorted['error'] = $errors['error']; } if (isset($errors['warning'])) { $sorted['warning'] = $errors['warning']; } if (isset($errors['info'])) { $sorted['info'] = $errors['info']; } foreach ($errors as $type => $logs) { $extra .= '<div class="panel panel-default">'; if ($type == 'info') { $typeclass = 'success'; } else { if ($type == 'error') { $typeclass = 'danger'; } else { $typeclass = $type; } } $extra .= '<div class="panel-heading ' . $typeclass . '">'; $extra .= '<h4 class="panel-title"><a href="#log-' . $type . '" data-parent="#accordion" data-toggle="collapse">'; $extra .= '<i class="fa fa-angle-right"></i>'; if (class_exists('sumo\\language')) { $extra .= Sumo\Language::getVar('SUMO_LOG_' . strtoupper($type)); } else { $extra .= ucfirst($type); } $extra .= '</a></h4>'; $extra .= '</div>'; $extra .= '<div id="log-' . $type . '" class="panel-collapse collapse ' . (!$collapsed ? ' in' : '') . '">'; $extra .= '<div class="panel-body">'; foreach ($logs as $log) { $i++; $time = explode('.', $log['runtime']); $extra .= '<span>'; $extra .= '[' . $time[0] . '.' . str_pad($time[1], 8, '0') . '] '; $debug_text .= '[' . $time[0] . '.' . str_pad($time[1], 8, '0') . '] '; $extra .= '[' . $log['memory'] . '] '; $debug_text .= '[' . $log['memory'] . '] '; $extra .= ' <a href="#" onclick="$(\'.message-' . $i . '\').toggle(); return false;">'; $extra .= htmlentities($log['message']); $debug_text .= htmlentities($log['message']); $extra .= ' </a>'; $extra .= '</span><br />'; $extra .= '<div style="display:none;" class="message-' . $i . '"><pre>'; foreach ($log['backtrace'] as $nr => $trace) { $extra .= 'trace ' . $nr . PHP_EOL; $debug_text .= 'trace ' . $nr . PHP_EOL; foreach ($trace as $key => $value) { $extra .= "\t" . $key . ":\t" . htmlentities($value) . PHP_EOL; $debug_text .= $key . ":\t" . htmlentities($value) . PHP_EOL; } $extra .= PHP_EOL; $debug_text .= PHP_EOL; } $extra .= '</pre></div>'; $extra .= '<br />'; $last = htmlentities($log['message']); } $extra .= '</div></div></div>'; $collapsed = true; } $extra .= '</div>'; } else { $extra .= 'No log available.</p>'; } if (defined('DIR_LOGS') && defined('DEVELOPMENT')) { $file = DIR_LOGS . 'log_'; if ($fatal) { $file .= 'fatal_'; } $file .= date('Y-m-d-H-i-s') . '.txt'; $fp = fopen($file, 'w'); if ($fp) { fwrite($fp, $debug_text); fclose($fp); } else { unset($file); } } $extra .= '</div><div class="modal-footer">'; $extra .= '<button class="btn btn-default btn-flat md-close" data-dismiss="modal" type="button">Close</button>'; $extra .= '<a class="btn btn-info btn-flat" href="mailto:klantenservice@sumostore.net?title=SumoStore ' . VERSION . ' / Error&body=There was ' . ($fatal ? 'a fatal' : 'an') . ' error. ' . (isset($file) ? 'The error log can be found in ' . $file . ', via FTP. Please add this file in the email.' : 'Log file could not be created, probably some write issues?') . '.' . PHP_EOL . PHP_EOL . ' The last error message: ' . $last . PHP_EOL . PHP_EOL . ' Please add some details about this error, for example which page, what were you doing etc.">Mail</a>'; $extra .= '</div></div></div></div>'; if (!$fatal) { $extra .= '<script type="text/javascript">$(function(){$("#footerdebug").hide();})</script>'; } } if ($fatal) { $head = '<link href="//fonts.googleapis.com/css?family=Open+Sans:600,300,400" rel="stylesheet" type="text/css">'; $head .= '<link rel="stylesheet" type="text/css" href="/admin/view/css/bootstrap/bootstrap.css">'; $head .= '<link rel="stylesheet" type="text/css" href="/admin/view/css/style.css">'; $head .= '<link rel="stylesheet" type="text/css" href="/admin/view/fonts/awesome.css">'; $head .= '<style>.accordion.accordion-semi .panel-heading a.collapsed { color: #FFF; }</style>'; $head .= '<script type="text/javascript" src="/admin/view/js/jquery/jquery.js"></script>'; $head .= '<script src="/admin/view/js/bootstrap/bootstrap.js"></script>'; $extra .= '<script type="text/javascript">$(function(){$("#error").trigger("click");});</script>'; $content = str_replace('</head>', $head . '</head>', $content); exit('<!-- ' . date('Y-m-d H:i:s') . '-->' . str_replace('</body>', $extra . '</body>', $content)); } return str_replace('</body>', $extra . '</body>', $content); }
require DIR_SYSTEM . 'library/formatter.php'; require DIR_SYSTEM . 'library/apps.php'; if (!isset($unknown)) { Sumo\Logger::info('Common library is loaded'); } // Application Classes require DIR_SYSTEM . 'library/customer.php'; require DIR_SYSTEM . 'library/affiliate.php'; require DIR_SYSTEM . 'library/currency.php'; require DIR_SYSTEM . 'library/tax.php'; # to be removed, legacy only require DIR_SYSTEM . 'library/weight.php'; require DIR_SYSTEM . 'library/length.php'; require DIR_SYSTEM . 'library/cart.php'; if (!isset($unknown)) { Sumo\Logger::info('Application library is loaded'); } // Load security plugin require DIR_SYSTEM . 'engine/communicator.php'; //if (!isset($unknown)) { //Sumo\Logger::info('SumoGuard Communicator loaded'); //} //else { //Sumo\Logger::info('test'); //} require DIR_SYSTEM . 'engine/security.php'; if (ini_get('register_globals')) { ini_set('session.use_cookies', 'On'); ini_set('session.use_trans_sid', 'Off'); session_set_cookie_params(0, '/'); session_start();