/** * @see Action::execute() */ public function execute() { parent::execute(); // count threads $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_thread"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get thread ids $threadIDs = ''; $sql = "SELECT\t\tthreadID, topic\n\t\t\tFROM\t\twbb" . WBB_N . "_thread\n\t\t\tORDER BY\tthreadID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); if (!WCF::getDB()->countRows($result)) { $this->calcProgress(); $this->finish(); } while ($row = WCF::getDB()->fetchArray($result)) { // delete old entries $sql = "DELETE FROM\twbb" . WBB_N . "_thread_similar\n\t\t\t\tWHERE\t\tthreadID = " . $row['threadID']; WCF::getDB()->sendQuery($sql); // update entries ThreadEditor::updateSimilarThreads($row['threadID'], $row['topic']); } $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // count board $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_board"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get board ids $boardIDs = ''; $sql = "SELECT\t\tboardID\n\t\t\tFROM\t\twbb" . WBB_N . "_board\n\t\t\tORDER BY\tboardID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); while ($row = WCF::getDB()->fetchArray($result)) { $boardIDs .= ',' . $row['boardID']; // update last post $board = new BoardEditor($row['boardID']); $board->setLastPosts(); } if (empty($boardIDs)) { // clear board cache WCF::getCache()->clear(WBB_DIR . 'cache', 'cache.boardData.php'); $this->calcProgress(); $this->finish(); } // update boards $sql = "UPDATE\twbb" . WBB_N . "_board board\n\t\t\tSET\tthreads = (\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\t\t\tWHERE\tboardID = board.boardID\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t),\n\t\t\t\tposts = (\n\t\t\t\t\tSELECT\tIFNULL(SUM(replies), 0) + COUNT(*)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread thread\n\t\t\t\t\tWHERE\tboardID = board.boardID\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\t)\n\t\t\tWHERE\tboard.boardID IN (0" . $boardIDs . ")"; WCF::getDB()->sendQuery($sql); $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // count posts $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_post"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get postids $postIDs = ''; $sql = "SELECT\t\tpostID\n\t\t\tFROM\t\twbb" . WBB_N . "_post\n\t\t\tORDER BY\tpostID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); while ($row = WCF::getDB()->fetchArray($result)) { $postIDs .= ',' . $row['postID']; } if (empty($postIDs)) { $this->calcProgress(); $this->finish(); } // update posts $sql = "UPDATE\twbb" . WBB_N . "_post post\n\t\t\tSET\tattachments = IFNULL((\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM\twcf" . WCF_N . "_attachment attachment\n\t\t\t\t\tWHERE\tattachment.packageID = " . PACKAGE_ID . "\n\t\t\t\t\t\tAND attachment.containerID = post.postID\n\t\t\t\t\t\tAND attachment.containerType = 'post'\n\t\t\t\t), 0)\n\t\t\tWHERE\tpost.postID IN (0" . $postIDs . ")"; WCF::getDB()->sendQuery($sql); $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // add cache resources WCF::getCache()->addResource('bbcodes', WCF_DIR . 'cache/cache.bbcodes.php', WCF_DIR . 'lib/system/cache/CacheBuilderBBCodes.class.php'); WCF::getCache()->addResource('smileys', WCF_DIR . 'cache/cache.smileys.php', WCF_DIR . 'lib/system/cache/CacheBuilderSmileys.class.php'); // count threads $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_thread"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get thread ids $threadIDs = ''; $sql = "SELECT\t\tthreadID\n\t\t\tFROM\t\twbb" . WBB_N . "_thread\n\t\t\tORDER BY\tthreadID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); while ($row = WCF::getDB()->fetchArray($result)) { $threadIDs .= ',' . $row['threadID']; } if (empty($threadIDs)) { $this->calcProgress(); $this->finish(); } // get data $sql = "SELECT\t\tthread.threadID,\n\t\t\t\t\tpost.postID, post.message, post.enableSmilies, post.enableHtml, post.enableBBCodes\n\t\t\tFROM\t\twbb" . WBB_N . "_thread thread\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_post post\n\t\t\tON\t\t(post.postID = thread.firstPostID)\n\t\t\tWHERE\t\tthread.threadID IN (0" . $threadIDs . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if ($row['postID']) { PostEditor::updateFirstPostPreview($row['threadID'], $row['postID'], $row['message'], $row); } } $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // count message $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_pm"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get message ids $pmIDArray = array(); $sql = "SELECT\t\tpmID\n\t\t\tFROM\t\twcf" . WCF_N . "_pm\n\t\t\tORDER BY\tpmID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); while ($row = WCF::getDB()->fetchArray($result)) { $pmIDArray[] = $row['pmID']; } if (!count($pmIDArray)) { $this->calcProgress(); $this->finish(); } // reset attachment status $sql = "UPDATE\twcf" . WCF_N . "_pm\n\t\t\tSET\tattachments = 0\n\t\t\tWHERE\tpmID IN (" . implode(',', $pmIDArray) . ")"; WCF::getDB()->sendQuery($sql); // update attachment status $sql = "SELECT\t\tCOUNT(*) AS count, containerID\n\t\t\tFROM\t\twcf" . WCF_N . "_attachment\n\t\t\tWHERE\t\tpackageID IN (\n\t\t\t\t\t\tSELECT\tdependency\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package_dependency\n\t\t\t\t\t\tWHERE\tpackageID = " . PACKAGE_ID . "\n\t\t\t\t\t)\n\t\t\t\t\tAND containerID IN (" . implode(',', $pmIDArray) . ")\n\t\t\t\t\tAND containerType = 'pm'\n\t\t\tGROUP BY\tcontainerID"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $sql = "UPDATE\twcf" . WCF_N . "_pm\n\t\t\t\tSET\tattachments = " . $row['count'] . "\n\t\t\t\tWHERE\tpmID = " . $row['containerID']; WCF::getDB()->sendQuery($sql); } // update viewed status $sql = "UPDATE\twcf" . WCF_N . "_pm pm\n\t\t\tSET\tisViewedByAll = if((\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM \twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tWHERE \tpmID = pm.pmID\n\t\t\t\t\t\tAND isDeleted < 2\n\t\t\t\t\t\tAND isViewed = 0) > 0\n\t\t\t\t, 0, 1)\n\t\t\tWHERE\tpm.pmID IN (" . implode(',', $pmIDArray) . ")"; WCF::getDB()->sendQuery($sql); $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // count thread $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_thread"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get threads $counter = 0; $sql = "SELECT\t\t*\n\t\t\tFROM\t\twbb" . WBB_N . "_thread\n\t\t\tORDER BY\tthreadID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); while ($row = WCF::getDB()->fetchArray($result)) { $counter++; if ($row['movedThreadID']) { continue; } // get last post information $sql = "SELECT\t\tpostID, time, userID, username\n\t\t\t\tFROM\t\twbb" . WBB_N . "_post\n\t\t\t\tWHERE\t\tthreadID = " . $row['threadID'] . "\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\tORDER BY\ttime DESC"; $lastPostRow = WCF::getDB()->getFirstRow($sql); if (empty($lastPostRow['postID'])) { $lastPostRow = array('time' => $row['lastPostTime'], 'userID' => $row['lastPosterID'], 'username' => $row['lastPoster']); } // get first post information $sql = "SELECT\t\tpostID, time, userID, username\n\t\t\t\tFROM\t\twbb" . WBB_N . "_post\n\t\t\t\tWHERE\t\tthreadID = " . $row['threadID'] . "\n\t\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\t\tAND isDisabled = 0\n\t\t\t\tORDER BY\ttime"; $firstPostRow = WCF::getDB()->getFirstRow($sql); if (empty($firstPostRow['postID'])) { $firstPostRow = array('postID' => $row['firstPostID'], 'time' => $row['time'], 'userID' => $row['userID'], 'username' => $row['username']); } // get stats $sql = "SELECT\tCOUNT(*) AS posts,\n\t\t\t\t\tSUM(attachments) AS attachments,\n\t\t\t\t\tSUM(IF(pollID <> 0, 1, 0)) AS polls\n\t\t\t\tFROM\twbb" . WBB_N . "_post\n\t\t\t\tWHERE\tthreadID = " . $row['threadID'] . "\n\t\t\t\t\tAND isDeleted = 0\n\t\t\t\t\tAND isDisabled = 0"; $statsRow = WCF::getDB()->getFirstRow($sql); if (empty($statsRow['posts'])) { $statsRow['posts'] = 1; } if (empty($statsRow['attachments'])) { $statsRow['attachments'] = 0; } if (empty($statsRow['polls'])) { $statsRow['polls'] = 0; } // update thread $sql = "UPDATE\twbb" . WBB_N . "_thread thread\n\t\t\t\tSET\tlastPostTime = " . $lastPostRow['time'] . ",\n\t\t\t\t\tlastPosterID = " . $lastPostRow['userID'] . ",\n\t\t\t\t\tlastPoster = '" . escapeString($lastPostRow['username']) . "',\n\t\t\t\t\treplies = " . ($statsRow['posts'] - 1) . ",\n\t\t\t\t\tattachments = " . $statsRow['attachments'] . ",\n\t\t\t\t\tpolls = " . $statsRow['polls'] . ",\n\t\t\t\t\tfirstPostID = " . $firstPostRow['postID'] . ",\n\t\t\t\t\ttime = " . $firstPostRow['time'] . ",\n\t\t\t\t\tuserID = " . $firstPostRow['userID'] . ",\n\t\t\t\t\tusername = '******'username']) . "'\n\t\t\t\tWHERE\tthread.threadID = " . $row['threadID']; WCF::getDB()->sendQuery($sql); } if (!$counter) { $this->calcProgress(); $this->finish(); } $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // set installation date $sql = "UPDATE\twcf" . WCF_N . "_option\n\t\t\tSET\toptionValue = IFNULL((\n\t\t\t\t\tSELECT\tMIN(time)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\t\t\tWHERE\ttime > 0\n\t\t\t\t), optionValue)\n\t\t\tWHERE\toptionName = 'install_date'\n\t\t\t\tAND packageID = " . PACKAGE_ID; WCF::getDB()->sendQuery($sql); // delete options file @unlink(WBB_DIR . 'options.inc.php'); // update boards $sql = "UPDATE\twbb" . WBB_N . "_board board\n\t\t\tSET\ttime = IFNULL((\n\t\t\t\t\tSELECT\tMIN(time)\n\t\t\t\t\tFROM\twbb" . WBB_N . "_thread\n\t\t\t\t\tWHERE\tboardID = board.boardID\n\t\t\t\t\t\tAND time > 0\n\t\t\t\t), " . TIME_NOW . ")"; WCF::getDB()->sendQuery($sql); // clear board cache WCF::getCache()->clear(WBB_DIR . 'cache', 'cache.board.php'); $this->executed(); $this->calcProgress(); $this->finish(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // count threads $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_attachment\n\t\t\tWHERE\tisImage = 1"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get attachments $threadIDs = ''; $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_attachment\n\t\t\tWHERE\t\tisImage = 1\n\t\t\tORDER BY\tattachmentID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); if (!WCF::getDB()->countRows($result)) { $this->calcProgress(); $this->finish(); } while ($row = WCF::getDB()->fetchArray($result)) { $attachment = new AttachmentEditor(null, $row); $attachment->createThumbnail(); } $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }
/** * @see Action::execute() */ public function execute() { parent::execute(); // count users $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twbb" . WBB_N . "_user"; $row = WCF::getDB()->getFirstRow($sql); $count = $row['count']; // get user ids $userIDs = ''; $sql = "SELECT\t\tuserID\n\t\t\tFROM\t\twbb" . WBB_N . "_user\n\t\t\tORDER BY\tuserID"; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop); while ($row = WCF::getDB()->fetchArray($result)) { $userIDs .= ',' . $row['userID']; // update last posts if (PROFILE_SHOW_LAST_POSTS) { // delete old entries $sql = "DELETE FROM\twbb" . WBB_N . "_user_last_post\n\t\t\t\t\tWHERE\t\tuserID = " . $row['userID']; WCF::getDB()->sendQuery($sql); // get new entries $sql = "SELECT\t\tpostID, time\n\t\t\t\t\tFROM\t\twbb" . WBB_N . "_post\n\t\t\t\t\tWHERE\t\tuserID = " . $row['userID'] . "\n\t\t\t\t\tORDER BY\ttime DESC"; $result2 = WCF::getDB()->sendQuery($sql, 20); while ($row2 = WCF::getDB()->fetchArray($result2)) { $sql = "INSERT INTO\twbb" . WBB_N . "_user_last_post\n\t\t\t\t\t\t\t\t(userID, postID, time)\n\t\t\t\t\t\tVALUES\t\t(" . $row['userID'] . ", " . $row2['postID'] . ", " . $row2['time'] . ")"; WCF::getDB()->sendQuery($sql); } } } if (empty($userIDs)) { $this->calcProgress(); $this->finish(); } // get boards $boardIDs = ''; $sql = "SELECT\tboardID\n\t\t\tFROM\twbb" . WBB_N . "_board\n\t\t\tWHERE\tboardType = 0\n\t\t\t\tAND countUserPosts = 1"; $result2 = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result2)) { $boardIDs .= ',' . $row['boardID']; } // update users posts $sql = "UPDATE\twbb" . WBB_N . "_user user\n\t\t\tSET\tposts = (\n\t\t\t\t\tSELECT\t\tCOUNT(*)\n\t\t\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\t\t\tWHERE\t\tpost.userID = user.userID\n\t\t\t\t\t\t\tAND post.isDeleted = 0\n\t\t\t\t\t\t\tAND post.isDisabled = 0\n\t\t\t\t\t\t\tAND thread.boardID IN (0" . $boardIDs . ")\n\t\t\t\t)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")"; WCF::getDB()->sendQuery($sql); // update activity points $sql = "SELECT\t\twbb_user.userID, wbb_user.posts, user.activityPoints, COUNT(thread.threadID) AS threads\n\t\t\tFROM\t\twbb" . WBB_N . "_user wbb_user\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = wbb_user.userID)\n\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\tON\t\t(thread.userID = wbb_user.userID AND thread.boardID IN (0" . $boardIDs . ") AND thread.isDeleted = 0 AND thread.isDisabled = 0)\n\t\t\tWHERE\t\twbb_user.userID IN (0" . $userIDs . ")\n\t\t\tGROUP BY\twbb_user.userID"; $result2 = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result2)) { $activityPoints = $row['threads'] * ACTIVITY_POINTS_PER_THREAD + ($row['posts'] - $row['threads']) * ACTIVITY_POINTS_PER_POST; // update activity points for this package $sql = "REPLACE INTO\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\t\t(userID, packageID, activityPoints)\n\t\t\t\tVALUES \t\t(" . $row['userID'] . ", " . PACKAGE_ID . ", " . $activityPoints . ")"; WCF::getDB()->sendQuery($sql); } // remove obsolet activity points $sql = "DELETE FROM\twcf" . WCF_N . "_user_activity_point\n\t\t\tWHERE\t\tpackageID NOT IN (\n\t\t\t\t\t\tSELECT\tpackageID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\t\t)"; WCF::getDB()->sendQuery($sql); // update global activity points $sql = "UPDATE\twcf" . WCF_N . "_user user\n\t\t\tSET\tuser.activityPoints = (\n\t\t\t\t\tSELECT\tSUM(activityPoints)\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user_activity_point\n\t\t\t\t\tWHERE\tuserID = user.userID\n\t\t\t\t)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")"; WCF::getDB()->sendQuery($sql); // update pm counts $sql = "UPDATE\twcf" . WCF_N . "_user user\n\t\t\tSET\tpmUnreadCount = (\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM \twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tWHERE \trecipientID = user.userID\n\t\t\t\t\t\tAND isDeleted < 2\n\t\t\t\t\t\tAND isViewed = 0\n\t\t\t\t),\n\t\t\t\tpmTotalCount = (\n\t\t\t\t\tSELECT\tCOUNT(*)\n\t\t\t\t\tFROM \twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\tWHERE \trecipientID = user.userID\n\t\t\t\t\t\tAND isDeleted < 2)\n\t\t\t\t\t\t+ (\n\t\t\t\t\tSELECT\t\tCOUNT(*)\n\t\t\t\t\tFROM \t\twcf" . WCF_N . "_pm pm\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_pm_to_user pm_to_user\n\t\t\t\t\tON\t\t(pm_to_user.pmID = pm.pmID\n\t\t\t\t\t\t\tAND pm_to_user.recipientID = pm.userID\n\t\t\t\t\t\t\tAND pm_to_user.isDeleted < 2)\n\t\t\t\t\tWHERE \t\tuserID = user.userID\n\t\t\t\t\t\t\tAND (saveInOutBox = 1\n\t\t\t\t\t\t\tOR isDraft = 1)\n\t\t\t\t\t\t\tAND pm_to_user.pmID IS NULL)\n\t\t\tWHERE\tuser.userID IN (0" . $userIDs . ")"; WCF::getDB()->sendQuery($sql); // update user rank require_once WCF_DIR . 'lib/data/user/rank/UserRank.class.php'; WCF::getDB()->seekResult($result, 0); while ($row = WCF::getDB()->fetchArray($result)) { UserRank::updateActivityPoints(0, $row['userID']); } $this->executed(); $this->calcProgress($this->limit * $this->loop, $count); $this->nextLoop(); }