php域名转发,php 域名转发程序
php 域名轉(zhuǎn)發(fā)程序是我從其它地方看到了,通過xml與php交換實現(xiàn)的,下面我們來看看源文件吧。
1
test.domain.com
http://www.111cn.net/to>
index.php文件。
處理文件
$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 ''."n";
?>
域名添加
域名轉(zhuǎn)向添加
域名添加
域名:
http://
不用加“http://”
轉(zhuǎn)向:
前面添加“http://”或“https://”等
提交
http://'.$value->domain.'跳轉(zhuǎn)到'.$value->to.' >刪除
$i++;
}
}
?>
本文原創(chuàng)發(fā)布php中文網(wǎng),轉(zhuǎn)載請注明出處,感謝您的尊重!
總結(jié)
以上是生活随笔為你收集整理的php域名转发,php 域名转发程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php oo,OO思想之PHP之三大特性
- 下一篇: php随机获取文件夹,php从文件夹随机