本文整理汇总了PHP中Guardian类的典型用法代码示例。如果您正苦于以下问题:PHP Guardian类的具体用法?PHP Guardian怎么用?PHP Guardian使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Guardian类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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']));
}
示例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);
}
示例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();
}
示例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');
示例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>
示例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>
示例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;
}
示例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));
});
示例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);
?>
示例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>
示例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);
}
}
示例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));
}
});
示例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);
}
}
//.........这里部分代码省略.........