当前位置: 首页>>代码示例>>PHP>>正文


PHP BigTree::isDirectoryWritable方法代码示例

本文整理汇总了PHP中BigTree::isDirectoryWritable方法的典型用法代码示例。如果您正苦于以下问题:PHP BigTree::isDirectoryWritable方法的具体用法?PHP BigTree::isDirectoryWritable怎么用?PHP BigTree::isDirectoryWritable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BigTree的用法示例。


在下文中一共展示了BigTree::isDirectoryWritable方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

<?php

//!BigTree Warnings
$warnings = array();
$writable_directories = array("cache/", "custom/inc/modules/", "custom/admin/ajax/developer/field-options/", "custom/admin/form-field-types/draw/", "custom/admin/form-field-types/process/", "templates/routed/", "templates/basic/", "templates/callouts/", "site/files/");
foreach ($writable_directories as $directory) {
    if (!BigTree::isDirectoryWritable(SERVER_ROOT . $directory)) {
        $warnings[] = array("parameter" => "Directory Permissions Error", "rec" => "Make " . SERVER_ROOT . $directory . " writable.", "status" => "bad");
    }
}
// Go through every module form and look for uploads, make sure the directories exist and are writable.
$forms = array_merge($admin->getModuleForms(), $admin->getModuleEmbedForms());
foreach ($forms as $form) {
    foreach (array_filter((array) $form["fields"]) as $key => $data) {
        if ($data["directory"]) {
            if (!BigTree::isDirectoryWritable(SITE_ROOT . $data["directory"])) {
                $warnings[] = array("parameter" => "Directory Permissions Error", "rec" => "Make " . SITE_ROOT . $data["directory"] . " writable.", "status" => "bad");
            }
        }
    }
}
// Search all content for links to the admin.
$bad = $admin->getPageAdminLinks();
foreach ($bad as $f) {
    $warnings[] = array("parameter" => "Bad Admin Links", "rec" => 'Remove links to Admin on <a href="' . ADMIN_ROOT . 'pages/edit/' . $f["id"] . '/">' . $f["nav_title"] . '</a>', "status" => "ok");
}
if (!file_exists(SITE_ROOT . "favicon.ico")) {
    $warnings[] = array("parameter" => "Missing Favicon", "rec" => "Create a favicon and place it in the /site/ root.", "status" => "ok");
}
//!Server Parameters
$mysql = extension_loaded('mysql') || extension_loaded("mysqli") ? "good" : "bad";
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:status.php

示例2: explode

<?php

