// If we can adopt this creature, do the adoption
if($canadopt == "yes") {
if (changecash(-$row->cost, $GLOBALS['loggedinname'], $GLOBALS['money'])==true) {
// BEGIN the actual adoption process
// First we see if we have a custom name; if not, we use the default name
if($name == "") $name = $row->type;
// Now we determine if we are using alternate images or not
$alts = getaltstatus($id, 0, 0);
// We need a unique code for the adoptable so we can show it to the user when we're done here...
$code = codegen(10, 0);
$genders = array('f', 'm');
$rand = rand(0,1);
$adopts->insert("owned_adoptables", array("aid" => NULL, "type" => $row->type, "name" => $name, "owner" => $loggedinname, "currentlevel" => 0, "totalclicks" => 0, "code" => $code,
"imageurl" => NULL, "usealternates" => $alts, "tradestatus" => 'fortrade', "isfrozen" => 'no', "gender" => $genders[$rand], "lastbred" => 0));
// Adoption complete, show the user a confirmation screen...
$owned_adoptable = $adopts->select("owned_adoptables", array(), "code='{$code}' and owner='{$loggedinname}'")->fetchObject();
$id = $owned_adoptable->aid;
$article_title = $name." adopted successfully";
$article_content = "<img src='{$row->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!";
unset($_SESSION["allow"]);
// END the actual adoption process
}
else {
$article_title = "Not enough money.";
$article_content = "You don't have enough {$GLOBALS['settings']['cost']} to buy this adoptable. Earn some money and then try again.";
}
}