source: branches/version-2_5-dev/data/class/pages/admin/system/LC_Page_Admin_System_AdminArea.php @ 20116

Revision 20116, 7.7 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * 店舗基本情報 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_System_AdminArea extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'system/adminarea.tpl';
47        $this->tpl_subnavi = 'system/subnavi.tpl';
48        $this->tpl_subno = 'adminarea';
49        $this->tpl_mainno = 'adminarea';
50        $this->tpl_subtitle = '管理画面設定';
51        $this->tpl_enable_ssl = FALSE;
52        if(strpos(HTTPS_URL,"https://") !== FALSE){
53            $this->tpl_enable_ssl = TRUE;
54        }
55    }
56
57    /**
58     * Page のプロセス.
59     *
60     * @return void
61     */
62    function process() {
63        $this->action();
64        $this->sendResponse();
65    }
66
67    /**
68     * Page のアクション.
69     *
70     * @return void
71     */
72    function action() {
73        $objSess = new SC_Session();
74
75        // 認証可否の判定
76        SC_Utils_Ex::sfIsSuccess($objSess);
77
78        if(count($_POST) >= 1 ) {
79            // POSTデータの引き継ぎ
80            $this->arrForm = $_POST;
81
82            // 入力データの変換
83            $this->arrForm = $this->lfConvertParam($this->arrForm);
84            // 入力データのエラーチェック
85            $this->arrErr = $this->lfErrorCheck($this->arrForm);
86            //設定ファイルの権限チェック
87            if(!is_writable(CONFIG_REALFILE)){
88                $this->arrErr["all"] = CONFIG_REALFILE . ' を変更する権限がありません。';
89            }
90            //管理画面ディレクトリのチェック
91            $this->lfCheckAdminArea($this->arrForm);
92
93            if(count($this->arrErr) == 0) {
94                $this->lfUpdateAdminData($this->arrForm);   // 既存編集
95                $this->tpl_onload = "window.alert('管理機能の設定を変更しました。URLを変更した場合は、新しいURLにアクセスしてください。');";
96            }else{
97                $this->tpl_onload = "window.alert('設定内容に誤りがあります。設定内容を確認してください。');";               
98            }
99        } else {
100            $admin_dir = str_replace("/","",ADMIN_DIR);
101            $this->arrForm = array("admin_dir"=>$admin_dir,"admin_force_ssl"=>ADMIN_FORCE_SSL,"admin_allow_hosts"=>"");
102            if(defined("ADMIN_ALLOW_HOSTS")){
103                $allow_hosts = unserialize(ADMIN_ALLOW_HOSTS);
104                $this->arrForm["admin_allow_hosts"] = implode("\n",$allow_hosts);
105            }
106        }
107    }
108
109    /**
110     * デストラクタ.
111     *
112     * @return void
113     */
114    function destroy() {
115        parent::destroy();
116    }
117   
118   
119   
120    //管理機能ディレクトリのチェック
121    function lfCheckAdminArea($array){
122        $admin_dir = trim($array['admin_dir'])."/";
123
124        $installData = file(CONFIG_REALFILE, FILE_IGNORE_NEW_LINES);
125        foreach($installData as $key=>$line){
126            if(strpos($line,"ADMIN_DIR") !== false and ADMIN_DIR != $admin_dir){
127                //既存ディレクトリのチェック
128                if(file_exists(HTML_REALDIR.$admin_dir) and $admin_dir != "admin/"){
129                    $this->arrErr["admin_dir"] .= ROOT_URLPATH.$admin_dir."は既に存在しています。別のディレクトリ名を指定してください。";
130                }
131                //権限チェック
132                if(!is_writable(HTML_REALDIR . ADMIN_DIR)){
133                    $this->arrErr["admin_dir"] .= ROOT_URLPATH.ADMIN_DIR."のディレクトリ名を変更する権限がありません。";
134                }
135            }
136        }
137    }
138
139   
140    //管理機能ディレクトリのリネームと CONFIG_REALFILE の変更
141    function lfUpdateAdminData($array){
142        $admin_dir = trim($array['admin_dir'])."/";
143        $admin_force_ssl = "FALSE";
144        if($array['admin_force_ssl'] == 1){
145            $admin_force_ssl = "TRUE";
146        }
147        $admin_allow_hosts = explode("\n",$array['admin_allow_hosts']);
148        foreach($admin_allow_hosts as $key=>$host){
149            $host = trim($host);
150            if(strlen($host) >= 8){
151                $admin_allow_hosts[$key] = $host;
152            }else{
153                unset($admin_allow_hosts[$key]);
154            }
155        }
156        $admin_allow_hosts = serialize($admin_allow_hosts);
157
158        // CONFIG_REALFILE の書き換え
159        $installData = file(CONFIG_REALFILE, FILE_IGNORE_NEW_LINES);
160        $diff = 0;
161        foreach($installData as $key=>$line){
162            if(strpos($line,"ADMIN_DIR") !== false and ADMIN_DIR != $admin_dir){
163                $installData[$key] = 'define("ADMIN_DIR","'.$admin_dir.'");';
164                //管理機能ディレクトリのリネーム
165                rename(HTML_REALDIR.ADMIN_DIR,HTML_REALDIR.$admin_dir);
166                $diff ++;
167            }
168           
169            if(strpos($line,"ADMIN_FORCE_SSL") !== false){
170                $installData[$key] = 'define("ADMIN_FORCE_SSL",'.$admin_force_ssl.');';
171                $diff ++;
172            }
173            if(strpos($line,"ADMIN_ALLOW_HOSTS") !== false and ADMIN_ALLOW_HOSTS != $admin_allow_hosts) {
174                $installData[$key] = "define('ADMIN_ALLOW_HOSTS','".$admin_allow_hosts."');";
175                $diff ++;
176            }
177        }
178       
179        if($diff > 0) {
180            $fp = fopen(CONFIG_REALFILE,"wb");
181            $installData = implode("\n",$installData);
182            echo $installData;
183            fwrite($fp, $installData);
184            fclose($fp);
185        }
186        return true;
187    }
188
189    /* 取得文字列の変換 */
190    function lfConvertParam($array) {
191        /*
192         *  文字列の変換
193         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
194         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
195         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
196         *  n :  「全角」数字を「半角(ハンカク)」に変換
197         *  a :  全角英数字を半角英数字に変換する
198         */
199        $arrConvList = array('admin_dir'=>"a",'admin_force_ssl' => "n",'admin_allow_hosts' => "a");
200        return SC_Utils_Ex::mbConvertKanaWithArray($array, $arrConvList);
201    }
202
203    // 入力エラーチェック
204    function lfErrorCheck($array) {
205        $objErr = new SC_CheckError($array);
206
207        //管理機能設定チェック
208        $objErr->doFunc(array('ディレクトリ名', "admin_dir", ID_MAX_LEN) ,array("EXIST_CHECK","SPTAB_CHECK", "ALNUM_CHECK"));
209        $objErr->doFunc(array('SSL制限', "admin_force_ssl", 1) ,array("NUM_CHECK", "MAX_LENGTH_CHECK"));
210        $objErr->doFunc(array('IP制限', "admin_allow_hosts", LTEXT_LEN) ,array("IP_CHECK", "MAX_LENGTH_CHECK"));
211        return $objErr->arrErr;
212    }
213}
214?>
Note: See TracBrowser for help on using the repository browser.