Esempio n. 1
0
 /**
  * Scan content of source url for a trackback url
  *
  * @return str - trackback url
  *
  * Adapted from Pligg.com and SocialWebCMS.com
  */
 public function detectTrackback($h)
 {
     include_once EXTENSIONS . 'SWCMS/HotaruHttpRequest.php';
     // Fetch the content of the original url...
     $url = $h->post->origUrl;
     if ($url != 'http://' && $url != '') {
         $r = new HotaruHttpRequest($url);
         $content = $r->DownloadToString();
     } else {
         $content = '';
     }
     $trackback = '';
     if (preg_match('/trackback:ping="([^"]+)"/i', $content, $matches) || preg_match('/trackback:ping +rdf:resource="([^>]+)"/i', $content, $matches) || preg_match('/<trackback:ping>([^<>]+)/i', $content, $matches)) {
         $trackback = trim($matches[1]);
     } elseif (preg_match('/<a[^>]+rel="trackback"[^>]*>/i', $content, $matches)) {
         if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
             $trackback = trim($matches2[1]);
         }
     } elseif (preg_match('/<a[^>]+href=[^>]+>trackback<\\/a>/i', $content, $matches)) {
         if (preg_match('/href="([^"]+)"/i', $matches[0], $matches2)) {
             $trackback = trim($matches2[1]);
         }
     } elseif (preg_match('/http:([^ ]+)trackback.php([^<|^ ]+)/i', $content, $matches)) {
         $trackback = trim($matches[1]);
     } elseif (preg_match('/trackback:ping="([^"]+)"/', $content, $matches)) {
         $trackback = trim($matches[1]);
     }
     return $trackback;
 }
Esempio n. 2
0
 /**
  * Add spammer to the StopForumSpam.com database
  */
 public function addSpammer($ip = '', $username = '', $email = '', $apikey = '')
 {
     if (!$ip || !$username || !$email || !$apikey || $ip == '127.0.0.1') {
         return false;
     }
     $url = "http://www.stopforumspam.com/add.php?";
     $url .= "username="******"&ip_addr=" . $ip;
     $url .= "&email=" . urlencode($email);
     $url .= "&api_key=" . $apikey;
     require_once EXTENSIONS . 'SWCMS/HotaruHttpRequest.php';
     $r = new HotaruHttpRequest($url);
     $error = $r->DownloadToString();
     //if (!$error) { echo "Success"; } else { echo $error; }
 }
Esempio n. 3
0
 function DownloadToString()
 {
     $response = "";
     $crlf = "\r\n";
     // generate request
     $req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . $crlf;
     error_reporting(E_ERROR);
     // fetch
     $this->_fp = fsockopen(($this->_protocol == 'https' ? 'tls://' : '') . $this->_host, $this->_port, $errno, $errstr, 20);
     if (!$this->_fp) {
         return "BADURL";
     }
     fwrite($this->_fp, $req);
     while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) {
         $response .= fread($this->_fp, 1024);
     }
     fclose($this->_fp);
     // split header and body
     $pos = strpos($response, $crlf . $crlf);
     if ($pos === false) {
         return $response;
     }
     $header = substr($response, 0, $pos);
     $body = substr($response, $pos + 2 * strlen($crlf));
     // parse headers
     $headers = array();
     $lines = explode($crlf, $header);
     foreach ($lines as $line) {
         if (($pos = strpos($line, ':')) !== false) {
             $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
         }
     }
     // redirection?
     if (isset($headers['location'])) {
         $http = new HotaruHttpRequest($headers['location']);
         return $http->DownloadToString($http);
     } else {
         return $body;
     }
 }
 /**
  * Scrapes the title from the page being submitted
  *
  * @param string $url
  * @link http://www.phpfour.com/blog/2008/01/php-http-class/
  */
 public function fetchTitle($url)
 {
     require_once EXTENSIONS . 'SWCMS/HotaruHttpRequest.php';
     if ($url != 'http://' && $url != '') {
         $r = new HotaruHttpRequest($url);
         $string = $r->DownloadToString();
     } else {
         $string = '';
     }
     if (preg_match('/charset=([a-zA-Z0-9-_]+)/i', $string, $matches)) {
         $encoding = trim($matches[1]);
         //you need iconv to encode to utf-8 (if not, use custom iconv in funcs.strings.php)
         if (strcasecmp($encoding, 'utf-8') != 0) {
             //convert the html code into utf-8 whatever encoding it is using
             $string = iconv($encoding, 'UTF-8//IGNORE', $string);
         }
     }
     if (preg_match("'<title>([^<]*?)</title>'", $string, $matches)) {
         $title = trim($matches[1]);
     } else {
         $title = '';
     }
     return $title;
 }