View file reg.php

File size: 8.66Kb
<?php
// MyForum - Сервис форумов
// Copyright Р’© A'lex Рё KO. All Rights Reserved
// РџРѕ всем вопросам обращайтесь РЅР° email [email protected] или РІ асю 376920428

include 'config.php';

if (!$RegEnabled) {exit;}
$date = date('j.n G:i');
$rdate = date('j.m.Y');


function displayWML($caption, $title, $body, $end)
{
header('Content-Type: text/vnd.wap.wml; charset=utf-8');

$caption = ereg_replace("&#39;","'",$caption);
$title = ereg_replace("&#39;","'",$title);
$body = ereg_replace("&#39;","'",$body);
$end = ereg_replace("&#39;","'",$end);

$title = ereg_replace('&','&amp;',$title);
$body = ereg_replace('&','&amp;',$body);
$body = ereg_replace('$','$$',$body);
$body = substr($body, 0, strrpos($body, '$'));
$body = substr($body, 0, strrpos($body, '$'));
$body = ereg_replace('<dol>','$',$body);

$end = ereg_replace('&','&amp;',$end);

echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"><wml><head><meta forua="true" http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate"/></head>';
echo "<card id=\"c1\" title=\"$caption\">";
$caption = ereg_replace('&','&amp;',$caption);

echo '<p align="left">' . $title . '</p>';
echo '<p align="center">------</p>';
echo '<p align="left">' . $body . '</p>';
echo '<p align="center">------</p>';
echo '<p align="left">' . $end . '</p>';
echo '</card></wml>';
}


function displayHTML($caption, $title, $body, $end)
{
header('Content-Type: text/html; charset=utf-8');
$caption = ereg_replace("&#39;","'",$caption);
$title = ereg_replace("&#39;","'",$title);
$body = ereg_replace("&#39;","'",$body);
$end = ereg_replace("&#39;","'",$end);

$title = ereg_replace('&','&amp;',$title);
$body = ereg_replace('&','&amp;',$body);
$end = ereg_replace('&','&amp;',$end);

$caption = ereg_replace("&amp;nbsp;","&nbsp;",$caption);
$title = ereg_replace("&amp;nbsp;","&nbsp;",$title);
$body = ereg_replace("&amp;nbsp;","&nbsp;",$body);
$end = ereg_replace("&amp;nbsp;","&nbsp;",$end);

$res=<<<END
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta forua="true" http-equiv="Cache-Control" content="no-cache,no-store,must-revalidate"/><title>$caption</title></head>
<body bgcolor="#0598AD" link="#917E35" vlink="#917E35" text="#000000">
<table align="center" border="0" cellspacing="1" cellpadding="5" width="500">
<tr><td bgcolor="#023339" align="center"><font color="#ffffff"><b>$caption</b></font></td></tr>
<tr><td bgcolor="#79EBFB">$title</td></tr>
<tr><td bgcolor="#C3F6FD">$body</td></tr>
<tr><td bgcolor="#79EBFB">$end</td></tr></table>
</body></html>
END;
echo $res;
}

function displaytext($caption, $title, $body, $end, $w)
{
if ($w=='html') {
displayHTML($caption, $title, $body, $end);
}
if ($w=='wml') {
displayWML($caption, $title, $body, $end);
}
if ($w==FALSE) {
$tp = $_SERVER['HTTP_ACCEPT'];
$user = $_SERVER["HTTP_USER_AGENT"];
if (strstr($user,'Mozilla') || strstr($user,'Opera')) {
displayHTML($caption, $title, $body, $end);
} else {
displayWML($caption, $title, $body, $end);
}
}
}
function getwmode($w)
{
if ($w=='html') {
$wmode = 'html';
}
if ($w=='wml') {
$wmode = 'wml';
}
if ($w==FALSE) {
$tp = $_SERVER['HTTP_ACCEPT'];
$user = $_SERVER["HTTP_USER_AGENT"];
if (strstr($user,'Mozilla') || strstr($user,'Opera')) {
$wmode = 'html';
} else {
$wmode = 'wml';
}
}
return $wmode;
}

function randstr($length = 8) {
$a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for($i=0; $i<$length; $i++) $ret .= substr($a, rand(0, strlen($a)), 1);
return $ret;
}

//-----------------------------------------------------------------------------------------------

$wmode=getwmode($w);

$formhtml=<<<END
<form action="reg.php" method="post">
<input type="hidden" name="mode" value="reg"/>
Nick:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="nick" cols="60"/></td></tr>
<tr><td bgcolor="#C3F6FD">
Пароль:&nbsp;<input type="password" name="pass" cols="60"/></td></tr>
<tr><td bgcolor="#C3F6FD">
Email:&nbsp;<input type="text" name="email" cols="60"/></td></tr>
<tr><td bgcolor="#C3F6FD">
Сайт:&nbsp;http://<input type="text" name="site" cols="60"/></td></tr>
<tr><td bgcolor="#79EBFB"><p align="center">
<input type="submit" name="submit" value="Регестрация"/></p>
</form>
END;


$formwml=<<<END
Nick: <input type="text" name="nick"/><br/>
Пароль: <input type="password" name="pass"/><br/>
Email: <input type="text" name="email"/><br/>
Сайт: http://<input type="text" name="site"/><br/>
<anchor>OK<go href="reg.php" accept-charset="UTF-8" method="post">
<postfield name="mode" value="reg"/>
<postfield name="nick" value="<dol>(nick)"/>
<postfield name="pass" value="<dol>(pass)"/>
<postfield name="email" value="<dol>(email)"/>
<postfield name="site" value="<dol>(site)"/>
</go></anchor>
END;

