Inheritance: extends BaseThread, implements HistoricalObjectI
 public function BoardRightUpToHTML()
 {
     global $infos;
     $myIndexSocial = new IndexSocial();
     echo "<div id=\"catcher2\" style=\"border:1px solid #c7d0d5; border-radius:15px;\">";
     $myIndexSocial->IndexSocialToHTML();
     echo "</div>";
     echo "<div id=\"sticky2\" style=\"margin-top:2%;width:100%;\">";
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     $connection->set_charset("utf8");
     $query = "SELECT * FROM threads WHERE threadCategory=\"" . $infos['boardCategory'] . "\" ORDER BY rand() LIMIT 2";
     $results2 = $connection->query($query);
     while ($curResult2 = $results2->fetch_assoc()) {
         $threadID2 = $curResult2["threadID"];
         $threadDate2 = $curResult2["threadDate"];
         $threadWriter2 = $curResult2["threadWriter"];
         $threadCategory2 = $curResult2["threadCategory"];
         $threadPicture2 = $curResult2["threadPicture"];
         $stepCount2 = $curResult2["stepCount"];
         $threadName2 = $curResult2["threadName"];
         $threadPoint2 = $curResult2["threadPoint"];
         $myThread2 = new Thread(array($threadID2, $threadDate2, $threadWriter2, $threadCategory2, $threadPicture2, $stepCount2, $threadName2, $threadPoint2));
         $myThread2->ThreadToPetitHTML();
     }
     echo "</div>";
     echo "<script>";
     echo "\n\t\t\$(document).ready(function(){\n\t\t\tif (\$(window).width()<=1028)\n\t\t\t{\n\t\t\t\t\$('#catcher2').remove();\n\t\t\t\t\$('#sticky2').remove();\n\t\t\t\t\$('#random_for_mobile').show();\n\t\t\t}\n\t\t});\n\tvar wid = \$('#sticky2').width();\n\tfunction isScrolledTo(elem) {\n    var docViewTop = \$(window).scrollTop(); //num of pixels hidden above current screen\n    var docViewBottom = docViewTop + \$(window).height();\n \n    var elemTop = \$(elem).offset().top; //num of pixels above the elem\n    var elemBottom = elemTop + \$(elem).height();\n \n    return ((elemTop <= docViewTop));\n}\n\n\tvar catcher = \$('#catcher2');\nvar sticky = \$('#sticky2');\n\n\t\$(window).scroll(function() {\n\tif (\$(window).width()>1028){\n    if(isScrolledTo(sticky)) {\n        sticky.css('position','fixed');\n        sticky.css('top','100px');\n\tsticky.css('max-width',wid);\n\t\$('#sticky_footer_div').show(500);\n    }\n\t\n    var stopHeight = catcher.offset().top + catcher.height(); \n\t  if ( stopHeight > sticky.offset().top) {\n        sticky.css('position','absolute');\n        sticky.css('top',stopHeight-70);\n\t\$('#sticky_footer_div').hide(500);\n    }\n}\n});\n\t\t";
     echo "</script>";
 }
 /**
  * @param Thread $thread
  * @return $this
  */
 public function unregisterThread(Thread $thread)
 {
     if (isset($this->registry[(int) $thread->getPid()])) {
         unset($this->registry[(int) $thread->getPid()]);
     }
     return $this;
 }
 public function create()
 {
     $thread = new Thread();
     $comment = new Comment();
     $page = Param::get('page_next', 'create');
     switch ($page) {
         case 'create':
             break;
         case 'create_end':
             $thread->title = Param::get('title');
             $comment->username = Param::get('username');
             $comment->body = Param::get('body');
             try {
                 $thread->create($comment);
             } catch (ValidationException $e) {
                 $page = 'create';
             }
             break;
         default:
             throw new NotFoundException("{$page} is not found");
             break;
     }
     $this->set(get_defined_vars());
     $this->render($page);
 }
 public function YazarBasliklariToHTML()
 {
     global $yazarAdi;
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     if ($connection->connect_error) {
         echo "Database'e bağlantı sorunu";
     } else {
         $connection->set_charset("utf8");
         echo "<div style=\"overflow:auto;border:1px solid #c7d0d5;border-radius:15px;background-color:#e6e6e6;width:100%;margin-top:4%;font-size:19px;font-family: 'Josefin Sans', sans-serif;color:#cb7c7a;max-width:100%;\">";
         echo "<div style=\"margin-top:5%;text-align:left;margin-right:5%;margin-left:5%;font-size:19px;font-family: 'Josefin Sans', sans-serif;color:#cb7c7a;\">";
         echo "<p style=\"word-wrap:break-word;text-align:left;width:80%;max-width:80%;\">";
         echo "Aynı yazardan bazı süper başlıklar";
         echo "</p>";
         echo "<hr style=\"border:1px solid #c7d0d5;\"/>";
         echo "</div>";
         $res = $connection->query("SELECT * from threads where threadWriter='{$yazarAdi}' ORDER BY threadPoint LIMIT 10");
         while ($curres = $res->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>";
         $connection->close();
     }
 }
 /**
  * @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'));
             }
         }
     }
 }
 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>";
 }
Beispiel #7
0
 /**
  *	Starts new threads if needed
  *
  *	@return int	queue size
  */
 public function tick()
 {
     $this->cleanup();
     if (count($this->threads) < $this->queueSize && count($this->jobs)) {
         $this->threads[] = $szal = new Thread($this->callable);
         $szal->start(array_shift($this->jobs));
     }
     usleep(ThreadQueue::TICK_DELAY);
     return $this->queueSize();
 }
Beispiel #8
0
 function run()
 {
     while (true != $this->exit) {
         $sock = socket_accept($this->ls);
         if ($sock) {
             $hs = new Thread(new HttpHandler($sock, $this->handler));
             $hs->start();
         }
     }
 }
 public function SuggestionsBarToHTML()
 {
     $myIndexSocial = new IndexSocial();
     echo "<div style=\"border:1px solid #c7d0d5; border-radius:15px;\">";
     $myIndexSocial->IndexSocialToHTML();
     echo "</div>";
     global $sinf;
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $connection2 = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     if ($connection2->connect_error) {
         echo "Database'e bağlantı sorunu";
     } else {
         $connection2->set_charset("utf8");
         echo "<div style=\"border:1px solid #c7d0d5;border-radius:15px;margin-top:3%;overflow:auto;height:100%;width:100%;max-width:100%;background-color:#e6e6e6;\">";
         echo "<div style=\"margin-top:5%;text-align:left;margin-right:5%;margin-left:5%;font-size:19px;font-family: 'Josefin Sans', sans-serif;color:#cb7c7a\">";
         echo "<p style=\"word-wrap:break-word;text-align:left;width:80%;max-width:80%;\">";
         echo "İlginizi çekebilecek başlıklar";
         echo "</p>";
         echo "<hr style=\"border:1px solid #c7d0d5;\"/>";
         echo "</div>";
         $quelloThreddo = $connection2->real_escape_string($sinf['quelleThread']);
         $sugQuery = "SELECT * FROM threads WHERE threadCategory =\"" . $sinf['quelleCategorie'] . "\" AND threadName<>\"" . $quelloThreddo . "\" ORDER BY RAND() LIMIT 30";
         $results2 = $connection2->query($sugQuery);
         while ($curResult2 = $results2->fetch_assoc()) {
             $threadID2 = $curResult2["threadID"];
             $threadDate2 = $curResult2["threadDate"];
             $threadWriter2 = $curResult2["threadWriter"];
             $threadCategory2 = $curResult2["threadCategory"];
             $threadPicture2 = $curResult2["threadPicture"];
             $stepCount2 = $curResult2["stepCount"];
             $threadName2 = $curResult2["threadName"];
             $threadPoint2 = $curResult2["threadPoint"];
             $myThread2 = new Thread(array($threadID2, $threadDate2, $threadWriter2, $threadCategory2, $threadPicture2, $stepCount2, $threadName2, $threadPoint2));
             $myThread2->ThreadToPetitHTML();
         }
         $sugQuery = "SELECT * FROM threads WHERE threadCategory <>\"" . $sinf['quelleCategorie'] . "\" AND threadName<>\"" . $quelloThreddo . "\" ORDER BY RAND() LIMIT 10";
         $results2 = $connection2->query($sugQuery);
         while ($curResult2 = $results2->fetch_assoc()) {
             $threadID2 = $curResult2["threadID"];
             $threadDate2 = $curResult2["threadDate"];
             $threadWriter2 = $curResult2["threadWriter"];
             $threadCategory2 = $curResult2["threadCategory"];
             $threadPicture2 = $curResult2["threadPicture"];
             $stepCount2 = $curResult2["stepCount"];
             $threadName2 = $curResult2["threadName"];
             $threadPoint2 = $curResult2["threadPoint"];
             $myThread2 = new Thread(array($threadID2, $threadDate2, $threadWriter2, $threadCategory2, $threadPicture2, $stepCount2, $threadName2, $threadPoint2));
             $myThread2->ThreadToPetitHTML();
         }
         echo "</div>";
         $connection2->close();
     }
 }
 /**
  * @Route("/createRandomThread" , name="create thread")
  */
 function createRandomThreadAction()
 {
     $doctrine = $this->getDoctrine();
     $em = $doctrine->getEntityManager();
     $thread = new Thread();
     $generator = $this->get('app.data_generator');
     $thread->setTitle($generator->generateRandomString());
     $em->persist($thread);
     $em->flush();
     return $this->redirect('/thread/' . $thread->getId());
 }
Beispiel #11
0
 static function start($transport, $nodename = null, $background = true)
 {
     $node = new LdwpNode();
     if ($background) {
         $t = new Thread($node);
         $pid = $t->start();
         console::writeLn("Forked with pid %d", $pid);
     } else {
         $node->threadmain();
     }
 }
 public function UserThreadsToHTML()
 {
     global $whichUsr;
     echo "<div style=\"margin-top:2%;\">";
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     if ($connection->connect_error) {
         echo "Database'e bağlantı sorunu";
     } else {
         $connection->set_charset("utf8");
         $res0 = $connection->query("SELECT * from threads where threadWriter= '{$whichUsr}'");
         $totalCount = $res0->num_rows;
         $res = $connection->query("SELECT * from threads where threadWriter='{$whichUsr}' ORDER BY threadPoint DESC LIMIT 6");
         $curCount = $res->num_rows;
         while ($curres = $res->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();
         }
         $connection->close();
     }
     echo "<div id=\"more_data_div\" style=\"\">";
     echo "</div>";
     echo "<div style=\"margin:2%;\">";
     if ($totalCount != 0) {
         echo "<form method =\"post\" id =\"userThreadsForm\" action=\"usrThreadsLoadMore.php?usr=" . $whichUsr . "\">";
         echo "<input name=\"offsetUsrThread\" id=\"offsetUsrThread\" value=\"" . $curCount . "\" style=\"display:none;\" />";
         echo "<input name=\"totalUsrThread\" id=\"totalUsrThread\" value=\"" . $totalCount . "\" style=\"display:none;\" />";
         echo "<button id=\"loadMoreDataButton\" class=\"btn btn-block btn-success\" style=\"\">";
         echo "<i id=\"loadMoreThreadSpinner\" style=\"display:none;\" class=\"fa fa-refresh fa-spin\"></i>";
         echo "<span id=\"loadMoreDataTXT\"> Daha fazla göster </span>";
         echo "</button>";
         echo "</form>";
     } else {
         echo "<span style=\"font-family: 'Josefin Sans', sans-serif;font-size:18px;color:#6e6e6e;\"> Bu yazar henüz başlık oluşturmamış. </span>";
     }
     echo "</div>";
     echo "</div>";
     echo "<script type=\"text/javascript\">";
     echo "\n\t\t\t\$('#loadMoreDataButton').click(function(e){\n\t\t\t\te.preventDefault();\n\t\t\t\t\$('#loadMoreDataTXT').hide();\n\t\t\t\t\$('#loadMoreThreadSpinner').show();\n\t\t\t\t\$('#userThreadsForm').ajaxForm({\n\t\t\t\t\tsuccess : function(msg){\n\t\t\t\t\t\t\$('#loadMoreDataTXT').show();\n\t\t\t\t\t\t\$('#loadMoreThreadSpinner').hide();\n\t\t\t\t\t\toldoffset = \$('#offsetUsrThread').val();\n\t\t\t\t\t\tnewoffset = msg.charAt(0);\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\$('#loadMoreDataTXT').html('Hepsi yüklendi');\n\t\t\t\t\t\t\t \$('#loadMoreDataButton').attr(\"disabled\", true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\$('#offsetUsrThread').val(oldint+newint);\n\t\t\t\t\t\tmsg2 = msg.substring(1);\n\t\t\t\t\t\t\$('#more_data_div').append(msg2);\n\t\t\t\t\t\t\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});\n\t\t";
     echo "</script>";
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (isset($_REQUEST['threadID']) && intval($_REQUEST['threadID']) != 0) {
         $threadID = intval($_REQUEST['threadID']);
         require_once WBB_DIR . 'lib/data/thread/Thread.class.php';
         $thread = new Thread($threadID);
         if (!$thread->threadID) {
             throw new IllegalLinkException();
         }
         $thread->enter();
         $sql = "SELECT\tpollID\n\t\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\t\tWHERE\tthreadID = " . $threadID . "\n\t\t\t\t\tAND\tisDeleted = 0\n\t\t\t\t\tAND\tisDisabled = 0\n\t\t\t\t\tAND\tpollID > 0\n\t\t\t\tORDER BY postID ASC";
         $row = WCF::getDB()->getFirstRow($sql);
         $eventObj->pollID = $row['pollID'];
     }
 }
Beispiel #14
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $dataProvider = Thread::model()->lastNew();
     $this->render('index', array('dataProvider' => $dataProvider));
 }
 public function run()
 {
     printf("%s: %lu running\n", __CLASS__, $this->getThreadId());
     if ($other = Thread::getThread($this->other)) {
         printf("%s: %lu working ... %s/%d\n", __CLASS__, $this->getThreadId(), $other->my, $other->scopeTestFunc());
         //usleep(1000); /* simulate some work */
         if ($other->isWaiting()) {
             printf("%s: %lu notifying %lu: %d\n", __CLASS__, $this->getThreadId(), $this->other, $other->notify());
         }
         $other->join();
         printf("%s: %lu testing again ... %s/%d\n", __CLASS__, $this->getThreadId(), $other->my, $other->scopeTestFunc());
         if ($next = Thread::getThread($this->next)) {
             printf("%s: %lu working ... %s/%d\n", __CLASS__, $this->getThreadId(), $next->my, $next->scopeTestFunc());
             //usleep(1000); /* simulate some work */
             if ($next->isWaiting()) {
                 printf("%s: %lu notifying %lu: %d\n", __CLASS__, $this->getThreadId(), $this->next, $next->notify());
             }
             $next->join();
             printf("%s: %lu testing again ... %s/%d\n", __CLASS__, $this->getThreadId(), $next->my, $next->scopeTestFunc());
         }
     } else {
         printf("%s: %lu failed to find %lu\n", __CLASS__, $this->getThreadId(), $this->other);
     }
     printf("%s: %lu notified: %d\n", __CLASS__, $this->getThreadId(), $this->wait());
 }
 public function __construct($sleepTime, $max)
 {
     parent::__construct();
     self::$code++;
     $this->sleepTime = $sleepTime;
     $this->max = $max;
 }
 /**
  * To view all comments on a particular thread.
  **/
 public function view()
 {
     $thread = Thread::get(Param::get('thread_id'));
     $comments = $thread->getComments();
     $user_name = $_SESSION['username'];
     $this->set(get_defined_vars());
 }
