View Full Version : Hall of Famer's gender ratio system
Hall of Famer
11-24-2010, 02:46 AM
Well this one is based on Arianna's gender mod. As far as I know, Kaeliah already has a gender ratio/chance system before I made this one, so I do not take any credits for this script. Dont forget to credit Arianna though, she was the first one to bring up this excellent gender idea that Rusnak Adoptables were originally, lacking.
Before you proceed, make sure you you have Arianna's gender system on your script already. Her thread can be found here:
http://www.rusnakweb.com/forum/showthread.php?tid=1367&page=1
It is rather straight forward to follow Arianna's mod-installation guide, so I wont explain much. The script simply defines a new variable Gender, which is a random number that has 50-50 chance of being male or female. The myadopts.php also displays an adoptable's gender. For those of you who do not know how to add a gender column to the 'owned_adoptables' table, I've attached this screenshot below for you to follow the instruction. Shouldnt be hard though, there's no coding involved:
http://oi54.tinypic.com/k2hesp.jpg
Alright lets get started on this gender ratio system. Before we proceed, it is necessary to add a new column called 'genderratio' to the table adoptables. Its strongly advised that you add it to the last column.
After this is done, go to admin.php and find the codes below:
<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'>
</strong>Enable Alternate Outcomes </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>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p> </p>
</form>";
Select and replace the entire codes with:
<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'>
</strong>Enable Alternate Outcomes </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>
<p>The Gender Ratio of your adoptable is
<input name='genderratio' type='text' id='genderratio' size='6' maxlength='6'>
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p> </p>
</form>";
You can see that we add codes for gender ratio in admin control panel, so you will be able to define gender ratio in acp instead of going all the way to PHPmyadmin. You will have to modify nadopt.php next, otherwise you will not be able to create new adoptables!
In nadopt.php, find:
$alternates = $_POST["alternates"];
$alternates = secure($alternates);
$altoutlevel = $_POST["altoutlevel"];
$altoutlevel = secure($altoutlevel);
$altchance = $_POST["altchance"];
$altchance = secure($altchance);
Add below:
$genderratio = $_POST["genderratio"];
$genderratio = secure($genderratio);
Also find the sql commands in this script file:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance')");
Replace with:
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$ge nderratio')");
Alright now we are done with nadopt.php. This isnt over yet, we will have to add codes for the actual gender ratio system. In doadopt.php, find:
$name = $_GET["name"];
$name = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $name);
$name = secure($name);
Add below:
$genderratio = $_GET["genderratio"];
$genderratio = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $genderratio);
$genderratio = secure($genderratio);
This is how we define the variable $genderratio in doadopt.php. Note this ratio must be an integer. After you complete this step, find:
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
Add below:
$genderratio=@mysql_result($result,$i,"genderratio");
This is how we retrieve data from sql. Here comes the fun, I promise it does. Search for the codes below:
//The gender mod
$tempgender = rand(0, 1);
if($tempgender == "0") {
$gender = "Female";
unset($tempgender);
}
else {
$gender = "Male";
unset($tempgender);
}
Yes this is Arianna's gender mod. You will have to install it before using my gender ratio script. We are going to replace Arianna's gender determination system with this gender ratio system. So select the codes and replace with:
//The gender mod
if($genderratio >= 0 and $genderratio < 101) {
$tempgender = rand(0, 100);
if($tempgender >= 0 and $tempgender < $genderratio) {
$gender = "Female";
unset($tempgender);
}
else {
$gender = "Male";
unset($tempgender);
}
}
else {
$gender = "Genderless";
}
So yes, we are all set now. Isnt this easy? Well there is a flaw in this code that the gender ratio is actually not 50-50 when you set the gender ratio to be 50. This is because there are actually 101 integers between 0 to 100. One way to solve this problem is to use another if-else statement that deals with gender ratio = 50, another way is to increase the gender ratio maximum from 100 to 1000, or even 10000. This may sound confusing, but please give a try if you are an aspiring coder.
Also, keep in mind that this is actually female gender ratio, not male gender ratio. A gender ratio of 80 typically tells us that you have 80% chance to get female adoptable, and 20% chance of getting male adoptable. Similarly, a gender ratio of 15 means that you only have 15% chance to get a female adoptable. What if you enter a gender ratio above 100? Well, if you actually look into the codes I wrote, I define it as genderless and such cases may exist for adoptables like Magnemite and Shellder in pokemon series. Make good use of it if you can. Here is an example of my genderless Magnemite:
http://oi52.tinypic.com/28pqb.jpg
Thats the end of it. Sorry I wrote a lot, and thanks for taking the time and trouble to go through the entire article. I hope it helps.
Hall of Famer
PTGigi
11-25-2010, 01:25 AM
Oh very nice :D I was wondering how to do something like this and thought out a not very good way to do it XD Nice of you to think of a better way. :D I'll be sure to test this out when I can get the time, thank you very much! =3
Hall of Famer
11-25-2010, 01:58 AM
You are very welcome, glad you like it. ^^
Like I've pointed out before, there's still a small problem with the formula used to calculate gender ratio. There are 101 integers between 0 to 100, not 100. Because of this, it is impossible to achieve 50-50 chance for male or female adoptables(it will be 51-50 instead). There are ways to fix this I am sure, and one easy approach is to set the range of Gender ratio to be 0-99 or 1-100, but then it will lead to confusion of the definition of Gender Ratio. *sigh*
Also if you are running a pokemon site and you want genderless pokemon such as Magnemite, the script does a good job for you. All you have to do is to enter a gender ratio outside of the range 0-100. I did 101 for my pokemon such as Magnemite and Voltorb, but you can even try 1000 if you want to. The adoptable you get will always be genderless then.
PTGigi
11-25-2010, 03:04 AM
Also if you are running a pokemon site and you want genderless pokemon such as Magnemite, the script does a good job for you. All you have to do is to enter a gender ratio outside of the range 0-100. I did 101 for my pokemon such as Magnemite and Voltorb, but you can even try 1000 if you want to. The adoptable you get will always be genderless then.
Lol did my name give it away? XD Thank you for that too :D It will most certainly come in handy =3
Hall of Famer
11-25-2010, 02:50 PM
Well yeah, a Pokemon trainer. XD
And you are welcome, just use my script if its available for public. I am actually not even half as good as Kaeliah when it comes to PHP coding, and if you ever encounter glitches please lemme know.
PTGigi
11-27-2010, 11:39 PM
Quick question, to get an all female or all male you use 0 and 100 right? 0 for all male and 100 for all female?
Also couldn't you change $tempgender = rand(0, 100); to $tempgender = rand(1, 100); to erase the 50-51 problem? =3 (not sure just started PHP X3)
Hall of Famer
11-28-2010, 01:25 AM
Quick question, to get an all female or all male you use 0 and 100 right? 0 for all male and 100 for all female?
Also couldn't you change $tempgender = rand(0, 100); to $tempgender = rand(1, 100); to erase the 50-51 problem? =3 (not sure just started PHP X3)
Since this is a female gender ratio script, I'd say 100 = all female and 0 = all male.
Well yeah, you can technically change that to as simple as 0 to 9. The problem is that most people are used to the idea of having a range of ratio/percentage between 0 to 100, but sure you can do that. ^^
Hall of Famer
12-24-2010, 09:59 PM
Oh btw, Arianna's gender mod is added in RA version 1.1, so you do not have to install any pre-requisites if you use RA version 1.1. Simply follow the rest of the steps as I provided a few weeks ago and you should have a fully functioning gender ratio system. ^^
Merry Christmas everyone!
Hall of Famer
RoconzaArt
01-24-2011, 01:06 AM
I'm getting this error:
The ID specified does not match any adoptable in our system. Sorry. If you wish, you can adopt a pet.Did I do some thing wrong?
Hall of Famer
01-24-2011, 01:15 AM
Can you show me the tables prefix_adoptables and prefix_owned_adoptables from phpmyadmin? My initial guess is that your table structure is different so the sql query lines must be modified to account for this change.
RoconzaArt
01-24-2011, 01:23 AM
Here you are HOF, Sorry I'm always being a pain and asking for help.
Hall of Famer
01-24-2011, 01:26 AM
Dont worry Roconza, this is a support forum and one of our jobs is to offer help to those who raise questions and concerns.
umm I dont see a problem with your prefix_adoptables table(its a little bit small for me to see, but guess I am fine with it), can you show me a screenshot of your prefix_owned_adoptables too? Also please lemme know where you get this error? Did you have problem creating an adoptable, or it happens when you try to adopt one?
RoconzaArt
01-24-2011, 01:37 AM
I only happens when I try to adopt a pet.
My bad I didn't know it would resize them like that. I have to say the support for this forum is 100% better. I think the best thing to ever happen to this script so being sold to you. Now it feel like this script is going places. Just look at how active this place is.
Adoptables
http://i1134.photobucket.com/albums/m605/LordMacguffin/267109b2.png
ownd_adoptables
http://i1134.photobucket.com/albums/m605/LordMacguffin/8807fe85.png
file:///C:/DOCUME%7E1/HP_ADM%7E1/LOCALS%7E1/Temp/moz-screenshot.png
Hall of Famer
01-24-2011, 01:40 AM
Can you change Gender ratio's type to int(11)? It is supposed to be an integer number, not a string.
RoconzaArt
01-24-2011, 01:53 AM
Still gives me a error when trying to adopt a pet.
Hall of Famer
01-24-2011, 02:01 AM
I see, you didnt get an error when creating an adoptable in acp? Anyway, please attach your admin.php, nadopt.php and doadopt.php in your next post so that I can look into it carefully. Thanks.
Hall of Famer
RoconzaArt
01-24-2011, 02:15 AM
doadopt.php
<?php
// ************************************************** ********************
// Mysidia Adoptables Script: doadopt.php
// Copyright 2011 Mysidia Adoptables staff team
// For help and support: http://www.mysidiaadoptables.com/forum/
//
// Redistribution prohibited without written permission
// ************************************************** ********************
// Wake the sleeping giant
// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************
include("inc/functions.php");
include("inc/config.php");
include("lang/lang.php");
$themeurl = grabanysetting("themeurl");
// ************************************************** ********************
// Define our top links by calling getlinks()
// ************************************************** ********************
$links = getlinks();
// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************
$ads = getads("any");
// ************************************************** ********************
// Grab any dynamic article content from the content table
// ************************************************** ********************
$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);
// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************
$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");
// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************
$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];
// ************************************************** ********************
// End Prepwork - Output the page to the user
// This file actually processes the adoption of a pet...
// ************************************************** ********************
$id = $_GET["id"];
$id = preg_replace("/[^a-zA-Z0-9s]/", "", $id);
$id = secure($id);
$promocode = $_GET["promocode"];
$promocode = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $promocode);
$promocode = secure($promocode);
$name = $_GET["name"];
$name = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $name);
$name = secure($name);
$genderratio = $_GET["genderratio"];
$genderratio = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $genderratio);
$genderratio = secure($genderratio);
if($isloggedin == "yes"){
// I guess the first thing to do is see if we have a valid adoptable ID submitted...
if($id == "" or !is_numeric($id)){
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
else{
// The adoptable ID appears to be valid, so we need to double check that it is valid by pulling up the adoptable in the DB
$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$id'";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < 1) {
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
$genderratio=@mysql_result($result,$i,"genderratio");
$i++;
}
if($id == $aid){
// The ID submitted matches an existing adoptable type
$canadopt = canadopt($aid, "adopting", $promocode);
// If we can adopt this creature, do the adoption
// Otherwise we show an error...
if($canadopt == "yes"){
// ************************************************** ********************
// BEGIN the actual adoption process
// ************************************************** ********************
// First we see if we have a custom name.
// If not, we use the default name
if($name == ""){
$name = $type;
}
//The gender mod
if($genderratio >= 0 and $genderratio < 101) {
$tempgender = rand(0, 100);
if($tempgender >= 0 and $tempgender < $genderratio) {
$gender = "Female";
unset($tempgender);
}
else {
$gender = "Male";
unset($tempgender);
}
}
else {
$gender = "Genderless";
}
// Now we determine if we are using alternate images or not
$alts = getaltstatus($id, 0, 0);
// Now we actually process the adoption and add it to the database...
// We need a unique code for the adoptable so we can show it to the user when we're done here...
$code = rand(1, 20000);
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender')");
// Adoption complete, show the user a confirmation screen...
// We need to show the adoptable info from the database...
$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE code='$code' and owner='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < 1) {
$id=@mysql_result($result,$i,"aid");
$i++;
}
$article_title = $name." adopted successfully";
$article_content = "<img src='".$eggimage."'><br>".$congrats1." ".$name.". You can now manage ".$name." on the
<a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id=".$id."'>Click Here to Manage ".$name."</a><br>
<a href='myadopts.php?act=bbcode&id=".$id."'>Click Here to get BBCodes / HTML Codes for ".$name."</a></b><br><br>
Be sure and <a href='levelup.php?id=".$id.">feed</a> ".$name." with clicks so that they grow!";
// ************************************************** ********************
// END the actual adoption process
// ************************************************** ********************
}
else{
$article_title = $accden;
$article_content = $adoptnoper;
}
} // End the if for if $id == $aid
else{
// Adoptable does not exist, show an error.
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
} // End the else for if $id == $aid
} // End the valid ID input else test statement (bulk of code goes above here)
} // End the log in check IF
else{
// Guests cannot adopt pets, so why bother...
$article_title = $guesttitleerror;
$article_content = $guesterror;
} // End the log in check ELSE
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************
//Define our current theme
$file = $themeurl;
// Do the template changes and echo the ready template
$template = file_get_contents($file);
$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);
//Define our links
$template = replace(':LINKSBAR:',$links,$template);
//Get the content for the side bar...
$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);
//Get the ad content...
$template = replace(':ADS:',$ads,$template);
//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);
echo $template;
// ************************************************** ********************
// End Template Definition
// ************************************************** ********************
?>nadopt.php
<?php
// ************************************************** ********************
// Mysidia Adoptables Script: nadopt.php
// Copyright 2011 Mysidia Adoptables staff team
// For help and support: http://www.mysidiaadoptables.com/forum/
//
// Redistribution prohibited without written permission
// ************************************************** ********************
// ************************************************** ********************
// This file allows the administrator to create a new adoptable...
// File ID: nadopt.php
// ************************************************** ********************
// Wake the sleeping giant
// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************
include("inc/functions.php");
include("inc/config.php");
$themeurl = grabanysetting("themeurl");
// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************
$ads = ""; // No Ads, because we're in the Admin CP...
// ************************************************** ********************
// Grab any dynamic article content from the content table
// ************************************************** ********************
$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);
// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************
$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");
// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************
$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];
// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************
if($isloggedin == "yes"){
$group = getgroup();
$cancp = cancp($group);
$canedit = cando($group, "canmanageadopts");
if($cancp == "yes" and $canedit == "yes"){
// We are logged in and can access this page, so let's get the post info...
// We sanitize at the same time we take in...
$name = $_POST["name"];
$name = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $name);
$name = secure($name);
$description = $_POST["description"];
$description = secure($description);
$imageurl = $_POST["imageurl"];
$imageurl = secure($imageurl);
$existingimageurl = $_POST["existingimageurl"];
$existingimageurl = secure($existingimageurl);
$cba = $_POST["cba"];
$cba = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $cba);
$cba = secure($cba);
$promocode = $_POST["promocode"];
$promocode = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $promocode);
$promocode = secure($promocode);
$freqcond = $_POST["freqcond"];
$freqcond = secure($freqcond);
$number = $_POST["number"];
$number = secure($number);
$datecond = $_POST["datecond"];
$datecond = secure($datecond);
$date = $_POST["date"];
$date = secure($date);
$adoptscond = $_POST["adoptscond"];
$adoptscond = secure($adoptscond);
//////////////////////////////////////////////////////////////////////
$maxnumcond = $_POST["maxnumcond"];
$maxnumcond = secure($maxnumcond);
$morethannum = $_POST["morethannum"];
$morethannum = secure($morethannum);
$usergroupcond = $_POST["usergroupcond"];
$usergroupcond = secure($usergroupcond);
$usergroups = $_POST["usergroups"];
$usergroups = secure($usergroups);
//////////////////////////////////////////////////////////////////////
$alternates = $_POST["alternates"];
$alternates = secure($alternates);
$altoutlevel = $_POST["altoutlevel"];
$altoutlevel = secure($altoutlevel);
$altchance = $_POST["altchance"];
$altchance = secure($altchance);
$genderratio = $_POST["genderratio"];
$genderratio = secure($genderratio);
// Now we run some checks to make sure that we have a go.
$error = "";
if($name == ""){
$error = "You did not enter in a name for the adoptable. Please go back and try again.";
}
if($name == ""){
$error = "You did not enter in a name for the adoptable. Please go back and try again.";
}
if($imageurl == "" and $existingimageurl == "none"){
$error = "You did not select an image for this adoptable. Please go back and make sure an image is selected for this adopt.";
}
if($imageurl != "" and $existingimageurl != "none"){
$error = "You selected two images for the adoptable's egg image. Please go back and make sure that either the image textbox is blank or the image dropdown box is set to No Exising Image.";
}
if($cba != "always" and $cba != "promo" and $cba != "conditions"){
$error = "You did not choose a valid scenario when this adoptable can be adopted. Please go back and either select the Always option, the Promo option or the Conditions option.";
}
//If we are using a promo code, we should have a promo code in the box...
if($cba == "promo" and $promocode == ""){
$error = "You selected that this adoptable is available for adoption only with a promo code, but you did not enter in a promo code. Please go back and either change this setting or type in a valid promo code.";
}
//If we are using conditions...
if($cba == "conditions"){
if($freqcond == "enabled" and !is_numeric($number)){
$error = "A condition is enabled but is blank or has an incorrect value. Please go back and double check your conditions and that they contain valid input.";
}
if($datecond == "enabled" and $date == ""){
$error = "A condition is enabled but is blank or has an incorrect value. Please go back and double check your conditions and that they contain valid input.";
}
if($adoptscond == "enabled"){
if($moreless == "" or !is_numeric($morelessnum) or $levelgrle == "" or !is_numeric($grlelevel)){
$error = "A condition is enabled but is blank or has an incorrect value. Please go back and double check your conditions and that they contain valid input.";
}
}
if($maxnumcond == "enabled" and !is_numeric($morethannum)){
$error = "A condition is enabled but is blank or has an incorrect value. Please go back and double check your conditions and that they contain valid input.";
}
if($usergroupcond == "enabled" and !is_numeric($usergroups)){
$error = "A condition is enabled but is blank or has an incorrect value. Please go back and double check your conditions and that they contain valid input.";
}
}
if($alternates == "enabled"){
if(!is_numeric($altoutlevel) or !is_numeric($altchance)){
$error = "There has been an error with the adoptable's alternate settings you selected. Please go back and make sure the alternate values are filled in correctly.";
}
}
//Check and see if an adoptable with this name already exists...
$query = "SELECT * FROM ".$prefix."adoptables WHERE type = '$name'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
$error = "An adoptable with this name already exists in your database. Please go back and rename the adoptable to something different.";
}
//If we have an error, show it. Otherwise continue...
if($error != ""){
$article_title = "An Error Has Occurred!";
$article_content = $error;
}
else{
//There has been no error, continue with the addition of the adoptable to the system...
//First determine which image URL to use...
$eggimage = "";
if($imageurl != "" and $existingimageurl == "none"){
$eggimage = $imageurl;
}
else{
$eggimage = $existingimageurl;
}
mysql_query("INSERT INTO ".$prefix."adoptables VALUES ('', '$name', '$description','$eggimage','$cba','$promocode', '$freqcond', '$number','$datecond','$date','$adoptscond','$maxn umcond','$morethannum','$usergroupcond','$usergrou ps','$alternates','$altoutlevel','$altchance','$ge nderratio')");
$article_title = "Adoptable Added Successfully";
$article_content = "Your adoptable, ".$name.", has been added to the database successfully. You can now <a href='admin.php?set=adopts&do=addlevel'>Add a Level</a> to this adoptable. You can also <a href='admin.php'>go back to the Admin CP index page</a>.";
}
} //This bracket ends the check of whether or not this user can access the adopts portion of the ACP
}
else{
$article_title = "Access Denied";
$article_content = "Access Denied";
}
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************
//Define our current theme
$file = $themeurl;
// Do the template changes and echo the ready template
$template = file_get_contents($file);
$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);
//Define our links
if($cancp == "yes"){
//Admins see a custom set of links here...
$links = getadmlinks();
}
else{
$links = getlinks();
}
$template = replace(':LINKSBAR:',$links,$template);
//Get the content for the side bar...
$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);
//Get the ad content...
$template = replace(':ADS:',$ads,$template);
//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);
echo $template;
// ************************************************** ********************
// End Template Definition
// ************************************************** ********************
?>
RoconzaArt
01-24-2011, 02:16 AM
admin
<?php
// ************************************************** ********************
// Mysidia Adoptables Script: admin.php
// Copyright 2011 Mysidia Adoptables staff team
// For help and support: http://www.mysidiaadoptables.com/forum/
//
// Redistribution prohibited without written permission
// ************************************************** ********************
// Wake the sleeping giant
// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************
include("inc/functions.php");
include("inc/config.php");
$themeurl = grabanysetting("themeurl");
// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************
$ads = ""; // No Ads, because we're in the Admin CP...
// ************************************************** ********************
// Grab any dynamic article content from the content table
// ************************************************** ********************
$article_title = "";
$article_content = "";
// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************
$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");
// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************
$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus;
// ************************************************** ********************
// End Prepwork - Output the page to the user
// ************************************************** ********************
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...
$set = $_GET["set"];
$set = preg_replace("/[^a-zA-Z0-9s]/", "", $set);
$set = secure($set);
$do = $_GET["do"];
$do = preg_replace("/[^a-zA-Z0-9s]/", "", $do);
$do = secure($do);
$more = $_GET["more"];
$more = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $more);
$more = secure($more);
$evenmore = $_GET["evenmore"];
$evenmore = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $evenmore);
$evenmore = secure($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 = "Welcome to your Admin CP";
$article_content = "Welcome to your Admin CP. Here's where you can manage your site, change the site's content,<br>
<p><strong><u>Admin Navagation</strong></u></p>
<p><strong>
<a href='admin.php?set=adopts'>Change Adoptables</a><br>
<a href='admin.php?set=content'>Change Content</a><br>
<a href='admin.php?set=users'>Change Users</a><br>
<a href='admin.php?set=settings'>Site Settings</a><br>
<a href='admin.php?set=ads'>Manage Ads</a><br></p></strong>
<p>Powered By EasyAdopables Script</p>";
} //End for the set = "" bit
else if($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
// ************************************************** ********************
$canedit = cando($group, "canmanageadopts");
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>";
}
else if($do == "new"){
//We are creating a new adoptable here...
$dynimages = getadmimages();
$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 Description:</p>
<p>
<textarea name='description' cols='45' rows='4' id='description'></textarea>
</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 = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$groupname=@mysql_result($result,$i,"groupname");
$groupid=@mysql_result($result,$i,"gid");
$article_content = $article_content."<option value='".$groupid."'>".$groupname."</option>";
$i++;
}
$article_content = $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'>
</strong>Enable Alternate Outcomes </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>
<p>The Gender Ratio of your adoptable is
<input name='genderratio' type='text' id='genderratio' size='6' maxlength='6'>
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p> </p>
</form>";
} //End the create a new adoptable form
else if($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...
$i = 0;
$num = 0;
$query = "SELECT * FROM ".$prefix."adoptables";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$adoptable=@mysql_result($result,$i,"type");
$article_content = $article_content."<option value='".$adoptable."'>".$adoptable."</option>";
$i++;
}
$article_content = $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...
$i = 0;
$num = 0;
$query = "SELECT * FROM ".$prefix."adoptables WHERE type='".$more."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
//A record was found in the database, so the adoptable exists
//Let's see if alternate images are enabled or disabled...
//Loop out code
$i=0;
while ($i < 1) {
$alt=@mysql_result($result,$i,"alternates");
$i++;
}
$alternatez = "DISABLED";
if($alt == "enabled"){
$alternatez = "ENABLED";
}
//Let us see how many levels of this adoptable already exist...
$i = 0;
$num = 0;
$query = "SELECT * FROM ".$prefix."levels WHERE adoptiename='".$more."'";
$result = mysql_query($query);
$numlevels = mysql_numrows($result); //This is the number of levels that exist for this adopt
if($numlevels == ""){
$numlevels = 0; //If nothing is returned, assume no levels exist already...
}
$editing = $numlevels + 1; //The current level we are creating...
//We need to see how many clicks were required for the previous level
$query = "SELECT * FROM ".$prefix."levels WHERE adoptiename = '$more' and thisislevel = '$numlevels'";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < 1) {
$prevlevelclicks=@mysql_result($result,$i,"requiredclicks");
$i++;
}
if($prevlevelclicks == ""){
$prevlevelclicks = 0;
}
$dynimages = getadmimages();
$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 ".$editing."</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>".$alternatez."</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='".$editing."'>
<input name='prevclix' type='hidden' id='prevclix' value='".$prevlevelclicks."'>
<input type='submit' name='Submit' value='Create Level'>
</p>
<p> </p>
<p> </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.rusnakweb.com/forum' target='_blank'>Rusnak PHP 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
else if($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
else if($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...
$i = 0;
$num = 0;
$query = "SELECT * FROM ".$prefix."adoptables";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$adoptable=@mysql_result($result,$i,"type");
$article_content = $article_content."<option value='".$adoptable."'>".$adoptable."</option>";
$i++;
}
$article_content = $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 = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
//Loop out code
$i=0;
while ($i < 1) {
$adoptabletype=@mysql_result($result,$i,"type");
$eggimage=@mysql_result($result,$i,"eggimage");
$i++;
}
if($evenmore == "" or !is_numeric($evenmore)){
// We are showing the table with all of the levels
$article_title = "Editing Levels for ".$adoptabletype." 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='".$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=".$adoptabletype."'><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."' ORDER BY thisislevel ASC";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$thisislevel=@mysql_result($result,$i,"thisislevel");
$requiredclicks=@mysql_result($result,$i,"requiredclicks");
$primaryimage=@mysql_result($result,$i,"primaryimage");
$alternateimage=@mysql_result($result,$i,"alternateimage");
$reward=@mysql_result($result,$i,"rewarduser");
$altdisplay = "<img src='templates/icons/no.gif'>";
if($alternateimage != ""){
$altdisplay = "<img src='".$alternateimage."'>";
}
$rewarddisplay = "<img src='templates/icons/no.gif'>";
if($reward == "yes"){
$rewarddisplay = "<img src='templates/icons/yes.gif'>";
}
$article_content = $article_content."<tr>
<td><center>".$thisislevel."</center></td>
<td><center><img src='".$primaryimage."'></center></td>
<td><center>".$altdisplay."</center></td>
<td><center>".$requiredclicks."</center></td>
<td><center>".$rewarddisplay."</center></td>
<td><center><a href='admin.php?set=adopts&do=editlevels&more=".$adoptabletype."&evenmore=".$thisislevel."'><img src='templates/icons/cog.gif' border=0></a></center></td>
</tr>";
$i++;
}
$article_content = $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 = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
//Loop out code
$i=0;
while ($i < 1) {
$thisislevel=@mysql_result($result,$i,"thisislevel");
$requiredclicks=@mysql_result($result,$i,"requiredclicks");
$primaryimage=@mysql_result($result,$i,"primaryimage");
$alternateimage=@mysql_result($result,$i,"alternateimage");
$reward=@mysql_result($result,$i,"rewarduser");
$promocode=@mysql_result($result,$i,"promocode");
if($alternateimage == ""){
$alternateimage = "templates/icons/no.gif";
}
$i++;
}
$remark = "<input name='reward' type='checkbox' id='reward' value='yes'>";
if($reward == "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='".$promocode."'>";
}
$dynimages = getadmimages();
$article_title = "Editing level ".$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='".$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='".$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>
<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>".$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...
else if($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 = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
//Loop out code
$i=0;
while ($i < $num) {
$adoptabletype=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
$whenisavail=@mysql_result($result,$i,"whenisavail");
$i++;
}
if($whenisavail != "always" and $whenisavail != ""){
$availtxt = "<b>This adoptable currently has adoption restrictions on it.</b>";
}
else{
$availtxt = "This adoptable currently does not have adoption restrictions on it.";
}
$dynimages = getadmimages();
// 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...
else if($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 = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$iid=@mysql_result($result,$i,"id");
$wwwpath=@mysql_result($result,$i,"wwwpath");
$article_content = $article_content."<p><img src='".$wwwpath."'></p><p>
<input name='iid' type='radio' value='".$iid."'> Delete This Image
</p>
";
$i++;
}
$article_content = $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...
else if($set == "content"){
// Check if we have permissions to access here...
$canedit = cando($group, "canmanageadopts");
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 = mysql_query($query);
$num = mysql_numrows($result);
while ($i < $num) {
$ourpage=@mysql_result($result,$i,"page");
$title=@mysql_result($result,$i,"title");
if($ourpage == "index" or $ourpage == "tos"){
$showdelete = "";
}
else{
$showdelete = "<center><a href='admin.php?set=content&do=delete&more=".$ourpage."'><img src='templates/icons/delete.gif' border=0></a></center>";
}
$article_content = $article_content."<tr>
<td>".$ourpage."</td>
<td>".$title."</td>
<td><center><a href='admin.php?set=content&do=edit&more=".$ourpage."'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td>".$showdelete."</td>
</tr>
";
$i++;
}
$article_content = $article_content."</table>";
}
else if($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+'[u]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=\"Image w/ Link\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.somesite.com/images/someimage.gif (http://www.yourlinksite.com)'\">
<br><textarea name='pagecontent' cols='45' rows='6' 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>
</p>";
}
else if($do == "delete"){
// Delete a page...
if($more != "index" and $more != "tos"){
$query = "DELETE FROM ".$prefix."content WHERE page='".$more."'";
mysql_query($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>";
}
}
else if($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 = $pageinfo[title];
$pagecontent = $pageinfo[content];
$pagetitle = stripslashes($pagetitle);
$pagecontent = stripslashes($pagecontent);
if($pagetitle != "" or $pagecontent != ""){
$article_content = $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=\"Image w/ Link\" onClick=\"document.forms['form1']. elements['pagecontent'].value=document.forms['form1']. elements['pagecontent'].value+'http://www.somesite.com/images/someimage.gif (http://www.yourlinksite.com)'\">
<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='6' 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...
else if($set == "users"){
$canedit = cando($group, "canmanageusers");
if($canedit == "yes"){
// We are managing users...
if($do == "edit"){
$user = $more;
$query = "SELECT * FROM ".$prefix."users WHERE username = '".$user."'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
//The user actually exists, so allow us to edit them...
$article_title = "User Editor - Editing ".$user."'s Account";
$article_content = "Here you can edit the user's account using the form below.<br>";
$i=0;
while ($i < 1) {
$email=@mysql_result($result,$i,"email");
$usergroup=@mysql_result($result,$i,"usergroup");
$i++;
}
//************************************************** **********************************************
// BEGIN THE FORM
//************************************************** **********************************************
$article_content = $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='".$email."'>
</p>
<p><u>".$user."'s Current Usergroup:</u> Group ".$usergroup."</p>
<p>Change ".$user."'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 = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$groupname=@mysql_result($result,$i,"groupname");
$groupid=@mysql_result($result,$i,"gid");
$article_content = $article_content."<option value='".$groupid."'>Group ".$groupid." :: ".$groupname."</option>";
$i++;
}
$article_content = $article_content."</select>
</p>
<p> <input name='page' type='hidden' id='page' value='users'>
<input name='username' type='hidden' id='username' value='".$user."'>
</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!";
}
}
else if($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><p></p><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 = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
$gender=@mysql_result($result,$i,"gender");
$editimage = "<a href='admin.php?set=users&do=adoptables&more=edit&evenmore=".$aid."'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=users&do=adoptables&more=delete&evenmore=".$aid."'><img src='templates/icons/delete.gif' border=0></a>";
// Finally we can show this table to the user...
$article_content = $article_content."<tr>
<td>".$aid."</td>
<td>".$type."</td>
<td><div align='center'>".$name."</div></td>
<td><div align='center'>".$owner."</div></td>
<td><div align='center'>".$gender."</div></td>
<td><div align='center'>".$editimage."</div></td>
<td><div align='center'>".$deleteimage."</div></td>
</tr>";
$i++;
}
$article_content = $article_content."</table>";
}
else if($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'>
<br>
<p>Adoptable Name:
<input name='name' type='text' id='name'>
<br>
<p>Adoptable Owner:
<input name='owner' type='text' id='owner'>
<br>
<p>Adoptable Clicks:
<input name='clicks' type='text' id='clicks'>
<br>
<p>Adoptable Level:
<input name='level' type='text' id='level'>
<br>
<p>Use Alternative?
<input name='usealternates' type='text' id='usealternates'>
<br>
<p>Adoptable Gender
<input name='gender' type='text' id='gender'>
<br>
<p>
<input type='submit' name='Submit' value='Create This Adoptable'>
</p>
<p> </p>
</form>";
}
else if($more == "edit"){
// We are editing an existing owned adoptable.
// $evenmore is the adoptable ID...
$aid = $evenmore;
$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE aid='$aid'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
// This owned adoptable exists, so fetch some basic information...
$article_title = "Owned Adoptables Editor - Editing ".$aid."'s Data";
$article_content = "Here you can edit this owned adoptable using the form below.<br>";
//Loop out code
$i=0;
while ($i < 1) {
$aid=@mysql_result($result,$i,"aid");
$type=@mysql_result($result,$i,"type");
$name=@mysql_result($result,$i,"name");
$totalclicks=@mysql_result($result,$i,"totalclicks");
$currentlevel=@mysql_result($result,$i,"currentlevel");
$usealternates=@mysql_result($result,$i,"usealternates");
$isfrozen=@mysql_result($result,$i,"isfrozen");
$owner=@mysql_result($result,$i,"owner");
$gender=@mysql_result($result,$i,"gender");
$i++;
}
$article_content = $article_content."<form name='form1' method='post' action='eadopt.php'>
<p>Change Adoptable's Type:
<input name='type' type='text' id='type' value='".$type."'>
</p>
<p>Change Adoptable's Name:
<input name='name' type='text' id='name' value='".$name."'>
</p>
<p>Change Adoptable's Owner:
<input name='owner' type='text' id='owner' value='".$owner."'>
</p>
<p>Change Adoptable's total clicks:
<input name='totalclicks' type='text' id='totalclicks' value='".$totalclicks."'>
</p>
<p>Change Adoptable's current level:
<input name='currentlevel' type='text' id='currentlevel' value='".$currentlevel."'>
</p>
<p>Change Adoptable's gender:
<input name='gender' type='text' id='gender' value='".$gender."'>
</p>
<input name='aid' type='hidden' id='aid' value='".$aid."'>
<p>
<input type='submit' name='Submit' value='Submit'>
</p>
</form>";
}
}
else if($more == "delete"){
$aid = $evenmore;
// We are deleting an owned adoptable...
$query = "DELETE FROM ".$prefix."owned_adoptables WHERE aid='".$evenmore."'";
mysql_query($query);
$article_title = "Adoptable Deleted";
$article_content = "This owned adoptable has been deleted successfully.";
}
}
else if($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 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=groups&more=new'><img src='templates/icons/add.gif' border=0> Create a New Usergroup</a></b><p></p><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 = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$groupname=@mysql_result($result,$i,"groupname");
$groupid=@mysql_result($result,$i,"gid");
$canadopt=@mysql_result($result,$i,"canadopt");
$canpm=@mysql_result($result,$i,"canpm");
$cancpx=@mysql_result($result,$i,"cancp");
if($canadopt == "yes"){
$canadoptimg = "<img src='templates/icons/yes.gif'>";
}
else{
$canadoptimg = "<img src='templates/icons/no.gif'>";
}
if($canpm == "yes"){
$canpmimg = "<img src='templates/icons/yes.gif'>";
}
else{
$canpmimg = "<img src='templates/icons/no.gif'>";
}
if($cancpx == "yes"){
$cancpimg = "<img src='templates/icons/yes.gif'>";
}
else{
$cancpimg = "<img src='templates/icons/no.gif'>";
}
if($groupname == "rootadmins" or $groupname == "registered"){
$editimage = "";
$deleteimage = "";
}
else{
$editimage = "<a href='admin.php?set=users&do=groups&more=edit&evenmore=".$groupid."'><img src='templates/icons/cog.gif' border=0></a>";
$deleteimage = "<a href='admin.php?set=users&do=groups&more=delete&evenmore=".$groupid."'><img src='templates/icons/delete.gif' border=0></a>";
}
// Finally we can show this table to the user...
$article_content = $article_content."<tr>
<td>".$groupid."</td>
<td>".$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>";
$i++;
}
$article_content = $article_content."</table>";
}
else if($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 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>
<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 = mysql_query($query);
$num = mysql_numrows($result);
if($num > 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...
mysql_query("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.";
}
}
}
else if($more == "edit"){
// We are editing an existing usergroup...
// $evenmore is the group ID...
$query = "SELECT * FROM ".$prefix."groups WHERE gid='$evenmore'";
$result = mysql_query($query);
$num = mysql_numrows($result);
if($num > 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...
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//Loop out code
$i=0;
while ($i < 1) {
$groupname=@mysql_result($result,$i,"groupname");
$groupid=@mysql_result($result,$i,"gid");
$canadopt=@mysql_result($result,$i,"canadopt");
$canpm=@mysql_result($result,$i,"canpm");
$cancpx=@mysql_result($result,$i,"cancp");
$cma=@mysql_result($result,$i,"canmanageadopts");
$cmc=@mysql_result($result,$i,"canmanagecontent");
$cmads=@mysql_result($result,$i,"canmanageads");
$cms=@mysql_result($result,$i,"canmanagesettings");
$cmu=@mysql_result($result,$i,"canmanageusers");
if($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($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($cancpx == "yes"){
$cancpimg = "<input name='cancp' type='checkbox' id='cancp' value='yes' checked>";
}
else{
$cancpimg = "<input name='cancp' type='checkbox' id='cancp' value='yes'>";
}
if($cma == "yes"){
$cmaimg = "<input name='canmanageadopts' type='checkbox' id='canmanageadopts' value='yes' checked>";
}
else{
$cmaimg = "<input name='canmanageadopts' type='checkbox' id='canmanageadopts' value='yes'>";
}
if($cmc == "yes"){
$cmcimg = "<input name='canmanagecontent' type='checkbox' id='canmanagecontent' value='yes' checked>";
}
else{
$cmcimg = "<input name='canmanagecontent' type='checkbox' id='canmanagecontent' value='yes'>";
}
if($cmads == "yes"){
$cmadsimg = "<input name='canmanageads' type='checkbox' id='canmanageads' value='yes' checked>";
}
else{
$cmadsimg = "<input name='canmanageads' type='checkbox' id='canmanageads' value='yes'>";
}
if($cms == "yes"){
$cmsimg = "<input name='canmanagesettings' type='checkbox' id='canmanagesettings' value='yes' checked>";
}
else{
$cmsimg = "<input name='canmanagesettings' type='checkbox' id='canmanagesettings' value='yes'>";
}
if($cmu == "yes"){
$cmuimg = "<input name='canmanageusers' type='checkbox' id='canmanageusers' value='yes' checked>";
}
else{
$cmuimg = "<input name='canmanageusers' type='checkbox' id='canmanageusers' value='yes'>";
}
$i++;
}
$article_title = "Editing ".$groupname." usergroup";
$article_content = "Here you can edit the settings for the ".$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.
Rusnak PHP 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='".$groupid."'>
</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>";
}
}
else if($more == "delete"){
// We are deleting a usergroup...
$query = "DELETE FROM ".$prefix."groups WHERE gid='".$evenmore."'";
mysql_query($query);
$article_title = "Usergroup Deleted";
$article_content = "The usergroup has been deleted successfully.";
}
else{
$article_title = "Error";
$article_content = "Error. Action does not exist!";
}
}
else if($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><table width='302' border='1'>
</p></form><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 = mysql_query($query);
$num = mysql_numrows($result);
$rowsperpage = 20;
$totalpages = ceil($num / $rowsperpage);
if(is_numeric($more) and $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 = mysql_query($query);
$num2 = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num2) {
$id=@mysql_result($result,$i,"uid");
$username=@mysql_result($result,$i,"username");
$email=@mysql_result($result,$i,"email");
$level=@mysql_result($result,$i,"usergroup");
$article_content = $article_content."
<tr>
<td><b><a href='profile.php?user=".$username."' target='_blank'>".$username."</a></b></td>
<td><a href='mailto:".$email."'>".$email."</a></td>
<td><center>".$level."</center></td>
<td><center><a href='admin.php?set=users&do=edit&more=".$username."'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td><center><a href='admin.php?set=users&do=delete&more=".$username."'><img src='templates/icons/delete.gif' border=0></a></center></td>
</tr>";
$i++;
}
$article_content = $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...
else if($set == "settings"){
//************************************************** *******************************
// HERE IS THE CODE THAT MANAGES CHANGING BASIC SITE SETTINGS...
//************************************************** *******************************
$canedit = cando($group, "canmanagesettings");
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 = $article_content."<b><u>Plugin Settings:</u></b><br>
Listed here are all of the plugins that are using hooks to interface with the Rusnak PHP 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 = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
//Loop out code
$i=0;
while ($i < $num) {
$linktext=@mysql_result($result,$i,"linktext");
$linkurl=@mysql_result($result,$i,"linkurl");
$pluginname=@mysql_result($result,$i,"pluginname");
$article_content = $article_content."<a href='".$linkurl."'>".$linktext."</a> - Generated by the <b>".$pluginname."</b> plugin.";
$i++;
}
}
else{
$article_content = $article_content."<b>There are currently no plugin hooks present.</b>";
}
}
else if($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 Rusnak PHP 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='sitetitle' type='text' id='sitetitle' value='".grabanysetting("browsertitle")."'>
</p>
<p>The site title is what will appear in the browser title bar for your visitors.</p>
<p>Site Slogan:
<input name='slogan' type='text' id='slogan' value='".grabanysetting("slogan")."'>
</p>
<p>Templates equipped to show the site slogan will use this for the slogan.</p>
<p>Admin Contact Email:
<input name='admincontact' type='text' id='admincontact' value='".grabanysetting("admincontact")."'>
</p>
<p>This is the email where a site administator can be reached.</p>
<p>System Mail From Email Address:
<input name='systememail' type='text' id='systememail' value='".grabanysetting("systememail")."'>
<input name='page' type='hidden' id='page' value='basicsettings'>
</p>
<p>This is the email address that will be shown on all outgoing emails from this script, for things such as rewards, password resets, message notifications, etc. It is recommended that you set this to an email address where your members can contact you if necessary.</p>
<p>
<input type='submit' name='Submit' value='Change Settings'>
</p>
</form>";
}
else if($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 = mysql_query($query);
$num = mysql_numrows($result);
while ($i < $num) {
$linktext=@mysql_result($result,$i,"linktext");
$linkurl=@mysql_result($result,$i,"linkurl");
$lid=@mysql_result($result,$i,"id");
if($lid < 6){
$showdelete = "";
}
else{
$showdelete = "<center><a href='admin.php?set=settings&do=links&more=delete&evenmore=".$lid."'><img src='templates/icons/delete.gif' border=0></a></center>";
}
$article_content = $article_content."<tr>
<td>".$linkurl."</td>
<td>".$linktext."</td>
<td><center><a href='admin.php?set=settings&do=links&more=edit&evenmore=".$lid."'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td>".$showdelete."</td>
</tr>
";
$i++;
}
$article_content = $article_content."</table>";
}
else if($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 = mysql_query($query);
$num = mysql_numrows($result);
while ($i < 1) {
$linktext=@mysql_result($result,$i,"linktext");
$linkurl=@mysql_result($result,$i,"linkurl");
$lid=@mysql_result($result,$i,"id");
$linktext = stripslashes($linktext);
$i++;
}
if($lid == $evenmore){
// The link exists, so let's edit it...
if($lid < 6){
// Special link, so we cannot change the location...
$lurlform = "<input name='linkurl' type='text' id='linkurl' value='".$linkurl."' readonly='readonly'>";
}
else{
$lurlform = "<input name='linkurl' type='text' id='linkurl' value='".$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='".$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.";
}
}
else if($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."'";
mysql_query($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.";
}
else if($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.";
}
}
else if($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.rusnakweb.com/forum' target='_blank'>RusnakWeb 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 = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$themeid=@mysql_result($result,$i,"id");
$themename=@mysql_result($result,$i,"themename");
if($themename == ""){
$themename = "Unnamed Theme :: ".$themeurl."";
}
$article_content = $article_content."<option value='".$themeid."'>".$themename."</option>";
$i++;
}
$article_content = $article_content."<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 = mysql_query($query);
$num = mysql_numrows($result);
if($num > 0){
//Loop out code
$i=0;
while ($i < 1) {
$themeurl=@mysql_result($result,$i,"themeurl");
// Update the theme URL in the DB...
$query = "UPDATE ".$prefix."settings SET value='".$themeurl."' WHERE name='themeurl'";
mysql_query($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>";
$i++;
}
}
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.";
}
}
}
else if($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>";
}
else if($do == "somethingelseagain"){
}
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...
else if($set == "ads"){
// We are managing the ads for the site...
$canedit = cando($group, "canmanageads");
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 = $article_content."Here you can manage your ad campaigns. Listed below are all the ads currently running on your website.
<p></p><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 = mysql_query($query);
$num = mysql_numrows($result);
if($num == 0){
$article_content = $article_content."You currently do not have any ads running on your website.";
}
else{
$article_content = $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>";
$i=0;
while ($i < $num) {
$id=@mysql_result($result,$i,"id");
$adname=@mysql_result($result,$i,"adname");
$page=@mysql_result($result,$i,"page");
$impressions=@mysql_result($result,$i,"impressions");
$actualimpressions=@mysql_result($result,$i,"actualimpressions");
$date=@mysql_result($result,$i,"date");
$status=@mysql_result($result,$i,"status");
$adname = stripslashes($adname);
$page = stripslashes($page);
if($status == "active"){
$statusicon = "<center><img src='templates/icons/yes.gif'></center>";
}
else{
$statusicon = "<center><img src='templates/icons/no.gif'></center>";
}
$article_content = $article_content." <tr>
<td>".$adname."</td>
<td>".$page."</td>
<td>".$impressions."</td>
<td>".$actualimpressions."</td>
<td>".$date."</td>
<td>".$statusicon."</td>
<td><center><a href='admin.php?set=ads&do=editad&more=".$id."'><img src='templates/icons/cog.gif' border=0></a></center></td>
<td><center><a href='admin.php?set=ads&do=deletead&more=".$id."'><img src='templates/icons/delete.gif' border=0></a></center></td>
</tr>";
$i++;
}
$article_content = $article_content."</table>";
}
}
else if($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 <center> and </center> 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>";
}
else if($do == "deletead"){
//Run the delete SQL query...
$query = "DELETE FROM ".$prefix."ads WHERE id='".$more."'";
mysql_query($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.";
}
else if($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 = @mysql_query($query);
$num = @mysql_numrows($result);
if($num > 0){
//Loop out code
$i=0;
while ($i < 1) {
$value=@mysql_result($result,$i,"text");
$value = stripslashes($value);
$aid=@mysql_result($result,$i,"id");
$actualimpressions=@mysql_result($result,$i,"actualimpressions");
$impressions=@mysql_result($result,$i,"impressions");
$adname=@mysql_result($result,$i,"adname");
$pagerun=@mysql_result($result,$i,"page");
$adname = stripslashes($adname);
$i++;
}
}
else{
die("Ad does not exist!");
}
$article_content = $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";
}
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************
//Define our current theme
$file = $themeurl;
// Do the template changes and echo the ready template
$template = file_get_contents($file);
$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);
//Define our links
if($cancp == "yes"){
//Admins see a custom set of links here...
$links = getadmlinks();
}
else{
$links = getlinks();
}
$template = replace(':LINKSBAR:',$links,$template);
//Get the content for the side bar...
$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);
//Get the ad content...
$template = replace(':ADS:',$ads,$template);
//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);
echo $template;
// ************************************************** ********************
// End Template Definition
// ************************************************** ********************
?>
Hall of Famer
01-24-2011, 02:35 AM
I dont see a problem with the two files you provided. Are you sure you have specified a gender ratio value for your adoptables already? Please show me the contents in your prefix_adoptables and prefix_owned_adoptables so we can work this out. Also make sure the new row genderratio looks like this:
http://oi55.tinypic.com/10idmb4.jpg
If you somehow have 'latin1_general_ci' in it, please leave that part blank since it may convert your integer values into a string or unrecognizable characters.
RoconzaArt
01-24-2011, 02:51 AM
Please show me the contents in your prefix_adoptables and prefix_owned_adoptables so we can work this out. Also make sure the new row genderratio looks like this:
But I already did post a screenshot what do you mean?
Hall of Famer
01-24-2011, 02:56 AM
I was talking about the actual contents in it, like this:
http://oi53.tinypic.com/25s0u4h.jpg
RoconzaArt
01-24-2011, 03:24 AM
My MYSQL look different so I can screen shot it easy.
http://fc08.deviantart.net/fs71/f/2011/024/2/4/65767658468_by_lord_macguffin-d37x8i9.png
Hall of Famer
01-24-2011, 03:27 AM
umm this is so strange, I cant seem to find out why you are having such a problem on your site at this point. Your script files look just fine, or maybe I could be wrong. Did you happen to install some other addons that may cause compatibility issue against this one? If so, I may try to recode doadopt.php and nadopt.php for you tomorrow when I have time. I am sorry you are still having problem with this modification, it is supposed to be an easy edit.
RoconzaArt
01-24-2011, 03:34 AM
Wait I did install fadillzzz (http://www.mysidiaadoptables.com/forum/member.php?u=1878)'s Secure Random Adoption Process mod come to think of it.
http://www.mysidiaadoptables.com/forum/showthread.php?t=1783
Hall of Famer
01-24-2011, 03:42 AM
I see, I will check for compatibility of his script with mine, perhaps this is what causes your problem? Lemme see if I can find out something for you then Roconza.
Kaeliah
01-24-2011, 08:06 AM
That's probably the issue. Fadilzzz's script replaces the doadopt.php if you use the fix for the promocodes, and he may not be counting correctly.
Hall of Famer
01-24-2011, 09:17 AM
I will take a look into his script and see what causes the incompatibility issue. It may not be the cause of Roconza's problem anyway, but I should give it a shot.
fadillzzz
01-24-2011, 10:08 AM
Wait I did install fadillzzz (http://www.mysidiaadoptables.com/forum/member.php?u=1878)'s Secure Random Adoption Process mod come to think of it.
http://www.mysidiaadoptables.com/forum/showthread.php?t=1783
You forgot to change the method for passing the variable to doadopt.php.
Make a backup of your current doadopt.php and use this code instead
<?php
// ************************************************** ********************
// Mysidia Adoptables Script: doadopt.php
// Copyright 2011 Mysidia Adoptables staff team
// For help and support: http://www.mysidiaadoptables.com/forum/
//
// Redistribution prohibited without written permission
// ************************************************** ********************
// Wake the sleeping giant
// ************************************************** ********************
// Basic Configuration Info
// ************************************************** ********************
include("inc/functions.php");
include("inc/config.php");
include("lang/lang.php");
$themeurl = grabanysetting("themeurl");
// ************************************************** ********************
// Define our top links by calling getlinks()
// ************************************************** ********************
$links = getlinks();
// ************************************************** ********************
// Define our ads by calling getads()
// ************************************************** ********************
$ads = getads("any");
// ************************************************** ********************
// Grab any dynamic article content from the content table
// ************************************************** ********************
$pagecontent = getsitecontent("index");
$article_title = $pagecontent[title];
$article_content = $pagecontent[content];
$article_content = nl2br($article_content);
// ************************************************** ********************
// Grab any settings that we will need for the current page from the DB
// ************************************************** ********************
$browsertitle = grabanysetting("browsertitle");
$sitename = grabanysetting("sitename");
$slogan = grabanysetting("slogan");
// ************************************************** ********************
// Check and see if the user is logged in to the site
// ************************************************** ********************
$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];
// ************************************************** ********************
// End Prepwork - Output the page to the user
// This file actually processes the adoption of a pet...
// ************************************************** ********************
$id = $_SESSION["id"];
$id = preg_replace("/[^a-zA-Z0-9s]/", "", $id);
$id = secure($id);
$promocode = $_REQUEST["promocode"];
$promocode = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $promocode);
$promocode = secure($promocode);
$name = $_REQUEST["name"];
$name = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $name);
$name = secure($name);
$genderratio = $_GET["genderratio"];
$genderratio = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $genderratio);
$genderratio = secure($genderratio);
if($isloggedin == "yes"){
// I guess the first thing to do is see if we have a valid adoptable ID submitted...
if($id == "" or !is_numeric($id)){
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
else{
// The adoptable ID appears to be valid, so we need to double check that it is valid by pulling up the adoptable in the DB
$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$id'";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < 1) {
$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");
$genderratio=@mysql_result($result,$i,"genderratio");
$i++;
}
if($id == $aid){
// The ID submitted matches an existing adoptable type
$canadopt = canadopt($aid, "adopting", $promocode);
// If we can adopt this creature, do the adoption
// Otherwise we show an error...
if($canadopt == "yes"){
// ************************************************** ********************
// BEGIN the actual adoption process
// ************************************************** ********************
// First we see if we have a custom name.
// If not, we use the default name
if($name == ""){
$name = $type;
}
//The gender mod
if($genderratio >= 0 and $genderratio < 101) {
$tempgender = rand(0, 100);
if($tempgender >= 0 and $tempgender < $genderratio) {
$gender = "Female";
unset($tempgender);
}
else {
$gender = "Male";
unset($tempgender);
}
}
else {
$gender = "Genderless";
}
// Now we determine if we are using alternate images or not
$alts = getaltstatus($id, 0, 0);
// Now we actually process the adoption and add it to the database...
// We need a unique code for the adoptable so we can show it to the user when we're done here...
$code = rand(1, 20000);
mysql_query("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no','$gender')");
// Adoption complete, show the user a confirmation screen...
// We need to show the adoptable info from the database...
$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE code='$code' and owner='$loggedinname'";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < 1) {
$id=@mysql_result($result,$i,"aid");
$i++;
}
$article_title = $name." adopted successfully";
$article_content = "<img src='".$eggimage."'><br>".$congrats1." ".$name.". You can now manage ".$name." on the
<a href='myadopts.php'>My Adopts</a> page.<br><br><b><a href='myadopts.php?act=manage&id=".$id."'>Click Here to Manage ".$name."</a><br>
<a href='myadopts.php?act=bbcode&id=".$id."'>Click Here to get BBCodes / HTML Codes for ".$name."</a></b><br><br>
Be sure and <a href='levelup.php?id=".$id.">feed</a> ".$name." with clicks so that they grow!";
// ************************************************** ********************
// END the actual adoption process
// ************************************************** ********************
}
else{
$article_title = $accden;
$article_content = $adoptnoper;
}
} // End the if for if $id == $aid
else{
// Adoptable does not exist, show an error.
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
} // End the else for if $id == $aid
} // End the valid ID input else test statement (bulk of code goes above here)
} // End the log in check IF
else{
// Guests cannot adopt pets, so why bother...
$article_title = $guesttitleerror;
$article_content = $guesterror;
} // End the log in check ELSE
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************
//Define our current theme
$file = $themeurl;
// Do the template changes and echo the ready template
$template = file_get_contents($file);
$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);
$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);
//Define our links
$template = replace(':LINKSBAR:',$links,$template);
//Get the content for the side bar...
$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);
//Get the ad content...
$template = replace(':ADS:',$ads,$template);
//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);
echo $template;
// ************************************************** ********************
// End Template Definition
// ************************************************** ********************
?>
Also please note that I've added a fix for people who use promo code on their adoptables site.
Kaeliah
01-24-2011, 10:12 AM
Thank you fadillzzz :smile:
RoconzaArt
01-24-2011, 10:40 AM
I dunno why but it still will not work for me.
Kaeliah
01-24-2011, 11:05 AM
Try removing the mod, and see if it works then. If it does work, there's still something in the mod messing with it. If it doesn't work then the mod is fine, there's some other mod messing with it.
RoconzaArt
01-24-2011, 11:34 AM
Nope it has to be fadillzzz's Secure Random Adoption Process mod because HOF gender mod works perfect letting me adopt pets just fine with no errors.
Hall of Famer
01-24-2011, 11:53 AM
Oh really? Did you test my script on your site without installing fadillzzz's random adoption system? If it aint causing any errors for you this way, then its definitely your best interest to contact fadillzzz in person to discuss what to do with his mod.
RoconzaArt
01-24-2011, 11:57 AM
It was in fact fadillzzz's random adoption system that was the cause of the problem. I reinstalled you gender ratio system and set a test pet to 102 and adopted a pet which it came out genderless. Your code works perfect it's the other mod that's causing the error.
fadillzzz
01-25-2011, 01:19 AM
Can you show me your current adopt.php and doadopt.php?
EDIT: I just installed this on my experimental site, and the mod is working fine. Also I've updated the tutorial again so that the mod won't break the promo code feature and is compatible with the gender ratio mod
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.