/**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if ($eventObj->poll->messageType == 'post') {
         // check permissions
         require_once WBB_DIR . 'lib/data/post/Post.class.php';
         $post = new Post($eventObj->poll->messageID);
         if (!$post->postID) {
             throw new IllegalLinkException();
         }
         require_once WBB_DIR . 'lib/data/thread/Thread.class.php';
         $thread = new Thread($post->threadID);
         $thread->enter();
         require_once WBB_DIR . 'lib/data/board/Board.class.php';
         $board = new Board($thread->boardID);
         $eventObj->canVotePoll = $board->getPermission('canVotePoll');
         // plug in breadcrumbs
         WCF::getTPL()->assign(array('board' => $board, 'thread' => $thread, 'showThread' => true));
         WCF::getTPL()->append('specialBreadCrumbs', WCF::getTPL()->fetch('navigation'));
         // get other polls from this thread
         if ($thread->polls > 1) {
             require_once WCF_DIR . 'lib/data/message/poll/Poll.class.php';
             $polls = array();
             $sql = "SELECT \t\tpoll_vote.pollID AS voted,\n\t\t\t\t\t\t\tpoll_vote.isChangeable,\n\t\t\t\t\t\t\tpoll.*\n\t\t\t\t\tFROM \t\twcf" . WCF_N . "_poll poll\n\t\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_poll_vote poll_vote\n\t\t\t\t\tON \t\t(poll_vote.pollID = poll.pollID\n\t\t\t\t\t\t\t" . (!WCF::getUser()->userID ? "AND poll_vote.ipAddress = '" . escapeString(WCF::getSession()->ipAddress) . "'" : '') . "\n\t\t\t\t\t\t\tAND poll_vote.userID = " . WCF::getUser()->userID . ")\n\t\t\t\t\tWHERE \t\tpoll.pollID IN (\n\t\t\t\t\t\t\t\tSELECT\tpollID\n\t\t\t\t\t\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\t\t\t\t\t\tWHERE\tthreadID = " . $thread->threadID . "\n\t\t\t\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t\t\t\t\t\tAND pollID <> 0\n\t\t\t\t\t\t\t)\n\t\t\t\t\tORDER BY\tpoll.question";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $polls[] = new Poll(null, $row, $eventObj->canVotePoll);
             }
             if (count($polls) > 1) {
                 WCF::getTPL()->assign(array('polls' => $polls, 'pollID' => $eventObj->pollID));
                 WCF::getTPL()->append('additionalSidebarContent', WCF::getTPL()->fetch('pollOverviewSidebar'));
             }
         }
     }
 }
Exemple #2
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth)
 {
     $weight = $this->getPrecedence();
     $indent = $board->indent($depth);
     $operator = $this->getName();
     $index = 0;
     /* @var $child Node */
     foreach ($this->getChildren() as $child) {
         // Prep
         $wrap = $child->getPrecedence() < $weight;
         // Indent
         if ($this->isBlock()) {
             $index && $board->write("\n");
             $board->write($indent);
         }
         // Operator
         if ($index) {
             $board->write($this->isBlock() ? '' : ' ');
             $board->write($operator);
             $board->write($child->isBlock() && !$wrap ? '' : ' ');
         }
         // Child:
         $wrap && $board->write("(");
         $child->isBlock() && $board->write("\n");
         // ---
         $child->build($board, $depth + 1);
         // ---
         $wrap && $board->write(")");
         // ===
         $index++;
     }
 }
Exemple #3
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth)
 {
     $board->write('INSERT INTO ');
     $this->table->build($board, $depth + 1);
     $board->write(" (");
     $this->columns->build($board, $depth + 1);
     $board->write(")\n");
     $this->data->build($board, $depth + 1);
 }
