protected function getForum() { $requestData = $this->getRequestData(); if (isset($requestData['clan'])) { $clan = new Dolumar_Players_Clan($requestData['clan']); if ($clan) { $login = Neuron_Core_Login::__getInstance(); if ($login->isLogin()) { $me = Neuron_GameServer::getPlayer(); $isMember = $clan->isMember($me); $isModerator = $clan->isModerator($me); //__construct ($iForumType, $iForumId, $objUser = false, $bCanSeeAll = false, $bIsModerator = false) $forum = new Neuron_Forum_Forum(1, $clan->getId(), $me, $isMember, $isModerator); } else { $forum = new Neuron_Forum_Forum(1, $clan->getId(), false, false, false); } // Fetch thze title $text = Neuron_Core_Text::__getInstance(); $forum->setTitle(Neuron_Core_Tools::putIntoText($text->get('title', 'forum', 'clan'), array('clan' => Neuron_Core_Tools::output_varchar($clan->getName())))); return $forum; } else { return false; } } else { return false; } }
protected function getForum() { $text = Neuron_Core_Text::__getInstance(); $login = Neuron_Core_Login::__getInstance(); if ($login->isLogin()) { $me = Neuron_GameServer::getPlayer(); $forum = new Neuron_Forum_Forum(0, 0, $me, $me->isChatModerator(), $me->isChatModerator()); } else { $forum = new Neuron_Forum_Forum(0, 0, false, false, false); } $forum->setTitle($text->get('ingameForum', 'menu', 'main')); return $forum; }
public function getHTML($input) { global $fdb; global $scopeBuster; $scopeBuster->input = $input; $page = new Neuron_Core_Template(); //q($input); if (count($fdb->x("\n \t\t\t\t\tSELECT\n \t\t\t\t\t\t*\n \t\t\t\t\tFROM\n \t\t\t\t\t\t`forum_bans`\n \t\t\t\t\tWHERE\n \t\t\t\t\t\t`ID`={$this->userID} AND `forumID`='{$this->compID}'\n \t\t\t\t")) == 1) { $page->set('content', 'You have been banned from this forum'); $page->set('mode', 'banned'); return $page->parse('forum.tpl'); die('There is no future. Forum:' . __LINE__); } $nowt = false; $done = false; //if not changed to true, triggers a default forum view later; that happens if no action set, invalid action, or invalid data if (!$input || !isset($input['action'])) { $input['action'] = 'default'; } switch ($input['action']) { case 'newTopic': if ($this->board->isBoard($input['board']) && $this->board->guestable($input['board']) && $input['title'] != '' && $input['post'] != '') { //if true board is valid & visable to user, and they've said something... $topic = $this->topic->makeNew($input['board'], $input['title'], $input['post']); $input = array('board' => $input['board']); $done = true; } else { break; } case 'viewBoard': if ($this->board->isBoard($input['board'])) { //also checks board access validity :) $topics = $this->topic->getList($input['board']); $info['board'] = $input['board']; $info['boardTitle'] = $this->board->getTitle($input['board']); $info['empty'] = count($topics) == 0 ? 'true' : 'false'; //$debug[] = $topics; //$page->set('debug', $debug); $page->set('mode', 'board'); $page->set('topics', $topics); $page->set('info', $info); $done = true; } break; /******************************************/ /******************************************/ case 'reply': if ($this->topic->isTopic($input['topic'])) { $board = $this->topic->getParentBoard($input['topic']); if ($this->board->isVisible($board) && $this->board->guestable($board) && $input['post'] != '') { $post = $this->post->makeNew($board, $input['topic'], $input['post']); $posts = $this->post->getList($input['topic']); $input = array('topic' => $input['topic'], 'pageNumber' => ceil(count($posts) / 15)); $done = true; } } else { break; } case 'viewTopic': if ($this->topic->isTopic($input['topic'])) { if ($this->board->isVisible($this->topic->getParentBoard($input['topic']))) { $posts = $this->post->getList($input['topic']); $info['board'] = $this->topic->getParentBoard($input['topic']); $info['boardTitle'] = $this->board->getTitle($info['board']); $info['topicTitle'] = $this->topic->getTitle($input['topic']); $info['topic'] = $input['topic']; $page->set('mode', 'topic'); $page->set('posts', $posts); $page->set('info', $info); $done = true; } } break; case 'editPost': //not used oop overly much here as other information is needed too, and tbh I doubt much else'd need this functionality if ($this->post->isPost(intval($input['postID'])) && $this->post->canEdit($input['postID'])) { $myPostID = $input['postID']; safen($myPostID); $postQuery = $fdb->x("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`board_id`,\n\t\t\t\t\t\t`poster_id`,\n\t\t\t\t\t\t`topic_id`,\n\t\t\t\t\t\t`post_content`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`forum_posts`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`ID`='{$myPostID}'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"); $resultToo = $fdb->x("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`ID`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`forum_posts`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`topic_id`='" . $postQuery[0]['topic_id'] . "'\n\t\t\t\t\tORDER BY\n\t\t\t\t\t\t`created` ASC\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"); $info['firstReply'] = $resultToo[0]['ID'] == $input['postID']; $info['topic'] = $postQuery[0]['topic_id']; $info['postID'] = $input['postID']; $info['board'] = $postQuery[0]['board_id']; $info['boardTitle'] = $this->board->getTitle($info['board']); $info['topicTitle'] = $this->topic->getTitle($info['topic']); textBits::toBB($postQuery[0]['post_content']); //altered by reference //textBits::dbUnpack($postQuery[0]['post_content']); $info['post'] = $postQuery[0]['post_content']; $page->set('mode', 'editPost'); $page->set('info', $info); $done = true; } break; case 'deletePost': //q($input, 'input(EP)'); if ($this->isMod && isset($input['postID'])) { if ($this->post->isPost($input['postID'])) { $this->modlog("Deleted post ID {$input['postID']}"); $topic = $this->post->getTopic($input['postID']); $this->post->deletePost($input['postID']); $forumToo = new Neuron_Forum_Forum($this->forumType, $this->forumID, $this->objUser, $this->isOmni, $this->isMod); $input = array('action' => 'viewTopic', 'topic' => $this->post->getTopic($input['postID'])); $forumToo->getHTML($input); return $forumToo->getHTML($input); $nowt = true; } } break; case 'editedPost': //var_dump($input); //print 'asd'.$this->topic->isTopic(intval($input['topic'])).'asd'; if ($this->post->canEdit($input['postID'])) { $postQuery = $fdb->x("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`board_id`,\n\t\t\t\t\t\t`poster_id`,\n\t\t\t\t\t\t`topic_id`,\n\t\t\t\t\t\t`post_content`\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`forum_posts`\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t`ID`='" . intval($input['postID']) . "'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"); if ($postQuery[0]['poster_id'] != $this->userID) { $this->modlog("Edited post ID {$input['postID']}"); } if (isset($input['topic']) && $this->topic->isTopic(intval($input['topic']))) { $this->post->update($input['postID'], $input['post'], $input['topic']); } else { $this->post->update($input['postID'], $input['post']); } $forumToo = new Neuron_Forum_Forum($this->forumType, $this->forumID, $this->objUser, $this->isOmni, $this->isMod); $input = array('action' => 'viewTopic', 'topic' => intval($input['topic'])); return $forumToo->getHTML($input); $nowt = true; } break; case 'topicAdmin': if ($this->isMod) { $page->set('mode', 'topicAdmin'); $page->set('board', $input['board']); $topics = $this->topic->getList($input['board']); $page->set('topics', $topics); $done = true; } break; case 'topicAdminSave': //q($input); $max = array(); foreach ($input as $k => $in) { if (substr($k, 0, 9) == 'topicType') { $max[] = substr($k, 10); } } sort($max); $top = array_pop($max); if ($this->isMod) { $curCount = 0; while ($curCount <= $top) { if (isset($input['topicType_' . $curCount])) { $topicType = intval($input['topicType_' . $curCount]); if ($topicType != 'unchanged' && ($topicType == '1' || $topicType == '2' || $topicType == '3')) { if ($this->topic->isTopic(intval($curCount))) { $this->modlog("Changed topic ID {$curCount} to type {$topicType} (1 = A, 2 = S, 3 = N)"); $fdb->q("\n\t\t\t\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\t\t\t\t`forum_topics`\n\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\t`type`='{$topicType}'\n\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t`ID`='{$curCount}'\n\t\t\t\t\t\t\t\t"); } } if (array_key_exists("delete_{$curCount}", $input)) { if ($this->topic->isTopic(intval($curCount))) { $title = $this->topic->getTitle($curCount); $this->modlog("Deleted topic ID {$curCount} ({$title})"); $this->topic->deleteTopic($curCount); } } } $curCount++; } } $this->board->reStat(intval($input['board'])); $forumToo = new Neuron_Forum_Forum($this->forumType, $this->forumID, $this->objUser, $this->isOmni, $this->isMod); $input = array('action' => 'viewBoard', 'board' => intval($input['board'])); return $forumToo->getHTML($input); $nowt = true; break; case 'boardAdmin': if ($this->isMod) { $boards = $this->board->getList(); $page->set('mode', 'boardAdmin'); $page->set('boards', $boards); $done = true; } break; case 'boardAdminSave': //print 'adsadsadd';/// //q($input); if ($this->isMod) { //load existing stuff. $highest = array(0); foreach ($input as $ik => $in) { if (substr($ik, 0, 6) == 'DelNum') { $highest[] = substr($ik, 6); } } sort($highest); $highest = array_pop($highest); if ($highest < $input['totalRows']) { $highest = $input['totalRows']; } $X = 0; //I know this is really ugly, but without var[] there's not much else I can do, without a large re-write & replan. You should have said sooner that [] was broken :( while ($X <= $highest && $X < 9000) { if (isset($input["DelNum{$X}"]) && !isset($input["Made{$X}"])) { //q($input["Priv$X"]); //print 'asdsd'; //q($input); if ($this->board->isBoard($X) && !isset($input["Made{$X}"]) && $input['DelNum' . $X] == 'Preserve' && $input['DelNum' . $X] !== 0) { //if board exists then update the name, desc and position. if not, then insert a new row with the relevant data //$dbg[] = "board exists ($X) - trying to update info"; safen($input["TitleNum{$X}"]); safen($input["DescNum{$X}"]); safen($input["Position{$X}"]); $priv = 0; $guest = 0; if (isset($input["Priv{$X}"])) { $priv = $input["Priv{$X}"] == 'on' ? 1 : 0; } if (isset($input["guest_{$X}"])) { $guest = $input["guest_{$X}"] == 'on' ? 1 : 0; } $fdb->q("\n\t\t\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\t\t\t`forum_boards`\n\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t`title`='" . $input['TitleNum' . $X] . "',\n\t\t\t\t\t\t\t\t\t`desc`='" . $input['DescNum' . $X] . "',\n\t\t\t\t\t\t\t\t\t`order`='" . $input['Position' . $X] . "',\n\t\t\t\t\t\t\t\t\t`private`='{$priv}',\n\t\t\t\t\t\t\t\t\t`guestable`='{$guest}'\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t`ID`='{$X}'\n\t\t\t\t\t\t\t"); } elseif ($input["DelNum{$X}"] != 'Preserve' && $X != 0) { //prevents chit-chat from being removed //$dbg[] = 'killing '.$X.' !'; $this->modlog("Deleted Board! ID ( {$X}, title was " . $this->board->getTitle($X) . " )"); $fdb->q("DELETE FROM `forum_boards` WHERE `ID`={$X}"); $fdb->q("DELETE FROM `forum_topics` WHERE `forum_id`='" . $this->compID . "' AND `board_id`={$X}"); $fdb->q("DELETE FROM `forum_posts` WHERE `forum_id`='" . $this->compID . "' AND `board_id`={$X}"); } } else { if (isset($input['DelNum' . $X])) { if (isset($input["Made{$X}"])) { $fdb->q("\n\t\t\t\t\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\t\t\t\t\t`forum_boards`\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t`forum_id`,\n\t\t\t\t\t\t\t\t\t\t`title`,\n\t\t\t\t\t\t\t\t\t\t`desc`,\n\t\t\t\t\t\t\t\t\t\t`order`\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t'" . $this->compID . "',\n\t\t\t\t\t\t\t\t\t\t'" . $input['TitleNum' . $X] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $input['DescNum' . $X] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $input['Position' . $X] . "'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t"); } } } $X++; } } break; case 'banAdmin': if ($this->isMod) { $bans = $fdb->x("SELECT * FROM `forum_bans`"); //var_dump($bans); $page->set('mode', 'banAdmin'); $page->set('bans', $bans); //$page->set('debug', $bans); $done = true; } break; case 'banAdminSave': if ($this->isMod) { $highest = array(0); foreach ($input as $ik => $in) { if (substr($ik, 0, 6) == 'DelNum') { $highest[] = substr($ik, 6); } } sort($highest); $highest = array_pop($highest); if ($highest < $input['totalRows']) { $highest = $input['totalRows']; } $X = 0; while ($X <= $highest && $X < 9000) { if (isset($input["DelNum{$X}"]) && !isset($input["Made{$X}"])) { if ($input["DelNum{$X}"] == 'Pickle') { $fdb->q("DELETE FROM `forum_bans` WHERE `ID`={$X}"); $this->modlog("Deleted ban - ID {$X}"); } } else { if (isset($input["Made{$X}"]) && $input['IDNum' . $X] != '' && $input['IDNum' . $X] != 0) { safen($input['ReasonNum' . $X]); $input['IDNum' . $X] = intval($input['IDNum' . $X]); $fdb->q("\n\t\t\t\t\t\t\t\tINSERT INTO\n\t\t\t\t\t\t\t\t\t`forum_bans`\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t`user`,\n\t\t\t\t\t\t\t\t\t`forumID`,\n\t\t\t\t\t\t\t\t\t`time`,\n\t\t\t\t\t\t\t\t\t`reason`,\n\t\t\t\t\t\t\t\t\t`by`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t'" . $input['IDNum' . $X] . "',\n\t\t\t\t\t\t\t\t\t'{$this->compID}',\n\t\t\t\t\t\t\t\t\t'" . time() . "',\n\t\t\t\t\t\t\t\t\t'" . $input['ReasonNum' . $X] . "',\n\t\t\t\t\t\t\t\t\t'{$this->userID}'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t"); } } $X++; } $bans = $fdb->x("SELECT * FROM `forum_bans`"); $page->set('mode', 'banAdmin'); $page->set('bans', $bans); $done = true; } break; } if (!$done) { $boards = $this->board->getList(); $page->set('mode', 'index'); $page->set('boards', $boards); } if (!$nowt) { return $page->parse('forum.tpl'); } }