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

Revision 11955, 5.4 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    // TODO:URL¤Ïɬ¿Ü¡¢¤µ¤é¤ËGET¤Ç¤Î¶õ¥¢¥¯¥»¥¹¤òÀ©¸æ(livedoor blog)
48    exit();
49}
50
51// ¥Ö¥í¥°µ­»ö¥¿¥¤¥È¥ë
52if (isset($_POST["title"])) {
53    $arrData["title"] = trim(mb_convert_encoding($_POST["title"], $afterEncode, $beforeEncode));
54} else if (isset($_GET["title"])) {
55    $arrData["title"] = trim(mb_convert_encoding($_GET["title"], $afterEncode, $beforeEncode));
56}
57
58// ¥Ö¥í¥°µ­»öÆâÍÆ
59if (isset($_POST["excerpt"])) {
60    $arrData["excerpt"] = trim(mb_convert_encoding($_POST["excerpt"], $afterEncode, $beforeEncode));
61} else if (isset($_GET["excerpt"])) {
62    $arrData["excerpt"] = trim(mb_convert_encoding($_GET["excerpt"], $afterEncode, $beforeEncode));
63}
64
65$log_path = DATA_PATH . "logs/tb_result.log";
66gfPrintLog("s1--------------------", $log_path);
67foreach($arrData as $key => $val) {
68    gfPrintLog( "\t" . $key . " => " . $val, $log_path);
69}
70gfPrintLog("s1--------------------", $log_path);
71
72$objFormParam->setParam($arrData);
73
74// ÆþÎÏʸ»ú¤ÎÊÑ´¹
75$objFormParam->convParam();
76$arrData = $objFormParam->getHashArray();
77
78// ¥¨¥é¡¼¥Á¥§¥Ã¥¯(¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¤¬À®¤êΩ¤¿¤Ê¤¤¤Î¤Ç¡¢URL°Ê³°¤âɬ¿Ü¤È¤¹¤ë)
79gfPrintLog("--- ERROR CHECK START ---", $log_path);
80$objPage->arrErr = lfCheckError();
81gfPrintLog("--- ERROR CHECK FINISH ---", $log_path);
82gfPrintLog("--- ERROR COUNT : " . count($objPage->arrErr), $log_path);
83
84// ¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç¤Ï¥Ç¡¼¥¿¤ò¹¹¿·
85if(count($objPage->arrErr) == 0) {
86   
87    // ¾¦ÉÊ¥³¡¼¥É¤Î¼èÆÀ(GET)
88    if (isset($_GET["pid"])) {
89        $product_id = $_GET["pid"];
90
91        gfPrintLog("--- PRODUCT ID : " . $product_id, $log_path);
92
93        // ¾¦Éʥǡ¼¥¿¤Î¸ºß³Îǧ
94        $table = "dtb_products";
95        $where = "product_id = ?";
96
97        // ¾¦Éʥǡ¼¥¿¤¬Â¸ºß¤¹¤ë¾ì¹ç¤Ï¥È¥é¥Ã¥¯¥Ð¥Ã¥¯¥Ç¡¼¥¿¤Î¹¹¿·
98        if (sfDataExists($table, $where, array($product_id))) {
99            $arrData["product_id"] = $product_id;
100           
101            // ¥Ç¡¼¥¿¤Î¹¹¿·
102            if (lfEntryTrackBack($arrData) == 1) {
103                IfResponseOk();
104            }
105        } else {
106            gfPrintLog("--- PRODUCT NOT EXISTS : " . $product_id, $log_path);
107        }
108    }
109}
110
111// NG
112IfResponseNg();
113exit();
114
115//----------------------------------------------------------------------------------------------------
116
117/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
118function lfInitParam() {
119    global $objFormParam;
120    $objFormParam->addParam("URL", "url", URL_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
121    $objFormParam->addParam("¥Ö¥í¥°¥¿¥¤¥È¥ë", "blog_name", MTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
122    $objFormParam->addParam("µ­»ö¥¿¥¤¥È¥ë", "title", MTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
123    $objFormParam->addParam("µ­»öÆâÍÆ", "excerpt", MLTEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
124}
125
126/* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */
127function lfCheckError() {
128    global $objFormParam;
129   
130    // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£
131    $arrRet =  $objFormParam->getHashArray();
132    $objErr = new SC_CheckError($arrRet);
133    $objErr->arrErr = $objFormParam->checkError();
134   
135    return $objErr->arrErr;
136}
137
138/* ¹¹¿·½èÍý */
139function lfEntryTrackBack($arrData) {
140    global $objQuery;
141
142    // ¥í¥°
143    $log_path = DATA_PATH . "logs/tb_result.log";
144
145    // ¥¹¥Ñ¥à¥Õ¥£¥ë¥¿¡¼
146    if (lfSpamFilter($arrData)) {
147        $arrData["status"] = TRACKBACK_STATUS_NOT_VIEW;
148    } else {
149        $arrData["status"] = TRACKBACK_STATUS_SPAM;
150    }
151
152    $arrData["create_date"] = "now()";
153    $arrData["update_date"] = "now()";
154
155    gfPrintLog("e--------------------", $log_path);
156    foreach($arrData as $key => $val) {
157        gfPrintLog( "\t" . $key . " => " . $val, $log_path);
158    }
159    gfPrintLog("e--------------------", $log_path);
160
161    // ¥Ç¡¼¥¿¤ÎÅÐÏ¿
162    $table = "dtb_trackback";
163    $ret = $objQuery->insert($table, $arrData);
164
165    gfPrintLog("INSERT RESULT : " . $ret, $log_path);
166    return $ret;
167}
168
169/* ¥¹¥Ñ¥à¥Õ¥£¥ë¥¿¡¼ */
170function lfSpamFilter($arrData, $run = false) {
171    $ret = true;
172   
173    // ¥Õ¥£¥ë¥¿¡¼½èÍý
174    if ($run) {
175    }
176    return $ret;
177}
178
179// OK¥ì¥¹¥Ý¥ó¥¹¤òÊÖ¤¹
180function IfResponseOk() {
181    header("Content-type: text/xml");
182    print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
183    print("<response>");
184    print("<error>0</error>");
185    print("</response>");
186    exit();
187}
188
189// NG¥ì¥¹¥Ý¥ó¥¹¤òÊÖ¤¹
190function IfResponseNg() {
191    header("Content-type: text/xml");
192    print("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
193    print("<response>");
194    print("<error>1</error>");
195    print("<message>The error message</message>");
196    print("</response>");
197    exit();
198}
199//-----------------------------------------------------------------------------------------------------------------------------------
200?>
Note: See TracBrowser for help on using the repository browser.