本帖最后由 小义哥 于 2010-12-26 13:49 编辑
如果有人做全国的网站, 那么假如 你的地段多了
用原来的 DZX 自己的城市 修改页面 恐怕 要卡死 可能同时输出 上W条记录 ....更新一个 既是更新全部 很郁闷
下面我发一段 管理城市的代码 可单一 更新 和查看 避免大卡
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <?php
- include('config/config_global.php'); //加载数据库配置
- $dbhost=$_config['db']['1']['dbhost'];
- $dbuser=$_config['db']['1']['dbuser'];
- $dbpw=$_config['db']['1']['dbpw'];
- $dbname=$_config['db']['1']['dbname'] ;
- $tablepre=$_config['db']['1']['tablepre'];
- $dbcharset = 'utf8'; // MySQL 字符集, 可选 'gbk', 'big5', 'utf8', 'latin1', 留空为按照论坛字符集设定
- $charset = 'utf8'; // 论坛页面默认字符集, 可选 'gbk', 'big5', 'utf-8'
- /****以下代码对数据进行安全过滤,非专业人员不建议修改***************/
- $timestamp=time();
- $db=new db($dbhost,$dbuser,$dbpw,$dbname,$charset,$dbcharset);
- $city=intval($_GET['city']);
- $cityid=intval($_GET['cityid']);
- $upname=$_GET['upname'];
- $pw=$_GET['pw'];
- if($pw != "123456")
- {
- exit("密码不对啊");
- }
- ?>
- <div>
- <h1><?=$upname?></h1>
- <ul>
- <?php
- if(intval($_GET['edt']==1))
- {
- $sql="update {$tablepre}category_area set title='".$_POST['tt']."' where aid=$cityid";
- $db->query($sql);
- }
- if($city=="")
- {
- $sql="select aid,title,type,title from {$tablepre}category_area where type='city' order by aid asc";
- }
- else
- {
- $sql="select aid,title,type,title from {$tablepre}category_area where aup=$city";
- }
- $res=$db->query($sql);
- if($res)
- {
- while($row=$db->fetch_array($res))
- {
- $aid=$row['aid']
- ?>
- <form action="?&city=<?=$city?>&cityid=<?=$aid?>&edt=1&pw=<?=$pw?>&upname=<?=$upname?>" method="post" name="frm">
- <li><a href="?city=<?=$aid?>&pw=<?=$pw?>&upname=<?=$row['title']?>"><?=$row['title']?></a><input name="tt" value="<?=$row['title']?>" id="tt"/>
- <input type="submit" name="bt" value="更新"/></li>
- </form>
- <?php
- }
- }
- ?>
- </ul>
- </div>
- <?
- /*当前为数据库操作类库*/
- class db {
- var $mlink;
- function db($dbhost, $dbuser, $dbpw, $dbname = '',$charset='gbk',$dbcharset='gbk', $pconnect=0){
- if($pconnect){
- if(!$this->mlink = @mysql_pconnect($dbhost, $dbuser, $dbpw)){
- $this->halt('Can not connect to MySQL');
- }
- } else {
- if(!$this->mlink = @mysql_connect($dbhost, $dbuser, $dbpw)){
- $this->halt('Can not connect to MySQL');
- }
- }
- if($this->version()>'4.1'){
- if('utf-8'==strtolower($dbcharset)){
- $dbcharset='utf8';
- }
- if($dbcharset){
- mysql_query("SET character_set_connection=$dbcharset, character_set_results=$dbcharset, character_set_client=binary", $this->mlink);
- }
- if($charset){
- mysql_query("SET $charset", $this->mlink);
- }
- if($this->version() > '5.0.1'){
- mysql_query("SET sql_mode=''", $this->mlink);
- }
- }
- if($dbname){
- mysql_select_db($dbname, $this->mlink);
- }
- }
- function select_db($dbname){
- return mysql_select_db($dbname, $this->mlink);
- }
- function get_array($sql){
- $list = array();
- $query=$this->query($sql);
- while($row=$this->fetch_array($query)){
- $list[]=$row;
- }
- return $list;
- }
- function fetch_array($query, $result_type = MYSQL_ASSOC){
- return (is_resource($query))? mysql_fetch_array($query, $result_type) :false;
- }
- function result_first($sql){
- $query = $this->query($sql);
- return $this->result($query, 0);
- }
- function fetch_first($sql){
- $query = $this->query($sql);
- return $this->fetch_array($query);
- }
- function fetch_total($table,$where='1'){
- return $this->result_first("SELECT COUNT(*) num FROM ".DB_TABLEPRE."$table WHERE $where");
- }
- function query($sql, $type = ''){
- global $mquerynum;
- $func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query';
- if(!($query = $func($sql, $this->mlink)) && $type != 'SILENT'){
- $this->halt("MySQL Query Error",'TRUE',$sql);
- }
- $mquerynum++;
- return $query;
- }
- function affected_rows(){
- return mysql_affected_rows($this->mlink);
- }
- function error(){
- return (($this->mlink) ? mysql_error($this->mlink) : mysql_error());
- }
- function errno(){
- return intval(($this->mlink) ? mysql_errno($this->mlink) : mysql_errno());
- }
- function result($query, $row){
- $query = @mysql_result($query, $row);
- return $query;
- }
- function num_rows($query){
- $query = mysql_num_rows($query);
- return $query;
- }
- function num_fields($query){
- return mysql_num_fields($query);
- }
- function free_result($query){
- return mysql_free_result($query);
- }
- function insert_id(){
- return ($id = mysql_insert_id($this->mlink)) >= 0 ? $id : $this->result($this->query('SELECT last_insert_id()'), 0);
- }
- function fetch_row($query){
- $query = mysql_fetch_row($query);
- return $query;
- }
- function fetch_fields($query){
- return mysql_fetch_field($query);
- }
- function version(){
- return mysql_get_server_info($this->mlink);
- }
- function close(){
- return mysql_close($this->mlink);
- }
- function halt($msg, $debug=true, $sql=''){
- @ini_set("date.timezone","Asia/Shanghai");
- $output .="<html>\n<head>\n";
- $output .="<meta http-equiv="Content-Type" content="text/html; charset=".$charset."">\n";
- $output .="<title>$msg</title>\n";
- $output .="</head>\n<body><table>";
- $output .="<b>MySql Error Info</b><table><tr><td width='100px'><b>Message</b></td><td>$msg</td></tr>\n";
- $output .="<tr><td><b>Time</b></td><td>".date("Y-m-d H:i:s")."<br /></td></tr>\n";
- $output .="<tr><td><b>Script</b></td><td> ".$_SERVER['PHP_SELF']."<br /></td></tr>\n\n";
- $output .="<tr><td><b>SQL</b></td><td> ".$sql."<br />\n</td></tr><tr><td><b>Error</b></td><td> ".$this->error()."</td></tr><br />\n";
- $output .="<tr><td><b>Errno.</b></td><td> ".$this->errno().".".$did."</td></tr></table>";
- $output .="\n</body></html>";
- echo $output;
- exit();
- }
- }
- ?>
复制代码
随便 保存一个文件 技术要有自己密码哦
传到跟目录 /area.php?pw=123456 级的要改成级自己的 这个有点危险呵呵
|