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


PHP valid类代码示例

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


在下文中一共展示了valid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: welcome@pluspanda.com \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


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