本文整理汇总了PHP中Guardian::happy方法的典型用法代码示例。如果您正苦于以下问题:PHP Guardian::happy方法的具体用法?PHP Guardian::happy怎么用?PHP Guardian::happy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guardian
的用法示例。
在下文中一共展示了Guardian::happy方法的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: cargo
/**
* Default Shortcut Variable(s)
* ----------------------------
*/
public static function cargo()
{
$config = Config::get();
$token = Guardian::token();
$results = array('config' => $config, 'speak' => $config->speak, 'articles' => $config->articles, 'article' => $config->article, 'pages' => $config->pages, 'page' => $config->page, 'pager' => $config->pagination, 'manager' => Guardian::happy(), 'token' => $token, 'messages' => Notify::read(false), 'message' => Notify::read(false));
Session::set(Guardian::$token, $token);
unset($config, $token);
self::$lot = array_merge(self::$lot, $results);
return self::$lot;
}
示例3: manager
/**
* Widget Manager
* --------------
*
* [1]. Widget::manager('MENU');
* [2]. Widget::manager('BAR');
*
*/
public static function manager($type = 'MENU')
{
if (!Guardian::happy()) {
return "";
}
$T1 = TAB;
if ($type === 'MENU') {
$menus = array();
if ($_menus = Mecha::A(Config::get('manager_menu'))) {
$_menus = Mecha::eat($_menus)->order('ASC', 'stack', true, 10)->vomit();
foreach ($_menus as $k => $v) {
// < 1.1.3
if (is_string($v)) {
$menus[$k] = $v;
} else {
$stack = isset($v['stack']) ? $v['stack'] : 10;
$_k = (strpos($v['icon'], '<') === false ? '<i class="fa fa-fw fa-' . $v['icon'] . '"></i>' : $v['icon']) . ' <span class="label">' . $k . '</span>' . (isset($v['count']) && ($v['count'] === '∞' || (double) $v['count'] > 0) ? ' <span class="counter">' . $v['count'] . '</span>' : "");
$menus[$_k] = isset($v['url']) ? $v['url'] : null;
}
}
}
$html = O_BEGIN . '<div class="widget widget-manager widget-manager-menu" id="widget-manager-menu-' . self::$id['manager_menu'] . '">' . NL;
self::$id['manager_menu']++;
$html .= Menu::get($menus, 'ul', $T1, 'manager:');
$html .= '</div>' . O_END;
$html = Filter::apply('widget', $html);
return Filter::apply('widget:manager.menu', Filter::apply('widget:manager', $html));
}
if ($type === 'BAR') {
$html = O_BEGIN . '<div class="widget widget-manager widget-manager-bar" id="widget-manager-bar-' . self::$id['manager_bar'] . '">' . NL;
self::$id['manager_bar']++;
$bars = array();
if ($_bars = Mecha::A(Config::get('manager_bar'))) {
$_bars = Mecha::eat($_bars)->order('ASC', 'stack', true, 10)->vomit();
foreach ($_bars as $k => $v) {
if (is_string($v)) {
$bar = $v;
} else {
$t = ' data-tooltip="' . Text::parse(isset($v['description']) ? $v['description'] : $k, '->encoded_html') . '"';
$bar = isset($v['url']) ? '<a class="item" href="' . Converter::url($v['url']) . '"' . $t . '>' : '<span class="item a"' . $t . '>';
$bar .= isset($v['icon']) ? strpos($v['icon'], '<') === false ? Jot::icon($v['icon']) : $v['icon'] : $k;
$bar .= ' <span class="label">' . $k . '</span>';
if (isset($v['count']) && ($v['count'] === '∞' || (double) $v['count'] > 0)) {
$bar .= ' <span class="counter">' . $v['count'] . '</span>';
}
$bar .= isset($v['url']) ? '</a>' : '</span>';
}
$bars[] = Filter::apply('manager:bar.item', $bar);
}
}
$html .= $T1 . Filter::apply('manager:bar', implode(' ', $bars)) . NL;
$html .= '</div>';
return Filter::apply('widget:manager.bar', Filter::apply('widget:manager', $html));
}
}
示例4: cargo
/**
* Default Shortcut Variable(s)
* ----------------------------
*/
public static function cargo()
{
$config = Config::get();
$token = Guardian::token();
$message = Notify::read();
$results = array('config' => $config, 'speak' => $config->speak, 'articles' => $config->articles, 'article' => $config->article, 'pages' => $config->pages, 'page' => $config->page, 'responses' => $config->responses, 'response' => $config->response, 'files' => $config->files, 'file' => $config->file, 'pager' => $config->pagination, 'manager' => Guardian::happy(), 'token' => $token, 'messages' => $message);
Session::set(Guardian::$token, $token);
Session::set(Notify::$message, $message);
unset($config, $token, $message);
return array_merge($results, self::$lot);
}
示例5: 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);
}
}
//.........这里部分代码省略.........
示例6: md5
// refresh ...
}
Weapon::fire(array('plugin_before', 'plugin_' . md5($k) . '_before'));
if ($launch = File::exist($__ . 'launch.php')) {
if (strpos(File::B($__), '__') === 0) {
if (Guardian::happy() && $config->page_type === 'manager') {
include $launch;
// backend
}
} else {
include $launch;
// frontend
}
}
if ($launch = File::exist($__ . '__launch.php')) {
if (Guardian::happy() && $config->page_type === 'manager') {
include $launch;
// backend
}
}
Weapon::fire(array('plugin_after', 'plugin_' . md5($k) . '_after'));
}
Weapon::fire('plugins_after');
/**
* Check the Plugin(s) Order
* -------------------------
*/
// var_dump($plugins); exit;
/**
* Loading Menu(s)
* ---------------
示例7: array
<?php
if (Guardian::happy(1)) {
Config::merge('manager_menu', array($speak->backup => array('icon' => 'life-ring', 'url' => $config->manager->slug . '/backup', 'stack' => 9.119999999999999)));
}
示例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: function
}, 90);
/**
* Static Page
* -----------
*
* [1]. page-slug
*
*/
Route::accept('(:any)', function ($slug = "") use($config) {
if (!($page = Get::page($slug))) {
Shield::abort('404-page');
}
if ($page->state === 'drafted') {
Shield::abort('404-page');
}
if (isset($_GET['repair']) && Guardian::happy()) {
Guardian::kick($config->manager->slug . '/page/repair/id:' . $page->id);
}
Filter::add('pager:url', function ($url) {
return Filter::apply('page:url', $url);
});
Config::set(array('page_title' => $page->title . $config->title_separator . $config->title, 'page' => $page));
Weapon::add('shell_after', function () use($page) {
if (isset($page->css) && trim($page->css) !== "") {
echo O_BEGIN . $page->css . O_END;
}
});
Weapon::add('sword_after', function () use($page) {
if (isset($page->js) && trim($page->js) !== "") {
echo O_BEGIN . $page->js . O_END;
}
示例10: function
<?php
// The `__launch.php` file will be included only in the backend
Route::accept($config->manager->slug . '/plugin/' . File::B(__DIR__) . '/update', function () use($config, $speak) {
if (!Guardian::happy()) {
Shield::abort();
// [1]
}
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
// [2]
File::write('test!')->saveTo(PLUGIN . DS . File::B(__DIR__) . DS . 'states' . DS . 'config.txt', 0600);
Notify::success(Config::speak('notify_success_updated', array($speak->plugin)));
// [3]
Guardian::kick(File::D($config->url_current));
// [4]
}
});
示例11: do_response_reply
function do_response_reply($response)
{
global $speak;
$prefix = File::B(File::D($response->path));
echo (Weapon::exist($prefix . '_footer') && Guardian::happy() ? ' / ' : "") . '<a class="a-reply" data-parent="' . $response->id . '" href="' . str_replace('&', '&', HTTP::query('reply', $response->id)) . '#' . $prefix . '-form" title="' . Config::speak($prefix . '_reply_to_', Text::parse($response->name_raw, '->text')) . '">' . $speak->reply . '</a>';
}
示例12: function
*/
Get::plug('page', function ($reference, $excludes = array()) {
return Get::post($reference, $excludes, PAGE, '/', 'page:');
});
Get::plug('article', function ($reference, $excludes = array()) {
$config = Config::get();
$speak = Config::speak();
$FP = 'article:';
if (!($results = Get::post($reference, $excludes, ARTICLE, '/' . $config->index->slug . '/', $FP))) {
return $results;
}
// Include comment(s) data
$c = array();
$cc = 0;
$ccc = '0 ' . $speak->comments;
if ($comments = Get::comments('ASC', 'post:' . $results->id, Guardian::happy() ? 'txt,hold' : 'txt')) {
$cc = $comments !== false ? count($comments) : 0;
$ccc = $cc . ' ' . ($cc === 1 ? $speak->comment : $speak->comments);
foreach ($comments as $comment) {
$c[] = Get::comment($comment);
}
$results->comments = Filter::colon($FP . 'comments', $c, $results);
}
$results->total_comments = Filter::colon($FP . 'total_comments', $cc, $results);
$results->total_comments_text = Filter::colon($FP . 'total_comments_text', $ccc, $results);
unset($comments, $c, $cc, $ccc);
return $results;
});
/**
* ==========================================================================
* GET COMMENT PATH
示例13: array
} 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) || !Shield::exist($slug)) {
Shield::abort();
}
$mode = $path === 'attach' ? 'mount' : 'eject';
Weapon::fire(array('on_shield_update', 'on_shield_' . $mode, 'on_shield_' . md5($slug) . '_update', 'on_shield_' . md5($slug) . '_' . $mode), array($G, $G));
$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));
Notify::success(Config::speak('notify_success_updated', $speak->shield));
foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
File::open($asset_cache)->delete();
}
Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
示例14: function
File::open(PLUGIN . DS . $slug . DS . '__pending.php')->renameTo('__launch.php');
} else {
// Rename `launch.php` to `pending.php` or `__launch.php` to `__pending.php`
File::open(PLUGIN . DS . $slug . DS . 'launch.php')->renameTo('pending.php');
File::open(PLUGIN . DS . $slug . DS . '__launch.php')->renameTo('__pending.php');
}
Notify::success(Config::speak('notify_success_updated', $speak->plugin));
Guardian::kick($config->manager->slug . '/plugin/' . $offset);
}, 1);
});
/**
* Plugin Killer
* -------------
*/
Route::accept($config->manager->slug . '/plugin/kill/id:(:any)', function ($slug = "") use($config, $speak) {
if (!Guardian::happy(1) || !($plugin = Plugin::exist($slug))) {
Shield::abort();
}
$info = Plugin::info($slug, true);
$info['slug'] = $slug;
Config::set(array('page_title' => $speak->deleting . ': ' . $info['title'] . $config->title_separator . $config->manager->title, 'page' => $info, 'cargo' => 'kill.plugin.php'));
if ($request = Request::post()) {
$request = Filter::apply('request:__plugin', $request);
Guardian::checkToken($request['token']);
$P = array('data' => array('id' => $slug));
Weapon::fire(array('on_plugin_update', 'on_plugin_destruct', 'on_plugin_' . md5($slug) . '_update', 'on_plugin_' . md5($slug) . '_destruct'), array($P, $P));
File::open($plugin)->delete();
// delete later ...
Notify::success(Config::speak('notify_success_deleted', $speak->plugin));
Guardian::kick($config->manager->slug . '/plugin');
} else {
示例15: 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);
});