• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP phutil_units函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中phutil_units函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_units函数的具体用法?PHP phutil_units怎么用?PHP phutil_units使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了phutil_units函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $viewer = $this->getViewer();
     $since = PhabricatorTime::getNow() - phutil_units('30 days in seconds');
     $until = PhabricatorTime::getNow();
     $mails = id(new PhabricatorMetaMTAMailQuery())->setViewer($viewer)->withDateCreatedBetween($since, $until)->execute();
     $unfiltered = array();
     foreach ($mails as $mail) {
         $unfiltered_actors = mpull($mail->loadAllActors(), 'getPHID');
         foreach ($unfiltered_actors as $phid) {
             if (empty($unfiltered[$phid])) {
                 $unfiltered[$phid] = 0;
             }
             $unfiltered[$phid]++;
         }
     }
     arsort($unfiltered);
     $table = id(new PhutilConsoleTable())->setBorders(true)->addColumn('user', array('title' => pht('User')))->addColumn('unfiltered', array('title' => pht('Unfiltered')));
     $handles = $viewer->loadHandles(array_keys($unfiltered));
     $names = mpull(iterator_to_array($handles), 'getName', 'getPHID');
     foreach ($unfiltered as $phid => $count) {
         $table->addRow(array('user' => idx($names, $phid), 'unfiltered' => $count));
     }
     $table->draw();
     echo "\n";
     echo pht('Mail sent in the last 30 days.') . "\n";
     echo pht('"Unfiltered" is raw volume before preferences were applied.') . "\n";
     echo "\n";
     return 0;
 }
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:31,代码来源:PhabricatorMailManagementVolumeWorkflow.php


示例2: renderModuleStatus

 public function renderModuleStatus(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $collectors = PhabricatorGarbageCollector::getAllCollectors();
     $collectors = msort($collectors, 'getCollectorConstant');
     $rows = array();
     $rowc = array();
     foreach ($collectors as $key => $collector) {
         $class = null;
         if ($collector->hasAutomaticPolicy()) {
             $policy_view = phutil_tag('em', array(), pht('Automatic'));
         } else {
             $policy = $collector->getRetentionPolicy();
             if ($policy === null) {
                 $policy_view = pht('Indefinite');
             } else {
                 $days = ceil($policy / phutil_units('1 day in seconds'));
                 $policy_view = pht('%s Day(s)', new PhutilNumber($days));
             }
             $default = $collector->getDefaultRetentionPolicy();
             if ($policy !== $default) {
                 $class = 'highlighted';
                 $policy_view = phutil_tag('strong', array(), $policy_view);
             }
         }
         $rowc[] = $class;
         $rows[] = array($collector->getCollectorConstant(), $collector->getCollectorName(), $policy_view);
     }
     $table = id(new AphrontTableView($rows))->setRowClasses($rowc)->setHeaders(array(pht('Constant'), pht('Name'), pht('Retention Policy')))->setColumnClasses(array(null, 'pri wide', null));
     $header = id(new PHUIHeaderView())->setHeader(pht('Garbage Collectors'))->setSubheader(pht('Collectors with custom policies are highlighted. Use ' . '%s to change retention policies.', phutil_tag('tt', array(), 'bin/garbage set-policy')));
     return id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
 }
开发者ID:pugong,项目名称:phabricator,代码行数:32,代码来源:PhabricatorConfigCollectorsModule.php


