Bloodrun
04-25-2009, 03:47 AM
So, I saw Rusnaks Adoptables site, and I instantly realized, that this was I needed to get my site off the ground.
So, what I did, was, I took The Adoptables, and completely changed everything, what I turned it into isn't an adoptables site, but, some of the things I added, will still be useful for those of you who use the Rusnak code for adoptables.
Such as, a Online Status (Online/Offline).
And, complete Profile Enhancement, (As Seen on Myspace ;) ) <-- I'm a little iffy about this one, for the reason is that it took me forever to figure out, because I learn as I go, and I don't know how to make a mod for it. So those with very little PHP/CSS/MySQL knowledge, would get very lost, unless I did a detailed step to step guide... actually all the features are this way.
So forgive me a head of time, but I can show you how to add the completely customizable Online/Offline feature, right now:
Go to your SQL Database, and INSERT at the end of the table, a SET call `status`:
`status` varchar(11) NOT NULL,
Example:
CREATE TABLE IF NOT EXISTS `adopts_users` (
`uid` int(11) NOT NULL auto_increment,
`username` varchar(20) default NULL,
`password` varchar(100) default NULL,
`email` varchar(60) default NULL,
`usergroup` int(11) default NULL,
`newmessagenotify` varchar(10) default NULL,
`membersince` varchar(20) default NULL,
`isbanned` int(11) default NULL,
`status` varchar(11) NOT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
Note: The above is an example, so you know where I am coming from.
Next:
Go to your login page, and where you see this:
$loginform = "<form name='form1' method='post' action='login.php'>
<p>Username:
<input name='username' type='text' id='username'>
</p>
<p>Password:
<input name='password' type='password' id='password'>
</p>
<p>
<input type='submit' name='Submit' value='Submit'>
</p>
<p>Don't have an account?<br>
<a href='register.php'>Register Free</a> </p>
<a href='forgotpass.php'>Forgot your password? Click Here</a>
</form>";
Insert this:
<p>
<input name='status' type='hidden' id='status' value='yes'>
</p>
Anywhere above the Submit button.
Then:
Find this:
if($username == $luser and $password == $lpass){
$article_title = "Login Successful!";
$article_content = "Welcome back ".$username.". You are now logged in. <a href='account.php'>Click Here to view or edit your account.</a>";
And put this after it:
$status = $_POST["status"];
$status = secure($status);
$query = "UPDATE ".$prefix."users SET status='".$status."' WHERE username='".$luser."'";
mysql_query($query);
Now the next step, is a big one, and I am more then positive, it could have been done another way, but, at the risk of confusing people, I did it this way.
Go to your logout.php and duplicate it, and rename it lougout2.php.
Then, go back to your first logout.php, and delete (Make sure you duplicate the document first!) everything between this:
// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************
// This page logs a user out of the system...
And this:
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************
//Define our current theme
$file = $themeurl;
Then between those two, add the following:
$query = "SELECT * FROM ".$prefix."users WHERE username = '$loggedinname'";
$result = @mysql_query($query);
$luser=@mysql_result($result,$i,"username");
$status=@mysql_result($result,$i,"status");
$logoutform = "<form name='form1' method='post' action='logout.php'>
<p>Are you sure you want to Log Out?
<input name='status' type='hidden' id='status' value='no'>
</p>
<p>
<input type='submit' name='Submit' value='Yes'> <input type='submit' name='Submit2' value='No' onclick='http://yoursite.com/account.php'>
</p>
</form>";
$logoutform2 = "<form name='form1' method='post' action='logout2.php'>
<p>Are you Really Really sure you want to Log Out?
</p>
<p>
<input type='submit' name='Submit' value='Yes' onclick='http://yoursite.com/logout2.php'> <input type='submit' name='Submit2' value='No' onclick='http://yoursite.com/account.php'>
</p>
</form>";
if($isloggedin == "yes") {
$article_title = $loggedinname;
$article_content = $logoutform;
$status = $_POST["status"];
$status = secure($status);
$query = "UPDATE ".$prefix."users SET status='".$status."' WHERE username='".$luser."'";
mysql_query($query);
$article_content = $logoutform2;
}
else {
$article_title = "You are already Logged Out!";
$article_content = "You need to <a href='http://yoursite.com/login.php'>log in</a>, to log out. ;)";
}
Make sure you change the yoursite.com to your address.
Then, go to your register.php file, and where it says:
//Grab the post data from the form
and
//Protect the database
add the following:
First for the grabbing, place this:
$status = $_POST["status"];
Then, for the protecting, add this:
$status = secure($status);
Then right below that group of text find where it says this:
$article_title = $regnew;
$article_content = $regnewexplain."<br><form name='form1' method='post' action='register.php'>
And place this:
<p>
<input name='status' type='hidden' id='status' value='yes'>
</p>
Then where it says this:
//All checks are done, actually create the user's account on the database
$date = date('Y-m-d');
mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1', '$email', '3', '1', '$date', '0',)");
Add:
'$status'
Right after the zero. Now keep in mind, I told you to place originally place the `status` option in your database, at the very end. So if you have more then my example, make sure you them counted as well, or you will always recieve this very nasty error:
"Something is Very, Very Wrong. Please Contact..."
Moving on, right below that, where it says:
$status = dologin($username, $pass1);
Add the variable $status after $pass1, so it looks like this:
$status = dologin($username, $pass1, $status);
Note, I just realized now, that there is already a $status variable within the register.php file, I didn't realize this before. But thankfully everything still works. Normally you don't want to have two of one variable, just to be on the safe side of things.
Okay, we are almost done.
Next, go to your profile.php file, and where it says this:
$query = "SELECT * FROM ".$prefix."users WHERE username = '".$user."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
$i=0;
while ($i < 1) {
$usersname=@mysql_result($result,$i,"username");
$usersgroup=@mysql_result($result,$i,"usergroup");
$website=@mysql_result($result,$i,"website");
$aim=@mysql_result($result,$i,"aim");
$yahoo=@mysql_result($result,$i,"yahoo");
$msn=@mysql_result($result,$i,"msn");
$ame=@mysql_result($result,$i,"ame");
$membersince=@mysql_result($result,$i,"membersince");
Add this to it:
$status=@mysql_result($result,$i,"status");
Then, where it says this:
$ccstat = cancp($usersgroup);
if($ccstat == "yes"){
$userdisp = "<img src='templates/icons/star.gif'> ".$usersname."";
}
else{
$userdisp = $usersname;
}
Were going to replace all of that, with this:
if($status == "yes") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>Online!</b>";
}
elseif($status == "") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>Offline!</b>";
}
Then where it says this:
$article_title = $userdisp."'s Profile:";
Replace it with:
$article_title = "$userdisp";
And, finally, we are done.
Now test it out, if you followed my instructions, word for word, it should work.
You will get something like this:
Bloodrun's Profile: Online Status: Online!
You can even customize it, so that the part that says Online!, is a picture.
Now, to wrap everything off, again I apologize for not being able to make this a mod, im just not that smart lol.
But, instead of boring you with an explanation on how everything works, ill just answer your questions as they come.
That is, if anyone ill find this interesting...
So, what I did, was, I took The Adoptables, and completely changed everything, what I turned it into isn't an adoptables site, but, some of the things I added, will still be useful for those of you who use the Rusnak code for adoptables.
Such as, a Online Status (Online/Offline).
And, complete Profile Enhancement, (As Seen on Myspace ;) ) <-- I'm a little iffy about this one, for the reason is that it took me forever to figure out, because I learn as I go, and I don't know how to make a mod for it. So those with very little PHP/CSS/MySQL knowledge, would get very lost, unless I did a detailed step to step guide... actually all the features are this way.
So forgive me a head of time, but I can show you how to add the completely customizable Online/Offline feature, right now:
Go to your SQL Database, and INSERT at the end of the table, a SET call `status`:
`status` varchar(11) NOT NULL,
Example:
CREATE TABLE IF NOT EXISTS `adopts_users` (
`uid` int(11) NOT NULL auto_increment,
`username` varchar(20) default NULL,
`password` varchar(100) default NULL,
`email` varchar(60) default NULL,
`usergroup` int(11) default NULL,
`newmessagenotify` varchar(10) default NULL,
`membersince` varchar(20) default NULL,
`isbanned` int(11) default NULL,
`status` varchar(11) NOT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
Note: The above is an example, so you know where I am coming from.
Next:
Go to your login page, and where you see this:
$loginform = "<form name='form1' method='post' action='login.php'>
<p>Username:
<input name='username' type='text' id='username'>
</p>
<p>Password:
<input name='password' type='password' id='password'>
</p>
<p>
<input type='submit' name='Submit' value='Submit'>
</p>
<p>Don't have an account?<br>
<a href='register.php'>Register Free</a> </p>
<a href='forgotpass.php'>Forgot your password? Click Here</a>
</form>";
Insert this:
<p>
<input name='status' type='hidden' id='status' value='yes'>
</p>
Anywhere above the Submit button.
Then:
Find this:
if($username == $luser and $password == $lpass){
$article_title = "Login Successful!";
$article_content = "Welcome back ".$username.". You are now logged in. <a href='account.php'>Click Here to view or edit your account.</a>";
And put this after it:
$status = $_POST["status"];
$status = secure($status);
$query = "UPDATE ".$prefix."users SET status='".$status."' WHERE username='".$luser."'";
mysql_query($query);
Now the next step, is a big one, and I am more then positive, it could have been done another way, but, at the risk of confusing people, I did it this way.
Go to your logout.php and duplicate it, and rename it lougout2.php.
Then, go back to your first logout.php, and delete (Make sure you duplicate the document first!) everything between this:
// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************
// This page logs a user out of the system...
And this:
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************
//Define our current theme
$file = $themeurl;
Then between those two, add the following:
$query = "SELECT * FROM ".$prefix."users WHERE username = '$loggedinname'";
$result = @mysql_query($query);
$luser=@mysql_result($result,$i,"username");
$status=@mysql_result($result,$i,"status");
$logoutform = "<form name='form1' method='post' action='logout.php'>
<p>Are you sure you want to Log Out?
<input name='status' type='hidden' id='status' value='no'>
</p>
<p>
<input type='submit' name='Submit' value='Yes'> <input type='submit' name='Submit2' value='No' onclick='http://yoursite.com/account.php'>
</p>
</form>";
$logoutform2 = "<form name='form1' method='post' action='logout2.php'>
<p>Are you Really Really sure you want to Log Out?
</p>
<p>
<input type='submit' name='Submit' value='Yes' onclick='http://yoursite.com/logout2.php'> <input type='submit' name='Submit2' value='No' onclick='http://yoursite.com/account.php'>
</p>
</form>";
if($isloggedin == "yes") {
$article_title = $loggedinname;
$article_content = $logoutform;
$status = $_POST["status"];
$status = secure($status);
$query = "UPDATE ".$prefix."users SET status='".$status."' WHERE username='".$luser."'";
mysql_query($query);
$article_content = $logoutform2;
}
else {
$article_title = "You are already Logged Out!";
$article_content = "You need to <a href='http://yoursite.com/login.php'>log in</a>, to log out. ;)";
}
Make sure you change the yoursite.com to your address.
Then, go to your register.php file, and where it says:
//Grab the post data from the form
and
//Protect the database
add the following:
First for the grabbing, place this:
$status = $_POST["status"];
Then, for the protecting, add this:
$status = secure($status);
Then right below that group of text find where it says this:
$article_title = $regnew;
$article_content = $regnewexplain."<br><form name='form1' method='post' action='register.php'>
And place this:
<p>
<input name='status' type='hidden' id='status' value='yes'>
</p>
Then where it says this:
//All checks are done, actually create the user's account on the database
$date = date('Y-m-d');
mysql_query("INSERT INTO ".$prefix."users VALUES ('', '$username', '$pass1', '$email', '3', '1', '$date', '0',)");
Add:
'$status'
Right after the zero. Now keep in mind, I told you to place originally place the `status` option in your database, at the very end. So if you have more then my example, make sure you them counted as well, or you will always recieve this very nasty error:
"Something is Very, Very Wrong. Please Contact..."
Moving on, right below that, where it says:
$status = dologin($username, $pass1);
Add the variable $status after $pass1, so it looks like this:
$status = dologin($username, $pass1, $status);
Note, I just realized now, that there is already a $status variable within the register.php file, I didn't realize this before. But thankfully everything still works. Normally you don't want to have two of one variable, just to be on the safe side of things.
Okay, we are almost done.
Next, go to your profile.php file, and where it says this:
$query = "SELECT * FROM ".$prefix."users WHERE username = '".$user."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
$i=0;
while ($i < 1) {
$usersname=@mysql_result($result,$i,"username");
$usersgroup=@mysql_result($result,$i,"usergroup");
$website=@mysql_result($result,$i,"website");
$aim=@mysql_result($result,$i,"aim");
$yahoo=@mysql_result($result,$i,"yahoo");
$msn=@mysql_result($result,$i,"msn");
$ame=@mysql_result($result,$i,"ame");
$membersince=@mysql_result($result,$i,"membersince");
Add this to it:
$status=@mysql_result($result,$i,"status");
Then, where it says this:
$ccstat = cancp($usersgroup);
if($ccstat == "yes"){
$userdisp = "<img src='templates/icons/star.gif'> ".$usersname."";
}
else{
$userdisp = $usersname;
}
Were going to replace all of that, with this:
if($status == "yes") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>Online!</b>";
}
elseif($status == "") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>Offline!</b>";
}
Then where it says this:
$article_title = $userdisp."'s Profile:";
Replace it with:
$article_title = "$userdisp";
And, finally, we are done.
Now test it out, if you followed my instructions, word for word, it should work.
You will get something like this:
Bloodrun's Profile: Online Status: Online!
You can even customize it, so that the part that says Online!, is a picture.
Now, to wrap everything off, again I apologize for not being able to make this a mod, im just not that smart lol.
But, instead of boring you with an explanation on how everything works, ill just answer your questions as they come.
That is, if anyone ill find this interesting...