Пример #1
0
 public function login($username, $password)
 {
     $db = \Lib\Database::get_instance();
     $dbconn = $db->get_db();
     $statement = $dbconn->prepare("SELECT id, role_id FROM users WHERE username = ? AND password = ? LIMIT 1");
     $statement->bind_param('ss', $username, $password);
     $statement->execute();
     $statement->bind_result($id, $role_id);
     $statement->fetch();
     if ($id && $role_id) {
         $_SESSION['username'] = $username;
         $_SESSION['user_id'] = $id;
         $_SESSION['role_id'] = $role_id;
         return true;
     }
     //
     //
     //		$result_set = $statement->store_result();
     //
     //		if ( $row = $result_set->fetch() ) {
     //			$_SESSION['username'] = $username;
     //			$_SESSION['user_id'] = $row['id'];
     //            $_SESSION['role_id'] = $row['role_id'];
     //			return true;
     //		}
     return false;
 }
Пример #2
0
 public function __construct($arg = array())
 {
     $arg = array('limit' => 0);
     if (!isset($arg['table'])) {
         die('Table not defined');
     }
     extract($arg);
     $this->table = $table;
     $this->limit = $limit;
     $db_object = \Lib\Database::get_instance();
     $this->db = $db_object::get_db();
 }
 public function __construct($args = array())
 {
     $args = array_merge(array('where' => '', 'columns' => '*', 'limit' => 0), $args);
     if (!isset($args['table'])) {
         die('Table not defined. Please define a model table.');
     }
     extract($args);
     $this->table = $table;
     $this->where = $where;
     $this->columns = $columns;
     $this->limit = $limit;
     $db_object = \Lib\Database::get_instance();
     $this->dbconn = $db_object::get_db();
 }
Пример #4
0
 public function login($username, $password)
 {
     $db_object = \Lib\Database::get_instance();
     $db = $db_object->get_db();
     $statement = $db->prepare("SELECT id FROM users WHERE username = ? AND password = MD5 ( ? ) LIMIT 1");
     $statement->bind_param('ss', $username, $password);
     $statement->execute();
     $result_set = $statement->get_result();
     if ($row = $result_set->fetch_assoc()) {
         $_SESSION['username'] = $row['username'];
         $_SESSION['user_id'] = $row['id'];
         return true;
     }
     return false;
 }
Пример #5
0
<?php

header('Content-Type: text/html; charset=utf-8');
// Db
include 'config/db.php';
include_once 'root.php';
include_once 'lib/database.php';
include_once 'lib/auth.php';
include_once 'controllers/master_controller.php';
include_once 'controllers/topics.php';
include_once 'models/master.php';
include_once 'models/category.php';
include_once 'models/topic.php';
$db = \Lib\Database::get_instance()->get_db();
$auth = \Lib\Auth::get_instance();
$topic_controller = new \Controllers\Topic_Controller();
$category_model = new \Models\Category_Model();
$topics_model = new \Models\Topic_Model();
$message = '';
$categories = $category_model->find(array('columns' => 'name'));
if (isset($_POST['submit'])) {
    $message = $topic_controller->add($categories);
}
$title = 'Forum';
$template_file = 'views/addTopic.php';
include 'views/layouts/default.php';
Пример #6
0
 */
define('DX_ROOT_DIR', dirname(__FILE__) . '/');
define('DX_ROOT_PATH', basename(dirname(__FILE__)) . '/');
$request = $_SERVER['REQUEST_URI'];
$request_home = '/' . DX_ROOT_PATH;
$controller = 'master';
$methods = 'index';
$param = array();
include_once './config/db.php';
include_once './lib/database.php';
include_once 'controllers\\master.php';
if (!empty($request)) {
    if (0 === strpos($request, $request_home)) {
        $request = substr($request, strlen($request_home));
        $components = explode('/', $request, 3);
        if (1 < count($components)) {
            list($controller, $methods) = $components;
            if (isset($components[2])) {
                $param = $components[2];
            }
            include_once 'controllers/' . $controller . '.php';
        }
    }
}
$controller_class = '\\Controllers\\' . ucfirst($controller) . '_Controller';
$instance = new $controller_class();
if (method_exists($instance, $methods)) {
    call_user_func_array(array($instance, $methods), array($param));
}
$db_object = \Lib\Database::get_instance();
$db_conn = $db_object::get_db();