Esempio n. 1
0
function getTitle($url)
{
    include '../includes/curl.php';
    $newc = new curl();
    $fd = $newc->getFile($url);
    if ($fd) {
        // Get title from title tag
        preg_match_all('/<title>(.*)<\\/title>/si', $fd, $matches);
        $title = $matches[1][0];
        // Get encoding from charset attribute
        preg_match_all('/<meta.*charset=([^;"]*)">/i', $fd, $matches);
        $encoding = strtoupper($matches[1][0]);
        // Convert to UTF-8 from the original encoding
        $title = @mb_convert_encoding($title, 'UTF-8', $encoding);
        if (strlen($title) > 0) {
            return $title;
        } else {
            // No title, so return filename
            $uriparts = explode('/', $url);
            $filename = end($uriparts);
            unset($uriparts);
            return $filename;
        }
    } else {
        return false;
    }
}
Esempio n. 2
0
function add_bookmark($uname, $title, $folderid, $url, $description, $tags = "", $newPublic = false, $date = NULL)
{
    $resultArr = array();
    $resultArr['success'] = false;
    include 'conn.php';
    require_once dirname(__FILE__) . '/protection.php';
    if ($date != "") {
        $date = "'{$date}'";
    } else {
        $date = "now()";
    }
    // Cut data to respect maximum length
    if (!empty($title)) {
        $title = substr($title, 0, 100);
    }
    if (!empty($description)) {
        $description = substr($description, 0, 150);
    }
    //$Query = sprintf("INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) " . "values('" . $uname . "', %s,'" . $folderid . "', %s, %s, $date) ", quote_smart($title), quote_smart($url), quote_smart($description));
    $Query = "INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) values(?, ?, ?, ?, ?, {$date})";
    $sth = $dblink->prepare($Query);
    $dataBookmark = array($uname, $title, $folderid, $url, $description);
    $AffectedRows = $sth->execute($dataBookmark);
    $rec_id = $dblink->lastInsertID(TABLE_PREFIX . "favourites", 'ID');
    if (PEAR::isError($AffectedRows)) {
        $resultArr['success'] = true;
        //echo 'ERROR: '. $AffectedRows->getMessage(). ' :: ' . $AffectedRows->getUserInfo();
    } else {
        $resultArr['success'] = true;
        $tags = trim($tags);
        if (TAGS && $tags != "") {
            require_once dirname(__FILE__) . '/tags_functions.php';
            //Remove any commas, dots, quotes, plus signs since the user might use commas to seperate tags rather than spaces
            $toRemove = array('"', "'", ",", "+");
            $tags = str_replace($toRemove, "", $tags);
            $tags = filter($tags);
            if ($tags != null && $newPublic) {
                // cut tags if too long > 150 chars
                $tags = substr($tags, 0, 150);
                //Add the tags
                addTags($tags);
                //Store the tags with the bookmark
                storeTags($rec_id, $tags);
            }
            if (USE_SCREENSHOT && CURL_AVAILABLE) {
                require_once dirname(__FILE__) . '/curl.php';
                $newc = new curl();
                $urlScreenshot = sprintf(SCREENSHOT_URL, $url);
                //echo $urlScreenshot;
                $fd = $newc->getFile($urlScreenshot);
            }
        }
    }
    return $resultArr;
}
Esempio n. 3
0
        } else {
            return $this->file_contents;
        }
    }
    function read($ch, $string)
    {
        $length = strlen($string);
        $this->file_contents .= $string;
        echo "Received {$length} bytes<br />\n";
        return $length;
    }
}
if (isset($_GET['url'])) {
    $url = $_GET['url'];
    $curl = new curl();
    $lines = $curl->getFile($url, 1000, 1000);
    if ($lines == FALSE) {
        print "error";
        return array("", "");
    }
}
if (isset($_POST['data'])) {
    $lines = $_POST['data'];
}
if (isset($lines)) {
    $ver = intval($_REQUEST['v']);
    header('Content-type: application/xml');
    $v4 = stristr($lines, "urn:ietf:params:xml:ns:metalink") !== FALSE;
    if ($v4 and $ver == 3) {
        $lines = metalink4to3(trim($lines));
    } elseif (!$v4 and $ver == 4) {