Projects : mp-wp : mp-wp_genesis

mp-wp/pingback-updater.php

Dir - Raw

1<?
2// Db connect data.
3
4$db_name = '';
5$db_user = '';
6$db_pass = '';
7
8$table_prefix = '';
9
10$nconnection = mysql_connect("localhost", $db_user, $db_pass );
11mysql_select_db($db_name, $nconnection);
12
13// Index of post at which script last ran. Script won't look through earlier posts. You have to update the value manually.
14$last_run = 61145;
15
16// Part one : select all the posts that contain a link to your own blog. Replace the url adequately.
17$local = "http://trilema.com/";
18
19$query = 'SELECT YEAR(post_date), post_name, post_content FROM '.$table_prefix.'posts WHERE post_type ="post" AND post_content LIKE "%<a href=%" AND ID > '.$last_run;
20$record = mysql_query($query);
21
22while ( $row = mysql_fetch_array($record, MYSQL_NUM)) {
23 $post_url = "http://trilema.com/".$row[0]."/".$row[1];
24 // echo "<h1>",$post_url,"</h1>";
25
26$dom = new DOMDocument();
27@$dom->loadHTML($row[2]);
28
29$xpath = new DOMXPath($dom);
30$hrefs = $xpath->evaluate("/html/body//a");
31
32for ($i = 0; $i < $hrefs->length; $i++) {
33 $href = $hrefs->item($i);
34 $url = $href->getAttribute('href');
35
36 $parse = parse_url($url);
37 echo 'curl -A "Mozilla/5.0" -r 0-4096 --connect-timeout 30 --max-time 10 "http://';
38 echo $parse['host'];
39 echo '/xmlrpc.php" --header "Content-Type: text/xml" --data "<?xmlversion="1.0"?><methodCall><methodName>pingback.ping</methodName><params><param><value><string>';
40 echo $post_url;
41 echo '</string></value></param><param><value><string>';
42 echo $url;
43 echo '</string></value></param></params></methodCall>"'."\n";
44}
45
46}
47
48?>