/**
  * Executes StringUtil::encodeHTML on the given text if disableEncoding is false.
  * @see StringUtil::encodeHTML()
  */
 protected function encodeHTML($text)
 {
     if (!$this->disableEncoding) {
         $text = StringUtil::encodeHTML($text);
     }
     return $text;
 }
Пример #2
0
 /**
  * Returns the formatted description of this class.
  * 
  * @return	string
  */
 public function getFormattedDescription()
 {
     if ($this->description) {
         return nl2br(StringUtil::encodeHTML($this->description));
     }
     return '';
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (MODULE_USERS_ONLINE == 1) {
         if ($eventObj->activeCategory == 'profile') {
             if ($eventName == 'validate') {
                 if (WCF::getUser()->getPermission('user.profile.rank.canSelectOnlineMarking')) {
                     if (isset($_POST['userOnlineGroupID'])) {
                         $this->userOnlineGroupID = intval($_POST['userOnlineGroupID']);
                     }
                     // validate user online group id
                     if ($this->userOnlineGroupID) {
                         try {
                             $sql = "SELECT\t\tgroupID\n\t\t\t\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_group\n\t\t\t\t\t\t\t\t\tWHERE\t\tgroupID = " . $this->userOnlineGroupID . "\n\t\t\t\t\t\t\t\t\t\t\tAND groupID IN (" . implode(',', WCF::getUser()->getGroupIDs()) . ")";
                             $row = WCF::getDB()->getFirstRow($sql);
                             if (!isset($row['groupID'])) {
                                 throw new UserInputException('userOnlineGroupID');
                             }
                             // save rankid
                             $eventObj->additionalFields['userOnlineGroupID'] = $this->userOnlineGroupID;
                         } catch (UserInputException $e) {
                             $eventObj->errorType[$e->getField()] = $e->getType();
                         }
                     }
                 }
             } else {
                 if ($eventName == 'assignVariables') {
                     if (!count($_POST)) {
                         // get current values
                         $this->userOnlineGroupID = WCF::getUser()->userOnlineGroupID;
                     }
                     $fields = array();
                     // get user online markings
                     if (WCF::getUser()->getPermission('user.profile.rank.canSelectOnlineMarking')) {
                         $markings = array();
                         $sql = "SELECT\t\tgroupID, groupName, userOnlineMarking\n\t\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_group\n\t\t\t\t\t\t\tWHERE\t\tgroupID IN (" . implode(',', WCF::getUser()->getGroupIDs()) . ")\n\t\t\t\t\t\t\tORDER BY\tgroupID ASC";
                         $result = WCF::getDB()->sendQuery($sql);
                         while ($row = WCF::getDB()->fetchArray($result)) {
                             $row['userOnlineMarking'] = sprintf($row['userOnlineMarking'], StringUtil::encodeHTML(WCF::getUser()->username));
                             $markings[] = $row;
                         }
                         if (count($markings) > 1) {
                             WCF::getTPL()->assign(array('markings' => $markings, 'userOnlineGroupID' => $this->userOnlineGroupID));
                             $fields[] = array('optionName' => 'userOnlineGroupID', 'divClass' => 'formRadio', 'beforeLabel' => false, 'isOptionGroup' => true, 'html' => WCF::getTPL()->fetch('userProfileEditOnlineMarkingSelect'));
                         }
                     }
                     // add fields
                     if (count($fields) > 0) {
                         foreach ($eventObj->options as $key => $category) {
                             if ($category['categoryName'] == 'profile.rank') {
                                 $eventObj->options[$key]['options'] = array_merge($category['options'], $fields);
                                 return;
                             }
                         }
                         $eventObj->options[] = array('categoryName' => 'profile.rank', 'categoryIconM' => '', 'options' => $fields);
                     }
                 }
             }
         }
     }
 }
 public function __construct($data, $boxname = "")
 {
     $this->TopData['templatename'] = "topthanksgivinguser";
     $this->getBoxStatus($data);
     $this->TopData['boxID'] = $data['boxID'];
     if (!defined('TOPTHANKSGIVINGUSER_COUNT_ACP')) {
         define('TOPTHANKSGIVINGUSER_COUNT_ACP', 10);
     }
     if (!defined('TOPTHANKSGIVINGUSER_TITLELENGTH_ACP')) {
         define('TOPTHANKSGIVINGUSER_TITLELENGTH_ACP', 28);
     }
     if (!defined('TOPTHANKSGIVINGUSER_SBCOLOR_ACP')) {
         define('TOPTHANKSGIVINGUSER_SBCOLOR_ACP', 2);
     }
     if (!defined('TOPTHANKSGIVINGUSER_HITS_ACP')) {
         define('TOPTHANKSGIVINGUSER_HITS_ACP', true);
     }
     $sql = "SELECT wcf.userID, wcf.username, wbb.thanks_got" . "\n  FROM wcf" . WCF_N . "_user wcf" . "\n  LEFT JOIN wbb" . WBB_N . "_user wbb ON (wbb.userid = wcf.userid)" . "\n WHERE wbb.thanks_got > 0" . "\n ORDER BY wbb.thanks_got DESC, wcf.username" . "\n LIMIT 0, " . TOPTHANKSGIVINGUSER_COUNT_ACP;
     $result = WBBCore::getDB()->sendQuery($sql);
     while ($row = WBBCore::getDB()->fetchArray($result)) {
         $plainUser = $row['username'];
         $row['thanks_got'] = StringUtil::formatInteger($row['thanks_got']);
         if (TOPTHANKSGIVINGUSER_TITLELENGTH_ACP != 0 && strlen($plainUser) > TOPTHANKSGIVINGUSER_TITLELENGTH_ACP) {
             $row['username'] = StringUtil::substring($plainUser, 0, TOPTHANKSGIVINGUSER_TITLELENGTH_ACP - 3) . '...';
         }
         $row['username'] = StringUtil::encodeHTML($row['username']);
         $this->TopData['thanksgivinguser'][] = $row;
     }
     WCF::getTPL()->assign('TOPTHANKSGIVINGUSER_SBCOLOR_ACP', intval(TOPTHANKSGIVINGUSER_SBCOLOR_ACP));
     WCF::getTPL()->assign('TOPTHANKSGIVINGUSER_HITS_ACP', TOPTHANKSGIVINGUSER_HITS_ACP);
 }
