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 ($f**k = trim($spam)) { if ($request['email'] === $f**k || strpos(strtolower($request['message']), strtolower($f**k)) !== false) { Notify::warning($speak->notify_warning_intruder_detected . ' <strong class="text-error pull-right">' . $f**k . '</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); } } } } }
if (trim($request['name']) === "") { $request['name'] = $id . '.txt'; // empty file name } $_path = Text::parse(sprintf($request['name'], $id), '->safe_path_name'); $e = File::E($_path, false); if ($e !== 'txt' && $e !== 'php') { $e = 'txt'; $_path .= '.txt'; } $_path_ = File::path($_path); $file = ASSET . DS . '__snippet' . DS . $e . DS . $_path; if (File::exist($file)) { // file already exists Notify::error(Config::speak('notify_file_exist', '<code>' . $_path_ . '</code>')); } if (trim($request['content']) === "") { // empty file content Notify::error($speak->notify_error_content_empty); } if (!Notify::errors()) { $recent = array_slice(File::open(CACHE . DS . 'plugin.snippet.cache')->unserialize(), 0, $config->per_page); File::serialize(array_merge(array($_path), $recent))->saveTo(CACHE . DS . 'plugin.snippet.cache', 0600); $url = $config->manager->slug . '/asset/repair/file:__snippet/' . $e . '/' . File::url($_path) . '?path=' . urlencode(rtrim('__snippet/' . $e . '/' . File::D(File::url($_path)), '/')); File::write($request['content'])->saveTo($file, 0600); Notify::success(Config::speak('notify_file_created', '<code>' . $_path_ . '</code>' . (!isset($request['redirect']) ? ' <a class="pull-right" href="' . $config->url . '/' . $url . '" target="_blank">' . Jot::icon('pencil') . ' ' . $speak->edit . '</a>' : ""))); Notify::info('<strong>' . $speak->shortcode . ':</strong> <code>{{' . ($e === 'php' ? 'include' : 'print') . ':' . str_replace('.' . $e . X, "", File::url($_path) . X) . '}}</code>'); Guardian::kick(isset($request['redirect']) ? $url : File::D($config->url_current)); } Guardian::kick(File::D($config->url_current)); });
$P = array('data' => $request); $name = strip_tags($request['name']); $email = Text::parse($request['email'], '->broken_entity'); $url = isset($request['url']) ? $request['url'] : false; $parser = strip_tags(Request::post('content_type', $config->html_parser)); $message = $request['message']; $field = Request::post('fields', array()); include DECK . DS . 'workers' . DS . 'task.field.1.php'; // Temporarily disallow image(s) in comment to prevent XSS $message = strip_tags($message, '<br><img>' . ($parser === 'HTML' ? '<a><abbr><b><blockquote><code><del><dfn><em><i><ins><p><pre><span><strong><sub><sup><time><u><var>' : "")); $message = preg_replace('#(\\!\\[.*?\\]\\(.*?\\))#', '`$1`', $message); $message = preg_replace('#<img(\\s[^<>]*?)>#', '<img$1>', $message); Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 'pilot' : 'passenger', 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false, 'UA' => Get::UA(), 'IP' => Get::IP()))->content($message)->saveTo(RESPONSE . DS . $post . '_' . Date::format($id, 'Y-m-d-H-i-s') . '_' . ($parent ? Date::format($parent, 'Y-m-d-H-i-s') : '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('on_comment_update', array($P, $P)); Weapon::fire('on_comment_construct', array($P, $P)); if ($config->comment_notification_email) { $mail = '<p>' . Config::speak('comment_notification', $article->url . '#' . sprintf($comment_id, Date::format($id, 'U'))) . '</p>'; $mail .= '<p><strong>' . $name . ':</strong></p>'; $mail .= $parser !== 'HTML' ? Text::parse($message, '->html') : $message; $mail .= '<p>' . Date::format($id, 'Y/m/d H:i:s') . '</p>'; // Sending email notification ... if (!Guardian::happy()) { if (Notify::send($request['email'], $config->author_email, $speak->comment_notification_subject, $mail, 'comment:')) { Weapon::fire('on_comment_notification_construct', array($request, $config->author_email, $speak->comment_notification_subject, $mail)); } } }
<?php include 'Notify.php'; include 'Builder.php'; $notify = new Notify(); $path = isset($argv[1]) ? $argv[1] : null; if (!$path) { die($notify->error('Please specify a file path')); } $notify->info('Parsing CSV...'); $builder = new Builder(array_map('str_getcsv', file($path))); $builder->build();
$c->html_parser = (object) array('type' => array('HTML' => 'HTML'), 'active' => $c->html_parser); } $menus = Get::state_menu(null, false); if (!isset($menus['navigation'])) { $menus['navigation'] = $menus; File::serialize($menus)->saveTo(STATE . DS . 'menu.txt', 0600); } if ($tag = Get::state_tag(null, false)) { if (isset($tag[0]['id'])) { $tags = array(); foreach ($tag as $t) { $tags[$t['id']] = array('name' => $t['name'], 'slug' => $t['slug'], 'description' => $t['description'], 'scope' => 'article'); } File::serialize($tags)->saveTo(STATE . DS . 'tag.txt', 0600); } } if (is_string($c->author)) { $c->author = (object) array('name' => $c->author, 'email' => $c->author_email, 'url' => $c->author_profile_url); if ($c->page_type === 'manager') { Notify::info('<strong>1.2.0</strong> — In your <a href="' . $c->url . '/' . $c->manager->slug . '/shield">shield</a> files, change all <code>$c->author</code> data to <code>$c->author->name</code>, <code>$c->author_email</code> data to <code>$c->author->email</code> and <code>$c->author_profile_url</code> data to <code>$c->author->url</code>. Then go to the <a href="' . $c->url . '/' . $c->manager->slug . '/config">configuration manager page</a> to kill this message by pressing the <strong>Update</strong> button.'); } } Config::set(Mecha::A($c)); $config = $c; }, 1); Weapon::add('on_config_update', function () { // Self destruct ... File::open(__FILE__)->delete(); Notify::clear(); Notify::success(Config::speak('notify_success_updated', Config::speak('config'))); });
<?php // 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 = Text::parse($v['name'], '->safe_file_name'); // File already exists. Don't overwrite and don't show the error message if (file_exists(SUBSTANCE . DS . $name)) { $field[$k]['value'] = $name; Notify::info(Config::speak('notify_file_exist', '<code>' . $name . '</code>')); // Upload new file } else { File::upload($v, SUBSTANCE); if (!Notify::errors()) { $field[$k]['value'] = $name; Weapon::fire('on_substance_update', array($G, $P)); Weapon::fire('on_substance_construct', array($G, $P)); } } } File::$config['file_extension_allow'] = $accept; } unset($accept); }
/** * Delete LDAP user entries * * @return void */ public function exportUsersTask() { $result = \Hubzero\Utility\Ldap::syncAllUsers(); //Notify::error(Lang::txt('COM_SYSTEM_LDAP_ERROR_RESULT_UNKNOWN')); if (isset($result['errors']) && isset($result['fatal']) && !empty($result['fatal'][0])) { Notify::error(Lang::txt('COM_SYSTEM_LDAP_ERROR_EXPORT_FAILED', $result['fatal'][0])); } elseif (isset($result['errors']) && isset($result['warning']) && !empty($result['warning'][0])) { Notify::warning(Lang::txt('COM_SYSTEM_LDAP_WARNING_COMPLETED_WITH_ERRORS', count($result['warning']))); } elseif (isset($result['success'])) { Notify::info(Lang::txt('COM_SYSTEM_LDAP_USERS_EXPORTED', $result['added'], $result['modified'], $result['deleted'], $result['unchanged'])); } App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false)); }