edit.php
资源名称:BBWPS.rar [点击查看]
上传用户:yttaitong
上传日期:2009-05-10
资源大小:128k
文件大小:4k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
PHP
- <?php
- /*
- [BBWPS!] (C)2006-2010 小蜜蜂版权所有.
- This is NOT a freeware, use is subject to license terms
- 时间:2007年12月
- 描述:编辑
- */
- error_reporting(0);
- require("../config.php");
- require("../class/mysql_class.php");
- require_once("../function/function.php");
- $db= new DB($hostname,$username,$password,$database);
- $mid = $_POST['mid'];
- $title = strip_tags($_POST['title']);
- $cont = nl2br($_POST['content']);
- $enter = "rn";
- $content = strip_tags(str_replace($enter," ",$cont));
- $oprice = $_POST['oprice'];
- $nprice = $_POST['nprice'];
- $i = $_POST['itime'];
- $sid = $_POST['sid'];
- $cid = $_POST["cid"];
- if(!$title||!$cont||!$oprice||!$nprice||!$i){
- MsgError("请完整输入信息内容");
- }
- if(!$cid){
- MsgError("请先添加城市");
- }
- if(!$sid){
- MsgError("请先添加分类");
- }
- if($nprice> $oprice){
- MsgError("折扣价比原价高");
- }
- //******判断能否选一级分类和有效期*********
- $onesort = "select sname from ".$prefix."sort where sparent='".$sid."';";
- $sort = $db->query($onesort,1);
- $sname = $db->fetch_array($sort);
- $setting = "select day from ".$prefix."setting";
- $setup = $db->query($setting,1);
- $set = $db->fetch_array($setup);
- if($sname["sname"]){
- echo "<script language = 'javascript'>";
- echo "window.alert('请选二级分类!');";
- echo "window.loaction=history.back(-1);";
- echo "</script>";
- }
- elseif($i> $set["day"]){
- echo "<script language = 'javascript'>";
- echo "window.alert('有效期最多".$set["day"]."天"."!');";
- echo "window.loaction=history.back(-1);";
- echo "</script>";
- }
- else{
- $cid = $_POST['cid'];
- $etime = time()+$i*3600*24;
- $upload_file = $_FILES['upload']['tmp_name'];
- $upload_file_name = $_FILES['upload']['name'];
- $upload_file_size = $_FILES['upload']['size'];
- $max_file_size = 502000;
- $exct = strrchr($upload_file_name,"."); //取后缀名,包括了点
- $ext = substr($exct,1); //取后缀名,不包括点
- $exct1 = "(jpg||jpeg||png||gif)";
- if($upload_file){
- if($upload_file_size > $max_file_size){
- echo "<script language = 'javascript'>";
- echo "window.alert('图片大于500K,请重新选择!');";
- echo "window.history.back(-1)";
- echo "</script>";
- exit();
- }
- if(!$exct2 = eregi($ext,$exct1)){
- echo "<script language='javascript'>";
- echo "window.alert('图片格式不对,请重新选择!');";
- echo "window.history.back(-1)";
- echo "</script>";
- exit();
- }
- $tmp_path = dirname(dirname(__FILE__));
- $list = date("Y-m-j");
- $newname=time().$exct; //取新名称
- if(!is_dir($tmp_path.'/upload/'.$list.'/')){
- mkdir ($tmp_path.'/upload/'.$list.'/'); //建立路径
- }
- $path = $tmp_path.'/upload/'.$list.'/'.$newname;
- if(!move_uploaded_file($upload_file,$path)){
- echo "<script language='javascript'>";
- echo "window.alert('图片上传不成功!');";
- echo "window.history.back(-1)";
- echo "</script>";
- exit;
- }
- $pic = "select picture from ".$prefix."message where mid='".$mid."'";
- $result = $db->query($pic,1);
- $row = $db->fetch_array($result);
- if($row["picture"]){
- $handle = explode(".",$row["picture"]);
- $file = date("Y-m-j",$handle[0]);
- $path = '../upload/'.$file.'/'.$row["picture"];
- unlink($path);
- }
- $sql = "update ".$prefix."message set sid='$sid',cid='$cid',title='$title',content='$content',oprice='$oprice',nprice='$nprice',btime='".time()."',etime='$etime',picture='$newname' where mid='".$mid."'";
- $db->query($sql,1);
- echo "<script language='javascript'>";
- echo "window.alert('提交成功!');";
- echo "</script>";
- echo "<meta http-equiv ="refresh" content="0 url=manage.php">";
- }
- else{
- $sql1 = "update ".$prefix."message set sid='$sid',cid='$cid',title='$title',content='$content',oprice='$oprice',nprice='$nprice',btime='".time()."',etime='$etime' where mid='".$mid."'";
- $db->query($sql1,1);
- echo "<script language='javascript'>";
- echo "window.alert('提交成功!');";
- echo "</script>";
- echo "<meta http-equiv ="refresh" content="0 url=manage.php">";
- }
- }
- ?>