Ejemplo n.º 1
0
 public function init()
 {
     global $yakbb;
     $yakbb->loadLanguageFile("viewboard");
     // Get and validate board ID
     $this->boardid = intval($_GET["board"]);
     // Force integer value
     if ($this->boardid == 0) {
         $yakbb->error(2, "invalid_board_id");
     }
     // Need to check if board is in the database and load data if so.
     $yakbb->db->query("\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\tyakbb_boards\r\n\t\t\tWHERE\r\n\t\t\t\tid='" . $this->boardid . "'\r\n\t\t\tLIMIT\r\n\t\t\t\t1\r\n\t\t");
     if ($yakbb->db->numRows() == 0) {
         $yakbb->error(2, "board_doesnt_exist");
     }
     $this->bdata = $yakbb->db->fetch();
     // Check some permissions
     $perms = boardPermissions($this->boardid);
     if ($perms["view"] == false) {
         $yakbb->error(2, "perms_cant_view_board");
     }
     // Calculate pagination and then load threads
     $showpagination = false;
     $totalpages = 1;
     if ($this->bdata["threads"] > 0) {
         // Don't load threads if no posts/threads. We'll still load announcements
         // Load pagination
         $currentpage = isset($_GET["page"]) && intval($_GET["page"]) > 0 ? intval($_GET["page"]) : 1;
         if ($this->bdata["threads"] > $yakbb->config["threads_per_page"]) {
             $showpagination = true;
             $totalpages = ceil($this->bdata["threads"] / $yakbb->config["threads_per_page"]);
             if ($currentpage > $totalpages) {
                 $yakbb->error(2, "viewboard_page_doesnt_exist");
             }
         } else {
             $totalpages = 1;
         }
         $yakbb->db->query("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tt.*,\r\n\t\t\t\t\tu.username, u.displayname, u.group,\r\n\t\t\t\t\tlpu.username AS lpusername, lpu.displayname AS lpdisplay, lpu.group AS lpgroup\r\n\t\t\t\tFROM\r\n\t\t\t\t\tyakbb_threads t\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\tyakbb_users u\r\n\t\t\t\t\tON (u.id = t.creatorid)\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\tyakbb_users lpu\r\n\t\t\t\t\tON (u.id = lastpostuser)\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tt.parentid = '" . $this->boardid . "'\r\n\t\t\t\tORDER BY\r\n\t\t\t\t\tt.lastposttime DESC,\r\n\t\t\t\t\tt.id DESC\r\n\t\t\t\tLIMIT\r\n\t\t\t\t\t" . ($currentpage - 1) * $yakbb->config["threads_per_page"] . ", " . $yakbb->config["threads_per_page"] . "\r\n\t\t\t");
         $this->threads = array();
         while ($t = $yakbb->db->fetch()) {
             $t["url"] = url_thread($t["id"], $t["name"]);
             $t["link"] = link_thread($t["id"], $t["name"]);
             $t["starterlink"] = link_user($t["creatorid"], $t["username"], $t["displayname"], $t["group"]);
             $t["lpuserlink"] = link_user($t["lastpostuser"], $t["lpusername"], $t["lpdisplay"], $t["lpgroup"]);
             $t["lpdate"] = makeDate($t["lastposttime"]);
             $this->threads[] = $t;
         }
     }
     // Template stuff
     $yakbb->smarty->assign("showpagination", $showpagination);
     $yakbb->smarty->assign("totalpages", $totalpages);
     $yakbb->smarty->assign("boardid", $this->boardid);
     $yakbb->smarty->assign("page_title", $this->bdata["name"]);
     $yakbb->smarty->assign("threads", $this->threads);
     $yakbb->loadTemplate("viewboard.tpl");
 }
