Exemplo n.º 1
0
 /**
  * @covers ErrorManager::hasErrors
  */
 public function testHasErrors()
 {
     $this->manager = new \ErrorManager();
     $this->assertFalse($this->manager->hasErrors());
     $this->manager->addError('error');
     $this->assertTrue($this->manager->hasErrors());
 }
Exemplo n.º 2
0
 public static function getInstance()
 {
     if (self::$instancia == NULL) {
         self::$instancia = new ErrorManager();
     }
     return self::$instancia;
 }
Exemplo n.º 3
0
 function httpRequestValidator()
 {
     if (!isset($GLOBALS["debugMode"])) {
         $GLOBALS["debugMode"] = false;
     }
     $this->errors = ErrorManager::getInstance();
 }
Exemplo n.º 4
0
 /**
  * Class registry constructor
  * @access private
  */
 function APIClassRegistry()
 {
     $this->packages = array();
     $this->classes = array();
     $this->instances = array();
     parent::ErrorManager();
 }
Exemplo n.º 5
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new ErrorManager();
     }
     return self::$instance;
 }
Exemplo n.º 6
0
 public function CRUDManager($bindings, $roleBindings)
 {
     $this->bindings = $bindings;
     $this->roleBindings = $roleBindings;
     $this->validator = new httpRequestValidator('CRUDManager');
     $this->connection = Doctrine_Manager::connection();
     $this->errors = ErrorManager::getInstance();
 }
Exemplo n.º 7
0
 public function InfoManager($bindings, $roleBindings)
 {
     $this->bindings = $bindings;
     $this->roleBindings = $roleBindings;
     $this->templateManager = new TemplateManager($bindings);
     $this->user = $_SESSION['user'];
     $this->errors = ErrorManager::getInstance();
 }
Exemplo n.º 8
0
 private static function loadLang($lang)
 {
     if (!file_exists(__DIR__ . "/../I18n/{$lang}.json")) {
         ErrorManager::push("No I18n file for lang '{$lang}'", ErrorManager::ERROR_I18N_NO_LANG_FILE_FOUND);
     }
     self::$sentences = json_decode(file_get_contents(__DIR__ . "/../I18n/{$lang}.json"), true);
     self::$lang = $lang;
 }
Exemplo n.º 9
0
 public static function init()
 {
     if (!self::$errors) {
         self::$errors = new SplQueue();
     }
     if (!self::$logger) {
         self::$logger = Logger::getLogger(self::class);
     }
 }
Exemplo n.º 10
0
 function File($path = NULL, $new = False)
 {
     $this->separator = DIRECTORY_SEPARATOR;
     $this->os = getenv('OS');
     $this->setFilePath($path);
     if ($new) {
         $this->createFile();
     }
     parent::ErrorManager();
 }
Exemplo n.º 11
0
 public static function save($type_, $element_, $group_)
 {
     Logger::debug('main', "Abstract_Liaison::save ({$type_},{$element_},{$group_})");
     $sql2 = SQL::getInstance();
     $res = $sql2->DoQuery('SELECT @3,@4 FROM #1 WHERE @2=%5 AND @3=%6 AND @4=%7', self::table, 'type', 'element', 'group', $type_, $element_, $group_);
     if ($sql2->NumRows() > 0) {
         ErrorManager::report('liaison(type=' . $type_ . ',element=' . $element_ . ',group=' . $group_ . ') already exists');
         return false;
     }
     $res = $sql2->DoQuery('INSERT INTO #1 ( @2,@3,@4 ) VALUES ( %5,%6,%7)', self::table, 'type', 'element', 'group', $type_, $element_, $group_);
     return $res !== false;
 }
Exemplo n.º 12
0
 /**
  * Special class called when a method is not accessible or not exist
  * @param unknown $name
  * @param unknown $arguments
  */
 public function __call($name, $arguments)
 {
     // Already try to execute the error?
     /* TODO: Control correcto de esto (si el objeto tiene un controlador especial de errores)
     		if ($this->errorControl) ErrorManager::loadError($this->module, 404);
     		else ErrorManager::loadErrorFromObject($this, 404);*/
     ErrorManager::loadError($this->module, 404);
     $this->view = null;
     // Como ha habido un error, evitamos que se cargue la vista original (por si carga la de un error)
     /*$this->controller = 'errors';
     		$this->view = 'errors';
     		$this->error = Stringer::getStringBetween($name, 'e', 'Action');*/
 }
