/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { if (WCF::getUser()->userID && WCF::getUser()->getPermission('admin.general.canUseAcp') && !defined(get_class($eventObj) . '::DO_NOT_LOG')) { // try to find existing session log $sql = "SELECT\tsessionLogID\n\t\t\t\tFROM\twcf" . WCF_N . "_acp_session_log\n\t\t\t\tWHERE\tsessionID = '" . WCF::getSession()->sessionID . "'\n\t\t\t\t\tAND lastActivityTime >= " . (TIME_NOW - SESSION_TIMEOUT); $row = WCF::getDB()->getFirstRow($sql); if (!empty($row['sessionLogID'])) { $sessionLogID = $row['sessionLogID']; // update session log $sql = "UPDATE\twcf" . WCF_N . "_acp_session_log\n\t\t\t\t\tSET\tlastActivityTime = " . TIME_NOW . "\n\t\t\t\t\tWHERE\tsessionLogID = " . $sessionLogID; WCF::getDB()->registerShutdownUpdate($sql); } else { // create new session log $sql = "INSERT INTO\twcf" . WCF_N . "_acp_session_log\n\t\t\t\t\t\t\t(sessionID, userID, ipAddress, hostname, userAgent, time, lastActivityTime)\n\t\t\t\t\tVALUES\t\t('" . WCF::getSession()->sessionID . "', " . WCF::getUser()->userID . ", '" . escapeString(WCF::getSession()->ipAddress) . "', '" . escapeString(@gethostbyaddr(WCF::getSession()->ipAddress)) . "', '" . escapeString(WCF::getSession()->userAgent) . "', " . TIME_NOW . ", " . TIME_NOW . ")"; WCF::getDB()->sendQuery($sql); $sessionLogID = WCF::getDB()->getInsertID("wcf" . WCF_N . "_acp_session_log", 'sessionLogID'); } // format request uri $requestURI = WCF::getSession()->requestURI; // remove directories $URIComponents = explode('/', $requestURI); $requestURI = array_pop($URIComponents); // remove session url $requestURI = preg_replace('/(?:\\?|&)s=[a-f0-9]{40}/', '', $requestURI); // save access $sql = "INSERT INTO\twcf" . WCF_N . "_acp_session_access_log\n\t\t\t\t\t\t(sessionLogID, packageID, ipAddress, time, requestURI, requestMethod, className)\n\t\t\t\tVALUES\t\t(" . $sessionLogID . ", " . PACKAGE_ID . ", '" . escapeString(WCF::getSession()->ipAddress) . "', " . TIME_NOW . ", '" . escapeString($requestURI) . "', '" . escapeString(WCF::getSession()->requestMethod) . "', '" . escapeString(get_class($eventObj)) . "')"; WCF::getDB()->registerShutdownUpdate($sql); } }
/** * @see CacheBuilder::getData() */ public function getData($cacheResource) { list($cache, $packageID, $languageIDs) = explode('-', $cacheResource['cache']); $data = array(); // get all taggable types $sql = "SELECT\t\ttaggable.taggableID, taggable.name\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_tag_taggable taggable\n\t\t\tWHERE \t\ttaggable.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority"; $result = WCF::getDB()->sendQuery($sql); $itemIDs = array(); while ($row = WCF::getDB()->fetchArray($result)) { $itemIDs[$row['name']] = $row['taggableID']; } if (count($itemIDs) > 0) { // get tag ids $tagIDs = array(); $sql = "SELECT\t\tCOUNT(*) AS counter, object.tagID\n\t\t\t\tFROM \t\twcf" . WCF_N . "_tag_to_object object\n\t\t\t\tWHERE \t\tobject.taggableID IN (" . implode(',', $itemIDs) . ")\n\t\t\t\t\t\tAND object.languageID IN (" . $languageIDs . ")\n\t\t\t\tGROUP BY \tobject.tagID\n\t\t\t\tORDER BY \tcounter DESC"; $result = WCF::getDB()->sendQuery($sql, 500); while ($row = WCF::getDB()->fetchArray($result)) { $tagIDs[$row['tagID']] = $row['counter']; } // get tags if (count($tagIDs)) { $sql = "SELECT\t\tname, tagID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\t\tWHERE\t\ttagID IN (" . implode(',', array_keys($tagIDs)) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $row['counter'] = $tagIDs[$row['tagID']]; $this->tags[StringUtil::toLowerCase($row['name'])] = new Tag(null, $row); } // sort by counter uasort($this->tags, array('self', 'compareTags')); $data = $this->tags; } } return $data; }
/** * @see MultipleLinkPage::countItems() */ public function countItems() { parent::countItems(); $sql = "SELECT\t\tCOUNT(*) AS count\n\t\t\tFROM \t\twcf" . WCF_N . "_user\n\t\t\tWHERE\t\tuserID IN (\n\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\tWHERE\tgroupID = " . $this->groupID . "\n\t\t\t\t\t)"; $result = WCF::getDB()->getFirstRow($sql); return $result['count']; }
/** * @see Cronjob::execute() */ public function execute($data) { $sql = "SELECT\t*\n\t\t\tFROM\twcf" . WCF_N . "_group\n\t\t\tWHERE\tneededAge <> 0\n\t\t\t\tOR neededPoints <> 0"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $userIDArray = array(); if ($row['neededAge'] > 0) { $sql = "SELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\tregistrationDate <= " . (TIME_NOW - 86400 * $row['neededAge']) . "\n\t\t\t\t\t\tAND userID NOT IN (\n\t\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\tWHERE\tgroupID = " . $row['groupID'] . "\n\t\t\t\t\t\t)"; $result2 = WCF::getDB()->sendQuery($sql); while ($row2 = WCF::getDB()->fetchArray($result2)) { $userIDArray[] = $row2['userID']; } } if ($row['neededPoints'] > 0) { $sql = "SELECT\tuserID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\tactivityPoints >= " . $row['neededPoints'] . "\n\t\t\t\t\t\tAND userID NOT IN (\n\t\t\t\t\t\t\tSELECT\tuserID\n\t\t\t\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\tWHERE\tgroupID = " . $row['groupID'] . "\n\t\t\t\t\t\t)"; $result2 = WCF::getDB()->sendQuery($sql); while ($row2 = WCF::getDB()->fetchArray($result2)) { $userIDArray[] = $row2['userID']; } } if (count($userIDArray)) { $userIDArray = array_unique($userIDArray); // assign to group $sql = "INSERT INTO\twcf" . WCF_N . "_user_to_groups\n\t\t\t\t\t\t\t(userID, groupID)\n\t\t\t\t\tSELECT\t\tuserID, " . $row['groupID'] . "\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\t\t\tWHERE\t\tuserID IN (" . implode(',', $userIDArray) . ")"; WCF::getDB()->sendQuery($sql); // reset sesions Session::resetSessions($userIDArray); } } }
/** * @see MultipleLinkPage::countItems() */ public function countItems() { SortablePage::countItems(); $sql = "SELECT COUNT(DISTINCT cronjobID) AS count FROM wcf" . WCF_N . "_admin_tools_function_to_cronjob"; $row = WCF::getDB()->getFirstRow($sql); return $row['count']; }
/** * @see Action::execute() */ public function execute() { parent::execute(); WCF::getUser()->checkPermission('admin.user.canDeleteUser'); require_once WCF_DIR . 'lib/data/user/UserEditor.class.php'; require_once WCF_DIR . 'lib/data/user/group/Group.class.php'; if ($this->userID !== 0) { $this->userIDs[] = $this->userID; } // active user can't delete himself $activeUserID = WCF::getSession()->getUser()->userID; $this->userIDs = array_diff($this->userIDs, array($activeUserID)); // check permission if (count($this->userIDs) > 0) { $sql = "SELECT\tDISTINCT groupID\n\t\t\t\tFROM\twcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE\tuserID IN (" . implode(',', $this->userIDs) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!Group::isAccessibleGroup($row['groupID'])) { throw new PermissionDeniedException(); } } } $deletedUsers = UserEditor::deleteUsers($this->userIDs); $this->executed(); if (!empty($this->url) && (strpos($this->url, 'searchID=0') !== false || strpos($this->url, 'searchID=') === false)) { HeaderUtil::redirect($this->url); } else { HeaderUtil::redirect('index.php?form=UserSearch&deletedUsers=' . $deletedUsers . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); } exit; }
/** * @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 CacheBuilder::getData() */ public function getData($cacheResource) { $sql = "SELECT *\r\n\t\t\t\tFROM ugml_stat_type\r\n\t\t\t\tGROUP BY ugml_stat_type.statTypeID"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $sql = "SELECT DISTINCT `time`\r\n\t\t\t\t\tFROM ugml_stat_entry_archive\r\n\t\t\t\t\tWHERE statTypeID = " . $row['statTypeID']; $result2 = WCF::getDB()->sendQuery($sql); while ($row2 = WCF::getDB()->fetchArray($result2)) { $row['times'][] = $row2['time']; } // range $sql = "SELECT MAX(rank)\r\n\t\t\t\t\t\tAS max\r\n\t\t\t\t\tFROM ugml_stat_entry\r\n\t\t\t\t\tWHERE statTypeID = " . $row['statTypeID']; $row += WCF::getDB()->getFirstRow($sql); $this->data[$row['statTypeID']] = $row; } $this->data = array('byStatTypeID' => $this->data, 'byTypeName' => array()); foreach ($this->data['byStatTypeID'] as $statTypeID => $row) { $name = StringUtil::firstCharToUpperCase($row['type']) . StringUtil::firstCharToUpperCase($row['name']); $this->data['byTypeName'][$name] = $row; } // get the names and the types $sql = "SELECT GROUP_CONCAT(DISTINCT type)\r\n\t\t\t\t\t\t\tAS types,\r\n\t\t\t\t\t\tGROUP_CONCAT(DISTINCT name)\r\n\t\t\t\t\t\t\tAS names\r\n\t\t\t\tFROM ugml_stat_type\r\n\t\t\t\tGROUP BY NULL"; $row = WCF::getDB()->getFirstRow($sql); $this->data['types'] = explode(',', $row['types']); $this->data['names'] = explode(',', $row['names']); return $this->data; }
/** * Gets page menu items. */ protected function readPageMenuItems() { $headerPosition = $footerPosition = 1; $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_page_menu_item\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\tORDER BY\tshowOrder"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $hasEnabledOption = true; // check the options of this item if (!empty($row['options'])) { $hasEnabledOption = false; $options = explode(',', strtoupper($row['options'])); foreach ($options as $option) { if (defined($option) && constant($option)) { $hasEnabledOption = true; break; } } } if (!$hasEnabledOption) { continue; } if ($row['menuPosition'] == 'header') { $row['showOrder'] = $headerPosition; $this->headerMenuItemList[$row['menuItemID']] = new PageMenuItem(null, $row); $headerPosition++; } else { $row['showOrder'] = $footerPosition; $this->footerMenuItemList[$row['menuItemID']] = new PageMenuItem(null, $row); $footerPosition++; } } }
/** * @see Form::save() */ public function save() { parent::save(); // send content type header('Content-Type: text/' . $this->fileType . '; charset=' . CHARSET); header('Content-Disposition: attachment; filename="export.' . $this->fileType . '"'); if ($this->fileType == 'xml') { echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<addresses>\n"; } // get users $sql = "SELECT\t\temail\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tWHERE\t\tuserID IN (" . $this->userIDs . ")\n\t\t\tORDER BY\temail"; $result = WCF::getDB()->sendQuery($sql); $i = 0; $j = WCF::getDB()->countRows($result) - 1; while ($row = WCF::getDB()->fetchArray($result)) { if ($this->fileType == 'xml') { echo "<address><![CDATA[" . StringUtil::escapeCDATA($row['email']) . "]]></address>\n"; } else { echo $this->textSeparator . $row['email'] . $this->textSeparator . ($i < $j ? $this->separator : ''); } $i++; } if ($this->fileType == 'xml') { echo "</addresses>"; } UserEditor::unmarkAll(); $this->saved(); exit; }
/** * @see CacheBuilder::getData() */ public function getData($cacheResource) { list($cache, $packageID) = explode('-', $cacheResource['cache']); $data = array('actions' => array('user' => array(), 'admin' => array()), 'inheritedActions' => array('user' => array(), 'admin' => array())); // get all listeners and filter options with low priority $sql = "SELECT\t\tlistener.*, package.packageDir\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_event_listener listener\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\tON\t\t(package.packageID = listener.packageID)\n\t\t\tWHERE \t\tlistener.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $row['listenerClassName'] = StringUtil::getClassName($row['listenerClassFile']); // distinguish between inherited actions and non-inherited actions if (!$row['inherit']) { $data['actions'][$row['environment']][EventHandler::generateKey($row['eventClassName'], $row['eventName'])][] = $row; } else { if (!isset($data['inheritedActions'][$row['environment']][$row['eventClassName']])) { $data['inheritedActions'][$row['eventClassName']] = array(); } $data['inheritedActions'][$row['environment']][$row['eventClassName']][$row['eventName']][] = $row; } } // sort data by class name foreach ($data['actions'] as $environment => $listenerMap) { foreach ($listenerMap as $key => $listeners) { uasort($data['actions'][$environment][$key], array('CacheBuilderEventListener', 'sortListeners')); } } foreach ($data['inheritedActions'] as $environment => $listenerMap) { foreach ($listenerMap as $class => $listeners) { foreach ($listeners as $key => $val) { uasort($data['inheritedActions'][$environment][$class][$key], array('CacheBuilderEventListener', 'sortListeners')); } } } return $data; }
/** * updates scores * @param array $data */ public static function updateRatings($solutionID, $userID, $data) { foreach ($data as $optionID => $score) { $sql = "INSERT INTO\twcf" . WCF_N . "_contest_solution_rating\n\t\t\t\t\t\t(solutionID, userID, optionID, score, time)\n\t\t\t\tVALUES\t\t(" . intval($solutionID) . ", " . intval($userID) . ", " . intval($optionID) . ", " . intval($score) . ", " . TIME_NOW . ")\n\t\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\t\t\tscore = " . intval($score) . ",\n\t\t\t\t\t\ttime = " . TIME_NOW; WCF::getDB()->sendQuery($sql); } }
/** * @see CacheBuilder::getData() */ public function getData($cacheResource) { $data = array('boards' => array(), 'boardStructure' => array(), 'moderators' => array()); // boards $sql = "SELECT\t*\n\t\t\tFROM \twbb" . WBB_N . "_board"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $data['boards'][$row['boardID']] = new Board(null, $row); } // board structure $sql = "SELECT\t\t*\n\t\t\tFROM \t\twbb" . WBB_N . "_board_structure\n\t\t\tORDER BY \tparentID ASC, position ASC"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $data['boardStructure'][$row['parentID']][] = $row['boardID']; } // board moderators $sql = "SELECT \t\tuser.username, wcf_group.groupName,\n\t\t\t\t\tmoderator.*, IFNULL(user.username, wcf_group.groupName) AS name\n\t\t\tFROM \t\twbb" . WBB_N . "_board_moderator moderator\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = moderator.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_group wcf_group\n\t\t\tON \t\t(wcf_group.groupID = moderator.groupID)\n\t\t\tORDER BY \tboardID,\n\t\t\t\t\tname"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (empty($row['name'])) { continue; } if ($row['userID'] != 0) { $object = new User(null, $row); $key = 'u' . $row['userID']; } else { $object = new Group(null, $row); $key = 'g' . $row['groupID']; } $data['moderators'][$row['boardID']][$key] = $object; } return $data; }
/** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { $um = WCF::getTPL()->get('userMessages'); if ($um && preg_match('/page=UserGuestbook/', $um)) { return; } if (WCF::getUser()->userID) { $userID = WCF::getUser()->userID; } if (!empty($userID)) { $ret = WCF::getTPL()->get('userMessages'); require_once WCF_DIR . 'lib/data/user/UserProfile.class.php'; $user = new UserProfile($userID, null, null, null); if ($user->userGuestbook_sendInfo) { $sql = "SELECT gbh.userLastVisit, gbh.newEntries, gbh.lastEntryUserID, gbh.lastEntry, u.username" . "\n FROM wcf" . WCF_N . "_user_guestbook_header gbh" . "\n LEFT JOIN wcf" . WCF_N . "_user u ON (u.userID = gbh.lastEntryUserID)" . "\n WHERE gbh.userID = " . $userID . "\n AND gbh.userID != gbh.lastEntryUserID"; $row = WCF::getDB()->getFirstRow($sql); if (!empty($row['newEntries']) && !empty($row['lastEntry']) && $row['lastEntry'] > $row['userLastVisit']) { if ($row['newEntries'] != 1) { $msg = WCF::getLanguage()->get('wcf.user.guestbook.infoMessages', array('$newEntries' => $row['newEntries'])); } else { $msg = WCF::getLanguage()->get('wcf.user.guestbook.infoMessage', array('$username' => $row['username'])); } WCF::getTPL()->append('userMessages', '<p class="info"><a href="index.php?page=UserGuestbook&userID=' . $userID . SID_ARG_2ND . '">' . $msg . '</a></p>'); } } } }
/** * @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 MultipleLinkPage::countItems() */ public function countItems() { parent::countItems(); $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_bbcode"; $row = WCF::getDB()->getFirstRow($sql); return $row['count']; }
/** * @see AbstractLostAndFoundFileSystemItem::createVirtualIDSpace() */ public static function createVirtualIDSpace() { $attachments = array(); chdir(WCF_DIR . 'attachments'); $dh = opendir(WCF_DIR . 'attachments'); $attachmentIDs = array(); while ($file = readdir($dh)) { if (preg_match("/^(attachment|thumbnail).*/", $file) && $file != '.' && $file != '..' && $file != '.htaccess' && !preg_match("/^.*\\.php\$/", $file)) { $attachmentID = (int) preg_replace("/.*\\-(\\d+)\$/", "\$1", $file); if ($attachmentID > 0) { $attachmentIDs[] = $attachmentID; } } } if (count($attachmentIDs)) { $sql = "SELECT attachmentID FROM wcf" . WCF_N . "_attachment WHERE attachmentID IN (" . implode(',', $attachmentIDs) . ")"; $result = WCF::getDB()->sendQuery($sql); $physicalAttachments = array_flip($attachmentIDs); while ($row = WCF::getDB()->fetchArray($result)) { unset($physicalAttachments[$row['attachmentID']]); } $physicalAttachments = array_keys($physicalAttachments); foreach ($physicalAttachments as $attachmentID) { $file = WCF_DIR . 'attachments/attachment-' . $attachmentID; $attachments[] = $file; } } closedir($dh); self::$virtualFileIDs['attachmentsFilesystem'] = $attachments; WCF::getSession()->register('virtualLostAndFoundIDs', self::$virtualFileIDs); }
protected function getTopOptionCategories($packageID) { // get all option categories and filter categories with low priority $sql = "SELECT\t\tcategoryName, categoryID \n\t\t\tFROM\t\twcf" . WCF_N . "_option_category option_category,\n\t\t\t\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\tWHERE \t\toption_category.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority"; $result = WCF::getDB()->sendQuery($sql); $optionCategories = array(); while ($row = WCF::getDB()->fetchArray($result)) { $optionCategories[$row['categoryName']] = $row['categoryID']; } $sql = "SELECT \t\tcategoryID, parentCategoryName, categoryName,\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT COUNT(*) FROM wcf" . WCF_N . "_option WHERE categoryName = category.categoryName AND packageID IN (\n\t\t\t\t\t\t\tSELECT dependency FROM wcf" . WCF_N . "_package_dependency WHERE packageID = " . $packageID . "\n\t\t\t\t\t\t)\n\t\t\t\t\t) AS count\n\t\t\tFROM\t\twcf" . WCF_N . "_option_category category\n\t\t\tWHERE\t\tcategoryID IN (" . implode(',', $optionCategories) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!isset($this->optionCategoryStructure[$row['parentCategoryName']])) { $this->optionCategoryStructure[$row['parentCategoryName']] = array(); } $this->optionCategoryStructure[$row['parentCategoryName']][] = $row; } $topOptionCategories = array(); foreach ($this->optionCategoryStructure[''] as $optionCategory) { $count = $optionCategory['count'] + $this->countOptions($optionCategory['categoryName']); if ($count > 0) { $topOptionCategories[] = $optionCategory['categoryID']; } } return $topOptionCategories; }
/** * @see MultipleLinkPage::countItems() */ public function countItems() { parent::countItems(); $sql = "SELECT COUNT(*) AS count\n\t\t\t\tFROM ugml_users\n\t\t\t\tWHERE ally_id = " . $this->alliance->allianceID; $result = WCF::getDB()->getFirstRow($sql); return $result['count']; }
/** * @see Form::save() */ public function save() { parent::save(); // save $updateOptionValueUpdate = ''; foreach ($this->activeOptions as $option) { if ($option['defaultValue'] != $option['optionValue']) { $sql = "UPDATE\twcf" . WCF_N . "_user_option\n\t\t\t\t\tSET\tdefaultValue = '" . escapeString($option['optionValue']) . "'\n\t\t\t\t\tWHERE\toptionID = " . $option['optionID']; WCF::getDB()->sendQuery($sql); if (!empty($updateOptionValueUpdate)) { $updateOptionValueUpdate .= ','; } $updateOptionValueUpdate .= 'userOption' . $option['optionID'] . "='" . escapeString($option['optionValue']) . "'"; } } // apply to existing users if ($this->applyChangesToExistingUsers == 1 && !empty($updateOptionValueUpdate)) { $sql = "UPDATE\twcf" . WCF_N . "_user_option_value\n\t\t\t\tSET\t" . $updateOptionValueUpdate; WCF::getDB()->sendQuery($sql); // reset sessions Session::resetSessions(); } // reset cache WCF::getCache()->clearResource($this->cacheName . PACKAGE_ID); // show success message WCF::getTPL()->assign('success', true); }
/** * @see AbstractAction::execute() */ public function execute() { parent::execute(); $subscriber = new NewsletterSubscriber($this->subscriberID); //deletes user subscribers $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->activationTable . ' WHERE userID = ' . intval($subscriber->userID); WCF::getDB()->sendQuery($sql); //resets user setting $user = new UserEditor($subscriber->userID); $options = array('acceptNewsletter' => 0); $user->updateOptions($options); //deletes guest subscribers $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->guestActivationTable . ' WHERE subscriberID = ' . $this->subscriberID; WCF::getDB()->sendQuery($sql); //deletes unsubscribe tokens $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->unsubscriptionTable . ' WHERE subscriberID = ' . $this->subscriberID; WCF::getDB()->sendQuery($sql); $sql = 'DELETE FROM wcf' . WCF_N . '_' . $this->subscriberTable . ' WHERE subscriberID = ' . $this->subscriberID; WCF::getDB()->sendQuery($sql); $this->executed(); //clear cache $cacheName = 'newsletter-subscriber-' . PACKAGE_ID; WCF::getCache()->clear(WCF_DIR . 'cache/', 'cache.' . $cacheName . '.php'); HeaderUtil::redirect('index.php?page=NewsletterSubscriberList&result=success&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED); exit; }
/** * @see Page::readData() */ public function readData() { parent::readData(); if (!empty($this->allianceID)) { $this->alliance = new Alliance($this->allianceID); } else { $this->alliance = Alliance::getByUserID(WCF::getUser()->userID); } // no such alliance if ($this->alliance === null || $this->alliance->id <= 0) { require_once WCF_DIR . 'lib/system/exception/NamedUserException.class.php'; //$_SERVER['HTTP_ACCEPT'] = str_replace('platzhalter', 'application/xhtml+xml', $_SERVER['HTTP_ACCEPT']); // user has no alliance if (empty($this->allianceID)) { // waiting for a answer to the application if (WCF::getUser()->ally_request) { $alliance = new Alliance(WCF::getUser()->ally_request); throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.waitingForApplicationAnswer', array('allianceID' => $alliance->allianceID, 'allianceTag' => $alliance->ally_tag, 'userID' => WCF::getUser()->userID))); } throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.notMember')); } // requested alliance does not exist throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.notExisting')); } // applications if ($this->alliance->getRank(true, 3)) { $sql = "SELECT COUNT(*) AS count\n\t\t\t\t\tFROM ugml_users\n\t\t\t\t\tWHERE ally_request = " . $this->alliance->allianceID; $result = WCF::getDB()->getFirstRow($sql); $this->applicationsCount = $result['count']; } }
/** * @see AbstractFleetEventHandler::executeImpact() */ public function executeImpact() { // check colonies $sql = "SELECT COUNT(*) AS count\r\n\t\t\t\tFROM ugml_planets\r\n\t\t\t\tWHERE planetKind = 1\r\n\t\t\t\t\tAND id_owner = " . $this->ownerID; $count = WCF::getDB()->getFirstRow($sql); // get existing planet $system = new System($this->galaxy, $this->system); $planetObj = $system->getPlanet($this->planet); // restricted by planet limit if ($count['count'] >= self::MAX_PLANETS) { $this->message = 'planetLimit'; return; } // planet exists if ($planetObj !== null) { $this->message = 'exists'; return; } // create planet --$this->fleet[self::COLONY_SHIP]; $name = WCF::getLanguage()->get('wot.planet.colony'); $planet = PlanetEditor::create($this->galaxy, $this->system, $this->planet, $name, $this->ownerID, self::DEFAULT_METAL, self::DEFAULT_CRYSTAL, self::DEFAULT_DEUTERIUM, 1, time(), self::DEFAULT_FIELDS, null); $planet->getEditor()->changeResources($this->metal, $this->crystal, $this->deuterium); $planet->getEditor()->changeLevel($this->fleet); $this->getEditor()->delete(); }
/** * Updates the data in our database table */ public function update() { $updateSQL = ''; if (!empty($this->serverID)) { if (!empty($updateSQL)) { $updateSQL .= ','; } $updateSQL .= '`serverID` = ' . $this->serverID; } if (!empty($updateSQL)) { $updateSQL .= ','; } $updateSQL .= '`authorID` = ' . $this->authorID; if (!empty($this->authorName)) { if (!empty($updateSQL)) { $updateSQL .= ','; } $updateSQL .= '`authorName` = \'' . escapeString($this->authorName) . '\''; } $updateSQL .= ',`message` = \'' . escapeString($this->message) . '\''; $updateSQL .= ",`timestamp` = " . $this->timestamp; $updateSQL .= ',`enableSmilies` = ' . ($this->enableSmilies ? '1' : '0'); $updateSQL .= ',`enableHtml` = ' . ($this->enableHtml ? '1' : '0'); $updateSQL .= ',`enableBBCodes` = ' . ($this->enableBBCodes ? '1' : '0'); $updateSQL .= ",`isDisabled` = " . $this->isDisabled; $sql = "UPDATE bash" . BASH_N . "_server_comment\r\n\t\t\t\tSET\r\n\t\t\t\t\t" . $updateSQL . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\tcommentID = " . $this->commentID; WCF::getDB()->sendQuery($sql); }
/** * @see Page::readData() */ public function readData() { parent::readData(); // create chart object $this->data = new OpenFlashChart(WCF::getLanguage()->get('cms.acp.statistics.chart.page.title')); // create element $element = new OpenFlashChartElement($this->type); // set special options $element->tip = WCF::getLanguage()->get('cms.acp.statistics.chart.page.tip'); // read data from db $sql = "SELECT\n\t\t\t\t\tstats.requestCount AS requestCount,\n\t\t\t\t\tpage.title AS title\n\t\t\t\tFROM\n\t\t\t\t\tcms" . CMS_N . "_statistic_page stats\n\t\t\t\tLEFT JOIN\n\t\t\t\t\twcf" . WCF_N . "_page page\n\t\t\t\tON\n\t\t\t\t\tstats.pageID = page.pageID"; $result = WCF::getDB()->sendQuery($sql); $items = array(); // get available colours $colours = array(); while ($row = WCF::getDB()->fetchArray($result)) { $colours[] = "#" . substr(sha1($row['title']), 0, 6); $items[] = $row; } // add colours to element $element->colours = $colours; // load data foreach ($items as $row) { switch ($this->type) { case 'pie': $element->addValue(intval($row['requestCount']), $row['title']); break; } } // add element to chart $this->data->addElement($element); }
/** * @see Cronjob::execute() */ public function execute($data) { $sql = "DELETE FROM wcf" . WCF_N . "_user_guestbook" . "\n WHERE userID NOT IN (SELECT userID FROM wcf" . WCF_N . "_user)"; WCF::getDB()->sendQuery($sql); $sql = "DELETE FROM wcf" . WCF_N . "_user_guestbook_header" . "\n WHERE userID NOT IN (SELECT userID FROM wcf" . WCF_N . "_user)"; WCF::getDB()->sendQuery($sql); }
/** * @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; }
/** * @see PostList::readPostIDs() */ protected function readPostIDs() { $sql = "SELECT\t\tpostID, attachments, pollID\n\t\t\tFROM\t\twbb" . WBB_N . "_post post\n\t\t\t" . (!empty($this->sqlConditions) ? "WHERE " . $this->sqlConditions : "") . "\n\t\t\tORDER BY\t" . $this->sqlOrderBy; $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->offset); while ($row = WCF::getDB()->fetchArray($result)) { // post id if (!empty($this->postIDs)) { $this->postIDs .= ','; } $this->postIDs .= $row['postID']; // attachments if ($row['attachments'] != 0) { $this->attachmentPostIDArray[] = $row['postID']; } // polls if ($row['pollID'] != 0) { if ($this->pollIDs != '') { $this->pollIDs .= ','; } $this->pollIDs .= $row['pollID']; } } $this->readAttachments(); $this->readPolls(); }
/** * {@inheritdoc} */ public function readObjects() { //get classes $baseClass = $this->className; $classParts = explode('\\', get_called_class()); $articleType = explode('.', $baseClass::$objectType); parent::readObjects(); if ($this->categoryList) { if (0 !== count($this->objectIDs)) { $conditionBuilder = new PreparedStatementConditionBuilder(); $conditionBuilder->add($this->getDatabaseTableIndexName() . ' IN (?)', array($this->objectIDs)); $sql = ' SELECT * FROM ' . $classParts[0] . WCF_N . '_' . $articleType . '_to_category ' . $conditionBuilder; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute($conditionBuilder->getParameters()); while ($row = $statement->fetchArray()) { if (isset($this->objects[$row[$this->getDatabaseTableIndexName()]])) { $this->objects[$row[$this->getDatabaseTableIndexName()]]->setCategoryID($row['categoryID']); } } } } }
/** * @see AdminToolsFunction::execute($data) */ public function execute($data) { parent::execute($data); $parameters = $data['parameters']['database.optimize']; $tables = WCF::getDB()->getTableNames(); $message = WCF::getLanguage()->get('wcf.acp.admintools.function.success', array('$functionName' => WCF::getLanguage()->get('wcf.acp.admintools.function.' . $data['functionName']))) . '<ul>'; if ($parameters['analyze']) { foreach ($tables as $table) { WCF::getDB()->sendQuery('ANALYZE TABLE ' . $table); } $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.database.optimize.analyze.success', array('$tableCount' => count($tables))); } if ($parameters['optimize']) { foreach ($tables as $table) { WCF::getDB()->sendQuery('OPTIMIZE TABLE ' . $table); } $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.database.optimize.optimize.success', array('$tableCount' => count($tables))); } if (!count($tables) || !$parameters['analyze'] && !$parameters['optimize']) { $this->setReturnMessage('error', WCF::getLanguage()->get('wcf.acp.admintools.function.database.optimize.analyze.error')); } else { $this->setReturnMessage('success', $message . '</ul>'); } $this->executed(); }