Пример #1
0
* @package     Heurist academic knowledge management system
* @subpackage  !!!subpackagename for file such as Administration, Search, Edit, Application, Library
*/
require_once dirname(__FILE__) . '/../../common/connect/applyCredentials.php';
require_once dirname(__FILE__) . '/../../records/files/fileUtils.php';
$title = '';
$url = @$_REQUEST['url'];
$rv = array('num' => $_REQUEST['num']);
if (!is_logged_in()) {
    $rv['error'] = 'You must be logged in';
} else {
    if (!$url || !intval($_REQUEST['num']) && $_REQUEST['num'] != 'popup') {
        $rv['error'] = 'URL is not defined';
    } else {
        $url = str_replace(' ', '+', $url);
        $data = loadRemoteURLContentWithRange($url, "0-10000");
        if ($data) {
            preg_match('!<\\s*title[^>]*>\\s*([^<]+?)\\s*</title>!is', $data, $matches);
            if ($matches) {
                $title = preg_replace('/\\s+/', ' ', $matches[1]);
            }
            if ($title) {
                $rv['title'] = $title;
                //type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
                //if (preg_match('!^image/!i', $type)) {
                //	preg_match('!.*/(.*)!', $_REQUEST['url'], $matches);
                //	$title = 'Image - ' . $matches[1];
                //}
            } else {
                $rv['error'] = 'Title is not defined';
            }
Пример #2
0
function loadRemoteURLContent($url, $bypassProxy = true)
{
    return loadRemoteURLContentWithRange($url, null, $bypassProxy);
}
Пример #3
0
if (@$_REQUEST['shortcut']) {
    $_REQUEST['mode'] = 'Analyse';
    $_REQUEST['source'] = 'url';
    $_REQUEST['url'] = $_REQUEST['shortcut'];
}
if (@$_REQUEST['old_srcname']) {
    $srcname = $_REQUEST['old_srcname'];
}
if (@$_REQUEST['mode'] == 'Analyse') {
    if (@$_REQUEST['source'] == 'file') {
        $src = file_get_contents($_FILES['file']['tmp_name']);
        $srcname = $_FILES['file']['name'];
    } else {
        if (@$_REQUEST['source'] == 'url') {
            $_REQUEST['url'] = preg_replace('/#.*/', '', $_REQUEST['url']);
            $src = loadRemoteURLContentWithRange($_REQUEST['url'], null, false, 120);
            if (!$src) {
                $error = 'URL could not be retrieved. Verify your proxy setting in configuration file. <span style="font-weight: normal;">You might try saving the page you are importing, and then <a href="importHyperlinks.php">import from file</a>.</span>';
            }
            $srcname = @$_REQUEST['url'];
        }
    }
    if (@$src) {
        $base_url = @$_REQUEST['url'];
        if (preg_match('!<base[^>]*href=["\']?([^"\'>\\s]+)["\']?!is', $src, $url_match)) {
            $base_url = $url_match[1];
        }
        $base_url_root = preg_replace('!([^:/])/.*!', '$1', $base_url);
        $base_url_base = preg_replace('!([^:/]/.*/)[^/]*$!', '$1', $base_url);
        if (substr($base_url_base, -1, 1) != '/') {
            $base_url_base = $base_url_base . '/';
Пример #4
0
/**
* utility functions for dealing with files
*
* @author      Stephen White   <*****@*****.**>
* @author      Artem Osmakov   <*****@*****.**>
* @copyright   (C) 2005-2013 University of Sydney
* @link        http://Sydney.edu.au/Heurist
* @version     3.1.0
* @license     http://www.gnu.org/licenses/gpl-3.0.txt GNU License 3.0
* @package     Heurist academic knowledge management system
* @subpackage  Files/Util
*/
function loadRemoteURLContent($url)
{
    return loadRemoteURLContentWithRange($url, null);
}