/** * 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); }
/** * 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()); }
/** * 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); }
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')) {
/** * 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.'); }
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')) {
/** * 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); }
/** * 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; } }
/** * 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; }
/** * 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.'); }
/** * 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; }
/** * 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; }
} // 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 {
/** * 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; }
/** * 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()); }
/** * The constructor * * @access public * @param string $name The name of the file (in Unicode) * @see OLE::Asc2Ucs() */ function OLE_PPS_File($name) { $this->_tmp_dir = System::tmpdir(); $this->OLE_PPS(null, $name, OLE_PPS_TYPE_FILE, null, null, null, null, null, '', array()); }
/** * setDebug * * Set {@link $debug} (true by default). * Call this to set {@link $debug} to true and enable logging. * * @param bool $value defaults to true to enable debugging * @param string $logFile path to local log file, defaults * to System::tmpdir() . PATH_SEPARATOR . 'vpopmaild.log' * (/tmp/vpopmaild.log on Unix, for example) * * @access public * @throws Net_Vpopmaild_Exception on failure to create a Log object * @return void */ public function setDebug($value = true, $logFile = null) { // Set debug value $this->debug = (bool) $value; // Instantiate Log object if necessary if ($this->debug && is_null($this->log)) { if (is_null($logFile)) { $system = System::tmpdir() . PATH_SEPARATOR . 'vpopmaild.log'; } $this->log = Log::factory('file', $logFile); if (is_null($this->log)) { throw new Net_Vpopmaild_Exception("Error creating Log object"); } } }