PHP Code:
<?php
include("inc/functions.php");
//***************//
// START SCRIPT //
//***************//
$id = $_GET["id"];
$promocode = $_GET["promocode"];
$_SESSION["allow"] = 1;
// Here we check if we have an ID that has been submitted or no
if($id == "" or !is_numeric($id)) {
// We did not enter in an id, or it is not a number
$article_content .= "<table class='shop' width='100%'><tr><td style='text-align:left;'>";
$article_title .="An eerie, howling wind is starting to pick up its pace in the Misty Woods...";
$article_content .="<big><b>As you walk through the misty woods...</b></big></span><br>a sort of blue fog begins to settle in the forest. You stumble upon a den of eggs, and you can see tiny ears and fluffy tails beginning to poke out from some of the eggs, others are of different shapes and colors. You don't see the mother and wonder if maybe you should attempt to take one. You have set up camp in your own <a href='myadopts.php' style='color:#fff;'>Den</a> and keep records of the animals you have already captured. You can also take an egg or baby that has been <a href='pound.php' style='color:#fff;'>abandoned</a>.
<br>
<center>Which one do you take {$loggedinname}?</center></td></tr></table><br><center><table class='adopt'><tr>
<form name='form1' method='get' action='doadopt.php'>
";
// Check to see if the Abandon Den is full
$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE owner='SYSTEM' AND currentlevel<='4' AND isfrozen='no'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if($num >= 11){
$canadopt = "no";
$article_title = "";
$article_content .= "<td>You realize that there are many eggs in the <a href='pound.php'>Abandoned Den</a> that need homes so you go there instead.</td></tr></table>";
}else{
// If we are a guest, show a message that lets them know that they cannot adopt...
if($isloggedin != "yes"){
$article_content = $article_content.$showingguest;
}
// Begin the output of all the adoptables to the user...
$query = "SELECT * FROM ".$prefix."adoptables WHERE whenisavail='always' and cost='0' ORDER BY RAND() LIMIT 3";
$result = runquery($query);
while($row = mysql_fetch_array($result)) {
$aid=$row['id']; //The adoptable's ID
$type=$row['type'];
$description=$row['description'];
$eggimage=$row['eggimage'];
// Call a function to check if we have the proper privledge level to adopt this pet
if($promocode == ""){
$promocode = "none";
}
$canadopt = canadopt($aid, "showing", $promocode, $row); // Feed an adoptable ID and showing, to show the adopt to guests...
if($canadopt == "yes"){
//If we can adopt the adoptable, show the image and adoption link...
$article_content .= "
<td VALIGN='top'><a href='doadopt.php?id=".$aid."'><img src='http://www.silvadopts.com/picuploads/png/dee54ce4a7e38bcc36d1fbfa8858be3a.png' /></a><br>
<b>".stripslashes($description)."</b></td>";
}
} // End the looping out of all adoptables...
}
$article_content .= "</tr></table><br><br>";
} // This bracket ends the IF check for whether or not an ID was entered
else{
// We have specified an ID of an adoptable we wish to adopt
$query = "SELECT * FROM ".$prefix."adoptables WHERE id='$id' LIMIT 1";
$result = runquery($query);
$row = mysql_fetch_array($result);
$aid = $row['id'];
$type=$row['type'];
$description=$row['description'];
$eggimage=$row['eggimage'];
if($aid == $id){
//The adoptable exists and is valid
$canadopt = canadopt($aid, "adopting", $promocode, $row);
if($canadopt == "yes"){
$article_title = "Adopting ".$type;
$article_content = $langa1."".$type.$langa2;
$article_content = $article_content."<br><img src='http://www.silvadopts.com/picuploads/png/385ade0f167fa7d74113e3eb74f55ff6.png'><br>
<form name='form1' method='get' action='doadopt.php'>
<p>Adoptable Name:
<input name='name' type='text' id='name'>
<input name='id' type='hidden' id='id' value='".$id."'>
<input name='promocode' type='hidden' id='promocode' value='".$promocode."'>
</p>
<p>
<input type='submit' name='Submit' value='Adopt Me'>
</p>
</form>";
}
else{
$article_title = $accden;
$article_content = $adoptnoper;
} // End Can Adopt ELSE
}
else {
//The adoptable does not exist, nothing we can do...
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
} // End adoptable does not exist ELSE
} // This bracket ends the else statements for whether or not an ID was entered
//***************//
// OUTPUT PAGE //
//***************//
echo showpage($article_title, $article_content, $date);
?>