GuardiansWish |
09-28-2012 08:05 PM |
Yea, I realized that and went back and re-did it, still getting the same error.
Code:
<?php
define("SUBDIR", "AdminCP");
include("../functions/functions.php");
include("../functions/functions_users.php");
include("../functions/functions_adopts.php");
include("../inc/lang.php");
//***************//
// START SCRIPT //
//***************//
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...
$page = $_POST["page"];
if($page == "createanadopt"){
// We are logged in and can access this page, so let's get the post info...
$name = $_POST["name"];
$class = $_POST["class"];
$description = $_POST["description"];
$cost = $_POST["cost"];
$imageurl = $_POST["imageurl"];
$existingimageurl = $_POST["existingimageurl"];
$cba = $_POST["cba"];
$freqcond = $_POST["freqcond"];
$number = $_POST["number"];
$datecond = $_POST["datecond"];
$date = $_POST["date"];
$adoptscond = $_POST["adoptscond"];
//////////////////////////////////////////////////////////////////////
$maxnumcond = $_POST["maxnumcond"];
$morethannum = $_POST["morethannum"];
$usergroupcond = $_POST["usergroupcond"];
$usergroups = $_POST["usergroups"];
//////////////////////////////////////////////////////////////////////
$alternates = $_POST["alternates"];
$altoutlevel = $_POST["altoutlevel"];
$altchance = $_POST["altchance"];
// Now we run some checks to make sure that we have a go.
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($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...
$obj = $adopts->select("adoptables", array(), "type = '{$name}'")->fetchObject();
if(is_object($obj)) $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...
if($imageurl != "" and $existingimageurl == "none") $eggimage = $imageurl;
else $eggimage = $existingimageurl;
// insert into table adoptables
$adopts->insert("adoptables", array("id" => NULL, "type" => $name, "class" => $class, "description" => $description, "eggimage" => $eggimage, "whenisavail" => $cba,
"alternates" => $alternates, "altoutlevel" => $altoutlevel, "altchance" => $altchance, "cost" => $cost));
// insert into table adoptables_conditions
$adopts->insert("adoptables_conditions", array("id" => NULL, "type" => $name, "whenisavail" => $cba, "freqcond" => $freqcond, "number" => $number, "datecond" => $datecond,
"date" => $date, "adoptscond" => $adoptscond, "moreless" => $maxnumcond, "morelessnum" => $morethannum, "levelgrle" => $usergroupcond, "grlelevel" => $usergroups));
// insert our level thing
$adopts->insert("levels", array("lvid" => NULL, "adoptiename" => $name, "thisislevel" => 0, "requiredclicks" => 0,
"primaryimage" => $eggimage, "alternateimage" => NULL, "rewarduser" => NULL, "promocode" => NULL));
$article_title = "Adoptable Added Successfully";
$article_content = "Your adoptable, {$name}, has been added to the database successfully. You can now <a href='adopt.php?do=addlevel'>Add a Level</a> to this adoptable. You can also <a href='index.php'>go back to the Admin CP index page</a>.";
}
}
elseif($page == "editanadopt"){
// Edit an adoptable...
$select = $_POST["select"];
$delete = $_POST["delete"];
$deltype = $_POST["deltype"];
$resetconds = $_POST["resetconds"];
$resetdate = $_POST["resetdate"];
$date = $_POST["date"];
$type = $_POST["type"];
if($delete == "yes"){
// We are either deleting or freezing the adoptable...
if($deltype == "freeze"){
// We are simply freezing the adoptable, prohibiting new adoptions...
// Let's use the conditions setting to make an impossible condition so it can never be adopted...
$code = rand(1,300000);
$adopts->update("adoptables", array("whenisavail" => promo), "type='{$type}'");
$adopts->update("adoptables_conditions", array("whenisavail" => promo), "type='{$type}'");
$article_title = "Adoptable Frozen Successfully";
$article_content = "This adoptable will no longer appear available for new adoptions.
To reverse this you can manage this adoptable again and choose to remove all restrictions on its adoption.
<a href='adopt.php'>Click Here</a> to manage your adoptables.";
}
elseif($deltype == "soft"){
// We are doing a soft delete...
// First we need to level up any users currently using this adoptable as an egg...
// Now we do a mass upgrade of all users with this adoptable type and eggs of this adoptable type...
$adopts->update("owned_adoptables", array("currentlevel" => 1), "type='{$type}' AND currentlevel='0'");
// Now we delete the egg image...
$adopts->delete("adoptables", "type='{$type}'");
$adopts->delete("adoptables_conditions", "type='{$type}'");
$article_title = "Adoptable Deleted Successfully";
$article_content = "A soft delete was performed successfully. <a href='adopts.php'>Click Here</a> to manage your adoptables.";
}
elseif($deltype == "hard"){
// Hard delete, there's no going back...
// First we delete any owned adoptables of this type from the system...
$adopts->delete("owned_adoptables", "type='{$type}'");
// Now delete any levels for this type of adoptable...
$adopts->delete("levels", "adoptiename='{$type}'");
// Now we can delete the egg image...
$adopts->delete("adoptables", "type='{$type}'");
$adopts->delete("adoptables_conditions", "type='{$type}'");
$article_title = "Adoptable Deleted Successfully";
$article_content = "The adoptable was deleted successfully and was purged from the system. All traces have been removed.
<a href='adopt.php'>Click Here</a> to manage adoptables.";
}
else{
// We should NEVER get here under normal operations (unless the user is an idiot)...
$article_title = "Delete Error";
$article_content = "We could not delete your adoptable from the system. Perhaps you did not specify a deletion type?
If that's the case, please go back and specify a deletion type.";
}
}
else{
// We are not deleting or freezing the adoptable, so do the rest of the actions...
if($select != "" and $select != "nochange"){
// We are updating the adoptable's image in the database...
$adopts->update("adoptables", array("eggimage" => $select), "type='{$type}'");
}
if($resetconds == "yes"){
// Let's remove all of the restrictions from this adoptable
// This is easy, just set when is available to always :)
$adopts->update("adoptables", array("whenisavail" => 'always'), "type='{$type}'");
$adopts->update("adoptables_conditions", array("whenisavail" => 'always'), "type='{$type}'");
}
if($resetdate == "yes" and $date != ""){
// We are resetting only the adoption based date restriction...
$adopts->update("adoptables_conditions", array("date" => $date), "type='{$type}'");
}
// All Done!
$article_title = "Adoptable Updated";
$article_content = "Your changes have been saved. <a href='adopt.php'>Click Here</a> to manage your adoptables.";
}
}
elseif($page == "addanadopt"){
// We are giving an adoptable to user
$owned_adoptable['type'] = $_POST["type"];
$owned_adoptable['name'] = $_POST["name"];
$owned_adoptable['owner'] = $_POST["owner"];
$owned_adoptable['clicks'] = $_POST["clicks"];
$owned_adoptable['level'] = $_POST["level"];
$owned_adoptable['usealternates'] = $_POST["usealternates"];
$owned_adoptable['gender'] = $_POST["gender"];
foreach($owned_adoptable as $key=>$val){
if($val == ""){
$error = "You did not enter in {$key} for the adoptable. Please go back and try again.";
$flag = "yes";
}
}
switch ($flag){
case "yes":
//If we have an error, show it. Otherwise continue...
$article_title = "An Error Has Occurred!";
$article_content = $error;
break;
default:
//There has been no error, continue with the addition of the adoptable to the system...
$code = codegen(10,0);
$adopts->insert("owned_adoptables", array("aid" => NULL, "type" => $owned_adoptable['type'], "name" => $owned_adoptable['name'], "owner" => $owned_adoptable['owner'], "currentlevel" => $owned_adoptable['level'], "totalclicks" => $owned_adoptable['clicks'], "code" => $code,
"imageurl" => NULL, "usealternates" => $owned_adoptable['usealternates'], "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $owned_adoptable['gender'], "lastbred" => 0));
$article_title = "Adoptable Added Successfully";
$article_content = "A new adoptable, {$owned_adoptable['name']}, has been added for user {$owned_adoptable['owner']} successfully.
</br><a href='users.php'>Click Here</a> to return to the user manager.";
}
}
elseif($page == "manageanadopt"){
// We are now editing this adoptable's info
$aid = $_POST["aid"];
$owned_adoptable['type'] = $_POST["type"];
$owned_adoptable['name'] = $_POST["name"];
$owned_adoptable['owner'] = $_POST["owner"];
$owned_adoptable['clicks'] = $_POST["totalclicks"];
$owned_adoptable['level'] = $_POST["currentlevel"];
$owned_adoptable['gender'] = $_POST["gender"];
// Now we run some checks to make sure that we have a go.
foreach($owned_adoptable as $key=>$val){
if($val == ""){
$error = "You did not enter in {$key} for the adoptable. Please go back and try again.";
$flag = "yes";
}
}
switch ($flag){
case "yes":
//If we have an error, show it. Otherwise continue...
$article_title = "An Error Has Occurred!";
$article_content = $error;
break;
default:
//There has been no error, continue with the editing of the adoptable to the system...
$adopts->update("owned_adoptables", array("type" => $owned_adoptable['type'], "name" => $owned_adoptable['name'], "owner" => $owned_adoptable['owner'], "totalclicks" => $owned_adoptable['clicks'], "currentlevel" => $owned_adoptable['level'], "gender" => $owned_adoptable['gender']), "aid='{$aid}'");
$article_title = "Adoptable Edited Successfully";
$article_content = "The data of adoptable {$owned_adoptable['name']} has been edited for user {$owned_adoptable['owner']} successfully.
</br><a href='users.php'>Click Here</a> to return to the user manager. ";
}
}
elseif($page == "delimg")
{
// Delete an image...
$iid = $_POST["iid"];
if(is_numeric($iid)){
// Check that the image with the ID actually exists on the server...
$stmt = $adopts->select("filesmap", array(), "id='{$iid}'");
if($row = $stmt->fetchObject()){
// Check that the image file exists on the server, it is writable, and the IDs match...
if($row->id == $iid and is_writable($row->serverpath)){
// We can only delete files that are writable by the server...
// Actually delete the file...
unlink($row->serverpath);
// Delete the file from the filesmap...
$adopts->delete("filesmap", "id='{$iid}'");
$article_title = "File Deleted Successfully";
$article_content = "The file was deleted successfully. <a href='adopt.php?do=manageimg'>Click Here</a> to delete another file.";
}
else{
// We cannot delete the file...
$article_title = "File Deletion Failed";
$article_content = "We cannot delete your file. Either the file does not exist on the server, or it does not exist in the database, or it exists but it is not writable so the server will not permit deletion.
Please use a FTP program to manually delete the file.";
}
}
else{
$article_title = "Image Not Found";
$article_content = "An image with the specified ID was not found. Please go back and try again. If issues persist, try deleting the image with your FTP program.";
}
}
else{
$article_title = "Invalid or Incorrect Image ID";
$article_content = "The image id is either blank or is not numeric. Please go back and select a valid image from the images list.";
}
}
else{
$article_title = "Error";
$article_content = "Error. The specified action is invalid or does not exist!";
}
}
else{
$article_title = "Access Denied";
$article_content = "Access Denied";
}
}
else{
$article_title = "Access Denied";
$article_content = "Access Denied";
}
//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, $date);
?>
|