• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP valid类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: save

 public function save()
 {
     if (!$_POST) {
         die;
     }
     $this->rsp = Response::instance();
     if (!valid::email($_POST['email'])) {
         $this->rsp->msg = 'Invalid Email!';
         $this->rsp->send();
     } elseif ($this->owner->unique_key_exists($_POST['email'])) {
         $this->rsp->msg = 'Email already exists!';
         $this->rsp->send();
     }
     $pw = text::random('alnum', 8);
     $this->owner->email = $_POST['email'];
     $this->owner->password = $pw;
     $this->owner->save();
     $replyto = 'unknown';
     $body = "Hi there, thanks for saving your progess over at http://pluspanda.com \r\n" . "Your auto-generated password is: {$pw} \r\n" . "Change your password to something more appropriate by going here:\r\n" . "http://pluspanda.com/admin/account?old={$pw} \r\n\n" . "Thank you! - Jade from pluspanda";
     # to do FIX THE HEADERS.
     $subject = 'Your Pluspanda account information =)';
     $headers = "From: [email protected] \r\n" . "Reply-To: Jade \r\n" . 'X-Mailer: PHP/' . phpversion();
     mail($_POST['email'], $subject, $body, $headers);
     # add to mailing list.
     include Kohana::find_file('vendor/mailchimp', 'MCAPI');
     $config = Kohana::config('mailchimp');
     $mailchimp = new MCAPI($config['apikey']);
     $mailchimp->listSubscribe($config['list_id'], $_POST['email'], '', 'text', FALSE, TRUE, TRUE, FALSE);
     $this->rsp->status = 'success';
     $this->rsp->msg = 'Thanks, Account Saved!';
     $this->rsp->send();
 }
开发者ID:plusjade,项目名称:pluspanda-php,代码行数:32,代码来源:account.php


