PDA

View Full Version : Conditions not working


SilverDragonTears
10-27-2011, 11:00 PM
I enabled conditions for users to only be able to adopt 2 of a certain type but it's letting me adopt more.

Hall of Famer
10-28-2011, 06:53 AM
umm I see you are having lots of glitches after upgrading manually? This can happen to anyone unless you've indeed been extraordinarily careful with upgrading, especially considering Mys v1.2.3 has a drastic change in programming pattern compared to previous releases.

SilverDragonTears
10-28-2011, 01:28 PM
I didn't upgrade O.o I decided not to.

Hall of Famer
10-28-2011, 04:37 PM
Oh really? Mys v1.2.2's conditions do work properly, so I am guessing you modified some part of your scripts and it wont work now? Post your admin.php and I will see if I can help you.

SilverDragonTears
10-28-2011, 04:39 PM
<?php

include("inc/functions.php");
$admin = true;

//***************//
// START SCRIPT //
//***************//

if($isloggedin == "yes")
{

$group = getgroup();
$cancp = cancp($group);

if($cancp == "yes")
{

// We are allowed in the Admin CP because our usergroup Can CP
// Since we are allowed in the Admin CP, we'll need a way to tell
// which setting we are editing...
$dynimages = getadmimages();
$canedit = cando($group, "canmanageadopts");
$set = $_GET["set"];
$do = $_GET["do"];
$more = $_GET["more"];
$evenmore = $_GET["evenmore"];

// ************************************************** ********************
// Begin our if / elseif / else block to determine what we're up to...
// ************************************************** ********************

if($set == "")
{

//No setting selected, so show the Admin CP welcome screen, credits, etc

$article_title = "";
$article_content = "Here you can add or edit the adoptables that are available to your site's visitors.
Please choose an option below...<br /><br />
<a href='admin.php?set=adopts&do=new'>Add a new adoptable</a><br /><br />
<a href='admin.php?set=adopts&do=addlevel'>Add A New Level to an Adoptable</a><br />
<a href='admin.php?set=adopts&do=editlevels'>Edit Existing Levels or Images</a><br /><br />
<a href='admin.php?set=adopts&do=uploadimg'>Upload a new Adoptable Image</a><br />
<a href='admin.php?set=adopts&do=manageimg'>Manage or Delete Images</a>";

} //End for the set = "" bit
elseif($set == "adopts")
{

// ************************************************** ********************
// This is the main place where adoptables are created and edited...
// First we need to see if we can access this portion of the ACP...
// Then we begin our if / elseif / else block for the do variable
// ************************************************** ********************

if($canedit == "yes")
{

//Our usergroup can edit adoptables, so begin our switch case for do

if($do == "")
{

//We haven't selected a setting...

$article_title = "Add / Edit / Manage Adoptables";
$article_content = "Here you can add or edit the adoptables that are available to your site's visitors.
Please choose an option below...<br /><br />
<a href='admin.php?set=adopts&do=new'>Add a new adoptable</a><br /><br />
<a href='admin.php?set=adopts&do=addlevel'>Add A New Level to an Adoptable</a><br />
<a href='admin.php?set=adopts&do=editlevels'>Edit Existing Levels or Images</a><br /><br />
<a href='admin.php?set=adopts&do=uploadimg'>Upload a new Adoptable Image</a><br />
<a href='admin.php?set=adopts&do=manageimg'>Manage or Delete Images</a>";

}
elseif($do == "new")
{

//We are creating a new adoptable here...

$article_title = "Create a new adoptable";
$article_content = "This page allows you to create a new adoptable that will be available to your site's visitors.
Please fill in the form below and hit the <i>Create Adoptable</i> button below when you're ready to create the adoptable.
<form name='form1' method='post' action='nadopt.php'>
<p><u><strong>Create A New Adoptable:</strong></u></p>
<p><strong>Basic Information: </strong></p>
<p>
Adoptable Name:
<input name='name' type='text' id='name'>
<br />
(This may contain only letters, numbers and spaces)
</p>
<p>
Adoptable Class:
<input name='class' type='text' id='class'>
<br />
(The adoptable class is a category that determines if two adoptables can interbreed or not)
</p>
<p>Adoptable Description:</p>
<p>
<textarea name='description' cols='45' rows='4' id='description'></textarea>
</p>
<p>
Price:
<input name='cost' type='text' id='cost'>
</p>
<p>
Adoptable's Egg (First) Image:
<input name='imageurl' type='text' id='imageurl'>
<br />
(Use a full image path, beginning with http://)
</p>
<p>
OR select an existing image:
<select name='existingimageurl' id='existingimageurl'>
<option value='none' selected>No Existing Image</option>{$dynimages}
</select>
</p>
<hr />
<p><strong>Adoption Information and Conditions:</strong></p>
<p>When can this adoptable be adopted?</p>
<p>
<input name='cba' type='radio' value='always'>
Always
<br />
<input name='cba' type='radio' value='promo'>
Only when users use this promo code:
<input name='promocode' type='text' id='promocode'>
<br />
(Promo codes may contain letters and numbers only. Adoptables using promo codes will be hidden on the adoption screen.)
<br />
<input name='cba' type='radio' value='conditions'>
Only when the following conditions are met: (Check the check box next to a condition to enable it)
</p>
<p>
<input name='freqcond' type='checkbox' id='freqcond' value='enabled'>
The adoptable has not been adopted more than
<input name='number' type='text' id='number' size='6' maxlength='6'>
times.
</p>
<p>
<input name='datecond' type='checkbox' id='datecond' value='enabled'>
The date is:
<input name='date' type='text' id='date'>
(For the date, use this format: Year-Month-Day. So, as an example: 2009-06-28)
</p>
<p>
<input name='maxnumcond' type='checkbox' id='maxnumcond' value='enabled'>
The user does not have more than
<input name='morethannum' type='text' id='morethannum' size='5' maxlength='5'>
of this type of adoptable
</p>
<p>
<input name='usergroupcond' type='checkbox' id='usergroupcond' value='enabled'>
The user is a member of the following usergroup:
<select name='usergroups' id='usergroups'>
<option value='none' selected>No Group Selected</option>";

// We need to stop here and fetch our usergroups...

$query = "SELECT * FROM {$prefix}groups";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$article_content .= " <option value='{$row['gid']}'>{$row['groupname']}</option>";

}


$article_content .= " </select>
</p>

<hr />
<p><strong>Alternate Outcomes Settings:</strong></p>
<p>
This section allows you to set if you want to enable alternate outcomes.
This setting allows you to specify what the chances are of a user getting an alternate or special version of this adoptable.
Check the checkbox below to enable this feature and then fill out the information below.. </p>
<p>
<strong>
<input name='alternates' type='checkbox' id='alternates' value='enabled'>
Enable Alternate Outcomes
</strong>
</p>
<p>Alternate Outcomes Selection Information:</p>
<p>
Start using the alternate outcome at level number:
<input name='altoutlevel' type='text' id='altoutlevel' size='6' maxlength='6'>
<br />
(Use Level 0 to have the alternate outcome be used from birth. This will not affect the first / egg image.)
</p>
<p>
The alternate outcome has a chance of 1 in
<input name='altchance' type='text' id='altchance' size='6' maxlength='6'>
of being selected.<br />
(Here you can select the chance that the alternate images for this adoptable are used.
So, for an equal chance of using say male or female images,
put 2 in the box to have a 1 out of 2 or 50% chance of using the alternate image.
If you want to have the alternate images be rare images, use a higher number,
like 100 for a 1 out of 100 chance of using the alternates.)
</p>
<p>Egg Description:
<input name='eggdesc' type='text' id='eggdesc'>
<br></p>
<p>Foxling Description:
<input name='foxdesc' type='text' id='foxdesc'>
<br></p>
<p>Adult Description:
<input name='adultdescription' type='text' id='adultdescription'>
<br></p>

<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
</form>";


} //End the create a new adoptable form
elseif($do == "addlevel")
{

if($more == "")
{

$article_title = "Add a new level to an adoptable";
$article_content = "This page allows you to add a new level to an adoptable. You may add as many levels to an adoptable as
you wish. Simply select the adoptable from the drop down list below and hit Submit to get started.
<form name='form1' method='get' action='admin.php'>
<p>
<select name='more' id='more'>
<option value='select' selected>Select an Adoptable...</option>";

//Now we select from the database and get a list of all the adoptables we have created thus far...

$query = "SELECT * FROM {$prefix}adoptables";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$article_content .= " <option value='{$row['type']}'>{$row['type']}</option>";

}

$article_content .= " </select>
</p>
<p>
<input name='set' type='hidden' id='set' value='adopts'>
<input name='do' type='hidden' id='do' value='addlevel'>
<input type='submit' name='Submit' value='Submit'>
</p>
</form>";

}
else
{

// We have an adoptable who we are working with...
// First let us see if the adoptable actually exists...
// If it does not, that means someone was playing with the query strings......bad...

$query = "SELECT * FROM {$prefix}adoptables WHERE type='{$more}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{

//A record was found in the database, so the adoptable exists
//Let's see if alternate images are enabled or disabled...

$alt = strtoupper(@mysql_result($result,0,"alternates"));
if($alt != "ENABLED")
{
$alt = "DISABLED";
}

//Let us see how many levels of this adoptable already exist...

$query = "SELECT * FROM {$prefix}levels WHERE adoptiename='{$more}'";
$result = runquery($query);
$numlevels = mysql_num_rows($result); //This is the number of levels that exist for this adopt

$currentlevel = $numlevels - 1;

//We need to see how many clicks were required for the previous level

$query = "SELECT * FROM {$prefix}levels WHERE adoptiename = '{$more}' and thisislevel = '{$currentlevel}'";
$result = runquery($query);

$prevlevelclicks = 0;
$prevlevelclicks += @mysql_result($result,0,"requiredclicks");
$currentlevel += 1; // This is now the new level we are adding
$article_title = "Create a New Level";
$article_content = "This page will allow you to create a new level for {$more}. Right now there are
<b>{$numlevels}</b> levels that exist for {$more}.
That means that you are creating <b>Level {$numlevels}</b> for {$more}
right now.<br /><br /><b><u>To create the level, fill out the form below:</u></b>

<form name='form1' method='post' action='newlevelpost.php'>
<p><u>Primary Image URL:</u></p>
<p>Hosted Image:
<input name='primaryhosted' type='text' id='primaryhosted'>
</p>
<p>OR Select an Existing Image:</p>
<p>
<select name='primarylocal' id='primarylocal'>
<option value='none' selected>Use Remote Image</option>{$dynimages}
</select>
</p>
<p><u>Alternate Image URL:</u> </p>
<p>
The alternate image URLs will only be used if you enabled alternate images for this
adoptable type AND the user randomly draws the alternate images.
</p>
<p>Alternate Images are <strong>{$alt}</strong> for this adoptable.</p>
<p>Hosted Image:
<input name='althosted' type='text' id='althosted'>
</p>
<p>OR Select an Existing Image:</p>
<p>
<select name='altlocal' id='altlocal'>
<option value='none' selected>Use Remote Image</option>{$dynimages}
</select>
</p>
<p><u>Required Clicks: </u></p>
<p>How many clicks are required to reach this level?</p>
<p>
<input name='reqclicks' type='text' id='reqclicks' size='6' maxlength='6'>
</p>
<p>
The previous level required <strong>{$prevlevelclicks}</strong> clicks,
so the number you enter here should be larger than <strong>{$prevlevelclicks }</strong>.
</p>
<p><u>Reward:</u></p>
<p>You can choose to reward the user because their adoptable reached this level. </p>
<p>
<input name='isreward' type='checkbox' id='isreward' value='yes'>
Give the user a reward
</p>
<p>
Enter a promo code in the box below that will be the user's reward.
This can be used to give the user access to a new exclusive adoptable using the Promo Code system.
</p>
<p>
Reward Code / Promo Code:
<input name='rewardcode' type='text' id='rewardcode'>
<br />
(This can only contain letters and numbers)
</p>
<p>
<input name='adoptiename' type='hidden' id='adoptiename' value='{$more}'>
<input name='islevel' type='hidden' id='islevel' value='{$currentlevel}'>
<input name='prevclix' type='hidden' id='prevclix' value='{$prevlevelclicks}'>
<input type='submit' name='Submit' value='Create Level'>
</p>
</form>";




}
else
{
$article_title = "An error has occurred";
$article_content = "It appears that the adoptable you selected does not exist in the database. If it does exist, please
contact <a href='http://www.mysidiaadoptables.com/forum' target='_blank'>Mysidiaadoptables Scripts</a>
and let us know that an error has occurred.";
}


} //End the process for adding a new level

} //End the add new level do setting
elseif($do == "uploadimg")
{

// We are uploading a new adoptable image to the site...

$article_title = "Upload a new image";
$article_content = "This page allows you to upload a new adoptable image to the server.
You may upload .gif or .jpg images no greater than 150 KB using the form below.
Uploaded images will be selectable from the drop down list of images when working with adoptables.<br />
<form enctype='multipart/form-data' method='post' action='admuploadpic.php'>
<p>Friendly Name:
<input name='ffn' type='text' id='ffn'>
</p>
<p>
Enter a name for this image that will appear in the image drop down box for this image.
This is here so you can remember what this image is.
A good name would be something like <strong>Dog Adoptable Level 3</strong> so you remember what the image is.
</p>
<p>File to Upload: <input name='uploadedfile' type='file'></p>
<p>
<input type='submit' name='Submit' value='Upload File'>
</p>
</form>";


} // End the upload new image do setting
elseif($do == "editlevels")
{

// Editing LEVELS for adoptables...

if($more == "")
{

// We haven't selected an adoptable whose levels to edit yet...

$article_title = "Edit an adoptable's levels";
$article_content = "Here you can edit levels and images for existing adoptables.
Please select the adoptable whose levels you wish to edit.<br />

<form name='form1' method='get' action='admin.php'>
<p>
<select name='more' id='more'>
<option value='select' selected>Select an Adoptable...</option>";

//Now we select from the database and get a list of all the adoptables we have created thus far...

$query = "SELECT * FROM {$prefix}adoptables";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$article_content .= " <option value='{$row['type']}'>{$row['type']}</option>";

}

$article_content .= " </select>
</p>
<p>
<input name='set' type='hidden' id='set' value='adopts'>
<input name='do' type='hidden' id='do' value='editlevels'>
<input type='submit' name='Submit' value='Submit'>
</p>
</form>";


}
else
{

// We're working with an adoptable and its levels...

// First we check if the adoptable exists or not...

$query = "SELECT * FROM {$prefix}adoptables WHERE type='{$more}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{

$row = mysql_fetch_array($result);

if(!is_numeric($evenmore))
{

// We are showing the table with all of the levels

$article_title = "Editing Levels for {$row['type']} adoptables";
$article_content = "This page allows you to view and edit the levels and images for existing adoptables of this type.
There are restrictions on what can be edited or deleted as deleting the wrong thing or changing the
wrong setting could severely break your adoptables.
Changing an adoptable level image here will change it for all users with an adoptable of that type at that image.
Listed below are all of the levels for this adoptable type.
<br /><br />
<table width='680' border='1'>
<tr>
<td width='58'><strong>Level:</strong></td>
<td width='240'><strong>Image:</strong></td>
<td width='100'><strong>Alt Image: </strong></td>
<td width='107'><strong>Clicks Required: </strong></td>
<td width='108'><strong>Reward Given: </strong></td>
<td width='33'><strong>Edit:</strong></td>
</tr>
<tr>
<td><center>0</center></td>
<td><center><img src='{$row['eggimage']}'></center></td>
<td><center><img src='templates/icons/no.gif'></center></td>
<td><center>0</center></td>
<td><center><img src='templates/icons/no.gif'></center></td>
<td><center><a href='admin.php?set=adopts&do=edit&more={$row['type']}'><img src='templates/icons/cog.gif' border=0></a></center></td>
</tr>";

// Select all of the images / levels for this adoptable

$query = "SELECT * FROM {$prefix}levels WHERE adoptiename='{$more}' and thisislevel != '0' ORDER BY thisislevel ASC";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$altdisplay = "<img src='templates/icons/no.gif'>";

if($row['alternateimage'] != "")
{
$altdisplay = "<img src='{$row['alternateimage']}'>";
}

$rewarddisplay = "<img src='templates/icons/no.gif'>";

if($row['rewarduser'] == "yes")
{
$rewarddisplay = "<img src='templates/icons/yes.gif'>";
}

$article_content .= "<tr>
<td><center>{$row['thisislevel']}</center></td>
<td><center><img src='{$row['primaryimage']}'></center></td>
<td><center>{$altdisplay}</center></td>
<td><center>{$row['requiredclicks']}</center></td>
<td><center>{$rewarddisplay}</center></td>
<td><center><a href='admin.php?set=adopts&do=editlevels&more={$row['type']}&evenmore={$row['thisislevel']}'><img src='templates/icons/cog.gif' border=0></a></center></td>
</tr>";

}

$article_content .= "</table><br />
<b>
<a href='admin.php?set=adopts&do=addlevel&more={$more}'><img src='templates/icons/add.gif' border=0>
Add a new level to this adoptable type.
</a>
</b>";

}
else
{

// We are editing a specific level

$query = "SELECT * FROM {$prefix}levels WHERE adoptiename='{$more}' and thisislevel='{$evenmore}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_array($result);

if($row['alternateimage'] == "")
{
$row['alternateimage'] = "templates/icons/no.gif";
}

$remark = "<input name='reward' type='checkbox' id='reward' value='yes'>";

if($row['rewarduser'] == "yes")
{
$remark = "<input name='reward' type='checkbox' id='reward' value='yes' checked>";
}

$prmark = "<input name='promocode' type='text' id='promocode'>";

if($prmark != "")
{
$prmark = "<input name='promocode' type='text' id='promocode' value='{$row['promocode']}'>";
}

$article_title = "Editing level {$row['thisislevel']} for {$more}";
$article_content = "Here you can edit this level for this adoptable.<br />
<form name='form1' method='post' action='admpost.php'>
<p><b><u>Primary Image for This Level:</u></b></p>
<p><img src='{$row['primaryimage']}'></p>
<p>
Change Image To:
<select name='primimg' id='primimg'>
<option value='nochange' selected>Do Not Change</option>{$dynimages}
</select>
</p>
<p><b><u>Alternate Image for This Level:</u></b></p>
<p><img src='{$row['alternateimage']}'></p>
<p>
Change Image To:
<select name='altimg' id='altimg'>
<option value='nochange' selected>Do Not Change</option>{$dynimages}
</select>
</p>
<p>
{$remark}
Reward the user for reaching this level
</p>
<p>Use the following promo code as the reward:</p>
<p>
{$prmark}
</p>
<p>
<strong>Required Clicks</strong><br />
<input name='klikks' type='checkbox' id='klikks' value='yes'> Change the number of required clicks.
It is currently at <strong>{$row['requiredclicks']}</strong><br />
<input name='newklikks' type='text' id='newklikks'>
<input name='page' type='hidden' id='page' value='editadoptlevel'>
<input name='type' type='hidden' id='type' value='{$more}'>
<input name='thisislevel' type='hidden' id='thisislevel' value='{$evenmore}'>
</p>
<p>
<input type='submit' name='Submit' value='Submit Edits'>
</p>
</form>";

}
else
{

$article_title = "Adoptable Level Not Found";
$article_content = "The level appears to be invalid. Please go back and try again.";

}

}

}
else
{

$article_title = "Adoptable Not Found";
$article_content = "An adoptable with the specified name was not found. Please go back and make sure you selected a valid adoptable.";

}

}

} // END the edit levels page...
elseif($do == "edit")
{

// We are expecting an adoptable to be submitted here already...
// Now we check if it exists...

$query = "SELECT * FROM {$prefix}adoptables WHERE type='{$more}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{

$row = mysql_fetch_array($result);

if($row['whenisavail'] != "always" and $row['whenisavail'] != "")
{
$availtxt = "<b>This adoptable currently has adoption restrictions on it.</b>";
}
else
{
$availtxt = "This adoptable currently does not have adoption restrictions on it.";
}

// Output the form to the user...

$article_title = "Editing {$more}";
$article_content = "<img src='{$eggimage}'><br />This page allows you to edit {$more}. Use the form below to edit (or delete) {$more}.<br />
<form name='form1' method='post' action='admpost.php'>
<p><u><strong>Egg Image: </strong></u></p>
<p>If you wish to change the egg image for this adoptable, you may do so below. </p>
<p>
Select a New Egg Image:
<select name='select'>
<option value='nochange' selected>Do Not Change</option>{$dynimages}
</select>
</p>
<p><u><strong>Adoptable Freeze and Delete Settings: </strong></u></p>
<p>
<input name='delete' type='checkbox' id='delete' value='yes'>
<strong>I want to delete or freeze this adoptable </strong>
</p>
<p>What sort of delete do you wish to perform for this adoptable?</p>
<p>
<input name='deltype' type='radio' value='freeze'>
Freeze Deletion - This will not delete the adoptable,
but will freeze it to all new adoptions by members of your site.
You can undo this by checking the <em>Remove all adoption conditions from this adoptable</em>
checkbox the next time you edit this adoptable.
</p>
<p>
<input name='deltype' type='radio' value='soft'>
Soft Delete (Adoptable Retirement) - This option will do a
soft delete of this adoptable from your system.
Selecting this option will remove the egg image level for this adoptable from your system.
Any users who have this type of adoptable as an egg will have them automatically
leveled up to Level 1 for this adoptable type.
This option closes the adoptable to new adoptions, but will not affect
users who already adopted this creature.
Note that once you do a soft delete you will no longer be able to edit
the levels associated with that adoptable,
so think about this carefully.
</p>
<p>
<input name='deltype' type='radio' value='hard'>
Hard Deletion (Purge) - This option will permanentally delete this adoptable from your site.
Any users currently using this adoptable will have it deleted by the system.
All levels for this adoptable will be purged. <strong>This cannot be undone! </strong>
</p>
<p><u><strong>Adoptable Adoption Conditions: </strong></u></p>
<p>{$availtxt}</p>
<p>
<input name='resetconds' type='checkbox' id='resetconds' value='yes'>
<strong>Remove all adoption conditions from this adoptable. </strong>
- This will remove all restrictions on the adoption of this creature, including promo codes.
</p>
<p>
<input name='resetdate' type='checkbox' id='resetdate' value='yes'>
Reset only the date condition for this adoptable to the following value:
</p>
<p>
<input name='date' type='text' id='date'>
(Ex: 2009-06-28)
</p>
<p>
This setting allows you to change the date that an adoptable is available to a new date.
This is handy if you only want the adoptable to be available certain times in a given year.
<input name='page' type='hidden' id='page' value='editanadopt'>
<input name='type' type='hidden' id='type' value='{$more}'>
</p>
<p>
<input type='submit' name='Submit' value='Submit Changes'>
</p>
</form>";

}
else
{

// Adoptable doesn't exist...

$article_title = "Adoptable Does Not Exist";
$article_content = "The specified adoptable does not exist in the database. Try going back and trying again.";

}


} // END the edit an adoptable's egg page...
elseif($do == "manageimg")
{

// This page manages images...

$article_title = "Image Management";
$article_content = "This page allows you to manage and delete all of the images that you have uploaded to your server.
You can select the image you wish to delete by selecting it with the button next to it.
Once you delete an image, it's gone, but you can always reupload it.
Please note that if you delete an image that is in use by any of your members or adoptables
this may break their adoptables.<br />
<form name='form1' method='post' action='admpost.php'>";

// Begin the database image pull...

$query = "SELECT * FROM {$prefix}filesmap";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$article_content .= "<p><img src='{$row['wwwpath']}'></p>
<p>
<input name='iid' type='radio' value='{$row['id']}'> Delete This Image
</p>";

}