Beispiel #18
0
 private function createFeedItem($row)
 {
     $thread = Thread::newFromRow($row);
     $titleStr = $thread->subject();
     $completeText = $thread->root()->getContent();
     $completeText = $this->getOutput()->parse($completeText);
     $threadTitle = clone $thread->topmostThread()->title();
     $threadTitle->setFragment('#' . $thread->getAnchorName());
     $titleUrl = $threadTitle->getFullURL();
     $timestamp = $thread->created();
     $user = $thread->author()->getName();
     // Prefix content with a quick description
     $userLink = Linker::userLink($thread->author()->getId(), $user);
     $talkpageLink = Linker::link($thread->getTitle());
     if ($thread->hasSuperThread()) {
         $stTitle = clone $thread->topmostThread()->title();
         $stTitle->setFragment('#' . $thread->superthread()->getAnchorName());
         $superthreadLink = Linker::link($stTitle);
         $description = wfMessage('lqt-feed-reply-intro')->rawParams($talkpageLink, $userLink, $superthreadLink)->params($user)->parseAsBlock();
     } else {
         // Third param is unused
         $description = wfMessage('lqt-feed-new-thread-intro')->rawParams($talkpageLink, $userLink, '')->params($user)->parseAsBlock();
     }
     $completeText = $description . $completeText;
     return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
 }
 public function actionReadTopic($id)
 {
     $thread = Thread::model()->getThreadInfoById($id);
     $this->areaLarge = $thread['program_name'];
     $this->areaSmall = $thread['semester_name'];
     $reply = new Reply();
     $complaint = new Complaint('postComplaint');
     if (isset($_POST['Reply'])) {
         $reply->attributes = $_POST['Reply'];
         $reply->post_item_id = $id;
         if ($reply->save()) {
             Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
             $reply->unsetAttributes();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
         }
     }
     if (isset($_POST['Complaint'])) {
         $complaint->attributes = $_POST['Complaint'];
         if ($complaint->save()) {
             if ($complaint->post_item_id == $id) {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             } else {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             }
             $complaint->unsetAttributes();
         } else {
             Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
         }
     }
     $dataProvider = Thread::model()->getPostsDataInThread($id);
     Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
     $this->render('application.modules.community.views.front.post.view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
 }
 public static function userPage($id)
 {
     $user = new ForumUser(ForumUser::find($id));
     $threads = Thread::findByUser($id);
     $messages = Message::findByUser($id);
     View::make('user/userpage.html', array('user' => $user, 'threads' => $threads, 'messages' => $messages));
 }
Beispiel #21
0
 public function testGetThreadFuncName()
 {
     // Find an existing thread
     $thread = Thread::model()->findByPk(1);
     $funcName = $thread->getThreadFuncName();
     $this->assertTrue($funcName == '_WinMainCRTStartup()');
 }
Beispiel #22
0
 public function post_create()
 {
     $posts = Input::all();
     $title = $posts['thread_name'];
     $contentRaw = $posts['inputarea'];
     if ($title != '' && strlen($contentRaw) > 10) {
         $alias = Str::slug($title, '-');
         $exist = Thread::where('alias', '=', $alias)->first();
         if ($exist != null) {
             return Redirect::to($exist->id);
         }
         $threadData = array('title' => $posts['thread_name'], 'alias' => $alias, 'type' => 0, 'poster_ip' => Request::ip(), 'dateline' => date("Y-m-d H:i:s"), 'last_message_at' => date("Y-m-d H:i:s"));
         $thread = Thread::create($threadData);
         if ($thread != null) {
             $content = static::replace_at(BBCode2Html(strip_tags_attributes($contentRaw)), $thread->id);
             $postData = array('thread_id' => $thread->id, 'entry' => $content, 'userip' => Request::ip(), 'user_id' => Sentry::user()->id, 'datetime' => date("Y-m-d H:i:s"), 'count' => 1, 'type' => 0);
             $pst = Post::create($postData);
             if ($pst != null) {
                 return Redirect::to($thread->id);
             }
         }
     } else {
         return Redirect::to(URL::full());
     }
 }
Beispiel #23
0
 /**
  * This action displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id, $tab = 'Summary', $thread = null)
 {
     // Load crash report
     $model = $this->loadModel($id);
     // Check if user is authorized to perform the action
     $this->checkAuthorization($model);
     // Determine what tab to display
     $activeItem = 'Summary';
     if ($tab == 'Summary' || $tab == 'CustomProps' || $tab == 'Screenshots' || $tab == 'Videos' || $tab == 'Threads' || $tab == 'Modules' || $tab == 'Files') {
         $activeItem = $tab;
     }
     $threadModel = null;
     $stackTraceProvider = null;
     if ($thread != null) {
         $threadModel = Thread::model()->findByPk((int) $thread);
         if ($threadModel == null) {
             throw new CHttpException(403, 'Unexpected parameter.');
         }
         $criteria = new CDbCriteria();
         $criteria->compare('thread_id', (int) $thread);
         $criteria->order = 'id ASC';
         $stackTraceProvider = new CActiveDataProvider('StackFrame', array('criteria' => $criteria, 'pagination' => false));
     }
     $customProps = $model->searchCustomProps();
     $screenshots = $model->searchScreenshots();
     $videos = $model->searchVideos();
     $modules = $model->searchModules();
     $threads = $model->searchThreads();
     $this->render('view', array('model' => $model, 'activeItem' => $activeItem, 'thread' => (int) $thread, 'threadModel' => $threadModel, 'stackTrace' => $stackTraceProvider, 'customProps' => $customProps, 'screenshots' => $screenshots, 'videos' => $videos, 'modules' => $modules, 'threads' => $threads));
 }
Beispiel #24
0
 public function index()
 {
     $type = Param::get('type', self::TYPE_THREAD);
     $query = trim_collapse(Param::get('query'));
     $page = Param::get('page', 1);
     $pagination = new SimplePagination($page, self::RESULTS_PERPAGE);
     if (!$query) {
         redirect(APP_URL);
     }
     $results = new stdClass();
     switch ($type) {
         case self::TYPE_THREAD:
             $results = Thread::search($query, $pagination->start_index - 1, $pagination->count + 1);
             // Get other info for each thread
             foreach ($results->result as $thread) {
                 $thread->creator = User::getByID($thread->user_id);
                 $thread->category = Category::getName($thread->category_id);
                 $thread->replies_count = Comment::countAll($thread->id);
             }
             break;
         case self::TYPE_COMMENT:
             $results = Comment::search($query, $pagination->start_index - 1, $pagination->count + 1);
             break;
         case self::TYPE_USER:
             $results = User::search($query, $pagination->start_index - 1, $pagination->count + 1);
             break;
         default:
             throw new PageNotFoundException();
             break;
     }
     $pagination->checkLastPage($results->result);
     $pages = ceil($results->total_result / self::RESULTS_PERPAGE);
     $title = "Search: '{$query}'";
     $this->set(get_defined_vars());
 }
 private function createFeedItem($row)
 {
     global $wgOut;
     $thread = Thread::newFromRow($row);
     $linker = new Linker();
     $titleStr = $thread->subject();
     $completeText = $thread->root()->getContent();
     $completeText = $wgOut->parse($completeText);
     $threadTitle = clone $thread->topmostThread()->title();
     $threadTitle->setFragment('#' . $thread->getAnchorName());
     $titleUrl = $threadTitle->getFullURL();
     $timestamp = $thread->created();
     $user = $thread->author()->getName();
     // Grab the title for the superthread, if one exists.
     $stTitle = null;
     if ($thread->hasSuperThread()) {
         $stTitle = clone $thread->topmostThread()->title();
         $stTitle->setFragment('#' . $thread->superthread()->getAnchorName());
     }
     // Prefix content with a quick description
     $userLink = $linker->userLink($thread->author()->getId(), $user);
     $talkpageLink = $linker->link($thread->getTitle());
     $superthreadLink = $linker->link($stTitle);
     $description = wfMsgExt($thread->hasSuperThread() ? 'lqt-feed-reply-intro' : 'lqt-feed-new-thread-intro', array('parse', 'replaceafter'), array($talkpageLink, $userLink, $superthreadLink));
     $completeText = $description . $completeText;
     return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
 }
 public function actionReadTopic($id)
 {
     $thread = Thread::model()->getThreadInfoById($id);
     $this->forumBreadcrumb = array('Programs' => array('forum/index'), $thread['program_name'] => array('forum/programView', 'programId' => $thread['program_id']), $thread['semester_name'] => array('forum/viewTopics', 'programId' => $thread['program_id'], 'semesterId' => $thread['semester_id']), $thread['title'] < Yii::app()->params['forum_max_crumb_length'] ? $thread['title'] : substr($thread['title'], 0, Yii::app()->params['forum_max_crumb_length']) . '...');
     $this->areaLarge = $thread['program_name'];
     $this->areaSmall = $thread['semester_name'];
     $reply = new Reply();
     $complaint = new Complaint('postComplaint');
     if (isset($_POST['Reply'])) {
         $reply->attributes = $_POST['Reply'];
         $reply->post_item_id = $id;
         if ($reply->save()) {
             Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
             $reply->unsetAttributes();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
         }
     }
     if (isset($_POST['Complaint'])) {
         $complaint->attributes = $_POST['Complaint'];
         if ($complaint->save()) {
             if ($complaint->post_item_id == $id) {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             } else {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             }
             $complaint->unsetAttributes();
         } else {
             Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
         }
     }
     $dataProvider = Thread::model()->getPostsDataInThread($id);
     Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
     $this->render('view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
 }
 /**
  * This is basically the "homepage" for the forums
  * It'll show a list of root categories which forums in each
  */
 public function actionIndex()
 {
     if (!isset($_GET['id'])) {
         $forum = null;
         if (!Yii::app()->user->isForumAdmin()) {
             $criteria = array('order' => 'lastPost_time DESC', 'condition' => "is_hidden=0", 'distinct' => true, "group" => 't.id');
         } else {
             $criteria = array('order' => 'lastPost_time DESC', "group" => 't.id');
         }
         $data = new CActiveDataProvider('Thread', array('criteria' => $criteria, 'pagination' => array('pageSize' => Yii::app()->controller->module->threadsPerPage)));
         $menuItem = 0;
         $breadcrumbs = array('Форум');
     } else {
         $forum = Forum::model()->findByPk($_GET['id']);
         if (null == $forum) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
         if ($forum->isCat) {
             $this->redirect($this->createUrl("index"));
         }
         if (!Yii::app()->user->isForumAdmin()) {
             $hidden = " AND is_hidden=0";
         } else {
             $hidden = "";
         }
         $data = new CActiveDataProvider('Thread', array('criteria' => array('condition' => 'forum_id=' . $forum->id . $hidden), 'pagination' => array('pageSize' => Yii::app()->controller->module->threadsPerPage)));
         $menuItem = $forum->id;
         $breadcrumbs = $forum->getBreadcrumbs();
     }
     $this->render('index', array('forums' => Thread::model()->findAll(), "data" => $data, "menuItem" => $menuItem, "breadcrumbs" => $breadcrumbs, 'forum' => $forum));
 }
Beispiel #28
0
 public function start($options = PTHREADS_INHERIT_ALL)
 {
     ThreadManager::getInstance()->add($this);
     if (!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()) {
         return parent::start($options);
     }
     return false;
 }
Beispiel #29
0
 public function view()
 {
     $comment = Comment::get(Param::get('id'));
     $auth_user = User::getAuthenticated();
     $thread = Thread::get($comment->thread_id);
     $title = "#{$comment->id}";
     $this->set(get_defined_vars());
 }
Beispiel #30
0
 public static function getInstance()
 {
     // TODO: mind the casing
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }