PHP Code:
<?php
include("functions/functions.php");
include("functions/functions_users.php");
include("functions/functions_adopts.php");
include("inc/lang.php");
//***************//
// START SCRIPT //
//***************//
$id = $_GET["id"];
$promocode = $_GET["promocode"];
$date = date("M j, Y");
// $date = "Oct 23, 2001";
$_SESSION["allow"] = 1;
// Here we check if we have an ID that has been submitted or no
if($id == "") {
// We did not enter in an id, or it is not a number
$article_title = $showingtitle;
// 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...
$uncommon = rand(1,50);
$rare = rand(1,100);
$ultrarare = rand(1,200);
if ($uncommon==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
}
else if ($rare==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
}
else if ($ultrarare==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
}
else{
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
}
$stmt = $adopts->query($query);
$article_content .= "
<table class='adopt'><tr>";
while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
$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'><br><br><br><br><br><br><br><br><br><br><a href='doadopt.php?id=".$aid."'><img src='picuploads/png/e42598f988b271a7e66b36b9a5d8143b.png' /></a><br>
{$description}</td>";
}
}
if ($uncommon==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
}
else if ($rare==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
}
else if ($ultrarare==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
}
else{
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
}
$stmt = $adopts->query($query);
while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
$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'><br><br><br><br><br><br><br><br><br><br><a href='doadopt.php?id=".$aid."'><img src='picuploads/png/e42598f988b271a7e66b36b9a5d8143b.png' /></a><br>
{$description}</td>";
}
}
if ($uncommon==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='1' ORDER BY RAND() LIMIT 1";
}
else if ($rare==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='2' ORDER BY RAND() LIMIT 1";
}
else if ($ultrarare==1){
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='3' ORDER BY RAND() LIMIT 1";
}
else{
$query = "SELECT * FROM ".$prefix."adoptables WHERE rarity='0' ORDER BY RAND() LIMIT 1";
}
$stmt = $adopts->query($query);
while($row = $stmt->fetch(PDO::FETCH_OBJ)) {
$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'><br><br><br><br><br><br><br><br><br><br><a href='doadopt.php?id=".$aid."'><img src='picuploads/png/e42598f988b271a7e66b36b9a5d8143b.png' /></a><br>
{$description}</td>";
}
}
// End the looping out of all adoptables...
$article_content .= "</tr></table>";
} // 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, {$prefix}adoptables_conditions
WHERE {$prefix}adoptables.id='{$id}'
{$prefix}adoptables_conditions.id = {$prefix}adoptables.id";
$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='{$eggimage}' border='0'><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);
?>