Example #1
0
                    $colorOptionalCode_arr[$imgColor] = $_POST['color_symbol_code3'];
                    break;
                case "4_photo_input":
                    $pic_path = "public_html/img/detailImg/" . $pics;
                    move_uploaded_file($_FILES[$photo_name]['tmp_name'], $pic_path);
                    $imgColor = $_POST['color4'];
                    $imgURL_arr[$imgColor] = $pic_path;
                    $colorOptionalCode_arr[$imgColor] = $_POST['color_symbol_code4'];
                    break;
            }
        }
    }
    $colorArr = array_keys($imgURL_arr);
    $colors = implode(",", $colorArr);
    $productMgr->addProduct($product_id, $product_name, $symbol_code, $price, $colors, $description, $stock);
    $photoMgr->AddPhoto($product_id, 'thumbnail', $imgURL_thumbnail);
    foreach ($colorArr as $color) {
        $photoMgr->AddPhoto($product_id, $color, $imgURL_arr[$color]);
        $productMgr->addProductColorOptionalCode($product_id, $color, $colorOptionalCode_arr[$color]);
    }
    header("Location: admin.php#viewProduct");
} elseif ($operation === "edit_product") {
    $valid = true;
    $product_id = filter_input(INPUT_POST, 'edit_product_id');
    $existingPhotoList = $photoMgr->getPhotos($product_id);
    $product_name = filter_input(INPUT_POST, 'edit_product_name');
    $symbol_code = filter_input(INPUT_POST, 'edit_symbol_code');
    if (empty($symbol_code)) {
        $symbol_code = '';
    }
    $price = filter_input(INPUT_POST, 'edit_price');
Example #2
0
 $hdPicname = $_FILES[$hdId]['name'];
 if ($hdPicname != "") {
     $count++;
     $type = strstr($hdPicname, '.');
     if ($type != ".gif" && $type != ".jpg" && $type != ".png") {
         echo 'invalid image type';
         exit;
     }
     $rand = rand(1000, 9999);
     $pics = date("YmdHis") . $rand . "hd" . $type;
     if (!file_exists("public_html/img/projectImg/" . $project_id)) {
         mkdir("public_html/img/projectImg/" . $project_id, 0777, true);
     }
     $pic_path = "public_html/img/projectImg/" . $project_id . "/" . $pics;
     move_uploaded_file($_FILES[$hdId]['tmp_name'], $pic_path);
     $photoMgr->AddPhoto($project_id, "hd" . strval($count), $pic_path);
 }
 $thumbnailPicname = $_FILES[$thumbnailId]['name'];
 if ($thumbnailPicname != "") {
     $type = strstr($thumbnailPicname, '.');
     if ($type != ".gif" && $type != ".jpg" && $type != ".png") {
         echo 'invalid image type';
         exit;
     }
     $rand = rand(1000, 9999);
     $pics = date("YmdHis") . $rand . "thumbnail" . $type;
     if (!file_exists("public_html/img/projectImg/" . $project_id)) {
         mkdir("public_html/img/projectImg/" . $project_id, 0777, true);
     }
     $pic_path = "public_html/img/projectImg/" . $project_id . "/" . $pics;
     move_uploaded_file($_FILES[$thumbnailId]['tmp_name'], $pic_path);