| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | /* |
|---|
| 9 | * ¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¼õ¿® |
|---|
| 10 | * |
|---|
| 11 | * [1]¤Ê¤ë¤Ù¤¯Â¿¤¯¤Î¥Ö¥í¥°¤ËÂбþ¤Ç¤¤ë¤è¤¦¤Ë¡¢GET/POST ¤Ë´Ø¤ï¤é¤º¼õ¿®¤¹¤ë |
|---|
| 12 | * [2]RSS¤ÎÍ×µá¤ÏGET¤Ç__mode¥Ñ¥é¥á¡¼¥¿¤¬rss¤Î¾ì¹ç¤Î¤ßÂбþ¤¹¤ë(¾¦ÉʾðÊó¤òÊÖ¤¹) |
|---|
| 13 | * [3]ʸ»ú¥³¡¼¥É¤Ï»ØÄ꤬¤Ê¤±¤ì¤Ðauto¤ÇÂбþ¤¹¤ë |
|---|
| 14 | * [4]¥¹¥Ñ¥à¤Ï¡¢¥ª¥ê¥¸¥Ê¥ë(¹¥¤ß)¤Î¥¢¥ë¥´¥ê¥º¥à¤ÇÂбþ¤Ç¤¤ë¤è¤¦¤Ë¤·¤Æ¤ª¤¯ |
|---|
| 15 | */ |
|---|
| 16 | |
|---|
| 17 | require_once("../require.php"); |
|---|
| 18 | |
|---|
| 19 | $objQuery = new SC_Query(); |
|---|
| 20 | $objFormParam = new SC_FormParam(); |
|---|
| 21 | |
|---|
| 22 | // ¥È¥é¥Ã¥¯¥Ð¥Ã¥¯µ¡Ç½¤Î²ÔƯ¾õ¶·¥Á¥§¥Ã¥¯ |
|---|
| 23 | if (sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) { |
|---|
| 24 | // NG |
|---|
| 25 | IfResponseNg(); |
|---|
| 26 | exit(); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ |
|---|
| 30 | lfInitParam(); |
|---|
| 31 | |
|---|
| 32 | // ¥¨¥ó¥³¡¼¥ÉÀßÄê(¥µ¡¼¥Ð´Ä¶¤Ë¤è¤Ã¤ÆÊѹ¹) |
|---|
| 33 | $beforeEncode = "auto"; |
|---|
| 34 | $afterEncode = mb_internal_encoding(); |
|---|
| 35 | |
|---|
| 36 | if (isset($_POST["charset"])) { |
|---|
| 37 | $beforeEncode = $_POST["charset"]; |
|---|
| 38 | } else if (isset($_GET["charset"])) { |
|---|
| 39 | $beforeEncode = $_GET["charset"]; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | // POST¥Ç¡¼¥¿¤Î¼èÆÀ¤È¥¨¥ó¥³¡¼¥ÉÊÑ´¹ |
|---|
| 43 | |
|---|
| 44 | // ¥Ö¥í¥°Ì¾ |
|---|
| 45 | if (isset($_POST["blog_name"])) { |
|---|
| 46 | $arrData["blog_name"] = trim(mb_convert_encoding($_POST["blog_name"], $afterEncode, $beforeEncode)); |
|---|
| 47 | } else if (isset($_GET["blog_name"])) { |
|---|
| 48 | $arrData["blog_name"] = trim(mb_convert_encoding($_GET["blog_name"], $afterEncode, $beforeEncode)); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | // ¥Ö¥í¥°µ»öURL |
|---|
| 52 | if (isset($_POST["url"])) { |
|---|
| 53 | $arrData["url"] = trim(mb_convert_encoding($_POST["url"], $afterEncode, $beforeEncode)); |
|---|
| 54 | } else if (isset($_GET["url"])) { |
|---|
| 55 | $arrData["url"] = trim(mb_convert_encoding($_GET["url"], $afterEncode, $beforeEncode)); |
|---|
| 56 | } else { |
|---|
| 57 | /* |
|---|
| 58 | * RSSÌÜŪ¤Ç¤Ï¤Ê¤¤GET¥ê¥¯¥¨¥¹¥È¤òÀ©¸æ(livedoor blog) |
|---|
| 59 | * _rss¥Ñ¥é¥á¡¼¥¿¤Ç¤ÎGET¥ê¥¯¥¨¥¹¥È¤òÀ©¸æ(Yahoo blog) |
|---|
| 60 | */ |
|---|
| 61 | if (isset($_GET["__mode"]) && isset($_GET["pid"])) { |
|---|
| 62 | if ($_GET["__mode"] == "rss") { |
|---|
| 63 | IfResponseRss($_GET["pid"]); |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | exit(); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | // ¥Ö¥í¥°µ»ö¥¿¥¤¥È¥ë |
|---|
| 70 | if (isset($_POST["title"])) { |
|---|
| 71 | $arrData["title"] = trim(mb_convert_encoding($_POST["title"], $afterEncode, $beforeEncode)); |
|---|
| 72 | } else if (isset($_GET["title"])) { |
|---|
| 73 | $arrData["title"] = trim(mb_convert_encoding($_GET["title"], $afterEncode, $beforeEncode)); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | // ¥Ö¥í¥°µ»öÆâÍÆ |
|---|
| 77 | if (isset($_POST["excerpt"])) { |
|---|
| 78 | $arrData["excerpt"] = trim(mb_convert_encoding($_POST["excerpt"], $afterEncode, $beforeEncode)); |
|---|
| 79 | } else if (isset($_GET["excerpt"])) { |
|---|
| 80 | $arrData["excerpt"] = trim(mb_convert_encoding($_GET["excerpt"], $afterEncode, $beforeEncode)); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | $log_path = DATA_PATH . "logs/tb_result.log"; |
|---|
| 84 | gfPrintLog("request data start -----", $log_path); |
|---|
| 85 | foreach($arrData as $key => $val) { |
|---|
| 86 | gfPrintLog( "\t" . $key . " => " . $val, $log_path); |
|---|
| 87 | } |
|---|
| 88 | gfPrintLog("request data end -----", $log_path); |
|---|
| 89 | |
|---|
| 90 | $objFormParam->setParam($arrData); |
|---|
| 91 | |
|---|
| 92 | // ÆþÎÏʸ»ú¤ÎÊÑ´¹ |
|---|
| 93 | $objFormParam->convParam(); |
|---|
| 94 | $arrData = $objFormParam->getHashArray(); |
|---|
| 95 | |
|---|
| 96 | // ¥¨¥é¡¼¥Á¥§¥Ã¥¯(¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¤¬À®¤êΩ¤¿¤Ê¤¤¤Î¤Ç¡¢URL°Ê³°¤âɬ¿Ü¤È¤¹¤ë) |
|---|
| 97 | $objPage->arrErr = lfCheckError(); |
|---|
| 98 | |
|---|
| 99 | // ¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç¤Ï¥Ç¡¼¥¿¤ò¹¹¿· |
|---|
| 100 | if(count($objPage->arrErr) == 0) { |
|---|
| 101 | |
|---|
| 102 | // ¾¦ÉÊ¥³¡¼¥É¤Î¼èÆÀ(GET) |
|---|
| 103 | if (isset($_GET["pid"])) { |
|---|
| 104 | $product_id = $_GET["pid"]; |
|---|
| 105 | |
|---|
| 106 | // ¾¦Éʥǡ¼¥¿¤Î¸ºß³Îǧ |
|---|
| 107 | $table = "dtb_products"; |
|---|
| 108 | $where = "product_id = ?"; |
|---|
| 109 | |
|---|
| 110 | // ¾¦Éʥǡ¼¥¿¤¬Â¸ºß¤¹¤ë¾ì¹ç¤Ï¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¥Ç¡¼¥¿¤Î¹¹¿· |
|---|
| 111 | if (sfDataExists($table, $where, array($product_id))) { |
|---|
| 112 | $arrData["product_id"] = $product_id; |
|---|
| 113 | |
|---|
| 114 | // ¥Ç¡¼¥¿¤Î¹¹¿· |
|---|
| 115 | if (lfEntryTrackBack($arrData) == 1) { |
|---|
| 116 | IfResponseOk(); |
|---|
| 117 | } |
|---|
| 118 | } else { |
|---|
| 119 | gfPrintLog("--- PRODUCT NOT EXISTS : " . $product_id, $log_path); |
|---|
| 120 | } |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | // NG |
|---|
| 125 | IfResponseNg(); |
|---|
| 126 | exit(); |
|---|
| 127 | |
|---|
| 128 | //---------------------------------------------------------------------------------------------------- |
|---|
| 129 | |
|---|
| 130 | /* |
|---|
| 131 | * ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ |
|---|
| 132 | * |
|---|
| 133 | * @param void ¤Ê¤· |
|---|
| 134 | * @return void ¤Ê¤· |
|---|
| 135 | */ |
|---|
| 136 | function lfInitParam() { |
|---|
| 137 | global $objFormParam; |
|---|
| 138 | $objFormParam->addParam("URL", "url", URL_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 139 | $objFormParam->addParam("¥Ö¥í¥°¥¿¥¤¥È¥ë", "blog_name", MTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 140 | $objFormParam->addParam("µ»ö¥¿¥¤¥È¥ë", "title", MTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 141 | $objFormParam->addParam("µ»öÆâÍÆ", "excerpt", MLTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | /* |
|---|
| 145 | * ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯ |
|---|
| 146 | * |
|---|
| 147 | * @param void ¤Ê¤· |
|---|
| 148 | * @return $objErr->arrErr ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸ |
|---|
| 149 | */ |
|---|
| 150 | function lfCheckError() { |
|---|
| 151 | global $objFormParam; |
|---|
| 152 | |
|---|
| 153 | // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£ |
|---|
| 154 | $arrRet = $objFormParam->getHashArray(); |
|---|
| 155 | $objErr = new SC_CheckError($arrRet); |
|---|
| 156 | $objErr->arrErr = $objFormParam->checkError(); |
|---|
| 157 | |
|---|
| 158 | return $objErr->arrErr; |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | /* |
|---|
| 162 | * ¹¹¿·½èÍý |
|---|
| 163 | * |
|---|
| 164 | * @param $arrData ¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¥Ç¡¼¥¿ |
|---|
| 165 | * @return $ret ·ë²Ì |
|---|
| 166 | */ |
|---|
| 167 | function lfEntryTrackBack($arrData) { |
|---|
| 168 | global $objQuery; |
|---|
| 169 | |
|---|
| 170 | // ¥í¥° |
|---|
| 171 | $log_path = DATA_PATH . "logs/tb_result.log"; |
|---|
| 172 | |
|---|
| 173 | // ¥¹¥Ñ¥à¥Õ¥£¥ë¥¿¡¼ |
|---|
| 174 | if (lfSpamFilter($arrData)) { |
|---|
| 175 | $arrData["status"] = TRACKBACK_STATUS_NOT_VIEW; |
|---|
| 176 | } else { |
|---|
| 177 | $arrData["status"] = TRACKBACK_STATUS_SPAM; |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | $arrData["create_date"] = "now()"; |
|---|
| 181 | $arrData["update_date"] = "now()"; |
|---|
| 182 | |
|---|
| 183 | if(!isset($arrData['url'])){ |
|---|
| 184 | $arrData['url'] = ''; |
|---|
| 185 | } |
|---|
| 186 | if(!isset($arrData['excerpt'])) |
|---|
| 187 | $arrData['excerpt'] = ''; |
|---|
| 188 | // ¥Ç¡¼¥¿¤ÎÅÐÏ¿ |
|---|
| 189 | $table = "dtb_trackback"; |
|---|
| 190 | $ret = $objQuery->insert($table, $arrData); |
|---|
| 191 | return $ret; |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | /* |
|---|
| 195 | * ¥¹¥Ñ¥à¥Õ¥£¥ë¥¿¡¼ |
|---|
| 196 | * |
|---|
| 197 | * @param $arrData ¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¥Ç¡¼¥¿ |
|---|
| 198 | * @param $run ¥Õ¥£¥ë¥¿¡¼¥Õ¥é¥°(true:»ÈÍѤ¹¤ë false:»ÈÍѤ·¤Ê¤¤) |
|---|
| 199 | * @return $ret ·ë²Ì |
|---|
| 200 | */ |
|---|
| 201 | function lfSpamFilter($arrData, $run = false) { |
|---|
| 202 | $ret = true; |
|---|
| 203 | |
|---|
| 204 | // ¥Õ¥£¥ë¥¿¡¼½èÍý |
|---|
| 205 | if ($run) { |
|---|
| 206 | } |
|---|
| 207 | return $ret; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | /* |
|---|
| 211 | * OK¥ì¥¹¥Ý¥ó¥¹¤òÊÖ¤¹ |
|---|
| 212 | * |
|---|
| 213 | * @param void ¤Ê¤· |
|---|
| 214 | * @return void ¤Ê¤· |
|---|
| 215 | */ |
|---|
| 216 | function IfResponseOk() { |
|---|
| 217 | header("Content-type: text/xml"); |
|---|
| 218 | print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"); |
|---|
| 219 | print("<response>"); |
|---|
| 220 | print("<error>0</error>"); |
|---|
| 221 | print("</response>"); |
|---|
| 222 | exit(); |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | /* |
|---|
| 226 | * NG¥ì¥¹¥Ý¥ó¥¹¤òÊÖ¤¹ |
|---|
| 227 | * |
|---|
| 228 | * @param void ¤Ê¤· |
|---|
| 229 | * @return void ¤Ê¤· |
|---|
| 230 | */ |
|---|
| 231 | function IfResponseNg() { |
|---|
| 232 | header("Content-type: text/xml"); |
|---|
| 233 | print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"); |
|---|
| 234 | print("<response>"); |
|---|
| 235 | print("<error>1</error>"); |
|---|
| 236 | print("<message>The error message</message>"); |
|---|
| 237 | print("</response>"); |
|---|
| 238 | exit(); |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | /* |
|---|
| 242 | * ¥È¥é¥Ã¥¯¥Ð¥Ã¥¯RSS¤òÊÖ¤¹ |
|---|
| 243 | * |
|---|
| 244 | * @param $product_id ¾¦ÉÊ¥³¡¼¥É |
|---|
| 245 | * @return void ¤Ê¤· |
|---|
| 246 | */ |
|---|
| 247 | function IfResponseRss($product_id) { |
|---|
| 248 | global $objQuery; |
|---|
| 249 | |
|---|
| 250 | $retProduct = $objQuery->select("*", "dtb_products", "product_id = ?", array($product_id)); |
|---|
| 251 | |
|---|
| 252 | if (count($retProduct) > 0) { |
|---|
| 253 | header("Content-type: text/xml"); |
|---|
| 254 | print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"); |
|---|
| 255 | print("<response>"); |
|---|
| 256 | print("<error>0</error>"); |
|---|
| 257 | print("<rss version=\"0.91\">"); |
|---|
| 258 | print("<channel>"); |
|---|
| 259 | print("<title>" . $retProduct[0]["name"] . "</title>"); |
|---|
| 260 | print("<link>"); |
|---|
| 261 | print(SITE_URL . "products/detail.php?product_id=" . $product_id); |
|---|
| 262 | print("</link>"); |
|---|
| 263 | print("<description>"); |
|---|
| 264 | print($retProduct[0]["main_comment"]); |
|---|
| 265 | print("</description>"); |
|---|
| 266 | print("<language>ja-jp</language>"); |
|---|
| 267 | print("</channel>"); |
|---|
| 268 | print("</rss>"); |
|---|
| 269 | print("</response>"); |
|---|
| 270 | exit(); |
|---|
| 271 | } |
|---|
| 272 | } |
|---|
| 273 | |
|---|
| 274 | //----------------------------------------------------------------------------------------------------------------------------------- |
|---|
| 275 | ?> |
|---|