Exemplo n.º 1
0
 public function set_rss_url($url)
 {
     if (!Valid::url($url)) {
         return NULL;
     }
     return $url;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
Arquivo: info.php Projeto: anqh/anqh
 /**
  * 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();
 }
Exemplo n.º 4
0
Arquivo: Util.php Projeto: Konro1/pms
 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;
 }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
 /**
  *
  * @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;
 }
Exemplo n.º 7
0
 /**
  * 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;
 }
Exemplo n.º 8
0
 /**
  * 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();
 }
Exemplo n.º 9
0
 /**
  * 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;
     }
 }
Exemplo n.º 10
0
 public static function check_link($link)
 {
     if (strpos($link, '//') !== FALSE) {
         return Valid::url($link);
     } elseif (strpos($link, '/') === 0) {
         return TRUE;
     }
 }
Exemplo n.º 11
0
 /**
  * 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() . '/';
     }
 }
Exemplo n.º 12
0
 /**
  * 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;
 }
Exemplo n.º 13
0
 /**
  * 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;
 }
Exemplo n.º 14
0
 /**
  * 
  * @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);
     }
 }
Exemplo n.º 15
0
 /**
  * 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;
     }
 }
Exemplo n.º 16
0
 public static function parse($feed, $limit = 0)
 {
     // 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)) {
         // Use native Request client to get remote contents
         $feed = CURL::get($feed);
         //$feed = HTTP::get($feed);
     } elseif (is_file($feed)) {
         // Get file contents
         $feed = file_get_contents($feed);
     }
     //var_dump($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;
 }
Exemplo n.º 17
0
Arquivo: remote.php Projeto: anqh/core
 /**
  * Download a file to a new location. If no filename is provided,
  * the original filename will be used, with a unique prefix added.
  *
  * @param   string   remote url
  * @param   string   new filename
  * @param   string   new directory
  * @param   integer  chmod mask
  * @return  array    on success, upload style file array
  * @return  false    on failure
  */
 public static function download($url, $filename = NULL, $directory = NULL, $chmod = 0644)
 {
     if (!Valid::url($url)) {
         return false;
     }
     // If no filename given, use remote filename with uniqid
     $original_filename = basename(parse_url($url, PHP_URL_PATH));
     if ($filename === null) {
         $filename = uniqid() . $original_filename;
     }
     // Remove spaces from the filename
     if (Upload::$remove_spaces === true) {
         $filename = preg_replace('/\\s+/', '_', $filename);
     }
     // Use the pre-configured upload directory if not given
     if ($directory === null) {
         $directory = Upload::$default_directory;
     }
     if (!is_dir($directory) || !is_writable(realpath($directory))) {
         throw new Kohana_Exception('Directory :dir must be writable', array(':dir' => Kohana::debug_path($directory)));
     }
     // Make the filename into a complete path
     $filename = realpath($directory) . DIRECTORY_SEPARATOR . $filename;
     // Download file
     try {
         // Dummy escape to get rid of spaces to awoid 400 Bad Request
         $url = str_replace(' ', '%20', $url);
         $fh = fopen($filename, 'w');
         Remote::get($url, null, array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FILE => $fh));
         $size = Arr::get(fstat($fh), 'size', 0);
         fclose($fh);
         // Set permissions
         if ($chmod !== false) {
             chmod($filename, $chmod);
         }
         // Build file array
         $finfo = finfo_open(FILEINFO_MIME_TYPE);
         $mime = finfo_file($finfo, $filename);
         finfo_close($finfo);
         return array('error' => UPLOAD_ERR_OK, 'name' => $original_filename, 'type' => $mime, 'tmp_name' => $filename, 'size' => $size);
     } catch (Kohana_Exception $e) {
         return false;
     }
 }