Пример #5
0
 public function __construct($data, $boxname = "")
 {
     $this->TopData['templatename'] = "topthreads";
     $this->getBoxStatus($data);
     $this->TopData['boxID'] = $data['boxID'];
     if (!defined('TOPTHREADS_COUNT')) {
         define('TOPTHREADS_COUNT', 10);
     }
     if (!defined('TOPTHREADS_TITLELENGTH')) {
         define('TOPTHREADS_TITLELENGTH', 25);
     }
     if (!defined('TOPTHREADS_SBCOLOR_ACP')) {
         define('TOPTHREADS_SBCOLOR_ACP', 2);
     }
     require_once WBB_DIR . 'lib/data/board/Board.class.php';
     $boardIDs = Board::getAccessibleBoards();
     if (!empty($boardIDs)) {
         $sql = "SELECT thread.*" . "\n  FROM wbb" . WBB_N . "_thread thread" . "\n WHERE thread.boardID IN (0" . $boardIDs . ")" . "\n ORDER BY thread.replies DESC" . "\n LIMIT 0, " . TOPTHREADS_COUNT;
         $result = WBBCore::getDB()->sendQuery($sql);
         while ($row = WBBCore::getDB()->fetchArray($result)) {
             $row['replies'] = StringUtil::formatInteger($row['replies']);
             $row['title'] = StringUtil::encodeHTML($row['topic']) . ' - ' . $row['replies'];
             if (TOPTHREADS_TITLELENGTH != 0 && strlen($row['topic']) > TOPTHREADS_TITLELENGTH) {
                 $row['topic'] = StringUtil::substring($row['topic'], 0, TOPTHREADS_TITLELENGTH - 3) . '...';
             }
             $row['topic'] = StringUtil::encodeHTML($row['topic']);
             $this->TopData['threads'][] = $row;
         }
     }
 }
 /**
  * Parses search keywords.
  * 
  * @param	string		$keywordString
  */
 protected static function parseKeywords($keywordString)
 {
     // convert encoding if necessary
     if (CHARSET == 'UTF-8' && !StringUtil::isASCII($keywordString) && !StringUtil::isUTF8($keywordString)) {
         $keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
     }
     // remove bad wildcards
     $keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString);
     // remove search operators
     $keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString);
     if (StringUtil::substring($keywordString, 0, 1) == '"' && StringUtil::substring($keywordString, -1) == '"') {
         // phrases search
         $keywordString = StringUtil::trim(StringUtil::substring($keywordString, 1, -1));
         if (!empty($keywordString)) {
             self::$keywords = array_merge(self::$keywords, array(StringUtil::encodeHTML($keywordString)));
         }
     } else {
         // replace word delimiters by space
         $keywordString = preg_replace('/[.,]/', ' ', $keywordString);
         $keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
         if (count($keywords) > 0) {
             self::$keywords = array_merge(self::$keywords, $keywords);
         }
     }
 }
    /**
     * @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'));
                        }
                    }
                }
            }
        }
    }
 /**
  * @see UserOptionOutput::getOutput()
  */
 public function getOutput(User $user, $optionData, $value)
 {
     if (empty($value)) {
         return '';
     }
     return '<img src="' . StringUtil::encodeHTML($value) . '" alt="" />';
 }
 /**
  * Returns the icon html code.
  * 
  * @return	string 
  */
 protected function getImage(User $user, $imageSize = 'M')
 {
     $title = WCF::getLanguage()->get('wcf.user.profile.' . $this->type . '.title', array('$username' => StringUtil::encodeHTML($user->username)));
     if (class_exists('StyleManager')) {
         return '<img src="' . StyleManager::getStyle()->getIconPath($this->type . $imageSize . '.png') . '" alt="" title="' . $title . '" />';
     }
     return '<img src="' . RELATIVE_WCF_DIR . 'icon/' . $this->type . $imageSize . '.png' . '" alt="" title="' . $title . '" />';
 }
 /**
  * Generates an image button.
  * 
  * @see UserOptionOutput::getShortOutput()
  */
 protected function getImage(User $user, $value, $imageSize = 'M')
 {
     if (empty($value) || $value == 'http://') {
         return '';
     }
     $value = self::getURL($value);
     $title = WCF::getLanguage()->get('wcf.user.profile.homepage.title', array('$username' => StringUtil::encodeHTML($user->username)));
     return '<a href="' . StringUtil::encodeHTML($value) . '"><img src="' . StyleManager::getStyle()->getIconPath('website' . $imageSize . '.png') . '" alt="" title="' . $title . '" /></a>';
 }
