Have A Little Problem

Started on the old forum in May 2008 · view the original in the archive · old links redirect here

20 replies · 1,142 views · started 18 years ago · 1 min read

3 participants
SpiderWap Lead · 622 posts #1

Ok, hear me out.

In my script im coding i want to add a code in register so folders and stuff on my surver cant be used if someone register with one of that names.

Example, if someone tries registering with the username downloads it should tell them

Name not allowed or something. heres my register page. help please?

elseif($spider=="register1")
{
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]Register[/size][/b]";
echo "</div>\n";
echo "<div align=\"center\">\n";
if($name!=""||$pass!=""){
$name = $_POST['name'];
$name= strtolower($name);
$query= ("INSERT INTO `users`
        ( `id`,
        `name` ,
        `pass`,
        `rtime`,
        `ip`,
        `soft` )
        values('','$name','$pass','".time()."','".getenv(REMOTE_ADDR)."','".getenv(HTTP_USER_AGENT)."');");
$name=$_POST['name'];
$result = mysql_query($query);
if(!$result) echo "Error
\n";
if(!$result){echo "Username exists, try another one
<a href=\"$PHP_SELF?spider=register\">Register</a>
\n";
}else{
$name=$_POST['name'];
mkdir("$name");
@ chmod("$name",0755);
mkdir("$name/files");
@ chmod("$name/files",0755);
mkdir("$name/pics");
@ chmod("$name/pics",0755);
$fp = fopen(addslashes($_POST['name']) . '/index.php', 'w');
$clear_page = <<<CLEARPAGE
<?
header("location: ../sites/index.php?name=$name");
CLEARPAGE;
fputs($fp, $clear_page);

/*
file("http://$cpaneluser:$cpanelpass@$domain:2082/frontend/x/subdomain/doadddomain.html?domain=$name&rootdomain=$domain
");
*/
echo "Registration Successful!
\n";
echo "<hr />\n";
echo "</div>\n";
echo "[b]Username:[/b] ".$name."
\n";
echo "[b]Password:[/b] ".$pass."
\n";
echo "------
\n";
echo "Your site can be viewd at:
\n";
echo "http://spiderwap.co.za/".$name."";
echo "<div align=\"center\">\n";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF?spider=menu&name=$name&pass=$pass\">Enter</a>
\n";
}}else{
echo "Please Fill in all Fields!
";
}
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
alesh Lead · 604 posts #2

Funmobile script already got reserved/forbiden nicks included..... So take a look there nd ull came up with idea

eeeeerrr....

Guest #4

This should work $forbidden_dirs = Array("cgi-bin","tmp","folder3","folder4"); are the names of the files and directories you dont want using

elseif($spider=="register1")
{
$forbidden_dirs = Array("cgi-bin","tmp","folder3","folder4");
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]Register[/size][/b]";
echo "</div>\n";
echo "<div align=\"center\">\n";
if($name!=""||$pass!=""){
$name = $_POST['name'];
$name= strtolower($name);
$query= ("INSERT INTO `users`
        ( `id`,
        `name` ,
        `pass`,
        `rtime`,
        `ip`,
        `soft` )
        values('','$name','$pass','".time()."','".getenv(REMOTE_ADDR)."','".getenv(HTTP_USER_AGENT)."');");
$name=$_POST['name'];
$result = mysql_query($query);
if(!$result) echo "Error
\n";
if(!$result){echo "Username exists, try another one
<a href=\"$PHP_SELF?spider=register\">Register</a>
\n";
}else{
$name=$_POST['name'];
if(in_array($name)){
echo "[b]The name ".$name." is reserved please use another one[/b]
";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}

mkdir("$name");
@ chmod("$name",0755);
mkdir("$name/files");
@ chmod("$name/files",0755);
mkdir("$name/pics");
@ chmod("$name/pics",0755);
$fp = fopen(addslashes($_POST['name']) . '/index.php', 'w');
$clear_page = <<<CLEARPAGE
<?
header("location: ../sites/index.php?name=$name");
CLEARPAGE;
fputs($fp, $clear_page);

/*
file("http://$cpaneluser:$cpanelpass@$domain:2082/frontend/x/subdomain/doadddomain.html?domain=$name&rootdomain=$domain
");
*/
echo "Registration Successful!
\n";
echo "<hr />\n";
echo "</div>\n";
echo "[b]Username:[/b] ".$name."
\n";
echo "[b]Password:[/b] ".$pass."
\n";
echo "------
\n";
echo "Your site can be viewd at:
\n";
echo "http://spiderwap.co.za/".$name."";
echo "<div align=\"center\">\n";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF?spider=menu&name=$name&pass=$pass\">Enter</a>
\n";
}}else{
echo "Please Fill in all Fields!
";
}
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
Guest #6

i just noticed something i did wrong

in_array($name)

should be

in_array($name,$forbidden_dirs)

Guest #9

the query was above the check that should fix that

elseif($spider=="register1")
{
$forbidden_dirs = Array("cgi-bin","tmp","folder3","folder4");
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]Register[/size][/b]";
echo "</div>\n";
echo "<div align=\"center\">\n";
if($name!=""||$pass!=""){
$name = $_POST['name'];
$name= strtolower($name);
if(in_array($name,$forbidden_dirs)){
echo "[b]The name ".$name." is reserved please use another one[/b]
";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
$query= ("INSERT INTO `users`
        ( `id`,
        `name` ,
        `pass`,
        `rtime`,
        `ip`,
        `soft` )
        values('','$name','$pass','".time()."','".getenv(REMOTE_ADDR)."','".getenv(HTTP_USER_AGENT)."');");
$name=$_POST['name'];
$result = mysql_query($query);
if(!$result) echo "Error
\n";
if(!$result){echo "Username exists, try another one
<a href=\"$PHP_SELF?spider=register\">Register</a>
\n";
}else{
$name=$_POST['name'];
mkdir("$name");
@ chmod("$name",0755);
mkdir("$name/files");
@ chmod("$name/files",0755);
mkdir("$name/pics");
@ chmod("$name/pics",0755);
$fp = fopen(addslashes($_POST['name']) . '/index.php', 'w');
$clear_page = <<<CLEARPAGE
<?
header("location: ../sites/index.php?name=$name");
CLEARPAGE;
fputs($fp, $clear_page);

/*
file("http://$cpaneluser:$cpanelpass@$domain:2082/frontend/x/subdomain/doadddomain.html?domain=$name&rootdomain=$domain
");
*/
echo "Registration Successful!
\n";
echo "<hr />\n";
echo "</div>\n";
echo "[b]Username:[/b] ".$name."
\n";
echo "[b]Password:[/b] ".$pass."
\n";
echo "------
\n";
echo "Your site can be viewd at:
\n";
echo "http://spiderwap.co.za/".$name."";
echo "<div align=\"center\">\n";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF?spider=menu&name=$name&pass=$pass\">Enter</a>
\n";
}}else{
echo "Please Fill in all Fields!
";
}
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
SpiderWap Lead · 622 posts #11
elseif($spider=="register1")
{
$forbidden_dirs = array("cgi-bin","tmp","_vti_bin","_vti_cnf","_vti_log","_vti_pvt","_vti_txt","downloads","emulator","flags","flags","ringtones","top","wap");
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]Register[/size][/b]";
echo "</div>\n";
echo "<div align=\"center\">\n";
if($name!=""||$pass!=""){
$name = $_POST['name'];
$name= strtolower($name);
if(array($name)){
echo "[b]The name ".$name." is reserved please use another one[/b]
";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
$query= ("INSERT INTO `users`
        ( `id`,
        `name` ,
        `pass`,
        `rtime`,
        `ip`,
        `soft` )
        values('','$name','$pass','".time()."','".getenv(REMOTE_ADDR)."','".getenv(HTTP_USER_AGENT)."');");
$name=$_POST['name'];
$result = mysql_query($query);
if(!$result) echo "Error
\n";
if(!$result){echo "Username exists, try another one
<a href=\"$PHP_SELF?spider=register\">Register</a>
\n";
}else{
$name=$_POST['name'];
mkdir("$name");
@ chmod("$name",0755);
mkdir("$name/files");
@ chmod("$name/files",0755);
mkdir("$name/pics");
@ chmod("$name/pics",0755);
$fp = fopen(addslashes($_POST['name']) . '/index.php', 'w');
$clear_page = <<<CLEARPAGE
<?
header("location: ../sites/index.php?name=$name");
CLEARPAGE;
fputs($fp, $clear_page);

/*
file("http://$cpaneluser:$cpanelpass@$domain:2082/frontend/x/subdomain/doadddomain.html?domain=$name&rootdomain=$domain
");
*/
echo "Registration Successful!
\n";
echo "<hr />\n";
echo "</div>\n";
echo "[b]Username:[/b] ".$name."
\n";
echo "[b]Password:[/b] ".$pass."
\n";
echo "------
\n";
echo "Your site can be viewd at:
\n";
echo "http://spiderwap.co.za/".$name."";
echo "<div align=\"center\">\n";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF?spider=menu&name=$name&pass=$pass\">Enter</a>
\n";
}}else{
echo "Please Fill in all Fields!
";
}
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}

Ok m8 this is how i done it now, now i get

The name quintin is reserved please use another one

Guest #12

Good luck with your builder mate

Guest #14

try this you did it wrong

elseif($spider=="register1")
{
$forbidden_dirs = array("cgi-bin","tmp","_vti_bin","_vti_cnf","_vti_log","_vti_pvt","_vti_txt","downloads","emulator","flags","flags","ringtones","top","wap");
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]Register[/size][/b]";
echo "</div>\n";
echo "<div align=\"center\">\n";
if($name!=""||$pass!=""){
$name = $_POST['name'];
$name= strtolower($name);
if(in_array($name,$forbidden_dirs)){
echo "[b]The name ".$name." is reserved please use another one[/b]
";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
$query= ("INSERT INTO `users`
        ( `id`,
        `name` ,
        `pass`,
        `rtime`,
        `ip`,
        `soft` )
        values('','$name','$pass','".time()."','".getenv(REMOTE_ADDR)."','".getenv(HTTP_USER_AGENT)."');");
$name=$_POST['name'];
$result = mysql_query($query);
if(!$result) echo "Error
\n";
if(!$result){echo "Username exists, try another one
<a href=\"$PHP_SELF?spider=register\">Register</a>
\n";
}else{
$name=$_POST['name'];
mkdir("$name");
@ chmod("$name",0755);
mkdir("$name/files");
@ chmod("$name/files",0755);
mkdir("$name/pics");
@ chmod("$name/pics",0755);
$fp = fopen(addslashes($_POST['name']) . '/index.php', 'w');
$clear_page = <<<CLEARPAGE
<?
header("location: ../sites/index.php?name=$name");
CLEARPAGE;
fputs($fp, $clear_page);

/*
file("http://$cpaneluser:$cpanelpass@$domain:2082/frontend/x/subdomain/doadddomain.html?domain=$name&rootdomain=$domain
");
*/
echo "Registration Successful!
\n";
echo "<hr />\n";
echo "</div>\n";
echo "[b]Username:[/b] ".$name."
\n";
echo "[b]Password:[/b] ".$pass."
\n";
echo "------
\n";
echo "Your site can be viewd at:
\n";
echo "http://spiderwap.co.za/".$name."";
echo "<div align=\"center\">\n";
echo "<hr />\n";
echo "<a href=\"$PHP_SELF?spider=menu&name=$name&pass=$pass\">Enter</a>
\n";
}}else{
echo "Please Fill in all Fields!
";
}
echo "<hr />\n";
echo "<a href=\"$PHP_SELF\">Home</a>
\n";
echo "</div>\n";
echo "<div style=\"background-color:#FF0000; color:#FFFFFF;\" align=\"center\">\n";
echo "[b][size="1"]© SpiderWap[/size][/b]";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close