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


PHP Validation::url方法代码示例

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


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

示例1: beforeSave

 public function beforeSave($options = array())
 {
     // add http:// if not present in webpage
     $webpage = $this->data['Registrant']['webpage'];
     $V = new Validation();
     if (!empty($webpage) && $V->url($webpage) && !$V->url($webpage, true)) {
         $this->data['Registrant']['webpage'] = 'http://' . $webpage;
     }
     // generate edit key
     if (empty($this->data['Registrant']['edit_key'])) {
         $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
         $this->data['Registrant']['edit_key'] = substr(str_shuffle($chars), 0, 8);
     }
     return true;
 }
开发者ID:nilesjohnson,项目名称:simple-conference,代码行数:15,代码来源:Registrant.php

示例2: __cleanOptions

 function __cleanOptions($options)
 {
     if (!$options['size']) {
         unset($options['size']);
     } else {
         if ($options['size'] < 1) {
             $options['size'] = 1;
         } elseif ($options['size'] > 512) {
             $options['size'] = 512;
         }
     }
     if (!$options['rating'] || !in_array($options['rating'], $this->__allowedRatings)) {
         unset($options['rating']);
     }
     if (!$options['default']) {
         unset($options['default']);
     } else {
         if (!in_array($options['default'], $this->__defaultIcons)) {
             if (!Validation::url($options['default'])) {
                 unset($options['default']);
             }
         }
     }
     return $options;
 }
开发者ID:kouak,项目名称:ircube,代码行数:25,代码来源:gravatar.php

