/**
  * @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::formatTime(isset($tagArgs[1]) ? $tagArgs[1] : null, $tagArgs[0], isset($tagArgs[1]) ? false : true, $useStrftime);
 }
 /**
  * Builds a package
  *
  * @param	integer		$source			id or instance of a source
  * @param	PackageReader	$package		required and optional packages
  * @param	string		$directory		source directory
  * @param	string		$filename		the filename
  * @param	mixed		$excludeFiles		files to exclude while packing archive
  * @param	boolean		$ignoreDotFiles		should files beginning with a dot be ignored
  * @param	boolean		$removeAfter		should temporary files be removed afterwards
  */
 public function __construct($source, PackageReader $package, $directory, $filename, $excludeFiles = array(), $ignoreDotFiles = true, $removeAfter = false, $allowedDotFiles = array())
 {
     // read source
     $this->source = $source instanceof Source ? $source : new Source($source);
     // read package
     $this->package = $package->getPackageData();
     if (!isset($this->package['name'])) {
         throw new SystemException('Missing package name in "' . $directory . '", package.xml is not valid');
     }
     $this->ignoreDotFiles = $ignoreDotFiles;
     // add additional files whitch should be allowed
     if (!empty($allowedDotFiles)) {
         if (!is_array($allowedDotFiles)) {
             $allowedDotFiles = array($allowedDotFiles);
         }
         $this->allowedDotFiles = array_merge($this->allowedDotFiles, $allowedDotFiles);
     }
     // add additional files whitch should be excluded
     if (!empty($excludeFiles)) {
         if (!is_array($excludeFiles)) {
             $excludeFiles = array($excludeFiles);
         }
         $this->excludeFiles = array_merge($this->excludeFiles, $excludeFiles);
     }
     // get data for filename
     $data = array('pn' => $this->package['name'], 'pv' => $this->package['version'], 'pr' => 'r' . $this->source->revision, 't' => DateUtil::formatTime('%Y-%m-%d %H:%M:%S', TIME_NOW, false));
     // set archive name
     $this->filename = PackageHelper::getArchiveName($filename, $data);
     // mark package as built
     $buildDirectory = FileUtil::addTrailingSlash($this->source->buildDirectory);
     $location = $buildDirectory . $this->filename;
     PackageHelper::addPackageData($this->package['name'], $location);
     // check requirements
     $this->verifyPackages('requiredpackage', $directory);
     $this->verifyPackages('optionalpackage', $directory);
     // intialize archive
     $location = $this->createArchive($directory, $this->filename, $removeAfter);
     // do not move files created on-the-fly
     if (PackageHelper::isTemporaryFile($location)) {
         $this->location = $location;
         return;
     }
     // register file
     require_once PB_DIR . 'lib/data/source/file/SourceFileEditor.class.php';
     $sourceFile = SourceFileEditor::create($this->source->sourceID, $location, 'package');
     $this->location = $sourceFile->getPath();
 }
