本文整理汇总了PHP中BigTree::getAvailableFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::getAvailableFileName方法的具体用法?PHP BigTree::getAvailableFileName怎么用?PHP BigTree::getAvailableFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::getAvailableFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
function store($local_file, $file_name, $relative_path, $remove_original = true, $prefixes = array())
{
// If the file name ends in a disabled extension, fail.
if (preg_match($this->DisabledExtensionRegEx, $file_name)) {
$this->DisabledFileError = true;
return false;
}
// If we're auto converting images to JPG from PNG
$file_name = $this->convertJPEG($local_file, $file_name);
// Enforce trailing slashe on relative_path
$relative_path = $relative_path ? rtrim($relative_path, "/") . "/" : "files/";
if ($this->Cloud) {
// Clean up the file name
global $cms;
$parts = BigTree::pathInfo($file_name);
$clean_name = $cms->urlify($parts["filename"]);
if (strlen($clean_name) > 50) {
$clean_name = substr($clean_name, 0, 50);
}
// Best case name
$file_name = $clean_name . "." . strtolower($parts["extension"]);
$x = 2;
// Make sure we have a unique name
while (!$file_name || sqlrows(sqlquery("SELECT `timestamp` FROM bigtree_caches WHERE `identifier` = 'org.bigtreecms.cloudfiles' AND `key` = '" . sqlescape($relative_path . $file_name) . "'"))) {
$file_name = $clean_name . "-{$x}." . strtolower($parts["extension"]);
$x++;
// Check all the prefixes, make sure they don't exist either
if (is_array($prefixes) && count($prefixes)) {
$prefix_query = array();
foreach ($prefixes as $prefix) {
$prefix_query[] = "`key` = '" . sqlescape($relative_path . $prefix . $file_name) . "'";
}
if (sqlrows(sqlquery("SELECT `timestamp` FROM bigtree_caches WHERE identifier = 'org.bigtreecms.cloudfiles' AND (" . implode(" OR ", $prefix_query) . ")"))) {
$file_name = false;
}
}
}
// Upload it
$success = $this->Cloud->uploadFile($local_file, $this->Settings->Container, $relative_path . $file_name, true);
if ($success) {
sqlquery("INSERT INTO bigtree_caches (`identifier`,`key`,`value`) VALUES ('org.bigtreecms.cloudfiles','" . sqlescape($relative_path . $file_name) . "','" . sqlescape(json_encode(array("name" => $file_name, "path" => $relative_path . $file_name, "size" => filesize($local_file)))) . "')");
}
if ($remove_original) {
unlink($local_file);
}
return $success;
} else {
$safe_name = BigTree::getAvailableFileName(SITE_ROOT . $relative_path, $file_name, $prefixes);
if ($remove_original) {
$success = BigTree::moveFile($local_file, SITE_ROOT . $relative_path . $safe_name);
} else {
$success = BigTree::copyFile($local_file, SITE_ROOT . $relative_path . $safe_name);
}
if ($success) {
return "{staticroot}" . $relative_path . $safe_name;
} else {
return false;
}
}
}
示例2:
<?php
$gateway->Service = "linkpoint";
$gateway->Settings["linkpoint-store"] = $_POST["linkpoint-store"];
$gateway->Settings["linkpoint-environment"] = $_POST["linkpoint-environment"];
if ($_FILES["linkpoint-certificate"]["tmp_name"]) {
$filename = BigTree::getAvailableFileName(SERVER_ROOT . "custom/certificates/", $_FILES["linkpoint-certificate"]["name"]);
BigTree::moveFile($_FILES["linkpoint-certificate"]["tmp_name"], SERVER_ROOT . "custom/certificates/" . $filename);
$gateway->Settings["linkpoint-certificate"] = $filename;
}
$gateway->saveSettings();
$admin->growl("Developer", "Updated Payment Gateway");
BigTree::redirect(DEVELOPER_ROOT);
示例3: installLocal
function installLocal()
{
// Create backups folder
BigTree::makeDirectory(SERVER_ROOT . "backups/");
// Doing a core upgrade
if ($this->Extension === false) {
// Move old core into backups
rename(SERVER_ROOT . "core/", SERVER_ROOT . "backups/core-" . BIGTREE_VERSION . "/");
// Backup database
global $admin;
$admin->backupDatabase(SERVER_ROOT . "backups/core-" . BIGTREE_VERSION . "/backup.sql");
// Move new core into place
rename(SERVER_ROOT . "cache/update/core/", SERVER_ROOT . "core/");
// Doing an extension upgrade
} else {
$extension = $this->Extension;
// Create a backups folder for this extension
BigTree::makeDirectory(SERVER_ROOT . "backups/extensions/{$extension}/");
// Read manifest file for current version
$current_manifest = json_decode(file_get_contents(SERVER_ROOT . "extensions/{$extension}/manifest.json"), true);
$old_version = $current_manifest["version"];
// Get a unique directory name
$old_version = BigTree::getAvailableFileName(SERVER_ROOT . "backups/extensions/{$extension}/", $old_version);
// Move old extension into backups
rename(SERVER_ROOT . "extensions/{$extension}/", SERVER_ROOT . "backups/extensions/{$extension}/{$old_version}/");
// Move new extension into place
rename(SERVER_ROOT . "cache/update/", SERVER_ROOT . "extensions/{$extension}/");
}
$this->cleanup();
}