Example #1
0
	function get($url) {
		$url=trim($url);
		if(!preg_match('/^http[s]*:/', $url)) return false;
		$url_components = parse_url($url);
		if($url_components[host] == get_server_name()) return false;
		if(version_compare(phpversion(), '5.1.0') >= 0) {
			$opts = array(
				'http' => array('user_agent' => 'Mozilla/5.0 (compatible; Meneame; +http://meneame.net/) Gecko/Meneame Firefox', 'max_redirects' => 7),
				'https' => array('user_agent' => 'Mozilla/5.0 (compatible; Meneame; +http://meneame.net/) Gecko/Meneame Firefox', 'max_redirects' => 7)
			);
			$context = stream_context_create($opts);
			$url_ok = $this->html = file_get_contents($url, false, $context, 0, 200000);
		} else {
			$url_ok = $this->html = file_get_contents($url);
		}
		if (!$url_ok) return false;
		$this->valid = true;
		$this->url=$url;
		if(preg_match('/charset=([a-zA-Z0-9-_]+)/i', $this->html, $matches)) {
			$this->encoding=trim($matches[1]);
			if(strcasecmp($this->encoding, 'utf-8') != 0) {
				$this->html=iconv($this->encoding, 'UTF-8//IGNORE', $this->html);
			}
		}
		if(preg_match('/<title>([^<>]*)<\/title>/i', $this->html, $matches)) {
			$this->url_title=trim($matches[1]);
		}
		require_once(mnminclude.'blog.php');
		$blog = new Blog();
		$blog->analyze_html($this->url, $this->html);
		if(!$blog->read('key')) {
			$blog->store();
		}
		$this->blog=$blog->id;
		$this->type=$blog->type;

		// Detect trackbacks
		if (!empty($_POST['trackback'])) {
			$this->trackback=trim($_POST['trackback']);
		} elseif (preg_match('/trackback:ping="([^"]+)"/i', $this->html, $matches) ||
			preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $this->html, $matches) || 
			preg_match('/<trackback:ping>([^<>]+)/i', $this->html, $matches)) {
			$this->trackback=trim($matches[1]);
		} elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		} elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\/a>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		}  
		
	}
Example #2
0
	function get($url) {
		$url=trim($url);
		//$context = array('user_agent' => 'Mozilla/5.0 (compatible; Meneame; +http://meneame.net/)'); // for PHP5
		if(!preg_match('/^http[s]*:/', $url) || !($this->html = file_get_contents($url))) {
			return;
		}
		$this->valid = true;
		$this->url=$url;
		if(preg_match('/charset=([a-zA-Z0-9-_]+)/i', $this->html, $matches)) {
			$this->encoding=trim($matches[1]);
			if(strcasecmp($this->encoding, 'utf-8') != 0) {
				$this->html=iconv($this->encoding, 'UTF-8//IGNORE', $this->html);
			}
		}
		if(preg_match('/<title>([^<>]*)<\/title>/i', $this->html, $matches)) {
			$this->url_title=trim($matches[1]);
		}
		require_once(mnminclude.'blog.php');
		$blog = new Blog();
		$blog->analyze_html($this->url, $this->html);
		if(!$blog->read('key')) {
			$blog->store();
		}
		$this->blog=$blog->id;
		$this->type=$blog->type;

		// Detect trackbacks
		if (!empty($_POST['trackback'])) {
			$this->trackback=trim($_POST['trackback']);
		} elseif (preg_match('/trackback:ping="([^"]+)"/i', $this->html, $matches) ||
			preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $this->html, $matches) || 
			preg_match('/<trackback:ping>([^<>]+)/i', $this->html, $matches)) {
			$this->trackback=trim($matches[1]);
		} elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		} elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\/a>/i', $this->html, $matches)) {
			if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
				$this->trackback=trim($matches2[1]);
			}
		}  
		
	}
Example #3
0
//$count = $db->get_var("SELECT count(*) from blogs where blog_url regexp 'http://.+/.+'");
$count = $db->get_var("SELECT count(*) from blogs where blog_url regexp 'http://.+'");
echo "{$count} <br>\n";
flush();
$ids = $db->get_col("SELECT blog_id from blogs where blog_url regexp 'http://.+' order by blog_id asc");
foreach ($ids as $dbid) {
    $blog->id = $dbid;
    if (!$blog->read()) {
        continue;
    }
    $url = $db->get_var("select link_url from links where link_blog = {$dbid} limit 1");
    if (!empty($url)) {
        $old_url = $blog->url;
        $blog->find_base_url($url);
        $old_key = $blog->key;
        $blog->calculate_key();
        if ($blog->url != $old_url || $old_key != $blog->key) {
            echo "NEW: {$new_url} ({$old_url})<br>\n";
            $old_id = $db->get_var("select blog_id from blogs where blog_key = '{$blog->key}' and blog_id != {$blog->id}");
            if ($old_id > 0) {
                echo "REPE: {$old_id} -> {$blog->id}<br>\n";
                $db->query("update links set link_blog={$blog->id} where link_blog={$old_id}");
                $db->query("delete from blogs where blog_id = {$old_id}");
            }
            $blog->store();
        }
    } else {
        echo "Deleting {$dbid}\n";
        $db->query("delete from blogs where blog_id = {$dbid}");
    }
}
Example #4
0
	function create_blog_entry() {
		$blog = new Blog();
		$blog->analyze_html($this->url, $this->html);
		if(!$blog->read('key')) {
			$blog->store();
		}
		$this->blog=$blog->id;
		$this->type=$blog->type;
	}