示例2: page

 public function page($page_id = NULL)
 {
     valid::id_key($page_id);
     ob_start();
     #TODO: if any tools are protected on this page, search for a possible
     # theme template and load that within the page css.
     # Is page_name protected?
     #$page_config_value = yaml::does_key_exist($this->site_name, 'pages_config', $page_name);
     # parse custom page sass file if it exists.
     $page_sass = $this->assets->themes_dir("{$this->theme}/pages/{$page_id}.sass");
     if (file_exists($page_sass)) {
         echo Kosass::factory('compact')->compile(file($page_sass));
     }
     # load custom tool css files
     $db = new Database();
     # get all tools that are added to this page.
     $tool_data = $db->query("\n      SELECT *, LOWER(system_tools.name) AS name, tools.id AS guid\n      FROM pages_tools \n      JOIN tools ON pages_tools.tool_id = tools.id\n      JOIN system_tools ON tools.system_tool_id = system_tools.id\n      WHERE (page_id BETWEEN 1 AND 5 OR page_id = '{$page_id}')\n      AND pages_tools.fk_site = '{$this->site_id}'\n      ORDER BY pages_tools.container, pages_tools.position\n    ");
     $tool_dir = $this->assets->themes_dir("{$this->theme}/tools");
     foreach ($tool_data as $tool) {
         # get the type and the view from the system.
         # TODO: try and optimize this later.
         $table = ORM::factory($tool->name)->where('fk_site', $this->site_id)->find($tool->parent_id);
         $custom_file = "{$tool_dir}/{$tool->name}/{$tool->parent_id}/{$table->type}_{$table->view}.css";
         if (file_exists($custom_file)) {
             readfile($custom_file);
         }
     }
     # cache the full result as the live global css file.
     file_put_contents("{$this->cache_dir}/{$page_id}.css", ob_get_clean());
     return TRUE;
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:31,代码来源:css.php


示例3: url_test

 public function url_test()
 {
     $this->assert_true(valid::url("http://foo.bar.com"));
     $this->assert_true(valid::url("https://foo.bar.com"));
     $this->assert_false(valid::url("mailto://bar"));
     $this->assert_false(valid::url("ftp://bar"));
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:7,代码来源:Valid_Test.php


示例4: parse

 /**
  * Parses a remote feed into an array.
  *
  * @param   string   remote feed URL
  * @param   integer  item limit to fetch
  * @return  array
  */
 public static function parse($feed, $limit = 0)
 {
     // Check if SimpleXML is installed
     if (!function_exists('simplexml_load_file')) {
         throw new Kohana_User_Exception('Feed Error', 'SimpleXML must be installed!');
     }
     // Make limit an integer
     $limit = (int) $limit;
     // Disable error reporting while opening the feed
     $ER = error_reporting(0);
     // Allow loading by filename or raw XML string
     $load = (is_file($feed) or valid::url($feed)) ? 'simplexml_load_file' : 'simplexml_load_string';
     // Load the feed
     $feed = $load($feed, 'SimpleXMLElement', LIBXML_NOCDATA);
     // Restore error reporting
     error_reporting($ER);
     // Feed could not be loaded
     if ($feed === FALSE) {
         return array();
     }
     // Detect the feed type. RSS 1.0/2.0 and Atom 1.0 are supported.
     $feed = isset($feed->channel) ? $feed->xpath('//item') : $feed->entry;
     $i = 0;
     $items = array();
     foreach ($feed as $item) {
         if ($limit > 0 and $i++ === $limit) {
             break;
         }
         $items[] = (array) $item;
     }
     return $items;
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:39,代码来源:feed.php


示例5: __construct

 public function __construct($username = '', $password = '', $email = '')
 {
     // load database library into $this->db
     parent::__construct();
     if ($username != '' and $password != '' and $email != '') {
         if (strlen($username) < 3) {
             throw new Exception('Username too short');
         } elseif (strlen($username) > 12) {
             throw new Exception('Username too long');
         } elseif (strlen($password) < 6) {
             throw new Exception('Password too short');
         } elseif (strlen($username) > 255) {
             throw new Exception('Password too long');
         } elseif (valid::email($email) == False) {
             throw new Exception('Invalid email supplied');
         } elseif ($this->user_exists($username, $email)) {
             throw new Exception('User already exists (login or email matched)');
         }
         if ($this->register($username, $password, $email)->valid()) {
             return true;
         } else {
             return false;
         }
     }
 }
开发者ID:esal,项目名称:SpeedFreak,代码行数:25,代码来源:user.php


示例6: convert_uploaded_to_abs

 /**
  * Converts a file location to an absolute URL or returns the absolute URL if absolute URL
  * is passed. This function is for uploaded files since it uses the configured upload dir
  *
  * @param   string  file location or full URL
  * @return  string
  */
 public static function convert_uploaded_to_abs($file)
 {
     if (valid::url($file) == true) {
         return $file;
     }
     return url::base() . Kohana::config('upload.relative_directory') . '/' . $file;
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:14,代码来源:MY_url.php


示例7: unique_key

 /**
  * Allows a model to be loaded by username or email address.
  */
 public function unique_key($id)
 {
     if (!empty($id) and is_string($id) and !ctype_digit($id)) {
         return valid::email($id) ? 'email' : 'username';
     }
     return parent::unique_key($id);
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:10,代码来源:forum.php


示例8: get_item

 public function get_item($table, $id = FALSE)
 {
     $id = $id ? $id : valid::id_key($this->item_id);
     $item = ORM::factory($table)->where('fk_site', $this->site_id)->find($id);
     if (!$item->loaded) {
         die("invalid item for {$table}");
     }
     return $item;
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:9,代码来源:edit_tool.php


示例9: request

 /**
  * Method that allows sending any kind of HTTP request to remote url
  *
  * @param string $method
  * @param string $url
  * @param array $headers
  * @param array $data
  * @return HTTP_Response
  */
 public static function request($method, $url, $headers = array(), $data = array())
 {
     $valid_methods = array('POST', 'GET', 'PUT', 'DELETE');
     $method = utf8::strtoupper($method);
     if (!valid::url($url, 'http')) {
         return FALSE;
     }
     if (!in_array($method, $valid_methods)) {
         return FALSE;
     }
     // Get the hostname and path
     $url = parse_url($url);
     if (empty($url['path'])) {
         // Request the root document
         $url['path'] = '/';
     }
     // Open a remote connection
     $remote = fsockopen($url['host'], 80, $errno, $errstr, 5);
     if (!is_resource($remote)) {
         return FALSE;
     }
     // Set CRLF
     $CRLF = "\r\n";
     $path = $url['path'];
     if ($method == 'GET' and !empty($url['query'])) {
         $path .= '?' . $url['query'];
     }
     $headers_default = array('Host' => $url['host'], 'Connection' => 'close', 'User-Agent' => 'Ushahidi Scheduler (+http://ushahidi.com/)');
     $body_content = '';
     if ($method != 'GET') {
         $headers_default['Content-Type'] = 'application/x-www-form-urlencoded';
         if (count($data) > 0) {
             $body_content = http_build_query($data);
         }
         $headers_default['Content-Length'] = strlen($body_content);
     }
     $headers = array_merge($headers_default, $headers);
     // Send request
     $request = $method . ' ' . $path . ' HTTP/1.0' . $CRLF;
     foreach ($headers as $key => $value) {
         $request .= $key . ': ' . $value . $CRLF;
     }
     // Send one more CRLF to terminate the headers
     $request .= $CRLF;
     if ($body_content) {
         $request .= $body_content . $CRLF;
     }
     fwrite($remote, $request);
     $response = '';
     while (!feof($remote)) {
         // Get 1K from buffer
         $response .= fread($remote, 1024);
     }
     // Close the connection
     fclose($remote);
     return new HTTP_Response($response, $method);
 }
开发者ID:pablohernandezb,项目名称:reportachacao-server,代码行数:66,代码来源:MY_remote.php


示例10: tool

 public function tool()
 {
     if (empty($_GET['tool_id'])) {
         die('invalid tool_id');
     }
     $tool_id = valid::id_key($_GET['tool_id']);
     $tool = ORM::factory('tool', $tool_id);
     if (!$tool->loaded) {
         die('invalid tool');
     }
     $toolname = strtolower($tool->system_tool->name);
     # load the tool parent
     $parent = ORM::factory($toolname, $tool->parent_id);
     if (!$parent->loaded) {
         die('invalid parent table');
     }
     # build the object.
     $export = new stdClass();
     $export->name = $toolname;
     # export the parent table.
     $parent_table = new stdClass();
     foreach ($parent->table_columns as $key => $value) {
         $parent_table->{$key} = $parent->{$key};
     }
     $export->parent_table = $parent_table;
     # export any child tables.
     $child_tables = new stdClass();
     # loop through data from available child tables.
     foreach ($parent->has_many as $table_name) {
         $table_name = inflector::singular($table_name);
         $child_tables->{$table_name} = array();
         # get the child table model so we can iterate through the fields.
         $table = ORM::factory($table_name);
         # get any rows beloning to the parent.
         $rows = ORM::factory($table_name)->where(array('fk_site' => $this->site_id, "{$toolname}_id" => $parent->id))->find_all();
         foreach ($rows as $row) {
             $object = new stdClass();
             foreach ($table->table_columns as $key => $value) {
                 $object->{$key} = $row->{$key};
             }
             array_push($child_tables->{$table_name}, $object);
         }
     }
     $export->child_tables = $child_tables;
     # get the css file.
     $export->css = file_get_contents($this->assets->themes_dir("{$this->theme}/tools/{$toolname}/_created/{$parent->id}/{$parent->type}_{$parent->view}.css"));
     $json = json_encode($export);
     echo '<h2>Copy this exactly and place into the importer=)</h2>';
     echo "<textarea style='width:99%;height:400px;'>{$json}</textarea>";
     die;
     echo kohana::debug($export);
     die;
     # just testing ...
     echo self::import($json);
     die;
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:56,代码来源:export.php


示例11: get_tag

 private function get_tag()
 {
     valid::id_key($this->tag_id);
     $tag = ORM::factory('tag')->where('owner_id', $this->owner->id)->find($this->tag_id);
     if (!$tag->loaded) {
         $this->rsp->msg = 'Tag does not exist';
         $this->rsp->send();
     }
     return $tag;
 }
开发者ID:plusjade,项目名称:pluspanda-php,代码行数:10,代码来源:tags.php


示例12: length

 public function length()
 {
     var_dump(valid::length(1, 10, 'evan'));
     var_dump(valid::length(1, 10, 'evan byrne'));
     var_dump(valid::length(1, 10, 'evan thomas byrne'));
     var_dump(valid::length(1, 10, ''));
     var_dump(valid::length(1, 3, 'evan'));
     var_dump(valid::length(4, 10, 'evan'));
     var_dump(valid::length(5, 10, 'evan'));
     var_dump(valid::length(5, 6, 'evan b'));
 }
开发者ID:reang,项目名称:Dingo-Framework,代码行数:11,代码来源:validate.php


示例13: validate_email_form

 private function validate_email_form()
 {
     $messages = array();
     if (valid::email($this->input->post('email')) == false) {
         $messages[] = 'The supplied email address does not appear valid';
     }
     if ($this->input->post('body') == '') {
         $messages[] = 'The body of your message should not be empty';
     }
     return $messages;
 }
开发者ID:ukd1,项目名称:Gearman-and-Kohana-example-project,代码行数:11,代码来源:welcome.php


示例14: save_tree

 function save_tree()
 {
     if ($_POST) {
         valid::id_key($this->pid);
         $json = json_decode($_POST['json']);
         if (NULL === $json or !is_array($json)) {
             die('invalid json');
         }
         echo Tree::save_tree('navigation', 'navigation_item', $this->pid, $this->site_id, $json);
     }
     die;
 }
开发者ID:plusjade,项目名称:plusjade,代码行数:12,代码来源:edit_navigation.php


示例15: get_testimonial

 private function get_testimonial()
 {
     if (0 == $this->testimonial_id) {
         $new = ORM::factory('testimonial');
         $new->owner_id = $this->owner->id;
         return $new;
     }
     valid::id_key($this->testimonial_id);
     $testimonial = ORM::factory('testimonial')->where('owner_id', $this->owner->id)->find($this->testimonial_id);
     if (!$testimonial->loaded) {
         $this->rsp->msg = 'Testimonial does not exist';
         $this->rsp->send();
     }
     return $testimonial;
 }
开发者ID:plusjade,项目名称:pluspanda-php,代码行数:15,代码来源:manage.php


示例16: pull

 /**
  * Quickly pulls data from a URI. This only works with GET requests but
  * can handle HTTP Basic Auth
  *
  * @param   string       uri  the url to pull from
  * @param   string       username  the username for the service [Optional]
  * @param   string       password  the password for the user [Optional]
  * @return  string
  * @throws  Kohana_User_Exception
  * @author  Sam Clark
  * @access  public
  * @static
  **/
 public static function pull($uri, $username = FALSE, $password = FALSE)
 {
     if (!valid::url($uri)) {
         throw new Kohana_User_Exception('Curl::pull()', 'The URL : ' . $uri . ' is not a valid resource');
     }
     // Initiate a curl session based on the URL supplied
     $curl = Curl::factory(array(CURLOPT_POST => FALSE), $uri);
     // If a username/password is supplied
     if ($username and $password) {
         // Add the HTTP Basic Auth headers
         $curl->setopt_array(array(CURLOPT_USERPWD => $username . ':' . $password));
     }
     // Launch the request and return the result
     return $curl->exec()->result();
 }
开发者ID:xig,项目名称:SocialFeed,代码行数:28,代码来源:Curl.php


示例17: layer_url_file_check

 /**
  * Performs validation checks on the layer url and layer file - Checks that at least
  * one of them has been specified using the applicable validation rules
  *
  * @param Validation $array Validation object containing the field names to be checked
  */
 public function layer_url_file_check(Validation $array)
 {
     // Ensure at least a layer URL or layer file has been specified
     if (empty($array->layer_url) and empty($array->layer_file) and empty($array->layer_file_old)) {
         $array->add_error('layer_url', 'atleast');
     }
     // Add validation rule for the layer URL if specified
     if (!empty($array->layer_url) and (empty($array->layer_file) or empty($array->layer_file_old))) {
         if (!valid::url($array->layer_url)) {
             $array->add_error('layer_url', 'url');
         }
     }
     // Check if both the layer URL and the layer file have been specified
     if (!empty($array->layer_url) and (!empty($array->layer_file_old) or !empty($array->layer_file))) {
         $array->add_error('layer_url', 'both');
     }
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:23,代码来源:layer.php


示例18: user

 /**
  * Displays a profile page for a user
  */
 public function user()
 {
     // Cacheable Controller
     $this->is_cachable = TRUE;
     $this->template->header->this_page = 'profile';
     // Check if we are looking for a user. Argument must be set to continue.
     if (!isset(Router::$arguments[0])) {
         url::redirect('profile');
     }
     $username = Router::$arguments[0];
     // We won't allow profiles to be public if the username is an email address
     if (valid::email($username)) {
         url::redirect('profile');
     }
     $user = User_Model::get_user_by_username($username);
     // We only want to show public profiles here
     if ($user->public_profile == 1) {
         $this->template->content = new View('profile/user');
         $this->template->content->user = $user;
         // User Reputation Score
         $this->template->content->reputation = reputation::calculate($user->id);
         // All users reports
         $this->template->content->reports = ORM::factory('incident')->where(array('user_id' => $user->id, 'incident_active' => 1))->with('incident:location')->find_all();
         // Get Badges
         $this->template->content->badges = Badge_Model::users_badges($user->id);
         // Logged in user id (false if not logged in)
         $logged_in_id = FALSE;
         if (isset(Auth::instance()->get_user()->id)) {
             $logged_in_id = Auth::instance()->get_user()->id;
         }
         $this->template->content->logged_in_id = $logged_in_id;
         // Is this the logged in user?
         $logged_in_user = FALSE;
         if ($logged_in_id == $user->id) {
             $logged_in_user = TRUE;
         }
         $this->template->content->logged_in_user = $logged_in_user;
     } else {
         // this is a private profile so get out of here
         url::redirect('profile');
     }
     $this->template->header->page_title .= $user->name . Kohana::config('settings.title_delimiter');
     $this->template->header->header_block = $this->themes->header_block();
     $this->template->footer->footer_block = $this->themes->footer_block();
 }
开发者ID:nanangsyaifudin,项目名称:HAC-2012,代码行数:48,代码来源:profile.php


示例19: color

 /**
  * Normalizes a hexadecimal HTML color value. All values will be converted
  * to lowercase, have a "#" prepended and contain six characters.
  *
  * @param   string  hexadecimal HTML color value
  * @return  string
  */
 public static function color($str = '')
 {
     // Reject invalid values
     if (!valid::color($str)) {
         return '';
     }
     // Convert to lowercase
     $str = strtolower($str);
     // Prepend "#"
     if ($str[0] !== '#') {
         $str = '#' . $str;
     }
     // Expand short notation
     if (strlen($str) === 4) {
         $str = '#' . $str[1] . $str[1] . $str[2] . $str[2] . $str[3] . $str[3];
     }
     return $str;
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:25,代码来源:format.php


示例20: validate

 public function validate($array)
 {
     $default = array("title" => "", "display_name" => "", "email" => "");
     $array = arr::overwrite($default, $array);
     $errors = array();
     if ($array['display_name'] == "") {
         $errors['display_name'] = "Please enter a display name";
     }
     if (!valid::email($array['email'])) {
         $errors['email'] = "Please enter a valid email";
     }
     if ($array['title'] == "") {
         $errors['title'] = "Please enter text for your comment";
     }
     $array['title'] = strip_tags($array['title']);
     $array['errors'] = $errors;
     return $array;
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:18,代码来源:zest_comment.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP validate类代码示例发布时间:2022-05-23
下一篇:
PHP vRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap