store.php
资源名称:BBWPS.rar [点击查看]
上传用户:yttaitong
上传日期:2009-05-10
资源大小:128k
文件大小:3k
源码类别:
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);
- $title = strip_tags($_POST['title']); //过滤HTML和PHP关键字
- $cont = strip_tags(nl2br($_POST['content'])); //过滤HTML和PHP关键字
- $enter = "rn";
- $content = strip_tags(str_replace($enter," ",$cont));
- $oprice = $_POST['oprice'];
- $nprice = $_POST['nprice'];
- $i = $_POST['itime'];
- $cid = $_POST['cid'];
- $sid = $_POST['sid'];
- 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"]){
- MsgError("请选二级分类!");
- }
- elseif($i> $set["day"]){
- MsgError("有效期最多{$set["day"]}天");
- }
- else{
- $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||gif||bmp)";
- //*********图片大小判断*****
- if($upload_file){
- if($upload_file_size > $max_file_size){
- MsgError("图片大于500K,请重新选择!");
- }
- //*********图片格式判断*****
- if(!$exct2 = eregi($ext,$exct1)){
- MsgError("图片格式不对,请重新选择!");
- }
- $tmp_path = dirname(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)){
- MsgError("图片上传不成功!");
- }
- $sql = "insert into ".$prefix."message (sid,cid,title,content,oprice,nprice,btime,etime,picture,username) values ('$sid','$cid','$title','$content','$oprice','$nprice','".time()."','$etime','$newname','管理员')";
- $db->query($sql,1);
- ExeSuccess("提交成功!","cm.php?cid={$cid}&sid={$sid}");
- }
- else{
- $sql1 = "insert into ".$prefix."message (sid,cid,title,content,oprice,nprice,btime,etime,username) values ('$sid','$cid','$title','$content','$oprice','$nprice','".time()."','$etime','管理员')";
- $db->query($sql1,1);
- ExeSuccess("提交成功!","cm.php?cid={$cid}&sid={$sid}");
- }
- }
- $db->close();
- ?>