Exemplo n.º 18
0
Arquivo: track.php Projeto: anqh/anqh
 /**
  * Add new forum topic for music.
  *
  * @return  boolean
  */
 public function add_forum_topic()
 {
     $forum_areas = Kohana::$config->load('music.forum_areas');
     if ($forum_areas && $forum_areas[$this->type]) {
         $forum_area = Model_Forum_Area::factory($forum_areas[$this->type]);
         if ($forum_area->loaded()) {
             try {
                 // Generate post
                 $content = '';
                 // Cover
                 if (Valid::url($this->cover)) {
                     $content .= '[img]' . $this->cover . "[/img]\n\n";
                 }
                 // Description
                 $content .= $this->description . "\n\n";
                 if ($this->type == Model_Music_Track::TYPE_MIX && $this->tracklist) {
                     $content .= '[b]' . __('Tracklist') . "[/b]\n";
                     $content .= $this->tracklist . "\n\n";
                 }
                 // Tags
                 if ($tags = $this->tags()) {
                     $content .= '[i]' . implode(', ', $tags) . "[/i]\n\n";
                 } else {
                     if (!empty($this->music)) {
                         $content .= '[i]' . $this->music . "[/i]\n\n";
                     }
                 }
                 // Links
                 $content .= '[url=' . URL::site(Route::model($this), true) . ']' . __('Show details') . '[/url] - ';
                 $content .= '[url=' . URL::site(Route::model($this, 'listen'), true) . ']' . __('Listen') . '[/url]';
                 // Create topic
                 $forum_topic = $forum_area->create_topic($this->name, $content, $this->author());
                 $forum_topic->save_post();
             } catch (Kohana_Exception $e) {
                 return false;
             }
             $this->forum_topic_id = $forum_topic->id;
             $this->save();
             return true;
         }
     }
     return false;
 }
Exemplo n.º 19
0
 public function validate(Jam_Validated $model, $attribute, $value)
 {
     if ($this->regex !== NULL and !preg_match($this->regex, $value)) {
         $model->errors()->add($attribute, 'format_regex', array(':regex' => $this->regex));
     }
     if ($this->filter !== NULL and !(filter_var($value, $this->filter, $this->flag) !== FALSE)) {
         $model->errors()->add($attribute, 'format_filter', array(':filter' => $this->filter));
     }
     if ($this->ip === TRUE and !Valid::ip($value)) {
         $model->errors()->add($attribute, 'format_ip');
     }
     if ($this->url === TRUE and !Valid::url($value)) {
         $model->errors()->add($attribute, 'format_url');
     }
     if ($this->email === TRUE and !Valid::email($value)) {
         $model->errors()->add($attribute, 'format_email');
     }
     if ($this->credit_card === TRUE and !Valid::credit_card($value)) {
         $model->errors()->add($attribute, 'format_credit_card');
     }
 }
Exemplo n.º 20
0
 /**
  * Tests Valid::url()
  *
  * @test
  * @dataProvider provider_url
  * @param string  $url       The url to test
  * @param boolean $expected  Is it valid?
  */
 public function test_url($url, $expected)
 {
     $this->assertSame($expected, Valid::url($url));
 }
Exemplo n.º 21
0
                </a>
                <a class="btn btn-default btn-sm desktop-btn" title="Desktop full width" href="#">
                    <span class="fa fa-desktop fa-2x"></span> 
                </a>
                <a type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#qrCode" title="<?php 
    echo __('Scan QR and check out the template on your phone or tablet');
    ?>
" href="#">
                    <span class="fa fa-qrcode fa-2x"></span>
                </a>
                <?php 
}
?>
                <a class="btn btn-success btn-sm" 
                    <?php 
if (Valid::url($product->url_buy)) {
    ?>
                    href="<?php 
    echo $product->url_buy;
    ?>
"
                    <?php 
} else {
    ?>
                    href="<?php 
    echo Route::url('product', array('seotitle' => $product->seotitle, 'category' => $product->category->seoname));
    ?>
"
                    <?php 
}
?>
Exemplo n.º 22
0
 /**
  *
  * given a file returns it's public path relative to the selected theme
  * @param string $file
  * @param string $theme optional
  * @return string
  */
 public static function public_path($file, $theme = NULL)
 {
     if ($theme === NULL) {
         $theme = self::$theme;
     }
     //not external file we need the public link
     if (!Valid::url($file)) {
         //@todo add a hook here in case we want to use a CDN
         return URL::base() . 'themes' . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . $file;
     }
     //seems an external url
     return $file;
 }