Exemple #4
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth = 0)
 {
     $resolve = $board->getResolve();
     $sql = $resolve ? $this->toSql($board) : '?';
     $board->write($sql);
     if (!$resolve) {
         $board->add($this->getValue());
     }
 }
 public function IndexGuncelToHTML()
 {
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     $connection->set_charset("utf8");
     echo "<div style=\"margin:2%;background-color:#e6e6e6;border-bottom:1px solid #c7d0d5;\">";
     echo "<p style=\"font-size:20px;word-wrap:break-word;color:#cb7c7a;font-family: 'Josefin Sans', sans-serif;\">";
     echo "Güncel panolar";
     echo "</p>";
     echo "</div>";
     echo "<div style=\"\">";
     $results = $connection->query("SELECT * FROM boards ORDER BY boardID DESC LIMIT 6 OFFSET 0");
     while ($boardInfos = $results->fetch_assoc()) {
         $myBoard = new Board(array($boardInfos['boardID'], $boardInfos['boardName'], $boardInfos['boardCategory'], $boardInfos['boardCreator'], $boardInfos['boardImage'], $boardInfos['boardDate']));
         $myBoard->BoardToPetitHTML();
     }
     echo "</div>";
     echo "<div id=\"x\" style=\"margin:2%;background-color:#e6e6e6;border-bottom:1px solid #c7d0d5;\">";
     echo "<p style=\"font-size:20px;word-wrap:break-word;color:#cb7c7a;font-family: 'Josefin Sans', sans-serif;\">";
     echo "Güncel içerikler";
     echo "</p>";
     echo "</div>";
     echo "<div style=\"\">";
     if (!$connection->connect_error) {
         $results = $connection->query("SELECT * FROM threads ORDER BY threadID DESC LIMIT 12 OFFSET 0 ");
         while ($curres = $results->fetch_assoc()) {
             $threadID5 = $curres["threadID"];
             $threadDate5 = $curres["threadDate"];
             $threadWriter5 = $curres["threadWriter"];
             $threadCategory5 = $curres["threadCategory"];
             $threadPicture5 = $curres["threadPicture"];
             $stepCount5 = $curres["stepCount"];
             $threadName5 = $curres["threadName"];
             $threadPoint5 = $curres["threadPoint"];
             $myThread5 = new Thread(array($threadID5, $threadDate5, $threadWriter5, $threadCategory5, $threadPicture5, $stepCount5, $threadName5, $threadPoint5));
             $myThread5->ThreadToPetitHTML();
         }
         echo "<div id=\"moreBestDiv\"></div>";
         echo "<div style=\"\">";
         echo "<form id=\"loadMoreBestForm\" method=\"post\" action=\"loadMoreRecentIndex.php\">";
         echo "<input id=\"loadMoreBestOffset\" name=\"loadMoreBestOffset\" style=\"display:none;\" value=\"" . $results->num_rows . "\"/>";
         echo "<button id=\"loadMoreBestButton\" class=\"btn btn-block btn-success\">";
         echo "<i id=\"loadMoreBestSpinner\" style=\"display:none;\" class=\"fa fa-refresh fa-spin\"></i>";
         echo "<span id=\"loadMoreBestTXT\">";
         echo "Daha fazla göster";
         echo "</span>";
         echo "</button>";
         echo "</form>";
         echo "</div>";
     }
     echo "</div>";
     echo "<script type=\"text/javascript\">";
     echo "\n\t\t\t\$(window).scroll(function(){\n\t\t\t\tvar p = \$('#x');\n\t\t\t\tvar pos = p.position();\n\t\t\t\tvar windowpos = \$(window).scrollTop();\n\t\t\t\tif (windowpos >= pos.top) {\n\t\t\t\t\t\$('#indexStickyFooter').fadeIn(500);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t\$('#indexStickyFooter').fadeOut(500);\n\t\t\t});\n\t\t\t\$('#loadMoreBestButton').click(function(e){\n\t\t\t\te.preventDefault();\n\t\t\t\t\$('#loadMoreBestTXT').hide();\n\t\t\t\t\$('#loadMoreBestSpinner').show();\n\t\t\t\t\$('#loadMoreBestForm').ajaxForm({\n\t\t\t\t\tsuccess : function(msg){\n\t\t\t\t\t\t\$('#loadMoreBestTXT').show();\n\t\t\t\t\t\t\$('#loadMoreBestSpinner').hide();\n\t\t\t\t\t\tnewoffset = msg.charAt(0);\n\t\t\t\t\t\toldoffset = \$('#loadMoreBestOffset').val();\n\t\t\t\t\t\toldint = parseInt(oldoffset);\n\t\t\t\t\t\tnewint = parseInt(newoffset);\n\t\t\t\t\t\tif (newint==0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\$('#loadMoreBestTXT').html(\"Hepsi yüklendi\");\n\t\t\t\t\t\t\t\$('#loadMoreBestButton').attr(\"disabled\",true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\$('#loadMoreBestOffset').val(oldint+newint);\n\t\t\t\t\t\tmsg2 = msg.substring(1);\n\t\t\t\t\t\t\$('#moreBestDiv').append(msg2);\n\t\t\t\t\t},\n\t\t\t\t\terror : function(){\n\n\t\t\t\t\t}\n\t\t\t\t}).submit();\n\t\t\t});\t\n\t\t";
     echo "</script>";
 }
 public function addBoard()
 {
     try {
         $db = new DB();
         $board = new Board($_POST["name"], $_POST["description"], $_GET["user"]);
         $sql = "INSERT INTO board(name,description,owner_id) VALUES (:name,:description,:owner_id)";
         $q = $db->getConnection()->prepare($sql);
         $q->execute(array(':name' => $board->getName(), ':description' => $board->getDescription(), ':owner_id' => $board->getOwnerId()));
     } catch (PDOException $e) {
         echo $e->getMessage();
     }
 }
