本文整理汇总了PHP中Filesystem::readRandomCharacters方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::readRandomCharacters方法的具体用法?PHP Filesystem::readRandomCharacters怎么用?PHP Filesystem::readRandomCharacters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filesystem
的用法示例。
在下文中一共展示了Filesystem::readRandomCharacters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeAcquireLease
public function executeAcquireLease(DrydockResource $resource, DrydockLease $lease)
{
$key = Filesystem::readRandomCharacters(12);
$ports = $resource->getAttribute('ports', array());
for ($ii = 2000;; $ii++) {
if (empty($ports[$ii])) {
$ports[$ii] = $lease->getID();
$port = $ii;
break;
}
}
$resource->setAttribute('ports', $ports);
$resource->save();
$host = $resource->getAttribute('host');
$lease->setAttribute('port', $port);
$lease->setAttribute('key', $key);
$lease->save();
$config = <<<EOCONFIG
Listen *:{$port}
<VirtualHost *:{$port}>
DocumentRoot /opt/drydock/webroot/{$key}/
ServerName {$host}
</VirtualHost>
EOCONFIG;
$cmd = $this->getInterface($resource, $lease, 'command');
$cmd->execx(<<<EOSETUP
sudo mkdir -p %s &&
sudo sh -c %s &&
sudo /etc/init.d/httpd restart
EOSETUP
, "/opt/drydock/webroot/{$key}/", csprintf('echo %s > %s', $config, "/etc/httpd/conf.d/drydock-{$key}.conf"));
$lease->setAttribute('uri', "http://{$host}:{$port}/");
$lease->save();
}
示例2: save
public function save()
{
if (!$this->verificationCode) {
$this->setVerificationCode(Filesystem::readRandomCharacters(24));
}
return parent::save();
}
示例3: save
public function save()
{
if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20);
}
return parent::save();
}
示例4: writeFile
/**
* Writes file data into Amazon S3.
*/
public function writeFile($data, array $params)
{
$s3 = $this->newS3API();
// Generate a random name for this file. We add some directories to it
// (e.g. 'abcdef123456' becomes 'ab/cd/ef123456') to make large numbers of
// files more browsable with web/debugging tools like the S3 administration
// tool.
$seed = Filesystem::readRandomCharacters(20);
$parts = array();
$parts[] = 'phabricator';
$instance_name = PhabricatorEnv::getEnvConfig('cluster.instance');
if (strlen($instance_name)) {
$parts[] = $instance_name;
}
$parts[] = substr($seed, 0, 2);
$parts[] = substr($seed, 2, 2);
$parts[] = substr($seed, 4);
$name = implode('/', $parts);
AphrontWriteGuard::willWrite();
$profiler = PhutilServiceProfiler::getInstance();
$call_id = $profiler->beginServiceCall(array('type' => 's3', 'method' => 'putObject'));
$s3->setParametersForPutObject($name, $data)->resolve();
$profiler->endServiceCall($call_id, array());
return $name;
}
示例5: save
public function save()
{
if (!$this->getAccountSecret()) {
$this->setAccountSecret(Filesystem::readRandomCharacters(32));
}
return parent::save();
}
示例6: save
public function save()
{
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
}
return parent::save();
}
示例7: initializeNewSMS
public static function initializeNewSMS($body)
{
// NOTE: these values will be updated to correct values when the
// SMS is sent for the first time. In particular, the ProviderShortName
// and ProviderSMSID are totally garbage data before a send it attempted.
return id(new PhabricatorSMS())->setBody($body)->setSendStatus(PhabricatorSMS::STATUS_UNSENT)->setProviderShortName(PhabricatorSMS::SHORTNAME_PLACEHOLDER)->setProviderSMSID(Filesystem::readRandomCharacters(40));
}
示例8: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
id(new PhabricatorAuthSessionEngine())->requireHighSecuritySession($viewer, $this->getRequest(), '/');
// Ideally we'd like to verify this, but it's fine to leave it unguarded
// for now and verifying it would need some Ajax junk or for the user to
// click a button or similar.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$old_token = id(new PhabricatorConduitCertificateToken())->loadOneWhere('userPHID = %s', $viewer->getPHID());
if ($old_token) {
$old_token->delete();
}
$token = id(new PhabricatorConduitCertificateToken())->setUserPHID($viewer->getPHID())->setToken(Filesystem::readRandomCharacters(40))->save();
unset($unguarded);
$pre_instructions = pht('Copy and paste this token into the prompt given to you by ' . '`arc install-certificate`');
$post_instructions = pht('After you copy and paste this token, `arc` will complete ' . 'the certificate install process for you.');
Javelin::initBehavior('select-on-click');
$form = id(new AphrontFormView())->setUser($viewer)->appendRemarkupInstructions($pre_instructions)->appendChild(id(new AphrontFormTextAreaControl())->setLabel(pht('Token'))->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setReadonly(true)->setSigil('select-on-click')->setValue($token->getToken()))->appendRemarkupInstructions($post_instructions);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Install Certificate'));
$crumbs->setBorder(true);
$object_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Certificate Token'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
$title = pht('Certificate Install Token');
$header = id(new PHUIHeaderView())->setHeader($title);
$view = id(new PHUITwoColumnView())->setHeader($header)->setFooter($object_box);
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
}
示例9: writeFile
/**
* Write file data into S3.
* @task impl
*/
public function writeFile($data, array $params)
{
$s3 = $this->newS3API();
$name = 'phabricator/' . Filesystem::readRandomCharacters(20);
AphrontWriteGuard::willWrite();
$s3->putObject($data, $this->getBucketName(), $name, $acl = 'private');
return $name;
}
示例10: generateNewPHID
public static function generateNewPHID($type)
{
if (!$type) {
throw new Exception("Can not generate PHID with no type.");
}
$uniq = Filesystem::readRandomCharacters(20);
return 'PHID-' . $type . '-' . $uniq;
}
示例11: save
public function save()
{
AlmanacNames::validateName($this->getName());
$this->nameIndex = PhabricatorHash::digestForIndex($this->getName());
if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20);
}
return parent::save();
}
示例12: generateTestFile
private function generateTestFile(PhabricatorUser $actor)
{
$engine = new PhabricatorTestStorageEngine();
$data = Filesystem::readRandomCharacters(64);
$params = array('name' => 'test.' . $actor->getPHID(), 'viewPolicy' => $actor->getPHID(), 'authorPHID' => $actor->getPHID(), 'storageEngines' => array($engine));
$file = PhabricatorFile::newFromFileData($data, $params);
$file->save();
return $file;
}
示例13: 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;
}
示例14: setClientIDCookie
/**
* Set the client ID cookie. This is a random cookie used like a CSRF value
* during authentication workflows.
*
* @param AphrontRequest Request to modify.
* @return void
* @task clientid
*/
public static function setClientIDCookie(AphrontRequest $request)
{
// NOTE: See T3471 for some discussion. Some browsers and browser extensions
// can make duplicate requests, so we overwrite this cookie only if it is
// not present in the request. The cookie lifetime is limited by making it
// temporary and clearing it when users log out.
$value = $request->getCookie(self::COOKIE_CLIENTID);
if (!strlen($value)) {
$request->setTemporaryCookie(self::COOKIE_CLIENTID, Filesystem::readRandomCharacters(16));
}
}
示例15: initializeNewToken
public static function initializeNewToken($object_phid, $token_type)
{
$token = new PhabricatorConduitToken();
$token->objectPHID = $object_phid;
$token->tokenType = $token_type;
$token->expires = $token->getTokenExpires($token_type);
$secret = $token_type . '-' . Filesystem::readRandomCharacters(32);
$secret = substr($secret, 0, 32);
$token->token = $secret;
return $token;
}