Exemplo n.º 23
0
?>
		<hr>

	</div>
</div>
<!-- ./Ad-header -->

<!-- ./Ad-content-main -->
<?php 
if ($is_preview != true) {
    ?>
	<!-- Ad-apply -->
	<div id="ad-apply">
		<br/>
		<a class="btn btn-success btn-large" href="<?php 
    if (Valid::url($ad->contact)) {
        echo $ad->contact;
    } elseif (Valid::email($ad->contact)) {
        ?>
mailto:<?php 
        echo HTML::email($ad->contact);
    }
    ?>
" id="apply-link">Apply for this Job <i class="icon-circle-arrow-right icon-white"></i></a>
	</div>
	<!-- ./Ad-apply -->
<?php 
}
?>

Exemplo n.º 24
0
?>
 <?php 
echo __('Hits');
?>
</span> 
            <?endif?>
        </div>    
    </div>

    <br/>

    <div>
         <?php 
echo Text::bb2html($ad->description, TRUE);
?>
         <?if (Valid::url($ad->website)):?>
         <p><a href="<?php 
echo $ad->website;
?>
" rel="nofollow" target="_blank">><?php 
echo $ad->website;
?>
</a></p>
         <?endif?>
     </div>

    <?if(core::config('payment.paypal_seller')==1 AND $ad->price != NULL AND $ad->price > 0):?>
        <?if(core::config('payment.stock')==0 OR ($ad->stock > 0 AND core::config('payment.stock')==1)):?>
            <?if (!Auth::instance()->logged_in()):?>
                <a class="btn btn-primary" data-toggle="modal" data-dismiss="modal" 
                    href="<?php 
Exemplo n.º 25
0
 protected function validate($value)
 {
     if (!Valid::url($value)) {
         return 'url';
     }
 }
Exemplo n.º 26
0
 /**
  * Set up the environment
  *
  * @param string $type
  * @param string $file
  * @param string $options
  * @param string $destination_path
  * @param bool   $copy
  * @param string $folder
  */
 function __construct($type, $file, array $options = array(), $destination_path = NULL, $copy = TRUE, $folder = NULL)
 {
     // Set processor to use
     $this->_processor = Arr::get($options, 'processor', Arr::get(Kohana::$config->load('asset-merger')->get('processor'), $type));
     // Set condition
     $this->_condition = Arr::get($options, 'condition');
     $this->_folder = $folder;
     // Set weight
     if (!empty($options['weight'])) {
         $this->_weight = $options['weight'];
     }
     // Set load paths
     if (!empty($options['load_paths'])) {
         $this->_load_paths = $options['load_paths'][$type];
     } elseif ($load_paths = Kohana::$config->load('asset-merger')->get('load_paths')) {
         $this->_load_paths = Arr::get($load_paths, $type);
     }
     // Set media
     if (!empty($options['media'])) {
         $this->_media = $options['media'];
     }
     // Set type and file
     $this->_type = $type;
     $this->_file = $file;
     $this->_copy = $copy;
     // Check if the type is a valid type
     Assets::require_valid_type($type);
     if (Valid::url($file)) {
         // No remote files allowed
         throw new Kohana_Exception('The asset :file must be local file', array(':file' => $file));
     }
     // Look for the specified file in each load path
     foreach ((array) $this->_load_paths as $path) {
         $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
         if (is_file($path . $file)) {
             // Set the destination and source file
             $this->_destination_file = Assets::file_path($type, $file, $destination_path, $this->_folder);
             $this->_source_file = $path . $file;
             // Don't continue
             break;
         }
     }
     if (!$this->source_file()) {
         // File not found
         throw new Kohana_Exception('Asset :file of type :type not found inside :paths', array(':file' => $file, ':type' => $type, ':paths' => join(', ', (array) Arr::get(Kohana::$config->load('asset-merger')->get('load_paths'), $type))));
     }
     if (!is_dir(dirname($this->destination_file())) and $this->copy()) {
         // Create directory for destination file
         mkdir(dirname($this->destination_file()), 0777, TRUE);
     }
     // Get the file parts
     $fileparts = explode('.', basename($file));
     // Extension index
     $extension_index = array_search($this->type(), $fileparts);
     // Set engines
     $this->_engines = array_reverse(array_slice($fileparts, $extension_index + 1));
     // Set the web destination
     $this->_destination_web = Assets::web_path($type, $file, $destination_path, $this->_folder);
 }
