-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
PHP-pingback.php
38 lines (34 loc) · 1.07 KB
/
PHP-pingback.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
// Her sayfaya girildiğinde Google'ye ping gönderme kodu
// Kullanımı: <link rel="pingback" href="https://www.girisimzel.com/pingback.php" />
function pingGoogleSitemaps( $url_xml )
{
$status = 0;
$google = 'www.google.com';
if( $fp=@fsockopen($google, 80) )
{
$req = 'GET /webmasters/sitemaps/ping?sitemap=' .
urlencode( $url_xml ) . " HTTP/1.1\r\n" .
"Host: $google\r\n" .
"User-Agent: Mozilla/5.0 (compatible; " .
PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" .
"Connection: Close\r\n\r\n";
fwrite( $fp, $req );
while( !feof($fp) )
{
if( @preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m) )
{
$status = intval( $m[1] );
break;
}
}
fclose( $fp );
}
return( $status );
}
// Once the sitemaps are ready, we ping Google...
if( 200 === ($status=pingGoogleSitemaps('https://toosba.com/sitemap.xml')) )
echo "
pingleme tamam";
else
echo "error: pingleme tamam değil";