コード例 #1
0
ファイル: backend.class.php プロジェクト: anhvn/pokerspot
 /**
  * Handle form action
  */
 protected function formAction()
 {
     switch ($this->s->action) {
         case 'reload':
             // element: submenu
             $this->s->resetParams('form');
             $module = $this->s->loadModule($this->s->controller);
             $tpl = new Template('system');
             $tpl->assign('subnav', $this->generateNav($module->getSection()));
             $tpl->display('submenu.html');
             return true;
             break;
         case 'submenu':
             if ($this->s->element == '') {
                 Error::addWarning('Fehler: ID des Untermenüs ist nicht definiert!');
                 return false;
             }
             $section = str_replace('nav_', '', $this->s->element);
             $this->s->resetParams();
             $tpl = new Template('system');
             $tpl->assign('subnav', $this->generateNav($section));
             $tpl->display('submenu.html');
             return true;
             break;
         case 'cleanlog':
             if ($this->s->element == 'error') {
                 $file = fopen("logs/error.log", "w+");
                 fclose($file);
             }
             return true;
             break;
     }
 }
コード例 #2
0
ファイル: backend.class.php プロジェクト: anhvn/pokerspot
 /**
  * Handle form action
  */
 protected function formAction()
 {
     switch ($this->s->action) {
         case 'activate':
             if ($this->s->element != '') {
                 $module = Module::getInstance($this->s->element);
                 $module->active = $this->vars['option'] == 'set' ? true : false;
                 if ($module->save()) {
                     return true;
                 }
             } else {
                 Error::addWarning('Fehler: Es wurde kein Modul ausgewählt!');
             }
             return false;
             break;
     }
 }
コード例 #3
0
 /**
  * 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;
     }
 }
コード例 #4
0
 /**
  * delete current message from server
  *
  * @return bool
  * @author Elias Müller
  **/
 public function delete()
 {
     if (($error = $this->server->DeleteMessage($this->current)) == "") {
         return true;
     } else {
         Error::addWarning('Fehler beim Mail-Abruf: Eine Nachricht konnte nicht gelöscht werden', true);
     }
     return false;
 }
コード例 #5
0
ファイル: message.class.php プロジェクト: anhvn/pokerspot
 /**
  * delete the object
  */
 public function delete()
 {
     $db = DB::getInstance();
     if (!is_array($this->info['replies'])) {
         $sql = "DELETE FROM messages\n\t\t\t\t\t WHERE idmessage = " . $this->id;
         if ($db->query($sql) === true) {
             return true;
         }
     } else {
         Error::addWarning('Nachricht kann nicht gelöscht werden: Noch Antworten vorhanden!');
     }
     return false;
 }
コード例 #6
0
ファイル: backend.class.php プロジェクト: anhvn/pokerspot
 /**
  * login to the backend system
  *
  * @param string $username
  * @param string $password
  */
 public function login($username, $password)
 {
     session_start();
     $user = User::getInstance($username);
     //Error::addMessage($this->generateHash($password));
     if ($user !== false) {
         $hash = $this->generateHash($password, $user->password);
         if ($hash == $user->password) {
             $_SESSION['loggedin'] = $username;
             // set datetime of login
             $user->last_login = $user->current_login;
             $user->current_login = date("Y-m-d H:i:s");
             $user->save();
             // redirect to previous page
             $hostname = $_SERVER['HTTP_HOST'];
             $path = dirname($_SERVER['PHP_SELF']);
             header('Location: http://' . $hostname . ($path == '/' ? '' : $path) . '/' . ($this->s->config['site']['has_frontend'] === true ? 'admin/' : '') . $this->s->post["path"]);
             return true;
         }
     }
     $_SESSION['loggedin'] = 0;
     Error::addWarning("Login fehlgeschlagen! Benutzername und/oder Passwort falsch!");
     return false;
 }
コード例 #7
0
ファイル: backend.class.php プロジェクト: anhvn/pokerspot
 /**
  * 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;
 }