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


PHP Valid::url方法代码示例

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


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

示例1: set_rss_url

 public function set_rss_url($url)
 {
     if (!Valid::url($url)) {
         return NULL;
     }
     return $url;
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:7,代码来源:rss.php

示例2: set_values

 public function set_values(array $data)
 {
     if (!Valid::url($data['next_url'])) {
         $data['next_url'] = NULL;
     }
     $data['fields'] = array();
     if (!empty($data['field']) and is_array($data['field'])) {
         foreach ($data['field'] as $key => $values) {
             foreach ($values as $index => $value) {
                 if ($index == 0) {
                     continue;
                 }
                 if ($key == 'source') {
                     $value = URL::title($value, '_');
                 }
                 $data['fields'][$index][$key] = $value;
             }
         }
         $data['field'] = NULL;
     }
     $email_type_fields = array();
     foreach ($data['fields'] as $field) {
         $email_type_fields['key'][] = $field['id'];
         $email_type_fields['value'][] = !empty($field['name']) ? $field['name'] : Inflector::humanize($field['id']);
     }
     $this->create_email_type($email_type_fields);
     return parent::set_values($data);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:28,代码来源:sendmail.php

示例3: content

 /**
  * Render content.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     // Cover
     if (Valid::url($this->track->cover)) {
         echo HTML::image($this->track->cover, array('class' => 'cover img-responsive', 'alt' => __('Cover')));
     }
     // Time
     if ($this->track->size_time) {
         echo '<i class="fa fa-fw fa-clock-o"></i> ' . $this->track->size_time . '<br />';
     }
     // Listen count
     if ($this->track->listen_count > 1) {
         echo '<i class="fa fa-fw fa-play"></i> ' . ($this->track->listen_count == 1 ? __(':count play', array(':count' => $this->track->listen_count)) : __(':count plays', array(':count' => $this->track->listen_count))) . '<br />';
     }
     // Tags
     if ($tags = $this->track->tags()) {
         echo '<i class="fa fa-fw fa-music"></i> ' . implode(', ', $tags) . '<br />';
     } elseif (!empty($this->track->music)) {
         echo '<i class="fa fa-fw fa-music"></i> ' . $this->track->music . '<br />';
     }
     // Meta
     echo '<footer class="meta text-muted">';
     echo __('Added :date', array(':date' => HTML::time(Date::format(Date::DMY_SHORT, $this->track->created), $this->track->created)));
     echo '</footer>';
     return ob_get_clean();
 }
开发者ID:anqh,项目名称:anqh,代码行数:32,代码来源:info.php

示例4: download

 public static function download($url, $directory, $filename = NULL)
 {
     $url = str_replace(' ', '%20', $url);
     if (!Valid::url($url)) {
         return FALSE;
     }
     $curl = curl_init($url);
     $file = Upload_Util::combine($directory, uniqid());
     $handle = fopen($file, 'w');
     $headers = new HTTP_Header();
     curl_setopt($curl, CURLOPT_FILE, $handle);
     curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
     curl_setopt($curl, CURLOPT_HEADERFUNCTION, array($headers, 'parse_header_string'));
     if (curl_exec($curl) === FALSE or curl_getinfo($curl, CURLINFO_HTTP_CODE) !== 200) {
         fclose($handle);
         unlink($file);
         throw new Kohana_Exception('Curl: Download Error: :error, status :status on url :url', array(':url' => $url, ':status' => curl_getinfo($curl, CURLINFO_HTTP_CODE), ':error' => curl_error($curl)));
     }
     fclose($handle);
     if ($filename === NULL) {
         if (!isset($headers['content-disposition']) or !($filename = Upload_Util::filename_from_content_disposition($headers['content-disposition']))) {
             $mime_type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
             $url = urldecode(curl_getinfo($curl, CURLINFO_EFFECTIVE_URL));
             $filename = Upload_Util::filename_from_url($url, $mime_type);
         }
     }
     $filename = substr(pathinfo($filename, PATHINFO_FILENAME), 0, 60) . '.' . pathinfo($filename, PATHINFO_EXTENSION);
     $result_file = Upload_Util::combine($directory, $filename);
     rename($file, $result_file);
     return is_file($result_file) ? $filename : FALSE;
 }
开发者ID:Konro1,项目名称:pms,代码行数:31,代码来源:Util.php

示例5: action_index

 public function action_index()
 {
     $code = $this->request->param('code');
     if ($code === NULL) {
         Model_Page_Front::not_found();
     }
     $reflink_model = ORM::factory('user_reflink', $code);
     if (!$reflink_model->loaded()) {
         Messages::errors(__('Reflink not found'));
         $this->go_home();
     }
     $next_url = Arr::get($reflink_model->data, 'next_url');
     try {
         Database::instance()->begin();
         Reflink::factory($reflink_model)->confirm();
         $reflink_model->delete();
         Database::instance()->commit();
     } catch (Kohana_Exception $e) {
         Database::instance()->rollback();
         Messages::errors($e->getMessage());
     }
     if (Valid::url($next_url)) {
         $this->go($next_url);
     }
     $this->go_home();
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:26,代码来源:reflink.php

示例6: validate_authorize_params

 /**
  *
  * @return array
  */
 public function validate_authorize_params()
 {
     $request_params = $this->_get_authorize_params();
     $validation = Validation::factory($request_params)->rule('client_id', 'not_empty')->rule('client_id', 'uuid::valid')->rule('response_type', 'not_empty')->rule('response_type', 'in_array', array(':value', OAuth2::$supported_response_types))->rule('scope', 'in_array', array(':value', OAuth2::$supported_scopes))->rule('redirect_uri', 'url');
     if (!$validation->check()) {
         throw new OAuth2_Exception_InvalidRequest("Invalid Request: " . Debug::vars($validation->errors()));
     }
     // Check we have a valid client
     $client = Model_OAuth2_Client::find_client($request_params['client_id']);
     if (!$client->loaded()) {
         throw new OAuth2_Exception_InvalidClient('Invalid client');
     }
     // Lookup the redirect_uri if none was supplied in the URL
     if (!Valid::url($request_params['redirect_uri'])) {
         $request_params['redirect_uri'] = $client->redirect_uri;
         // Is the redirect_uri still empty? Error if so..
         if (!Valid::url($request_params['redirect_uri'])) {
             throw new OAuth2_Exception_InvalidRequest('\'redirect_uri\' is required');
         }
     } else {
         if ($client->redirect_uri != $request_params['redirect_uri']) {
             throw new OAuth2_Exception_InvalidGrant('redirect_uri mismatch');
         }
     }
     // Check if this client is allowed use this response_type
     if (!in_array($request_params['response_type'], $client->allowed_response_types())) {
         throw new OAuth2_Exception_UnauthorizedClient('You are not allowed use the \':response_type\' response_type', array(':response_type' => $request_params['response_type']));
     }
     return $request_params;
 }
开发者ID:rafi,项目名称:kohana-oauth2,代码行数:34,代码来源:provider.php

示例7: parse

 /**
  * Parse a remote feed into an array.
  *
  * @param   string   $feed   Remote feed URL
  * @param   integer  $limit  Item limit to fetch [Optional]
  *
  * @return  array
  *
  * @uses    Valid::url
  */
 public function parse($feed, $limit = 0)
 {
     // Make limit an integer
     $limit = (int) $limit;
     // Disable error reporting while opening the feed
     $error_level = 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($error_level);
     // Feed could not be loaded
     if (!$feed) {
         return array();
     }
     $namespaces = $feed->getNamespaces(TRUE);
     // This only for RSS 1.0/2.0 are supported
     $feed = $feed->xpath('//item');
     $i = 0;
     $items = array();
     foreach ($feed as $item) {
         if ($limit > 0 and $i++ === $limit) {
             break;
         }
         $item_fields = (array) $item;
         // get namespaced tags
         foreach ($namespaces as $ns) {
             $item_fields += (array) $item->children($ns);
         }
         $items[] = $item_fields;
     }
     return $items;
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:44,代码来源:rss.php

示例8: content

 /**
  * Render content.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     // Stamp
     echo HTML::time(Date('l ', $this->event->stamp_begin) . Date::format('DDMMYYYY', $this->event->stamp_begin), $this->event->stamp_begin, true);
     // Location
     if ($this->event->venue) {
         echo ' @ ', HTML::anchor(Route::model($this->event->venue), HTML::chars($this->event->venue->name)), ', ', HTML::chars($this->event->venue->city_name);
     } elseif ($this->event->venue_name) {
         echo ' @ ', $this->event->venue_url ? HTML::anchor($this->event->venue_url, $this->event->venue_name) : HTML::chars($this->event->venue_name), $this->event->city_name ? ', ' . HTML::chars($this->event->city_name) : '';
     } elseif ($this->event->city_name) {
         echo ' @ ', HTML::chars($this->event->city_name);
     }
     // Flyer
     if ($this->event->flyer_front) {
         echo '<figure>', HTML::image($this->event->flyer_front->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>';
     } elseif ($this->event->flyer_back) {
         echo '<figure>', HTML::image($this->event->flyer_back->get_url(Model_Image::SIZE_THUMBNAIL)), '</figure>';
     } elseif (Valid::url($this->event->flyer_front_url)) {
         echo '<br /><figure>', HTML::image($this->event->flyer_front_url, array('width' => 160)), '</figure>';
     }
     // Favorites
     if ($this->event->favorite_count) {
         echo '<span class="stats"><i class="icon-heart"></i> ' . $this->event->favorite_count . '</span>';
     }
     return ob_get_clean();
 }
开发者ID:anqh,项目名称:events,代码行数:32,代码来源:hovercard.php

示例9: action_links

 /**
  * Links restful api
  */
 public function action_links()
 {
     // Is the logged in user an owner?
     if (!$this->owner) {
         throw new HTTP_Exception_403();
     }
     $this->template = "";
     $this->auto_render = FALSE;
     $droplet_id = intval($this->request->param('id', 0));
     $link_id = intval($this->request->param('id2', 0));
     switch ($this->request->method()) {
         case "POST":
             $link_array = json_decode($this->request->body(), TRUE);
             $url = $link_array['url'];
             if (!Valid::url($url)) {
                 $this->response->status(400);
                 $this->response->headers('Content-Type', 'application/json');
                 $errors = array(__("Invalid url"));
                 echo json_encode(array('errors' => $errors));
                 return;
             }
             $account_id = $this->visited_account->id;
             $link_orm = Model_Account_Droplet_Link::get_link($url, $droplet_id, $account_id);
             echo json_encode(array('id' => $link_orm->link->id, 'tag' => $link_orm->link->url));
             break;
         case "DELETE":
             Model_Droplet::delete_link($droplet_id, $link_id, $this->visited_account->id);
             break;
     }
 }
开发者ID:rukku,项目名称:SwiftRiver,代码行数:33,代码来源:base.php

示例10: check_link

 public static function check_link($link)
 {
     if (strpos($link, '//') !== FALSE) {
         return Valid::url($link);
     } elseif (strpos($link, '/') === 0) {
         return TRUE;
     }
 }
开发者ID:greor,项目名称:satin-spb,代码行数:8,代码来源:page.php

示例11: static_base

 /**
  * Returns LogReader static url.
  * 
  * @return  string
  * @uses    URL::base()
  */
 public static function static_base()
 {
     if (Valid::url(static::$config->get_static_route())) {
         return static::$config->get_static_route() . '/';
     } else {
         return URL::base(Request::current()) . static::$config->get_static_route() . '/';
     }
 }
开发者ID:siloor,项目名称:kohana-logreader,代码行数:14,代码来源:URL.php

示例12: parse

 /**
  * Parses a remote feed into an array.
  *
  * @param   string  $feed   remote feed URL
  * @param   integer $limit  item limit to fetch
  * @param   integer $cache_expire_time in seconds when cache expires
  * @return  array
  */
 public static function parse($feed, $limit = 0, $cache_expire_time = NULL)
 {
     //in case theres no expire time set to 24h
     if ($cache_expire_time === NULL) {
         $cache_expire_time = 24 * 60 * 60;
     }
     // Check if SimpleXML is installed
     if (!function_exists('simplexml_load_file')) {
         throw new Kohana_Exception('SimpleXML must be installed!');
     }
     // Make limit an integer
     $limit = (int) $limit;
     // Disable error reporting while opening the feed
     $error_level = error_reporting(0);
     // Allow loading by filename or raw XML string
     if (Valid::url($feed)) {
         //mod! force usage of curl with timeout and cached!
         $feed_result = Core::cache($feed, NULL, $cache_expire_time);
         //not cached :(
         if ($feed_result === NULL) {
             $feed_result = Core::curl_get_contents($feed, 5);
             Core::cache($feed, $feed_result, $cache_expire_time);
         }
         $feed = $feed_result;
     } elseif (is_file($feed)) {
         // Get file contents
         $feed = file_get_contents($feed);
     }
     // Load the feed
     $feed = simplexml_load_string($feed, 'SimpleXMLElement', LIBXML_NOCDATA);
     // Restore error reporting
     error_reporting($error_level);
     // Feed could not be loaded
     if ($feed === FALSE) {
         return array();
     }
     $namespaces = $feed->getNamespaces(TRUE);
     // 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;
         }
         $item_fields = (array) $item;
         // get namespaced tags
         foreach ($namespaces as $ns) {
             $item_fields += (array) $item->children($ns);
         }
         $items[] = $item_fields;
     }
     return $items;
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:62,代码来源:feed.php

示例13: set_loc

 /**
  * URL of the page. This URL must begin with the protocol (such as http) and end
  * with a trailing slash, if your web server requires it. This value must be
  * less than 2,048 characters.
  * @see http://www.sitemaps.org/protocol.php
  * @param string $location
  */
 public function set_loc($location)
 {
     if (!Valid::max_length($location, 2048)) {
         throw new LengthException('The location was too long, maximum length of 2,048 characters.');
     }
     $location = Sitemap::encode($location);
     if (!Valid::url($location)) {
         throw new InvalidArgumentException('The location was not a valid URL');
     }
     $this->attributes['loc'] = $location;
     return $this;
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:19,代码来源:URL.php

示例14: apply

 /**
  * 
  * @param string $patch
  */
 public static function apply($patch)
 {
     $installed_patches = self::installed();
     $filename = pathinfo($patch, PATHINFO_BASENAME);
     if (Valid::url($patch)) {
         $filename = Upload::from_url($patch, PATCHES_FOLDER, $filename, array('php'), TRUE);
         $patch = PATCHES_FOLDER . $filename;
     }
     if (file_exists($patch) and !in_array($patch, $installed_patches)) {
         include $patch;
         @unlink($patch);
         $installed_patches[] = $filename;
         Config::set('update', 'installed_patches', $installed_patches);
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:19,代码来源:patch.php

示例15: guess_type

 /**
  * Guess the type of the source:
  *
  *  - Upload_Source::TYPE_URL
  *  - Upload_Source::TYPE_STREAM
  *  - Upload_Source::TYPE_TEMP
  *  - Upload_Source::TYPE_FILE
  *  - Upload_Source::TYPE_UPLOAD
  *  - FALSE
  *
  * @param  mixed $source
  * @return string|boolean
  */
 public static function guess_type($source)
 {
     if (is_array($source)) {
         return (Upload::valid($source) and $source['error'] !== UPLOAD_ERR_NO_FILE) ? Upload_Source::TYPE_UPLOAD : FALSE;
     } elseif ($source == 'php://input') {
         return Upload_Source::TYPE_STREAM;
     } elseif (Valid::url($source)) {
         return Upload_Source::TYPE_URL;
     } elseif (substr_count($source, DIRECTORY_SEPARATOR) === 1) {
         return Upload_Source::TYPE_TEMP;
     } elseif (is_file($source)) {
         return Upload_Source::TYPE_FILE;
     } else {
         return FALSE;
     }
 }
开发者ID:openbuildings,项目名称:jam,代码行数:29,代码来源:Source.php


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