/**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (isset($eventObj->additionalFields['styleID']) && WCF::getSession()->getStyleID() != 0) {
         // reset session style
         WCF::getSession()->setStyleID(0);
     }
 }
 /**
  * Returns true, if this session is the active user session.
  *
  * @return	boolean
  */
 public function isActiveUserSession()
 {
     if ($this->isActive() && $this->sessionID == WCF::getSession()->sessionID) {
         return 1;
     }
     return 0;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $this->board->markAsRead();
     WCF::getSession()->unregister('lastSubscriptionsStatusUpdateTime');
     $this->executed();
 }
 /**
  * @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);
 }
 /**
  * @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'));
             }
         }
     }
 }
 /**
  * Renders the list of boards.
  */
 public function renderBoards()
 {
     // get unread threads
     $this->readUnreadThreads();
     // get boards
     $this->readBoards();
     // assign data
     WCF::getTPL()->assign('boards', $this->boards);
     WCF::getTPL()->assign('unreadThreadsCount', $this->unreadThreadsCount);
     // show newest posts
     if (BOARD_LIST_ENABLE_LAST_POST) {
         $lastPosts = WCF::getCache()->get('boardData', 'lastPosts');
         if (is_array($lastPosts)) {
             $visibleLanguages = false;
             if (count(WCF::getSession()->getVisibleLanguageIDArray())) {
                 $visibleLanguages = WCF::getSession()->getVisibleLanguageIDArray();
             }
             foreach ($lastPosts as $boardID => $languages) {
                 foreach ($languages as $languageID => $row) {
                     if (!$languageID || !$visibleLanguages || in_array($languageID, $visibleLanguages)) {
                         $this->lastPosts[$row['boardID']] = new DatabaseObject($row);
                         continue 2;
                     }
                 }
             }
         }
         WCF::getTPL()->assign('lastPosts', $this->lastPosts);
     }
     // stats
     if (BOARD_LIST_ENABLE_STATS) {
         WCF::getTPL()->assign('boardStats', WCF::getCache()->get('boardData', 'counts'));
     }
 }
 /**
  * Creates a new ModerationMarkedThreadsPage object.
  */
 public function __construct()
 {
     if ($markedThreads = WCF::getSession()->getVar('markedThreads')) {
         $this->sqlConditions = 'thread.threadID IN (' . implode(',', $markedThreads) . ') AND movedThreadID = 0';
     }
     parent::__construct();
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if ($eventObj->board->getPermission('canPostAnonymously')) {
         if ($eventName === 'readFormParameters') {
             if (isset($_POST['postAnonymously'])) {
                 self::$postAnonymously = intval($_POST['postAnonymously']);
             }
         } else {
             if ($eventName === 'assignVariables') {
                 WCF::getTPL()->assign('postAnonymously', self::$postAnonymously);
             } else {
                 if ($eventName === 'show') {
                     WCF::getTPL()->append('additionalSettings', WCF::getTPL()->fetch('messageFormSettingsPostAnonymously'));
                 } else {
                     if ($eventName === 'save') {
                         if (self::$postAnonymously) {
                             self::$userID = WCF::getUser()->userID;
                             self::$ipAddress = WCF::getSession()->ipAddress;
                             $eventObj->username = WCF::getLanguage()->get('wbb.threadAdd.anonymousUsername');
                             WCF::getUser()->userID = 0;
                             WCF::getSession()->ipAddress = '';
                         }
                     } else {
                         if ($eventName === 'saved') {
                             if (self::$postAnonymously) {
                                 WCF::getUser()->userID = self::$userID;
                                 WCF::getSession()->ipAddress = self::$ipAddress;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Creates a new ModerationMarkedPostsPage object.
  */
 public function __construct()
 {
     if ($markedPosts = WCF::getSession()->getVar('markedPosts')) {
         $this->sqlConditions = 'post.postID IN (' . implode(',', $markedPosts) . ')';
     }
     parent::__construct();
 }
 /**
  * @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 EventListener::execute()
     */
    public function execute($eventObj, $className, $eventName)
    {
        if ($eventName == 'init') {
            $eventObj->sqlSelects .= 'wbb_user.posts,';
            $eventObj->sqlJoins .= ' LEFT JOIN wbb' . WBB_N . '_user wbb_user
						ON (wbb_user.userID = user.userID) ';
        } else {
            if ($eventName == 'assignVariables') {
                $user = $eventObj->frame->getUser();
                $eventObj->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('postM.png'), 'title' => WCF::getLanguage()->get('wcf.user.posts'), 'value' => '<a href="index.php?form=Search&amp;types[]=post&amp;userID=' . $user->userID . SID_ARG_2ND . '" title="' . WCF::getLanguage()->get('wcf.user.profile.search', array('$username' => StringUtil::encodeHTML($user->username))) . '">' . StringUtil::formatInteger(intval($user->posts)) . ($user->getProfileAge() > 1 ? ' ' . WCF::getLanguage()->get('wcf.user.postsPerDay', array('$posts' => StringUtil::formatDouble($user->posts / $user->getProfileAge()))) : '') . '</a>');
                // show last 5 posts
                if (PROFILE_SHOW_LAST_POSTS) {
                    require_once WBB_DIR . 'lib/data/post/ViewablePost.class.php';
                    require_once WBB_DIR . 'lib/data/board/Board.class.php';
                    $boardIDArray = Board::getAccessibleBoardIDArray(array('canViewBoard', 'canEnterBoard', 'canReadThread'));
                    if (count($boardIDArray)) {
                        $posts = array();
                        $sql = "SELECT\t\tpost.postID, post.time,\n\t\t\t\t\t\t\t\tCASE WHEN post.subject <> '' THEN post.subject ELSE thread.topic END AS subject\n\t\t\t\t\t\tFROM\t\twbb" . WBB_N . "_user_last_post user_last_post\n\t\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_post post\n\t\t\t\t\t\tON\t\t(post.postID = user_last_post.postID)\n\t\t\t\t\t\tLEFT JOIN\twbb" . WBB_N . "_thread thread\n\t\t\t\t\t\tON\t\t(thread.threadID = post.threadID)\n\t\t\t\t\t\tWHERE\t\tuser_last_post.userID = " . $user->userID . "\n\t\t\t\t\t\t\t\tAND post.isDeleted = 0\n\t\t\t\t\t\t\t\tAND post.isDisabled = 0\n\t\t\t\t\t\t\t\tAND thread.boardID IN (" . implode(',', $boardIDArray) . ")\n\t\t\t\t\t\t\t\t" . (count(WCF::getSession()->getVisibleLanguageIDArray()) ? "AND thread.languageID IN (" . implode(',', WCF::getSession()->getVisibleLanguageIDArray()) . ")" : "") . "\n\t\t\t\t\t\tORDER BY\tuser_last_post.time DESC";
                        $result = WCF::getDB()->sendQuery($sql, 5);
                        while ($row = WCF::getDB()->fetchArray($result)) {
                            $posts[] = new ViewablePost(null, $row);
                        }
                        if (count($posts)) {
                            WCF::getTPL()->assign(array('posts' => $posts, 'user' => $user));
                            WCF::getTPL()->append('additionalContent2', WCF::getTPL()->fetch('userProfileLastPosts'));
                        }
                    }
                }
            }
        }
    }
 /**
  * Gets marked posts from session.
  */
 public function getMarkedPosts()
 {
     $sessionVars = WCF::getSession()->getVars();
     if (isset($sessionVars['markedPosts'])) {
         $this->postIDs = implode(',', $sessionVars['markedPosts']);
     }
 }
 /**
  * @see AbstractLostAndFoundFileSystemItem::createVirtualIDSpace() 
  */
 public static function createVirtualIDSpace()
 {
     $theAvatars = array();
     chdir(WCF_DIR . 'images/avatars');
     $dh = opendir(WCF_DIR . 'images/avatars');
     $avatarIDs = array();
     $avatars = array();
     while ($file = readdir($dh)) {
         if (preg_match("/^(avatar).*/", $file) && $file != '.' && $file != '..' && $file != '.htaccess' && !preg_match("/^.*\\.php\$/", $file)) {
             $avatarID = (int) preg_replace("/.*\\-(\\d+).*/", "\$1", $file);
             $avatars[$avatarID] = preg_replace("/.*\\-(\\d+)(.*)/", "\$2", $file);
             if ($avatarID > 0) {
                 $avatarIDs[] = $avatarID;
             }
         }
     }
     if (count($avatarIDs)) {
         $sql = "SELECT avatarID, avatarExtension FROM wcf" . WCF_N . "_avatar WHERE avatarID IN (" . implode(',', $avatarIDs) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         $physicalAvatars = array_flip($avatarIDs);
         while ($row = WCF::getDB()->fetchArray($result)) {
             unset($physicalAvatars[$row['avatarID']]);
         }
         $physicalAvatars = array_keys($physicalAvatars);
         foreach ($physicalAvatars as $avatarID) {
             $file = WCF_DIR . 'images/avatars/avatar-' . $avatarID . $avatars[$avatarID];
             $theAvatars[] = $file;
         }
     }
     closedir($dh);
     self::$virtualFileIDs['avatarsFilesystem'] = $theAvatars;
     WCF::getSession()->register('virtualLostAndFoundIDs', self::$virtualFileIDs);
 }
 /**
  * @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 PackageUninstallation::finishInstallation()
  */
 protected function finishUninstallation()
 {
     if ($this->packageArchive !== null) {
         $this->packageArchive->deleteArchive();
     }
     // unregister package installation plugins
     WCF::getSession()->unregister('queueID' . $this->queueID . 'PIPs');
     // mark this package uninstallation as done
     $sql = "UPDATE\twcf" . WCF_N . "_package_installation_queue\n\t\t\tSET\tdone = 1\n\t\t\tWHERE\tqueueID = " . $this->queueID;
     WCF::getDB()->sendQuery($sql);
     // search for open queue children
     $sql = "SELECT\t\tqueueID, action\n\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_queue\n\t\t\tWHERE\t\tparentQueueID = " . $this->queueID . "\n\t\t\t\t\tAND processNo = " . $this->processNo . "\n\t\t\t\t\tAND done = 0\n\t\t\tORDER BY\tqueueID";
     $row = WCF::getDB()->getFirstRow($sql);
     if (isset($row['queueID'])) {
         // entry found
         WCF::getTPL()->assign(array('action' => $row['action'], 'queueID' => $row['queueID']));
         return '';
     } else {
         // search for other open queue entries in current level
         $sql = "SELECT\t\tqueueID, action\n\t\t\t\tFROM\t\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\tWHERE\t\tparentQueueID = " . $this->parentQueueID . "\n\t\t\t\t\t\tAND processNo = " . $this->processNo . "\n\t\t\t\t\t\tAND done = 0\n\t\t\t\tORDER BY\tqueueID";
         $row = WCF::getDB()->getFirstRow($sql);
         if (isset($row['queueID'])) {
             // other entries found
             WCF::getTPL()->assign(array('action' => $row['action'], 'queueID' => $row['queueID'], 'processNo' => $this->processNo));
             if ($this->parentQueueID == 0) {
                 // reload installation frame
                 // and uninstall next package
                 WCF::getTPL()->display('packageInstallationReloadFrame');
                 exit;
             } else {
                 // uninstall next package in current window
                 return '';
             }
         } else {
             if ($this->parentQueueID == 0) {
                 // nothing to do
                 // finish uninstallation
                 // delete all package installation queue entries with the active process number
                 $sql = "DELETE FROM\twcf" . WCF_N . "_package_installation_queue\n\t\t\t\t\t\tWHERE\t\tprocessNo = " . $this->processNo;
                 WCF::getDB()->sendQuery($sql);
                 // var to redirect to package list
                 WCF::getTPL()->assign('installationType', 'other');
                 // show finish page
                 WCF::getTPL()->display('packageInstallationFinish');
                 exit;
             } else {
                 // jump to parent package uninstallation
                 // get information about parent queue id
                 WCF::getTPL()->assign(array('action' => $this->action, 'queueID' => $this->parentQueueID));
                 if ($this->packageType == 'requirement') {
                     return 'finish';
                 }
                 if ($this->packageType == 'optional') {
                     return 'optionals';
                 }
             }
         }
     }
 }
 /**
  * Gets a list of users online.
  */
 public function getUsersOnline()
 {
     $sql = "SELECT \t\t" . $this->sqlSelects . "\n\t\t\t\t\tuser_option.userOption" . User::getUserOptionID('invisible') . ", session.userID, session.username as guestname, session.ipAddress,\n\t\t\t\t\tsession.userAgent, session.lastActivityTime, session.requestURI, session.sessionID,\n\t\t\t\t\tsession.requestMethod, session.spiderID, groups.userOnlineMarking, user.username \n\t\t\tFROM \t\twcf" . WCF_N . "_session session\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user\n\t\t\tON\t\t(user.userID = session.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user_option_value user_option\n\t\t\tON\t\t(user_option.userID = session.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_group groups\n\t\t\tON\t\t(groups.groupID = user.userOnlineGroupID)\n\t\t\t" . $this->sqlJoins . "\n\t\t\tWHERE \t\tsession.packageID = " . PACKAGE_ID . "\n\t\t\t\t\tAND session.lastActivityTime > " . (TIME_NOW - USER_ONLINE_TIMEOUT) . "\n\t\t\t\t\t" . ($this->getSpiders ? '' : 'AND session.spiderID = 0') . "\n\t\t\t\t\t" . (!$this->enableOwnView ? "AND session.sessionID <> '" . WCF::getSession()->sessionID . "'" . (WCF::getUser()->userID ? " AND session.userID <> " . WCF::getUser()->userID : '') : '') . "\n\t\t\t\t\t" . $this->sqlConditions . " \n\t\t\tORDER BY \t" . $this->sqlOrderBy;
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->handleRow($row, new User(null, $row));
     }
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // avoid session update
     WCF::getSession()->disableUpdate();
     // execute cronjobs
     new CronjobsExec();
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     AllianceEditor::create($this->allianceName, $this->allianceTag, WCF::getUser()->userID);
     WCF::getSession()->setUpdate(true);
     header('Location: index.php?page=Alliance');
     exit;
 }
 /**
  * @see Page::show()
  */
 public function show()
 {
     try {
         // get attachment from database
         $sql = "SELECT\t*\n\t\t\t\tFROM \twcf" . WCF_N . "_attachment\n\t\t\t\tWHERE \tattachmentID = " . $this->attachmentID . " \n\t\t\t\t\tAND packageID 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)";
         $this->attachment = WCF::getDB()->getFirstRow($sql);
         // check attachment id
         if (!isset($this->attachment['attachmentID'])) {
             throw new IllegalLinkException();
         }
         // check thumbnail status
         if ($this->thumbnail && !$this->attachment['thumbnailType']) {
             throw new IllegalLinkException();
         }
         parent::show();
         // reset URI in session
         if ($this->thumbnail && WCF::getSession()->lastRequestURI) {
             WCF::getSession()->setRequestURI(WCF::getSession()->lastRequestURI);
         }
         // update download count
         if (!$this->thumbnail) {
             $sql = "UPDATE\twcf" . WCF_N . "_attachment\n\t\t\t\t\tSET\tdownloads = downloads + 1,\n\t\t\t\t\t\tlastDownloadTime = " . TIME_NOW . "\n\t\t\t\t\tWHERE\tattachmentID = " . $this->attachmentID;
             WCF::getDB()->registerShutdownUpdate($sql);
         }
         // send headers
         // file type
         $mimeType = $this->thumbnail ? $this->attachment['thumbnailType'] : $this->attachment['fileType'];
         if ($mimeType == 'image/x-png') {
             $mimeType = 'image/png';
         }
         @header('Content-Type: ' . $mimeType);
         // file name
         @header('Content-disposition: ' . (!in_array($mimeType, self::$inlineMimeTypes) ? 'attachment; ' : 'inline; ') . 'filename="' . $this->attachment['attachmentName'] . '"');
         // send file size
         @header('Content-Length: ' . ($this->thumbnail ? $this->attachment['thumbnailSize'] : $this->attachment['attachmentSize']));
         // no cache headers
         if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
             // internet explorer doesn't cache files downloaded from a https website, if 'Pragma: no-cache' was sent
             // @see http://support.microsoft.com/kb/316431/en
             @header('Pragma: public');
         } else {
             @header('Pragma: no-cache');
         }
         @header('Expires: 0');
         // show attachment
         readfile(WCF_DIR . 'attachments/' . ($this->thumbnail ? 'thumbnail' : 'attachment') . '-' . $this->attachment['attachmentID']);
         exit;
     } catch (Exception $e) {
         if ($this->embedded == 1) {
             @header('Content-Type: image/png');
             @header('Content-disposition: filename="imageNoPermissionL.png"');
             readfile(WCF_DIR . 'icon/imageNoPermissionL.png');
             exit;
         } else {
             throw $e;
         }
     }
 }
示例#20
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     $sql = "UPDATE ugml_users\n\t\t\t\tSET ally_request = " . $this->allianceID . ",\n\t\t\t\t\tally_request_text = '" . escapeString($this->applicationText) . "',\n\t\t\t\t\tally_register_time = " . TIME_NOW . "\n\t\t\t\tWHERE id = " . WCF::getUser()->userID;
     WCF::getDB()->sendQuery($sql);
     WCF::getSession()->setUpdate(true);
     header('Location: index.php?page=Alliance');
     exit;
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     // create needed variables
     $knownHostIDs = $knownPageIDs = array();
     // read known page and host IDs
     $sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\tcms" . CMS_N . "_statistic_known\n\t\t\t\tWHERE\n\t\t\t\t\tsessionID = '" . escapeString(WCF::getSession()->sessionID) . "'";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (intval($row['pageID'])) {
             $knownPageIDs[] = intval($row['pageID']);
         }
         if (intval($row['hostID'])) {
             $knownHostIDs[] = intval($row['hostID']);
         }
     }
     // handle hosts
     if (!in_array(CMSCore::getActiveHost()->getHostID(), $knownHostIDs)) {
         // update count for host if this user isn't known
         $sql = "UPDATE\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_host\n\t\t\t\t\tSET\n\t\t\t\t\t\trequestCount = requestCount + 1\n\t\t\t\t\tWHERE\n\t\t\t\t\t\thostID = " . CMSCore::getActiveHost()->getHostID();
         WCF::getDB()->sendQuery($sql);
         // add to known hosts
         $sql = "INSERT INTO\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_known (sessionID, hostID, timestamp)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . escapeString(WCF::getSession()->sessionID) . "', " . CMSCore::getActiveHost()->getHostID() . ", " . TIME_NOW . ")";
         WCF::getDB()->sendQuery($sql);
     }
     // handle pages
     if (!in_array($eventObj->pageID, $knownPageIDs)) {
         // update count for page if this user isn't known
         $sql = "UPDATE\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_page\n\t\t\t\t\tSET\n\t\t\t\t\t\trequestCount = requestCount + 1\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tpageID = " . $eventObj->pageID;
         WCF::getDB()->sendQuery($sql);
         // add to known pages
         $sql = "INSERT INTO\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_known (sessionID, pageID, timestamp)\n\t\t\t\t\tVALUES\n\t\t\t\t\t\t('" . escapeString(WCF::getSession()->sessionID) . "', " . $eventObj->pageID . ", " . TIME_NOW . ")";
         WCF::getDB()->sendQuery($sql);
     }
     if (isset($_SERVER['HTTP_REFERER']) and !strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'], 0) and !empty($_SERVER['HTTP_REFERER'])) {
         $url = parse_url($_SERVER['HTTP_REFERER']);
         $sql = "SELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer_host\n\t\t\t\t\tWHERE\n\t\t\t\t\t\thostname = '" . escapeString($url['host']) . "'";
         $row = WCF::getDB()->getFirstRow($sql);
         if (WCF::getDB()->countRows()) {
             $hostID = $row['hostID'];
             $sql = "UPDATE\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer_host\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tcount = count + 1\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\thostname = '" . escapeString($url['host']) . "'";
             WCF::getDB()->sendQuery($sql);
         } else {
             $sql = "INSERT INTO\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer_host (hostname, count)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('" . escapeString($url['host']) . "', 1)";
             WCF::getDB()->sendQuery($sql);
             $hostID = WCF::getDB()->getInsertID();
         }
         $sql = "SELECT\n\t\t\t\t\t\t*\n\t\t\t\t\tFROM\n\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer\n\t\t\t\t\tWHERE\n\t\t\t\t\t\turl = '" . escapeString($_SERVER['HTTP_REFERER']) . "'";
         $row = WCF::getDB()->getFirstRow($sql);
         if (WCF::getDB()->countRows()) {
             $sql = "UPDATE\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tcount = count + 1\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\turl = '" . escapeString($_SERVER['HTTP_REFERER']) . "'";
             WCF::getDB()->sendQuery($sql);
         } else {
             $sql = "INSERT INTO\n\t\t\t\t\t\t\tcms" . CMS_N . "_statistic_referer (url, count, hostID)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('" . escapeString($_SERVER['HTTP_REFERER']) . "', 1, " . $hostID . ")";
             WCF::getDB()->sendQuery($sql);
         }
     }
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     WCF::getUser()->checkPermission(array('admin.smiley.canEditSmiley', 'admin.smiley.canDeleteSmiley'));
     // unmark
     WCF::getSession()->unregister('markedSmileys');
     $this->executed();
 }
示例#23
0
 /**
  * Creates a new Poll object.
  * 
  * @param	integer		$pollID
  * @param	array<mixed>	$row
  * @param	boolean		$canVotePoll	true, if the active user has permission to vote a poll
  */
 public function __construct($pollID, $row = null, $canVotePoll = true)
 {
     $this->canVotePoll = $canVotePoll;
     if ($pollID !== null) {
         $sql = "SELECT \t\tpoll_vote.pollID AS voted,\n\t\t\t\t\t\tpoll_vote.isChangeable,\n\t\t\t\t\t\tpoll.*\n\t\t\t\tFROM \t\twcf" . WCF_N . "_poll poll\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_poll_vote poll_vote\n\t\t\t\tON \t\t(poll_vote.pollID = poll.pollID\n\t\t\t\t\t\t" . (!WCF::getUser()->userID ? "AND poll_vote.ipAddress = '" . escapeString(WCF::getSession()->ipAddress) . "'" : '') . "\n\t\t\t\t\t\tAND poll_vote.userID = " . WCF::getUser()->userID . ")\n\t\t\t\tWHERE \t\tpoll.pollID = " . $pollID;
         $row = WCF::getDB()->getFirstRow($sql);
     }
     parent::__construct($row);
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (MODULE_MODERATED_USER_GROUP == 1) {
         // check available groups
         $availableGroups = Group::getGroupsByType(array(5, 6, 7)) ? true : false;
         // active user is a group leader?
         $isGroupLeader = null;
         //WCF::getSession()->getVar('isGroupLeader');
         if ($isGroupLeader === null) {
             $sql = "SELECT\tCOUNT(*) AS count\n\t\t\t\t\tFROM\twcf" . WCF_N . "_group_leader leader, wcf" . WCF_N . "_group usergroup\n\t\t\t\t\tWHERE\t(leader.leaderUserID = " . WCF::getUser()->userID . "\n\t\t\t\t\t\tOR leader.leaderGroupID IN (" . implode(',', WCF::getUser()->getGroupIDs()) . "))\n\t\t\t\t\t\tAND leader.groupID = usergroup.groupID";
             $row = WCF::getDB()->getFirstRow($sql);
             $isGroupLeader = $row['count'] ? true : false;
             // save status
             WCF::getSession()->register('isGroupLeader', $isGroupLeader);
         }
         // fix usercp menu
         if (!$availableGroups || !$isGroupLeader) {
             if (!$availableGroups && !$isGroupLeader) {
                 // remove user groups tab
                 if (isset($eventObj->menuItems[''])) {
                     foreach ($eventObj->menuItems[''] as $key => $tab) {
                         if ($tab['menuItem'] == 'wcf.user.usercp.menu.link.userGroups') {
                             unset($eventObj->menuItems[''][$key]);
                             break;
                         }
                     }
                 }
             } else {
                 if ($availableGroups) {
                     // remove group leader subtab
                     foreach ($eventObj->menuItems['wcf.user.usercp.menu.link.userGroups'] as $key => $tab) {
                         if ($tab['menuItem'] == 'wcf.user.usercp.menu.link.userGroups.leader') {
                             unset($eventObj->menuItems['wcf.user.usercp.menu.link.userGroups'][$key]);
                             break;
                         }
                     }
                 } else {
                     // remove user groups subtab
                     foreach ($eventObj->menuItems['wcf.user.usercp.menu.link.userGroups'] as $key => $tab) {
                         if ($tab['menuItem'] == 'wcf.user.usercp.menu.link.userGroups.overview') {
                             unset($eventObj->menuItems['wcf.user.usercp.menu.link.userGroups'][$key]);
                             break;
                         }
                     }
                     // map user groups tab to group leader subtab
                     foreach ($eventObj->menuItems[''] as $key => $tab) {
                         if ($tab['menuItem'] == 'wcf.user.usercp.menu.link.userGroups') {
                             $eventObj->menuItems[''][$key]['menuItemLink'] = 'index.php?page=UserGroupLeader' . SID_ARG_2ND_NOT_ENCODED;
                             break;
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     $this->readGroups();
     if (!count($this->groups)) {
         throw new PermissionDeniedException();
     }
     $this->readApplications();
     WCF::getSession()->unregister('outstandingGroupApplications');
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $this->thread->subscribe();
     $this->thread->updateSubscription();
     if ($this->thread->subscribed) {
         WCF::getSession()->unregister('lastSubscriptionsStatusUpdateTime');
     }
     $this->executed();
 }
示例#27
0
 /**
  * Returns true, if this smiley is marked in the active session.
  */
 public function isMarked()
 {
     $sessionVars = WCF::getSession()->getVars();
     if (isset($sessionVars['markedSmileys'])) {
         if (in_array($this->smileyID, $sessionVars['markedSmileys'])) {
             return 1;
         }
     }
     return 0;
 }
示例#28
0
 /**
  * Marks this private message as unread.
  */
 public function markAsUnread()
 {
     // update only if current user is recipient and message is read
     if (WCF::getUser()->userID == $this->recipientID && $this->isViewed) {
         $sql = "UPDATE\twcf" . WCF_N . "_pm_to_user\n\t\t\t\tSET \tisViewed = 0\n\t\t\t\tWHERE \tpmID = " . $this->messageID . "\n\t\t\t\t\tAND recipientID = " . $this->recipientID;
         WCF::getDB()->sendQuery($sql);
         $this->updateViewedByAll();
         $this->updateUnreadMessageCount(WCF::getUser()->userID);
         WCF::getSession()->resetUserData();
     }
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     if ($this->thread->isNew()) {
         WCF::getUser()->setThreadVisitTime($this->threadID, TIME_NOW);
         if ($this->thread->subscribed) {
             WCF::getSession()->unregister('lastSubscriptionsStatusUpdateTime');
         }
     }
     $this->executed();
 }
 /**
  * @see StandardPortalBox::readData()
  */
 public function readData()
 {
     // get shoutbox entry factory
     $this->factory = new ShoutboxEntryFactory();
     $this->factory->entryList->sqlLimit = SHOUTBOX_MAX_ENTRIES;
     $this->factory->init();
     // get entries
     $this->entries = $this->factory->getEntries();
     // get smileys
     $this->smileys = $this->factory->getSmileys();
     // get username
     $this->username = WCF::getSession()->username;
 }