示例3: executeQuery

 protected final function executeQuery()
 {
     $future = $this->newQueryFuture();
     $drequest = $this->getRequest();
     $name = basename($drequest->getPath());
     $ttl = PhabricatorTime::getNow() + phutil_units('48 hours in seconds');
     try {
         $threshold = PhabricatorFileStorageEngine::getChunkThreshold();
         $future->setReadBufferSize($threshold);
         $source = id(new PhabricatorExecFutureFileUploadSource())->setName($name)->setTTL($ttl)->setViewPolicy(PhabricatorPolicies::POLICY_NOONE)->setExecFuture($future);
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         $file = $source->uploadFile();
         unset($unguarded);
     } catch (CommandException $ex) {
         if (!$future->getWasKilledByTimeout()) {
             throw $ex;
         }
         $this->didHitTimeLimit = true;
         $file = null;
     }
     $byte_limit = $this->getByteLimit();
     if ($byte_limit && $file->getByteSize() > $byte_limit) {
         $this->didHitByteLimit = true;
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         id(new PhabricatorDestructionEngine())->destroyObject($file);
         unset($unguarded);
         $file = null;
     }
     return $file;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:30,代码来源:DiffusionFileFutureQuery.php


示例4: collectGarbage

 public function collectGarbage()
 {
     $ttl = phutil_units('90 days in seconds');
     $table = new MultimeterEvent();
     $conn_w = $table->establishConnection('w');
     queryfx($conn_w, 'DELETE FROM %T WHERE epoch < %d LIMIT 100', $table->getTableName(), PhabricatorTime::getNow() - $ttl);
     return $conn_w->getAffectedRows() == 100;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:8,代码来源:MultimeterEventGarbageCollector.php


示例5: collectGarbage

 public function collectGarbage()
 {
     $ttl = phutil_units('90 days in seconds');
     $table = new PhabricatorMetaMTAMail();
     $conn_w = $table->establishConnection('w');
     queryfx($conn_w, 'DELETE FROM %T WHERE dateCreated < %d LIMIT 100', $table->getTableName(), time() - $ttl);
     return $conn_w->getAffectedRows() == 100;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:8,代码来源:MetaMTAMailSentGarbageCollector.php


示例6: collectGarbage

 public function collectGarbage()
 {
     $ttl = phutil_units('3 days in seconds');
     $table = new PhabricatorSystemActionLog();
     $conn_w = $table->establishConnection('w');
     queryfx($conn_w, 'DELETE FROM %T WHERE epoch < %d LIMIT 100', $table->getTableName(), time() - $ttl);
     return $conn_w->getAffectedRows() == 100;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:8,代码来源:PhabricatorSystemActionGarbageCollector.php


示例7: collectGarbage

 public function collectGarbage()
 {
     $ttl = phutil_units('90 days in seconds');
     $mails = id(new PhabricatorMetaMTAMail())->loadAllWhere('dateCreated < %d LIMIT 100', PhabricatorTime::getNow() - $ttl);
     foreach ($mails as $mail) {
         $mail->delete();
     }
     return count($mails) == 100;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:9,代码来源:MetaMTAMailSentGarbageCollector.php


示例8: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $viewer = $this->getViewer();
     $days = (int) $args->getArg('days');
     if ($days < 1) {
         throw new PhutilArgumentUsageException(pht('Period specified with --days must be at least 1.'));
     }
     $duration = phutil_units("{$days} days in seconds");
     $since = PhabricatorTime::getNow() - $duration;
     $until = PhabricatorTime::getNow();
     $mails = id(new PhabricatorMetaMTAMailQuery())->setViewer($viewer)->withDateCreatedBetween($since, $until)->execute();
     $unfiltered = array();
     $delivered = array();
     foreach ($mails as $mail) {
         // Count messages we attempted to deliver. This includes messages which
         // were voided by preferences or other rules.
         $unfiltered_actors = mpull($mail->loadAllActors(), 'getPHID');
         foreach ($unfiltered_actors as $phid) {
             if (empty($unfiltered[$phid])) {
                 $unfiltered[$phid] = 0;
             }
             $unfiltered[$phid]++;
         }
         // Now, count mail we actually delivered.
         $result = $mail->getDeliveredActors();
         if ($result) {
             foreach ($result as $actor_phid => $actor_info) {
                 if (!$actor_info['deliverable']) {
                     continue;
                 }
                 if (empty($delivered[$actor_phid])) {
                     $delivered[$actor_phid] = 0;
                 }
                 $delivered[$actor_phid]++;
             }
         }
     }
     // Sort users by delivered mail, then unfiltered mail.
     arsort($delivered);
     arsort($unfiltered);
     $delivered = $delivered + array_fill_keys(array_keys($unfiltered), 0);
     $table = id(new PhutilConsoleTable())->setBorders(true)->addColumn('user', array('title' => pht('User')))->addColumn('unfiltered', array('title' => pht('Unfiltered')))->addColumn('delivered', array('title' => pht('Delivered')));
     $handles = $viewer->loadHandles(array_keys($unfiltered));
     $names = mpull(iterator_to_array($handles), 'getName', 'getPHID');
     foreach ($delivered as $phid => $delivered_count) {
         $unfiltered_count = idx($unfiltered, $phid, 0);
         $table->addRow(array('user' => idx($names, $phid), 'unfiltered' => $unfiltered_count, 'delivered' => $delivered_count));
     }
     $table->draw();
     echo "\n";
     echo pht('Mail sent in the last %s day(s).', new PhutilNumber($days)) . "\n";
     echo pht('"Unfiltered" is raw volume before rules applied.') . "\n";
     echo pht('"Delivered" shows email actually sent.') . "\n";
     echo "\n";
     return 0;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:57,代码来源:PhabricatorMailManagementVolumeWorkflow.php


示例9: newHTTPAuthorization

 public static function newHTTPAuthorization(PhabricatorRepository $repository, PhabricatorUser $viewer, $operation)
 {
     $lfs_user = self::HTTP_USERNAME;
     $lfs_pass = Filesystem::readRandomCharacters(32);
     $lfs_hash = PhabricatorHash::digest($lfs_pass);
     $ttl = PhabricatorTime::getNow() + phutil_units('1 day in seconds');
     $token = id(new PhabricatorAuthTemporaryToken())->setTokenResource($repository->getPHID())->setTokenType(self::TOKENTYPE)->setTokenCode($lfs_hash)->setUserPHID($viewer->getPHID())->setTemporaryTokenProperty('lfs.operation', $operation)->setTokenExpires($ttl)->save();
     $authorization_header = base64_encode($lfs_user . ':' . $lfs_pass);
     return 'Basic ' . $authorization_header;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:10,代码来源:DiffusionGitLFSTemporaryTokenType.php


示例10: execute

 public function execute(PhutilArgumentParser $args)
 {
     $viewer = $this->getViewer();
     $engine = new PhabricatorCalendarNotificationEngine();
     $minutes = $args->getArg('minutes');
     if ($minutes) {
         $engine->setNotifyWindow(phutil_units("{$minutes} minutes in seconds"));
     }
     $engine->publishNotifications();
     return 0;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:11,代码来源:PhabricatorCalendarManagementNotifyWorkflow.php


示例11: testICSDuration

 public function testICSDuration()
 {
     $event = $this->parseICSSingleEvent('duration.ics');
     // Raw value is "20160719T095722Z".
     $start_epoch = strtotime('2016-07-19 09:57:22 UTC');
     $this->assertEqual(1468922242, $start_epoch);
     // Raw value is "P1DT17H4M23S".
     $duration = phutil_units('1 day in seconds') + phutil_units('17 hours in seconds') + phutil_units('4 minutes in seconds') + phutil_units('23 seconds in seconds');
     $this->assertEqual($start_epoch, $event->getStartDateTime()->getEpoch());
     $this->assertEqual($start_epoch + $duration, $event->getEndDateTime()->getEpoch());
 }
开发者ID:endlessm,项目名称:libphutil,代码行数:11,代码来源:PhutilICSParserTestCase.php


示例12: getSessionTypeTTL

 public static function getSessionTypeTTL($session_type)
 {
     switch ($session_type) {
         case self::TYPE_WEB:
             return phutil_units('30 days in seconds');
         case self::TYPE_CONDUIT:
             return phutil_units('24 hours in seconds');
         default:
             throw new Exception(pht('Unknown session type "%s".', $session_type));
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:11,代码来源:PhabricatorAuthSession.php


示例13: processAddFactorForm

 public function processAddFactorForm(AphrontFormView $form, AphrontRequest $request, PhabricatorUser $user)
 {
     $totp_token_type = PhabricatorAuthTOTPKeyTemporaryTokenType::TOKENTYPE;
     $key = $request->getStr('totpkey');
     if (strlen($key)) {
         // If the user is providing a key, make sure it's a key we generated.
         // This raises the barrier to theoretical attacks where an attacker might
         // provide a known key (such attacks are already prevented by CSRF, but
         // this is a second barrier to overcome).
         // (We store and verify the hash of the key, not the key itself, to limit
         // how useful the data in the table is to an attacker.)
         $temporary_token = id(new PhabricatorAuthTemporaryTokenQuery())->setViewer($user)->withTokenResources(array($user->getPHID()))->withTokenTypes(array($totp_token_type))->withExpired(false)->withTokenCodes(array(PhabricatorHash::digest($key)))->executeOne();
         if (!$temporary_token) {
             // If we don't have a matching token, regenerate the key below.
             $key = null;
         }
     }
     if (!strlen($key)) {
         $key = self::generateNewTOTPKey();
         // Mark this key as one we generated, so the user is allowed to submit
         // a response for it.
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         id(new PhabricatorAuthTemporaryToken())->setTokenResource($user->getPHID())->setTokenType($totp_token_type)->setTokenExpires(time() + phutil_units('1 hour in seconds'))->setTokenCode(PhabricatorHash::digest($key))->save();
         unset($unguarded);
     }
     $code = $request->getStr('totpcode');
     $e_code = true;
     if ($request->getExists('totp')) {
         $okay = self::verifyTOTPCode($user, new PhutilOpaqueEnvelope($key), $code);
         if ($okay) {
             $config = $this->newConfigForUser($user)->setFactorName(pht('Mobile App (TOTP)'))->setFactorSecret($key);
             return $config;
         } else {
             if (!strlen($code)) {
                 $e_code = pht('Required');
             } else {
                 $e_code = pht('Invalid');
             }
         }
     }
     $form->addHiddenInput('totp', true);
     $form->addHiddenInput('totpkey', $key);
     $form->appendRemarkupInstructions(pht('First, download an authenticator application on your phone. Two ' . 'applications which work well are **Authy** and **Google ' . 'Authenticator**, but any other TOTP application should also work.'));
     $form->appendInstructions(pht('Launch the application on your phone, and add a new entry for ' . 'this Phabricator install. When prompted, scan the QR code or ' . 'manually enter the key shown below into the application.'));
     $prod_uri = new PhutilURI(PhabricatorEnv::getProductionURI('/'));
     $issuer = $prod_uri->getDomain();
     $uri = urisprintf('otpauth://totp/%s:%s?secret=%s&issuer=%s', $issuer, $user->getUsername(), $key, $issuer);
     $qrcode = $this->renderQRCode($uri);
     $form->appendChild($qrcode);
     $form->appendChild(id(new AphrontFormStaticControl())->setLabel(pht('Key'))->setValue(phutil_tag('strong', array(), $key)));
     $form->appendInstructions(pht('(If given an option, select that this key is "Time Based", not ' . '"Counter Based".)'));
     $form->appendInstructions(pht('After entering the key, the application should display a numeric ' . 'code. Enter that code below to confirm that you have configured ' . 'the authenticator correctly:'));
     $form->appendChild(id(new PHUIFormNumberControl())->setLabel(pht('TOTP Code'))->setName('totpcode')->setValue($code)->setError($e_code));
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:54,代码来源:PhabricatorTOTPAuthFactor.php


示例14: newFile

 private function newFile(DiffusionRequest $drequest, $content)
 {
     $path = $drequest->getPath();
     $name = basename($path);
     $repository = $drequest->getRepository();
     $repository_phid = $repository->getPHID();
     $file = PhabricatorFile::buildFromFileDataOrHash($content, array('name' => $name, 'ttl' => time() + phutil_units('48 hours in seconds'), 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE));
     $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
     $file->attachToObject($repository_phid);
     unset($unguarded);
     return $file;
 }
开发者ID:modernfactory,项目名称:phabricator,代码行数:12,代码来源:DiffusionFileContentQueryConduitAPIMethod.php


示例15: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $show_prototypes = PhabricatorEnv::getEnvConfig('phabricator.show-prototypes');
     if (!$show_prototypes) {
         throw new Exception(pht('Show prototypes is disabled.
       Set `phabricator.show-prototypes` to `true` to use the image proxy'));
     }
     $viewer = $request->getViewer();
     $img_uri = $request->getStr('uri');
     // Validate the URI before doing anything
     PhabricatorEnv::requireValidRemoteURIForLink($img_uri);
     $uri = new PhutilURI($img_uri);
     $proto = $uri->getProtocol();
     if (!in_array($proto, array('http', 'https'))) {
         throw new Exception(pht('The provided image URI must be either http or https'));
     }
     // Check if we already have the specified image URI downloaded
     $cached_request = id(new PhabricatorFileExternalRequest())->loadOneWhere('uriIndex = %s', PhabricatorHash::digestForIndex($img_uri));
     if ($cached_request) {
         return $this->getExternalResponse($cached_request);
     }
     $ttl = PhabricatorTime::getNow() + phutil_units('7 days in seconds');
     $external_request = id(new PhabricatorFileExternalRequest())->setURI($img_uri)->setTTL($ttl);
     $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
     // Cache missed so we'll need to validate and download the image
     try {
         // Rate limit outbound fetches to make this mechanism less useful for
         // scanning networks and ports.
         PhabricatorSystemActionEngine::willTakeAction(array($viewer->getPHID()), new PhabricatorFilesOutboundRequestAction(), 1);
         $file = PhabricatorFile::newFromFileDownload($uri, array('viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 'canCDN' => true));
         if (!$file->isViewableImage()) {
             $mime_type = $file->getMimeType();
             $engine = new PhabricatorDestructionEngine();
             $engine->destroyObject($file);
             $file = null;
             throw new Exception(pht('The URI "%s" does not correspond to a valid image file, got ' . 'a file with MIME type "%s". You must specify the URI of a ' . 'valid image file.', $uri, $mime_type));
         } else {
             $file->save();
         }
         $external_request->setIsSuccessful(true)->setFilePHID($file->getPHID())->save();
         unset($unguarded);
         return $this->getExternalResponse($external_request);
     } catch (HTTPFutureHTTPResponseStatus $status) {
         $external_request->setIsSuccessful(false)->setResponseMessage($status->getMessage())->save();
         return $this->getExternalResponse($external_request);
     } catch (Exception $ex) {
         // Not actually saving the request in this case
         $external_request->setResponseMessage($ex->getMessage());
         return $this->getExternalResponse($external_request);
     }
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:51,代码来源:PhabricatorFileImageProxyController.php


示例16: getTokenExpires

 private function getTokenExpires($token_type)
 {
     $now = PhabricatorTime::getNow();
     switch ($token_type) {
         case self::TYPE_STANDARD:
             return null;
         case self::TYPE_COMMANDLINE:
             return $now + phutil_units('1 hour in seconds');
         case self::TYPE_CLUSTER:
             return $now + phutil_units('30 minutes in seconds');
         default:
             throw new Exception(pht('Unknown Conduit token type "%s"!', $token_type));
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:14,代码来源:PhabricatorConduitToken.php


示例17: execute

 public function execute(PhutilArgumentParser $args)
 {
     $config_key = 'phd.garbage-collection';
     $collector = $this->getCollector($args->getArg('collector'));
     $days = $args->getArg('days');
     $indefinite = $args->getArg('indefinite');
     $default = $args->getArg('default');
     $count = 0;
     if ($days !== null) {
         $count++;
     }
     if ($indefinite) {
         $count++;
     }
     if ($default) {
         $count++;
     }
     if (!$count) {
         throw new PhutilArgumentUsageException(pht('Choose a policy with "%s", "%s" or "%s".', '--days', '--indefinite', '--default'));
     }
     if ($count > 1) {
         throw new PhutilArgumentUsageException(pht('Options "%s", "%s" and "%s" represent mutually exclusive ways ' . 'to choose a policy. Specify only one.', '--days', '--indefinite', '--default'));
     }
     if ($days !== null) {
         $days = (int) $days;
         if ($days < 1) {
             throw new PhutilArgumentUsageException(pht('Specify a positive number of days to retain data for.'));
         }
     }
     $collector_const = $collector->getCollectorConstant();
     $value = PhabricatorEnv::getEnvConfig($config_key);
     if ($days !== null) {
         echo tsprintf("%s\n", pht('Setting retention policy for "%s" to %s day(s).', $collector->getCollectorName(), new PhutilNumber($days)));
         $value[$collector_const] = phutil_units($days . ' days in seconds');
     } else {
         if ($indefinite) {
             echo tsprintf("%s\n", pht('Setting "%s" to be retained indefinitely.', $collector->getCollectorName()));
             $value[$collector_const] = null;
         } else {
             echo tsprintf("%s\n", pht('Restoring "%s" to the default retention policy.', $collector->getCollectorName()));
             unset($value[$collector_const]);
         }
     }
     id(new PhabricatorConfigLocalSource())->setKeys(array($config_key => $value));
     echo tsprintf("%s\n", pht('Wrote new policy to local configuration.'));
     echo tsprintf("%s\n", pht('This change will take effect the next time the daemons are ' . 'restarted.'));
     return 0;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:48,代码来源:PhabricatorGarbageCollectorManagementSetPolicyWorkflow.php


示例18: processRequest

 public function processRequest()
 {
     $out = array();
     // Prevent indexing of '/diffusion/', since the content is not generally
     // useful to index, web spiders get stuck scraping the history of every
     // file, and much of the content is Ajaxed in anyway so spiders won't even
     // see it. These pages are also relatively expensive to generate.
     // Note that this still allows commits (at '/rPxxxxx') to be indexed.
     // They're probably not hugely useful, but suffer fewer of the problems
     // Diffusion suffers and are hard to omit with 'robots.txt'.
     $out[] = 'User-Agent: *';
     $out[] = 'Disallow: /diffusion/';
     // Add a small crawl delay (number of seconds between requests) for spiders
     // which respect it. The intent here is to prevent spiders from affecting
     // performance for users. The possible cost is slower indexing, but that
     // seems like a reasonable tradeoff, since most Phabricator installs are
     // probably not hugely concerned about cutting-edge SEO.
     $out[] = 'Crawl-delay: 1';
     $content = implode("\n", $out) . "\n";
     return id(new AphrontPlainTextResponse())->setContent($content)->setCacheDurationInSeconds(phutil_units('2 hours in seconds'));
 }
开发者ID:barcelonascience,项目名称:phabricator,代码行数:21,代码来源:PhabricatorRobotsController.php


示例19: getHeaders

 public function getHeaders()
 {
     $headers = array();
     if (!$this->frameable) {
         $headers[] = array('X-Frame-Options', 'Deny');
     }
     if ($this->getRequest() && $this->getRequest()->isHTTPS()) {
         $hsts_key = 'security.strict-transport-security';
         $use_hsts = PhabricatorEnv::getEnvConfig($hsts_key);
         if ($use_hsts) {
             $duration = phutil_units('365 days in seconds');
         } else {
             // If HSTS has been disabled, tell browsers to turn it off. This may
             // not be effective because we can only disable it over a valid HTTPS
             // connection, but it best represents the configured intent.
             $duration = 0;
         }
         $headers[] = array('Strict-Transport-Security', "max-age={$duration}; includeSubdomains; preload");
     }
     return $headers;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:21,代码来源:AphrontResponse.php


示例20: run

 public function run()
 {
     $is_temporary = $this->getArgument('temporary');
     $conduit = $this->getConduit();
     $results = array();
     $uploader = id(new ArcanistFileUploader())->setConduitClient($conduit);
     foreach ($this->paths as $key => $path) {
         $file = id(new ArcanistFileDataRef())->setName(basename($path))->setPath($path);
         if ($is_temporary) {
             $expires_at = time() + phutil_units('24 hours in seconds');
             $file->setDeleteAfterEpoch($expires_at);
         }
         $uploader->addFile($file);
     }
     $files = $uploader->uploadFiles();
     $results = array();
     foreach ($files as $file) {
         // TODO: This could be handled more gracefully; just preserving behavior
         // until we introduce `file.query` and modernize this.
         if ($file->getErrors()) {
             throw new Exception(implode("\n", $file->getErrors()));
         }
         $phid = $file->getPHID();
         $name = $file->getName();
         $info = $conduit->callMethodSynchronous('file.info', array('phid' => $phid));
         $results[$path] = $info;
         if (!$this->json) {
             $id = $info['id'];
             echo "  F{$id} {$name}: " . $info['uri'] . "\n\n";
         }
     }
     if ($this->json) {
         echo json_encode($results) . "\n";
     } else {
         $this->writeStatus(pht('Done.'));
     }
     return 0;
 }
开发者ID:noikiy,项目名称:arcanist,代码行数:38,代码来源:ArcanistUploadWorkflow.php



注:本文中的phutil_units函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP phutil_utf8_convert函数代码示例发布时间:2022-05-15
下一篇:
PHP phutil_tag_div函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap