本文整理汇总了PHP中BigTree::putFile方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::putFile方法的具体用法?PHP BigTree::putFile怎么用?PHP BigTree::putFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BigTree
的用法示例。
在下文中一共展示了BigTree::putFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
// If the cache exists, just use it.
if (file_exists(SERVER_ROOT . "cache/bigtree-module-class-list.json")) {
$items = json_decode(file_get_contents(SERVER_ROOT . "cache/bigtree-module-class-list.json"), true);
} else {
// Get the Module Class List
$q = sqlquery("SELECT * FROM bigtree_modules");
$items = array();
while ($f = sqlfetch($q)) {
$items[$f["class"]] = $f["route"];
}
// Cache it so we don't hit the database.
BigTree::putFile(SERVER_ROOT . "cache/bigtree-module-class-list.json", BigTree::json($items));
}
$this->ModuleClassList = $items;
}
示例2: fopen
<?php
// Remove existing update zips
@unlink(SERVER_ROOT . "cache/update.zip");
// Get download info
$url = $cms->cacheGet("org.bigtreecms.downloads", $_POST["key"]);
$cms->cacheDelete("org.bigtreecms.downloads", $_POST["key"]);
// Try fopen first
$resource = @fopen($url, "r");
if ($resource) {
BigTree::putFile(SERVER_ROOT . "cache/update.zip", $resource);
} else {
$file = fopen(SERVER_ROOT . "cache/update.zip", "w");
$curl = curl_init();
curl_setopt_array($curl, array(CURLOPT_URL => $url, CURLOPT_TIMEOUT => 300, CURLOPT_FILE => $file));
curl_exec($curl);
fclose($file);
}
示例3: getCachedFieldTypes
static function getCachedFieldTypes($split = false)
{
// Used cached values if available, otherwise query the DB
if (file_exists(SERVER_ROOT . "cache/bigtree-form-field-types.json")) {
$types = json_decode(file_get_contents(SERVER_ROOT . "cache/bigtree-form-field-types.json"), true);
} else {
$types["modules"] = $types["templates"] = $types["callouts"] = $types["settings"] = array("default" => array("text" => array("name" => "Text", "self_draw" => false), "textarea" => array("name" => "Text Area", "self_draw" => false), "html" => array("name" => "HTML Area", "self_draw" => false), "upload" => array("name" => "Upload", "self_draw" => false), "list" => array("name" => "List", "self_draw" => false), "checkbox" => array("name" => "Checkbox", "self_draw" => false), "date" => array("name" => "Date Picker", "self_draw" => false), "time" => array("name" => "Time Picker", "self_draw" => false), "datetime" => array("name" => "Date & Time Picker", "self_draw" => false), "photo-gallery" => array("name" => "Photo Gallery", "self_draw" => false), "callouts" => array("name" => "Callouts", "self_draw" => true), "matrix" => array("name" => "Matrix", "self_draw" => true), "one-to-many" => array("name" => "One to Many", "self_draw" => false)), "custom" => array());
$types["modules"]["default"]["route"] = array("name" => "Generated Route", "self_draw" => true);
unset($types["callouts"]["default"]["callouts"]);
$q = sqlquery("SELECT * FROM bigtree_field_types ORDER BY name");
while ($f = sqlfetch($q)) {
$use_cases = json_decode($f["use_cases"], true);
foreach ((array) $use_cases as $case => $val) {
if ($val) {
$types[$case]["custom"][$f["id"]] = array("name" => $f["name"], "self_draw" => $f["self_draw"]);
}
}
}
BigTree::putFile(SERVER_ROOT . "cache/bigtree-form-field-types.json", BigTree::json($types));
}
// Re-merge if we don't want them split
if (!$split) {
foreach ($types as $use_case => $list) {
$types[$use_case] = array_merge($list["default"], $list["custom"]);
}
}
return $types;
}
示例4: page
- Not a forced secure page (i.e. checkout)
- User is logged BigTree admin
- User is logged into the BigTree admin FOR THIS PAGE
- Developer mode is either disabled OR the logged in user is a Developer
*/
if (isset($bigtree["page"]) && !BigTreeCMS::$Secure && $_SESSION["bigtree_admin"]["id"] && $_COOKIE["bigtree_admin"]["email"] && (empty($bigtree["config"]["developer_mode"]) || $_SESSION["bigtree_admin"]["level"] > 1)) {
$show_bar_default = $_COOKIE["hide_bigtree_bar"] ? false : true;
$show_preview_bar = false;
$return_link = "";
if (!empty($_GET["bigtree_preview_return"])) {
$show_bar_default = false;
$show_preview_bar = true;
$return_link = htmlspecialchars(urlencode($_GET["bigtree_preview_return"]));
}
// Pending Pages don't have their ID set.
if (!isset($bigtree["page"]["id"])) {
$bigtree["page"]["id"] = $bigtree["page"]["page"];
}
$bigtree["content"] = str_ireplace('</body>', '<script type="text/javascript" src="' . str_replace(array("http://", "https://"), "//", $bigtree["config"]["admin_root"]) . 'ajax/bar.js/?previewing=' . BIGTREE_PREVIEWING . '&current_page_id=' . $bigtree["page"]["id"] . '&show_bar=' . $show_bar_default . '&username=' . $_SESSION["bigtree_admin"]["name"] . '&show_preview=' . $show_preview_bar . '&return_link=' . $return_link . '&custom_edit_link=' . (empty($bigtree["bar_edit_link"]) ? "" : BigTree::safeEncode($bigtree["bar_edit_link"])) . '"></script></body>', $bigtree["content"]);
// Don't cache the page with the BigTree bar
$bigtree["config"]["cache"] = false;
}
echo $bigtree["content"];
// Write to the cache
if ($bigtree["config"]["cache"] && !defined("BIGTREE_DO_NOT_CACHE") && !count($_POST)) {
$cache = ob_get_flush();
if (!$bigtree["page"]["path"]) {
$bigtree["page"]["path"] = "!";
}
BigTree::putFile(SERVER_ROOT . "cache/" . md5(json_encode($_GET)) . ".page", $cache);
}
示例5: foreach
} else {
$package["sql_revisions"][$revision][] = "DROP TABLE IF EXISTS `{$table}`";
}
}
// Add new tables that don't exist in the old manifest
foreach ($package["components"]["tables"] as $table => $create_statement) {
if (!isset($existing_json["components"]["tables"][$table])) {
$package["sql_revisions"][$revision][] = $create_statement;
}
}
// Clean up the revisions (if we don't have any)
$package["sql_revisions"] = array_filter($package["sql_revisions"]);
}
// Write the manifest file
$json = BigTree::json($package);
BigTree::putFile(SERVER_ROOT . "extensions/{$id}/manifest.json", $json);
// Create the zip, clear caches since we may have moved the routes of field types and modules
@unlink(SERVER_ROOT . "cache/package.zip");
@unlink(SERVER_ROOT . "cache/bigtree-form-field-types.json");
@unlink(SERVER_ROOT . "cache/bigtree-module-class-list.json");
include BigTree::path("inc/lib/pclzip.php");
$zip = new PclZip(SERVER_ROOT . "cache/package.zip");
$zip->create(BigTree::directoryContents(SERVER_ROOT . "extensions/{$id}/"), PCLZIP_OPT_REMOVE_PATH, SERVER_ROOT . "extensions/{$id}/");
// Store it in the database for future updates -- existing packages might be replaced
if (sqlrows(sqlquery("SELECT id FROM bigtree_extensions WHERE id = '" . sqlescape($id) . "'"))) {
sqlquery("UPDATE bigtree_extensions SET type = 'extension', name = '" . sqlescape($title) . "', version = '" . sqlescape($version) . "', last_updated = NOW(), manifest = '" . sqlescape($json) . "' WHERE id = '" . sqlescape($id) . "'");
} else {
sqlquery("INSERT INTO bigtree_extensions (`id`,`type`,`name`,`version`,`last_updated`,`manifest`) VALUES ('" . sqlescape($id) . "','extension','" . sqlescape($title) . "','" . sqlescape($version) . "',NOW(),'" . sqlescape($json) . "')");
}
// Turn foreign key checks back on
sqlquery("SET foreign_key_checks = 1");
示例6: implode
}
}
$package["sql"][] = "INSERT INTO `{$table}` (" . implode(",", $fields) . ") VALUES (" . implode(",", $values) . ")";
}
}
$package["components"]["tables"][] = $table;
}
$package["sql"][] = "SET foreign_key_checks = 1";
foreach ((array) $files as $file) {
$file = str_replace(SERVER_ROOT, "", $file);
BigTree::copyFile(SERVER_ROOT . $file, SERVER_ROOT . "cache/package/" . $file);
$package["files"][] = $file;
}
// Write the manifest file
$json = BigTree::json($package);
BigTree::putFile(SERVER_ROOT . "cache/package/manifest.json", $json);
// Create the zip
@unlink(SERVER_ROOT . "cache/package.zip");
include BigTree::path("inc/lib/pclzip.php");
$zip = new PclZip(SERVER_ROOT . "cache/package.zip");
$zip->create(BigTree::directoryContents(SERVER_ROOT . "cache/package/"), PCLZIP_OPT_REMOVE_PATH, SERVER_ROOT . "cache/package/");
// Remove the package directory
BigTree::deleteDirectory(SERVER_ROOT . "cache/package/");
// Store it in the database for future updates
if (sqlrows(sqlquery("SELECT * FROM bigtree_extensions WHERE id = '" . sqlescape($id) . "'"))) {
sqlquery("UPDATE bigtree_extensions SET name = '" . sqlescape($title) . "', version = '" . sqlescape($version) . "', last_updated = NOW(), manifest = '" . sqlescape($json) . "' WHERE id = '" . sqlescape($id) . "'");
} else {
sqlquery("INSERT INTO bigtree_extensions (`id`,`type`,`name`,`version`,`last_updated`,`manifest`) VALUES ('" . sqlescape($id) . "','package','" . sqlescape($title) . "','" . sqlescape($version) . "',NOW(),'" . sqlescape($json) . "')");
}
?>
<div class="container">
示例7: unzip
static function unzip($file, $destination)
{
// If we can't write the output directory, we're not getting anywhere.
if (!BigTree::isDirectoryWritable($destination)) {
return false;
}
// Up the memory limit for the unzip.
ini_set("memory_limit", "512M");
$destination = rtrim($destination) . "/";
BigTree::makeDirectory($destination);
// If we have the built in ZipArchive extension, use that.
if (class_exists("ZipArchive")) {
$z = new ZipArchive();
if (!$z->open($file)) {
// Bad zip file.
return false;
}
for ($i = 0; $i < $z->numFiles; $i++) {
if (!($info = $z->statIndex($i))) {
// Unzipping the file failed for some reason.
return false;
}
// If it's a directory, ignore it. We'll create them in putFile.
if (substr($info["name"], -1) == "/") {
continue;
}
// Ignore __MACOSX and all it's files.
if (substr($info["name"], 0, 9) == "__MACOSX/") {
continue;
}
$content = $z->getFromIndex($i);
if ($content === false) {
// File extraction failed.
return false;
}
BigTree::putFile($destination . $file["name"], $content);
}
$z->close();
return true;
// Fall back on PclZip if we don't have the "native" version.
} else {
// WordPress claims this could be an issue, so we'll make sure multibyte encoding isn't overloaded.
if (ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding')) {
$previous_encoding = mb_internal_encoding();
mb_internal_encoding('ISO-8859-1');
}
$z = new PclZip($file);
$archive = $z->extract(PCLZIP_OPT_EXTRACT_AS_STRING);
// If we saved a previous encoding, reset it now.
if (isset($previous_encoding)) {
mb_internal_encoding($previous_encoding);
unset($previous_encoding);
}
// If it's not an array, it's not a good zip. Also, if it's empty it's not a good zip.
if (!is_array($archive) || !count($archive)) {
return false;
}
foreach ($archive as $item) {
// If it's a directory, ignore it. We'll create them in putFile.
if ($item["folder"]) {
continue;
}
// Ignore __MACOSX and all it's files.
if (substr($item["filename"], 0, 9) == "__MACOSX/") {
continue;
}
BigTree::putFile($directory . $item["filename"], $item["content"]);
}
return true;
}
}
示例8: cacheInformation
function cacheInformation()
{
$cache = array();
// First we're going to update the monthly view counts for all pages.
$results = $this->getData($this->Settings["profile"], "1 month ago", "today", "pageviews", "pagePath");
$used_paths = array();
foreach ($results as $item) {
$clean_path = sqlescape(trim($item->pagePath, "/"));
$views = sqlescape($item->pageviews);
// Sometimes Google has slightly different routes like "cheese" and "cheese/" so we need to add these page views together.
if (in_array($clean_path, $used_paths)) {
sqlquery("UPDATE bigtree_pages SET ga_page_views = (ga_page_views + {$views}) WHERE `path` = '{$clean_path}'");
} else {
sqlquery("UPDATE bigtree_pages SET ga_page_views = {$views} WHERE `path` = '{$clean_path}'");
$used_paths[] = $clean_path;
}
}
// Service Provider report
$results = $this->getData($this->Settings["profile"], "1 month ago", "today", array("pageviews", "visits"), "networkLocation", "-ga:pageviews");
foreach ($results as $item) {
$cache["service_providers"][] = array("name" => $item->networkLocation, "views" => $item->pageviews, "visits" => $item->visits);
}
// Referrer report
$results = $this->getData($this->Settings["profile"], "1 month ago", "today", array("pageviews", "visits"), "source", "-ga:pageviews");
foreach ($results as $item) {
$cache["referrers"][] = array("name" => $item->source, "views" => $item->pageviews, "visits" => $item->visits);
}
// Keyword report
$results = $this->getData($this->Settings["profile"], "1 month ago", "today", array("pageviews", "visits"), "keyword", "-ga:pageviews");
foreach ($results as $item) {
$cache["keywords"][] = array("name" => $item->keyword, "views" => $item->pageviews, "visits" => $item->visits);
}
// Yearly Report
$this->getData($this->Settings["profile"], date("Y-01-01"), date("Y-m-d"), array("pageviews", "visits", "bounces", "timeOnSite"), "browser");
$cache["year"] = $this->cacheParseLastData();
$this->getData($this->Settings["profile"], date("Y-01-01", strtotime("-1 year")), date("Y-m-d", strtotime("-1 year")), array("pageviews", "visits", "bounces", "timeOnSite"), "browser");
$cache["year_ago_year"] = $this->cacheParseLastData();
// Quarterly Report
$quarters = array(1, 3, 6, 9);
$current_quarter_month = $quarters[floor((date("m") - 1) / 3)];
$this->getData($this->Settings["profile"], date("Y-" . str_pad($current_quarter_month, 2, "0", STR_PAD_LEFT) . "-01"), date("Y-m-d"), array("pageviews", "visits", "bounces", "timeOnSite"), "browser");
$cache["quarter"] = $this->cacheParseLastData();
$this->getData($this->Settings["profile"], date("Y-" . str_pad($current_quarter_month, 2, "0", STR_PAD_LEFT) . "-01", strtotime("-1 year")), date("Y-m-d", strtotime("-1 year")), array("pageviews", "visits", "bounces", "timeOnSite"), "browser");
$cache["year_ago_quarter"] = $this->cacheParseLastData();
// Monthly Report
$this->getData($this->Settings["profile"], date("Y-m-01"), date("Y-m-d"), array("pageviews", "visits", "bounces", "timeOnSite"), "browser");
$cache["month"] = $this->cacheParseLastData();
$this->getData($this->Settings["profile"], date("Y-m-01", strtotime("-1 year")), date("Y-m-d", strtotime("-1 year")), array("pageviews", "visits", "bounces", "timeOnSite"), "browser");
$cache["year_ago_month"] = $this->cacheParseLastData();
// Two Week Heads Up
$results = $this->getData($this->Settings["profile"], date("Y-m-d", strtotime("-2 weeks")), date("Y-m-d", strtotime("-1 day")), "visits", "date", "date");
foreach ($results as $item) {
$cache["two_week"][$item->date] = $item->visits;
}
BigTree::putFile(SERVER_ROOT . "cache/analytics.json", BigTree::json($cache));
}