// First we need to package the file so they can download it manually if they wish.
if (!BigTree::isDirectoryWritable(SERVER_ROOT . "cache/package/")) {
    ?>
<div class="container">
	<section>
		<h3>Error</h3>
		<p>Your cache/ and cache/package/ directories must be writable.</p>
	</section>
</div>
<?php 
    $admin->stop();
}
@mkdir(SERVER_ROOT . "cache/package/");
// Fix keywords into an array
$keywords = explode(",", $keywords);
foreach ($keywords as &$word) {
    $word = trim($word);
}
// Fix licenses into an array
if ($license_name) {
    $license_array = array($license_name => $license_url);
} elseif ($license) {
    $license_array = array($license => $available_licenses["Closed Source"][$license]);
} else {
    $license_array = array();
    if (is_array($licenses)) {
        foreach ($licenses as $license) {
            $license_array[$license] = $available_licenses["Open Source"][$license];
        }
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:31,代码来源:create.php

示例3: backupDatabase

 static function backupDatabase($file)
 {
     if (!BigTree::isDirectoryWritable($file)) {
         return false;
     }
     $pointer = fopen($file, "w");
     fwrite($pointer, "SET SESSION sql_mode = 'NO_AUTO_VALUE_ON_ZERO';\n");
     fwrite($pointer, "SET foreign_key_checks = 0;\n\n");
     // We need to dump the bigtree tables in the proper order or they will not properly be recreated with the right foreign keys
     $q = sqlquery("SHOW TABLES");
     while ($f = sqlfetch($q)) {
         $table = current($f);
         // Write the drop / create statements
         fwrite($pointer, "DROP TABLE IF EXISTS `{$table}`;\n");
         $definition = sqlfetch(sqlquery("SHOW CREATE TABLE `{$table}`"));
         fwrite($pointer, str_replace(array("\n  ", "\n"), "", end($definition)) . ";\n");
         // Get all the table contents, write them out
         $rows = BigTree::tableContents($table);
         foreach ($rows as $row) {
             fwrite($pointer, $row . ";\n");
         }
         // Separate it from the next table
         fwrite($pointer, "\n");
     }
     fwrite($pointer, "\nSET foreign_key_checks = 1;");
     fclose($pointer);
     return true;
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:28,代码来源:admin.php

示例4: explode

<?php

// First we need to package the file so they can download it manually if they wish.
if (!is_writable(SERVER_ROOT . "cache/") || !BigTree::isDirectoryWritable(SERVER_ROOT . "extensions/{$id}/")) {
    ?>
<div class="container">
	<section>
		<h3>Error</h3>
		<p>Your /cache/ and /extensions/<?php 
    echo $id;
    ?>
/ directories must be writable.</p>
	</section>
</div>
<?php 
    $admin->stop();
}
// Fix keywords into an array
$keywords = explode(",", $keywords);
foreach ($keywords as &$word) {
    $word = trim($word);
}
// Fix licenses into an array
if (array_filter((array) $licenses)) {
    $license_array = array();
    foreach ($licenses as $license) {
        $license_array[$license] = $available_licenses["Open Source"][$license];
    }
} elseif ($license_name) {
    $license_array = array($license_name => $license_url);
} elseif ($license) {
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:create.php

示例5: backupDatabase

 function backupDatabase($file)
 {
     if (!BigTree::isDirectoryWritable($file)) {
         return false;
     }
     $pointer = fopen($file, "w");
     fwrite($pointer, "SET SESSION sql_mode = 'NO_AUTO_VALUE_ON_ZERO';\n");
     fwrite($pointer, "SET foreign_key_checks = 0;\n\n");
     // We need to dump the bigtree tables in the proper order or they will not properly be recreated with the right foreign keys
     $tables = array();
     $q = sqlquery("SHOW TABLES");
     while ($f = sqlfetch($q)) {
         $table = current($f);
         fwrite($pointer, "DROP TABLE IF EXISTS `{$table}`;\n");
         $definition = sqlfetch(sqlquery("SHOW CREATE TABLE `{$table}`"));
         fwrite($pointer, str_replace(array("\n  ", "\n"), "", end($definition)) . ";\n");
         // Need to figure out which columns are binary so that we can request them as hex
         $description = BigTree::describeTable($table);
         $column_query = array();
         $binary_columns = array();
         foreach ($description["columns"] as $key => $column) {
             if ($column["type"] == "tinyblob" || $column["type"] == "blob" || $column["type"] == "mediumblob" || $column["type"] == "longblob" || $column["type"] == "binary" || $column["type"] == "varbinary") {
                 $column_query[] = "HEX(`{$key}`) AS `{$key}`";
                 $binary_columns[] = $key;
             } else {
                 $column_query[] = "`{$key}`";
             }
         }
         $qq = sqlquery("SELECT " . implode(", ", $column_query) . " FROM `{$table}`");
         while ($ff = sqlfetch($qq)) {
             $keys = array();
             $vals = array();
             foreach ($ff as $key => $val) {
                 $keys[] = "`{$key}`";
                 if ($val === null) {
                     $vals[] = "NULL";
                 } else {
                     if (in_array($key, $binary_columns)) {
                         $vals[] = "X'" . sqlescape(str_replace("\n", "\\n", $val)) . "'";
                     } else {
                         $vals[] = "'" . sqlescape(str_replace("\n", "\\n", $val)) . "'";
                     }
                 }
             }
             fwrite($pointer, "INSERT INTO `{$table}` (" . implode(",", $keys) . ") VALUES (" . implode(",", $vals) . ");\n");
         }
         fwrite($pointer, "\n");
     }
     fwrite($pointer, "\nSET foreign_key_checks = 1;");
     fclose($pointer);
     return true;
 }
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:52,代码来源:admin.php

示例6: foreach

        $warnings[] = "A field type already exists with the id &ldquo;" . $type["id"] . "&rdquo; &mdash; the field type will be overwritten.";
    }
}
// Check for table collisions
foreach ((array) $json["sql"] as $command) {
    if (substr($command, 0, 14) == "CREATE TABLE `") {
        $table = substr($command, 14);
        $table = substr($table, 0, strpos($table, "`"));
        if (sqlrows(sqlquery("SHOW TABLES LIKE '{$table}'"))) {
            $warnings[] = "A table named &ldquo;{$table}&rdquo; already exists &mdash; the table will be overwritten.";
        }
    }
}
// Check file permissions and collisions
foreach ((array) $json["files"] as $file) {
    if (!BigTree::isDirectoryWritable(SERVER_ROOT . $file)) {
        $errors[] = "Cannot write to {$file} &mdash; please make the root directory or file writable.";
    } elseif (file_exists(SERVER_ROOT . $file)) {
        if (!is_writable(SERVER_ROOT . $file)) {
            $errors[] = "Cannot overwrite existing file: {$file} &mdash; please make the file writable or delete it.";
        } else {
            $warnings[] = "A file already exists at {$file} &mdash; the file will be overwritten.";
        }
    }
}
?>
<div class="container">
	<summary>
		<h2>
			<?php 
echo $json["title"];
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:unpack.php

示例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;
     }
 }
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:71,代码来源:utils.php

示例8: foreach

foreach ($writable_directories as $directory) {
    if (!BigTree::isDirectoryWritable(SERVER_ROOT . $directory)) {
        $warnings[] = array("parameter" => "Directory Permissions Error", "rec" => "Make " . SERVER_ROOT . $directory . " writable.", "status" => "bad");
    }
}
// Setup a recursive function to loop through fields
$directory_warnings = array();
$recurse_fields = function ($fields) {
    global $directory_warnings, $recurse_fields, $warnings;
    foreach (array_filter((array) $fields) as $key => $data) {
        $options = is_string($data["options"]) ? array_filter((array) json_decode($data["options"], true)) : $data["options"];
        if ($data["type"] == "matrix") {
            $recurse_fields($options["columns"]);
        } else {
            if ($options["directory"]) {
                if (!BigTree::isDirectoryWritable(SITE_ROOT . $options["directory"]) && !in_array($options["directory"], $directory_warnings)) {
                    $directory_warnings[] = $options["directory"];
                    $warnings[] = array("parameter" => "Directory Permissions Error", "rec" => "Make " . SITE_ROOT . $options["directory"] . " writable.", "status" => "bad");
                }
            }
        }
    }
};
// Go through every module form and look for uploads, make sure the directories exist and are writable.
$forms = array_merge($admin->getModuleForms(), $admin->getModuleEmbedForms());
foreach ($forms as $form) {
    $recurse_fields($form["fields"]);
}
// Now templates and callouts
$templates = array_merge($admin->getTemplates(), $admin->getCallouts());
foreach ($templates as $template) {
开发者ID:kalle0045,项目名称:BigTree-CMS,代码行数:31,代码来源:status.php


注:本文中的BigTree::isDirectoryWritable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。