Exemple #7
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth)
 {
     $board->write('DELETE FROM ');
     $this->table->build($board, $depth + 1);
     $where = $this->where;
     if ($where) {
         $board->write("\n");
         $board->write('WHERE');
         $board->write($where->isBlock() ? "\n" : " ");
         $where->build($board, $depth + 1);
     }
 }
Exemple #8
0
function writePins(array $rgb)
{
    static $pi, $r, $g, $b;
    if ($pi === null) {
        $pi = new Board();
        $r = $pi->getPin(0)->mode(Pin::SOFT_PWM_OUT)->softPwmWrite(100);
        $g = $pi->getPin(1)->mode(Pin::SOFT_PWM_OUT);
        $b = $pi->getPin(2)->mode(Pin::SOFT_PWM_OUT);
    }
    $r->softPwmWrite($rgb[0]);
    $g->softPwmWrite($rgb[1]);
    $b->softPwmWrite($rgb[2]);
}
 public function test5x6Game()
 {
     $bombs = [new Point(2, 2), new Point(2, 3), new Point(4, 5)];
     $settings = new Settings(['length' => 5, 'width' => 6, 'bombs' => count($bombs)]);
     $board = new Board($settings);
     $board->initBombs($bombs);
     $game = new Game($board);
     ob_start();
     $game->play(__DIR__ . '/resources/5x6_game_input.txt');
     $output = ob_get_clean();
     $expectedOutput = file_get_contents(__DIR__ . '/resources/5x6_game_expected_output.txt');
     $this->assertEquals($expectedOutput, $output);
 }
    /**
     * @see EventListener::execute()
     */
    public function execute($eventObj, $className, $eventName)
    {
        if ($eventName == 'init') {
            $eventObj->sqlSelects .= 'wbb_user.posts,';
            $eventObj->sqlJoins .= ' LEFT JOIN wbb' . WBB_N . '_user wbb_user
						ON (wbb_user.userID = user.userID) ';
        } else {
            if ($eventName == 'assignVariables') {
                $user = $eventObj->frame->getUser();
                $eventObj->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('postM.png'), 'title' => WCF::getLanguage()->get('wcf.user.posts'), 'value' => '<a href="index.php?form=Search&amp;types[]=post&amp;userID=' . $user->userID . SID_ARG_2ND . '" title="' . WCF::getLanguage()->get('wcf.user.profile.search', array('$username' => StringUtil::encodeHTML($user->username))) . '">' . StringUtil::formatInteger(intval($user->posts)) . ($user->getProfileAge() > 1 ? ' ' . WCF::getLanguage()->get('wcf.user.postsPerDay', array('$posts' => StringUtil::formatDouble($user->posts / $user->getProfileAge()))) : '') . '</a>');
                // show last 5 posts
                if (PROFILE_SHOW_LAST_POSTS) {
                    require_once WBB_DIR . 'lib/data/post/ViewablePost.class.php';
                    require_once WBB_DIR . 'lib/data/board/Board.class.php';
                    $boardIDArray = Board::getAccessibleBoardIDArray(array('canViewBoard', 'canEnterBoard', 'canReadThread'));
                    if (count($boardIDArray)) {
                        $posts = array();
                        $sql = "SELECT\t\tpost.postID, post.time,\n\t\t\t\t\t\t\t\tCASE WHEN post.subject <> '' THEN post.subject ELSE thread.topic END AS subject\n\t\t\t\t\t\tFROM\t\twbb" . WBB_N . "_user_last_post user_last_post\n\t\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_post post\n\t\t\t\t\t\tON\t\t(post.postID = user_last_post.postID)\n\t\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\t\t\t\tWHERE\t\tuser_last_post.userID = " . $user->userID . "\n\t\t\t\t\t\t\t\tAND post.isDeleted = 0\n\t\t\t\t\t\t\t\tAND post.isDisabled = 0\n\t\t\t\t\t\t\t\tAND thread.boardID IN (" . implode(',', $boardIDArray) . ")\n\t\t\t\t\t\t\t\t" . (count(WCF::getSession()->getVisibleLanguageIDArray()) ? "AND thread.languageID IN (" . implode(',', WCF::getSession()->getVisibleLanguageIDArray()) . ")" : "") . "\n\t\t\t\t\t\tORDER BY\tuser_last_post.time DESC";
                        $result = WCF::getDB()->sendQuery($sql, 5);
                        while ($row = WCF::getDB()->fetchArray($result)) {
                            $posts[] = new ViewablePost(null, $row);
                        }
                        if (count($posts)) {
                            WCF::getTPL()->assign(array('posts' => $posts, 'user' => $user));
                            WCF::getTPL()->append('additionalContent2', WCF::getTPL()->fetch('userProfileLastPosts'));
                        }
                    }
                }
            }
        }
    }
 /**
  * Gets the posts for the feed.
  */
 protected function readPosts()
 {
     // accessible boards
     $accessibleBoardIDArray = Board::getAccessibleBoardIDArray(array('canViewBoard', 'canEnterBoard', 'canReadThread'));
     if (!count($accessibleBoardIDArray)) {
         throw new PermissionDeniedException();
     }
     // get posts
     $attachmentPostIDArray = array();
     $sql = "SELECT\t\tpost.*\n\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\tWHERE\t\tpost.threadID IN (" . implode(',', $this->threadIDArray) . ")\n\t\t\t\t\tAND post.threadID IN (SELECT threadID FROM wbb" . WBB_N . "_thread WHERE boardID IN (" . implode(',', $accessibleBoardIDArray) . "))\n\t\t\t\t\tAND post.isDeleted = 0\n\t\t\t\t\tAND post.isDisabled = 0\n\t\t\t\t\t" . ($this->hours ? "AND post.time > " . (TIME_NOW - $this->hours * 3600) : '') . "\n\t\t\tORDER BY\tpost.time DESC";
     $result = WCF::getDB()->sendQuery($sql, $this->limit);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->posts[] = new FeedPost(null, $row);
         // attachments
         if ($row['attachments'] != 0) {
             $attachmentPostIDArray[] = $row['postID'];
         }
     }
     // read attachments
     if (MODULE_ATTACHMENT == 1 && count($attachmentPostIDArray) > 0 && (WCF::getUser()->getPermission('user.board.canViewAttachmentPreview') || WCF::getUser()->getPermission('user.board.canDownloadAttachment'))) {
         require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php';
         $attachmentList = new MessageAttachmentList($attachmentPostIDArray, 'post');
         $attachmentList->readObjects();
         $attachments = $attachmentList->getSortedAttachments();
         // set embedded attachments
         require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php';
         AttachmentBBCode::setAttachments($attachments);
     }
 }
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 70; $i++) {
         $user = User::where('roles', 'applicant')->get()->shuffle()->first();
         $board = null;
         while (null == $board) {
             $day_type = array('internal' => self::INTERNAL_DAYS, 'external' => self::EXTERNAL_DAYS, 'union' => self::UNION_DAYS);
             $type = $faker->randomElement(['internal', 'external', 'union']);
             $days = $day_type[$type] - 1;
             $from = date_format($faker->dateTimeBetween('-3 months', '+3 months'), 'Y-m-d');
             $end = date('Y-m-d', strtotime("{$from} + {$days} days"));
             $board = Board::where('type', '!=', 'large')->isEmpty($from, $end)->get()->shuffle()->first();
         }
         ApplyRecord::create(array('board_id' => $board->id, 'user_id' => $user->id, 'event_name' => $faker->company(), 'event_type' => $type, 'post_from' => $from, 'post_end' => $end));
     }
     for ($i = 0; $i < 30; $i++) {
         $user = User::where('roles', 'applicant')->get()->shuffle()->first();
         $board = null;
         while (null == $board) {
             $type = $faker->randomElement(['internal', 'external', 'union']);
             $days = self::LARGE_POSTER_DAYS - 1;
             $from = date_format($faker->dateTimeBetween('-3 months', '+3 months'), 'Y-m-d');
             $end = date('Y-m-d', strtotime("{$from} + {$days} days"));
             $board = Board::where('type', 'large')->isEmpty($from, $end)->get()->shuffle()->first();
         }
         ApplyRecord::create(array('board_id' => $board->id, 'user_id' => $user->id, 'event_name' => $faker->company(), 'event_type' => $type, 'post_from' => $from, 'post_end' => $end));
     }
 }
 /**
  * @see WarningObjectType::getObjectByID()
  */
 public function getObjectByID($objectID)
 {
     if (is_array($objectID)) {
         $posts = array();
         $sql = "SELECT\t\tpost.*, thread.topic, thread.boardID\n\t\t\t\tFROM \t\twbb" . WBB_N . "_post post\n\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\t\tWHERE \t\tpostID IN (" . implode(',', $objectID) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $posts[$row['postID']] = new PostWarningObject(null, $row);
         }
         return count($posts) > 0 ? $posts : null;
     } else {
         // get object
         $post = new PostWarningObject($objectID);
         if (!$post->postID) {
             return null;
         }
         // check permissions
         if (!class_exists('WBBACP')) {
             // ignore permission in acp
             $board = Board::getBoard($post->boardID);
             if (!$board->getPermission('canViewBoard') || !$board->getPermission('canEnterBoard')) {
                 return null;
             }
         }
         // return object
         return $post;
     }
 }
 /**
  * @see Taggable::getObjectsByTagID()
  */
 public function getObjectsByTagID($tagID, $limit = 0, $offset = 0)
 {
     $accessibleBoardIDArray = Board::getAccessibleBoardIDArray();
     if (count($accessibleBoardIDArray) == 0) {
         return array();
     }
     $sqlThreadVisitSelect = $sqlThreadVisitJoin = $sqlSubscriptionSelect = $sqlSubscriptionJoin = $sqlOwnPostsSelect = $sqlOwnPostsJoin = '';
     if (WCF::getUser()->userID != 0) {
         $sqlThreadVisitSelect = ', thread_visit.lastVisitTime';
         $sqlThreadVisitJoin = " LEFT JOIN \twbb" . WBB_N . "_thread_visit thread_visit \n\t\t\t\t\t\tON \t\t(thread_visit.threadID = thread.threadID\n\t\t\t\t\t\t\t\tAND thread_visit.userID = " . WCF::getUser()->userID . ")";
         $sqlSubscriptionSelect = ', IF(thread_subscription.userID IS NOT NULL, 1, 0) AS subscribed';
         $sqlSubscriptionJoin = " LEFT JOIN \twbb" . WBB_N . "_thread_subscription thread_subscription \n\t\t\t\t\t\tON \t\t(thread_subscription.userID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\t\t\tAND thread_subscription.threadID = thread.threadID)";
         if (BOARD_THREADS_ENABLE_OWN_POSTS) {
             $sqlOwnPostsSelect = "DISTINCT post.userID AS ownPosts,";
             $sqlOwnPostsJoin = "\tLEFT JOIN\twbb" . WBB_N . "_post post\n\t\t\t\t\t\t\tON \t\t(post.threadID = thread.threadID\n\t\t\t\t\t\t\t\t\tAND post.userID = " . WCF::getUser()->userID . ")";
         }
     }
     $threads = array();
     $sql = "SELECT\t\t" . $sqlOwnPostsSelect . "\n\t\t\t\t\tthread.*,\n\t\t\t\t\tboard.boardID, board.title\n\t\t\t\t\t" . $sqlThreadVisitSelect . "\n\t\t\t\t\t" . $sqlSubscriptionSelect . "\n\t\t\tFROM\t\twcf" . WCF_N . "_tag_to_object tag_to_object\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\tON\t\t(thread.threadID = tag_to_object.objectID)\n\t\t\tLEFT JOIN \twbb" . WBB_N . "_board board\n\t\t\tON \t\t(board.boardID = thread.boardID)\n\t\t\t" . $sqlOwnPostsJoin . "\n\t\t\t" . $sqlThreadVisitJoin . "\n\t\t\t" . $sqlSubscriptionJoin . "\n\t\t\tWHERE\t\ttag_to_object.tagID = " . $tagID . "\n\t\t\t\t\tAND tag_to_object.taggableID = " . $this->getTaggableID() . "\n\t\t\t\t\tAND thread.boardID IN (" . implode(',', $accessibleBoardIDArray) . ")\n\t\t\t\t\tAND thread.isDeleted = 0\n\t\t\t\t\tAND thread.isDisabled = 0\n\t\t\tORDER BY\tthread.lastPostTime DESC";
     $result = WCF::getDB()->sendQuery($sql, $limit, $offset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $row['taggable'] = $this;
         $threads[] = new TaggedThread(null, $row);
     }
     return $threads;
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Board::create([]);
     }
 }
