예제 #1
0
 public static function createConfig($dir, $file)
 {
     if (!fopen(self::$userDepo . "/" . $dir . $file, 'w')) {
         ErrorLogHandling::register("Cannot open file:" . $file . " , catch line: " . __LINE__ . " ,method: " . __METHOD__ . " ,class: " . get_class($this));
         return false;
     } else {
         return TRUE;
     }
 }
예제 #2
0
 public static function getError($text = '')
 {
     ErrorLogHandling::register("Error is occured." . $text . " USER ID:" . SessionService::getInstance()->get('userId') . " DATE: " . date("F j, Y, g:i a"));
     if (file_exists(\GLOBALVAR\CONTROLLERS_PATH . '/errorControl.php')) {
         header("HTTP/1.1 301 Moved Permanently");
         header("Location: " . \GLOBALVAR\ROOT . "/?core=error");
         header("Connection: close");
     }
 }
예제 #3
0
 public static function writeContent($dir, $record)
 {
     try {
         $res = file_put_contents($dir, $record, FILE_APPEND);
     } catch (Exception $e) {
         ErrorLogHandling::register("Cannot put contents:" . $e->getMessage() . " , catch line: " . __LINE__ . " ,method: " . __METHOD__ . " ,class: " . get_class($this));
         return false;
     }
     return $res;
 }
 public function __construct()
 {
     try {
         $this->connection = pg_connect("host='" . parent::$serverName . "' port='" . parent::$serverPort . "'dbname='" . parent::$dbName . "' user='******'password='******'");
         if (!is_resource($this->connection)) {
             throw new Exception("Can't connect to the database.");
         }
     } catch (Exception $e) {
         ErrorLogHandling::register($e . "Can't connect to the database.");
     }
 }
예제 #5
0
 public function __construct()
 {
     try {
         $this->connection = mysql_connect(parent::$serverName, parent::$serverPort, parent::$dbName, parent::$userName, parent::$passCode . "'");
         if (!$this->connection) {
             throw new Exception("Can't connect to the database.");
         }
     } catch (Exception $e) {
         ErrorLogHandling::register($e . "Can't connect to the database.");
     }
 }
예제 #6
0
 public static function registerData($email, $password)
 {
     //$hashPass = crypt($password);
     $crypt = new Mcrypt();
     $hashPass = $crypt->encrypt($password);
     $newUser = $email . "\t" . $hashPass . "\n";
     if (file_put_contents(self::$userLogFile, $newUser, FILE_APPEND) && self::createDirectory($email)) {
         return true;
     } else {
         ErrorLogHandling::register("Wrong registration process, catch line: " . __LINE__ . " ,method: " . __METHOD__ . " ,class: " . get_class($this));
         return false;
     }
 }
예제 #7
0
 public function render($temp, $permit = NULL)
 {
     // pokud je nastaveno opravneni, je provedena autorizace uzivatele
     if (!empty($permit)) {
         if (!$this->user->isAllowed($permit)) {
             ErrorLogHandling::register("Unauthorized access attempted . TEMP: {$temp}  " . __LINE__ . " ,method: " . __METHOD__);
             return FALSE;
         }
     }
     if ($this->render == $temp) {
         $path = \GLOBALVAR\VIEWS_PATH . "/" . $this->core . "/" . $temp . '.php';
         if (file_exists($path)) {
             require_once $path;
         } else {
             require_once \GLOBALVAR\VIEWS_PATH . "/error/index.php";
         }
     }
 }
예제 #8
0
 public static function callAction($controller)
 {
     $response = array();
     try {
         if (isset($_GET['action']) && !empty($_GET['action'])) {
             if (method_exists($controller, 'action_' . $_GET['action'])) {
                 $response = call_user_func(array($controller, 'action_' . $_GET['action']));
             }
         }
         if (method_exists($controller, 'action_main') && !$controller->stopPropagation()) {
             $response = array_merge($response, call_user_func(array($controller, 'action_main')));
         }
     } catch (Exception $e) {
         ErrorLogHandling::register("Exception is occured." . $e->getMessage() . " USER ID:" . SessionService::getInstance()->get('userId') . " DATE: " . date("F j, Y, g:i a"));
         ErrorLogHandling::getException($e->getMessage());
     }
     return $response;
 }
예제 #9
0
 public static function getError($text = '')
 {
     ErrorLogHandling::register("Error is occured." . $text . " USER ID:" . SessionService::getInstance()->get('userId') . " DATE: " . date("F j, Y, g:i a"));
     ErrorLogHandling::getErrorPage();
 }
예제 #10
0
 public static function setLostPass($email)
 {
     $pass = self::generateTempPass();
     $hashPass = crypt($pass);
     $res = pg_query(self::$connect, "UPDATE aplikace.uzivatel SET nove_heslo = '{$hashPass}' WHERE email = '{$email}' RETURNING jmeno_uzivatel");
     $data = pg_fetch_array($res);
     if ($data) {
         return array('new_pass' => $pass, 'jmeno_uzivatel' => $data['jmeno_uzivatel']);
     } else {
         ErrorLogHandling::register("Email: " . $email . ", line:" . __LINE__ . " ,method: " . __METHOD__ . " ,class: " . get_called_class() . "DATE:" . date("Y-m-d H:i:s"));
         return false;
     }
 }