| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
|---|
| 4 | * |
|---|
| 5 | * http://www.lockon.co.jp/ |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | //---¤³¤Î¥Õ¥¡¥¤¥ë¤Î¥Ñ¥¹¤ò»ØÄê |
|---|
| 9 | $INC_PATH = realpath( dirname( __FILE__) ); |
|---|
| 10 | require_once( $INC_PATH ."/../conf/conf.php" ); |
|---|
| 11 | require_once( $INC_PATH ."/../class/SC_DbConn.php" ); |
|---|
| 12 | require_once( $INC_PATH ."/../class/SC_Query.php" ); |
|---|
| 13 | require_once( $INC_PATH ."/../class/SC_CampaignSession.php" ); |
|---|
| 14 | require_once( $INC_PATH ."/../include/session.inc" ); |
|---|
| 15 | |
|---|
| 16 | // Á´¥Ú¡¼¥¸¶¦ÄÌ¥¨¥é¡¼ |
|---|
| 17 | $GLOBAL_ERR = ""; |
|---|
| 18 | // ¥¤¥ó¥¹¥È¡¼¥ë½é´ü½èÍý |
|---|
| 19 | sfInitInstall(); |
|---|
| 20 | |
|---|
| 21 | /* ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥Ð¡¼¥¸¥ç¥ó½êÆÀ */ |
|---|
| 22 | function sfGetDBVersion($dsn = "") { |
|---|
| 23 | if($dsn == "") { |
|---|
| 24 | if(defined('DEFAULT_DSN')) { |
|---|
| 25 | $dsn = DEFAULT_DSN; |
|---|
| 26 | } else { |
|---|
| 27 | return; |
|---|
| 28 | } |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 31 | $objQuery = new SC_Query($dsn, true, true); |
|---|
| 32 | list($db_type) = split(":", $dsn); |
|---|
| 33 | if($db_type == 'mysql') { |
|---|
| 34 | $val = $objQuery->getOne("select version()"); |
|---|
| 35 | $version = "MySQL " . $val; |
|---|
| 36 | } |
|---|
| 37 | if($db_type == 'pgsql') { |
|---|
| 38 | $val = $objQuery->getOne("select version()"); |
|---|
| 39 | $arrLine = split(" " , $val); |
|---|
| 40 | $version = $arrLine[0] . " " . $arrLine[1]; |
|---|
| 41 | } |
|---|
| 42 | return $version; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | /* ¥Æ¡¼¥Ö¥ë¤Î¸ºß¥Á¥§¥Ã¥¯ */ |
|---|
| 46 | function sfTabaleExists($table_name, $dsn = "") { |
|---|
| 47 | if($dsn == "") { |
|---|
| 48 | if(defined('DEFAULT_DSN')) { |
|---|
| 49 | $dsn = DEFAULT_DSN; |
|---|
| 50 | } else { |
|---|
| 51 | return; |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | $objQuery = new SC_Query($dsn, true, true); |
|---|
| 56 | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
|---|
| 57 | if(!$objQuery->isError()) { |
|---|
| 58 | list($db_type) = split(":", $dsn); |
|---|
| 59 | // postgresql¤Èmysql¤È¤Ç½èÍý¤òʬ¤±¤ë |
|---|
| 60 | if ($db_type == "pgsql") { |
|---|
| 61 | $sql = "SELECT |
|---|
| 62 | relname |
|---|
| 63 | FROM |
|---|
| 64 | pg_class |
|---|
| 65 | WHERE |
|---|
| 66 | (relkind = 'r' OR relkind = 'v') AND |
|---|
| 67 | relname = ? |
|---|
| 68 | GROUP BY |
|---|
| 69 | relname"; |
|---|
| 70 | $arrRet = $objQuery->getAll($sql, array($table_name)); |
|---|
| 71 | if(count($arrRet) > 0) { |
|---|
| 72 | return true; |
|---|
| 73 | } |
|---|
| 74 | }else if ($db_type == "mysql") { |
|---|
| 75 | $sql = "SHOW TABLE STATUS LIKE ?"; |
|---|
| 76 | $arrRet = $objQuery->getAll($sql, array($table_name)); |
|---|
| 77 | if(count($arrRet) > 0) { |
|---|
| 78 | return true; |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | } |
|---|
| 82 | return false; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | // ¥«¥é¥à¤Î¸ºß¥Á¥§¥Ã¥¯¤ÈºîÀ® |
|---|
| 86 | function sfColumnExists($table_name, $col_name, $col_type = "", $dsn = "", $add = false) { |
|---|
| 87 | if($dsn == "") { |
|---|
| 88 | if(defined('DEFAULT_DSN')) { |
|---|
| 89 | $dsn = DEFAULT_DSN; |
|---|
| 90 | } else { |
|---|
| 91 | return; |
|---|
| 92 | } |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | // ¥Æ¡¼¥Ö¥ë¤¬Ìµ¤±¤ì¤Ð¥¨¥é¡¼ |
|---|
| 96 | if(!sfTabaleExists($table_name, $dsn)) return false; |
|---|
| 97 | |
|---|
| 98 | $objQuery = new SC_Query($dsn, true, true); |
|---|
| 99 | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
|---|
| 100 | if(!$objQuery->isError()) { |
|---|
| 101 | list($db_type) = split(":", $dsn); |
|---|
| 102 | |
|---|
| 103 | // ¥«¥é¥à¥ê¥¹¥È¤ò¼èÆÀ |
|---|
| 104 | $arrRet = sfGetColumnList($table_name, $objQuery, $db_type); |
|---|
| 105 | if(count($arrRet) > 0) { |
|---|
| 106 | if(in_array($col_name, $arrRet)){ |
|---|
| 107 | return true; |
|---|
| 108 | } |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | // ¥«¥é¥à¤òÄɲ乤ë |
|---|
| 113 | if($add){ |
|---|
| 114 | $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); |
|---|
| 115 | return true; |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | return false; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß¥Á¥§¥Ã¥¯¤ÈºîÀ® |
|---|
| 122 | function sfIndexExists($table_name, $col_name, $index_name, $length = "", $dsn = "", $add = false) { |
|---|
| 123 | if($dsn == "") { |
|---|
| 124 | if(defined('DEFAULT_DSN')) { |
|---|
| 125 | $dsn = DEFAULT_DSN; |
|---|
| 126 | } else { |
|---|
| 127 | return; |
|---|
| 128 | } |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | // ¥Æ¡¼¥Ö¥ë¤¬Ìµ¤±¤ì¤Ð¥¨¥é¡¼ |
|---|
| 132 | if(!sfTabaleExists($table_name, $dsn)) return false; |
|---|
| 133 | |
|---|
| 134 | $objQuery = new SC_Query($dsn, true, true); |
|---|
| 135 | // Àµ¾ï¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¾ì¹ç |
|---|
| 136 | if(!$objQuery->isError()) { |
|---|
| 137 | list($db_type) = split(":", $dsn); |
|---|
| 138 | switch($db_type) { |
|---|
| 139 | case 'pgsql': |
|---|
| 140 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß³Îǧ |
|---|
| 141 | $arrRet = $objQuery->getAll("SELECT relname FROM pg_class WHERE relname = ?", array($index_name)); |
|---|
| 142 | break; |
|---|
| 143 | case 'mysql': |
|---|
| 144 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î¸ºß³Îǧ |
|---|
| 145 | $arrRet = $objQuery->getAll("SHOW INDEX FROM ? WHERE Key_name = ?", array($table_name, $index_name)); |
|---|
| 146 | break; |
|---|
| 147 | default: |
|---|
| 148 | return false; |
|---|
| 149 | } |
|---|
| 150 | // ¤¹¤Ç¤Ë¥¤¥ó¥Ç¥Ã¥¯¥¹¤¬Â¸ºß¤¹¤ë¾ì¹ç |
|---|
| 151 | if(count($arrRet) > 0) { |
|---|
| 152 | return true; |
|---|
| 153 | } |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | // ¥¤¥ó¥Ç¥Ã¥¯¥¹¤òºîÀ®¤¹¤ë |
|---|
| 157 | if($add){ |
|---|
| 158 | switch($db_type) { |
|---|
| 159 | case 'pgsql': |
|---|
| 160 | $objQuery->query("CREATE INDEX ? ON ? (?)", array($index_name, $table_name, $col_name)); |
|---|
| 161 | break; |
|---|
| 162 | case 'mysql': |
|---|
| 163 | $objQuery->query("CREATE INDEX ? ON ? (?(?))", array($index_name, $table_name, $col_name, $length)); |
|---|
| 164 | break; |
|---|
| 165 | default: |
|---|
| 166 | return false; |
|---|
| 167 | } |
|---|
| 168 | return true; |
|---|
| 169 | } |
|---|
| 170 | return false; |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | // ¥Ç¡¼¥¿¤Î¸ºß¥Á¥§¥Ã¥¯ |
|---|
| 174 | function sfDataExists($table_name, $where, $arrval, $dsn = "", $sql = "", $add = false) { |
|---|
| 175 | if($dsn == "") { |
|---|
| 176 | if(defined('DEFAULT_DSN')) { |
|---|
| 177 | $dsn = DEFAULT_DSN; |
|---|
| 178 | } else { |
|---|
| 179 | return; |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | $objQuery = new SC_Query($dsn, true, true); |
|---|
| 183 | $count = $objQuery->count($table_name, $where, $arrval); |
|---|
| 184 | |
|---|
| 185 | if($count > 0) { |
|---|
| 186 | $ret = true; |
|---|
| 187 | } else { |
|---|
| 188 | $ret = false; |
|---|
| 189 | } |
|---|
| 190 | // ¥Ç¡¼¥¿¤òÄɲ乤ë |
|---|
| 191 | if(!$ret && $add) { |
|---|
| 192 | $objQuery->exec($sql); |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | return $ret; |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | /* |
|---|
| 199 | * ¥µ¥¤¥È´ÉÍý¾ðÊ󤫤éÃͤò¼èÆÀ¤¹¤ë¡£ |
|---|
| 200 | * ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ë¾ì¹ç¡¢É¬¤º1°Ê¾å¤Î¿ôÃͤ¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¡£ |
|---|
| 201 | * 0¤òÊÖ¤·¤¿¾ì¹ç¤Ï¡¢¸Æ¤Ó½Ð¤·¸µ¤ÇÂбþ¤¹¤ë¤³¤È¡£ |
|---|
| 202 | * |
|---|
| 203 | * @param $control_id ´ÉÍýID |
|---|
| 204 | * @param $dsn DataSource |
|---|
| 205 | * @return $control_flg ¥Õ¥é¥° |
|---|
| 206 | */ |
|---|
| 207 | function sfGetSiteControlFlg($control_id, $dsn = "") { |
|---|
| 208 | |
|---|
| 209 | // ¥Ç¡¼¥¿¥½¡¼¥¹ |
|---|
| 210 | if($dsn == "") { |
|---|
| 211 | if(defined('DEFAULT_DSN')) { |
|---|
| 212 | $dsn = DEFAULT_DSN; |
|---|
| 213 | } else { |
|---|
| 214 | return; |
|---|
| 215 | } |
|---|
| 216 | } |
|---|
| 217 | |
|---|
| 218 | // ¥¯¥¨¥êÀ¸À® |
|---|
| 219 | $target_column = "control_flg"; |
|---|
| 220 | $table_name = "dtb_site_control"; |
|---|
| 221 | $where = "control_id = ?"; |
|---|
| 222 | $arrval = array($control_id); |
|---|
| 223 | $control_flg = 0; |
|---|
| 224 | |
|---|
| 225 | // ¥¯¥¨¥êȯ¹Ô |
|---|
| 226 | $objQuery = new SC_Query($dsn, true, true); |
|---|
| 227 | $arrSiteControl = $objQuery->select($target_column, $table_name, $where, $arrval); |
|---|
| 228 | |
|---|
| 229 | // ¥Ç¡¼¥¿¤¬Â¸ºß¤¹¤ì¤Ð¥Õ¥é¥°¤ò¼èÆÀ¤¹¤ë |
|---|
| 230 | if (count($arrSiteControl) > 0) { |
|---|
| 231 | $control_flg = $arrSiteControl[0]["control_flg"]; |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | return $control_flg; |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | // ¥Æ¡¼¥Ö¥ë¤Î¥«¥é¥à°ìÍ÷¤ò¼èÆÀ¤¹¤ë |
|---|
| 238 | function sfGetColumnList($table_name, $objQuery = "", $db_type = DB_TYPE){ |
|---|
| 239 | if($objQuery == "") $objQuery = new SC_Query(); |
|---|
| 240 | $arrRet = array(); |
|---|
| 241 | |
|---|
| 242 | // postgresql¤Èmysql¤È¤Ç½èÍý¤òʬ¤±¤ë |
|---|
| 243 | if ($db_type == "pgsql") { |
|---|
| 244 | $sql = "SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname=? AND c.oid=a.attrelid AND a.attnum > 0 ORDER BY a.attnum"; |
|---|
| 245 | $arrColList = $objQuery->getAll($sql, array($table_name)); |
|---|
| 246 | $arrColList = sfswaparray($arrColList); |
|---|
| 247 | $arrRet = $arrColList["attname"]; |
|---|
| 248 | }else if ($db_type == "mysql") { |
|---|
| 249 | $sql = "SHOW COLUMNS FROM $table_name"; |
|---|
| 250 | $arrColList = $objQuery->getAll($sql); |
|---|
| 251 | $arrColList = sfswaparray($arrColList); |
|---|
| 252 | $arrRet = $arrColList["Field"]; |
|---|
| 253 | } |
|---|
| 254 | return $arrRet; |
|---|
| 255 | } |
|---|
| 256 | |
|---|
| 257 | // ¥¤¥ó¥¹¥È¡¼¥ë½é´ü½èÍý |
|---|
| 258 | function sfInitInstall() { |
|---|
| 259 | // ¥¤¥ó¥¹¥È¡¼¥ëºÑ¤ß¤¬ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£ |
|---|
| 260 | if(!defined('ECCUBE_INSTALL')) { |
|---|
| 261 | if(!ereg("/install/", $_SERVER['PHP_SELF'])) { |
|---|
| 262 | header("Location: ./install/"); |
|---|
| 263 | } |
|---|
| 264 | } else { |
|---|
| 265 | $path = HTML_PATH . "install/index.php"; |
|---|
| 266 | if(file_exists($path)) { |
|---|
| 267 | sfErrorHeader(">> /install/index.php¤Ï¡¢¥¤¥ó¥¹¥È¡¼¥ë´°Î»¸å¤Ë¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£"); |
|---|
| 268 | } |
|---|
| 269 | |
|---|
| 270 | // µì¥Ð¡¼¥¸¥ç¥ó¤Îinstall.php¤Î¥Á¥§¥Ã¥¯ |
|---|
| 271 | $path = HTML_PATH . "install.php"; |
|---|
| 272 | if(file_exists($path)) { |
|---|
| 273 | sfErrorHeader(">> /install.php¤Ï¥»¥¥å¥ê¥Æ¥£¡¼¥Û¡¼¥ë¤È¤Ê¤ê¤Þ¤¹¡£ºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£"); |
|---|
| 274 | } |
|---|
| 275 | } |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | // ¥¢¥Ã¥×¥Ç¡¼¥È¤ÇÀ¸À®¤µ¤ì¤¿PHP¤òÆÉ¤ß½Ð¤· |
|---|
| 279 | function sfLoadUpdateModule() { |
|---|
| 280 | // URLÀßÄê¥Ç¥£¥ì¥¯¥È¥ê¤òºï½ü |
|---|
| 281 | $main_php = ereg_replace(URL_DIR, "", $_SERVER['PHP_SELF']); |
|---|
| 282 | $extern_php = UPDATE_PATH . $main_php; |
|---|
| 283 | if(file_exists($extern_php)) { |
|---|
| 284 | require_once($extern_php); |
|---|
| 285 | } |
|---|
| 286 | } |
|---|
| 287 | |
|---|
| 288 | function sf_getBasisData() { |
|---|
| 289 | //DB¤«¤éÀßÄê¾ðÊó¤ò¼èÆÀ |
|---|
| 290 | $objConn = new SC_DbConn(DEFAULT_DSN); |
|---|
| 291 | $result = $objConn->getAll("SELECT * FROM dtb_baseinfo"); |
|---|
| 292 | if(is_array($result[0])) { |
|---|
| 293 | foreach ( $result[0] as $key=>$value ){ |
|---|
| 294 | $CONF["$key"] = $value; |
|---|
| 295 | } |
|---|
| 296 | } |
|---|
| 297 | return $CONF; |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | // Áõ¾þÉÕ¤¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Îɽ¼¨ |
|---|
| 301 | function sfErrorHeader($mess, $print = false) { |
|---|
| 302 | global $GLOBAL_ERR; |
|---|
| 303 | if($GLOBAL_ERR == "") { |
|---|
| 304 | $GLOBAL_ERR = "<meta http-equiv='Content-Type' content='text/html; charset=" . CHAR_CODE . "'>\n"; |
|---|
| 305 | } |
|---|
| 306 | $GLOBAL_ERR.= "<table width='100%' border='0' cellspacing='0' cellpadding='0' summary=' '>\n"; |
|---|
| 307 | $GLOBAL_ERR.= "<tr>\n"; |
|---|
| 308 | $GLOBAL_ERR.= "<td bgcolor='#ffeebb' height='25' colspan='2' align='center'>\n"; |
|---|
| 309 | $GLOBAL_ERR.= "<SPAN style='color:red; font-size:12px'><strong>" . $mess . "</strong></span>\n"; |
|---|
| 310 | $GLOBAL_ERR.= "</td>\n"; |
|---|
| 311 | $GLOBAL_ERR.= " </tr>\n"; |
|---|
| 312 | $GLOBAL_ERR.= "</table>\n"; |
|---|
| 313 | |
|---|
| 314 | if($print) { |
|---|
| 315 | print($GLOBAL_ERR); |
|---|
| 316 | } |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | /* ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ */ |
|---|
| 320 | function sfDispError($type) { |
|---|
| 321 | |
|---|
| 322 | class LC_ErrorPage { |
|---|
| 323 | function LC_ErrorPage() { |
|---|
| 324 | $this->tpl_mainpage = 'login_error.tpl'; |
|---|
| 325 | $this->tpl_title = '¥¨¥é¡¼'; |
|---|
| 326 | } |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | $objPage = new LC_ErrorPage(); |
|---|
| 330 | $objView = new SC_AdminView(); |
|---|
| 331 | |
|---|
| 332 | switch ($type) { |
|---|
| 333 | case LOGIN_ERROR: |
|---|
| 334 | $objPage->tpl_error="£É£Ä¤Þ¤¿¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£"; |
|---|
| 335 | break; |
|---|
| 336 | case ACCESS_ERROR: |
|---|
| 337 | $objPage->tpl_error="¥í¥°¥¤¥óǧ¾Ú¤Î͸ú´ü¸ÂÀÚ¤ì¤Î²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
|---|
| 338 | break; |
|---|
| 339 | case AUTH_ERROR: |
|---|
| 340 | $objPage->tpl_error="¤³¤Î¥Õ¥¡¥¤¥ë¤Ë¤Ï¥¢¥¯¥»¥¹¸¢¸Â¤¬¤¢¤ê¤Þ¤»¤ó¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
|---|
| 341 | break; |
|---|
| 342 | case PAGE_ERROR: |
|---|
| 343 | $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£"; |
|---|
| 344 | break; |
|---|
| 345 | default: |
|---|
| 346 | $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£<br />¤â¤¦°ìÅÙ¤´³Îǧ¤Î¤¦¤¨¡¢ºÆÅÙ¥í¥°¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£"; |
|---|
| 347 | break; |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | $objView->assignobj($objPage); |
|---|
| 351 | $objView->display(LOGIN_FRAME); |
|---|
| 352 | |
|---|
| 353 | exit; |
|---|
| 354 | } |
|---|
| 355 | |
|---|
| 356 | /* ¥µ¥¤¥È¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ */ |
|---|
| 357 | function sfDispSiteError($type, $objSiteSess = "", $return_top = false, $err_msg = "", $is_mobile = false) { |
|---|
| 358 | global $objCampaignSess; |
|---|
| 359 | |
|---|
| 360 | if ($objSiteSess != "") { |
|---|
| 361 | $objSiteSess->setNowPage('error'); |
|---|
| 362 | } |
|---|
| 363 | |
|---|
| 364 | class LC_ErrorPage { |
|---|
| 365 | function LC_ErrorPage() { |
|---|
| 366 | $this->tpl_mainpage = 'error.tpl'; |
|---|
| 367 | $this->tpl_css = URL_DIR.'css/layout/error.css'; |
|---|
| 368 | $this->tpl_title = '¥¨¥é¡¼'; |
|---|
| 369 | } |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | $objPage = new LC_ErrorPage(); |
|---|
| 373 | |
|---|
| 374 | if($is_mobile === true) { |
|---|
| 375 | $objView = new SC_MobileView(); |
|---|
| 376 | } else { |
|---|
| 377 | $objView = new SC_SiteView(); |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | switch ($type) { |
|---|
| 381 | case PRODUCT_NOT_FOUND: |
|---|
| 382 | $objPage->tpl_error="¤´»ØÄê¤Î¥Ú¡¼¥¸¤Ï¤´¤¶¤¤¤Þ¤»¤ó¡£"; |
|---|
| 383 | break; |
|---|
| 384 | case PAGE_ERROR: |
|---|
| 385 | $objPage->tpl_error="ÉÔÀµ¤Ê¥Ú¡¼¥¸°Üư¤Ç¤¹¡£"; |
|---|
| 386 | break; |
|---|
| 387 | case CART_EMPTY: |
|---|
| 388 | $objPage->tpl_error="¥«¡¼¥È¤Ë¾¦Éʤ¬¤¬¤¢¤ê¤Þ¤»¤ó¡£"; |
|---|
| 389 | break; |
|---|
| 390 | case CART_ADD_ERROR: |
|---|
| 391 | $objPage->tpl_error="¹ØÆþ½èÍýÃæ¤Ï¡¢¥«¡¼¥È¤Ë¾¦ÉʤòÄɲ乤뤳¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£"; |
|---|
| 392 | break; |
|---|
| 393 | case CANCEL_PURCHASE: |
|---|
| 394 | $objPage->tpl_error="¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£°Ê²¼¤ÎÍ×°ø¤¬¹Í¤¨¤é¤ì¤Þ¤¹¡£<br />¡¦¥»¥Ã¥·¥ç¥ó¾ðÊó¤Î͸ú´ü¸Â¤¬ÀÚ¤ì¤Æ¤ë¾ì¹ç<br />¡¦¹ØÆþ¼ê³¤Ãæ¤Ë¿·¤·¤¤¹ØÆþ¼ê³¤¤ò¼Â¹Ô¤·¤¿¾ì¹ç<br />¡¦¤¹¤Ç¤Ë¹ØÆþ¼ê³¤¤ò´°Î»¤·¤Æ¤¤¤ë¾ì¹ç"; |
|---|
| 395 | break; |
|---|
| 396 | case CATEGORY_NOT_FOUND: |
|---|
| 397 | $objPage->tpl_error="¤´»ØÄê¤Î¥«¥Æ¥´¥ê¤Ï¸ºß¤·¤Þ¤»¤ó¡£"; |
|---|
| 398 | break; |
|---|
| 399 | case SITE_LOGIN_ERROR: |
|---|
| 400 | $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£"; |
|---|
| 401 | break; |
|---|
| 402 | case TEMP_LOGIN_ERROR: |
|---|
| 403 | $objPage->tpl_error="¥á¡¼¥ë¥¢¥É¥ì¥¹¤â¤·¤¯¤Ï¥Ñ¥¹¥ï¡¼¥É¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡£<br />ËÜÅÐÏ¿¤¬¤ªºÑ¤ß¤Ç¤Ê¤¤¾ì¹ç¤Ï¡¢²¾ÅÐÏ¿¥á¡¼¥ë¤ËµºÜ¤µ¤ì¤Æ¤¤¤ë<br />URL¤è¤êËÜÅÐÏ¿¤ò¹Ô¤Ã¤Æ¤¯¤À¤µ¤¤¡£"; |
|---|
| 404 | break; |
|---|
| 405 | case CUSTOMER_ERROR: |
|---|
| 406 | $objPage->tpl_error="ÉÔÀµ¤Ê¥¢¥¯¥»¥¹¤Ç¤¹¡£"; |
|---|
| 407 | break; |
|---|
| 408 | case SOLD_OUT: |
|---|
| 409 | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¤´¹ØÆþ¤ÎľÁ°¤ÇÇä¤êÀڤ줿¾¦Éʤ¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
|---|
| 410 | break; |
|---|
| 411 | case CART_NOT_FOUND: |
|---|
| 412 | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥«¡¼¥ÈÆâ¤Î¾¦ÉʾðÊó¤Î¼èÆÀ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
|---|
| 413 | break; |
|---|
| 414 | case LACK_POINT: |
|---|
| 415 | $objPage->tpl_error="¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¤¬¡¢¥Ý¥¤¥ó¥È¤¬ÉÔ¤·¤Æ¤ª¤ê¤Þ¤¹¡£¤³¤Î¼ê³¤¤Ï̵¸ú¤È¤Ê¤ê¤Þ¤·¤¿¡£"; |
|---|
| 416 | break; |
|---|
| 417 | case FAVORITE_ERROR: |
|---|
| 418 | $objPage->tpl_error="´û¤Ë¤ªµ¤¤ËÆþ¤ê¤ËÄɲäµ¤ì¤Æ¤¤¤ë¾¦ÉʤǤ¹¡£"; |
|---|
| 419 | break; |
|---|
| 420 | case EXTRACT_ERROR: |
|---|
| 421 | $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤Î²òÅà¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Ë½ñ¤¹þ¤ß¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
|---|
| 422 | break; |
|---|
| 423 | case FTP_DOWNLOAD_ERROR: |
|---|
| 424 | $objPage->tpl_error="¥Õ¥¡¥¤¥ë¤ÎFTP¥À¥¦¥ó¥í¡¼¥É¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
|---|
| 425 | break; |
|---|
| 426 | case FTP_LOGIN_ERROR: |
|---|
| 427 | $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
|---|
| 428 | break; |
|---|
| 429 | case FTP_CONNECT_ERROR: |
|---|
| 430 | $objPage->tpl_error="FTP¥í¥°¥¤¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"; |
|---|
| 431 | break; |
|---|
| 432 | case CREATE_DB_ERROR: |
|---|
| 433 | $objPage->tpl_error="DB¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n»ØÄê¤Î¥æ¡¼¥¶¡¼¤Ë¤Ï¡¢DBºîÀ®¤Î¸¢¸Â¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
|---|
| 434 | break; |
|---|
| 435 | case DB_IMPORT_ERROR: |
|---|
| 436 | $objPage->tpl_error="¥Ç¡¼¥¿¥Ù¡¼¥¹¹½Â¤¤Î¥¤¥ó¥Ý¡¼¥È¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\nsql¥Õ¥¡¥¤¥ë¤¬²õ¤ì¤Æ¤¤¤ë²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡£"; |
|---|
| 437 | break; |
|---|
| 438 | case FILE_NOT_FOUND: |
|---|
| 439 | $objPage->tpl_error="»ØÄê¤Î¥Ñ¥¹¤Ë¡¢ÀßÄê¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó¡£"; |
|---|
| 440 | break; |
|---|
| 441 | case WRITE_FILE_ERROR: |
|---|
| 442 | $objPage->tpl_error="ÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤á¤Þ¤»¤ó¡£\nÀßÄê¥Õ¥¡¥¤¥ë¤Ë½ñ¤¹þ¤ß¸¢¸Â¤òÍ¿¤¨¤Æ¤¯¤À¤µ¤¤¡£"; |
|---|
| 443 | break; |
|---|
| 444 | case FREE_ERROR_MSG: |
|---|
| 445 | $objPage->tpl_error=$err_msg; |
|---|
| 446 | break; |
|---|
| 447 | default: |
|---|
| 448 | $objPage->tpl_error="¥¨¥é¡¼¤¬È¯À¸¤·¤Þ¤·¤¿¡£"; |
|---|
| 449 | break; |
|---|
| 450 | } |
|---|
| 451 | |
|---|
| 452 | $objPage->return_top = $return_top; |
|---|
| 453 | |
|---|
| 454 | $objView->assignobj($objPage); |
|---|
| 455 | |
|---|
| 456 | if(is_object($objCampaignSess)) { |
|---|
| 457 | // ¥Õ¥ì¡¼¥à¤òÁªÂò(¥¥ã¥ó¥Ú¡¼¥ó¥Ú¡¼¥¸¤«¤éÁ«°Ü¤Ê¤éÊѹ¹) |
|---|
| 458 | $objCampaignSess->pageView($objView); |
|---|
| 459 | } else { |
|---|
| 460 | $objView->display(SITE_FRAME); |
|---|
| 461 | } |
|---|
| 462 | exit; |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | /* ǧ¾Ú¤Î²ÄÈÝȽÄê */ |
|---|
| 466 | function sfIsSuccess($objSess, $disp_error = true) { |
|---|
| 467 | $ret = $objSess->IsSuccess(); |
|---|
| 468 | if($ret != SUCCESS) { |
|---|
| 469 | if($disp_error) { |
|---|
| 470 | // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ |
|---|
| 471 | sfDispError($ret); |
|---|
| 472 | } |
|---|
| 473 | return false; |
|---|
| 474 | } |
|---|
| 475 | return true; |
|---|
| 476 | } |
|---|
| 477 | |
|---|
| 478 | /* Á°¤Î¥Ú¡¼¥¸¤ÇÀµ¤·¤¯ÅÐÏ¿¤¬¹Ô¤ï¤ì¤¿¤«È½Äê */ |
|---|
| 479 | function sfIsPrePage($objSiteSess, $is_mobile = false) { |
|---|
| 480 | $ret = $objSiteSess->isPrePage(); |
|---|
| 481 | if($ret != true) { |
|---|
| 482 | // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ |
|---|
| 483 | sfDispSiteError(PAGE_ERROR, $objSiteSess, false, "", $is_mobile); |
|---|
| 484 | } |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | function sfCheckNormalAccess($objSiteSess, $objCartSess) { |
|---|
| 488 | // ¥æ¡¼¥¶¥æ¥Ë¡¼¥¯ID¤Î¼èÆÀ |
|---|
| 489 | $uniqid = $objSiteSess->getUniqId(); |
|---|
| 490 | // ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤¿»þ¤Î¥«¡¼¥ÈÆâÍÆ¤¬¥³¥Ô¡¼¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Î¤ß¥³¥Ô¡¼¤¹¤ë¡£ |
|---|
| 491 | $objCartSess->saveCurrentCart($uniqid); |
|---|
| 492 | // POST¤Î¥æ¥Ë¡¼¥¯ID¤È¥»¥Ã¥·¥ç¥ó¤Î¥æ¥Ë¡¼¥¯ID¤òÈæ³Ó(¥æ¥Ë¡¼¥¯ID¤¬POST¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¥¹¥ë¡¼) |
|---|
| 493 | $ret = $objSiteSess->checkUniqId(); |
|---|
| 494 | if($ret != true) { |
|---|
| 495 | // ¥¨¥é¡¼¥Ú¡¼¥¸¤Îɽ¼¨ |
|---|
| 496 | sfDispSiteError(CANCEL_PURCHASE, $objSiteSess); |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | // ¥«¡¼¥ÈÆâ¤¬¶õ¤Ç¤Ê¤¤¤« || ¹ØÆþ¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤«¤éÊѲ½¤¬¤Ê¤¤¤« |
|---|
| 500 | $quantity = $objCartSess->getTotalQuantity(); |
|---|
| 501 | $ret = $objCartSess->checkChangeCart(); |
|---|
| 502 | if($ret == true || !($quantity > 0)) { |
|---|
| 503 | // ¥«¡¼¥È¾ðÊóɽ¼¨¤Ë¶¯À©°Üư¤¹¤ë |
|---|
| 504 | header("Location: ".URL_CART_TOP); |
|---|
| 505 | exit; |
|---|
| 506 | } |
|---|
| 507 | return $uniqid; |
|---|
| 508 | } |
|---|
| 509 | |
|---|
| 510 | /* DBÍÑÆüÉÕʸ»úÎó¼èÆÀ */ |
|---|
| 511 | function sfGetTimestamp($year, $month, $day, $last = false) { |
|---|
| 512 | if($year != "" && $month != "" && $day != "") { |
|---|
| 513 | if($last) { |
|---|
| 514 | $time = "23:59:59"; |
|---|
| 515 | } else { |
|---|
| 516 | $time = "00:00:00"; |
|---|
| 517 | } |
|---|
| 518 | $date = $year."-".$month."-".$day." ".$time; |
|---|
| 519 | } else { |
|---|
| 520 | $date = ""; |
|---|
| 521 | } |
|---|
| 522 | return $date; |
|---|
| 523 | } |
|---|
| 524 | |
|---|
| 525 | // INT·¿¤Î¿ôÃÍ¥Á¥§¥Ã¥¯ |
|---|
| 526 | function sfIsInt($value) { |
|---|
| 527 | if($value != "" && strlen($value) <= INT_LEN && is_numeric($value)) { |
|---|
| 528 | return true; |
|---|
| 529 | } |
|---|
| 530 | return false; |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | function sfCSVDownload($data, $prefix = ""){ |
|---|
| 534 | |
|---|
| 535 | if($prefix == "") { |
|---|
| 536 | $dir_name = sfUpDirName(); |
|---|
| 537 | $file_name = $dir_name . date("ymdHis") .".csv"; |
|---|
| 538 | } else { |
|---|
| 539 | $file_name = $prefix . date("ymdHis") .".csv"; |
|---|
| 540 | } |
|---|
| 541 | |
|---|
| 542 | /* HTTP¥Ø¥Ã¥À¤Î½ÐÎÏ */ |
|---|
| 543 | Header("Content-disposition: attachment; filename=${file_name}"); |
|---|
| 544 | Header("Content-type: application/octet-stream; name=${file_name}"); |
|---|
| 545 | Header("Cache-Control: "); |
|---|
| 546 | Header("Pragma: "); |
|---|
| 547 | |
|---|
| 548 | /* i18n¢· ¤À¤ÈÀµ¾ï¤Ëưºî¤·¤Ê¤¤¤¿¤á¡¢mb¢· ¤ËÊѹ¹ |
|---|
| 549 | if (i18n_discover_encoding($data) == CHAR_CODE){ |
|---|
| 550 | $data = i18n_convert($data,'SJIS',CHAR_CODE); |
|---|
| 551 | } |
|---|
| 552 | */ |
|---|
| 553 | if (mb_internal_encoding() == CHAR_CODE){ |
|---|
| 554 | $data = mb_convert_encoding($data,'SJIS',CHAR_CODE); |
|---|
| 555 | } |
|---|
| 556 | |
|---|
| 557 | /* ¥Ç¡¼¥¿¤ò½ÐÎÏ */ |
|---|
| 558 | echo $data; |
|---|
| 559 | } |
|---|
| 560 | |
|---|
| 561 | /* 1³¬Áؾå¤Î¥Ç¥£¥ì¥¯¥È¥ê̾¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 562 | function sfUpDirName() { |
|---|
| 563 | $path = $_SERVER['PHP_SELF']; |
|---|
| 564 | $arrVal = split("/", $path); |
|---|
| 565 | $cnt = count($arrVal); |
|---|
| 566 | return $arrVal[($cnt - 2)]; |
|---|
| 567 | } |
|---|
| 568 | |
|---|
| 569 | // ¸½ºß¤Î¥µ¥¤¥È¤ò¹¹¿·¡Ê¤¿¤À¤·¥Ý¥¹¥È¤Ï¹Ô¤ï¤Ê¤¤¡Ë |
|---|
| 570 | function sfReload($get = "") { |
|---|
| 571 | if ($_SERVER["SERVER_PORT"] == "443" ){ |
|---|
| 572 | $url = ereg_replace(URL_DIR . "$", "", SSL_URL); |
|---|
| 573 | } else { |
|---|
| 574 | $url = ereg_replace(URL_DIR . "$", "", SITE_URL); |
|---|
| 575 | } |
|---|
| 576 | |
|---|
| 577 | if($get != "") { |
|---|
| 578 | header("Location: ". $url . $_SERVER['PHP_SELF'] . "?" . $get); |
|---|
| 579 | } else { |
|---|
| 580 | header("Location: ". $url . $_SERVER['PHP_SELF']); |
|---|
| 581 | } |
|---|
| 582 | exit; |
|---|
| 583 | } |
|---|
| 584 | |
|---|
| 585 | // ¥é¥ó¥¥ó¥°¤ò¾å¤²¤ë¡£ |
|---|
| 586 | function sfRankUp($table, $colname, $id, $andwhere = "") { |
|---|
| 587 | $objQuery = new SC_Query(); |
|---|
| 588 | $objQuery->begin(); |
|---|
| 589 | $where = "$colname = ?"; |
|---|
| 590 | if($andwhere != "") { |
|---|
| 591 | $where.= " AND $andwhere"; |
|---|
| 592 | } |
|---|
| 593 | // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ |
|---|
| 594 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 595 | // ¥é¥ó¥¯¤ÎºÇÂçÃͤò¼èÆÀ |
|---|
| 596 | $maxrank = $objQuery->max($table, "rank", $andwhere); |
|---|
| 597 | // ¥é¥ó¥¯¤¬ºÇÂçÃͤè¤ê¤â¾®¤µ¤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£ |
|---|
| 598 | if($rank < $maxrank) { |
|---|
| 599 | // ¥é¥ó¥¯¤¬°ì¤Ä¾å¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 600 | $where = "rank = ?"; |
|---|
| 601 | if($andwhere != "") { |
|---|
| 602 | $where.= " AND $andwhere"; |
|---|
| 603 | } |
|---|
| 604 | $uprank = $rank + 1; |
|---|
| 605 | $up_id = $objQuery->get($table, $colname, $where, array($uprank)); |
|---|
| 606 | // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô |
|---|
| 607 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
|---|
| 608 | $objQuery->exec($sqlup, array($rank + 1, $id)); |
|---|
| 609 | $objQuery->exec($sqlup, array($rank, $up_id)); |
|---|
| 610 | } |
|---|
| 611 | $objQuery->commit(); |
|---|
| 612 | } |
|---|
| 613 | |
|---|
| 614 | // ¥é¥ó¥¥ó¥°¤ò²¼¤²¤ë¡£ |
|---|
| 615 | function sfRankDown($table, $colname, $id, $andwhere = "") { |
|---|
| 616 | $objQuery = new SC_Query(); |
|---|
| 617 | $objQuery->begin(); |
|---|
| 618 | $where = "$colname = ?"; |
|---|
| 619 | if($andwhere != "") { |
|---|
| 620 | $where.= " AND $andwhere"; |
|---|
| 621 | } |
|---|
| 622 | // ÂоݹàÌܤΥé¥ó¥¯¤ò¼èÆÀ |
|---|
| 623 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 624 | |
|---|
| 625 | // ¥é¥ó¥¯¤¬1(ºÇ¾®ÃÍ)¤è¤ê¤âÂ礤¤¾ì¹ç¤Ë¼Â¹Ô¤¹¤ë¡£ |
|---|
| 626 | if($rank > 1) { |
|---|
| 627 | // ¥é¥ó¥¯¤¬°ì¤Ä²¼¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 628 | $where = "rank = ?"; |
|---|
| 629 | if($andwhere != "") { |
|---|
| 630 | $where.= " AND $andwhere"; |
|---|
| 631 | } |
|---|
| 632 | $downrank = $rank - 1; |
|---|
| 633 | $down_id = $objQuery->get($table, $colname, $where, array($downrank)); |
|---|
| 634 | // ¥é¥ó¥¯Æþ¤ìÂØ¤¨¤Î¼Â¹Ô |
|---|
| 635 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
|---|
| 636 | $objQuery->exec($sqlup, array($rank - 1, $id)); |
|---|
| 637 | $objQuery->exec($sqlup, array($rank, $down_id)); |
|---|
| 638 | } |
|---|
| 639 | $objQuery->commit(); |
|---|
| 640 | } |
|---|
| 641 | |
|---|
| 642 | //----¡¡»ØÄê½ç°Ì¤Ø°Üư |
|---|
| 643 | function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = "") { |
|---|
| 644 | $objQuery = new SC_Query(); |
|---|
| 645 | $objQuery->begin(); |
|---|
| 646 | |
|---|
| 647 | // ¼«¿È¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë |
|---|
| 648 | $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId)); |
|---|
| 649 | $max = $objQuery->max($tableName, "rank", $where); |
|---|
| 650 | |
|---|
| 651 | // ÃͤÎÄ´À°¡ÊµÕ½ç¡Ë |
|---|
| 652 | if($pos > $max) { |
|---|
| 653 | $position = 1; |
|---|
| 654 | } else if($pos < 1) { |
|---|
| 655 | $position = $max; |
|---|
| 656 | } else { |
|---|
| 657 | $position = $max - $pos + 1; |
|---|
| 658 | } |
|---|
| 659 | |
|---|
| 660 | if( $position > $rank ) $term = "rank - 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤êÂ礤¤¾ì¹ç |
|---|
| 661 | if( $position < $rank ) $term = "rank + 1"; //Æþ¤ìÂØ¤¨Àè¤Î½ç°Ì¤¬Æþ¤ì´¹¤¨¸µ¤Î½ç°Ì¤è¤ê¾®¤µ¤¤¾ì¹ç |
|---|
| 662 | |
|---|
| 663 | //--¡¡»ØÄꤷ¤¿½ç°Ì¤Î¾¦Éʤ«¤é°Üư¤µ¤»¤ë¾¦ÉʤޤǤÎrank¤ò£±¤Ä¤º¤é¤¹ |
|---|
| 664 | $sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0"; |
|---|
| 665 | if($where != "") { |
|---|
| 666 | $sql.= " AND $where"; |
|---|
| 667 | } |
|---|
| 668 | |
|---|
| 669 | if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position )); |
|---|
| 670 | if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 )); |
|---|
| 671 | |
|---|
| 672 | //-- »ØÄꤷ¤¿½ç°Ì¤Ørank¤ò½ñ¤´¹¤¨¤ë¡£ |
|---|
| 673 | $sql = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 "; |
|---|
| 674 | if($where != "") { |
|---|
| 675 | $sql.= " AND $where"; |
|---|
| 676 | } |
|---|
| 677 | |
|---|
| 678 | $objQuery->exec( $sql, array( $position, $keyId ) ); |
|---|
| 679 | $objQuery->commit(); |
|---|
| 680 | } |
|---|
| 681 | |
|---|
| 682 | // ¥é¥ó¥¯¤ò´Þ¤à¥ì¥³¡¼¥É¤Îºï½ü |
|---|
| 683 | // ¥ì¥³¡¼¥É¤´¤Èºï½ü¤¹¤ë¾ì¹ç¤Ï¡¢$delete¤òtrue¤Ë¤¹¤ë¡£ |
|---|
| 684 | function sfDeleteRankRecord($table, $colname, $id, $andwhere = "", $delete = false) { |
|---|
| 685 | $objQuery = new SC_Query(); |
|---|
| 686 | $objQuery->begin(); |
|---|
| 687 | // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 688 | $where = "$colname = ?"; |
|---|
| 689 | if($andwhere != "") { |
|---|
| 690 | $where.= " AND $andwhere"; |
|---|
| 691 | } |
|---|
| 692 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 693 | |
|---|
| 694 | if(!$delete) { |
|---|
| 695 | // ¥é¥ó¥¯¤òºÇ²¼°Ì¤Ë¤¹¤ë¡¢DEL¥Õ¥é¥°ON |
|---|
| 696 | $sqlup = "UPDATE $table SET rank = 0, del_flg = 1, update_date = Now() "; |
|---|
| 697 | $sqlup.= "WHERE $colname = ?"; |
|---|
| 698 | // UPDATE¤Î¼Â¹Ô |
|---|
| 699 | $objQuery->exec($sqlup, array($id)); |
|---|
| 700 | } else { |
|---|
| 701 | $objQuery->delete($table, "$colname = ?", array($id)); |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | // Äɲå쥳¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä¤º¤é¤¹¡£ |
|---|
| 705 | $where = "rank > ?"; |
|---|
| 706 | if($andwhere != "") { |
|---|
| 707 | $where.= " AND $andwhere"; |
|---|
| 708 | } |
|---|
| 709 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
|---|
| 710 | $objQuery->exec($sqlup, array($rank)); |
|---|
| 711 | $objQuery->commit(); |
|---|
| 712 | } |
|---|
| 713 | |
|---|
| 714 | // ¥ì¥³¡¼¥É¤Î¸ºß¥Á¥§¥Ã¥¯ |
|---|
| 715 | function sfIsRecord($table, $col, $arrval, $addwhere = "") { |
|---|
| 716 | $objQuery = new SC_Query(); |
|---|
| 717 | $arrCol = split("[, ]", $col); |
|---|
| 718 | |
|---|
| 719 | $where = "del_flg = 0"; |
|---|
| 720 | |
|---|
| 721 | if($addwhere != "") { |
|---|
| 722 | $where.= " AND $addwhere"; |
|---|
| 723 | } |
|---|
| 724 | |
|---|
| 725 | foreach($arrCol as $val) { |
|---|
| 726 | if($val != "") { |
|---|
| 727 | if($where == "") { |
|---|
| 728 | $where = "$val = ?"; |
|---|
| 729 | } else { |
|---|
| 730 | $where.= " AND $val = ?"; |
|---|
| 731 | } |
|---|
| 732 | } |
|---|
| 733 | } |
|---|
| 734 | $ret = $objQuery->get($table, $col, $where, $arrval); |
|---|
| 735 | |
|---|
| 736 | if($ret != "") { |
|---|
| 737 | return true; |
|---|
| 738 | } |
|---|
| 739 | return false; |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤò¥Þ¡¼¥¸ |
|---|
| 743 | function sfMergeCBValue($keyname, $max) { |
|---|
| 744 | $conv = ""; |
|---|
| 745 | $cnt = 1; |
|---|
| 746 | for($cnt = 1; $cnt <= $max; $cnt++) { |
|---|
| 747 | if ($_POST[$keyname . $cnt] == "1") { |
|---|
| 748 | $conv.= "1"; |
|---|
| 749 | } else { |
|---|
| 750 | $conv.= "0"; |
|---|
| 751 | } |
|---|
| 752 | } |
|---|
| 753 | return $conv; |
|---|
| 754 | } |
|---|
| 755 | |
|---|
| 756 | // html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤Æ2¿Ê¿ô·Á¼°¤ËÊѹ¹¤¹¤ë¡£ |
|---|
| 757 | function sfMergeCheckBoxes($array, $max) { |
|---|
| 758 | $ret = ""; |
|---|
| 759 | if(is_array($array)) { |
|---|
| 760 | foreach($array as $val) { |
|---|
| 761 | $arrTmp[$val] = "1"; |
|---|
| 762 | } |
|---|
| 763 | } |
|---|
| 764 | for($i = 1; $i <= $max; $i++) { |
|---|
| 765 | if($arrTmp[$i] == "1") { |
|---|
| 766 | $ret.= "1"; |
|---|
| 767 | } else { |
|---|
| 768 | $ret.= "0"; |
|---|
| 769 | } |
|---|
| 770 | } |
|---|
| 771 | return $ret; |
|---|
| 772 | } |
|---|
| 773 | |
|---|
| 774 | |
|---|
| 775 | // html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤Æ¡Ö-¡×¤Ç¤Ä¤Ê¤²¤ë¡£ |
|---|
| 776 | function sfMergeParamCheckBoxes($array) { |
|---|
| 777 | if(is_array($array)) { |
|---|
| 778 | foreach($array as $val) { |
|---|
| 779 | if($ret != "") { |
|---|
| 780 | $ret.= "-$val"; |
|---|
| 781 | } else { |
|---|
| 782 | $ret = $val; |
|---|
| 783 | } |
|---|
| 784 | } |
|---|
| 785 | } else { |
|---|
| 786 | $ret = $array; |
|---|
| 787 | } |
|---|
| 788 | return $ret; |
|---|
| 789 | } |
|---|
| 790 | |
|---|
| 791 | // html_checkboxes¤ÎÃͤò¥Þ¡¼¥¸¤·¤ÆSQL¸¡º÷ÍѤËÊѹ¹¤¹¤ë¡£ |
|---|
| 792 | function sfSearchCheckBoxes($array) { |
|---|
| 793 | $max = 0; |
|---|
| 794 | $ret = ""; |
|---|
| 795 | foreach($array as $val) { |
|---|
| 796 | $arrTmp[$val] = "1"; |
|---|
| 797 | if($val > $max) { |
|---|
| 798 | $max = $val; |
|---|
| 799 | } |
|---|
| 800 | } |
|---|
| 801 | for($i = 1; $i <= $max; $i++) { |
|---|
| 802 | if($arrTmp[$i] == "1") { |
|---|
| 803 | $ret.= "1"; |
|---|
| 804 | } else { |
|---|
| 805 | $ret.= "_"; |
|---|
| 806 | } |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | if($ret != "") { |
|---|
| 810 | $ret.= "%"; |
|---|
| 811 | } |
|---|
| 812 | return $ret; |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | // 2¿Ê¿ô·Á¼°¤ÎÃͤòhtml_checkboxesÂбþ¤ÎÃͤËÀÚ¤êÂØ¤¨¤ë |
|---|
| 816 | function sfSplitCheckBoxes($val) { |
|---|
| 817 | $len = strlen($val); |
|---|
| 818 | for($i = 0; $i < $len; $i++) { |
|---|
| 819 | if(substr($val, $i, 1) == "1") { |
|---|
| 820 | $arrRet[] = ($i + 1); |
|---|
| 821 | } |
|---|
| 822 | } |
|---|
| 823 | return $arrRet; |
|---|
| 824 | } |
|---|
| 825 | |
|---|
| 826 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤò¥Þ¡¼¥¸ |
|---|
| 827 | function sfMergeCBSearchValue($keyname, $max) { |
|---|
| 828 | $conv = ""; |
|---|
| 829 | $cnt = 1; |
|---|
| 830 | for($cnt = 1; $cnt <= $max; $cnt++) { |
|---|
| 831 | if ($_POST[$keyname . $cnt] == "1") { |
|---|
| 832 | $conv.= "1"; |
|---|
| 833 | } else { |
|---|
| 834 | $conv.= "_"; |
|---|
| 835 | } |
|---|
| 836 | } |
|---|
| 837 | return $conv; |
|---|
| 838 | } |
|---|
| 839 | |
|---|
| 840 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤ÎÃͤòʬ²ò |
|---|
| 841 | function sfSplitCBValue($val, $keyname = "") { |
|---|
| 842 | $len = strlen($val); |
|---|
| 843 | $no = 1; |
|---|
| 844 | for ($cnt = 0; $cnt < $len; $cnt++) { |
|---|
| 845 | if($keyname != "") { |
|---|
| 846 | $arr[$keyname . $no] = substr($val, $cnt, 1); |
|---|
| 847 | } else { |
|---|
| 848 | $arr[] = substr($val, $cnt, 1); |
|---|
| 849 | } |
|---|
| 850 | $no++; |
|---|
| 851 | } |
|---|
| 852 | return $arr; |
|---|
| 853 | } |
|---|
| 854 | |
|---|
| 855 | // ¥¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ |
|---|
| 856 | function sfArrKeyValue($arrList, $keyname, $valname, $len_max = "", $keysize = "") { |
|---|
| 857 | |
|---|
| 858 | $max = count($arrList); |
|---|
| 859 | |
|---|
| 860 | if($len_max != "" && $max > $len_max) { |
|---|
| 861 | $max = $len_max; |
|---|
| 862 | } |
|---|
| 863 | |
|---|
| 864 | for($cnt = 0; $cnt < $max; $cnt++) { |
|---|
| 865 | if($keysize != "") { |
|---|
| 866 | $key = sfCutString($arrList[$cnt][$keyname], $keysize); |
|---|
| 867 | } else { |
|---|
| 868 | $key = $arrList[$cnt][$keyname]; |
|---|
| 869 | } |
|---|
| 870 | $val = $arrList[$cnt][$valname]; |
|---|
| 871 | |
|---|
| 872 | if(!isset($arrRet[$key])) { |
|---|
| 873 | $arrRet[$key] = $val; |
|---|
| 874 | } |
|---|
| 875 | |
|---|
| 876 | } |
|---|
| 877 | return $arrRet; |
|---|
| 878 | } |
|---|
| 879 | |
|---|
| 880 | // ¥¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ(Ãͤ¬Ê£¿ô¤Î¾ì¹ç) |
|---|
| 881 | function sfArrKeyValues($arrList, $keyname, $valname, $len_max = "", $keysize = "", $connect = "") { |
|---|
| 882 | |
|---|
| 883 | $max = count($arrList); |
|---|
| 884 | |
|---|
| 885 | if($len_max != "" && $max > $len_max) { |
|---|
| 886 | $max = $len_max; |
|---|
| 887 | } |
|---|
| 888 | |
|---|
| 889 | for($cnt = 0; $cnt < $max; $cnt++) { |
|---|
| 890 | if($keysize != "") { |
|---|
| 891 | $key = sfCutString($arrList[$cnt][$keyname], $keysize); |
|---|
| 892 | } else { |
|---|
| 893 | $key = $arrList[$cnt][$keyname]; |
|---|
| 894 | } |
|---|
| 895 | $val = $arrList[$cnt][$valname]; |
|---|
| 896 | |
|---|
| 897 | if($connect != "") { |
|---|
| 898 | $arrRet[$key].= "$val".$connect; |
|---|
| 899 | } else { |
|---|
| 900 | $arrRet[$key][] = $val; |
|---|
| 901 | } |
|---|
| 902 | } |
|---|
| 903 | return $arrRet; |
|---|
| 904 | } |
|---|
| 905 | |
|---|
| 906 | // ÇÛÎó¤ÎÃͤò¥«¥ó¥Þ¶èÀÚ¤ê¤ÇÊÖ¤¹¡£ |
|---|
| 907 | function sfGetCommaList($array, $space=true) { |
|---|
| 908 | if (count($array) > 0) { |
|---|
| 909 | $line = ""; |
|---|
| 910 | foreach($array as $val) { |
|---|
| 911 | if ($space) { |
|---|
| 912 | $line .= $val . ", "; |
|---|
| 913 | }else{ |
|---|
| 914 | $line .= $val . ","; |
|---|
| 915 | } |
|---|
| 916 | } |
|---|
| 917 | if ($space) { |
|---|
| 918 | $line = ereg_replace(", $", "", $line); |
|---|
| 919 | }else{ |
|---|
| 920 | $line = ereg_replace(",$", "", $line); |
|---|
| 921 | } |
|---|
| 922 | return $line; |
|---|
| 923 | }else{ |
|---|
| 924 | return false; |
|---|
| 925 | } |
|---|
| 926 | |
|---|
| 927 | } |
|---|
| 928 | |
|---|
| 929 | /* ÇÛÎó¤ÎÍ×ÁǤòCSV¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç½ÐÎϤ¹¤ë¡£*/ |
|---|
| 930 | function sfGetCSVList($array) { |
|---|
| 931 | if (count($array) > 0) { |
|---|
| 932 | foreach($array as $key => $val) { |
|---|
| 933 | $val = mb_convert_encoding($val, CHAR_CODE, CHAR_CODE); |
|---|
| 934 | $line .= "\"".$val."\","; |
|---|
| 935 | } |
|---|
| 936 | $line = ereg_replace(",$", "\n", $line); |
|---|
| 937 | }else{ |
|---|
| 938 | return false; |
|---|
| 939 | } |
|---|
| 940 | return $line; |
|---|
| 941 | } |
|---|
| 942 | |
|---|
| 943 | /* ÇÛÎó¤ÎÍ×ÁǤòPDF¥Õ¥©¡¼¥Þ¥Ã¥È¤Ç½ÐÎϤ¹¤ë¡£*/ |
|---|
| 944 | function sfGetPDFList($array) { |
|---|
| 945 | foreach($array as $key => $val) { |
|---|
| 946 | $line .= "\t".$val; |
|---|
| 947 | } |
|---|
| 948 | $line.="\n"; |
|---|
| 949 | return $line; |
|---|
| 950 | } |
|---|
| 951 | |
|---|
| 952 | |
|---|
| 953 | |
|---|
| 954 | /*-----------------------------------------------------------------*/ |
|---|
| 955 | /* check_set_term |
|---|
| 956 | /* ǯ·îÆü¤ËÊ̤줿2¤Ä¤Î´ü´Ö¤ÎÂÅÅöÀ¤ò¥Á¥§¥Ã¥¯¤·¡¢À°¹çÀ¤È´ü´Ö¤òÊÖ¤¹ |
|---|
| 957 | /*¡¡°ú¿ô (³«»Ïǯ,³«»Ï·î,³«»ÏÆü,½ªÎ»Ç¯,½ªÎ»·î,½ªÎ»Æü) |
|---|
| 958 | /*¡¡ÌáÃÍ array(£±¡¤£²¡¤£³¡Ë |
|---|
| 959 | /* £±¡¥³«»Ïǯ·îÆü (YYYY/MM/DD 000000) |
|---|
| 960 | /* £²¡¥½ªÎ»Ç¯·îÆü (YYYY/MM/DD 235959) |
|---|
| 961 | /* £³¡¥¥¨¥é¡¼ ( 0 = OK, 1 = NG ) |
|---|
| 962 | /*-----------------------------------------------------------------*/ |
|---|
| 963 | function sfCheckSetTerm ( $start_year, $start_month, $start_day, $end_year, $end_month, $end_day ) { |
|---|
| 964 | |
|---|
| 965 | // ´ü´Ö»ØÄê |
|---|
| 966 | $error = 0; |
|---|
| 967 | if ( $start_month || $start_day || $start_year){ |
|---|
| 968 | if ( ! checkdate($start_month, $start_day , $start_year) ) $error = 1; |
|---|
| 969 | } else { |
|---|
| 970 | $error = 1; |
|---|
| 971 | } |
|---|
| 972 | if ( $end_month || $end_day || $end_year){ |
|---|
| 973 | if ( ! checkdate($end_month ,$end_day ,$end_year) ) $error = 2; |
|---|
| 974 | } |
|---|
| 975 | if ( ! $error ){ |
|---|
| 976 | $date1 = $start_year ."/".sprintf("%02d",$start_month) ."/".sprintf("%02d",$start_day) ." 000000"; |
|---|
| 977 | $date2 = $end_year ."/".sprintf("%02d",$end_month) ."/".sprintf("%02d",$end_day) ." 235959"; |
|---|
| 978 | if ($date1 > $date2) $error = 3; |
|---|
| 979 | } else { |
|---|
| 980 | $error = 1; |
|---|
| 981 | } |
|---|
| 982 | return array($date1, $date2, $error); |
|---|
| 983 | } |
|---|
| 984 | |
|---|
| 985 | // ¥¨¥é¡¼²Õ½ê¤ÎÇØ·Ê¿§¤òÊѹ¹¤¹¤ë¤¿¤á¤Îfunction SC_View¤ÇÆÉ¤ß¹þ¤à |
|---|
| 986 | function sfSetErrorStyle(){ |
|---|
| 987 | return 'style="background-color:'.ERR_COLOR.'"'; |
|---|
| 988 | } |
|---|
| 989 | |
|---|
| 990 | /* DB¤ËÅϤ¹¿ôÃͤΥÁ¥§¥Ã¥¯ |
|---|
| 991 | * 10·å°Ê¾å¤Ï¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¥¨¥é¡¼¤òµ¯¤³¤¹¤Î¤Ç¡£ |
|---|
| 992 | */ |
|---|
| 993 | function sfCheckNumLength( $value ){ |
|---|
| 994 | if ( ! is_numeric($value) ){ |
|---|
| 995 | return false; |
|---|
| 996 | } |
|---|
| 997 | |
|---|
| 998 | if ( strlen($value) > 9 ) { |
|---|
| 999 | return false; |
|---|
| 1000 | } |
|---|
| 1001 | |
|---|
| 1002 | return true; |
|---|
| 1003 | } |
|---|
| 1004 | |
|---|
| 1005 | // °ìÃפ·¤¿ÃͤΥ¡¼Ì¾¤ò¼èÆÀ |
|---|
| 1006 | function sfSearchKey($array, $word, $default) { |
|---|
| 1007 | foreach($array as $key => $val) { |
|---|
| 1008 | if($val == $word) { |
|---|
| 1009 | return $key; |
|---|
| 1010 | } |
|---|
| 1011 | } |
|---|
| 1012 | return $default; |
|---|
| 1013 | } |
|---|
| 1014 | |
|---|
| 1015 | // ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ($products_check:true¾¦ÉÊÅÐÏ¿ºÑ¤ß¤Î¤â¤Î¤À¤±¼èÆÀ) |
|---|
| 1016 | function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) { |
|---|
| 1017 | $objQuery = new SC_Query(); |
|---|
| 1018 | $where = "del_flg = 0"; |
|---|
| 1019 | |
|---|
| 1020 | if($addwhere != "") { |
|---|
| 1021 | $where.= " AND $addwhere"; |
|---|
| 1022 | } |
|---|
| 1023 | |
|---|
| 1024 | $objQuery->setoption("ORDER BY rank DESC"); |
|---|
| 1025 | |
|---|
| 1026 | if($products_check) { |
|---|
| 1027 | $col = "T1.category_id, category_name, level"; |
|---|
| 1028 | $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; |
|---|
| 1029 | $where .= " AND product_count > 0"; |
|---|
| 1030 | } else { |
|---|
| 1031 | $col = "category_id, category_name, level"; |
|---|
| 1032 | $from = "dtb_category"; |
|---|
| 1033 | } |
|---|
| 1034 | |
|---|
| 1035 | $arrRet = $objQuery->select($col, $from, $where); |
|---|
| 1036 | |
|---|
| 1037 | $max = count($arrRet); |
|---|
| 1038 | for($cnt = 0; $cnt < $max; $cnt++) { |
|---|
| 1039 | $id = $arrRet[$cnt]['category_id']; |
|---|
| 1040 | $name = $arrRet[$cnt]['category_name']; |
|---|
| 1041 | $arrList[$id] = ""; |
|---|
| 1042 | /* |
|---|
| 1043 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
|---|
| 1044 | $arrList[$id].= "¡¡"; |
|---|
| 1045 | } |
|---|
| 1046 | */ |
|---|
| 1047 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
|---|
| 1048 | $arrList[$id].= $head; |
|---|
| 1049 | } |
|---|
| 1050 | $arrList[$id].= $name; |
|---|
| 1051 | } |
|---|
| 1052 | return $arrList; |
|---|
| 1053 | } |
|---|
| 1054 | |
|---|
| 1055 | // ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ¡Ê¿Æ¥«¥Æ¥´¥ê¤ÎValue:0) |
|---|
| 1056 | function sfGetLevelCatList($parent_zero = true) { |
|---|
| 1057 | $objQuery = new SC_Query(); |
|---|
| 1058 | $col = "category_id, category_name, level"; |
|---|
| 1059 | $where = "del_flg = 0"; |
|---|
| 1060 | $objQuery->setoption("ORDER BY rank DESC"); |
|---|
| 1061 | $arrRet = $objQuery->select($col, "dtb_category", $where); |
|---|
| 1062 | $max = count($arrRet); |
|---|
| 1063 | |
|---|
| 1064 | for($cnt = 0; $cnt < $max; $cnt++) { |
|---|
| 1065 | if($parent_zero) { |
|---|
| 1066 | if($arrRet[$cnt]['level'] == LEVEL_MAX) { |
|---|
| 1067 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
|---|
| 1068 | } else { |
|---|
| 1069 | $arrValue[$cnt] = ""; |
|---|
| 1070 | } |
|---|
| 1071 | } else { |
|---|
| 1072 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
|---|
| 1073 | } |
|---|
| 1074 | |
|---|
| 1075 | $arrOutput[$cnt] = ""; |
|---|
| 1076 | /* |
|---|
| 1077 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
|---|
| 1078 | $arrOutput[$cnt].= "¡¡"; |
|---|
| 1079 | } |
|---|
| 1080 | */ |
|---|
| 1081 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
|---|
| 1082 | $arrOutput[$cnt].= CATEGORY_HEAD; |
|---|
| 1083 | } |
|---|
| 1084 | $arrOutput[$cnt].= $arrRet[$cnt]['category_name']; |
|---|
| 1085 | } |
|---|
| 1086 | return array($arrValue, $arrOutput); |
|---|
| 1087 | } |
|---|
| 1088 | |
|---|
| 1089 | function sfGetErrorColor($val) { |
|---|
| 1090 | if($val != "") { |
|---|
| 1091 | return "background-color:" . ERR_COLOR; |
|---|
| 1092 | } |
|---|
| 1093 | return ""; |
|---|
| 1094 | } |
|---|
| 1095 | |
|---|
| 1096 | |
|---|
| 1097 | function sfGetEnabled($val) { |
|---|
| 1098 | if( ! $val ) { |
|---|
| 1099 | return " disabled=\"disabled\""; |
|---|
| 1100 | } |
|---|
| 1101 | return ""; |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | function sfGetChecked($param, $value) { |
|---|
| 1105 | if($param == $value) { |
|---|
| 1106 | return "checked=\"checked\""; |
|---|
| 1107 | } |
|---|
| 1108 | return ""; |
|---|
| 1109 | } |
|---|
| 1110 | |
|---|
| 1111 | // SELECT¥Ü¥Ã¥¯¥¹Íѥꥹ¥È¤ÎºîÀ® |
|---|
| 1112 | function sfGetIDValueList($table, $keyname, $valname) { |
|---|
| 1113 | $objQuery = new SC_Query(); |
|---|
| 1114 | $col = "$keyname, $valname"; |
|---|
| 1115 | $objQuery->setwhere("del_flg = 0"); |
|---|
| 1116 | $objQuery->setorder("rank DESC"); |
|---|
| 1117 | $arrList = $objQuery->select($col, $table); |
|---|
| 1118 | $count = count($arrList); |
|---|
| 1119 | for($cnt = 0; $cnt < $count; $cnt++) { |
|---|
| 1120 | $key = $arrList[$cnt][$keyname]; |
|---|
| 1121 | $val = $arrList[$cnt][$valname]; |
|---|
| 1122 | $arrRet[$key] = $val; |
|---|
| 1123 | } |
|---|
| 1124 | return $arrRet; |
|---|
| 1125 | } |
|---|
| 1126 | |
|---|
| 1127 | function sfTrim($str) { |
|---|
| 1128 | $ret = ereg_replace("^[¡¡ \n\r]*", "", $str); |
|---|
| 1129 | $ret = ereg_replace("[¡¡ \n\r]*$", "", $ret); |
|---|
| 1130 | return $ret; |
|---|
| 1131 | } |
|---|
| 1132 | |
|---|
| 1133 | /* ½ê°¤¹¤ë¤¹¤Ù¤Æ¤Î³¬ÁؤοÆID¤òÇÛÎó¤ÇÊÖ¤¹ */ |
|---|
| 1134 | function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) { |
|---|
| 1135 | $arrRet = sfGetParentsArray($table, $pid_name, $id_name, $id); |
|---|
| 1136 | // ÇÛÎó¤ÎÀèÆ¬1¤Ä¤òºï½ü¤¹¤ë¡£ |
|---|
| 1137 | array_shift($arrRet); |
|---|
| 1138 | return $arrRet; |
|---|
| 1139 | } |
|---|
| 1140 | |
|---|
| 1141 | |
|---|
| 1142 | /* ¿ÆID¤ÎÇÛÎó¤ò¸µ¤ËÆÃÄê¤Î¥«¥é¥à¤ò¼èÆÀ¤¹¤ë¡£*/ |
|---|
| 1143 | function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) { |
|---|
| 1144 | $col = $col_name; |
|---|
| 1145 | $len = count($arrId); |
|---|
| 1146 | $where = ""; |
|---|
| 1147 | |
|---|
| 1148 | for($cnt = 0; $cnt < $len; $cnt++) { |
|---|
| 1149 | if($where == "") { |
|---|
| 1150 | $where = "$id_name = ?"; |
|---|
| 1151 | } else { |
|---|
| 1152 | $where.= " OR $id_name = ?"; |
|---|
| 1153 | } |
|---|
| 1154 | } |
|---|
| 1155 | |
|---|
| 1156 | $objQuery->setorder("level"); |
|---|
| 1157 | $arrRet = $objQuery->select($col, $table, $where, $arrId); |
|---|
| 1158 | return $arrRet; |
|---|
| 1159 | } |
|---|
| 1160 | |
|---|
| 1161 | /* »ÒID¤ÎÇÛÎó¤òÊÖ¤¹ */ |
|---|
| 1162 | function sfGetChildsID($table, $pid_name, $id_name, $id) { |
|---|
| 1163 | $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id); |
|---|
| 1164 | return $arrRet; |
|---|
| 1165 | } |
|---|
| 1166 | |
|---|
| 1167 | /* ¥«¥Æ¥´¥êÊѹ¹»þ¤Î°Üư½èÍý */ |
|---|
| 1168 | function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) { |
|---|
| 1169 | if ($old_catid == $new_catid) { |
|---|
| 1170 | return; |
|---|
| 1171 | } |
|---|
| 1172 | // µì¥«¥Æ¥´¥ê¤Ç¤Î¥é¥ó¥¯ºï½ü½èÍý |
|---|
| 1173 | // °Üư¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 1174 | $where = "$id_name = ?"; |
|---|
| 1175 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
|---|
| 1176 | // ºï½ü¥ì¥³¡¼¥É¤Î¥é¥ó¥¯¤è¤ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä²¼¤Ë¤º¤é¤¹¡£ |
|---|
| 1177 | $where = "rank > ? AND $cat_name = ?"; |
|---|
| 1178 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
|---|
| 1179 | $objQuery->exec($sqlup, array($rank, $old_catid)); |
|---|
| 1180 | // ¿·¥«¥Æ¥´¥ê¤Ç¤ÎÅÐÏ¿½èÍý |
|---|
| 1181 | // ¿·¥«¥Æ¥´¥ê¤ÎºÇÂç¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 1182 | $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1; |
|---|
| 1183 | $where = "$id_name = ?"; |
|---|
| 1184 | $sqlup = "UPDATE $table SET rank = ? WHERE $where"; |
|---|
| 1185 | $objQuery->exec($sqlup, array($max_rank, $id)); |
|---|
| 1186 | } |
|---|
| 1187 | |
|---|
| 1188 | /* ÀǶâ·×»» */ |
|---|
| 1189 | function sfTax($price, $tax, $tax_rule) { |
|---|
| 1190 | $real_tax = $tax / 100; |
|---|
| 1191 | $ret = $price * $real_tax; |
|---|
| 1192 | switch($tax_rule) { |
|---|
| 1193 | // »Í¼Î¸ÞÆþ |
|---|
| 1194 | case 1: |
|---|
| 1195 | $ret = round($ret); |
|---|
| 1196 | break; |
|---|
| 1197 | // ÀÚ¤ê¼Î¤Æ |
|---|
| 1198 | case 2: |
|---|
| 1199 | $ret = floor($ret); |
|---|
| 1200 | break; |
|---|
| 1201 | // ÀÚ¤ê¾å¤² |
|---|
| 1202 | case 3: |
|---|
| 1203 | $ret = ceil($ret); |
|---|
| 1204 | break; |
|---|
| 1205 | // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤² |
|---|
| 1206 | default: |
|---|
| 1207 | $ret = ceil($ret); |
|---|
| 1208 | break; |
|---|
| 1209 | } |
|---|
| 1210 | return $ret; |
|---|
| 1211 | } |
|---|
| 1212 | |
|---|
| 1213 | /* ÀǶâÉÕÍ¿ */ |
|---|
| 1214 | function sfPreTax($price, $tax, $tax_rule) { |
|---|
| 1215 | $real_tax = $tax / 100; |
|---|
| 1216 | $ret = $price * (1 + $real_tax); |
|---|
| 1217 | |
|---|
| 1218 | switch($tax_rule) { |
|---|
| 1219 | // »Í¼Î¸ÞÆþ |
|---|
| 1220 | case 1: |
|---|
| 1221 | $ret = round($ret); |
|---|
| 1222 | break; |
|---|
| 1223 | // ÀÚ¤ê¼Î¤Æ |
|---|
| 1224 | case 2: |
|---|
| 1225 | $ret = floor($ret); |
|---|
| 1226 | break; |
|---|
| 1227 | // ÀÚ¤ê¾å¤² |
|---|
| 1228 | case 3: |
|---|
| 1229 | $ret = ceil($ret); |
|---|
| 1230 | break; |
|---|
| 1231 | // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤² |
|---|
| 1232 | default: |
|---|
| 1233 | $ret = ceil($ret); |
|---|
| 1234 | break; |
|---|
| 1235 | } |
|---|
| 1236 | return $ret; |
|---|
| 1237 | } |
|---|
| 1238 | |
|---|
| 1239 | // ·å¿ô¤ò»ØÄꤷ¤Æ»Í¼Î¸ÞÆþ |
|---|
| 1240 | function sfRound($value, $pow = 0){ |
|---|
| 1241 | $adjust = pow(10 ,$pow-1); |
|---|
| 1242 | |
|---|
| 1243 | // À°¿ô³î¤Ä0½Ð¤Ê¤±¤ì¤Ð·å¿ô»ØÄê¤ò¹Ô¤¦ |
|---|
| 1244 | if(sfIsInt($adjust) and $pow > 1){ |
|---|
| 1245 | $ret = (round($value * $adjust)/$adjust); |
|---|
| 1246 | } |
|---|
| 1247 | |
|---|
| 1248 | $ret = round($ret); |
|---|
| 1249 | |
|---|
| 1250 | return $ret; |
|---|
| 1251 | } |
|---|
| 1252 | |
|---|
| 1253 | /* ¥Ý¥¤¥ó¥ÈÉÕÍ¿ */ |
|---|
| 1254 | function sfPrePoint($price, $point_rate, $rule = POINT_RULE, $product_id = "") { |
|---|
| 1255 | if(sfIsInt($product_id)) { |
|---|
| 1256 | $objQuery = new SC_Query(); |
|---|
| 1257 | $where = "now() >= cast(start_date as date) AND "; |
|---|
| 1258 | $where .= "now() < cast(end_date as date) AND "; |
|---|
| 1259 | |
|---|
| 1260 | $where .= "del_flg = 0 AND campaign_id IN (SELECT campaign_id FROM dtb_campaign_detail where product_id = ? )"; |
|---|
| 1261 | //ÅÐÏ¿(¹¹¿·)ÆüÉÕ½ç |
|---|
| 1262 | $objQuery->setorder('update_date DESC'); |
|---|
| 1263 | //¥¥ã¥ó¥Ú¡¼¥ó¥Ý¥¤¥ó¥È¤Î¼èÆÀ |
|---|
| 1264 | $arrRet = $objQuery->select("campaign_name, campaign_point_rate", "dtb_campaign", $where, array($product_id)); |
|---|
| 1265 | } |
|---|
| 1266 | //Ê£¿ô¤Î¥¥ã¥ó¥Ú¡¼¥ó¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾¦Éʤϡ¢ºÇ¿·¤Î¥¥ã¥ó¥Ú¡¼¥ó¤«¤é¥Ý¥¤¥ó¥È¤ò¼èÆÀ |
|---|
| 1267 | if($arrRet[0]['campaign_point_rate'] != "") { |
|---|
| 1268 | $campaign_point_rate = $arrRet[0]['campaign_point_rate']; |
|---|
| 1269 | $real_point = $campaign_point_rate / 100; |
|---|
| 1270 | } else { |
|---|
| 1271 | $real_point = $point_rate / 100; |
|---|
| 1272 | } |
|---|
| 1273 | $ret = $price * $real_point; |
|---|
| 1274 | switch($rule) { |
|---|
| 1275 | // »Í¼Î¸ÞÆþ |
|---|
| 1276 | case 1: |
|---|
| 1277 | $ret = round($ret); |
|---|
| 1278 | break; |
|---|
| 1279 | // ÀÚ¤ê¼Î¤Æ |
|---|
| 1280 | case 2: |
|---|
| 1281 | $ret = floor($ret); |
|---|
| 1282 | break; |
|---|
| 1283 | // ÀÚ¤ê¾å¤² |
|---|
| 1284 | case 3: |
|---|
| 1285 | $ret = ceil($ret); |
|---|
| 1286 | break; |
|---|
| 1287 | // ¥Ç¥Õ¥©¥ë¥È:ÀÚ¤ê¾å¤² |
|---|
| 1288 | default: |
|---|
| 1289 | $ret = ceil($ret); |
|---|
| 1290 | break; |
|---|
| 1291 | } |
|---|
| 1292 | //¥¥ã¥ó¥Ú¡¼¥ó¾¦Éʤξì¹ç |
|---|
| 1293 | if($campaign_point_rate != "") { |
|---|
| 1294 | $ret = "(".$arrRet[0]['campaign_name']."¥Ý¥¤¥ó¥ÈΨ".$campaign_point_rate."%)".$ret; |
|---|
| 1295 | } |
|---|
| 1296 | return $ret; |
|---|
| 1297 | } |
|---|
| 1298 | |
|---|
| 1299 | /* µ¬³ÊʬÎà¤Î·ï¿ô¼èÆÀ */ |
|---|
| 1300 | function sfGetClassCatCount() { |
|---|
| 1301 | $sql = "select count(dtb_class.class_id) as count, dtb_class.class_id "; |
|---|
| 1302 | $sql.= "from dtb_class inner join dtb_classcategory on dtb_class.class_id = dtb_classcategory.class_id "; |
|---|
| 1303 | $sql.= "where dtb_class.del_flg = 0 AND dtb_classcategory.del_flg = 0 "; |
|---|
| 1304 | $sql.= "group by dtb_class.class_id, dtb_class.name"; |
|---|
| 1305 | $objQuery = new SC_Query(); |
|---|
| 1306 | $arrList = $objQuery->getall($sql); |
|---|
| 1307 | // ¥¡¼¤ÈÃͤò¥»¥Ã¥È¤·¤¿ÇÛÎó¤ò¼èÆÀ |
|---|
| 1308 | $arrRet = sfArrKeyValue($arrList, 'class_id', 'count'); |
|---|
| 1309 | |
|---|
| 1310 | return $arrRet; |
|---|
| 1311 | } |
|---|
| 1312 | |
|---|
| 1313 | /* µ¬³Ê¤ÎÅÐÏ¿ */ |
|---|
| 1314 | function sfInsertProductClass($objQuery, $arrList, $product_id) { |
|---|
| 1315 | // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£ |
|---|
| 1316 | $where = "product_id = ? AND classcategory_id1 <> 0 AND classcategory_id1 <> 0"; |
|---|
| 1317 | $count = $objQuery->count("dtb_products_class", $where, array($product_id)); |
|---|
| 1318 | |
|---|
| 1319 | // ¤¹¤Ç¤Ëµ¬³ÊÅÐÏ¿¤¬¤Ê¤¤¾ì¹ç |
|---|
| 1320 | if($count == 0) { |
|---|
| 1321 | // ´û¸µ¬³Ê¤Îºï½ü |
|---|
| 1322 | $where = "product_id = ?"; |
|---|
| 1323 | $objQuery->delete("dtb_products_class", $where, array($product_id)); |
|---|
| 1324 | $sqlval['product_id'] = $product_id; |
|---|
| 1325 | $sqlval['classcategory_id1'] = '0'; |
|---|
| 1326 | $sqlval['classcategory_id2'] = '0'; |
|---|
| 1327 | $sqlval['product_code'] = $arrList["product_code"]; |
|---|
| 1328 | $sqlval['stock'] = $arrList["stock"]; |
|---|
| 1329 | $sqlval['stock_unlimited'] = $arrList["stock_unlimited"]; |
|---|
| 1330 | $sqlval['price01'] = $arrList['price01']; |
|---|
| 1331 | $sqlval['price02'] = $arrList['price02']; |
|---|
| 1332 | $sqlval['creator_id'] = $_SESSION['member_id']; |
|---|
| 1333 | $sqlval['create_date'] = "now()"; |
|---|
| 1334 | |
|---|
| 1335 | if($_SESSION['member_id'] == "") { |
|---|
| 1336 | $sqlval['creator_id'] = '0'; |
|---|
| 1337 | } |
|---|
| 1338 | |
|---|
| 1339 | // INSERT¤Î¼Â¹Ô |
|---|
| 1340 | $objQuery->insert("dtb_products_class", $sqlval); |
|---|
| 1341 | } |
|---|
| 1342 | } |
|---|
| 1343 | |
|---|
| 1344 | function sfGetProductClassId($product_id, $classcategory_id1, $classcategory_id2) { |
|---|
| 1345 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
|---|
| 1346 | $objQuery = new SC_Query(); |
|---|
| 1347 | $ret = $objQuery->get("dtb_products_class", "product_class_id", $where, Array($product_id, $classcategory_id1, $classcategory_id2)); |
|---|
| 1348 | return $ret; |
|---|
| 1349 | } |
|---|
| 1350 | |
|---|
| 1351 | /* ʸËö¤Î¡Ö/¡×¤ò¤Ê¤¯¤¹ */ |
|---|
| 1352 | function sfTrimURL($url) { |
|---|
| 1353 | $ret = ereg_replace("[/]+$", "", $url); |
|---|
| 1354 | return $ret; |
|---|
| 1355 | } |
|---|
| 1356 | |
|---|
| 1357 | /* ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ */ |
|---|
| 1358 | function sfGetProductsClass($arrID) { |
|---|
| 1359 | list($product_id, $classcategory_id1, $classcategory_id2) = $arrID; |
|---|
| 1360 | |
|---|
| 1361 | if($classcategory_id1 == "") { |
|---|
| 1362 | $classcategory_id1 = '0'; |
|---|
| 1363 | } |
|---|
| 1364 | if($classcategory_id2 == "") { |
|---|
| 1365 | $classcategory_id2 = '0'; |
|---|
| 1366 | } |
|---|
| 1367 | |
|---|
| 1368 | // ¾¦Éʵ¬³Ê¼èÆÀ |
|---|
| 1369 | $objQuery = new SC_Query(); |
|---|
| 1370 | $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited"; |
|---|
| 1371 | $table = "vw_product_class AS prdcls"; |
|---|
| 1372 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
|---|
| 1373 | $objQuery->setorder("rank1 DESC, rank2 DESC"); |
|---|
| 1374 | $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2)); |
|---|
| 1375 | return $arrRet[0]; |
|---|
| 1376 | } |
|---|
| 1377 | |
|---|
| 1378 | /* ½¸·×¾ðÊó¤ò¸µ¤ËºÇ½ª·×»» */ |
|---|
| 1379 | function sfTotalConfirm($arrData, $objPage, $objCartSess, $arrInfo, $objCustomer = "") { |
|---|
| 1380 | // ¾¦Éʤιç·×¸Ä¿ô |
|---|
| 1381 | $total_quantity = $objCartSess->getTotalQuantity(true); |
|---|
| 1382 | |
|---|
| 1383 | // ÀǶâ¤Î¼èÆÀ |
|---|
| 1384 | $arrData['tax'] = $objPage->tpl_total_tax; |
|---|
| 1385 | // ¾®·×¤Î¼èÆÀ |
|---|
| 1386 | $arrData['subtotal'] = $objPage->tpl_total_pretax; |
|---|
| 1387 | |
|---|
| 1388 | // ¹ç·×Á÷ÎÁ¤Î¼èÆÀ |
|---|
| 1389 | $arrData['deliv_fee'] = 0; |
|---|
| 1390 | |
|---|
| 1391 | // ¾¦Éʤ´¤È¤ÎÁ÷ÎÁ¤¬Í¸ú¤Î¾ì¹ç |
|---|
| 1392 | if (OPTION_PRODUCT_DELIV_FEE == 1) { |
|---|
| 1393 | $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee(); |
|---|
| 1394 | } |
|---|
| 1395 | |
|---|
| 1396 | // ÇÛÁ÷¶È¼Ô¤ÎÁ÷ÎÁ¤¬Í¸ú¤Î¾ì¹ç |
|---|
| 1397 | if (OPTION_DELIV_FEE == 1) { |
|---|
| 1398 | // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë |
|---|
| 1399 | $arrData['deliv_fee']+= sfGetDelivFee($arrData['deliv_pref'], $arrData['payment_id']); |
|---|
| 1400 | } |
|---|
| 1401 | |
|---|
| 1402 | // Á÷ÎÁ̵ÎÁ¤Î¹ØÆþ¿ô¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç |
|---|
| 1403 | if(DELIV_FREE_AMOUNT > 0) { |
|---|
| 1404 | if($total_quantity >= DELIV_FREE_AMOUNT) { |
|---|
| 1405 | $arrData['deliv_fee'] = 0; |
|---|
| 1406 | } |
|---|
| 1407 | } |
|---|
| 1408 | |
|---|
| 1409 | // Á÷ÎÁ̵ÎÁ¾ò·ï¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç |
|---|
| 1410 | if($arrInfo['free_rule'] > 0) { |
|---|
| 1411 | // ¾®·×¤¬ÌµÎÁ¾ò·ï¤òͤ¨¤Æ¤¤¤ë¾ì¹ç |
|---|
| 1412 | if($arrData['subtotal'] >= $arrInfo['free_rule']) { |
|---|
| 1413 | $arrData['deliv_fee'] = 0; |
|---|
| 1414 | } |
|---|
| 1415 | } |
|---|
| 1416 | |
|---|
| 1417 | // ¹ç·×¤Î·×»» |
|---|
| 1418 | $arrData['total'] = $objPage->tpl_total_pretax; // ¾¦Éʹç·× |
|---|
| 1419 | $arrData['total']+= $arrData['deliv_fee']; // Á÷ÎÁ |
|---|
| 1420 | $arrData['total']+= $arrData['charge']; // ¼ê¿ôÎÁ |
|---|
| 1421 | // ¤ª»Ùʧ¤¤¹ç·× |
|---|
| 1422 | $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE); |
|---|
| 1423 | // ²Ã»»¥Ý¥¤¥ó¥È¤Î·×»» |
|---|
| 1424 | $arrData['add_point'] = sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo); |
|---|
| 1425 | |
|---|
| 1426 | if($objCustomer != "") { |
|---|
| 1427 | // ÃÂÀ¸Æü·î¤Ç¤¢¤Ã¤¿¾ì¹ç |
|---|
| 1428 | if($objCustomer->isBirthMonth()) { |
|---|
| 1429 | $arrData['birth_point'] = BIRTH_MONTH_POINT; |
|---|
| 1430 | $arrData['add_point'] += $arrData['birth_point']; |
|---|
| 1431 | } |
|---|
| 1432 | } |
|---|
| 1433 | |
|---|
| 1434 | if($arrData['add_point'] < 0) { |
|---|
| 1435 | $arrData['add_point'] = 0; |
|---|
| 1436 | } |
|---|
| 1437 | |
|---|
| 1438 | return $arrData; |
|---|
| 1439 | } |
|---|
| 1440 | |
|---|
| 1441 | /* ¥«¡¼¥ÈÆâ¾¦Éʤν¸·×½èÍý */ |
|---|
| 1442 | function sfTotalCart($objPage, $objCartSess, $arrInfo) { |
|---|
| 1443 | // µ¬³Ê̾°ìÍ÷ |
|---|
| 1444 | $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); |
|---|
| 1445 | // µ¬³ÊʬÎà̾°ìÍ÷ |
|---|
| 1446 | $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
|---|
| 1447 | |
|---|
| 1448 | $objPage->tpl_total_pretax = 0; // ÈñÍѹç·×(Àǹþ¤ß) |
|---|
| 1449 | $objPage->tpl_total_tax = 0; // ¾ÃÈñÀǹç·× |
|---|
| 1450 | $objPage->tpl_total_point = 0; // ¥Ý¥¤¥ó¥È¹ç·× |
|---|
| 1451 | |
|---|
| 1452 | // ¥«¡¼¥ÈÆâ¾ðÊó¤Î¼èÆÀ |
|---|
| 1453 | $arrCart = $objCartSess->getCartList(); |
|---|
| 1454 | $max = count($arrCart); |
|---|
| 1455 | $cnt = 0; |
|---|
| 1456 | |
|---|
| 1457 | for ($i = 0; $i < $max; $i++) { |
|---|
| 1458 | // ¾¦Éʵ¬³Ê¾ðÊó¤Î¼èÆÀ |
|---|
| 1459 | $arrData = sfGetProductsClass($arrCart[$i]['id']); |
|---|
| 1460 | $limit = ""; |
|---|
| 1461 | // DB¤Ë¸ºß¤¹¤ë¾¦ÉÊ |
|---|
| 1462 | if (count($arrData) > 0) { |
|---|
| 1463 | |
|---|
| 1464 | // ¹ØÆþÀ©¸Â¿ô¤òµá¤á¤ë¡£ |
|---|
| 1465 | if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') { |
|---|
| 1466 | if($arrData['sale_limit'] < $arrData['stock']) { |
|---|
| 1467 | $limit = $arrData['sale_limit']; |
|---|
| 1468 | } else { |
|---|
| 1469 | $limit = $arrData['stock']; |
|---|
| 1470 | } |
|---|
| 1471 | } else { |
|---|
| 1472 | if ($arrData['sale_unlimited'] != '1') { |
|---|
| 1473 | $limit = $arrData['sale_limit']; |
|---|
| 1474 | } |
|---|
| 1475 | if ($arrData['stock_unlimited'] != '1') { |
|---|
| 1476 | $limit = $arrData['stock']; |
|---|
| 1477 | } |
|---|
| 1478 | } |
|---|
| 1479 | |
|---|
| 1480 | if($limit != "" && $limit < $arrCart[$i]['quantity']) { |
|---|
| 1481 | // ¥«¡¼¥ÈÆâ¾¦ÉÊ¿ô¤òÀ©¸Â¤Ë¹ç¤ï¤»¤ë |
|---|
| 1482 | $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit); |
|---|
| 1483 | $quantity = $limit; |
|---|
| 1484 | $objPage->tpl_message = "¢¨¡Ö" . $arrData['name'] . "¡×¤ÏÈÎÇäÀ©¸Â¤·¤Æ¤ª¤ê¤Þ¤¹¡¢°ìÅ٤ˤ³¤ì°Ê¾å¤Î¹ØÆþ¤Ï¤Ç¤¤Þ¤»¤ó¡£"; |
|---|
| 1485 | } else { |
|---|
| 1486 | $quantity = $arrCart[$i]['quantity']; |
|---|
| 1487 | } |
|---|
| 1488 | |
|---|
| 1489 | $objPage->arrProductsClass[$cnt] = $arrData; |
|---|
| 1490 | $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; |
|---|
| 1491 | $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no']; |
|---|
| 1492 | $objPage->arrProductsClass[$cnt]['class_name1'] = $arrClassName[$arrData['class_id1']]; |
|---|
| 1493 | $objPage->arrProductsClass[$cnt]['class_name2'] = $arrClassName[$arrData['class_id2']]; |
|---|
| 1494 | $objPage->arrProductsClass[$cnt]['classcategory_name1'] = $arrClassCatName[$arrData['classcategory_id1']]; |
|---|
| 1495 | $objPage->arrProductsClass[$cnt]['classcategory_name2'] = $arrClassCatName[$arrData['classcategory_id2']]; |
|---|
| 1496 | |
|---|
| 1497 | // ²èÁü¥µ¥¤¥º |
|---|
| 1498 | list($image_width, $image_height) = getimagesize(IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"])); |
|---|
| 1499 | $objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60; |
|---|
| 1500 | $objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80; |
|---|
| 1501 | |
|---|
| 1502 | // ²Á³Ê¤ÎÅÐÏ¿ |
|---|
| 1503 | if ($arrData['price02'] != "") { |
|---|
| 1504 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']); |
|---|
| 1505 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02']; |
|---|
| 1506 | } else { |
|---|
| 1507 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']); |
|---|
| 1508 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01']; |
|---|
| 1509 | } |
|---|
| 1510 | // ¥Ý¥¤¥ó¥ÈÉÕͿΨ¤ÎÅÐÏ¿ |
|---|
| 1511 | $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']); |
|---|
| 1512 | // ¾¦Éʤ´¤È¤Î¹ç·×¶â³Û |
|---|
| 1513 | $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']); |
|---|
| 1514 | // Á÷ÎÁ¤Î¹ç·×¤ò·×»»¤¹¤ë |
|---|
| 1515 | $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']); |
|---|
| 1516 | $cnt++; |
|---|
| 1517 | } else { |
|---|
| 1518 | // DB¤Ë¾¦Éʤ¬¸«¤Ä¤«¤é¤Ê¤¤¾ì¹ç¤Ï¥«¡¼¥È¾¦Éʤκï½ü |
|---|
| 1519 | $objCartSess->delProductKey('id', $arrCart[$i]['id']); |
|---|
| 1520 | } |
|---|
| 1521 | } |
|---|
| 1522 | |
|---|
| 1523 | // Á´¾¦Éʹç·×¶â³Û(Àǹþ¤ß) |
|---|
| 1524 | $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo); |
|---|
| 1525 | // Á´¾¦Éʹç·×¾ÃÈñÀÇ |
|---|
| 1526 | $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo); |
|---|
| 1527 | // Á´¾¦Éʹç·×¥Ý¥¤¥ó¥È |
|---|
| 1528 | $objPage->tpl_total_point = $objCartSess->getAllProductsPoint(); |
|---|
| 1529 | |
|---|
| 1530 | return $objPage; |
|---|
| 1531 | } |
|---|
| 1532 | |
|---|
| 1533 | /* DB¤«¤é¼è¤ê½Ð¤·¤¿ÆüÉÕ¤Îʸ»úÎó¤òÄ´À°¤¹¤ë¡£*/ |
|---|
| 1534 | function sfDispDBDate($dbdate, $time = true) { |
|---|
| 1535 | list($y, $m, $d, $H, $M) = split("[- :]", $dbdate); |
|---|
| 1536 | |
|---|
| 1537 | if(strlen($y) > 0 && strlen($m) > 0 && strlen($d) > 0) { |
|---|
| 1538 | if ($time) { |
|---|
| 1539 | $str = sprintf("%04d/%02d/%02d %02d:%02d", $y, $m, $d, $H, $M); |
|---|
| 1540 | } else { |
|---|
| 1541 | $str = sprintf("%04d/%02d/%02d", $y, $m, $d, $H, $M); |
|---|
| 1542 | } |
|---|
| 1543 | } else { |
|---|
| 1544 | $str = ""; |
|---|
| 1545 | } |
|---|
| 1546 | return $str; |
|---|
| 1547 | } |
|---|
| 1548 | |
|---|
| 1549 | function sfGetDelivTime($payment_id = "") { |
|---|
| 1550 | $objQuery = new SC_Query(); |
|---|
| 1551 | |
|---|
| 1552 | $deliv_id = ""; |
|---|
| 1553 | |
|---|
| 1554 | if($payment_id != "") { |
|---|
| 1555 | $where = "del_flg = 0 AND payment_id = ?"; |
|---|
| 1556 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
|---|
| 1557 | $deliv_id = $arrRet[0]['deliv_id']; |
|---|
| 1558 | } |
|---|
| 1559 | |
|---|
| 1560 | if($deliv_id != "") { |
|---|
| 1561 | $objQuery->setorder("time_id"); |
|---|
| 1562 | $where = "deliv_id = ?"; |
|---|
| 1563 | $arrRet= $objQuery->select("time_id, deliv_time", "dtb_delivtime", $where, array($deliv_id)); |
|---|
| 1564 | } |
|---|
| 1565 | |
|---|
| 1566 | return $arrRet; |
|---|
| 1567 | } |
|---|
| 1568 | |
|---|
| 1569 | |
|---|
| 1570 | // ÅÔÆ»Éܸ©¡¢»Ùʧ¤¤ÊýË¡¤«¤éÇÛÁ÷ÎÁ¶â¤ò¼èÆÀ¤¹¤ë |
|---|
| 1571 | function sfGetDelivFee($pref, $payment_id = "") { |
|---|
| 1572 | $objQuery = new SC_Query(); |
|---|
| 1573 | |
|---|
| 1574 | $deliv_id = ""; |
|---|
| 1575 | |
|---|
| 1576 | // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¡¢Âбþ¤·¤¿ÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë |
|---|
| 1577 | if($payment_id != "") { |
|---|
| 1578 | $where = "del_flg = 0 AND payment_id = ?"; |
|---|
| 1579 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
|---|
| 1580 | $deliv_id = $arrRet[0]['deliv_id']; |
|---|
| 1581 | // »Ùʧ¤¤ÊýË¡¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÀèÆ¬¤ÎÇÛÁ÷¶È¼Ô¤ò¼èÆÀ¤¹¤ë |
|---|
| 1582 | } else { |
|---|
| 1583 | $where = "del_flg = 0"; |
|---|
| 1584 | $objQuery->setOrder("rank DESC"); |
|---|
| 1585 | $objQuery->setLimitOffset(1); |
|---|
| 1586 | $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where); |
|---|
| 1587 | $deliv_id = $arrRet[0]['deliv_id']; |
|---|
| 1588 | } |
|---|
| 1589 | |
|---|
| 1590 | // ÇÛÁ÷¶È¼Ô¤«¤éÇÛÁ÷ÎÁ¤ò¼èÆÀ |
|---|
| 1591 | if($deliv_id != "") { |
|---|
| 1592 | |
|---|
| 1593 | // ÅÔÆ»Éܸ©¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢ÅìµþÅÔ¤ÎÈÖ¹æ¤ò»ØÄꤷ¤Æ¤ª¤¯ |
|---|
| 1594 | if($pref == "") { |
|---|
| 1595 | $pref = 13; |
|---|
| 1596 | } |
|---|
| 1597 | |
|---|
| 1598 | $objQuery = new SC_Query(); |
|---|
| 1599 | $where = "deliv_id = ? AND pref = ?"; |
|---|
| 1600 | $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref)); |
|---|
| 1601 | } |
|---|
| 1602 | return $arrRet[0]['fee']; |
|---|
| 1603 | } |
|---|
| 1604 | |
|---|
| 1605 | /* »Ùʧ¤¤ÊýË¡¤Î¼èÆÀ */ |
|---|
| 1606 | function sfGetPayment() { |
|---|
| 1607 | $objQuery = new SC_Query(); |
|---|
| 1608 | // ¹ØÆþ¶â³Û¤¬¾ò·ï³Û°Ê²¼¤Î¹àÌܤò¼èÆÀ |
|---|
| 1609 | $where = "del_flg = 0"; |
|---|
| 1610 | $objQuery->setorder("fix, rank DESC"); |
|---|
| 1611 | $arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where); |
|---|
| 1612 | return $arrRet; |
|---|
| 1613 | } |
|---|
| 1614 | |
|---|
| 1615 | /* ÇÛÎó¤ò¥¡¼Ì¾¤´¤È¤ÎÇÛÎó¤ËÊѹ¹¤¹¤ë */ |
|---|
| 1616 | function sfSwapArray($array) { |
|---|
| 1617 | $max = count($array); |
|---|
| 1618 | for($i = 0; $i < $max; $i++) { |
|---|
| 1619 | foreach($array[$i] as $key => $val) { |
|---|
| 1620 | $arrRet[$key][] = $val; |
|---|
| 1621 | } |
|---|
| 1622 | } |
|---|
| 1623 | return $arrRet; |
|---|
| 1624 | } |
|---|
| 1625 | |
|---|
| 1626 | /* ¤«¤±»»¤ò¤¹¤ë¡ÊSmartyÍÑ) */ |
|---|
| 1627 | function sfMultiply($num1, $num2) { |
|---|
| 1628 | return ($num1 * $num2); |
|---|
| 1629 | } |
|---|
| 1630 | |
|---|
| 1631 | /* DB¤ËÅÐÏ¿¤µ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È¥á¡¼¥ë¤ÎÁ÷¿® */ |
|---|
| 1632 | function sfSendTemplateMail($to, $to_name, $template_id, $objPage) { |
|---|
| 1633 | global $arrMAILTPLPATH; |
|---|
| 1634 | $objQuery = new SC_Query(); |
|---|
| 1635 | // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ |
|---|
| 1636 | $where = "template_id = ?"; |
|---|
| 1637 | $arrRet = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($template_id)); |
|---|
| 1638 | $objPage->tpl_header = $arrRet[0]['header']; |
|---|
| 1639 | $objPage->tpl_footer = $arrRet[0]['footer']; |
|---|
| 1640 | $tmp_subject = $arrRet[0]['subject']; |
|---|
| 1641 | |
|---|
| 1642 | $objSiteInfo = new SC_SiteInfo(); |
|---|
| 1643 | $arrInfo = $objSiteInfo->data; |
|---|
| 1644 | |
|---|
| 1645 | $objMailView = new SC_SiteView(); |
|---|
| 1646 | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
|---|
| 1647 | $objMailView->assignobj($objPage); |
|---|
| 1648 | $body = $objMailView->fetch($arrMAILTPLPATH[$template_id]); |
|---|
| 1649 | |
|---|
| 1650 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
|---|
| 1651 | $objSendMail = new GC_SendMail(); |
|---|
| 1652 | $from = $arrInfo['email03']; |
|---|
| 1653 | $error = $arrInfo['email04']; |
|---|
| 1654 | $tosubject = $tmp_subject; |
|---|
| 1655 | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error); |
|---|
| 1656 | $objSendMail->setTo($to, $to_name); |
|---|
| 1657 | $objSendMail->sendMail(); // ¥á¡¼¥ëÁ÷¿® |
|---|
| 1658 | } |
|---|
| 1659 | |
|---|
| 1660 | /** ¼õÃí´°Î»¥á¡¼¥ëÁ÷¿® |
|---|
| 1661 | * $template_id ¤¬ 1¡§·ÈÂÓÍѥƥó¥×¥ì¡¼¥È¡¢0¡§PCÍѥƥó¥×¥ì¡¼¥È |
|---|
| 1662 | */ |
|---|
| 1663 | function sfSendOrderMail($order_id, $template_id, $subject = "", $body, $send = true) { |
|---|
| 1664 | global $arrMAILTPLPATH; |
|---|
| 1665 | |
|---|
| 1666 | $objPage = new LC_Page(); |
|---|
| 1667 | $objSiteInfo = new SC_SiteInfo(); |
|---|
| 1668 | $arrInfo = $objSiteInfo->data; |
|---|
| 1669 | $objPage->arrInfo = $arrInfo; |
|---|
| 1670 | |
|---|
| 1671 | $objQuery = new SC_Query(); |
|---|
| 1672 | |
|---|
| 1673 | if($subject == "" && $body == "" ) { |
|---|
| 1674 | // ¥á¡¼¥ë¥Æ¥ó¥×¥ì¡¼¥È¾ðÊó¤Î¼èÆÀ |
|---|
| 1675 | $where = "template_id = ?"; |
|---|
| 1676 | $arrRet = $objQuery->select("subject, body", "dtb_mailtemplate", $where, array($template_id)); |
|---|
| 1677 | $objPage->tpl_body = $arrRet[0]['body']; |
|---|
| 1678 | $tmp_subject = $arrRet[0]['subject']; |
|---|
| 1679 | } else { |
|---|
| 1680 | $objPage->tpl_body = $body; |
|---|
| 1681 | $tmp_subject = $subject; |
|---|
| 1682 | } |
|---|
| 1683 | |
|---|
| 1684 | // ¼õÃí¾ðÊó¤Î¼èÆÀ |
|---|
| 1685 | $where = "order_id = ?"; |
|---|
| 1686 | $arrRet = $objQuery->select("*", "dtb_order", $where, array($order_id)); |
|---|
| 1687 | $arrOrder = $arrRet[0]; |
|---|
| 1688 | $arrOrderDetail = $objQuery->select("*", "dtb_order_detail", $where, array($order_id)); |
|---|
| 1689 | |
|---|
| 1690 | $objPage->Message_tmp = $arrOrder['message']; |
|---|
| 1691 | |
|---|
| 1692 | // ¸ÜµÒ¾ðÊó¤Î¼èÆÀ |
|---|
| 1693 | $customer_id = $arrOrder['customer_id']; |
|---|
| 1694 | $arrRet = $objQuery->select("point,name01,name02", "dtb_customer", "customer_id = ?", array($customer_id)); |
|---|
| 1695 | $arrCustomer = $arrRet[0]; |
|---|
| 1696 | sfprintr($arrCustomer);exit; |
|---|
| 1697 | $objPage->arrCustomer = $arrCustomer; |
|---|
| 1698 | $objPage->arrOrder = $arrOrder; |
|---|
| 1699 | |
|---|
| 1700 | //¤½¤Î¾·èºÑ¾ðÊó |
|---|
| 1701 | if($arrOrder['memo02'] != "") { |
|---|
| 1702 | $arrOther = unserialize($arrOrder['memo02']); |
|---|
| 1703 | |
|---|
| 1704 | foreach($arrOther as $other_key => $other_val){ |
|---|
| 1705 | if(sfTrim($other_val["value"]) == ""){ |
|---|
| 1706 | $arrOther[$other_key]["value"] = ""; |
|---|
| 1707 | } |
|---|
| 1708 | } |
|---|
| 1709 | |
|---|
| 1710 | $objPage->arrOther = $arrOther; |
|---|
| 1711 | } |
|---|
| 1712 | |
|---|
| 1713 | // ÅÔÆ»Éܸ©ÊÑ´¹ |
|---|
| 1714 | global $arrPref; |
|---|
| 1715 | $objPage->arrOrder['deliv_pref'] = $arrPref[$objPage->arrOrder['deliv_pref']]; |
|---|
| 1716 | |
|---|
| 1717 | $objPage->arrOrderDetail = $arrOrderDetail; |
|---|
| 1718 | |
|---|
| 1719 | $objCustomer = new SC_Customer(); |
|---|
| 1720 | $objPage->tpl_user_point = $objCustomer->getValue('point'); |
|---|
| 1721 | |
|---|
| 1722 | $objMailView = new SC_SiteView(); |
|---|
| 1723 | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
|---|
| 1724 | $objMailView->assignobj($objPage); |
|---|
| 1725 | $name = $objPage->arrCustomer['name01']." ".$objPage->arrCustomer['name02']; |
|---|
| 1726 | $objPage->tpl_body = ereg_replace( "(\{name\})", $name , $objPage->tpl_body ); |
|---|
| 1727 | $tmp_subject = ereg_replace( "(\{name\})", $name , $tmp_subject ); |
|---|
| 1728 | |
|---|
| 1729 | // $template_id==1¤Ï·ÈÂÓÍÑ |
|---|
| 1730 | if($template_id == '1'){ |
|---|
| 1731 | $body = $objMailView->fetch($arrMAILTPLPATH[1]); |
|---|
| 1732 | $body = ereg_replace( "(\{order\})", $body , $objPage->tpl_body ); |
|---|
| 1733 | }else{ |
|---|
| 1734 | $body = $objMailView->fetch($arrMAILTPLPATH[0]); |
|---|
| 1735 | $body = ereg_replace( "(\{order\})", $body , $objPage->tpl_body ); |
|---|
| 1736 | } |
|---|
| 1737 | |
|---|
| 1738 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
|---|
| 1739 | $objSendMail = new GC_SendMail(); |
|---|
| 1740 | $bcc = $arrInfo['email01']; |
|---|
| 1741 | $from = $arrInfo['email03']; |
|---|
| 1742 | $error = $arrInfo['email04']; |
|---|
| 1743 | |
|---|
| 1744 | $tosubject = sfMakeSubject($tmp_subject); |
|---|
| 1745 | |
|---|
| 1746 | $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
|---|
| 1747 | $objSendMail->setTo($arrOrder["order_email"], $arrOrder["order_name01"] . " ". $arrOrder["order_name02"] ." ÍÍ"); |
|---|
| 1748 | |
|---|
| 1749 | |
|---|
| 1750 | // Á÷¿®¥Õ¥é¥°:true¤Î¾ì¹ç¤Ï¡¢Á÷¿®¤¹¤ë¡£ |
|---|
| 1751 | if($send) { |
|---|
| 1752 | if ($objSendMail->sendMail()) { |
|---|
| 1753 | sfSaveMailHistory($order_id, $template_id, $tosubject, $body); |
|---|
| 1754 | } |
|---|
| 1755 | } |
|---|
| 1756 | return $objSendMail; |
|---|
| 1757 | } |
|---|
| 1758 | |
|---|
| 1759 | // ¥Æ¥ó¥×¥ì¡¼¥È¤ò»ÈÍѤ·¤¿¥á¡¼¥ë¤ÎÁ÷¿® |
|---|
| 1760 | function sfSendTplMail($to, $subject, $tplpath, $objPage) { |
|---|
| 1761 | $objMailView = new SC_SiteView(); |
|---|
| 1762 | $objSiteInfo = new SC_SiteInfo(); |
|---|
| 1763 | $arrInfo = $objSiteInfo->data; |
|---|
| 1764 | // ¥á¡¼¥ëËÜʸ¤Î¼èÆÀ |
|---|
| 1765 | $objPage->tpl_shopname=$arrInfo['shop_name']; |
|---|
| 1766 | $objPage->tpl_infoemail = $arrInfo['email02']; |
|---|
| 1767 | $objMailView->assignobj($objPage); |
|---|
| 1768 | $body = $objMailView->fetch($tplpath); |
|---|
| 1769 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
|---|
| 1770 | $objSendMail = new GC_SendMail(); |
|---|
| 1771 | $to = mb_encode_mimeheader($to); |
|---|
| 1772 | $bcc = $arrInfo['email01']; |
|---|
| 1773 | $from = $arrInfo['email03']; |
|---|
| 1774 | $error = $arrInfo['email04']; |
|---|
| 1775 | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
|---|
| 1776 | $objSendMail->sendMail(); |
|---|
| 1777 | } |
|---|
| 1778 | |
|---|
| 1779 | // Ä̾ï¤Î¥á¡¼¥ëÁ÷¿® |
|---|
| 1780 | function sfSendMail($to, $subject, $body) { |
|---|
| 1781 | $objSiteInfo = new SC_SiteInfo(); |
|---|
| 1782 | $arrInfo = $objSiteInfo->data; |
|---|
| 1783 | // ¥á¡¼¥ëÁ÷¿®½èÍý |
|---|
| 1784 | $objSendMail = new GC_SendMail(); |
|---|
| 1785 | $bcc = $arrInfo['email01']; |
|---|
| 1786 | $from = $arrInfo['email03']; |
|---|
| 1787 | $error = $arrInfo['email04']; |
|---|
| 1788 | $objSendMail->setItem($to, $subject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); |
|---|
| 1789 | $objSendMail->sendMail(); |
|---|
| 1790 | } |
|---|
| 1791 | |
|---|
| 1792 | //·ï̾¤Ë¥Æ¥ó¥×¥ì¡¼¥È¤òÍѤ¤¤ë |
|---|
| 1793 | function sfMakeSubject($subject){ |
|---|
| 1794 | |
|---|
| 1795 | $objQuery = new SC_Query(); |
|---|
| 1796 | $objMailView = new SC_SiteView(); |
|---|
| 1797 | $objPage = new LC_Page(); |
|---|
| 1798 | |
|---|
| 1799 | $arrInfo = $objQuery->select("*","dtb_baseinfo"); |
|---|
| 1800 | $arrInfo = $arrInfo[0]; |
|---|
| 1801 | $objPage->tpl_shopname=$arrInfo['shop_name']; |
|---|
| 1802 | $objPage->tpl_infoemail=$subject; |
|---|
| 1803 | $objMailView->assignobj($objPage); |
|---|
| 1804 | $mailtitle = $objMailView->fetch('mail_templates/mail_title.tpl'); |
|---|
| 1805 | $ret = $mailtitle.$subject; |
|---|
| 1806 | return $ret; |
|---|
| 1807 | } |
|---|
| 1808 | |
|---|
| 1809 | // ¥á¡¼¥ëÇÛ¿®ÍúÎò¤Ø¤ÎÅÐÏ¿ |
|---|
| 1810 | function sfSaveMailHistory($order_id, $template_id, $subject, $body) { |
|---|
| 1811 | $sqlval['subject'] = $subject; |
|---|
| 1812 | $sqlval['order_id'] = $order_id; |
|---|
| 1813 | $sqlval['template_id'] = $template_id; |
|---|
| 1814 | $sqlval['send_date'] = "Now()"; |
|---|
| 1815 | if($_SESSION['member_id'] != "") { |
|---|
| 1816 | $sqlval['creator_id'] = $_SESSION['member_id']; |
|---|
| 1817 | } else { |
|---|
| 1818 | $sqlval['creator_id'] = '0'; |
|---|
| 1819 | } |
|---|
| 1820 | $sqlval['mail_body'] = $body; |
|---|
| 1821 | |
|---|
| 1822 | $objQuery = new SC_Query(); |
|---|
| 1823 | $objQuery->insert("dtb_mail_history", $sqlval); |
|---|
| 1824 | } |
|---|
| 1825 | |
|---|
| 1826 | /* ²ñ°÷¾ðÊó¤ò°ì»þ¼õÃí¥Æ¡¼¥Ö¥ë¤Ø */ |
|---|
| 1827 | function sfGetCustomerSqlVal($uniqid, $sqlval) { |
|---|
| 1828 | $objCustomer = new SC_Customer(); |
|---|
| 1829 | // ²ñ°÷¾ðÊóÅÐÏ¿½èÍý |
|---|
| 1830 | if ($objCustomer->isLoginSuccess()) { |
|---|
| 1831 | // ÅÐÏ¿¥Ç¡¼¥¿¤ÎºîÀ® |
|---|
| 1832 | $sqlval['order_temp_id'] = $uniqid; |
|---|
| 1833 | $sqlval['update_date'] = 'Now()'; |
|---|
| 1834 | $sqlval['customer_id'] = $objCustomer->getValue('customer_id'); |
|---|
| 1835 | $sqlval['order_name01'] = $objCustomer->getValue('name01'); |
|---|
| 1836 | $sqlval['order_name02'] = $objCustomer->getValue('name02'); |
|---|
| 1837 | $sqlval['order_kana01'] = $objCustomer->getValue('kana01'); |
|---|
| 1838 | $sqlval['order_kana02'] = $objCustomer->getValue('kana02'); |
|---|
| 1839 | $sqlval['order_sex'] = $objCustomer->getValue('sex'); |
|---|
| 1840 | $sqlval['order_zip01'] = $objCustomer->getValue('zip01'); |
|---|
| 1841 | $sqlval['order_zip02'] = $objCustomer->getValue('zip02'); |
|---|
| 1842 | $sqlval['order_pref'] = $objCustomer->getValue('pref'); |
|---|
| 1843 | $sqlval['order_addr01'] = $objCustomer->getValue('addr01'); |
|---|
| 1844 | $sqlval['order_addr02'] = $objCustomer->getValue('addr02'); |
|---|
| 1845 | $sqlval['order_tel01'] = $objCustomer->getValue('tel01'); |
|---|
| 1846 | $sqlval['order_tel02'] = $objCustomer->getValue('tel02'); |
|---|
| 1847 | $sqlval['order_tel03'] = $objCustomer->getValue('tel03'); |
|---|
| 1848 | if (defined('MOBILE_SITE')) { |
|---|
| 1849 | $sqlval['order_email'] = $objCustomer->getValue('email_mobile'); |
|---|
| 1850 | } else { |
|---|
| 1851 | $sqlval['order_email'] = $objCustomer->getValue('email'); |
|---|
| 1852 | } |
|---|
| 1853 | $sqlval['order_job'] = $objCustomer->getValue('job'); |
|---|
| 1854 | $sqlval['order_birth'] = $objCustomer->getValue('birth'); |
|---|
| 1855 | } |
|---|
| 1856 | return $sqlval; |
|---|
| 1857 | } |
|---|
| 1858 | |
|---|
| 1859 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤Ø¤Î½ñ¤¹þ¤ß½èÍý |
|---|
| 1860 | function sfRegistTempOrder($uniqid, $sqlval) { |
|---|
| 1861 | if($uniqid != "") { |
|---|
| 1862 | // ´û¸¥Ç¡¼¥¿¤Î¥Á¥§¥Ã¥¯ |
|---|
| 1863 | $objQuery = new SC_Query(); |
|---|
| 1864 | $where = "order_temp_id = ?"; |
|---|
| 1865 | $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid)); |
|---|
| 1866 | // ´û¸¥Ç¡¼¥¿¤¬¤Ê¤¤¾ì¹ç |
|---|
| 1867 | if ($cnt == 0) { |
|---|
| 1868 | // ½é²ó½ñ¤¹þ¤ß»þ¤Ë²ñ°÷¤ÎÅÐÏ¿ºÑ¤ß¾ðÊó¤ò¼è¤ê¹þ¤à |
|---|
| 1869 | $sqlval = sfGetCustomerSqlVal($uniqid, $sqlval); |
|---|
| 1870 | $sqlval['create_date'] = "now()"; |
|---|
| 1871 | $objQuery->insert("dtb_order_temp", $sqlval); |
|---|
| 1872 | } else { |
|---|
| 1873 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); |
|---|
| 1874 | } |
|---|
| 1875 | } |
|---|
| 1876 | } |
|---|
| 1877 | |
|---|
| 1878 | /* ²ñ°÷¤Î¥á¥ë¥Þ¥¬ÅÐÏ¿¤¬¤¢¤ë¤«¤É¤¦¤«¤Î¥Á¥§¥Ã¥¯(²¾²ñ°÷¤ò´Þ¤Þ¤Ê¤¤) */ |
|---|
| 1879 | function sfCheckCustomerMailMaga($email) { |
|---|
| 1880 | $col = "email, mailmaga_flg, customer_id"; |
|---|
| 1881 | $from = "dtb_customer"; |
|---|
| 1882 | $where = "email = ? AND status = 2"; |
|---|
| 1883 | $objQuery = new SC_Query(); |
|---|
| 1884 | $arrRet = $objQuery->select($col, $from, $where, array($email)); |
|---|
| 1885 | // ²ñ°÷¤Î¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë |
|---|
| 1886 | if($arrRet[0]['customer_id'] != "") { |
|---|
| 1887 | return true; |
|---|
| 1888 | } |
|---|
| 1889 | return false; |
|---|
| 1890 | } |
|---|
| 1891 | |
|---|
| 1892 | // ¥«¡¼¥É¤Î½èÍý·ë²Ì¤òÊÖ¤¹ |
|---|
| 1893 | function sfGetAuthonlyResult($dir, $file_name, $name01, $name02, $card_no, $card_exp, $amount, $order_id, $jpo_info = "10"){ |
|---|
| 1894 | |
|---|
| 1895 | $path = $dir .$file_name; // cgi¥Õ¥¡¥¤¥ë¤Î¥Õ¥ë¥Ñ¥¹À¸À® |
|---|
| 1896 | $now_dir = getcwd(); // require¤¬¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¤Î¤Ç¡¢cgi¼Â¹Ô¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Üư¤¹¤ë |
|---|
| 1897 | chdir($dir); |
|---|
| 1898 | |
|---|
| 1899 | // ¥Ñ¥¤¥×ÅϤ·¤Ç¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤écgiµ¯Æ° |
|---|
| 1900 | $cmd = "$path card_no=$card_no name01=$name01 name02=$name02 card_exp=$card_exp amount=$amount order_id=$order_id jpo_info=$jpo_info"; |
|---|
| 1901 | |
|---|
| 1902 | $tmpResult = popen($cmd, "r"); |
|---|
| 1903 | |
|---|
| 1904 | // ·ë²Ì¼èÆÀ |
|---|
| 1905 | while( ! FEOF ( $tmpResult ) ) { |
|---|
| 1906 | $result .= FGETS($tmpResult); |
|---|
| 1907 | } |
|---|
| 1908 | pclose($tmpResult); // ¥Ñ¥¤¥×¤òÊĤ¸¤ë |
|---|
| 1909 | chdir($now_dir); //¡¡¸µ¤Ë¤¤¤¿¥Ç¥£¥ì¥¯¥È¥ê¤Ëµ¢¤ë |
|---|
| 1910 | |
|---|
| 1911 | // ·ë²Ì¤òÏ¢ÁÛÇÛÎ󤨳ÊǼ |
|---|
| 1912 | $result = ereg_replace("&$", "", $result); |
|---|
| 1913 | foreach (explode("&",$result) as $data) { |
|---|
| 1914 | list($key, $val) = explode("=", $data, 2); |
|---|
| 1915 | $return[$key] = $val; |
|---|
| 1916 | } |
|---|
| 1917 | |
|---|
| 1918 | return $return; |
|---|
| 1919 | } |
|---|
| 1920 | |
|---|
| 1921 | // ¼õÃí°ì»þ¥Æ¡¼¥Ö¥ë¤«¤é¾ðÊó¤ò¼èÆÀ¤¹¤ë |
|---|
| 1922 | function sfGetOrderTemp($order_temp_id) { |
|---|
| 1923 | $objQuery = new SC_Query(); |
|---|
| 1924 | $where = "order_temp_id = ?"; |
|---|
| 1925 | $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id)); |
|---|
| 1926 | return $arrRet[0]; |
|---|
| 1927 | } |
|---|
| 1928 | |
|---|
| 1929 | // ¥«¥Æ¥´¥êID¼èÆÀȽÄêÍѤΥ°¥í¡¼¥Ð¥ëÊÑ¿ô(°ìÅÙ¼èÆÀ¤µ¤ì¤Æ¤¤¤¿¤éºÆ¼èÆÀ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë) |
|---|
| 1930 | $g_category_on = false; |
|---|
| 1931 | $g_category_id = ""; |
|---|
| 1932 | |
|---|
| 1933 | /* ÁªÂòÃæ¤Î¥«¥Æ¥´¥ê¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 1934 | function sfGetCategoryId($product_id, $category_id) { |
|---|
| 1935 | global $g_category_on; |
|---|
| 1936 | global $g_category_id; |
|---|
| 1937 | if(!$g_category_on) { |
|---|
| 1938 | $g_category_on = true; |
|---|
| 1939 | $category_id = (int) $category_id; |
|---|
| 1940 | $product_id = (int) $product_id; |
|---|
| 1941 | if(sfIsInt($category_id) && sfIsRecord("dtb_category","category_id", $category_id)) { |
|---|
| 1942 | $g_category_id = $category_id; |
|---|
| 1943 | } else if (sfIsInt($product_id) && sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { |
|---|
| 1944 | $objQuery = new SC_Query(); |
|---|
| 1945 | $where = "product_id = ?"; |
|---|
| 1946 | $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id)); |
|---|
| 1947 | $g_category_id = $category_id; |
|---|
| 1948 | } else { |
|---|
| 1949 | // ÉÔÀµ¤Ê¾ì¹ç¤Ï¡¢0¤òÊÖ¤¹¡£ |
|---|
| 1950 | $g_category_id = 0; |
|---|
| 1951 | } |
|---|
| 1952 | } |
|---|
| 1953 | return $g_category_id; |
|---|
| 1954 | } |
|---|
| 1955 | |
|---|
| 1956 | // ROOTID¼èÆÀȽÄêÍѤΥ°¥í¡¼¥Ð¥ëÊÑ¿ô(°ìÅÙ¼èÆÀ¤µ¤ì¤Æ¤¤¤¿¤éºÆ¼èÆÀ¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë) |
|---|
| 1957 | $g_root_on = false; |
|---|
| 1958 | $g_root_id = ""; |
|---|
| 1959 | |
|---|
| 1960 | /* ÁªÂòÃæ¤Î¥¢¥¤¥Æ¥à¤Î¥ë¡¼¥È¥«¥Æ¥´¥êID¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 1961 | function sfGetRootId() { |
|---|
| 1962 | global $g_root_on; |
|---|
| 1963 | global $g_root_id; |
|---|
| 1964 | if(!$g_root_on) { |
|---|
| 1965 | $g_root_on = true; |
|---|
| 1966 | $objQuery = new SC_Query(); |
|---|
| 1967 | if($_GET['product_id'] != "" || $_GET['category_id'] != "") { |
|---|
| 1968 | // ÁªÂòÃæ¤Î¥«¥Æ¥´¥êID¤òȽÄꤹ¤ë |
|---|
| 1969 | $category_id = sfGetCategoryId($_GET['product_id'], $_GET['category_id']); |
|---|
| 1970 | // ROOT¥«¥Æ¥´¥êID¤Î¼èÆÀ |
|---|
| 1971 | $arrRet = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); |
|---|
| 1972 | $root_id = $arrRet[0]; |
|---|
| 1973 | } else { |
|---|
| 1974 | // ROOT¥«¥Æ¥´¥êID¤ò¤Ê¤·¤ËÀßÄꤹ¤ë |
|---|
| 1975 | $root_id = ""; |
|---|
| 1976 | } |
|---|
| 1977 | $g_root_id = $root_id; |
|---|
| 1978 | } |
|---|
| 1979 | return $g_root_id; |
|---|
| 1980 | } |
|---|
| 1981 | |
|---|
| 1982 | /* ¥«¥Æ¥´¥ê¤«¤é¾¦Éʤò¸¡º÷¤¹¤ë¾ì¹ç¤ÎWHEREʸ¤ÈÃͤòÊÖ¤¹ */ |
|---|
| 1983 | function sfGetCatWhere($category_id) { |
|---|
| 1984 | // »Ò¥«¥Æ¥´¥êID¤Î¼èÆÀ |
|---|
| 1985 | $arrRet = sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id); |
|---|
| 1986 | $tmp_where = ""; |
|---|
| 1987 | foreach ($arrRet as $val) { |
|---|
| 1988 | if($tmp_where == "") { |
|---|
| 1989 | $tmp_where.= " category_id IN ( ?"; |
|---|
| 1990 | } else { |
|---|
| 1991 | $tmp_where.= ",? "; |
|---|
| 1992 | } |
|---|
| 1993 | $arrval[] = $val; |
|---|
| 1994 | } |
|---|
| 1995 | $tmp_where.= " ) "; |
|---|
| 1996 | return array($tmp_where, $arrval); |
|---|
| 1997 | } |
|---|
| 1998 | |
|---|
| 1999 | /* ²Ã»»¥Ý¥¤¥ó¥È¤Î·×»»¼° */ |
|---|
| 2000 | function sfGetAddPoint($totalpoint, $use_point, $arrInfo) { |
|---|
| 2001 | // ¹ØÆþ¾¦Éʤιç·×¥Ý¥¤¥ó¥È¤«¤éÍøÍѤ·¤¿¥Ý¥¤¥ó¥È¤Î¥Ý¥¤¥ó¥È´¹»»²ÁÃͤò°ú¤¯Êý¼° |
|---|
| 2002 | $add_point = $totalpoint - intval($use_point * ($arrInfo['point_rate'] / 100)); |
|---|
| 2003 | |
|---|
| 2004 | if($add_point < 0) { |
|---|
| 2005 | $add_point = '0'; |
|---|
| 2006 | } |
|---|
| 2007 | return $add_point; |
|---|
| 2008 | } |
|---|
| 2009 | |
|---|
| 2010 | /* °ì°Õ¤«¤Äͽ¬¤µ¤ì¤Ë¤¯¤¤ID */ |
|---|
| 2011 | function sfGetUniqRandomId($head = "") { |
|---|
| 2012 | // ͽ¬¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¥é¥ó¥À¥àʸ»úÎó¤òÉÕÍ¿¤¹¤ë¡£ |
|---|
| 2013 | $random = gfMakePassword(8); |
|---|
| 2014 | // Ʊ°ì¥Û¥¹¥ÈÆâ¤Ç°ì°Õ¤ÊID¤òÀ¸À® |
|---|
| 2015 | $id = uniqid($head); |
|---|
| 2016 | return ($id . $random); |
|---|
| 2017 | } |
|---|
| 2018 | |
|---|
| 2019 | // ¥«¥Æ¥´¥êÊÌ¥ª¥¹¥¹¥áÉʤμèÆÀ |
|---|
| 2020 | function sfGetBestProducts( $conn, $category_id = 0){ |
|---|
| 2021 | // ´û¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëÆâÍÆ¤ò¼èÆÀ¤¹¤ë |
|---|
| 2022 | $sql = "SELECT name, main_image, main_list_image, price01_min, price01_max, price02_min, price02_max, point_rate, |
|---|
| 2023 | A.product_id, A.comment FROM dtb_best_products as A LEFT JOIN vw_products_allclass AS allcls |
|---|
| 2024 | USING (product_id) WHERE A.category_id = ? AND A.del_flg = 0 AND status = 1 ORDER BY A.rank"; |
|---|
| 2025 | $arrItems = $conn->getAll($sql, array($category_id)); |
|---|
| 2026 | |
|---|
| 2027 | return $arrItems; |
|---|
| 2028 | } |
|---|
| 2029 | |
|---|
| 2030 | // ÆÃ¼ìÀ©¸æÊ¸»ú¤Î¼êư¥¨¥¹¥±¡¼¥× |
|---|
| 2031 | function sfManualEscape($data) { |
|---|
| 2032 | // ÇÛÎó¤Ç¤Ê¤¤¾ì¹ç |
|---|
| 2033 | if(!is_array($data)) { |
|---|
| 2034 | if (DB_TYPE == "pgsql") { |
|---|
| 2035 | $ret = pg_escape_string($data); |
|---|
| 2036 | }else if(DB_TYPE == "mysql"){ |
|---|
| 2037 | $ret = mysql_real_escape_string($data); |
|---|
| 2038 | } |
|---|
| 2039 | $ret = ereg_replace("%", "\\%", $ret); |
|---|
| 2040 | $ret = ereg_replace("_", "\\_", $ret); |
|---|
| 2041 | return $ret; |
|---|
| 2042 | } |
|---|
| 2043 | |
|---|
| 2044 | // ÇÛÎó¤Î¾ì¹ç |
|---|
| 2045 | foreach($data as $val) { |
|---|
| 2046 | if (DB_TYPE == "pgsql") { |
|---|
| 2047 | $ret = pg_escape_string($val); |
|---|
| 2048 | }else if(DB_TYPE == "mysql"){ |
|---|
| 2049 | $ret = mysql_real_escape_string($val); |
|---|
| 2050 | } |
|---|
| 2051 | |
|---|
| 2052 | $ret = ereg_replace("%", "\\%", $ret); |
|---|
| 2053 | $ret = ereg_replace("_", "\\_", $ret); |
|---|
| 2054 | $arrRet[] = $ret; |
|---|
| 2055 | } |
|---|
| 2056 | |
|---|
| 2057 | return $arrRet; |
|---|
| 2058 | } |
|---|
| 2059 | |
|---|
| 2060 | // ¼õÃíÈÖ¹æ¡¢ÍøÍѥݥ¤¥ó¥È¡¢²Ã»»¥Ý¥¤¥ó¥È¤«¤éºÇ½ª¥Ý¥¤¥ó¥È¤ò¼èÆÀ |
|---|
| 2061 | function sfGetCustomerPoint($order_id, $use_point, $add_point) { |
|---|
| 2062 | $objQuery = new SC_Query(); |
|---|
| 2063 | $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); |
|---|
| 2064 | $customer_id = $arrRet[0]['customer_id']; |
|---|
| 2065 | if($customer_id != "" && $customer_id >= 1) { |
|---|
| 2066 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
|---|
| 2067 | $point = $arrRet[0]['point']; |
|---|
| 2068 | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
|---|
| 2069 | } else { |
|---|
| 2070 | $total_point = ""; |
|---|
| 2071 | $point = ""; |
|---|
| 2072 | } |
|---|
| 2073 | return array($point, $total_point); |
|---|
| 2074 | } |
|---|
| 2075 | |
|---|
| 2076 | /* ¥É¥á¥¤¥ó´Ö¤Ç͸ú¤Ê¥»¥Ã¥·¥ç¥ó¤Î¥¹¥¿¡¼¥È */ |
|---|
| 2077 | function sfDomainSessionStart() { |
|---|
| 2078 | $ret = session_id(); |
|---|
| 2079 | /* |
|---|
| 2080 | ¥Ø¥Ã¥À¡¼¤òÁ÷¿®¤·¤Æ¤¤¤Æ¤âsession_start()¤¬É¬Íפʥڡ¼¥¸¤¬¤¢¤ë¤Î¤Ç |
|---|
| 2081 | ¥³¥á¥ó¥È¥¢¥¦¥È¤·¤Æ¤ª¤¯ |
|---|
| 2082 | if($ret == "" && !headers_sent()) { |
|---|
| 2083 | */ |
|---|
| 2084 | if($ret == "") { |
|---|
| 2085 | /* ¥»¥Ã¥·¥ç¥ó¥Ñ¥é¥á¡¼¥¿¤Î»ØÄê |
|---|
| 2086 | ¡¦¥Ö¥é¥¦¥¶¤òÊĤ¸¤ë¤Þ¤Ç͸ú |
|---|
| 2087 | ¡¦¤¹¤Ù¤Æ¤Î¥Ñ¥¹¤Ç͸ú |
|---|
| 2088 | ¡¦Æ±¤¸¥É¥á¥¤¥ó´Ö¤Ç¶¦Í */ |
|---|
| 2089 | session_set_cookie_params (0, "/", DOMAIN_NAME); |
|---|
| 2090 | |
|---|
| 2091 | if(!ini_get("session.auto_start")){ |
|---|
| 2092 | // ¥»¥Ã¥·¥ç¥ó³«»Ï |
|---|
| 2093 | session_start(); |
|---|
| 2094 | } |
|---|
| 2095 | } |
|---|
| 2096 | } |
|---|
| 2097 | |
|---|
| 2098 | /* ʸ»úÎó¤Ë¶¯À©Åª¤Ë²þ¹Ô¤òÆþ¤ì¤ë */ |
|---|
| 2099 | function sfPutBR($str, $size) { |
|---|
| 2100 | $i = 0; |
|---|
| 2101 | $cnt = 0; |
|---|
| 2102 | $line = array(); |
|---|
| 2103 | $ret = ""; |
|---|
| 2104 | |
|---|
| 2105 | while($str[$i] != "") { |
|---|
| 2106 | $line[$cnt].=$str[$i]; |
|---|
| 2107 | $i++; |
|---|
| 2108 | if(strlen($line[$cnt]) > $size) { |
|---|
| 2109 | $line[$cnt].="<br />"; |
|---|
| 2110 | $cnt++; |
|---|
| 2111 | } |
|---|
| 2112 | } |
|---|
| 2113 | |
|---|
| 2114 | foreach($line as $val) { |
|---|
| 2115 | $ret.=$val; |
|---|
| 2116 | } |
|---|
| 2117 | return $ret; |
|---|
| 2118 | } |
|---|
| 2119 | |
|---|
| 2120 | // Æó²ó°Ê¾å·«¤êÊÖ¤µ¤ì¤Æ¤¤¤ë¥¹¥é¥Ã¥·¥å[/]¤ò°ì¤Ä¤ËÊÑ´¹¤¹¤ë¡£ |
|---|
| 2121 | function sfRmDupSlash($istr){ |
|---|
| 2122 | if(ereg("^http://", $istr)) { |
|---|
| 2123 | $str = substr($istr, 7); |
|---|
| 2124 | $head = "http://"; |
|---|
| 2125 | } else if(ereg("^https://", $istr)) { |
|---|
| 2126 | $str = substr($istr, 8); |
|---|
| 2127 | $head = "https://"; |
|---|
| 2128 | } else { |
|---|
| 2129 | $str = $istr; |
|---|
| 2130 | } |
|---|
| 2131 | $str = ereg_replace("[/]+", "/", $str); |
|---|
| 2132 | $ret = $head . $str; |
|---|
| 2133 | return $ret; |
|---|
| 2134 | } |
|---|
| 2135 | |
|---|
| 2136 | function sfEncodeFile($filepath, $enc_type, $out_dir) { |
|---|
| 2137 | $ifp = fopen($filepath, "r"); |
|---|
| 2138 | |
|---|
| 2139 | $basename = basename($filepath); |
|---|
| 2140 | $outpath = $out_dir . "enc_" . $basename; |
|---|
| 2141 | |
|---|
| 2142 | $ofp = fopen($outpath, "w+"); |
|---|
| 2143 | |
|---|
| 2144 | while(!feof($ifp)) { |
|---|
| 2145 | $line = fgets($ifp); |
|---|
| 2146 | $line = mb_convert_encoding($line, $enc_type, "auto"); |
|---|
| 2147 | fwrite($ofp, $line); |
|---|
| 2148 | } |
|---|
| 2149 | |
|---|
| 2150 | fclose($ofp); |
|---|
| 2151 | fclose($ifp); |
|---|
| 2152 | |
|---|
| 2153 | return $outpath; |
|---|
| 2154 | } |
|---|
| 2155 | |
|---|
| 2156 | function sfCutString($str, $len, $byte = true, $commadisp = true) { |
|---|
| 2157 | if($byte) { |
|---|
| 2158 | if(strlen($str) > ($len + 2)) { |
|---|
| 2159 | $ret =substr($str, 0, $len); |
|---|
| 2160 | $cut = substr($str, $len); |
|---|
| 2161 | } else { |
|---|
| 2162 | $ret = $str; |
|---|
| 2163 | $commadisp = false; |
|---|
| 2164 | } |
|---|
| 2165 | } else { |
|---|
| 2166 | if(mb_strlen($str) > ($len + 1)) { |
|---|
| 2167 | $ret = mb_substr($str, 0, $len); |
|---|
| 2168 | $cut = mb_substr($str, $len); |
|---|
| 2169 | } else { |
|---|
| 2170 | $ret = $str; |
|---|
| 2171 | $commadisp = false; |
|---|
| 2172 | } |
|---|
| 2173 | } |
|---|
| 2174 | |
|---|
| 2175 | // ³¨Ê¸»ú¥¿¥°¤ÎÅÓÃæ¤ÇʬÃǤµ¤ì¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£ |
|---|
| 2176 | if (isset($cut)) { |
|---|
| 2177 | // ʬ³ä°ÌÃÖ¤è¤êÁ°¤ÎºÇ¸å¤Î [ °Ê¹ß¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 2178 | $head = strrchr($ret, '['); |
|---|
| 2179 | |
|---|
| 2180 | // ʬ³ä°ÌÃÖ¤è¤ê¸å¤ÎºÇ½é¤Î ] °ÊÁ°¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 2181 | $tail_pos = strpos($cut, ']'); |
|---|
| 2182 | if ($tail_pos !== false) { |
|---|
| 2183 | $tail = substr($cut, 0, $tail_pos + 1); |
|---|
| 2184 | } |
|---|
| 2185 | |
|---|
| 2186 | // ʬ³ä°ÌÃÖ¤è¤êÁ°¤Ë [¡¢¸å¤Ë ] ¤¬¸«¤Ä¤«¤Ã¤¿¾ì¹ç¤Ï¡¢[ ¤«¤é ] ¤Þ¤Ç¤ò |
|---|
| 2187 | // Àܳ¤·¤Æ³¨Ê¸»ú¥¿¥°1¸Äʬ¤Ë¤Ê¤ë¤«¤É¤¦¤«¤ò¥Á¥§¥Ã¥¯¤¹¤ë¡£ |
|---|
| 2188 | if ($head !== false && $tail_pos !== false) { |
|---|
| 2189 | $subject = $head . $tail; |
|---|
| 2190 | if (preg_match('/^\[emoji:e?\d+\]$/', $subject)) { |
|---|
| 2191 | // ³¨Ê¸»ú¥¿¥°¤¬¸«¤Ä¤«¤Ã¤¿¤Î¤Çºï½ü¤¹¤ë¡£ |
|---|
| 2192 | $ret = substr($ret, 0, -strlen($head)); |
|---|
| 2193 | } |
|---|
| 2194 | } |
|---|
| 2195 | } |
|---|
| 2196 | |
|---|
| 2197 | if($commadisp){ |
|---|
| 2198 | $ret = $ret . "..."; |
|---|
| 2199 | } |
|---|
| 2200 | return $ret; |
|---|
| 2201 | } |
|---|
| 2202 | |
|---|
| 2203 | // ǯ¡¢·î¡¢Äù¤áÆü¤«¤é¡¢Àè·î¤ÎÄù¤áÆü+1¡¢º£·î¤ÎÄù¤áÆü¤òµá¤á¤ë¡£ |
|---|
| 2204 | function sfTermMonth($year, $month, $close_day) { |
|---|
| 2205 | $end_year = $year; |
|---|
| 2206 | $end_month = $month; |
|---|
| 2207 | |
|---|
| 2208 | // ³«»Ï·î¤¬½ªÎ»·î¤ÈƱ¤¸¤«Èݤ« |
|---|
| 2209 | $same_month = false; |
|---|
| 2210 | |
|---|
| 2211 | // ³ºÅö·î¤ÎËöÆü¤òµá¤á¤ë¡£ |
|---|
| 2212 | $end_last_day = date("d", mktime(0, 0, 0, $month + 1, 0, $year)); |
|---|
| 2213 | |
|---|
| 2214 | // ·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç |
|---|
| 2215 | if($end_last_day < $close_day) { |
|---|
| 2216 | // Äù¤áÆü¤ò·îËöÆü¤Ë¹ç¤ï¤»¤ë |
|---|
| 2217 | $end_day = $end_last_day; |
|---|
| 2218 | } else { |
|---|
| 2219 | $end_day = $close_day; |
|---|
| 2220 | } |
|---|
| 2221 | |
|---|
| 2222 | // Á°·î¤Î¼èÆÀ |
|---|
| 2223 | $tmp_year = date("Y", mktime(0, 0, 0, $month, 0, $year)); |
|---|
| 2224 | $tmp_month = date("m", mktime(0, 0, 0, $month, 0, $year)); |
|---|
| 2225 | // Á°·î¤ÎËöÆü¤òµá¤á¤ë¡£ |
|---|
| 2226 | $start_last_day = date("d", mktime(0, 0, 0, $month, 0, $year)); |
|---|
| 2227 | |
|---|
| 2228 | // Á°·î¤ÎËöÆü¤¬Äù¤áÆü¤è¤ê¾¯¤Ê¤¤¾ì¹ç |
|---|
| 2229 | if ($start_last_day < $close_day) { |
|---|
| 2230 | // ·îËöÆü¤Ë¹ç¤ï¤»¤ë |
|---|
| 2231 | $tmp_day = $start_last_day; |
|---|
| 2232 | } else { |
|---|
| 2233 | $tmp_day = $close_day; |
|---|
| 2234 | } |
|---|
| 2235 | |
|---|
| 2236 | // Àè·î¤ÎËöÆü¤ÎÍâÆü¤ò¼èÆÀ¤¹¤ë |
|---|
| 2237 | $start_year = date("Y", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
|---|
| 2238 | $start_month = date("m", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
|---|
| 2239 | $start_day = date("d", mktime(0, 0, 0, $tmp_month, $tmp_day + 1, $tmp_year)); |
|---|
| 2240 | |
|---|
| 2241 | // ÆüÉդκîÀ® |
|---|
| 2242 | $start_date = sprintf("%d/%d/%d 00:00:00", $start_year, $start_month, $start_day); |
|---|
| 2243 | $end_date = sprintf("%d/%d/%d 23:59:59", $end_year, $end_month, $end_day); |
|---|
| 2244 | |
|---|
| 2245 | return array($start_date, $end_date); |
|---|
| 2246 | } |
|---|
| 2247 | |
|---|
| 2248 | // PDFÍѤÎRGB¥«¥é¡¼¤òÊÖ¤¹ |
|---|
| 2249 | function sfGetPdfRgb($hexrgb) { |
|---|
| 2250 | $hex = substr($hexrgb, 0, 2); |
|---|
| 2251 | $r = hexdec($hex) / 255; |
|---|
| 2252 | |
|---|
| 2253 | $hex = substr($hexrgb, 2, 2); |
|---|
| 2254 | $g = hexdec($hex) / 255; |
|---|
| 2255 | |
|---|
| 2256 | $hex = substr($hexrgb, 4, 2); |
|---|
| 2257 | $b = hexdec($hex) / 255; |
|---|
| 2258 | |
|---|
| 2259 | return array($r, $g, $b); |
|---|
| 2260 | } |
|---|
| 2261 | |
|---|
| 2262 | //¥á¥ë¥Þ¥¬²¾ÅÐÏ¿¤È¥á¡¼¥ëÇÛ¿® |
|---|
| 2263 | function sfRegistTmpMailData($mail_flag, $email){ |
|---|
| 2264 | $objQuery = new SC_Query(); |
|---|
| 2265 | $objConn = new SC_DBConn(); |
|---|
| 2266 | $objPage = new LC_Page(); |
|---|
| 2267 | |
|---|
| 2268 | $random_id = sfGetUniqRandomId(); |
|---|
| 2269 | $arrRegistMailMagazine["mail_flag"] = $mail_flag; |
|---|
| 2270 | $arrRegistMailMagazine["email"] = $email; |
|---|
| 2271 | $arrRegistMailMagazine["temp_id"] =$random_id; |
|---|
| 2272 | $arrRegistMailMagazine["end_flag"]='0'; |
|---|
| 2273 | $arrRegistMailMagazine["update_date"] = 'now()'; |
|---|
| 2274 | |
|---|
| 2275 | //¥á¥ë¥Þ¥¬²¾ÅÐÏ¿Íѥե饰 |
|---|
| 2276 | $flag = $objQuery->count("dtb_customer_mail_temp", "email=?", array($email)); |
|---|
| 2277 | $objConn->query("BEGIN"); |
|---|
| 2278 | switch ($flag){ |
|---|
| 2279 | case '0': |
|---|
| 2280 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine); |
|---|
| 2281 | break; |
|---|
| 2282 | |
|---|
| 2283 | case '1': |
|---|
| 2284 | $objConn->autoExecute("dtb_customer_mail_temp",$arrRegistMailMagazine, "email = '" .addslashes($email). "'"); |
|---|
| 2285 | break; |
|---|
| 2286 | } |
|---|
| 2287 | $objConn->query("COMMIT"); |
|---|
| 2288 | $subject = sfMakeSubject('¥á¥ë¥Þ¥¬²¾ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£'); |
|---|
| 2289 | $objPage->tpl_url = SSL_URL."mailmagazine/regist.php?temp_id=".$arrRegistMailMagazine['temp_id']; |
|---|
| 2290 | switch ($mail_flag){ |
|---|
| 2291 | case '1': |
|---|
| 2292 | $objPage->tpl_name = "ÅÐÏ¿"; |
|---|
| 2293 | $objPage->tpl_kindname = "HTML"; |
|---|
| 2294 | break; |
|---|
| 2295 | |
|---|
| 2296 | case '2': |
|---|
| 2297 | $objPage->tpl_name = "ÅÐÏ¿"; |
|---|
| 2298 | $objPage->tpl_kindname = "¥Æ¥¥¹¥È"; |
|---|
| 2299 | break; |
|---|
| 2300 | |
|---|
| 2301 | case '3': |
|---|
| 2302 | $objPage->tpl_name = "²ò½ü"; |
|---|
| 2303 | break; |
|---|
| 2304 | } |
|---|
| 2305 | $objPage->tpl_email = $email; |
|---|
| 2306 | sfSendTplMail($email, $subject, 'mail_templates/mailmagazine_temp.tpl', $objPage); |
|---|
| 2307 | } |
|---|
| 2308 | |
|---|
| 2309 | // ºÆµ¢Åª¤Ë¿ÃÊÇÛÎó¤ò¸¡º÷¤·¤Æ°ì¼¡¸µÇÛÎó(Hidden°úÅϤ·ÍÑÇÛÎó)¤ËÊÑ´¹¤¹¤ë¡£ |
|---|
| 2310 | function sfMakeHiddenArray($arrSrc, $arrDst = array(), $parent_key = "") { |
|---|
| 2311 | if(is_array($arrSrc)) { |
|---|
| 2312 | foreach($arrSrc as $key => $val) { |
|---|
| 2313 | if($parent_key != "") { |
|---|
| 2314 | $keyname = $parent_key . "[". $key . "]"; |
|---|
| 2315 | } else { |
|---|
| 2316 | $keyname = $key; |
|---|
| 2317 | } |
|---|
| 2318 | if(is_array($val)) { |
|---|
| 2319 | $arrDst = sfMakeHiddenArray($val, $arrDst, $keyname); |
|---|
| 2320 | } else { |
|---|
| 2321 | $arrDst[$keyname] = $val; |
|---|
| 2322 | } |
|---|
| 2323 | } |
|---|
| 2324 | } |
|---|
| 2325 | return $arrDst; |
|---|
| 2326 | } |
|---|
| 2327 | |
|---|
| 2328 | // DB¼èÆÀÆü»þ¤ò¥¿¥¤¥à¤ËÊÑ´¹ |
|---|
| 2329 | function sfDBDatetoTime($db_date) { |
|---|
| 2330 | $date = ereg_replace("\..*$","",$db_date); |
|---|
| 2331 | $time = strtotime($date); |
|---|
| 2332 | return $time; |
|---|
| 2333 | } |
|---|
| 2334 | |
|---|
| 2335 | // ½ÐÎϤκݤ˥ƥó¥×¥ì¡¼¥È¤òÀÚ¤êÂØ¤¨¤é¤ì¤ë |
|---|
| 2336 | /* |
|---|
| 2337 | index.php?tpl=test.tpl |
|---|
| 2338 | */ |
|---|
| 2339 | function sfCustomDisplay($objPage, $is_mobile = false) { |
|---|
| 2340 | $basename = basename($_SERVER["REQUEST_URI"]); |
|---|
| 2341 | |
|---|
| 2342 | if($basename == "") { |
|---|
| 2343 | $path = $_SERVER["REQUEST_URI"] . "index.php"; |
|---|
| 2344 | } else { |
|---|
| 2345 | $path = $_SERVER["REQUEST_URI"]; |
|---|
| 2346 | } |
|---|
| 2347 | |
|---|
| 2348 | if($_GET['tpl'] != "") { |
|---|
| 2349 | $tpl_name = $_GET['tpl']; |
|---|
| 2350 | } else { |
|---|
| 2351 | $tpl_name = ereg_replace("^/", "", $path); |
|---|
| 2352 | $tpl_name = ereg_replace("/", "_", $tpl_name); |
|---|
| 2353 | $tpl_name = ereg_replace("(\.php$|\.html$)", ".tpl", $tpl_name); |
|---|
| 2354 | } |
|---|
| 2355 | |
|---|
| 2356 | $template_path = TEMPLATE_FTP_DIR . $tpl_name; |
|---|
| 2357 | |
|---|
| 2358 | if($is_mobile === true) { |
|---|
| 2359 | $objView = new SC_MobileView(); |
|---|
| 2360 | $objView->assignobj($objPage); |
|---|
| 2361 | $objView->display(SITE_FRAME); |
|---|
| 2362 | } else if(file_exists($template_path)) { |
|---|
| 2363 | $objView = new SC_UserView(TEMPLATE_FTP_DIR, COMPILE_FTP_DIR); |
|---|
| 2364 | $objView->assignobj($objPage); |
|---|
| 2365 | $objView->display($tpl_name); |
|---|
| 2366 | } else { |
|---|
| 2367 | $objView = new SC_SiteView(); |
|---|
| 2368 | $objView->assignobj($objPage); |
|---|
| 2369 | $objView->display(SITE_FRAME); |
|---|
| 2370 | } |
|---|
| 2371 | } |
|---|
| 2372 | |
|---|
| 2373 | //²ñ°÷ÊÔ½¸ÅÐÏ¿½èÍý |
|---|
| 2374 | function sfEditCustomerData($array, $arrRegistColumn) { |
|---|
| 2375 | $objQuery = new SC_Query(); |
|---|
| 2376 | |
|---|
| 2377 | foreach ($arrRegistColumn as $data) { |
|---|
| 2378 | if ($data["column"] != "password") { |
|---|
| 2379 | if($array[ $data['column'] ] != "") { |
|---|
| 2380 | $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; |
|---|
| 2381 | } else { |
|---|
| 2382 | $arrRegist[ $data['column'] ] = NULL; |
|---|
| 2383 | } |
|---|
| 2384 | } |
|---|
| 2385 | } |
|---|
| 2386 | if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) { |
|---|
| 2387 | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
|---|
| 2388 | } else { |
|---|
| 2389 | $arrRegist["birth"] = NULL; |
|---|
| 2390 | } |
|---|
| 2391 | |
|---|
| 2392 | //-- ¥Ñ¥¹¥ï¡¼¥É¤Î¹¹¿·¤¬¤¢¤ë¾ì¹ç¤Ï°Å¹æ²½¡£¡Ê¹¹¿·¤¬¤Ê¤¤¾ì¹ç¤ÏUPDATEʸ¤ò¹½À®¤·¤Ê¤¤¡Ë |
|---|
| 2393 | if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
|---|
| 2394 | $arrRegist["update_date"] = "NOW()"; |
|---|
| 2395 | |
|---|
| 2396 | //-- ÊÔ½¸ÅÐÏ¿¼Â¹Ô |
|---|
| 2397 | if (defined('MOBILE_SITE')) { |
|---|
| 2398 | $arrRegist['email_mobile'] = $arrRegist['email']; |
|---|
| 2399 | unset($arrRegist['email']); |
|---|
| 2400 | } |
|---|
| 2401 | $objQuery->begin(); |
|---|
| 2402 | $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id'])); |
|---|
| 2403 | $objQuery->commit(); |
|---|
| 2404 | } |
|---|
| 2405 | |
|---|
| 2406 | // PHP¤Îmb_convert_encoding´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë |
|---|
| 2407 | function sf_mb_convert_encoding($str, $encode = 'CHAR_CODE') { |
|---|
| 2408 | return mb_convert_encoding($str, $encode); |
|---|
| 2409 | } |
|---|
| 2410 | |
|---|
| 2411 | // PHP¤Îmktime´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë |
|---|
| 2412 | function sf_mktime($format, $hour=0, $minute=0, $second=0, $month=1, $day=1, $year=1999) { |
|---|
| 2413 | return date($format,mktime($hour, $minute, $second, $month, $day, $year)); |
|---|
| 2414 | } |
|---|
| 2415 | |
|---|
| 2416 | // PHP¤Îdate´Ø¿ô¤òSmarty¤Ç¤â»È¤¨¤ë¤è¤¦¤Ë¤¹¤ë |
|---|
| 2417 | function sf_date($format, $timestamp = '') { |
|---|
| 2418 | return date( $format, $timestamp); |
|---|
| 2419 | } |
|---|
| 2420 | |
|---|
| 2421 | // ¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤Î·¿¤òÊÑ´¹¤¹¤ë |
|---|
| 2422 | function sfChangeCheckBox($data , $tpl = false){ |
|---|
| 2423 | if ($tpl) { |
|---|
| 2424 | if ($data == 1){ |
|---|
| 2425 | return 'checked'; |
|---|
| 2426 | }else{ |
|---|
| 2427 | return ""; |
|---|
| 2428 | } |
|---|
| 2429 | }else{ |
|---|
| 2430 | if ($data == "on"){ |
|---|
| 2431 | return 1; |
|---|
| 2432 | }else{ |
|---|
| 2433 | return 2; |
|---|
| 2434 | } |
|---|
| 2435 | } |
|---|
| 2436 | } |
|---|
| 2437 | |
|---|
| 2438 | function sfCategory_Count($objQuery){ |
|---|
| 2439 | $sql = ""; |
|---|
| 2440 | |
|---|
| 2441 | //¥Æ¡¼¥Ö¥ëÆâÍÆ¤Îºï½ü |
|---|
| 2442 | $objQuery->query("DELETE FROM dtb_category_count"); |
|---|
| 2443 | $objQuery->query("DELETE FROM dtb_category_total_count"); |
|---|
| 2444 | |
|---|
| 2445 | //³Æ¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò¿ô¤¨¤Æ³ÊǼ |
|---|
| 2446 | $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) "; |
|---|
| 2447 | $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 "; |
|---|
| 2448 | $sql .= " ON T1.category_id = T2.category_id "; |
|---|
| 2449 | $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; |
|---|
| 2450 | $sql .= " GROUP BY T1.category_id, T2.category_id "; |
|---|
| 2451 | $objQuery->query($sql); |
|---|
| 2452 | |
|---|
| 2453 | //»Ò¥«¥Æ¥´¥êÆâ¤Î¾¦ÉÊ¿ô¤ò½¸·×¤¹¤ë |
|---|
| 2454 | $arrCat = $objQuery->getAll("SELECT * FROM dtb_category"); |
|---|
| 2455 | |
|---|
| 2456 | $sql = ""; |
|---|
| 2457 | foreach($arrCat as $key => $val){ |
|---|
| 2458 | |
|---|
| 2459 | // »ÒID°ìÍ÷¤ò¼èÆÀ |
|---|
| 2460 | $arrRet = sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']); |
|---|
| 2461 | $line = sfGetCommaList($arrRet); |
|---|
| 2462 | |
|---|
| 2463 | $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) "; |
|---|
| 2464 | $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count "; |
|---|
| 2465 | $sql .= " WHERE category_id IN (" . $line . ")"; |
|---|
| 2466 | |
|---|
| 2467 | $objQuery->query($sql, array($val['category_id'])); |
|---|
| 2468 | } |
|---|
| 2469 | } |
|---|
| 2470 | |
|---|
| 2471 | // 2¤Ä¤ÎÇÛÎó¤òÍѤ¤¤ÆÏ¢ÁÛÇÛÎó¤òºîÀ®¤¹¤ë |
|---|
| 2472 | function sfarrCombine($arrKeys, $arrValues) { |
|---|
| 2473 | |
|---|
| 2474 | if(count($arrKeys) <= 0 and count($arrValues) <= 0) return array(); |
|---|
| 2475 | |
|---|
| 2476 | $keys = array_values($arrKeys); |
|---|
| 2477 | $vals = array_values($arrValues); |
|---|
| 2478 | |
|---|
| 2479 | $max = max( count( $keys ), count( $vals ) ); |
|---|
| 2480 | $combine_ary = array(); |
|---|
| 2481 | for($i=0; $i<$max; $i++) { |
|---|
| 2482 | $combine_ary[$keys[$i]] = $vals[$i]; |
|---|
| 2483 | } |
|---|
| 2484 | if(is_array($combine_ary)) return $combine_ary; |
|---|
| 2485 | |
|---|
| 2486 | return false; |
|---|
| 2487 | } |
|---|
| 2488 | |
|---|
| 2489 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤é»ÒIDÇÛÎó¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 2490 | function sfGetChildrenArray($table, $pid_name, $id_name, $id) { |
|---|
| 2491 | $objQuery = new SC_Query(); |
|---|
| 2492 | $col = $pid_name . "," . $id_name; |
|---|
| 2493 | $arrData = $objQuery->select($col, $table); |
|---|
| 2494 | |
|---|
| 2495 | $arrPID = array(); |
|---|
| 2496 | $arrPID[] = $id; |
|---|
| 2497 | $arrChildren = array(); |
|---|
| 2498 | $arrChildren[] = $id; |
|---|
| 2499 | |
|---|
| 2500 | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); |
|---|
| 2501 | |
|---|
| 2502 | while(count($arrRet) > 0) { |
|---|
| 2503 | $arrChildren = array_merge($arrChildren, $arrRet); |
|---|
| 2504 | $arrRet = sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); |
|---|
| 2505 | } |
|---|
| 2506 | |
|---|
| 2507 | return $arrChildren; |
|---|
| 2508 | } |
|---|
| 2509 | |
|---|
| 2510 | /* ¿ÆIDľ²¼¤Î»ÒID¤ò¤¹¤Ù¤Æ¼èÆÀ¤¹¤ë */ |
|---|
| 2511 | function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) { |
|---|
| 2512 | $arrChildren = array(); |
|---|
| 2513 | $max = count($arrData); |
|---|
| 2514 | |
|---|
| 2515 | for($i = 0; $i < $max; $i++) { |
|---|
| 2516 | foreach($arrPID as $val) { |
|---|
| 2517 | if($arrData[$i][$pid_name] == $val) { |
|---|
| 2518 | $arrChildren[] = $arrData[$i][$id_name]; |
|---|
| 2519 | } |
|---|
| 2520 | } |
|---|
| 2521 | } |
|---|
| 2522 | return $arrChildren; |
|---|
| 2523 | } |
|---|
| 2524 | |
|---|
| 2525 | |
|---|
| 2526 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤é¿ÆIDÇÛÎó¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 2527 | function sfGetParentsArray($table, $pid_name, $id_name, $id) { |
|---|
| 2528 | $objQuery = new SC_Query(); |
|---|
| 2529 | $col = $pid_name . "," . $id_name; |
|---|
| 2530 | $arrData = $objQuery->select($col, $table); |
|---|
| 2531 | |
|---|
| 2532 | $arrParents = array(); |
|---|
| 2533 | $arrParents[] = $id; |
|---|
| 2534 | $child = $id; |
|---|
| 2535 | |
|---|
| 2536 | $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $child); |
|---|
| 2537 | |
|---|
| 2538 | while($ret != "") { |
|---|
| 2539 | $arrParents[] = $ret; |
|---|
| 2540 | $ret = sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret); |
|---|
| 2541 | } |
|---|
| 2542 | |
|---|
| 2543 | $arrParents = array_reverse($arrParents); |
|---|
| 2544 | |
|---|
| 2545 | return $arrParents; |
|---|
| 2546 | } |
|---|
| 2547 | |
|---|
| 2548 | /* »ÒID½ê°¤¹¤ë¿ÆID¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 2549 | function sfGetParentsArraySub($arrData, $pid_name, $id_name, $child) { |
|---|
| 2550 | $max = count($arrData); |
|---|
| 2551 | $parent = ""; |
|---|
| 2552 | for($i = 0; $i < $max; $i++) { |
|---|
| 2553 | if($arrData[$i][$id_name] == $child) { |
|---|
| 2554 | $parent = $arrData[$i][$pid_name]; |
|---|
| 2555 | break; |
|---|
| 2556 | } |
|---|
| 2557 | } |
|---|
| 2558 | return $parent; |
|---|
| 2559 | } |
|---|
| 2560 | |
|---|
| 2561 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤éÍ¿¤¨¤é¤ì¤¿ID¤Î·»Äï¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 2562 | function sfGetBrothersArray($arrData, $pid_name, $id_name, $arrPID) { |
|---|
| 2563 | $max = count($arrData); |
|---|
| 2564 | |
|---|
| 2565 | $arrBrothers = array(); |
|---|
| 2566 | foreach($arrPID as $id) { |
|---|
| 2567 | // ¿ÆID¤ò¸¡º÷¤¹¤ë |
|---|
| 2568 | for($i = 0; $i < $max; $i++) { |
|---|
| 2569 | if($arrData[$i][$id_name] == $id) { |
|---|
| 2570 | $parent = $arrData[$i][$pid_name]; |
|---|
| 2571 | break; |
|---|
| 2572 | } |
|---|
| 2573 | } |
|---|
| 2574 | // ·»ÄïID¤ò¸¡º÷¤¹¤ë |
|---|
| 2575 | for($i = 0; $i < $max; $i++) { |
|---|
| 2576 | if($arrData[$i][$pid_name] == $parent) { |
|---|
| 2577 | $arrBrothers[] = $arrData[$i][$id_name]; |
|---|
| 2578 | } |
|---|
| 2579 | } |
|---|
| 2580 | } |
|---|
| 2581 | return $arrBrothers; |
|---|
| 2582 | } |
|---|
| 2583 | |
|---|
| 2584 | /* ³¬Áع½Â¤¤Î¥Æ¡¼¥Ö¥ë¤«¤éÍ¿¤¨¤é¤ì¤¿ID¤Îľ°¤Î»Ò¤ò¼èÆÀ¤¹¤ë */ |
|---|
| 2585 | function sfGetUnderChildrenArray($arrData, $pid_name, $id_name, $parent) { |
|---|
| 2586 | $max = count($arrData); |
|---|
| 2587 | |
|---|
| 2588 | $arrChildren = array(); |
|---|
| 2589 | // »ÒID¤ò¸¡º÷¤¹¤ë |
|---|
| 2590 | for($i = 0; $i < $max; $i++) { |
|---|
| 2591 | if($arrData[$i][$pid_name] == $parent) { |
|---|
| 2592 | $arrChildren[] = $arrData[$i][$id_name]; |
|---|
| 2593 | } |
|---|
| 2594 | } |
|---|
| 2595 | return $arrChildren; |
|---|
| 2596 | } |
|---|
| 2597 | |
|---|
| 2598 | |
|---|
| 2599 | // ¥«¥Æ¥´¥ê¥Ä¥ê¡¼¤Î¼èÆÀ |
|---|
| 2600 | function sfGetCatTree($parent_category_id, $count_check = false) { |
|---|
| 2601 | $objQuery = new SC_Query(); |
|---|
| 2602 | $col = ""; |
|---|
| 2603 | $col .= " cat.category_id,"; |
|---|
| 2604 | $col .= " cat.category_name,"; |
|---|
| 2605 | $col .= " cat.parent_category_id,"; |
|---|
| 2606 | $col .= " cat.level,"; |
|---|
| 2607 | $col .= " cat.rank,"; |
|---|
| 2608 | $col .= " cat.creator_id,"; |
|---|
| 2609 | $col .= " cat.create_date,"; |
|---|
| 2610 | $col .= " cat.update_date,"; |
|---|
| 2611 | $col .= " cat.del_flg, "; |
|---|
| 2612 | $col .= " ttl.product_count"; |
|---|
| 2613 | $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; |
|---|
| 2614 | // ÅÐÏ¿¾¦ÉÊ¿ô¤Î¥Á¥§¥Ã¥¯ |
|---|
| 2615 | if($count_check) { |
|---|
| 2616 | $where = "del_flg = 0 AND product_count > 0"; |
|---|
| 2617 | } else { |
|---|
| 2618 | $where = "del_flg = 0"; |
|---|
| 2619 | } |
|---|
| 2620 | $objQuery->setoption("ORDER BY rank DESC"); |
|---|
| 2621 | $arrRet = $objQuery->select($col, $from, $where); |
|---|
| 2622 | |
|---|
| 2623 | $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); |
|---|
| 2624 | |
|---|
| 2625 | foreach($arrRet as $key => $array) { |
|---|
| 2626 | foreach($arrParentID as $val) { |
|---|
| 2627 | if($array['category_id'] == $val) { |
|---|
| 2628 | $arrRet[$key]['display'] = 1; |
|---|
| 2629 | break; |
|---|
| 2630 | } |
|---|
| 2631 | } |
|---|
| 2632 | } |
|---|
| 2633 | |
|---|
| 2634 | return $arrRet; |
|---|
| 2635 | } |
|---|
| 2636 | |
|---|
| 2637 | // ¿Æ¥«¥Æ¥´¥ê¡¼¤òÏ¢·ë¤·¤¿Ê¸»úÎó¤ò¼èÆÀ¤¹¤ë |
|---|
| 2638 | function sfGetCatCombName($category_id){ |
|---|
| 2639 | // ¾¦Éʤ¬Â°¤¹¤ë¥«¥Æ¥´¥êID¤ò½Ä¤Ë¼èÆÀ |
|---|
| 2640 | $objQuery = new SC_Query(); |
|---|
| 2641 | $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
|---|
| 2642 | $ConbName = ""; |
|---|
| 2643 | |
|---|
| 2644 | // ¥«¥Æ¥´¥ê¡¼Ì¾¾Î¤ò¼èÆÀ¤¹¤ë |
|---|
| 2645 | foreach($arrCatID as $key => $val){ |
|---|
| 2646 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
|---|
| 2647 | $arrVal = array($val); |
|---|
| 2648 | $CatName = $objQuery->getOne($sql,$arrVal); |
|---|
| 2649 | $ConbName .= $CatName . ' | '; |
|---|
| 2650 | } |
|---|
| 2651 | // ºÇ¸å¤Î ¡Ã ¤ò¥«¥Ã¥È¤¹¤ë |
|---|
| 2652 | $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); |
|---|
| 2653 | |
|---|
| 2654 | return $ConbName; |
|---|
| 2655 | } |
|---|
| 2656 | |
|---|
| 2657 | // »ØÄꤷ¤¿¥«¥Æ¥´¥ê¡¼ID¤ÎÂ祫¥Æ¥´¥ê¡¼¤ò¼èÆÀ¤¹¤ë |
|---|
| 2658 | function sfGetFirstCat($category_id){ |
|---|
| 2659 | // ¾¦Éʤ¬Â°¤¹¤ë¥«¥Æ¥´¥êID¤ò½Ä¤Ë¼èÆÀ |
|---|
| 2660 | $objQuery = new SC_Query(); |
|---|
| 2661 | $arrRet = array(); |
|---|
| 2662 | $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
|---|
| 2663 | $arrRet['id'] = $arrCatID[0]; |
|---|
| 2664 | |
|---|
| 2665 | // ¥«¥Æ¥´¥ê¡¼Ì¾¾Î¤ò¼èÆÀ¤¹¤ë |
|---|
| 2666 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
|---|
| 2667 | $arrVal = array($arrRet['id']); |
|---|
| 2668 | $arrRet['name'] = $objQuery->getOne($sql,$arrVal); |
|---|
| 2669 | |
|---|
| 2670 | return $arrRet; |
|---|
| 2671 | } |
|---|
| 2672 | |
|---|
| 2673 | //MySQLÍѤÎSQLʸ¤ËÊѹ¹¤¹¤ë |
|---|
| 2674 | function sfChangeMySQL($sql){ |
|---|
| 2675 | // ²þ¹Ô¡¢¥¿¥Ö¤ò1¥¹¥Ú¡¼¥¹¤ËÊÑ´¹ |
|---|
| 2676 | $sql = preg_replace("/[\r\n\t]/"," ",$sql); |
|---|
| 2677 | |
|---|
| 2678 | $sql = sfChangeView($sql); // viewɽ¤ò¥¤¥ó¥é¥¤¥ó¥Ó¥å¡¼¤ËÊÑ´¹¤¹¤ë |
|---|
| 2679 | $sql = sfChangeILIKE($sql); // ILIKE¸¡º÷¤òLIKE¸¡º÷¤ËÊÑ´¹¤¹¤ë |
|---|
| 2680 | $sql = sfChangeRANDOM($sql); // RANDOM()¤òRAND()¤ËÊÑ´¹¤¹¤ë |
|---|
| 2681 | |
|---|
| 2682 | return $sql; |
|---|
| 2683 | } |
|---|
| 2684 | |
|---|
| 2685 | // SQL¤ÎÃæ¤Ëview¤¬Â¸ºß¤·¤Æ¤¤¤ë¤«¥Á¥§¥Ã¥¯¤ò¹Ô¤¦¡£ |
|---|
| 2686 | function sfInArray($sql){ |
|---|
| 2687 | global $arrView; |
|---|
| 2688 | |
|---|
| 2689 | foreach($arrView as $key => $val){ |
|---|
| 2690 | if (strcasecmp($sql, $val) == 0){ |
|---|
| 2691 | $changesql = eregi_replace("($key)", "$val", $sql); |
|---|
| 2692 | sfInArray($changesql); |
|---|
| 2693 | } |
|---|
| 2694 | } |
|---|
| 2695 | return false; |
|---|
| 2696 | } |
|---|
| 2697 | |
|---|
| 2698 | // SQL¥·¥ó¥°¥ë¥¯¥©¡¼¥ÈÂбþ |
|---|
| 2699 | function sfQuoteSmart($in){ |
|---|
| 2700 | |
|---|
| 2701 | if (is_int($in) || is_double($in)) { |
|---|
| 2702 | return $in; |
|---|
| 2703 | } elseif (is_bool($in)) { |
|---|
| 2704 | return $in ? 1 : 0; |
|---|
| 2705 | } elseif (is_null($in)) { |
|---|
| 2706 | return 'NULL'; |
|---|
| 2707 | } else { |
|---|
| 2708 | return "'" . str_replace("'", "''", $in) . "'"; |
|---|
| 2709 | } |
|---|
| 2710 | } |
|---|
| 2711 | |
|---|
| 2712 | // viewɽ¤ò¥¤¥ó¥é¥¤¥ó¥Ó¥å¡¼¤ËÊÑ´¹¤¹¤ë |
|---|
| 2713 | function sfChangeView($sql){ |
|---|
| 2714 | global $arrView; |
|---|
| 2715 | global $arrViewWhere; |
|---|
| 2716 | |
|---|
| 2717 | $arrViewTmp = $arrView; |
|---|
| 2718 | |
|---|
| 2719 | // view¤Îwhere¤òÊÑ´¹ |
|---|
| 2720 | foreach($arrViewTmp as $key => $val){ |
|---|
| 2721 | $arrViewTmp[$key] = strtr($arrViewTmp[$key], $arrViewWhere); |
|---|
| 2722 | } |
|---|
| 2723 | |
|---|
| 2724 | // view¤òÊÑ´¹ |
|---|
| 2725 | $changesql = strtr($sql, $arrViewTmp); |
|---|
| 2726 | |
|---|
| 2727 | return $changesql; |
|---|
| 2728 | } |
|---|
| 2729 | |
|---|
| 2730 | // ILIKE¸¡º÷¤òLIKE¸¡º÷¤ËÊÑ´¹¤¹¤ë |
|---|
| 2731 | function sfChangeILIKE($sql){ |
|---|
| 2732 | $changesql = eregi_replace("(ILIKE )", "LIKE BINARY ", $sql); |
|---|
| 2733 | return $changesql; |
|---|
| 2734 | } |
|---|
| 2735 | |
|---|
| 2736 | // RANDOM()¤òRAND()¤ËÊÑ´¹¤¹¤ë |
|---|
| 2737 | function sfChangeRANDOM($sql){ |
|---|
| 2738 | $changesql = eregi_replace("( RANDOM)", " RAND", $sql); |
|---|
| 2739 | return $changesql; |
|---|
| 2740 | } |
|---|
| 2741 | |
|---|
| 2742 | // view¤Îwhere¤òÃÖ´¹¤¹¤ë |
|---|
| 2743 | function sfViewWhere($target, $where = "", $arrval = array(), $option = ""){ |
|---|
| 2744 | global $arrViewWhere; |
|---|
| 2745 | $arrWhere = split("[?]", $where); |
|---|
| 2746 | $where_tmp = " WHERE " . $arrWhere[0]; |
|---|
| 2747 | for($i = 1; $i < count($arrWhere); $i++){ |
|---|
| 2748 | $where_tmp .= sfQuoteSmart($arrval[$i - 1]) . $arrWhere[$i]; |
|---|
| 2749 | } |
|---|
| 2750 | $arrViewWhere[$target] = $where_tmp . " " . $option; |
|---|
| 2751 | } |
|---|
| 2752 | |
|---|
| 2753 | // ¥Ç¥£¥ì¥¯¥È¥ê°Ê²¼¤Î¥Õ¥¡¥¤¥ë¤òºÆµ¢Åª¤Ë¥³¥Ô¡¼ |
|---|
| 2754 | function sfCopyDir($src, $des, $mess, $override = false){ |
|---|
| 2755 | if(!is_dir($src)){ |
|---|
| 2756 | return false; |
|---|
| 2757 | } |
|---|
| 2758 | |
|---|
| 2759 | $oldmask = umask(0); |
|---|
| 2760 | $mod= stat($src); |
|---|
| 2761 | |
|---|
| 2762 | // ¥Ç¥£¥ì¥¯¥È¥ê¤¬¤Ê¤±¤ì¤ÐºîÀ®¤¹¤ë |
|---|
| 2763 | if(!file_exists($des)) { |
|---|
| 2764 | if(!mkdir($des, $mod[2])) { |
|---|
| 2765 | print("path:" . $des); |
|---|
| 2766 | } |
|---|
| 2767 | } |
|---|
| 2768 | |
|---|
| 2769 | $fileArray=glob( $src."*" ); |
|---|
| 2770 | foreach( $fileArray as $key => $data_ ){ |
|---|
| 2771 | // CVS´ÉÍý¥Õ¥¡¥¤¥ë¤Ï¥³¥Ô¡¼¤·¤Ê¤¤ |
|---|
| 2772 | if(ereg("/CVS/Entries", $data_)) { |
|---|
| 2773 | break; |
|---|
| 2774 | } |
|---|
| 2775 | if(ereg("/CVS/Repository", $data_)) { |
|---|
| 2776 | break; |
|---|
| 2777 | } |
|---|
| 2778 | if(ereg("/CVS/Root", $data_)) { |
|---|
| 2779 | break; |
|---|
| 2780 | } |
|---|
| 2781 | |
|---|
| 2782 | mb_ereg("^(.*[\/])(.*)",$data_, $matches); |
|---|
| 2783 | $data=$matches[2]; |
|---|
| 2784 | if( is_dir( $data_ ) ){ |
|---|
| 2785 | $mess = sfCopyDir( $data_.'/', $des.$data.'/', $mess); |
|---|
| 2786 | }else{ |
|---|
| 2787 | if(!$override && file_exists($des.$data)) { |
|---|
| 2788 | $mess.= $des.$data . "¡§¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤¹\n"; |
|---|
| 2789 | } else { |
|---|
| 2790 | if(@copy( $data_, $des.$data)) { |
|---|
| 2791 | $mess.= $des.$data . "¡§¥³¥Ô¡¼À®¸ù\n"; |
|---|
| 2792 | } else { |
|---|
| 2793 | $mess.= $des.$data . "¡§¥³¥Ô¡¼¼ºÇÔ\n"; |
|---|
| 2794 | } |
|---|
| 2795 | } |
|---|
| 2796 | $mod=stat($data_ ); |
|---|
| 2797 | } |
|---|
| 2798 | } |
|---|
| 2799 | umask($oldmask); |
|---|
| 2800 | return $mess; |
|---|
| 2801 | } |
|---|
| 2802 | |
|---|
| 2803 | // »ØÄꤷ¤¿¥Õ¥©¥ë¥ÀÆâ¤Î¥Õ¥¡¥¤¥ë¤òÁ´¤Æºï½ü¤¹¤ë |
|---|
| 2804 | function sfDelFile($dir){ |
|---|
| 2805 | $dh = opendir($dir); |
|---|
| 2806 | // ¥Õ¥©¥ë¥ÀÆâ¤Î¥Õ¥¡¥¤¥ë¤òºï½ü |
|---|
| 2807 | while($file = readdir($dh)){ |
|---|
| 2808 | if ($file == "." or $file == "..") continue; |
|---|
| 2809 | $del_file = $dir . "/" . $file; |
|---|
| 2810 | if(is_file($del_file)){ |
|---|
| 2811 | $ret = unlink($dir . "/" . $file); |
|---|
| 2812 | }else if (is_dir($del_file)){ |
|---|
| 2813 | $ret = sfDelFile($del_file); |
|---|
| 2814 | } |
|---|
| 2815 | |
|---|
| 2816 | if(!$ret){ |
|---|
| 2817 | return $ret; |
|---|
| 2818 | } |
|---|
| 2819 | } |
|---|
| 2820 | |
|---|
| 2821 | // ÊĤ¸¤ë |
|---|
| 2822 | closedir($dh); |
|---|
| 2823 | |
|---|
| 2824 | // ¥Õ¥©¥ë¥À¤òºï½ü |
|---|
| 2825 | return rmdir($dir); |
|---|
| 2826 | |
|---|
| 2827 | } |
|---|
| 2828 | |
|---|
| 2829 | /* |
|---|
| 2830 | * ´Ø¿ô̾¡§sfWriteFile |
|---|
| 2831 | * °ú¿ô1 ¡§½ñ¤¹þ¤à¥Ç¡¼¥¿ |
|---|
| 2832 | * °ú¿ô2 ¡§¥Õ¥¡¥¤¥ë¥Ñ¥¹ |
|---|
| 2833 | * °ú¿ô3 ¡§½ñ¤¹þ¤ß¥¿¥¤¥× |
|---|
| 2834 | * °ú¿ô4 ¡§¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó |
|---|
| 2835 | * Ìá¤êÃÍ¡§·ë²Ì¥Õ¥é¥° À®¸ù¤Ê¤é true ¼ºÇԤʤé false |
|---|
| 2836 | * ÀâÌÀ¡¡¡§¥Õ¥¡¥¤¥ë½ñ¤½Ð¤· |
|---|
| 2837 | */ |
|---|
| 2838 | function sfWriteFile($str, $path, $type, $permission = "") { |
|---|
| 2839 | //¥Õ¥¡¥¤¥ë¤ò³«¤¯ |
|---|
| 2840 | if (!($file = fopen ($path, $type))) { |
|---|
| 2841 | return false; |
|---|
| 2842 | } |
|---|
| 2843 | |
|---|
| 2844 | //¥Õ¥¡¥¤¥ë¥í¥Ã¥¯ |
|---|
| 2845 | flock ($file, LOCK_EX); |
|---|
| 2846 | //¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß |
|---|
| 2847 | fputs ($file, $str); |
|---|
| 2848 | //¥Õ¥¡¥¤¥ë¥í¥Ã¥¯¤Î²ò½ü |
|---|
| 2849 | flock ($file, LOCK_UN); |
|---|
| 2850 | //¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë |
|---|
| 2851 | fclose ($file); |
|---|
| 2852 | // ¸¢¸Â¤ò»ØÄê |
|---|
| 2853 | if($permission != "") { |
|---|
| 2854 | chmod($path, $permission); |
|---|
| 2855 | } |
|---|
| 2856 | |
|---|
| 2857 | return true; |
|---|
| 2858 | } |
|---|
| 2859 | |
|---|
| 2860 | function sfFlush($output = " ", $sleep = 0){ |
|---|
| 2861 | // ¼Â¹Ô»þ´Ö¤òÀ©¸Â¤·¤Ê¤¤ |
|---|
| 2862 | set_time_limit(0); |
|---|
| 2863 | // ½ÐÎϤò¥Ð¥Ã¥Õ¥¡¥ê¥ó¥°¤·¤Ê¤¤(==ÆüËܸ켫ưÊÑ´¹¤â¤·¤Ê¤¤) |
|---|
| 2864 | ob_end_clean(); |
|---|
| 2865 | |
|---|
| 2866 | // IE¤Î¤¿¤á¤Ë256¥Ð¥¤¥È¶õʸ»ú½ÐÎÏ |
|---|
| 2867 | echo str_pad('',256); |
|---|
| 2868 | |
|---|
| 2869 | // ½ÐÎϤϥ֥é¥ó¥¯¤À¤±¤Ç¤â¤¤¤¤¤È»×¤¦ |
|---|
| 2870 | echo $output; |
|---|
| 2871 | // ½ÐÎϤò¥Õ¥é¥Ã¥·¥å¤¹¤ë |
|---|
| 2872 | flush(); |
|---|
| 2873 | |
|---|
| 2874 | ob_end_flush(); |
|---|
| 2875 | ob_start(); |
|---|
| 2876 | |
|---|
| 2877 | // »þ´Ö¤Î¤«¤«¤ë½èÍý |
|---|
| 2878 | sleep($sleep); |
|---|
| 2879 | } |
|---|
| 2880 | |
|---|
| 2881 | // @version¤ÎµºÜ¤¬¤¢¤ë¥Õ¥¡¥¤¥ë¤«¤é¥Ð¡¼¥¸¥ç¥ó¤ò¼èÆÀ¤¹¤ë¡£ |
|---|
| 2882 | function sfGetFileVersion($path) { |
|---|
| 2883 | if(file_exists($path)) { |
|---|
| 2884 | $src_fp = fopen($path, "rb"); |
|---|
| 2885 | if($src_fp) { |
|---|
| 2886 | while (!feof($src_fp)) { |
|---|
| 2887 | $line = fgets($src_fp); |
|---|
| 2888 | if(ereg("@version", $line)) { |
|---|
| 2889 | $arrLine = split(" ", $line); |
|---|
| 2890 | $version = $arrLine[5]; |
|---|
| 2891 | } |
|---|
| 2892 | } |
|---|
| 2893 | fclose($src_fp); |
|---|
| 2894 | } |
|---|
| 2895 | } |
|---|
| 2896 | return $version; |
|---|
| 2897 | } |
|---|
| 2898 | |
|---|
| 2899 | // »ØÄꤷ¤¿URL¤ËÂФ·¤ÆPOST¤Ç¥Ç¡¼¥¿¤òÁ÷¿®¤¹¤ë |
|---|
| 2900 | function sfSendPostData($url, $arrData, $arrOkCode = array()){ |
|---|
| 2901 | require_once(DATA_PATH . "module/Request.php"); |
|---|
| 2902 | |
|---|
| 2903 | // Á÷¿®¥¤¥ó¥¹¥¿¥ó¥¹À¸À® |
|---|
| 2904 | $req = new HTTP_Request($url); |
|---|
| 2905 | |
|---|
| 2906 | $req->addHeader('User-Agent', 'DoCoMo/2.0¡¡P2101V(c100)'); |
|---|
| 2907 | $req->setMethod(HTTP_REQUEST_METHOD_POST); |
|---|
| 2908 | |
|---|
| 2909 | // POST¥Ç¡¼¥¿Á÷¿® |
|---|
| 2910 | $req->addPostDataArray($arrData); |
|---|
| 2911 | |
|---|
| 2912 | // ¥¨¥é¡¼¤¬Ìµ¤±¤ì¤Ð¡¢±þÅú¾ðÊó¤ò¼èÆÀ¤¹¤ë |
|---|
| 2913 | if (!PEAR::isError($req->sendRequest())) { |
|---|
| 2914 | |
|---|
| 2915 | // ¥ì¥¹¥Ý¥ó¥¹¥³¡¼¥É¤¬¥¨¥é¡¼È½Äê¤Ê¤é¡¢¶õ¤òÊÖ¤¹ |
|---|
| 2916 | $res_code = $req->getResponseCode(); |
|---|
| 2917 | |
|---|
| 2918 | if(!in_array($res_code, $arrOkCode)){ |
|---|
| 2919 | $response = ""; |
|---|
| 2920 | }else{ |
|---|
| 2921 | $response = $req->getResponseBody(); |
|---|
| 2922 | } |
|---|
| 2923 | |
|---|
| 2924 | } else { |
|---|
| 2925 | $response = ""; |
|---|
| 2926 | } |
|---|
| 2927 | |
|---|
| 2928 | // POST¥Ç¡¼¥¿¥¯¥ê¥¢ |
|---|
| 2929 | $req->clearPostData(); |
|---|
| 2930 | |
|---|
| 2931 | return $response; |
|---|
| 2932 | } |
|---|
| 2933 | |
|---|
| 2934 | /** ¥Ç¥Ð¥Ã¥°ÍÑ´Ø¿ô **/ |
|---|
| 2935 | |
|---|
| 2936 | /** |
|---|
| 2937 | * ÅϤµ¤ì¤¿ÊÑ¿ô¤òDump¤¹¤ë |
|---|
| 2938 | * |
|---|
| 2939 | * @param mixed $obj Dump¤·¤¿¤¤ÊÑ¿ô |
|---|
| 2940 | * @param string $color ½ÐÎϤ¹¤ë¿§ |
|---|
| 2941 | * |
|---|
| 2942 | * @return void ¤Ê¤· |
|---|
| 2943 | */ |
|---|
| 2944 | function sfPrintR($obj, $color='green') { |
|---|
| 2945 | if ( DEBUG_MODE === false ) { |
|---|
| 2946 | return; |
|---|
| 2947 | } |
|---|
| 2948 | |
|---|
| 2949 | $arrColor = array( |
|---|
| 2950 | 'green' => '#00FF00', |
|---|
| 2951 | 'red' => '#FF0000', |
|---|
| 2952 | 'blue' => '#0000FF' |
|---|
| 2953 | ); |
|---|
| 2954 | |
|---|
| 2955 | if ( empty($arrColor[$color]) ) { |
|---|
| 2956 | $color = $arrColor['green']; |
|---|
| 2957 | } else { |
|---|
| 2958 | $color = $arrColor[$color]; |
|---|
| 2959 | } |
|---|
| 2960 | |
|---|
| 2961 | print("<div style='font-size: 12px;color: $color;'>\n"); |
|---|
| 2962 | print("<strong>**¥Ç¥Ð¥Ã¥°Ãæ**</strong><br />\n"); |
|---|
| 2963 | print("<pre>\n"); |
|---|
| 2964 | print_r($obj); |
|---|
| 2965 | print("</pre>\n"); |
|---|
| 2966 | print("<strong>**¥Ç¥Ð¥Ã¥°Ãæ**</strong></div>\n"); |
|---|
| 2967 | } |
|---|
| 2968 | |
|---|
| 2969 | ?> |
|---|