| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * http://www.lockon.co.jp/
|
|---|
| 6 | */
|
|---|
| 7 | require_once("../../require.php");
|
|---|
| 8 |
|
|---|
| 9 | class LC_Page {
|
|---|
| 10 |
|
|---|
| 11 | function LC_Page() {
|
|---|
| 12 | $this->tpl_mainpage = 'design/upload.tpl';
|
|---|
| 13 | $this->tpl_subnavi = 'design/subnavi.tpl';
|
|---|
| 14 | $this->tpl_subno = 'template';
|
|---|
| 15 | $this->tpl_subno_template = 'upload';
|
|---|
| 16 | $this->tpl_mainno = "design";
|
|---|
| 17 | $this->tpl_subtitle = '¥¢¥Ã¥×¥í¡¼¥É';
|
|---|
| 18 | $this->template_name = '¥¢¥Ã¥×¥í¡¼¥É';
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | $objPage = new LC_Page();
|
|---|
| 23 | $objView = new SC_AdminView();
|
|---|
| 24 | $objSess = new SC_Session();
|
|---|
| 25 | $objQuery = new SC_Query();
|
|---|
| 26 |
|
|---|
| 27 | // ǧ¾Ú²ÄÈݤÎȽÄê
|
|---|
| 28 | $objSess = new SC_Session();
|
|---|
| 29 | sfIsSuccess($objSess);
|
|---|
| 30 |
|
|---|
| 31 | // ¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹
|
|---|
| 32 | $objUpFile = new SC_UploadFile(TEMPLATE_TEMP_DIR, USER_TEMPLATE_PATH.$_POST['template_code']);
|
|---|
| 33 | // ¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
|
|---|
| 34 | lfInitFile();
|
|---|
| 35 | // ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
|
|---|
| 36 | $objFormParam = new SC_FormParam();
|
|---|
| 37 | // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
|
|---|
| 38 | lfInitParam();
|
|---|
| 39 |
|
|---|
| 40 | switch($_POST['mode']) {
|
|---|
| 41 | case 'upload':
|
|---|
| 42 | $objFormParam->setParam($_POST);
|
|---|
| 43 | $arrRet = $objFormParam->getHashArray();
|
|---|
| 44 |
|
|---|
| 45 | $objPage->arrErr = lfErrorCheck($arrRet);
|
|---|
| 46 |
|
|---|
| 47 | // ¥Õ¥¡¥¤¥ë¤ò°ì»þ¥Õ¥©¥ë¥À¤ØÊݸ
|
|---|
| 48 | $ret = $objUpFile->makeTempFile('template_file', false);
|
|---|
| 49 | if($ret != "") {
|
|---|
| 50 | $objPage->arrErr['template_file'] = $ret;
|
|---|
| 51 | } else if(count($objPage->arrErr) <= 0) {
|
|---|
| 52 | // ¥Õ¥©¥ë¥ÀºîÀ®
|
|---|
| 53 | $ret = @mkdir(USER_TEMPLATE_PATH.$arrRet['template_code']);
|
|---|
| 54 | // °ì»þ¥Õ¥©¥ë¥À¤«¤éÊݸ¥Ç¥£¥ì¥¯¥È¥ê¤Ø°Üư
|
|---|
| 55 | $objUpFile->moveTempFile();
|
|---|
| 56 | // DB¤ËÊݸ
|
|---|
| 57 | lfRegistTemplate($arrRet);
|
|---|
| 58 |
|
|---|
| 59 | $objPage->tpl_onload = "alert('¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤ò¥¢¥Ã¥×¥í¡¼¥É¤·¤Þ¤·¤¿¡£');";
|
|---|
| 60 | }
|
|---|
| 61 | break;
|
|---|
| 62 | default:
|
|---|
| 63 | break;
|
|---|
| 64 | }
|
|---|
| 65 | // ²èÌ̤Îɽ¼¨
|
|---|
| 66 | $objPage->arrForm = $objFormParam->getFormParamList();
|
|---|
| 67 | $objView->assignobj($objPage);
|
|---|
| 68 | $objView->display(MAIN_FRAME);
|
|---|
| 69 |
|
|---|
| 70 | //---------------------------------------------------------------------------------------------------------------------------------------------------------
|
|---|
| 71 |
|
|---|
| 72 | /*
|
|---|
| 73 | * ´Ø¿ô̾¡§lfInitFile()
|
|---|
| 74 | * ÀâÌÀ¡¡¡§¥Õ¥¡¥¤¥ë¾ðÊó¤Î½é´ü²½
|
|---|
| 75 | */
|
|---|
| 76 | function lfInitFile() {
|
|---|
| 77 | global $objUpFile;
|
|---|
| 78 |
|
|---|
| 79 | $objUpFile->addFile("¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë", 'template_file', array(), TEMPLATE_SIZE, true, 0, 0, false);
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | /*
|
|---|
| 83 | * ´Ø¿ô̾¡§lfInitParam()
|
|---|
| 84 | * ÀâÌÀ¡¡¡§¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
|
|---|
| 85 | */
|
|---|
| 86 | function lfInitParam() {
|
|---|
| 87 | global $objFormParam;
|
|---|
| 88 |
|
|---|
| 89 | $objFormParam->addParam("¥Æ¥ó¥×¥ì¡¼¥È¥³¡¼¥É", "template_code", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
|
|---|
| 90 | $objFormParam->addParam("¥Æ¥ó¥×¥ì¡¼¥È̾", "template_name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | /*
|
|---|
| 94 | * ´Ø¿ô̾¡§lfErrorCheck()
|
|---|
| 95 | * °ú¿ô1 ¡§¥Ñ¥é¥á¡¼¥¿
|
|---|
| 96 | * ÀâÌÀ¡¡¡§¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
|
|---|
| 97 | */
|
|---|
| 98 | function lfErrorCheck($arrList) {
|
|---|
| 99 | global $objQuery;
|
|---|
| 100 | global $objFormParam;
|
|---|
| 101 |
|
|---|
| 102 | $objErr = new SC_CheckError($arrList);
|
|---|
| 103 | $objErr->arrErr = $objFormParam->checkError();
|
|---|
| 104 |
|
|---|
| 105 | if(count($objErr->arrErr) <= 0) {
|
|---|
| 106 | // Ʊ̾¤Î¥Õ¥©¥ë¥À¤¬Â¸ºß¤¹¤ë¾ì¹ç¤Ï¥¨¥é¡¼
|
|---|
| 107 | if(file_exists(USER_TEMPLATE_PATH.$arrList['template_code'])) {
|
|---|
| 108 | $objErr->arrErr['template_code'] = "¢¨ Ʊ̾¤Î¥Õ¥¡¥¤¥ë¤¬¤¹¤Ç¤Ë¸ºß¤·¤Þ¤¹¡£<br/>";
|
|---|
| 109 | }
|
|---|
| 110 | // DB¤Ë¤¹¤Ç¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤¤¤«¥Á¥§¥Ã¥¯
|
|---|
| 111 | $ret = $objQuery->get("dtb_templates", "template_code", "template_code = ?", array($arrList['template_code']));
|
|---|
| 112 | if($ret != "") {
|
|---|
| 113 | $objErr->arrErr['template_code'] = "¢¨ ¤¹¤Ç¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥³¡¼¥É¤Ç¤¹¡£<br/>";
|
|---|
| 114 | }
|
|---|
| 115 | // ¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¥Á¥§¥Ã¥¯(.tar/tar.gz¤Î¤ßµö²Ä)
|
|---|
| 116 | $errFlag = true;
|
|---|
| 117 | $array_ext = explode(".", $_FILES['template_file']['name']);
|
|---|
| 118 | $ext = $array_ext[ count ( $array_ext ) - 1 ];
|
|---|
| 119 | $ext = strtolower($ext);
|
|---|
| 120 | // .tar¥Á¥§¥Ã¥¯
|
|---|
| 121 | if ($ext == 'tar') {
|
|---|
| 122 | $errFlag = false;
|
|---|
| 123 | }
|
|---|
| 124 | $ext = $array_ext[ count ( $array_ext ) - 2 ].$ext;
|
|---|
| 125 | $ext = strtolower($ext);
|
|---|
| 126 | // .tar.gz¥Á¥§¥Ã¥¯
|
|---|
| 127 | if ($ext== 'tar.gz') {
|
|---|
| 128 | $errFlag = false;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | if($errFlag) {
|
|---|
| 132 | $objErr->arrErr['template_file'] = "¢¨ ¥¢¥Ã¥×¥í¡¼¥É¤¹¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤Çµö²Ä¤µ¤ì¤Æ¤¤¤ë·Á¼°¤Ï¡¢tar/tar.gz¤Ç¤¹¡£<br />";
|
|---|
| 133 | }
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | return $objErr->arrErr;
|
|---|
| 137 | }
|
|---|
| 138 |
|
|---|
| 139 | /*
|
|---|
| 140 | * ´Ø¿ô̾¡§lfErrorCheck()
|
|---|
| 141 | * °ú¿ô1 ¡§¥Ñ¥é¥á¡¼¥¿
|
|---|
| 142 | * ÀâÌÀ¡¡¡§¥Æ¥ó¥×¥ì¡¼¥È¥Ç¡¼¥¿ÅÐÏ¿
|
|---|
| 143 | */
|
|---|
| 144 | function lfRegistTemplate($arrList) {
|
|---|
| 145 | global $objQuery;
|
|---|
| 146 |
|
|---|
| 147 | // INSERT¤¹¤ëÃͤòºîÀ®¤¹¤ë¡£
|
|---|
| 148 | $sqlval['template_code'] = $arrList['template_code'];
|
|---|
| 149 | $sqlval['template_name'] = $arrList['template_name'];
|
|---|
| 150 | $sqlval['create_date'] = "now()";
|
|---|
| 151 | $sqlval['update_date'] = "now()";
|
|---|
| 152 |
|
|---|
| 153 | $objQuery->insert("dtb_templates", $sqlval);
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|