예제 #3
0
파일: infos.php 프로젝트: sonicmaster/RPG
    $parse['knockDown'] = '<span><a href="game/index.php?action=BuildingKnockDown&buildingID=' . $gid . '">Abrei&szlig;en</a></span>';
} else {
    if ($gid == 502 && LWCore::getPlanet()->interceptor_misil > 1) {
        $parse['knockDown'] = '<form name="interceptormissileknockdown" action="game/index.php?action=InterceptorMissileKnockDown" method="post">
			<input name="interceptorMissiles" type="text" size="2" /><input type="submit" value="Abfangraketen abrei&szlig;en" />
			</form>';
    } else {
        $parse['knockDown'] = '';
    }
}
// refinery
if ($gid == 13) {
    $page .= '<fieldset>
		<legend>
			Produktion
		</legend><form name="refineryProductionForm" action="game/index.php?action=SetRefineryProduction" method="post">';
    if (LWCore::getPlanet()->refineryProductionChange > time() - 60 * 60 * 48) {
        $page .= '<p class="error">Wechsel erst am ' . DateUtil::formatTime(null, LWCore::getPlanet()->refineryProductionChange + 60 * 60 * 48) . ' möglich!</p>';
    } else {
        $select = '<select name="production" onchange="if(confirm(\'Willst du wirklich die Raffinerie-Produktion festsetzen? Sie lässt sich danach für 48 Stunden nicht mehr verändern!\')) document.forms.refineryProductionForm.submit()">';
        $select .= '<option value="metal"' . (LWCore::getPlanet()->refineryProduction == 'metal' ? ' selected = "selected"' : '') . '>Metall</option>';
        $select .= '<option value="crystal"' . (LWCore::getPlanet()->refineryProduction == 'crystal' ? ' selected = "selected"' : '') . '>Kristall</option>';
        $select .= '<option value="deuterium"' . (LWCore::getPlanet()->refineryProduction == 'deuterium' ? ' selected = "selected"' : '') . '>Deuterium</option>';
        $select .= '</select>';
        $page .= 'Ich möchte mit Hilfe der Raffinerie die ' . $select . '-Produktion steigern.';
    }
    $page .= '</form></fieldset>';
}
$parse['datas'] = $page;
$page = parsetemplate(gettemplate('infos_body'), $parse);
display($page, $lang['Information']);
 /**
  * @see TemplatePluginModifier::execute()
  */
 public function execute($tagArgs, Template $tplObj)
 {
     return DateUtil::formatTime(null, $tagArgs[0], false);
 }
 /**
  * Adds a user to the naval formation.
  * 
  * @param	int		user id
  * @param	LWUser	inviter
  */
 public function addUser($userID, $inviter = null, $sendMessage = true)
 {
     // add
     $sql = "INSERT IGNORE INTO ugml_naval_formation_to_users\n\t\t\t\t(formationID, userID, joinTime)\n\t\t\t\tVALUES\n\t\t\t\t(" . $this->formationID . ", " . $userID . ", " . time() . ")";
     WCF::getDB()->sendQuery($sql);
     // send message
     if ($sendMessage) {
         if ($inviter === null) {
             $inviter = WCF::getUser();
         }
         $subject = WCF::getLanguage()->get('wot.fleet.navalFormation.invite.message.subject');
         $sender = WCF::getLanguage()->get('wot.fleet.navalFormation.invite.message.sender');
         $text = WCF::getLanguage()->get('wot.fleet.navalFormation.invite.message.text', array('$formationName' => $this->formationName, '$impactTime' => DateUtil::formatTime(null, $this->impactTime), '$inviter' => $inviter, '$planet' => $this->getTargetPlanet()));
         require_once LW_DIR . 'lib/data/message/MessageEditor.class.php';
         MessageEditor::create($userID, $subject, $text, 0, $sender, 0);
     }
 }
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     if (!count($_POST)) {
         // default values
         // user
         if ($this->userID) {
             $user = new User($this->userID);
             $this->recipients = $user->username;
         }
         // existing message
         if ($this->pm) {
             if ($this->forwarding) {
                 $data = array('$author' => $this->pm->username ? $this->pm->username : WCF::getLanguage()->get('wcf.pm.author.system'), '$date' => DateUtil::formatTime(null, $this->pm->time), '$recipients' => implode(', ', $this->pm->getRecipients()), '$subject' => $this->pm->subject, '$text' => $this->pm->message);
                 $this->subject = WCF::getLanguage()->get('wcf.pm.forward.subject', array('$subject' => $this->pm->subject));
                 $this->text = WCF::getLanguage()->get('wcf.pm.forward.text', $data);
             } else {
                 if ($this->reply) {
                     $this->subject = WCF::getLanguage()->get('wcf.pm.reply.subject', array('$subject' => $this->pm->subject));
                     // replace RE: RE: RE: by RE[3]:
                     $this->subject = preg_replace('/(^RE: RE\\[)(\\d+)(?=\\]:)/ie', '"RE[".(\\2+1)', $this->subject);
                     $this->subject = preg_replace('/^(RE: RE:(?: RE:)+)/ie', '"RE[".substr_count("\\1", "RE:")."]:"', $this->subject);
                     if ($this->replyToAll == 1) {
                         $recipients = array();
                         foreach ($this->pm->getRecipients() as $recipient) {
                             $recipients[] = $recipient->recipient;
                         }
                         $recipients[] = $this->pm->username;
                         $recipients = array_unique($recipients);
                         foreach ($recipients as $key => $value) {
                             if (StringUtil::toLowerCase($value) == StringUtil::toLowerCase(WCF::getUser()->username)) {
                                 unset($recipients[$key]);
                                 break;
                             }
                         }
                         $this->recipients = implode(', ', $recipients);
                     } else {
                         $this->recipients = $this->pm->username;
                     }
                 } else {
                     // edit draft
                     $sql = "SELECT\t\trecipient, isBlindCopy\n\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\t\tWHERE\t\tpmID = " . $this->pm->pmID . "\n\t\t\t\t\t\tORDER BY\trecipient";
                     $result = WCF::getDB()->sendQuery($sql);
                     while ($row = WCF::getDB()->fetchArray($result)) {
                         if ($row['isBlindCopy']) {
                             if (!empty($this->blindCopies)) {
                                 $this->blindCopies .= ', ';
                             }
                             $this->blindCopies .= $row['recipient'];
                         } else {
                             if (!empty($this->recipients)) {
                                 $this->recipients .= ', ';
                             }
                             $this->recipients .= $row['recipient'];
                         }
                     }
                     $this->subject = $this->pm->subject;
                     $this->text = $this->pm->message;
                     // options
                     $this->enableSmilies = $this->pm->enableSmilies;
                     $this->enableHtml = $this->pm->enableHtml;
                     $this->enableBBCodes = $this->pm->enableBBCodes;
                     $this->showSignature = $this->pm->showSignature;
                 }
             }
         }
     }
     if ($this->reply) {
         require_once WCF_DIR . 'lib/data/message/pm/PMList.class.php';
         $this->pmList = new PMList($this->pm);
         $this->pmList->sqlLimit = 10;
         $this->pmList->readObjects();
     }
 }
 /**
  * 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&amp;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&amp;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;
 }
예제 #8
0
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     // get profile options
     require_once WCF_DIR . 'lib/data/user/option/UserOptions.class.php';
     $userOptions = new UserOptions();
     $this->categories = $userOptions->getOptionTree('profile', $this->frame->getUser());
     // move contact information and about me
     foreach ($this->categories as $category => $categoryData) {
         if ($category == 'profile.contact' || $category == 'profile.messenger') {
             foreach ($categoryData['options'] as $key => $option) {
                 if (isset($option['outputData'])) {
                     $this->contactInformation[] = $option['outputData'];
                 } else {
                     if (!empty($option['optionValue']) && (empty($option['outputClass']) || !$userOptions->getOutputObject($option['outputClass']) instanceof UserOptionOutputContactInformation)) {
                         $this->contactInformation[] = array('icon' => '', 'title' => WCF::getLanguage()->get('wcf.user.option.' . $option['optionName']), 'value' => $option['optionValue'], 'url' => '');
                     }
                 }
             }
             unset($this->categories[$category]);
         }
     }
     // add vcard link
     $this->contactInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('vCardM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.downloadVCard'), 'value' => StringUtil::encodeHTML($this->frame->getUser()->username), 'url' => 'index.php?page=VCard&amp;userID=' . $this->frame->getUserID() . SID_ARG_2ND);
     // add general informations
     // registration date
     $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('registerM.png'), 'title' => WCF::getLanguage()->get('wcf.user.registrationDate'), 'value' => DateUtil::formatTime(null, $this->frame->getUser()->registrationDate));
     // languages
     require_once WCF_DIR . 'lib/acp/form/UserOptionListForm.class.php';
     $languages = array();
     $availableLanguages = UserOptionListForm::getAvailableContentLanguages();
     if (!$this->frame->getUser()->languageIDs) {
         $this->languages = $availableLanguages;
     } else {
         $languageIDs = explode(',', $this->frame->getUser()->languageIDs);
         foreach ($languageIDs as $languageID) {
             if (isset($availableLanguages[$languageID])) {
                 $languages[$languageID] = $availableLanguages[$languageID];
             }
         }
         // sort languages
         StringUtil::sort($languages);
     }
     if (count($languages)) {
         $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('languageM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.languages'), 'value' => implode(', ', $languages));
     }
     // last activity
     if (!$this->frame->getUser()->isOnline() && (!$this->frame->getUser()->invisible || WCF::getUser()->getPermission('admin.general.canViewInvisible')) && $this->frame->getUser()->lastActivityTime != 0) {
         $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('offlineM.png'), 'title' => WCF::getLanguage()->get('wcf.user.lastActivity'), 'value' => DateUtil::formatTime(null, $this->frame->getUser()->lastActivityTime, true));
     }
     // profile visits
     WCF::getTPL()->assign('user', $this->frame->getUser());
     $this->generalInformation[] = array('icon' => StyleManager::getStyle()->getIconPath('visitsM.png'), 'title' => WCF::getLanguage()->get('wcf.user.profile.hits'), 'value' => StringUtil::formatNumeric($this->frame->getUser()->profileHits) . ($this->frame->getUser()->getProfileAge() > 1 ? ' ' . WCF::getLanguage()->getDynamicVariable('wcf.user.profile.hitsPerDay') : ''));
     // get profile visitors
     $sql = "SELECT\t\tavatar.*, user_table.*, visitor.*\n\t\t\tFROM\t\twcf" . WCF_N . "_user_profile_visitor visitor\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user_table\n\t\t\tON \t\t(user_table.userID = visitor.userID)\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_avatar avatar\n\t\t\tON \t\t(avatar.avatarID = user_table.avatarID)\n\t\t\tWHERE\t\townerID = " . $this->frame->getUserID() . "\n\t\t\t\t\tAND user_table.userID IS NOT NULL\n\t\t\tORDER BY\ttime DESC";
     $result = WCF::getDB()->sendQuery($sql, 5);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->profileVisitors[] = new UserProfile(null, $row);
     }
     // friends
     if (MODULE_MEMBERS_LIST == 1 && $this->frame->getUser()->shareWhitelist) {
         $sql = "SELECT\t\tavatar.*, user_table.*\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user_whitelist friends\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_user user_table\n\t\t\t\tON \t\t(user_table.userID = friends.whiteUserID)\n\t\t\t\tLEFT JOIN \twcf" . WCF_N . "_avatar avatar\n\t\t\t\tON \t\t(avatar.avatarID = user_table.avatarID)\n\t\t\t\tWHERE\t\tfriends.userID = " . $this->frame->getUserID() . "\n\t\t\t\t\t\tAND confirmed = 1\n\t\t\t\t\t\tAND user_table.userID IS NOT NULL\n\t\t\t\tORDER BY\tfriends.time DESC";
         $result = WCF::getDB()->sendQuery($sql, 5);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $this->friends[] = new UserProfile(null, $row);
         }
     }
 }
예제 #9
0
 /**
  * Starts the download of the specified messages.
  * 
  * @param	string		$pmIDs
  */
 public static function downloadAll($pmIDs)
 {
     // count messages
     $sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_pm\n\t\t\tWHERE\tpmID IN (" . $pmIDs . ")";
     $row = WCF::getDB()->getFirstRow($sql);
     $count = $row['count'];
     // get recipients
     $recpients = array();
     $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_pm_to_user\n\t\t\tWHERE\t\tpmID IN (" . $pmIDs . ")\n\t\t\t\t\tAND isBlindCopy = 0\n\t\t\tORDER BY\trecipient";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         if (!isset($recpients[$row['pmID']])) {
             $recpients[$row['pmID']] = array();
         }
         $recpients[$row['pmID']][] = new PMRecipient(null, null, $row);
     }
     // get messages
     if ($count > 1) {
         $zip = new ZipWriter();
     }
     $sql = "SELECT\t\trecipient.*,\n\t\t\t\t\tpm.*\n\t\t\tFROM\t\twcf" . WCF_N . "_pm pm\n\t\t\tLEFT JOIN \twcf" . WCF_N . "_pm_to_user recipient\n\t\t\tON \t\t(recipient.pmID = pm.pmID\n\t\t\t\t\tAND recipient.recipientID = " . WCF::getUser()->userID . "\n\t\t\t\t\tAND recipient.isDeleted < 2)\n\t\t\tWHERE\t\tpm.pmID IN (" . $pmIDs . ")\n\t\t\tGROUP BY\tpm.pmID\n\t\t\tORDER BY\tpm.time DESC";
     $result = WCF::getDB()->sendQuery($sql);
     $messageNo = 1;
     while ($row = WCF::getDB()->fetchArray($result)) {
         $pm = new PM(null, $row);
         $pm->setRecipients(isset($recpients[$row['pmID']]) ? $recpients[$row['pmID']] : array());
         // get parsed text
         require_once WCF_DIR . 'lib/data/message/bbcode/MessageParser.class.php';
         $parser = MessageParser::getInstance();
         $parser->setOutputType('text/plain');
         $parsedText = $parser->parse($pm->message, $pm->enableSmilies, $pm->enableHtml, $pm->enableBBCodes, false);
         $data = array('$author' => $pm->username ? $pm->username : WCF::getLanguage()->get('wcf.pm.author.system'), '$date' => DateUtil::formatTime(null, $pm->time), '$recipient' => implode(', ', $pm->getRecipients()), '$subject' => $pm->subject, '$text' => $parsedText);
         if ($count == 1) {
             // send headers
             // file type
             @header('Content-Type: text/plain');
             // file name
             @header('Content-disposition: attachment; filename="' . $pm->pmID . '-' . preg_replace('~[^a-z0-9_ -]+~i', '', $pm->subject) . '.txt"');
             // no cache headers
             @header('Pragma: no-cache');
             @header('Expires: 0');
             // output message
             echo (CHARSET == 'UTF-8' ? "" : '') . WCF::getLanguage()->get('wcf.pm.download.message', $data);
             exit;
         } else {
             $zip->addFile((CHARSET == 'UTF-8' ? "" : '') . WCF::getLanguage()->get('wcf.pm.download.message', $data), $pm->pmID . '-' . preg_replace('~[^a-z0-9_ -]+~i', '', $pm->subject) . '.txt', $pm->time);
         }
         $messageNo++;
     }
     if ($messageNo > 1) {
         // send headers
         // file type
         @header('Content-Type: application/octet-stream');
         // file name
         @header('Content-disposition: attachment; filename="messages-' . ($messageNo - 1) . '.zip"');
         // no cache headers
         @header('Pragma: no-cache');
         @header('Expires: 0');
         // output file
         echo $zip->getFile();
         exit;
     }
 }
 /**
  * Builds any combination of archive names
  *
  * @param	string	$pattern
  */
 protected function generateArchiveName($pattern)
 {
     // recursively call method if pattern is an array
     if (is_array($pattern)) {
         foreach ($pattern as $filename) {
             if (!$filename) {
                 continue;
             }
             $this->generateArchiveName($filename);
         }
         return;
     }
     // dummy values
     if ($this->currentDirectory === null || !isset($this->packages[$this->currentDirectory])) {
         $data = array('pn' => 'packageName', 'pv' => 'packageVersion', 'pr' => 'r' . $this->source->revision, 't' => DateUtil::formatTime('%Y-%m-%d %H:%M:%S', TIME_NOW, false));
     } else {
         $data = array('pn' => $this->packages[$this->currentDirectory]['packageName'], 'pv' => $this->packages[$this->currentDirectory]['version'], 'pr' => 'r' . $this->source->revision, 't' => DateUtil::formatTime('%Y-%m-%d %H:%M:%S', TIME_NOW, false));
     }
     // get filename
     $this->filenames[$pattern] = PackageHelper::getArchiveName($pattern, $data);
 }