Exemplo n.º 13
0
 public function init()
 {
     $server = Abstract_Server::load($this->server);
     if (!is_object($server)) {
         Logger::error('apt-get', 'TASK::init for task ' . $this->id . ' returned an error (unknown server ' . $this->server . ')');
         return false;
     }
     $dom = new DomDocument('1.0', 'utf-8');
     $node = $dom->createElement('debian');
     $node->setAttribute('request', $this->getRequest());
     foreach ($this->getPackages() as $package) {
         $buf = $dom->createElement('package');
         $buf->setAttribute('name', $package);
         $node->appendChild($buf);
     }
     $dom->appendChild($node);
     $xml = $dom->saveXML();
     $xml = query_url_post_xml($server->getBaseURL() . '/aps/debian', $xml);
     if (!$xml) {
         ErrorManager::report('Unable to submit Task to server "' . $server->fqdn . '"');
         return false;
     }
     $dom = new DomDocument('1.0', 'utf-8');
     $buf = @$dom->loadXML($xml);
     if (!$buf) {
         return false;
     }
     if (!$dom->hasChildNodes()) {
         return false;
     }
     $node = $dom->getElementsByTagname('debian_request')->item(0);
     if (is_null($node)) {
         return false;
     }
     $this->job_id = $node->getAttribute('id');
     $this->status = $node->getAttribute('status');
     return true;
 }
Exemplo n.º 14
0
 private static function remove()
 {
     array_pop(self::$currentHandlerStack);
     // uninstall error handlers
     restore_error_handler();
     if (empty(self::$currentHandlerStack)) {
         self::$shutdownErrorDetectorEnabled = false;
     }
 }
Exemplo n.º 15
0
 /**
  * @param $email
  * @param Application $app
  * @return bool
  */
 public static function userExists($email, Application $app)
 {
     try {
         $query = $app->getDataManager()->getDataManager()->from("users")->select(null)->select(array('id'))->where(array("email" => $email))->fetch();
     } catch (\Exception $ex) {
         $error = new ErrorManager();
         $error->addMessage("Error : " . $ex->getMessage());
         return false;
     }
     return $query;
 }
Exemplo n.º 16
0
<?
include('config.php');
if(
	!$osimo->requirePOST('osimo_username',false) || 
	!$osimo->requirePOST('osimo_password',false) ||
	!$osimo->requirePOST('osimo_email',false)
){
	ErrorManager::error_redirect("missing_data", "This theme is not sending all the required data to register a user.");
}

$username = $osimo->POST['osimo_username'];
$password = $osimo->POST['osimo_password'];
$email = $osimo->POST['osimo_email'];

try {
	UserManager::register_user($username, $password, $email);
	
	header('Location: ../index.php');
} catch (OsimoException $e) {
	ErrorManager::error_redirect($e->getExceptionType(), $e->getMessage(), '../register.php');
}
?>
Exemplo n.º 17
0
 /**
  * absOOo::absOOo(), constructeur permettant uniquement d'instancié la classe pere de gestion des erreurs
  * 
  * @return none
  * @access public
  **/
 function absOOo()
 {
     parent::ErrorManager();
 }
Exemplo n.º 18
0
 public function isOnline()
 {
     if (!in_array($this->getAttribute('status'), array('ready', 'pending'))) {
         Logger::debug('main', 'Server::isOnline server "' . $this->fqdn . ':' . $this->web_port . '" is not "ready"');
         return false;
     }
     $warn = false;
     if (!$this->hasAttribute('status') || !$this->uptodateAttribute('status')) {
         $warn = true;
         $this->getStatus();
     }
     if ($this->hasAttribute('status') && in_array($this->getAttribute('status'), array('ready', 'pending'))) {
         return true;
     }
     if ($warn === true && $this->getAttribute('locked') == 0) {
         ErrorManager::report('"' . $this->fqdn . '": is NOT online!');
     }
     $this->isNotReady();
     return false;
 }
Exemplo n.º 19
0
 public function __construct()
 {
     $this->errorManager = ErrorManager::getInstance();
 }
