예제 #1
0
 /**
  * Replaces hashtag and username with links.
  *
  * @return string
  */
 public function filter_text()
 {
     $text = htmlEscapeAndLinkUrls($this->text);
     $pattern_username = '******';
     $replacement_username = '******' . BBTF_TWITTER_URL . '/${1}">@${1}</a>';
     $text = preg_replace($pattern_username, $replacement_username, $text);
     $pattern_hashtag = '/#([a-zA-z0-9]+)/';
     $replacement_hashtag = '<a href="' . BBTF_TWITTER_URL . '/hashtag/${1}">#${1}</a>';
     $text = preg_replace($pattern_hashtag, $replacement_hashtag, $text);
     return $text;
 }
 public function view($gallery_id = 0, $current_image_index = 1, $name = '')
 {
     $this->load->model('browse_model');
     $this->load->model('comments_model');
     $this->load->model('evaluations_model');
     $this->load->library('typography');
     $this->load->helper(array('urllinker', 'urlslug', 'browse'));
     if (($gallery = $this->browse_model->get_gallery(intval($gallery_id))) === FALSE) {
         show_error("Galeria nie występuje...", 404, 'Błąd!');
     }
     if (($current_page = $this->current_page(5)) === FALSE) {
         show_error("Strona nie występuje...", 404, 'Błąd!');
     }
     $current_image_index = intval($current_image_index);
     $gallery_images = $this->browse_model->get_gallery_images($gallery_id);
     if ($current_image_index < 1 || $current_image_index > count($gallery_images)) {
         show_error("Brak pracy w galerii...", 404, 'Błąd!');
     }
     $this->data['adult_user'] = $this->adult_user;
     $all_gallery_comments = $this->comments_model->counts_gallery_comments($gallery_id);
     if ($all_gallery_comments > 0) {
         $last_page = ceil($all_gallery_comments / $this->gallery_comments_config['page_size']);
         if ($current_page > $last_page) {
             $current_page = $last_page;
         }
         $gallery_comments = $this->comments_model->get_gallery_comments($gallery_id, $this->gallery_comments_config['page_size'], $current_page);
         foreach ($gallery_comments as &$gallery_comment) {
             $gallery_comment->comment = $this->typography->auto_typography(htmlEscapeAndLinkUrls($gallery_comment->comment), TRUE);
             $gallery_comment->signature = $this->typography->auto_typography(htmlEscapeAndLinkUrls($gallery_comment->signature), TRUE);
         }
         $this->data['object_comments'] = $gallery_comments;
         $this->data['pagination_links'] = $this->pagination_links("/gallery/view/{$gallery_id}/" . $current_image_index, $this->gallery_comments_config['page_size'], $all_gallery_comments, 5);
     } else {
         $this->data['object_comments'] = array();
     }
     $this->data['can_comment'] = $gallery->can_comment;
     $this->data['comment_object_owner'] = $gallery->user_id;
     $this->data['can_evaluate'] = $gallery->can_evaluate;
     $this->data['gallery_images'] = $gallery_images;
     $this->data['current_image_index'] = $current_image_index;
     $this->data['preview_image'] = $gallery_images[$current_image_index - 1];
     if ($current_image_index - 1 > 0) {
         $this->data['previous_image_index'] = $current_image_index - 1;
     }
     if ($current_image_index + 1 <= count($this->data['gallery_images'])) {
         $this->data['next_image_index'] = $current_image_index + 1;
     }
     $cats_uri_rows = $this->browse_model->get_cats_uri_rows($this->browse_model->build_path_cats($gallery->category_id, 'galleries'), 'galleries');
     $this->data['gallery_cats_path'] = create_hierarchical_path(base_url() . 'browse/galleries/', $cats_uri_rows);
     $cats_uri_rows = $this->browse_model->get_cats_uri_rows($this->browse_model->build_path_cats($gallery_images[$current_image_index - 1]->category_id, 'images'), 'images');
     $this->data['current_image_cats_path'] = create_hierarchical_path(base_url() . 'browse/images/', $cats_uri_rows);
     $this->data['user_gallery'] = $this->browse_model->get_user($gallery->user_id);
     $this->data['gallery'] = $gallery;
     if ($this->ion_auth->logged_in()) {
         $logged_in_user = $this->ion_auth->user()->row();
         $this->data['logged_in_user'] = $logged_in_user;
         $this->data['object_rated'] = $this->evaluations_model->rated_gallery($gallery->id, $logged_in_user->id);
     }
     $this->data['thumb_mini_config'] = $this->config->item('thumb_mini', 'digallery');
     $this->data['thumb_preview_config'] = $this->config->item('thumb_preview', 'digallery');
     $this->data['avatars_config'] = $this->config->item('avatar', 'digallery');
     $this->data['name_of_ratings'] = $this->config->item('name_of_ratings', 'digallery');
     $this->data['js'][] = 'comments.js';
     $this->data['js'][] = 'jquery.jcarousel.min.0.2.8.js';
     //$this->data['js'][] = 'jquery.jcarousel.min.0.3.0.js';
     $this->data['js'][] = 'gallery_view.js';
     $this->render();
 }
 public function comments($user_id = 0, $comments_type = 'all', $current_page = 1)
 {
     $this->load->helper('browse');
     $this->load->library('typography');
     $this->load->helper('urllinker');
     $this->load->model('comments_model');
     $user = $this->browse_model->get_user(intval($user_id));
     if ($user === FALSE || !$user->active) {
         show_error("Użytkownik nie istnieje...", 404, 'Błąd!');
     }
     if ($comments_type == 'all') {
         $page_segment = 4;
     } else {
         $page_segment = 5;
     }
     if ($current_page == 0) {
         $current_page = 1;
     }
     $all_comments = $this->comments_model->counts_user_comments($user_id, $comments_type);
     if ($all_comments > 0) {
         $last_page = ceil($all_comments / $this->profile_comments_config['page_size']);
         if ($current_page > $last_page) {
             $current_page = $last_page;
         }
         $user_comments = $this->comments_model->get_user_comments($user_id, $current_page, $this->profile_comments_config['page_size'], $comments_type);
         foreach ($user_comments as &$user_comment) {
             $user_comment->comment = $this->typography->auto_typography(htmlEscapeAndLinkUrls($user_comment->comment), TRUE);
         }
         $this->data['object_comments'] = $user_comments;
         $this->data['pagination_links'] = $this->pagination_links("/profile/{$user_id}/comments/" . ($comments_type !== 'all' ? $comments_type . '/' : ''), $this->profile_comments_config['page_size'], $all_comments, $page_segment);
     } else {
         $this->data['object_comments'] = array();
     }
     $this->data['user'] = $user;
     if ($this->ion_auth->logged_in()) {
         $this->data['logged_in_user'] = $this->ion_auth->user()->row();
     }
     $this->data['avatars_config'] = $this->config->item('avatar', 'digallery');
     $this->render();
 }
 public function edit_comment($comment_id)
 {
     if ($this->input->is_ajax_request()) {
         $comment_id = intval($comment_id);
         if ($this->ion_auth->logged_in()) {
             $old_comment = $this->comments_model->get_comment($comment_id);
             if ($old_comment === FALSE) {
                 $this->output->set_status_header('500');
                 return;
             }
             $logged_in_user = $this->ion_auth->user()->row();
             if ($logged_in_user->id === $old_comment->user_id) {
                 if ($this->input->post('comment') && $this->input->post('comment') != '') {
                     if ($old_comment->comment !== $this->input->post('comment')) {
                         if ($this->comments_model->update_comment($comment_id, $this->input->post('comment'))) {
                             $updated_comment = $this->comments_model->get_comment($comment_id);
                             $typography_comment = $this->typography->auto_typography(htmlEscapeAndLinkUrls($updated_comment->comment), TRUE);
                             //$typography_comment = nl2br($this->typography->format_characters(htmlEscapeAndLinkUrls($updated_comment->comment)));
                             $this->output->set_content_type('application/json')->set_output(json_encode(array("status" => 1, "comment" => $typography_comment, "last_edit" => $updated_comment->last_edit)));
                         } else {
                             $this->output->set_content_type('application/json')->set_output(json_encode(array("status" => 0)));
                         }
                     }
                 }
             }
         } else {
             $this->output->set_status_header('401');
         }
     }
 }
 public function preview($image_id = 0, $name = '')
 {
     $this->load->model('browse_model');
     $this->load->model('comments_model');
     $this->load->model('evaluations_model');
     $this->load->library('typography');
     $this->load->helper(array('browse', 'urllinker', 'urlslug'));
     if (($image = $this->browse_model->get_image(intval($image_id))) === FALSE) {
         show_error("Praca nie występuje...", 404, 'Błąd!');
     }
     if (($current_page = $this->current_page(4)) === FALSE) {
         show_error("Strona nie występuje...", 404, 'Błąd!');
     }
     $this->data['adult_user'] = $this->adult_user;
     $this->data['previous_image_id_name'] = $this->browse_model->get_user_prev_image_id_name($image->user_id, $image->id);
     $this->data['next_image_id_name'] = $this->browse_model->get_user_next_image_id_name($image->user_id, $image->id);
     $all_image_comments = $this->comments_model->counts_image_comments($image_id);
     if ($all_image_comments > 0) {
         $last_page = ceil($all_image_comments / $this->image_comments_config['page_size']);
         if ($current_page > $last_page) {
             $current_page = $last_page;
         }
         $image_comments = $this->comments_model->get_image_comments($image_id, $this->image_comments_config['page_size'], $current_page);
         foreach ($image_comments as &$image_comment) {
             $image_comment->comment = $this->typography->auto_typography(htmlEscapeAndLinkUrls($image_comment->comment), TRUE);
             $image_comment->signature = $this->typography->auto_typography(htmlEscapeAndLinkUrls($image_comment->signature), TRUE);
         }
         $this->data['object_comments'] = $image_comments;
         $this->data['pagination_links'] = $this->pagination_links("/image/preview/{$image_id}/", $this->image_comments_config['page_size'], $all_image_comments, 4);
     } else {
         $this->data['object_comments'] = array();
     }
     $this->data['can_comment'] = $image->can_comment;
     $this->data['comment_object_owner'] = $image->user_id;
     $this->data['can_evaluate'] = $image->can_evaluated;
     $cats_uri_rows = $this->browse_model->get_cats_uri_rows($this->browse_model->build_path_cats($image->category_id, 'images'), 'images');
     $cats_path = create_hierarchical_path(base_url() . 'browse/images/', $cats_uri_rows);
     $user_image = $this->browse_model->get_user($image->user_id);
     $this->data['number_views'] = $this->browse_model->counts_views($image->id);
     $this->data['number_views_today'] = $this->browse_model->counts_views_today($image->id);
     $this->increment_views($image->id);
     $this->data['number_downloads'] = $this->browse_model->counts_downloads($image->id);
     $this->data['number_downloads_today'] = $this->browse_model->counts_downloads_today($image->id);
     //$this->browse_model->increment_downloads($image->id);
     $this->data['user_image'] = $user_image;
     $this->data['thumbs_mini'] = $this->browse_model->get_thumb_images(0, 0, 'dd', $image->user_id, 1, 8);
     $this->data['preview_image'] = $image;
     $this->data['cats_path'] = $cats_path;
     $this->data['number_favs'] = $this->browse_model->counts_favorites($image->id);
     $this->data['number_favs_today'] = $this->browse_model->counts_favorites_today($image->id);
     if ($this->ion_auth->logged_in()) {
         $logged_in_user = $this->ion_auth->user()->row();
         $this->data['logged_in_user'] = $logged_in_user;
         $this->data['image_added_to_favs'] = $this->browse_model->added_to_favorites($image_id, $logged_in_user->id);
         $this->data['object_rated'] = $this->evaluations_model->rated_image($image->id, $logged_in_user->id);
     }
     $this->data['thumb_mini_config'] = $this->config->item('thumb_mini', 'digallery');
     $this->data['thumb_preview_config'] = $this->config->item('thumb_preview', 'digallery');
     $this->data['avatars_config'] = $this->config->item('avatar', 'digallery');
     if ($image->plus_18 && !$this->adult_user && !(isset($logged_in_user) && $logged_in_user->id === $image->user_id)) {
         $this->data['adult_filter'] = TRUE;
     } else {
         $this->data['adult_filter'] = FALSE;
     }
     $this->data['js'][] = 'comments.js';
     $this->data['js'][] = 'preview.js';
     $this->data['name_of_ratings'] = $this->config->item('name_of_ratings', 'digallery');
     $this->render();
 }
 /**
  * @param string $text
  * @return string
  */
 protected function linkify($text)
 {
     return htmlEscapeAndLinkUrls($text);
 }
 public function show_post_in($post_id = 0)
 {
     $this->load->library('typography');
     $this->load->helper('urllinker');
     if ($this->ion_auth->logged_in()) {
         $user = $this->ion_auth->user()->row();
         if (($post = $this->posts_model->get_post('inbox', $post_id, $user->id)) === FALSE) {
             $this->session->set_flashdata(array('type' => 'error', 'msg' => 'Wiadomość nie istnieje lub nie jesteś jej adresatem...'));
             redirect('posts/inbox', 'refresh');
         }
         $user_to = $this->ion_auth->user($post->user_id_from)->row();
         if (empty($user_to)) {
             //@todo
             // Zastanowic sie co robic gdy user nie wystepuje już w bazie? Moze jakis statyczny ANONIM.
             // Pamiętać należy by wyłączyć możliwość odpowiedzi do takiego użytkownika...
             $this->session->set_flashdata(array('type' => 'error', 'msg' => 'Adresat nie istnieje...'));
             redirect('posts/inbox', 'refresh');
         }
         $this->form_validation->set_error_delimiters('', '');
         $this->form_validation->set_rules('subject', 'Tytuł', 'required|xss_clean');
         $this->form_validation->set_rules('post_message', 'Wiadomość', 'required|xss_clean');
         if ($this->form_validation->run() == TRUE) {
             if ($this->posts_model->send_post($user->id, $user_to->id, $this->input->post('subject'), date('Y-m-d H:i:s'), $this->input->post('post_message'))) {
                 $this->session->set_flashdata(array('type' => 'info', 'msg' => 'Wiadomość została wysłana...'));
                 redirect('posts/inbox/', 'refresh');
             } else {
                 $this->session->set_flashdata(array('type' => 'error', 'msg' => 'Nie udało się wysłać wiadomości...'));
                 redirect('posts/inbox/', 'refresh');
             }
         } else {
             $this->data['message'] = array('type' => $this->session->flashdata('type'), 'msg' => $this->session->flashdata('msg'));
             $this->data['form_attr'] = array('id' => 'posts-message-inbox', 'class' => 'form-horizontal');
             $this->data['subject'] = array('name' => 'subject', 'id' => 'subject', 'class' => 'span7', 'type' => 'text', 'value' => $this->form_validation->set_value('subject', '[RE]: ' . $post->subject));
             $this->data['subject_label'] = array('for' => 'subject', 'text' => 'Temat:', 'attributes' => array('class' => 'control-label'));
             $this->data['post_message'] = array('name' => 'post_message', 'id' => 'post_message', 'class' => 'span7', 'rows' => '6', 'value' => $this->form_validation->set_value('post_message'));
             $this->data['post_label'] = array('for' => 'post', 'text' => 'Treść wiadomości:', 'attributes' => array('class' => 'control-label'));
             $this->data['del_post_form_attr'] = array('id' => 'posts-message-inbox-delete');
             // hidden input
             $this->data['hidden_post_id'] = array('posts[]' => $post->id);
             $this->data['control_groups'] = array('subject' => form_error('subject') ? ' error' : '', 'post_message' => form_error('post_message') ? ' error' : '');
             $post->message = $this->typography->auto_typography(htmlEscapeAndLinkUrls($post->message), TRUE);
             $this->data['post'] = $post;
             $this->data['user_from'] = $user_to;
             $this->data['js'] = 'show_post_in.js';
             $this->render();
         }
     } else {
         redirect('user/login');
     }
 }
