当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper::getRandomString方法代码示例

本文整理汇总了PHP中Helper::getRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::getRandomString方法的具体用法?PHP Helper::getRandomString怎么用?PHP Helper::getRandomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Helper的用法示例。


在下文中一共展示了Helper::getRandomString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Renders the field
  *
  * @return string
  */
 function render()
 {
     $random_keys = array('name' => $this->field_id, 'latitude' => Helper::getRandomString(), 'longitude' => Helper::getRandomString());
     $values = array('name' => isset($this->field_data['name']) ? $this->field_data['name'] : '', 'latitude' => isset($this->field_data['latitude']) ? $this->field_data['latitude'] : '', 'longitude' => isset($this->field_data['longitude']) ? $this->field_data['longitude'] : '');
     $html = '<div class="map"';
     // add in per-field settings
     $settings = array();
     foreach ($this->field_config as $setting => $value) {
         if (!in_array($setting, $this->allowed_settings) || is_null($value)) {
             continue;
         }
         $settings[$setting] = $value;
     }
     // if we found something, add the configuration to the element
     if (count($settings)) {
         $html .= " data-location-configuration='" . json_encode($settings) . "'";
     }
     $html .= '></div>';
     $html .= '<div class="entry">';
     $html .= '	<div class="name">';
     $html .= '		<p>';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][name', array('display' => Localization::fetch('location_name')), $values['name'], NULL, NULL, $random_keys['name']);
     $html .= '		</p>';
     $html .= '	</div>';
     $html .= '	<div class="coordinates">';
     $html .= '		<p class="latitude">';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][latitude', array('display' => Localization::fetch('latitude')), $values['latitude'], NULL, NULL, $random_keys['latitude']);
     $html .= '		</p>';
     $html .= '		<p class="longitude">';
     $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][longitude', array('display' => Localization::fetch('longitude')), $values['longitude'], NULL, NULL, $random_keys['longitude']);
     $html .= '		</p>';
     $html .= '	</div>';
     $html .= '</div>';
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:40,代码来源:ft.location.php

示例2: set_password

 public function set_password($password, $encrypted = FALSE)
 {
     if ($encrypted) {
         if (!isset($this->data['salt']) || $this->data['salt'] == '') {
             $this->data['salt'] = Helper::getRandomString(32);
         }
         $encrypted_password = sha1($password . $this->data['salt']);
         $this->data['encrypted_password'] = $encrypted_password;
         $this->data['password'] = '';
     } else {
         $this->data['password'] = $password;
         $this->data['encrypted_password'] = '';
         $this->data['salt'] = '';
     }
 }
开发者ID:nob,项目名称:joi,代码行数:15,代码来源:user.php

示例3: ensureSecretKey

 /**
  * Ensures that there's a random secret key for cookies to use
  * 
  * @return bool
  */
 public static function ensureSecretKey()
 {
     $secret_key_file = BASE_PATH . "/_cache/_app/cookie/key.php";
     // check that an existing key has been set
     if (File::exists($secret_key_file) && strlen(File::get($secret_key_file)) >= 24) {
         return true;
     }
     // no key set, generate one
     $key = Helper::getRandomString(128, true);
     // check the result, log errors if needed
     $result = File::put($secret_key_file, $key);
     if (!$result) {
         Log::error("Could not create a secret cookie key.", "core", "cookie");
     }
     return (bool) $result;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:21,代码来源:cookie.php

示例4: map

    /**
     * Displays entries on a map
     *
     * @return string
     */
    public function map()
    {
        // check for valid center point
        if (!preg_match(Pattern::COORDINATES, $this->fetchParam('center_point'), $matches)) {
            print_r($this->fetchParam('center_point'));
            $this->log->error("Could not create map, invalid center point coordinates given");
            return NULL;
        } else {
            $latitude  = $matches[1];
            $longitude = $matches[2];
        }

        // pop-up template
        $pop_up_template = NULL;

        // check for a valid pop_up template
        if (preg_match_all("/(?:\{\{\s*pop_up\s*\}\})\s*(.*)\s*(?:\{\{\s*\/pop_up\s*\}\})/ism", $this->content, $matches) && is_array($matches[1]) && isset($matches[1][0])) {
            $pop_up_template = trim($matches[1][0]);
        }

        $folders = $this->fetchParam('folder', ltrim($this->fetchParam('from', URL::getCurrent()), "/"));

        if ($this->fetchParam('taxonomy', false, null, true, null)) {
            $taxonomy_parts  = Taxonomy::getCriteria(URL::getCurrent());
            $taxonomy_type   = $taxonomy_parts[0];
            $taxonomy_slug   = Config::get('_taxonomy_slugify') ? Slug::humanize($taxonomy_parts[1]) : urldecode($taxonomy_parts[1]);

            $content_set = ContentService::getContentByTaxonomyValue($taxonomy_type, $taxonomy_slug, $folders);
        } else {
            $content_set = ContentService::getContentByFolders($folders);
        }

        // filter
        $content_set->filter(array(
            'show_hidden' => $this->fetchParam('show_hidden', false, null, true, false),
            'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false),
            'since'       => $this->fetchParam('since'),
            'until'       => $this->fetchParam('until'),
            'show_past'   => $this->fetchParam('show_past', true, null, true),
            'show_future' => $this->fetchParam('show_future', false, null, true),
            'type'        => 'entries',
            'conditions'  => trim($this->fetchParam('conditions', null))
        ));
        
        // prepare if needed
        $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content);
        if ($parse_content) {
            $content_set->prepare();
        }

        // supplement
        $content_set->supplement(array(
            'locate_with'     => $this->fetchParam('locate_with'),
            'center_point'    => $this->fetchParam('center_point')
        ));

        // re-filter, we only want entries that have been found
        $content_set->filter(array(
            'located'     => true
        ));

        // sort
        $content_set->sort($this->fetchParam('sort_by', 'order_key'), $this->fetchParam('sort_dir'));

        // limit
        $limit     = $this->fetchParam('limit', null, 'is_numeric');
        $offset    = $this->fetchParam('offset', 0, 'is_numeric');
        $paginate  = $this->fetchParam('paginate', true, null, true, false);

        if ($limit || $offset) {
            if ($limit && $paginate && !$offset) {
                // pagination requested, isolate the appropriate page
                $content_set->isolatePage($limit, URL::getCurrentPaginationPage());
            } else {
                // just limit
                $content_set->limit($limit, $offset);
            }
        }

        // get content
        $content_set->prepare(false, true);
        $content = $content_set->get($parse_content);

        // set variables
        $map_id   = $this->fetchParam('map_id', Helper::getRandomString());
        $zoom     = $this->fetchParam('zoom', 12);

        // cluster options
        $clusters = $this->fetchParam('clusters', TRUE, NULL, TRUE);
        $clusters = ($clusters) ? "true" : "false";

        $spiderfy_on_max_zoom = $this->fetchParam('spiderfy_on_max_zoom', TRUE, NULL, TRUE);
        $spiderfy_on_max_zoom = ($spiderfy_on_max_zoom) ? "true" : "false";

        $show_coverage_on_hover = $this->fetchParam('show_coverage_on_hover', TRUE, NULL, TRUE);
//.........这里部分代码省略.........
开发者ID:jalmelb,项目名称:24hl2015,代码行数:101,代码来源:pi.entries.php

示例5: ensureUID

 /**
  * Ensures this user has a UID
  * 
  * @param bool  $save  Save this record?
  * @return void
  */
 public function ensureUID($save)
 {
     if ($this->get('_uid')) {
         return;
     }
     $this->data['_uid'] = uniqid(Helper::getRandomString(6)) . Helper::getRandomString(8);
     if ($save) {
         $this->save();
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:16,代码来源:member.php

示例6: init

 /**
  * init
  * Allows field setup, called before rendering happens
  */
 protected function init()
 {
     $this->field_id = Helper::getRandomString();
 }
开发者ID:nob,项目名称:joi,代码行数:8,代码来源:fieldtype.php

示例7: create

    /**
     * Creates a new token, stores it in the session cache and returns it for use
     * 
     * @return string
     */
    public function create()
    {
        // grab list of known tokens
        $tokens = $this->getTokens();

        // create a new token
        do {
            $new_token = Helper::getRandomString(64);
        } while (in_array($new_token, $tokens));

        // we have a new token, add it to the list
        $tokens[] = $new_token;

        // save that list to the session
        $this->setTokens($tokens);

        // return the token
        return $new_token;
    }
开发者ID:jalmelb,项目名称:24hl2015,代码行数:24,代码来源:addon.php

示例8: render

 function render()
 {
     // Get the field settings
     self::$field_settings = $this->field_config;
     // Get the field settings
     $field_settings = Fieldtype_fileclerk::get_field_settings();
     // Set the destination
     $destination = isset($field_settings['destination']) ? $field_settings['destination'] : false;
     // Get merged configs from tasks
     $field_config = $this->tasks->merge_configs($destination, 'html');
     /**
      * If we have errors in the config, no (sur)render.
      */
     if (isset($field_config['errors'])) {
         // Get the errors view file
         $template = File::get(__DIR__ . '/views/error-no-render.html');
         // Parse the errors template with error data
         return Parse::template($template, array('errors' => $field_config['errors']));
     }
     // Field data
     $data = array('action' => Config::getSiteRoot() . 'TRIGGER/fileclerk/ajaxupload', 'basename_value' => null, 'destination' => $destination, 'extension' => null, 'field_data' => $this->field_data, 'filename' => null, 'id' => Helper::getRandomString(), 'is_image' => null, 'mime_type' => null, 'name' => $this->fieldname, 'site_root' => Config::getSiteRoot(), 'size' => null, 'size_bytes' => null, 'size_kilobytes' => null, 'size_megabytes' => null, 'size_gigabytes' => null, 'tabindex' => $this->tabindex, 'value' => $this->field_data, 'url' => null);
     // If field data is an array, it means we have an existing file.
     // @todo Or does it?
     if (is_array($this->field_data)) {
         // Check if $this->field_data is a zero-index array
         if (isset($this->field_data[0])) {
             // Reset the zero indexed array to normalize data for return.
             $field_data = reset($this->field_data);
         } else {
             // Not a zero-indexed array, no normalization needed.
             $field_data = $this->field_data;
         }
         // Set return data values from $this->field_data
         $data['basename_value'] = $field_data['filename'];
         $data['extension'] = $field_data['extension'];
         $data['filename'] = $field_data['filename'];
         $data['is_image'] = $field_data['is_image'] ? 'true' : 'false';
         //$data['mime_type']      = $field_data['mime_type'];
         $data['size'] = $field_data['size'];
         $data['size_bytes'] = $field_data['size_bytes'];
         $data['size_kilobytes'] = $field_data['size_kilobytes'];
         $data['size_megabytes'] = $field_data['size_megabytes'];
         $data['size_gigabytes'] = $field_data['size_gigabytes'];
         $data['url'] = $field_data['url'];
     }
     /**
      * If there is a destination parameter set in the field,
      * let's append it to the action and choose_file
      */
     $query_data = $destination ? array('destination' => $destination) : array('destination' => false);
     // Set the action attribute
     $data['action'] .= '?' . http_build_query($query_data);
     // Get the fieldtype view file
     $ft_template = File::get(__DIR__ . '/views/ft.fileclerk.html');
     /**
      * For developer debugging only
      * @return Dumps all $data values for each File Clerk field to screen.
      */
     if (defined('FILECLERK_DEV_DEBUG') && FILECLERK_DEV_DEBUG === TRUE) {
         echo '<pre>';
         var_dump($data);
         echo '</pre>';
     }
     // Parse the template with data
     return Parse::template($ft_template, $data);
 }
开发者ID:omadahealth,项目名称:Statamic-File-Clerk,代码行数:66,代码来源:ft.fileclerk.php

示例9: random_string

 /**
  * random_string
  * Returns a random string $length characters long
  *
  * @deprecated  Use Helper::getRandomString() instead
  *
  * @param string  $length  Length of random string to return
  * @return string
  */
 public static function random_string($length = NULL)
 {
     Log::warn("Use of Statamic_Helper::random_string() is deprecated. Use Helper::getRandomString() instead.", "core", "Statamic_Helper");
     return Helper::getRandomString($length);
 }
开发者ID:nob,项目名称:joi,代码行数:14,代码来源:helper.php

示例10: parseParameters

    private function parseParameters()
    {
        // determine folder
        $folders = array('folders' => $this->fetchParam('folder', $this->fetchParam('folders', ltrim($this->fetchParam('from', URL::getCurrent()), "/"))));
        
        // url
        $url = array(
            'url' => $this->fetchParam('url', URL::getCurrent())  
        );
        
        // filters
        $filters = array(
            'show_hidden' => $this->fetchParam('show_hidden', false, null, true, false),
            'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false),
            'since'       => $this->fetchParam('since'),
            'until'       => $this->fetchParam('until'),
            'show_past'   => $this->fetchParam('show_past', true, null, true),
            'show_future' => $this->fetchParam('show_future', false, null, true),
            'type'        => $this->fetchParam('type', 'all', false, false, true),
            'conditions'  => trim($this->fetchParam('conditions', null, false, false, false))
        );

        // other
        $other = array(
            'taxonomy'  => $this->fetchParam('taxonomy', false, null, true, null),
            'sort_by'   => $this->fetchParam('sort_by', 'order_key'),
            'sort_dir'  => $this->fetchParam('sort_dir')
        );
        
        // map settings
        $map = array(
            'map_id'       => $this->fetchParam('map_id', Helper::getRandomString(), false, false, false),
            'map_class'    => $this->fetchParam('map_class', null, false, false, false),
            'locate_with'  => $this->fetch('locate_with', null, false, false, true),
            'center_point' => $this->fetch('center_point', null, false, false, false),
            
            // starting position
            'starting_zoom'      => $this->fetch('starting_zoom', 12, 'is_numeric', false, false),
            'starting_latitude'  => $this->fetch('starting_latitude', null, 'is_numeric', false, false),
            'starting_longitude' => $this->fetch('starting_longitude', null, 'is_numeric', false, false),
            
            // display
            'mapping_service'             => $this->fetch('mapping_service', 'openstreetmap', null, false, true),
            'mapping_service_api_key'     => $this->fetch('mapping_service_api_key', null, null, false, true),
            'mapping_service_style'       => $this->fetch('mapping_service_style', null, null, false, true),
            'mapping_service_attribution' => $this->fetch('mapping_service_attribution', null, null, false, true),
  
            // limitations
            'min_zoom' => $this->fetch('min_zoom', 4, 'is_numeric', false, false),
            'max_zoom' => $this->fetch('max_zoom', 18, 'is_numeric', false, false),
            
            // interactions
            'interaction_scroll_wheel_zoom' => ($this->fetch('interaction_scroll_wheel_zoom', false, null, true)) ? 'true' : 'false',
            'interaction_double_click_zoom' => ($this->fetch('interaction_double_click_zoom', true, null, true)) ? 'true' : 'false',
            'interaction_box_zoom'          => ($this->fetch('interaction_box_zoom', true, null, true)) ? 'true' : 'false',
            'interaction_touch_zoom'        => ($this->fetch('interaction_touch_zoom', true, null, true)) ? 'true' : 'false',
            'interaction_draggable'         => ($this->fetch('interaction_draggable', true, null, true)) ? 'true' : 'false',
            'interaction_tap'               => ($this->fetch('interaction_tap', true, null, true)) ? 'true' : 'false',
            'open_popup'                    => ($this->fetchParam('open_popup', false, null, true)) ? 'true' : 'false',
            'auto_center'                   => ($this->fetch('auto_center', true, null, true)) ? 'true' : 'false',
            
            // clustering
            'clusters'                   => ($this->fetch('clusters', true, null, true)) ? 'true' : 'false',
            'spiderfy_on_max_zoom'       => ($this->fetch('spiderfy_on_max_zoom', true, null, true)) ? 'true' : 'false',
            'show_coverage_on_hover'     => ($this->fetch('show_coverage_on_hover', true, null, true)) ? 'true' : 'false',
            'zoom_to_bounds_on_click'    => ($this->fetch('zoom_to_bounds_on_click', true, null, true)) ? 'true' : 'false',
            'single_marker_mode'         => ($this->fetch('single_marker_mode', false, null, true)) ? 'true' : 'false',
            'animate_adding_markers'     => ($this->fetch('animate_adding_markers', true, null, true)) ? 'true' : 'false',
            'disable_clustering_at_zoom' => $this->fetch('disable_clustering_at_zoom', 15, 'is_numeric', false, false),
            'max_cluster_radius'         => $this->fetch('max_cluster_radius', 80, 'is_numeric', false, false)
        );

        // mapping service
        $service = $this->getMappingServiceVariables($map);
        $mapping = array(
            'tiles' => $service['tiles'],
            'attribution' => ($map['mapping_service_attribution']) ? $map['mapping_service_attribution'] : $service['service_attr'],
            'subdomains' => (isset($service['subdomains'])) ? $service['subdomains'] : null
        );

        return $other + $filters + $folders + $url + $map + $mapping;
    }
开发者ID:jalmelb,项目名称:24hl2015,代码行数:82,代码来源:pi.location.php


注:本文中的Helper::getRandomString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。