source: branches/dev/html/tb/index.php @ 12036

Revision 12036, 6.4 KB checked in by inoue, 17 years ago (diff)

不要ログを削除

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