$article_content .= " <p>
<input name='page' type='hidden' id='page' value='delimg'>
<input type='submit' name='Submit' value='Submit'>
</p>
</form>";

}
}
else
{

$article_title = "Access Denied";
$article_content = "Your usergroup does not seem to have the permission to edit the adoptables settings...";


} //This bracket ends the check of whether or not this user can access the adopts portion of the ACP


} //This bracket ends the "adopts" if / else block...
elseif($set == "content")
{

// Check if we have permissions to access here...

if($canedit == "yes")
{

// We can edit pages!

if($do == "")
{

//Not working on a specific page...

$article_title = "Page and Content Editor";
$article_content = "Here you can edit the content that appears on your site.
Here you can edit your home page, terms of service page, and more.
You can also create new pages as needed below.
<br /><br />
<b><a href='admin.php?set=content&do=new'><img src='templates/icons/add.gif' border=0> Add a new page</a></b>
<p><b><u>Your Existing Pages:</u></b></p>
<table width='575' border='1'>
<tr>
<td width='150'><strong>Page URL: </strong></td>
<td width='175'><strong>Page Title: </strong></td>
<td width='32'><strong>Edit:</strong></td>
<td width='51'><strong>Delete:</strong></td>
</tr>";

$query = "SELECT * FROM {$prefix}content";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

if($ourpage == "index" or $ourpage == "tos")
{
$showdelete = "";
}
else
{
$showdelete = "<center><a href='admin.php?set=content&do=delete&more={$row['page']}'><img src='templates/icons/delete.gif' border=0></a></center>";
}

$article_content .= "
<tr>
<td>{$row['page']}</td>
<td>{$row['title']}</td>
<td><center><a href='admin.php?set=content&do=edit&more={$row['page']}'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td>{$showdelete}</td>
</tr>";

}

$article_content .= "</table>";

}
elseif($do == "new")
{

$article_title = "Create a new page";
$article_content = "Here you can create a new page for your site. You can use the buttons above the textarea below to insert BBCODE into the form.
<br />
<form name='form1' method='post' action='admpost.php'>
<p>
Page URL:
<input name='pageurl' type='text' id='pageurl'><br />
<br /><u>Pages will appear at:</u><br /> http://www.{$domain}{$scriptpath}/<b>pages.php?page=pageurl</b>
<br />The page url may contain letters and numbers only and may not include spaces.
</p>
<p>
Page Title:
<input name='pagetitle' type='text' id='pagetitle'>
</p>
<p>Page Content: </p>
<p>
<input type=\"button\" value=\"Bold\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Bold Text Here'\">
<input type=\"button\" value=\"Italics\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Italic Text Here'\">
<input type=\"button\" value=\"Underline\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Underlined Text Here'\">
<input type=\"button\" value=\"URL / Link\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Link text goes here (http://www.yoursite.com)'\">
<input type=\"button\" value=\"Image\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.somesite.com/images/someimage.gif'\">
<input type=\"button\" value=\"Links a Text\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Linked Text Here'\">
<input type=\"button\" value=\"Striking Format\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Strike Text Here'\">
<input type=\"button\" value=\"Youtube Video\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.youtube.com/videoname'\">
<input type=\"button\" value=\"User Profile\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Username'\">
<input type=\"button\" value=\"Image Maps\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.urlhere.com/'\">
<input type=\"button\" value=\"Map Locations\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'[where=#,#,#,#=http://www.firstlinkhere.com/][wherecirc=#,#,#=http://www.secondinkhere.com/]'\">

<br /><textarea name='pagecontent' cols='45' rows='10' id='pagecontent'></textarea>
</p>
<p>
<input name='page' type='hidden' id='page' value='pages'>
<input name='type' type='hidden' id='type' value='newpage'>
<input type='submit' name='Submit' value='Create New Page'>
</p>
</form>";

}
elseif($do == "delete")
{

// Delete a page...

if($more != "index" and $more != "tos")
{

$query = "DELETE FROM {$prefix}content WHERE page='{$more}'";
runquery($query);

$article_title = "Page Deleted Successfully";
$article_content = "The page with the name <b>{$more}</b> has been deleted.<br /><br /><a href='admin.php'>ACP Home</a>";
}
else
{
$article_title = "Error";
$article_content = "The page you tried to delete is a special page and cannot be deleted.
<br /><br /> <a href='admin.php?set=content'>Return to the Pages Editor</a>";
}

}
elseif($do == "edit")
{

$article_title = "Edit a Page";

if($more != "")
{

$article_content = "Here you can edit an existing page:<br />";

//Select the page info from the database...

$pageinfo = getsitecontent($more);
$pagetitle = stripslashes($pageinfo[title]);
$pagecontent = stripslashes($pageinfo[content]);

if($pagetitle != "" or $pagecontent != "")
{

$article_content .= "Here you can edit an existing page. Use the text editor below to change the page title or content.
You may use some limited BBCodes in the box below.<br />
<form name='form1' method='post' action='admpost.php'>
<p>
<b><u>Currently Editing Page:</u> {$more}</b>
<input name='pageurl' type='hidden' id='pageurl' value='{$more}'>
</p>
<p>
Page Title:
<input name='pagetitle' type='text' id='pagetitle' value='{$pagetitle}'>
</p>
<p>Page Content: </p>
<p>
<input type=\"button\" value=\"Bold\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Bold Text Here'\">
<input type=\"button\" value=\"Italics\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Italic Text Here'\">
<input type=\"button\" value=\"Underline\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Underlined Text Here'\">
<input type=\"button\" value=\"URL / Link\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Link text goes here (http://www.yoursite.com)'\">
<input type=\"button\" value=\"Image\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.somesite.com/images/someimage.gif'\">
<input type=\"button\" value=\"Links a Text\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Linked Text Here'\">
<input type=\"button\" value=\"Striking Format\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Strike Text Here'\">
<input type=\"button\" value=\"Youtube Video\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.youtube.com/videoname'\">
<input type=\"button\" value=\"User Profile\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'Username'\">
<input type=\"button\" value=\"Image Maps\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.urlhere.com/'\">
<input type=\"button\" value=\"Map Locations\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'[where=#,#,#,#=http://www.firstlinkhere.com/][wherecirc=#,#,#=http://www.secondinkhere.com/]'\">

<br /><textarea name='pagecontent' cols='45' rows='10' id='pagecontent'>{$pagecontent}</textarea>
</p>
<p>
<input name='page' type='hidden' id='page' value='pages'>
<input name='type' type='hidden' id='type' value='editpage'>
<input type='submit' name='Submit' value='Edit Page Content'>
</p>
</form>";
}
else
{
$article_title = "Page does not exist";
$article_content = "<p>Page does not exist!</p>";
}
}
else
{

$article_title = "Page does not exist";
$article_content = "<p>Page does not exist!</p>";

}
}

}
else
{

$article_title = "Access Denied";
$article_content = "Your usergroup does not seem to have the permission to edit the site content settings...";

}

} // End the set=content block ... start a new setting here...
elseif($set == "users")
{

if($canedit == "yes")
{

// We are managing users...

if($do == "edit")
{

$query = "SELECT * FROM {$prefix}users WHERE username = '{$more}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{

//The user actually exists, so allow us to edit them...
$article_title = "User Editor - Editing {$more}'s Account";
$article_content = "Here you can edit the user's account using the form below.<br />";

$row = mysql_fetch_array($result);

//************************************************** **********************************************
// BEGIN THE FORM
//************************************************** **********************************************

$article_content .= "<form name='form1' method='post' action='admpost.php'>
<p>
<input name='delete' type='checkbox' id='delete' value='yes'>
<img src='templates/icons/delete.gif'> Delete This User. <strong>This cannot be undone!</strong>
</p>
<p>Assign New Password:
<input name='pass1' type='password' id='pass1'>
</p>
<p>Passwords may contain letters and numbers only. Leave the box blank to keep the current password.</p>
<p>
<input name='emailpwchange' type='checkbox' id='emailpwchange' value='yes'>
Email the user the new password (Only takes effect if setting a new password)
</p>
<p>Change Email Address:
<input name='email' type='text' id='email' value='{$row['email']}'>
</p>
<p>
<input name='bantrade' type='checkbox' id='bantrade' value='yes'>
Ban this user's rights to trade adoptables
</p>
<p><u>{$more}'s Current Usergroup:</u> Group {$row['usergroup']}</p>
<p>Change {$more}'s Usergroup To:<br />
<select name='level' id='level'>
<option value='nochange' selected>Do not change</option>";

// We need to stop here and fetch our usergroups...

$query = "SELECT * FROM {$prefix}groups";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$article_content .= "<option value='{$row['gid']}'>Group {$row['gid']} :: {$row['groupname']}</option>";
}

$article_content .= " </select>
</p>
<p>
<input name='page' type='hidden' id='page' value='users'>
<input name='username' type='hidden' id='username' value='{$more}'>
</p>
<p>
<input type='submit' name='Submit' value='Submit'>
</p>
</form>";

}
else
{
$article_title = "User Does Not Exist!";
$article_content = "You cannot edit this user because they do not exist!";

}

}
elseif($do == "adoptables")
{
if($more == "")
{
$article_title = "Manage Adoptables";
$article_content = "This page allows you to manage each adoptable owned by users registered on your site.
Only admins who can edit users and usergroups can carry out this task.
Use the table below to edit existing adoptables, or click the link below to create a new adoptable for a user.
<br /><br />
<b><a href='admin.php?set=users&do=adoptables&more=new'><img src='templates/icons/add.gif' border=0>Create a New Owned Adoptables</a></b>
<table width='680' border='1'>
<tr>
<td><strong>Adoptables ID:</strong></td>
<td><strong>Adoptables Type: </strong></td>
<td><strong>Adoptables Name: </strong></td>
<td><strong>Adoptables Owner: </strong></td>
<td><strong>Adoptables Gender: </strong></td>
<td><strong>Edit:</strong></td>
<td><strong>Delete:</strong></td>
</tr>";

// Get the adoptables from the database...

$query = "SELECT * FROM {$prefix}owned_adoptables";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$editimage = "<a href='admin.php?set=users&do=adoptables&more=edit&evenmore={$row['aid']}'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=users&do=adoptables&more=delete&evenmore={$row['aid']}'><img src='templates/icons/delete.gif' border=0></a>";


// Finally we can show this table to the user...

$article_content .= "<tr>
<td>{$row['aid']}</td>
<td>{$row['type']}</td>
<td><div align='center'>{$row['name']}</div></td>
<td><div align='center'>{$row['owner']}</div></td>
<td><div align='center'>{$row['gender']}</div></td>
<td><div align='center'>{$editimage}</div></td>
<td><div align='center'>{$deleteimage}</div></td>
</tr>";

}

$article_content .= "</table>";

}
elseif($more == "new")
{

// We are now creating a new adoptable
$article_title = "Create an adoptable for a user";
$article_content = "This page allows you to create a new adoptable for a given user on your site.
Please fill in the form below and hit the <i>Create Adoptable</i> button below when you're ready to create this adoptable.
<form name='form1' method='post' action='cadopt.php'>
<p><u><strong>Create A New Adoptable For a User:</strong></u></p>
<p><strong>Basic Information: </strong></p>
<p>
Adoptable Type:
<input name='type' type='text' id='type'>
</p>
<p>
Adoptable Name:
<input name='name' type='text' id='name'>
</p>
<p>
Adoptable Owner:
<input name='owner' type='text' id='owner'>
</p>
<p>
Adoptable Clicks:
<input name='clicks' type='text' id='clicks'>
</p>
<p>
Adoptable Level:
<input name='level' type='text' id='level'>
</p>
<p>
Use Alternative?
<input name='usealternates' type='text' id='usealternates'>
</p>
<p>
Adoptable Gender
<input name='gender' type='text' id='gender'>
</p>
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
</form>";
}
elseif($more == "edit")
{
// We are editing an existing owned adoptable.
// $evenmore is the adoptable ID...

$query = "SELECT * FROM {$prefix}owned_adoptables WHERE aid='$evenmore'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{
// This owned adoptable exists, so fetch some basic information...
$row = mysql_fetch_array($result);

$article_title = "Owned Adoptables Editor - Editing {$evenmore}'s Data";
$article_content = "Here you can edit this owned adoptable using the form below.<br />
<form name='form1' method='post' action='eadopt.php'>
<p>
Change Adoptable's Type:
<input name='type' type='text' id='type' value='{$row['type']}'>
</p>
<p>
Change Adoptable's Name:
<input name='name' type='text' id='name' value='{$row['name']}'>
</p>
<p>
Change Adoptable's Owner:
<input name='owner' type='text' id='owner' value='{$row['owner']}'>
</p>
<p>
Change Adoptable's total clicks:
<input name='totalclicks' type='text' id='totalclicks' value='{$row['totalclicks']}'>
</p>
<p>
Change Adoptable's current level:
<input name='currentlevel' type='text' id='currentlevel' value='{$row['currentlevel']}'>
</p>
<p>
Change Adoptable's gender:
<input name='gender' type='text' id='gender' value='{$row['gender']}'>
</p>
<input name='aid' type='hidden' id='aid' value='{$evenmore}'>
<p>
<input type='submit' name='Submit' value='Submit'>
</p>
</form>";
}
}
elseif($more == "delete")
{

// We are deleting an owned adoptable...

$query = "DELETE FROM {$prefix}owned_adoptables WHERE aid='{$evenmore}'";
runquery($query);

$article_title = "Adoptable Deleted";
$article_content = "This owned adoptable has been deleted successfully.";


}

}
elseif($do == "groups")
{

//************************************************** ************************************************** **
// USERGROUP MANAGEMENT PAGE HERE >>>
//************************************************** ************************************************** **

if($more == "")
{

// No action specified for the usergroups, so show some basic information...

$article_title = "Manage Usergroups";
$article_content = "This page allows you to manage the usergroups available to you and your site's users.
Usergroups are a powerful feature as they determine who can access what parts of
the site and which functions they can use. Here you can create and manage administrative user groups,
artist user groups, donator user groups, custom user groups, and more.
Use the table below to edit existing usergroups, or click the link below to create a custom usergroup.
<br /><br />
<b><a href='admin.php?set=users&do=groups&more=new'><img src='templates/icons/add.gif' border=0> Create a New Usergroup</a></b>
<table width='680' border='1'>
<tr>
<td><strong>Group ID:</strong></td>
<td><strong>Group Name: </strong></td>
<td><strong>Can Adopt Pets: </strong></td>
<td><strong>Can Use PM System: </strong></td>
<td><strong>Can Access Admin CP: </strong></td>
<td><strong>Edit:</strong></td>
<td><strong>Delete:</strong></td>
</tr>";

// Get the usergroups from the database...

$query = "SELECT * FROM {$prefix}groups";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

if($row['canadopt'] == "yes")
{
$canadoptimg = "<img src='templates/icons/yes.gif'>";
}
else
{
$canadoptimg = "<img src='templates/icons/no.gif'>";
}

if($row['canpm'] == "yes")
{
$canpmimg = "<img src='templates/icons/yes.gif'>";
}
else
{
$canpmimg = "<img src='templates/icons/no.gif'>";
}

if($row['cancp'] == "yes")
{
$cancpimg = "<img src='templates/icons/yes.gif'>";
}
else
{
$cancpimg = "<img src='templates/icons/no.gif'>";
}

if($row['groupname'] == "rootadmins" or $row['groupname'] == "registered")
{
$editimage = "";
$deleteimage = "";
}
else
{
$editimage = "<a href='admin.php?set=users&do=groups&more=edit&evenmore={$row['gid']}'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=users&do=groups&more=delete&evenmore={$row['gid']}'><img src='templates/icons/delete.gif' border=0></a>";

}

// Finally we can show this table to the user...

$article_content .= "<tr>
<td>{$row['gid']}</td>
<td>{$row['groupname']}</td>
<td><div align='center'>{$canadoptimg}</div></td>
<td><div align='center'>{$canpmimg}</div></td>
<td><div align='center'>{$cancpimg}</div></td>
<td><div align='center'>{$editimage}</div></td>
<td><div align='center'>{$deleteimage}</div></td>
</tr>";

}

$article_content .= "</table>";

}
elseif($more == "new")
{

// Show the user a form to make a new usergroup...

if($evenmore == "")
{

// We are showing a form to make a new usergroup...

$article_title = "Make a New Usergroup";
$article_content = "This page allows you to make a new usergroup. Type in the desired name of the new usergroup in the box below to get started.
Your usergroup will be created based on the registered usergroup's template.
You can then edit the group's settings as desired.<br />
<form name='form1' method='get' action='admin.php'>
<p>New Usergroup Name:</p>
<p>
<input name='evenmore' type='text' id='evenmore'>
<input name='set' type='hidden' id='set' value='users'>
<input name='do' type='hidden' id='do' value='groups'>
<input name='more' type='hidden' id='more' value='new'>
</p>
<p>
<input type='submit' name='Submit' value='Create New Usergroup'>
</p>
</form>";

}
else
{

// We are actually making the usergroup in the DB...

// First we check that a group with that name doesn't already exist...

$query = "SELECT * FROM {$prefix}groups WHERE groupname='{$evenmore}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{

// Group already exists, so show error...

$article_title = "Error";
$article_content = "A group already exists with the name specified.
Please <a href='admin.php?set=users&do=groups&more=new'>go back</a> and choose a different group name.";

}
else
{

// Create the usergroup...

runquery("INSERT INTO {$prefix}groups VALUES ('', '$evenmore', 'yes','yes','no','no', 'no', 'no','no','no')");

$article_title = "Group Created Successfully";
$article_content = "A usergroup with the name {$evenmore} has been created successfully.
Please <a href='admin.php?set=users&do=groups'>click here</a> to return to the group manager and edit this group";

}

}

}
elseif($more == "edit")
{

// We are editing an existing usergroup...
// $evenmore is the group ID...

$query = "SELECT * FROM {$prefix}groups WHERE gid='$evenmore'";
$result = runquery($query);

if(mysql_num_rows($result)> 0)
{

// The group exists, so fetch some basic group information...

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////

// WE ARE EDITING A SINGLE USERGROUP, NOT TO BE CONFUSED WITH THE CODE
// ABOVE TO SHOW ALL THE USERGROUPS IN A TABLE...

/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////

while ($row = mysql_fetch_array($result))
{

if($row['canadopt'] == "yes")
{
$canadoptimg = "<input name='canadopt' type='checkbox' id='canadopt' value='yes' checked> ";
}
else
{
$canadoptimg = "<input name='canadopt' type='checkbox' id='canadopt' value='yes'> ";
}

if($row['canpm'] == "yes")
{
$canpmimg = "<input name='canpm' type='checkbox' id='canpm' value='yes' checked>";
}
else
{
$canpmimg = "<input name='canpm' type='checkbox' id='canpm' value='yes'>";
}

if($row['cancp'] == "yes")
{
$cancpimg = "<input name='cancp' type='checkbox' id='cancp' value='yes' checked>";
}
else
{
$cancpimg = "<input name='cancp' type='checkbox' id='cancp' value='yes'>";
}

if($row['canmanageadopts'] == "yes")
{
$cmaimg = "<input name='canmanageadopts' type='checkbox' id='canmanageadopts' value='yes' checked>";
}
else
{
$cmaimg = "<input name='canmanageadopts' type='checkbox' id='canmanageadopts' value='yes'>";
}

if($row['canmanagecontent'] == "yes")
{
$cmcimg = "<input name='canmanagecontent' type='checkbox' id='canmanagecontent' value='yes' checked>";
}
else
{
$cmcimg = "<input name='canmanagecontent' type='checkbox' id='canmanagecontent' value='yes'>";
}

if($row['canmanageads'] == "yes")
{
$cmadsimg = "<input name='canmanageads' type='checkbox' id='canmanageads' value='yes' checked>";
}
else
{
$cmadsimg = "<input name='canmanageads' type='checkbox' id='canmanageads' value='yes'>";
}

if($row['canmanagesettings'] == "yes")
{
$cmsimg = "<input name='canmanagesettings' type='checkbox' id='canmanagesettings' value='yes' checked>";
}
else
{
$cmsimg = "<input name='canmanagesettings' type='checkbox' id='canmanagesettings' value='yes'>";
}

if($row['canmanageusers'] == "yes")
{
$cmuimg = "<input name='canmanageusers' type='checkbox' id='canmanageusers' value='yes' checked>";
}
else
{
$cmuimg = "<input name='canmanageusers' type='checkbox' id='canmanageusers' value='yes'>";
}

}

$article_title = "Editing {$row['groupname']} usergroup";
$article_content = "Here you can edit the settings for the {$row['groupname']} usergroup. Use the checkboxes below to
specify what parts of your site members of this group may access. A checked value is a YES value.<br />
<form name='form1' method='post' action='admpost.php'>
<p><strong><u>User Settings: </u></strong></p>
<p>
{$canadoptimg}
Users May Adopt Pets
</p>
<p>
{$canpmimg}
Users May Use PM System / Message System
</p>
<p><strong><u>Admin Settings: </u></strong></p>
<p>
{$cancpimg}
Users May Access the Admin CP (Required for any of the checkboxes below to take effect)
</p>
<p>
{$cmaimg}
Users May Create / Edit / Delete Adoptables and Upload Adoptable Images
</p>
<img src='templates/icons/warning.gif'> <b>WARNING:</b> Allowing users to access the adoptables settings
also allows users to upload files to your server.
Mysidia Adoptables Adoptables restricts the type of files a user may upload to this server,
however enabling a user to upload even image files should only be given to users
you trust as all images uploaded to your server count towards your web host's total storage quota for your account.<br /><br />
<p>
{$cmcimg}
Users May Create / Edit / Delete site pages and content
</p>
<p>
{$cmadsimg}
Users May Create / Edit / Delete sitewide advertisements
</p>
<p>
{$cmsimg}
Users May Change / Alter site settings
</p>
<p>
{$cmuimg}
Users May Edit / Delete / Alter user accounts and passwords
</p>
<p>
<img src='templates/icons/warning.gif'>
<b>WARNING:</b> Allowing users to access the user accounts portion of the
Admin CP may allow them to delete admin accounts,
so only give this privledge to users you trust.
<input name='page' type='hidden' id='page' value='groups'>
<input name='groupid' type='hidden' id='groupid' value='{$row['gid']}'>
</p>
<p>
<input type='submit' name='Submit' value='Edit Usergroup'>
</p>
</form>";

}
else
{

$article_title = "Invalid Group Specified";
$article_content = "The group specified does not appear to exist in the database. <a href='admin.php?set=users&do=groups'>Click Here</a> to return to the groups manager.</a>";

}


}
elseif($more == "delete")
{

// We are deleting a usergroup...

$query = "DELETE FROM {$prefix}groups WHERE gid='{$evenmore}'";
runquery($query);

$article_title = "Usergroup Deleted";
$article_content = "The usergroup has been deleted successfully.";

}
else
{

$article_title = "Error";
$article_content = "Error. Action does not exist!";

}

}
elseif($do == "delete")
{
//We are deleting a user from the system...

deleteuser($more);
$article_title = "User Deleted";
$article_content = "The user has been deleted from the database successfully.
<a href='admin.php?set=users'>Click Here</a> to return to the user manager.";

}
else
{
//No action, show the users table
$article_title = "Manage Users";
$article_content = "This page allows you to manage your site's users.
Use the table below to manage users.
If you know the name of a user you want to edit you can type their name in the search box
below to quickly edit them.<br />
<form name='form1' method='get' action='admin.php'>
<p>
Edit User:
<input name='more' type='text' id='more'>
<input name='set' type='hidden' id='set' value='users'>
<input name='do' type='hidden' id='do' value='edit'>
<input type='submit' name='Submit' value='Edit User'>
</p>
</form>
<b><a href='admin.php?set=users&do=adoptables'><img src='templates/icons/fr.gif' border=0> Manage User's Owned Adoptables</a>
</b><br />
</p><b><a href='admin.php?set=users&do=groups'><img src='templates/icons/fr.gif' border=0> Manage Usergroups and Permissions</a></b>
<br />
<table width='302' border='1'>
<tr>
<td width='100'><strong>Username:</strong></td>
<td width='60'><strong>Email:</strong></td>
<td width='60'><strong>Usergroup:</strong></td>

<td width='32'><strong>Edit:</strong></td>
<td width='50'><strong>Delete:</strong></td>
</tr>";

//Begin the output from the database to show the users...

$query = "SELECT * FROM {$prefix}users ORDER BY uid DESC";
$result = runquery($query);

$rowsperpage = 20;
$totalpages = ceil(mysql_num_rows($result) / $rowsperpage);

if(is_numeric($more))
{
$currentpage = $more;
}
else
{
$currentpage = 1;
}

if ($currentpage > $totalpages)
{
$currentpage = $totalpages;
}
if ($currentpage < 1)
{
$currentpage = 1;
}
$offset = ($currentpage - 1) * $rowsperpage;

$query = "SELECT * FROM {$prefix}users ORDER BY uid DESC LIMIT $offset, $rowsperpage";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$article_content .= "<tr>
<td><b><a href='profile.php?user={$row['username']}' target='_blank'>{$row['username']}</a></b></td>
<td><a href='mailto:{$row['email']}'>{$row['email']}</a></td>
<td><center>{$row['usergroup']}</center></td>
<td><center><a href='admin.php?set=users&do=edit&more={$row['username']}'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td><center><a href='admin.php?set=users&do=delete&more={$row['username']}'><img src='templates/icons/delete.gif' border=0></a></center></td>
</tr>";
}

