コード例 #1
0
     //***************刪除舊的 上傳新的
     if (mysql_affected_rows() > 0) {
         //刪除舊的照片圖檔
         if (!empty($_SESSION['PHOTOfilename'])) {
             if (@unlink($upload_dir . $_SESSION['PHOTOfilename']) && @unlink($thumb_dir . $_SESSION['PHOTOfilename'])) {
                 $message = "已經成功刪除圖檔(" . $upload_dir . $_SESSION['PHOTOfilename'] . ' 與 ' . $thumb_dir . $_SESSION['PHOTOfilename'] . ")";
                 echo "<script type='text/javascript'>alert('" . $message . "');</script>";
             } else {
                 $message = "無法刪除照片檔案,請自行刪除(" . $upload_dir . $_SESSION['PHOTOfilename'] . ' 與 ' . $thumb_dir . $_SESSION['PHOTOfilename'] . ")";
                 echo "<script type='text/javascript'>alert('" . $message . "');</script>";
             }
         }
         if (!empty($sourcefile)) {
             //上傳新的照片圖檔
             if (move_uploaded_file($_FILES['newproductphoto']['tmp_name'], $upload_dir . $sourcefile)) {
                 $err = mkthumb($upload_dir . $sourcefile, $thumb_dir . $sourcefile, 168);
                 if ($err != 'ok') {
                     echo '圖檔壓縮錯誤<br>';
                 }
             }
         }
     }
 }
 $SQLStr = "update 商品 set 商品.商品名稱='" . $_POST['newproductname'] . "', 商品.單價=" . $_POST['newproductprice'] . " where 商品.代號=" . $_POST['updproductno'];
 echo $_SESSION['OPERATION'] . "<p>SQL=" . $SQLStr . "</p>";
 //可刪
 $rs = mysql_query($SQLStr);
 if (mysql_error()) {
     die("修改商品 發生錯誤 " . mysql_error());
 } else {
     echo "修改" . mysql_affected_rows() . "筆";
コード例 #2
0
<?php

require_once '../header_php.php';
?>






<?php 
if ($action == "photo_edit" && $photoid) {
    @mysql_query("UPDATE photos SET caption=\"{$photo_caption}\" WHERE photoid=\"{$photoid}\"");
    if (is_uploaded_file($_FILES['photo_name']['tmp_name'])) {
        @move_uploaded_file($_FILES['photo_name']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . "/gallery/gallery_{$photoid}.jpg");
        mkthumb("gallery_{$photoid}.jpg", 200);
    }
    @mysql_query("DELETE FROM photos_categories WHERE photoid='{$photoid}'");
    if ($category1) {
        @mysql_query("INSERT INTO photos_categories (photoid,categoryid) VALUES ('{$photoid}','{$category1}')");
    }
    if ($category2 && $category2 != $category1) {
        @mysql_query("INSERT INTO photos_categories (photoid,categoryid) VALUES ('{$photoid}','{$category2}')");
    }
    if ($category3 && $category3 != $category2 && $category3 != $category1) {
        @mysql_query("INSERT INTO photos_categories (photoid,categoryid) VALUES ('{$photoid}','{$category3}')");
    }
}
$photorow = mysql_fetch_array(mysql_unbuffered_query("SELECT * FROM photos WHERE photoid='{$photoid}'"));
?>
コード例 #3
0
    } else {
        $file_type = strtolower(substr(strrchr($real_file, '.'), 1));
        if (!in_array($file_type, $types)) {
            $error[] = "_FILETYPENOTALLOWED";
        }
    }
    //check filesize
    if ($_FILES['filename']['size'] >= $config->max_file_size * 1024 * 1024) {
        $error[] = "_FILETOBIG";
    }
    //move file to dir and generate thumb if needed
    if (!$error) {
        $temp_file = md5(microtime() . uniqid(rand(), true)) . "_" . $bid;
        if (move_uploaded_file($_FILES['filename']['tmp_name'], "include/files/" . $temp_file)) {
            if (extension_loaded("gd")) {
                mkthumb($temp_file);
            }
        } else {
            $error[] = "_FILEUPLOADFAIL";
        }
    }
    //save file to db
    if (!$error) {
        //save it to db
        $query = mysql_query("INSERT INTO `" . $config->db_prefix . "_files` (`upload_time`,`down_count`,`bid`,`demo_file`,`demo_real`,`comment`,`name`,`email`,`file_size`,`addr`) \n\t\t\t\tVALUES (UNIX_TIMESTAMP(),0," . $bid . ",'" . $temp_file . "','" . $real_file . "','" . $comment . "','" . $name . "','" . $email . "'," . $_FILES['filename']['size'] . ",'" . $_SERVER["REMOTE_ADDR"] . "')") or die(mysql_error());
        $msg_demo = "_FILEUPLOADSUCCESS";
    }
    new_captcha();
    $smarty->assign("upload_error", $error);
    $smarty->assign("demo_layer", 1);
}