示例3: register

 function register()
 {
     global $timezones;
     $this->pageTitle = __('register', true);
     $this->set('tzs', $timezones);
     $this->set('utz', $this->data['User']['tz']);
     if (!empty($this->data)) {
         $this->Security->requirePost('register');
         $v = new Validation();
         if ($this->data['User']['email'] !== $this->data['User']['confemail']) {
             $this->User->invalidate('confemail');
         }
         if ($this->User->findByEmail($this->data['User']['email']) || !$v->email($this->data['User']['email'])) {
             $this->User->invalidate('email');
         }
         if ($this->data['User']['password'] !== $this->data['User']['confpass']) {
             $this->User->invalidate('confpass');
         }
         if (!$v->url($this->data['User']['website']) && !empty($this->data['User']['website'])) {
             $this->User->invalidate('website');
         }
         if ($this->User->validates()) {
             $clean = new Sanitize();
             // Generate and set the password, salt and activation key
             $pass = $this->Hash->password($this->data['User']['password'], $this->data['User']['email']);
             $this->data['User']['active'] = $this->Hash->keygen(10, true);
             $this->data['User']['password'] = $pass['pass'];
             $this->data['User']['salt'] = $pass['salt'];
             // Save a few fields from the wrath of cleanArray()
             $temp = array('lat' => $this->data['User']['lat'], 'lng' => $this->data['User']['lng'], 'tz' => $this->data['User']['tz'], 'email' => $this->data['User']['email']);
             // Scrub 'a dub
             $clean->clean($this->data);
             $this->data['User']['email'] = $clean->escape($temp['email']);
             $this->data['User']['lng'] = floatval($temp['lng']);
             $this->data['User']['lat'] = floatval($temp['lat']);
             $this->data['User']['tz'] = intval($temp['tz']);
             $this->data['User']['role'] = 0;
             $this->User->begin();
             if ($this->User->save($this->data)) {
                 $this->Email->to = $this->data['User']['email'];
                 $this->Email->replyTo = $this->data['User']['email'];
                 $this->Email->from = APP_NAME . ' <' . APP_EMAIL . '>';
                 $this->Email->subject = sprintf(__('email_subject_welcome', true), APP_NAME);
                 $this->Email->template = 'register';
                 $this->Email->sendAs = 'both';
                 $this->set('actcode', $this->data['User']['active']);
                 if ($this->Email->send()) {
                     $this->User->commit();
                     $this->Session->setFlash('Account created!');
                 } else {
                     $this->User->rollback();
                     $this->Session->setFlash('Error!');
                 }
             } else {
                 $this->User->rollback();
                 $this->Session->setFlash('Error\'d');
             }
         }
     }
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:60,代码来源:users_controller.php

示例4: setURL

 /**
  * Set URL
  *
  * Validates and sets the URL.
  *
  * @param string $url
  * @return true
  * @throws Exception
  */
 public function setURL($url)
 {
     if (!Validation::url($url) || !is_string($url)) {
         throw new Exception("URL is not valid to curl.");
     }
     curl_setopt($this->curl, CURLOPT_URL, $url);
     $this->set[] = 'url';
     return true;
 }
开发者ID:ZacharyDuBois,项目名称:Research-Botnet,代码行数:18,代码来源:HTTP.php

示例5: view

 public function view()
 {
     if (empty($this->request->query['link'])) {
         throw new NotFoundException('Missing link parameter');
     }
     $link = rawurldecode($this->request->query['link']);
     if (!Validation::url($link)) {
         throw new NotFoundException('Invalid link');
     }
     $request = new Nodes\Curl($link);
     $request->exec();
     $responseCode = $request->getResponseCode();
     if ($responseCode != 200) {
         throw new NotFoundException('Response code was not 200 OK');
     }
     $this->response->disableCache();
     $this->response->type($request->getResponseHeader('content-type'));
     $this->response->body($request->getResponseBody());
     $this->response->send();
     $this->_stop();
 }
开发者ID:nodesagency,项目名称:Platform-Common-Plugin,代码行数:21,代码来源:SslProxyController.php

示例6: testUrl

 /**
  * testUrl method
  *
  * @return void
  */
 public function testUrl()
 {
     $this->assertTrue(Validation::url('http://www.cakephp.org'));
     $this->assertTrue(Validation::url('http://cakephp.org'));
     $this->assertTrue(Validation::url('http://www.cakephp.org/somewhere#anchor'));
     $this->assertTrue(Validation::url('http://192.168.0.1'));
     $this->assertTrue(Validation::url('https://www.cakephp.org'));
     $this->assertTrue(Validation::url('https://cakephp.org'));
     $this->assertTrue(Validation::url('https://www.cakephp.org/somewhere#anchor'));
     $this->assertTrue(Validation::url('https://192.168.0.1'));
     $this->assertTrue(Validation::url('ftps://www.cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftps://cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftps://192.168.0.1/pub/cake'));
     $this->assertTrue(Validation::url('ftp://www.cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftp://cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftp://192.168.0.1/pub/cake'));
     $this->assertTrue(Validation::url('sftp://192.168.0.1/pub/cake'));
     $this->assertTrue(Validation::url('https://my.domain.com/gizmo/app?class=MySip;proc=start'));
     $this->assertTrue(Validation::url('www.domain.tld'));
     $this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
     $this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
     $this->assertTrue(Validation::url('http://www.domain.com/blogs/parenth()eses.php'));
     $this->assertTrue(Validation::url('http://www.domain.com/index.php?get=params&amp;get2=params'));
     $this->assertTrue(Validation::url('http://www.domain.com/ndex.php?get=params&amp;get2=params#anchor'));
     $this->assertTrue(Validation::url('http://www.domain.com/real%20url%20encodeing'));
     $this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)'));
     $this->assertTrue(Validation::url('http://www.cakephp.org', true));
     $this->assertTrue(Validation::url('http://example.com/~userdir/'));
     $this->assertTrue(Validation::url('http://underscore_subdomain.example.org'));
     $this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com'));
     $this->assertTrue(Validation::url('http://www.domain.longttldnotallowed'));
     $this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
     $this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
     $this->assertFalse(Validation::url('http://w_w.domain.co_m'));
     $this->assertFalse(Validation::url('http://www.domain.12com'));
     $this->assertFalse(Validation::url('http://www.-invaliddomain.tld'));
     $this->assertFalse(Validation::url('http://www.domain.-invalidtld'));
     $this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
     $this->assertFalse(Validation::url('http://www.underscore_domain.org'));
     $this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com'));
     $this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
     $this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode'));
     $this->assertFalse(Validation::url('--.example.com'));
     $this->assertFalse(Validation::url('www.cakephp.org', true));
     $this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));
     $this->assertTrue(Validation::url('http://www.zwischenraume.de'));
     $this->assertTrue(Validation::url('http://www.zwischenraume.cz'));
     $this->assertTrue(Validation::url('http://www.last.fm/music/浜崎あゆみ'), 'utf8 path failed');
     $this->assertTrue(Validation::url('http://www.electrohome.ro/images/239537750-284232-215_300[1].jpg'));
     $this->assertTrue(Validation::url('http://www.eräume.foo'));
     $this->assertTrue(Validation::url('http://äüö.eräume.foo'));
     $this->assertTrue(Validation::url('http://cakephp.org:80'));
     $this->assertTrue(Validation::url('http://cakephp.org:443'));
     $this->assertTrue(Validation::url('http://cakephp.org:2000'));
     $this->assertTrue(Validation::url('http://cakephp.org:27000'));
     $this->assertTrue(Validation::url('http://cakephp.org:65000'));
     $this->assertTrue(Validation::url('[2001:0db8::1428:57ab]'));
     $this->assertTrue(Validation::url('[::1]'));
     $this->assertTrue(Validation::url('[2001:0db8::1428:57ab]:80'));
     $this->assertTrue(Validation::url('[::1]:80'));
     $this->assertTrue(Validation::url('http://[2001:0db8::1428:57ab]'));
     $this->assertTrue(Validation::url('http://[::1]'));
     $this->assertTrue(Validation::url('http://[2001:0db8::1428:57ab]:80'));
     $this->assertTrue(Validation::url('http://[::1]:80'));
     $this->assertFalse(Validation::url('[1::2::3]'));
 }
