www.pudn.com > smartstarwap.rar > add_news.php, change:2005-10-04,size:5756b


<? 
    /* ====================================== 
	 * ******smartstar firm wap system****** 
	 * ====================================== 
	 * AUTHOR : 
     * ======= 
     * Copyright (C) 2006 Wap-system - A wap system designed for firm 
     * by smartstar. 
	 */ 
?> 
<? 
include("function.inc.php"); 
   include("../chinese/class.Chinese.php"); 
?> 
<link href=js/common.css rel=stylesheet type=text/css> 
<? 
if ($_POST) 
{ 
	if(!empty($_POST['title'])) 
	{ 
	include("../db_connect.php"); 
	$maxid=mysql_query("select max(id) from wap_news",$db) or die ("query failed"); 
	$maxid_row=mysql_fetch_row($maxid); 
	$id=$maxid_row[0]+1; 
	$sortid=$_POST['sortid']; 
	$sortid=intval($sortid); 
	$title=$_POST['title']; 
	$info=$_POST['info']; 
	$chs_t = new Chinese("GB2312","UTF8",trim($title)); 
    $title = $chs_t->ConvertIT(); 
	$chs_i = new Chinese("GB2312","UTF8",trim($info)); 
    $info = $chs_i->ConvertIT(); 
	mysql_query("insert into wap_news values('$id','$sortid','$title','$info')",$db) or die ("query failed"); 
	mysql_close($db); 
	  echo "<p align=center>内容添加成功,3秒后自动返回内容管理页!"; 
	echo "<script>window.setTimeout(\"location.href='admin_news.php'\",3000);</script></p>"; 
	exit; 
	   
	} 
	else 
	{ 
		echo "<p align=center>标题不能为空!"; 
		echo "<a href=\"add_news.php\">返回</a></p>"; 
		exit; 
	} 
} 
	 
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>添加内容</title></head> 
<body> 
<script language="JavaScript"> 
<!-- 
if(navigator.appName == "Microsoft Internet Explorer") 
{ 
    isIE=true; 
} 
else 
{ 
    isIE=false; 
} 
 
 
function AddText(NewCode)  
{ 
    if(document.all){ 
        insertAtCaret(document.myform.Content, NewCode); 
        document.myform.info.focus(); 
    } 
    else 
    { 
        document.myform.info.value += NewCode; 
        document.myform.info.focus(); 
    } 
} 
 
function insertAtCaret (textEl, text){ 
    if (textEl.createTextRange && textEl.caretPos) 
    { 
        var caretPos = textEl.caretPos; 
        caretPos.text += caretPos.text.charAt(caretPos.text.length - 2) == ' ' ? text + ' ' : text; 
    } 
    else if(textEl) 
    { 
        textEl.value += text; 
    } 
    else 
    { 
        textEl.value = text; 
    } 
} 
 
function ubbFormat(what)  
{ 
    if (document.selection && document.selection.type == "Text") 
    { 
        var range = document.selection.createRange(); 
        range.text = "["+what+"]" + range.text + "[/"+what+"]"; 
    } 
    else 
    { 
        txt=window.prompt("请输入内容","");      
        if (txt!=null) {            
                AddTxt="["+what+"]"+txt; 
                AddText(AddTxt); 
                AddText("[/"+what+"]"); 
        }        
    }  
} 
 
function ubbInsert(what)  
{ 
    if (document.selection && document.selection.type == "Text") 
    { 
        var range = document.selection.createRange(); 
        range.text = "["+what+"]" + range.text + "[/"+what+"]"; 
    } 
    else 
    { 
        txt=window.prompt("请输入内容","");      
        if (txt!=null) {            
                AddTxt="["+what+"]"+txt; 
                AddText(AddTxt); 
                AddText("[/"+what+"]"); 
        }        
    }  
} 
 
 
//--> 
</script> 
<table width="100%"  border="0" cellpadding="3" cellspacing="1" bgcolor="#DEDFDE"> 
<form name ="myform" method="post" action="add_news.php"> 
    <tr>  
      <td colspan="2" bgcolor="#f7f7f7"><div align="center"> <strong>内 容 添 加</strong></div></td> 
    </tr> 
         <tr>  
      <td bgcolor="#FFFFFF">所属菜单:</td> 
<td bgcolor="#FFFFFF"><select name="sortid"> 
<? 
   include("../db_connect.php"); 
   $result=mysql_query("select * from wap_newssort order by sortid asc",$db) or die ("query failed"); 
   while($row=mysql_fetch_row($result)) 
   { 
	 $sortid=$row[0]; 
	 $type=$row[1]; 
	 $sortname=$row[2]; 
	 $result1=mysql_query("select * from wap_news where sortid='$sortid'",$db); 
	 $num=mysql_num_rows($result1); 
	 if($num!=0 and $type==0) 
	   { 
		 // 只单页显示一条信息的菜单下内容已有时不显示其菜单 
	 } 
	 else 
	   { 
	 $chs_s = new Chinese("UTF8","GB2312",trim($sortname)); 
     $sortname = $chs_s->ConvertIT(); 
     echo "<option value=\"$row[0]\">$sortname</option>"; 
	   } 
     } 
	 mysql_close($db); 
?> 
     </select></td></tr> 
     <tr>  
      <td bgcolor="#FFFFFF">内容标题:</td> 
      <td bgcolor="#FFFFFF"><input name="title" type="text" class="input_text" id="Title" size="50"></td> 
    </tr> 
     <tr>  
      <td width="120" rowspan="2" bgcolor="#FFFFFF"><p>新闻内容:</p> 
        <p>换行请按<FONT color=#ff6600>Enter</FONT>,</p> 
		 <p>会wml的朋友</p> 
		<p>可直接填写wml代码</p> 
        <p>注意添加内容</p> 
        <p>后要记得预览.</p> 
      <td bgcolor="#FFFFFF"><img src="ubb/bold.gif" border="0" alt="粗体" onClick="ubbFormat('B')"><img src="ubb/italicize.gif" border="0" alt="斜体" onClick="ubbFormat('I')"><img src="ubb/underline.gif" border="0" alt="下划线" onClick="ubbFormat('U')"><img src="ubb/url.gif" alt="插入网址" width="23" height="22" border="0" onClick="ubbFormat('URL')"><img src="ubb/image.gif" border="0" alt="插入图片" onClick="ubbInsert('IMG')">  
      </td> 
    </tr> 
    <tr> 
      <td bgcolor="#FFFFFF"><textarea name="info" cols="90" rows="25"  class="input_text" id="Content"></textarea></td> 
    </tr> 
    <tr>  
      <td height="40" colspan="2" bgcolor="#FFFFFF"><div align="center">  
          <input type="submit" name="submit" value=" 提 交 " class="input_submit"> 
                 
          <input type="reset" name="reset" value=" 重 置 " class="input_submit"> 
        </div></td> 
    </tr> 
  </form> 
</table> 
</body></html>