php 域名转发程序
php 域名转发程序是我从其它地方看到了,通过xml与php交换实现的,下面我们来看看源文件吧。
<?xml version="1.0" encoding="utf-8"?>
<urls>
<num>1</num>
<url id="1">
<domain>test.domain.com</domain>
<to>http://www.111cn.net/to>
</url>
</urls>
index.php文件。
<?php
/*
域名伪跳转方案
By IVershuo.cn
*/
header("content-type:text/html; charset=utf-8");
$xml = simplexml_load_file("url.xml"); //xml文件路径
$to = 'http://www.111cn.net'; //默认跳转地址
foreach ($xml as $key => $value) {
if($value->domain == $_SERVER['SERVER_NAME']) {
$to = $value->to;
break;
}
}
header('Location: '.$to);
?>
处理文件
<?php
/*
域名伪跳转方案,域名跳转配置脚本
###注意:没设置验证可配置,使用时请修改该文件名和xml文件名!!!
By IVershuo.cn
*/
$xmlFile = 'url.xml'; //xml文件的路径
$xml = simplexml_load_file($xmlFile);
$num = $xml->num[0];
if (@$_POST['domain'] && $_POST['to']) {
$xmlUrl = $xml->addChild('url');
$xmlUrl->addAttribute('id',$num+=1);
$xmlUrl->addChild('domain',$_POST['domain']);
$xmlUrl->addChild('to',$_POST['to']);
$xml->num[0] = $num;
}
if (@$_GET['del']) {
removeNode($xml, "//url[@id='".$_GET['del']."']", 'all');
$xml->num[0] = $num;
}
$sp = fopen($xmlFile,"wb");
fwrite($sp,$xml->asXML());
fclose($sp);
function removeNode($xml, $path, $multi='one'){
$result = $xml->xpath($path);
# for wrong $path
if (!isset($result[0])) return false;
switch ($multi) {
case 'all':
$errlevel = error_reporting(E_ALL & ~E_WARNING);
foreach ($result as $r) unset ($r[0]);
error_reporting($errlevel);
return true;
case 'child':
unset($result[0][0]);
return true;
case 'one':
if (count($result[0]->children())==0 && count($result)==1) {
unset($result[0][0]);
return true;
}
default:
return false;
}
}
echo '<?xml version="1.0" encoding="utf-8"?>'."n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>域名添加</title>
<meta name="author" content="阿肆|IVershuo.cn" />
<style type="text/css">
label {display:block;margin:10px 0;}
input {width:300px;}
label span {color:#666;}
</style>
<script type="text/javascript" src=""></script>
</head>
<body>
<h1>域名转向添加</h1>
<div>
<form action="<?=$_SERVER ['PHP_SELF']?>" method="post">
<fieldset>
<legend>域名添加</legend>
<label for="domain">
域名:
http://<input type="text" name="domain" id="domain" />
<span>不用加“http://”</span>
</label>
<label for="to">
转向:
<input type="text" name="to" id="to" value="http://" />
<span>前面添加“http://”或“https://”等</span>
</label>
<button type="submit">提交</button>
</fieldset>
</form>
</div>
<div>
<ul id="listed">
<?php
$i=0;
foreach ($xml as $key => $value) {
if($key == 'url') {
echo '<li><em>http://'.$value->domain.'</em>跳转到<a href="'.$value->to.'">'.$value->to.'</a> <a href="'.$_SERVER ['PHP_SELF'].'?del='.$xml->url[$i]['id'].'">>删除<</a></li>';
$i++;
}
}
?>
<script type="text/javascript">
var li=document.getElementById('listed').getElementsByTagName('li');
for (var i=0,l=li.length;i<l ;i++ ) {
li[i].getElementsByTagName('a')[1].onclick=function () {
var u = this.parentNode.getElementsByTagName('em')[0].innerHTML;
if (confirm ('确定要删除 '+u+' 的转向?')) {
return true;
} else {
return false;
}
}
}
</script>
</ul>
</div>
</body>
</html>
php 修复表与优化数据表
//--------------------------修复表
function Ebak_Rep($tablename,$dbname){
global $empire;
$dbname=RepPostVar($dbname);
$empire->query("use `$dbname`");
$count=count($tablename);
if(empty($count))
{
printerror("EmptyChangeTb","history.go(-1)");
}
for($i=0;$i<$count;$i++)
{
$sql1=$empire->query("REPAIR TABLE `$tablename[$i]`;");
}
printerror("RepairTbSuccess","ChangeTable.php?mydbname=$dbname");
}
//--------------------------忧化表
function Ebak_Opi($tablename,$dbname){
global $empire;
$dbname=RepPostVar($dbname);
$empire->query("use `$dbname`");
$count=count($tablename);
if(empty($count))
{
printerror("EmptyChangeTb","history.go(-1)");
}
for($i=0;$i<$count;$i++)
{
$sql1=$empire->query("OPTIMIZE TABLE `$tablename[$i]`;");
}
printerror("OptimizeTbSuccess","ChangeTable.php?mydbname=$dbname");
}
<?php function ff_page($content,$page)
{
global $expert_id;
$PageLength = 2000; //每页字数
$CLength = strlen($content);
$PageCount = floor(($CLength / $PageLength)) + 1; //计算页数
$PageArray=array();
$Seperator = array("n","r","。","!","?",";",",","”","'"); //分隔符号
//echo "页数:".$PageCount."<br>";
//echo "长度:".$CLength."<br><br><br>";
//strpos() 函数返回字符串在另一个字符串中第一次出现的位置
if($CLength<$PageLength)
{
echo $content;
}else{
$PageArray[0]=0;
$Pos = 0;
$i=0;
//第一页
for($j=0;$j<sizeof($Seperator);$j++)
{
//echo $Seperator[$j];
$Pos=strpos($content,$Seperator[$j],$PageArray[$i]+1900);
while($Pos > 0 && $Pos < ($i+1)*$PageLength && $Pos > $i*$PageLength )
{
$PageArray[$i] = $Pos ;
$Pos = strpos($Pos+$PageLength,$content,$Seperator[$j]) ;
}
if($PageArray[$i]>0)
{
$j = $j + sizeof($Seperator) + 1;
}
}
//---
for($i=1;$i<$PageCount-1;$i++){
for($j=0;$j<sizeof($Seperator);$j++)
{
//echo $Seperator[$j];
$Pos=strpos($content,$Seperator[$j],$PageArray[$i-1]+1900);
while($Pos > 0 && $Pos < ($i+1)*$PageLength && $Pos > $i*$PageLength )
{
$PageArray[$i] = $Pos ;
$Pos = strpos($Pos+$PageLength,$content,$Seperator[$j]) ;
}
if($PageArray[$i]>0)
{
$j = $j + sizeof($Seperator) + 1;
}
}
}
//--最后一页
$PageArray[$PageCount-1]=$CLength;
//$page=2;
if($page==1)
{
$output=substr($content,0,$PageArray[$page-1]+2);
}
if($page>1 && $page<=$PageCount)
{
$output=substr($content,$PageArray[$page-2]+2,$PageArray[$page-1]-$PageArray[$page-2]);
$output=" (上接第".($page-1)."页)n".$output;
}
echo str_replace("n","<br> ",$output);
//if($page==$PageCount)
//return $output=substr($content,$PageArray[$page-2]+2,$PageArray[$page-1]-$PageArray[$page-2]);
if($PageCount>1)
{
echo "<br><br><br><center>";
echo "<font color='ff0000'>".$page."</font>/".$PageCount." 页 ";
if($page>1)
echo "<a href=$PHP_SELF?expert_id=$expert_id&page_t=".($page-1).">上一页</a> ";
else
echo "上一页 ";
for($i=1;$i<=$PageCount;$i++)
{
echo "<a href=$PHP_SELF?expert_id=$expert_id&page_t=".$i.">[".$i."]</a> ";
}
if($page<$PageCount)
echo " <a href=$PHP_SELF?expert_id=$expert_id&page_t=".($page+1).">下一页</a> ";
else
echo " 下一页 ";
echo "</center>";
}
}
}?>
<?php
$content1=''测试文字,尽量长一些,www.111cn.net";
$current=$_REQUEST['page_t'];
$result=ff_page($content1,$current);
echo $result;
?>
<?php
/**
*通过phpmailer发送qq邮件
*@author ray
*@since 2009-08-07
*/
define('__DEBUG__', false);
define('__PSW_FILE__', dirname(__FILE__) . '/smtp.dat');
define('SLEEPING_EMAIL', dirname(__FILE__) . "/sleepMail.dat");//休眠的email
define('SLEEPING_TIME', 1800);//休眠多长时间,以秒为单位
define('FILE_APPEND', 1);
if (!function_exists('file_put_contents')) {
function file_put_contents($n, $d, $flag = false) {
$mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
$f = @fopen($n, $mode);
if ($f === false) {
return 0;
} else {
if (is_array($d)) $d = implode($d);
$bytesWritten = fwrite($f, $d);
fclose($f);
return $bytesWritten;
}
}
}
$errorNo = 0;
$errorMsg = '';
$currTime = time();
$unuseMails = array();
//收件人和邮件标题和邮件内容
$to = isset($argv[1]) ? $argv[1] : "" ;
$subject = isset($argv[2]) ? $argv[2] : "";
$mailFile = isset($argv[3]) ? $argv[3] : "" ;
if (__DEBUG__) {
echo "
file:$mailFile to:$to subject:$subjectrn";
}
if (empty($mailFile) || empty($to) || empty($subject)) {
$errorNo = 1;
$errorMsg = "参数不全";
}
//加载不可用的email列表
if (!$errorNo) {
if (file_exists(SLEEPING_EMAIL)) {
$sleepMails = file(SLEEPING_EMAIL);
if (!empty($sleepMails)) {
foreach($sleepMails as $sleepMail) {
//解析
if (false !== strpos($sleepMail, '|')) {
$tmp = explode('|', $sleepMail);
if (isset($tmp[0]) && isset($tmp[1])) {
$mail = trim($tmp[0]);
$time = trim($tmp[1]);
//是否可用
if ( ($currTime - $time )< SLEEPING_TIME) {
$unuseMails[] = $mail;
}
}
}
}
}
}
}
if (!$errorNo) {
//随机加载smtp服务器和smtp用户名和密码
$info = file(__PSW_FILE__);
$len = count($info);
do {
$rnd = mt_rand(0, $len - 1);
$line = isset($info[$rnd]) ? $info[$rnd] : "";
if (false !== strpos($line, '|')) {
$tmp = explode('|', $line);
if (isset($tmp[0]) && isset($tmp[1]) && isset($tmp[2])) {
$smtpServer = trim($tmp[0]);
$fromMail = trim($tmp[1]);
$psw = trim($tmp[2]);
$smtpUserName = substr($fromMail, 0, strrpos($fromMail, '@'));
}
}
}while (in_array($fromMail, $unuseMails));//如果在不可用的列表中,在次加载
if (!isset($smtpServer) || !isset($fromMail) || !isset($psw)) {
$errorNo = 2;
$errorMsg = "没找到发件人QQ信箱和密码";
}
}
if (!$errorNo && __DEBUG__) {
echo "smtp:$smtpServer from:$fromMail psw:$psw user:$smtpUserNamern";
}
if (!$errorNo) {
//通过phpmailer连接smtp服务器发信
require(dirname(__FILE__) . "/phpmailer/class.phpmailer.php");
require(dirname(__FILE__) . "/phpmailer/class.smtp.php");
$mail = new PHPMailer();
$body = $mail->getFile($mailFile);
$body = eregi_replace("[]",'',$body);
//charset
$mail->CharSet = "GB2312";
//$mail->SMTPDebug = 2;//用于显示具体的smtp错误
$mail->IsSMTP();
$mail->SMTPAuth = true;
if ("smtp.qq.com" == trim($smtpServer)) {
$mail->Username = $fromMail;
} else {
$mail->Username = $smtpUserName;
}
$mail->Password = $psw;
$mail->Host = $smtpServer;
$mail->From = $fromMail;
$mail->FromName = "晴天网络";
$mail->IsHTML(true);
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $body;
if (!$mail->Send()) {
// echo "Message could not be sent. ";
$errorNo = 3;
$errorMsg = $mail->ErrorInfo;
} else {
echo "
Send to $to success use $fromMailrn";
exit;
}
}
if (3 == $errorNo) {
//记录信息,该信息地址休眠N分钟
$content = "$fromMail|" . time() . "rn";//email|当前时间戳
file_put_contents(SLEEPING_EMAIL, $content, FILE_APPEND);
}
echo "
Error No($errorNo) " . $errorMsg . "rn";
exit;
?>
define('IN_UCHOME','asdfasdf');
// 加载dzhome的基本配置文件
include .'/home/data/data_config.php';
// 生成防伪
$action_login = md5('login'.md5($_SCONFIG['sitekey']));
$action_register = md5('register'.md5($_SCONFIG['sitekey']));
$action_formhash = substr(md5(substr(time(), 0, -7).'|0|'.md5($_SCONFIG['sitekey']).'|'.$hashadd), 8, 8);
echo '
<script>
var loginNum = "',($action_login = md5('login'.md5($_SCONFIG['sitekey']))),'";
var registerNum = "',($action_register = md5('register'.md5($_SCONFIG['sitekey']))),'";
var formhashNum = "',($action_formhash = substr(md5(substr(time(), 0, -7).'|0|'.md5($_SCONFIG['sitekey']).'|'.$hashadd), 8, 8)),'"
</script>
<ul class="login">
<form name="loginform" action="/home/do.php?ac=',$action_login,'&&ref" method="post">
<input type="text" name="username" size="10" value="用户名">
<input type="text" name="password" size="9" value="密码">
<input type="hidden" name="refer" value="space.php?do=home" />
<input type="hidden" name="formhash" value="',$action_formhash,'">
<input type="submit" value="登陆" class="int" name="loginsubmit">
<input type="button" name="regbutton" class="int" value="注册" class="button">
<input type="button" value="忘记密码" class="int" >
</ul>
</form>
相关文章
- 这篇文章主要介绍了C#开发Windows窗体应用程序的简单操作步骤,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-04-12
- 本文通过例子,讲述了C++调用C#的DLL程序的方法,作出了以下总结,下面就让我们一起来学习吧。...2020-06-25
- 这篇文章主要介绍了源码分析系列之json_encode()如何转化一个对象,对json_encode()感兴趣的同学,可以参考下...2021-04-22
- PHP去除html、css样式、js格式的方法很多,但发现,它们基本都有一个弊端:空格往往清除不了 经过不断的研究,最终找到了一个理想的去除html包括空格css样式、js 的PHP函数。...2013-08-02
- 本文通过两个示例讲解了一下Process类调用外部应用程序的基本用法,并简单讲解了StartInfo属性,有需要的朋友可以参考一下。...2020-06-25
- 这篇文章主要介绍了微信小程序 页面传值详解的相关资料,需要的朋友可以参考下...2017-03-13
- 大概有如下步骤 新建项目Bejs 新建文件package.json 新建文件Gruntfile.js 命令行执行grunt任务 一、新建项目Bejs源码放在src下,该目录有两个js文件,selector.js和ajax.js。编译后代码放在dest,这个grunt会...2014-06-07
- index.php怎么打开?初学者可能不知道如何打开index.php,不会的同学可以参考一下本篇教程 打开编辑:右键->打开方式->经文本方式打开打开运行:首先你要有个支持运行PH...2017-07-06
- 这篇文章主要介绍了uniapp微信小程序:key失效的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-20
- 本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
将c#编写的程序打包成应用程序的实现步骤分享(安装,卸载) 图文
时常会写用c#一些程序,但如何将他们和photoshop一样的大型软件打成一个压缩包,以便于发布....2020-06-25PHP中func_get_args(),func_get_arg(),func_num_args()的区别
复制代码 代码如下:<?php function jb51(){ print_r(func_get_args()); echo "<br>"; echo func_get_arg(1); echo "<br>"; echo func_num_args(); } jb51("www","j...2013-10-04- 这篇文章主要介绍了微信小程序 网络请求(GET请求)详解的相关资料,需要的朋友可以参考下...2016-11-22
- 这篇文章主要给大家介绍了关于微信小程序如何获取图片宽度与高度的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-10
- 这篇文章主要为大家详细介绍了微信小程序自定义tabbar组件,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-03-14
- 这篇文章主要介绍了微信小程序 二维码生成工具 weapp-qrcode详解,教大家如何在项目中引入weapp-qrcode.js文件,通过实例代码给大家介绍的非常详细,需要的朋友可以参考下...2021-10-23
- 这篇文章主要介绍了PHP编程 SSO详细介绍及简单实例的相关资料,这里介绍了三种模式跨子域单点登陆、完全跨单点域登陆、站群共享身份认证,需要的朋友可以参考下...2017-01-25
- 这篇文章主要介绍了Python爬取微信小程序通用方法代码实例详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-09-29
- 这篇文章主要介绍了微信小程序(应用号)开发新闻客户端实例的相关资料,需要的朋友可以参考下...2016-10-25
详解nginx同一端口监听多个域名和同时监听http与https
这篇文章主要介绍了详解nginx同一端口监听多个域名和同时监听http与https的相关资料,需要的朋友可以参考下...2017-07-06