本文整理汇总了PHP中temp_path函数的典型用法代码示例。如果您正苦于以下问题:PHP temp_path函数的具体用法?PHP temp_path怎么用?PHP temp_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了temp_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
protected function init()
{
$settings = Settings::instance();
if (!strlen($settings->profile_id)) {
throw new ApplicationException(trans('rainlab.googleanalytics::lang.strings.notconfigured'));
}
if (!$settings->gapi_key) {
throw new ApplicationException(trans('rainlab.googleanalytics::lang.strings.keynotuploaded'));
}
$client = new Google_Client();
/*
* Set caching
*/
$cache = new Google_Cache_File(temp_path() . '/Google_Client');
$client->setCache($cache);
/*
* Set assertion credentials
*/
$auth = json_decode($settings->gapi_key->getContents(), true);
$client->setAuthConfig($auth);
$client->addScope(Google_Service_Analytics::ANALYTICS_READONLY);
if ($client->isAccessTokenExpired()) {
$client->refreshTokenWithAssertion();
}
$this->client = $client;
$this->service = new Google_Service_Analytics($client);
$this->viewId = 'ga:' . $settings->profile_id;
}
示例2: speak
public function speak($lang = 'en', $text = 'text not provided')
{
// Create temp path
$uxmsTtsTempPath = temp_path(Configs::get('temp_name'));
if (!File::isDirectory($uxmsTtsTempPath)) {
if (!File::makeDirectory($uxmsTtsTempPath)) {
throw new ApplicationException('Unable to create temp directory: ' . $uxmsTtsTempPath);
}
}
// Create storage path
$uxmsTtsStoragePath = storage_path() . '/app/' . Configs::get('final_audio_folder_name');
if (!File::isDirectory($uxmsTtsStoragePath)) {
if (!File::makeDirectory($uxmsTtsStoragePath)) {
throw new ApplicationException('Unable to create storage directory: ' . $uxmsTtsStoragePath);
}
}
// Check if saved audios will be using and if it exists in stor dir
if (Configs::get('use_saved_files')) {
if (File::exists($uxmsTtsStoragePath . '/' . md5($text) . '.mp3')) {
return $this->tts->getAudioElementOrUri(md5($text));
}
}
// Lets create the speech
$this->tts->text($lang, $text)->saveFile(false);
// Do not forget to activate puging from settings..
if (Configs::get('purge_temp')) {
$this->tts->clearTemp();
}
return $this->tts->getAudioElementOrUri();
}
示例3: fromUrl
/**
* Download remote file and save to temp.
*
* @param string
* @return File
* @throws SystemException If file could not be downloaded
*/
public function fromUrl($url)
{
$this->source = $url;
$fileName = basename(parse_url($url, PHP_URL_PATH));
$localFile = temp_path('images') . '/' . $fileName;
$response = Http::get($url, function ($http) use($localFile) {
$http->toFile($localFile);
});
if ($response->code == 200) {
$this->data = $localFile;
$this->tempFile = $localFile;
}
return $this;
}
示例4: init
/**
* Initialize this singleton.
*/
protected function init()
{
$this->pluginManager = PluginManager::instance();
$this->versionManager = VersionManager::instance();
$this->tempDirectory = temp_path();
$this->baseDirectory = base_path();
$this->disableCoreUpdates = Config::get('cms.disableCoreUpdates', false);
$this->bindContainerObjects();
/*
* Ensure temp directory exists
*/
if (!File::isDirectory($this->tempDirectory)) {
File::makeDirectory($this->tempDirectory, 0777, true);
}
}
示例5: getSystemWarnings
protected function getSystemWarnings()
{
$warnings = [];
$writablePaths = [temp_path(), themes_path(), storage_path(), storage_path('app'), storage_path('logs'), storage_path('framework'), storage_path('cms'), storage_path('cms/cache'), storage_path('cms/twig'), storage_path('cms/combiner')];
$requiredExtensions = ['GD' => extension_loaded('gd'), 'fileinfo' => extension_loaded('fileinfo'), 'Zip' => class_exists('ZipArchive'), 'cURL' => function_exists('curl_init') && defined('CURLOPT_FOLLOWLOCATION'), 'OpenSSL' => function_exists('openssl_random_pseudo_bytes')];
foreach ($writablePaths as $path) {
if (!is_writable($path)) {
$warnings[] = Lang::get('backend::lang.warnings.permissions', ['name' => '<strong>' . $path . '</strong>']);
}
}
foreach ($requiredExtensions as $extension => $installed) {
if (!$installed) {
$warnings[] = Lang::get('backend::lang.warnings.extension', ['name' => '<strong>' . $extension . '</strong>']);
}
}
return $warnings;
}
示例6: store
/**
* Create the report
* @return Response
*/
public function store()
{
$input = Input::all();
$file = Input::file('file');
$filename = $file->getClientOriginalName();
$file->move(temp_path(), $filename);
$filename = str_replace('.ZIP', '.zip', $filename);
$unzipSuccess = Unzip(temp_path() . "/{$filename}", temp_path());
$contents = file_get_contents(temp_path() . "/report_generator.json");
$report_info = json_decode($contents, true);
$input = array('name' => $report_info['name'], 'author' => $report_info['author'], 'version' => $report_info['version'], 'website' => $report_info['website'], 'modules' => json_encode($report_info['modules']), 'show_calendars' => $report_info['show_calendars']);
if ($report_generator = ReportGenerator::where('name', '=', $input['name'])->first()) {
$report_generator->update($input);
} else {
$report_generator = ReportGenerator::create($input);
}
return Redirect::to("{$this->link_type}/report-generators")->with('success_message', trans('success_messages.report_generator_install'));
}
示例7: import
public function import($theme, $data = [], $sessionKey = null)
{
@set_time_limit(3600);
$this->theme = $theme;
$this->fill($data);
try {
$file = $this->uploaded_file()->withDeferred($sessionKey)->first();
if (!$file) {
throw new ApplicationException('There is no file attached to import!');
}
$themePath = $this->theme->getPath();
$tempPath = temp_path() . '/' . uniqid('oc');
$zipName = uniqid('oc');
$zipPath = temp_path() . '/' . $zipName;
File::put($zipPath, $file->getContents());
if (!@mkdir($tempPath)) {
throw new ApplicationException('Unable to create directory ' . $tempPath);
}
Zip::extract($zipPath, $tempPath);
// if (File::isFile($tempPath.'/theme.yaml')) {
// File::copy($tempPath.'/theme.yaml', $themePath.'/theme.yaml');
// }
if (File::isDirectory($tempPath . '/meta')) {
$this->copyDirectory($tempPath . '/meta', $themePath . '/meta');
}
foreach ($this->folders as $folder) {
if (!array_key_exists($folder, $this->getFoldersOptions())) {
continue;
}
$this->copyDirectory($tempPath . '/' . $folder, $themePath . '/' . $folder);
}
File::deleteDirectory($tempPath);
File::delete($zipPath);
$file->delete();
} catch (Exception $ex) {
if (!empty($tempPath) && File::isDirectory($tempPath)) {
File::deleteDirectory($tempPath);
}
if (!empty($zipPath) && File::isFile($zipPath)) {
File::delete($zipPath);
}
throw $ex;
}
}
示例8: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// get random file name and file extension
$path = temp_path(str_random());
$originalExtension = substr(strrchr($this->argument('url'), '.'), 1);
// download file and store it
$this->info('Downloading the file...' . PHP_EOL);
$response = $this->client->get($this->argument('url'), ['verify' => storage_path('app/wildcard_ccu_edu_tw')]);
$this->filesystem->put("{$path}.{$originalExtension}", $response->getBody()->getContents());
// extract the file
$this->info('Extracting the file...' . PHP_EOL);
(new PharData("{$path}.{$originalExtension}"))->decompress();
(new PharData("{$path}.tar"))->extractTo(temp_path());
// delete non-used files
$this->info('Deleting non-used the file...' . PHP_EOL);
$this->filesystem->delete(["{$path}.{$originalExtension}", "{$path}.tar", temp_path('index.html')]);
$this->filesystem->delete($this->filesystem->glob(temp_path('*e.html')));
$this->info('Succeed!');
}
示例9: getMedia
public function getMedia($mediaId)
{
$query = ['media_id' => $mediaId];
$result = $this->httpGet(static::MEDIA_GET_URL, $query, [], true, false);
$contentType = $result->getHeader('Content-Type')[0];
if (strpos($contentType, 'application/json') !== false) {
$result = $this->processHttpResult($result);
return $this->processWechatApiResult($result);
}
$contentDisposition = $result->getHeader('Content-disposition')[0];
preg_match('#filename="(.*)"#', $contentDisposition, $matches);
$filename = $matches[1];
$tempDir = temp_path(uniqid());
if (!is_dir($tempDir)) {
mkdir($tempDir);
}
$tempPath = $tempDir . '/' . $filename;
file_put_contents($tempPath, $result->getBody());
return new File($tempPath);
}
示例10: init
protected function init()
{
$settings = Settings::instance();
if (!strlen($settings->project_name)) {
throw new ApplicationException(Lang::get('rainlab.googleanalytics::lang.exceptions.google_api_not_configured'));
}
if (!$settings->gapi_key) {
throw new ApplicationException(Lang::get('rainlab.googleanalytics::lang.exceptions.google_api_key_not_uploaded'));
}
$tmpDir = temp_path() . '/Google_Client';
$this->client = new Google_Client();
$this->client->setApplicationName($settings->project_name);
$this->client->setClassConfig('Google_Cache_File', 'directory', $tmpDir);
/*
* Set assertion credentials
*/
$this->client->setAssertionCredentials(new Google_Auth_AssertionCredentials($settings->app_email, array(Google_Service_Analytics::ANALYTICS_READONLY), $settings->gapi_key->getContents()));
$this->client->setClientId($settings->client_id);
$this->service = new Google_Service_Analytics($this->client);
$this->viewId = 'ga:' . $settings->profile_id;
}
示例11: installLanguageFile
public function installLanguageFile($file)
{
$filename = $this->uploadLanguageFile($file);
$filename = str_replace('.ZIP', '.zip', $filename);
$canonical = str_replace('.zip', '', $filename);
$temp_import_path = temp_path() . '/translations_import/' . $canonical . '/';
if (File::exists($temp_import_path)) {
File::deleteDirectory($temp_import_path);
}
$unzipSuccess = Unzip("{$this->temp_path}{$filename}", $temp_import_path);
if (!$unzipSuccess) {
throw new Exception("The language file {$filename} couldn\\'t be extracted.");
}
if (!File::exists("{$temp_import_path}language.json")) {
throw new Exception('language.json doesn\'t exist in the language file');
}
$language_config = json_decode(file_get_contents("{$temp_import_path}/language.json"), true);
$language_dir = $this->language_path . $language_config['code'];
File::copyDirectory($temp_import_path . 'lang', $language_dir);
// Import the translations from file to database
$this->translation_manager->importTranslations();
return $language_config;
}
示例12: export
public function export($theme, $data = [])
{
$this->theme = $theme;
$this->fill($data);
try {
$themePath = $this->theme->getPath();
$tempPath = temp_path() . '/' . uniqid('oc');
$zipName = uniqid('oc');
$zipPath = temp_path() . '/' . $zipName;
if (!File::makeDirectory($tempPath)) {
throw new ApplicationException('Unable to create directory ' . $tempPath);
}
if (!File::makeDirectory($metaPath = $tempPath . '/meta')) {
throw new ApplicationException('Unable to create directory ' . $metaPath);
}
File::copy($themePath . '/theme.yaml', $tempPath . '/theme.yaml');
File::copyDirectory($themePath . '/meta', $metaPath);
foreach ($this->folders as $folder) {
if (!array_key_exists($folder, $this->getFoldersOptions())) {
continue;
}
File::copyDirectory($themePath . '/' . $folder, $tempPath . '/' . $folder);
}
Zip::make($zipPath, $tempPath);
File::deleteDirectory($tempPath);
} catch (Exception $ex) {
if (strlen($tempPath) && File::isDirectory($tempPath)) {
File::deleteDirectory($tempPath);
}
if (strlen($zipPath) && File::isFile($zipPath)) {
File::delete($zipPath);
}
throw $ex;
}
return $zipName;
}
示例13: generateZip
/**
* Generate a zip file of the module
* @param $module_alias
* @return string
*/
private function generateZip($module_alias)
{
$zip_file = temp_path() . "/{$module_alias}.zip";
$this->Zip(temp_path() . "/{$module_alias}/", $zip_file, false);
File::deleteDirectory(temp_path() . "/{$module_alias}/");
return $zip_file;
}
示例14: getTempPath
/**
* Define the internal working path, override this method to define.
*/
public function getTempPath()
{
$path = temp_path() . '/uploads';
if (!FileHelper::isDirectory($path)) {
FileHelper::makeDirectory($path, 0777, true, true);
}
return $path;
}
示例15: getReportGenerator
/**
* Create the report generator for download
* @param $input
* @return
*/
private function getReportGenerator($input)
{
if (isset($input['id'])) {
unset($input['id']);
}
if (isset($input['created_by'])) {
unset($input['created_by']);
}
if (isset($input['updated_by'])) {
unset($input['updated_by']);
}
if (isset($input['created_at'])) {
unset($input['created_at']);
}
if (isset($input['updated_at'])) {
unset($input['updated_at']);
}
$report_alias = Str::slug($input['name'], '_');
$report_file = temp_path() . "/report_generator.json";
file_put_contents($report_file, json_encode($input));
$zip_file = temp_path() . "/report_{$report_alias}.zip";
Zip(temp_path() . "/report_generator.json", $zip_file, false);
return $zip_file;
}