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

Revision 11968, 5.5 KB checked in by inoue, 15 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}
18
19// ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
20lfInitParam();
21
22// ¥¨¥ó¥³¡¼¥ÉÀßÄê(¥µ¡¼¥Ð´Ä¶­¤Ë¤è¤Ã¤ÆÊѹ¹)
23$beforeEncode = "auto";
24$afterEncode = mb_internal_encoding();
25
26if (isset($_POST["charset"])) {
27    $beforeEncode = $_POST["charset"];
28} else if (isset($_GET["charset"])) {
29    $beforeEncode = $_GET["charset"];
30}
31
32// POST¥Ç¡¼¥¿¤Î¼èÆÀ¤È¥¨¥ó¥³¡¼¥ÉÊÑ´¹
33
34// ¥Ö¥í¥°Ì¾
35if (isset($_POST["blog_name"])) {
36    $arrData["blog_name"] = trim(mb_convert_encoding($_POST["blog_name"], $afterEncode, $beforeEncode));
37} else if (isset($_GET["blog_name"])) {
38    $arrData["blog_name"] = trim(mb_convert_encoding($_GET["blog_name"], $afterEncode, $beforeEncode));
39}
40
41// ¥Ö¥í¥°µ­»öURL
42if (isset($_POST["url"])) {
43    $arrData["url"] = trim(mb_convert_encoding($_POST["url"], $afterEncode, $beforeEncode));
44} else if (isset($_GET["url"])) {
45    $arrData["url"] = trim(mb_convert_encoding($_GET["url"], $afterEncode, $beforeEncode));
46} else {
47    /*
48     * TODO:¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¼õ¿®¤Îɸ½à²½¤ò·è¤á¤ë
49     * RSSÌÜŪ¤Ç¤Ï¤Ê¤¤GET¥ê¥¯¥¨¥¹¥È¤òÀ©¸æ(livedoor blog)
50     * _rss¥Ñ¥é¥á¡¼¥¿¤Ç¤ÎGET¥ê¥¯¥¨¥¹¥È¤òÀ©¸æ(Yahoo blog)
51     */
52    exit();
53}
54
55// ¥Ö¥í¥°µ­»ö¥¿¥¤¥È¥ë
56if (isset($_POST["title"])) {
57    $arrData["title"] = trim(mb_convert_encoding($_POST["title"], $afterEncode, $beforeEncode));
58} else if (isset($_GET["title"])) {
59    $arrData["title"] = trim(mb_convert_encoding($_GET["title"], $afterEncode, $beforeEncode));
60}
61
62// ¥Ö¥í¥°µ­»öÆâÍÆ
63if (isset($_POST["excerpt"])) {
64    $arrData["excerpt"] = trim(mb_convert_encoding($_POST["excerpt"], $afterEncode, $beforeEncode));
65} else if (isset($_GET["excerpt"])) {
66    $arrData["excerpt"] = trim(mb_convert_encoding($_GET["excerpt"], $afterEncode, $beforeEncode));
67}
68
69$log_path = DATA_PATH . "logs/tb_result.log";
70gfPrintLog("s1--------------------", $log_path);
71foreach($arrData as $key => $val) {
72    gfPrintLog( "\t" . $key . " => " . $val, $log_path);
73}
74gfPrintLog("s1--------------------", $log_path);
75
76$objFormParam->setParam($arrData);
77
78// ÆþÎÏʸ»ú¤ÎÊÑ´¹
79$objFormParam->convParam();
80$arrData = $objFormParam->getHashArray();
81
82// ¥¨¥é¡¼¥Á¥§¥Ã¥¯(¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¤¬À®¤êΩ¤¿¤Ê¤¤¤Î¤Ç¡¢URL°Ê³°¤âɬ¿Ü¤È¤¹¤ë)
83gfPrintLog("--- ERROR CHECK START ---", $log_path);
84$objPage->arrErr = lfCheckError();
85gfPrintLog("--- ERROR CHECK FINISH ---", $log_path);
86gfPrintLog("--- ERROR COUNT : " . count($objPage->arrErr), $log_path);
87
88// ¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç¤Ï¥Ç¡¼¥¿¤ò¹¹¿·
89if(count($objPage->arrErr) == 0) {
90   
91    // ¾¦ÉÊ¥³¡¼¥É¤Î¼èÆÀ(GET)
92    if (isset($_GET["pid"])) {
93        $product_id = $_GET["pid"];
94
95        gfPrintLog("--- PRODUCT ID : " . $product_id, $log_path);
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/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
122function lfInitParam() {
123    global $objFormParam;
124    $objFormParam->addParam("URL", "url", URL_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
125    $objFormParam->addParam("¥Ö¥í¥°¥¿¥¤¥È¥ë", "blog_name", MTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
126    $objFormParam->addParam("µ­»ö¥¿¥¤¥È¥ë", "title", MTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
127    $objFormParam->addParam("µ­»öÆâÍÆ", "excerpt", MLTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
128}
129
130/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
131function lfCheckError() {
132    global $objFormParam;
133   
134    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
135    $arrRet =  $objFormParam->getHashArray();
136    $objErr = new SC_CheckError($arrRet);
137    $objErr->arrErr = $objFormParam->checkError();
138   
139    return $objErr->arrErr;
140}
141
142/* ¹¹¿·½èÍý */
143function lfEntryTrackBack($arrData) {
144    global $objQuery;
145
146    // ¥í¥°
147    $log_path = DATA_PATH . "logs/tb_result.log";
148
149    // ¥¹¥Ñ¥à¥Õ¥£¥ë¥¿¡¼
150    if (lfSpamFilter($arrData)) {
151        $arrData["status"] = TRACKBACK_STATUS_NOT_VIEW;
152    } else {
153        $arrData["status"] = TRACKBACK_STATUS_SPAM;
154    }
155
156    $arrData["create_date"] = "now()";
157    $arrData["update_date"] = "now()";
158
159    gfPrintLog("e--------------------", $log_path);
160    foreach($arrData as $key => $val) {
161        gfPrintLog( "\t" . $key . " => " . $val, $log_path);
162    }
163    gfPrintLog("e--------------------", $log_path);
164
165    // ¥Ç¡¼¥¿¤ÎÅÐÏ¿
166    $table = "dtb_trackback";
167    $ret = $objQuery->insert($table, $arrData);
168
169    gfPrintLog("INSERT RESULT : " . $ret, $log_path);
170    return $ret;
171}
172
173/* ¥¹¥Ñ¥à¥Õ¥£¥ë¥¿¡¼ */
174function lfSpamFilter($arrData, $run = false) {
175    $ret = true;
176   
177    // ¥Õ¥£¥ë¥¿¡¼½èÍý
178    if ($run) {
179    }
180    return $ret;
181}
182
183// OK¥ì¥¹¥Ý¥ó¥¹¤òÊÖ¤¹
184function IfResponseOk() {
185    header("Content-type: text/xml");
186    print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
187    print("<response>");
188    print("<error>0</error>");
189    print("</response>");
190    exit();
191}
192
193// NG¥ì¥¹¥Ý¥ó¥¹¤òÊÖ¤¹
194function IfResponseNg() {
195    header("Content-type: text/xml");
196    print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
197    print("<response>");
198    print("<error>1</error>");
199    print("<message>The error message</message>");
200    print("</response>");
201    exit();
202}
203//-----------------------------------------------------------------------------------------------------------------------------------
204?>
Note: See TracBrowser for help on using the repository browser.