| [ PHPXref.com ] | [ Generated: Sun Jul 20 16:41:55 2008 ] | [ boastMachine 3.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 =========================== 5 6 boastMachine v3.1 7 Released : Sunday, June 5th 2005 ( 06/05/2005 ) 8 http://boastology.com 9 10 Developed by Kailash Nadh 11 Email : mail@kailashnadh.name 12 Website : http://kailashnadh.name, http://bnsoft.net 13 Blog : http://boastology.com/blog 14 15 boastMachine is a free software licensed under GPL (General public license) 16 17 =========================== 18 */ 19 20 21 include_once dirname(__FILE__)."/config.php"; 22 include_once dirname(__FILE__)."/$bmc_dir/main.php"; 23 24 25 //================== SEND TRACKBACKS ======================= 26 27 // This code works when the flag $send_track_back is set to true 28 // Only used while posting a new article 29 30 31 32 if(isset($send_track_back)) { 33 $urls=$_POST['track_urls']; 34 $urls=explode("\n", $urls); // The url list to be trackbacked 35 36 $title=urlencode($_POST['title']); 37 38 $excerpt=urlencode(substr($_POST['smr'],0,255)); // Cut the characters at 255 39 40 $blog_name=urlencode($i_blog['blog_name']); 41 $post_id=$db->query("SELECT last_insert_id() FROM ".MY_PRF."posts", false); // Id of the last post 42 43 $url=$bmc_vars['site_url']."/".BLOG_FILE."?id=".$post_id['last_insert_id()']; // The perma link for this post 44 $url=urlencode($url); 45 // Send pings! 46 for($n=0;$n<count($urls);$n++) { 47 48 // Get the host url, parse it and take out the domain and the path 49 $the_host=$urls[$n]; 50 $the_host=str_replace("http://","",$the_host); 51 $the_host=str_replace("https://","",$the_host); 52 $the_host=explode("/",$the_host); 53 54 $host=trim($the_host[0]); // The host domain name 55 unset($the_host[0]); 56 $path="/".trim(implode("/",$the_host)); // The path 57 58 if(!empty($path) && !empty($host)) { 59 $query = "title=$title&url=$url&excerpt=$excerpt&blog_name=$blog_name"; 60 $fp = fsockopen("$host", 80, $errnum, $errstr, 30); // Send the ping 61 if($fp) { 62 fputs($fp, "POST {$path} HTTP/1.1\r\n"); 63 fputs($fp, "Host: {$host}\r\n"); 64 fputs($fp, "Content-type: application/x-www-form-urlencoded; charset=\"{$lang['ENCODING']}\"\r\n"); 65 fputs($fp, "User-Agent: boastMachine ".BMC_VERSION."\r\n"); 66 fputs($fp, "Content-length: ".strlen($query)."\r\n"); 67 fputs($fp, "Connection: close\r\n\r\n"); 68 fputs($fp, $query."\r\n\r\n"); 69 fclose($fp); 70 } 71 } 72 } 73 74 return 1; 75 } 76 77 //================== ACCEPTING TRACKBACKS ======================= 78 79 80 $vars=explode("/", $_SERVER['REQUEST_URI']); // The URI (path) 81 $post_id=$vars[count($vars)-1]; 82 $blog_id=$vars[count($vars)-2]; 83 84 // Get the blog/post ids from the trackback uri 85 86 if(!$bmc_vars['trackbacks']) { 87 bmc_trackback_respond(1,"Trackbacks disabled"); 88 } 89 90 91 $track_blog=$db->query("SELECT id FROM ".MY_PRF."blogs WHERE frozen='0' AND id='{$blog_id}'", false); 92 $track_post=$db->query("SELECT id FROM ".MY_PRF."posts WHERE accept_trackback='1' AND status ='1' AND blog='{$track_blog['id']}' AND id='{$post_id}'", false); 93 94 if(!isset($track_post['id'])) { 95 bmc_trackback_respond(1,"Invalid target post"); 96 } 97 98 // Empty parameters 99 if(!$post_id || !is_numeric($post_id) || !$blog_id || !is_numeric($blog_id)) { 100 bmc_trackback_respond(1,"Missing post info"); 101 } 102 103 // Get the posted variables 104 if(!empty($_REQUEST)) { 105 if(empty($_REQUEST['title']) || empty($_REQUEST['url'])) { 106 bmc_trackback_respond(1,"Missing required fields"); 107 } 108 } else { 109 bmc_trackback_respond(1,"Missing required fields"); 110 } 111 112 // Get the source charset 113 preg_match_all ("/\"(.*?)\"/", $_SERVER['CONTENT_TYPE'], $charset); 114 $charset=ereg_replace("[^[:space:]a-zA-Z0-9\-]", "", $charset[1][0]); 115 116 $title=substr(mb_convert_encoding($_REQUEST['title'],$lang['ENCODING'],$charset),0,75); // Cut the characters at 75 117 $url=mb_convert_encoding($_REQUEST['url'],$lang['ENCODING'],$charset); 118 119 120 // The excerpt ( summary ) 121 if(!empty($_REQUEST['excerpt'])) { 122 $excerpt=substr(mb_convert_encoding($_REQUEST['excerpt'],$lang['ENCODING'],$charset),0,400); // Cut the characters at 400 123 } else { 124 $excerpt=$title; 125 } 126 127 // Check for spam (3.1) 128 bmc_filterSpam($title); 129 bmc_filterSpam($excerpt); 130 131 132 // The blog name 133 if(!empty($_REQUEST['blog_name'])) { 134 $blog_name=substr(mb_convert_encoding($_REQUEST['blog_name'],$lang['ENCODING'],$charset),0,75); 135 } else { 136 $blog_name=""; 137 } 138 139 // Save the data 140 $db->query("INSERT INTO ".MY_PRF."trackbacks (title,url,excerpt,blog_name,date,post) VALUES('{$title}','{$url}','{$excerpt}','{$blog_name}','".time()."','{$track_post['id']}')"); 141 142 // Send the response 143 bmc_trackback_respond(1, "Ping accepted"); 144 145 // Trackback reception ends here! 146 //==================================================== 147 148 149 150 151 //============ Function to send response in XML format 152 153 function bmc_trackback_respond($error=0,$text="") { 154 global $lang; 155 156 $fp=fopen(CFG_ROOT."/inc/vars/track.log", "w+"); 157 fputs($fp, serialize($_REQUEST)); 158 fclose($fp); 159 160 161 header("Content-type: text/xml\n\n"); // XML header 162 echo <<<EOF 163 <?xml version="1.0" encoding="{$lang['ENCODING']}"?> 164 <response> 165 <error>$error</error> 166 <message>$text</message> 167 </response> 168 EOF; 169 exit; 170 } 171 172 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |