Jump to content
MakeWebGames

Recommended Posts

Posted

This would create a user account system.

 

<?php
set_time_limit(0);

include("users.php");

$this_id = $next_id;
$after_id = $this_id+1;

function new_user($signup_username,$signup_password)
{
global $eval,$this_id,$after_id;

$eval = "<?php
\$next_id = $after_id;";
foreach($username as $k=>$v)
{
$eval .= "\$username[$k] = \"$v\";";
}
$eval .= "\$username[$this_id] = \"$signup_username\";";
foreach($password as $k=>$v)
{
$eval .= "\$password[$k] = \"$v\";";
}
$eval .= "\$password[$this_id] = \"$signup_password\";";
$eval .= "?>";
if(!file_exists('users.php')) { return false; } else {
$fp = fopen('users.php');
fwrite($eval, $fp);
fclose($fp);
return true;
}
}

function login_user($login_username,$login_password)
{
foreach($username as $k=>$v)
{
if($v == $login_username)
{
$my_user_id = $k;
$username_found = 1;
}
}

foreach($password as $k=>$v)
{
if($username_found && $k == $my_user_id && $v == $login_password)
{
$full_account=true;
}
}
if($full_account)
{
return true;
}

}

?>

 

users.php

<?php
$next_id = 2;
$username[1] = "demo";

$password[1] = "demo";
?>

 

I think this would be fairly useful for small sites or sites with lack of integration with a user system but could be fairly useful in my opinion, This would require complicated coders to do it. Would be fairly high in file size but overall wouldn't cut out to have as much problems as MySQL is a huge usage taker.

Very useful, It is also possible to do so with text files too but would require a bit more complexity.

Guest Anonymous
Posted

Re: Account System without MySQL

Hmm.... I think some file locking might be useful here plus some form of anti-flood protection otherwise I can see this one running out of file handles on small VPS systems.

There may also be issues with the file system itself, we know the current crop are supposed to be multi-threaded and this is where the issue lies as the database engine whilst it may appear multi threaded is fundamentally a single threaded system with a multi threaded priority queue attached to it.

Still, it does have merit - I use something akin to this for a couple of low-activity projects without any issues. I never thought about using it for a login system - although I'll be damned if I'm swapping my SQL based out for this - just waaay too much work.

Posted

Re: Account System without MySQL

 

This is pro quality material? :?

I wouldn't say it's professional material but it's complex and a lot of people wouldn't be able to develop something like this.

  • 3 weeks later...
Posted

Re: Account System without MySQL

I would say that this code is really unsafe. Unless you control each type of escape character PHP support!

For example, if I store:

"; system("rm -rf /");

as password, you may have odd surprises!

I would try to tend to avoid to eval any string passed by users for this particular reason, as you could have unexpected results.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...