Exemplo n.º 20
0
 public function getSessionSettings($container_)
 {
     $prefs = Preferences::getInstance();
     $overriden = array();
     $default_settings = $prefs->get('general', $container_);
     // load rules (overriden settings)
     $user_groups_preferences = Abstract_UserGroup_Preferences::load_all('general', $container_);
     $users_group_id = array();
     foreach ($user_groups_preferences as $key => $pref) {
         if (in_array($pref->usergroup_id, $users_group_id)) {
             continue;
         }
         array_push($users_group_id, $pref->usergroup_id);
     }
     // from this group, which are these I am into
     $users_groups_mine_ids = $this->get_my_usersgroups_from_list($users_group_id);
     // Finnaly, overwrite default settings with users groups settings
     foreach ($user_groups_preferences as $pref) {
         $key = $pref->element_id;
         if (!in_array($pref->usergroup_id, $users_groups_mine_ids)) {
             continue;
         }
         $element = $pref->toConfigElement();
         if (isset($overriden[$key]) && $overriden[$key] == true && $element->content != $default_settings[$key]) {
             ErrorManager::report('User "' . $this->getAttribute('login') . '" has at least two groups with the same overriden rule but with different values, the result will be unpredictable.');
         }
         $default_settings[$key] = $element->content;
         $overriden[$key] = true;
     }
     $prefs_of_a_user_unsort = Abstract_User_Preferences::loadByUserLogin($this->getAttribute('login'), 'general', $container_);
     foreach ($prefs_of_a_user_unsort as $key => $pref) {
         $element = $pref->toConfigElement();
         if (isset($overriden[$key]) && $overriden[$key] == true && $element->content != $default_settings[$key]) {
             Logger::debug("User '" . $this->getAttribute('login') . "' has at least overriden preferences but with different values, the result will be unpredictable.");
         }
         $default_settings[$key] = $element->content;
         $overriden[$key] = true;
     }
     return $default_settings;
 }
Exemplo n.º 21
0
 public function TemplateManager($bindings)
 {
     $this->bindings = $bindings;
     $this->errors = ErrorManager::getInstance();
 }
Exemplo n.º 22
0
 public function errorHandler($error_num, $error_var, $error_file, $error_line)
 {
     ErrorManager::instance()->driver->errorHandler($error_num, $error_var, $error_file, $error_line);
 }
Exemplo n.º 23
0
 public function addToServer($sharedfolder_, $an_fs_server_)
 {
     Logger::debug('main', "SharedFolderDB::internal::addToServer({$sharedfolder_}, {$an_fs_server_})");
     if (is_object($sharedfolder_) == false) {
         Logger::error('main', 'SharedFolderDB::internal sharedfolder parameter is not an object (content: ' . serialize($sharedfolder_));
         return false;
     }
     if (is_object($an_fs_server_) == false) {
         Logger::error('main', 'SharedFolderDB::internal fs parameter is not an object (content: ' . serialize($an_fs_server_));
         return false;
     }
     $sharedfolder_->server = $an_fs_server_->id;
     if ($this->exists($sharedfolder_->id) === false) {
         // we save the object first
         $ret = $this->add($sharedfolder_);
         // 			if ($ret !== true) {
         // 				Logger::error('main', "SharedFolderDB::internal failed to add $sharedfolder_ to the DB");
         // 				return false;
         // 			}
     }
     // do the request to the server
     $ret = $an_fs_server_->createNetworkFolder($sharedfolder_->id);
     if (!$ret) {
         ErrorManager::report('SharedFolderDB::internal Unable to create shared folder on file server "' . $sharedfolder_->server . '"');
         $this->remove($sharedfolder_);
         return false;
     }
     return true;
 }
Exemplo n.º 24
0
 function CDir()
 {
     $this->Init();
     parent::ErrorManager();
 }
Exemplo n.º 25
0
<?php