Ejemplo n.º 2
0
 public function init()
 {
     global $yakbb;
     $yakbb->loadLanguageFile("viewthread");
     // Get and validate thread ID
     $this->threadid = intval($_GET["thread"]);
     // Force integer value
     if ($this->threadid == 0) {
         $yakbb->error(2, "invalid_thread_id");
     }
     // Need to check if thread is in the database and load data if so.
     $yakbb->db->query("\r\n\t\t\tSELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\tyakbb_threads\r\n\t\t\tWHERE\r\n\t\t\t\tid='" . $this->threadid . "'\r\n\t\t\tLIMIT\r\n\t\t\t\t1\r\n\t\t");
     if ($yakbb->db->numRows() == 0) {
         $yakbb->error(2, "thread_doesnt_exist");
     }
     $this->tdata = $yakbb->db->fetch();
     // Check some permissions
     $perms = boardPermissions($this->tdata["parentid"]);
     if ($perms["view"] == false) {
         $yakbb->error(2, "perms_cant_view_board");
     }
     // Load posts
     $yakbb->db->query("\r\n\t\t\tSELECT\r\n\t\t\t\tp.id AS postid, p.*,\r\n\t\t\t\tu.*\r\n\t\t\tFROM\r\n\t\t\t\tyakbb_posts p\r\n\t\t\tLEFT JOIN\r\n\t\t\t\tyakbb_users u\r\n\t\t\t\tON (p.userid = u.id)\r\n\t\t\tWHERE\r\n\t\t\t\tp.threadid='" . $this->threadid . "'\r\n\t\t\tORDER BY\r\n\t\t\t\tp.timestamp ASC\r\n\t\t\tLIMIT\r\n\t\t\t\t15\r\n\t\t");
     $this->posts = array();
     while ($p = $yakbb->db->fetch()) {
         $p["userlink"] = link_user($p["userid"], $p["username"], $p["displayname"], $p["group"]);
         $p["message"] = $yakbb->parser->parse($p["message"]);
         $this->posts[] = $p;
     }
     // Raise view count if not thread creator
     if ($this->tdata["creatorid"] == $yakbb->user["id"]) {
         $yakbb->db->query("\r\n\t\t\t\tUPDATE\r\n\t\t\t\t\tyakbb_threads\r\n\t\t\t\tSET\r\n\t\t\t\t\tviews=views+1\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tid = '" . $this->threadid . "'\r\n\t\t\t\tLIMIT\r\n\t\t\t\t\t1\r\n\t\t\t");
     }
     // Template stuff
     $yakbb->smarty->assign("viewcount", $this->tdata["views"] + 1);
     $yakbb->smarty->assign("threadid", $this->threadid);
     $yakbb->smarty->assign("page_title", $this->tdata["name"]);
     $yakbb->smarty->assign("posts", $this->posts);
     $yakbb->loadTemplate("viewthread.tpl");
 }
