Changeset 14676 for branches/beta/data/class
- Timestamp:
- 2007/06/14 22:01:13 (19 years ago)
- Location:
- branches/beta/data/class
- Files:
-
- 7 edited
-
SC_CartSession.php (modified) (4 diffs)
-
SC_CustomerList.php (modified) (2 diffs)
-
SC_DbConn.php (modified) (2 diffs)
-
SC_Query.php (modified) (8 diffs)
-
SC_SelectSql.php (modified) (2 diffs)
-
SC_UploadFile.php (modified) (1 diff)
-
SC_View.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/beta/data/class/SC_CartSession.php
r11907 r14676 173 173 174 174 // ¥«¡¼¥È¤Ø¤Î¾¦ÉÊÄɲà 175 function addProduct($id, $quantity ) {175 function addProduct($id, $quantity, $campaign_id = "") { 176 176 $find = false; 177 177 $max = $this->getMax(); … … 182 182 if(strlen($val) <= INT_LEN) { 183 183 $_SESSION[$this->key][$i]['quantity']+= $quantity; 184 if(!empty($campaign_id)){ 185 $_SESSION[$this->key][$i]['campaign_id'] = $campaign_id; 186 $_SESSION[$this->key][$i]['is_campaign'] = true; 187 } 184 188 } 185 189 $find = true; … … 190 194 $_SESSION[$this->key][$max+1]['quantity'] = $quantity; 191 195 $_SESSION[$this->key][$max+1]['cart_no'] = $this->getNextCartID(); 196 if(!empty($campaign_id)){ 197 $_SESSION[$this->key][$max+1]['campaign_id'] = $campaign_id; 198 $_SESSION[$this->key][$max+1]['is_campaign'] = true; 199 } 192 200 } 193 201 } … … 322 330 } 323 331 } 324 332 333 /** 334 * ¥«¡¼¥È¤ÎÃæ¤Î¥¥ã¥ó¥Ú¡¼¥ó¾¦ÉʤΥÁ¥§¥Ã¥¯ 335 * @param integer $campaign_id ¥¥ã¥ó¥Ú¡¼¥óID 336 * @return boolean True:¥¥ã¥ó¥Ú¡¼¥ó¾¦ÉÊͤê False:¥¥ã¥ó¥Ú¡¼¥ó¾¦ÉÊ̵¤· 337 */ 338 function chkCampaign($campaign_id){ 339 $max = $this->getMax(); 340 for($i = 0; $i <= $max; $i++) { 341 if($_SESSION[$this->key][$i]['is_campaign'] and $_SESSION[$this->key][$i]['campaign_id'] == $campaign_id) return true; 342 } 343 344 return false; 345 } 346 347 325 348 } 326 349 ?> -
branches/beta/data/class/SC_CustomerList.php
r11771 r14676 5 5 * http://www.lockon.co.jp/ 6 6 */ 7 7 $INC_PATH = realpath( dirname( __FILE__) ); 8 require( $INC_PATH ."/../conf/conf.php" ); 8 9 /* [̾¾Î] SC_CustomerList 9 10 * [³µÍ×] ²ñ°÷¸¡º÷ÍÑ¥¯¥é¥¹ … … 191 192 $this->setWhere($sql_where); 192 193 } 193 194 //¡¡ÇÛ¿®¥á¡¼¥ë¥¢¥É¥ì¥¹¼ïÊÌ 195 if ( $mode == 'magazine' ){ 196 if ( strlen($this->arrSql['mail_type']) > 0 && $this->arrSql['mail_type'] == 2) { 197 $this->setWhere( " dtb_customer.email_mobile <> '' "); 198 } 199 } 200 201 //¡¡HTML-mail 202 if ( $mode == 'magazine' ){ 194 195 /* 2007/05/28 °ìö¡¢Ää»ß¤·¤Þ¤¹¡£ 196 * //¡¡ÇÛ¿®¥á¡¼¥ë¥¢¥É¥ì¥¹¼ïÊÌ 197 * if ( $mode == 'magazine' ){ 198 * if ( strlen($this->arrSql['mail_type']) > 0 && $this->arrSql['mail_type'] == 2) { 199 * $this->setWhere( " dtb_customer.email_mobile <> '' "); 200 * } 201 * } 202 */ 203 204 if($mode == 'magazine'){ 205 global $arrDomainType; 206 $sql_where = ""; 207 //¥É¥á¥¤¥ó»ØÄê¡££±¤Ï£Ð£Ã¡¢£²¤Ï·ÈÂÓ 208 if ( $this->arrSql['domain'] > 0 ) { 209 foreach($arrDomainType as $val) { 210 if($this->arrSql['domain'] == 1) { 211 if($sql_where == "") { 212 $sql_where .= "dtb_customer.email NOT ILIKE ? "; 213 } else { 214 $sql_where .= "AND dtb_customer.email NOT ILIKE ? " ; 215 } 216 } elseif($this->arrSql['domain'] == 2) { 217 if($sql_where == "") { 218 $sql_where .= "dtb_customer.email ILIKE ? "; 219 } else { 220 $sql_where .= "OR dtb_customer.email LIKE ? " ; 221 } 222 $sql_where = "(".$sql_where.")"; 223 } 224 $searchDomain = $this->addSearchStr($val); 225 $this->arrVal[] = $searchDomain; 226 } 227 $this->setWhere($sql_where); 228 } 229 } 230 231 //¡¡HTML-mail¡ÊÇÛ¿®Êý¼°) 232 if( $mode == 'magazine' ){ 203 233 if ( strlen($this->arrSql['htmlmail']) > 0 ) { 204 234 $this->setWhere( " mailmaga_flg = ? "); -
branches/beta/data/class/SC_DbConn.php
r13370 r14676 112 112 sfErrorHeader("DB¤Ø¤ÎÀܳ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£:" . $this->dsn); 113 113 }else{ 114 sfErrorHeader("DB¤Ø¤ÎÀܳ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£ :");114 sfErrorHeader("DB¤Ø¤ÎÀܳ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"); 115 115 } 116 116 return 0; … … 167 167 } 168 168 169 function send_err_mail( $result, $sql ){ 170 171 if ($this->err_disp && DEBUG_MODE) { 172 if ($_SERVER['HTTPS'] == "on") { 173 $url = "https://"; 174 } else { 175 $url = "http://"; 176 } 177 $url.= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 178 179 $errmsg = $url."\n\n"; 180 $errmsg.= $sql . "\n"; 181 $errmsg.= $result->message . "\n\n"; 182 $errmsg.= $result->userinfo . "\n\n"; 169 function debug_print($result, $sql){ 170 $this->send_err_mail($result, $sql); 171 } 172 173 function send_err_mail($result, $sql){ 174 $url = ''; 175 $errmsg = ''; 176 177 if ($_SERVER['HTTPS'] == "on") { 178 $url = "https://"; 179 } else { 180 $url = "http://"; 181 } 182 $url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 183 184 $errmsg = $url."\n\n"; 185 $errmsg .= $sql . "\n"; 186 $errmsg .= $result->message . "\n\n"; 187 $errmsg .= $result->userinfo . "\n\n"; 188 189 if ($this->err_disp && DEBUG_MODE === true) { 190 print('<pre>'); 183 191 print_r(htmlspecialchars($errmsg, ENT_QUOTES, CHAR_CODE)); 184 185 exit(); 192 print('</pre>'); 186 193 } 194 195 gfDebugLog($errmsg, DB_ERR_LOG_PATH); 196 197 exit(); 187 198 } 188 199 } -
branches/beta/data/class/SC_Query.php
r337 r14676 1 1 <?php 2 /* 2 /** 3 3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. 4 4 * … … 6 6 */ 7 7 8 /** 9 * SC_Query¥¯¥é¥¹ 10 * 11 * @author LOCKON CO.,LTD. 12 * @access public 13 */ 8 14 class SC_Query { 9 var $option; 10 var $where; 11 var $conn; 12 var $groupby; 13 var $order; 14 15 // ¥³¥ó¥¹¥È¥é¥¯¥¿ 16 /* 17 $err_disp:¥¨¥é¡¼É½¼¨¤ò¹Ô¤¦¤« 18 $new¡§¿·µ¬¤ËÀܳ¤ò¹Ô¤¦¤« 19 */ 20 function SC_Query($dsn = "", $err_disp = true, $new = false) { 21 $this->conn = new SC_DBconn($dsn, $err_disp, $new); 22 $this->where = ""; 23 return $this->conn; 24 } 25 26 // ¥¨¥é¡¼È½Äê 27 function isError() { 28 if(PEAR::isError($this->conn->conn)) { 29 return true; 30 } 31 return false; 32 } 33 34 // COUNTʸ¤Î¼Â¹Ô 35 function count($table, $where = "", $arrval = array()) { 36 if(strlen($where) <= 0) { 37 $sqlse = "SELECT COUNT(*) FROM $table"; 38 } else { 39 $sqlse = "SELECT COUNT(*) FROM $table WHERE $where"; 40 } 41 // ¥«¥¦¥ó¥Èʸ¤Î¼Â¹Ô 42 $ret = $this->conn->getOne($sqlse, $arrval); 43 return $ret; 44 } 45 46 function select($col, $table, $where = "", $arrval = array()){ 47 $sqlse = $this->getsql($col, $table, $where); 48 $ret = $this->conn->getAll($sqlse, $arrval); 49 return $ret; 50 } 51 52 function getLastQuery($disp = true) { 53 $sql = $this->conn->conn->last_query; 54 if($disp) { 55 print($sql.";<br />\n"); 56 } 57 return $sql; 58 } 15 /**#@+ 16 * @access private 17 */ 18 19 /** 20 * SC_DBConn¥ª¥Ö¥¸¥§¥¯¥È 21 * @var SC_DBConn 22 */ 23 var $conn; 24 25 /** 26 * LIMIT,OFFSET ¶ç 27 * @var string 28 */ 29 var $option; 30 31 /** 32 * WHERE ¶ç 33 * @var string 34 */ 35 var $where; 36 37 /** 38 * GROUP BY ¶ç 39 * @var string 40 */ 41 var $groupby; 42 43 /** 44 * ORDER BY ¶ç 45 * @var string 46 */ 47 var $order; 48 49 /**#@-*/ 50 51 /** 52 * SC_Query¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿ 53 * 54 * @access public 55 * @param string $dsn DSN¾ðÊó 56 * @param boolean $err_disp ¥¨¥é¡¼É½¼¨¤ò¹Ô¤¦¤«¤É¤¦¤« 57 * @param boolean $new ¿·µ¬¤ËDBÀܳ¤ò¹Ô¤¦¤«¤É¤¦¤« 58 */ 59 function SC_Query($dsn = "", $err_disp = true, $new = false) { 60 $this->conn = new SC_DBconn($dsn, $err_disp, $new); 61 $this->where = ""; 62 $this->option = ""; 63 $this->groupby = ""; 64 return $this->conn; //? 65 } 66 67 /** 68 * DB¥¨¥é¡¼¤ÎȽÄê 69 * 70 * @access public 71 * @return boolean À®¸ù»þ¡§true ¼ºÇÔ»þ¡§false 72 */ 73 function isError() { 74 if(PEAR::isError($this->conn->conn)) { 75 return true; 76 } 77 return false; 78 } 79 80 /** 81 * ¥ª¥×¥·¥ç¥ó¤Î½é´ü²½ 82 * 83 * @access public 84 * @return void 85 */ 86 function clear(){ 87 $arrProperty = array_keys((get_object_vars($this))); 88 foreach ( $arrProperty as $property ) { 89 if ($property != 'conn') { 90 $this->$property = ''; 91 } 92 } 93 } 94 95 /** 96 * COUNTʸ¤Î¼Â¹Ô 97 * 98 * @access public 99 * @param string $table ¥Æ¡¼¥Ö¥ë̾ 100 * @param string $where WHERE¶ç 101 * @param array $arrval ¥×¥ì¡¼¥¹¥Û¥ë¥À¤ÎÇÛÎó 102 * @return string ¥ì¥³¡¼¥É·ï¿ô 103 */ 104 function count($table, $where = "", $arrval = array()) { 105 if(strlen($where) <= 0) { 106 $sqlse = "SELECT COUNT(*) FROM $table"; 107 } else { 108 $sqlse = "SELECT COUNT(*) FROM $table WHERE $where"; 109 } 110 // ¥«¥¦¥ó¥Èʸ¤Î¼Â¹Ô 111 $ret = $this->conn->getOne($sqlse, $arrval); 112 return $ret; 113 } 114 115 /** 116 * SELECTʸ¤Î¼Â¹Ô 117 * 118 * @access public 119 * @param string $col ¥«¥é¥à̾ 120 * @param string $table ¥Æ¡¼¥Ö¥ë̾ 121 * @param string $where WHERE¶ç 122 * @param array $arrval ¥×¥ì¡¼¥¹¥Û¥ë¥À¤ÎÇÛÎó 123 * @return array SELECTʸ¤Î¼Â¹Ô·ë²Ì 124 */ 125 function select($col, $table, $where = "", $arrval = array()){ 126 $sqlse = $this->getsql($col, $table, $where); 127 $ret = $this->conn->getAll($sqlse, $arrval); 128 return $ret; 129 } 130 131 /** 132 * ºÇ¸å¤Ë¼Â¹Ô¤·¤¿SQLʸ¤ò¼èÆÀ¤¹¤ë 133 * 134 * @access public 135 * @param boolean $disp SQLʸ¤òprint¤¹¤ë¤«¤É¤¦¤« 136 * @return string $disp==false¤Î¾ì¹ç¡§ºÇ¸å¤Ë¼Â¹Ô¤·¤¿SQLʸ¡¡$disp==true¤Î¾ì¹ç¡§¤Ê¤· 137 */ 138 function getLastQuery($disp = true) { 139 $sql = $this->conn->conn->last_query; 140 if($disp) { 141 print($sql.";<br />\n"); 142 } 143 return $sql; 144 } 59 145 60 146 function commit() { … … 105 191 } 106 192 107 function getsql($col, $table, $where) { 108 if($where != "") { 109 // °ú¿ô¤Î$where¤òÍ¥À褷¤Æ¼Â¹Ô¤¹¤ë¡£ 110 $sqlse = "SELECT $col FROM $table WHERE $where " . $this->groupby . " " . $this->order . " " . $this->option; 111 } else { 112 if($this->where != "") { 113 $sqlse = "SELECT $col FROM $table WHERE $this->where " . $this->groupby . " " . $this->order . " " . $this->option; 114 } else { 115 $sqlse = "SELECT $col FROM $table " . $this->groupby . " " . $this->order . " " . $this->option; 116 } 117 } 118 return $sqlse; 119 } 120 121 function setoption($str) { 122 $this->option = $str; 123 } 124 125 function setlimitoffset($limit, $offset = 0, $return = false) { 126 if (is_numeric($limit) && is_numeric($offset)){ 127 128 $option.= " LIMIT " . $limit; 129 $option.= " OFFSET " . $offset; 130 131 if($return){ 132 return $option; 133 }else{ 134 $this->option.= $option; 135 } 136 } 137 } 138 139 function setgroupby($str) { 140 $this->groupby = "GROUP BY " . $str; 141 } 142 143 function andwhere($str) { 144 if($this->where != "") { 145 $this->where .= " AND " . $str; 146 } else { 147 $this->where = $str; 148 } 149 } 150 151 function orwhere($str) { 152 if($this->where != "") { 153 $this->where .= " OR " . $str; 154 } else { 155 $this->where = $str; 156 } 157 } 158 159 function setwhere($str) { 160 $this->where = $str; 161 } 162 163 function setorder($str) { 164 $this->order = "ORDER BY " . $str; 165 } 166 167 168 function setlimit($limit){ 169 if ( is_numeric($limit)){ 170 $this->option = " LIMIT " .$limit; 171 } 172 } 173 174 function setoffset($offset) { 175 if ( is_numeric($offset)){ 176 $this->offset = " OFFSET " .$offset; 177 } 178 } 179 180 181 // INSERTʸ¤ÎÀ¸À®¡¦¼Â¹Ô 182 // $table :¥Æ¡¼¥Ö¥ë̾ 183 // $sqlval :Îó̾ => ÃͤγÊǼ¤µ¤ì¤¿¥Ï¥Ã¥·¥åÇÛÎó 193 /** 194 * SELECTʸ¤ò¹½ÃÛ¤¹¤ë 195 * 196 * @access public 197 * @param string $col ¥«¥é¥à̾ 198 * @param string $table ¥Æ¡¼¥Ö¥ë̾ 199 * @param string $where WHERE¶ç 200 * @return string SQLʸ 201 */ 202 function getsql($col, $table, $where="") { 203 if($where != "") { 204 // °ú¿ô¤Î$where¤òÍ¥À褷¤Æ¼Â¹Ô¤¹¤ë¡£ 205 $sqlse = "SELECT $col FROM $table WHERE $where " . $this->groupby . " " . $this->order . " " . $this->option; 206 } else { 207 if($this->where != "") { 208 $sqlse = "SELECT $col FROM $table WHERE $this->where " . $this->groupby . " " . $this->order . " " . $this->option; 209 } else { 210 $sqlse = "SELECT $col FROM $table " . $this->groupby . " " . $this->order . " " . $this->option; 211 } 212 } 213 return $sqlse; 214 } 215 216 /** 217 * WHERE,GROUPBY,ORDERBY°Ê³°¤Î¥ª¥×¥·¥ç¥Ê¥ë¤Ê¶ç¤ò¥»¥Ã¥È¤¹¤ë 218 * 219 * @access public 220 * @param string $str ¥ª¥×¥·¥ç¥ó¤Ë»ÈÍѤ¹¤ëʸ»úÎó 221 */ 222 function setoption($str) { 223 $this->option = $str; 224 } 225 226 /** 227 * LIMIT¶ç¡¢OFFSET¶ç¤ò¥»¥Ã¥È¤¹¤ë 228 * 229 * @access public 230 * @param mixed $limit LIMIT¤Î·ï¿ô 231 * @param mixed $offset OFFSET¤Î·ï¿ô 232 * @param string $return À¸À®¤·¤¿LIMIT,OFFSET¶ç¤òreturn¤¹¤ë¤«¤É¤¦¤« 233 * @return string À¸À®¤·¤¿LIMIT,OFFSET¶ç 234 */ 235 function setlimitoffset($limit, $offset = 0, $return = false) { 236 if (is_numeric($limit) && is_numeric($offset)){ 237 238 $option.= " LIMIT " . $limit; 239 $option.= " OFFSET " . $offset; 240 241 if($return){ 242 return $option; 243 }else{ 244 $this->option.= $option; 245 } 246 } 247 } 248 249 /** 250 * GROUP BY ¶ç¤ò¥»¥Ã¥È¤¹¤ë 251 * 252 * @access public 253 * @param string $str ¥«¥é¥à̾ 254 */ 255 function setgroupby($str) { 256 $this->groupby = "GROUP BY " . $str; 257 } 258 259 /** 260 * WHERE ¶ç¤ò¥»¥Ã¥È¤¹¤ë(AND) 261 * 262 * @access public 263 * @param string $str WHERE ¶ç 264 * @example $objQuery->andWhere('product_id = ?'); 265 */ 266 function andwhere($str) { 267 if($this->where != "") { 268 $this->where .= " AND " . $str; 269 } else { 270 $this->where = $str; 271 } 272 } 273 274 /** 275 * WHERE ¶ç¤ò¥»¥Ã¥È¤¹¤ë(OR) 276 * 277 * @access public 278 * @param string $str WHERE ¶ç 279 * @example $objQuery->orWhere('product_id = ?'); 280 */ 281 function orwhere($str) { 282 if($this->where != "") { 283 $this->where .= " OR " . $str; 284 } else { 285 $this->where = $str; 286 } 287 } 288 289 /** 290 * WHERE ¶ç¤ò¥»¥Ã¥È¤¹¤ë 291 * 292 * @access public 293 * @param string $str WHERE ¶ç 294 * @example $objQuery->setWhere('product_id = ?'); 295 */ 296 function setwhere($str) { 297 $this->where = $str; 298 } 299 300 /** 301 * ORDER BY ¶ç¤ò¥»¥Ã¥È¤¹¤ë 302 * 303 * @access public 304 * @param string $str ¥«¥é¥à̾ 305 * @example $objQuery->setorder("rank DESC"); 306 */ 307 function setorder($str) { 308 $this->order = "ORDER BY " . $str; 309 } 310 311 /** 312 * LIMIT ¶ç¤ò¥»¥Ã¥È¤¹¤ë 313 * 314 * @access public 315 * @param mixed $limit LIMIT¤Î·ï¿ô 316 * @example $objQuery->setlimit(50); 317 */ 318 function setlimit($limit){ 319 if ( is_numeric($limit)){ 320 $this->option = " LIMIT " .$limit; 321 } 322 } 323 324 /** 325 * OFFSET ¶ç¤ò¥»¥Ã¥È¤¹¤ë 326 * 327 * @access public 328 * @param mixed $offset OFFSET¤Î·ï¿ô 329 * @example $objQuery->setOffset(30); 330 */ 331 function setoffset($offset) { 332 if ( is_numeric($offset)){ 333 $this->offset = " OFFSET " .$offset; 334 } 335 } 336 337 /** 338 * INSERTʸ¤ò¼Â¹Ô¤¹¤ë 339 * 340 * @access public 341 * @param string $table ¥Æ¡¼¥Ö¥ë̾ 342 * @param array $sqlval (¥«¥é¥à̾ => ÃÍ)¤ÎÏ¢ÁÛÇÛÎó 343 * 344 * @return mixed $result DB_Error¥ª¥Ö¥¸¥§¥¯¥È(¼ºÇÔ»þ)¤Þ¤¿¤ÏDB_OK(À®¸ù»þ)¤Þ¤¿¤Ïfalse(¥«¥é¥à¤¬¸«¤Ä¤«¤é¤Ê¤¤) 345 */ 184 346 function insert($table, $sqlval) { 185 347 $strcol = ''; … … 218 380 } 219 381 220 // INSERTʸ¤ÎÀ¸À®¡¦¼Â¹Ô 221 // $table :¥Æ¡¼¥Ö¥ë̾ 222 // $sqlval :Îó̾ => ÃͤγÊǼ¤µ¤ì¤¿¥Ï¥Ã¥·¥åÇÛÎó 382 /** 383 * INSERTʸ¤ò¼Â¹Ô¤¹¤ë 384 * 385 * @access public 386 * @param string $table ¥Æ¡¼¥Ö¥ë̾ 387 * @param array $sqlval (¥«¥é¥à̾ => ÃÍ)¤ÎÏ¢ÁÛÇÛÎó 388 * 389 * @return mixed $result DB_Error¥ª¥Ö¥¸¥§¥¯¥È(¼ºÇÔ»þ)¤Þ¤¿¤ÏDB_OK(À®¸ù»þ)¤Þ¤¿¤Ïfalse(¥«¥é¥à¤¬¸«¤Ä¤«¤é¤Ê¤¤) 390 */ 223 391 function fast_insert($table, $sqlval) { 224 392 $strcol = ''; … … 248 416 $ret = $this->conn->query($sqlin); 249 417 250 return $ret; 418 return $ret; 251 419 } 252 420 … … 373 541 } 374 542 543 //»ØÄꤷ¤¿¥«¥é¥à¤Î°ìÈֺǸå¤Ë¥ì¥³¡¼¥É¤òÁÞÆþ 375 544 function nextval($table, $colname) { 376 545 $sql = ""; … … 379 548 $seqtable = $table . "_" . $colname . "_seq"; 380 549 $sql = "SELECT NEXTVAL('$seqtable')"; 550 $ret = $this->conn->getOne($sql); 381 551 }else if (DB_TYPE == "mysql") { 382 $sql = "SELECT last_insert_id();"; 383 } 384 $ret = $this->conn->getOne($sql); 552 $sql = "SELECT last_insert_id();"; 553 $ret = $this->conn->getOne($sql); 554 } 555 385 556 386 557 return $ret; … … 437 608 } 438 609 } 439 440 610 ?> -
branches/beta/data/class/SC_SelectSql.php
r11917 r14676 27 27 } 28 28 29 //-- SQLÊ ¬À¸À®29 //-- SQLʸÀ¸À® 30 30 function getSql( $mode = "" ){ 31 31 $this->sql = $this->select ." ". $this->where ." ". $this->group ." "; … … 196 196 } 197 197 } 198 198 199 199 function setOrder($order){ 200 200 -
branches/beta/data/class/SC_UploadFile.php
r293 r14676 7 7 8 8 $SC_UPLOADFILE_DIR = realpath(dirname( __FILE__)); 9 require_once($SC_UPLOADFILE_DIR . "/../lib/gdthumb.php"); 9 require_once($SC_UPLOADFILE_DIR . "/../lib/gdthumb.php"); 10 require_once($SC_UPLOADFILE_DIR . "/../include/ftp.php"); 10 11 11 12 /* ¥¢¥Ã¥×¥í¡¼¥É¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹ */ 12 13 class SC_UploadFile { 13 var $temp_dir; 14 var $save_dir; 15 var $keyname; // ¥Õ¥¡¥¤¥ëinput¥¿¥°¤Îname 16 var $width; // ²£¥µ¥¤¥º 17 var $height; // ½Ä¥µ¥¤¥º 18 var $arrExt; // »ØÄꤹ¤ë³ÈÄ¥»Ò 19 var $temp_file; // Êݸ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë̾ 20 var $save_file; // DB¤«¤éÆÉ¤ß½Ð¤·¤¿¥Õ¥¡¥¤¥ë̾ 21 var $disp_name; // ¹àÌÜ̾ 22 var $size; // À©¸Â¥µ¥¤¥º 23 var $necessary; // ɬ¿Ü¤Î¾ì¹ç:true 24 var $image; // ²èÁü¤Î¾ì¹ç:true 25 26 // ¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹ 27 function SC_UploadFile($temp_dir, $save_dir) { 28 $this->temp_dir = $temp_dir; 29 $this->save_dir = $save_dir; 30 $this->file_max = 0; 31 } 32 33 // ¥Õ¥¡¥¤¥ë¾ðÊóÄɲà 34 function addFile($disp_name, $keyname, $arrExt, $size, $necessary=false, $width=0, $height=0, $image=true) { 35 $this->disp_name[] = $disp_name; 36 $this->keyname[] = $keyname; 37 $this->width[] = $width; 38 $this->height[] = $height; 39 $this->arrExt[] = $arrExt; 40 $this->size[] = $size; 41 $this->necessary[] = $necessary; 42 $this->image[] = $image; 43 } 44 // ¥µ¥à¥Í¥¤¥ë²èÁü¤ÎºîÀ® 45 function makeThumb($src_file, $width, $height) { 46 // °ì°Õ¤ÊID¤ò¼èÆÀ¤¹¤ë¡£ 47 $uniqname = date("mdHi") . "_" . uniqid(""); 48 49 $dst_file = $this->temp_dir . $uniqname; 50 51 $objThumb = new gdthumb(); 52 $ret = $objThumb->Main($src_file, $width, $height, $dst_file); 53 54 if($ret[0] != 1) { 55 // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Îɽ¼¨ 56 print($ret[1]); 57 exit; 58 } 59 60 return basename($ret[1]); 61 } 62 63 // ¥¢¥Ã¥×¥í¡¼¥É¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤òÊݸ¤¹¤ë¡£ 64 function makeTempFile($keyname, $rename = true) { 65 $objErr = new SC_CheckError(); 66 $cnt = 0; 67 $arrKeyname = array_flip($this->keyname); 68 69 if(!($_FILES[$keyname]['size'] > 0)) { 70 $objErr->arrErr[$keyname] = "¢¨ " . $this->disp_name[$arrKeyname[$keyname]] . "¤¬¥¢¥Ã¥×¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br />"; 71 } else { 72 foreach($this->keyname as $val) { 73 // °ìÃפ·¤¿¥¡¼¤Î¥Õ¥¡¥¤¥ë¤Ë¾ðÊó¤òÊݸ¤¹¤ë¡£ 74 if ($val == $keyname) { 75 // ³ÈÄ¥»Ò¥Á¥§¥Ã¥¯ 76 $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]), array("FILE_EXT_CHECK")); 77 // ¥Õ¥¡¥¤¥ë¥µ¥¤¥º¥Á¥§¥Ã¥¯ 78 $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array("FILE_SIZE_CHECK")); 79 // ¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç 80 if(!isset($objErr->arrErr[$keyname])) { 81 // ²èÁü¥Õ¥¡¥¤¥ë¤Î¾ì¹ç 82 if($this->image[$cnt]) { 83 $this->temp_file[$cnt] = $this->makeThumb($_FILES[$keyname]['tmp_name'], $this->width[$cnt], $this->height[$cnt]); 84 // ²èÁü¥Õ¥¡¥¤¥ë°Ê³°¤Î¾ì¹ç 85 } else { 86 // °ì°Õ¤Ê¥Õ¥¡¥¤¥ë̾¤òºîÀ®¤¹¤ë¡£ 87 if($rename) { 88 $uniqname = date("mdHi") . "_" . uniqid("")."."; 89 $this->temp_file[$cnt] = ereg_replace("^.*\.",$uniqname, $_FILES[$keyname]['name']); 90 } else { 91 $this->temp_file[$cnt] = $_FILES[$keyname]['name']; 92 } 93 $result = copy($_FILES[$keyname]['tmp_name'], $this->temp_dir. "/". $this->temp_file[$cnt]); 94 gfPrintLog($_FILES[$keyname]['name']." -> ".$this->temp_dir. "/". $this->temp_file[$cnt]); 95 } 96 } 97 } 98 $cnt++; 99 } 100 } 101 return $objErr->arrErr[$keyname]; 102 } 103 104 // ²èÁü¤òºï½ü¤¹¤ë¡£ 105 function deleteFile($keyname) { 106 $objImage = new SC_Image($this->temp_dir); 107 $cnt = 0; 108 foreach($this->keyname as $val) { 109 if ($val == $keyname) { 110 // °ì»þ¥Õ¥¡¥¤¥ë¤Î¾ì¹çºï½ü¤¹¤ë¡£ 111 if($this->temp_file[$cnt] != "") { 112 $objImage->deleteImage($this->temp_file[$cnt], $this->save_dir); 113 } 114 $this->temp_file[$cnt] = ""; 115 $this->save_file[$cnt] = ""; 116 } 117 $cnt++; 118 } 119 } 120 121 // °ì»þ¥Õ¥¡¥¤¥ë¥Ñ¥¹¤ò¼èÆÀ¤¹¤ë¡£ 122 function getTempFilePath($keyname) { 123 $cnt = 0; 124 $filepath = ""; 125 foreach($this->keyname as $val) { 126 if ($val == $keyname) { 127 if($this->temp_file[$cnt] != "") { 128 $filepath = $this->temp_dir . "/" . $this->temp_file[$cnt]; 129 } 130 } 131 $cnt++; 132 } 133 return $filepath; 134 } 135 136 // °ì»þ¥Õ¥¡¥¤¥ë¤òÊݸ¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Ü¤¹ 137 function moveTempFile() { 138 $cnt = 0; 139 $objImage = new SC_Image($this->temp_dir); 140 141 foreach($this->keyname as $val) { 142 if($this->temp_file[$cnt] != "") { 143 144 $objImage->moveTempImage($this->temp_file[$cnt], $this->save_dir); 145 // ¤¹¤Ç¤ËÊݸ¥Õ¥¡¥¤¥ë¤¬¤¢¤Ã¤¿¾ì¹ç¤Ïºï½ü¤¹¤ë¡£ 146 if($this->save_file[$cnt] != "" && !ereg("^sub/", $this->save_file[$cnt])) { 147 $objImage->deleteImage($this->save_file[$cnt], $this->save_dir); 148 } 149 } 150 $cnt++; 151 } 152 } 153 154 // HIDDENÍѤΥե¡¥¤¥ë̾ÇÛÎó¤òÊÖ¤¹ 155 function getHiddenFileList() { 156 $cnt = 0; 157 foreach($this->keyname as $val) { 158 if($this->temp_file[$cnt] != "") { 159 $arrRet["temp_" . $val] = $this->temp_file[$cnt]; 160 } 161 if($this->save_file[$cnt] != "") { 162 $arrRet["save_" . $val] = $this->save_file[$cnt]; 163 } 164 $cnt++; 165 } 166 return $arrRet; 167 } 168 169 // HIDDEN¤ÇÁ÷¤é¤ì¤Æ¤¤¿¥Õ¥¡¥¤¥ë̾¤ò¼èÆÀ¤¹¤ë 170 function setHiddenFileList($arrPOST) { 171 $cnt = 0; 172 foreach($this->keyname as $val) { 173 $key = "temp_" . $val; 174 if($arrPOST[$key] != "") { 175 $this->temp_file[$cnt] = $arrPOST[$key]; 176 } 177 $key = "save_" . $val; 178 if($arrPOST[$key] != "") { 179 $this->save_file[$cnt] = $arrPOST[$key]; 180 } 181 $cnt++; 182 } 183 } 184 185 // ¥Õ¥©¡¼¥à¤ËÅϤ¹ÍѤΥե¡¥¤¥ë¾ðÊóÇÛÎó¤òÊÖ¤¹ 186 function getFormFileList($temp_url, $save_url, $real_size = false) { 187 188 $cnt = 0; 189 foreach($this->keyname as $val) { 190 if($this->temp_file[$cnt] != "") { 191 // ¥Õ¥¡¥¤¥ë¥Ñ¥¹¥Á¥§¥Ã¥¯(¥Ñ¥¹¤Î¥¹¥é¥Ã¥·¥å/¤¬Ï¢Â³¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£) 192 if(ereg("/$", $temp_url)) { 193 $arrRet[$val]['filepath'] = $temp_url . $this->temp_file[$cnt]; 194 } else { 195 $arrRet[$val]['filepath'] = $temp_url . "/" . $this->temp_file[$cnt]; 196 } 197 $arrRet[$val]['real_filepath'] = $this->temp_dir . $this->temp_file[$cnt]; 198 } elseif ($this->save_file[$cnt] != "") { 199 // ¥Õ¥¡¥¤¥ë¥Ñ¥¹¥Á¥§¥Ã¥¯(¥Ñ¥¹¤Î¥¹¥é¥Ã¥·¥å/¤¬Ï¢Â³¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£) 200 if(ereg("/$", $save_url)) { 201 $arrRet[$val]['filepath'] = $save_url . $this->save_file[$cnt]; 202 } else { 203 $arrRet[$val]['filepath'] = $save_url . "/" . $this->save_file[$cnt]; 204 } 205 $arrRet[$val]['real_filepath'] = $this->save_dir . $this->save_file[$cnt]; 206 } 207 if($arrRet[$val]['filepath'] != "") { 208 if($real_size){ 209 if(is_file($arrRet[$val]['real_filepath'])) { 210 list($width, $height) = getimagesize($arrRet[$val]['real_filepath']); 211 } 212 // ¥Õ¥¡¥¤¥ë²£Éý 213 $arrRet[$val]['width'] = $width; 214 // ¥Õ¥¡¥¤¥ë½ÄÉý 215 $arrRet[$val]['height'] = $height; 216 }else{ 217 // ¥Õ¥¡¥¤¥ë²£Éý 218 $arrRet[$val]['width'] = $this->width[$cnt]; 219 // ¥Õ¥¡¥¤¥ë½ÄÉý 220 $arrRet[$val]['height'] = $this->height[$cnt]; 221 } 222 // ɽ¼¨Ì¾ 223 $arrRet[$val]['disp_name'] = $this->disp_name[$cnt]; 224 } 225 $cnt++; 226 } 227 return $arrRet; 228 } 229 230 // DBÊݸÍѤΥե¡¥¤¥ë̾ÇÛÎó¤òÊÖ¤¹ 231 function getDBFileList() { 232 $cnt = 0; 233 foreach($this->keyname as $val) { 234 if($this->temp_file[$cnt] != "") { 235 $arrRet[$val] = $this->temp_file[$cnt]; 236 } else { 237 $arrRet[$val] = $this->save_file[$cnt]; 238 } 239 $cnt++; 240 } 241 return $arrRet; 242 } 243 244 // DB¤ÇÊݸ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë̾ÇÛÎó¤ò¥»¥Ã¥È¤¹¤ë 245 function setDBFileList($arrVal) { 246 $cnt = 0; 247 foreach($this->keyname as $val) { 248 if($arrVal[$val] != "") { 249 $this->save_file[$cnt] = $arrVal[$val]; 250 } 251 $cnt++; 252 } 253 } 254 255 // ²èÁü¤ò¥»¥Ã¥È¤¹¤ë 256 function setDBImageList($arrVal) { 257 $cnt = 0; 258 foreach($this->keyname as $val) { 259 if($arrVal[$val] != "" && $val == 'tv_products_image') { 260 $this->save_file[$cnt] = $arrVal[$val]; 261 } 262 $cnt++; 263 } 264 } 265 266 // DB¾å¤Î¥Õ¥¡¥¤¥ë¤ÎÆâºï½üÍ׵᤬¤¢¤Ã¤¿¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë¡£ 267 function deleteDBFile($arrVal) { 268 $objImage = new SC_Image($this->temp_dir); 269 $cnt = 0; 270 foreach($this->keyname as $val) { 271 if($arrVal[$val] != "") { 272 if($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal[$val])) { 273 $objImage->deleteImage($arrVal[$val], $this->save_dir); 274 } 275 } 276 $cnt++; 277 } 278 } 279 280 // ɬ¿ÜȽÄê 281 function checkEXISTS($keyname = "") { 282 $cnt = 0; 283 $arrRet = array(); 284 foreach($this->keyname as $val) { 285 if($val == $keyname || $keyname == "") { 286 // ɬ¿Ü¤Ç¤¢¤ì¤Ð¥¨¥é¡¼¥Á¥§¥Ã¥¯ 287 if ($this->necessary[$cnt] == true) { 288 if($this->save_file[$cnt] == "" && $this->temp_file[$cnt] == "") { 289 $arrRet[$val] = "¢¨ " . $this->disp_name[$cnt] . "¤¬¥¢¥Ã¥×¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br>"; 290 } 291 } 292 } 293 $cnt++; 294 } 295 return $arrRet; 296 } 297 298 // ³ÈÂçΨ¤ò»ØÄꤷ¤Æ²èÁüÊݸ 299 function saveResizeImage($keyname, $to_w, $to_h) { 300 $path = ""; 301 302 // keyname¤ÎźÉÕ¥Õ¥¡¥¤¥ë¤ò¼èÆÀ 303 $arrImageKey = array_flip($this->keyname); 304 $file = $this->temp_file[$arrImageKey[$keyname]]; 305 $filepath = $this->temp_dir . $file; 306 307 $path = $this->makeThumb($filepath, $to_w, $to_h); 308 309 // ¥Õ¥¡¥¤¥ë̾¤À¤±ÊÖ¤¹ 310 return basename($path); 311 } 14 var $temp_dir; // °ì»þ¥Õ¥¡¥¤¥ëÊݸ¥Ç¥£¥ì¥¯¥È¥ê 15 var $save_dir; // ¥Õ¥¡¥¤¥ëÊݸ¥Ç¥£¥ì¥¯¥È 16 var $ftp_temp_dir; // FTPÀè°ì»þ¥Ç¥£¥ì¥¯¥È¥ê(Éé²Ùʬ»¶»þ»ÈÍÑ) 17 var $ftp_save_dir; // FTPÀè¥Õ¥¡¥¤¥ëÊݸ¥Ç¥£¥ì¥¯¥È¥ê(Éé²Ùʬ»¶»þ»ÈÍÑ) 18 var $multi_web_server_mode; // Éé²Ùʬ»¶¥Õ¥é¥°(Éé²Ùʬ»¶»þ»ÈÍÑ) 19 var $keyname; // ¥Õ¥¡¥¤¥ëinput¥¿¥°¤Îname 20 var $width; // ²£¥µ¥¤¥º 21 var $height; // ½Ä¥µ¥¤¥º 22 var $arrExt; // »ØÄꤹ¤ë³ÈÄ¥»Ò 23 var $temp_file; // Êݸ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë̾ 24 var $save_file; // DB¤«¤éÆÉ¤ß½Ð¤·¤¿¥Õ¥¡¥¤¥ë̾ 25 var $disp_name; // ¹àÌÜ̾ 26 var $size; // À©¸Â¥µ¥¤¥º 27 var $necessary; // ɬ¿Ü¤Î¾ì¹ç:true 28 var $image; // ²èÁü¤Î¾ì¹ç:true 29 30 // ¥Õ¥¡¥¤¥ë´ÉÍý¥¯¥é¥¹ 31 function SC_UploadFile($temp_dir, $save_dir, $ftp_temp_dir = "", $ftp_save_dir = "", $multi_web_server_mode = false) { 32 $this->temp_dir = $temp_dir; 33 $this->save_dir = $save_dir; 34 $this->ftp_temp_dir = $ftp_temp_dir; 35 $this->ftp_save_dir = $ftp_save_dir; 36 $this->multi_web_server_mode = $multi_web_server_mode; 37 $this->file_max = 0; 38 } 39 40 // ¥Õ¥¡¥¤¥ë¾ðÊóÄɲà 41 function addFile($disp_name, $keyname, $arrExt, $size, $necessary=false, $width=0, $height=0, $image=true) { 42 $this->disp_name[] = $disp_name; 43 $this->keyname[] = $keyname; 44 $this->width[] = $width; 45 $this->height[] = $height; 46 $this->arrExt[] = $arrExt; 47 $this->size[] = $size; 48 $this->necessary[] = $necessary; 49 $this->image[] = $image; 50 } 51 // ¥µ¥à¥Í¥¤¥ë²èÁü¤ÎºîÀ® 52 function makeThumb($src_file, $width, $height) { 53 // °ì°Õ¤ÊID¤ò¼èÆÀ¤¹¤ë¡£ 54 $uniqname = date("mdHi") . "_" . uniqid(""); 55 56 $objThumb = new gdthumb(); 57 58 // WEB¥µ¡¼¥ÐÉé²Ùʬ»¶´Ä¶¤Î¾ì¹ç 59 if($this->multi_web_server_mode === true) { 60 61 // FTPÍÑ¥Õ¥¡¥¤¥ë°ì»þ³ÊǼÍѥǥ£¥ì¥¯¥È¥êºîÀ® 62 $ftp_temp_dir = $this->makeFtpTempDir($this->temp_dir); 63 $dst_file = $ftp_temp_dir . $uniqname; 64 $ret = $objThumb->Main($src_file, $width, $height, $dst_file); 65 $this->ftpMoveFile($this->ftp_temp_dir . basename($ret[1]), $ret[1], true); 66 } else { 67 $dst_file = $this->temp_dir . $uniqname; 68 $ret = $objThumb->Main($src_file, $width, $height, $dst_file); 69 } 70 71 if($ret[0] != 1) { 72 // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Îɽ¼¨ 73 print($ret[1]); 74 exit; 75 } 76 77 return basename($ret[1]); 78 } 79 80 // ¥¢¥Ã¥×¥í¡¼¥É¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤òÊݸ¤¹¤ë¡£ 81 function makeTempFile($keyname, $rename = true) { 82 $objErr = new SC_CheckError(); 83 $cnt = 0; 84 $arrKeyname = array_flip($this->keyname); 85 86 if(!($_FILES[$keyname]['size'] > 0)) { 87 $objErr->arrErr[$keyname] = "¢¨ " . $this->disp_name[$arrKeyname[$keyname]] . "¤¬¥¢¥Ã¥×¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br />"; 88 } else { 89 foreach($this->keyname as $val) { 90 // °ìÃפ·¤¿¥¡¼¤Î¥Õ¥¡¥¤¥ë¤Ë¾ðÊó¤òÊݸ¤¹¤ë¡£ 91 if ($val == $keyname) { 92 // ³ÈÄ¥»Ò¥Á¥§¥Ã¥¯ 93 $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]), array("FILE_EXT_CHECK")); 94 // ¥Õ¥¡¥¤¥ë¥µ¥¤¥º¥Á¥§¥Ã¥¯ 95 $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array("FILE_SIZE_CHECK")); 96 // ¥¨¥é¡¼¤¬¤Ê¤¤¾ì¹ç 97 if(!isset($objErr->arrErr[$keyname])) { 98 // ²èÁü¥Õ¥¡¥¤¥ë¤Î¾ì¹ç 99 if($this->image[$cnt]) { 100 $this->temp_file[$cnt] = $this->makeThumb($_FILES[$keyname]['tmp_name'], $this->width[$cnt], $this->height[$cnt]); 101 // ²èÁü¥Õ¥¡¥¤¥ë°Ê³°¤Î¾ì¹ç 102 } else { 103 // °ì°Õ¤Ê¥Õ¥¡¥¤¥ë̾¤òºîÀ®¤¹¤ë¡£ 104 if($rename) { 105 $uniqname = date("mdHi") . "_" . uniqid("")."."; 106 $this->temp_file[$cnt] = ereg_replace("^.*\.",$uniqname, $_FILES[$keyname]['name']); 107 } else { 108 $this->temp_file[$cnt] = $_FILES[$keyname]['name']; 109 } 110 $result = copy($_FILES[$keyname]['tmp_name'], $this->temp_dir. "/". $this->temp_file[$cnt]); 111 gfPrintLog($_FILES[$keyname]['name']." -> ".$this->temp_dir. "/". $this->temp_file[$cnt]); 112 } 113 } 114 } 115 $cnt++; 116 } 117 } 118 return $objErr->arrErr[$keyname]; 119 } 120 121 // ²èÁü¤òºï½ü¤¹¤ë¡£ 122 function deleteFile($keyname) { 123 $objImage = new SC_Image($this->temp_dir); 124 $cnt = 0; 125 foreach($this->keyname as $val) { 126 if ($val == $keyname) { 127 // °ì»þ¥Õ¥¡¥¤¥ë¤Î¾ì¹çºï½ü¤¹¤ë¡£ 128 if($this->temp_file[$cnt] != "") { 129 // Éé²Ùʬ»¶»þ¤Ï¤¹¤Ù¤Æ¤Î¥µ¡¼¥Ð¤«¤éºï½ü 130 if($this->multi_web_server_mode === true) { 131 $this->ftpDeleteFile($this->ftp_temp_dir . $this->temp_file[$cnt]); 132 } else { 133 $objImage->deleteImage($this->temp_file[$cnt], $this->save_dir); 134 } 135 } 136 $this->temp_file[$cnt] = ""; 137 $this->save_file[$cnt] = ""; 138 } 139 $cnt++; 140 } 141 } 142 143 // °ì»þ¥Õ¥¡¥¤¥ë¥Ñ¥¹¤ò¼èÆÀ¤¹¤ë¡£ 144 function getTempFilePath($keyname) { 145 $cnt = 0; 146 $filepath = ""; 147 foreach($this->keyname as $val) { 148 if ($val == $keyname) { 149 if($this->temp_file[$cnt] != "") { 150 $filepath = $this->temp_dir . "/" . $this->temp_file[$cnt]; 151 } 152 } 153 $cnt++; 154 } 155 return $filepath; 156 } 157 158 // °ì»þ¥Õ¥¡¥¤¥ë¤òÊݸ¥Ç¥£¥ì¥¯¥È¥ê¤Ë°Ü¤¹ 159 function moveTempFile() { 160 $cnt = 0; 161 $objImage = new SC_Image($this->temp_dir); 162 163 foreach($this->keyname as $val) { 164 if($this->temp_file[$cnt] != "") { 165 // Éé²Ùʬ»¶»þ¤Ï¤¹¤Ù¤Æ¤Î¥µ¡¼¥Ð¤Ç°Üư¤ò¼Â¹Ô 166 if($this->multi_web_server_mode === true) { 167 $dist_path = $this->ftp_save_dir . $this->temp_file[$cnt]; 168 $src_path = $this->temp_dir . $this->temp_file[$cnt]; 169 $this->ftpMoveFile($dist_path, $src_path); 170 } else { 171 $objImage->moveTempImage($this->temp_file[$cnt], $this->save_dir); 172 } 173 174 // ¤¹¤Ç¤ËÊݸ¥Õ¥¡¥¤¥ë¤¬¤¢¤Ã¤¿¾ì¹ç¤Ïºï½ü¤¹¤ë¡£ 175 if($this->save_file[$cnt] != "" && !ereg("^sub/", $this->save_file[$cnt])) { 176 // Éé²Ùʬ»¶»þ¤Ï¤¹¤Ù¤Æ¤Î¥µ¡¼¥Ð¤Ç¥Õ¥¡¥¤¥ëºï½ü 177 if($this->multi_web_server_mode === true) { 178 $this->ftpDeleteFile($this->ftp_save_dir . $this->save_file[$cnt]); 179 } else { 180 $objImage->deleteImage($this->save_file[$cnt], $this->save_dir); 181 } 182 } 183 } 184 $cnt++; 185 } 186 } 187 188 // HIDDENÍѤΥե¡¥¤¥ë̾ÇÛÎó¤òÊÖ¤¹ 189 function getHiddenFileList() { 190 $cnt = 0; 191 foreach($this->keyname as $val) { 192 if($this->temp_file[$cnt] != "") { 193 $arrRet["temp_" . $val] = $this->temp_file[$cnt]; 194 } 195 if($this->save_file[$cnt] != "") { 196 $arrRet["save_" . $val] = $this->save_file[$cnt]; 197 } 198 $cnt++; 199 } 200 return $arrRet; 201 } 202 203 // HIDDEN¤ÇÁ÷¤é¤ì¤Æ¤¤¿¥Õ¥¡¥¤¥ë̾¤ò¼èÆÀ¤¹¤ë 204 function setHiddenFileList($arrPOST) { 205 $cnt = 0; 206 foreach($this->keyname as $val) { 207 $key = "temp_" . $val; 208 if($arrPOST[$key] != "") { 209 $this->temp_file[$cnt] = $arrPOST[$key]; 210 } 211 $key = "save_" . $val; 212 if($arrPOST[$key] != "") { 213 $this->save_file[$cnt] = $arrPOST[$key]; 214 } 215 $cnt++; 216 } 217 } 218 219 // ¥Õ¥©¡¼¥à¤ËÅϤ¹ÍѤΥե¡¥¤¥ë¾ðÊóÇÛÎó¤òÊÖ¤¹ 220 function getFormFileList($temp_url, $save_url, $real_size = false) { 221 222 $cnt = 0; 223 foreach($this->keyname as $val) { 224 if($this->temp_file[$cnt] != "") { 225 // ¥Õ¥¡¥¤¥ë¥Ñ¥¹¥Á¥§¥Ã¥¯(¥Ñ¥¹¤Î¥¹¥é¥Ã¥·¥å/¤¬Ï¢Â³¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£) 226 if(ereg("/$", $temp_url)) { 227 $arrRet[$val]['filepath'] = $temp_url . $this->temp_file[$cnt]; 228 } else { 229 $arrRet[$val]['filepath'] = $temp_url . "/" . $this->temp_file[$cnt]; 230 } 231 $arrRet[$val]['real_filepath'] = $this->temp_dir . $this->temp_file[$cnt]; 232 } elseif ($this->save_file[$cnt] != "") { 233 // ¥Õ¥¡¥¤¥ë¥Ñ¥¹¥Á¥§¥Ã¥¯(¥Ñ¥¹¤Î¥¹¥é¥Ã¥·¥å/¤¬Ï¢Â³¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë¡£) 234 if(ereg("/$", $save_url)) { 235 $arrRet[$val]['filepath'] = $save_url . $this->save_file[$cnt]; 236 } else { 237 $arrRet[$val]['filepath'] = $save_url . "/" . $this->save_file[$cnt]; 238 } 239 $arrRet[$val]['real_filepath'] = $this->save_dir . $this->save_file[$cnt]; 240 } 241 if($arrRet[$val]['filepath'] != "") { 242 if($real_size){ 243 if(is_file($arrRet[$val]['real_filepath'])) { 244 list($width, $height) = getimagesize($arrRet[$val]['real_filepath']); 245 } 246 // ¥Õ¥¡¥¤¥ë²£Éý 247 $arrRet[$val]['width'] = $width; 248 // ¥Õ¥¡¥¤¥ë½ÄÉý 249 $arrRet[$val]['height'] = $height; 250 }else{ 251 // ¥Õ¥¡¥¤¥ë²£Éý 252 $arrRet[$val]['width'] = $this->width[$cnt]; 253 // ¥Õ¥¡¥¤¥ë½ÄÉý 254 $arrRet[$val]['height'] = $this->height[$cnt]; 255 } 256 // ɽ¼¨Ì¾ 257 $arrRet[$val]['disp_name'] = $this->disp_name[$cnt]; 258 } 259 $cnt++; 260 } 261 return $arrRet; 262 } 263 264 // DBÊݸÍѤΥե¡¥¤¥ë̾ÇÛÎó¤òÊÖ¤¹ 265 function getDBFileList() { 266 $cnt = 0; 267 foreach($this->keyname as $val) { 268 if($this->temp_file[$cnt] != "") { 269 $arrRet[$val] = $this->temp_file[$cnt]; 270 } else { 271 $arrRet[$val] = $this->save_file[$cnt]; 272 } 273 $cnt++; 274 } 275 return $arrRet; 276 } 277 278 // DB¤ÇÊݸ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë̾ÇÛÎó¤ò¥»¥Ã¥È¤¹¤ë 279 function setDBFileList($arrVal) { 280 $cnt = 0; 281 foreach($this->keyname as $val) { 282 if($arrVal[$val] != "") { 283 $this->save_file[$cnt] = $arrVal[$val]; 284 } 285 $cnt++; 286 } 287 } 288 289 // ²èÁü¤ò¥»¥Ã¥È¤¹¤ë 290 function setDBImageList($arrVal) { 291 $cnt = 0; 292 foreach($this->keyname as $val) { 293 if($arrVal[$val] != "" && $val == 'tv_products_image') { 294 $this->save_file[$cnt] = $arrVal[$val]; 295 } 296 $cnt++; 297 } 298 } 299 300 // DB¾å¤Î¥Õ¥¡¥¤¥ë¤ÎÆâºï½üÍ׵᤬¤¢¤Ã¤¿¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë¡£ 301 function deleteDBFile($arrVal) { 302 $objImage = new SC_Image($this->temp_dir); 303 $cnt = 0; 304 foreach($this->keyname as $val) { 305 if($arrVal[$val] != "") { 306 if($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal[$val])) { 307 308 // Éé²Ùʬ»¶»þ¤Ï¤¹¤Ù¤Æ¤Î¥µ¡¼¥Ð¤Ç¥Õ¥¡¥¤¥ëºï½ü 309 if($this->multi_web_server_mode === true) { 310 $this->ftpDeleteFile($this->ftp_save_dir . $arrVal[$val]); 311 } else { 312 $objImage->deleteImage($arrVal[$val], $this->save_dir); 313 } 314 } 315 } 316 $cnt++; 317 } 318 } 319 320 // ɬ¿ÜȽÄê 321 function checkEXISTS($keyname = "") { 322 $cnt = 0; 323 $arrRet = array(); 324 foreach($this->keyname as $val) { 325 if($val == $keyname || $keyname == "") { 326 // ɬ¿Ü¤Ç¤¢¤ì¤Ð¥¨¥é¡¼¥Á¥§¥Ã¥¯ 327 if ($this->necessary[$cnt] == true) { 328 if($this->save_file[$cnt] == "" && $this->temp_file[$cnt] == "") { 329 $arrRet[$val] = "¢¨ " . $this->disp_name[$cnt] . "¤¬¥¢¥Ã¥×¥í¡¼¥É¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£<br>"; 330 } 331 } 332 } 333 $cnt++; 334 } 335 return $arrRet; 336 } 337 338 // ³ÈÂçΨ¤ò»ØÄꤷ¤Æ²èÁüÊݸ 339 function saveResizeImage($keyname, $to_w, $to_h) { 340 $path = ""; 341 342 // keyname¤ÎźÉÕ¥Õ¥¡¥¤¥ë¤ò¼èÆÀ 343 $arrImageKey = array_flip($this->keyname); 344 $file = $this->temp_file[$arrImageKey[$keyname]]; 345 $filepath = $this->temp_dir . $file; 346 347 $path = $this->makeThumb($filepath, $to_w, $to_h); 348 349 // ¥Õ¥¡¥¤¥ë̾¤À¤±ÊÖ¤¹ 350 return basename($path); 351 } 352 353 /** 354 * ¥Õ¥¡¥¤¥ë¤òÁ´¤Æ¤ÎWEB¥µ¡¼¥Ð¤Ø¥³¥Ô¡¼ 355 * 356 * @param string $dst_path ¥³¥Ô¡¼Àè¥Õ¥¡¥¤¥ë¥Ñ¥¹(ÁêÂХѥ¹) 357 * @param string $src_path ¥³¥Ô¡¼¸µ¥Õ¥¡¥¤¥ë¥Ñ¥¹(ÀäÂХѥ¹) 358 * @param boolean $del_flag °Üư¥Õ¥¡¥¤¥ë¤òºï½ü¤¹¤ë¥Õ¥é¥° 359 * @return void 360 */ 361 function ftpMoveFile($dst_path, $src_path, $del_flag = false) { 362 global $arrWEB_SERVERS; 363 364 // Á´¤Æ¤Î¥µ¡¼¥Ð¤Ë¥Õ¥¡¥¤¥ë¤ò¥³¥Ô¡¼¤¹¤ë 365 foreach($arrWEB_SERVERS as $array) { 366 sfFtpCopy($array['host'], $array['user'], $array['pass'], $dst_path, $src_path); 367 } 368 // °Üư¸å¤Ï¥Õ¥¡¥¤¥ë¤òºï½ü 369 if($del_flag === true) { 370 @unlink($src_path); 371 } 372 } 373 374 /** 375 * ¥Õ¥¡¥¤¥ë¤òÁ´¤Æ¤ÎWEB¥µ¡¼¥Ð¾å¤«¤éºï½ü 376 * 377 * @param string $dst_path ¥³¥Ô¡¼Àè¥Õ¥¡¥¤¥ë¥Ñ¥¹(ÁêÂХѥ¹) 378 * @return void 379 */ 380 function ftpDeleteFile($dst_path) { 381 global $arrWEB_SERVERS; 382 383 // Á´¤Æ¤Î¥µ¡¼¥Ð¤Ë¥Õ¥¡¥¤¥ë¤ò¥³¥Ô¡¼¤¹¤ë 384 foreach($arrWEB_SERVERS as $array) { 385 sfFtpDelete($array['host'], $array['user'], $array['pass'], $dst_path); 386 } 387 } 388 389 390 /** 391 * FTPÍÑ¥Õ¥¡¥¤¥ë°ì»þ³ÊǼ¥Ç¥£¥ì¥¯¥È¥êºîÀ® 392 * 393 * @param string $dir ºîÀ®¥Ç¥£¥ì¥¯¥È¥ê 394 * @return string $ftp_temp_dir ºîÀ®°ì»þ³ÊǼ¥Ç¥£¥ì¥¯¥È¥ê¥Ñ¥¹ 395 */ 396 function makeFtpTempDir($dir) { 397 // FTPÍÑ¥Õ¥¡¥¤¥ë°ì»þ³ÊǼÍѥǥ£¥ì¥¯¥È¥ê 398 $ftp_temp_dir = $this->temp_dir . "ftp_temp/"; 399 // ¥Ç¥£¥ì¥¯¥È¥ê¤¬Â¸ºß¤·¤Ê¤«¤Ã¤¿¤éºîÀ® 400 if(!file_exists($ftp_temp_dir)) { 401 mkdir($ftp_temp_dir); 402 chmod($ftp_temp_dir, 0777); 403 } 404 405 return $ftp_temp_dir; 406 } 312 407 } 313 408 ?> -
branches/beta/data/class/SC_View.php
r14392 r14676 44 44 $this->_smarty->register_function("sfPrintEbisTag","sfPrintEbisTag"); 45 45 $this->_smarty->register_function("sfPrintAffTag","sfPrintAffTag"); 46 $this->_smarty->default_modifiers = array('script_escape');46 $this->_smarty->default_modifiers = array('script_escape'); 47 47 48 48 if(ADMIN_MODE == '1') { … … 96 96 print("½èÍý»þ´Ö:" . $time . "ÉÃ"); 97 97 } 98 99 if (DEBUG_MODE === true) { 100 print($_SERVER["SERVER_ADDR"]."-"); 101 } 98 102 } 99 103
Note: See TracChangeset
for help on using the changeset viewer.
