Example #1
0
if ($_POST['submit']) {
    $unit = new product_class();
    $tool = new My_Tool();
    $sam = new guard();
    //檢查傳入值--------------------------
    $name = htmlspecialchars(trim($_POST['name']));
    if (empty($name)) {
        $tool->error(get_msg("name_error"));
    } else {
        $name = $sam->var_check($name);
    }
    $unit->table = $pro_class_table;
    $unit->get_vars();
    $buff = array();
    $unit->get_history($unit->upid, $buff);
    $unit->add();
    $tool->show(get_msg("add_success"), $_SERVER['HTTP_REFERER']);
    exit;
}
?>
			 
    <form method="post" action="">
	<input type="hidden" name="upid" value="<?php 
print $_GET['id'];
?>
" />
	類別名稱:<input type="text" name="name" size="20" />
	排序:   <input type="text" name="no" value="100" />
	<input type="submit" name="submit" value="新增類別" />
	</form>
    $img->set_width($pic_width);
    //決定縮圖大小,大圖大小
    $img->set_savepath("../images/" . date("Y-m-d"));
    //設定儲存路徑
    $pic2 = $img->save();
} else {
    $pic2 = $_POST['pic2'];
}
if ($check == 'upd') {
    $unit->table = $pro_class_table;
    $unit->get_vars();
    $unit->pic = $pic;
    $unit->pic2 = $pic2;
    $buff = array();
    $unit->get_history($unit->upid, $buff);
    $unit->upd();
    $tool->show(get_msg("upd_success"), $_SERVER['HTTP_REFERER']);
    exit;
}
if (isset($_POST['del'])) {
    $id = $_POST['id'];
    for ($i = 0; $i < count($id); $i++) {
        del_child($id[$i]);
    }
    if (count($id) > 0) {
        $tool->show(get_msg("del_success"), $_SERVER['HTTP_REFERER']);
    } else {
        $tool->error(get_msg("del_fail"));
    }
    exit;
}
        remove_home_num($id);
    }
    //維持首頁勾選數量
    //變更相關資料-----------------------------------------------------------------------
    $sql = "UPDATE `{$pro_pic_table}` SET `upid`='{$id}' where `upid`='0'";
    mysql_query($sql);
    $sql = "UPDATE `{$pro_color_relate_table}` SET `upid`='{$id}' where `upid`='0'";
    mysql_query($sql);
    $sql = "UPDATE `{$pro_size_relate_table}` SET `upid`='{$id}' where `upid`='0'";
    mysql_query($sql);
    $sql = "UPDATE `{$pro_stock_table}` SET `pid`='{$id}' where `pid`='0'";
    mysql_query($sql);
    $sql = "UPDATE `{$pro_download_table}` SET `upid`='{$id}' where `upid`='0'";
    mysql_query($sql);
    //變更相關資料-----------------------------------------------------------------------
    $tool->show("新增成功!", $_SERVER['HTTP_REFERER']);
    exit;
} elseif ($check == 'upd') {
    $unit->get_vars();
    //取得所有post資料
    //------------------------------------------------------------
    $unit->get_db_var();
    //取出資料庫資料,檢查圖片看是否須刪除上次的檔案
    if ($unit->pic != $pic and $unit->pic != $pic_no_pic) {
        @unlink($unit->pic);
    }
    //------------------------------------------------------------
    $unit->get_vars();
    $unit->pic = $pic;
    //圖片路徑需重新取得 (來自$_FILES的檔案需另外處理上傳)
    $unit->upd();
Example #4
0
        $upload->allow_size = 1024 * 1024 * 10;
        //大小限制 10mb
        $upload->save_path = "../../images/file/" . date("Y-m-d");
        //儲存的資料夾路徑
        $file = $upload->save($_FILES['file']);
        if ($file === false) {
            $tool->error("檔案上傳失敗!!");
        }
    }
    if (!empty($file)) {
        //有檔
        $file = substr($file, 3);
        $name = $_POST['name'];
        $str = "INSERT INTO {$now_table} (id,name,no,upid,size,color,cct,type,cri,forward,file) VALUES ('','{$name}','0','{$upid}','','','','','','','{$file}')";
        mysql_query($str);
        $tool->show("上傳成功!!");
        //彈出視窗訊息
        echo "<script type='text/javascript'>";
        echo "window.parent.download_get();";
        //讓母視窗, 重新載入 顯示其它新增圖片的頁面
        echo "</script>";
    }
}
?>
<div style="font-size:12px;">
<form method="post" enctype="multipart/form-data" action="">
<input type="hidden" name="upid" value="<?php 
echo $id;
?>
" />
檔案名稱:<input name="name" type="text" value="" size="20"/>