Example #1
0
 /**
  * 随机生成一个 18 位身份证。
  * @link http://baike.baidu.com/view/1697.htm#4 [<description>]
  * @link http://zhidao.baidu.com/question/1954561.html [<description>]
  * @return [type] [description]
  */
 public static function id()
 {
     $addressId = Helper::pick(array_keys(\Mock\Dictionary\Address::getDictionay()));
     $sum = 0;
     $rank = array("7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7", "9", "10", "5", "8", "4", "2");
     $last = array("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2");
     $id = $addressId . Date::date('Ymd') . Basic::string('number', 3);
     for ($i = 0; $i < strlen($id); $i++) {
         $sum += $id[$i] * $rank[$i];
     }
     $id .= $last[$sum % 11];
     return $id;
 }
 public function require_password()
 {
     $password_list = trim($this->fetchParam('allowed', '', null, false, false));
     $passwords = explode('|', $password_list);
     $password_url = $this->fetch('password_url', null, null, false, false);
     $no_access_url = $this->fetch('no_access_url', '/', null, false, false);
     $return_variable = $this->fetch('return_variable', 'return', null, false, false);
     // no passwords set? this is OK
     if (!$password_list) {
         return;
     }
     // determine form URL
     $form_url = Helper::pick($password_url, $no_access_url);
     if (!$this->tasks->hasPassword(URL::getCurrent(), $passwords)) {
         URL::redirect(URL::appendGetVariable($form_url, $return_variable, URL::getCurrent()), 302);
         exit;
     }
 }
Example #3
0
 public function register_form()
 {
     if (Auth::isLoggedIn()) {
         // logged in
         return false;
     }
     $attr_string = '';
     $site_root = Config::getSiteRoot();
     $return = $this->fetchParam('return', $site_root, null, false, false);
     $allow_request_return = $this->fetchParam('allow_request_return', false, null, true, false);
     $attr = $this->fetchParam('attr', false);
     $auto_login = (int) $this->fetchParam('auto_login', true, null, true, false);
     // grab request return
     $get_return = filter_input(INPUT_GET, 'return', FILTER_SANITIZE_URL);
     $post_return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_URL);
     $request_return = Helper::pick($post_return, $get_return);
     // if we're letting return values to be set in URL and one exists, grab it
     if ($allow_request_return && $request_return) {
         $return = $request_return;
     }
     // get old values
     $old_values = $this->flash->get('register_old_values', array());
     array_walk_recursive($old_values, function (&$item, $key) {
         $item = htmlspecialchars($item);
     });
     // set up any data to be parsed into content
     $data = array('error' => $this->flash->get('register_error', ''), 'success' => $this->flash->get('register_success', ''), 'field_errors' => $this->flash->get('register_field_errors', array()), 'old_values' => $old_values);
     // set up attributes
     if ($attr) {
         $attributes_array = Helper::explodeOptions($attr, true);
         foreach ($attributes_array as $key => $value) {
             $attr_string .= ' ' . $key . '="' . $value . '"';
         }
     }
     // set up form HTML
     $html = '<form method="post" action="' . Path::tidy($site_root . "/TRIGGER/member/register") . '" ' . $attr_string . '>';
     $html .= '<input type="hidden" name="return" value="' . $return . '">';
     $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">';
     $html .= '<input type="hidden" name="auto_login" value="' . $auto_login . '">';
     $html .= Parse::template($this->content, $data);
     $html .= '</form>';
     // return that HTML
     return $html;
 }
Example #4
0
File: content.php Project: nob/joi
 /**
  * Render content via a given $content_type
  *
  * @param string  $content  Content to render
  * @param mixed  $content_type  Content type to use (overrides configured content_type)
  * @return string
  */
 public static function transform($content, $content_type = NULL)
 {
     $content_type = Helper::pick($content_type, Config::getContentType());
     // render HTML from the given $content_type
     switch (strtolower($content_type)) {
         case "markdown":
         case "md":
             $content = Markdown($content);
             break;
         case "text":
         case "txt":
             $content = nl2br(strip_tags($content));
             break;
         case "textile":
             $textile = new Textile();
             $content = $textile->TextileThis($content);
     }
     if (Config::get('_enable_smartypants', TRUE) == TRUE) {
         $content = SmartyPants($content, 2);
     }
     return trim($content);
 }
