本文整理汇总了PHP中mk_temp_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP mk_temp_dir函数的具体用法?PHP mk_temp_dir怎么用?PHP mk_temp_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mk_temp_dir函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractFile
function extractFile($zip_file, $file_in_zip)
{
global $base_tmp_upgrade_dir;
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例2: extractFile
function extractFile($zip_file, $file_in_zip)
{
global $base_tmp_upgrade_dir;
if (empty($base_tmp_upgrade_dir)) {
$base_tmp_upgrade_dir = $GLOBALS['sugar_config']['upload_dir'] . "upgrades/temp";
}
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例3: testmk_temp_dir
public function testmk_temp_dir()
{
//execute the method and test if created dir/file exists
//without prefix
$actual = mk_temp_dir('vfs://root', '');
$this->assertFileExists($actual);
//with prefix
$actual = mk_temp_dir('vfs://root', 'pfx');
$this->assertFileExists($actual);
}
示例4: extractFile
function extractFile($zip_file, $file_in_zip)
{
global $base_tmp_upgrade_dir;
if (empty($base_tmp_upgrade_dir)) {
$base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
}
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例5: extractFile
public static function extractFile($zip_file, $file_in_zip)
{
global $base_tmp_upgrade_dir;
if (empty($base_tmp_upgrade_dir)) {
$base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
}
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
register_shutdown_function('rmdir_recursive', $my_zip_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例6: preflightCheckJsonFindUpgradeFiles
function preflightCheckJsonFindUpgradeFiles($persistence)
{
global $sugar_config;
global $mod_strings;
unset($persistence['rebuild_relationships']);
unset($persistence['rebuild_extensions']);
// don't bother if are rechecking
$manualDiff = array();
if (!isset($persistence['unzip_dir']) || empty($persistence['unzip_dir'])) {
logThis('unzipping files in upgrade archive...');
$errors = array();
$base_upgrade_dir = "upload://upgrades";
$base_tmp_upgrade_dir = sugar_cached("upgrades/temp");
$install_file = urldecode($persistence['install_file']);
$show_files = true;
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
$zip_from_dir = ".";
$zip_to_dir = ".";
$zip_force_copy = array();
unzip($install_file, $unzip_dir);
// assumption -- already validated manifest.php at time of upload
include "{$unzip_dir}/manifest.php";
if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
$zip_from_dir = $manifest['copy_files']['from_dir'];
}
if (isset($manifest['copy_files']['to_dir']) && $manifest['copy_files']['to_dir'] != "") {
$zip_to_dir = $manifest['copy_files']['to_dir'];
}
if (isset($manifest['copy_files']['force_copy']) && $manifest['copy_files']['force_copy'] != "") {
$zip_force_copy = $manifest['copy_files']['force_copy'];
}
if (isset($manifest['version'])) {
$version = $manifest['version'];
}
if (!is_writable("config.php")) {
logThis('BAD error');
return $mod_strings['ERR_UW_CONFIG'];
}
logThis('setting "unzip_dir" to ' . $unzip_dir);
$persistence['unzip_dir'] = clean_path($unzip_dir);
$persistence['zip_from_dir'] = clean_path($zip_from_dir);
logThis('unzip done.');
} else {
$unzip_dir = $persistence['unzip_dir'];
$zip_from_dir = $persistence['zip_from_dir'];
}
$persistence['upgrade_files'] = uwFindAllFiles(clean_path("{$unzip_dir}/{$zip_from_dir}"), array(), true, array(), true);
return $persistence;
}
示例7: urldecode
$upgrade_directories_not_found = <<<eoq
\t<table cellpadding="3" cellspacing="0" border="0">
\t\t<tr>
\t\t\t<th colspan="2" align="left">
\t\t\t\t<span class='error'><b>'Upload file missing or has been deleted. Refresh the page to go back to UpgradeWizard start'</b></span>
\t\t\t</th>
\t\t</tr>
\t</table>
eoq;
$uwMain = $upgrade_directories_not_found;
return '';
}
$install_file = urldecode($_SESSION['install_file']);
$show_files = true;
if (empty($unzip_dir)) {
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
}
$zip_from_dir = ".";
$zip_to_dir = ".";
$zip_force_copy = array();
if (!$unzip_dir) {
logThis('Could not create a temporary directory using mk_temp_dir( $base_tmp_upgrade_dir )');
die($mod_strings['ERR_UW_NO_CREATE_TMP_DIR']);
}
//double check whether unzipped .
if (file_exists($unzip_dir . "/scripts") && file_exists($unzip_dir . "/manifest.php")) {
//already unzipped
} else {
unzip($install_file, $unzip_dir);
}
// assumption -- already validated manifest.php at time of upload
示例8: performUninstall
function performUninstall($name)
{
$uh = new UpgradeHistory();
$uh->name = $name;
$uh->id_name = $name;
$found = $uh->checkForExisting($uh);
if ($found != null) {
global $sugar_config;
global $mod_strings;
global $current_language;
$base_upgrade_dir = sugar_cached("/upgrades");
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
if (!isset($GLOBALS['mi_remove_tables'])) {
$GLOBALS['mi_remove_tables'] = true;
}
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip($found->filename, $unzip_dir);
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->uninstall("{$unzip_dir}");
$found->delete();
unlink(remove_file_extension($found->filename) . '-manifest.php');
unlink($found->filename);
}
}
示例9: upgradeSugarCache
/**
* change from using the older SugarCache in 6.1 and below to the new one in 6.2
*/
function upgradeSugarCache($file)
{
global $sugar_config;
$cacheUploadUpgradesTemp = mk_temp_dir(sugar_cached('upgrades/temp'));
unzip($file, $cacheUploadUpgradesTemp);
if (!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) {
logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
return;
} else {
include clean_path("{$cacheUploadUpgradesTemp}/manifest.php");
}
$from_dir = "{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}";
$allFiles = array();
if (file_exists("{$from_dir}/include/SugarCache")) {
$allFiles = findAllFiles("{$from_dir}/include/SugarCache", $allFiles);
}
if (file_exists("{$from_dir}/include/database")) {
$allFiles = findAllFiles("{$from_dir}/include/database", $allFiles);
}
if (file_exists("{$from_dir}/include/utils/external_cache.php")) {
$allFiles[] = "{$from_dir}/include/utils/external_cache.php";
}
if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) {
$allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php";
}
if (file_exists("{$from_dir}/include/utils/sugar_file_utils.php")) {
$allFiles[] = "{$from_dir}/include/utils/sugar_file_utils.php";
}
foreach ($allFiles as $k => $file) {
$destFile = str_replace($from_dir . "/", "", $file);
if (!is_dir(dirname($destFile))) {
mkdir_recursive(dirname($destFile));
// make sure the directory exists
}
if (stristr($file, 'uw_main.tpl')) {
logThis('Skipping "' . $file . '" - file copy will during commit step.');
} else {
logThis('updating UpgradeWizard code: ' . $destFile);
copy_recursive($file, $destFile);
}
}
}
示例10: getFile
function getFile($zip_file, $file_in_zip)
{
$base_upgrade_dir = sugar_cached("/upgrades");
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例11: extractFile
function extractFile($zip_file, $file_in_zip)
{
global $base_tmp_upgrade_dir;
// strip cwd
$absolute_base_tmp_upgrade_dir = clean_path($base_tmp_upgrade_dir);
$relative_base_tmp_upgrade_dir = clean_path(str_replace(clean_path(getcwd()), '', $absolute_base_tmp_upgrade_dir));
// mk_temp_dir expects relative pathing
$my_zip_dir = mk_temp_dir($relative_base_tmp_upgrade_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}
示例12: performUninstall
function performUninstall($name)
{
$uh = new UpgradeHistory();
$uh->name = $name;
$uh->id_name = $name;
$found = $uh->checkForExisting($uh);
if ($found != null) {
global $sugar_config;
global $mod_strings;
global $current_language;
$base_upgrade_dir = $this->upload_dir . '/upgrades';
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
if (is_file($found->filename)) {
if (!isset($GLOBALS['mi_remove_tables'])) {
$GLOBALS['mi_remove_tables'] = true;
}
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip($found->filename, $unzip_dir);
$mi = new ModuleInstaller();
$mi->silent = true;
$mi->uninstall("{$unzip_dir}");
$found->delete();
unlink(remove_file_extension($found->filename) . '-manifest.php');
unlink($found->filename);
} else {
//file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem
$found->delete();
}
}
}
示例13: upgradeSugarCache
/**
* change from using the older SugarCache in 6.1 and below to the new one in 6.2
*/
function upgradeSugarCache($file)
{
global $sugar_config;
// file = getcwd().'/'.$sugar_config['upload_dir'].$_FILES['upgrade_zip']['name'];
$cacheUploadUpgradesTemp = clean_path(mk_temp_dir("{$sugar_config['upload_dir']}upgrades/temp"));
unzip($file, $cacheUploadUpgradesTemp);
if (!file_exists(clean_path("{$cacheUploadUpgradesTemp}/manifest.php"))) {
logThis("*** ERROR: no manifest file detected while bootstraping upgrade wizard files!");
return;
} else {
include clean_path("{$cacheUploadUpgradesTemp}/manifest.php");
}
$allFiles = array();
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/database"))) {
$allFiles = findAllFiles(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/database"), $allFiles);
}
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/SugarCache"))) {
$allFiles = findAllFiles(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/SugarCache"), $allFiles);
}
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/external_cache.php"))) {
$allFiles[] = clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/external_cache.php");
}
$cwd = clean_path(getcwd());
foreach ($allFiles as $k => $file) {
$file = clean_path($file);
$destFile = str_replace(clean_path($cacheUploadUpgradesTemp . '/' . $manifest['copy_files']['from_dir']), $cwd, $file);
if (!is_dir(dirname($destFile))) {
mkdir_recursive(dirname($destFile));
// make sure the directory exists
}
if (stristr($file, 'uw_main.tpl')) {
logThis('Skipping "' . $file . '" - file copy will during commit step.');
} else {
logThis('updating UpgradeWizard code: ' . $destFile);
copy_recursive($file, $destFile);
}
}
logThis('is sugar_file_util there ' . file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php")));
if (file_exists(clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php"))) {
$file = clean_path("{$cacheUploadUpgradesTemp}/{$manifest['copy_files']['from_dir']}/include/utils/sugar_file_utils.php");
$destFile = str_replace(clean_path($cacheUploadUpgradesTemp . '/' . $manifest['copy_files']['from_dir']), $cwd, $file);
copy($file, $destFile);
}
}
示例14: getFile
function getFile($zip_file, $file_in_zip)
{
global $sugar_config;
$base_upgrade_dir = $sugar_config['upload_dir'] . "/upgrades";
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
$my_zip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip_file($zip_file, $file_in_zip, $my_zip_dir);
return "{$my_zip_dir}/{$file_in_zip}";
}