Exemplo n.º 27
0
Arquivo: user.php Projeto: anqh/anqh
 /**
  * Get user's default image url
  *
  * @param   string  $size
  * @return  string
  */
 public function get_image_url($size = null)
 {
     $image = null;
     if ($this->default_image_id) {
         $image = Model_Image::factory($this->default_image_id)->get_url($size);
     } else {
         if (Valid::url($this->picture)) {
             $image = $this->picture;
         } else {
             if (count($images = $this->images())) {
                 $image = $images->current()->get_url($size);
             }
         }
     }
     return $image;
 }
Exemplo n.º 28
0
 /**
  *
  * given a file returns it's public path relative to the selected theme
  * @param string $file
  * @param string $theme optional
  * @return string
  */
 public static function public_path($file, $theme = NULL)
 {
     if ($theme === NULL) {
         $theme = self::$theme;
         $parent_theme = Theme::$parent_theme;
     } else {
         $parent_theme = self::get_theme_parent($theme);
     }
     //handle protocol-relative URLs, we return it directly
     if (strpos($file, '//') === 0) {
         // This request is secure?
         $protocol = Core::is_HTTPS() ? 'https:' : 'http:';
         return $protocol . $file;
     }
     //getting the public url only if was not external
     if (!Valid::url($file)) {
         //copy of the file
         $file_check = $file;
         //public URI
         $uri = URL::base() . 'themes/';
         //remove the query from the uri
         if (($version = strpos($file, '?')) > 0) {
             $file_check = substr($file, 0, $version);
         }
         //check file exists in the theme folder
         if (file_exists(self::theme_folder($theme) . DIRECTORY_SEPARATOR . $file_check)) {
             return $uri . $theme . '/' . $file;
         } elseif ($parent_theme !== NULL and file_exists(self::theme_folder($parent_theme) . DIRECTORY_SEPARATOR . $file_check)) {
             return $uri . $parent_theme . '/' . $file;
         } elseif (file_exists(self::theme_folder('default') . DIRECTORY_SEPARATOR . $file_check)) {
             return $uri . 'default/' . $file;
         }
     } else {
         return $file;
     }
     return FALSE;
 }
Exemplo n.º 29
0
Arquivo: api.php Projeto: anqh/core
 /**
  * Prepare user for data array
  *
  * @param   Model_User  $user
  * @param   array       $fields
  * @return  array
  */
 protected function _prepare_user(Model_User $user, array $fields = null)
 {
     $data = array();
     empty($fields) and $fields = self::$_fields;
     foreach ($fields as $field) {
         switch ($field) {
             // Raw value
             case 'id':
             case 'username':
             case 'homepage':
             case 'gender':
             case 'description':
             case 'logins':
             case 'posts':
             case 'adds':
             case 'signature':
             case 'title':
             case 'dob':
             case 'latitude':
             case 'longitude':
             case 'created':
             case 'modified':
             case 'last_login':
                 $data[$field] = $user->{$field};
                 break;
                 // Custom value
             // Custom value
             case 'city':
                 $data[$field] = ($city = $user->city()) ? $city->name : $user->city_name;
                 break;
             case 'avatar':
                 $data[$field] = $user->avatar ? URL::site($user->avatar, true) : URL::site('avatar/unknown.png');
                 break;
             case 'picture':
                 if ($user->default_image_id) {
                     $image = new Model_Image($user->default_image_id);
                     $data[$field] = $image->loaded() ? $image->get_url() : '';
                 } else {
                     if (Valid::url($user->picture)) {
                         $data[$field] = URL::site($user->picture, true);
                     } else {
                         $data[$field] = null;
                     }
                 }
                 break;
             case 'url':
                 $data[$field] = URL::site(URL::user($user), true);
                 break;
         }
     }
     return $data;
 }