Example #5
0
 /**
  * Render content via a given $content_type
  *
  * @param string  $content  Content to render
  * @param mixed  $content_type  Content type to use (overrides configured content_type)
  * @return string
  */
 public static function transform($content, $content_type = NULL)
 {
     $content_type = Helper::pick($content_type, Config::getContentType());
     // render HTML from the given $content_type
     switch (strtolower($content_type)) {
         case "markdown":
         case "md":
             $content = Parse::markdown($content);
             break;
         case "text":
         case "txt":
             $content = nl2br(strip_tags($content));
             break;
         case "textile":
             $content = Parse::textile($content);
     }
     if (Config::get('enable_smartypants', TRUE) === TRUE) {
         $content = Parse::smartypants($content);
     } elseif (Config::get('enable_smartypants', TRUE) === 'typographer') {
         $content = Parse::smartypants($content, TRUE);
     }
     return trim($content);
 }
Example #6
0
 /**
  * Sorts the current content by $field and $direction
  *
  * @param string  $field  Field to sort on
  * @param string  $direction  Direction to sort
  * @return void
  */
 public function sort($field = "order_key", $direction = null)
 {
     $hash = Debug::markStart('content', 'sorting');
     // no content, abort
     if (!count($this->content)) {
         return;
     }
     // sort by random, short-circuit
     if ($field == "random") {
         shuffle($this->content);
         return;
     }
     // sort by field
     usort($this->content, function ($item_1, $item_2) use($field) {
         // grab values, translating some user-facing names into internal ones
         switch ($field) {
             case "order_key":
                 $value_1 = $item_1['_order_key'];
                 $value_2 = $item_2['_order_key'];
                 break;
             case "number":
                 $value_1 = $item_1['_order_key'];
                 $value_2 = $item_2['_order_key'];
                 break;
             case "datestamp":
                 $value_1 = $item_1['datestamp'];
                 $value_2 = $item_2['datestamp'];
                 break;
             case "date":
                 $value_1 = $item_1['datestamp'];
                 $value_2 = $item_2['datestamp'];
                 break;
             case "folder":
                 $value_1 = $item_1['_folder'];
                 $value_2 = $item_2['_folder'];
                 break;
             case "distance":
                 $value_1 = $item_1['distance_km'];
                 $value_2 = $item_2['distance_km'];
                 break;
                 // not a special case, grab the field values if they exist
             // not a special case, grab the field values if they exist
             default:
                 $value_1 = isset($item_1[$field]) ? $item_1[$field] : null;
                 $value_2 = isset($item_2[$field]) ? $item_2[$field] : null;
                 break;
         }
         // compare the two values
         // ----------------------------------------------------------------
         return Helper::compareValues($value_1, $value_2);
     });
     // apply sort direction
     if (is_null($direction)) {
         reset($this->content);
         $sample = $this->content[key($this->content)];
         // if we're sorting by order_key and it's date-based order, default sorting is 'desc'
         if ($field == "order_key" && $sample['_order_key'] && $sample['datestamp']) {
             $direction = "desc";
         } else {
             $direction = "asc";
         }
     }
     // do we need to flip the order?
     if (Helper::pick($direction, "asc") == "desc") {
         $this->content = array_reverse($this->content);
     }
     Debug::markEnd($hash);
 }
Example #7
0
$config['log_enabled'] = TRUE;
$config['log.level'] = Log::convert_log_level($config['_log_level']);
$config['whoops.editor'] = 'sublime';
$config['log.writer'] = new Statamic_Logwriter(array('path' => $config['_log_file_path'], 'file_prefix' => $config['_log_file_prefix']));
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Many users are upgrading to PHP 5.3 for the first time. I know.
| We've gone ahead set the default timezone that will be used by the PHP
| date and date-time functions. This prevents some potentially
| frustrating errors for novice developers.
|
*/
date_default_timezone_set(Helper::pick($config['_timezone'], @date_default_timezone_get(), "UTC"));
/*
|--------------------------------------------------------------------------
| Slim Initialization
|--------------------------------------------------------------------------
|
| Time to get an instance of Slim fired up. We're passing the $config
| array, which contains a bit more data than necessary, but helps keep
| everything simple.
|
*/
// mark milestone for debug panel
Debug::markMilestone('bootstrapped');
$app = new \Slim\Slim(array_merge($config, array('view' => new Statamic_View())));
// mark milestone for debug panel
Debug::markMilestone('app created');
Example #8
0
 /**
  * Sort
  *
  * @param string  $field  Field to sort by
  * @param string  $direction  Direction to sort
  * @return void
  */
 public function sort($field = "name", $direction = NULL)
 {
     if ($field == "random") {
         shuffle($this->data);
         return;
     }
     usort($this->data, function ($item_1, $item_2) use($field) {
         $value_1 = isset($item_1[$field]) ? $item_1[$field] : NULL;
         $value_2 = isset($item_2[$field]) ? $item_2[$field] : NULL;
         return Helper::compareValues($value_1, $value_2);
     });
     // do we need to flip the order?
     if (Helper::pick($direction, "asc") == "desc") {
         $this->data = array_reverse($this->data);
     }
 }
