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