本文整理汇总了PHP中get_temp_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP get_temp_dir函数的具体用法?PHP get_temp_dir怎么用?PHP get_temp_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_temp_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Replace $replace, DatabaseManager $dbm)
{
$this->errors = new \WP_Error();
$this->backup_dir = get_temp_dir();
$this->replace = $replace;
$this->dbm = $dbm;
}
示例2: save_data_file
/**
* Save some CSV data to a file, and create a quasi-$_FILES entry for it.
* @param string $data
* @return string|array
*/
private function save_data_file($data)
{
$test_filename = get_temp_dir() . '/test_' . uniqid() . '.csv';
file_put_contents($test_filename, $data);
$uploaded = array('type' => 'text/csv', 'file' => $test_filename);
return $uploaded;
}
示例3: getThumbnail
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$this->initCmd();
if (is_null($this->cmd)) {
return false;
}
$absPath = $fileview->toTmpFile($path);
$tmpDir = get_temp_dir();
$defaultParameters = ' --headless --nologo --nofirststartwizard --invisible --norestore -convert-to pdf -outdir ';
$clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
$exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
$export = 'export HOME=/' . $tmpDir;
shell_exec($export . "\n" . $exec);
//create imagick object from pdf
try {
$pdf = new \imagick($absPath . '.pdf' . '[0]');
$pdf->setImageFormat('jpg');
} catch (\Exception $e) {
unlink($absPath);
unlink($absPath . '.pdf');
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
return false;
}
$image = new \OC_Image();
$image->loadFromData($pdf);
unlink($absPath);
unlink($absPath . '.pdf');
return $image->valid() ? $image : false;
}
示例4: jb_doPostFacebook
function jb_doPostFacebook($status_msg)
{
$username = get_option('facebook-account-username');
$password = get_option('facebook-account-password');
$firstname = get_option('facebook-account-firstname');
$cookiejar = get_temp_dir() . $firstname . "-" . sha1(mt_rand()) . "-cookiejar.txt";
$fp = fopen($cookiejar, "w+") or die("<BR><B>Unable to open cookie file {$cookiejar} for write!<BR>");
fclose($fp);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'email=' . urlencode($username) . '&pass=' . urlencode($password) . '&login=Login');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
$page = curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 1);
preg_match('/name="post_form_id" value="(.*)" \\/>' . ucfirst($firstname) . '/', $page, $form_id);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'post_form_id=' . $form_id[1] . '&status=' . urlencode($status_msg) . '&update=Update');
curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/home.php');
curl_exec($ch);
unlink($cookiejar);
// Delete cookiefile
}
示例5: getThumbnail
/**
* {@inheritDoc}
*/
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$this->initCmd();
if (is_null($this->cmd)) {
return false;
}
$absPath = $fileview->toTmpFile($path);
$tmpDir = get_temp_dir();
$defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ';
$clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
$exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
shell_exec($exec);
//create imagick object from pdf
$pdfPreview = null;
try {
list($dirname, , , $filename) = array_values(pathinfo($absPath));
$pdfPreview = $dirname . '/' . $filename . '.pdf';
$pdf = new \imagick($pdfPreview . '[0]');
$pdf->setImageFormat('jpg');
} catch (\Exception $e) {
unlink($absPath);
unlink($pdfPreview);
\OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR);
return false;
}
$image = new \OC_Image();
$image->loadFromData($pdf);
unlink($absPath);
unlink($pdfPreview);
return $image->valid() ? $image : false;
}
示例6: image_assets
function image_assets()
{
// TODO: check if ziparchive is installed cms/cmsdev
$zip = new ZipArchive();
$ids = explode(',', $_GET['ids']);
$name = $_GET['name'] . '.zip';
$path = get_temp_dir() . $name;
if ($zip->open($path, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE) !== TRUE) {
die(json_encode(array('error' => 'Could not retrieve files.')));
}
foreach ($ids as $id) {
$image = get_attached_file($id);
if (file_exists($image)) {
$zip->addFile($image, basename($image));
} else {
// die("File $filepath doesnt exit");
}
}
$zip->close();
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=' . $name);
header('Content-Length: ' . filesize($path));
//TODO: alternate method to make zip file work?
ob_clean();
flush();
readfile($path);
wp_die();
}
示例7: setUp
public function setUp()
{
$this->baseDir = get_temp_dir() . '/oc_tmp_test';
if (!is_dir($this->baseDir)) {
mkdir($this->baseDir);
}
}
示例8: export
public function export(FW_Backup_Interface_Feedback $feedback)
{
$db = new FW_Backup_Export_Database();
$fs = new FW_Backup_Export_File_System();
$zip_file = sprintf('%s/backup-full-%s.zip', get_temp_dir(), date('Y_m_d-H_i_s'));
$tmp_file = array();
try {
touch($zip_file);
$zip = new ZipArchive();
if ($zip->open($zip_file) !== true) {
throw new FW_Backup_Exception(__('Could not create .zip file', 'fw'));
}
$fs->append_zip($zip, ABSPATH, '', $feedback);
$zip->addFile($tmp_file[] = $db->export_sql($feedback), 'database.txt');
$feedback->set_task(__('Compressing files...', 'fw'));
$zip->close();
} catch (FW_Backup_Exception $exception) {
unset($zip);
unlink($zip_file);
}
array_map('unlink', $tmp_file);
if (isset($exception)) {
throw $exception;
}
return $zip_file;
}
示例9: ninja_forms_csv_attachment
function ninja_forms_csv_attachment($sub_id)
{
global $ninja_forms_processing;
// make sure this form is supposed to attach a CSV
if (1 == $ninja_forms_processing->get_form_setting('admin_attach_csv') and 'submit' == $ninja_forms_processing->get_action()) {
// convert submission id to array
$sub_ids = array($sub_id);
// create CSV content
$csv_content = ninja_forms_export_subs_to_csv($sub_ids, true);
// create temporary file
$path = tempnam(get_temp_dir(), 'Sub');
$temp_file = fopen($path, 'r+');
// write to temp file
fwrite($temp_file, $csv_content);
fclose($temp_file);
// find the directory we will be using for the final file
$path = pathinfo($path);
$dir = $path['dirname'];
$basename = $path['basename'];
// create name for file
$new_name = apply_filters('ninja_forms_submission_csv_name', 'ninja-forms-submission');
// remove a file if it already exists
if (file_exists($dir . '/' . $new_name . '.csv')) {
unlink($dir . '/' . $new_name . '.csv');
}
// move file
rename($dir . '/' . $basename, $dir . '/' . $new_name . '.csv');
$file1 = $dir . '/' . $new_name . '.csv';
// add new file to array of existing files
$files = $ninja_forms_processing->get_form_setting('admin_attachments');
array_push($files, $file1);
$ninja_forms_processing->update_form_setting('admin_attachments', $files);
}
}
示例10: setUp
public function setUp()
{
$this->tmpDir = get_temp_dir() . '/filestoragecommon';
if (!file_exists($this->tmpDir)) {
mkdir($this->tmpDir);
}
$this->instance = new OC_Filestorage_CommonTest(array('datadir' => $this->tmpDir));
}
示例11: getCacheDir
protected static function getCacheDir()
{
$cache_dir = get_temp_dir() . '/owncloud-' . \OC_Util::getInstanceId() . '/';
if (!is_dir($cache_dir)) {
mkdir($cache_dir);
}
return $cache_dir;
}
示例12: _app_gcal_client_temp_dir_lookup
/**
* Wrapper for Google Client cache filepath + open_basedir restriction resolution.
*/
function _app_gcal_client_temp_dir_lookup($params)
{
if (!function_exists('get_temp_dir')) {
return $params;
}
$params['ioFileCache_directory'] = get_temp_dir() . 'Google_Client';
return $params;
}
示例13: setUp
protected function setUp()
{
parent::setUp();
$this->baseDir = get_temp_dir() . $this->getUniqueID('/oc_tmp_test');
if (!is_dir($this->baseDir)) {
mkdir($this->baseDir);
}
}
示例14: tmpDir
/**
* Finds a writable tmp directory.
*
* @since 150329 Improving tmp directory detection.
*
* @throws \exception On any failure.
*
* @return string Writable tmp directory.
*/
public function tmpDir()
{
$tmp_dir = $this->nSeps(get_temp_dir());
if (!$tmp_dir || !@is_dir($tmp_dir) || !@is_writable($tmp_dir)) {
throw new \exception(__('Unable to find a writable tmp directory.', 'comment-mail'));
}
return $tmp_dir;
// Writable tmp directory.
}
示例15: getTempFile
/**
* Caller should handle removal of the temp file when finished.
*
* @param string $ext The extension to be given to the temp file.
*
* @return string A temp file with the given extension.
*/
public static function getTempFile($ext = 'png')
{
static $base = null;
static $tmp;
if (is_null($base)) {
$base = md5(time());
$tmp = untrailingslashit(get_temp_dir());
}
return $tmp . DIRECTORY_SEPARATOR . wp_unique_filename($tmp, $base . '.' . $ext);
}