Here's the answer: http://www.google.com/search?rls=en&q=42&ie=utf-8&oe=utf-8&hl=en. What was the question?
A quick look at 'http://en.wikipedia.org/wiki/URI_scheme#Generic_syntax' is helpful.
There is no place like 127.0.0.1! Except maybe http://news.bbc.co.uk/1/hi/england/surrey/8168892.stm?
Ports: 192.168.0.1:8080, https://example.net:1234/.
Beware of Greeks bringing internationalized top-level domains (xn--hxajbheg2az3al.xn--jxalpdlp).
10.000.000.000 is not an IP-address. Nor is this.a.domain.

<script>alert('Remember kids: Say no to XSS-attacks! Always HTML escape untrusted input!');</script>

https://mail.google.com/mail/u/0/#starred?compose=141d598cd6e13025
https://www.google.com/search?q=bla%20bla%20bla
https://www.google.com/search?q=bla+bla+bla

We need to support IDNs and IRIs and röck döts:
møøse.kwi.dk/阿驼鹿一旦咬了我的妹妹/من-اليمين-إلى-اليسار-لغات-تخلط-لي.
EOD;
print nl2br(htmlEscapeAndLinkUrls($text));
?>
</p>
<!-- HTML input -->
<?php 
$html = <<<EOD
<p>Send me an <a href="*****@*****.**">e-mail</a> at bob@example.com.</p>
<p>This is already a link: <a href="http://google.com">http://google.com</a></p>
<p title='10>20'>Tricky markup...</p>
EOD;
print linkUrlsInTrustedHtml($html);
?>
</body>
</html>