$article_content .= "</table><br />";


if($currentpage > 1)
{
$newpage = $currentpage - 1;
$article_content = $article_content."<a href='admin.php?set=users&more={$newpage}'>Previous Page</a> ";
}
if($currentpage < $totalpages)
{
$newpage = $currentpage + 1;
$article_content = $article_content."<a href='admin.php?set=users&more={$newpage}'>Next Page</a> ";
}

}

}
else
{

$article_title = "Access Denied";
$article_content = "Your usergroup does not seem to have the permission to edit the user based settings...";

}

} // End the users=content block ... start a new setting here...

elseif($set == "items"){
if($canedit == "yes")
{

if($do == ""){
//Show the list of editable settings.
$article_title = "Add / Edit / Manage Items/Shops";
$article_content = "Here you can add or edit the items and shops that are available to your site's visitors.
Please choose an option below...<br /><br />
<a href='admin.php?set=items&do=newitem'>Create a New Item</a><br />
<a href='admin.php?set=items&do=manageitem'>Manage an Existing Item</a><br /><br />
<a href='admin.php?set=items&do=newshop'>Add a New Shop</a><br />
<a href='admin.php?set=items&do=manageshop'>Manage an Existing Shop</a><br /><br />
<a href='admin.php?set=items&do=newinventory'>Give an Item to User</a><br />
<a href='admin.php?set=items&do=manageinventory'>Manage User's Item</a><br /><br />";
}
else if($do == "newitem"){
//We are creating a new item now!

$article_title = "Create a new item";
$article_content = "This page allows you to create a new item that will be available to your site's visitors.
Please fill in the form below and hit the <i>Create Item</i> button below when you're ready.
<form name='form1' method='post' action='itempost.php?act=items&page=new'>
<p><u><strong>Create A New Item:</strong></u></p>
<p><strong>Basic Info: </strong></p>
<p>
Item Name:
<input name='itemname' type='text' id='itemname'>
<br />
(This may contain only letters, numbers and spaces)
</p>
<p>
Item Category:
<input name='category' type='text' id='category'>
<br />
(The item category is used to identify items of the same type)
</p>
<p>Item Description:</p>
<p>
<textarea name='description' cols='45' rows='4' id='description'></textarea>
</p>
<p>
Item Image:
<input name='imageurl' type='text' id='imageurl'>
<br />
(Use a full image path, beginning with http://)
</p>
<p>
OR select an existing image:
<select name='existingimageurl' id='existingimageurl'>
<option value='none' selected>No Existing Image</option>{$dynimages}
</select>
</p>
<hr />
<p><strong>Items Functions and Usage:</strong></p>
Choose an item function from the list below, this will determine what happens to this item if used in inventory:
<select name='function'>";

// We need to stop here and fetch our usergroups...

$query = "SELECT function FROM adopts_items";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{
$article_content .= "<option value='{$row['function']}'>{$row['function']}</option>";
}

$article_content .= "</select></p>
<p>
Now lets decide what adoptables(id) can use the very item you are creating, each adoptable's id should be separated by
comma, an example is: 1,5,9,13<br />
Enter <strong>all</strong> if you want your item applicable to all adoptables, or leave it blank if no adoptable can use it.
<input name='target' type='text' id='target'>
</p>
<p>You may also assign a unique value to the item: <br />
(This is important for item functions such as Level and Click, since you will need to specify how many points of levels/clicks an item can raise)
<input name='value' type='text' id='value'>
</p>
<hr />
<p><strong>Item Shop Settings:</strong></p>
<p>
Item Shop:
<input name='shop' type='text' id='shop'>
<br />
(Leave this field blank if you do not want users to buy it from itemshops)
</p>
<p>
Item Price:
<input name='price' type='text' id='price'>
<br />
(Enter a non-negative value for the price set on your item)
</p>
<hr />
<p><strong>Miscellaneous Settings:</strong></p>
<p><strong>
<input name='tradable' type='checkbox' id='tradable' value='yes'>
The item can be traded.</strong>
</p>
<p><strong>
<input name='consumable' type='checkbox' id='consumable' value='yes'>
The item can be consumed(thus its quantity decreases by 1 each time used).</strong>
</p>
<p>
<input name='act' type='hidden' id='act' value='items'>
<input name='page' type='hidden' id='page' value='new'>
<input type='submit' name='Submit' value='Create Item'>
</p>
</form>";
}
else if($do == "manageitem"){
if($more == ""){
//Show the item list!
$article_title = "Here is a list of items available";
$article_content = "<table border='1'>
<tr>
<th>Image</th><th>Item</th><th>Description</th><th>Function</th><th>Edit</th><th>Delete</th>
</tr>";
$query = "SELECT * FROM {$prefix}items";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$editimage = "<a href='admin.php?set=items&do=manageitem&more=edit&evenmore={$row['id']}'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=items&do=manageitem&more=delete&evenmore={$row['id']}'><img src='templates/icons/delete.gif' border=0></a>";


// Finally we can show this table to the user...

$article_content .= "<tr>
<td><div align='center'><img src='{$row['imageurl']}'></div></td>
<td><div align='center'>{$row['itemname']}</div></td>
<td><div align='center'>{$row['description']}</div></td>
<td><div align='center'>{$row['function']}</div></td>
<td><div align='center'>{$editimage}</div></td>
<td><div align='center'>{$deleteimage}</div></td>
</tr>";

}

$article_content .= "</table>";
}

else if($more == "edit"){
$query = "SELECT * FROM {$prefix}items WHERE id='{$evenmore}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{
// This owned adoptable exists, so fetch some basic information...
$item = mysql_fetch_array($result);

$article_title = "Edit item";
$article_content = "This page allows you to edit an item that you have created.
Please fill in the form below and hit the <i>Edit Item</i> button below when you're ready.
<form name='form1' method='post' action='itempost.php?act=items&page=edit'>
<p><u><strong>Edit An Item:</strong></u></p>
<p><strong>Basic Info: </strong></p>
<p>
Item Name:
<input name='itemname' type='text' id='itemname' value='{$item['itemname']}'>
<br />
(This may contain only letters, numbers and spaces)
</p>
<p>
Item Category:
<input name='category' type='text' id='category' value='{$item['category']}'>
<br />
(The item category is used to identify items of the same type)
</p>
<p>
Item Image:
<input name='imageurl' type='text' id='imageurl' value='{$item['imageurl']}'>
<br />
(Use a full image path, beginning with http://)
</p>
<hr />
<p><strong>Items Functions and Usage:</strong></p>
Choose an item function from the list below, this will determine what happens to this item if used in inventory:
<select name='function'>";

// We need to stop here and fetch our usergroups...

$query2 = "SELECT function FROM adopts_items";
$result2 = runquery($query2);

while ($row = mysql_fetch_array($result2))
{
$article_content .= "<option value='{$row['function']}'>{$row['function']}</option>";
}

$article_content .= "</select></p>
<p>
Now lets decide what adoptables(id) can use the very item you are creating, each adoptable's id should be separated by
comma, an example is: 1,5,9,13<br />
Enter <strong>all</strong> if you want your item applicable to all adoptables, or leave it blank if no adoptable can use it.
<input name='target' type='text' id='target' value='{$item['target']}'>
</p>
<p>You may also assign a unique value to the item: <br />
(This is important for item functions such as Level and Click, since you will need to specify how many points of levels/clicks an item can raise)
<input name='value' type='text' id='value' value='{$item['value']}'>
</p>
<hr />
<p><strong>Item Shop Settings:</strong></p>
<p>
Item Shop:
<input name='shop' type='text' id='shop' value='{$item['shop']}'>
<br />
(Leave this field blank if you do not want users to buy it from itemshops)
</p>
<p>
Item Price:
<input name='price' type='text' id='price' value='{$item['price']}'>
<br />
(Enter a non-negative value for the price set on your item)
</p>
<hr />
<p><strong>Miscellaneous Settings:</strong></p>
<p><strong>
<input name='tradable' type='checkbox' id='tradable' value='yes'>
The item can be traded.</strong>
</p>
<p><strong>
<input name='consumable' type='checkbox' id='consumable' value='yes'>
The item can be consumed(thus its quantity decreases by 1 each time used).</strong>
</p>
<p>
<input name='id' type='hidden' id='id' value='{$item['id']}'>
<input name='act' type='hidden' id='act' value='items'>
<input name='page' type='hidden' id='page' value='edit'>
<input type='submit' name='Submit' value='Edit Item'>
</p>
</form>";
}
}
else if($more =="delete"){
$query = "SELECT * FROM {$prefix}items WHERE id='{$evenmore}'";
$result = runquery($query);
$item = mysql_fetch_array($result);
$article_title = "Confirm your action";
$article_content = "Are you sure you wish to delete the item {$item['itemname']}?<br>
It will be permanently removed from your database, and this action cannot be undone!<br><br>
<form name='form1' method='post' action='itempost.php?act=items&page=delete'>
<input name='id' type='hidden' id='id' value='{$item['id']}'>
<input name='itemname' type='hidden' id='itemname' value='{$item['itemname']}'>
<input name='act' type='hidden' id='act' value='items'>
<input name='page' type='hidden' id='page' value='delete'>
<p>
<input type='submit' name='Submit' value='Delete'>
</p>
</form>";
}
}
else if($do == "newshop"){
//We are creating a new shop now!

$article_title = "Create a new shop";
$article_content = "This page allows you to create a new shop that will be available to your site's visitors.
Please fill in the form below and hit the <i>Create Shop</i> button below when you're ready.
<form name='form1' method='post' action='itempost.php?act=shops&page=new'>
<p><u><strong>Create A New Shop:</strong></u></p>
<p><strong>Basic Info: </strong></p>
<p>
Shop Name:
<input name='shopname' type='text' id='shopname'>
<br />
(This may contain only letters, numbers and spaces)
</p>
<p>
Shop Category:
<input name='category' type='text' id='category'>
<br />
(Note: Shop category is different from Item Category)
</p>
<p>Shop Description:</p>
<p>
<textarea name='description' cols='45' rows='4' id='description'></textarea>
</p>
<p>
Shop Image:
<input name='imageurl' type='text' id='imageurl'>
<br />
(Use a full image path, beginning with http://)
</p>
<p>
OR select an existing image:
<select name='existingimageurl' id='existingimageurl'>
<option value='none' selected>No Existing Image</option>{$dynimages}
</select>
</p>
<hr />
<p><strong>Miscellaneous Settings:</strong></p>
<p>
Shop Status:
<input name='status' type='text' id='status'>
<br />
(Only three values are applicable here: open, closed and invisible)
</p>
<p>
Restriction:
<input name='restriction' type='text' id='restriction'>
<br />
(Enter the usergroup ids that are forbidden to buy items in this shop, separated by comma)
</p>
<p>
Sales Tax:
<input name='salestax' type='text' id='salestax'>%
<br />
(Enter a non-negative value to determine how much tax users should pay in order to purchase from this shop)
</p>
<p>
<input name='act' type='hidden' id='act' value='shops'>
<input name='page' type='hidden' id='page' value='new'>
<input type='submit' name='Submit' value='Create Shop'>
</p>
</form>";
}
else if($do == "manageshop"){
if($more == ""){
//Show the shop list!
$article_title = "Here is a list of shops you have created";
$article_content = "<table border='1'>
<tr>
<th>Image</th><th>Shop</th><th>Description</th><th>Status</th><th>Edit</th><th>Delete</th>
</tr>";
$query = "SELECT * FROM {$prefix}shops";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$editimage = "<a href='admin.php?set=items&do=manageshop&more=edit&evenmore={$row['sid']}'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=items&do=manageshop&more=delete&evenmore={$row['sid']}'><img src='templates/icons/delete.gif' border=0></a>";


// Finally we can show this table to the user...

$article_content .= "<tr>
<td><div align='center'><img src='{$row['imageurl']}'></div></td>
<td><div align='center'>{$row['shopname']}</div></td>
<td><div align='center'>{$row['description']}</div></td>
<td><div align='center'>{$row['status']}</div></td>
<td><div align='center'>{$editimage}</div></td>
<td><div align='center'>{$deleteimage}</div></td>
</tr>";

}

$article_content .= "</table>";
}

else if($more == "edit"){
$query = "SELECT * FROM {$prefix}shops WHERE sid='{$evenmore}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{
// This owned adoptable exists, so fetch some basic information...
$shop = mysql_fetch_array($result);

$article_title = "Edit shop";
$article_content = "This page allows you to edit a shop that you have already created.
Please fill in the form below and hit the <i>Edit Shop</i> button below when you're ready.
<form name='form1' method='post' action='itempost.php?act=shops&page=edit'>
<p><u><strong>Create A New Shop:</strong></u></p>
<p><strong>Basic Info: </strong></p>
<p>
Shop Name:
<input name='shopname' type='text' id='shopname' value='{$shop['shopname']}'>
<br />
(This may contain only letters, numbers and spaces)
</p>
<p>
Shop Category:
<input name='category' type='text' id='category' value='{$shop['category']}'>
<br />
(Note: Shop category is different from Item Category)
</p>
<p>
Shop Image:
<input name='imageurl' type='text' id='imageurl' value='{$shop['imageurl']}'>
<br />
(Use a full image path, beginning with http://)
</p>
<hr />
<p><strong>Miscellaneous Settings:</strong></p>
<p>
Shop Status:
<input name='status' type='text' id='status' value='{$shop['status']}'>
<br />
(Only three values are applicable here: open, closed and invisible)
</p>
<p>
Restriction:
<input name='restriction' type='text' id='restriction' value='{$shop['restriction']}'>
<br />
(Enter the usergroup ids that are forbidden to buy items in this shop, separated by comma)
</p>
<p>
Sales Tax:
<input name='salestax' type='text' id='salestax' value='{$shop['salestax']}'>%
<br />
(Enter a non-negative value to determine how much tax users should pay in order to purchase from this shop)
</p>
<p>
<input name='sid' type='hidden' id='sid' value='{$shop['sid']}'>
<input name='act' type='hidden' id='act' value='shops'>
<input name='page' type='hidden' id='page' value='edit'>
<input type='submit' name='Submit' value='Edit Shop'>
</p>
</form>";
}
}
else if($more =="delete"){
$query = "SELECT * FROM {$prefix}shops WHERE sid='{$evenmore}'";
$result = runquery($query);
$shop = mysql_fetch_array($result);
$article_title = "Confirm your action";
$article_content = "Are you sure you wish to delete the item {$shop['shopname']}?<br>
It will be permanently removed from your database, and this action cannot be undone!<br><br>
<form name='form1' method='post' action='itempost.php?act=items&page=delete'>
<input name='id' type='hidden' id='id' value='{$shop['sid']}'>
<input name='shopname' type='hidden' id='shopname' value='{$shop['shopname']}'>
<input name='sid' type='hidden' id='sid' value='{$shop['sid']}'>
<input name='act' type='hidden' id='act' value='shops'>
<input name='page' type='hidden' id='page' value='delete'>
<p>
<input type='submit' name='Submit' value='Delete'>
</p>
</form>";
}
}
else if($do == "newinventory"){
//We are inserting an item for user now!

$article_title = "Give an Item to User";
$article_content = "This page allows you to give an item to a certain user.
Please fill in the form below and hit the <i>Give Item</i> button below when you're ready.
<form name='form1' method='post' action='itempost.php?act=inventory&page=new'>
<p><u><strong>Give an Item to User:</strong></u></p>
<p><strong>Basic Info: </strong></p>
<p>
Item Name:
<input name='itemname' type='text' id='itemname'>
<br />
(This may contain only letters, numbers and spaces)
</p>
<p>
Item Owner:
<input name='owner' type='text' id='owner'>
</p>
<p>
Item Quantity:
<input name='quantity' type='text' id='quantity'>
</p>
<p>
<input name='act' type='hidden' id='act' value='inventory'>
<input name='page' type='hidden' id='page' value='new'>
<input type='submit' name='Submit' value='Give Item'>
</p>
</form>";
}
else if($do == "manageinventory"){
if($more == ""){
//Show the shop list!
$article_title = "Here is a list of owned items for your members";
$article_content = "<table border='1'>
<tr>
<th>ID</th><th>Item</th><th>Owner</th><th>Quantity</th><th>Edit</th><th>Delete</th>
</tr>";
$query = "SELECT * FROM {$prefix}inventory";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

$editimage = "<a href='admin.php?set=items&do=manageinventory&more=edit&evenmore={$row['iid']}'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=items&do=manageinventory&more=delete&evenmore={$row['iid']}'><img src='templates/icons/delete.gif' border=0></a>";


// Finally we can show this table to the user...

$article_content .= "<tr>
<td><div align='center'>{$row['iid']}</div></td>
<td><div align='center'>{$row['itemname']}</div></td>
<td><div align='center'>{$row['owner']}</div></td>
<td><div align='center'>{$row['quantity']}</div></td>
<td><div align='center'>{$editimage}</div></td>
<td><div align='center'>{$deleteimage}</div></td>
</tr>";

}

$article_content .= "</table>";
}

else if($more == "edit"){
$query = "SELECT * FROM {$prefix}inventory WHERE iid='{$evenmore}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{
// This owned adoptable exists, so fetch some basic information...
$inventory = mysql_fetch_array($result);

$article_title = "Edit User's Inventory";
$article_content = "This page allows you to edit an owned item for certain users.
Please fill in the form below and hit the <i>Edit User's Item</i> button below when you're ready.
<form name='form1' method='post' action='itempost.php?act=inventory&page=edit'>
<p><u><strong>Edit User's Items:</strong></u></p>
<p><strong>Basic Info: </strong></p>
<p>
Item Name:
<input name='itemname' type='text' id='itemname' value='{$inventory['itemname']}'>
<br />
(This may contain only letters, numbers and spaces)
</p>
<p>
Item Owner:
<input name='owner' type='text' id='owner' value='{$inventory['owner']}'>
</p>
<p>
Item Quantity:
<input name='quantity' type='text' id='quantity' value='{$inventory['quantity']}'>
</p>
<p>
<input name='iid' type='hidden' id='iid' value='{$inventory['iid']}'>
<input name='category' type='hidden' id='category' value='{$inventory['category']}'>
<input name='status' type='hidden' id='status' value='{$inventory['status']}'>
<input name='act' type='hidden' id='act' value='inventory'>
<input name='page' type='hidden' id='page' value='edit'>
<input type='submit' name='Submit' value='Edit User's Item'>
</p>
</form>";
}
}
else if($more =="delete"){
$query = "SELECT * FROM {$prefix}inventory WHERE iid='{$evenmore}'";
$result = runquery($query);
$shop = mysql_fetch_array($result);
$article_title = "Confirm your action";
$article_content = "Are you sure you wish to delete the item {$inventory['itemname']} for user {$inventory['owner']}?<br>
It will be permanently removed from your database, and this action cannot be undone!<br><br>
<form name='form1' method='post' action='itempost.php?act=inventory&page=delete'>
<input name='itemname' type='hidden' id='itemname' value='{$inventory['itemname']}'>
<input name='owner' type='hidden' id='owner' value='{$inventory['owner']}'>
<input name='iid' type='hidden' id='iid' value='{$inventory['iid']}'>
<input name='act' type='hidden' id='act' value='inventory'>
<input name='page' type='hidden' id='page' value='delete'>
<p>
<input type='submit' name='Submit' value='Delete'>
</p>
</form>";
}
}
}
else
{

$article_title = "Access Denied";
$article_content = "Your usergroup does not seem to have the permission to edit items and shops...";

}
}


