예제 #1
0
}
$message = array();
$steps = he_quiz::check_steps($quiz_id);
if ($task == 'save_general') {
    $name = trim($_POST['name']);
    $description = trim($_POST['description']);
    $cat_id = (int) $_POST['cat_id'];
    $photo = $_FILES['photo'];
    $result = he_quiz::save_quiz($quiz_id, $user->user_info['user_id'], $name, $description, $cat_id);
    $quiz_id = !$quiz_id && $result ? $result : $quiz_id;
    if (!$result) {
        $message = array('type' => 'error', 'title' => SE_Language::get(690691090), 'text' => SE_Language::get(690691094));
    } else {
        $file_upload = he_quiz::save_photo($quiz_id, $photo);
        if (!$file_upload['result'] && $photo['name']) {
            $message = array('type' => 'notice', 'text' => $file_upload['error']);
            $redirect_url = "quiz_general.php?quiz_id={$quiz_id}";
        } else {
            $redirect_url = "quiz_results.php?quiz_id={$quiz_id}";
        }
        header("Location: {$redirect_url}");
    }
}
$general_info = $quiz_id ? he_quiz::general_info($quiz_id) : $_POST;
$quiz_cats = he_quiz::find_cats();
$smarty->assign('quiz_id', $quiz_id);
$smarty->assign('general_info', $general_info);
$smarty->assign('steps', $steps);
$smarty->assign('message', $message);
$smarty->assign('quiz_cats', $quiz_cats);
include "footer.php";
예제 #2
0
<?php

$page = "browse_quiz";
include "header.php";
$current_page = isset($_GET['page']) && $_GET['page'] ? (int) $_GET['page'] : 1;
$mode = isset($_GET['mode']) && $_GET['mode'] ? trim($_GET['mode']) : 'popular';
$cat_id = isset($_GET['cat_id']) && $_GET['cat_id'] ? (int) $_GET['cat_id'] : 0;
//TODO get from configs
$on_page = 10;
$pages = 5;
$first = ($current_page - 1) * $on_page;
$where_cond = $cat_id != 0 ? he_database::placeholder("AND `quiz`.`cat_id`=?", $cat_id) : '';
if ($mode != 'commented') {
    $quiz_arr = he_quiz::quiz_list($first, $on_page, $mode, $where_cond);
    $quiz_total = he_quiz::quiz_total($where_cond);
} else {
    $quiz_arr = he_quiz::recent_commented_list($first, $on_page, $where_cond);
    $quiz_total = he_quiz::recent_commented_total($where_cond);
}
$quiz_cats = he_quiz::find_cats($where_cond);
$taked_quiz_list = he_quiz::recent_taked_quizzes();
$smarty->assign('mode', $mode);
$smarty->assign('current_page', $current_page);
$smarty->assign('quiz_arr', $quiz_arr);
$smarty->assign('message', $message);
$smarty->assign('paging', array('total' => $quiz_total, 'on_page' => $on_page, 'pages' => $pages));
$smarty->assign('quiz_cats', $quiz_cats);
$smarty->assign('taked_quiz_list', $taked_quiz_list);
$smarty->assign('cat_id', $cat_id);
include "footer.php";