开发者ID:alvaroziqar,项目名称:galei,代码行数:71,代码来源:ValidationTest.php

示例7: _cleanOptions

 /**
  * Sanitize the options array
  *
  * @param array $options Array of options, keyed from default settings
  * @return array Clean options array
  */
 protected function _cleanOptions($options)
 {
     if (!isset($options['size']) || empty($options['size']) || !is_numeric($options['size'])) {
         unset($options['size']);
     } else {
         $options['size'] = min(max($options['size'], 1), 512);
     }
     if (!$options['rating'] || !in_array(mb_strtolower($options['rating']), $this->_allowedRatings)) {
         unset($options['rating']);
     }
     if (!$options['default']) {
         unset($options['default']);
     } else {
         App::uses('Validation', 'Utility');
         if (!in_array($options['default'], $this->_defaultIcons) && !Validation::url($options['default'])) {
             unset($options['default']);
         }
     }
     return $options;
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:26,代码来源:GravatarHelper.php

示例8: testUrl

 /**
  * testUrl method
  *
  * @access public
  * @return void
  */
 function testUrl()
 {
     $this->assertTrue(Validation::url('http://www.cakephp.org'));
     $this->assertTrue(Validation::url('http://cakephp.org'));
     $this->assertTrue(Validation::url('http://www.cakephp.org/somewhere#anchor'));
     $this->assertTrue(Validation::url('http://192.168.0.1'));
     $this->assertTrue(Validation::url('https://www.cakephp.org'));
     $this->assertTrue(Validation::url('https://cakephp.org'));
     $this->assertTrue(Validation::url('https://www.cakephp.org/somewhere#anchor'));
     $this->assertTrue(Validation::url('https://192.168.0.1'));
     $this->assertTrue(Validation::url('ftps://www.cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftps://cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftps://192.168.0.1/pub/cake'));
     $this->assertTrue(Validation::url('ftp://www.cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftp://cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftp://192.168.0.1/pub/cake'));
     $this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
     $this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
     $this->assertTrue(Validation::url('https://my.domain.com/gizmo/app?class=MySip;proc=start'));
     $this->assertTrue(Validation::url('www.domain.tld'));
     $this->assertFalse(Validation::url('http://w_w.domain.co_m'));
     $this->assertFalse(Validation::url('http://www.domain.12com'));
     $this->assertFalse(Validation::url('http://www.domain.longttldnotallowed'));
     $this->assertFalse(Validation::url('http://www.-invaliddomain.tld'));
     $this->assertFalse(Validation::url('http://www.domain.-invalidtld'));
     $this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
     $this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
     $this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
     $this->assertTrue(Validation::url('http://www.domain.com/blogs/parenth()eses.php'));
     $this->assertTrue(Validation::url('http://www.domain.com/index.php?get=params&amp;get2=params'));
     $this->assertTrue(Validation::url('http://www.domain.com/ndex.php?get=params&amp;get2=params#anchor'));
     $this->assertFalse(Validation::url('http://www.domain.com/fakeenco%ode'));
     $this->assertTrue(Validation::url('http://www.domain.com/real%20url%20encodeing'));
     $this->assertTrue(Validation::url('http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)'));
     $this->assertFalse(Validation::url('http://en.(wikipedia).org/'));
     $this->assertFalse(Validation::url('www.cakephp.org', true));
     $this->assertTrue(Validation::url('http://www.cakephp.org', true));
     $this->assertTrue(Validation::url('http://example.com/~userdir/'));
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:45,代码来源:validation.test.php

示例9: location

 /**
  * Checks if path is within given locations
  *
  * @param string $check Absolute path
  * @param mixed $allow True or * allows any location,
  * 	an array containing absolute paths to locations
  * @return boolean
  */
 function location($check, $allow = false)
 {
     $allow = self::_normalize($allow);
     if ($allow === true) {
         return true;
     } elseif ($allow === false) {
         return false;
     }
     if (!is_array($allow)) {
         $allow = array($allow);
     } else {
         $allow = array_unique($allow);
     }
     if (Validation::url($check)) {
         foreach ($allow as $path) {
             if (preg_match('/^' . preg_quote($path, '/') . '/', $check)) {
                 return true;
             }
         }
     } elseif (MediaValidation::file($check, false)) {
         $check = dirname($check);
         if (!Folder::isAbsolute($check)) {
             return false;
         }
         $Check = new Folder($check);
         foreach ($allow as $path) {
             if (!Folder::isAbsolute($path) || Validation::url($path)) {
                 continue;
             }
             if ($Check->inPath($path)) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:rcaravita,项目名称:jodeljodel,代码行数:44,代码来源:media_validation.php

示例10: testInvalidUrlWithoutPrefix

 /**
  * @testdox url should return false to URLs without protocol
  */
 public function testInvalidUrlWithoutPrefix()
 {
     $value = 'spaghettiphp.org/download#download';
     $this->assertFalse(Validation::url($value));
 }
开发者ID:klawdyo,项目名称:spaghettiphp,代码行数:8,代码来源:ValidationTest.php

示例11: __cleanOptions

 /**
  * Sanitize the options array
  *
  * @param array $options Array of options, keyed from default settings
  * @return array Clean options array
  * @access public
  */
 public function __cleanOptions($options)
 {
     if (!isset($options['size']) || empty($options['size']) || !is_numeric($options['size'])) {
         unset($options['size']);
     } else {
         $options['size'] = min(max($options['size'], 1), 512);
     }
     if (!$options['rating'] || !in_array(mb_strtolower($options['rating']), $this->__allowedRatings)) {
         unset($options['rating']);
     }
     if (!$options['default']) {
         unset($options['default']);
     } else {
         if (!in_array($options['default'], $this->__defaultIcons) && !Validation::url($options['default'])) {
             unset($options['default']);
         }
     }
     return $options;
 }
开发者ID:Galvanio,项目名称:Kinspir,代码行数:26,代码来源:gravatar.php

示例12: url

 /**
  * Validates url
  *
  * @param string string to check
  * @param array options for allowing different url parts currently only scheme is supported
  */
 static function url($check, $options = array())
 {
     if (!is_string($check)) {
         return false;
     }
     if (isset($options['scheme'])) {
         if (!preg_match('/^(' . implode('|', (array) $options['scheme']) . ':)+/', $check)) {
             return false;
         }
     }
     return Validation::url($check);
 }
开发者ID:razzman,项目名称:media,代码行数:18,代码来源:TransferValidation.php

示例13: validateUrl

 /**
  * Checks if a url is valid AND accessable (returns false otherwise)
  *
  * @param array/string $data: full url(!) starting with http://...
  * @options array
  * - allowEmpty TRUE/FALSE (TRUE: if empty => return TRUE)
  * - required TRUE/FALSE (TRUE: overrides allowEmpty)
  * - autoComplete (default: TRUE)
  * - deep (default: TRUE)
  * @return bool Success
  */
 public function validateUrl($data, $options = [])
 {
     if (is_array($data)) {
         foreach ($data as $key => $url) {
             break;
         }
     } else {
         $url = $data;
     }
     if (empty($url)) {
         if (!empty($options['allowEmpty']) && empty($options['required'])) {
             return true;
         }
         return false;
     }
     if (!isset($options['autoComplete']) || $options['autoComplete'] !== false) {
         $url = $this->_autoCompleteUrl($url);
         if (isset($key)) {
             $this->data[$this->alias][$key] = $url;
         }
     }
     if (!isset($options['strict']) || $options['strict'] !== false) {
         $options['strict'] = true;
     }
     // validation
     if (!Validation::url($url, $options['strict']) && env('REMOTE_ADDR') && env('REMOTE_ADDR') !== '127.0.0.1') {
         return false;
     }
     // same domain?
     if (!empty($options['sameDomain']) && env('HTTP_HOST')) {
         $is = parse_url($url, PHP_URL_HOST);
         $expected = env('HTTP_HOST');
         if (mb_strtolower($is) !== mb_strtolower($expected)) {
             return false;
         }
     }
     if (isset($options['deep']) && $options['deep'] === false) {
         return true;
     }
     return $this->_validUrl($url);
 }
开发者ID:ByMyHandsOnly,项目名称:BMHO_Web,代码行数:52,代码来源:MyModel.php

示例14: testUrl

 /**
  * testUrl method
  *
  * @access public
  * @return void
  */
 function testUrl()
 {
     $this->assertTrue(Validation::url('http://www.cakephp.org'));
     $this->assertTrue(Validation::url('http://cakephp.org'));
     $this->assertTrue(Validation::url('http://www.cakephp.org/somewhere#anchor'));
     $this->assertTrue(Validation::url('http://192.168.0.1'));
     $this->assertTrue(Validation::url('https://www.cakephp.org'));
     $this->assertTrue(Validation::url('https://cakephp.org'));
     $this->assertTrue(Validation::url('https://www.cakephp.org/somewhere#anchor'));
     $this->assertTrue(Validation::url('https://192.168.0.1'));
     $this->assertTrue(Validation::url('ftps://www.cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftps://cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftps://192.168.0.1/pub/cake'));
     $this->assertTrue(Validation::url('ftp://www.cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftp://cakephp.org/pub/cake'));
     $this->assertTrue(Validation::url('ftp://192.168.0.1/pub/cake'));
     $this->assertFalse(Validation::url('ftps://256.168.0.1/pub/cake'));
     $this->assertFalse(Validation::url('ftp://256.168.0.1/pub/cake'));
     $this->assertTrue(Validation::url('https://my.domain.com/gizmo/app?class=MySip;proc=start'));
     $this->assertTrue(Validation::url('www.domain.tld'));
     $this->assertFalse(Validation::url('http://w_w.domain.co_m'));
     $this->assertFalse(Validation::url('http://www.domain.12com'));
     $this->assertFalse(Validation::url('http://www.domain.longttldnotallowed'));
     $this->assertFalse(Validation::url('http://www.-invaliddomain.tld'));
     $this->assertFalse(Validation::url('http://www.domain.-invalidtld'));
     $this->assertTrue(Validation::url('http://123456789112345678921234567893123456789412345678951234567896123.com'));
     $this->assertFalse(Validation::url('http://this-domain-is-too-loooooong-by-icann-rules-maximum-length-is-63.com'));
     $this->assertTrue(Validation::url('http://www.domain.com/blogs/index.php?blog=6&tempskin=_rss2'));
 }
开发者ID:subh,项目名称:raleigh-workshop-08,代码行数:35,代码来源:validation.test.php

示例15: validateUrlOrAbsolute

 /**
  * @brief check for urls either /something/here or full
  *
  * this can be a url relative to the site /my/page or full like
  * http://site.com/my/page it can also be empty for times when the selects
  * are used to build the url
  *
  * @todo remove current($field) == '' || as 'notEmpty' works fine
  *
  * @param array $field the field being validated
  * @access public
  *
  * @return bool is it valid
  */
 public function validateUrlOrAbsolute($Model, $field)
 {
     return current($field) == '' || substr(current($field), 0, 1) == '/' || Validation::url(current($field), true);
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:18,代码来源:ValidationBehavior.php


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