Exemple #1
0
 public static function createUser($data)
 {
     $sql = "INSERT INTO " . self::$table . " SET " . "email_user = '******'email_user']) . "'," . "login_user = '******'login_user']) . "'," . "password_user = '******'login_user'])) . "'";
     print $sql;
     parent::query($sql);
     return parent::queryError();
 }
Exemple #2
0
 public static function getCurrentUserId()
 {
     // get curent user data
     $user_data = parent::getSession('curent_user');
     $_get_id_user = isset($_GET['id_user']) ? $_GET['id_user'] : null;
     $_post_id_user = isset($_POST['id_user']) ? $_POST['id_user'] : null;
     return self::is_SuperUserSession() ? $_post_id_user ? $_post_id_user : ($_get_id_user ? $_get_id_user : $user_data['id_user']) : parent::getSession('id_user');
 }
 static function deleteLogData($id_platform)
 {
     $sql = "DELETE FROM check_log WHERE id_platform = '" . $id_platform . "'";
     parent::query($sql);
     if (parent::queryError()) {
         self::$errors[] = parent::queryError();
     }
     return null;
 }
 private function Authorize($login, $password)
 {
     if (authModel::checkInBase($login, $password)) {
         classModel::setSession(array('login' => true));
         // set loggined user data
         authModel::$userData = usersModel::getUser("login_user = '******' AND " . "password_user = '******'");
         // write to session
         classModel::setSession(array('userData' => authModel::$userData));
         // go to main admin page
         header("Location: " . $this->makeURI(array('controller' => 'archive')));
         exit;
     } else {
         authModel::$errors[] = 'Wrong login\\password';
     }
     return null;
 }
Exemple #5
0
 public static function checkInBase($data, $exceptions = array())
 {
     $condition = array();
     if (is_array($data)) {
         foreach ($data as $k => $v) {
             if (!in_array($k, $exceptions)) {
                 $condition[] = $k . ' = "' . parent::escapeString($v) . '"';
             }
         }
     }
     if (count($condition)) {
         $sql = "SELECT * FROM check_log\n                    WHERE " . implode(" AND ", $condition);
         $q = parent::query($sql);
         $r = parent::fetchAssoc($q);
         print parent::queryError();
         return $r['id_check_log'] ? $r['id_check_log'] : false;
     }
     return false;
 }
 private function createTopMenu()
 {
     classModel::$adminTopMenu = $this->render_common("adminTopMenu", array(array("title" => "Archive", "href" => self::makeURI(array("controller" => "archive")), "controller" => "archive"), array("title" => "Broadcast", "href" => self::makeURI(array("controller" => "broadcast")), "controller" => "broadcast"), array("title" => "Users", "href" => self::makeURI(array("controller" => "users")), "controller" => "users")));
 }
 /**
  * Get app list
  * @return string
  */
 private function getUsersList()
 {
     $users_list = userModel::getUsers();
     foreach ($users_list as $k => $v) {
         $users_list[$k]['btn_edit'] = $this->render_common('btn_edit', array('url' => $this->makeURI(array('action' => 'edit', 'id_user' => $v['id_user']))));
         if (classModel::getCurrentUserId() !== $v['id_user']) {
             $users_list[$k]['btn_delete'] = $this->render_common('btn_delete', array('url' => $this->makeURI(array('action' => 'delete', 'id_user' => $v['id_user'])), 'confirm_text' => 'Do you want to delete this user?'));
         } else {
             $users_list[$k]['btn_delete'] = 'Current';
         }
     }
     return $this->render('users_list', array('users_list' => $users_list));
 }
 private function getFilter()
 {
     if (authModel::is_SuperUserSession()) {
         $id_user = classModel::getCurrentUserId();
         // if the superuser is logged - set id user according to the filter state
         classModel::setSession('id_user', $id_user);
         return $this->render('filter_section', array('user_filter' => userModel::getUsers(), 'curent_user' => $id_user));
     } else {
         return null;
     }
 }
 public function logout_class($user_id, $class_id)
 {
     if (empty(self::$conn)) {
         self::$conn = $this->connect_pdo();
     }
     $sql = "DELETE FROM join_class WHERE user_id=? AND class_id=?";
     $stmt = self::$conn->prepare($sql);
     $stmt->bindParam(1, $user_id);
     $stmt->bindParam(2, $class_id);
     if ($stmt->execute()) {
         return true;
     } else {
         return false;
     }
 }
Exemple #10
0
 public static function deleteLogData($id_application)
 {
     $sql = "DELETE FROM check_log WHERE id_application = '" . $id_application . "'";
     parent::query($sql);
     if (parent::queryError()) {
         self::$errors[] = parent::queryError();
     }
     return null;
 }
Exemple #11
0
<?php

include 'constants.php';
// settings constants
include 'functions.php';
// functions
// save computed controller an action names
classModel::$controller = $controller;
classModel::$action = $action;
// define executed class name and method
$controller .= 'Controller';
$action .= 'Action';
// if can't find controller file - go 404
if (!file_exists(CONTEROLLERS_DIR . '/' . $controller . '.php')) {
    _404();
}
//  init controller and execute action
if (!method_exists($obj = new $controller(), $action)) {
    _404();
} else {
    $obj->{$action}();
}