static function thumb_info($theme, $item) { $results = ""; if ($item->view_count) { $results .= "<li>"; $results .= t("Views: %view_count", array("view_count" => $item->view_count)); $results .= "</li>"; } // rWatcher Edit: Display Tags if (module::is_active("tag")) { $tags = ORM::factory("tag")->join("items_tags", "tags.id", "items_tags.tag_id")->where("items_tags.item_id", "=", $item->id)->find_all(); if (count($tags) > 0) { $results .= "<li>"; $results .= t("Tags:") . " "; $anchors = array(); foreach ($tags as $tag) { $anchors[] = "<a href=" . $tag->url() . ">" . html::clean($tag->name) . "</a>"; } $results .= join(", ", $anchors) . "</li>"; } } // rWatcher End Edit if ($item->owner) { $results .= "<li>"; if ($item->owner->url) { $results .= t("By: <a href=\"%owner_url\">%owner_name</a>", array("owner_name" => $item->owner->display_name(), "owner_url" => $item->owner->url)); } else { $results .= t("By: %owner_name", array("owner_name" => $item->owner->display_name())); } $results .= "</li>"; } return $results; }
public function mark_clean_test() { $safe_string = html::mark_clean("hello <p >world</p>"); $this->assert_true($safe_string instanceof SafeString); $safe_string_2 = html::clean($safe_string); $this->assert_equal("hello <p >world</p>", $safe_string_2); }
static function thumb_info($theme, $item) { $results = ""; if ($item->view_count) { $results .= "<li>"; $results .= t("Views: %view_count", array("view_count" => $item->view_count)); $results .= "</li>"; } if (module::is_active("tag")) { $tagsItem = ORM::factory("tag")->join("items_tags", "tags.id", "items_tags.tag_id")->where("items_tags.item_id", $item->id)->find_all(); if (count($tagsItem) > 0) { $results .= "<li>"; $results .= t("Tags:") . " "; for ($counter = 0; $counter < count($tagsItem); $counter++) { if ($counter < count($tagsItem) - 1) { $results .= "<a href=" . url::site("tags/{$tagsItem[$counter]}") . ">" . html::clean($tagsItem[$counter]->name) . "</a>, "; } else { $results .= "<a href=" . url::site("tags/{$tagsItem[$counter]}") . ">" . html::clean($tagsItem[$counter]->name) . "</a>"; } } $results .= "</li>"; } } if ($item->owner) { $results .= "<li>"; if ($item->owner->url) { $results .= t("By: %owner_name", array("owner_name" => "<a href=\"{$item->owner->url}\">{$item->owner->full_name}</a>")); } else { $results .= t("By: %owner_name", array("owner_name" => "{$item->owner->full_name}")); } $results .= "</li>"; } return $results; }
public function autocomplete() { $tags = array(); $tag_parts = explode(",", Input::instance()->get("term")); $tag_part = ltrim(end($tag_parts)); $tag_list = ORM::factory("tag")->where("name", "LIKE", Database::escape_for_like($tag_part) . "%")->order_by("name", "ASC")->limit(100)->find_all(); foreach ($tag_list as $tag) { $tags[] = (string) html::clean($tag->name); } ajax::response(json_encode($tags)); }
public function autocomplete() { $directories = array(); $path_prefix = Input::instance()->get("term"); foreach (glob("{$path_prefix}*") as $file) { if (is_dir($file) && !is_link($file)) { $directories[] = (string) html::clean($file); } } ajax::response(json_encode($directories)); }
public function autocomplete() { $directories = array(); $path_prefix = Input::instance()->get("q"); foreach (glob("{$path_prefix}*") as $file) { if (is_dir($file) && !is_link($file)) { $directories[] = html::clean($file); } } ajax::response(implode("\n", $directories)); }
public function autocomplete() { $tags = array(); $tag_parts = explode(",", Input::instance()->get("q")); $limit = Input::instance()->get("limit"); $tag_part = ltrim(end($tag_parts)); $tag_list = ORM::factory("tag")->where("name", "LIKE", "{$tag_part}%")->order_by("name", "ASC")->limit($limit)->find_all(); foreach ($tag_list as $tag) { $tags[] = html::clean($tag->name); } ajax::response(implode("\n", $tags)); }
static function logout() { $user = identity::active_user(); if (!$user->guest) { try { Session::instance()->destroy(); } catch (Exception $e) { Kohana::log("error", $e); } module::event("user_logout", $user); } log::info("user", t("User %name logged out", array("name" => $user->name)), html::anchor("user/{$user->id}", html::clean($user->name))); }
static function logout() { $user = identity::active_user(); if (!$user->guest) { try { Session::instance()->destroy(); } catch (Exception $e) { Kohana_Log::add("error", $e); } module::event("user_logout", $user); } log::info("user", t("User %name logged out", array("name" => $user->name)), t('<a href="%url">%user_name</a>', array("url" => user_profile::url($user->id), "user_name" => html::clean($user->name)))); }
public function send($id) { access::verify_csrf(); $user = identity::lookup_user($id); $form = user_profile::get_contact_form($user); if ($form->validate()) { Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=iso-8859-1")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send(); message::success(t("Sent message to %user_name", array("user_name" => $user->display_name()))); print json_encode(array("result" => "success")); } else { print json_encode(array("result" => "error", "form" => (string) $form)); } }
public function index() { //access::verify_csrf(); $user = user::active(); user::logout(); log::info("user", t("User %name logged out", array("name" => $user->name)), html::anchor("user/{$user->id}", html::clean($user->name))); if ($continue_url = $this->input->get("continue")) { $item = url::get_item_from_uri($continue_url); if (access::can("view", $item)) { // Don't use url::redirect() because it'll call url::site() and munge the continue url. header("Location: {$continue_url}"); } else { url::redirect(item::root()->abs_url()); } } }
public function send($id) { access::verify_csrf(); $user = identity::lookup_user($id); if (!$this->_can_view_profile_pages($user)) { throw new Kohana_404_Exception(); } $form = user_profile::get_contact_form($user); if ($form->validate()) { Sendmail::factory()->to($user->email)->subject(html::clean($form->message->subject->value))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->reply_to($form->message->reply_to->value)->message(html::purify($form->message->message->value))->send(); message::success(t("Sent message to %user_name", array("user_name" => $user->display_name()))); json::reply(array("result" => "success")); } else { json::reply(array("result" => "error", "html" => (string) $form)); } }
protected function html_element() { // Import the data $data = $this->data; if (empty($data['checked'])) { // Not checked unset($data['checked']); } else { // Is checked $data['checked'] = 'checked'; } if ($label = arr::remove('label', $data)) { // There must be one space before the text $label = ' ' . ltrim($label); } return '<label>' . form::input($data) . html::clean($label) . '</label>'; }
public function process($do) { if ($do == 'ok') { $this->status = true; return; } if (empty($_POST['feed_url'])) { return; } $this->feed_url = $_POST['feed_url']; $feed = feedReader::quickParse($this->feed_url); if ($feed === false) { throw new Exception(__('Cannot retrieve feed URL.')); } if (count($feed->items) == 0) { throw new Exception(__('No items in feed.')); } if ($this->core->plugins->moduleExists('metadata')) { $meta = new dcMeta($this->core); } $cur = $this->core->con->openCursor($this->core->prefix . 'post'); $this->core->con->begin(); foreach ($feed->items as $item) { $cur->clean(); $cur->user_id = $this->core->auth->userID(); $cur->post_content = $item->content ? $item->content : $item->description; $cur->post_title = $item->title ? $item->title : text::cutString(html::clean($cur->post_content), 60); $cur->post_format = 'xhtml'; $cur->post_status = -2; $cur->post_dt = strftime('%Y-%m-%d %H:%M:%S', $item->TS); try { $post_id = $this->core->blog->addPost($cur); } catch (Exception $e) { $this->core->con->rollback(); throw $e; } if (isset($meta)) { foreach ($item->subject as $subject) { $meta->setPostMeta($post_id, 'tag', dcMeta::sanitizeMetaID($subject)); } } } $this->core->con->commit(); http::redirect($this->getURL() . '&do=ok'); }
static function get($block_id, $theme) { switch ($block_id) { case "aboutthisalbum": $item = $theme->item; if (!$item or !$theme->item->is_album()) { return ""; } if ($theme->item->is_album()) { $block = new Block(); $block->css_id = "g-about-this-album"; $block->content = new View("about_this_album.html"); if ($theme->item()->id == item::root()->id) { $block->title = t("About this Site"); $block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all(); $block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all(); $block->content->vcount = Database::instance()->query("SELECT SUM({items}.view_count) as c FROM {items} WHERE type=\"photo\"")->current()->c; } else { $block->title = t("About this Album"); $block->content->album_count = $item->descendants_count(array(array("type", "=", "album"))); $block->content->photo_count = $item->descendants_count(array(array("type", "=", "photo"))); // $block->content->vcount= $theme->item()->view_count; $descds = $item->descendants(); $descds_view = 0; foreach ($descds as $descd) { if ($descd->is_photo()) { $descds_view += $descd->view_count; } } $block->content->vcount = $descds_view; if ($item->description) { $block->content->description = html::clean($item->description); } } $all_tags = ORM::factory("tag")->join("items_tags", "items_tags.tag_id", "tags.id")->join("items", "items.id", "items_tags.item_id", "LEFT")->where("items.parent_id", "=", $item->id)->order_by("tags.id", "ASC")->find_all(); if (count($all_tags) > 0) { $block->content->all_tags = $all_tags; } } break; } return $block; }
function cleanmsword($html) { /* rewrite : array with rewrite/remove rules preserve : array with exeptions on the rewrite rules rewrite : tag : attribute : value match = new value or false (remove) */ $rules = array(); $rules['rewrite']['.*']['class']['mso.*'] = false; // class="msoNormal" etc $rules['rewrite']['o:.*'] = false; // <o:p style=".."></o> $rules['rewrite']['.*']['style'] = false; // style="..." $rules['rewrite']['font'] = false; // font tags begone $rules['rewrite']['.*']['v:.*'] = false; // v:shape="..." return html::clean($html, $rules); }
static function thumb_info($theme, $item) { $results = ""; if ($item->view_count) { $results .= "<li>"; $results .= t("Views: %view_count", array("view_count" => $item->view_count)); $results .= "</li>"; } // rWatcher Edit: Display Tags on Thumbnails if (module::is_active("tag")) { $tags = ORM::factory("tag")->join("items_tags", "tags.id", "items_tags.tag_id")->where("items_tags.item_id", "=", $item->id)->find_all(); if (count($tags) > 0) { $results .= "<li>"; $results .= t("Tags:") . " "; $anchors = array(); foreach ($tags as $tag) { $anchors[] = "<a href=" . $tag->url() . ">" . html::clean($tag->name) . "</a>"; } $results .= join(", ", $anchors) . "</li>"; } } // rWatcher End Edit if ($item->owner) { // rWatcher Edit: Display profile instead of web site, if viewable. $str_owner_url = $item->owner->url; if (rwinfo_theme_Core::_can_view_profile_pages(identity::lookup_user($item->owner->id))) { $str_owner_url = user_profile::url($item->owner->id); } // rWatcher End Edit $results .= "<li>"; if ($str_owner_url) { //rW Edit str_owner_url $results .= t("By: <a href=\"%owner_url\">%owner_name</a>", array("owner_name" => $item->owner->display_name(), "owner_url" => $str_owner_url)); // rW Edit str_owner_url } else { $results .= t("By: %owner_name", array("owner_name" => $item->owner->display_name())); } $results .= "</li>"; } return $results; }
static function feed($feed_id, $offset, $limit, $id) { if ($feed_id != "newest" && $feed_id != "item") { return; } $comments = ORM::factory("comment")->viewable()->where("state", "=", "published")->order_by("created", "DESC"); if ($feed_id == "item") { $comments->where("item_id", "=", $id); } $feed->view = "comment.mrss"; $feed->children = array(); foreach ($comments->find_all($limit, $offset) as $comment) { $item = $comment->item(); $feed->children[] = new ArrayObject(array("pub_date" => date("D, d M Y H:i:s T", $comment->created), "text" => nl2br(html::purify($comment->text)), "thumb_url" => $item->thumb_url(), "thumb_height" => $item->thumb_height, "thumb_width" => $item->thumb_width, "item_uri" => url::abs_site("{$item->type}s/{$item->id}"), "title" => html::purify($item->title), "author" => html::clean($comment->author_name())), ArrayObject::ARRAY_AS_PROPS); } $feed->max_pages = ceil($comments->count_all() / $limit); $feed->title = htmlspecialchars(t("Recent Comments")); $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id)); $feed->description = t("Recent comments"); return $feed; }
static function get($block_id, $theme) { $block = ""; switch ($block_id) { case "metadata": if ($theme->item()) { $block = new Block(); $block->css_id = "g-metadata"; $block->title = $theme->item()->is_album() ? t("Album info") : ($theme->item()->is_movie() ? t("Movie info") : t("Photo info")); $block->content = new View("info_block.html"); if ($theme->item->title && module::get_var("info", "show_title")) { $info["title"] = array("label" => t("Title:"), "value" => html::purify($theme->item->title)); } if ($theme->item->description && module::get_var("info", "show_description")) { $info["description"] = array("label" => t("Description:"), "value" => nl2br(html::purify($theme->item->description))); } if (!$theme->item->is_album() && module::get_var("info", "show_name")) { $info["file_name"] = array("label" => t("File name:"), "value" => html::clean($theme->item->name)); } if ($theme->item->captured && module::get_var("info", "show_captured")) { $info["captured"] = array("label" => t("Captured:"), "value" => gallery::date_time($theme->item->captured)); } if ($theme->item->owner && module::get_var("info", "show_owner")) { $display_name = $theme->item->owner->display_name(); if ($theme->item->owner->url) { $info["owner"] = array("label" => t("Owner:"), "value" => html::anchor(html::clean($theme->item->owner->url), html::clean($display_name))); } else { $info["owner"] = array("label" => t("Owner:"), "value" => html::clean($display_name)); } } if ($theme->item->width && $theme->item->height && module::get_var("info", "show_dimensions")) { $info["size"] = array("label" => t("Dimensions:"), "value" => t("%width x %height px", array("width" => $theme->item->width, "height" => $theme->item->height))); } $block->content->metadata = $info; module::event("info_block_get_metadata", $block, $theme->item); } break; } return $block; }
static function feed($feed_id, $offset, $limit, $id) { if (!comment_rss::feed_visible($feed_id)) { return; } $comments = ORM::factory("comment")->viewable()->where("comments.state", "=", "published")->order_by("comments.created", "DESC"); if ($feed_id == "item") { $item = ORM::factory("item", $id); $comments->where("items.left_ptr", ">=", $item->left_ptr)->where("items.right_ptr", "<=", $item->right_ptr); } $feed = new stdClass(); $feed->view = "comment.mrss"; $feed->comments = array(); foreach ($comments->find_all($limit, $offset) as $comment) { $item = $comment->item(); $feed->comments[] = new ArrayObject(array("pub_date" => date("D, d M Y H:i:s O", $comment->created), "text" => nl2br(html::purify($comment->text)), "thumb_url" => $item->thumb_url(), "thumb_height" => $item->thumb_height, "thumb_width" => $item->thumb_width, "item_uri" => url::abs_site("{$item->type}s/{$item->id}"), "title" => $item->id == item::root()->id ? html::purify($item->title) : t("%site_title - %item_title", array("site_title" => item::root()->title, "item_title" => $item->title)), "author" => html::clean($comment->author_name())), ArrayObject::ARRAY_AS_PROPS); } $feed->max_pages = ceil($comments->count_all() / $limit); $feed->title = html::purify(t("%site_title - Recent Comments", array("site_title" => item::root()->title))); $feed->uri = url::abs_site("albums/" . (empty($id) ? "1" : $id)); $feed->description = t("Recent comments"); return $feed; }
static function get($block_id, $theme) { $block = ""; switch ($block_id) { case "metadata": if ($theme->item()) { $block = new Block(); $block->css_id = "g-metadata"; $block->title = $theme->item()->is_album() ? t("Album info") : t("Photo info"); $block->content = new View("info_block.html"); if ($theme->item->title && module::get_var("info", "show_title")) { $info["title"] = array("label" => t("Title:"), "value" => html::purify($theme->item->title)); } if ($theme->item->description && module::get_var("info", "show_description")) { $info["description"] = array("label" => t("Description:"), "value" => nl2br(html::purify($theme->item->description))); } if (!$theme->item->is_album() && module::get_var("info", "show_name")) { $info["file_name"] = array("label" => t("File name:"), "value" => html::clean($theme->item->name)); } if ($theme->item->captured && module::get_var("info", "show_captured")) { $info["captured"] = array("label" => t("Captured:"), "value" => gallery::date_time($theme->item->captured)); } if ($theme->item->owner && module::get_var("info", "show_owner")) { $display_name = $theme->item->owner->display_name(); if ($theme->item->owner->url) { $info["owner"] = array("label" => t("Owner:"), "value" => "<a href=\"{$theme->item->owner->url}\">" . html::clean($display_name) . "</a>"); } else { $info["owner"] = array("label" => t("Owner:"), "value" => html::clean($display_name)); } } $block->content->metadata = $info; module::event("info_block_get_metadata", $block, $theme->item); } break; } return $block; }
$jscode .= "\"noteid\": " . $oneFace->id . ",\n"; $jscode .= "\"notetype\": \"face\",\n"; $jscode .= "\"editable\": true,\n"; $jscode .= "\"url\": \"" . $oneTag->url() . "\" },\n"; } } foreach ($existingNotes as $oneNote) { if ($shownotes) { $legend_notes .= "<span id=\"photoannotation-legend-note-" . $oneNote->id . "\">" . html::clean($oneNote->title) . "</span> "; } $jscode .= "{ \"top\": " . $oneNote->y1 . ",\n"; $jscode .= "\"left\": " . $oneNote->x1 . ",\n"; $jscode .= "\"width\": " . ($oneNote->x2 - $oneNote->x1) . ",\n"; $jscode .= "\"height\": " . ($oneNote->y2 - $oneNote->y1) . ",\n"; $jscode .= "\"text\": \"" . html::clean($oneNote->title) . "\",\n"; $jscode .= "\"description\": \"" . html::clean($oneNote->description) . "\",\n"; $jscode .= "\"noteid\": " . $oneNote->id . ",\n"; $jscode .= "\"notetype\": \"note\",\n"; $jscode .= "\"editable\": false,\n"; $jscode .= "\"url\": \"\" },\n"; } $jscode = trim($jscode, ",\n"); $jscode .= " ],"; } $display = "none"; if ($legend_users != "") { $display = "block"; } $legend_users = t("<span id=\"photoannotation-legend-user\" style=\"display: " . $display . "\">People on this photo: ") . $legend_users . "</span>"; $display = "none"; if ($legend_faces != "") {
public function edit_product($id) { access::verify_csrf(); $product = ORM::factory("product", $id); if (!$product->loaded()) { throw new Kohana_404_Exception(); } $form = product::get_edit_form_admin($product); $valid = $form->validate(); if ($valid) { $new_name = $form->edit_product->inputs["name"]->value; if ($new_name != $product->name && ORM::factory("product")->where("name", "=", $new_name)->where("id", "<>", $product->id)->find()->loaded()) { $form->edit_product->inputs["name"]->add_error("in_use", 1); $valid = false; } else { $product->name = $new_name; } } if ($valid) { $product->cost = $form->edit_product->cost->value; $product->description = $form->edit_product->description->value; $product->postage_band_id = $form->edit_product->postage_band->value; $product->save(); message::success(t("Changed product %product_name", array("product_name" => html::clean($product->name)))); print json_encode(array("result" => "success")); } else { print json_encode(array("result" => "error", "form" => $form->__toString())); } }
/** * Returns a string safe for use in HTML element attributes. * * Assumes that the HTML element attribute is already * delimited by single or double quotes * * Example:<pre> * <a title="<?= html::clean_for_attribute($php_var) ?>">; * </script> * </pre> * @return the string escaped for use in HTML attributes. */ static function clean_attribute($string) { return html::clean($string)->for_html_attr(); }
alt="<?php echo html::clean_attribute($comment->author_name()); ?> " width="40" height="40" /> </a> <p><a href="mailto:<?php echo html::clean_attribute($comment->author_email()); ?> " title="<?php echo html::clean_attribute($comment->author_email()); ?> "> <?php echo html::clean($comment->author_name()); ?> </a></p> </td> <td> <div class="g-right"> <?php $item = $comment->item(); ?> <div class="g-item g-photo"> <a href="<?php echo $item->url(); ?> "> <?php if ($item->has_thumb()) {
/** * Ajout/modification des textes internationnalisés d'un élément. * * @param integer $iItemId * @param array $aItemLocalesData */ protected function setItemI18n($iItemId, $aItemLocalesData) { foreach ($this->okt->languages->list as $aLanguage) { if (empty($aItemLocalesData[$aLanguage['code']]['title'])) { continue; } $oCursor = $this->db->openCursor($this->t_items_locales); $oCursor->item_id = $iItemId; $oCursor->language = $aLanguage['code']; foreach ($aItemLocalesData[$aLanguage['code']] as $k => $v) { $oCursor->{$k} = $v; } $oCursor->content = $this->okt->HTMLfilter($oCursor->content); $oCursor->words = implode(' ', array_unique(text::splitWords($oCursor->title . ' ' . $oCursor->subtitle . ' ' . $oCursor->content . ' ' . $oCursor->author . ' ' . $oCursor->place))); $oCursor->meta_description = html::clean($oCursor->meta_description); $oCursor->meta_keywords = html::clean($oCursor->meta_keywords); $oCursor->insertUpdate(); $this->setItemSlug($iItemId, $aLanguage['code']); } }
<?php } ?> <div> <ul class="g-breadcrumbs"> <?php foreach ($album->parents() as $i => $parent) { ?> <li<?php if ($i == 0) { print " class=\"g-first\""; } ?> > <?php echo html::clean($parent->title); ?> </li> <?php } ?> <li class="g-active"> <?php echo html::purify($album->title); ?> </li> </ul> </div> <div id="g-add-photos-canvas"> <button id="g-add-photos-button" class="g-button ui-state-default ui-corner-all" href="#"><?php echo t("Select photos (%size max per file)...", array("size" => $size_limit));
<td class="g-odd"> <?php echo html::clean($details[$i]["value"]); ?> </td> <?php if (!empty($details[++$i])) { ?> <td class="g-even"> <?php echo $details[$i]["caption"]; ?> </td> <td class="g-odd"> <?php echo html::clean($details[$i]["value"]); ?> </td> <?php } else { ?> <td class="g-even"></td><td class="g-odd"></td> <?php } ?> </tr> <?php } ?> </tbody> </table>
/** * Convert simple text content to rich text content, init html editor * * @since version 0.85 * * @param $name name of textarea * @param $content content to convert in html * @param $rand * * @return $content **/ function setRichTextContent($name, $content, $rand) { // Init html editor Html::initEditorSystem($name, $rand); // If no html if ($content == strip_tags($content)) { $content = $this->convertTagToImage($content); } // Neutralize non valid HTML tags $content = html::clean($content, false, 1); // If content does not contain <br> or <p> html tag, use nl2br if (!preg_match("/<br\\s?\\/?>/", $content) && !preg_match("/<p>/", $content)) { $content = nl2br($content); } return $content; }
?> <li class="ui-icon-left"> <span class="ui-icon <?php echo is_dir($file) ? "ui-icon-folder-collapsed" : "ui-icon-document"; ?> "></span> <span class="<?php echo is_dir($file) ? "gDirectory" : "gFile"; ?> " ref="<?php echo html::clean_attribute($file); ?> " > <?php echo html::clean(basename($file)); ?> </span> </li> <?php } ?> <?php if (!$files) { ?> <li> <i> <?php echo t("empty"); ?> </i> </li> <?php }