示例#1
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;
         }
     }
 }
	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];
	}
 /**
  * @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;
             }
         }
     }
 }
 /**
  * @see BBCode::getParsedTag()
  */
 public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser)
 {
     $url = '';
     if (isset($openingTag['attributes'][0])) {
         $url = $openingTag['attributes'][0];
     }
     $noTitle = $content == $url;
     // add protocol if necessary
     if (!preg_match("/[a-z]:\\/\\//si", $url)) {
         $url = 'http://' . $url;
     }
     if ($parser->getOutputType() == 'text/html') {
         $external = true;
         if (($newURL = $this->isInternalURL($url)) !== false) {
             $url = $newURL;
             $external = false;
         }
         // cut visible url
         if ($noTitle) {
             $decodedContent = StringUtil::decodeHTML($content);
             if (StringUtil::length($decodedContent) > 60) {
                 $content = StringUtil::encodeHTML(StringUtil::substring($decodedContent, 0, 40)) . '&hellip;' . StringUtil::encodeHTML(StringUtil::substring($decodedContent, -15));
             }
         } else {
             $content = StringUtil::trim($content);
         }
         return '<a href="' . $url . '"' . ($external ? ' class="externalURL"' : '') . '>' . $content . '</a>';
     } else {
         if ($parser->getOutputType() == 'text/plain') {
             if ($noTitle) {
                 return $url;
             }
             return $content . ': ' . $url;
         }
     }
 }
 /**
  * Converts the encoding of an title into the charset used from the database
  * 
  * @param string $title			the title to be converted
  * @param string $fromCharset	the charset of the title, using 'auto' if not set
  */
 protected static function normalizeTitle($title, $fromCharset = 'auto')
 {
     //remove uneccessary empty characters und convert html special chars
     $title = StringUtil::convertEncoding($fromCharset, WCF::getDB()->getCharset(), $title);
     //return title converted to the used charset.
     return StringUtil::decodeHTML(StringUtil::trim($title));
 }
 private static function parseURLsCallback($matches)
 {
     $url = $title = $matches[0];
     $decodedTitle = StringUtil::decodeHTML($title);
     if (StringUtil::length($decodedTitle) > 60) {
         $title = StringUtil::encodeHTML(StringUtil::substring($decodedTitle, 0, 40)) . '&hellip;' . StringUtil::encodeHTML(StringUtil::substring($decodedTitle, -15));
     }
     // add protocol if necessary
     if (!preg_match("/[a-z]:\\/\\//si", $url)) {
         $url = 'http://' . $url;
     }
     $external = true;
     if (($newURL = self::isInternalURL($url)) !== false) {
         $url = $newURL;
         $external = false;
     }
     return '<a href="' . $url . '"' . ($external ? ' class="externalURL"' : '') . '>' . $title . '</a>';
 }
 /**
  * Formats a message for search result output.
  * 
  * @param	string		$text
  * @return	string
  */
 public static function parse($text)
 {
     // remove html codes
     $text = StringUtil::stripHTML($text);
     // decode html
     $text = StringUtil::decodeHTML($text);
     // get abstract
     $text = self::getMessageAbstract($text);
     // encode html
     $text = StringUtil::encodeHTML($text);
     // do highlighting
     return KeywordHighlighter::doHighlight($text);
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     WCF::getUser()->checkPermission('admin.user.canPMToUserGroups');
     $sql = "SELECT COUNT(DISTINCT u.userID) AS cnt" . "\n  FROM wcf" . WCF_N . "_user u" . "\n  LEFT JOIN wcf" . WCF_N . "_user_to_groups g ON (g.userID = u.userID)" . "\n  LEFT JOIN wcf" . WCF_N . "_group_option_value v ON (v.groupID = g.groupID)" . "\n  LEFT JOIN wcf" . WCF_N . "_group_option o ON (o.optionID = v.optionID)" . "\n WHERE o.optionName = 'user.pm.canUsePm'" . "\n   AND v.optionValue = '1'" . "\n   AND u.userID != " . $this->userID . "\n   AND g.groupID IN (" . $this->pmData['groupIDs'] . ")";
     $row = WCF::getDB()->getFirstRow($sql);
     $count = $row['cnt'];
     if (!$count > 0) {
         // clear session
         if (isset($this->pmData)) {
             $pmData = WCF::getSession()->getVar('pmData');
             unset($pmData[$this->pmSessionID]);
             WCF::getSession()->register('pmData', $pmData);
         }
         $this->finish('wcf.pmToUgrps.error.noRecipients', 'index.php?form=PMToUserGroups&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     }
     if ($count <= $this->limit * $this->loop) {
         $endTime = TIME_NOW;
         $lf = "\n";
         // remove from outbox
         $sql = "UPDATE wcf" . WCF_N . "_pm" . "\n   SET saveInOutbox = 0" . "\n WHERE pmID = " . $this->pmID;
         WCF::getDB()->sendQuery($sql);
         // groups...
         $groups = '';
         $sql = "SELECT groupName" . "\n  FROM wcf" . WCF_N . "_group" . "\n WHERE groupID IN (" . $this->pmData['groupIDs'] . ")" . "\n ORDER BY groupName";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             if (!empty($groups)) {
                 $groups .= ', ';
             }
             $groups .= StringUtil::decodeHTML($row['groupName']);
         }
         // log...
         $log = '';
         $subject = WCF::getLanguage()->get('wcf.pmToUgrps.log.subject', array('$pmID' => $this->pmID)) . ' ' . $this->pmData['subject'];
         if ($this->pmData['enableHtml']) {
             $log .= '<pre>';
         }
         $log .= WCF::getLanguage()->get('wcf.pmToUgrps.log.started', array('$startTime' => DateUtil::formatDate('%d.%m.%Y %H:%M:%S', $this->pmData['startTime']))) . $lf;
         $log .= WCF::getLanguage()->get('wcf.pmToUgrps.log.finished', array('$endTime' => DateUtil::formatDate('%d.%m.%Y %H:%M:%S', $endTime))) . $lf;
         $log .= WCF::getLanguage()->get('wcf.pmToUgrps.log.recipients', array('$groups' => $groups, '$count' => StringUtil::decodeHTML(StringUtil::formatInteger($count)))) . $lf;
         $log .= str_repeat('-', 60) . $lf;
         if ($this->pmData['enableHtml']) {
             $log .= '</pre>' . $lf;
         }
         $log .= $this->pmData['text'];
         $this->recipientArray = $this->blindCopyArray = array();
         $this->recipientArray[0]['userID'] = $this->userID;
         $this->recipientArray[0]['username'] = $this->username;
         PMEditor::create($this->draft, $this->recipientArray, $this->blindCopyArray, $subject, $log, $this->userID, $this->username, array('enableSmilies' => $this->pmData['enableSmilies'], 'enableHtml' => $this->pmData['enableHtml'], 'enableBBCodes' => $this->pmData['enableBBCodes'], 'showSignature' => false));
         // clear session
         $pmData = WCF::getSession()->getVar('pmData');
         unset($pmData[$this->pmSessionID]);
         WCF::getSession()->register('pmData', $pmData);
         $this->calcProgress();
         $msg = WCF::getLanguage()->get('wcf.pmToUgrps.finish', array('$count' => StringUtil::decodeHTML(StringUtil::formatInteger($count)), '$startTime' => DateUtil::formatShortTime('%H:%M:%S', $this->pmData['startTime']), '$endTime' => DateUtil::formatShortTime('%H:%M:%S', $endTime)));
         $this->finish($msg, 'index.php?form=PMToUserGroups&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
     }
     // get users
     $sql = "SELECT DISTINCT u.userID, u.username" . "\n  FROM wcf" . WCF_N . "_user u" . "\n  LEFT JOIN wcf" . WCF_N . "_user_to_groups g ON (g.userID = u.userID)" . "\n  LEFT JOIN wcf" . WCF_N . "_group_option_value v ON (v.groupID = g.groupID)" . "\n  LEFT JOIN wcf" . WCF_N . "_group_option o ON (o.optionID = v.optionID)" . "\n WHERE o.optionName = 'user.pm.canUsePm'" . "\n   AND v.optionValue = '1'" . "\n   AND u.userID != " . $this->userID . "\n   AND g.groupID IN (" . $this->pmData['groupIDs'] . ")" . "\n ORDER BY u.userID";
     $this->blindCopyArray = array();
     $i = 0;
     $result = WCF::getDB()->sendQuery($sql, $this->limit, $this->limit * $this->loop);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->blindCopyArray[$i]['userID'] = $row['userID'];
         $this->blindCopyArray[$i]['username'] = $row['username'];
         $i++;
     }
     if (count($this->blindCopyArray)) {
         if (empty($this->pmID)) {
             $tmp = PMEditor::create($this->draft, $this->recipientArray, $this->blindCopyArray, $this->pmData['subject'], $this->pmData['text'], $this->userID, $this->username, array('enableSmilies' => $this->pmData['enableSmilies'], 'enableHtml' => $this->pmData['enableHtml'], 'enableBBCodes' => $this->pmData['enableBBCodes'], 'showSignature' => $this->pmData['showSignature']));
             if ($tmp->pmID) {
                 $this->pmID = intval($tmp->pmID);
                 $pmData = WCF::getSession()->getVar('pmData');
                 $pmData[$this->pmSessionID]['pmID'] = $this->pmID;
                 WCF::getSession()->register('pmData', $pmData);
                 $mlt = intval($this->pmData['maxLifeTime']);
                 if ($mlt > 0) {
                     $mlt = $this->pmData['startTime'] + 86400 * $mlt;
                 } else {
                     $mlt = 0;
                 }
                 $sql = "INSERT IGNORE INTO wcf" . WCF_N . "_pm_bulk_mailing" . "\n       (pmID, elapsedTime, time, userID)" . "\nVALUES (" . $this->pmID . ", " . $mlt . ", " . $this->pmData['startTime'] . ", " . $this->userID . ")";
                 WCF::getDB()->sendQuery($sql);
             }
         } else {
             $recipientIDs = $inserts = '';
             foreach ($this->blindCopyArray as $k => $v) {
                 $username = WCF::getDB()->escapeString($this->blindCopyArray[$k]['username']);
                 if (!empty($recipientIDs)) {
                     $recipientIDs .= ',';
                 }
                 $recipientIDs .= $this->blindCopyArray[$k]['userID'];
                 if (!empty($inserts)) {
                     $inserts .= ',';
                 }
                 $inserts .= "\n       (" . $this->pmID . ", " . intval($this->blindCopyArray[$k]['userID']) . ", '" . $username . "', 1)";
             }
             if (!empty($recipientIDs) && !empty($inserts)) {
                 $sql = "INSERT IGNORE INTO wcf" . WCF_N . "_pm_to_user" . "\n       (pmID, recipientID, recipient, isBlindCopy)" . "\nVALUES " . $inserts;
                 WCF::getDB()->sendQuery($sql);
                 PMEditor::updateUnreadMessageCount($recipientIDs);
                 PMEditor::updateTotalMessageCount($recipientIDs);
                 Session::resetSessions($recipientIDs, true, false);
             }
         }
     }
     $this->executed();
     $this->calcProgress($this->limit * $this->loop, $count);
     $msg = WCF::getLanguage()->get('wcf.pmToUgrps.progress', array('$loop' => StringUtil::decodeHTML(StringUtil::formatInteger($this->limit * $this->loop)), '$count' => StringUtil::decodeHTML(StringUtil::formatInteger($count))));
     $this->nextLoop($msg, 'index.php?action=' . $this->action . '&pmSessionID=' . $this->pmSessionID . '&limit=' . $this->limit . '&loop=' . ($this->loop + 1) . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED);
 }
 /**
  * Builds the url bbcode tag.
  * 
  * @param	string		$url
  * @param	integer		$id
  * @param	boolean		$isPost
  */
 protected function buildURLTag($url, $id, $isPost = false)
 {
     if ($isPost) {
         if (isset($this->postIDToThreadID[$id])) {
             $id = $this->postIDToThreadID[$id];
         } else {
             $id = 0;
         }
     }
     if ($id != 0 && isset($this->threads[$id])) {
         return (!empty($this->threads[$id]['prefix']) ? '[b]' . StringUtil::decodeHTML(WCF::getLanguage()->get(StringUtil::encodeHTML($this->threads[$id]['prefix']))) . '[/b] ' : '') . '[url=\'' . $url . '\']' . $this->threads[$id]['topic'] . '[/url]';
     }
     return '[url]' . $url . '[/url]';
 }
示例#10
0
 public function cronRunJournal($pmDelCnt = 0, $cLog = 0, $cStat = 0, $cAdminMail = 0)
 {
     if (!empty($cLog) || !empty($cStat)) {
         require_once WCF_DIR . 'lib/data/mail/Mail.class.php';
         require_once WCF_DIR . 'lib/data/user/User.class.php';
         require_once WCF_DIR . 'lib/system/language/Language.class.php';
         $pR = 45;
         $pL = 35;
         // get default language
         $sql = "SELECT languageID" . "\n  FROM wcf" . WCF_N . "_language" . "\n WHERE isDefault = 1";
         $tmp = WCF::getDB()->getFirstRow($sql);
         $lang = $tmp['languageID'] == WCF::getLanguage()->getLanguageID() ? WCF::getLanguage() : new Language($tmp['languageID']);
         $useStrftime = DateUtil::$useStrftime;
         DateUtil::$useStrftime = $lang->get('wcf.global.dateMethod') == 'strftime';
         $currentDate = DateUtil::formatDate($lang->get('wcf.global.dateFormat'), TIME_NOW);
         $previousDayStart = mktime(0, 0, 0, (int) date("m", TIME_NOW), (int) date("d", TIME_NOW) - 1, (int) date("Y", TIME_NOW));
         $previousDayEnd = mktime(0, 0, -1, (int) date("m", TIME_NOW), (int) date("d", TIME_NOW), (int) date("Y", TIME_NOW));
         $logDate = DateUtil::formatDate($lang->get('wcf.global.dateFormat'), $previousDayStart);
         $spacer = str_repeat('-', 80);
         $mailUserHeader = "\n" . self::str_pad("USER", 26, " ") . self::str_pad("USERID", 12, " ", STR_PAD_LEFT) . "    " . self::str_pad("REG-DATE", 20, " ") . "LAST-ACTIVE" . "\n" . $spacer;
         $subject = $lang->get('wcf.acp.adminTools.cron.mail.subject', array('PAGE_TITLE' => PAGE_TITLE, '$currentDate' => $currentDate));
         $message = $lang->get('wcf.acp.adminTools.cron.mail.header', array('PAGE_TITLE' => PAGE_TITLE));
         // log -----------------------------------------
         if (!empty($cLog)) {
             $message .= "\n\n" . $spacer;
             $message .= "\n" . $lang->get('wcf.acp.adminTools.cron.mail.logHeader', array('$logDate' => $logDate));
             $message .= "\n" . $spacer;
             // deleted PMs -----------------------------
             if (!empty($pmDelCnt)) {
                 $message .= "\n\n" . $lang->get('wcf.acp.adminTools.cron.mail.statsCntDeletedPMs') . ' ' . StringUtil::decodeHTML(StringUtil::formatInteger($pmDelCnt));
             }
             // registrations ---------------------------
             $mailMsg = '';
             $cnt = 0;
             $sql = "SELECT userID" . "\n  FROM wcf" . WCF_N . "_user" . "\n WHERE registrationDate >= " . $previousDayStart . "\n   AND registrationDate <= " . $previousDayEnd . "\n ORDER BY LOWER(username)";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $user = new User($row['userID']);
                 $cnt++;
                 $mailMsg .= "\n" . self::str_pad(StringUtil::encodeHTML($user->username), 26, " ") . self::str_pad($user->userID, 12, " ", STR_PAD_LEFT) . "    " . self::str_pad(DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->registrationDate), 20, " ") . DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->lastActivityTime);
             }
             $message .= "\n\n";
             $message .= $lang->get('wcf.acp.adminTools.cron.mail.registrations') . ' ' . $cnt . $mailUserHeader;
             if (!empty($cnt)) {
                 $message .= $mailMsg;
             } else {
                 $message .= "\n-";
             }
             // user quits ------------------------------
             $mailMsg = '';
             $cnt = 0;
             $sql = "SELECT userID" . "\n  FROM wcf" . WCF_N . "_user" . "\n WHERE quitStarted > 0" . "\n ORDER BY LOWER(username)";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $user = new User($row['userID']);
                 $cnt++;
                 $mailMsg .= "\n" . self::str_pad(StringUtil::encodeHTML($user->username), 26, " ") . self::str_pad($user->userID, 12, " ", STR_PAD_LEFT) . "    " . self::str_pad(DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->registrationDate), 20, " ") . DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->lastActivityTime);
                 $quitStarted = DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->quitStarted);
                 $quitExec = DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->quitStarted + 7 * 86400);
                 $mailMsg .= "\n" . self::str_pad(StringUtil::encodeHTML($lang->get('wcf.acp.adminTools.cron.mail.quitInfo', array('$quitStarted' => $quitStarted, '$quitExec' => $quitExec))), $pL + $pR, " ", STR_PAD_LEFT);
             }
             $message .= "\n\n";
             $message .= $lang->get('wcf.acp.adminTools.cron.mail.quit') . ' ' . $cnt . $mailUserHeader;
             if (!empty($cnt)) {
                 $message .= $mailMsg;
             } else {
                 $message .= "\n-";
             }
             // inactive ------------------------------------
             $mailMsg = '';
             $cnt = 0;
             $sql = "SELECT userID" . "\n  FROM wcf" . WCF_N . "_user" . "\n WHERE activationCode > 0" . "\n ORDER BY LOWER(username)";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $user = new User($row['userID']);
                 $cnt++;
                 $mailMsg .= "\n" . self::str_pad(StringUtil::encodeHTML($user->username), 26, " ") . self::str_pad($user->userID, 12, " ", STR_PAD_LEFT) . "    " . self::str_pad(DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->registrationDate), 20, " ") . DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->lastActivityTime);
             }
             $message .= "\n\n";
             $message .= $lang->get('wcf.acp.adminTools.cron.mail.inactives') . ' ' . $cnt . $mailUserHeader;
             if (!empty($cnt)) {
                 $message .= $mailMsg;
             } else {
                 $message .= "\n-";
             }
             // banned --------------------------------------
             $mailMsg = '';
             $cnt = 0;
             $sql = "SELECT userID" . "\n  FROM wcf" . WCF_N . "_user" . "\n WHERE banned > 0" . "\n ORDER BY LOWER(username)";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $user = new User($row['userID']);
                 $cnt++;
                 $mailMsg .= "\n" . self::str_pad(StringUtil::encodeHTML($user->username), 26, " ") . self::str_pad($user->userID, 12, " ", STR_PAD_LEFT) . "    " . self::str_pad(DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->registrationDate), 20, " ") . DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $user->lastActivityTime);
             }
             $message .= "\n\n";
             $message .= $lang->get('wcf.acp.adminTools.cron.mail.banned') . ' ' . $cnt . $mailUserHeader;
             if (!empty($cnt)) {
                 $message .= $mailMsg;
             } else {
                 $message .= "\n-";
             }
         }
         if (!empty($cStat)) {
             // stats -----------------------------------
             $nStats = array();
             // user
             $sql = "SELECT COUNT(userID) AS user, MAX(userID) AS userMax FROM wcf" . WCF_N . "_user";
             $tmp = WCF::getDB()->getFirstRow($sql);
             foreach ($tmp as $k => $v) {
                 $nStats[$k] = $v;
             }
             $sql = "SELECT SUM(banned) AS userLocked, SUM(disableSignature) AS signLocked FROM wcf" . WCF_N . "_user";
             $tmp = WCF::getDB()->getFirstRow($sql);
             foreach ($tmp as $k => $v) {
                 $nStats[$k] = $v;
             }
             // threads
             if (self::wbbExists()) {
                 $sql = "SELECT COUNT(threadID) AS threads, MAX(threadID) AS threadsMax, SUM(views) AS threadViews FROM wbb" . WBB_N . "_thread";
                 $tmp = WCF::getDB()->getFirstRow($sql);
                 foreach ($tmp as $k => $v) {
                     $nStats[$k] = $v;
                 }
                 $sql = "SELECT COUNT(threadID) AS threadClosed FROM wbb" . WBB_N . "_thread WHERE isClosed = 1";
                 $tmp = WCF::getDB()->getFirstRow($sql);
                 foreach ($tmp as $k => $v) {
                     $nStats[$k] = $v;
                 }
                 // posts
                 $sql = "SELECT COUNT(postID) AS posts, MAX(postID) AS postsMax FROM wbb" . WBB_N . "_post";
                 $tmp = WCF::getDB()->getFirstRow($sql);
                 foreach ($tmp as $k => $v) {
                     $nStats[$k] = $v;
                 }
                 // pm
             }
             $sql = "SELECT COUNT(pmID) AS pms, MAX(pmID) AS pmsMax FROM wcf" . WCF_N . "_pm";
             $tmp = WCF::getDB()->getFirstRow($sql);
             foreach ($tmp as $k => $v) {
                 $nStats[$k] = $v;
             }
             // polls
             $sql = "SELECT COUNT(pollID) AS polls FROM wcf" . WCF_N . "_poll";
             $tmp = WCF::getDB()->getFirstRow($sql);
             foreach ($tmp as $k => $v) {
                 $nStats[$k] = $v;
             }
             // attachments *****************************
             // get decimal point
             $dp = StringUtil::decodeHTML($lang->get('wcf.global.decimalPoint'));
             if (!preg_match('/^[\\,\\.]{1}$/', $dp)) {
                 $dp = ',';
             }
             // get thousands separator
             $tp = StringUtil::decodeHTML($lang->get('wcf.global.thousandsSeparator'));
             if (!preg_match('/^[\\,\\.\\s]{1}$/', $tp)) {
                 $tp = ' ';
             }
             $sql = "SELECT COUNT(attachmentID) AS atCnt, SUM(attachmentSize) AS atSize FROM wcf" . WCF_N . "_attachment WHERE messageID != 0";
             $tmp = WCF::getDB()->getFirstRow($sql);
             foreach ($tmp as $k => $v) {
                 $nStats[$k] = $v;
             }
             if (!empty($nStats['atSize'])) {
                 $atSize = number_format($nStats['atSize'] / pow(1024, 2), 2, $dp, $tp);
             } else {
                 $atSize = 0;
             }
             // avatars
             $sql = "SELECT COUNT(avatarID) AS avatars FROM wcf" . WCF_N . "_avatar WHERE userID > 0";
             $tmp = WCF::getDB()->getFirstRow($sql);
             foreach ($tmp as $k => $v) {
                 $nStats[$k] = $v;
             }
             // record
             $nStats['record'] = USERS_ONLINE_RECORD;
             $nStats['recordTime'] = USERS_ONLINE_RECORD_TIME;
             // mail message
             $message .= "\n\n" . $spacer;
             $message .= "\n" . $lang->get('wcf.acp.adminTools.cron.mail.statsHeader');
             $message .= "\n" . $spacer;
             $di = self::getDiskInfo();
             if (is_array($di) && count($di)) {
                 $totalSpace = StringUtil::decodeHTML(StringUtil::formatNumeric($di['TOTAL_SPACE'])) . ' GB';
                 $freeSpace = StringUtil::decodeHTML(StringUtil::formatNumeric($di['FREE_SPACE'])) . ' GB (' . StringUtil::decodeHTML(StringUtil::formatNumeric($di['FREE_QUOTA'])) . '%)';
                 $usedSpace = StringUtil::decodeHTML(StringUtil::formatNumeric($di['USED_SPACE'])) . ' GB (' . StringUtil::decodeHTML(StringUtil::formatNumeric($di['USED_QUOTA'])) . '%)';
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.diskTotalSpace'), $pR, " ") . self::str_pad($totalSpace, $pL, " ", STR_PAD_LEFT);
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.diskFreeSpace'), $pR, " ") . self::str_pad($freeSpace, $pL, " ", STR_PAD_LEFT);
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.diskUsedSpace'), $pR, " ") . self::str_pad($usedSpace, $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['user'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntMembers'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['user'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['userMax'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntMembersMax'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['userMax'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['userLocked'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntMembersLocked'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['userLocked'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['signLocked'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntSignLocked'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['signLocked'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['threads'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntThreads'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['threads'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['threadsMax'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntThreadsMax'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['threadsMax'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['threadClosed'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntThreadsLocked'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['threadClosed'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['threadViews'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntThreadsView'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['threadViews'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['posts'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntPosts'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['posts'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['postsMax'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntPostsMax'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['postsMax'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['pms'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntPMs'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['pms'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['pmsMax'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntPMsMax'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['pmsMax'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['polls'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntPolls'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['polls'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['atCnt'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntAttachments'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['atCnt'])) . ' (' . $atSize . ' MB)', $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['avatars'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntAvatars'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['avatars'])), $pL, " ", STR_PAD_LEFT);
             }
             if (isset($nStats['record'])) {
                 $message .= "\n" . self::str_pad($lang->get('wcf.acp.adminTools.cron.mail.statsCntRecord'), $pR, " ") . self::str_pad(StringUtil::decodeHTML(StringUtil::formatInteger($nStats['record'])) . ' (' . DateUtil::formatDate($lang->get('wcf.global.timeFormat'), $nStats['recordTime']) . ')', $pL, " ", STR_PAD_LEFT);
             }
         }
         // sendmail ------------------------------------
         if (empty($cAdminMail)) {
             $sendTo = array(MAIL_FROM_NAME => MAIL_FROM_ADDRESS);
         } else {
             $sendTo = MAIL_ADMIN_ADDRESS;
         }
         $mail = new Mail($sendTo, $subject, $message);
         $mail->send();
         // reset datetime
         DateUtil::$useStrftime = $useStrftime;
     }
 }