elseif($set == "settings")
{

//************************************************** *******************************
// HERE IS THE CODE THAT MANAGES CHANGING BASIC SITE SETTINGS...
//************************************************** *******************************

if($canedit == "yes")
{

if($do == "")
{

// No setting was specified, so show the user their choices...

$article_title = "Site Settings";
$article_content = "Here you can manage the settings for your site.
Click on a setting below to view or change its current configuration.<br /><br />
<b><u>Site Settings:</u></b><br />
<a href='admin.php?set=settings&do=basic'>View or Edit Basic Site Settings</a><br />
<a href='admin.php?set=settings&do=themes'>View or Edit Theme and Template Settings</a><br />
<a href='admin.php?set=settings&do=links'>View or Edit Site Navigation Links</a><br />
<a href='admin.php?set=settings&do=gd'>View or Edit Adoptable Signature Image Settings / GD Settings</a><br /><br />";

// Start plugin hooks...

$article_content .= "<b><u>Plugin Settings:</u></b><br />
Listed here are all of the plugins that are using hooks to interface with the Mysidia Adoptables Admin CP.
Clicking on a link below will redirect you to a page generated by the respecive plugin where you can change plugin-specific settings.<br /><br />";

$query = "SELECT * FROM {$prefix}acp_hooks";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{

while ($row = mysql_fetch_array($result))
{

$article_content .= "<a href='{$row['linkurl']}'>{$row['linktext']}</a> - Generated by the <b>{$row['pluginname']}</b> plugin";

}
}
else
{
$article_content = $article_content."<b>There are currently no plugin hooks present.</b>";
}

}
elseif($do == "basic")
{

// We are editing the basic site settings, such as title, etc...

$article_title = "Basic Site Settings";
$article_content = "This page allows you to edit the basic settings for your Mysidia Adoptables installation.
Fill out the form below to change the settings.
Settings which need further explanation will have more information next to their area on the form.<br />
<form name='form1' method='post' action='admpost.php'>
<p>Site Name: <input name='sitename' type='text' id='sitename' value='".grabanysetting("sitename")."'></p>
<p>Site Title: <input name='browsertitle' type='text' id='browsertitle' value='".grabanysetting("browsertitle")."'></p>
<p>Currency Name: <input name='cost' type='text' id='cost' value='".grabanysetting("cost")."'></p>
<p>Start Money: <input name='startmoney' type='text' id='startmoney' value='".grabanysetting("startmoney")."'></p>
<p>Site Slogan: <input name='slogan' type='text' id='slogan' value='".grabanysetting("slogan")."'></p>
<p>Admin Email: <input name='admincontact' type='text' id='admincontact' value='".grabanysetting("admincontact")."'></p>
<p>Mail From: <input name='systememail' type='text' id='systememail' value='".grabanysetting("systememail")."'> </p>
<p>Trade Enabled: <input name='enabletrades' type='text' id='enabletrades' value='".grabanysetting("enabletrades")."'> </p>
<p>Trade offer Cost: <input name='tradeoffercost' type='text' id='tradeoffercost' value='".grabanysetting("tradeoffercost")."'> </p>
<p>Trade Completion Cost: <input name='tradecost' type='text' id='tradecost' value='".grabanysetting("tradecost")."'> </p>
<p>Breeding Wait: <input name='breedinginterval' type='text' id='breedinginterval' value='".grabanysetting("breedinginterval")."'> </p>
<p>Breeding Level: <input name='breedinglevel' type='text' id='breedinglevel' value='".grabanysetting("breedinglevel")."'> </p>
<p>Levelup Money: <input name='rewardmoney' type='text' id='rewardmoney' value='".grabanysetting("rewardmoney")."'> </p>

<input name='page' type='hidden' id='page' value='basicsettings'>
<p><input type='submit' name='Submit' value='Change Settings'></p>
</form>";

}
elseif($do == "links")
{

// We are editing the links for this site...

if($more == "")
{

// We are not editing a specific link

$article_title = "Link Editor";
$article_content = "Here you can edit the navigation links for your site.
You may add, edit or delete links here on this page.
This makes customizing your site and link text very easy.
<br /><br />
<b><a href='admin.php?set=settings&do=links&more=new'><img src='templates/icons/add.gif' border=0> Add a new link</a></b>
<p><b><u>Your Existing Links:</u></b></p>
<table width='575' border='1'>
<tr>
<td width='150'><strong>Link URL: </strong></td>
<td width='175'><strong>Link Text: </strong></td>
<td width='32'><strong>Edit:</strong></td>
<td width='51'><strong>Delete:</strong></td>
</tr>";

$query = "SELECT * FROM {$prefix}links ORDER BY id ASC";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

if($lid < 6)
{
$showdelete = "";
}
else
{
$showdelete = "<center><a href='admin.php?set=settings&do=links&more=delete&evenmore={$row['id']}'><img src='templates/icons/delete.gif' border=0></a></center>";
}

$article_content .= "<tr>
<td>{$row['linkurl']}</td>
<td>{$row['linktext']}</td>
<td><center><a href='admin.php?set=settings&do=links&more=edit&evenmore={$row['id']}'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td>{$showdelete}</td>
</tr>";

}

$article_content .= "</table>";

}
elseif($more == "edit")
{

// We are editing a specific link...
// Select from the database where the link is...

$query = "SELECT * FROM {$prefix}links WHERE id='{$evenmore}'";
$result = runquery($query);
$row = mysql_fetch_array($result);
$row['linktext'] = stripslashes($row['linktext']);

if($row['id'] == $evenmore)
{

// The link exists, so let's edit it...

if($row['id'] < 6)
{

// Special link, so we cannot change the location...

$lurlform = "<input name='linkurl' type='text' id='linkurl' value='{$row['linkurl']}' readonly='readonly'>";

}
else
{
$lurlform = "<input name='linkurl' type='text' id='linkurl' value='{$row['linkurl']}'>";
}

$article_title = "Editing a Link";
$article_content = "Here you can edit a link that you have previously created.
You may edit the link text here.
In addition, you may modify the link's URL if the link is not a special link.<br />
<form name='form1' method='post' action='admpost.php'>
<p>
Link Text:
<input name='linktext' type='text' id='linktext' value='{$row['linktext']}'>
</p>
<p>Type the text that will appear for the new link.</p>
<p>
Link URL:
{$lurlform}
</p>
<p>
Type the location of where this link will lead.
This can either be a local file location, such as index.php,
or this can be a link to an outside webpage. If linking to an outside webpage, your Link URL must begin with http://.
<input name='page' type='hidden' id='page' value='editlink'>
<input name='linkid' type='hidden' id='linkid' value='{$evenmore}'>
</p>
<p>
<input type='submit' name='Submit' value='Edit Link'>
</p>
</form>";

}
else
{

$article_title = "Link Not Found";
$article_content = "The link could not be found in the database. Please go back and try again.";

}

}
elseif($more == "delete")
{

// We are deleting a link...
// Just run a straight-up delete query on the link...

$query = "DELETE FROM {$prefix}links WHERE id='{$evenmore}'";
runquery($query);

$article_title = "Link Deleted Successfully";
$article_content = "Your link has been deleted successfully. <a href='admin.php?set=settings&do=links'>Click Here</a> to return to the link manager.";

}
elseif($more == "new")
{

// We are creating a new link...
// Show the form to make the link...

$article_title = "Create a New Link";
$article_content = "This page allows you to create a new link that will appear in your site's navigation.
Use the form below to create a new link.<br />
<form name='form1' method='post' action='admpost.php'>
<p>
Link Text:
<input name='linktext' type='text' id='linktext'>
</p>
<p>Type the text that will appear for the new link. </p>
<p>
Link URL:
<input name='linkurl' type='text' id='linkurl'>
</p>
<p>
Type the location of where this link will lead.
This can either be a local file location, such as index.php,
or this can be a link to an outside webpage.
If linking to an outside webpage, your Link URL must begin with http://.
<input name='page' type='hidden' id='page' value='newlink'>
</p>
<p>
<input type='submit' name='Submit' value='Add Link'>
</p>
</form>
<img src='templates/icons/warning.gif'> <b>Template Warning:</b>
Adding more links than your current template was designed to handle may cause issues with the way your site looks.
If you notice that some links do not appear on your site,
appear in the wrong place, or are otherwise causing problems,
it is probably because you have more links than your current theme allows for.
If this is the case you can either delete some links or change your site's template to one that supports more links.";

}
else
{

$article_title = "Invalid Action Specified";
$article_content = "The action specified is invalid. Please go back and try again.";

}

}
elseif($do == "themes")
{

// Theme based settings...

if($more == "" or $more == "sel")
{

// Grab all of our themes...

$article_title = "Theme Manager";
$article_content = "This page allows you to change the theme for your website.
Themes allow you to style your website.
You can select a theme to use from the dropdown list below or you can
install a new theme to your site using the theme installation form below.
To get more themes please visit the
<a href='http://www.mysidiaadoptables.com/forum' target='_blank'>Mysidia Adoptables Support Forums</a>.<br />
<br /><b><u>Select a Theme:</u></b><br />
<form name='form1' method='get' action='admin.php'>
<p>
<select name='more' id='more'>
<option value='sel' selected>Select a Theme...</option>";

$query = "SELECT * FROM {$prefix}themes";
$result = runquery($query);

while ($row = mysql_fetch_array($result))
{

if($row['themename'] == "")
{
$row['themename'] = "Unnamed Theme :: {$row['themeurl']}";
}

$article_content .= " <option value='{$row['id']}'>{$row['themename']}</option>";

}

$article_content .= " </select>
<input name='set' type='hidden' id='set' value='settings'>
<input name='do' type='hidden' id='do' value='themes'>
</p>
<p>
<input type='submit' name='Submit' value='Use This Theme'>
</p>
</form>
<b><u>Install a Theme:</u></b><br /><br />
<form name='form1' method='post' action='admpost.php'>
<p>Theme Name:
<input name='themename' type='text' id='themename'>
</p>
<p>Type a name to use for this theme. This should be something to help you remember what this theme looks like.</p>
<p>Theme URL:
<input name='themeurl' type='text' id='themeurl'>
</p>
<p>This is the path to the theme's HTML file on your server. Usually the theme author will give you this value to paste into this box.
<input name='page' type='hidden' id='page' value='newtheme'>
</p>
<p>
<input type='submit' name='Submit' value='Install Theme'>
</p>
</form>";

}
else
{

// We are changing the theme...

// Pull up the inputted theme's info...

$query = "SELECT * FROM {$prefix}themes WHERE id='{$more}'";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_array($result);

// Update the theme URL in the DB...

$query = "UPDATE {$prefix}settings SET value='{$row['themeurl']}' WHERE name='themeurl'";
runquery($query);

$article_title = "Theme Updated Successfully";
$article_content = "The theme has been changed successfully! <a href='admin.php?set=settings'>Click Here</a> to change the site settings.</a>";

}
else
{

$article_title = "Invalid Theme Selected";
$article_content = "It appears that the theme you selected is invalid or does not exist. Please go back and try selecting another theme.";

}

}

}
elseif($do == "gd")
{

// The GD image settings and BBCode settings...

$gdstatus = grabanysetting("gdimages");
$altbbstatus = grabanysetting("usealtbbcode");

// Form fanagaling here...

$gdform = "<input name='enablegd' type='checkbox' id='enablegd' value='yes'>";

if($gdstatus == "yes")
{
$gdform = "<input name='enablegd' type='checkbox' id='enablegd' value='yes' checked>";
}

$altform = "<input name='altbb' type='checkbox' id='altbb' value='yes'>";

if($altbbstatus == "yes")
{
$altform = "<input name='altbb' type='checkbox' id='altbb' value='yes' checked>";
}

// Output content...

$article_title = "Signature Settings";
$article_content = "This page allows you to change settings related to how the script handles adoptable signature images generated by the BBCode generator.
<form name='form1' method='post' action='admpost.php'>
<p>
{$gdform}
Enable GD Signature Images for GIF files
</p>
<p>
If you enable GD Signature Images for GIF files then all adoptables that use GIF files for their images
will have their signature images modified by the GD image library before being output by the system.
Enabling this setting will put the adoptable's name and owner on the image
for the adoptable that is served by this server.
Please note that if GD is not installed or enabled on this server this setting will
not take effect and all images will fall back to the default method of showing signature images.
</p>
<p>
{$altform}
Enable Alternate Friendly Signature BBCode
</p>
<p>
If you enable this setting then an additional set of BBCode will be shown for all adoptables that will convert URLs such as /siggy.php?id=20 to URLs such as /get/20.gif. You should only enable this if you have uploaded and edited the modified .htaccess file so that users can access the pets at their friendly URLs. If you have not uploaded the .htaccess file required for this then users who use the alternate BBCodes will not have their signature images work properly.
<input name='page' type='hidden' id='page' value='gd'>
</p>
<p>
<input type='submit' name='Submit' value='Change Settings'>
</p>
</form>";

}
elseif($do == "somethingelseagain")
{

// Huh...?

}
else
{

$article_title = "The setting does not exist.";
$article_content = "Error. The specified setting does not exist!";

}

}
else
{

$article_title = "Access Denied";
$article_content = "Your usergroup does not seem to have the permission to edit the user based settings...";

}

} // End the settings content block .. start a new setting here...
elseif($set == "ads")
{

// We are managing the ads for the site...

if($canedit == "yes")
{

///////////////////////////////////////////////////////////////////////////////////////////////////////
// BEGIN AD MANAGEMENT - MOST OF THIS IS STRAIGHT FROM MAX VOLUME'S ACP - YAY - LESS WORK...
///////////////////////////////////////////////////////////////////////////////////////////////////////

if($do == "")
{

$article_title = "Ad Management";
$article_content .= "Here you can manage your ad campaigns.
Listed below are all the ads currently running on your website.
<b><a href='admin.php?set=ads&do=newad'><img src='templates/icons/add.gif' border=0> Create a new ad</a></b>
<br /><br />
<b><u>Current Ad Campaigns:</u></b>
<br /><br />";

$query = "SELECT * FROM {$prefix}ads";
$result = runquery($query);

if(mysql_num_rows($result) == 0)
{
$article_content .= "You currently do not have any ads running on your website.";
}
else
{
$article_content .= "<table width='680' border='1'>
<tr>
<td width='151'>Ad Name: </td>
<td width='140'>Page:</td>
<td width='75'>Impressions:</td>
<td width='75'><p>Actual<br />Impressions:</p>
</td>
<td width='74'>Date:</td>
<td width='40'>Status:</td>
<td width='31'>Edit: </td>
<td width='42'>Delete:</td>
</tr>";


while ($row = mysql_fetch_array($result))
{
$row['adname'] = stripslashes($row['adname']);
$row['page'] = stripslashes($row['page']);

if($row['status'] == "active")
{
$statusicon = "<center><img src='templates/icons/yes.gif'></center>";
}
else
{
$statusicon = "<center><img src='templates/icons/no.gif'></center>";
}

$article_content .= "<tr>
<td>{$row['adname']}</td>
<td>{$row['page']}</td>
<td>{$row['impressions']}</td>
<td>{$row['actualimpressions']}</td>
<td>{$row['date']}</td>
<td>{$statusicon}</td>
<td><center><a href='admin.php?set=ads&do=editad&more={$row['id']}'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td><center><a href='admin.php?set=ads&do=deletead&more={$row['id']}'><img src='templates/icons/delete.gif' border=0></a></center></td>
</tr>";

}

$article_content .= "</table>";

}

}
elseif($do == "newad")
{

$article_title = "Create a new ad";
$article_content = "Here you can create a new ad campaign for your website.
You can either create a sitewide ad, or you can restrict an ad to a specific page or make a certain page have a blank ad.
This is useful for premium pages or pages that do not have content so AdSense ads won't be shown there if you so choose.
HTML is enabled for the ad system.
Remember that if you want your ad centered you should use the &lt;center&gt; and &lt;/center&gt; HTML tags to achieve this.<br />
<form name='form1' method='post' action='admpost.php'>
<p>Ad Code:</p>
<p>
<textarea name='adtext' cols='50' rows='4' id='adtext'></textarea>
</p>
<p>
Ad Campaign Name (Optional, but handy):
<input name='adname' type='text' id='adname'>
</p>
<p>
Page to run this ad on:
<input name='pagerun' type='text' id='pagerun'>
</p>
<p>
The page setting allows you to run the ad on a specific page only.
<b>To run the ad on a single page, enter the page URL in the box above.</b>
To run the ad on your entire site please leave the page setting blank.
</p>
<p>
Max Impressions Allowed:
<input name='impressions' type='text' id='impressions' size='10' maxlength='8'>
</p>
<p>
If you wish to run the ad for only a certain amount of impressions fill in the max impressions allowed box.
Leave the box blank or set to 0 to run the ad indefinentally.
When the maximum amount of impressions has been reached, the ad will become inactive and will no longer be shown.
<input name='page' type='hidden' id='page' value='newad'>
</p>
<p>
<input type='submit' name='Submit' value='Start Ad Campaign'>
<input type='reset' name='Reset' value='Reset Form'>
</p>
</form>";


}
elseif($do == "deletead")
{

//Run the delete SQL query...
$query = "DELETE FROM {$prefix}ads WHERE id='{$more}'";
runquery($query);

$article_title = "Ad Deleted Successfully";
$article_content = "Your ad has been deleted successfully. <a href='admin.php?set=ads'>Click Here</a> to manage the ads.";

}
elseif($do == "editad")
{

$article_title = "Edit an Existing Ad";

//Run the SQL queries to get the ad info and populate the form.....

$query = "SELECT * FROM {$prefix}ads WHERE id = '{$more}' LIMIT 1";
$result = runquery($query);

if(mysql_num_rows($result) > 0)
{

$row = mysql_fetch_array($result);
$row['adname'] = stripslashes($row['adname']);
$row['text'] = stripslashes($row['text']);

}
else
{
die("Ad does not exist!");
}

$article_content .= "<form name='form1' method='post' action='admpost.php'>
Here you can edit an existing advertisement.<br /><br /><p>Ad Code:</p>
<p>
<textarea name='adtext' cols='50' rows='4' id='adtext'>{$value}</textarea>
</p>
<p>
Ad Campaign Name (Optional, but handy):
<input name='adname' type='text' id='adname' value='{$adname}'>
</p>
<p>
Page to run this ad on:
<input name='pagerun' type='text' id='pagerun' value='{$pagerun}'>
</p>
<p>
The page setting allows you to run the ad on a specific band's profile page only.
<b>To run the ad on a single band's page, enter their access url in the box above.</b>
To run the ad on your entire site please leave the page setting blank.
</p>
<p>
Max Impressions Allowed:
<input name='impressions' type='text' id='impressions' size='10' maxlength='8' value='{$impressions}'>
</p>
<p>
If you wish to run the ad for only a certain amount of impressions fill in the max impressions allowed box.
Leave the box blank or set to 0 to run the ad indefinentally.
When the maximum amount of impressions has been reached, the ad will become inactive and will no longer be shown.
<input name='aid' type='hidden' id='aid' value='{$more}'>
<input name='aimp' type='hidden' id='aimp' value='{$actualimpressions}'>
<input name='page' type='hidden' id='page' value='editad'>

</p>
<p>
<input type='submit' name='Submit' value='Edit Ad Campaign'>
<input type='reset' name='Reset' value='Reset Form'>
</p>
</form>";

}
}
else
{

$article_title = "Access Denied";
$article_content = "Your usergroup does not seem to have the permission to edit the advertisement settings...";


}

} // End the ads setting block...start a new setting here...
}
else
{
$article_title = "Access Denied";
$article_content = "Access Denied";
}

}
else
{

$article_title = "Access Denied";
$article_content = "Access Denied";

}

