本文整理汇总了PHP中System::tmpdir方法的典型用法代码示例。如果您正苦于以下问题:PHP System::tmpdir方法的具体用法?PHP System::tmpdir怎么用?PHP System::tmpdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::tmpdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OLE
/**
* Constructor
*
* @access public
* @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp
*/
function OLE_PPS_Root($time_1st, $time_2nd, $raChild)
{
$_ole = new OLE();
$_sys = new System();
$this->_tmp_dir = $_sys->tmpdir();
$this->OLE_PPS(null, $_ole->Asc2Ucs('Root Entry'), OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild);
}
示例2: __construct
/**
* The constructor
*
* @access public
* @param string $name The name of the file (in Unicode)
* @see OLE::Asc2Ucs()
*/
function __construct($name)
{
$this->_tmp_dir = System::tmpdir();
parent::__construct(
null,
$name,
OLE_PPS_TYPE_FILE,
null,
null,
null,
null,
null,
'',
array());
}
示例3: __construct
/**
* Constructor
*
* @access public
* @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp
*/
function __construct($time_1st, $time_2nd, $raChild)
{
$this->_tmp_dir = System::tmpdir();
parent::__construct(
null,
OLE::Asc2Ucs('Root Entry'),
OLE_PPS_TYPE_ROOT,
null,
null,
null,
$time_1st,
$time_2nd,
null,
$raChild);
}
示例4: define
if (getenv('PHP_PEAR_DATA_DIR')) {
define('PEAR_CONFIG_DEFAULT_DATA_DIR', getenv('PHP_PEAR_DATA_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_DATA_DIR', PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . 'data');
}
// Default for test_dir
if (getenv('PHP_PEAR_TEST_DIR')) {
define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_TEST_DIR', PEAR_INSTALL_DIR . DIRECTORY_SEPARATOR . 'tests');
}
// Default for cache_dir
if (getenv('PHP_PEAR_CACHE_DIR')) {
define('PEAR_CONFIG_DEFAULT_CACHE_DIR', getenv('PHP_PEAR_CACHE_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_CACHE_DIR', System::tmpdir() . DIRECTORY_SEPARATOR . 'pear' . DIRECTORY_SEPARATOR . 'cache');
}
// Default for php_bin
if (getenv('PHP_PEAR_PHP_BIN')) {
define('PEAR_CONFIG_DEFAULT_PHP_BIN', getenv('PHP_PEAR_PHP_BIN'));
} else {
define('PEAR_CONFIG_DEFAULT_PHP_BIN', PEAR_CONFIG_DEFAULT_BIN_DIR . DIRECTORY_SEPARATOR . 'php' . (OS_WINDOWS ? '.exe' : ''));
}
// Default for verbose
if (getenv('PHP_PEAR_VERBOSE')) {
define('PEAR_CONFIG_DEFAULT_VERBOSE', getenv('PHP_PEAR_VERBOSE'));
} else {
define('PEAR_CONFIG_DEFAULT_VERBOSE', 1);
}
// Default for preferred_state
if (getenv('PHP_PEAR_PREFERRED_STATE')) {
示例5: getTempFile
/**
* Returns a temporary filename using tempnam() and the above getTmpDir() function.
*
* @access public
* @param string $dirname Optional directory name for the tmp file
* @return string Filename and path of the tmp file
*/
static function getTempFile($dirname = NULL)
{
return tempnam(is_null($dirname) ? System::tmpdir() : $dirname, 'temp.');
}
示例6: define
if (getenv('PHP_PEAR_TEMP_DIR')) {
define('PEAR_CONFIG_DEFAULT_TEMP_DIR', getenv('PHP_PEAR_TEMP_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_TEMP_DIR', System::tmpdir() . DIRECTORY_SEPARATOR . 'pear' . DIRECTORY_SEPARATOR . 'temp');
}
// Default for cache_dir
if (getenv('PHP_PEAR_CACHE_DIR')) {
define('PEAR_CONFIG_DEFAULT_CACHE_DIR', getenv('PHP_PEAR_CACHE_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_CACHE_DIR', System::tmpdir() . DIRECTORY_SEPARATOR . 'pear' . DIRECTORY_SEPARATOR . 'cache');
}
// Default for download_dir
if (getenv('PHP_PEAR_DOWNLOAD_DIR')) {
define('PEAR_CONFIG_DEFAULT_DOWNLOAD_DIR', getenv('PHP_PEAR_DOWNLOAD_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_DOWNLOAD_DIR', System::tmpdir() . DIRECTORY_SEPARATOR . 'pear' . DIRECTORY_SEPARATOR . 'download');
}
// Default for php_bin
if (getenv('PHP_PEAR_PHP_BIN')) {
define('PEAR_CONFIG_DEFAULT_PHP_BIN', getenv('PHP_PEAR_PHP_BIN'));
} else {
define('PEAR_CONFIG_DEFAULT_PHP_BIN', PEAR_CONFIG_DEFAULT_BIN_DIR . DIRECTORY_SEPARATOR . 'php' . (OS_WINDOWS ? '.exe' : ''));
}
// Default for verbose
if (getenv('PHP_PEAR_VERBOSE')) {
define('PEAR_CONFIG_DEFAULT_VERBOSE', getenv('PHP_PEAR_VERBOSE'));
} else {
define('PEAR_CONFIG_DEFAULT_VERBOSE', 1);
}
// Default for preferred_state
if (getenv('PHP_PEAR_PREFERRED_STATE')) {
示例7: OLE_PPS_Root
/**
* Constructor
*
* @access public
* @param integer $time_1st A timestamp
* @param integer $time_2nd A timestamp
*/
function OLE_PPS_Root($time_1st, $time_2nd, $raChild)
{
$this->_tmp_dir = System::tmpdir();
$this->OLE_PPS(null, OLE::Asc2Ucs('Root Entry'), OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild);
}
示例8: System_Command
/**
* Class constructor
*
* Defines all necessary constants and sets defaults
*
* @access public
*/
function System_Command($in_shell = null)
{
// Defining constants
$this->options = array('SEQUENCE' => true, 'SHUTDOWN' => false, 'SHELL' => $this->which($in_shell), 'OUTPUT' => true, 'NOHUP' => false, 'BACKGROUND' => false, 'STDERR' => false, 'AUTORESET' => false);
// prepare the available control operators
$this->controlOperators = array('PIPE' => '|', 'AND' => '&&', 'OR' => '||', 'GROUP' => ';', 'LFIFO' => '<', 'RFIFO' => '>');
// List of allowed/available shells
$this->shells = array('sh', 'bash', 'zsh', 'tcsh', 'csh', 'ash', 'sash', 'esh', 'ksh');
// Find the first available shell
if (empty($this->options['SHELL'])) {
foreach ($this->shells as $shell) {
if ($this->options['SHELL'] = $this->which($shell)) {
break;
}
}
// see if we still have no shell
if (empty($this->options['SHELL'])) {
$this->_initError =& PEAR::raiseError(null, SYSTEM_COMMAND_NO_SHELL, null, E_USER_WARNING, null, 'System_Command_Error', true);
return;
}
}
// Caputre a temporary directory for capturing stderr from commands
$this->tmpDir = System::tmpdir();
if (!System::mkDir("-p {$this->tmpDir}")) {
$this->_initError =& PEAR::raiseError(null, SYSTEM_COMMAND_TMPDIR_ERROR, null, E_USER_WARNING, null, 'System_Command_Error', true);
return;
}
}
示例9: mktemp
/**
* Creates temporary files or directories. This function will remove
* the created files when the scripts finish its execution.
*
* Usage:
* 1) $tempfile = System::mktemp("prefix");
* 2) $tempdir = System::mktemp("-d prefix");
* 3) $tempfile = System::mktemp();
* 4) $tempfile = System::mktemp("-t /var/tmp prefix");
*
* prefix -> The string that will be prepended to the temp name
* (defaults to "tmp").
* -d -> A temporary dir will be created instead of a file.
* -t -> The target dir where the temporary (file|dir) will be created. If
* this param is missing by default the env vars TMP on Windows or
* TMPDIR in Unix will be used. If these vars are also missing
* c:\windows\temp or /tmp will be used.
*
* @param string $args The arguments
* @return mixed the full path of the created (file|dir) or false
* @see System::tmpdir()
* @static
* @access public
*/
function mktemp($args = null)
{
static $first_time = true;
$opts = System::_parseArgs($args, 't:d');
if (PEAR::isError($opts)) {
return System::raiseError($opts);
}
foreach ($opts[0] as $opt) {
if ($opt[0] == 'd') {
$tmp_is_dir = true;
} elseif ($opt[0] == 't') {
$tmpdir = $opt[1];
}
}
$prefix = isset($opts[1][0]) ? $opts[1][0] : 'tmp';
if (!isset($tmpdir)) {
$tmpdir = System::tmpdir();
}
/*
* Magento fix for set tmp dir in config.ini
*/
if (class_exists('Maged_Controller', false)) {
$magedConfig = Maged_Controller::model('Config', true)->load();
if ($magedConfig->get('use_custom_permissions_mode') == '1' && ($mode = $magedConfig->get('mkdir_mode'))) {
$result = System::mkDir(array('-m' . $mode, $tmpdir));
} else {
$result = System::mkDir(array('-p', $tmpdir));
}
if (!$result) {
return false;
}
}
// Old realisation
//if (!System::mkDir(array('-p', $tmpdir))) {
// return false;
//}
/*
* End fix
*/
$tmp = tempnam($tmpdir, $prefix);
if (isset($tmp_is_dir)) {
unlink($tmp);
// be careful possible race condition here
if (!mkdir($tmp, 0700)) {
return System::raiseError("Unable to create temporary directory {$tmpdir}");
}
}
$GLOBALS['_System_temp_files'][] = $tmp;
if ($first_time) {
PEAR::registerShutdownFunc(array('System', '_removeTmpFiles'));
$first_time = false;
}
return $tmp;
}
示例10: getTempFile
/**
* Returns a temporary filename using tempnam() and the above getTmpDir() function.
*
* @param string $dirname Optional directory name for the tmp file
*
* @return string Filename and path of the tmp file
* @access public
*/
function getTempFile($dirname = null)
{
if (is_null($dirname)) {
include_once 'System.php';
$dirname = System::tmpdir();
}
return tempnam($dirname, 'temp.');
}
示例11: createCommandLine
/**
* Prepare the command to execute
*
* @param array $targets contains hostnames, IP addresses, networks to scan
*
* @return string
*/
protected function createCommandLine($targets)
{
if ($this->_output_file === null) {
$this->_output_file = tempnam(System::tmpdir(), __CLASS__);
} else {
$this->_delete_output_file = false;
}
$cmd = escapeshellarg($this->_nmap_binary);
$cmd .= ' ' . implode(' ', $this->_nmap_options);
$cmd .= ' -oX ' . escapeshellarg($this->_output_file) . ' ';
foreach ($targets as $target) {
$cmd .= escapeshellarg($target) . ' ';
}
$cmd .= '2>&1';
/*
if (OS_WINDOWS) {
$cmd = '"' . $cmd . '"';
}
*/
return $cmd;
}
示例12: mktemp
/**
* Creates temporal files or directories
*
* Usage:
* 1) $tempfile = System::mktemp("prefix");
* 2) $tempdir = System::mktemp("-d prefix");
* 3) $tempfile = System::mktemp();
* 4) $tempfile = System::mktemp("-t /var/tmp prefix");
*
* prefix -> The string that will be prepended to the temp name
* (defaults to "tmp").
* -d -> A temporal dir will be created instead of a file.
* -t -> The target dir where the temporal (file|dir) will be created. If
* this param is missing by default the env vars TMP on Windows or
* TMPDIR in Unix will be used. If these vars are also missing
* c:\windows\temp or /tmp will be used.
*
* @param string $args The arguments
* @return mixed the full path of the created (file|dir) or false
* @see System::tmpdir()
* @access public
*/
function mktemp($args = null)
{
$opts = System::_parseArgs($args, 't:d');
if (PEAR::isError($opts)) {
return System::raiseError($opts);
}
foreach ($opts[0] as $opt) {
if ($opt[0] == 'd') {
$tmp_is_dir = true;
} elseif ($opt[0] == 't') {
$tmpdir = $opt[1];
}
}
$prefix = isset($opts[1][0]) ? $opts[1][0] : 'tmp';
if (!isset($tmpdir)) {
$tmpdir = System::tmpdir();
}
if (!System::mkDir("-p {$tmpdir}")) {
return false;
}
$tmp = tempnam($tmpdir, $prefix);
if (isset($tmp_is_dir)) {
unlink($tmp);
// be careful possible race condition here
if (!mkdir($tmp, 0700)) {
return System::raiseError("Unable to create temporary directory {$tmpdir}");
}
}
return $tmp;
}
示例13: define
}
// Default for test_dir
if (getenv('PHP_PEAR_TEST_DIR')) {
define('PEAR_CONFIG_DEFAULT_TEST_DIR', getenv('PHP_PEAR_TEST_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_TEST_DIR',
$PEAR_INSTALL_DIR.DIRECTORY_SEPARATOR.'tests');
}
// Default for cache_dir
if (getenv('PHP_PEAR_CACHE_DIR')) {
define('PEAR_CONFIG_DEFAULT_CACHE_DIR', getenv('PHP_PEAR_CACHE_DIR'));
} else {
define('PEAR_CONFIG_DEFAULT_CACHE_DIR',
System::tmpdir() . DIRECTORY_SEPARATOR . 'pear' .
DIRECTORY_SEPARATOR . 'cache');
}
// Default for php_bin
if (getenv('PHP_PEAR_PHP_BIN')) {
define('PEAR_CONFIG_DEFAULT_PHP_BIN', getenv('PHP_PEAR_PHP_BIN'));
} else {
define('PEAR_CONFIG_DEFAULT_PHP_BIN', PEAR_CONFIG_DEFAULT_BIN_DIR.
DIRECTORY_SEPARATOR.'php'.(OS_WINDOWS ? '.exe' : ''));
}
// Default for verbose
if (getenv('PHP_PEAR_VERBOSE')) {
define('PEAR_CONFIG_DEFAULT_VERBOSE', getenv('PHP_PEAR_VERBOSE'));
} else {
示例14: mktemp
/**
* Creates temporary files or directories. This function will remove
* the created files when the scripts finish its execution.
*
* Usage:
* 1) $tempfile = System::mktemp("prefix");
* 2) $tempdir = System::mktemp("-d prefix");
* 3) $tempfile = System::mktemp();
* 4) $tempfile = System::mktemp("-t /var/tmp prefix");
*
* prefix -> The string that will be prepended to the temp name
* (defaults to "tmp").
* -d -> A temporary dir will be created instead of a file.
* -t -> The target dir where the temporary (file|dir) will be created. If
* this param is missing by default the env vars TMP on Windows or
* TMPDIR in Unix will be used. If these vars are also missing
* c:\windows\temp or /tmp will be used.
*
* @param string $args The arguments
* @return mixed the full path of the created (file|dir) or false
* @see System::tmpdir()
* @access public
*/
function mktemp($args = null)
{
static $first_time = true;
$opts = System::_parseArgs($args, 't:d');
if (PEAR::isError($opts)) {
return System::raiseError($opts);
}
foreach ($opts[0] as $opt) {
if ($opt[0] == 'd') {
$tmp_is_dir = true;
} elseif ($opt[0] == 't') {
$tmpdir = $opt[1];
}
}
$prefix = isset($opts[1][0]) ? $opts[1][0] : 'tmp';
if (!isset($tmpdir)) {
$tmpdir = System::tmpdir();
}
if (!System::mkDir("-p {$tmpdir}")) {
return false;
}
$tmp = tempnam($tmpdir, $prefix);
if (isset($tmp_is_dir)) {
unlink($tmp);
// be careful possible race condition here
if (!call_user_func('mkdir', $tmp, 0700)) {
return System::raiseError("Unable to create temporary directory {$tmpdir}");
}
}
$GLOBALS['_System_temp_files'][] = $tmp;
if ($first_time) {
PEAR::registerShutdownFunc(array('System', '_removeTmpFiles'));
$first_time = false;
}
return $tmp;
}
示例15: System
/**
* The constructor
*
* @access public
* @param string $name The name of the file (in Unicode)
* @see OLE::Asc2Ucs()
*/
function OLE_PPS_File($name)
{
$system = new System();
$this->_tmp_dir = $system->tmpdir();
$this->OLE_PPS(null, $name, OLE_PPS_TYPE_FILE, null, null, null, null, null, '', array());
}