Exemple #16
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     App::import("vendor", array("model/board", "inc/pagination"));
     if (!isset($this->params['name'])) {
         $this->error(ECode::$BOARD_NONE);
     }
     try {
         $boardName = $this->params['name'];
         if (preg_match("/^\\d+\$/", $boardName)) {
             throw new BoardNullException();
         }
         $this->_board = Board::getInstance($boardName);
         if ($this->_board->isDir()) {
             throw new BoardNullException();
         }
     } catch (BoardNullException $e) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     if (isset($this->params['url']['mode'])) {
         $mode = (int) trim($this->params['url']['mode']);
         $this->_board->setMode($mode);
     }
     if (!$this->_board->hasReadPerm(User::getInstance())) {
         $this->error(ECode::$BOARD_NOPERM);
     }
     $this->_board->setOnBoard();
 }
Exemple #17
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (!isset($this->params['name'])) {
         $this->error(ECode::$BOARD_NONE);
     }
     try {
         $boardName = $this->params['name'];
         if (preg_match("/^\\d+\$/", $boardName)) {
             throw new BoardNullException();
         }
         $this->_board = Board::getInstance($boardName);
     } catch (BoardNullException $e) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     if (isset($this->params['url']['mode'])) {
         $mode = (int) trim($this->params['url']['mode']);
         if (!$this->_board->setMode($mode)) {
             $this->error(ECode::$BOARD_NOPERM);
         }
     }
     if (!$this->_board->hasReadPerm(User::getInstance())) {
         if (!$this->ByrSession->isLogin) {
             $this->requestLogin();
         }
         $this->error(ECode::$BOARD_NOPERM);
     }
     $this->_board->setOnBoard();
     $this->ByrSession->Cookie->write("XWJOKE", "hoho", false);
 }