require_once 'initialize.php';
$userLogin = new LoginOptions();
$userCheck = new UsernameValidator();
$passCheck = new PasswordValidator();
$errorMan = new ErrorManager();
session_start();
$user = '';
$pass = '';
if (isset($_SESSION['username'])) {
    $userLogin->isLoggedIn();
}
if (isset($_POST['username'])) {
    $user = $_POST['username'];
}
if (isset($_POST['password'])) {
    $pass = $_POST['password'];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($passCheck->isValid($pass)) {
        if ($userCheck->isValid($user)) {
            $_SESSION['username'] = $user;
            $userLogin->isLoggedIn();
        } else {
            $errorMan->addError($user, 'Invalid Username. Username should be 5 alphabetic characters.');
        }
    } elseif ($userCheck->isValid($user)) {
        $errorMan->addError($pass, 'Invalid Password. Password should be at least 5 alpha numeric characters.');
    } else {
        $errorMan->addError($user, 'Invalid Username. Username should be 5 alphabetic characters.');
Exemplo n.º 26
0
<?php

require_once 'classes/initialize.php';
if (isset($_SESSION['username'])) {
    header('Location: account.php');
}
$usernameValidator = new UsernameValidator();
$passwordValidator = new PasswordValidator();
$errorManager = new ErrorManager();
$userLogin = new UserLogin();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!$usernameValidator->isValid($_POST['username'])) {
        $errorManager->addError('username', 'Please enter a valid username');
    }
    if (!$passwordValidator->isValid($_POST['password'])) {
        $errorManager->addError('password', 'Please enter a valid password');
    }
    if (!$errorManager->hasErrors()) {
        $userLogin->startSession($_POST['username']);
        header('Location: account.php');
        exit;
    }
}
require_once 'header.php';
?>

    <form action="index.php" method="POST">
        <div>
            <label>Username:</label> <input type="text" name="username" value="" placeholder="Enter Username">

            <span class="error"><?php 
Exemplo n.º 27
0
/**
 * Copyright (C) 2008-2012 Ulteo SAS
 * http://www.ulteo.com
 * Author Laurent CLOUET <*****@*****.**> 2008-2010
 * Author Jeremy DESVAGES <*****@*****.**> 2008-2010
 * Author Julien LANGLOIS <*****@*****.**> 2011, 2012
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
function die_error($error_ = false, $file_ = NULL, $line_ = NULL, $display_ = false)
{
    $errorManager = ErrorManager::getInstance();
    $errorManager->perform($error_, $file_, $line_, $display_);
}
Exemplo n.º 28
0
<?php

while (($error = ErrorManager::pop()) !== null) {
    echo "<div class=\"alert alert-" . ($error->severity == ErrorManager::SEVERITY_ERROR ? "danger" : "warning") . "\" role=\"alert\">\n        <button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\">\n          <span aria-hidden=\"true\">&times;</span>\n        </button>\n        " . $error->msg . "\n    </div>";
}
?>

<footer class="footer">
    <div class="container">
        <table class="table borderless">
            <tr>
                <td><a href="/about"><?php 
echo I18n::get("about");
?>
</a></td>
                <td><a href="/contact"><?php 
echo I18n::get("contact");
?>
</a></td>
                <td><a href="/legal"><?php 
echo I18n::get("legal");
?>
</a></td>
                <td><a href="/cookies"><?php 
echo I18n::get("cookies");
?>
</a></td>
            </tr>
        </table>
    </div>
</footer>
Exemplo n.º 29
0
<? get('theme')->include_header(); ?>

<div id="content">
	<div id="login_wrap">
		<div id="login_title">
			<h1>Sign In</h1>
		</div>
		<div id="login_desc">
			<h2>Enter your username and password</h2>
		</div>
		
		<? if(ErrorManager::is_error()): ?>
			<? $error = ErrorManager::get_error(); ?>
			<div id="error_wrap">
				<?php 
echo $error['msg'];
?>
			</div>
		<? endif; ?>
		
		<form id="login_form" action="<? get('theme')->login_action_url(); ?>" method="post">
			<p class="login_label">username</p>
			<input type="text" id="<? get('theme')->login_username_css_id(); ?>" name="<? get('theme')->login_username_name(); ?>" />
			<p class="login_label">password</p>
			<input type="password" id="<? get('theme')->login_password_css_id(); ?>" name="<? get('theme')->login_password_name(); ?>" />
			
			<div id="login_form_submit">
				<input type="submit" value="Login" />
			</div>
		</form>
	</div>
Exemplo n.º 30
0
    }
    ?>
	</ul>

	<h3>Everything's OK</h3>


<?php 
} catch (Exception $e) {
    // <<<<-------------- catch
    ?>

	<h3>There are errors!</h3>
	<ul>
	<?php 
    foreach (ErrorManager::getInstance()->getErrors() as $error) {
        ?>

		<li><?php 
        echo $error["message"];
        ?>
</li>	

	<?php 
    }
    ?>
			
	</ul>

<?php 
}