Index: /branches/feature-module-zeus/data/downloads/module/mdl_zero/mdl_zeus.php
===================================================================
--- /branches/feature-module-zeus/data/downloads/module/mdl_zero/mdl_zeus.php	(revision 15410)
+++ /branches/feature-module-zeus/data/downloads/module/mdl_zero/mdl_zeus.php	(revision 15410)
@@ -0,0 +1,262 @@
+<?php
+/**
+ * 
+ * @copyright    2000-2007 LOCKON CO.,LTD. All Rights Reserved.
+ * @version CVS: $Id: 1.0 2006-06-04 06:38:01Z kakinaka $ 
+ * @link        http://www.lockon.co.jp/
+ *
+ */
+require_once(MODULE_PATH . "mdl_zeus/mdl_zeus.inc");
+
+//¥Ú¡¼¥¸´ÉÍý¥¯¥é¥¹
+class LC_Page {
+    //¥³¥ó¥¹¥È¥é¥¯¥¿
+    function LC_Page() {
+        //¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È¤Î»ØÄê
+        $this->tpl_mainpage = MODULE_PATH . 'mdl_zero/mdl_zero.tpl';
+        $this->tpl_subtitle = '¥¼¥í·èºÑ¥â¥¸¥å¡¼¥ë';
+    }
+}
+$objPage = new LC_Page();
+$objView = new SC_AdminView();
+$objQuery = new SC_Query();
+
+// ¥¯¥ì¥¸¥Ã¥È¥Á¥§¥Ã¥¯
+lfZeroCheck();
+
+// Ç§¾Ú³ÎÇ§
+$objSess = new SC_Session();
+sfIsSuccess($objSess);
+
+// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
+$objFormParam = new SC_FormParam();
+$objFormParam = lfInitParam($objFormParam);
+// POSTÃÍ¤Î¼èÆÀ
+$objFormParam->setParam($_POST);
+
+// ÈÆÍÑ¹àÌÜ¤òÄÉ²Ã(É¬¿Ü¡ª¡ª)
+sfAlterMemo();
+
+switch($_POST['mode']) {
+case 'edit':
+    // ÆþÎÏ¥¨¥é¡¼È½Äê
+    $objPage->arrErr = lfCheckError();
+
+    // ¥¨¥é¡¼¤Ê¤·¤Î¾ì¹ç¤Ë¤Ï¥Ç¡¼¥¿¤ò¹¹¿·    
+    if(count($objPage->arrErr) == 0) {
+        // ¥Ç¡¼¥¿¹¹¿·
+        lfUpdPaymentDB();
+        
+        // javascript¼Â¹Ô
+        $objPage->tpl_onload = 'alert("ÅÐÏ¿´°Î»¤·¤Þ¤·¤¿¡£\n´ðËÜ¾ðÊó¡ä»ÙÊ§ÊýË¡ÀßÄê¤è¤ê¾ÜºÙÀßÄê¤ò¤·¤Æ¤¯¤À¤µ¤¤¡£"); window.close();';
+    }
+    break;
+case 'module_del':
+    // ÈÆÍÑ¹àÌÜ¤ÎÂ¸ºß¥Á¥§¥Ã¥¯
+    if(sfColumnExists("dtb_payment", "memo01")){
+        // ¥Ç¡¼¥¿¤Îºï½ü¥Õ¥é¥°¤ò¤¿¤Æ¤ë
+        $objQuery->query("UPDATE dtb_payment SET del_flg = 1 WHERE module_id = ?", array(MDL_ZERO_ID));
+    }
+    break;
+default:
+    // ¥Ç¡¼¥¿¤Î¥í¡¼¥É
+    lfLoadData();    
+    break;
+}
+
+$objPage->arrForm = $objFormParam->getFormParamList();
+
+$objView->assignobj($objPage);                    //ÊÑ¿ô¤ò¥Æ¥ó¥×¥ì¡¼¥È¤Ë¥¢¥µ¥¤¥ó¤¹¤ë
+$objView->display($objPage->tpl_mainpage);        //¥Æ¥ó¥×¥ì¡¼¥È¤Î½ÐÎÏ
+//-------------------------------------------------------------------------------------------------------
+/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
+function lfInitParam($objFormParam) {
+    $objFormParam->addParam("PCÈÇ", "pc", INT_LEN, "n");
+    $objFormParam->addParam("²ÃÌÁÅ¹¥³¡¼¥É", "pc_send", SEND_LEN, "KVa", array("MAX_LENGTH_CHECK", "SPTAB_CHECK"));
+    $objFormParam->addParam("ÈÖÁÈ¥³¡¼¥É ", "pc_clientip", CLIENTIP_LEN, "KVa", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+
+    $objFormParam->addParam("·ÈÂÓÈÇ", "mobile", INT_LEN, "n");
+    $objFormParam->addParam("²ÃÌÁÅ¹¥³¡¼¥É", "mobile_send", SEND_LEN, "KVa", array("MAX_LENGTH_CHECK", "SPTAB_CHECK"));
+    $objFormParam->addParam("ÈÖÁÈ¥³¡¼¥É ", "mobile_clientip", CLIENTIP_LEN, "KVa", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
+    
+    return $objFormParam;
+}
+
+// ¥¨¥é¡¼¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
+function lfCheckError(){
+    global $objFormParam;
+    
+    $arrErr = $objFormParam->checkError();
+    
+    if($_POST["pc"]){
+        if(empty($_POST["pc_send"])) $arrErr["pc_send"] = "¢¨ ²ÃÌÁÅ¹¥³¡¼¥É ¤¬ÆþÎÏ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br>";
+        if(empty($_POST["pc_clientip"])) $arrErr["pc_clientip"] = "¢¨ ÈÖÁÈ¥³¡¼¥É ¤¬ÆþÎÏ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br>";
+    }
+
+    if($_POST["mobile"]){
+        if(empty($_POST["mobile_send"])) $arrErr["mobile_send"] = "¢¨ ²ÃÌÁÅ¹¥³¡¼¥É ¤¬ÆþÎÏ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br>";
+        if(empty($_POST["mobile_clientip"])) $arrErr["mobile_clientip"] = "¢¨ ÈÖÁÈ¥³¡¼¥É ¤¬ÆþÎÏ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br>";
+    }
+    
+    // ÀÜÂ³¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
+    if(count($arrErr) == 0) $arrErr = lfChkConnect();
+    
+    return $arrErr;
+}
+
+// ÀÜÂ³¥Á¥§¥Ã¥¯¤ò¹Ô¤¦
+function lfChkConnect(){
+    $arrRet = array();
+    
+    // PCÈÇ¤ÎÀÜÂ³³ÎÇ§
+    if($_POST["pc"]){
+        // Á÷¿®¥Ç¡¼¥¿À¸À®
+        $arrSendData = array(
+            'clientip' => $_POST["pc_clientip"],    // ÈÖÁÈ¥³¡¼¥É
+            'custom' => SEND_PARAM_CUSTOM,            // yes¸ÇÄê
+            'send' => $_POST["pc_send"],            // ²ÃÌÁÅ¹¥³¡¼¥É
+            'money' => 0                            // ¶â³Û
+        );
+/*
+        // ¥Ç¡¼¥¿Á÷¿®
+        $arrResponse = sfPostPaymentData(SEND_PARAM_PC_URL, $arrSendData, false);
+        
+        // ¥¨¥é¡¼¤¬¤¢¤ë¤«¥Á¥§¥Ã¥¯¤¹¤ë
+        if(!ereg("^<HTML>",$arrResponse )){
+            $arrRet["pc_clientip"] = "ÆþÎÏ¥Ç¡¼¥¿¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó<br>";
+        }
+*/
+    }
+
+    // ·ÈÂÓÈÇ¤ÎÀÜÂ³³ÎÇ§
+    if($_POST["mobile"]){
+        // Á÷¿®¥Ç¡¼¥¿À¸À®
+        $arrSendData = array(
+            'clientip' => $_POST["mobile_clientip"],    // ÈÖÁÈ¥³¡¼¥É
+            'act' => SEND_PARAM_ACT,                    // imode¸ÇÄê
+            'money' => 0                                // ¶â³Û
+        );
+/*        
+        // ¥Ç¡¼¥¿Á÷¿®
+        $arrResponse = sfPostPaymentData(SEND_PARAM_MOBILE_URL, $arrSendData, false);
+        
+        // ¥¨¥é¡¼¤¬¤¢¤ë¤«¥Á¥§¥Ã¥¯¤¹¤ë
+        if(!ereg("^<HTML>",$arrResponse )){
+            $arrRet["mobile_clientip"] = "ÆþÎÏ¥Ç¡¼¥¿¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó<br>";
+        }
+*/
+    }
+    
+    return $arrRet;    
+}
+
+// ÅÐÏ¿¥Ç¡¼¥¿¤òÆÉ¤ß¹þ¤à
+function lfLoadData(){
+    global $objFormParam;
+    
+    //¥Ç¡¼¥¿¤ò¼èÆÀ
+    $arrRet = lfGetPaymentDB(" AND del_flg = '0'");
+    
+    // ÃÍ¤ò¥»¥Ã¥È
+    $objFormParam->setParam($arrRet[0]);
+
+    // ²èÌÌÉ½¼¨ÍÑ¤Ë¥Ç¡¼¥¿¤òÊÑ´¹
+    $arrDisp = array();
+    $arrDisp = $arrRet[0];
+    if (!empty($arrDisp["pc_send"])) $arrDisp["pc"] = 1;
+    if (!empty($arrDisp["mobile_send"])) $arrDisp["mobile"] = 1;
+    $objFormParam->setParam($arrDisp);
+}
+
+// DB¤«¤é¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë
+function lfGetPaymentDB($where = "", $arrWhereVal = array()){
+    global $objQuery;
+    
+    $arrVal = array(MDL_ZEUS_ID);
+    $arrVal = array_merge($arrVal, $arrWhereVal);
+    
+    $arrRet = array();
+    $sql = "SELECT 
+                module_id, 
+                memo01 as pc_send, 
+                memo02 as pc_clientip,
+                memo04 as mobile_send, 
+                memo05 as mobile_clientip
+            FROM dtb_payment WHERE module_id = ? " . $where;
+    $arrRet = $objQuery->getall($sql, $arrVal);
+
+    return $arrRet;
+}
+
+
+// ¥Ç¡¼¥¿¤Î¹¹¿·½èÍý
+function lfUpdPaymentDB(){
+    global $objQuery;
+    global $objSess;
+    $arrData = array();
+
+    // del_flg¤òºï½ü¤Ë¤·¤Æ¤ª¤¯
+    $del_sql = "UPDATE dtb_payment SET del_flg = 1 WHERE module_id = ? ";
+    $arrDel = array(MDL_ZEUS_ID);
+    $objQuery->query($del_sql, $arrDel);
+
+    // PCÍÑ¥Ç¡¼¥¿ÅÐÏ¿
+    if($_POST["pc"]){
+		$arrData["payment_method"] = "Zero¥¯¥ì¥¸¥Ã¥È";
+		$arrData["fix"] = 3;
+		$arrData["creator_id"] = $objSess->member_id;
+		$arrData["update_date"] = "now()";
+		$arrData["module_id"] = MDL_ZEUS_ID;
+		$arrData["module_path"] = MODULE_PATH . "mdl_zeus/zeus_credit.php";
+		$arrData["memo01"] = $_POST["pc_send"];
+		$arrData["memo02"] = $_POST["pc_clientip"];
+		$arrData["memo03"] = ZERO_CREDIT_ID;
+		$arrData["del_flg"] = "0";
+    }
+    
+    // ·ÈÂÓÍÑ¥Ç¡¼¥¿ÅÐÏ¿
+    if($_POST["mobile"]){
+		$arrData["payment_method"] = "Zero¥¯¥ì¥¸¥Ã¥È";
+		$arrData["fix"] = 3;
+		$arrData["creator_id"] = $objSess->member_id;
+		$arrData["update_date"] = "now()";
+		$arrData["module_id"] = MDL_ZEUS_ID;
+		$arrData["module_path"] = MODULE_PATH . "mdl_zeus/zeus_credit.php";
+		$arrData["memo03"] = ZERO_CREDIT_ID;
+		$arrData["memo04"] = $_POST["mobile_send"];
+		$arrData["memo05"] = $_POST["mobile_clientip"];
+		$arrData["del_flg"] = "0";
+    }
+    
+    // ¹¹¿·¥Ç¡¼¥¿¤¬¤¢¤ì¤Ð¹¹¿·¤¹¤ë¡£
+    if(count($arrData) > 0){
+	    // ¥é¥ó¥¯¤ÎºÇÂçÃÍ¤ò¼èÆÀ¤¹¤ë
+	    $max_rank = $objQuery->getone("SELECT max(rank) FROM dtb_payment");
+	    
+	    // »ÙÊ§ÊýË¡¥Ç¡¼¥¿¤ò¼èÆÀ
+	    $arrPaymentData = lfGetPaymentDB();
+	    
+	    // ¥Ç¡¼¥¿¤¬Â¸ºß¤·¤Æ¤¤¤ì¤ÐUPDATE¡¢Ìµ¤±¤ì¤ÐINSERT
+	    if(count($arrPaymentData) > 0){
+            $objQuery->update("dtb_payment", array("memo01"=>"","memo02"=>"","memo03"=>"","memo04"=>"","memo05"=>""), " module_id = '" . MDL_ZEUS_ID . "'");
+	        $objQuery->update("dtb_payment", $arrData, " module_id = '" . MDL_ZEUS_ID . "'");
+	    }else{
+	        $arrData["rank"] = $max_rank + 1;
+	        $objQuery->insert("dtb_payment", $arrData);
+	    }
+    }
+}
+
+
+function lfZeroCheck(){
+    if(!empty($_GET["clientip"])){
+        global $objPage;
+        global $objView;
+        global $objQuery;
+        require_once(MODULE_PATH . "mdl_zero/recv.php");
+        exit();
+    }
+}
+
+
+?>