Exemplo n.º 30
0
 /**
  * Action: gallery
  */
 public function action_gallery()
 {
     /** @var  Model_Gallery  $gallery */
     $gallery_id = (int) $this->request->param('id');
     $gallery = Model_Gallery::factory($gallery_id);
     if (!$gallery->loaded()) {
         throw new Model_Exception($gallery, $gallery_id);
     }
     Permission::required($gallery, Model_Gallery::PERMISSION_READ);
     // External links
     $link_add = trim(Arr::get($_POST, 'link'));
     $link_del = Arr::get($_GET, 'delete_link');
     if ($link_add || is_numeric($link_del)) {
         if (Permission::has($gallery, Model_Gallery::PERMISSION_CREATE) && Security::csrf_valid()) {
             $links = $gallery->links;
             if ($link_add && Valid::url($link_add)) {
                 // Add new link
                 $links .= ($links ? "\n" : '') . Visitor::$user->id . ',' . $link_add;
             } else {
                 if (is_numeric($link_del)) {
                     // Remove link
                     $old_links = explode("\n", $links);
                     if ($old_links[$link_del]) {
                         list($user_id, $url) = explode(',', $old_links[$link_del]);
                         if (Visitor::$user->id == $user_id || Permission::has($gallery, Model_Gallery::PERMISSION_UPDATE)) {
                             unset($old_links[$link_del]);
                             $links = implode("\n", $old_links);
                         }
                     }
                 }
             }
             $gallery->links = $links;
             try {
                 $gallery->save();
             } catch (Validation_Exception $e) {
             }
         }
         $this->request->redirect(Route::model($gallery));
     }
     // Build page
     $this->view = View_Page::factory(__('Gallery'));
     $this->_set_page_actions(Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_CREATE));
     $this->_set_gallery($gallery);
     if (Permission::has(new Model_Gallery(), Model_Gallery::PERMISSION_UPDATE)) {
         $this->view->actions[] = array('link' => Route::model($gallery, 'update'), 'text' => '<i class="icon-refresh"></i> ' . __('Update gallery'));
     }
     // Share
     Anqh::page_meta('title', __('Gallery') . ': ' . $gallery->name);
     Anqh::page_meta('url', URL::site(Route::get('gallery')->uri(array('id' => $gallery->id, 'action' => '')), true));
     Anqh::page_meta('description', __($gallery->image_count == 1 ? ':images image' : ':images images', array(':images' => $gallery->image_count)) . ' - ' . date('l ', $gallery->date) . Date::format(Date::DMY_SHORT, $gallery->date) . ($event ? ' @ ' . $event->venue_name : ''));
     if ($event && ($flyer = $event->flyer())) {
         Anqh::page_meta('image', URL::site($flyer->image()->get_url('thumbnail'), true));
     } else {
         if ($image = $gallery->default_image()) {
             Anqh::page_meta('image', URL::site($image->get_url('thumbnail'), true));
         }
     }
     Anqh::share(true);
     // Event info
     if ($event = $gallery->event()) {
         // Event info
         $this->view->subtitle = Controller_Events::_event_subtitle($event);
         // Event flyer
         if ($event->flyer_id) {
             $this->view->add(View_Page::COLUMN_RIGHT, $this->section_event_image($event));
         }
     }
     // Pictures
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_gallery_thumbs($gallery));
     // External links
     if ($gallery->links || Permission::has($gallery, Model_Gallery::PERMISSION_CREATE)) {
         $this->view->add(View_Page::COLUMN_CENTER, $this->section_gallery_links($gallery));
     }
 }