Changeset 21441 for branches/version-2_12-dev/data/class/SC_UploadFile.php
- Timestamp:
- 2012/02/06 11:05:15 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_UploadFile.php
r21420 r21441 83 83 $ret = $objThumb->Main($src_file, $width, $height, $dst_file); 84 84 85 if ($ret[0] != 1) {85 if ($ret[0] != 1) { 86 86 // エラーメッセージの表示 87 87 echo $ret[1]; … … 98 98 $arrKeyname = array_flip($this->keyname); 99 99 100 if (!($_FILES[$keyname]['size'] > 0)) {100 if (!($_FILES[$keyname]['size'] > 0)) { 101 101 $objErr->arrErr[$keyname] = "※ " . $this->disp_name[$arrKeyname[$keyname]] . "がアップロードされていません。<br />"; 102 102 } else { 103 foreach ($this->keyname as $val) {103 foreach ($this->keyname as $val) { 104 104 // 一致したキーのファイルに情報を保存する。 105 105 if ($val == $keyname) { … … 109 109 $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array("FILE_SIZE_CHECK")); 110 110 // エラーがない場合 111 if (!isset($objErr->arrErr[$keyname])) {111 if (!isset($objErr->arrErr[$keyname])) { 112 112 // 画像ファイルの場合 113 if ($this->image[$cnt]) {113 if ($this->image[$cnt]) { 114 114 // 保存用の画像名を取得する 115 115 $dst_file = $this->lfGetTmpImageName($rename, $keyname); … … 118 118 } else { 119 119 // 一意なファイル名を作成する。 120 if ($rename) {120 if ($rename) { 121 121 $uniqname = date('mdHi') . "_" . uniqid("")."."; 122 122 $this->temp_file[$cnt] = ereg_replace("^.*\.",$uniqname, $_FILES[$keyname]['name']); … … 144 144 $cnt = 0; 145 145 $arrKeyname = array_flip($this->keyname); 146 if (!($_FILES[$keyname]['size'] > 0)) {146 if (!($_FILES[$keyname]['size'] > 0)) { 147 147 $objErr->arrErr[$keyname] = "※ " . $this->disp_name[$arrKeyname[$keyname]] . "がアップロードされていません。(ファイルがアップロードできない場合は、.htaccessファイルのphp_value upload_max_filesizeを調整してください)<br />"; 148 148 } else { 149 foreach ($this->keyname as $val) {149 foreach ($this->keyname as $val) { 150 150 // 一致したキーのファイルに情報を保存する。 151 151 if ($val == $keyname) { … … 155 155 $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array("FILE_SIZE_CHECK")); 156 156 // エラーがない場合 157 if (!isset($objErr->arrErr[$keyname])) {157 if (!isset($objErr->arrErr[$keyname])) { 158 158 // 一意なファイル名を作成する。 159 159 $uniqname = date('mdHi') . "_" . uniqid("")."."; … … 174 174 $objImage = new SC_Image_Ex($this->temp_dir); 175 175 $cnt = 0; 176 foreach ($this->keyname as $val) {176 foreach ($this->keyname as $val) { 177 177 if ($val == $keyname) { 178 178 // 一時ファイルの場合削除する。 179 if ($this->temp_file[$cnt] != "") {179 if ($this->temp_file[$cnt] != "") { 180 180 $objImage->deleteImage($this->temp_file[$cnt], $this->temp_dir); 181 181 } … … 191 191 $objImage = new SC_Image_Ex($this->temp_dir); 192 192 $cnt = 0; 193 foreach ($this->keyname as $val) {193 foreach ($this->keyname as $val) { 194 194 if ($val == $keyname) { 195 195 // 一時ファイルの場合削除する。 196 if ($this->temp_file[$cnt] != "") {196 if ($this->temp_file[$cnt] != "") { 197 197 $objImage->deleteImage($this->temp_file[$cnt], $this->temp_dir); 198 198 } … … 208 208 $cnt = 0; 209 209 $filepath = ""; 210 foreach ($this->keyname as $val) {210 foreach ($this->keyname as $val) { 211 211 if ($val == $keyname) { 212 if ($this->temp_file[$cnt] != "") {212 if ($this->temp_file[$cnt] != "") { 213 213 $filepath = $this->temp_dir . $this->temp_file[$cnt]; 214 214 } … … 224 224 $objImage = new SC_Image_Ex($this->temp_dir); 225 225 226 foreach ($this->keyname as $val) {227 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") {226 foreach ($this->keyname as $val) { 227 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") { 228 228 229 229 $objImage->moveTempImage($this->temp_file[$cnt], $this->save_dir); … … 245 245 $cnt = 0; 246 246 $objImage = new SC_Image_Ex($this->temp_dir); 247 foreach ($this->keyname as $val) {248 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") {247 foreach ($this->keyname as $val) { 248 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") { 249 249 $objImage->moveTempImage($this->temp_file[$cnt], $this->save_dir); 250 250 // すでに保存ファイルがあった場合は削除する。 … … 264 264 $cnt = 0; 265 265 $arrRet = array(); 266 foreach ($this->keyname as $val) {267 if (isset($this->temp_file[$cnt])) {266 foreach ($this->keyname as $val) { 267 if (isset($this->temp_file[$cnt])) { 268 268 $arrRet["temp_" . $val] = $this->temp_file[$cnt]; 269 269 } 270 if (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != "") {270 if (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != "") { 271 271 $arrRet["save_" . $val] = $this->save_file[$cnt]; 272 272 } … … 279 279 function setHiddenFileList($arrPOST) { 280 280 $cnt = 0; 281 foreach ($this->keyname as $val) {281 foreach ($this->keyname as $val) { 282 282 $key = "temp_" . $val; 283 if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) {283 if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) { 284 284 $this->temp_file[$cnt] = $arrPOST[$key]; 285 285 } 286 286 $key = "save_" . $val; 287 if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) {287 if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) { 288 288 $this->save_file[$cnt] = $arrPOST[$key]; 289 289 } … … 294 294 function setHiddenKikakuFileList($arrPOST) { 295 295 $cnt = 0; 296 foreach ($this->keyname as $val) {296 foreach ($this->keyname as $val) { 297 297 $key = "temp_" . $val; 298 if (isset($arrPOST[$key])) {298 if (isset($arrPOST[$key])) { 299 299 $this->temp_file[$cnt] = $arrPOST[$key]; 300 300 } 301 301 $key = "save_" . $val; 302 if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) {302 if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) { 303 303 $this->save_file[$cnt] = $arrPOST[$key]; 304 304 } … … 311 311 $arrRet = array(); 312 312 $cnt = 0; 313 foreach ($this->keyname as $val) {314 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") {313 foreach ($this->keyname as $val) { 314 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") { 315 315 // ファイルパスチェック(パスのスラッシュ/が連続しないようにする。) 316 if (ereg("/$", $temp_url)) {316 if (ereg("/$", $temp_url)) { 317 317 $arrRet[$val]['filepath'] = $temp_url . $this->temp_file[$cnt]; 318 318 } else { … … 322 322 } elseif (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != "") { 323 323 // ファイルパスチェック(パスのスラッシュ/が連続しないようにする。) 324 if (ereg("/$", $save_url)) {324 if (ereg("/$", $save_url)) { 325 325 $arrRet[$val]['filepath'] = $save_url . $this->save_file[$cnt]; 326 326 } else { … … 329 329 $arrRet[$val]['real_filepath'] = $this->save_dir . $this->save_file[$cnt]; 330 330 } 331 if (isset($arrRet[$val]['filepath']) && !empty($arrRet[$val]['filepath'])) {332 if ($real_size){333 if (is_file($arrRet[$val]['real_filepath'])) {331 if (isset($arrRet[$val]['filepath']) && !empty($arrRet[$val]['filepath'])) { 332 if ($real_size) { 333 if (is_file($arrRet[$val]['real_filepath'])) { 334 334 list($width, $height) = getimagesize($arrRet[$val]['real_filepath']); 335 335 } … … 338 338 // ファイル縦幅 339 339 $arrRet[$val]['height'] = $height; 340 } else{340 } else { 341 341 // ファイル横幅 342 342 $arrRet[$val]['width'] = $this->width[$cnt]; … … 356 356 $arrRet = ""; 357 357 $cnt = 0; 358 foreach ($this->keyname as $val) {359 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") {358 foreach ($this->keyname as $val) { 359 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") { 360 360 $arrRet = $this->temp_file[$cnt]; 361 361 } elseif (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != "") { … … 369 369 $arrRet = array(); 370 370 $cnt = 0; 371 foreach ($this->keyname as $val) {372 if (isset($this->temp_file[$cnt])) {371 foreach ($this->keyname as $val) { 372 if (isset($this->temp_file[$cnt])) { 373 373 $arrRet[$val] = $this->temp_file[$cnt]; 374 374 } elseif (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != "") { … … 383 383 function getDBFileList() { 384 384 $cnt = 0; 385 foreach ($this->keyname as $val) {386 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") {385 foreach ($this->keyname as $val) { 386 if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != "") { 387 387 $arrRet[$val] = $this->temp_file[$cnt]; 388 } else 388 } else { 389 389 $arrRet[$val] = isset($this->save_file[$cnt]) ? $this->save_file[$cnt] : ""; 390 390 } … … 397 397 function setDBFileList($arrVal) { 398 398 $cnt = 0; 399 foreach ($this->keyname as $val) {400 if (isset($arrVal[$val]) && $arrVal[$val] != "") {399 foreach ($this->keyname as $val) { 400 if (isset($arrVal[$val]) && $arrVal[$val] != "") { 401 401 $this->save_file[$cnt] = $arrVal[$val]; 402 402 } … … 407 407 // DBで保存されたダウンロードファイル名をセットする 408 408 function setDBDownFile($arrVal) { 409 if (isset($arrVal['down_realfilename']) && $arrVal['down_realfilename'] != "") {409 if (isset($arrVal['down_realfilename']) && $arrVal['down_realfilename'] != "") { 410 410 $this->save_file[0] = $arrVal['down_realfilename']; 411 411 } … … 415 415 function setPostFileList($arrPost,$arrVal) { 416 416 $cnt = 0; 417 foreach ($this->keyname as $val) {418 if (isset($arrPost['temp_down_realfilename:' . ($cnt+1)])) {417 foreach ($this->keyname as $val) { 418 if (isset($arrPost['temp_down_realfilename:' . ($cnt+1)])) { 419 419 $this->temp_file[$cnt] = $arrPost['temp_down_realfilename:' . ($cnt+1)]; 420 420 } … … 426 426 function setDBImageList($arrVal) { 427 427 $cnt = 0; 428 foreach ($this->keyname as $val) {429 if ($arrVal[$val] != "" && $val == 'tv_products_image') {428 foreach ($this->keyname as $val) { 429 if ($arrVal[$val] != "" && $val == 'tv_products_image') { 430 430 $this->save_file[$cnt] = $arrVal[$val]; 431 431 } … … 438 438 $objImage = new SC_Image_Ex($this->temp_dir); 439 439 $cnt = 0; 440 foreach ($this->keyname as $val) {441 if ($arrVal[$val] != "") {442 if ($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal[$val])) {440 foreach ($this->keyname as $val) { 441 if ($arrVal[$val] != "") { 442 if ($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal[$val])) { 443 443 $objImage->deleteImage($arrVal[$val], $this->save_dir); 444 444 } … … 452 452 $objImage = new SC_Image_Ex($this->temp_dir); 453 453 $cnt = 0; 454 if ($arrVal['down_realfilename'] != "") {455 if ($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal['down_realfilename'])) {454 if ($arrVal['down_realfilename'] != "") { 455 if ($this->save_file[$cnt] == "" && !ereg("^sub/", $arrVal['down_realfilename'])) { 456 456 $objImage->deleteImage($arrVal['down_realfilename'], $this->save_dir); 457 457 } … … 463 463 $cnt = 0; 464 464 $arrRet = array(); 465 foreach ($this->keyname as $val) {466 if ($val == $keyname || $keyname == "") {465 foreach ($this->keyname as $val) { 466 if ($val == $keyname || $keyname == "") { 467 467 // 必須であればエラーチェック 468 468 if ($this->necessary[$cnt] == true) { … … 504 504 function lfGetTmpImageName($rename, $keyname = "", $uploadfile = ""){ 505 505 506 if ( $rename === true ){506 if ($rename === true ) { 507 507 // 一意なIDを取得し、画像名をリネームし保存 508 508 $uniqname = date('mdHi') . "_" . uniqid("");
Note: See TracChangeset
for help on using the changeset viewer.