diff options
Diffstat (limited to 'xmlrpc.php')
| -rw-r--r-- | xmlrpc.php | 101 |
1 files changed, 101 insertions, 0 deletions
| diff --git a/xmlrpc.php b/xmlrpc.php new file mode 100644 index 0000000..2c634d3 --- /dev/null +++ b/xmlrpc.php | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | <?php | ||
| 2 | /* | ||
| 3 | 444444444 | ||
| 4 | 4::::::::4 | ||
| 5 | 4:::::::::4 | ||
| 6 | 4::::44::::4 | ||
| 7 | 4::::4 4::::4 Four Island | ||
| 8 | 4::::4 4::::4 | ||
| 9 | 4::::4 4::::4 Written and maintained by Starla Insigna | ||
| 10 | 4::::444444::::444 | ||
| 11 | 4::::::::::::::::4 xmlrpc.php | ||
| 12 | 4444444444:::::444 | ||
| 13 | 4::::4 Please do not use, reproduce or steal the | ||
| 14 | 4::::4 contents of this file without explicit | ||
| 15 | 4::::4 permission from Hatkirby. | ||
| 16 | 44::::::44 | ||
| 17 | 4::::::::4 | ||
| 18 | 4444444444 | ||
| 19 | */ | ||
| 20 | |||
| 21 | require('headerproc.php'); | ||
| 22 | |||
| 23 | include('../security/config.php'); | ||
| 24 | include('includes/db.php'); | ||
| 25 | include('includes/xmlrpc/xmlrpc.inc'); | ||
| 26 | include('includes/xmlrpc/xmlrpcs.inc'); | ||
| 27 | include('includes/functions.php'); | ||
| 28 | |||
| 29 | function ping($xmlrpcmsg) | ||
| 30 | { | ||
| 31 | $from = $xmlrpcmsg->getParam(0)->scalarVal(); | ||
| 32 | $to = $xmlrpcmsg->getParam(1)->scalarVal(); | ||
| 33 | |||
| 34 | if (preg_match('/^http:\/\/w?w?w?\.?fourisland\.com\/blog\/([-a-z0-9]+)\/$/',$to)) | ||
| 35 | { | ||
| 36 | $slug = preg_replace('/^http:\/\/w?w?w?\.?fourisland\.com\/blog\/([-a-z0-9]+)\/$/','$1',$to); | ||
| 37 | |||
| 38 | $getpost = "SELECT * FROM updates WHERE slug = \"" . $slug . "\""; | ||
| 39 | $getpost2 = mysql_query($getpost); | ||
| 40 | $getpost3 = mysql_fetch_array($getpost2); | ||
| 41 | |||
| 42 | if ($getpost3['slug'] == $slug) | ||
| 43 | { | ||
| 44 | |||
| 45 | $c = curl_init(); | ||
| 46 | curl_setopt($c, CURLOPT_URL, $from); | ||
| 47 | curl_setopt($c, CURLOPT_RETURNTRANSFER, true); | ||
| 48 | curl_setopt($c, CURLOPT_HEADER, false); | ||
| 49 | $page_data = curl_exec($c); | ||
| 50 | curl_close($c); | ||
| 51 | |||
| 52 | if (stripos($page_data,$to) !== FALSE) | ||
| 53 | { | ||
| 54 | if (preg_match('/<TITLE>([^>]+)<\/TITLE>/i',$page_data,$matches)) | ||
| 55 | { | ||
| 56 | $title = $matches[1]; | ||
| 57 | } else { | ||
| 58 | $title = $from; | ||
| 59 | } | ||
| 60 | |||
| 61 | $text = substr($page_data,(stripos($page_data,$to)-300),700); | ||
| 62 | $text = strip_tags($text); | ||
| 63 | $text = str_replace("\n",' ',$text); | ||
| 64 | |||
| 65 | $commentText = "[url=" . $from . "]" . $title . "[/url]\n\n[....] " . $text . " [....]"; | ||
| 66 | |||
| 67 | $getping = "SELECT * FROM comments WHERE page_id = \"updates-" . $getpost3['id'] . "\" AND comment = \"" . addslashes($commentText) . "\""; | ||
| 68 | $getping2 = mysql_query($getping); | ||
| 69 | $getping3 = mysql_fetch_array($getping2); | ||
| 70 | |||
| 71 | if ($getping3['comment'] == $commentText) | ||
| 72 | { | ||
| 73 | return new xmlrpcresp(0, 48, "Target uri cannot be used as target"); | ||
| 74 | } else { | ||
| 75 | $insping = "INSERT INTO comments (page_id,username,comment) VALUES (\"updates-" . $getpost3['id'] . "\",\"Pingback\",\"" . $commentText . "\")"; | ||
| 76 | $insping2 = mysql_query($insping); | ||
| 77 | recalcPop($getpost3['id']); | ||
| 78 | |||
| 79 | return new xmlrpcresp(new xmlrpcval("YAY! Your Pingback has been registered!", "string")); | ||
| 80 | } | ||
| 81 | } else { | ||
| 82 | return new xmlrpcresp(0, 17, "Source uri does have link to target uri"); | ||
| 83 | } | ||
| 84 | } else { | ||
| 85 | return new xmlrpcresp(0, 32, "Target uri does not exist"); | ||
| 86 | } | ||
| 87 | } else { | ||
| 88 | return new xmlrpcresp(0, 33, "Target uri cannot be used as target"); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | function rr($xmlrpcmsg) | ||
| 93 | { | ||
| 94 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
| 95 | } | ||
| 96 | |||
| 97 | $s = new xmlrpc_server(array( | ||
| 98 | "pingback.ping" => array("function" => "ping"), | ||
| 99 | "InstaDisc.checkRegistration" => array("function" => "rr"))); | ||
| 100 | |||
| 101 | ?> | ||