Exemple #18
0
 function reachable_squares()
 {
     #Array of square where the piece can move to
     $squares = array();
     $csq = $this->get_current_square();
     $hdist = abs(Board::horz_distance("a1", $csq));
     $vdist = abs(Board::vert_distance("a1", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, -$dist);
     $sq = Board::add_vert_distance($sq, -$dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("h1", $csq));
     $vdist = abs(Board::vert_distance("h1", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, $dist);
     $sq = Board::add_vert_distance($sq, -$dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("a8", $csq));
     $vdist = abs(Board::vert_distance("a8", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, -$dist);
     $sq = Board::add_vert_distance($sq, $dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     $hdist = abs(Board::horz_distance("h8", $csq));
     $vdist = abs(Board::vert_distance("h8", $csq));
     $dist = $hdist > $vdist ? $vdist : $hdist;
     $sq = Board::add_horz_distance($csq, $dist);
     $sq = Board::add_vert_distance($sq, $dist);
     $squares = array_merge($squares, Board::squares_in_line($csq, $sq));
     #Removes current position square
     $squares = preg_grep("/^{$csq}\$/", $squares, PREG_GREP_INVERT);
     return $squares;
 }
Exemple #19
0
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (isset($this->params['name'])) {
         $bName = trim($this->params['name']);
     } else {
         $this->error(ECode::$BOARD_NONE);
     }
     try {
         $this->_board = Board::getInstance($bName);
         if ($this->_board->isDir()) {
             throw new BoardNullException();
         }
     } catch (BoardNullException $e) {
         $this->error(ECode::$BOARD_NONE);
     }
     if (isset($this->params['mode'])) {
         $mode = (int) trim($this->params['mode']);
         if (!$this->_board->setMode($mode)) {
             $this->error(ECode::$BOARD_NOPERM);
         }
     }
     if (!$this->_board->hasReadPerm(User::getInstance())) {
         $this->error(ECode::$BOARD_NOPERM);
     }
     $this->_board->setOnBoard();
 }
 public function __construct($data, $boxname = "")
 {
     $this->TopData['templatename'] = "topthreads";
     $this->getBoxStatus($data);
     $this->TopData['boxID'] = $data['boxID'];
     if (!defined('TOPTHREADS_COUNT')) {
         define('TOPTHREADS_COUNT', 10);
     }
     if (!defined('TOPTHREADS_TITLELENGTH')) {
         define('TOPTHREADS_TITLELENGTH', 25);
     }
     if (!defined('TOPTHREADS_SBCOLOR_ACP')) {
         define('TOPTHREADS_SBCOLOR_ACP', 2);
     }
     require_once WBB_DIR . 'lib/data/board/Board.class.php';
     $boardIDs = Board::getAccessibleBoards();
     if (!empty($boardIDs)) {
         $sql = "SELECT thread.*" . "\n  FROM wbb" . WBB_N . "_thread thread" . "\n WHERE thread.boardID IN (0" . $boardIDs . ")" . "\n ORDER BY thread.replies DESC" . "\n LIMIT 0, " . TOPTHREADS_COUNT;
         $result = WBBCore::getDB()->sendQuery($sql);
         while ($row = WBBCore::getDB()->fetchArray($result)) {
             $row['replies'] = StringUtil::formatInteger($row['replies']);
             $row['title'] = StringUtil::encodeHTML($row['topic']) . ' - ' . $row['replies'];
             if (TOPTHREADS_TITLELENGTH != 0 && strlen($row['topic']) > TOPTHREADS_TITLELENGTH) {
                 $row['topic'] = StringUtil::substring($row['topic'], 0, TOPTHREADS_TITLELENGTH - 3) . '...';
             }
             $row['topic'] = StringUtil::encodeHTML($row['topic']);
             $this->TopData['threads'][] = $row;
         }
     }
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     list($cache, $groupIDs) = explode('-', $cacheResource['cache']);
     $data = array();
     $sql = "SELECT\t\t*\n\t\t\tFROM\t\twbb" . WBB_N . "_board_to_group\n\t\t\tWHERE\t\tgroupID IN (" . $groupIDs . ")";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $boardID = $row['boardID'];
         unset($row['boardID'], $row['groupID']);
         foreach ($row as $permission => $value) {
             if ($value == -1) {
                 continue;
             }
             if (!isset($data[$boardID][$permission])) {
                 $data[$boardID][$permission] = $value;
             } else {
                 $data[$boardID][$permission] = $value || $data[$boardID][$permission];
             }
         }
     }
     if (count($data)) {
         require_once WBB_DIR . 'lib/data/board/Board.class.php';
         Board::inheritPermissions(0, $data);
     }
     $data['groupIDs'] = $groupIDs;
     return $data;
 }
Exemple #22
0
 /**
  * View a board
  *
  * List all the threads in the board
  */
 public function get_view($board_id)
 {
     // get all the threads for this board
     $threadlist = DB::table('threads')->join('users', 'threads.user_id', '=', 'users.id')->where('threads.board_id', '=', $board_id)->order_by('threads.updated_at', 'desc')->paginate(10, array('threads.id', 'threads.user_id', 'threads.subject', 'threads.postcount', 'threads.created_at', 'users.username'));
     // get this board
     $board = Board::find($board_id);
     return View::make('thread-list')->with('threadlist', $threadlist)->with('board', $board);
 }
Exemple #23
0
 public static function Inst()
 {
     if (!isset(self::$inst)) {
         $class_name = __CLASS__;
         self::$inst = new $class_name();
     }
     return self::$inst;
 }
 /**
  * @param int $userId
  * @return Board[]
  */
 public function getBoards($userId = null)
 {
     return $this->hasMany(Board::className(), ['id' => 'board_id'])->viaTable('cp_users_board_rights', ['board_rights_id' => 'id'], function ($query) use($userId) {
         if ($userId != null && is_numeric($userId)) {
             $query->andWhere(['user_id' => $userId]);
         }
     });
 }
Exemple #25
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth)
 {
     $weight = $this->getPrecedence();
     $indent = $board->indent($depth);
     $index = 0;
     /* @var $child Node */
     foreach ($this->getChildren() as $child) {
         // Prep
         $wrap = $child->getPrecedence() <= $weight;
         // Operator
         if ($index) {
             $board->write(',');
             if ($this->isBlock()) {
                 $board->write("\n");
                 (!$child->isBlock() || $wrap) && $board->write($indent);
             } else {
                 $board->write(" ");
             }
         } else {
             $this->isBlock() && $board->write($indent);
         }
         // Child:
         if ($wrap) {
             $board->write("(");
             $child->isBlock() && $board->write("\n");
         }
         $child->build($board, $depth + 1);
         $wrap && $board->write(")");
         // ===
         $index++;
     }
 }
Exemple #26
0
 function get($data)
 {
     $board = new Board();
     $string = "<div style='text-align:center;'>" . $board->get($data) . "</div> \n                       <div style='text-align:center;'>\n                           <form method='post' action=''>\n                           <input type='hidden' name='reset' value='true' />\n                           <input type='submit' value='Reset' />\n                           </form>";
     switch ($data['win']) {
         case 0:
             $string = $string . "You are player " . $data['player'] . ". Make your move please.</div>";
             break;
         case 1:
         case 2:
             $string = $string . "Player " . $data['win'] . " has won!</div>";
             break;
         case 3:
             $string = $string . "Stalemate!</div>";
             break;
     }
     return $string;
 }
Exemple #27
0
 public function __construct($boardid, $parentid, $name, $desc, $indexer, $readAuthManager, $writeAuthManager, $host, $loginusername, $loginpassword, $folder, $writer)
 {
     parent::__construct($boardid, $parentid, $name, $desc, $indexer, $readAuthManager, $writeAuthManager);
     $this->host = $host;
     $this->loginusername = $loginusername;
     $this->loginpassword = $loginpassword;
     $this->folder = $folder;
     $this->writer = $writer;
 }
Exemple #28
0
 /**
  * Gets the coordinates of a square position
  * 
  * @param string $sq square position on the board
  * @return array x,y coordinates
  */
 static function _get_square_coords($sq)
 {
     #If $sq is not a valid square
     if (Board::square_is_valid($sq) == false) {
         return NULL;
     }
     $x = ord(strtolower(substr($sq, 0, 1))) - ord('a');
     $y = substr($sq, 1, 1) - 1;
     return array($x, $y);
 }
 /**
  * Creates a new BoardEditor object.
  * @see Board::__construct()
  */
 public function __construct($boardID, $row = null, $cacheObject = null, $useCache = true)
 {
     if ($useCache) {
         parent::__construct($boardID, $row, $cacheObject);
     } else {
         $sql = "SELECT\t*\n\t\t\t\tFROM\twbb" . WBB_N . "_board\n\t\t\t\tWHERE\tboardID = " . $boardID;
         $row = WCF::getDB()->getFirstRow($sql);
         parent::__construct(null, $row);
     }
 }
Exemple #30
0
 /**
  * Get landing pages
  * @return mixed
  */
 public function index(Request $request)
 {
     //        $members = Venue::where('status', '=', 1)->paginate(15);
     if ($request->has('column') && $request->has('value')) {
         $members = Board::where($request->get('column'), 'like', $request->get('value'))->where('status', '=', 1)->paginate(15);
     } else {
         $members = Board::where('status', '=', 1)->paginate(15);
     }
     return view('blupl/venue::printing.list-printing', compact('members'));
 }