Example #9
0
File: plugin.php Project: nob/joi
 /**
  * Attempts to fetch a given $key's value from (in order): user-passed parameters, config file, default value
  *
  * @param string  $key  Key of value to retrieve
  * @param mixed  $default  Default value if no value is found
  * @param string  $validity_check  Allows a boolean callback function to validate parameter
  * @param boolean  $is_boolean  Indicates parameter is boolean
  * @param boolean  $force_lower  Force the parameter's value to be lowercase?
  * @return mixed
  */
 protected function fetch($key, $default = NULL, $validity_check = NULL, $is_boolean = FALSE, $force_lower = TRUE)
 {
     return Helper::pick($this->fetchParam($key, NULL, $validity_check, $is_boolean, $force_lower), $this->fetchConfig($key, NULL, $validity_check, $is_boolean, $force_lower), $default);
 }
 /**
  * Returns the stored name for a $taxonomy and $taxonomy_slug if exists in cache
  * 
  * @param string  $taxonomy  Taxonomy to use
  * @param string  $taxonomy_slug  Taxonomy slug to look up
  * @return string
  */
 public static function getTaxonomyName($taxonomy, $taxonomy_slug)
 {
     return Helper::pick(ContentService::getTaxonomyName($taxonomy, $taxonomy_slug), $taxonomy_slug);
 }
Example #11
0
File: start.php Project: nob/joi
<?php

