Results 1 to 1 of 1
-
4th Jul 2009, 06:12 AM #1OPMember
php code help
EDIT:nevermind jet helped
I am over looking something....
I get Parse error: syntax error, unexpected T_STRING in /home/home/domain/testing.com/public_html/pingback.php on line 56
PHP Code:function pingback($text, $sourceURI, $sameSite = False) {
$targets = getTargets($text);
foreach($targets as $targetURI) {
preg_match("/X-Pingback: (\S+)/i", http_req($targetURI, "HEAD"), $matches);
if(isset($matches[1])) {
$pingbackserver = $matches[1];
} else {
preg_match("/<link rel=\"pingback\" href=\"([^\"]+)\" ?\/?>/i", http_req($targetURI), $matches);
$pingbackserver = $matches[1];
if(!$pingbackserver) {
continue;
}
}
if ($sameSite !== False) {
preg_match("/^http:\/\/([^\/]+)(.*)$/", $sourceURI, $matches);
$hostname1 = $matches[1];
preg_match("/^http:\/\/([^\/]+)(.*)$/", $targetURI, $matches);
$hostname2 = $matches[1];
if ($hostname2 == $hostname) {
continue;
}
}
ping($pingbackserver, $sourceURI, $targetURI);
}
return true;
}
function getTargets($text) {
preg_match_all("/<a[^>]+href=.(http:\/\/[^'\"]+)/i", $text, $matches);
return array_unique($matches[1]);
}
function http_req($uri, $method = "GET", $add_header = '', $payload = '') {
preg_match("/^http:\/\/([^\/]+)(.*)$/", $uri, $matches);
$hostname = $matches[1];
$script = $matches[2];
if(empty($hostname)) {
return;
}
$fp = fsockopen($hostname, 80, $errno, $errstr, 30);
if(!$fp) {
return;
}
fwrite($fp, "$method $script HTTP/1.1
Host: $hostname
User-Agent: pingback
$add_header
$payload
");
stream_set_timeout($fp, 5);
$res = stream_get_contents($fp);
fclose($fp);
return $res;
}
function ping($pingbackserver, $sourceURI, $targetURI) {
$payload = <<<ENDE
<?xml version="1.0"?>
<methodCall>
<methodName>pingback.ping</methodName>
<params>
<param>
<value>$sourceURI</value>
</param>
<param>
<value>$targetURI</value>
</param>
</params>
</methodCall>
ENDE;
$length = strlen($payload);
$request_head = "Content-Type: text/xml\r\nContent-length: $length";
return http_req($pingbackserver, "POST", $request_head, $payload);
}r0ck Reviewed by r0ck on . php code help EDIT:nevermind jet helped I am over looking something.... I get Parse error: syntax error, unexpected T_STRING in /home/home/domain/testing.com/public_html/pingback.php on line 56 function pingback($text, $sourceURI, $sameSite = False) { $targets = getTargets($text); foreach($targets as $targetURI) { Rating: 5
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Help With Letitbit Js To BB Code aka Embedding streaming code in forums
By JoomlaZ in forum Web Development AreaReplies: 1Last Post: 3rd Apr 2012, 09:50 AM -
need help with php code
By itmees in forum Web Development AreaReplies: 6Last Post: 22nd Mar 2012, 10:01 AM -
Need a good coder to code a skin, I will show you what I need, you just code it
By Nickk96 in forum Web Development AreaReplies: 1Last Post: 27th Aug 2011, 01:45 PM -
{LF} a code
By DeathNote in forum Web Application/Script SupportReplies: 2Last Post: 23rd Oct 2010, 04:18 AM -
[vBulletin BB Code] Moderated Message: (Like W-BB's Staff BB Code!)
By Ghost Dog 13 in forum Webmaster ResourcesReplies: 13Last Post: 26th Sep 2009, 06:19 PM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...