Пример #11
0
 public function __construct($data, $boxname = "")
 {
     if (!defined('BUDDIESBOX_SBCOLOR_ACP')) {
         define('BUDDIESBOX_SBCOLOR_ACP', 2);
     }
     if (!defined('BUDDIESBOX_SHOWDEL_ACP')) {
         define('BUDDIESBOX_SHOWDEL_ACP', false);
     }
     if (!defined('BUDDIESBOX_SHOWUSERMARKING_ACP')) {
         define('BUDDIESBOX_SHOWUSERMARKING_ACP', false);
     }
     if (!defined('BUDDIESBOX_SHOWONLYONLINE_ACP')) {
         define('BUDDIESBOX_SHOWONLYONLINE_ACP', true);
     }
     if (!defined('BUDDIESBOX_HIDEIFEMPTY_ACP')) {
         define('BUDDIESBOX_HIDEIFEMPTY_ACP', true);
     }
     $this->BuddiesData['templatename'] = "buddiesbox";
     $this->getBoxStatus($data);
     $this->BuddiesData['boxID'] = $data['boxID'];
     $this->BuddiesData['showBuddiesBox'] = false;
     //        $buddies = WCF::getUser()->buddies;
     if (WCF::getUser()->userID != 0) {
         require_once WCF_DIR . 'lib/data/user/UserProfile.class.php';
         $cnt = 0;
         $sql = "SELECT u.*, uo.*, wcg.*" . "\n  FROM wcf" . WCF_N . "_user_whitelist wcu" . "\n  JOIN wcf" . WCF_N . "_user u ON (u.userID = wcu.whiteUserID)" . "\n  LEFT JOIN wcf" . WCF_N . "_user_option_value uo ON (uo.userID = u.userID)" . "\n  LEFT JOIN wcf" . WCF_N . "_group wcg ON (wcg.groupID = u.userOnlineGroupID)" . "\n WHERE wcu.userID = " . WCF::getUser()->userID . "\n ORDER BY u.username";
         $result = WBBCore::getDB()->sendQuery($sql);
         while ($row = WBBCore::getDB()->fetchArray($result)) {
             $user = new UserProfile(null, $row);
             if (BUDDIESBOX_SHOWONLYONLINE_ACP && !$user->isOnline()) {
                 continue;
             }
             if ($user->isOnline()) {
                 $this->BuddiesData['buddies'][$cnt]['imgTitle'] = StringUtil::decodeHTML(WCF::getLanguage()->get('wcf.user.online', array('$username' => $row['username'])));
                 $this->BuddiesData['buddies'][$cnt]['img'] = 'onlineS.png';
             } else {
                 $this->BuddiesData['buddies'][$cnt]['imgTitle'] = StringUtil::decodeHTML(WCF::getLanguage()->get('wcf.user.offline', array('$username' => $row['username'])));
                 $this->BuddiesData['buddies'][$cnt]['img'] = 'offlineS.png';
             }
             if ($user->acceptPm) {
                 $this->BuddiesData['buddies'][$cnt]['pm'] = '1';
             } else {
                 $this->BuddiesData['buddies'][$cnt]['pm'] = '';
             }
             $this->BuddiesData['buddies'][$cnt]['userID'] = $row['userID'];
             $this->BuddiesData['buddies'][$cnt]['username'] = StringUtil::encodeHTML($row['username']);
             // userOnlineMarking...
             if (BUDDIESBOX_SHOWUSERMARKING_ACP && !empty($row['userOnlineMarking']) && $row['userOnlineMarking'] != '%s') {
                 $this->BuddiesData['buddies'][$cnt]['username'] = sprintf($row['userOnlineMarking'], StringUtil::encodeHTML($row['username']));
             }
             $cnt++;
         }
         if ($cnt > 0 || !BUDDIESBOX_HIDEIFEMPTY_ACP) {
             $this->BuddiesData['showBuddiesBox'] = true;
         }
     }
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     if (!USERGUESTBOOK_SHOWINSIDEBAR) {
         return;
     }
     if (!WCF::getUser()->getPermission('user.guestbook.canRead')) {
         return;
     }
     if (empty($eventObj->postList->posts)) {
         return;
     }
     $seen = $ret = array();
     $ret = WCF::getTPL()->get('additionalSidebarUserContacts');
     $link = '<a href="index.php?page=UserGuestbook&amp;userID=%1$d' . SID_ARG_2ND . '"><img src="' . RELATIVE_WCF_DIR . 'icon/guestbookS.png" alt="" title="%2$s" /></a>';
     $curUserID = WCF::getUser()->userID;
     $curUserCanUse = WCF::getUser()->getPermission('user.guestbook.canUseOwn');
     $gbEnableOption = 'userOption' . User::getUserOptionID('userGuestbook_enable');
     require_once WCF_DIR . 'lib/data/user/UserProfile.class.php';
     foreach ($eventObj->postList->posts as $post) {
         if ($post->userID) {
             if ($curUserID == $post->userID && !$curUserCanUse) {
                 continue;
             } else {
                 if (!$post->{$gbEnableOption}) {
                     continue;
                 } else {
                     if (array_key_exists($post->userID, $seen)) {
                         if (!empty($seen[$post->userID])) {
                             if (isset($ret[$post->postID])) {
                                 $ret[$post->postID] .= ' ' . $seen[$post->userID];
                             } else {
                                 $ret[$post->postID] = $seen[$post->userID];
                             }
                         }
                     } else {
                         $add = '';
                         $user = new UserProfile($post->userID, null, null, null);
                         if ($user->getPermission('user.guestbook.canUseOwn')) {
                             $username = StringUtil::encodeHTML($user->username);
                             $title = WCF::getLanguage()->get('wcf.user.guestbook.title', array('$user->username' => $username));
                             $add = sprintf($link, $post->userID, $title);
                             if (isset($ret[$post->postID])) {
                                 $ret[$post->postID] .= ' ' . $add;
                             } else {
                                 $ret[$post->postID] = $add;
                             }
                         }
                         $seen[$post->userID] = $add;
                     }
                 }
             }
         }
     }
     if (count($ret)) {
         WCF::getTPL()->assign('additionalSidebarUserContacts', $ret);
     }
 }
	public function rewriteCallback($match) {
		$args = array();
		if (isset($match[2]))
			parse_str(StringUtil::decodeHTML($match[2]), $args);
		
		if ($newUrl = $this->rewriteUrl($args))
			return StringUtil::encodeHTML($newUrl);
		
		return $match[0];
	}
