Log in

View Full Version : Modification Out-Dated New one will be added.


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...

Ashje
04-25-2009, 07:31 AM
Nice, but I'm still waiting for the upgrade so I can't use it...

Bloodrun
04-25-2009, 07:14 PM
Nice, but I'm still waiting for the upgrade so I can't use it...


Ahh, you haven't installed the upgrade yet?

Blue Icebox
04-25-2009, 09:46 PM
useful, useful... very useful!

I just needed this!

-bookmarking this page also!--

Bloodrun
04-26-2009, 04:40 PM
useful, useful... very useful!

I just needed this!

-bookmarking this page also!--


Lol, glad I could help you. =)

Blue Icebox
04-26-2009, 07:43 PM
you should change all the [code ] to [php ] cause it has the syntax colors! :D

Bloodrun
04-26-2009, 08:00 PM
you should change all the [code ] to [php ] cause it has the syntax colors! :D


Lol, I changed some, but not all.

Bloodrun
04-27-2009, 03:20 PM
Update!

There is a slight problem with this code. And that is, if a person does not hit the log-out button, it will continue to say that the person is online. Until he/she logs in again, in which it will say he/she is offline, until the Next time they log on.

So a little diaphram to help you understand that:

First Login, (does not log off)
-Is Online.
Second Login (it doesnt matter if he/she logs off or not)
-Offline.
Third Login (has to log off so the cycle doesnt repeat)
-Is Online (when they are actually online)

Now there is a solution to this problem. But it isn't has "Professional" as the first.

If you don't want to go through all this work, to end up with this possible broken cycle, all you have to do insert the following, in your account.php, accountpost.php, and profile.php: Note: You will need the same Database entry as in the first one, so use that one.

account.php
Find where it says:


$query = "SELECT * FROM ".$prefix."users WHERE username='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);

//Loop out code
$i=0;
while ($i < 1) {



And place the following:
Under the first group:

$status=@mysql_result($result,$i,"status");

Under the second group:

$status = stripslashes($status);


Then find where it says:

<form name='form1' method='post' action='accountpost.php'>
<p>".$box."
Notify me via email when I receive a new message or reward code</p>
<p><u>Publically Viewable Details: </u></p>


And place the following anywhere within that form:

<p>Status:
<select name='status' id='status'>
<option value='none'>None</option>
<option value='online'>Online!</option>
<option value='offline'>Offline!</option>
<option value='busy'>Busy!</option>
<option value='away'>Away!</option>
</select>
</p>

Note: you can add more, I made it short so you can get the gist of it. You can also add pictures to each one. You can do pretty much anything with it.

accountpost.php
Find where it says:

// We are changing the settings

$newmsgnotify = $_POST["newmsgnotify"];
$newmsgnotify = preg_replace("/[^a-zA-Z0-9@._-]/", "", $newmsgnotify);
$newmsgnotify = secure($newmsgnotify);


Then place this uner it:

$status = $_POST["status"];
$status = secure($status);


Then find where it says:

// Run update queries...

$query = "UPDATE ".$prefix."users SET newmessagenotify='".$newmsgnotify."' WHERE username='".$loggedinname."'";
mysql_query($query);


And place this under it:

$query = "UPDATE ".$prefix."users SET status='".$status."' WHERE username='".$loggedinname."'";
mysql_query($query);


profile.php
Find where it says:

$query = "SELECT * FROM ".$prefix."users WHERE username = '".$user."'";
$result = mysql_query($query);
$num = mysql_numrows($result);

if($num > 0){

$i=0;
while ($i < 1) {


Place this under it:

$status=@mysql_result($result,$i,"status");


Then find where it says:

$ccstat = cancp($usersgroup);
if($ccstat == "yes"){
$userdisp = "<img src='templates/icons/star.gif'> ".$usersname."";
}
else{
$userdisp = $usersname;
}

And place this

if($status == "none") {
$userdisp = "".$usersname."'s Profile:";
}
elseif($status == "online") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>Online!</b>";
}
elseif($status == "offline") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>Offline!</b>";
}
elseif($status == "busy") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>Busy!</b>";
}
elseif($status == "away") {
$userdisp = "".$usersname."'s Profile: Online Status: <b>away!</b>";
}


Then find where it says:

$article_title = $userdisp."'s Profile:";

And change it to:

$article_title = "$userdisp";


Like I said this is just the very least you can do with the code. There is so much you can do with it. Who knows, maybe Ill bring in something else. =D

Ashje
04-27-2009, 04:41 PM
Nice, but I'm still waiting for the upgrade so I can't use it...


Ahh, you haven't installed the upgrade yet?


Well, seeing as the upgrade script isn't out and I can't be bothered doing what Sea did, No...

Bloodrun
04-27-2009, 05:31 PM
Nice, but I'm still waiting for the upgrade so I can't use it...


Ahh, you haven't installed the upgrade yet?


Well, seeing as the upgrade script isn't out and I can't be bothered doing what Sea did, No...


Wait, what? I think we are talking about two seperate things..
First off, who is Sea, and what did he/she do?
Secondly, which script are you talking about?

Ashje
04-28-2009, 04:44 AM
1. Sea = Seapyramid, Senior Member here. He uploaded the new files and changed his MySQL to fit. In other words, a manual upgrade.
2. This script, the adoptables one.

Bloodrun
04-28-2009, 08:36 AM
1. Sea = Seapyramid, Senior Member here. He uploaded the new files and changed his MySQL to fit. In other words, a manual upgrade.
2. This script, the adoptables one.


I didn't have any trouble installing the new one :?

Ashje
04-30-2009, 01:40 AM
I'm upgrading from the old version, which you can't currently do unless you do what Seapyramid did and convert all the files manually. I can't be bothered XD

Bloodrun
05-01-2009, 06:49 AM
I'm upgrading from the old version, which you can't currently do unless you do what Seapyramid did and convert all the files manually. I can't be bothered XD


Ahh, you always have to be mister lazy lol.

Ashje
05-08-2009, 01:44 AM
True, true. Besides, I'm not a professional so I don't want to screw anything up...

Bloodrun
05-09-2009, 01:09 PM
True, true. Besides, I'm not a professional so I don't want to screw anything up...


Lol if you say so.
Can't learn if you don't try.

Seapyramid
05-09-2009, 11:10 PM
1. Sea = Seapyramid, Senior Member here. He uploaded the new files and changed his MySQL to fit. In other words, a manual upgrade.
2. This script, the adoptables one.


Sea is a she & mother of 3 so please denote that :)

Yes I did an upgrade of the myadopts.php page & if you want more info you can pm me on it. BUT if you MUST have knowledge of HTML, PHP and MYSQL! I am NOT a teaching service. I will offer the scripts & MySQL info... but I will NOT train you on it.

Bloodrun
05-10-2009, 12:21 PM
1. Sea = Seapyramid, Senior Member here. He uploaded the new files and changed his MySQL to fit. In other words, a manual upgrade.
2. This script, the adoptables one.


Sea is a she & mother of 3 so please denote that :)

Yes I did an upgrade of the myadopts.php page & if you want more info you can pm me on it. BUT if you MUST have knowledge of HTML, PHP and MYSQL! I am NOT a teaching service. I will offer the scripts & MySQL info... but I will NOT train you on it.


You were referencing attention to ashje on last part.. right?

Ashje
05-13-2009, 01:35 AM
Sea is a she & mother of 3 so please denote that :)


Oops, sorry. I haven't been here long enough to see a post with reference to your gender/lifestyle. My apologies.

ghazal
05-23-2009, 01:52 AM
Fantastic Blood run