Exemplo n.º 1
0
 function excerptHTML($params, $node)
 {
     global $CTX, $FUNCS;
     extract($FUNCS->get_named_vars(array('count' => '', 'ignore' => '', 'trail' => '…'), $params));
     $count = $FUNCS->is_non_zero_natural($count) ? intval($count) : 50;
     if ($ignore != '') {
         $ignore = explode(",", $ignore);
         $ignore = array_map("trim", $ignore);
     }
     foreach ($node->children as $child) {
         $html .= $child->get_HTML();
     }
     $arr = explode(' ', $html, $count + 1);
     if (count($arr) > $count) {
         $sep = $trail;
         $arr = array_slice($arr, 0, -1);
     }
     $html = implode(' ', $arr) . $sep;
     $parser = new KHTMLParser($html, $ignore);
     $html = $parser->get_HTML();
     return $html;
 }
Exemplo n.º 2
0
 function cleanXSS($val, $nl2br = 0, $allowed_html_tags = '')
 {
     if (is_array($val)) {
         $val = $val[0];
     }
     //?? do what? take only the first value
     $parser = new KHTMLParser($val, '', 1, $nl2br, $allowed_html_tags);
     $val = $parser->get_HTML();
     return $val;
 }
Exemplo n.º 3
0
<?php

$output .= "<h2>Aggregator</h2>";
$sql = null;
//Logged in as...
include "views/heading.php";
//Parsing the webpage
require "models/KHTMLParser.class.php";
$parser = new KHTMLParser();
//adding a new element
if ($_SERVER['QUERY_STRING'] != "") {
    $url = $parser->httpPrefix($_SERVER['QUERY_STRING']);
    $urlContents = $parser->file_get_contents_curl($url);
    $dom = new DOMDocument();
    @$dom->loadHTML($urlContents);
    $title = $dom->getElementsByTagName('title');
    $name = $title->item(0)->nodeValue;
    // "Example Web Page"
    //Is this an image?
    if (strpos($url, '.jpg') || strpos($url, '.jpeg') || strpos($url, '.png') || strpos($url, '.gif')) {
        $name = "<a href='" . $url . "'><img class=thumb src='" . $url . "'></a>";
    }
    //YOUTUBE
    if (strpos($url, 'youtube.com') !== false) {
        $name = '<iframe width="330" height="186" src="' . $url . '" frameborder="0" allowfullscreen>This might be broken...</iframe>';
    }
    //Saving the IP of whoever added the link
    $srcIp = $_SERVER['REMOTE_ADDR'];
    try {
        $database->query("insertPost", $name, $url, $srcIp, $_SESSION['login_user']) === TRUE;
        $output .= "<p>New record created successfully.</p>";