日期:2011-06-18  浏览次数:20429 次

<?php
/*******所用到的表结构********
DROP TABLE IF EXISTS index_news;
CREATE TABLE index_news (
   news_id bigint(20) NOT NULL auto_increment,
   news_date date DEFAULT '0000-00-00' NOT NULL,
   news_title varchar(100) NOT NULL,
   news_content text,
   news_link varchar(100),
   is_new char(1) DEFAULT '1',
   picture_id int(11),
   picture_side char(1) DEFAULT '1',
   news_show char(1) DEFAULT '1',
   PRIMARY KEY (news_id),
   KEY id (news_id)
);
DROP TABLE IF EXISTS picture;
CREATE TABLE picture (
   id int(11) NOT NULL auto_increment,
   picture blob NOT NULL,
   picture_type varchar(50) NOT NULL,
   PRIMARY KEY (id),
   UNIQUE id (id)
);
**********************/
require("../include/date.inc.php3");
require("../include/config.inc.php3");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>修改首页新闻信息</title>
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; obj_name=args[i+1]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+obj_name+' 必须是一个E-Mail地址.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+obj_name+' 必须是一个数字.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+obj_name+' 必须是一个在 '+min+' 和 '+max+'之间的数字.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+obj_name+' 必须输入.\n'; }
  } if (errors) alert('输入数据存在错误:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>

<body>
<?php
if ($add){
    $date=input2date($news_date);
    //echo $picture . "  ". filesize($picture);
    //if ($is_new!="0") $is_new="1" ;
    //if ($news_show!="0") $news_show="1";
    //if ($picture_side!="2") $picture_side="1";
    if ($picture!="none"){
        $pic_data = addslashes(fread($fp=fopen($picture,"r"), filesize($picture)));
        $i_str="insert into picture (picture,picture_typ