if ($mode==FALSE) {
if ($wmode=='html') {
displayHTML('Регестрация', "Указывайте реальный email!", $formhtml, "<a href=\"http://wapsib.com\">WAPSIB.COM</a>");
} else {
displayWML('Регестрация', "Указывайте реальный email!", $formwml, "<a href=\"http://wapsib.com\">WAPSIB.COM</a>");
}
}

if($mode=='reg') {
$label=randstr(10);
mysql_query("INSERT INTO {$table}forums VALUES (NULL, '$label', '$email', '<a href=\"http://$site\">На главную</a>', 1, 0, 'rules.txt')");
$r = mysql_query("SELECT * FROM {$table}forums WHERE Title='$label'");
$a=mysql_fetch_array($r);
$id=$a['ID'];
mysql_query("UPDATE {$table}forums SET Title='MyForum' WHERE ID='$id'");
mysql_query("DROP TABLE `{$table}{$id}_banip`, `{$table}{$id}_bannick`, `{$table}{$id}_forums`, `{$table}{$id}_messages`, `{$table}{$id}topiks`, `{$table}{$id}_users`");
mysql_query("CREATE TABLE `{$table}{$id}_users` (`Nick` VARCHAR( 50 ) NOT NULL ,`Password` VARCHAR( 50 ) NULL DEFAULT NULL ,`BSID` VARCHAR( 8 ) NULL DEFAULT '00000000',`FSID` VARCHAR( 16 ) NULL DEFAULT '0000000000000000',`GoDate` VARCHAR( 15 ) NULL DEFAULT NULL ,`Lever` INT( 1 ) NULL DEFAULT '1',`RegisterDate` VARCHAR( 15 ) NULL DEFAULT NULL ,`PhotoURL` VARCHAR( 100 ) NULL DEFAULT NULL ,`RealName` VARCHAR( 50 ) NULL DEFAULT NULL ,`Sex` INT( 1 ) NULL DEFAULT '0',`City` VARCHAR( 30 ) NULL DEFAULT NULL ,`Mail` VARCHAR( 50 ) NULL DEFAULT NULL ,`ICQ` VARCHAR( 50 ) NULL DEFAULT NULL ,`Site` VARCHAR( 50 ) NULL DEFAULT NULL ,`Info` TEXT NULL DEFAULT NULL ,INDEX ( `Nick` ) ) TYPE = MYISAM ");
mysql_query("CREATE TABLE `{$table}{$id}_forums` (`ID` INT NOT NULL AUTO_INCREMENT ,`Title` VARCHAR( 50 ) NULL DEFAULT NULL ,`Info` TEXT NULL DEFAULT NULL ,INDEX ( `ID` ) ) TYPE = MYISAM ");
mysql_query("CREATE TABLE `{$table}{$id}_topiks` (`ID` INT( 10 ) NOT NULL AUTO_INCREMENT ,`Cop` VARCHAR( 50 ) NULL DEFAULT NULL ,`Title` VARCHAR( 255 ) NULL DEFAULT NULL ,`ForumID` INT( 10 ) NULL DEFAULT NULL ,`Date` VARCHAR( 15 ) NULL DEFAULT NULL ,`Visible` BOOL NULL DEFAULT '1',`Enabled` BOOL NULL DEFAULT '1',INDEX ( `ID` ) ) TYPE = MYISAM ");
mysql_query("CREATE TABLE `{$table}{$id}_messages` (`ID` INT( 10 ) NOT NULL AUTO_INCREMENT ,`Cop` VARCHAR( 50 ) NULL DEFAULT NULL ,`Body` TEXT NULL DEFAULT NULL ,`ForumID` INT( 10 ) NULL DEFAULT NULL ,`TopikID` INT( 10 ) NULL DEFAULT NULL ,`Date` VARCHAR( 15 ) NULL DEFAULT NULL ,`Visible` BOOL NULL DEFAULT '1',`IP` VARCHAR( 50 ) NULL DEFAULT 'no',`UserAgent` VARCHAR( 150 ) NULL DEFAULT 'all',INDEX ( `ID` ) ) TYPE = MYISAM ");
mysql_query("CREATE TABLE `{$table}{$id}_banip` (`IP` VARCHAR( 50 ) NULL DEFAULT 'no',`UserAgent` VARCHAR( 150 ) NULL DEFAULT 'all',`Date` VARCHAR( 15 ) NOT NULL ) TYPE = MYISAM ");
mysql_query("CREATE TABLE `{$table}{$id}_bannick` (`Nick` VARCHAR( 50 ) NOT NULL ,`Date` VARCHAR( 15 ) NOT NULL ,`Comment` TEXT NULL ,INDEX ( `Nick` ) ) TYPE = MYISAM ");
mysql_query("INSERT INTO {$table}{$id}_users VALUES ('$nick', '$pass', 'no', 'no', '$date', 4, '$rdate', NULL,  NULL, NULL, NULL, NULL, NULL, NULL, NULL)");
mysql_query("INSERT INTO {$table}{$id}_users VALUES ('$AdminName', '$AdminPassword', 'no', 'no', '$date', 5, '$rdate', NULL,  NULL, NULL, NULL, NULL, NULL, NULL, NULL)");
mysql_query("INSERT INTO {$table}{$id}_forums VALUES (NULL, 'Главный форум', '')");
$surl=$HTTP_SERVER_VARS[SERVER_NAME];
$forumurl="http://".$surl.$forumdir."?f=$id";
$body="Регестрация прошла успешно.<br/> Адрес вашего форума: $forumurl<br/><a href=\"login.php?f=$id&nick=$nick&pass=$pass&size=5000&mode=login\">В форум</a>";
displaytext('Регестрация', "", $body, "<a href=\"http://wapsib.com\">WAPSIB.COM</a>", $w);
}
mysql_close($lnk);
?>