コード例 #1
0
ファイル: profile.php プロジェクト: nok32/SoftUni
//
$topics_model = new \Models\Topic_Model();
$user_model = new \Models\User_Model();
$message = '';
$message1 = '';
if (isset($_GET['mid'])) {
    $mid = $_GET['mid'];
    $user = $user_model->find(array('where' => 'id = "' . $mid . '"'));
    if (empty($user)) {
        header('Location: ' . DX_ROOT_URL);
        exit;
    }
} else {
    header('Location: ' . DX_ROOT_URL);
    exit;
}
$member = $user_model->get($mid);
$topics = $topics_model->find(array('where' => 'user_id = "' . $mid . '"'));
if (isset($_POST['name'], $_POST['email'])) {
    $message = $register_controller->update(array('id' => $_SESSION['user_id'], 'name' => $_POST['name'], 'email' => $_POST['email']));
}
if (isset($_POST['curr-password'], $_POST['password'], $_POST['confirm-pass'])) {
    $message1 = $register_controller->update(array('id' => $_SESSION['user_id'], 'curr-password' => $_POST['curr-password'], 'password' => $_POST['password'], 'confirm-pass' => $_POST['confirm-pass']));
}
if (isset($_GET['logout'])) {
    Lib\Auth::get_instance()->logout();
    header('Location: ' . DX_ROOT_URL);
}
$title = 'Profile';
$template_file = 'views/profile.php';
include 'views/layouts/default.php';
コード例 #2
0
ファイル: category.php プロジェクト: nok32/SoftUni
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 '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();
$topics_model = new \Models\Topic_Model();
if (isset($_GET['cid'])) {
    $cid = $_GET['cid'];
    $topics = $topics_model->find(array('where' => 'category_id = "' . $cid . '"'));
    if (empty($topics)) {
        header('Location: ' . DX_ROOT_URL);
        exit;
    }
} else {
    header('Location: ' . DX_ROOT_URL);
    exit;
}
if (isset($_GET['logout'])) {
    Lib\Auth::get_instance()->logout();
    header('Location: ' . DX_ROOT_URL);
    exit;
}
$title = 'Forum';
$template_file = 'views/category.php';
コード例 #3
0
ファイル: topic.php プロジェクト: nok32/SoftUni
include_once 'root.php';
include_once 'lib/database.php';
include_once 'lib/auth.php';
include_once 'controllers/master_controller.php';
include_once 'models/master.php';
include_once 'models/category.php';
include_once 'models/topic.php';
include_once 'models/answer.php';
$db = \Lib\Database::get_instance()->get_db();
$auth = \Lib\Auth::get_instance();
$topics_model = new \Models\Topic_Model();
$answer_model = new \Models\Answer_Model();
$message = '';
if (isset($_GET['tid'])) {
    $tid = $_GET['tid'];
    $topic = $topics_model->find(array('where' => 'id = "' . $tid . '"'));
    if (!empty($topic)) {
        $views = $topic[0]['views'] + 1;
        $topics_model->update(array('id' => $tid, 'views' => $views));
    } else {
        header('Location: ' . DX_ROOT_URL);
    }
} else {
    header('Location: ' . DX_ROOT_URL);
}
$answers = $answer_model->find(array('where' => 'topic_id = "' . $tid . '"'));
if (count($answers) <= PER_PAGE) {
    $initialPages = 1;
} elseif (count($answers) % PER_PAGE === 0) {
    $initialPages = intval(count($answers) / PER_PAGE);
} else {