發布新聞'; } $error_msg=$news_list=""; $uname=isset($_POST['uname'])?$_POST['uname']:""; $passwd=isset($_POST['passwd'])?$_POST['passwd']:""; /*----流程控制----*/ switch ($op) { case 'db_error': $error_msg=error_msg("資料庫連線錯誤!!請檢查資料庫帳號、密碼是否正確!"); break; case 'view': //列出單一內容 $news_list=view($sn); $toolbar.=" 回新聞列表"; break; case 'delete': //刪除單一內容 delete($sn); header("location: {$_SERVER['PHP_SELF']}"); break; case 'login': //登入 login($uname,$passwd); header("location: {$_SERVER['PHP_SELF']}"); break; case 'logout': //登出 logout(); header("location: {$_SERVER['PHP_SELF']}"); break; default: //列出所有內容 $news_list=list_news(); break; } /*----輸出----*/ show_page('list_tpl'); /*----所有函數----*/ function login($uname,$passwd){ link_db(); $passwd=md5($passwd); $sql="select uid from eznews_users where uname='$uname' and passwd='$passwd'"; $result=mysql_query($sql) or die("{$sql}".mysql_error()); list($uid)=mysql_fetch_row($result); if(!empty($uid)){ $_SESSION['uid']=$uid; $_SESSION['uname']=$uname; } } //登出 function logout(){ unset($_SESSION['uid']); unset($_SESSION['uname']); } //列出所有內容 function list_news(){ global $g2p; include_once "PageBar.php"; link_db(); //讀取eznews資料表所有欄位(日期大到小排列) //$sql="select * from eznews order by post_time desc"; $sql="select a.*,b.cate_title from eznews as a left join eznews_cate as b on a.cate_sn=b.cate_sn order by a.status='置頂' desc, a.post_time desc"; $PageBar = new PageBar($sql, 10); $bar_arr=$PageBar->makeBar(); $sql=$bar_arr['sql']; $bar=$bar_arr['bar']; //傳回值存到 $result 以供抓取資料用 $result=mysql_query($sql) or die("{$sql}".mysql_error()); $tools_title=""; if(isset($_SESSION['uid']) and !empty($_SESSION['uid'])){ $tools_title=" 功能 "; } $news_list=" 列出所有新聞 $bar
進階搜尋
50人線上 (17人在瀏覽線上書籍)
會員: 0
訪客: 50