| 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 |
|---|
| 25 | require_once(CLASS_PATH . "pages/LC_Page.php"); |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | * メイン編集 のページクラス. |
|---|
| 29 | * |
|---|
| 30 | * @package Page |
|---|
| 31 | * @author LOCKON CO.,LTD. |
|---|
| 32 | * @version $Id$ |
|---|
| 33 | */ |
|---|
| 34 | class LC_Page_Admin_Design_MainEdit extends LC_Page { |
|---|
| 35 | |
|---|
| 36 | // }}} |
|---|
| 37 | // {{{ functions |
|---|
| 38 | |
|---|
| 39 | /** |
|---|
| 40 | * Page を初期化する. |
|---|
| 41 | * |
|---|
| 42 | * @return void |
|---|
| 43 | */ |
|---|
| 44 | function init() { |
|---|
| 45 | parent::init(); |
|---|
| 46 | $this->tpl_mainpage = 'design/main_edit.tpl'; |
|---|
| 47 | $this->tpl_subnavi = 'design/subnavi.tpl'; |
|---|
| 48 | $this->user_URL = USER_URL; |
|---|
| 49 | $this->text_row = 13; |
|---|
| 50 | $this->tpl_subno = "main_edit"; |
|---|
| 51 | $this->tpl_mainno = "design"; |
|---|
| 52 | $this->tpl_subtitle = 'ページ詳細編集'; |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | /** |
|---|
| 56 | * Page のプロセス. |
|---|
| 57 | * |
|---|
| 58 | * @return void |
|---|
| 59 | */ |
|---|
| 60 | function process() { |
|---|
| 61 | $objView = new SC_AdminView(); |
|---|
| 62 | $this->objLayout = new SC_Helper_PageLayout_Ex(); |
|---|
| 63 | |
|---|
| 64 | // 認証可否の判定 |
|---|
| 65 | $objSess = new SC_Session(); |
|---|
| 66 | SC_Utils_Ex::sfIsSuccess($objSess); |
|---|
| 67 | |
|---|
| 68 | // ページ一覧を取得 |
|---|
| 69 | $this->arrPageList = $this->objLayout->lfgetPageData(); |
|---|
| 70 | |
|---|
| 71 | // ブロックIDを取得 |
|---|
| 72 | if (isset($_POST['page_id'])) { |
|---|
| 73 | $page_id = $_POST['page_id']; |
|---|
| 74 | }else if (isset($_GET['page_id'])){ |
|---|
| 75 | $page_id = $_GET['page_id']; |
|---|
| 76 | }else{ |
|---|
| 77 | $page_id = ''; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | $this->page_id = $page_id; |
|---|
| 81 | |
|---|
| 82 | // メッセージ表示 |
|---|
| 83 | if (isset($_GET['msg']) && $_GET['msg'] == "on"){ |
|---|
| 84 | $this->tpl_onload="alert('登録が完了しました。');"; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | // page_id が指定されている場合にはテンプレートデータの取得 |
|---|
| 88 | if (is_numeric($page_id) and $page_id != '') { |
|---|
| 89 | $arrPageData = $this->objLayout->lfgetPageData(" page_id = ? " , array($page_id)); |
|---|
| 90 | |
|---|
| 91 | if ($arrPageData[0]['tpl_dir'] === "") { |
|---|
| 92 | $this->arrErr['page_id_err'] = "※ 指定されたページは編集できません。"; |
|---|
| 93 | // 画面の表示 |
|---|
| 94 | $objView->assignobj($this); |
|---|
| 95 | $objView->display(MAIN_FRAME); |
|---|
| 96 | exit; |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | // テンプレートファイルが存在していれば読み込む |
|---|
| 100 | $tpl_file = USER_TEMPLATE_PATH . "/" . TEMPLATE_NAME . "/" . $arrPageData[0]['filename'] . ".tpl"; |
|---|
| 101 | if (file_exists($tpl_file)){ |
|---|
| 102 | $arrPageData[0]['tpl_data'] = file_get_contents($tpl_file); |
|---|
| 103 | // 存在してなければ, 指定されたテンプレートのファイルを読み込む |
|---|
| 104 | } else { |
|---|
| 105 | $arrPageData[0]['tpl_data'] = file_get_contents(TEMPLATE_DIR . $arrPageData[0]['filename'] . ".tpl"); |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | // チェックボックスの値変更 |
|---|
| 109 | $arrPageData[0]['header_chk'] = SC_Utils_Ex::sfChangeCheckBox($arrPageData[0]['header_chk'], true); |
|---|
| 110 | $arrPageData[0]['footer_chk'] = SC_Utils_Ex::sfChangeCheckBox($arrPageData[0]['footer_chk'], true); |
|---|
| 111 | |
|---|
| 112 | // ディレクトリを画面表示用に編集 |
|---|
| 113 | $arrPageData[0]['directory'] = str_replace(USER_DIR, '', $arrPageData[0]['php_dir']); |
|---|
| 114 | |
|---|
| 115 | $this->arrPageData = $arrPageData[0]; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | // プレビュー処理 |
|---|
| 119 | if (!isset($_POST['mode'])) $_POST['mode'] = ""; |
|---|
| 120 | |
|---|
| 121 | if ($_POST['mode'] == 'preview') { |
|---|
| 122 | |
|---|
| 123 | $page_id_old = $page_id; |
|---|
| 124 | // プレビューの場合ページIDを0にセットする。 |
|---|
| 125 | $page_id = "0"; |
|---|
| 126 | $url = basename($_POST['url']); |
|---|
| 127 | |
|---|
| 128 | $tmpPost = $_POST; |
|---|
| 129 | $tmpPost['page_id'] = $page_id; |
|---|
| 130 | $tmpPost['url'] = $url; |
|---|
| 131 | $tmpPost['tpl_dir'] = USER_PATH . "templates/preview/"; |
|---|
| 132 | |
|---|
| 133 | $arrPreData = $this->objLayout->lfgetPageData("page_id = ?" , array($page_id)); |
|---|
| 134 | |
|---|
| 135 | // tplファイルの削除 (XXX: 処理の意図が不明。存在していると都合が悪いファイル?) |
|---|
| 136 | $del_tpl = USER_PATH . "templates/" . $arrPreData[0]['filename'] . '.tpl'; |
|---|
| 137 | if (file_exists($del_tpl)){ |
|---|
| 138 | unlink($del_tpl); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | // DBへデータを更新する |
|---|
| 142 | $this->lfEntryPageData($tmpPost); |
|---|
| 143 | |
|---|
| 144 | // TPLファイル作成 |
|---|
| 145 | $preview_tpl = USER_PATH . "templates/preview/" . TEMPLATE_NAME . "/" . $url . '.tpl'; |
|---|
| 146 | $this->lfCreateFile($preview_tpl); |
|---|
| 147 | |
|---|
| 148 | // blocposition を削除 |
|---|
| 149 | $objDBConn = new SC_DbConn; // DB操作オブジェクト |
|---|
| 150 | $sql = 'delete from dtb_blocposition where page_id = 0'; |
|---|
| 151 | $ret = $objDBConn->query($sql); |
|---|
| 152 | |
|---|
| 153 | if ($page_id_old != "") { |
|---|
| 154 | // 登録データを取得 |
|---|
| 155 | $sql = "SELECT 0, target_id, bloc_id, bloc_row FROM dtb_blocposition WHERE page_id = ?"; |
|---|
| 156 | $ret = $objDBConn->getAll($sql,array($page_id_old)); |
|---|
| 157 | |
|---|
| 158 | if (count($ret) > 0) { |
|---|
| 159 | |
|---|
| 160 | // blocposition を複製 |
|---|
| 161 | $sql = " insert into dtb_blocposition ("; |
|---|
| 162 | $sql .= " page_id,"; |
|---|
| 163 | $sql .= " target_id,"; |
|---|
| 164 | $sql .= " bloc_id,"; |
|---|
| 165 | $sql .= " bloc_row"; |
|---|
| 166 | $sql .= " )values(?, ?, ?, ?)"; |
|---|
| 167 | |
|---|
| 168 | // 取得件数文INSERT実行 |
|---|
| 169 | foreach($ret as $key => $val){ |
|---|
| 170 | $ret = $objDBConn->query($sql,$val); |
|---|
| 171 | } |
|---|
| 172 | } |
|---|
| 173 | } |
|---|
| 174 | $_SESSION['preview'] = "ON"; |
|---|
| 175 | $this->sendRedirect($this->getLocation(URL_DIR . "preview/index.php", array("filename" => $arrPageData[0]["filename"]))); |
|---|
| 176 | exit; |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | // データ登録処理 |
|---|
| 180 | if ($_POST['mode'] == 'confirm') { |
|---|
| 181 | |
|---|
| 182 | // エラーチェック |
|---|
| 183 | $this->arrErr = $this->lfErrorCheck($_POST); |
|---|
| 184 | |
|---|
| 185 | // エラーがなければ更新処理を行う |
|---|
| 186 | if (count($this->arrErr) == 0) { |
|---|
| 187 | // DBへデータを更新する |
|---|
| 188 | $this->lfEntryPageData($_POST); |
|---|
| 189 | |
|---|
| 190 | // ベースデータでなければファイルを削除し、PHPファイルを作成する |
|---|
| 191 | if (!$this->objLayout->lfCheckBaseData($page_id)) { |
|---|
| 192 | // ファイル削除 |
|---|
| 193 | $this->objLayout->lfDelFile($arrPageData[0]); |
|---|
| 194 | // PHPファイル作成 |
|---|
| 195 | $this->lfCreatePHPFile($_POST['url']); |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | // TPLファイル作成 |
|---|
| 199 | $cre_tpl = USER_TEMPLATE_PATH . "/" . TEMPLATE_NAME . "/" . basename($_POST['url']) . '.tpl'; |
|---|
| 200 | $this->lfCreateFile($cre_tpl); |
|---|
| 201 | |
|---|
| 202 | // 新規作成の場合、 |
|---|
| 203 | if ($page_id == '') { |
|---|
| 204 | // ページIDを取得する |
|---|
| 205 | $arrPageData = $this->objLayout->lfgetPageData(" url = ? AND page_id <> 0" , array(USER_URL.$_POST['url'] . ".php")); |
|---|
| 206 | $page_id = $arrPageData[0]['page_id']; |
|---|
| 207 | } |
|---|
| 208 | $this->sendRedirect($this->getLocation("./main_edit.php", |
|---|
| 209 | array("page_id" => $page_id, |
|---|
| 210 | "msg" => "on"))); |
|---|
| 211 | exit; |
|---|
| 212 | } else { |
|---|
| 213 | // エラーがあれば入力時のデータを表示する |
|---|
| 214 | $this->arrPageData = $_POST; |
|---|
| 215 | $this->arrPageData['header_chk'] = SC_Utils_Ex::sfChangeCheckBox(SC_Utils_Ex::sfChangeCheckBox($_POST['header_chk']), true); |
|---|
| 216 | $this->arrPageData['footer_chk'] = SC_Utils_Ex::sfChangeCheckBox(SC_Utils_Ex::sfChangeCheckBox($_POST['footer_chk']), true); |
|---|
| 217 | $this->arrPageData['directory'] = ''; |
|---|
| 218 | $this->arrPageData['filename'] = $_POST['url']; |
|---|
| 219 | } |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | // データ削除処理 ベースデータでなければファイルを削除 |
|---|
| 223 | if ($_POST['mode'] == 'delete' and !$this->objLayout->lfCheckBaseData($page_id)) { |
|---|
| 224 | $this->objLayout->lfDelPageData($_POST['page_id']); |
|---|
| 225 | $this->sendRedirect($this->getLocation("./main_edit.php")); |
|---|
| 226 | exit; |
|---|
| 227 | } |
|---|
| 228 | |
|---|
| 229 | // 画面の表示 |
|---|
| 230 | $objView->assignobj($this); |
|---|
| 231 | $objView->display(MAIN_FRAME); |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | /** |
|---|
| 235 | * デストラクタ. |
|---|
| 236 | * |
|---|
| 237 | * @return void |
|---|
| 238 | */ |
|---|
| 239 | function destroy() { |
|---|
| 240 | parent::destroy(); |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | /** |
|---|
| 244 | * ブロック情報を更新する. |
|---|
| 245 | * |
|---|
| 246 | * @param array $arrData 更新データ |
|---|
| 247 | * @return integer 更新結果 |
|---|
| 248 | */ |
|---|
| 249 | function lfEntryPageData($arrData){ |
|---|
| 250 | $objDBConn = new SC_DbConn; // DB操作オブジェクト |
|---|
| 251 | $sql = ""; // データ更新SQL生成用 |
|---|
| 252 | $ret = ""; // データ更新結果格納用 |
|---|
| 253 | $arrUpdData = array(); // 更新データ生成用 |
|---|
| 254 | $arrChk = array(); // 排他チェック用 |
|---|
| 255 | |
|---|
| 256 | // 更新データの変換 |
|---|
| 257 | $arrUpdData = $this->lfGetUpdData($arrData); |
|---|
| 258 | |
|---|
| 259 | // データが存在しているかチェックを行う |
|---|
| 260 | if($arrData['page_id'] !== ''){ |
|---|
| 261 | $arrChk = $this->objLayout->lfgetPageData("page_id = ?", array($arrData['page_id'])); |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | // page_id が空 若しくは データが存在していない場合にはINSERTを行う |
|---|
| 265 | if ($arrData['page_id'] === '' or !isset($arrChk[0])) { |
|---|
| 266 | // SQL生成 |
|---|
| 267 | $sql = " INSERT INTO dtb_pagelayout "; |
|---|
| 268 | $sql .= " ( "; |
|---|
| 269 | $sql .= " page_name"; |
|---|
| 270 | $sql .= " ,url"; |
|---|
| 271 | $sql .= " ,php_dir"; |
|---|
| 272 | $sql .= " ,tpl_dir"; |
|---|
| 273 | $sql .= " ,filename"; |
|---|
| 274 | $sql .= " ,header_chk"; |
|---|
| 275 | $sql .= " ,footer_chk"; |
|---|
| 276 | $sql .= " ,update_url"; |
|---|
| 277 | $sql .= " ,create_date"; |
|---|
| 278 | $sql .= " ,update_date"; |
|---|
| 279 | $sql .= " ) VALUES ( ?,?,?,?,?,?,?,?,now(),now() )"; |
|---|
| 280 | $sql .= " "; |
|---|
| 281 | } else { |
|---|
| 282 | // データが存在してる場合にはアップデートを行う |
|---|
| 283 | // SQL生成 |
|---|
| 284 | $sql = " UPDATE dtb_pagelayout "; |
|---|
| 285 | $sql .= " SET"; |
|---|
| 286 | $sql .= " page_name = ? "; |
|---|
| 287 | $sql .= " ,url = ? "; |
|---|
| 288 | $sql .= " ,php_dir = ? "; |
|---|
| 289 | $sql .= " ,tpl_dir = ? "; |
|---|
| 290 | $sql .= " ,filename = ? "; |
|---|
| 291 | $sql .= " ,header_chk = ? "; |
|---|
| 292 | $sql .= " ,footer_chk = ? "; |
|---|
| 293 | $sql .= " ,update_url = ? "; |
|---|
| 294 | $sql .= " ,update_date = now() "; |
|---|
| 295 | $sql .= " WHERE page_id = ?"; |
|---|
| 296 | $sql .= " "; |
|---|
| 297 | |
|---|
| 298 | // 更新データにブロックIDを追加 |
|---|
| 299 | array_push($arrUpdData, $arrData['page_id']); |
|---|
| 300 | } |
|---|
| 301 | |
|---|
| 302 | // SQL実行 |
|---|
| 303 | $ret = $objDBConn->query($sql,$arrUpdData); |
|---|
| 304 | |
|---|
| 305 | return $ret; |
|---|
| 306 | } |
|---|
| 307 | |
|---|
| 308 | /** |
|---|
| 309 | * DBへ更新を行うデータを生成する. |
|---|
| 310 | * |
|---|
| 311 | * @param array $arrData 更新データ |
|---|
| 312 | * @return array 更新データ |
|---|
| 313 | */ |
|---|
| 314 | function lfGetUpdData($arrData){ |
|---|
| 315 | // ベースデータの場合には変更しない。 |
|---|
| 316 | if ($this->objLayout->lfCheckBaseData($arrData['page_id'])) { |
|---|
| 317 | $arrPageData = $this->objLayout->lfgetPageData( ' page_id = ? ' , array($arrData['page_id'])); |
|---|
| 318 | |
|---|
| 319 | $name = $arrPageData[0]['page_name'] ; |
|---|
| 320 | $url = $arrPageData[0]['url']; |
|---|
| 321 | $php_dir = $arrPageData[0]['php_dir']; |
|---|
| 322 | $filename = $arrPageData[0]['filename']; |
|---|
| 323 | } else { |
|---|
| 324 | $name = $arrData['page_name'] ; |
|---|
| 325 | $url = USER_DIR . $arrData['url'] . '.php'; |
|---|
| 326 | $php_dir = dirname($url); |
|---|
| 327 | if ($php_dir == '.') { |
|---|
| 328 | $php_dir = ''; |
|---|
| 329 | } else { |
|---|
| 330 | $php_dir .= '/'; |
|---|
| 331 | } |
|---|
| 332 | $tpl_dir = substr(TPL_DIR, strlen(URL_DIR)); |
|---|
| 333 | $filename = basename($arrData['url']); // 拡張子を付加しない |
|---|
| 334 | } |
|---|
| 335 | |
|---|
| 336 | // 更新データ配列の作成 |
|---|
| 337 | $arrUpdData = array( |
|---|
| 338 | $name // 名称 |
|---|
| 339 | ,$url // URL |
|---|
| 340 | ,$php_dir // PHPディレクトリ |
|---|
| 341 | ,$tpl_dir // TPLディレクトリ |
|---|
| 342 | ,$filename // ファイル名 |
|---|
| 343 | ,SC_Utils_Ex::sfChangeCheckBox($arrData['header_chk']) // ヘッダー使用 |
|---|
| 344 | ,SC_Utils_Ex::sfChangeCheckBox($arrData['footer_chk']) // フッター使用 |
|---|
| 345 | ,$_SERVER['HTTP_REFERER'] // 更新URL |
|---|
| 346 | ); |
|---|
| 347 | |
|---|
| 348 | return $arrUpdData; |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | /** |
|---|
| 352 | * 入力項目のエラーチェックを行う. |
|---|
| 353 | * |
|---|
| 354 | * @param array $arrData 入力データ |
|---|
| 355 | * @return array エラー情報 |
|---|
| 356 | */ |
|---|
| 357 | function lfErrorCheck($array) { |
|---|
| 358 | $objErr = new SC_CheckError($array); |
|---|
| 359 | $objErr->doFunc(array("名称", "page_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 360 | $objErr->doFunc(array("URL", "url", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
|---|
| 361 | |
|---|
| 362 | // URLチェック |
|---|
| 363 | $okUrl = true; |
|---|
| 364 | foreach (explode('/', $array['url']) as $url_part) { |
|---|
| 365 | if (!ereg( '^[a-zA-Z0-9:_~\.-]+$', $url_part)) { |
|---|
| 366 | $okUrl = false; |
|---|
| 367 | } |
|---|
| 368 | if ($url_part == '.' || $url_part == '..') { |
|---|
| 369 | $okUrl = false; |
|---|
| 370 | } |
|---|
| 371 | } |
|---|
| 372 | if (!$okUrl) { |
|---|
| 373 | $objErr->arrErr['url'] = "※ URLを正しく入力してください。<br />"; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | // 同一のURLが存在している場合にはエラー |
|---|
| 377 | $sqlWhere = ''; |
|---|
| 378 | $params = array(); |
|---|
| 379 | |
|---|
| 380 | $sqlWhere .= ' (url = ? OR url = ?)'; |
|---|
| 381 | $params[] = USER_DIR . $array['url'] . '.php'; |
|---|
| 382 | $params[] = USER_URL . $array['url'] . '.php'; // 従来形式 |
|---|
| 383 | |
|---|
| 384 | // プレビュー用のレコードは除外 |
|---|
| 385 | $sqlWhere .= ' AND page_id <> 0'; |
|---|
| 386 | |
|---|
| 387 | // 変更の場合、自身のレコードは除外 |
|---|
| 388 | if (strlen($array['page_id']) != 0) { |
|---|
| 389 | $sqlWhere .= ' AND page_id <> ?'; |
|---|
| 390 | $params[] = $array['page_id']; |
|---|
| 391 | } |
|---|
| 392 | |
|---|
| 393 | $arrChk = $this->objLayout->lfgetPageData($sqlWhere , $params); |
|---|
| 394 | |
|---|
| 395 | if (count($arrChk) >= 1) { |
|---|
| 396 | $objErr->arrErr['url'] = '※ 同じURLのデータが存在しています。別のURを付けてください。<br />'; |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | return $objErr->arrErr; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | /** |
|---|
| 403 | * ファイルを作成する. |
|---|
| 404 | * |
|---|
| 405 | * @param string $path テンプレートファイルのパス |
|---|
| 406 | * @return void |
|---|
| 407 | */ |
|---|
| 408 | function lfCreateFile($path){ |
|---|
| 409 | |
|---|
| 410 | // ディレクトリが存在していなければ作成する |
|---|
| 411 | if (!is_dir(dirname($path))) { |
|---|
| 412 | mkdir(dirname($path)); |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | // ファイル作成 |
|---|
| 416 | $fp = fopen($path,"w"); |
|---|
| 417 | fwrite($fp, $_POST['tpl_data']); // FIXME いきなり POST はちょっと... |
|---|
| 418 | fclose($fp); |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | /** |
|---|
| 422 | * PHPファイルを作成する. |
|---|
| 423 | * |
|---|
| 424 | * @param string $path PHPファイルのパス |
|---|
| 425 | * @return void |
|---|
| 426 | */ |
|---|
| 427 | function lfCreatePHPFile($url){ |
|---|
| 428 | |
|---|
| 429 | $path = USER_PATH . $url . ".php"; |
|---|
| 430 | |
|---|
| 431 | // php保存先ディレクトリが存在していなければ作成する |
|---|
| 432 | if (!is_dir(dirname($path))) { |
|---|
| 433 | mkdir(dirname($path)); |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | // ベースとなるPHPファイルの読み込み |
|---|
| 437 | if (file_exists(USER_DEF_PHP)){ |
|---|
| 438 | $php_data = file_get_contents(USER_DEF_PHP); |
|---|
| 439 | } |
|---|
| 440 | |
|---|
| 441 | // require.phpの場所を書き換える |
|---|
| 442 | $php_data = str_replace("###require###", str_repeat('../', substr_count($url, '/')) . '../require.php', $php_data); |
|---|
| 443 | |
|---|
| 444 | // phpファイルの作成 |
|---|
| 445 | $fp = fopen($path,"w"); |
|---|
| 446 | fwrite($fp, $php_data); |
|---|
| 447 | fclose($fp); |
|---|
| 448 | } |
|---|
| 449 | |
|---|
| 450 | } |
|---|
| 451 | ?> |
|---|