function __construct() { parent::Controller(); if (!is_logged_in() && !is_in_group(4)) { redirect('login/index'); } $this->load->model('Series_model', 'sm'); }
/** * Function to check if a user is a moderator of a forum */ function is_moderator($user, $forum) { global $_USERGROUPS; if (is_a($user, 'FAUser')) { $user = $user->getInfoArray(); } if (!is_array($user)) { trigger_error('Invalid $user call for is_moderator.', E_USER_ERROR); } if ($user['perms'] >= ADMIN) { return TRUE; } $result = explode('|', trim($forum['moderating_groups'], '|')); $moderators = !$result ? force_usergroups($forum['moderating_groups']) : $result; $groups = array(); foreach ($moderators as $g) { if (isset($_USERGROUPS[$g])) { $groups[] = $g; } } if (isset($user['usergroups'])) { $unserialize = explode('|', trim($user['usergroups'], '|')); $my_groups = !$unserialize ? force_usergroups($user['usergroups']) : $unserialize; /* Do we toggle our moderator's panel? */ if (is_in_group($my_groups, $groups, $user['perms'])) { return TRUE; } } if ($forum['moderating_users'] != '') { $users = force_unserialize($forum['moderating_users']); if (is_array($users)) { foreach ($users as $user_id => $username) { if ($user['name'] == $username && $user['id'] == $user_id) { return TRUE; } } } } return FALSE; }
/** * Function to check if a user is a moderator of a forum */ function is_moderator($user, $forum) { global $_USERGROUPS; if ($user['perms'] >= ADMIN) { return TRUE; } $moderators = !@unserialize($forum['moderating_groups']) ? force_usergroups($forum['moderating_groups']) : unserialize($forum['moderating_groups']); /* Make _sure_ that the moderating groups for this forum are set */ //if(!is_array($moderators) || empty($moderators)) { // if(isset($_USERGROUPS[6]) && $_USERGROUPS[6]['min_perm'] >= ADMIN) { // $moderators = array(6); // } else { // foreach($_USERGROUPS as $g) // if($g['min_perm'] >= ADMIN) // $moderators = array($g['id']); // } //} $groups = array(); foreach ($moderators as $g) { if (isset($_USERGROUPS[$g])) { $groups[] = $g; } } if (isset($user['usergroups'])) { $my_groups = !@unserialize($user['usergroups']) ? force_usergroups($user['usergroups']) : unserialize($user['usergroups']); /* Do we toggle our moderator's panel? */ if (is_in_group($my_groups, $groups, $user['perms'])) { return TRUE; } } return FALSE; }
function edit_data() { global $fname; global $fname_st; if (strlen($_POST['val']) > 102400 || strlen($_POST['val']) + filesize($fname) > 10485760) { return "0"; } $did = B64AtoV($_POST['did'], 0, 5); $uid = B64AtoV($_POST['uid'], 0, 2); $enc = B64AtoV($_POST['val'], 0, 4); $val = substr($_POST['val'], 4); $tmpfname = "tmp" . $uid . ".txt"; if (!copy($fname, $tmpfname) || ($fp = fopenL($fname, "w", LOCK_EX, 10, 250)) == false) { return "0"; } if (($fpr = fopenL($tmpfname, "r", LOCK_SH, 10, 250)) == false) { fclose($fp); return "0"; } $r = "1"; $f = false; while (!feof($fpr)) { $str = fgets($fpr); $str_did = B64AtoV($str, 0, 5); $r .= "#" . $str_did; if (($str_did = B64AtoV($str, 0, 5)) != $did) { $r .= "[D]"; fwrite($fp, ($f ? "\n" : "") . $str); $f = false; continue; } $str_uid = B64AtoV($str, 9, 2); $str_gid = B64AtoV($str, 11, 2); if ($uid == ($str_uid & 0x1ff) || $str_uid & 0x400 || $str_gid & 0x400 && is_in_group($uid, $str_gid & 0x1ff)) { $str = substr($str, 0, 13) . VtoB64A($enc, 4) . $val; $f = true; } if (enc & 0x800000) { //add pos count to strlen of val } fwrite($fp, $str); } fclose($fp); fclose($fpr); unlink($tmpfname); return $r; }
</div> <ul> <li><a href="<?php echo base_url(); ?> ">Start</a></li> <li><a href="<?php echo base_url(); ?> series">Serier</a></li> <li><a href="<?php echo base_url(); ?> series/favorites">Favoriter</a></li> <?php if (is_in_group(4)) { ?> <li><a href="<?php echo base_url(); ?> admin">Admin</a></li> <?php } ?> <li><a href="<?php echo base_url(); ?> login/logout">Logga ut</a></li> </ul> </div>