Пример #14
0
 /**
  * Converts html special characters in arrays.
  *
  * @param 	array 		$array
  * @return 	array 		$array
  */
 public static function encodeHTML($array)
 {
     if (!is_array($array)) {
         return StringUtil::encodeHTML($array);
     } else {
         foreach ($array as $key => $val) {
             $array[$key] = self::encodeHTML($val);
         }
         return $array;
     }
 }
Пример #15
0
 /**
  * Returns the image of this user rank.
  * 
  * @return	string		html code
  */
 public function getImage()
 {
     if ($this->rankImage) {
         $image = '<img src="' . (!preg_match('~^(/|https?://)~i', $this->rankImage) ? RELATIVE_WCF_DIR : '') . StringUtil::encodeHTML($this->rankImage) . '" alt="" />';
         if ($this->repeatImage > 1) {
             $image = str_repeat($image, $this->repeatImage);
         }
         return $image;
     }
     return '';
 }
Пример #16
0
 /**
  * @see Location::get()
  */
 public function get($location, $requestURI, $requestMethod, $match)
 {
     if ($this->threads == null) {
         $this->readThreads();
     }
     $threadID = $match[1];
     if (!isset($this->threads[$threadID])) {
         return '';
     }
     return WCF::getLanguage()->get($location['locationName'], array('$thread' => '<a href="index.php?page=Thread&amp;threadID=' . $threadID . SID_ARG_2ND . '">' . StringUtil::encodeHTML($this->threads[$threadID]) . '</a>'));
 }
 /**
  * @see Location::get()
  */
 public function get($location, $requestURI, $requestMethod, $match)
 {
     if ($this->boards == null) {
         $this->readBoards();
     }
     $boardID = $match[1];
     if (!isset($this->boards[$boardID]) || !$this->boards[$boardID]->getPermission()) {
         return '';
     }
     return WCF::getLanguage()->get($location['locationName'], array('$board' => '<a href="index.php?page=Board&amp;boardID=' . $this->boards[$boardID]->boardID . SID_ARG_2ND . '">' . WCF::getLanguage()->get(StringUtil::encodeHTML($this->boards[$boardID]->title)) . '</a>'));
 }
 /**
  * Gets the log entries.
  */
 protected function readLogEntries()
 {
     $sql = "SELECT\t\tcronjobs.*, cronjobs_log.*\n\t\t\tFROM\t\twcf" . WCF_N . "_cronjobs_log cronjobs_log\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_cronjobs cronjobs\n\t\t\tON\t\t(cronjobs.cronjobID = cronjobs_log.cronjobID)\n\t\t\tWHERE\t\tcronjobs_log.cronjobID IN (\n\t\t\t\t\t\tSELECT\tcronjobID\n\t\t\t\t\t\tFROM\twcf" . WCF_N . "_cronjobs cronjobs,\n\t\t\t\t\t\t\twcf" . WCF_N . "_package_dependency package_dependency\n\t\t\t\t\t\tWHERE \tcronjobs.packageID = package_dependency.dependency\n\t\t\t\t\t\t\tAND package_dependency.packageID = " . PACKAGE_ID . "\n\t\t\t\t\t)\n\t\t\tORDER BY\t" . ($this->sortField == 'classPath' || $this->sortField == 'description' ? 'cronjobs.' : 'cronjobs_log.') . $this->sortField . " " . $this->sortOrder;
     $result = WCF::getDB()->sendQuery($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if ($row['error']) {
             $row['error'] = nl2br(StringUtil::encodeHTML($row['error']));
         }
         $this->logEntries[] = $row;
     }
 }
