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]); } } }
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]); } } }
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; }
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; }
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; }
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]); } } }