function update(array $arrPlugin, SC_Plugin_Installer $installer) { $base_dir = dirname(__FILE__); GC_Utils_Ex::gfPrintLog("[" . $arrPlugin["plugin_code"] . "]更新処理を実行します。", PLUGIN_LOG_REALFILE, FALSE); $log = ""; $xdir = PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"]; if (!is_dir($xdir . "_" . date("Ymd") . "/")) { rename($xdir . "/", $xdir . "_" . date("Ymd") . "/"); } SC_Helper_FileManager_Ex::deleteFile($xdir . "/", false); $log .= SC_Utils_Ex::sfCopyDir("{$base_dir}/", PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"] . "/", '', true); // logo コピー $installer->copyDirectory("copy/plugin_dir/", ""); GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE, false); $core = new SupportDeviceCore($arrPlugin); $plugin_version = $arrPlugin["plugin_version"]; switch ($plugin_version) { case "0.0.0": case "0.0.1": // 再インストール $core->install($arrPlugin, $installer); $core->update($arrPlugin, $installer, "0.0.0"); break; default: $core->update($arrPlugin, $installer, $plugin_version); break; } $core->createCash(); $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); GC_Utils_Ex::gfPrintLog("[" . $arrPlugin["plugin_code"] . "]更新処理を実行完了しました。", PLUGIN_LOG_REALFILE, FALSE); }
function install(array $arrPlugin, SC_Plugin_Installer $installer) { $plugin_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR; $upload_plugin_dir = PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"] . DIRECTORY_SEPARATOR; $backup_plugin_dir = PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"] . "_" . date("Ymd") . DIRECTORY_SEPARATOR; if (!is_dir($backup_plugin_dir)) { SC_Utils_Ex::sfCopyDir($upload_plugin_dir, $backup_plugin_dir); } SC_Helper_FileManager_Ex::deleteFile($upload_plugin_dir, false); SC_Utils_Ex::sfCopyDir($plugin_dir . "/", $upload_plugin_dir); SC_Utils_Ex::sfCopyDir($plugin_dir . "/copy/Smarty/templates/admin/", TEMPLATE_ADMIN_REALDIR); SC_Utils_Ex::sfCopyDir($plugin_dir . "/copy/modules/", DATA_REALDIR . "module/"); // logo コピー $installer->copyDirectory("copy/plugin_dir/", ""); $table = "dtb_products"; $fields = array('auto_display_status' => $this->intColumn('自動公開'), 'auto_display_start_date' => $this->timestampColumn('公開開始日'), 'auto_display_end_date' => $this->timestampColumn('公開終了日')); $type = "timestamp"; $definition = compact("type"); foreach ($fields as $name => $define) { $this->objDb->sfColumnExists($table, $name, $define["type"], "", true); $this->fieldComment($installer, $table, $name, $define["comment"]); switch ($define["type"]) { case "timestamp": break; default: continue; } $change = array(); $change[$name] = compact('definition'); $this->objManager->alterTable($table, compact("change"), false); } $this->objQuery->update("dtb_products", array(), "auto_display_start_date IS NULL", array(), array("auto_display_start_date" => "create_date")); $masterfields = array("id" => $this->intColumn("ID"), "name" => $this->textColumn("NAME"), "rank" => $this->intColumn("RANK")); $table = "atd_mtb_auto_display_status"; if ($this->objDb->sfColumnExists($table, "id") == false) { $this->objManager->createTable($table, $masterfields); } foreach ($masterfields as $name => $define) { $this->objDb->sfColumnExists($table, $name, $define["type"], "", true); $this->fieldComment($installer, $table, $name, $define["comment"]); } $this->masterdata->deleteMasterData($table); $this->masterdata->clearCache($table); $this->masterdata->registMasterData($table, array(), explode(",", "常時公開,時限公開")); // $this->insertMasterData ( "PRODUCTS_RESULT_ROWSPAN", 1, '管理画面/商品管理一覧 行結合数' ); // $this->insertMasterData ( "PRODUCTS_RESULT_COLUMN", 5, '管理画面/商品管理一覧 列位置' ); // $this->insertMasterData ( "PRODUCTS_SEARCH_AUTO_DISPLAY", 1, '検索画面表示設定(1: ON/ 0:OFF)' ); // $this->insertMasterData ( "PRODUCTS_DETAIL_AUTO_DISPLAY", 1, '検索画面表示設定(1: ON/ 0:OFF)' ); }
function update(array $arrPlugin, SC_Plugin_Installer $installer) { require_once DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "KisekaeTouchCore.php"; $plugin_code = $arrPlugin["plugin_code"]; $date = date("Ymd"); define("KTC_PLG_ORG_DIR", PLUGIN_UPLOAD_REALDIR . "{$plugin_code}/"); define("KTC_PLG_UPD_DIR", DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR); define("KTC_PLG_BKU_DIR", PLUGIN_UPLOAD_REALDIR . "{$plugin_code}_{$date}/"); if (file_exists(KTC_PLG_BKU_DIR)) { // nop } else { SC_Utils_Ex::recursiveMkdir(KTC_PLG_BKU_DIR); $log = SC_Utils_Ex::sfCopyDir(KTC_PLG_ORG_DIR, KTC_PLG_BKU_DIR, "", TRUE); GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE, FALSE); } SC_Helper_FileManager_Ex::deleteFile(KTC_PLG_ORG_DIR, FALSE); $log = SC_Utils_Ex::sfCopyDir(KTC_PLG_UPD_DIR, KTC_PLG_ORG_DIR, "", TRUE); GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE, FALSE); $installer->copyDirectory("copy/plugin_dir/", ""); $core = new KisekaeTouchCore($arrPlugin); $plugin_version = $arrPlugin["plugin_version"]; $core->update($arrPlugin, $installer, $plugin_version); $core->createCash(); }
function sfCopyDir($src, $des, $mess = '', $override = false) { if (!is_dir($src)) { return false; } $oldmask = umask(0); $mod = stat($src); // ディレクトリがなければ作成する if (!file_exists($des)) { if (!mkdir($des, $mod[2])) { echo 'path:' . $des; } } $fileArray = glob($src . '*'); if (is_array($fileArray)) { foreach ($fileArray as $data_) { // CVS管理ファイルはコピーしない if (strpos($data_, '/CVS/Entries') !== false) { break; } if (strpos($data_, '/CVS/Repository') !== false) { break; } if (strpos($data_, '/CVS/Root') !== false) { break; } mb_ereg("^(.*[\\/])(.*)", $data_, $matches); $data = $matches[2]; if (is_dir($data_)) { $mess = SC_Utils_Ex::sfCopyDir($data_ . '/', $des . $data . '/', $mess); } else { if (!$override && file_exists($des . $data)) { $mess .= $des . $data . ":ファイルが存在します\n"; } else { if (@copy($data_, $des . $data)) { $mess .= $des . $data . ":コピー成功\n"; } else { $mess .= $des . $data . ":コピー失敗\n"; } } $mod = stat($data_); } } } umask($oldmask); return $mess; }
/** * ファイルコピー * * @param string $srcPath * @param string $dstPath * @param string $dirFlg * @return boolean */ static function lfCopyFile($srcPath, $dstPath, $dirFlg = false) { if ($dirFlg) { if (SC_Utils_Ex::sfCopyDir($srcPath, $dstPath) === false) { AddProduct::lfTriggerError("'" . $srcPath . "'から、'" . $dstPath . "へのディレクトリコピーに失敗しました"); } } else { if (copy($srcPath, $dstPath) === false) { AddProduct::lfTriggerError("'" . $srcPath . "'から、'" . $dstPath . "'へのコピーに失敗しました"); } } return true; }
/** * ダウンロードを実行する. * * 指定のテンプレートをアーカイブし, ブラウザに出力する. * 失敗した場合は, エラーメッセージを出力し, false を返す. * * @param string $template_code テンプレートコード * @return boolean 成功した場合 true; 失敗した場合 false */ public function doDownload($template_code) { $from_dir = USER_TEMPLATE_REALDIR . $template_code . '/'; $to_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/'; if (SC_Utils_Ex::recursiveMkdir($to_dir) === false) { $this->arrErr['err'] = '※ ディレクトリの作成に失敗しました<br />'; return false; } SC_Utils_Ex::sfCopyDir($from_dir, $to_dir); if (SC_Helper_FileManager_Ex::downloadArchiveFiles(SMARTY_TEMPLATES_REALDIR . $template_code, $template_code) === false) { $this->arrErr['err'] = '※ アーカイブファイルの作成に失敗しました<br />'; return false; } return true; }
/** * DBおよびファイルシステムにテンプレートパッケージを追加する. * * エラーが発生した場合は, エラーを出力し, false を返す. * * @param SC_FormParam $objFormParam SC_FormParamのインスタンス * @param SC_UploadFile_Ex $objUpFile SC_UploadFileのインスタンス * @return boolean 成功した場合 true; 失敗した場合 false */ public function doUpload($objFormParam, $objUpFile) { $template_code = $objFormParam->getValue('template_code'); $template_name = $objFormParam->getValue('template_name'); $device_type_id = $objFormParam->getValue('device_type_id'); $template_dir = SMARTY_TEMPLATES_REALDIR . $template_code; $compile_dir = DATA_REALDIR . 'Smarty/templates_c/' . $template_code; $objQuery =& SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); $arrValues = array('template_code' => $template_code, 'device_type_id' => $device_type_id, 'template_name' => $template_name, 'create_date' => 'CURRENT_TIMESTAMP', 'update_date' => 'CURRENT_TIMESTAMP'); $objQuery->insert('dtb_templates', $arrValues); // フォルダ作成 if (!file_exists($template_dir)) { if (!mkdir($template_dir)) { $this->arrErr['err'] = '※ テンプレートフォルダが作成できませんでした。<br/>'; $objQuery->rollback(); return false; } } if (!file_exists($compile_dir)) { if (!mkdir($compile_dir)) { $this->arrErr['err'] = '※ Smarty コンパイルフォルダが作成できませんでした。<br/>'; $objQuery->rollback(); return false; } } // 一時フォルダから保存ディレクトリへ移動 $objUpFile->moveTempFile(); // 解凍 if (!SC_Helper_FileManager_Ex::unpackFile($template_dir . '/' . $_FILES['template_file']['name'])) { $this->arrErr['err'] = '※ テンプレートファイルの解凍に失敗しました。<br/>'; $objQuery->rollback(); return false; } // ユーザデータの下のファイルをコピーする $from_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/'; $to_dir = USER_REALDIR . 'packages/' . $template_code . '/'; if (!SC_Utils_Ex::recursiveMkdir($to_dir)) { $this->arrErr['err'] = '※ ' . $to_dir . ' の作成に失敗しました。<br/>'; $objQuery->rollback(); return false; } SC_Utils_Ex::sfCopyDir($from_dir, $to_dir); $objQuery->commit(); return true; }
function lfDispStep0_2($objPage) { global $objWebParam; global $objDBParam; // hiddenに入力値を保持 $objPage->arrHidden = $objWebParam->getHashArray(); // hiddenに入力値を保持 $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray()); $objPage->arrHidden['db_skip'] = $_POST['db_skip']; $objPage->arrHidden['agreement'] = $_POST['agreement']; $objPage->tpl_mainpage = 'step0_1.tpl'; $objPage->tpl_mode = 'step0_1'; // ファイルコピー $objPage->copy_mess = SC_Utils_Ex::sfCopyDir("./user_data/", "../user_data/", $objPage->copy_mess); $objPage->copy_mess = SC_Utils_Ex::sfCopyDir("./save_image/", "../upload/save_image/", $objPage->copy_mess); return $objPage; }
/** * ダウンロードを実行する. * * 指定のテンプレートをアーカイブし, ブラウザに出力する. * 失敗した場合は, エラーメッセージを出力し, false を返す. * * @param string $template_code テンプレートコード * @return boolean 成功した場合 true; 失敗した場合 false */ function doDownload($template_code) { $from_dir = USER_TEMPLATE_REALDIR . $template_code . '/'; $to_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/'; if (SC_Utils_Ex::recursiveMkdir($to_dir) === false) { $this->arrErr['err'] = t('c_* Directory creation failed<br />_01'); return false; } SC_Utils_Ex::sfCopyDir($from_dir, $to_dir); if (SC_Helper_FileManager_Ex::downloadArchiveFiles(SMARTY_TEMPLATES_REALDIR . $template_code, $template_code) === false) { $this->arrErr['err'] = t('c_* Archive file creation failed<br />_01'); return false; } return true; }
/** * 初回インストール用 テンプレート更新 * * @param unknown $arrPlugin * @param SC_Plugin_Installer $objPluginInstaller */ function updateTemplate($arrPlugin, $objPluginInstaller = null) { if (file_exists(SMARTY_TEMPLATES_REALDIR . "kisekae/")) { $log .= SC_Utils_Ex::sfCopyDir(SMARTPHONE_TEMPLATE_REALDIR, SMARTY_TEMPLATES_REALDIR . "kisekae/"); $log .= SC_Utils_Ex::sfCopyDir(USER_TEMPLATE_REALDIR . "sphone/", USER_TEMPLATE_REALDIR . "kisekae/"); } if (file_exists(SMARTY_TEMPLATES_REALDIR . "kisekae_pc/")) { $log .= SC_Utils_Ex::sfCopyDir(TEMPLATE_REALDIR, SMARTY_TEMPLATES_REALDIR . "kisekae_pc/"); $log .= SC_Utils_Ex::sfCopyDir(USER_TEMPLATE_REALDIR . "default/", USER_TEMPLATE_REALDIR . "kisekae_pc/"); } if ($log) { GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE); } $templates = array("template_name" => "きせかえタッチ用テンプレート", "create_date" => "NOW()", "update_date" => "NOW()"); if (!$this->objQuery->exists("dtb_templates", "template_code=?", array("kisekae"))) { $this->objQuery->insert("dtb_templates", array_merge($templates, array("template_code" => "kisekae", "device_type_id" => DEVICE_TYPE_SMARTPHONE))); } if (!$this->objQuery->exists("dtb_templates", "template_code=?", array("kisekae_pc"))) { $this->objQuery->insert("dtb_templates", array_merge($templates, array("template_code" => "kisekae_pc", "device_type_id" => DEVICE_TYPE_PC))); } $this->masterdata->updateMasterData("mtb_constants", array(), array("TEMPLATE_NAME" => "'kisekae_pc'", "SMARTPHONE_TEMPLATE_NAME" => "'kisekae'")); $bloc = array('device_type_id' => DEVICE_TYPE_SMARTPHONE, 'deletable_flg' => 0, "create_date" => "NOW()", "update_date" => "NOW()"); $arrSql = array("bloc_id" => "(SELECT max(bloc_id)+1 FROM dtb_bloc)"); $file = "new_contents"; if (!$this->existBloc(DEVICE_TYPE_SMARTPHONE, $file)) { $this->objQuery->insert("dtb_bloc", $this->bloc($bloc, "【スマートパス】 新着コンテンツ", $file), $arrSql); } $file = "header_spass"; $file2 = "header"; if (!$this->existBloc(DEVICE_TYPE_SMARTPHONE, $file)) { $this->objQuery->insert("dtb_bloc", $this->bloc($bloc, "【スマートパス】 ヘッダー共通", $file, "{$file2}.php"), $arrSql); } $file = "navi_fotter_spass"; $file2 = "navi_fotter"; if (!$this->existBloc(DEVICE_TYPE_SMARTPHONE, $file)) { $this->objQuery->insert("dtb_bloc", $this->bloc($bloc, "【スマートパス】 フッターナビ共通", $file, "{$file2}.php"), $arrSql); } $file = "character_search_spass"; $file2 = "character_search"; if (!$this->existBloc(DEVICE_TYPE_SMARTPHONE, $file)) { $this->objQuery->insert("dtb_bloc", $this->bloc($bloc, "【スマートパス】 キャラクターで探す", $file, "{$file2}.php"), $arrSql); } $file = "settings_css"; if (!$this->existBloc(DEVICE_TYPE_SMARTPHONE, $file)) { $this->objQuery->insert("dtb_bloc", $this->bloc($bloc, "【全ページ】CSS設定", $file, null, true), $arrSql); } else { $this->objQuery->update("dtb_bloc", array("deletable_flg" => '2'), "filename=? AND deletable_flg <> ?", array($file, 2)); } if ($log) { GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE, false); } $pagelayout = array("device_type_id" => DEVICE_TYPE_SMARTPHONE, "header_chk" => 1, "footer_chk" => 1, "edit_flg" => 2, "author" => "", "description" => "", "keyword" => "", "update_url" => "", "create_date" => "NOW()", "update_date" => "NOW()", "meta_robots" => "noindex"); $file = "au/index"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/会員登録", "{$file}.php")); } $file = "au/complete"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/会員登録/完了", "{$file}.php")); } $file = "au/login"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/ログイン", "{$file}.php")); } $file = "au/logout"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/ログアウト", "{$file}.php")); } $file = "au/point_add"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/ポイント追加", "{$file}.php")); } $file = "au/point_add_confirm"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/ポイント追加/確認", "{$file}.php")); } $file = "au/point_add_complete"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/ポイント追加/完了", "{$file}.php")); } $file = "au/refusal"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/会員退会", "{$file}.php")); } $file = "au/refusal_complete"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "auone/会員退会/完了", "{$file}.php")); } $this->objQuery->update("dtb_pagelayout", array(), "rank = 0", array(), array("rank" => "page_id")); $pagelayout["header_chk"] = 0; $pagelayout["footer_chk"] = 0; // products/detail_spass $file = "products/detail_spass"; if (!$this->exist(DEVICE_TYPE_SMARTPHONE, "{$file}.php")) { $this->objQuery->insert("dtb_pagelayout", $this->pagelayout($pagelayout, "商品詳細ページ/スマートパス", "{$file}.php")); } $this->updateTemplate_110($arrPlugin, $objPluginInstaller); }
/** * DBおよびファイルシステムにテンプレートパッケージを追加する. * * エラーが発生した場合は, エラーを出力し, false を返す. * * @param object $objFormParam SC_FormParamのインスタンス * @param object $objUpFile SC_UploadFileのインスタンス * @return boolean 成功した場合 true; 失敗した場合 false */ function doUpload($objFormParam, $objUpFile) { $template_code = $objFormParam->getValue('template_code'); $template_name = $objFormParam->getValue('template_name'); $device_type_id = $objFormParam->getValue('device_type_id'); $template_dir = SMARTY_TEMPLATES_REALDIR . $template_code; $compile_dir = DATA_REALDIR . 'Smarty/templates_c/' . $template_code; $objQuery =& SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); $arrValues = array('template_code' => $template_code, 'device_type_id' => $device_type_id, 'template_name' => $template_name, 'create_date' => 'CURRENT_TIMESTAMP', 'update_date' => 'CURRENT_TIMESTAMP'); $objQuery->insert('dtb_templates', $arrValues); $is_error = false; // フォルダ作成 if (!file_exists($template_dir)) { if (!mkdir($template_dir)) { $this->arrErr['err'] = t('c_* The template folder could not be created.<br/>_01'); $objQuery->rollback(); return false; } } if (!file_exists($compile_dir)) { if (!mkdir($compile_dir)) { $this->arrErr['err'] = t('c_* Smarty compile folder could not be created.<br/>_01'); $objQuery->rollback(); return false; } } // 一時フォルダから保存ディレクトリへ移動 $objUpFile->moveTempFile(); // 解凍 if (!SC_Helper_FileManager_Ex::unpackFile($template_dir . '/' . $_FILES['template_file']['name'])) { $this->arrErr['err'] = t('c_* Decompression of the template file failed.<br/>_01'); $objQuery->rollback(); return false; } // ユーザデータの下のファイルをコピーする $from_dir = SMARTY_TEMPLATES_REALDIR . $template_code . '/_packages/'; $to_dir = USER_REALDIR . 'packages/' . $template_code . '/'; if (!SC_Utils_Ex::recursiveMkdir($to_dir)) { $this->arrErr['err'] = t('c_* T_ARG1 creation failed.<br/>_01', array('T_ARG1' => $to_dir)); $objQuery->rollback(); return false; } SC_Utils_Ex::sfCopyDir($from_dir, $to_dir); $objQuery->commit(); return true; }