//***************//
// OUTPUT PAGE //
//***************//

echo showpage($article_title, $article_content, $date);

?>

Hall of Famer
10-28-2011, 05:15 PM
I see, it does not seem that anything was wrong with admin.php. Can you show me your adopt.php then? Perhaps the condition-check is not working for adoption process.

SilverDragonTears
10-28-2011, 05:35 PM
<?php

include("inc/functions.php");

//***************//
// START SCRIPT //
//***************//

$id = $_GET["id"];
$promocode = $_GET["promocode"];
$_SESSION["allow"] = 1;
// Here we check if we have an ID that has been submitted or no

if($id == "" or !is_numeric($id)) {
// We did not enter in an id, or it is not a number
$article_content .= "<table class='shop' width='100%'><tr><td style='text-align:left;'>";



$article_title .="An eerie, howling wind is starting to pick up its pace in the Misty Woods...";
$article_content .="<big><b>As you walk through the misty woods...</b></big></span><br>a sort of blue fog begins to settle in the forest. You stumble upon a den of eggs, and you can see tiny ears and fluffy tails beginning to poke out from some of the eggs, others are of different shapes and colors. You don't see the mother and wonder if maybe you should attempt to take one. You have set up camp in your own <a href='myadopts.php' style='color:#fff;'>Den</a> and keep records of the animals you have already captured. You can also take an egg or baby that has been <a href='pound.php' style='color:#fff;'>abandoned</a>.
<br>
<center>Which one do you take {$loggedinname}?</center></td></tr></table><br><center><table class='adopt'><tr>


<form name='form1' method='get' action='doadopt.php'>
";

// Check to see if the Abandon Den is full
$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE owner='SYSTEM' AND currentlevel<='4' AND isfrozen='no'";
$result = mysql_query($query);
$num = mysql_num_rows($result);

if($num >= 11){
$canadopt = "no";
$article_title = "";
$article_content .= "<td>You realize that there are many eggs in the <a href='pound.php'>Abandoned Den</a> that need homes so you go there instead.</td></tr></table>";
}else{

// If we are a guest, show a message that lets them know that they cannot adopt...
if($isloggedin != "yes"){
$article_content = $article_content.$showingguest;
}

// Begin the output of all the adoptables to the user...
$query = "SELECT * FROM ".$prefix."adoptables WHERE whenisavail='always' and cost='0' ORDER BY RAND() LIMIT 3";
$result = runquery($query);


while($row = mysql_fetch_array($result)) {
$aid=$row['id']; //The adoptable's ID
$type=$row['type'];
$description=$row['description'];
$eggimage=$row['eggimage'];

// Call a function to check if we have the proper privledge level to adopt this pet
if($promocode == ""){
$promocode = "none";
}


$canadopt = canadopt($aid, "showing", $promocode, $row); // Feed an adoptable ID and showing, to show the adopt to guests...



if($canadopt == "yes"){
//If we can adopt the adoptable, show the image and adoption link...

$article_content .= "
<td VALIGN='top'><a href='doadopt.php?id=".$aid."'><img src='http://www.silvadopts.com/picuploads/png/dee54ce4a7e38bcc36d1fbfa8858be3a.png' /></a><br>
<b>".stripslashes($description)."</b></td>";
}

} // End the looping out of all adoptables...

}
$article_content .= "</tr></table><br><br>";
} // This bracket ends the IF check for whether or not an ID was entered


