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

Revision 21986, 7.4 KB checked in by h_yoshimoto, 12 years ago (diff)

#1909 SC_FormParamインスタンス生成時にExtendsを使用するように修正

  • 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
RevLine 
[19996]1<?php
2/*
3 * This file is part of EC-CUBE
4 *
[21867]5 * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved.
[19996]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
[20534]25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
[19996]26
27/**
28 * 店舗基本情報 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
[20116]32 * @version $Id$
[19996]33 */
[20345]34class LC_Page_Admin_System_AdminArea extends LC_Page_Admin_Ex {
[19996]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_subno = 'adminarea';
[20604]48        $this->tpl_mainno = 'system';
[20911]49        $this->tpl_maintitle = 'システム設定';
[19996]50        $this->tpl_subtitle = '管理画面設定';
51        $this->tpl_enable_ssl = FALSE;
52    }
53
54    /**
55     * Page のプロセス.
56     *
57     * @return void
58     */
59    function process() {
60        $this->action();
61        $this->sendResponse();
62    }
63
64    /**
65     * Page のアクション.
66     *
67     * @return void
68     */
69    function action() {
70
[21514]71        if (strpos(HTTPS_URL,'https://') !== FALSE) {
[20356]72            $this->tpl_enable_ssl = TRUE;
73        }
74
[21986]75        $objFormParam = new SC_FormParam_Ex;
[20356]76
[20970]77        // パラメーターの初期化
[20356]78        $this->initParam($objFormParam, $_POST);
79
[21442]80        if (count($_POST) > 0) {
[20356]81
82            // エラーチェック
83            $arrErr = $objFormParam->checkError();
84
85            $this->arrForm = $objFormParam->getHashArray();
86
[19996]87            //設定ファイルの権限チェック
[21441]88            if (!is_writable(CONFIG_REALFILE)) {
[20538]89                $arrErr['all'] = CONFIG_REALFILE . ' を変更する権限がありません。';
[19996]90            }
[20356]91
[19996]92            //管理画面ディレクトリのチェック
[20356]93            $this->lfCheckAdminArea($this->arrForm, $arrErr);
[19996]94
[21441]95            if (SC_Utils_Ex::isBlank($arrErr) && $this->lfUpdateAdminData($this->arrForm)) {
[21420]96
[19996]97                $this->tpl_onload = "window.alert('管理機能の設定を変更しました。URLを変更した場合は、新しいURLにアクセスしてください。');";
[21441]98            } else {
[20356]99                $this->tpl_onload = "window.alert('設定内容に誤りがあります。設定内容を確認してください。');";
[20676]100                $this->arrErr = array_merge($arrErr, $this->arrErr);
[19996]101            }
[20356]102
[19996]103        } else {
[20356]104
[21514]105            $admin_dir = str_replace('/','',ADMIN_DIR);
[21515]106            $this->arrForm = array('admin_dir'=>$admin_dir,'admin_force_ssl'=>ADMIN_FORCE_SSL,'admin_allow_hosts'=>'');
[21480]107            if (defined('ADMIN_ALLOW_HOSTS')) {
[19996]108                $allow_hosts = unserialize(ADMIN_ALLOW_HOSTS);
[21481]109                $this->arrForm['admin_allow_hosts'] = implode("\n",$allow_hosts);
[20356]110
[19996]111            }
112        }
[21743]113
[19996]114    }
115
116    /**
117     * デストラクタ.
118     *
119     * @return void
120     */
121    function destroy() {
122        parent::destroy();
123    }
124
[20356]125    /**
[20970]126     * パラメーター初期化.
[20356]127     *
128     * @param object $objFormParam
129     * @param array  $arrParams  $_POST値
130     * @return void
131     */
132    function initParam(&$objFormParam, &$arrParams) {
133
134        $objFormParam->addParam('ディレクトリ名', 'admin_dir', ID_MAX_LEN, 'a', array('EXIST_CHECK', 'SPTAB_CHECK', 'ALNUM_CHECK'));
135        $objFormParam->addParam('SSL制限', 'admin_force_ssl', 1, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
136        $objFormParam->addParam('IP制限', 'admin_allow_hosts', LTEXT_LEN, 'a', array('IP_CHECK', 'MAX_LENGTH_CHECK'));
137        $objFormParam->setParam($arrParams);
138        $objFormParam->convParam();
139
140    }
141
142    /**
143     * 管理機能ディレクトリのチェック.
144     *
145     * @param array  $arrForm  $this->arrForm値
146     * @param array  $arrErr   エラーがあった項目用配列
147     * @return void
148     */
[21479]149    function lfCheckAdminArea(&$arrForm, &$arrErr) {
[21514]150        $admin_dir = trim($arrForm['admin_dir']).'/';
[20356]151
[19996]152        $installData = file(CONFIG_REALFILE, FILE_IGNORE_NEW_LINES);
[21441]153        foreach ($installData as $key=>$line) {
[21480]154            if (strpos($line,'ADMIN_DIR') !== false and ADMIN_DIR != $admin_dir) {
[19996]155                //既存ディレクトリのチェック
[21514]156                if (file_exists(HTML_REALDIR.$admin_dir) and $admin_dir != 'admin/') {
157                    $arrErr['admin_dir'] .= ROOT_URLPATH.$admin_dir.'は既に存在しています。別のディレクトリ名を指定してください。';
[19996]158                }
159                //権限チェック
[21441]160                if (!is_writable(HTML_REALDIR . ADMIN_DIR)) {
[21514]161                    $arrErr['admin_dir'] .= ROOT_URLPATH.ADMIN_DIR.'のディレクトリ名を変更する権限がありません。';
[19996]162                }
163            }
164        }
165    }
166
167    //管理機能ディレクトリのリネームと CONFIG_REALFILE の変更
[21479]168    function lfUpdateAdminData(&$arrForm) {
[21514]169        $admin_dir = trim($arrForm['admin_dir']).'/';
[20538]170        $admin_force_ssl = 'FALSE';
[21441]171        if ($arrForm['admin_force_ssl'] == 1) {
[20538]172            $admin_force_ssl = 'TRUE';
[19996]173        }
[20356]174        $admin_allow_hosts = explode("\n",$arrForm['admin_allow_hosts']);
[21441]175        foreach ($admin_allow_hosts as $key=>$host) {
[19996]176            $host = trim($host);
[21441]177            if (strlen($host) >= 8) {
[19996]178                $admin_allow_hosts[$key] = $host;
[21441]179            } else {
[19996]180                unset($admin_allow_hosts[$key]);
181            }
182        }
183        $admin_allow_hosts = serialize($admin_allow_hosts);
184
185        // CONFIG_REALFILE の書き換え
186        $installData = file(CONFIG_REALFILE, FILE_IGNORE_NEW_LINES);
187        $diff = 0;
[21441]188        foreach ($installData as $key=>$line) {
[21480]189            if (strpos($line,'ADMIN_DIR') !== false and ADMIN_DIR != $admin_dir) {
[21481]190                $installData[$key] = 'define("ADMIN_DIR","'.$admin_dir.'");';
[19996]191                //管理機能ディレクトリのリネーム
[20676]192                if (!rename(HTML_REALDIR.ADMIN_DIR,HTML_REALDIR.$admin_dir)) {
[21514]193                    $this->arrErr['admin_dir'] .= ROOT_URLPATH.ADMIN_DIR.'のディレクトリ名を変更できませんでした。';
[20676]194                    return false;
195                }
[19996]196                $diff ++;
197            }
[20540]198
[21480]199            if (strpos($line,'ADMIN_FORCE_SSL') !== false) {
[21481]200                $installData[$key] = 'define("ADMIN_FORCE_SSL",'.$admin_force_ssl.');';
[19996]201                $diff ++;
202            }
[21480]203            if (strpos($line,'ADMIN_ALLOW_HOSTS') !== false and ADMIN_ALLOW_HOSTS != $admin_allow_hosts) {
[19996]204                $installData[$key] = "define('ADMIN_ALLOW_HOSTS','".$admin_allow_hosts."');";
205                $diff ++;
206            }
207        }
[20540]208
[21441]209        if ($diff > 0) {
[20538]210            $fp = fopen(CONFIG_REALFILE,'wb');
[19996]211            $installData = implode("\n",$installData);
212            echo $installData;
213            fwrite($fp, $installData);
214            fclose($fp);
215        }
216        return true;
217    }
218}
Note: See TracBrowser for help on using the repository browser.