7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
9 * @package Magic3 Framework
10 * @author 平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11 * @copyright Copyright 2006-2018 Magic3 Project.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
14 * @link http://www.magic3.org
16 require_once($gEnvManager->getCurrentWidgetContainerPath() . '/admin_mainConfigsystemBaseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/admin_mainDb.php');
18 require_once(M3_SYSTEM_INCLUDE_PATH . '/common/scriptLibInfo.php');
20 class admin_mainConfigsysWidgetContainer extends admin_mainConfigsystemBaseWidgetContainer
22 private $db; // DB接続オブジェクト
23 private $adminTheme; // 管理画面用jQueryUIテーマ
24 private $defaultTheme; // フロント画面用jQueryUIテーマ
25 private $systemTemplate;// システム画面用テンプレート
26 private $jqueryVersion; // jQueryバージョン
27 private $wysiwygMenuData; // WYSIWYGエディター選択メニューデータ
28 private $wysiwygEditor; // 管理画面用WYSIWYGエディター
29 const DEFAULT_THEME_DIR = '/ui/themes'; // jQueryUIテーマ格納ディレクトリ
30 const DEFAULT_SYSTEM_TEMPLATE_ID = '_system'; // デフォルトのシステム画面用テンプレート
31 const DEFAULT_JQUERY_VERSION = '1.8'; // デフォルトのjQueryバージョン
34 const CF_USE_SSL = 'use_ssl'; // SSL機能を使用するかどうか
35 const CF_USE_SSL_ADMIN = 'use_ssl_admin'; // 管理画面にSSL機能を使用するかどうか
36 const CF_SITE_IN_PUBLIC = 'site_in_public'; // サイト公開状況
37 const CF_SITE_PC_IN_PUBLIC = 'site_pc_in_public'; // PC用サイトの公開状況
38 const CF_SITE_MOBILE_IN_PUBLIC = 'site_mobile_in_public'; // 携帯用サイトの公開状況
39 const CF_SITE_SMARTPHONE_IN_PUBLIC = 'site_smartphone_in_public'; // スマートフォン用サイトの公開状況
40 const CF_SMARTPHONE_AUTO_REDIRECT = 'smartphone_auto_redirect'; // スマートフォンの自動遷移
41 const CF_SITE_SMARTPHONE_URL = 'site_smartphone_url'; // スマートフォン用サイトURL
42 const CF_SITE_OPERATION_MODE = 'site_operation_mode'; // サイト運用モード
43 const CF_ACCESS_IN_INTRANET = 'access_in_intranet'; // イントラネット運用
44 const CF_MULTI_DOMAIN = 'multi_domain'; // マルチドメイン運用
45 const CF_USE_LANDING_PAGE = 'use_landing_page'; // ランディングページ機能を使用するかどうか
46 const CF_SITE_ACCESS_EXCEPTION_IP = 'site_access_exception_ip'; // アクセス制御、例外とするIP
47 const CF_USE_PAGE_CACHE = 'use_page_cache'; // 画面キャッシュ機能を使用するかどうか
48 const CF_USE_TEMPLATE_ID_IN_SESSION = 'use_template_id_in_session'; // セッションにテンプレートIDを保存
49 const CF_SSL_URL = 'ssl_root_url'; // SSL用のルートURL
50 const CF_CONNECT_SERVER_URL = 'default_connect_server_url'; // ポータル接続先URL
51 const CF_CONFIG_WINDOW_OPEN_TYPE = 'config_window_open_type'; // ウィジェット設定画面のウィンドウ表示タイプ(0=別ウィンドウ、1=タブ)
52 const CF_SYSTEM_TEMPLATE = 'msg_template'; // メッセージ用テンプレート取得キー
53 const CF_ADMIN_DEFAULT_THEME = 'admin_default_theme'; // 管理画面用jQueryUIテーマ
54 const CF_DEFAULT_THEME = 'default_theme'; // フロント画面用jQueryUIテーマ
55 const CF_HIERARCHICAL_PAGE = 'hierarchical_page'; // 階層化ページを使用するかどうか
56 const CF_MULTI_LANGUAGE = 'multi_language'; // 多言語対応
57 const CF_JQUERY_VERSION = 'jquery_version'; // jQueryバージョン
58 const CF_EXTERNAL_JQUERY = 'external_jquery'; // システム外部のjQueryを使用するかどうか
59 // const CF_USE_JQUERY = 'use_jquery'; // jQueryを常に使用するかどうか
60 const CF_SMARTPHONE_USE_JQUERY_MOBILE = 'smartphone_use_jquery_mobile'; // スマートフォン画面でjQuery Mobileを使用
61 const CF_WYSIWYG_EDITOR = 'wysiwyg_editor'; // 管理画面用WYSIWYGエディター
62 const CF_MULTI_DEVICE_ADMIN = 'multi_device_admin'; // マルチデバイス最適化管理画面
63 const CF_PERMIT_DETAIL_CONFIG = 'permit_detail_config'; // 詳細設定が可能かどうか
64 const CF_DEFAULT_LANG = 'default_lang'; // デフォルト言語
65 const CF_WORK_DIR = 'work_dir'; // 作業ディレクトリ
70 function __construct()
73 parent::__construct();
76 $this->db = new admin_mainDb();
78 $this->wysiwygMenuData = array('ckeditor' => 'CKEditor 4.4.2'); // WYSIWYGエディター選択メニューデータ
83 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
84 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
86 * @param RequestManager $request HTTPリクエスト処理クラス
87 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
88 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
90 function _setTemplate($request, &$param)
92 return 'configsystem.tmpl.html';
97 * ヘルプの設定を行う場合はヘルプIDを返す。
98 * ヘルプデータの読み込むディレクトリは「自ウィジェットディレクトリ/include/help」に固定。
100 * @param RequestManager $request HTTPリクエスト処理クラス
101 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
102 * @return string ヘルプID。ヘルプデータはファイル名「help_[ヘルプID].php」で作成。ヘルプを使用しない場合は空文字列「''」を返す。
104 function _setHelp($request, &$param)
111 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
113 * @param RequestManager $request HTTPリクエスト処理クラス
114 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
117 function _assign($request, &$param)
119 $this->defaultLang = $this->gEnv->getDefaultLanguage();
121 $act = $request->trimValueOf('act');
122 $useSsl = ($request->trimValueOf('item_use_ssl') == 'on') ? 1 : 0; // SSL機能を使用するかどうか
123 $useSslAdmin = ($request->trimValueOf('item_use_ssl_admin') == 'on') ? 1 : 0; // 管理画面にSSL機能を使用するかどうか
124 $useHierPage = ($request->trimValueOf('item_use_hier_page') == 'on') ? 1 : 0; // 階層化ページを使用するかどうか
125 $sslUrl = $request->trimValueOf('item_ssl_url'); // SSL用のURL
126 $connectServerUrl = $request->trimValueOf('item_connect_server_url'); // ポータル接続先URL
127 $siteSmartphoneUrl = $request->trimValueOf('item_site_smartphone_url'); // スマートフォン用サイトURL
128 $usePageCache = ($request->trimValueOf('item_use_page_cache') == 'on') ? 1 : 0; // 表示キャッシュ機能を使用するかどうか
129 $canChangeTemplate = ($request->trimValueOf('item_can_change_template') == 'on') ? 1 : 0; // ユーザによるテンプレート変更を許可するかどうか
130 $canDetailConfig = ($request->trimValueOf('item_can_detail_config') == 'on') ? 1 : 0; // 詳細システム設定が可能かどうか
131 $multiDeviceAdmin = ($request->trimValueOf('item_multi_device_admin') == 'on') ? 1 : 0;// マルチデバイス最適化管理画面
132 $smartphoneAutoRedirect = ($request->trimValueOf('item_smartphone_auto_redirect') == 'on') ? 1 : 0; // スマートフォンの自動遷移
133 $sitePcInPublic = ($request->trimValueOf('item_site_pc_in_public') == 'on') ? 1 : 0; // PC用サイトの公開状況
134 $siteMobileInPublic = ($request->trimValueOf('item_site_mobile_in_public') == 'on') ? 1 : 0; // 携帯用サイトの公開状況
135 $siteSmartphoneInPublic = ($request->trimValueOf('item_site_smartphone_in_public') == 'on') ? 1 : 0; // スマートフォン用サイトの公開状況
136 $accessInIntranet = $request->trimCheckedValueOf('item_access_in_intranet'); // イントラネット運用
137 $multiDomain = ($request->trimValueOf('item_multi_domain') == 'on') ? 1 : 0;// マルチドメイン運用
138 $useLandingPage = $request->trimCheckedValueOf('item_use_landing_page'); // ランディングページ機能を使用するかどうか
139 $isActiveSitePc = ($request->trimValueOf('item_is_active_site_pc') == 'on') ? 1 : 0; // PC用サイト有効
140 $isActiveSiteSmartphone = ($request->trimValueOf('item_is_active_site_smartphone') == 'on') ? 1 : 0; // スマートフォン用サイト有効
141 $configWindowOpenByTab = ($request->trimValueOf('item_config_window_open_by_tab') == 'on') ? 1 : 0; // ウィジェット設定画面をタブで開くかどうか
142 $multiLanguage = ($request->trimValueOf('item_multi_language') == 'on') ? 1 : 0; // 多言語対応
143 $lang = $request->trimValueOf('item_lang');
144 $workDir = $request->trimValueOf('item_work_dir');
145 $this->systemTemplate = $request->trimValueOf('item_systemplate'); // システム画面用テンプレート
146 $this->adminTheme = $request->trimValueOf('item_admin_theme'); // 管理画面用jQueryUIテーマ
147 $this->defaultTheme = $request->trimValueOf('item_default_theme'); // フロント画面用jQueryUIテーマ
148 $this->jqueryVersion = $request->trimValueOf('item_jquery_version'); // jQueryバージョン
149 $externalJquery = $request->trimCheckedValueOf('item_external_jquery'); // システム外部のjQueryを使用するかどうか
150 // $useJquery = ($request->trimValueOf('item_use_jquery') == 'on') ? 1 : 0; // 常にjQueryを使用するかどうか
151 $smartphoneUseJqueryMobile = ($request->trimValueOf('item_smartphone_use_jquery_mobile') == 'on') ? 1 : 0;// スマートフォン画面でjQuery Mobileを使用
152 $this->wysiwygEditor = $request->trimValueOf('item_wysiwyg_editor'); // 管理画面用WYSIWYGエディター
153 $uploadImageAutoresize = $request->trimCheckedValueOf('item_upload_image_autoresize'); // アップロード画像の自動リサイズを行うかどうか
154 $uploadImageAutoresizeMaxWidth = $request->trimValueOf('item_upload_image_autoresize_max_width'); // アップロード画像の自動リサイズ、画像最大幅
155 $uploadImageAutoresizeMaxHeight = $request->trimValueOf('item_upload_image_autoresize_max_height'); // アップロード画像の自動リサイズ、画像最大高さ
156 $isHier = $request->trimValueOf('menu_type');
158 if ($act == 'update'){ // 設定更新のとき
160 if (!$isErr && !empty($lang)){
161 if (!$this->db->updateSystemConfig(self::CF_DEFAULT_LANG, $lang)) $isErr = true;
164 if (!$this->db->updateSystemConfig(self::CF_USE_SSL, $useSsl)) $isErr = true; // SSL機能を使用するかどうか
166 if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_USE_SSL_ADMIN, $useSslAdmin)) $isErr = true; // SSL機能を使用するかどうか
167 if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_HIERARCHICAL_PAGE, $useHierPage)) $isErr = true; // 階層化ページを使用するかどうか
168 if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_USE_PAGE_CACHE, $usePageCache)) $isErr = true; // 表示キャッシュ機能を使用するかどうか
169 if (!$isErr) if (!$this->db->updateSystemConfig(self::CF_USE_TEMPLATE_ID_IN_SESSION, $canChangeTemplate)) $isErr = true;// ユーザによるテンプレート変更を許可するかどうか
171 if (!$this->db->updateSystemConfig(self::CF_PERMIT_DETAIL_CONFIG, $canDetailConfig)) $isErr = true;
174 if (!$this->db->updateSystemConfig(self::CF_MULTI_DEVICE_ADMIN, $multiDeviceAdmin)) $isErr = true;// マルチデバイス最適化管理画面
177 if (!$this->db->updateSystemConfig(self::CF_SMARTPHONE_AUTO_REDIRECT, $smartphoneAutoRedirect)) $isErr = true;
180 if (!$this->db->updateSystemConfig(self::CF_SITE_PC_IN_PUBLIC, $sitePcInPublic)) $isErr = true;
183 if (!$this->db->updateSystemConfig(self::CF_SITE_MOBILE_IN_PUBLIC, $siteMobileInPublic)) $isErr = true;
186 if (!$this->db->updateSystemConfig(self::CF_SITE_SMARTPHONE_IN_PUBLIC, $siteSmartphoneInPublic)) $isErr = true;
189 if (!$this->db->updateSystemConfig(self::CF_ACCESS_IN_INTRANET, $accessInIntranet)) $isErr = true;// イントラネット運用
192 if (!$this->db->updateSystemConfig(self::CF_MULTI_DOMAIN, $multiDomain)) $isErr = true;// マルチドメイン運用
195 if (!$this->db->updateSystemConfig(self::CF_USE_LANDING_PAGE, $useLandingPage)) $isErr = true;// ランディングページ機能を使用するかどうか
198 if (!$this->updateActiveAccessPoint(0/*PC*/, $isActiveSitePc)) $isErr = true;// PC用サイト有効
201 if (!$this->updateActiveAccessPoint(2/*スマートフォン*/, $isActiveSiteSmartphone)) $isErr = true;// スマートフォン用サイト有効
204 if (!$this->db->updateSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE, $configWindowOpenByTab)) $isErr = true; // ウィジェット設定画面をタブで開くかどうか
207 if (!$this->db->updateSystemConfig(self::CF_MULTI_LANGUAGE, $multiLanguage)) $isErr = true; // 多言語対応
210 $sslUrl = rtrim($sslUrl, '/');// 最後の「/」を除く
211 $sslUrl = str_replace('http://', 'https://', $sslUrl);// httpの場合はhttpsに変更
212 if (!$this->db->updateSystemConfig(self::CF_SSL_URL, $sslUrl)) $isErr = true;
215 $connectServerUrl = rtrim($connectServerUrl, '/');// 最後の「/」を除く
216 if (!$this->db->updateSystemConfig(self::CF_CONNECT_SERVER_URL, $connectServerUrl)) $isErr = true;// ポータル接続先URL
219 $siteSmartphoneUrl = rtrim($siteSmartphoneUrl, '/');// 最後の「/」を除く
220 if (!$this->db->updateSystemConfig(self::CF_SITE_SMARTPHONE_URL, $siteSmartphoneUrl)) $isErr = true;// スマートフォン用サイトURL
223 $workDir = rtrim($workDir, '/');// 最後の「/」を除く
224 if (!$this->db->updateSystemConfig(self::CF_WORK_DIR, $workDir)) $isErr = true;
227 if (!$this->db->updateSystemConfig(self::CF_SYSTEM_TEMPLATE, $this->systemTemplate)) $isErr = true;// システム画面用テンプレート
229 // 管理画面用jQueryUIテーマは「smoothness」に固定(2017/4/25)
231 // if (!$this->db->updateSystemConfig(self::CF_ADMIN_DEFAULT_THEME, $this->adminTheme)) $isErr = true;// 管理画面用jQueryUIテーマ
234 if (!$this->db->updateSystemConfig(self::CF_DEFAULT_THEME, $this->defaultTheme)) $isErr = true;// フロント画面用jQueryUIテーマ
237 if (!$this->db->updateSystemConfig(self::CF_JQUERY_VERSION, $this->jqueryVersion)) $isErr = true;// jQueryバージョン
240 if (!$this->db->updateSystemConfig(self::CF_EXTERNAL_JQUERY, $externalJquery)) $isErr = true;// システム外部のjQueryを使用するかどうか
243 if (!$this->db->updateSystemConfig(self::CF_USE_JQUERY, $useJquery)) $isErr = true;// 常にjQueryを使用するかどうか
246 if (!$this->db->updateSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE, $smartphoneUseJqueryMobile)) $isErr = true;// スマートフォン画面でjQuery Mobileを使用
249 if (!$this->db->updateSystemConfig(self::CF_WYSIWYG_EDITOR, $this->wysiwygEditor)) $isErr = true;// 管理画面用WYSIWYGエディター
252 if (!$this->db->updateSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE, $uploadImageAutoresize)) $isErr = true; // アップロード画像の自動リサイズを行うかどうか
255 if (!$this->db->updateSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_WIDTH, $uploadImageAutoresizeMaxWidth)) $isErr = true; // アップロード画像の自動リサイズ、画像最大幅
258 if (!$this->db->updateSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_HEIGHT, $uploadImageAutoresizeMaxHeight)) $isErr = true; // アップロード画像の自動リサイズ、画像最大高さ
261 if (!$this->gSystem->changeSiteMenuHier($isHier)) $isErr = true;// メニュー管理画面を変更
265 $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
267 $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
270 $this->gEnv->loadSystemParams();
273 $this->defaultLang = $this->gEnv->getDefaultLanguage();
274 $useSsl = $this->db->getSystemConfig(self::CF_USE_SSL); // SSL機能を使用するかどうか
275 $useSslAdmin = $this->db->getSystemConfig(self::CF_USE_SSL_ADMIN); // SSL機能を使用するかどうか
276 $useHierPage = $this->db->getSystemConfig(self::CF_HIERARCHICAL_PAGE); // 階層化ページを使用するかどうか
277 $sslUrl = $this->db->getSystemConfig(self::CF_SSL_URL); // SSLのURL
278 $connectServerUrl = $this->db->getSystemConfig(self::CF_CONNECT_SERVER_URL);// ポータル接続先URL
279 $usePageCache = $this->db->getSystemConfig(self::CF_USE_PAGE_CACHE); // 表示キャッシュ機能を使用するかどうか
280 $canChangeTemplate = $this->db->getSystemConfig(self::CF_USE_TEMPLATE_ID_IN_SESSION);// ユーザによるテンプレート変更を許可するかどうか
281 $canDetailConfig = $this->db->getSystemConfig(self::CF_PERMIT_DETAIL_CONFIG);
282 $multiDeviceAdmin = $this->db->getSystemConfig(self::CF_MULTI_DEVICE_ADMIN); // マルチデバイス最適化管理画面
283 $smartphoneAutoRedirect = $this->gSystem->smartphoneAutoRedirect(true/*再取得*/); // スマートフォンの自動遷移
284 $workDir = $this->db->getSystemConfig(self::CF_WORK_DIR);
285 $sitePcInPublic = $this->gSystem->sitePcInPublic(true/*再取得*/); // PC用サイトの公開状況
286 $siteMobileInPublic = $this->gSystem->siteMobileInPublic(true/*再取得*/); // 携帯用サイトの公開状況
287 $siteSmartphoneInPublic = $this->gSystem->siteSmartphoneInPublic(true/*再取得*/); // スマートフォン用サイトの公開状況
288 $accessInIntranet = $this->db->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用
289 $multiDomain = $this->db->getSystemConfig(self::CF_MULTI_DOMAIN); // マルチドメイン運用
290 $useLandingPage = $this->db->getSystemConfig(self::CF_USE_LANDING_PAGE);// ランディングページ機能を使用するかどうか
291 $isActiveSitePc = $this->isActiveAccessPoint(0/*PC*/); // PC用サイト有効かどうか
292 $isActiveSiteSmartphone = $this->isActiveAccessPoint(2/*スマートフォン*/); // スマートフォン用サイト有効かどうか
293 $siteSmartphoneUrl = $this->db->getSystemConfig(self::CF_SITE_SMARTPHONE_URL); // スマートフォン用サイトURL
294 $configWindowOpenByTab = $this->db->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE); // ウィジェット設定画面をタブで開くかどうか
295 $multiLanguage = $this->gSystem->getSystemConfig(self::CF_MULTI_LANGUAGE); // 多言語対応かどうか
296 $this->systemTemplate = $this->db->getSystemConfig(self::CF_SYSTEM_TEMPLATE);// システム画面用テンプレート
297 $this->adminTheme = $this->db->getSystemConfig(self::CF_ADMIN_DEFAULT_THEME); // 管理画面用jQueryUIテーマ
298 $this->defaultTheme = $this->db->getSystemConfig(self::CF_DEFAULT_THEME); // フロント画面用jQueryUIテーマ
299 $this->jqueryVersion = $this->db->getSystemConfig(self::CF_JQUERY_VERSION); // jQueryバージョン
300 if (empty($this->jqueryVersion)) $this->jqueryVersion = self::DEFAULT_JQUERY_VERSION;
301 $externalJquery = $this->db->getSystemConfig(self::CF_EXTERNAL_JQUERY);// システム外部のjQueryを使用するかどうか
302 // $useJquery = $this->db->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
303 $smartphoneUseJqueryMobile = $this->db->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面でjQuery Mobileを使用
304 $this->wysiwygEditor = $this->db->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
305 $uploadImageAutoresize = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE); // アップロード画像の自動リサイズを行うかどうか
306 $uploadImageAutoresizeMaxWidth = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_WIDTH); // アップロード画像の自動リサイズ、画像最大幅
307 $uploadImageAutoresizeMaxHeight = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_HEIGHT); // アップロード画像の自動リサイズ、画像最大高さ
308 $isHier = $this->gSystem->isSiteMenuHier(); // メニューを階層化するかどうかを取得
310 // ### サイト定義ファイル(siteDef.php)にオプション定義を追加 ###
311 $adminUrl = $this->gEnv->getAdminUrl(); // 管理機能URL
313 $params['M3_SYSTEM_ADMIN_URL'] = $adminUrl;
314 $ret = $this->gConfig->updateOptionParam($params, $msg);
315 if (!$ret) var_dump($msg);
317 } else if ($act == 'updateip'){ // IPアドレスを更新のとき
318 $exceptIp = $request->trimValueOf('except_ip');
321 $this->checkIp($exceptIp, 'IP', true);
324 if ($this->getMsgCount() == 0){
326 if (!$this->db->updateSystemConfig(self::CF_SITE_ACCESS_EXCEPTION_IP, $exceptIp)) $isErr = true;
328 $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
330 $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
333 } else if ($act == 'siteopen'){ // サイト運用開始のとき
334 $this->db->updateSystemConfig(self::CF_SITE_IN_PUBLIC, 1);
335 } else if ($act == 'siteclose'){ // サイト運用停止のとき
336 $this->db->updateSystemConfig(self::CF_SITE_IN_PUBLIC, 0);
337 } else if ($act == 'site_operation_mode_on'){ // サイト運用モード変更
339 $this->gSystem->updateSystemConfig(self::CF_SITE_OPERATION_MODE, 1);
340 } else if ($act == 'site_operation_mode_off'){ // サイト運用モード変更
342 $this->gSystem->updateSystemConfig(self::CF_SITE_OPERATION_MODE, 0);
343 } else if ($act == 'clearcache'){ // キャッシュクリアのとき
344 $ret = $this->gCache->clearAllCache();
346 $this->setMsg(self::MSG_GUIDANCE, 'キャッシュをクリアしました');
348 $this->setMsg(self::MSG_APP_ERR, 'キャッシュをクリアに失敗しました');
351 $useSsl = $this->db->getSystemConfig(self::CF_USE_SSL); // SSL機能を使用するかどうか
352 $useSslAdmin = $this->db->getSystemConfig(self::CF_USE_SSL_ADMIN); // SSL機能を使用するかどうか
353 $useHierPage = $this->db->getSystemConfig(self::CF_HIERARCHICAL_PAGE); // 階層化ページを使用するかどうか
354 $sslUrl = $this->db->getSystemConfig(self::CF_SSL_URL); // SSLのURL
355 $connectServerUrl = $this->db->getSystemConfig(self::CF_CONNECT_SERVER_URL);// ポータル接続先URL
356 $usePageCache = $this->db->getSystemConfig(self::CF_USE_PAGE_CACHE); // 表示キャッシュ機能を使用するかどうか
357 $canChangeTemplate = $this->db->getSystemConfig(self::CF_USE_TEMPLATE_ID_IN_SESSION);// ユーザによるテンプレート変更を許可するかどうか
358 $canDetailConfig = $this->db->getSystemConfig(self::CF_PERMIT_DETAIL_CONFIG);
359 $multiDeviceAdmin = $this->db->getSystemConfig(self::CF_MULTI_DEVICE_ADMIN); // マルチデバイス最適化管理画面
360 $smartphoneAutoRedirect = $this->gSystem->smartphoneAutoRedirect(true/*再取得*/); // スマートフォンの自動遷移
361 $workDir = $this->db->getSystemConfig(self::CF_WORK_DIR);
362 $sitePcInPublic = $this->gSystem->sitePcInPublic(true/*再取得*/); // PC用サイトの公開状況
363 $siteMobileInPublic = $this->gSystem->siteMobileInPublic(true/*再取得*/); // 携帯用サイトの公開状況
364 $siteSmartphoneInPublic = $this->gSystem->siteSmartphoneInPublic(true/*再取得*/); // スマートフォン用サイトの公開状況
365 $accessInIntranet = $this->db->getSystemConfig(self::CF_ACCESS_IN_INTRANET); // イントラネット運用
366 $multiDomain = $this->db->getSystemConfig(self::CF_MULTI_DOMAIN);// マルチドメイン運用
367 $useLandingPage = $this->db->getSystemConfig(self::CF_USE_LANDING_PAGE);// ランディングページ機能を使用するかどうか
368 $isActiveSitePc = $this->isActiveAccessPoint(0/*PC*/); // PC用サイト有効かどうか
369 $isActiveSiteSmartphone = $this->isActiveAccessPoint(2/*スマートフォン*/); // スマートフォン用サイト有効かどうか
370 $siteSmartphoneUrl = $this->db->getSystemConfig(self::CF_SITE_SMARTPHONE_URL); // スマートフォン用サイトURL
371 $configWindowOpenByTab = $this->db->getSystemConfig(self::CF_CONFIG_WINDOW_OPEN_TYPE); // ウィジェット設定画面をタブで開くかどうか
372 $multiLanguage = $this->gSystem->getSystemConfig(self::CF_MULTI_LANGUAGE); // 多言語対応かどうか
373 $this->systemTemplate = $this->db->getSystemConfig(self::CF_SYSTEM_TEMPLATE);// システム画面用テンプレート
374 $this->adminTheme = $this->db->getSystemConfig(self::CF_ADMIN_DEFAULT_THEME); // 管理画面用jQueryUIテーマ
375 $this->defaultTheme = $this->db->getSystemConfig(self::CF_DEFAULT_THEME); // フロント画面用jQueryUIテーマ
376 $this->jqueryVersion = $this->db->getSystemConfig(self::CF_JQUERY_VERSION); // jQueryバージョン
377 if (empty($this->jqueryVersion)) $this->jqueryVersion = self::DEFAULT_JQUERY_VERSION;
378 $externalJquery = $this->db->getSystemConfig(self::CF_EXTERNAL_JQUERY);// システム外部のjQueryを使用するかどうか
379 // $useJquery = $this->db->getSystemConfig(self::CF_USE_JQUERY);// 常にjQueryを使用するかどうか
380 $smartphoneUseJqueryMobile = $this->db->getSystemConfig(self::CF_SMARTPHONE_USE_JQUERY_MOBILE);// スマートフォン画面でjQuery Mobileを使用
381 $this->wysiwygEditor = $this->db->getSystemConfig(self::CF_WYSIWYG_EDITOR); // 管理画面用WYSIWYGエディター
382 $uploadImageAutoresize = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE); // アップロード画像の自動リサイズを行うかどうか
383 $uploadImageAutoresizeMaxWidth = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_WIDTH); // アップロード画像の自動リサイズ、画像最大幅
384 $uploadImageAutoresizeMaxHeight = $this->db->getSystemConfig(SystemManager::CF_UPLOAD_IMAGE_AUTORESIZE_MAX_HEIGHT); // アップロード画像の自動リサイズ、画像最大高さ
385 $isHier = $this->gSystem->isSiteMenuHier(); // メニューを階層化するかどうかを取得
388 $this->db->getLangs($this->gSystem->getSystemLanguages(), array($this, 'langLoop'));
391 $this->db->getAllTemplateList(0/*PC用*/, array($this, 'sysTemplateLoop'), false/*利用不可も表示*/);
393 // jQueryUIテーマ選択メニュー作成
394 $this->createAdminThemeMenu($this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR);
395 $this->createDefaultThemeMenu($this->gEnv->getSystemRootPath() . self::DEFAULT_THEME_DIR);
397 // jQueryバージョン選択メニュー作成
398 $this->createJqueryVerMenu(ScriptLibInfo::getJQueryVersionInfo());
400 // WYSIWYGエディター選択メニュー作成
401 $this->createWysiwygMenu();
404 $this->tmpl->addVar("_widget", "site_url", $this->gEnv->getRootUrl());
405 $this->tmpl->addVar("show_site_pc_open", "pc_access_url", $this->gEnv->getDefaultUrl());
406 $this->tmpl->addVar("show_site_smartphone_open", "smartphone_access_url", $this->gEnv->getDefaultSmartphoneUrl());
407 $this->tmpl->addVar("_widget", "admin_access_url", $this->gEnv->getDefaultAdminUrl());
411 if ($this->gSystem->siteInPublic(true/*再取得*/)) $checked = 'checked'; // 運用中のとき
412 $this->tmpl->addVar("_widget", "site_status_checked", $checked);
413 $this->tmpl->addVar("_widget", "except_ip", $this->db->getSystemConfig(self::CF_SITE_ACCESS_EXCEPTION_IP));
415 if ($this->db->getSystemConfig(self::CF_SITE_OPERATION_MODE) == '1') $checked = 'checked'; // サイト運用モードのとき
416 $this->tmpl->addVar("_widget", "site_operation_mode_checked", $checked);
419 $isActiveSite = $this->gSystem->getSiteActiveStatus(0); // PC用サイト
421 $this->tmpl->setAttribute('show_site_pc_open', 'visibility', 'visible');
423 $this->tmpl->setAttribute('show_site_pc_close', 'visibility', 'visible');
425 $isActiveSite = $this->gSystem->getSiteActiveStatus(2); // スマートフォン用サイト
427 $this->tmpl->setAttribute('show_site_smartphone_open', 'visibility', 'visible');
429 $this->tmpl->setAttribute('show_site_smartphone_close', 'visibility', 'visible');
433 if (!empty($sslUrl)){
434 $expireDt = $this->_getSslExpireDt($sslUrl, $sslDomain);
435 if (empty($expireDt)){
436 $expireDtTag = '未取得';
438 if (time() <= $expireDt){
439 $expireDt = date("Y/m/d H:i:s", $expireDt);
440 $expireDtTag = '<span class="available">' . $this->convertToDispDateTime($expireDt) . '</span>';
442 $expireDt = date("Y/m/d H:i:s", $expireDt);
443 $expireDtTag = '<span class="stopped">' . $this->convertToDispDateTime($expireDt) . '</span>';
450 if ($sitePcInPublic) $checked = 'checked';
451 $this->tmpl->addVar("show_site_pc_open", "site_pc_in_public", $checked);// PC用サイトの公開状況
453 if ($siteSmartphoneInPublic) $checked = 'checked';
454 $this->tmpl->addVar("show_site_smartphone_open", "site_smartphone_in_public", $checked);// スマートフォン用サイトの公開状況
455 $this->tmpl->addVar("_widget", "access_in_intranet", $this->convertToCheckedString($accessInIntranet));// イントラネット運用
457 if ($multiDomain) $checked = 'checked';
458 $this->tmpl->addVar("_widget", "multi_domain", $checked);// マルチドメイン運用
459 $this->tmpl->addVar("_widget", "use_landing_page_checked", $this->convertToCheckedString($useLandingPage));// ランディングページ機能を使用するかどうか
461 if ($isActiveSitePc) $checked = 'checked';
462 $this->tmpl->addVar("_widget", "is_active_site_pc", $checked);// PC用サイト有効
464 if ($isActiveSiteSmartphone) $checked = 'checked';
465 $this->tmpl->addVar("_widget", "is_active_site_smartphone", $checked);// スマートフォン用サイト有効
467 if ($useSsl) $checked = 'checked';
468 $this->tmpl->addVar("_widget", "use_ssl", $checked);// SSL機能を使用するかどうか
470 if ($useSslAdmin) $checked = 'checked';
471 $this->tmpl->addVar("_widget", "use_ssl_admin", $checked);// 管理画面にSSL機能を使用するかどうか
473 if ($useHierPage) $checked = 'checked';
474 $this->tmpl->addVar("_widget", "use_hier_page", $checked);// 階層化ページを使用するかどうか
476 if ($usePageCache) $checked = 'checked';
477 $this->tmpl->addVar("_widget", "use_page_cache", $checked); // 表示キャッシュ機能を使用するかどうか
479 if ($canChangeTemplate) $checked = 'checked';
480 $this->tmpl->addVar("_widget", "can_change_template", $checked); // ユーザによるテンプレート変更を許可するかどうか
482 if ($multiLanguage) $checked = 'checked';
483 $this->tmpl->addVar("_widget", "multi_language", $checked); // 多言語対応かどうか
484 $this->tmpl->addVar("_widget", "external_jquery", $this->convertToCheckedString($externalJquery));// システム外部のjQueryを使用するかどうか
486 // if ($useJquery) $checked = 'checked';
487 // $this->tmpl->addVar("_widget", "use_jquery", $checked); // 常にjQueryを使用するかどうか
489 if ($smartphoneUseJqueryMobile) $checked = 'checked';
490 $this->tmpl->addVar("_widget", "smartphone_use_jquery_mobile", $checked); // スマートフォン画面でjQuery Mobileを使用
491 if ($isHier){ // 階層化メニューのとき
492 $this->tmpl->addVar("_widget", "menu_type_tree", 'checked'); // 多階層メニュー
494 $this->tmpl->addVar("_widget", "menu_type_single", 'checked'); // 単階層メニュー
498 $this->tmpl->addVar("_widget", "root_url", $this->gEnv->getRootUrl());
499 $this->tmpl->addVar("_widget", "connect_server_url", $connectServerUrl);// ポータル接続先URL
500 $this->tmpl->addVar("_widget", "site_smartphone_url", $siteSmartphoneUrl); // スマートフォン用サイトURL
503 if (!empty($sslUrl)){
504 $this->tmpl->setAttribute('show_ssl_url', 'visibility', 'hidden');
505 $this->tmpl->setAttribute('show_ssl_url_expiredt', 'visibility', 'visible'); // SSLの期限を表示
507 $this->tmpl->addVar("show_ssl_url_expiredt", "ssl_url", $sslUrl);// SSLのURL
508 $this->tmpl->addVar('show_ssl_url_expiredt', 'ssl_expire_dt', $expireDtTag); // SSL証明書期限
512 if ($canDetailConfig) $checked = 'checked';
513 $this->tmpl->addVar("_widget", "can_detail_config", $checked);
514 $this->tmpl->addVar("_widget", "multi_device_admin", $this->convertToCheckedString($multiDeviceAdmin));// マルチデバイス最適化管理画面
516 if (!empty($smartphoneAutoRedirect)) $checked = 'checked';
517 $this->tmpl->addVar("_widget", "smartphone_auto_redirect", $checked);// スマートフォンの自動遷移
519 if (!empty($configWindowOpenByTab)) $checked = 'checked'; // ウィジェット設定画面をタブで開くかどうか
520 $this->tmpl->addVar("_widget", "config_window_open_by_tab", $checked);
522 $this->tmpl->addVar("_widget", "upload_image_autoresize", $this->convertToCheckedString($uploadImageAutoresize)); // アップロード画像の自動リサイズを行うかどうか
523 $this->tmpl->addVar("_widget", "upload_image_autoresize_max_width", $uploadImageAutoresizeMaxWidth); // アップロード画像の自動リサイズ、画像最大幅
524 $this->tmpl->addVar("_widget", "upload_image_autoresize_max_height", $uploadImageAutoresizeMaxHeight); // アップロード画像の自動リサイズ、画像最大高さ
527 $this->tmpl->addVar("_widget", "work_dir", $workDir);
528 if (is_writable($workDir)){
529 if (checkWritableDir($workDir)){
530 $data = '<b><font color="green">書き込み可能</font></b>';
532 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
535 $data = '<b><font color="red">書き込み不可</font></b>';
537 $this->tmpl->addVar("_widget","work_dir_access", $data); // 一時ディレクトリの書き込み権限
538 $this->tmpl->addVar("_widget", "system_db_version", $this->db->getSystemConfig(M3_TB_FIELD_DB_VERSION)); // Magic3システムDBバージョン
539 $this->tmpl->addVar("_widget", "system_db_update_dt", $this->db->getSystemConfig(M3_TB_FIELD_DB_UPDATE_DT)); // Magic3システムDB更新日時
542 $path = $this->gEnv->getResourcePath();
543 $this->tmpl->addVar("_widget", "resource_dir", $path);
544 if (is_writable($path)){
545 if (checkWritableDir($path)){
546 $data = '<b><font color="green">書き込み可能</font></b>';
548 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
551 $data = '<b><font color="red">書き込み不可</font></b>';
553 $this->tmpl->addVar("_widget", "resource_dir_access", $data);
556 $path = $this->gEnv->getTemplatesPath();
557 $this->tmpl->addVar("_widget", "templates_dir", $path);
558 if (is_writable($path)){
559 if (checkWritableDir($path)){
560 $data = '<b><font color="green">書き込み可能</font></b>';
562 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
565 $data = '<b><font color="red">書き込み不可</font></b>';
567 $this->tmpl->addVar("_widget", "templates_dir_access", $data);
570 $path = $this->gEnv->getWidgetsPath();
571 $this->tmpl->addVar("_widget", "widgets_dir", $path);
572 if (is_writable($path)){
573 if (checkWritableDir($path)){
574 $data = '<b><font color="green">書き込み可能</font></b>';
576 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
579 $data = '<b><font color="red">書き込み不可</font></b>';
581 $this->tmpl->addVar("_widget", "widgets_dir_access", $data);
584 $path = $this->gEnv->getPrivateResourcePath();
585 $this->tmpl->addVar("_widget", "private_resource_dir", $path);
586 if (is_writable($path)){
587 if (checkWritableDir($path)){
588 $data = '<b><font color="green">書き込み可能</font></b>';
590 $data = '<b><font color="red">Safe Modeにより書き込み不可</font></b>';
593 $data = '<b><font color="red">書き込み不可</font></b>';
595 $this->tmpl->addVar("_widget", "private_resource_dir_access", $data);
598 $size = convFromBytes(calcDirSize($this->gEnv->getResourcePath()));
599 $this->tmpl->addVar("_widget", "resource_dir_size", $size);
604 * @param int $index 行番号(0~)
605 * @param array $fetchedRow フェッチ取得した行
606 * @param object $param 未使用
607 * @return bool true=処理続行の場合、false=処理終了の場合
609 function langLoop($index, $fetchedRow, $param)
612 if ($fetchedRow['ln_id'] == $this->defaultLang){
613 $selected = 'selected';
615 //if ($this->gEnv->getCurrentLanguage() == 'ja'){ // 日本語表示の場合
616 $name = $this->convertToDispString($fetchedRow['ln_name']) . ' - ';
618 $name .= $this->convertToDispString($fetchedRow['ln_name_en']);
622 'value' => $this->convertToDispString($fetchedRow['ln_id']), // 言語ID
623 'name' => $name, // 言語名
624 'selected' => $selected // 選択中かどうか
626 $this->tmpl->addVars('lang_list', $row);
627 $this->tmpl->parseTemplate('lang_list', 'a');
631 * jQueryUIテーマの選択メニューを作成
633 * @param string $dir テーマのディレクトリ
636 function createAdminThemeMenu($themeDir)
638 if (is_dir($themeDir)){
639 $dir = dir($themeDir);
640 while (($file = $dir->read()) !== false){
641 $filePath = $themeDir . '/' . $file;
643 if (strncmp($file, '.', 1) != 0 && $file != '..' && is_dir($filePath) &&
644 strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のディレクトリは読み込まない
647 if ($file == $this->adminTheme) $selected = 'selected';
650 'value' => $this->convertToDispString($file), // テーマID
651 'name' => $this->convertToDispString($file),
652 'selected' => $selected // 選択中かどうか
654 $this->tmpl->addVars('admin_theme_list', $row);
655 $this->tmpl->parseTemplate('admin_theme_list', 'a');
662 * jQueryUIテーマの選択メニューを作成
664 * @param string $dir テーマのディレクトリ
667 function createDefaultThemeMenu($themeDir)
670 if (empty($this->defaultTheme)) $selected = 'selected';
673 'value' => '', // テーマID
674 'name' => '-- 指定なし --',
675 'selected' => $selected // 選択中かどうか
677 $this->tmpl->addVars('theme_list', $row);
678 $this->tmpl->parseTemplate('theme_list', 'a');
680 if (is_dir($themeDir)){
681 $dir = dir($themeDir);
682 while (($file = $dir->read()) !== false){
683 $filePath = $themeDir . '/' . $file;
685 if (strncmp($file, '.', 1) != 0 && $file != '..' && is_dir($filePath) &&
686 strncmp($file, '_', 1) != 0){ // 「_」で始まる名前のディレクトリは読み込まない
689 if ($file == $this->defaultTheme) $selected = 'selected';
692 'value' => $this->convertToDispString($file), // テーマID
693 'name' => $this->convertToDispString($file),
694 'selected' => $selected // 選択中かどうか
696 $this->tmpl->addVars('theme_list', $row);
697 $this->tmpl->parseTemplate('theme_list', 'a');
706 * @param int $index 行番号(0~)
707 * @param array $fetchedRow フェッチ取得した行
708 * @param object $param 未使用
709 * @return bool true=処理続行の場合、false=処理終了の場合
711 function sysTemplateLoop($index, $fetchedRow, $param)
714 if ($fetchedRow['tm_id'] == $this->systemTemplate){
715 $selected = 'selected';
717 $name = $fetchedRow['tm_name'];
718 if ($fetchedRow['tm_id'] == self::DEFAULT_SYSTEM_TEMPLATE_ID) $name = '[デフォルト]';
721 'value' => $this->convertToDispString($fetchedRow['tm_id']), // テンプレートID
722 'name' => $this->convertToDispString($name), // テンプレート名名
723 'selected' => $selected // 選択中かどうか
725 $this->tmpl->addVars('systemplate_list', $row);
726 $this->tmpl->parseTemplate('systemplate_list', 'a');
730 * jQueryのバージョン選択メニューを作成
732 * @param array $versionInfo jQueryバージョン情報
735 function createJqueryVerMenu($versionInfo)
737 foreach ($versionInfo as $key => $value){
742 if ($value == $this->jqueryVersion) $selected = 'selected';
745 'value' => $this->convertToDispString($value),
746 'name' => $this->convertToDispString($name),
747 'selected' => $selected // 選択中かどうか
749 $this->tmpl->addVars('jquery_version_list', $row);
750 $this->tmpl->parseTemplate('jquery_version_list', 'a');
754 * WYSIWYGエディター選択メニュー作成
758 function createWysiwygMenu()
760 foreach ($this->wysiwygMenuData as $key => $value){
764 if ($key == $this->wysiwygEditor) $selected = 'selected';
767 'value' => $this->convertToDispString($key),
768 'name' => $this->convertToDispString($name),
769 'selected' => $selected // 選択中かどうか
771 $this->tmpl->addVars('wysiwyg_editor_list', $row);
772 $this->tmpl->parseTemplate('wysiwyg_editor_list', 'a');
778 * @param int $deviceType デバイスタイプ(0=PC,1=携帯,2=スマートフォン)
779 * @return bool true=有効、false=無効
781 function isActiveAccessPoint($deviceType)
784 switch ($deviceType){
789 $pageId = M3_DIR_NAME_MOBILE . '_index';
792 $pageId = M3_DIR_NAME_SMARTPHONE . '_index';
797 $ret = $this->db->getPageIdRecord(0/*アクセスポイント*/, $pageId, $row);
799 $isActive = $row['pg_active'];
806 * @param int $deviceType デバイスタイプ(0=PC,1=携帯,2=スマートフォン)
807 * @param bool $status 有効状態
808 * @return bool true=成功、false=失敗
810 function updateActiveAccessPoint($deviceType, $status)
813 switch ($deviceType){
818 $pageId = M3_DIR_NAME_MOBILE . '_index';
821 $pageId = M3_DIR_NAME_SMARTPHONE . '_index';
825 $ret = $this->db->getPageIdRecord(0/*アクセスポイント*/, $pageId, $row);
827 $ret = $this->db->updatePageId(0/*アクセスポイント*/, $pageId, $row['pg_name'], $row['pg_description'], $row['pg_priority'], $status, $row['pg_visible']);
834 * @param string $url SSL証明書を取得するURL
835 * @param string $sslDomain SSLの対象となるドメイン名
836 * @return int UNIXタイムスタンプ。取得できない場合は0。
838 function _getSslExpireDt($url, &$sslDomain)
840 $arr = parse_url($url);
841 if ($arr == false) return '';
843 $hostname = $arr['host'];
845 $stream_context = stream_context_create(array(
846 'ssl' => array('capture_peer_cert' => true)
848 $fp = @stream_socket_client(
849 'ssl://' . $hostname . ':443',
853 STREAM_CLIENT_CONNECT,
856 if (!$fp) return 0; // 取得不可の場合は終了
858 $cont = stream_context_get_params($fp);
859 $parsed = openssl_x509_parse($cont['options']['ssl']['peer_certificate']);
860 // $expireDt = date("Y/m/d H:i:s", $parsed['validTo_time_t']);
861 $expireDt = $parsed['validTo_time_t'];
862 $sslDomain = $parsed['subject']['CN']; // ドメイン名
868 if (strStartsWith($sslDomain, '*.')){ // ワイルドカードSSLの場合
869 if (!strEndsWith($hostname, substr($sslDomain, 1))) $expireDt = 0;
871 if (!strEndsWith($hostname, '.' . $sslDomain)) $expireDt = 0;