Last active
August 29, 2015 13:57
-
-
Save hayakawa/9578643 to your computer and use it in GitHub Desktop.
Wordpress XML-RPC Pingback checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($argc != 2 or empty($argv[1])) { | |
echo "Usage : $argv[0] {CHECK TARGET}\n"; | |
echo "Example: $argv[0] http://www.example.com/wp/xmlrpc.php\n"; | |
exit(1); | |
} elseif (!preg_match("/^(http|https):\/\//",$argv[1])) { | |
echo "Invalid URL\n"; | |
exit(1); | |
} | |
$request = xmlrpc_encode_request('pingback.ping',array('127.0.0.1', str_replace(array('http://','https://'), '', $argv[1]))); | |
$context = stream_context_create(array('http' => array( | |
'method' => 'POST', | |
'header' => 'Content-Type: text/xml', | |
'content' => $request | |
))); | |
echo "[Request]\n"; | |
print_r($request); | |
echo "\n"; | |
echo "[Response]\n"; | |
$file = file_get_contents($argv[1], false, $context); | |
$response = xmlrpc_decode($file); | |
if ($response) { | |
print_r($response); | |
} else { | |
echo "No response...\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment