/** * read the config file and check for existence * * @return void */ private function _checkConfig() { if (!is_readable(APP_ROOT . '/config.php')) { $this->error->addError('file_exists(config.php)', 'config.php does not exist or is not readable by the webserver in the phpsysinfo directory.'); } else { include_once APP_ROOT . '/config.php'; } if ($this->error->errorsExist()) { $this->error->errorsAsXML(); } }
/** * trigger Smarty error * * @param string $error_msg * @param integer $error_type */ function trigger_error($error_msg, $error_type = E_USER_WARNING) { // print the error message Error::addError("Smarty error: {$error_msg}", true); if ($error_type == E_USER_ERROR) { die("Smarty error!"); } }
public function Error($msg) { // unset all class variables $this->_destroy(true); // exit program and print error // print the error message Error::addError('TCPDF ERROR: ' . $msg, true); //die("TCPDF error!"); }
/** * generate the xml document * * @return void */ private function _buildXml() { if (!$this->_plugin_request || $this->_complete_request) { if (version_compare("5.2", PHP_VERSION, ">")) { $this->_errors->addError("ERROR", "PHP 5.2 or greater is required, some things may not work correctly"); } if ($this->_sys === null) { if (PSI_DEBUG === true) { // unstable version check if (!is_numeric(substr(PSI_VERSION, -1))) { $this->_errors->addError("WARN", "This is an unstable version of phpSysInfo, some things may not work correctly"); } // Safe mode check $safe_mode = @ini_get("safe_mode") ? true : false; if ($safe_mode) { $this->_errors->addError("WARN", "PhpSysInfo requires to set off 'safe_mode' in 'php.ini'"); } // Include path check $include_path = @ini_get("include_path"); if ($include_path && $include_path != "") { $include_path = preg_replace("/(:)|(;)/", "\n", $include_path); if (preg_match("/^\\.\$/m", $include_path)) { $include_path = "."; } } if ($include_path != ".") { $this->_errors->addError("WARN", "PhpSysInfo requires '.' inside the 'include_path' in php.ini"); } // popen mode check if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) { $this->_errors->addError("WARN", "Installed version of PHP does not support proc_open() function, popen() is used"); } } $this->_sys = $this->_sysinfo->getSys(); } $this->_buildVitals(); $this->_buildNetwork(); $this->_buildHardware(); $this->_buildMemory(); $this->_buildFilesystems(); $this->_buildMbinfo(); $this->_buildUpsinfo(); } $this->_buildPlugins(); $this->_xml->combinexml($this->_errors->errorsAddToXML($this->_sysinfo->getEncoding())); }
/** * check if there is a default translation file availabe and also the required js file for * appending the content of the plugin to the main webpage * * @return void */ private function _checkfiles() { if (!file_exists($this->_plugin_base . "js/" . strtolower($this->_plugin_name) . ".js")) { $this->global_error->addError("file_exists(" . $this->_plugin_base . "js/" . strtolower($this->_plugin_name) . ".js)", "JS-File for Plugin '" . $this->_plugin_name . "' is missing!"); } else { if (!is_readable($this->_plugin_base . "js/" . strtolower($this->_plugin_name) . ".js")) { $this->global_error->addError("is_readable(" . $this->_plugin_base . "js/" . strtolower($this->_plugin_name) . ".js)", "JS-File for Plugin '" . $this->_plugin_name . "' is not readable but present!"); } } if (!file_exists($this->_plugin_base . "lang/en.xml")) { $this->global_error->addError("file_exists(" . $this->_plugin_base . "lang/en.xml)", "At least an english translation must exist for the plugin!"); } else { if (!is_readable($this->_plugin_base . "lang/en.xml")) { $this->global_error->addError("is_readable(" . $this->_plugin_base . "js/" . $this->_plugin_name . ".js)", "The english translation can't be read but is present!"); } } }
/** * generate the xml document * * @return void */ private function _buildXml() { if (!$this->_plugin_request || $this->_complete_request) { if ($this->_sys === null) { if (PSI_DEBUG === true) { // Safe mode check $safe_mode = @ini_get("safe_mode") ? TRUE : FALSE; if ($safe_mode) { $this->_errors->addError("WARN", "PhpSysInfo requires to set off 'safe_mode' in 'php.ini'"); } // Include path check $include_path = @ini_get("include_path"); if ($include_path && $include_path != "") { $include_path = preg_replace("/(:)|(;)/", "\n", $include_path); if (preg_match("/^\\.\$/m", $include_path)) { $include_path = "."; } } if ($include_path != ".") { $this->_errors->addError("WARN", "PhpSysInfo requires '.' inside the 'include_path' in php.ini"); } // popen mode check if (defined("PSI_MODE_POPEN") && PSI_MODE_POPEN === true) { $this->_errors->addError("WARN", "Installed version of PHP does not support proc_open() function, popen() is used"); } } $this->_sys = $this->_sysinfo->getSys(); } $this->_buildVitals(); $this->_buildNetwork(); $this->_buildHardware(); $this->_buildMemory(); $this->_buildFilesystems(); $this->_buildMbinfo(); $this->_buildUpsinfo(); } $this->_buildPlugins(); $this->_xml->combinexml($this->_errors->errorsAddToXML($this->_sysinfo->getEncoding())); }
/** * Handle the submitted forms. */ protected final function handleForm() { // check, if user is logged in (except for /user/login OR /booking/website) if ($this->s->auth() === false && !($this->s->controller == 'user' && $this->s->action == 'login') && !($this->s->controller == 'booking' && $this->s->action == 'website')) { Error::addError('<strong>Die Anfrage konnte leider nicht bearbeitet werden</strong><br/>Sie sind nicht im System angemeldet!', true); return false; } // check if action is allowed for the user $right = $this->right(); $action = $this->s->controller . ':' . $right; if (!($this->s->controller == 'user' && $this->s->action == 'login') && !($this->s->controller == 'booking' && $this->s->action == 'website') && !$this->s->user->hasRights($action) && array_key_exists($right, $this->registerRights())) { Error::addError('<strong>Die Anfrage konnte leider nicht bearbeitet werden</strong><br/>Du besitzt nicht die erforderlichen Rechte, um die Aktion ' . $action . ' auszuführen!', true); return false; } // get the validation rules for this action $rules = $this->config['rules'][$this->s->action]; // is it a valid action? if (!is_array($rules)) { Error::addError('<strong>Die Anfrage konnte leider nicht bearbeitet werden</strong><br/>Interner Fehler: Es sind keine Regeln für die Aktion "' . $this->s->action . '" im Modul "' . $this->s->controller . '" definiert. Bitte benachrichtigen Sie den Administrator!', true); return false; } // validate the form fields using the rules of the module for this action $vars = array_merge($this->s->get, $this->s->post); $check = new Check($vars, $rules, $this->config["messages"]); if (true === $check->run($escape)) { // replace unfiltered post vars $this->vars = $check->vars; // execute the requested action return $this->formAction(); } else { $this->form['errors'] = $check->errorFields; foreach ($check->errorMessages as $error) { Error::addWarning($error); } return false; } }
/** * Handle form action */ protected function formAction() { $this->escapeFormVars(); switch ($this->s->action) { case 'send': $message = new Message(); $message->text = $this->vars['text']; $message->subject = $this->vars['subject']; if ($this->s->params[0] != '') { $message->type = $this->s->params[0]; switch ($message->type) { case 'poker': $message->receiver = PokerTable::getInstance($this->s->params[1]); break; } } else { if (!is_array($this->vars['user']) || count($this->vars['user']) == 0) { return false; } $message->type = 'user'; $rec = array(); foreach ($this->vars['user'] as $r) { $rec[] = User::getInstance($r); } $message->receiver = $rec; } $message->sender = $this->s->user; if ($message->save()) { Error::addMessage('Die Nachricht wurde verschickt!'); $this->form['reload'] = array('message' => array('sidebar')); return true; } break; case 'update': $message = Message::getInstance($this->s->element); $message->text = $this->vars['text']; $message->subject = $this->vars['subject']; if ($message->save()) { Error::addMessage('Die Nachricht wurde geändert!'); $this->form['reload'] = array('message' => array('u_message')); return true; } break; case 'reply': $r = Message::getInstance($this->s->element); $message = new Message(); $message->text = $this->vars['text']; $message->subject = $this->vars['subject']; $message->receiver = $r->sender; $message->sender = $this->s->user; $message->replyto = $this->s->element; if ($message->save()) { Error::addMessage('Die Nachricht wurde verschickt!'); $this->form['reload'] = array('message' => array('u_message')); return true; } break; case 'mark': if ($this->s->element != '') { $m = Message::getInstance($this->s->element); // mark all messages in thread as (un-)read if ($this->vars['messages'] == 'all') { if (is_array($m->replies)) { foreach ($m->replies as $r) { if ($r->receiver == $this->s->user) { $r->read = $this->vars['option'] == 'read' ? true : false; if (!$r->save()) { Error::addError('Interner Fehler: Nachricht konnte nicht gespeichert werden!'); return false; } } } } $this->form['reload'] = array('message' => array('u_message')); } else { $this->form['reload'] = array('message' => array('sidebar', 'bb_messages')); } // mark current message as (un-)read $m->read = $this->vars['option'] == 'read' ? true : false; if ($m->save()) { return true; } else { Error::addError('Interner Fehler: Nachricht konnte nicht gespeichert werden!'); return false; } } Error::addError('Es konnte keine Nachricht gefunden werden!'); break; case 'delete': $m = Message::getInstance($this->s->element); if ($m->delete()) { Error::addMessage('Die Nachricht wurde gelöscht!'); $this->form['reload'] = array('message' => array('sidebar', 'u_message')); return true; } break; case 'reload': switch ($this->s->element) { case 'sidebar': $tpl = new Template('message'); $this->s->resetParams(); $m = $this->listMessages($this->s->element); $tpl->assign('messages', $m['messages']); $tpl->assign('current', $m['current']); $tpl->assign('read', $m['read']); $tpl->assign('user', $this->s->user); echo $tpl->fetch('message_list.html'); break; case 'u_message': $tpl = new Template('message'); $this->s->resetParams(); $tpl->assign('m', Message::getInstance($this->s->element)); $tpl->assign('user', $this->s->user); echo $tpl->fetch('message.html'); break; case 'bb_messages': echo $this->blackboardTable(); default: echo ''; } return true; } return false; }
/** * List all availiable Modules */ private function listModules() { // get all modules listed in the database $db = DB::getInstance(); $sql = "SELECT name\n FROM modules"; $result = $db->query($sql); do { $mod_db[$result->name] = ''; } while ($result->next()); // get all available modules from the file system $dir = opendir('modules/'); // run through module directory while (false !== ($name = readdir($dir))) { // only real folders if ($name != "." && $name != ".." && is_dir('modules/' . $name)) { // is there any MODULENAME.info file? $file = 'modules/' . $name . '/' . $name . '.info'; if (is_readable($file)) { // read module information $info = array(); $raw = file($file); foreach ($raw as $line) { $parts = explode(':', $line); if (strtolower($parts[0]) == 'requires') { $req = explode(',', trim($parts[1])); if (count($req) > 0 && $req[0] != '') { $info[strtolower($parts[0])] = $req; } } else { $info[strtolower($parts[0])] = trim($parts[1]); } } // is all given info correct? if ($info['id'] == $name && !empty($info['name']) && !empty($info['version']) && !empty($info['group']) && !empty($info['description'])) { $module = Module::getInstance($name); unset($mod_db[$name]); $module->version = $info['version']; $module->requires = $info['requires']; $module->name = $info['name']; $module->description = $info['description']; $module->save(); $groups[$info['group']][] = $module; $modules[$module->id] = $module; } } } } closedir($dir); // are there any module entries in the db for which no module folder exist? if (count($mod_db) > 0) { Error::addError('Achtung: Zu einigen Einträgen in der Datenbank konnte kein Modul gefunden werden!'); } // resolve dependancies foreach ($modules as $m) { $activable = $deact = true; // all required modules active? if (is_array($m->requires)) { foreach ($m->requires as $r) { if ($r->active === false) { $activable = false; break; } } } $m->can_act = $activable; // any active modules which rely on the current one? foreach ($modules as $d) { if ($d->active === true && is_array($d->requires)) { foreach ($d->requires as $r) { if ($r === $m->id) { $deact = false; break; } } } } $m->can_deact = $deact; } $tpl = new Template('module'); $tpl->assign('modules', $modules); $tpl->assign('groups', $groups); $tpl->assign('permission', $this->s->user->hasRights('module:activate')); return $tpl->fetch("modules_table.html"); }
/** * close server connection and delete marked messages * * @return bool * @author Elias Müller **/ public function close() { if (($error = $this->server->Close()) == "") { return true; } else { Error::addError("Fehler beim Trennen der Verbindung zum Mail-Server: " . HtmlSpecialChars($error), true); return false; } }
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // $Id: index.php,v 1.122.4.1 2007/08/19 09:21:57 xqus Exp $ // phpsysinfo release version number $VERSION = "2.5.4"; $startTime = array_sum(explode(" ", microtime())); define('APP_ROOT', dirname(__FILE__)); define('IN_PHPSYSINFO', true); ini_set('magic_quotes_runtime', 'off'); ini_set('register_globals', 'off'); // ini_set('display_errors','on'); require_once APP_ROOT . '/includes/class.error.inc.php'; $error = new Error(); // Figure out which OS where running on, and detect support if (file_exists(APP_ROOT . '/includes/os/class.' . PHP_OS . '.inc.php')) { } else { $error->addError('include(class.' . PHP_OS . '.php.inc)', PHP_OS . ' is not currently supported', __LINE__, __FILE__); } if (!extension_loaded('xml')) { $error->addError('extension_loaded(xml)', 'phpsysinfo requires the xml module for php to work', __LINE__, __FILE__); } if (!extension_loaded('pcre')) { $error->addError('extension_loaded(pcre)', 'phpsysinfo requires the pcre module for php to work', __LINE__, __FILE__); } if (!file_exists(APP_ROOT . '/config.php')) { $error->addError('file_exists(config.php)', 'config.php does not exist in the phpsysinfo directory.', __LINE__, __FILE__); } else { require_once APP_ROOT . '/config.php'; // get the config file } if ($error->ErrorsExist()) { echo $error->ErrorsAsHTML();
/** * delete the object information from the db */ public function delete() { $db = DB::getInstance(); $sql = "SELECT idstatus\n\t\t\t\t FROM users\n\t\t\t\t WHERE idstatus = " . $this->id; $result = $db->query($sql); if ($result->length() == 0) { $sql = "DELETE FROM groups\n\t\t\t\t\t\t WHERE idstatus = '" . $this->id . "'"; if ($db->query($sql) != 0) { return true; } } Error::addError('Die Gruppe konnte nicht gelöscht werden, da ihr noch Benutzer zugeordnet sind. Diese müssen zuvor anderen Gruppen zugewiesen werden!'); return false; }
/** * Handle form action */ protected function formAction() { switch ($this->s->action) { case 'create': $spot = $this->vars['idspot'] != 0 ? PokerSpot::getInstance($this->vars['idspot']) : FALSE; $table = new PokerTable($this->vars['title'], $this->vars['seats'], $this->vars['blind'], $spot); if ($table->save()) { Error::addMessage('Der Pokertisch wurde erfolgreich angelegt!'); $this->form['reload'] = array('poker' => array('poker_table' => 'tables')); return true; } //*/ break; case 'update': $table = PokerTable::getInstance($this->s->element); $table->title = $this->vars['title']; $table->seats = $this->vars['seats']; if ($this->vars['idspot'] != 0) { $table->spot = PokerSpot::getInstance($this->vars['idspot']); } $table->blinds = array('big' => 2 * $this->vars['blind'], 'small' => $this->vars['blind']); if ($table->save()) { Error::addMessage('Die Änderungen wurden erfolgreich gespeichert!'); $this->form['reload'] = array('poker' => array('poker_table' => 'tables')); return true; } break; case 'delete': $table = PokerTable::getInstance($this->s->element); if (is_object($table->game)) { Error::addError('Der Tisch kann nicht gelöscht werden (Spiel ist noch aktiv)!'); return false; } if ($table->delete()) { Error::addMessage('Der Pokertisch wurde erfolgreich gelöscht!'); $this->form['reload'] = array('poker' => array('poker_table' => 'tables')); return true; } break; case 'reload': echo $this->listTables(); break; } return false; }
/** * Handle form action */ protected function formAction() { switch ($this->s->action) { case "activate": if ($this->s->element != '') { $group = Group::getInstance($this->s->element); $rights = $group->rights; if (current($rights) == '') { $rights = array(); } if ($this->vars['option'] == 'set' && !in_array($this->vars['right'], $rights)) { $rights[] = $this->vars['right']; } elseif ($this->vars['option'] == 'remove') { foreach ($rights as $key => $right) { if ($right == $this->vars['right']) { unset($rights[$key]); } } } $group->rights = $rights; if ($group->save()) { return true; } } Error::addWarning('Fehler: Es wurde kein Modul ausgewählt!'); break; case 'create': $group = Group::getInstance(); $group->name = $this->vars['name']; if ($group->save()) { Error::addMessage('Die Benutzergruppe wurde erfolgreich angelegt!'); $this->form['reload'] = array('group' => array('groups')); return true; } case 'delete': $group = Group::getInstance($this->s->element); $name = $group->name; if ($group->delete()) { Error::addMessage('Die Gruppe ' . $name . ' wurde erfolgreich gelöscht!'); $this->form['reload'] = array('group' => array('groups')); } break; case 'reload': switch ($this->s->element) { case 'groups': // groups table echo $this->listGroups(); break; default: Error::addError('Fehler: Element nicht gefunden!'); return false; } return true; break; } return false; }
/** * Handle form action */ protected function formAction() { $this->escapeFormVars(); switch ($this->s->action) { case "create": $user = User::getInstance($this->vars['username']); $user->realname = $this->vars['realname']; $user->email = $this->vars['email']; $user->password = $this->generateHash($this->vars['password']); $user->idstatus = $this->vars['status']; if ($user->save()) { Error::addMessage('Die Änderungen wurden erfolgreich gespeichert!'); $this->form['reload'] = array('user' => array('users')); return true; } break; case "self": $this->s->user->realname = $this->vars['realname']; $this->s->user->email = $this->vars['email']; if ($this->vars['password'] != '') { $this->s->user->password = $this->generateHash($this->vars['password']); } if ($this->vars['status'] != '') { $this->s->user->idstatus = $this->vars['status']; } if ($this->s->user->save()) { Error::addMessage('Die Änderungen wurden erfolgreich gespeichert!'); $this->form['reload'] = array('user' => array('user', 'users')); return true; } break; case "update": $user = User::getInstance($this->vars['username']); $user->realname = $this->vars['realname']; $user->email = $this->vars['email']; if ($this->vars['password'] != '') { $user->password = $this->generateHash($this->vars['password']); } if ($this->vars['status'] != '') { $user->idstatus = $this->vars['status']; } if ($user->save()) { Error::addMessage('Die Änderungen wurden erfolgreich gespeichert!'); $this->form['reload'] = array('user' => array('user', 'users')); return true; } break; case 'delete': $user = User::getInstance($this->s->element); $name = $user->realname; if ($user->delete()) { Error::addMessage('Der Benutzer ' . $name . ' wurde erfolgreich gelöscht!'); $this->form['reload'] = array('user' => array('users')); return true; } break; case "login": return $this->login($this->vars["username"], $this->vars["password"]); break; case 'reload': switch ($this->s->element) { case 'users': // user table echo $this->listUsers(); break; case 'user': // user info echo '<a href="admin/user/self/' . $this->s->user->username . '.html?width=600&height=500" class="dialog form" title="Benutzer bearbeiten">' . $this->s->user->realname . '</a> <a href="admin/user/logout" id="logout"></a>'; break; default: Error::addError('Fehler: Element nicht gefunden!'); return false; } return true; break; } return false; }
/** * error handling * * @param string $msg the error message */ private function halt($msg) { // get the errors $this->error = @mysql_error($this->link_id); $this->errno = @mysql_errno($this->link_id); // should we ignore the error? if ($this->halt_on_error == "no") { return; } // print the error message Error::addError("<strong>Database error:</strong> {$msg}<br/>\n<strong>MySQL Error</strong>: {$this->errno} ({$this->error})<br/>\n", true); // skip the whole programm if ($this->halt_on_error != "report") { die("Session halted."); } }
/** * Load a module. * @param string $module_name The name of the module * @param bool $site_call true, if the loaded module should display a site (only to set by cBootstrap) * @return SiteController An instance of the requested module */ public function loadModule($module_name, $site_call = false) { // check if requested module is active if (!array_key_exists($module_name, $this->active_modules)) { Error::addError('<strong>Ihre Anfrage konnte leider nicht bearbeitet werden</strong><br/>Interner Fehler: Modul "' . $module_name . '" ist nicht aktiv. Bitte benachrichtigen Sie den Administrator!', true); return false; } // check if module exists if (!is_dir("modules/" . $module_name)) { Error::addError('<strong>Ihre Anfrage konnte leider nicht bearbeitet werden</strong><br/>Interner Fehler: Modul "' . $module_name . '" nicht vorhanden. Bitte benachrichtigen Sie den Administrator!', true); return false; } $class = $this->params["area"] == 'frontend' ? 'frontend' : 'backend'; require_once 'classes/site_controller.class.php'; $action = $site_call === true ? $this->params['action'] : ''; $controller = SiteController::factory($class, $module_name, $action); return $controller; }
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // $Id: index.php,v 1.122.4.1 2007/08/19 09:21:57 xqus Exp $ // phpsysinfo release version number $VERSION = "2.5.4"; $startTime = array_sum(explode(" ", microtime())); define('APP_ROOT', dirname(__FILE__)); define('IN_PHPSYSINFO', true); ini_set('magic_quotes_runtime', 'off'); ini_set('register_globals', 'off'); // ini_set('display_errors','on'); require_once APP_ROOT . '/includes/class.error.inc.php'; $error = new Error(); // Figure out which OS where running on, and detect support if (file_exists(APP_ROOT . '/includes/os/class.' . PHP_OS . '.inc.php')) { } else { $error->addError('include(class.' . PHP_OS . '.php.inc)', PHP_OS . ' is not currently supported', __LINE__, __FILE__); } if (!extension_loaded('xml')) { $error->addError('extension_loaded(xml)', 'phpsysinfo requires the xml module for php to work', __LINE__, __FILE__); } if (!extension_loaded('pcre')) { $error->addError('extension_loaded(pcre)', 'phpsysinfo requires the pcre module for php to work', __LINE__, __FILE__); } if (!file_exists(APP_ROOT . '/config.php')) { $error->addError('file_exists(config.php)', 'config.php does not exist in the phpsysinfo directory.', __LINE__, __FILE__); } else { require_once APP_ROOT . '/config.php'; // get the config file } if (!empty($sensor_program)) { $sensor_program = basename($sensor_program);
/** * send mail * * @param string $subject message subject * @param array $from sender name and adress * @param array $to receiver name and adress * @return bool * @author Elias Müller **/ public function send($subject, $from, $to) { if ($subject == '') { Error::addError('Kein Mail-Versand ohne Betreff!'); return false; } $this->mail->SetEncodedEmailHeader("To", $to['email'], $to['name']); $this->mail->SetEncodedEmailHeader("From", $from['email'], $from['name']); $this->mail->SetEncodedEmailHeader("Reply-To", '*****@*****.**', 'Jugendburg Balduinstein'); $this->mail->SetHeader("Return-Path", '*****@*****.**'); $this->mail->SetEncodedEmailHeader("Errors-To", '*****@*****.**', 'Elias Müller'); $this->mail->SetEncodedHeader("Subject", $subject); if (($error = $this->mail->Send()) == '') { return true; } Error::addError("Fehler beim Mail-Versand: " . HtmlSpecialChars($error), true); return false; }