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