本文整理汇总了PHP中File::D方法的典型用法代码示例。如果您正苦于以下问题:PHP File::D方法的具体用法?PHP File::D怎么用?PHP File::D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::D方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public static function load()
{
if ($plugins_order = File::exist(CACHE . DS . 'plugins.order.cache')) {
return File::open($plugins_order)->unserialize();
}
$plugins = array();
$plugins_list = glob(PLUGIN . DS . '*' . DS . 'launch.php', GLOB_NOSORT);
$plugins_payload = count($plugins_list);
sort($plugins_list);
for ($i = 0; $i < $plugins_payload; ++$i) {
$plugins[] = false;
}
for ($j = 0; $j < $plugins_payload; ++$j) {
$plugins_list[$j] = str_replace(PLUGIN . DS, "", File::D($plugins_list[$j]));
if ($overtake = File::exist(PLUGIN . DS . $plugins_list[$j] . DS . '__overtake.txt')) {
$to_index = Mecha::edge((int) file_get_contents($overtake) - 1, 0, $plugins_payload - 1);
array_splice($plugins, $to_index, 0, array($plugins_list[$j]));
} else {
$plugins[$j] = $plugins_list[$j];
}
}
File::serialize($plugins)->saveTo(CACHE . DS . 'plugins.order.cache', 0600);
unset($plugins_list, $plugins_order, $plugins_payload);
return $plugins;
}
示例2: do_response_ping
function do_response_ping($message, $results = array())
{
$results = (object) $results;
if (isset($results->parent) && !is_null($results->parent)) {
$prefix = File::B(File::D($results->path));
$name = is_callable('Get::' . $prefix . 'Anchor') ? call_user_func('Get::' . $prefix . 'Anchor', $results->parent)->name : $results->parent;
$to = '<a href="#' . $prefix . '-' . $results->parent . '">@' . $name . '</a>';
return strpos($message, '<p>') === 0 ? str_replace('^<p>', '<p>' . $to . ' ', '^' . $message) : $message . '<p>' . $to . '</p>';
}
return $message;
}
示例3: foreach
foreach ($files as $file) {
?>
<?php
if (strpos($file->path, $shield_path . 'states' . DS) === 0 || strpos($file->path, $shield_path . 'workers' . DS) === 0) {
continue;
}
?>
<?php
$url = File::url(str_replace($shield_path, "", $file->path));
?>
<tr<?php
echo Session::get('recent_item_update') === File::B($file->path) ? ' class="active"' : "";
?>
>
<td><?php
echo strpos($url, '/') !== false ? Jot::span('fade', File::D($url) . '/') . File::B($url) : $url;
?>
</td>
<td class="td-icon">
<?php
echo Jot::a('construct', $shield_url_repair . $url, Jot::icon('pencil'), array('title' => $speak->edit));
?>
</td>
<td class="td-icon">
<?php
echo Jot::a('destruct', $shield_url_kill . $url, Jot::icon('times'), array('title' => $speak->delete));
?>
</td>
</tr>
<?php
}
示例4: post
/**
* ==========================================================================
* EXTRACT POST FILE INTO LIST OF POST DATA FROM ITS PATH/SLUG/ID
* ==========================================================================
*
* -- CODE: -----------------------------------------------------------------
*
* var_dump(Get::post('about'));
*
* --------------------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* ---------- | ------ | ---------------------------------------------------
* $reference | mixed | Slug, ID, path or array of `Get::postExtract()`
* $excludes | array | Exclude some field(s) from result(s)
* $folder | string | Folder of the post(s)
* $connector | string | Path connector for post URL
* $FP | string | Filter prefix for `Text::toPage()`
* ---------- | ------ | ---------------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function post($reference, $excludes = array(), $folder = POST, $connector = '/', $FP = 'post:')
{
$config = Config::get();
$speak = Config::speak();
$excludes = array_flip($excludes);
$results = false;
if (!is_array($reference)) {
// By slug => `post-slug` or by ID => `1403355917`
if (strpos($reference, $folder) !== 0) {
$reference = self::postPath($reference, $folder);
}
// By path => `lot\posts\$folder\2014-06-21-20-05-17_1,2,3_page-slug.txt`
$results = self::postExtract($reference, $FP);
} else {
// From `Get::postExtract()`
$results = $reference;
}
if (!$results || !file_exists($results['path'])) {
return false;
}
// RULES: Do not do any tags looping, content parsing
// and external file requesting if it has been marked as
// the excluded field(s). For better performance.
$results = $results + Text::toPage(file_get_contents($results['path']), isset($excludes['content']) ? false : 'content', $FP, array('link' => "", 'author' => $config->author->name, 'description' => "", 'content_type' => $config->html_parser->active, 'fields' => array(), 'content' => "", 'css' => "", 'js' => ""), $results);
$content = $results['content_raw'];
$time = str_replace(array(' ', ':'), '-', $results['time']);
$e = File::E($results['path']);
// Custom post content with PHP file, named as the post slug
if ($php = File::exist(File::D($results['path']) . DS . $results['slug'] . '.php')) {
ob_start();
include $php;
$results['content'] = ob_get_clean();
}
$results['date'] = Filter::colon($FP . 'date', Date::extract($results['time']), $results);
$results['url'] = Filter::colon($FP . 'url', $config->url . $connector . $results['slug'], $results);
$results['excerpt'] = $more = "";
if ($content !== "") {
$exc = isset($excludes['content']) && strpos($content, '<!--') !== false ? Text::toPage(Converter::ES($content), 'content', $FP, array(), $results) : $results;
$exc = $exc['content'];
$exc = is_array($exc) ? implode("", $exc) : $exc;
// Generate fake description data
if ($results['description'] === "") {
$results['description'] = Converter::curt($exc, $config->excerpt->length, $config->excerpt->suffix);
}
// Manual post excerpt with `<!-- cut+ "Read More" -->`
if (strpos($exc, '<!-- cut+ ') !== false) {
preg_match('#<!-- cut\\+( +([\'"]?)(.*?)\\2)? -->#', $exc, $matches);
$more = !empty($matches[3]) ? $matches[3] : $speak->read_more;
$more = '<p><a class="fi-link" href="' . $results['url'] . '#' . sprintf($config->excerpt->id, $results['id']) . '">' . $more . '</a></p>';
$exc = preg_replace('#<!-- cut\\+( +(.*?))? -->#', '<!-- cut -->', $exc);
}
// ... or `<!-- cut -->`
if (strpos($exc, '<!-- cut -->') !== false) {
$parts = explode('<!-- cut -->', $exc, 2);
$results['excerpt'] = Filter::colon($FP . 'excerpt', trim($parts[0]) . $more, $results);
$results['content'] = trim($parts[0]) . NL . NL . '<span class="fi" id="' . sprintf($config->excerpt->id, $results['id']) . '" aria-hidden="true"></span>' . NL . NL . trim($parts[1]);
}
}
// Post Tags
if (!isset($excludes['tags'])) {
$tags = array();
foreach ($results['kind'] as $id) {
$tags[] = call_user_func('self::' . rtrim($FP, ':') . 'Tag', 'id:' . $id);
}
$results['tags'] = Filter::colon($FP . 'tags', Mecha::eat($tags)->order('ASC', 'name')->vomit(), $results);
}
// Post Images
$results['images'] = Filter::colon($FP . 'images', self::imagesURL($results['content']), $results);
$results['image'] = Filter::colon($FP . 'image', isset($results['images'][0]) ? $results['images'][0] : Image::placeholder(), $results);
// Post CSS and JS
if ($file = File::exist(CUSTOM . DS . Date::slug($results['time']) . '.' . File::E($results['path']))) {
$custom = explode(SEPARATOR, File::open($file)->read());
$css = isset($custom[0]) ? Converter::DS(trim($custom[0])) : "";
$js = isset($custom[1]) ? Converter::DS(trim($custom[1])) : "";
// css_raw
// post:css_raw
// custom:css_raw
//.........这里部分代码省略.........
示例5: foreach
// New file data
if (isset($_FILES) && !empty($_FILES)) {
$accept = File::$config['file_extension_allow'];
foreach ($_FILES as $k => $v) {
if (isset($field[$k]['accept'])) {
File::$config['file_extension_allow'] = explode(',', $field[$k]['accept']);
}
if ($v['size'] > 0 && $v['error'] === 0) {
$name = $name_o = Text::parse($v['name'], '->safe_file_name');
// Group substance by extension
if ($e = File::E($name, false)) {
$name = $e . DS . $name;
}
// File already exists. Don't overwrite and don't show the error message
if (file_exists(SUBSTANCE . DS . $name)) {
$field[$k]['value'] = File::url($name_o);
Notify::info(Config::speak('notify_file_exist', '<code>' . $name . '</code>'));
// Upload new file
} else {
File::upload($v, SUBSTANCE . DS . File::D($name));
if (!Notify::errors()) {
$field[$k]['value'] = File::url($name_o);
Weapon::fire(array('on_substance_update', 'on_substance_construct'), array($G, $P));
}
}
}
File::$config['file_extension_allow'] = $accept;
}
unset($accept);
}
示例6: function
<?php
/**
* Error Log
* ---------
*/
Route::accept($config->manager->slug . '/error', function () use($config, $speak) {
Config::set(array('page_title' => $speak->errors . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.error.php'));
Shield::lot(array('segment' => 'error', 'content' => File::open(ini_get('error_log'))->read(false)))->attach('manager');
});
/**
* Error Log Killer
* ----------------
*/
Route::accept($config->manager->slug . '/error/kill', function () use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$errors = LOG . DS . 'errors.log';
$G = array('data' => array('content' => File::open($errors)->read()));
File::open($errors)->delete();
Weapon::fire('on_error_destruct', array($G, $G));
Notify::success(Config::speak('notify_success_deleted', $speak->file));
Guardian::kick(File::D($config->url_current));
});
示例7: array
<?php
// Deleting custom CSS and JavaScript file of article ...
File::open(CUSTOM . DS . Date::format($id, 'Y-m-d-H-i-s') . '.txt')->delete();
File::open(CUSTOM . DS . Date::format($id, 'Y-m-d-H-i-s') . '.draft')->delete();
Weapon::fire('on_custom_update', array($G, $P));
Weapon::fire('on_custom_destruct', array($G, $P));
// Deleting custom PHP file of article ...
File::open(File::D($task_connect->path) . DS . $task_connect->slug . '.php')->delete();
示例8: function
<?php
/**
* Login Page
* ----------
*
* [1]. manager/login
*
*/
Route::accept($config->manager->slug . '/login', function () use($config, $speak) {
if (!File::exist(File::D(__DIR__) . DS . 'launch.php')) {
Shield::abort('404-manager');
}
if (Guardian::happy()) {
Guardian::kick($config->manager->slug . '/article');
}
Config::set(array('page_title' => $speak->log_in . $config->title_separator . $config->title, 'cargo' => 'cargo.login.php'));
include __DIR__ . DS . 'cargo.php';
if ($request = Request::post()) {
Guardian::authorize()->kick(isset($request['kick']) ? $request['kick'] : $config->manager->slug . '/article');
}
Shield::attach('manager-login');
}, 20);
/**
* Logout Page
* -----------
*
* [1]. manager/logout
*
*/
Route::accept($config->manager->slug . '/logout', function () use($config, $speak) {
示例9: array
$task_connect_page_css = $config->defaults->page_custom_css;
$task_connect_page_js = $config->defaults->page_custom_js;
// Ignite
if (!$id) {
Page::header($header)->content($content)->saveTo(PAGE . DS . Date::format($date, 'Y-m-d-H-i-s') . '__' . $slug . $extension);
include DECK . DS . 'workers' . DS . 'task.custom.2.php';
Notify::success(Config::speak('notify_success_created', $title) . ($extension === '.txt' ? ' <a class="pull-right" href="' . $config->url . '/' . $slug . '" target="_blank"><i class="fa fa-eye"></i> ' . $speak->view . '</a>' : ""));
Weapon::fire('on_page_update', array($G, $P));
Weapon::fire('on_page_construct', array($G, $P));
Guardian::kick($config->manager->slug . '/page/repair/id:' . Date::format($date, 'U'));
// Repair
} else {
Page::open($page->path)->header($header)->content($content)->save();
File::open($page->path)->renameTo(Date::format($date, 'Y-m-d-H-i-s') . '__' . $slug . $extension);
include DECK . DS . 'workers' . DS . 'task.custom.1.php';
if ($page->slug !== $slug && ($php_file = File::exist(File::D($page->path) . DS . $page->slug . '.php'))) {
File::open($php_file)->renameTo($slug . '.php');
}
Notify::success(Config::speak('notify_success_updated', $title) . ($extension === '.txt' ? ' <a class="pull-right" href="' . $config->url . '/' . $slug . '" target="_blank"><i class="fa fa-eye"></i> ' . $speak->view . '</a>' : ""));
Weapon::fire('on_page_update', array($G, $P));
Weapon::fire('on_page_repair', array($G, $P));
Guardian::kick($config->manager->slug . '/page/repair/id:' . Date::format($date, 'U'));
}
}
}
Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
echo Asset::javascript('manager/assets/sword/editor.compose.js', "", 'sword/editor.compose.min.js');
}, 11);
Shield::lot(array('segment' => 'page', 'default' => $page))->attach('manager', false);
});
/**
示例10: function
* =============================================================
*
* -- CODE: ----------------------------------------------------
*
* Config::load();
*
* -------------------------------------------------------------
*
*/
Config::plug('load', function () {
// Extract the configuration file
$config = Get::state_config();
// Define some default variable(s)
$config['protocol'] = $config['url_protocol'] = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] === 443 ? 'https://' : 'http://';
$config['host'] = $config['url_host'] = $_SERVER['HTTP_HOST'];
$config['base'] = $config['url_base'] = trim(File::url(File::D($_SERVER['SCRIPT_NAME'])), '/');
$config['url'] = rtrim($config['protocol'] . $config['host'] . '/' . $config['base'], '/');
$config['url_path'] = trim(str_replace('/?', '?', $_SERVER['REQUEST_URI']), '/') === $config['base'] . '?' . trim('?' . $_SERVER['QUERY_STRING'], '/?') ? "" : preg_replace('#[?&].*$#', "", trim('?' . $_SERVER['QUERY_STRING'], '/?'));
$config['url_current'] = rtrim($config['url'] . '/' . $config['url_path'], '/');
$config['page_title'] = $config['title'];
$config['index_query'] = $config['tag_query'] = $config['archive_query'] = $config['search_query'] = "";
$config['articles'] = $config['article'] = $config['pages'] = $config['page'] = $config['responses'] = $config['response'] = $config['files'] = $config['file'] = $config['pagination'] = $config['cargo'] = false;
$config['total_articles'] = count(glob(ARTICLE . DS . '*.txt', GLOB_NOSORT));
$config['total_pages'] = count(glob(PAGE . DS . '*.txt', GLOB_NOSORT));
$config['total_comments'] = count(glob(RESPONSE . DS . '*.txt', GLOB_NOSORT));
$config['total_articles_backend'] = count(glob(ARTICLE . DS . '*.{txt,draft,archive}', GLOB_NOSORT | GLOB_BRACE));
$config['total_pages_backend'] = count(glob(PAGE . DS . '*.{txt,draft,archive}', GLOB_NOSORT | GLOB_BRACE));
$config['total_comments_backend'] = count(glob(RESPONSE . DS . '*.{txt,hold}', GLOB_NOSORT | GLOB_BRACE));
$page = '404';
$path = $config['url_path'];
$s = explode('/', $path);
示例11: saveAs
/**
* ====================================================================
* SAVE IMAGE TO THE CURRENT DIRECTORY
* ====================================================================
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ------ | ----------------------------------------------
* $name | string | New name for the image
* --------- | ------ | ----------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function saveAs($name = 'image-%d.png')
{
return self::saveTo(File::D(self::$placeholder) . DS . sprintf($name, time()));
}
示例12: rtrim
<?php
$q_path = Request::get('path', "");
$q_path_dir = rtrim(File::D($q_path), '.');
$q = $q_path ? '?path=' . Text::parse($q_path, '->encoded_url') : "";
?>
<table class="table-bordered table-full-width">
<thead>
<tr>
<th class="th-icon">
<?php
echo Form::checkbox(null, null, false, "", array('data-connection' => 'selected[]'));
?>
</th>
<th class="th-collapse"><?php
echo Config::speak('last_', $speak->updated);
?>
</th>
<th><?php
echo $speak->file;
?>
</th>
<th class="text-center" colspan="2"><?php
echo $speak->action;
?>
</th>
</tr>
</thead>
<tbody>
<?php
if ($files) {
示例13: renameFiles
/**
* ====================================================================
* RENAME FILE(S) INSIDE A ZIP FILE
* ====================================================================
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ----- | -----------------------------------------------
* $old | array | Array of old file name and new file name
* --------- | ----- | -----------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function renameFiles($old, $new = "")
{
$zip = new ZipArchive();
if (File::exist(self::$open) && $zip->open(self::$open)) {
if (is_array($old)) {
foreach ($old as $k => $v) {
$k = File::path($k);
$v = File::path($v);
$root = trim(File::D($k), DS . '.') !== "" ? File::D($k) . DS : "";
$zip->renameName($k, $root . File::B($v));
}
} else {
$old = File::path($old);
$root = trim(File::D($old), DS . '.') !== "" ? File::D($old) . DS : "";
$zip->renameName($old, $root . File::B($new));
}
$zip->close();
}
return new static();
}
示例14: array
Weapon::fire('main_action_before', $hooks);
?>
<?php
echo Jot::button('destruct', $speak->delete, 'action:kill');
?>
<?php
Weapon::fire('main_action_after', $hooks);
?>
</div>
<?php
$asset_url = $config->manager->slug . '/asset';
$asset_url_kill = $asset_url . '/kill/file:';
$asset_url_repair = $asset_url . '/repair/file:';
$asset_path = ASSET . DS;
$q_path = Request::get('path', "");
$q_path_parent = File::D($q_path);
$q_path_ = str_replace('&', '&', HTTP::query(array('path' => $q_path ? $q_path : false, 'q' => false)));
$q_path_parent_ = str_replace('&', '&', HTTP::query(array('path' => $q_path_parent ? $q_path_parent : false, 'q' => false)));
?>
<table class="table-bordered table-full-width">
<thead>
<tr>
<th class="th-icon">
<?php
echo Form::checkbox(null, null, false, "", array('data-connection' => 'selected[]'));
?>
</th>
<th class="th-collapse"><?php
echo Config::speak('last_', $speak->updated);
?>
</th>
示例15: array
if (!Guardian::happy(1) && Guardian::get('author') !== $post->author) {
Shield::abort();
}
Config::set(array('page_title' => $speak->deleting . ': ' . $post->title . $config->title_separator . $config->manager->title, 'page' => $post, 'cargo' => 'kill.post.php'));
$G = array('data' => Mecha::A($post));
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
File::open($post->path)->delete();
// Deleting response(s) ...
if ($responses = call_user_func('Get::' . $response . 's', 'DESC', 'post:' . $id, 'txt,hold')) {
foreach ($responses as $v) {
File::open($v)->delete();
}
}
$P = array('data' => $request);
include __DIR__ . DS . 'task.kill.substance.php';
// Deleting custom CSS and JavaScript file of post ...
File::open(CUSTOM . DS . Date::slug($id) . '.txt')->delete();
File::open(CUSTOM . DS . Date::slug($id) . '.draft')->delete();
Weapon::fire(array('on_custom_update', 'on_custom_destruct'), array($G, $P));
// Deleting custom PHP file of post ...
File::open(File::D($post->path) . DS . $post->slug . '.php')->delete();
Notify::success(Config::speak('notify_success_deleted', $post->title));
Weapon::fire(array('on_' . $segment . '_update', 'on_' . $segment . '_destruct'), array($G, $G));
Guardian::kick($config->manager->slug . '/' . $segment);
} else {
Notify::warning(Config::speak('notify_confirm_delete_', '<strong>' . $post->title . '</strong>'));
Notify::warning(Config::speak('notify_confirm_delete_page', strtolower($speak->{$segment}), strtolower($speak->{$response . 's'})));
}
Shield::lot(array('segment' => $segment))->attach('manager');
});