/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Many users are upgrading to PHP 5.3 for the first time. I know.
| We've gone ahead set the default timezone that will be used by the PHP
| date and date-time functions. This prevents some potentially
| frustrating errors for novice developers.
|
*/
date_default_timezone_set(Helper::pick($config['_timezone'], 'UTC'));
/*
|--------------------------------------------------------------------------
| Slim Initialization
|--------------------------------------------------------------------------
|
| Time to get an instance of Slim fired up. We're passing the $config
| array, which contains a bit more data than necessary, but helps keep
| everything simple.
|
*/
$admin_app = new \Slim\Slim(array_merge($config, array('view' => new Statamic_View())));
$admin_app->config = $config;
/*
|--------------------------------------------------------------------------
| Cookies for the Monster
|--------------------------------------------------------------------------
|
Example #12
0
File: theme.php Project: nob/joi
 /**
  * Returns a list of layouts for a given $theme, or current theme if no $theme passed
  *
  * @param mixed  $theme  Theme to list layouts from, or current if none is passed
  * @return array
  */
 public static function getLayouts($theme = NULL)
 {
     $layouts = array();
     $list = glob("_themes/" . Helper::pick($theme, Config::getTheme()) . "/layouts/*");
     if ($list) {
         foreach ($list as $name) {
             $start = strrpos($name, "/") + 1;
             $end = strrpos($name, ".");
             $layouts[] = substr($name, $start, $end - $start);
         }
     }
     return $layouts;
 }
 /**
  * Merge all configs
  * @param string  $destination Paramter for destination YAML file to attempt to load.
  * @param string  $return_type Set the return type
  * @return array
  */
 public function merge_configs($destination = null, $respons_type = 'json')
 {
     // Set environment
     $this->env = $env = FILECLERK_ENV;
     // Error(s) holder
     $errors = false;
     // Check for a destination config
     $destination = is_null($destination) ? Request::get('destination') : $destination;
     // A complete list of all possible config variables
     $config = array('aws_access_key' => null, 'aws_secret_key' => null, 'custom_domain' => null, 'bucket' => null, 'directory' => null, 'permissions' => CannedAcl::PUBLIC_READ, 'content_types' => false);
     // Requried config values
     $required_config = array('aws_access_key', 'aws_secret_key');
     // Destination config values that even if null should override master config.
     $allow_override = array('custom_domain', 'directory', 'content_types');
     // Destination config array
     $destination_config = array();
     // Check that the destination config file exists
     if (!is_null($destination) || $destination !== 0 || $destination) {
         // Set the full path for the destination file
         $destination_file = FILECLERK_DESTINATION_PATH . ltrim($destination) . '.yaml';
         if (File::exists($destination_file)) {
             $destination_config = YAML::parseFile($destination_file);
             foreach ($destination_config as $key => $value) {
                 if (!in_array($key, $allow_override) && (empty($value) || is_null($value))) {
                     unset($destination_config[$key]);
                 }
             }
         } else {
             $this->log->error("Could not use destination `" . $destination . "`, YAML file does not exist.");
         }
     }
     // load global config
     $addon_config = Helper::pick($this->getConfig(), array());
     // merge config variables in order
     $config = array_merge($config, $addon_config, $destination_config);
     // Handle content types
     // If it's a string, need to cast to an array
     if (is_string($config['content_types'])) {
         switch ($config['content_types']) {
             // If empty string, set to false
             case '':
             case null:
                 $config['content_types'] = false;
                 break;
                 // If there is a value, push to an array
             // If there is a value, push to an array
             default:
                 $config['content_types'] = array($config['content_types']);
                 break;
         }
     }
     // Convert permissions to the corresponding Canned ACL constant.
     switch (strtolower(trim($config['permissions']))) {
         case 'private':
             $config['permissions'] = CannedAcl::PRIVATE_ACCESS;
             break;
         case 'public-read':
             $config['permissions'] = CannedAcl::PUBLIC_READ;
             break;
         case 'public-read-write':
             $config['permissions'] = CannedAcl::PUBLIC_READ_WRITE;
             break;
         case 'authenticated-read':
             $config['permissions'] = CannedAcl::AUTHENTICATED_READ;
             break;
         default:
             $config['permissions'] = CannedAcl::PUBLIC_READ;
             break;
     }
     // Check that required configs are set
     foreach ($required_config as $key) {
         if (!isset($config[$key]) || $config[$key] == '') {
             $errors[] = array('error' => "<pre>{$key}</pre> is a required File Clerk config value.");
         }
     }
     // If errors, set in config for checking later
     if ($errors) {
         $config['errors'] = $errors;
     }
     // Create our S3 client
     //self::load_s3();
     return $config;
 }
 /**
  * Retrieves the resource URI for this request
  *
  * @param mixed  $default  Default value to use if not set
  * @return string
  */
 public static function getResourceURI($default = NULL)
 {
     return Helper::pick(URL::sanitize(\Slim\Slim::getInstance()->request()->getResourceUri()), $default);
 }
