if(!isset($_SESSION['logged_user'])) {
header('Location: /'); exit;
}
if($_SESSION['logged_user'] != 'admin') {
header('Location: /'); exit;
}
function getPerPageNews ($page,$ads_per_page,$search='') {
if($page) $start=($page-1)*$ads_per_page;
global $db;
global $appearance_settings, $ads_settings, $settings, $seo_settings;
$db = new mysqli('localhost', 'user', 'password', 'base');
$field="category_id";
if($search!='') $where=" where `$field` = '$search'"; else $where="";
$limit_str = "";
if($page) $limit_str = " order by `created_at` desc limit ".$start.", ".$ads_per_page;
$result = $db->query("select * from `posts`$where".$limit_str);
$results = array();
while ($row = $result->fetch_assoc()) {
array($results, array(
'id' => cleanStr($row['id']),
'title' => cleanStr($row['title']),
'content' => cleanStr($row['content']),
'image_url' => cleanStr($row['image_url']),
'post_url' => cleanStr($row['post_url']),
'created_at' => cleanStr($row['created_at']),
'summary' => cleanStr($row['summary'])
));
}
$result->free();
return $results;
}
if( !$test_id ) return;
$ulogin = null;
if(isset($_SESSION['logged_user'])) {
$ulogin = $_SESSION['logged_user'];
}
global $db;
$query = "SELECT q.question, q.parent_test, a.id, a.answer, a.parent_question, u.group
FROM questions q
LEFT JOIN answers a
ON q.id = a.parent_question
LEFT JOIN test
ON test.id = q.parent_test
INNER JOIN users u
ON u.group = test.GroupId
WHERE q.parent_test = $test_id AND test.enable = '1' AND u.login = '$ulogin'";
$res = mysqli_query($db, $query);
$data = null;
while ($row = mysqli_fetch_assoc($res)) {
if( !$row['parent_question'] ) return false;
$data[$row['parent_question']][0]= $row['question'];
$data[$row['parent_question']][$row['id']] = $row['answer'];
}
return $data;
global $db;
$ulogin = null;
if(isset($_SESSION['logged_user'])) {
$ulogin = $_SESSION['logged_user'];
}
$query = "SELECT *
FROM
test AS t
LEFT JOIN users AS u
ON u.login = '$ulogin'
WHERE
t.enable = '1'
AND
t.GroupId = u.group";
$res = mysqli_query($db, $query);
if(!$res) return false;
$data = array();
while($row = mysqli_fetch_assoc($res)){
$data[] = $row;
}
return $data;
AND u.login = 'logged_user'