Example #5
0
 function create_blog_entry()
 {
     require_once mnminclude . 'blog.php';
     $blog = new Blog();
     $blog->analyze_html($this->url, $this->html);
     if (!$blog->read('key')) {
         $blog->store();
     }
     $this->blog = $blog->id;
     $this->type = $blog->type;
 }
Example #6
0
 function create_blog_entry()
 {
     $blog = new Blog();
     $blog->analyze_html($this->url, $this->html);
     if (!$blog->read('key') || $blog->type != 'noiframe' && $this->noiframe) {
         if ($blog->type != 'noiframe' && $this->noiframe) {
             $blog->type = 'noiframe';
             syslog(LOG_INFO, "Meneame, changed to noiframe ({$blog->id}, {$blog->url})");
         }
         $blog->store();
     }
     $this->blog = $blog->id;
     $this->type = $blog->type;
 }
Example #7
0
    $is_admin = true;   
}
if (strpos($call_script, '/blog/moderator/') !== false && $g_user->hasPermission('plugin_blog_moderator')) {
    $is_moderator = true;
}

// Check permissions
if (!$g_user->hasPermission('plugin_blog_admin')) {
    camp_html_display_error(getGS('You do not have the right to manage blogs.'));
    exit;
}

$f_blog_id = Input::Get('f_blog_id', 'int');
$Blog = new Blog($f_blog_id);

if ($Blog->store($is_admin)) {
    camp_html_add_msg(getGS('Blog saved.'), 'ok');
    ?>
    <script language="javascript">
        window.opener.location.reload();
        window.close();
    </script>
    <?php
    exit();
}

?>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Expires" content="now">
	<link rel="stylesheet" type="text/css" href="<?php echo $Campsite['WEBSITE_URL']; ?>/admin-style/admin_stylesheet.css">
Example #8
0
 function get($url)
 {
     $url = trim($url);
     if (Validate_URL != false) {
         $r = new HTTPRequest($url);
         $xxx = $r->DownloadToString();
     } else {
         $xxx = "";
         $this->valid = true;
         $this->url = $url;
         return;
     }
     if (CHECK_SPAM && $this->check_spam($url)) {
         $this->valid = false;
         return;
     }
     if (!($this->html = $xxx)) {
         return;
     }
     if ($xxx == "BADURL") {
         $this->valid = false;
         return;
     }
     $this->valid = true;
     $this->url = $url;
     if (preg_match('/charset=([a-zA-Z0-9-_]+)/i', $this->html, $matches)) {
         $this->encoding = trim($matches[1]);
         //you need iconv to encode to utf-8
         if (function_exists("iconv")) {
             if (strcasecmp($this->encoding, 'utf-8') != 0) {
                 //convert the html code into utf-8 whatever encoding it is using
                 $this->html = iconv($this->encoding, 'UTF-8//IGNORE', $this->html);
             }
         }
     }
     if (preg_match("'<title>([^<]*?)</title>'", $this->html, $matches)) {
         $this->url_title = trim($matches[1]);
     }
     require_once mnminclude . 'blog.php';
     $blog = new Blog();
     $blog->analyze_html($this->url, $this->html);
     if (!$blog->read('key')) {
         $blog->store();
     }
     $this->blog = $blog->id;
     $this->type = $blog->type;
     // Detect trackbacks
     if (!empty($_POST['trackback'])) {
         $this->trackback = trim($_POST['trackback']);
     } elseif (preg_match('/trackback:ping="([^"]+)"/i', $this->html, $matches) || preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $this->html, $matches) || preg_match('/<trackback:ping>([^<>]+)/i', $this->html, $matches)) {
         $this->trackback = trim($matches[1]);
     } elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $this->html, $matches)) {
         if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
             $this->trackback = trim($matches2[1]);
         }
     } elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\\/a>/i', $this->html, $matches)) {
         if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
             $this->trackback = trim($matches2[1]);
         }
     }
 }