您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > PHP单用户微博程序源码整理
1单用户微博程序源码数据库结构(共三张表:w_comment、w_log、w_online)主页index.php源码?phperror_reporting(E_ALL);date_default_timezone_set('PRC');session_start();header(content-type:text/html;charset=utf-8);@set_magic_quotes_runtime(0);if(@get_magic_quotes_gpc()){//移除反斜杠functionrs($s){if(is_array($s)){foreach($sas$k=$v)$s[$k]=rs($v);}else{$s=stripslashes($s);}return$s;}2$_GET=rs($_GET);$_POST=rs($_POST);$_COOKIE=rs($_COOKIE);}/*=======系统配置开始=======*/$db_host='localhost';//MYSQL数据库服务器$db_user='root';//MYSQL数据库用户$db_password='';//MYSQL数据库用户密码$db_name='miniblog';//MYSQL数据库名称$db_prefix='w_';//MYSQL数据表前缀$rewrite=false;//是否开启路径重写规则$rewrite_ext='html';//重写文件名后缀$password='admin';//管理登录密码$online_overtime=30;//在线记录超时时间间隔(分钟)/*=======系统配置结束=======*///检查是否非法提交functioncheck_request(){if(empty($_SERVER['HTTP_REFERER'])||(preg_replace(/https?:\/\/([^\:\/]+).*/i,\\1,$_SERVER['HTTP_REFERER'])!=preg_replace(/([^\:]+).*/,\\1,$_SERVER['HTTP_HOST']))){exit('AccessDenied!');}}//过滤非法字符functionfilter_badwords($content,$badwords){$words=explode(,,$badwords);$words_count=count($words);$words_tmep=$content;for($i=0;$i$words_count;$i++){$replace_tmep=explode(=,$words[$i]);$words_tmep=str_replace($replace_tmep[0],$replace_tmep[1],$words_tmep);}return$words_tmep;}//获取当前文件名functionget_self(){returnisset($_SERVER['PHP_SELF'])?$_SERVER['PHP_SELF']:$_SERVER['SCRIPT_NAME'];}//获取IPfunctionget_ip(){if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];}elseif(isset($_SERVER['HTTP_CLIENT_IP'])){$ip=$_SERVER['HTTP_CLIENT_IP'];}else{$ip=$_SERVER['REMOTE_ADDR'];}return$ip;}//从IP.CN获取IP物理地址functionget_ip_address($ip){if($ip=='127.0.0.1')return'IP:'.$ip.'来自:本地';$content=@file_get_contents(=queryip&ip_url=.$ip);returnstr_replace(您查询的IP是,IP,iconv(GB2312,UTF-8//IGNORE,$content));}//格式化日期时间functionformat_datetime($time){3$now=time()-$time;if($now60){return$now.'秒前';}elseif($now3600){returnintval($now/60).'分钟前';}elseif($now86400){returnintval($now/3600).'小时前';}else{returndate('Y-m-dH:i:s',$time);}}//分页程序functionpager($page_name,$page_parameters='',$page_current,$page_size,$log_count){global$config;parse_str($page_parameters);$page_count=ceil($log_count/$page_size);$page_start=$page_current-2;$page_end=$page_current+2;if($page_current3){$page_start=1;$page_end=3;}if($page_current$page_count-2){$page_start=$page_count-4;$page_end=$page_count;}if($page_start1)$page_start=1;if($page_end$page_count)$page_end=$page_count;$html=;$html.=divid=\pager\;//$html.=spanclass=\info\RecordCount:.$log_count./span\n;$html.=spanclass=\info\.$page_current./.$page_count./span;if($page_current!=1){if($GLOBALS['rewrite']){$html.=ahref='index-1..$GLOBALS['rewrite_ext'].'«/a;}else{$html.=ahref='.$page_name..php?.$page_parameters.page=1'«/a;}}for($i=$page_start;$i=$page_end;$i++){if($i==$page_current){$html.=ahref=\#\class=\hover\.$i./a;}else{if($GLOBALS['rewrite']){$html.=ahref='index-.$i...$GLOBALS['rewrite_ext'].'.$i./a;}else{$html.=ahref='.$page_name..php?.$page_parameters.page=.$i.'.$i./a;}}}if($page_current!=$page_count){if($GLOBALS['rewrite']){$html.=ahref='index-.$page_count...$GLOBALS['rewrite_ext'].'»/a;}else{$html.=a4href='.$page_name..php?.$page_parameters.page=.$page_count.'»/a;}}$html.=/div;return$html;}//获取操作系统functionget_os(){$AGENT=$_SERVER[HTTP_USER_AGENT];if(strpos($AGENT,WindowsNT5.0))$os=Windows2000;elseif(strpos($AGENT,WindowsNT5.1))$os=WindowsXP;elseif(strpos($AGENT,WindowsNT5.2))$os=Windows2003;elseif(strpos($AGENT,WindowsNT6.0))$os=WindowsVista;elseif(strpos($AGENT,WindowsNT6.1))$os=Windows7;elseif(strpos($AGENT,WindowsNT))$os=WindowsNT;elseif(strpos($AGENT,WindowsCE))$os=WindowsCE;elseif(strpos($AGENT,ME))$os=WindowsME;elseif(strpos($AGENT,Windows9))$os=Windows98;elseif(strpos($AGENT,unix))$os=Unix;elseif(strpos($AGENT,linux))$os=Linux;elseif(strpos($AGENT,SunOS))$os=SunOS;elseif(strpos($AGENT,OpenBSD))$os=OpenBSD;elseif(strpos($AGENT,FreeBSD))$os=FreeBSD;elseif(strpos($AGENT,AIX))$os=AIX;elseif(strpos($AGENT,Mac))$os=Mac;else$os=Other;return$os;}//获取浏览器functionget_bs(){$AGENT=$_SERVER[HTTP_USER_AGENT];if(strpos($AGENT,Opera))$bs=Opera;elseif(strpos($AGENT,Firefox))$bs=Firefox;elseif(strpos($AGENT,Chrome))$bs=Chrome;elseif(strpos($AGENT,MSIE6))$bs=IE6;elseif(strpos($AGENT,MSIE7))$bs=IE7;elseif(strpos($AGENT,MSIE8))$bs=IE8;else$bs=Other;return$bs;}//获取在线信息functionset_online(){if($GLOBALS['db']-getcount(select*from.$GLOBALS['db_prefix'].onlinewhereonlineip='.get_ip().')0){$sql=update.$GLOBALS['db_prefix'].onlinesetonlinetime='.$_SERVER['REQUEST_TIME'].',onlineagent='.get_os()./.get_bs().'whereonlineip='.get_ip().';}else{$sql=insertinto.$GLOBALS['db_prefix'].online(onlinetime,onlineip,onlineagent)values('.$_SERVER['REQUEST_TIME'].','.get_ip().','.get_os()./.get_bs().');;}$GLOBALS['db']-query($sql);$GLOBALS['db']-delete(.$GLOBALS['db_prefix'].online,onlinetimeUNIX_TIMESTAMP(NOW())-.($GLOBALS['online_overtime']*60).);}5//db类classdb{var$db_link=null
本文标题:PHP单用户微博程序源码整理
链接地址:https://www.777doc.com/doc-3380504 .html