Пример #19
0
 /**
  * Shows private message specific form elements in the global search form.
  */
 public function show($form = null)
 {
     $folderOptions = array();
     foreach (PMFolderList::getFolders() as $folder) {
         $folderOptions[$folder['folderID']] = StringUtil::encodeHTML($folder['folderName']);
     }
     // get existing values
     if ($form !== null && isset($form->searchData['additionalData']['pm'])) {
         $this->folderIDs = $form->searchData['additionalData']['pm']['folderIDs'];
     }
     WCF::getTPL()->assign(array('folderOptions' => $folderOptions, 'folderIDs' => $this->folderIDs, 'selectAllFolders' => count($this->folderIDs) == 0 || $this->folderIDs[0] == -10));
 }
 public static function getTitle($name, $html = false)
 {
     $item = 'wcf.sketchbook.sketchTitles.' . self::nameToLangVar($name);
     $value = WCF::getLanguage()->getDynamicVariable($item);
     $new = false;
     if ($value == $title) {
         $value = StringUtil::substring($title, StringUtil::lastIndexOf($title, '.'));
         $new = true;
     }
     if ($html) {
         return '<span class="sketch' . ($new ? ' sketchNew' : '') . '">' . StringUtil::encodeHTML($title) . '</span>';
     }
     return $title;
 }
 /**
  * @see Location::get()
  */
 public function get($location, $requestURI, $requestMethod, $match)
 {
     if ($this->entries == null) {
         $this->readEntries();
     }
     if (count($match) <= 1) {
         return '';
     }
     $contestID = $match[1];
     if (!isset($this->entries[$contestID])) {
         return '';
     }
     return WCF::getLanguage()->get($location['locationName'], array('$entry' => '<a href="index.php?page=Contest&amp;contestID=' . $contestID . SID_ARG_2ND . '">' . StringUtil::encodeHTML($this->entries[$contestID]->subject) . '</a>'));
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if ($parser->getOutputType() == 'text/html') {
         // encode html
         $content = self::trim($content);
         $content = StringUtil::encodeHTML($content);
         // show template
         WCF::getTPL()->assign(array('lineNumbers' => $this->makeLineNumbers($content, $this->getLineNumbersStart($openingTag)), 'content' => $content, 'codeBoxName' => WCF::getLanguage()->get('wcf.bbcode.code.title')));
         return WCF::getTPL()->fetch('codeBBCodeTag');
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             return WCF::getLanguage()->get('wcf.bbcode.code.text', array('$content' => $content));
         }
     }
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     if (self::$messageID == 0 && !isset(self::$attachments[self::$messageID]) && count(self::$attachments) == 1) {
         // get first message id
         $keys = array_keys(self::$attachments);
         self::$messageID = reset($keys);
     }
     if (isset($openingTag['attributes'][0])) {
         $attachmentID = $openingTag['attributes'][0];
         if (isset(self::$attachments[self::$messageID]['images'][$attachmentID])) {
             // image
             $attachment = self::$attachments[self::$messageID]['images'][$attachmentID];
             if ($parser->getOutputType() == 'text/html') {
                 $align = isset($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : '';
                 $result = '<img src="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . ($attachment->thumbnailType ? '&amp;thumbnail=1' : '') . '&amp;embedded=1" alt="" class="embeddedAttachment" style="width: ' . ($attachment->thumbnailType ? $attachment->getThumbnailWidth() : $attachment->getWidth()) . 'px; height: ' . ($attachment->thumbnailType ? $attachment->getThumbnailHeight() : $attachment->getHeight()) . 'px;' . (!empty($align) ? ' float:' . StringUtil::encodeHTML($align) . '; margin: ' . ($align == 'left' ? '0 15px 7px 0' : '0 0 7px 15px') : '') . '" />';
                 if ($attachment->thumbnailType) {
                     $result = '<a href="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '" class="enlargable">' . $result . '</a>';
                 }
                 return $result;
             } else {
                 if ($parser->getOutputType() == 'text/plain') {
                     return ($content != $attachmentID ? $content : $attachment->attachmentName) . ': ' . PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID . ($attachment->thumbnailType ? '&thumbnail=1' : '');
                 }
             }
         } else {
             if (isset(self::$attachments[self::$messageID]['files'][$attachmentID])) {
                 // file
                 $attachment = self::$attachments[self::$messageID]['files'][$attachmentID];
                 if ($parser->getOutputType() == 'text/html') {
                     return '<a href="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '">' . (!empty($content) && $content != $attachmentID ? $content : StringUtil::encodeHTML($attachment->attachmentName)) . '</a>';
                 } else {
                     if ($parser->getOutputType() == 'text/plain') {
                         return ($content != $attachmentID ? $content : $attachment->attachmentName) . ': ' . PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID;
                     }
                 }
             }
         }
     }
     if ($parser->getOutputType() == 'text/html') {
         return '<a href="index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '">index.php?page=Attachment&amp;attachmentID=' . $attachmentID . '</a>';
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             return PAGE_URL . '/index.php?page=Attachment&attachmentID=' . $attachmentID;
         }
     }
 }
 /**
  * @see OptionType::getFormElement()
  */
 public function getFormElement(&$optionData)
 {
     $optionData['divClass'] = 'select';
     if (!isset($optionData['optionValue'])) {
         if (isset($optionData['defaultValue'])) {
             $optionData['optionValue'] = $optionData['defaultValue'];
         } else {
             $optionData['optionValue'] = false;
         }
     }
     $options = array();
     $groups = Group::getAllGroups();
     foreach ($groups as $groupID => $group) {
         $options[$groupID] = StringUtil::encodeHTML($group);
     }
     WCF::getTPL()->assign(array('optionData' => $optionData, 'options' => $options));
     return WCF::getTPL()->fetch('optionTypeSelect');
 }
 /**
  * @see EventListener::execute()
  */
 public function execute($eventObj, $className, $eventName)
 {
     foreach ($eventObj->categories as $categoryKey => $category) {
         foreach ($category['options'] as $optionKey => $option) {
             if ($option['optionType'] == 'text' && $option['outputClass'] == '' && $option['searchable'] == 1) {
                 $values = preg_split('/\\s*(?:,|;|&)\\s*/', StringUtil::decodeHTML($option['optionValue']));
                 $newValue = '';
                 foreach ($values as $value) {
                     if (!empty($newValue)) {
                         $newValue .= ', ';
                     }
                     $newValue .= '<a href="index.php?form=MembersSearch&amp;values[' . $option['optionName'] . ']=' . StringUtil::encodeHTML(rawurlencode($value)) . SID_ARG_2ND . '">' . StringUtil::encodeHTML($value) . '</a>';
                 }
                 $eventObj->categories[$categoryKey]['options'][$optionKey]['optionValue'] = $newValue;
             }
         }
     }
 }