Example #15
0
 /**
  * Formats a given $date (automatically resolving timestamps) to a given $format
  *
  * @param string  $format  Format to use (based on PHP's date formatting)
  * @param mixed  $date  Date string or timestamp (if blank, now)
  * @return mixed
  */
 public static function format($format, $date = NULL)
 {
     return date($format, self::resolve(Helper::pick($date, time())));
 }
 public function forgot_password_form()
 {
     // parse parameters and vars
     $attr_string = '';
     $site_root = Config::getSiteRoot();
     $return = $this->fetchParam('return', URL::getCurrent(), null, false, false);
     $reset_return = $this->fetchParam('reset_return', null, null, false, false);
     $allow_request_return = $this->fetchParam('allow_request_return', false, null, true, false);
     $logged_in_redirect = $this->fetchParam('logged_in_redirect', $return, null, false, false);
     $attr = $this->fetchParam('attr', false);
     // check that email template(s) exist
     if (!Theme::getTemplate($this->fetchConfig('reset_password_html_email', false, null, false, false)) && !Theme::getTemplate($this->fetchConfig('reset_password_text_email', false, null, false, false))) {
         throw new Exception('Your reset password email template(s) must exist and contain a {{ reset_url }}.');
     }
     // grab request return
     $get_return = filter_input(INPUT_GET, 'return', FILTER_SANITIZE_URL);
     $post_return = filter_input(INPUT_POST, 'return', FILTER_SANITIZE_URL);
     $request_return = Helper::pick($post_return, $get_return);
     // is user already logged in? forward as needed
     if (Auth::isLoggedIn()) {
         URL::redirect($logged_in_redirect, 302);
     }
     // if we're letting return values to be set in URL and one exists, grab it
     if ($allow_request_return && $request_return) {
         $return = $request_return;
     }
     // set up any data to be parsed into content
     $data = array('error' => $this->flash->get('forgot_password_error', ''), 'email_sent' => $this->flash->get('forgot_password_sent'));
     // set up attributes
     if ($attr) {
         $attributes_array = Helper::explodeOptions($attr, true);
         foreach ($attributes_array as $key => $value) {
             $attr_string .= ' ' . $key . '="' . $value . '"';
         }
     }
     // set up form HTML
     $html = '<form method="post" action="' . Path::tidy($site_root . "/TRIGGER/member/forgot_password") . '" ' . $attr_string . '>';
     $html .= '<input type="hidden" name="return" value="' . $return . '">';
     if ($reset_return) {
         $html .= '<input type="hidden" name="reset_return" value="' . $reset_return . '">';
     }
     $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">';
     $html .= Parse::template($this->content, $data);
     $html .= '</form>';
     // return that HTML
     return $html;
 }
 /**
  * Does the current member have access to a given $url?
  * 
  * @param string  $url  URL to check
  * @return boolean
  * @throws Exception
  */
 public function hasAccess($url = null)
 {
     // load data for the given $url
     $data = Content::get($url);
     if (!isset($data['_protect']) || !$data['_protect']) {
         return true;
     }
     // grab the protection scheme
     $scheme = $data['_protect'];
     // determine URLs
     $login_url = URL::prependSiteRoot(array_get($scheme, 'login_url', $this->fetchConfig('login_url', '/', null, false, false)));
     $no_access_url = URL::prependSiteRoot(array_get($scheme, 'no_access_url', $this->fetchConfig('no_access_url', '/', null, false, false)));
     $password_url = URL::prependSiteRoot(array_get($scheme, 'password_form_url', $this->fetchConfig('password_url', '/', null, false, false)));
     // support external log-in systems
     $require_member = array_get($scheme, 'require_member', $this->fetchConfig('require_member', true, null, true, false));
     $return_variable = array_get($scheme, 'return_variable', $this->fetchConfig('return_variable', 'return', null, false, false));
     $use_full_url = array_get($scheme, 'use_full_url', $this->fetchConfig('use_full_url', false, null, true, false));
     // get the current URL
     $current_url = $use_full_url ? URL::tidy(Config::getSiteURL() . '/' . URL::getCurrent()) : URL::getCurrent();
     // append query string
     if (!empty($_GET)) {
         $current_url .= '?' . http_build_query($_GET, '', '&');
     }
     // store if we've matched
     $match = false;
     if (isset($scheme['password'])) {
         // this is a password-check
         // get the form URL
         $form_url = array_get($scheme['password'], 'form_url', Helper::pick($password_url, $no_access_url));
         // check for passwords
         if (!$this->evaluatePassword($url)) {
             URL::redirect(URL::appendGetVariable($form_url, $return_variable, $current_url), 302);
             exit;
         }
         // we're good
         return true;
     } elseif (isset($scheme['ip_address'])) {
         // this is an IP-address-check
         if (!$this->evaluateIP($url)) {
             URL::redirect($no_access_url, 302);
             exit;
         }
     } else {
         try {
             // are we going to allow or deny people?
             if (isset($scheme['allow']) && is_array($scheme['allow'])) {
                 $type = 'allow';
                 $rules = $scheme['allow'];
             } elseif (isset($scheme['deny']) && is_array($scheme['deny'])) {
                 $type = 'deny';
                 $rules = $scheme['deny'];
             } else {
                 throw new Exception('The `_protect` field is set for [' . $data['url'] . '](' . $data['url'] . '), but the configuration given could not be parsed. For caution’s sake, *everyone* is being blocked from this content.');
             }
             // if $require_member is true, do a check up-front to see if
             // this user is currently logged in
             if ($require_member && !Auth::isLoggedIn()) {
                 URL::redirect(URL::appendGetVariable($login_url, $return_variable, $current_url), 302);
                 exit;
             }
             // parse the rules
             foreach ($rules as $key => $value) {
                 if ($this->tasks->evaluateRule($key, $value)) {
                     $match = true;
                     break;
                 }
             }
             // send to no access page if user didn't match and needed to, or did and shouldn't have
             if (!$match && $type === 'allow' || $match && $type === 'deny') {
                 URL::redirect($no_access_url, 302);
                 exit;
             }
         } catch (\Slim\Exception\Stop $e) {
             throw $e;
         } catch (Exception $e) {
             // something has gone wrong, log the message
             Log::error($e->getMessage(), "api", "security");
             // always return false
             URL::redirect($no_access_url, 302);
         }
     }
 }
