本文整理汇总了PHP中Guardian类的典型用法代码示例。如果您正苦于以下问题:PHP Guardian类的具体用法?PHP Guardian怎么用?PHP Guardian使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Guardian类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: do_private_post
function do_private_post($content, $results)
{
global $config, $speak;
$results = Mecha::O($results);
$results = $config->is->post ? Get::postHeader($results->path, POST . DS . $config->page_type, '/', $config->page_type . ':') : false;
if ($results === false) {
return $speak->plugin_private_post->description;
}
$s = isset($results->fields->pass) ? $results->fields->pass : "";
if (strpos($s, ':') !== false) {
$s = explode(':', $s, 2);
if (isset($s[1])) {
$speak->plugin_private_post->hint = ltrim($s[1]);
}
// override password hint
$s = $s[0];
}
$hash = md5($s . PRIVATE_POST_SALT);
$html = Notify::read(false) . '<div class="overlay--' . File::B(__DIR__) . '"></div><form class="form--' . File::B(__DIR__) . '" action="' . $config->url . '/' . File::B(__DIR__) . '/do:access" method="post">' . NL;
$html .= TAB . Form::hidden('token', Guardian::token()) . NL;
$html .= TAB . Form::hidden('_', $hash) . NL;
$html .= TAB . Form::hidden('kick', $config->url_current) . NL;
$html .= TAB . '<p>' . $speak->plugin_private_post->hint . '</p>' . NL;
$html .= TAB . '<p>' . Form::text('access', "", $speak->password . '…', array('autocomplete' => 'off')) . ' ' . Form::button($speak->submit, null, 'submit') . '</p>' . NL;
$html .= '</form>' . O_END;
if ($results && isset($results->fields->pass) && trim($results->fields->pass) !== "") {
if (!Guardian::happy() && Session::get('is_allow_post_access') !== $hash) {
return $html;
}
}
return $content;
}
开发者ID:tovic,项目名称:private-post-plugin-for-mecha-cms,代码行数:32,代码来源:launch.php
示例2: __callStatic
public static function __callStatic($kin, $arguments = array())
{
$kin = get_called_class() . '::' . $kin;
if (!isset(self::$o[$kin])) {
Guardian::abort('Method <code>' . $kin . '()</code> does not exist.');
}
return call_user_func_array(self::$o[$kin], $arguments);
}
开发者ID:razordaze,项目名称:mecha-cms,代码行数:8,代码来源:base.php
示例3: test_all_false_when_not_logged_in
public function test_all_false_when_not_logged_in()
{
$this->assertFalse(Guardian::hasRole('editor'));
$this->assertFalse(Guardian::hasAnyRole(['editor']));
$this->assertFalse(Guardian::hasAllRoles(['editor', 'reporter']));
$this->assertFalse(Guardian::hasCapability('create_user'));
$this->assertFalse(Guardian::hasAnyCapability(['create_user', 'edit_user']));
$this->assertFalse(Guardian::hasAllCapabilities(['create_user', 'edit_user']));
}
开发者ID:aamirchaudhary,项目名称:guardian,代码行数:9,代码来源:GuardianFacadeTest.php
示例4: send
public static function send($from, $to, $subject, $message, $FP = 'common:')
{
if (trim($to) === "" || !Guardian::check($to, '->email')) {
return false;
}
$header = "MIME-Version: 1.0\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\n";
$header .= "From: " . $from . "\n";
$header .= "Reply-To: " . $from . "\n";
$header .= "Return-Path: " . $from . "\n";
$header .= "X-Mailer: PHP/" . phpversion();
$header = Filter::apply($FP . 'notification.email.header', $header);
$message = Filter::apply($FP . 'notification.email.message', $message);
return mail($to, $subject, $message, $header);
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:15,代码来源:notify.php
示例5: take
public static function take($files)
{
if (!extension_loaded('gd')) {
Guardian::abort('<a href="http://www.php.net/manual/en/book.image.php" title="PHP – Image Processing and GD" rel="nofollow" target="_blank">PHP GD</a> extension is not installed on your web server.');
}
if (is_array($files)) {
self::$open = array();
foreach ($files as $file) {
self::$open[] = File::path($file);
}
} else {
self::$open = File::path($files);
}
$file = is_array(self::$open) ? self::$open[0] : self::$open;
self::$placeholder = File::D($file) . DS . '__' . File::B($file);
self::$original = $file;
File::open($file)->copyTo(self::$placeholder);
self::gen($file);
return new static();
}
开发者ID:razordaze,项目名称:mecha-cms,代码行数:20,代码来源:image.php
示例6:
echo Form::hidden('token', $token);
?>
<?php
Weapon::fire('comment_form_input_before', $hooks);
?>
<?php
Shield::chunk('comment.form.name');
?>
<?php
Shield::chunk('comment.form.email');
?>
<?php
Shield::chunk('comment.form.url');
?>
<?php
echo Form::hidden('parent', Guardian::wayback('parent'));
?>
<?php
Weapon::fire('comment_form_input_after', $hooks);
?>
<?php
Weapon::fire('comment_form_textarea_before', $hooks);
?>
<?php
Shield::chunk('comment.form.message');
?>
<?php
Weapon::fire('comment_form_textarea_after', $hooks);
?>
<?php
Shield::chunk('comment.form.math');
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:comment.form.php
示例7: date
<label class="grid-group">
<span class="grid span-1 form-label"><?php
echo $speak->date;
?>
</span>
<span class="grid span-5">
<?php
echo Form::text('date', Request::get('date', Guardian::wayback('date', $page->date->W3C)), date('c'), array('class' => 'input-block'));
?>
</span>
</label>
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:11,代码来源:date.php
示例8: array
<label class="grid-group">
<span class="grid span-1 form-label"><?php
echo $speak->key;
?>
</span>
<span class="grid span-5">
<?php
echo Form::text('key', Request::get('key', Guardian::wayback('key', $page->key_raw)), null, array('class' => 'input-block'));
?>
</span>
</label>
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:11,代码来源:key.php
示例9: do_footer_manager_link
function do_footer_manager_link($content, $path)
{
global $config, $speak;
if (File::N($path) === 'block.footer.bar') {
$s = Guardian::happy() ? '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout') . '" rel="nofollow">' . $speak->log_out . '</a>' : '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/login') . '" rel="nofollow">' . $speak->log_in . '</a>';
return str_replace('<div class="blog-footer-right">', '<div class="blog-footer-right">' . $s, $content);
}
return $content;
}
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:9,代码来源:launch.php
示例10: 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));
});
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:25,代码来源:route.error.php
示例11: strpos
?>
" method="post">
<?php
echo Form::hidden('token', $token);
?>
<?php
$e = File::E($path !== false ? $path : "");
$is_text = $path === false || strpos(',' . SCRIPT_EXT . ',', ',' . $e . ',') !== false;
$path = File::url($path);
?>
<?php
if ($is_text && $content !== false) {
?>
<p>
<?php
echo Form::textarea('content', Request::get('content', Guardian::wayback('content', $content)), $speak->manager->placeholder_content, array('class' => array('textarea-block', 'textarea-expand', 'code')));
?>
</p>
<?php
}
?>
<p>
<?php
echo Form::hidden('name', $path);
?>
<?php
Weapon::fire('action_before', $hooks);
?>
<?php
echo Jot::button('action', $is_text ? $speak->update : $speak->rename);
?>
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:repair.cache.php
示例12: array
<label class="grid-group">
<span class="grid span-1 form-label"><?php
echo $speak->value;
?>
</span>
<span class="grid span-5">
<?php
echo Form::textarea('value', Converter::str(Request::get('value', Guardian::wayback('value', $page->value))), null, array('class' => 'textarea-block'));
?>
</span>
</label>
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:11,代码来源:value.textarea.php
示例13:
<?php
if ($package = File::exist($destination . DS . $name)) {
if (is_file($package)) {
Package::take($package)->extract();
// Extract the ZIP file
File::open($package)->delete();
// Delete the ZIP file
Config::load();
// Refresh the configuration data ...
Guardian::kick(Config::get('manager.slug') . '/' . $segment);
}
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:13,代码来源:task.package.php
示例14: count
$_path = ASSET . DS . $v;
File::open($_path)->delete();
return $_path;
});
$is_folder_or_file = count($deletes) === 1 && is_dir(ASSET . DS . $deletes[0]) ? 'folder' : 'file';
$P = array('data' => array('files' => $info_path));
Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
Weapon::fire(array('on_asset_update', 'on_asset_destruct'), array($P, $P));
Guardian::kick($config->manager->slug . '/asset/1' . str_replace('&', '&', HTTP::query('path', $p)));
} else {
Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete);
}
Shield::lot(array('segment' => 'asset', 'files' => Mecha::O($deletes)))->attach('manager');
});
/**
* Multiple Asset Action
* ---------------------
*/
Route::accept($config->manager->slug . '/asset/do', function ($path = "") use($config, $speak) {
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
if (!isset($request['selected'])) {
Notify::error($speak->notify_error_no_files_selected);
Guardian::kick($config->manager->slug . '/asset/1');
}
$files = Mecha::walk($request['selected'], function ($v) {
return str_replace('%2F', '/', Text::parse($v, '->encoded_url'));
});
Guardian::kick($config->manager->slug . '/asset/' . $request['action'] . '/files:' . implode(';', $files));
}
});
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:route.asset.php
示例15: do_comment_construct
function do_comment_construct()
{
$config = Config::get();
$speak = Config::speak();
if ($config->page_type === 'article') {
$comment_id = 'comment-%d';
// Your comment ID
$comment_form_id = 'comment-form';
// Your comment form ID
$article = isset($config->article->path) ? $config->article : false;
$G = array('data' => array('article' => Mecha::A($article), 'comment_id' => $comment_id, 'comment_form_id' => $comment_form_id));
if ($article !== false && ($request = Request::post())) {
if ($task = File::exist(SHIELD . DS . $config->shield . DS . 'workers' . DS . 'task.comment.php')) {
require $task;
// Custom comment constructor
} else {
// Check token
Guardian::checkToken($request['token'], $article->url . '#' . $comment_form_id);
$extension = $config->comments->moderation && !Guardian::happy() ? '.hold' : '.txt';
// Check name
if (trim($request['name']) === "") {
Notify::error(Config::speak('notify_error_empty_field', $speak->name));
}
// Check email
if (trim($request['email']) !== "") {
if (!Guardian::check($request['email'], '->email')) {
Notify::error($speak->notify_invalid_email);
} else {
// Disallow passenger(s) from entering your email address in the comment email field
if (!Guardian::happy() && $request['email'] === $config->author->email) {
Notify::warning(Config::speak('notify_warning_forbidden_input', array('<em>' . $request['email'] . '</em>', strtolower($speak->email))));
}
}
} else {
Notify::error(Config::speak('notify_error_empty_field', $speak->email));
}
// Check URL
if (trim($request['url']) !== "" && !Guardian::check($request['url'], '->url')) {
Notify::error($speak->notify_invalid_url);
}
// Check message
if (trim($request['message']) === "") {
Notify::error(Config::speak('notify_error_empty_field', $speak->message));
}
// Check challenge
if (!Guardian::checkMath($request['math'])) {
Notify::error($speak->notify_invalid_math_answer);
}
// Check name length
if (Guardian::check($request['name'], '->too_long', 100)) {
Notify::error(Config::speak('notify_error_too_long', $speak->name));
}
// Check email length
if (Guardian::check($request['email'], '->too_long', 100)) {
Notify::error(Config::speak('notify_error_too_long', $speak->email));
}
// Check URL length
if (Guardian::check($request['url'], '->too_long', 100)) {
Notify::error(Config::speak('notify_error_too_long', $speak->url));
}
// Check message length
if (Guardian::check($request['message'], '->too_long', 1700)) {
Notify::error(Config::speak('notify_error_too_long', $speak->message));
}
// Check for spam keyword(s) in comment
$fucking_words = explode(',', $config->keywords_spam);
foreach ($fucking_words as $spam) {
if ($fuck = trim($spam)) {
if ($request['email'] === $fuck || strpos(strtolower($request['message']), strtolower($fuck)) !== false) {
Notify::warning($speak->notify_warning_intruder_detected . ' <strong class="text-error pull-right">' . $fuck . '</strong>');
break;
}
}
}
if (!Notify::errors()) {
$post = Date::slug($article->time);
$id = (int) time();
$parent = Request::post('parent');
$P = array('data' => $request);
$P['data']['id'] = $id;
$name = strip_tags($request['name']);
$email = Text::parse($request['email'], '->broken_entity');
$url = isset($request['url']) && trim($request['url']) !== "" ? $request['url'] : false;
$parser = strip_tags(Request::post('content_type', $config->html_parser->active));
$message = Text::parse($request['message'], '->text', WISE_CELL . '<img>', false);
$field = Request::post('fields', array());
include File::D(__DIR__, 2) . DS . 'task.fields.php';
// Temporarily disallow image(s) in comment to prevent XSS
$message = preg_replace('#<img(\\s[^<>]*?)>#i', '<img$1>', $message);
Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 1 : 2, 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false))->content($message)->saveTo(COMMENT . DS . $post . '_' . Date::slug($id) . '_' . ($parent ? Date::slug($parent) : '0000-00-00-00-00-00') . $extension);
Notify::success(Config::speak('notify_success_submitted', $speak->comment));
if ($extension === '.hold') {
Notify::info($speak->notify_info_comment_moderation);
}
Weapon::fire(array('on_comment_update', 'on_comment_construct'), array($G, $P));
Guardian::kick($config->url_current . $config->ur_query . (!Guardian::happy() && $config->comments->moderation ? '#' . $comment_form_id : '#' . sprintf($comment_id, Date::format($id, 'U'))));
} else {
Guardian::kick($config->url_current . $config->url_query . '#' . $comment_form_id);
}
}
//.........这里部分代码省略.........
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:101,代码来源:__task.comment.php
示例16: array
<p>
<?php
echo Form::textarea('content', Guardian::wayback('content', $the_content), $speak->manager->placeholder_content, array('class' => array('textarea-block', 'textarea-expand', 'code'), 'data-MTE-config' => '{"tabSize":"' . (isset($editor_tab_size) ? $editor_tab_size : TAB) . '"}'));
?>
</p>
<p>
<?php
if (isset($action_update) && $action_update !== false) {
?>
<?php
echo Jot::button('action', $speak->update);
?>
<?php
}
?>
<?php
if (isset($action_create) && $action_create !== false) {
?>
<?php
echo Jot::button('construct', $speak->create);
?>
<?php
}
?>
<?php
if (isset($path_destruct) && $path_destruct !== false) {
?>
<?php
echo Jot::btn('destruct', $speak->delete, $path_destruct);
?>
<?php
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:unit.editor.1.php
示例17: array
$info_path[] = $_path;
File::open($_path)->delete();
}
$P = array('data' => array('files' => $info_path));
Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
Weapon::fire('on_asset_update', array($P, $P));
Weapon::fire('on_asset_destruct', array($P, $P));
Guardian::kick($config->manager->slug . '/asset/1' . $p);
} else {
Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete);
}
Shield::lot('segment', 'asset')->attach('manager', false);
});
/**
* Multiple Asset Killer
* ---------------------
*/
Route::accept($config->manager->slug . '/asset/kill', function ($path = "") use($config, $speak) {
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
if (!isset($request['selected'])) {
Notify::error($speak->notify_error_no_files_selected);
Guardian::kick($config->manager->slug . '/asset/1');
}
$files = array();
foreach ($request['selected'] as $file) {
$files[] = str_replace('%2F', '/', Text::parse($file, '->encoded_url'));
}
Guardian::kick($config->manager->slug . '/asset/kill/files:' . implode(';', $files));
}
});
开发者ID:razordaze,项目名称:mecha-cms,代码行数:31,代码来源:route.asset.php
示例18: array
Notify::success(Config::speak('notify_file_deleted', '<code>' . File::B($_file) . '</code>'));
} else {
Notify::success(Config::speak('notify_success_deleted', $speak->shield));
}
Weapon::fire(array('on_shield_update', 'on_shield_destruct'), array($P, $P));
Guardian::kick($config->manager->slug . '/shield' . ($_file !== false ? '/' . $folder : ""));
} else {
Notify::warning(Config::speak('notify_confirm_delete_', $file !== false ? '<code>' . $path . '</code>' : '<strong>' . $info->title . '</strong>'));
}
Shield::lot(array('segment' => 'shield', 'folder' => $folder, 'files' => Mecha::O(Get::files(SHIELD . DS . $folder, '*')), 'path' => $path))->attach('manager');
});
/**
* Shield Attacher
* ---------------
*/
Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) {
if (!Guardian::happy(1) || !file_exists(SHIELD . DS . $slug)) {
Shield::abort();
}
$new_config = Get::state_config();
$new_config['shield'] = $path === 'attach' ? $slug : 'normal';
File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600);
$G = array('data' => array('id' => $slug, 'action' => $path));
$mode = $path === 'eject' ? 'eject' : 'mount';
Notify::success(Config::speak('notify_success_updated', $speak->shield));
Weapon::fire(array('on_shield_update', 'on_shield_' . $mode, 'on_shield_' . md5($slug) . '_update', 'on_shield_' . md5($slug) . '_' . $mode), array($G, $G));
foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
File::open($asset_cache)->delete();
}
Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:route.shield.php
示例19: function
<?php
/**
* Shortcode Manager
* -----------------
*/
Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$shortcodes = Get::state_shortcode(null, array(), false);
$G = array('data' => $shortcodes);
Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php'));
if ($request = Request::post()) {
$request = Filter::apply('request:__shortcode', $request);
Guardian::checkToken($request['token']);
$data = array();
for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) {
if (trim($keys[$i]) !== "") {
$data[$keys[$i]] = $request['value'][$i];
}
}
$P = array('data' => $data);
File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600);
Notify::success(Config::speak('notify_success_updated', $speak->shortcode));
Weapon::fire('on_shortcode_update', array($G, $P));
Guardian::kick($config->url_current);
}
Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager');
});
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:30,代码来源:route.shortcode.php
示例20: function
<?php
Weapon::add('on_comment_construct', function ($G, $P) use($config, $speak) {
if ($config->is->post && ($post = $G['data'][$config->page_type])) {
$c = $config->states->{'plugin_' . md5(File::B(__DIR__))};
$title = $post['title'];
$url = $post['url'] . '#' . sprintf($G['data']['comment_id'], Date::format($P['data']['id'], 'U'));
$topic = sprintf($c->subject, $title, $url);
$parser = Request::post('content_type', $config->html_parser->active);
$message = '<blockquote><p>' . sprintf($c->message, $title, $url) . '</p></blockquote>';
$message .= '<h3>' . $P['data']['name'] . '</h3>';
$message .= $parser !== false && $parser !== 'HTML' ? Text::parse($P['data']['message'], '->html') : $P['data']['message'];
$message .= '<p>';
$message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/repair/id:' . $P['data']['id'] . '">' . $speak->edit . '</a>';
$message .= ' / ';
$message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/kill/id:' . $P['data']['id'] . '">' . $speak->delete . '</a>';
$message .= '</p>';
// Sending email notification ...
if (!Guardian::happy() && Notify::send($P['data']['email'], $config->author->email, $topic, $message, 'comment:')) {
Weapon::fire('on_comment_notify_construct', array($P, $config->author->email, $topic, $message));
}
}
});
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:23,代码来源:launch.php
注:本文中的Guardian类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论