else{
// We have specified an ID of an adoptable we wish to adopt

$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$id' LIMIT 1";
$result = runquery($query);
$row = mysql_fetch_array($result);

$aid = $row['id'];
$type=$row['type'];
$description=$row['description'];
$eggimage=$row['eggimage'];

if($aid == $id){
//The adoptable exists and is valid

$canadopt = canadopt($aid, "adopting", $promocode, $row);

if($canadopt == "yes"){

$article_title = "Adopting ".$type;
$article_content = $langa1."".$type.$langa2;

$article_content = $article_content."<br><img src='http://www.silvadopts.com/picuploads/png/385ade0f167fa7d74113e3eb74f55ff6.png'><br>
<form name='form1' method='get' action='doadopt.php'>
<p>Adoptable Name:
<input name='name' type='text' id='name'>
<input name='id' type='hidden' id='id' value='".$id."'>
<input name='promocode' type='hidden' id='promocode' value='".$promocode."'>
</p>
<p>
<input type='submit' name='Submit' value='Adopt Me'>
</p>
</form>";
}
else{
$article_title = $accden;
$article_content = $adoptnoper;
} // End Can Adopt ELSE
}
else {
//The adoptable does not exist, nothing we can do...
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
} // End adoptable does not exist ELSE
} // This bracket ends the else statements for whether or not an ID was entered


//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, $date);

?>

Hall of Famer
10-28-2011, 06:18 PM
I see, it seems that your adopt.php has been significantly modified. Are you using Fadillzzz's random adoption script? Also this appears to be different from Fadillzzz's original script, I am assuming you have modified adopt.php yourself too? I am sure the old Mysidia Adoptables v1.2.2 script does not have a glitch that prevents adopt-conditions to work properly, so its safe to conclude that it is either Fadillzzz or your edits of adopt.php that results in adopt-conditions to malfunction.