/** * @see TemplatePluginModifier::execute() */ public function execute($tagArgs, Template $tplObj) { if (isset($tagArgs[2])) { $useStrftime = $tagArgs[2] ? true : false; } else { $useStrftime = isset($tagArgs[1]) ? true : false; } return DateUtil::formatDate(isset($tagArgs[1]) ? $tagArgs[1] : null, $tagArgs[0], false, $useStrftime); }
/** * Constructs an instance of this class. */ public function __construct() { // get current server system time for use with date() in order to ensure valid // and consistent date and time values all over one instance of this class // in case the timebase is "now" which will be the case if no multipleExec action // is requested by configuration. $this->now = TIME_NOW; // set the timezone which is either the one set by the WBB admin, or if it isn't set, it's GMT. DateUtil::formatDate(); // set cache name. $this->cacheName = 'cronjobs-' . PACKAGE_ID; // read cache. $this->getCronjobsCache(); }
/** * @see Page::readData() */ public function readData() { $newsletter = new NewsletterEditor($this->newsletterID); $this->subject = $newsletter->subject; $this->text = $newsletter->text; $time = $newsletter->deliveryTime; $dateArray = explode('-', DateUtil::formatDate('%Y-%m-%d' . (MESSAGE_NEWSLETTERSYSTEM_GENERAL_HOURLYCRONJOB ? '-%H' : ''), $time, false, true)); $this->dateValues['day'] = $dateArray[2]; $this->dateValues['month'] = $dateArray[1]; $this->dateValues['year'] = $dateArray[0]; if (MESSAGE_NEWSLETTERSYSTEM_GENERAL_HOURLYCRONJOB) { $this->dateValues['hour'] = $dateArray[3]; } parent::readData(); }
/** * @see OptionType::getFormElement() */ public function getFormElement(&$optionData) { if (!isset($optionData['optionValue'])) { if (isset($optionData['defaultValue'])) { $optionData['optionValue'] = $optionData['defaultValue']; } else { $optionData['optionValue'] = ''; } } $optionData['isOptionGroup'] = true; $optionData['divClass'] = 'formDate'; $year = $month = $day = ''; $optionValue = explode('-', is_array($optionData['optionValue']) ? implode('-', $optionData['optionValue']) : $optionData['optionValue']); if (isset($optionValue[0])) { $year = intval($optionValue[0]); } if (empty($year)) { $year = ''; } if (isset($optionValue[1])) { $month = $optionValue[1]; } if (isset($optionValue[2])) { $day = $optionValue[2]; } $dateInputOrder = explode('-', WCF::getLanguage()->get('wcf.global.dateInputOrder')); // generate days $days = array(); $days[0] = ''; for ($i = 1; $i < 32; $i++) { $days[$i] = $i; } // generate months $months = array(); $months[0] = ''; $monthFormat = Language::$dateFormatLocalized ? '%B' : '%m'; for ($i = 1; $i < 13; $i++) { $months[$i] = DateUtil::formatDate($monthFormat, gmmktime(0, 0, 0, $i, 10, 2006), false, true); } WCF::getTPL()->assign(array('year' => $year, 'month' => $month, 'day' => $day, 'days' => $days, 'months' => $months, 'optionData' => $optionData, 'dateInputOrder' => $dateInputOrder, 'yearRequired' => $this->yearRequired)); return WCF::getTPL()->fetch('optionTypeDate'); }
/** * Creates a new MessageSidebar object. * * @param UserProfile $user */ public function __construct(MessageSidebarObject $object) { $this->object = $object; // init user options if ($this->getUser()->userID) { if (!$this->getUser()->protectedProfile || $this->getUser()->userID == WCF::getUser()->userID) { $userOptions = self::getUserOptions(); $categories = $userOptions->getOptionTree('profile', $this->getUser()); // add registration date if (MESSAGE_SIDEBAR_ENABLE_REGISTRATION_DATE == 1) { $this->addUserCredit(WCF::getLanguage()->get('wcf.user.registrationDate'), DateUtil::formatDate(null, $this->getUser()->registrationDate)); } // user options foreach ($categories as $category) { if ($category['categoryName'] == 'profile.contact' || $category['categoryName'] == 'profile.messenger') { foreach ($category['options'] as $userOption) { $this->addUserContact($userOption['optionValue']); } } else { foreach ($category['options'] as $userOption) { if ($userOption['optionName'] == 'birthday' || $userOption['optionName'] == 'gender') { $this->addUserSymbol($userOption['optionValue']); } else { $this->addUserCredit(WCF::getLanguage()->get('wcf.user.option.' . $userOption['optionName']), $userOption['optionValue']); } } } } // add friend icon if (MESSAGE_SIDEBAR_ENABLE_FRIEND_ICON) { if (WCF::getUser()->userID && UserProfile::isBuddy($this->getUser()->userID)) { $this->addUserSymbol('<img src="' . StyleManager::getStyle()->getIconPath('friendsS.png') . '" alt="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.friend', array('username' => $this->getUser()->username)) . '" title="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.friend', array('username' => $this->getUser()->username)) . '" />'); } } } // banned icon if ($object->getUser()->banned) { $this->addUserSymbol('<img src="' . StyleManager::getStyle()->getIconPath('bannedS.png') . '" alt="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.banned', array('username' => $this->getUser()->username)) . '" title="' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.banned', array('username' => $this->getUser()->username)) . '" />'); } } }
/** * @see Page::assignVariables() */ public static function assignVariables() { // create calendar data $dayOptions = array(0 => ''); $hourOptions = $minuteOptions = array('' => ''); $monthList = $weekdayList = ''; $weekdays = $monthOptions = array(); // days for ($i = 1; $i <= 31; $i++) { $dayOptions[$i] = $i; } // months $monthFormat = Language::$dateFormatLocalized ? '%B' : '%m'; for ($i = 1; $i <= 12; $i++) { $monthOptions[$i] = DateUtil::formatDate($monthFormat, gmmktime(0, 0, 0, $i, 15, 2000), false, true); } $monthList = implode(',', $monthOptions); $monthOptions[0] = ''; ksort($monthOptions); // weekdays for ($i = 1; $i <= 7; $i++) { $weekdayNumber = intval(DateUtil::formatDate('%w', gmmktime(0, 0, 0, 1, $i, 2000), false, true)); $weekdays[$weekdayNumber] = DateUtil::formatDate('%a', gmmktime(0, 0, 0, 1, $i, 2000), false, true); } ksort($weekdays); $weekdayList = implode(',', $weekdays); // hours for ($i = 0; $i < 24; $i++) { $hourOptions[$i] = $i < 10 ? "0" . $i : $i; } // minutes for ($i = 0; $i < 60; $i += 5) { $minuteOptions[$i] = $i < 10 ? "0" . $i : $i; } WCF::getTPL()->assign(array('monthOptions' => $monthOptions, 'monthList' => $monthList, 'dayOptions' => $dayOptions, 'weekdayList' => $weekdayList, 'startOfWeek' => WCF::getUser()->firstDayOfWeek == '' ? 1 : intval(WCF::getUser()->firstDayOfWeek), 'hourOptions' => $hourOptions, 'minuteOptions' => $minuteOptions)); }
/** * Returns the age of this user. * * @return integer */ public function getAge() { if ($this->birthday) { // split date $year = $month = $day = 0; $optionValue = explode('-', $this->birthday); if (isset($optionValue[0])) { $year = intval($optionValue[0]); } if (isset($optionValue[1])) { $month = intval($optionValue[1]); } if (isset($optionValue[2])) { $day = intval($optionValue[2]); } // calc if ($year) { $age = DateUtil::formatDate('%Y', null, false, true) - $year; if (intval(DateUtil::formatDate('%m', null, false, true)) < intval($month)) { $age--; } else { if (intval(DateUtil::formatDate('%m', null, false, true)) == intval($month) && DateUtil::formatDate('%e', null, false, true) < intval($day)) { $age--; } } return $age; } } return 0; }
/** * Reads the data that should be displayed in the report and creates it. */ protected function create() { $this->blocks = $this->getDisplayBlocks(); Spec::storeData($this->getTargetPlanet(), $this->getOfiara()); // header $this->ereport .= '<table> <tr> <td class="c" colspan="4">'; // TODO: fix if (!defined('TIMEZONE')) { define('TIMEZONE', '1'); } WCF::getUser()->timezone = TIMEZONE; echo "utz:" . WCF::getUser()->timezone . "gtz:" . TIMEZONE; $vars = array('$targetPlanet' => $this->getTargetPlanet(), '$time' => DateUtil::formatDate(WCF::getLanguage()->get('wot.global.timeFormat'), time())); $this->ereport .= WCF::getLanguage()->get('wot.mission.mission' . $this->missionID . '.report.header', $vars); $this->ereport .= '</td> </tr>'; // resources if ($this->blocks & self::RESOURCES) { $array = array(); foreach ($this->resourceTypes as $resourceType) { $key = WCF::getLanguage()->get('wot.global.' . $resourceType); $count = $this->getTargetPlanet()->{$resoureType}; $array[$key] = array('id' => $resourceType, 'name' => WCF::getLanguage()->get('wot.global.' . $resourceType), 'count' => intval(floor($this->getTargetPlanet()->{$resourceType}))); } $this->ereport .= $this->createBlock($array); } $this->addBlock(self::FLEET, 3, 'fleet'); $this->addBlock(self::DEFENSE, array(4, 51, 52), 'defense'); $this->addBlock(self::BUILDINGS, 1, 'buildings'); $this->addBlock(self::RESEARCH, 2, 'research'); $this->ereport .= '</table>'; }
define('TEMPLATE_DIR', "templates/"); define('TEMPLATE_NAME', "OpenGame"); define('DEFAULT_LANG', 'de'); // include ugamela $ugamela_root_path = '/var/www/vhosts/finaluniverse.com/httpdocs/'; include $ugamela_root_path . 'extension.inc'; // mastercook patch $_SERVER['REQUEST_METHOD'] = ''; $_SERVER['SERVER_PORT'] = ''; // include wcf if (!defined('WCF_DIR')) { define('WCF_DIR', dirname(__FILE__) . '/../wcf/'); } require_once $ugamela_root_path . 'game/global.php'; //require_once($ugamela_root_path.'wotapi/global.php'); restore_error_handler(); // include some ugamela libs require $ugamela_root_path . 'includes/vars.php'; require $ugamela_root_path . 'includes/functions.php'; require $ugamela_root_path . 'includes/strings.php'; // load config $sql = "SELECT *\r\n\t\tFROM ugml_config"; $config = WCF::getDB()->getResultList($sql); $game_config = array(); foreach ($config as $row) { $game_config[$row['config_name']] = $row['config_value']; } $vars = array('$time' => DateUtil::formatDate(WCF::getLanguage()->get('wot.global.timeFormat'), time())); var_dump(WCF::getLanguage()->get('wot.global.timeFormat')); var_dump(DateUtil::formatDate(WCF::getLanguage()->get('wot.global.timeFormat'), time())); var_dump(gmstrftime("%d.%m.%Y, %H:%M:%S", time()));
/** * Informs admins about the current warnings and deletions * */ protected function sendProtocol() { $generalOptions = $this->data['parameters']['user.inactiveUsers.general']; $deleteOptions = $this->data['parameters']['user.inactiveUsers.inactive']; $actionDate = DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.dateFormat'), TIME_NOW); $mailUserTableHeader = "\n" . str_pad("USER", 26, " ") . str_pad("USERID", 12, " ", STR_PAD_LEFT) . " " . str_pad("REG-DATE", 20, " ") . "LAST-ACTIVE" . "\n" . str_repeat('-', 80); $subject = WCF::getLanguage()->get('wcf.acp.admintools.function.user.inactiveUsers.mailsubject', array('PAGE_TITLE' => PAGE_TITLE, '$actionDate' => $actionDate)); $message = WCF::getLanguage()->get('wcf.acp.admintools.function.user.inactiveUsers.message', array('PAGE_TITLE' => PAGE_TITLE, '$actionDate' => $actionDate)) . "\n"; if ($generalOptions['appendNewUsers']) { $regTimeStart = mktime(0, 0, 0, (int) date("m", TIME_NOW), (int) date("d", TIME_NOW) - 1, (int) date("Y", TIME_NOW)); $regTimeEnd = mktime(0, 0, 0, (int) date("m", TIME_NOW), (int) date("d", TIME_NOW), (int) date("Y", TIME_NOW)); $regDate = DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.dateFormat'), $regTimeStart); $sql = "SELECT user.* FROM wcf" . WCF_N . "_user user\n WHERE registrationDate >= " . $regTimeStart . "\n AND registrationDate < " . $regTimeEnd . "\n ORDER BY LOWER(username)"; $result = WCF::getDB()->sendQuery($sql); $users = array(); while ($row = WCF::getDB()->fetchArray($result)) { $users[] = new User(null, $row); } $message .= "\n\n"; $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.user.inactiveUsers.newUsers', array('$count' => count($users), '$registrationDate' => $regDate)) . $mailUserTableHeader; foreach ($users as $user) { $message .= "\n" . str_pad($user->username, 26, " ") . str_pad($user->userID, 12, " ", STR_PAD_LEFT) . " " . str_pad(DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.timeFormat'), $user->registrationDate), 20, " ") . DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.timeFormat'), $user->lastActivityTime); } } if (($deleteOptions['action'] == 'warn' || $deleteOptions['action'] == 'warnanddelete') && $generalOptions['sendWarnMail']) { $message .= "\n\n"; $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.user.inactiveUsers.inactive.mailwarned', array('$count' => count($this->warnedInactiveUsers))) . $mailUserTableHeader; if (count($this->warnedInactiveUsers)) { foreach ($this->warnedInactiveUsers as $user) { $message .= "\n" . str_pad($user->username, 26, " ") . str_pad($user->userID, 12, " ", STR_PAD_LEFT) . " " . str_pad(DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.timeFormat'), $user->registrationDate), 20, " ") . DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.timeFormat'), $user->lastActivityTime); } } else { $message .= "\n-"; } } if ($deleteOptions['action'] == 'delete' || $deleteOptions['action'] == 'warnanddelete') { $message .= "\n\n"; $message .= WCF::getLanguage()->get('wcf.acp.admintools.function.user.inactiveUsers.inactive.adminmail', array('$count' => count($this->deletedInactiveUsers))) . $mailUserTableHeader; if (count($this->deletedInactiveUsers)) { foreach ($this->deletedInactiveUsers as $user) { $message .= "\n" . str_pad($user->username, 26, " ") . str_pad($user->userID, 12, " ", STR_PAD_LEFT) . " " . str_pad(DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.timeFormat'), $user->registrationDate), 20, " ") . DateUtil::formatDate(WCF::getLanguage()->get('wcf.global.timeFormat'), $user->lastActivityTime); } } else { $message .= "\n-"; } } $mail = new Mail(array(MAIL_FROM_NAME => MAIL_FROM_ADDRESS), $subject, $message); $mail->send(); }
/** * @see Page::readData() */ public function readData() { parent::readData(); if (!count($_POST)) { // set current date $this->untilDay = intval(DateUtil::formatDate('%d', null, false, true)); $this->untilMonth = intval(DateUtil::formatDate('%m', null, false, true)); $this->untilYear = intval(DateUtil::formatDate('%Y', null, false, true)); } $this->availableTypes = SearchEngine::getSearchTypes(); }
protected static function calcAge($year, $month, $day) { $age = DateUtil::formatDate('%Y', null, false, true) - $year; if (intval(DateUtil::formatDate('%m', null, false, true)) < intval($month)) { $age--; } else { if (intval(DateUtil::formatDate('%m', null, false, true)) == intval($month) && DateUtil::formatDate('%e', null, false, true) < intval($day)) { $age--; } } return $age; }
/** * Returns the data of a member. * * @param array $row * @return array */ protected function getMember($row) { $user = new UserProfile(null, $row); $username = StringUtil::encodeHTML($row['username']); $protectedProfile = $user->protectedProfile && WCF::getUser()->userID != $user->userID; $userData = array('user' => $user, 'encodedUsername' => $username, 'protectedProfile' => $protectedProfile); foreach ($this->activeFields as $field) { switch ($field) { // default fields case 'username': $userData['username'] = '******'; if ($user->isOnline()) { $title = WCF::getLanguage()->get('wcf.user.online', array('$username' => $username)); $userData['username'] .= '<img src="' . StyleManager::getStyle()->getIconPath('onlineS.png') . '" alt="' . $title . '" title="' . $title . '" />'; } else { $title = WCF::getLanguage()->get('wcf.user.offline', array('$username' => $username)); $userData['username'] .= '<img src="' . StyleManager::getStyle()->getIconPath('offlineS.png') . '" alt="' . $title . '" title="' . $title . '" />'; } $userData['username'] .= '</div><div class="containerContentSmall">'; $title = WCF::getLanguage()->get('wcf.user.viewProfile', array('$username' => $username)); $userData['username'] .= '<p><a href="index.php?page=User&userID=' . $row['userID'] . SID_ARG_2ND . '" title="' . $title . '">' . $username . '</a></p>'; if (MODULE_USER_RANK == 1 && $user->getUserTitle()) { $userData['username'] .= '<p class="smallFont">' . $user->getUserTitle() . ' ' . ($user->getRank() ? $user->getRank()->getImage() : '') . '</p>'; } $userData['username'] .= '</div>'; break; case 'registrationDate': $userData['registrationDate'] = DateUtil::formatDate(null, $row['registrationDate']); break; case 'lastActivity': $userData['lastActivity'] = ''; if ($user->invisible != 1 || WCF::getUser()->getPermission('admin.general.canViewInvisible')) { $userData['lastActivity'] = DateUtil::formatTime(null, $row['lastActivityTime']); } break; case 'avatar': if ($user->getAvatar() && ($row['userID'] == WCF::getUser()->userID || WCF::getUser()->getPermission('user.profile.avatar.canViewAvatar'))) { $user->getAvatar()->setMaxHeight(50); $title = WCF::getLanguage()->get('wcf.user.viewProfile', array('$username' => $username)); $userData['avatar'] = '<a href="index.php?page=User&userID=' . $row['userID'] . SID_ARG_2ND . '" title="' . $title . '">' . $user->getAvatar()->__toString() . '</a>'; } else { $userData['avatar'] = ''; } break; case 'language': if ($row['languageID'] && $row['languageCode']) { $userData['language'] = '<img src="' . RELATIVE_WCF_DIR . 'icon/language' . ucfirst($row['languageCode']) . 'S.png" alt="' . WCF::getLanguage()->get('wcf.global.language.' . $row['languageCode']) . '" title="' . WCF::getLanguage()->get('wcf.global.language.' . $row['languageCode']) . '" />'; } else { $userData['language'] = ''; } break; // user options // user options default: $userData[$field] = ''; $option = $this->userOptions->getOptionValue($field, $user); if (!$protectedProfile && $option) { $userData[$field] = $option['optionValue']; } } } return $userData; }
/** * Initializes the user status symbols. */ protected function initUserSymbols() { // gender icon if ($this->user->getUserOption('gender')) { $title = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.gender.' . ($this->user->getUserOption('gender') == 1 ? 'male' : 'female'), array('username' => $this->user->username)); $this->userSymbols[] = '<img src="' . StyleManager::getStyle()->getIconPath('gender' . ($this->user->getUserOption('gender') == 1 ? 'Male' : 'Female') . 'S.png') . '" alt="" title="' . $title . '" /> <span class="hidden">' . $title . '</span>'; } // birthday icon if ($this->user->birthday) { if (substr($this->user->birthday, 5) == DateUtil::formatDate('%m-%d', TIME_NOW, false, true)) { $title = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.birthday', array('username' => $this->user->username, 'age' => $this->user->getAge())); $this->userSymbols[] = '<img src="' . StyleManager::getStyle()->getIconPath('birthdayS.png') . '" alt="" title="' . $title . '" /> <span class="hidden">' . $title . '</span>'; } } // friend icon if ($this->user->buddy) { $title = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.friend', array('username' => $this->user->username)); $this->userSymbols[] = '<img src="' . StyleManager::getStyle()->getIconPath('friendsS.png') . '" alt="" title="' . $title . '" /> <span class="hidden">' . $title . '</span>'; } // banned icon if ($this->user->banned) { $title = WCF::getLanguage()->getDynamicVariable('wcf.user.profile.banned', array('username' => $this->user->username)); $this->userSymbols[] = '<img src="' . StyleManager::getStyle()->getIconPath('bannedS.png') . '" alt="" title="' . $title . '" /> <span class="hidden">' . $title . '</span>'; } }
/** * @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); }
/** * Gets the list of results. */ protected function readUsers() { // get user ids $userIDs = array(); $sql = "SELECT\t\tuser_table.userID\n\t\t\tFROM\t\twcf" . WCF_N . "_user user_table\n\t\t\t" . (isset($this->options[$this->sortField]) ? "LEFT JOIN wcf" . WCF_N . "_user_option_value USING (userID)" : '') . "\n\t\t\t" . (!empty($this->sqlConditions) ? 'WHERE ' . $this->sqlConditions : '') . "\n\t\t\tORDER BY\t" . ($this->sortField != 'email' && isset($this->options[$this->sortField]) ? 'userOption' . $this->options[$this->sortField]['optionID'] : $this->sortField) . " " . $this->sortOrder; $result = WCF::getDB()->sendQuery($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage); while ($row = WCF::getDB()->fetchArray($result)) { $userIDs[] = $row['userID']; } // get user data if (count($userIDs)) { $sql = "SELECT\t\toption_value.*, user_table.*,\n\t\t\t\t\t\tGROUP_CONCAT(groupID SEPARATOR ',') AS groupIDs\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user user_table\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value\n\t\t\t\tON\t\t(option_value.userID = user_table.userID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_to_groups groups\n\t\t\t\tON\t\t(groups.userID = user_table.userID)\n\t\t\t\tWHERE\t\tuser_table.userID IN (" . implode(',', $userIDs) . ")\n\t\t\t\tGROUP BY\tuser_table.userID\n\t\t\t\tORDER BY\t" . ($this->sortField != 'email' && isset($this->options[$this->sortField]) ? 'option_value.userOption' . $this->options[$this->sortField]['optionID'] : 'user_table.' . $this->sortField) . " " . $this->sortOrder; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $accessible = Group::isAccessibleGroup(explode(',', $row['groupIDs'])); $row['accessible'] = $accessible; $row['deletable'] = $accessible && WCF::getUser()->getPermission('admin.user.canDeleteUser') && $row['userID'] != WCF::getUser()->userID ? 1 : 0; $row['editable'] = $accessible && WCF::getUser()->getPermission('admin.user.canEditUser') ? 1 : 0; $row['isMarked'] = intval(in_array($row['userID'], $this->markedUsers)); $this->users[] = new User(null, $row); } // get special columns foreach ($this->users as $key => $user) { foreach ($this->columns as $column) { if (isset($this->options[$column])) { if ($this->options[$column]['outputClass']) { $outputObj = $this->getOutputObject($this->options[$column]['outputClass']); $this->columnValues[$user->userID][$column] = $outputObj->getOutput($user, $this->options[$column], $user->{$column}); } else { $this->columnValues[$user->userID][$column] = StringUtil::encodeHTML($user->{$column}); } } else { switch ($column) { case 'email': $this->columnValues[$user->userID][$column] = '<a href="mailto:' . StringUtil::encodeHTML($user->email) . '">' . StringUtil::encodeHTML($user->email) . '</a>'; break; case 'registrationDate': $this->columnValues[$user->userID][$column] = DateUtil::formatDate(null, $user->{$column}); break; } } } } } }
public function __construct($data, $boxname = "") { $this->BoxData['templatename'] = "monthlyCalendarBox"; $this->getBoxStatus($data); $this->BoxData['boxID'] = $data['boxID']; $this->mcbHelper = new MonthlyCalendarBoxHelper(); $calendarInstalled = false; $mcbAppointments = array(); // misc vars if (!defined('MONTHLYCALENDARBOX_COL_ALIGN')) { define('MONTHLYCALENDARBOX_COL_ALIGN', 'Right'); } if (!defined('MONTHLYCALENDARBOX_SHOW_DOY')) { define('MONTHLYCALENDARBOX_SHOW_DOY', true); } if (!defined('MONTHLYCALENDARBOX_SHOW_NAV')) { define('MONTHLYCALENDARBOX_SHOW_NAV', true); } if (!defined('MONTHLYCALENDARBOX_SHOW_FORM')) { define('MONTHLYCALENDARBOX_SHOW_FORM', true); } if (!defined('MONTHLYCALENDARBOX_NAV_BOTTOM')) { define('MONTHLYCALENDARBOX_NAV_BOTTOM', true); } if (!defined('MONTHLYCALENDARBOX_MAXLEN')) { define('MONTHLYCALENDARBOX_MAXLEN', 22); } if (!defined('MONTHLYCALENDARBOX_MBFUNCTIONS')) { define('MONTHLYCALENDARBOX_MBFUNCTIONS', true); } if (!defined('MONTHLYCALENDARBOX_SHOWBIRTHDAYTOGUEST')) { define('MONTHLYCALENDARBOX_SHOWBIRTHDAYTOGUEST', false); } if (!defined('MONTHLYCALENDARBOX_SHOWHOLIDAYTOGUEST')) { define('MONTHLYCALENDARBOX_SHOWHOLIDAYTOGUEST', 'DISABLED'); } if (MONTHLYCALENDARBOX_MBFUNCTIONS && function_exists('mb_substr')) { $dF = ini_get('disable_functions'); if (preg_match('/(mb_substr|mbstring)/', $dF)) { $mbSubstr = false; } else { $mbSubstr = true; } } else { $mbSubstr = false; } if (!empty($_REQUEST['page'])) { $redirTo = $_REQUEST['page']; } else { $redirTo = 'Portal'; } $mcbTitleLinkTo = ''; if (WBBCore::getUser()->getPermission('user.calendar.canUseCalendar') || WBBCore::getUser()->getPermission('user.calendar.canEnter')) { $mcbTitleLinkTo = 'Calendar'; $calendarInstalled = true; } else { $mcbTitleLinkTo = 'UserProfileEdit'; } if (!WBBCore::getUser()->userID || WBBCore::getUser()->monthlyCalendarBox_showCalendarWeeks) { $mcbShowCW = true; } else { $mcbShowCW = false; } if (WBBCore::getUser()->monthlyCalendarBox_showBirthdays || !WBBCore::getUser()->userID && MONTHLYCALENDARBOX_SHOWBIRTHDAYTOGUEST) { $mcbShowBirthdays = true; } else { $mcbShowBirthdays = false; } if (WBBCore::getUser()->monthlyCalendarBox_showHolidays || !WBBCore::getUser()->userID && MONTHLYCALENDARBOX_SHOWHOLIDAYTOGUEST != 'DISABLED') { $mcbShowHolidays = true; } else { $mcbShowHolidays = false; } $mcbShowAppointments = $mcbShowAppointmentsAsDefault = $showAppointmentsInCalendar = false; if ($calendarInstalled) { if (!WBBCore::getUser()->userID || WBBCore::getUser()->monthlyCalendarBox_showAppointmentsInCalendar) { if (WBBCore::getUser()->getPermission('user.calendar.canEnter') && !WBBCore::getUser()->getPermission('user.calendar.canViewEvents')) { $showAppointmentsInCalendar = false; } else { $showAppointmentsInCalendar = true; } } if (!WBBCore::getUser()->userID || WBBCore::getUser()->monthlyCalendarBox_showAppointments) { if (WBBCore::getUser()->getPermission('user.calendar.canEnter') && !WBBCore::getUser()->getPermission('user.calendar.canViewEvents')) { $mcbShowAppointments = false; } else { $mcbShowAppointments = true; } if (WBBCore::getUser()->monthlyCalendarBox_showAppointmentsAsDefault) { $mcbShowAppointmentsAsDefault = true; } } } $mcDays = $daysBefore = $daysAfter = $calendarWeeks = $birthdays = $dates = $holidays = $months = array(); $curDay = 0; $mcCurY = intval(date('Y')); $mcCurM = intval(date('n')); if (isset($_REQUEST['mcY'])) { $mcY = intval($_REQUEST['mcY']); } else { if (WCF::getSession()->getVar('monthlyCalendarBoxY')) { $mcY = intval(WCF::getSession()->getVar('monthlyCalendarBoxY')); } } if (isset($_REQUEST['mcM'])) { $mcM = intval($_REQUEST['mcM']); if ($mcM < 1) { $mcM = 12; $mcY--; } else { if ($mcM > 12) { $mcM = 1; $mcY++; } } } else { if (WCF::getSession()->getVar('monthlyCalendarBoxM')) { $mcM = intval(WCF::getSession()->getVar('monthlyCalendarBoxM')); } } if (empty($mcY)) { $mcY = $mcCurY; } else { if ($mcY < 1902) { $mcY = 1902; } else { if ($mcY > 2037) { $mcY = 2037; } } } if (empty($mcM)) { $mcM = $mcCurM; } else { if ($mcM < 1) { $mcM = 1; } else { if ($mcM > 12) { $mcM = 12; } } } if ($mcY == $mcCurY && $mcM == $mcCurM) { $curDay = date('j'); } $mcbTitle = WCF::getLanguage()->get('wbb.portal.box.monthlyCalendar.month_' . $mcM) . ' ' . $mcY; if ($mcbShowBirthdays) { $birthdays = $this->mcbHelper->getBirthdays($mcY, $mcM); } if ($showAppointmentsInCalendar) { $dates = $this->mcbHelper->getAppointments($mcY, $mcM); } if ($mcbShowHolidays && $mcY >= 1970) { if (WBBCore::getUser()->monthlyCalendarBox_showHolidaysFrom) { $h = WBBCore::getUser()->monthlyCalendarBox_showHolidaysFrom; } else { $h = MONTHLYCALENDARBOX_SHOWHOLIDAYTOGUEST; } if ($h && $h != 'DISABLED') { $holidays = $this->mcbHelper->getHolidays($h, $mcY, $mcM); } } if (WCF::getUser()->getPermission('user.board.canViewMonthlyCalendarBox')) { $cntDays = strftime('%d', gmmktime(0, 0, 0, $mcM + 1, 0, $mcY)); $firstWeekday = strftime('%w', gmmktime(0, 0, 0, $mcM, 1, $mcY)); $lastWeekday = strftime('%w', gmmktime(0, 0, 0, $mcM, $cntDays, $mcY)); if ($firstWeekday == 0) { $firstWeekday = 7; } if ($lastWeekday == 0) { $lastWeekday = 7; } for ($i = 1; $i < $firstWeekday; $i++) { $time = gmmktime(0, 0, 0, $mcM, $i - $firstWeekday + 1, $mcY); $daysBefore[$i]['day'] = date('j', $time); $daysBefore[$i]['weekday'] = date('w', $time) + 1; } for ($i = 1; $i <= 7 - $lastWeekday; $i++) { $time = gmmktime(0, 0, 0, $mcM, $i + $cntDays, $mcY); $daysAfter[$i]['day'] = date('j', $time); $daysAfter[$i]['weekday'] = date('w', $time) + 1; } for ($i = 1; $i <= $cntDays; $i++) { $mcDays[$i]['day'] = $i; $time = gmmktime(0, 0, 0, $mcM, $i, $mcY); $doy = date('z', $time) + 1; $mcDays[$i]['weekday'] = date('w', $time) + 1; $mcDays[$i]['birthday'] = false; $mcDays[$i]['appointment'] = false; $mcDays[$i]['holiday'] = false; if (MONTHLYCALENDARBOX_SHOW_DOY) { $mcDays[$i]['title'] = WCF::getLanguage()->get('wbb.portal.box.monthlyCalendar.dayOfTheYear', array('$doy' => $doy)); } else { $mcDays[$i]['title'] = ''; } if ($mcbShowHolidays && isset($holidays[$i])) { if ($mcDays[$i]['title']) { $mcDays[$i]['title'] .= ' • '; } $mcDays[$i]['title'] .= $holidays[$i]; $mcDays[$i]['holiday'] = true; } if ($showAppointmentsInCalendar && isset($dates[$i])) { if ($mcDays[$i]['title']) { $mcDays[$i]['title'] .= ' • '; } $mcDays[$i]['title'] .= WCF::getLanguage()->get('wbb.portal.box.monthlyCalendar.appointments') . ': ' . $dates[$i]; $mcDays[$i]['appointment'] = true; } if ($mcbShowBirthdays && isset($birthdays[$i])) { if ($mcDays[$i]['title']) { $mcDays[$i]['title'] .= ' • '; } $mcDays[$i]['title'] .= WCF::getLanguage()->get('wbb.portal.box.monthlyCalendar.birthdays') . ': ' . $birthdays[$i]; $mcDays[$i]['birthday'] = true; } if (empty($mcDays[$i]['title'])) { $mcDays[$i]['title'] = DateUtil::formatDate(null, $time); } } for ($i = 1; $i <= 12; $i++) { $months[$i] = WCF::getLanguage()->get('wbb.portal.box.monthlyCalendar.month_' . $i); } if ($mcbShowAppointments) { $mcbAppointments = $this->mcbHelper->getAppointmentList(); } if (!count($mcbAppointments) or !empty($_REQUEST['mcM'])) { $mcbShowAppointmentsAsDefault = false; } } WCF::getSession()->register('monthlyCalendarBoxY', $mcY); WCF::getSession()->register('monthlyCalendarBoxM', $mcM); WCF::getTPL()->assign(array('mcbHelper' => $this->mcbHelper, 'mcbTitle' => $mcbTitle, 'curDay' => $curDay, 'mcCurY' => $mcCurY, 'mcCurM' => $mcCurM, 'mcY' => $mcY, 'mcM' => $mcM, 'daysAfter' => $daysAfter, 'mcDays' => $mcDays, 'daysBefore' => $daysBefore, 'months' => $months, 'mcbShowCW' => $mcbShowCW, 'redirTo' => $redirTo, 'mcbTitleLinkTo' => $mcbTitleLinkTo, 'calendarInstalled' => $calendarInstalled, 'mcbShowAppointments' => $mcbShowAppointments, 'mcbShowAppointmentsAsDefault' => $mcbShowAppointmentsAsDefault, 'mcbAppointments' => $mcbAppointments, 'mbSubstr' => $mbSubstr)); }
public function getAppointmentList() { $ret = array(); $i = 0; $limit = intval(WBBCore::getUser()->monthlyCalendarBox_maxAppointments); $showPublic = intval(WBBCore::getUser()->monthlyCalendarBox_showPublicAppointments); $showBirthdays = intval(WBBCore::getUser()->monthlyCalendarBox_showBirthdaysInAppointments); $maxDays = intval(WBBCore::getUser()->monthlyCalendarBox_maxAppointmentDays); $userID = intval(WCF::getUser()->userID); if (!$limit > 0) { $limit = 10; } if (empty($maxDays)) { $maxDays = 30; } if (empty($userID)) { $showPublic = 1; $showBirthdays = 1; } $m = intval(date('n')); $y = intval(date('Y')); $d = intval(date('j')); $sTimestamp = mktime(0, 0, 0, $m, $d, $y); $eTimestamp = $sTimestamp + 86400; // WoltLab Calendar... if (WBBCore::getUser()->getPermission('user.calendar.canUseCalendar')) { require_once WCF_DIR . 'lib/util/CalendarUtil.class.php'; require_once WCF_DIR . 'lib/data/calendar/event/EventList.class.php'; $cals = Calendar::getEnabledCalendars(); if (empty($showBirthdays)) { foreach ($cals as $k => $v) { if ($v->className == 'BirthdayEvent') { unset($cals[$k]); break; } } } if (!empty($userID) && empty($showPublic)) { foreach ($cals as $k => $v) { if ($v->ownerID != $userID && $v->className != 'BirthdayEvent') { unset($cals[$k]); } } } $events = new EventList($sTimestamp, $sTimestamp + 86400 * $maxDays, $cals); $events->readEvents(); $myEvents = $events->getEvents($limit); // file_put_contents('/tmp/debug.txt', print_r($myEvents, true)); foreach ($myEvents as $event) { if ($showBirthdays && $event->calendar->className == 'BirthdayEvent' && $event->user && !$event->eventID) { $ret[$i]['birthday'] = true; $ret[$i]['userID'] = $event->userID; $ret[$i]['username'] = $event->user->username; $ret[$i]['age'] = $event->user->age; $ret[$i]['time'] = $event->startTime; $ret[$i]['eventID'] = null; } else { $ret[$i]['birthday'] = false; $ret[$i]['eventID'] = $event->eventID; } if ($event->isFullDay) { $ret[$i]['startTime'] = DateUtil::getUTC($event->startTime); $ret[$i]['endTime'] = DateUtil::getUTC($event->endTime); } else { $ret[$i]['startTime'] = $event->startTime; $ret[$i]['endTime'] = $event->endTime; } $ret[$i]['fullDay'] = $event->isFullDay; $ret[$i]['subject'] = $event->subject; $ret[$i]['severalDays'] = false; $ret[$i]['curYear'] = true; $ret[$i]['sameDay'] = false; $ret[$i]['color'] = $event->color; $ret[$i]['today'] = false; $ret[$i]['title'] = ''; if ($ret[$i]['startTime'] >= $sTimestamp && $ret[$i]['endTime'] < $eTimestamp) { $ret[$i]['today'] = true; } else { $ret[$i]['today'] = false; if (date('j', $ret[$i]['startTime']) != date('j', $ret[$i]['endTime'])) { $ret[$i]['severalDays'] = true; } if (date('Y', $ret[$i]['startTime']) != date('Y')) { $ret[$i]['curYear'] = false; } } if ($ret[$i]['severalDays']) { $ret[$i]['title'] = DateUtil::formatDate('%d.%m. %H:%M', $ret[$i]['startTime']) . ' - ' . DateUtil::formatDate('%d.%m. %H:%M', $ret[$i]['endTime']); } else { $ret[$i]['title'] = DateUtil::formatDate('%H:%M', $ret[$i]['startTime']) . '-' . DateUtil::formatDate('%H:%M', $ret[$i]['endTime']); } $ret[$i]['title'] .= ': ' . $ret[$i]['subject']; $i++; } } else { if (WBBCore::getUser()->getPermission('user.calendar.canEnter')) { if (!empty($showBirthdays)) { $birthdays = self::getBirthdayList($y, $m, $d); $color = ''; $isEnabled = 1; foreach ($birthdays as $k => $v) { $ret[$i]['birthday'] = true; $ret[$i]['color'] = $color; $ret[$i]['userID'] = $v['userID']; $ret[$i]['username'] = $v['username']; $ret[$i]['age'] = $v['age']; $ret[$i]['time'] = $v['time']; $i++; } } $sql = "SELECT ce.eventID, cem.subject AS subject, ce.eventTime AS startTime, ce.eventEndTime AS endTime, ce.isFullDay AS fullDay" . "\n FROM wcf" . WCF_N . "_calendar_event ce" . "\n LEFT JOIN wcf" . WCF_N . "_calendar_event_message cem ON (cem.eventID = ce.eventID)" . "\n WHERE (ce.eventTime >= " . TIME_NOW . "\n OR (ce.isFullDay = 1 AND ce.eventTime >= " . $sTimestamp . ")" . "\n OR (ce.eventEndTime > ce.eventTime AND ce.eventEndTime > " . $sTimestamp . "))" . "\n AND cem.isDeleted != 1"; if (!empty($userID) && empty($showPublic)) { $sql .= "\n AND cem.userID = " . $userID; } $sql .= "\n ORDER BY ce.eventTime" . "\n LIMIT " . $limit; $result = WBBCore::getDB()->sendQuery($sql); while ($row = WBBCore::getDB()->fetchArray($result)) { if (!empty($row['fullDay'])) { $tM = intval(date('n', $row['startTime'])); $tY = intval(date('Y', $row['startTime'])); $tD = intval(date('j', $row['startTime'])); $row['startTime'] = mktime(0, 0, 0, $tM, $tD, $tY); if (empty($row['endTime'])) { $row['endTime'] = mktime(0, 0, 0, $tM, $tD, $tY); } else { $tM = intval(date('n', $row['endTime'])); $tY = intval(date('Y', $row['endTime'])); $tD = intval(date('j', $row['endTime'])); $row['endTime'] = mktime(0, 0, 0, $tM, $tD, $tY); } } if (empty($row['endTime'])) { $row['endTime'] = $row['startTime']; } $ret[$i]['fullDay'] = $row['fullDay']; $ret[$i]['birthday'] = false; $ret[$i]['color'] = ''; $ret[$i]['eventID'] = $row['eventID']; $ret[$i]['subject'] = $row['subject']; $ret[$i]['startTime'] = $row['startTime']; $ret[$i]['endTime'] = $row['endTime']; $ret[$i]['severalDays'] = false; $ret[$i]['curYear'] = true; $ret[$i]['sameDay'] = false; if ($row['startTime'] >= $sTimestamp && $row['endTime'] <= $eTimestamp) { $ret[$i]['today'] = true; } else { $ret[$i]['today'] = false; if (date('j', $row['startTime']) != date('j', $row['endTime'])) { $ret[$i]['severalDays'] = true; } if (date('Y', $row['startTime']) != date('Y')) { $ret[$i]['curYear'] = false; } } if ($ret[$i]['severalDays']) { $ret[$i]['title'] = DateUtil::formatShortTime('%d.%m. %H:%M', $row['startTime']) . ' - ' . DateUtil::formatShortTime('%d.%m. %H:%M', $row['endTime']); } else { $ret[$i]['title'] = DateUtil::formatShortTime('%H:%M', $row['startTime']) . '-' . DateUtil::formatShortTime('%H:%M', $row['endTime']); } $ret[$i]['title'] .= ': ' . $row['subject']; $i++; } } } return $ret; }
/** * Generates the report */ protected function generateReport() { // header $report = '<table> <tr> <td class="c" colspan="4"> ' . WCF::getLanguage()->get('wot.mission.mission' . $this->missionID . '.report.header', array('$targetPlanet' => $this->getTargetPlanet(), '$attacker' => $this->getOwner(), '$time' => DateUtil::formatDate(WCF::getLanguage()->get('wot.global.timeFormat'), time()))) . ' </td> </tr> <tr> <td class="c" colspan="4"> ' . WCF::getLanguage()->get('wot.mission.mission' . $this->missionID . '.report.lostDefense') . ' </td> </tr>'; $startTR = true; $specs = Spec::getBySpecType(array(4, 51, 52), true); foreach ($specs as $specID => $specObj) { if (empty($this->destroyedDefense[$specID]) && !isset($this->prototypes[$specID])) { continue; } if ($startTR) { $report .= '<tr>'; } $report .= '<td>' . WCF::getLanguage()->get('wot.spec.spec' . $specID) . '</td><td>' . $specObj->level . ' (-' . intval($this->destroyedDefense[$specID]) . ')</td>'; if (!$startTR) { $report .= '</tr>'; } $startTR = !$startTR; } if (!$startTR) { $report .= '<td></td></tr>'; } $report .= '</table>'; $this->report = $report; }
/** * Assigns the data of this poll to the template engine. */ protected function assign() { require_once WCF_DIR . 'lib/page/util/InlineCalendar.class.php'; InlineCalendar::assignVariables(); if (!count($_POST) && $this->endTime) { $this->endTimeDay = intval(DateUtil::formatDate('%e', $this->endTime, false, true)); $this->endTimeMonth = intval(DateUtil::formatDate('%m', $this->endTime, false, true)); $this->endTimeYear = DateUtil::formatDate('%Y', $this->endTime, false, true); $this->endTimeHour = DateUtil::formatDate('%H', $this->endTime, false, true); $this->endTimeMinutes = DateUtil::formatDate('%M', $this->endTime, false, true); } WCF::getTPL()->assign(array('pollID' => $this->pollID, 'pollQuestion' => $this->question, 'pollOptions' => implode("\n", $this->pollOptionsArray), 'choiceCount' => $this->choiceCount, 'timeout' => $this->timeout, 'votesNotChangeable' => $this->votesNotChangeable, 'sortByResult' => $this->sortByResult, 'isPublic' => $this->isPublic, 'endTimeDay' => $this->endTimeDay, 'endTimeMonth' => $this->endTimeMonth, 'endTimeYear' => $this->endTimeYear, 'endTimeHour' => $this->endTimeHour, 'endTimeMinutes' => $this->endTimeMinutes, 'canStartPublicPoll' => $this->canStartPublicPoll)); }
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; } }