function System_Creator($num, $test = NULL) { //Creation and rating of chromosomes of future systems $ratings = array(); $chromosomes = array(); for ($i = 0; $i < $num; $i++) { $chromosome = $this->Random_Chromosome(); $rating = $this->Rate_Chromosome($chromosome); $ratings[] = $rating; $chromosomes[] = $chromosome; } rsort($ratings); foreach ($ratings as $key => $value) { $this->queue[$key] = array('rating' => $value, 'chromosome' => $chromosomes[$key]); } //Spreading energy between most perspective systems in first launch $count = $this->simultaneous_systems_count; $energy_per_system = $this->energy / $count; //Creating systems $threads = new Threads(); for ($i = 0; $i < $count; $i++) { $threads->newThread('D:/web/www/lh/tests/fuzzy/system/system.php', $this->queue[0]); //Delete first element and reindex queue unset($this->queue[0]); $this->queue = array_values($this->queue); } while (false !== ($result = $threads->iteration())) { echo $result . "\r\n"; } //$this->Run_Test($test); }
function createPost($info, $subject, $super = null) { $userName = $info['user']; if (strpos($userName, '#') !== false) { $pos = strpos($userName, '#'); $userName = substr($userName, 0, $pos); } $user = User::newFromName($userName, false); if (!$user) { throw new MWException("Username " . $info['user'] . " is invalid."); } global $article; if ($super) { $title = Threads::newReplyTitle($super, $user); } else { $title = Threads::newThreadTitle($subject, $article); } print "Creating thread {$title} as a subthread of " . ($super ? $super->title() : 'none') . "\n"; $root = new Article($title); $root->doEdit($info['content'], 'Imported from JSON', EDIT_NEW, false, $user); $t = LqtView::postEditUpdates($super ? 'reply' : 'new', $super, $root, $article, $subject, 'Imported from JSON', null); $t = Threads::withId($t->id()); // Some weirdness. return $t; }
function show() { $thread = Threads::withSummary($this->article); if ($thread && $thread->root()) { $t = $thread->root()->getTitle(); $link = Linker::link($t); $this->output->setSubtitle(wfMessage('lqt_summary_subtitle')->rawParams($link)->parse()); } return true; }
/** * Execute the job * * @return bool */ public function run() { $article = new Article($this->title); $limit = $this->params['limit']; $cascade = $this->params['cascade']; if ($article) { Threads::synchroniseArticleData($article, $limit, $cascade); } return true; }
function __construct(&$output, &$article, &$title, &$user, &$request) { parent::__construct($output, $article, $title, $user, $request); $t = Threads::withRoot($this->article); $this->thread = $t; if (!$t) { return; } $this->article = $t->article(); }
function show() { $thread = Threads::withSummary($this->article); if ($thread && $thread->root()) { $t = $thread->root()->getTitle(); $linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker(); $link = $linker->link($t); $this->output->setSubtitle(wfMsgExt('lqt_summary_subtitle', array('parseinline', 'replaceafter'), $link)); } return true; }
function formatThreadField($field, $threadid) { if (!is_object($threadid)) { $t = Threads::withId($threadid); } else { $t = $threadid; $threadid = $t->id(); } $out = Html::hidden($field, $threadid); $out .= LqtView::permalink($t); return $out; }
public function Start($metod, $param) { $result = ""; $input = $param[q]; $query = explode('/', $input); if ($metod == "POST") { $query_p["queuename"] = "ats24"; $query_p["metod"] = $metod; $query_p["q"] = $query[1] . "/" . $query[2]; $query_p["date"] = date("Y-m-d H:i:s"); $query_p["bodyq"] = file_get_contents('php://input'); $id = $this->savequeue($query_p); $connectionInfo = array("host" => "localhost"); $thread = new Threads($connectionInfo); $result = $thread->GET("ats24/start/" . $id); if (isset($result["error"])) { $result = "Не удалось открыть поток: " . $result["error"]; } else { $result = $id; } } elseif ($metod == "GET") { unset($query[0]); //Удалим первый элемент if ($query[1] == "queuelist") { $wparam = array(); if (count($query) > 1) { $wparam["id"] = $query[2]; } $result = $this->getlist($wparam); } elseif ($query[1] == "queue") { $wparam["id"] = $query[2]; $result = $this->getqueue($wparam); } elseif ($query[1] == "start") { $result = $this->insert_into_kih($query[2]); } } return $result; }
function checkParameters($par) { // Handle parameter $this->mTarget = $par; if ($par === null || $par === "") { $this->output->addHTML(wfMsg('lqt_threadrequired')); return false; } $thread = Threads::withRoot(new Article(Title::newFromURL($par))); if (!$thread) { $this->output->addHTML(wfMsg('lqt_nosuchthread')); return false; } $this->mThread = $thread; return true; }
function showOnce() { NewMessages::recacheMessageCount($this->user->getId()); $this->user->setNewtalk(false); if ($this->methodApplies('mark_as_unread')) { $ids = explode(',', $this->request->getVal('lqt_operand', '')); if ($ids !== false) { foreach ($ids as $id) { $tmp_thread = Threads::withId($id); if ($tmp_thread) { NewMessages::markThreadAsUnReadByUser($tmp_thread, $this->user); } } $this->output->redirect($this->title->getLocalURL()); } } elseif ($this->methodApplies('mark_as_read')) { $ids = explode(',', $this->request->getVal('lqt_operand')); if ($ids !== false) { foreach ($ids as $id) { if ($id == 'all') { NewMessages::markAllReadByUser($this->user); } else { $tmp_thread = Threads::withId($id); if ($tmp_thread) { NewMessages::markThreadAsReadByUser($tmp_thread, $this->user); } } } $query = 'lqt_method=undo_mark_as_read&lqt_operand=' . implode(',', $ids); $this->output->redirect($this->title->getLocalURL($query)); } } elseif ($this->methodApplies('undo_mark_as_read')) { $ids = explode(',', $this->request->getVal('lqt_operand', '')); $this->output->addHTML($this->getUndoButton($ids)); } }
<?php require '../loader.php'; /** * get thread messages */ $thread_id = input_get('thread_id'); if ($thread_id) { $users = new Users(); $threads = new Threads(); $messages = new Messages(); $thread_messages_ids = $threads->getThreadMessages($thread_id); $thread_users_ids = $threads->getThreadUsers($thread_id); $thread_users = array(); for ($i = 0, $count = count($thread_users_ids); $i < $count; $i++) { $thread_users[] = $users->getUser($thread_users_ids[$i]); } $thread_messages = array(); for ($i = 0, $count = count($thread_messages_ids); $i < $count; $i++) { $message = $messages->getMessage($thread_messages_ids[$i]); $message['user'] = $users->getUser($message['sender_id']); unset($message['sender_id']); $thread_messages[] = $message; } echo output_json(TRUE, ERR_EMPTY, array('users' => $thread_users, 'messages' => $thread_messages)); } else { echo output_json(FALSE, ERR_MISSING_DATA); } /* End of file get_thread_messages.php */ /* Location ./scripts/get_thread_messages.php */
public function actionReply($threads, $params) { // Validate thread parameter if (count($threads) > 1) { $this->dieUsage('You may only reply to one thread at a time', 'too-many-threads'); } elseif (count($threads) < 1) { $this->dieUsage('You must specify a thread to reply to', 'no-specified-threads'); } $replyTo = array_pop($threads); // Check if we can reply to that thread. $user = $this->getUser(); $perm_result = $replyTo->canUserReply($user); if ($perm_result !== true) { $this->dieUsage("You cannot reply to this thread, because the " . $perm_result . " is protected from replies.", $perm_result . '-protected'); } // Validate text parameter if (empty($params['text'])) { $this->dieUsage('You must include text in your post', 'no-text'); } $text = $params['text']; $bump = isset($params['bump']) ? $params['bump'] : null; // Generate/pull summary $summary = wfMessage('lqt-reply-summary', $replyTo->subject(), $replyTo->title()->getPrefixedText())->inContentLanguage()->text(); if (!empty($params['reason'])) { $summary = $params['reason']; } $signature = null; if (isset($params['signature'])) { $signature = $params['signature']; } // Grab data from parent $talkpage = $replyTo->article(); // Generate a reply title. $title = Threads::newReplyTitle($replyTo, $user); $article = new Article($title, 0); // Inform hooks what we're doing LqtHooks::$editTalkpage = $talkpage; LqtHooks::$editArticle = $article; LqtHooks::$editThread = null; LqtHooks::$editType = 'reply'; LqtHooks::$editAppliesTo = $replyTo; // Pull token in $token = $params['token']; // All seems in order. Construct an API edit request $requestData = array('action' => 'edit', 'title' => $title->getPrefixedText(), 'text' => $text, 'summary' => $summary, 'token' => $token, 'basetimestamp' => wfTimestampNow(), 'minor' => 0, 'format' => 'json'); if ($user->isAllowed('bot')) { $requestData['bot'] = true; } $editReq = new DerivativeRequest($this->getRequest(), $requestData, true); $internalApi = new ApiMain($editReq, true); $internalApi->execute(); if (defined('ApiResult::META_CONTENT')) { $editResult = $internalApi->getResult()->getResultData(); } else { $editResult = $internalApi->getResultData(); } if ($editResult['edit']['result'] != 'Success') { $result = array('result' => 'EditFailure', 'details' => $editResult); $this->getResult()->addValue(null, $this->getModuleName(), $result); return; } $articleId = $editResult['edit']['pageid']; $article->getTitle()->resetArticleID($articleId); $title->resetArticleID($articleId); $thread = LqtView::replyMetadataUpdates(array('root' => $article, 'replyTo' => $replyTo, 'signature' => $signature, 'summary' => $summary, 'text' => $text, 'bump' => $bump)); $result = array('action' => 'reply', 'result' => 'Success', 'thread-id' => $thread->id(), 'thread-title' => $title->getPrefixedText(), 'parent-id' => $replyTo->id(), 'parent-title' => $replyTo->title()->getPrefixedText(), 'ancestor-id' => $replyTo->topmostThread()->id(), 'ancestor-title' => $replyTo->topmostThread()->title()->getPrefixedText(), 'modified' => $thread->modified()); if (!empty($params['render'])) { $result['html'] = $this->renderThreadPostAction($thread); } $result = array('thread' => $result); $this->getResult()->addValue(null, $this->getModuleName(), $result); }
<?php require '../loader.php'; /** * send message */ $thread_id = input_post('thread_id'); $message_body = input_post('message'); $sender_id = input_post('sender_id'); if ($thread_id && $message_body && $sender_id) { $users = new Users(); $threads = new Threads(); $messages = new Messages(); $push = new PushService(); $message_id = $messages->createMessage($thread_id, $sender_id, $message_body); $threads->addMessageToThread($thread_id, $message_id); $message = $messages->getMessage($message_id); $message['user'] = $users->getUser($message['sender_id']); unset($message['sender_id']); $push->pushMessage($message_id); echo output_json(TRUE, ERR_EMPTY, $message); } else { echo output_json(FALSE, ERR_MISSING_DATA); } /* End of file send_message.php */ /* Location ./scripts/send_message.php */
public function article() { $this->js[] = "forum.board.js"; $this->css[] = "board.css"; $this->notice[] = array("url" => "", "text" => "ËÑË÷½á¹û"); App::import('Sanitize'); $day = $title1 = $title2 = $title3 = $author = $t = ""; if (isset($this->params['url']['t1'])) { $title1 = trim(rawurldecode($this->params['url']['t1'])); } if (isset($this->params['url']['t2'])) { $title2 = trim(rawurldecode($this->params['url']['t2'])); } if (isset($this->params['url']['tn'])) { $title3 = trim(rawurldecode($this->params['url']['tn'])); } if (isset($this->params['url']['au'])) { $author = trim($this->params['url']['au']); } if (isset($this->params['url']['d'])) { $day = intval($this->params['url']['d']); } $title1 = nforum_iconv('utf-8', $this->encoding, $title1); $title2 = nforum_iconv('utf-8', $this->encoding, $title2); $title3 = nforum_iconv('utf-8', $this->encoding, $title3); $m = isset($this->params['url']['m']); $a = isset($this->params['url']['a']); $full = isset($this->params['url']['f']); $site = Configure::read('search.site'); $return = Configure::read("search.max"); $res = array(); $u = User::getInstance(); if ($title1 == '' && $title3 == '' && $author == '' && !$m && !$a) { $res = array(); } else { if ($full && $site && $u->isAdmin()) { App::import('vendor', 'model/section'); $secs = array_keys(Configure::read("section")); foreach ($secs as $v) { $sec = Section::getInstance($v, Section::$ALL); foreach ($sec->getList() as $brd) { if (!$brd->isNormal()) { continue; } $res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return)); } } } else { $b = @$this->params['url']['b']; try { $brd = Board::getInstance($b); } catch (BoardNullException $e) { $this->error(ECode::$BOARD_NONE); } $res = Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return); } } $p = 1; if (isset($this->params['url']['p'])) { $p = $this->params['url']['p']; } App::import("vendor", "inc/pagination"); $page = new Pagination(new ArrayPageableAdapter($res), Configure::read("pagination.search")); $threads = $page->getPage($p); $info = false; $curTime = strtotime(date("Y-m-d", time())); $pageArticle = Configure::read("pagination.article"); foreach ($threads as $v) { $tabs = ceil($v->articleNum / $pageArticle); $last = $v->LAST; $postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME) . " "; $replyTime = $curTime > $last->POSTTIME ? date("Y-m-d", $last->POSTTIME) : date("H:i:s", $last->POSTTIME) . " "; $info[] = array("title" => Sanitize::html($v->TITLE), "poster" => $v->isSubject() ? $v->OWNER : "ÔÌûÒÑɾ³ý", "postTime" => $postTime, "gid" => $v->ID, "last" => $last->OWNER, "replyTime" => $replyTime, "page" => $tabs, "bName" => $v->getBoard()->NAME, "num" => $v->articleNum - 1); } $this->set("info", $info); $query = $this->params['url']; unset($query['url']); unset($query['p']); unset($query['ext']); foreach ($query as $k => &$v) { $v = $k . '=' . rawurlencode($v); } $query[] = "p=%page%"; $link = "{$this->base}/s/article?" . join("&", $query); $this->set("pageBar", $page->getPageBar($p, $link)); $this->set("pagination", $page); }
/** * op=g|m|;|top|%|x|sharp * top=m|um|x|ux|;|u;|d|dx */ public function ajax_manage() { if (!$this->RequestHandler->isPost()) { $this->error(ECode::$SYS_REQUESTERROR); } if (!isset($this->params['id'])) { $this->error(ECode::$ARTICLE_NONE); } if (!isset($this->params['form']['op']) && !isset($this->params['form']['top'])) { $this->error(); } $u = User::getInstance(); if (!($u->isBM($this->_board) || $u->isAdmin())) { $this->error(ECode::$ARTICLE_NOMANAGE); } $id = $this->params['id']; $ret['refresh'] = true; if (isset($this->params['form']['op'])) { $op = explode('|', $this->params['form']['op']); try { $a = Article::getInstance($id, $this->_board); foreach ($op as $v) { switch ($v) { case 'g': $a->manage(3); break; case 'm': $a->manage(2); break; case ';': $a->manage(4); break; case 'top': if (!$a->isSubject()) { $this->error(ECode::$ARTICLE_NOTORIGIN); } if ($a->isReallyTop()) { $a->manage(1, true); } else { $a->manage(5); } break; case '%': $a->manage(7); break; case 'x': $a->manage(8); break; case 'sharp': $a->manage(9); break; } } } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } catch (ArticleManageException $e) { $this->error($e->getMessage); } } if (isset($this->params['form']['top'])) { $top = explode('|', $this->params['form']['top']); $gid = isset($this->params['form']['gid']) ? $this->params['form']['gid'] : $id; try { $t = Threads::getInstance($gid, $this->_board); $s = $gid == $id ? null : $id; if (in_array('d', $top)) { $t->manage(1, $s); $ret['refresh'] = false; } else { foreach ($top as $v) { switch ($v) { case 'm': $t->manage(2, $s); break; case 'um': $t->manage(3, $s); break; case 'x': $t->manage(6, $s); break; case 'ux': $t->manage(7, $s); break; case ';': $t->manage(8, $s); break; case 'u;': $t->manage(9, $s); break; case 'dx': $t->manage(4, $s); $ret['refresh'] = false; break; } } } } catch (ThreadsNullException $e) { $this->error(ECode::$ARTICLE_NONE); } catch (ArticleManageException $e) { $this->error($e->getMessage); } } $ret['ajax_code'] = ECode::$SYS_AJAXOK; $ret['default'] = '/board/' . $this->_board->NAME; $mode = $this->Cookie->read('BMODE'); if ($mode != null && $mode != BOARD::$THREAD) { $ret['default'] .= '/mode/' . $this->Cookie->read('BMODE'); } $this->set('no_html_data', $ret); }
function getMustShowThreads($threads = array()) { if ($this->request->getCheck('lqt_operand')) { $operands = explode(',', $this->request->getVal('lqt_operand')); $threads = array_merge($threads, $operands); } if ($this->request->getCheck('lqt_mustshow')) { // Check for must-show in the request $specifiedMustShow = $this->request->getVal('lqt_mustshow'); $specifiedMustShow = explode(',', $specifiedMustShow); $threads = array_merge($threads, $specifiedMustShow); } foreach ($threads as $walk_thread) { do { if (!is_object($walk_thread)) { $walk_thread = Threads::withId($walk_thread); } if (!is_object($walk_thread)) { continue; } $threads[$walk_thread->id()] = $walk_thread; $walk_thread = $walk_thread->superthread(); } while ($walk_thread); } return $threads; }
public function view() { $this->css[] = "xwidget.css"; $this->css['plugin']['vote'][] = "vote.css"; $this->js['plugin']['vote'][] = "vote.js"; $this->js[] = "forum.share.js"; $this->notice[] = array("url" => "", "text" => "查看投票"); $this->cache(false); if (!isset($this->params['vid'])) { $this->error("未知的投票"); } $vid = intval($this->params['vid']); try { $vote = new Vote($vid); } catch (VoteNullException $e) { $this->error("未知的投票"); } $u = User::getInstance(); if ($vote->isDeleted() && !$u->isAdmin()) { $this->error("此投票已删除"); } $myres = $vote->getResult($u->userid); $voted = false; if ($myres !== false) { $voted = true; $myres['time'] = date("Y-m-d H:i:s", $myres['time']); $this->set("myres", $myres); } App::import('Sanitize'); $info = array("vid" => $vote->vid, "title" => Sanitize::html($vote->subject), "desc" => nl2br(Sanitize::html($vote->desc)), "start" => date("Y-m-d H:i:s", $vote->start), "end" => date("Y-m-d", $vote->end), "num" => $vote->num, "type" => $vote->type, "limit" => $vote->limit, "aid" => $vote->aid, "isEnd" => $vote->isEnd(), "isDel" => $vote->isDeleted(), "voted" => $voted, "uid" => $vote->uid); $item = $vote->items; foreach ($item as $k => $v) { $item[$k]["label"] = Sanitize::html($v["label"]); $item[$k]["percent"] = $vote->total === 0 ? 0 : round(intval($v['num']) * 100 / $vote->total); $item[$k]["on"] = $myres !== false && in_array($v['viid'], $myres['items']); } $this->set("board", $this->_board); $this->set("admin", $u->userid === $vote->uid || $u->isAdmin()); $this->set("result_voted", $vote->result_voted); $this->set("no_result", !$vote->isEnd() && !$this->get('admin') && $vote->result_voted && !$voted); $this->set("vinfo", $info); $this->set("vitems", $item); try { $u = User::getInstance($vote->uid); $furl = $u->getFace(); } catch (UserNullException $e) { $furl = false; } $this->set("furl", Sanitize::html($furl)); $this->set("fwidth", $u->userface_width === 0 ? "" : $u->userface_width); $this->set("fheight", $u->userface_height === 0 ? "" : $u->userface_height); App::import('vendor', array('model/board', 'model/threads', 'inc/ubb')); try { $threads = Threads::getInstance($vote->aid, Board::getInstance($this->_board)); $s = $threads->getTotalNum() - $this->_commentNum + 1; $articles = $threads->getRecord($s > 1 ? $s : 1, $this->_commentNum); $info = array(); foreach ($articles as $v) { if ($v->OWNER === 'deliver') { continue; } $tmp = array(); try { $own = User::getInstance($v->OWNER); $tmp['uid'] = $own->userid; $tmp['furl'] = Sanitize::html($own->getFace()); } catch (UserNullException $e) { $tmp['uid'] = $v->OWNER; $tmp['furl'] = false; } $tmp['time'] = date("Y-m-d H:i:s", $v->POSTTIME); $content = $v->getPlant(); $content = preg_replace("|<br/>【 在 deliver[\\s\\S]+<br/>: \\.{5,}<br/>|", '', $content); $content = preg_replace("/ /", " ", $content); $content = preg_replace("/ /", " ", $content); $content = preg_replace("|※ 修改:·([\\S]+) .*?FROM:[\\s]*([0-9a-zA-Z.:*]+)|", '', $content); $content = preg_replace("|※ 来源:.*FROM:[\\s]*([0-9a-zA-Z.:*]+)|", '', $content); $s = ($pos = strpos($content, "<br/><br/>")) === false ? 0 : $pos + 10; $e = ($pos = strpos($content, "<br/>--<br/>")) === false ? strlen($content) : $pos + 7; $content = preg_replace(array("'^(<br/>)+'", "|(<br/>)+--\$|"), array("", ""), substr($content, $s, $e - $s)); if (Configure::read("ubb.parse")) { $content = XUBB::parse($content); } $tmp['content'] = $content; $info[] = $tmp; } if (!strncmp($threads->TITLE, "Re: ", 4)) { $this->set("title", $threads->TITLE); } else { $this->set("title", 'Re: ' . $threads->TITLE); } $this->set("ajax_title", urlencode('投票:' . $threads->TITLE)); $this->set("reid", $threads->ID); $this->set("more", $threads->getTotalNum() > $this->_commentNum + 1); $this->set("comments", $info); } catch (ThreadsNullException $e) { $this->set("comments", false); } }
<?php require '../loader.php'; /** * get user threads */ $userId = input_get('user_id'); if ($userId) { $users = new Users(); $threads = new Threads(); $messages = new Messages(); $user_threads = array(); $user_threads_ids = $users->getUserThreads($userId); if ($user_threads_ids) { for ($i = 0, $count = count($user_threads_ids); $i < $count; $i++) { $user_threads[] = array('id' => $user_threads_ids[$i]); $thread_users = $threads->getThreadUsers($user_threads_ids[$i]); $user_threads[$i]['users'] = array(); for ($j = 0, $jCount = count($thread_users); $j < $jCount; $j++) { $user_threads[$i]['users'][] = $users->getUser($thread_users[$j]); } $last_message = $messages->getMessage($threads->getLastMessageOfThread($user_threads_ids[$i])); $last_message['user'] = $users->getUser($last_message['sender_id']); unset($last_message['sender_id']); $user_threads[$i]['last_message'] = $last_message; } } echo output_json(TRUE, ERR_EMPTY, $user_threads); } else { echo output_json(FALSE, ERR_MISSING_DATA); }
static function watchedThreadsForUser($user) { $talkPage = new Article($user->getUserPage()->getTalkPage()); $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select(array('thread', 'user_message_state'), '*', array('ums_read_timestamp' => null, 'ums_user' => $user->getId(), 'not (' . Threads::articleClause($talkPage) . ')'), __METHOD__, array(), array('user_message_state' => array('INNER JOIN', 'ums_thread=thread_id'))); return Threads::loadFromResult($res, $dbr); }
function getQueryInfo() { $queryInfo = array('tables' => array('thread_history', 'thread', 'page'), 'fields' => '*', 'conds' => array(Threads::articleClause($this->talkpage)), 'options' => array('order by' => 'th_timestamp desc'), 'join_conds' => array('thread' => array('LEFT JOIN', 'thread_id=th_thread'), 'page' => array('LEFT JOIN', 'thread_root=page_id'))); return $queryInfo; }
/** * @param $params array * @param $db DatabaseBase * @return array */ function getConditions($params, $db) { $conds = array(); // Types $conds['thread_type'] = Threads::TYPE_NORMAL; // Limit $cutoff = time() - intval($params['days'] * 24 * 3600); $cutoff = $db->timestamp($cutoff); $conds[] = 'thread_created > ' . $db->addQuotes($cutoff); // Talkpage conditions $pageConds = array(); $talkpages = (array) $params['talkpage']; foreach ($talkpages as $page) { $title = Title::newFromText($page); $pageCond = array('thread_article_namespace' => $title->getNamespace(), 'thread_article_title' => $title->getDBkey()); $pageConds[] = $db->makeList($pageCond, LIST_AND); } // Thread conditions $threads = (array) $params['thread']; foreach ($threads as $thread) { $root = new Article(Title::newFromText($thread)); $thread = Threads::withRoot($root); if (!$thread) { continue; } $threadCond = array('thread_ancestor' => $thread->id(), 'thread_id' => $thread->id()); $pageConds[] = $db->makeList($threadCond, LIST_OR); } if (count($pageConds)) { $conds[] = $db->makeList($pageConds, LIST_OR); } // New thread v. Reply $types = (array) $params['type']; if (!in_array('replies', $types)) { $conds[] = Threads::topLevelClause(); } elseif (!in_array('newthreads', $types)) { $conds[] = '!' . Threads::topLevelClause(); } return $conds; }
static function showLqtThread($details) { $title = $details["title"]; $article = $details["article"]; global $wgUser, $wgRequest, $wgOut; $oldOut = $wgOut->getHTML(); $wgOut->clearHTML(); $root = new Article($title, 0); $thread = Threads::withRoot($root); $view = new LqtView($wgOut, $article, $title, $wgUser, $wgRequest); $view->showThread($thread); $html = $wgOut->getHTML(); $wgOut->clearHTML(); $wgOut->getHTML($oldOut); return $html; }
getObject('ThisComputer')->raiseEvent("StartUp"); // 1 second sleep sleep(1); // getting list of /scripts/cycle_*.php files to run each in separate thread $cycles = array(); if (is_dir("./scripts")) { if ($lib_dir = opendir("./scripts")) { while (($lib_file = readdir($lib_dir)) !== false) { if (preg_match("/^cycle_.+?\\.php\$/", $lib_file)) { $cycles[] = './scripts/' . $lib_file; } } closedir($lib_dir); } } $threads = new Threads(); if (defined('PATH_TO_PHP')) { $threads->phpPath = PATH_TO_PHP; } else { $threads->phpPath = IsWindowsOS() ? '..\\server\\php\\php.exe' : 'php'; } foreach ($cycles as $path) { if (file_exists($path)) { DebMes("Starting " . $path . " ... "); echo "Starting " . $path . " ... "; if (preg_match("/_X/", $path)) { //для начала убедимся, что мы в Линуксе. Иначе удаленный запуск этих скриптов не делаем if (!IsWindowsOS()) { $display = '101'; //Попробуем получить номер Дисплея из имени файла if (preg_match("/_X(.+)_/", $path, $displays)) {
<?php require_once dirname(__DIR__) . "/classes/general/threads.php"; set_time_limit(0); if ($params = Threads::getParams()) { $_SERVER["DOCUMENT_ROOT"] = $DOCUMENT_ROOT = $params["documentRoot"]; require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php"; Cmodule::IncludeModule("acrit.exportpro"); $export = new CAcritExportproExport(intval($params["profileId"])); $export->Export("cron", $params["cronPage"]); }
public function forward() { $this->requestLogin(); if (!isset($this->params['gid'])) { $this->error(ECode::$ARTICLE_NONE); } $single = isset($this->params['url']['s']) || isset($this->params['form']['s']); if ($this->RequestHandler->isPost()) { if (!isset($this->params['form']['target'])) { $this->error(ECode::$USER_NONE); } $gid = intval($this->params['gid']); $target = trim($this->params['form']['target']); $threads = isset($this->params['form']['threads']); $noref = isset($this->params['form']['noref']); $noatt = isset($this->params['form']['noatt']); $noansi = isset($this->params['form']['noansi']); $big5 = isset($this->params['form']['big5']); try { $gid = $this->params['gid']; $article = Article::getInstance($gid, $this->_board); if ($threads) { $t = Threads::getInstance($article->GROUPID, $this->_board); $t->forward($target, $t->ID, $noref, $noatt, $noansi, $big5); } else { $article->forward($target, $noatt, $noansi, $big5); } } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } catch (ArticleForwardException $e) { $this->error($e->getMessage()); } $this->redirect($this->_mbase . "/board/" . $this->_board->NAME . ($single ? "/0" : "") . "?m=" . ECode::$ARTICLE_FORWARDOK); } $this->notice = "{$this->_board->DESC}-转寄"; App::import("vendor", array("model/friend")); $f = new Friend(User::getInstance()); $friends = $f->getRecord(1, $f->getTotalNum()); $ret = array(); foreach ($friends as $v) { $ret[] = $v->userid; } $this->set('friends', $ret); $this->set('bName', $this->_board->NAME); $this->set('gid', $this->params['gid']); $this->set("single", $single); }
if (!$db->fieldExists('thread', $field, 'lqt-update-script')) { $db->sourceFile(dirname(__FILE__) . '/schema-changes/' . $patch); } } foreach ($threadIndexUpdates as $index => $patch) { if (!$db->indexExists('thread', $index, 'lqt-update-script')) { $db->sourceFile(dirname(__FILE__) . '/schema-changes/' . $patch); } } foreach ($newTableUpdates as $table => $patch) { if (!$db->tableExists($table, 'lqt-update-script')) { $db->sourceFile(dirname(__FILE__) . '/schema-changes/' . $patch); } } // Batch lazy updates $upTo = $lastUpTo = 0; do { $lastUpTo = $upTo; $db->begin(); // Read 500 rows $res = $db->select('thread', '*', array('thread_id>' . $db->addQuotes($upTo)), 'lqt-update-script', array('LIMIT' => 500, 'FOR UPDATE', 'ORDER BY' => 'thread_id asc')); $threads = Threads::loadFromResult($res, $db); foreach ($threads as $thread) { $thread->doLazyUpdates(); $thread->updateHistory(); if ($thread->id() > $upTo) { $upTo = $thread->id(); } } $db->commit(); } while ($lastUpTo != $upTo);
static function validateSubject($subject, &$title, $replyTo, $article) { $t = null; $ok = true; while (!$t) { try { global $wgUser; if (!$replyTo && $subject) { $t = Threads::newThreadTitle($subject, $article); } elseif ($replyTo) { $t = Threads::newReplyTitle($replyTo, $wgUser); } if ($t) { break; } } catch (Exception $e) { } $subject = md5(mt_rand()); // Just a random title $ok = false; } $title = $t; return $ok; }
static function onArticleDelete($article) { // Synchronise article data so that moving the article doesn't break any // article association. Threads::synchroniseArticleData($article); return true; }
/** Keep trying titles starting with $basename until one is unoccupied. */ public static function incrementedTitle($basename, $namespace) { global $wgContLang; $i = 2; // Try to make the title valid. $basename = Threads::makeTitleValid($basename); $t = Title::makeTitleSafe($namespace, $basename); while (!$t || in_array($t->getPrefixedDBkey(), self::$occupied_titles) || $t->exists() || $t->isDeletedQuick()) { if (!$t) { throw new Exception("Error in creating title for basename {$basename}"); } $n = $wgContLang->formatNum($i); $t = Title::makeTitleSafe($namespace, $basename . ' (' . $n . ')'); $i++; } return $t; }
public function threads() { App::import('vendor', array('model/board', 'model/threads', 'inc/pagination')); $day = 7; $title1 = $title2 = $title3 = $author = ''; if (isset($this->params['url']['title1'])) { $title1 = trim($this->params['url']['title1']); } if (isset($this->params['url']['title2'])) { $title2 = trim($this->params['url']['title2']); } if (isset($this->params['url']['titlen'])) { $title3 = trim($this->params['url']['titlen']); } if (isset($this->params['url']['author'])) { $author = trim($this->params['url']['author']); } if (isset($this->params['url']['day'])) { $day = intval($this->params['url']['day']); } $m = isset($this->params['url']['m']) && $this->params['url']['m'] == '1'; $a = isset($this->params['url']['a']) && $this->params['url']['a'] == '1'; $return = Configure::read('search.max'); $res = array(); if (!isset($this->params['url']['boards'])) { $this->error(ECode::$BOARD_UNKNOW); } $boards = $this->params['url']['boards']; foreach (explode('|', $boards) as $b) { try { $brd = Board::getInstance($b); $res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return)); } catch (BoardNullException $e) { } } $count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.threads"); if (($count = intval($count)) <= 0) { $count = Configure::read("pagination.threads"); } if ($count > Configure::read('plugins.api.page_item_limit')) { $count = Configure::read("pagination.threads"); } $page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1; $page = intval($page); $pagination = new Pagination(new ArrayPageableAdapter($res), $count); $articles = $pagination->getPage($page); $wrapper = Wrapper::getInstance(); $data = array(); $data['pagination'] = $wrapper->page($pagination); foreach ($articles as $v) { $data['threads'][] = $wrapper->article($v, array('threads' => true)); } $this->set('data', $data); }