Пример #26
0
 /**
  * Generates the select list.
  * 
  * @param	integer		$parentID		id of the parent template pack
  * @param	integer		$depth 			current list depth
  * @param	array		$ignore			list of template pack ids to ignore in result
  */
 protected static function makeSelectList($parentID = 0, $depth = 0, $ignore = array())
 {
     if (!isset(self::$templatePackStructure[$parentID])) {
         return;
     }
     foreach (self::$templatePackStructure[$parentID] as $templatePack) {
         if (!empty($ignore) && in_array($templatePack->templatePackID, $ignore)) {
             continue;
         }
         // we must encode html here because the htmloptions plugin doesn't do it
         $title = StringUtil::encodeHTML($templatePack->templatePackName);
         if ($depth > 0) {
             $title = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $depth) . ' ' . $title;
         }
         self::$selectList[$templatePack->templatePackID] = $title;
         self::makeSelectList($templatePack->templatePackID, $depth + 1, $ignore);
     }
 }
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     $this->identifier = $this->user->{$this->action};
     if (!$this->identifier) {
         throw new IllegalLinkException();
     }
     // check permissions
     WCF::getUser()->checkPermission('user.profile.canView');
     if ($this->user->ignoredUser) {
         throw new NamedUserException(WCF::getLanguage()->get('wcf.user.profile.error.ignoredUser', array('$username' => StringUtil::encodeHTML($this->user->username))));
     }
     if (!$this->user->canViewProfile()) {
         throw new IllegalLinkException();
     }
     if ($this->action == 'icq') {
         $this->identifier = StringUtil::replace('-', '', $this->identifier);
     }
 }
 /**
  * @see TemplatePluginFunction::execute()
  */
 public function execute($tagArgs, Template $tplObj)
 {
     // needed params: link, pages
     if (!isset($tagArgs['link'])) {
         throw new SystemException("missing 'link' argument in pages tag", 12001);
     }
     if (!isset($tagArgs['pages'])) {
         if (($tagArgs['pages'] = $tplObj->get('pages')) === null) {
             throw new SystemException("missing 'pages' argument in pages tag", 12001);
         }
     }
     $html = '';
     if ($tagArgs['pages'] > 1) {
         // encode link
         $link = StringUtil::encodeHTML($tagArgs['link']);
         // open div and ul
         $html .= "<div class=\"pageNavigation\">\n<ul>\n";
         // generate simple links
         $simpleLinks = $tagArgs['pages'];
         if ($simpleLinks > self::SHOW_LINKS) {
             $simpleLinks = self::SHOW_LINKS - 2;
         }
         for ($i = 1; $i <= $simpleLinks; $i++) {
             $html .= $this->makeLink($link, $i);
         }
         if ($tagArgs['pages'] > self::SHOW_LINKS) {
             // jumper
             $html .= '<li><a onclick="var result = prompt(\'' . WCF::getLanguage()->get('wcf.global.page.input') . '\', \'' . $tagArgs['pages'] . '\'); if (typeof(result) != \'object\' &amp;&amp; typeof(result) != \'undefined\') document.location.href = fixURL((\'' . StringUtil::replace("'", "\\'", $link) . '\').replace(/%d/, result));">&hellip;</a></li>' . "\n";
             // last page
             $html .= $this->makeLink($link, $tagArgs['pages']);
         }
         // close div and ul
         $html .= "</ul></div>\n";
     }
     // assign html output to template var
     if (isset($tagArgs['assign'])) {
         $tplObj->assign($tagArgs['assign'], $html);
         if (!isset($tagArgs['print']) || !$tagArgs['print']) {
             return '';
         }
     }
     return $html;
 }
 /**
  * @see Action::execute();
  */
 public function execute()
 {
     parent::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.board.canEditBoard');
     // check board title
     if (StringUtil::encodeHTML($this->board->title) != WCF::getLanguage()->get(StringUtil::encodeHTML($this->board->title))) {
         // change language variable
         require_once WCF_DIR . 'lib/system/language/LanguageEditor.class.php';
         $language = new LanguageEditor(WCF::getLanguage()->getLanguageID());
         $language->updateItems(array($this->board->title => $this->title), 0, PACKAGE_ID, array($this->board->title => 1));
     } else {
         // change title
         $this->board->updateData(array('title' => $this->title));
     }
     // reset cache
     WCF::getCache()->clearResource('board');
     $this->executed();
 }
 public function __construct($data, $boxname = "")
 {
     $this->threadLastPostsBoxData['templatename'] = "threadlastpostsbox";
     $this->getBoxStatus($data);
     $this->threadLastPostsBoxData['boxID'] = $data['boxID'];
     $cntPosts = 0;
     if (!defined('THREADLASTPOSTSBOX_THREADID')) {
         define('THREADLASTPOSTSBOX_THREADID', 0);
     }
     if (!defined('THREADLASTPOSTSBOX_LIMIT')) {
         define('THREADLASTPOSTSBOX_LIMIT', 10);
     }
     if (!defined('THREADLASTPOSTSBOX_TITLELENGTH')) {
         define('THREADLASTPOSTSBOX_TITLELENGTH', 28);
     }
     if (!defined('THREADLASTPOSTSBOX_SBCOLOR')) {
         define('THREADLASTPOSTSBOX_SBCOLOR', 2);
     }
     require_once WBB_DIR . 'lib/data/board/Board.class.php';
     $boardIDs = Board::getAccessibleBoards();
     if (!empty($boardIDs) && THREADLASTPOSTSBOX_THREADID) {
         $sql = "SELECT wp.postID, wp.threadID, wp.userID, wp.subject, wp.message, wp.time" . "\n  FROM wbb1_1_post wp" . "\n  JOIN wbb1_1_thread wt ON (wt.threadID = wp.threadID)" . "\n WHERE wp.threadID = " . THREADLASTPOSTSBOX_THREADID . "\n   AND wp.isDeleted = 0" . "\n   AND wp.isDisabled = 0" . "\n   AND wt.isDeleted = 0" . "\n   AND wt.isDisabled = 0" . "\n   AND wt.boardID IN (" . $boardIDs . ")" . "\n ORDER BY wp.postID DESC" . "\n  LIMIT 0, " . THREADLASTPOSTSBOX_LIMIT;
         $result = WBBCore::getDB()->sendQuery($sql);
         while ($row = WBBCore::getDB()->fetchArray($result)) {
             if (!empty($row['subject'])) {
                 $title = $row['subject'];
             } else {
                 $title = preg_replace('/\\[/', '<', $row['message']);
                 $title = preg_replace('/\\]/', '>', $title);
                 $title = strip_tags($title);
                 //StringUtil::stripHTML($title);
             }
             if (THREADLASTPOSTSBOX_TITLELENGTH != 0 && StringUtil::length($title) > THREADLASTPOSTSBOX_TITLELENGTH) {
                 $title = StringUtil::substring($title, 0, THREADLASTPOSTSBOX_TITLELENGTH - 3) . '...';
             }
             $row['title'] = StringUtil::encodeHTML($title);
             $this->threadLastPostsBoxData['box'][] = $row;
             $cntPosts++;
         }
     }
     WCF::getTPL()->assign(array('THREADLASTPOSTSBOX_SBCOLOR' => intval(THREADLASTPOSTSBOX_SBCOLOR), 'threadLastPostBoxCnt' => $cntPosts));
 }