Ejemplo n.º 3
0
 }
 $boards = '';
 while ($a_category = db_result($r_category)) {
     $new_cat = 0;
     $session_cat = 'c' . $a_category['category_id'];
     // openclose Variable
     if ($_SESSION['openclose'] == 0) {
         $_SESSION[$session_cat] = $a_category['category_is_open'];
         // SESSION_vars für openclose setzen
     }
     $board_count = 0;
     $r_boards = db_query("SELECT\n\t         board_id,\n\t\t     board_name,\n\t\t\t board_under,\n\t\t\t last_act_time,\n\t\t\t last_post_id,\n\t\t\t last_act_user, \n\t\t\t last_thread_id, \n\t\t\t last_act_thread,\n\t\t\t threads,\n\t\t\t posts,\n\t\t\t threads_del,\n\t\t\t posts_del\n\t     FROM " . $pref . "board WHERE disabled='0' AND category='" . $a_category['category_id'] . "' ORDER BY board_order ASC");
     if (db_rows($r_boards) > 0) {
         $category = '';
         while ($board = db_result($r_boards)) {
             $P = boardPermissions(U_GROUPIDS, $board['board_id']);
             if ($P[0] == 1) {
                 $board_count++;
                 $session_var = 'b' . $board['board_id'];
                 $new_topic = 0;
                 $gif = '';
                 if (U_ID != 0) {
                     if ($board['last_post_id'] > $_SESSION[$session_var] && $board['last_post_id'] != 0) {
                         $gif = '_new';
                         $new_topic = 1;
                         $new_cat = 1;
                     }
                 }
                 $boardname = '<a href="board.php?boardid=' . $board['board_id'] . '"><b>' . $board['board_name'] . '</b></a>';
                 $boardname .= '<br />[smallfont]' . $board['board_under'] . '[smallfontend]';
                 $threads = $board['threads'];
Ejemplo n.º 4
0
    define("U_ISURADMIN", '0');
    define("U_GROUPIDS", ',' . $config['guest_groupid'] . ',');
    define("U_STYLEID", '0');
    $r_guest = db_query("SELECT\n\t     last_act_time\n\t FROM " . $pref . "guest WHERE session_id='{$sid}'");
    if (db_rows($r_guest) == 1) {
        $a_guest = db_result($r_guest);
        define("U_LAST", $a_guest['last_act_time']);
        db_query("UPDATE " . $pref . "guest SET\n\t\t\t last_act_time='{$board_time}' WHERE session_id='{$sid}'");
    } else {
        define("U_LAST", 0);
        db_query("INSERT INTO " . $pref . "guest SET\n\t\t     session_id='{$sid}',\n\t\t\t last_act_time='{$board_time}'");
    }
}
// _groups lesen und Rechtestring erstellen
if (isset($boardid)) {
    $P = boardPermissions(U_GROUPIDS, $boardid);
    define('P_VIEW', $P[0]);
    define('P_REPLY', $P[1]);
    define('P_POSTNEW', $P[2]);
    define('P_CLOSE', $P[3]);
    define('P_MOVE', $P[4]);
    define('P_TDELETE', $P[5]);
    define('P_TOP', $P[6]);
    define('P_EDITTOPIC', $P[7]);
    define('P_EDIT', $P[8]);
    define('P_OEDIT', $P[9]);
    define('P_DELPOST', $P[10]);
    define('P_ODELPOST', $P[11]);
    define('P_EDITCLOSED', $P[12]);
    define('P_IP', $P[13]);
    define('P_NOFLOODPROT', $P[14]);
Ejemplo n.º 5
0
 /**
  * Generate a report on the current permissions by board and membergroup.
  * functions ending with "Report" are responsible for generating data
  * for reporting.
  * they are all called from action_index.
  * never access the context directly, but use the data handling
  * functions to do so.
  */
 public function action_board_perms()
 {
     global $txt;
     // Get as much memory as possible as this can be big.
     setMemoryLimit('256M');
     // Boards, first.
     require_once SUBSDIR . '/Boards.subs.php';
     require_once SUBSDIR . '/Membergroups.subs.php';
     // Lets get started
     $query_boards = array();
     if (isset($_REQUEST['boards'])) {
         if (!is_array($_REQUEST['boards'])) {
             $query_boards['boards'] = array_map('intval', explode(',', $_REQUEST['boards']));
         } else {
             $query_boards['boards'] = array_map('intval', $_REQUEST['boards']);
         }
     } else {
         $query_boards = 'all';
     }
     // Fetch the board names and profiles.
     // This returns id_board, name, id_profile keys
     $boards = fetchBoardsInfo($query_boards, array('sort_by' => 'id_board', 'selects' => 'permissions'));
     $profiles = array();
     foreach ($boards as $b) {
         $profiles[] = $b['id_profile'];
     }
     // Groups, next.
     $query_groups = array();
     if (isset($_REQUEST['groups'])) {
         if (!is_array($_REQUEST['groups'])) {
             $query_groups = array_map('intval', explode(',', $_REQUEST['groups']));
         } else {
             $query_groups = array_map('intval', $_REQUEST['groups']);
         }
         $group_clause = 'id_group IN ({array_int:groups})';
     } else {
         $group_clause = '1=1';
     }
     // Get all the possible membergroups, except admin!
     require_once SUBSDIR . '/Reports.subs.php';
     $all_groups = allMembergroups($group_clause, $query_groups);
     if (empty($query_groups) || in_array(-1, $query_groups) || in_array(0, $query_groups)) {
         $member_groups = array('col' => '', -1 => $txt['membergroups_guests'], 0 => $txt['membergroups_members']) + $all_groups;
     } else {
         $member_groups = array('col' => '') + $all_groups;
     }
     // Make sure that every group is represented - plus in rows!
     setKeys('rows', $member_groups);
     // Permissions, last!
     $boardPermissions = boardPermissions($profiles, $group_clause, $query_groups);
     $permissions = array();
     $board_permissions = array();
     foreach ($boardPermissions as $row) {
         foreach ($boards as $id => $board) {
             if ($board['id_profile'] == $row['id_profile']) {
                 $board_permissions[$id][$row['id_group']][$row['permission']] = $row['add_deny'];
             }
         }
         // Make sure we get every permission.
         if (!isset($permissions[$row['permission']])) {
             // This will be reused on other boards.
             $permissions[$row['permission']] = array('title' => isset($txt['board_perms_name_' . $row['permission']]) ? $txt['board_perms_name_' . $row['permission']] : $row['permission']);
         }
     }
     // Now cycle through the board permissions array... lots to do ;)
     foreach ($board_permissions as $board => $groups) {
         // Create the table for this board first.
         newTable($boards[$board]['name'], 'x', 'all', 100, 'center', 200, 'left');
         // Add the header row - shows all the membergroups.
         addData($member_groups);
         // Add the separator.
         addSeparator($txt['board_perms_permission']);
         // Here cycle through all the detected permissions.
         foreach ($permissions as $ID_PERM => $perm_info) {
             // Default data for this row.
             $curData = array('col' => $perm_info['title']);
             // Now cycle each membergroup in this set of permissions.
             foreach ($member_groups as $id_group => $name) {
                 // Don't overwrite the key column!
                 if ($id_group === 'col') {
                     continue;
                 }
                 $group_permissions = isset($groups[$id_group]) ? $groups[$id_group] : array();
                 // Do we have any data for this group?
                 if (isset($group_permissions[$ID_PERM])) {
                     // Set the data for this group to be the local permission.
                     $curData[$id_group] = $group_permissions[$ID_PERM];
                 } else {
                     $curData[$id_group] = 'x';
                 }
                 // Now actually make the data for the group look right.
                 if (empty($curData[$id_group])) {
                     $curData[$id_group] = '<span class="alert">' . $txt['board_perms_deny'] . '</span>';
                 } elseif ($curData[$id_group] == 1) {
                     $curData[$id_group] = '<span class="success">' . $txt['board_perms_allow'] . '</span>';
                 } else {
                     $curData[$id_group] = 'x';
                 }
             }
             // Now add the data for this permission.
             addData($curData);
         }
     }
 }