Example #18
0
 public static function character($pool = '')
 {
     $pool = \Mock\Dictionary\Text::getPool($pool);
     return Helper::pick($pool);
 }
Example #19
0
File: url.php Project: nob/joi
 /**
  * Gets the value of pagination in the current URL
  *
  * @return int
  */
 public static function getCurrentPaginationPage()
 {
     return Helper::pick(Request::get(Config::getPaginationVariable()), 1);
 }
Example #20
0
    /**
     * Display the previous entry listing for the settings provided based $current URL
     *
     * @param array  $passed_settings  Optional passed settings for reusing methods
     * @param boolean  $check_for_next  Should we check for next values?
     * @param boolean  $wrap_around  If there's no previous, return the last item?
     * @return array
     */
    public function previous($passed_settings=null, $check_for_next=true, $wrap_around=null)
    {
        // grab common parameters
        $settings = Helper::pick($passed_settings, $this->parseCommonParameters());

        // grab content set based on the common parameters
        $content_set = $this->getContentSet($settings);

        // what is our base point?
        $current = $this->fetch('current', URL::getCurrent(), false, false, false);

        // should we wrap around?
        $wrap_around = Helper::pick($wrap_around, $this->fetch('wrap', false, false, true, false));

        // check for has_next, used for method interoperability
        if ($check_for_next) {
            $next = $this->next($settings, false, $wrap_around);
            $has_next = !is_array($next);
        } else {
            $has_next = false;
        }

        // if current wasn't set, we can't determine the previous content
        if (!$current) {
            return array('no_results' => true, 'has_next' => $has_next);
        }

        // get the content
        $content = $content_set->get(preg_match(Pattern::USING_CONTENT, $this->content));

        // set up iterator variables
        $previous_data = null;
        $output_data   = null;

        // loop through content looking for current
        if (!empty($content)) {
            foreach ($content as $item) {
                // this should never happen, but just in case
                if (!isset($item['url'])) {
                    continue;
                }

                if ($item['url'] == $current) {
                    $output_data = $previous_data;
                    break;
                }

                // wasn't a match, set this item as previous data and do it again
                $previous_data = $item;
            }
        }

        // wrap around?
        if ($wrap_around && is_array($content) && !empty($content) && (!$output_data || !is_array($output_data))) {
            $output_data = array_pop($content);
        }

        // if no $output_data was found, tell'em so
        if (!$output_data || !is_array($output_data)) {
            return array('no_results' => true, 'has_next' => $has_next);
        }

        // does this context have a previous?
        $output_data['has_next'] = $has_next;

        // return the found data
        return Parse::template($this->content, $output_data);
    }
Example #21
0
 /**
  * Logs that a search was performed
  *
  * @param string  $query  The string that was queried
  * @param string|int  $results  The number of results
  * @return void
  */
 public function logSearch($query, $results)
 {
     $searches = Helper::pick($this->session->get('searches'), array());
     $plural = $results === 1 ? '' : 's';
     $query = htmlentities($query);
     // check to see if this session has performed this search before
     // this prevents multiple page views from being tagged as multiple searches
     if (!isset($searches[$query])) {
         // mark as stored
         $searches[$query] = true;
         $this->session->set('searches', $searches);
         // make a note in the log
         if ($results) {
             // log `info` message
             if ($this->fetchConfig('log_successful_searches', true, null, true, false)) {
                 $this->log->info('Someone searched for *' . $query . '* and found ' . $results . ' result' . $plural . '.');
             }
             // set file to update
             $file = 'successful_searches.yaml';
         } else {
             // log `warn` message
             if ($this->fetchConfig('log_successful_searches', true, null, true, false)) {
                 $this->log->warn('Someone searched for *' . $query . '* and no results were found.');
             }
             // set file to update
             $file = 'failed_searches.yaml';
         }
         $search_list = $this->cache->getYAML($file, array());
         if (isset($search_list[$query])) {
             $search_list[$query] = $search_list[$query] + 1;
         } else {
             $search_list[$query] = 1;
         }
         $this->cache->putYAML($file, $search_list);
     }
 }