SilverDragonTears |
01-05-2012 08:57 PM |
This is what I tried and it's not working. I'm sure I'm not even close.
PHP Code:
else if($act == "breed"){
$_SESSION["breeding"] = 1;
if(is_numeric($id)){
$breedinglevel = grabanysetting('breedinglevel');
$article_title = "Breeding System";
$article_content = "<p>You may breed your adoptables here. They must be at least a level {$breedinglevel} to be able to breed.</p>";
$femaleid = $_POST['female'];
$maleid = $_POST['male'];
$breed = $_POST['breed'];
$date = date("M j, Y");
// $date = "March 23, 2010";
if ($isloggedin == "yes"){
if($_SESSION["breeding"] != 1){
$article_title = $err_idnoexist;
$article_content = $err_idnoexist_text;
}
elseif($_SESSION["breeding"] == 1){
$query = "SELECT * FROM ".$prefix."owned_adoptables WHERE owner='".$loggedinname."' AND currentlevel<='3' AND isfrozen='no'";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if($num >= 5){
$breed = 'no';
$article_title = "Too many eggs to breed!";
$article_content = "You already have too many eggs to take care of!";
}
else if ($breed != 'yes'){ // if they have not chosen which pets to breed yet, we let them choose
$article_content .= "<p>Select the two adoptables that you'd like to breed:</p><form method='post'>";
$lastweek = time() - ((grabanysetting('breedinginterval')) * 24 * 60 * 60);
// show all available female adoptables
$result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' and aid='$id' AND gender = 'f' AND canbreed = 'yes' AND currentlevel >= {$breedinglevel} AND lastbred <= '$lastweek'") ;
$num = mysql_num_rows($result);
if ($num!=0) {
$article_content .= "<p>Female: <select name='female'>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$article_content .= "<option value='{$row['aid']}'>{$row['aid']} {$row['name']} ({$row['type']})</option>";
}
$article_content .= "</select></p>";
}
else {
$article_content .= "<p>Your female can't breed at this time.</p>";
}
// show all available male adoptables
$result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE owner = '$loggedinname' AND gender = 'm' AND canbreed = 'yes' AND currentlevel >= {$breedinglevel} AND lastbred <= '$lastweek'") ;
$num = mysql_num_rows($result);
if ($num!=0) {
$article_content .= "<p>Male: <select name='male'>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$article_content .= "<option value='{$row['aid']}'>{$row['aid']} {$row['name']} ({$row['type']})</option><br>";
}
$article_content .= "</select></p>";
}
else {
$article_content .= "<p>None of your male adoptables can breed at the time.</p>";
}
$article_content .= "<input type='hidden' name='breed' value='yes'><input type='submit' value='Breed It'></form>";
}
else {
$result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$femaleid'") ;
$female = mysql_fetch_array($result);
$female_type = @mysql_result($result,0,'type');
$female_name = @mysql_result($result,0,'name');
$result2 = runquery("SELECT * FROM ".$prefix."adoptables WHERE type = '$female_type'") ;
$female_species = mysql_fetch_array($result2);
$female_class = @mysql_result($result2,0,'class');
$bredchance = @mysql_result($result2,0,'bredchance');
$result = runquery("SELECT * FROM ".$prefix."owned_adoptables WHERE aid = '$maleid'") ;
$male = mysql_fetch_array($result);
$male_type = @mysql_result($result,0,'type');
$male_name = @mysql_result($result,0,'name');
$result2 = runquery("SELECT * FROM ".$prefix."adoptables WHERE type = '$male_type'") ;
$male_species = mysql_fetch_array($result2);
$male_class = @mysql_result($result2,0,'class');
// let's check the requirements first.
if($female_class != $male_class){//check if the male and female belong to the same breeding class
$article_content = "Sorry, it seems that your two adoptables do not belong to the same breeding class.";
}
else if (($female['currentlevel'] < (grabanysetting('breedinglevel'))) OR ($male['currentlevel'] < (grabanysetting('breedinglevel')))){ // check the adoptables' levels
$article_content .= "Sorry, one of your adoptables don't have the minimum level to breed. Keep getting clicks for them so they can grow.";
}
// the below codes check if the user has modified the form using firebug or inspect element...
elseif($female['owner'] != $loggedinname or $male['owner'] != $loggedinname){
// The adoptables do not belong to the owner... This user has apparently modified the content of drop-down form, and thus deserves his/her punishment
runquery("UPDATE {$prefix}users SET usergroup=5 WHERE username='{$loggedinname}'");
$article_title = "An error has occurred";
$article_content = "It appears that at least one of the adoptables selected do not belong to yours. You have been banned for this action, please contact site administrator for more info.";
}
elseif($female['gender'] != "f" or $male['gender'] != "m"){
// The female's gender is male or male's gender is female? This user has apparently modified the content of drop-down form, and thus deserves his/her punishment
runquery("UPDATE {$prefix}users SET usergroup=5 WHERE username='{$loggedinname}'");
$article_title = "An error has occurred";
$article_content = "It appears that the female and/or male adoptables gender's have been modified. You have been banned for this action, please contact site administrator for more info.";
}
else {
// we choose the type!
if ($female_type == 'Noctis Silvfox Beta' && $male_type == 'Noctis Silvfox Beta'){
$female_type = 'Noctis Silvfox' && $male_type = 'Noctis Silvfox';}
$types = array($female_type, $male_type);
if ($female_type == 'Red Stitch Silvfox Beta' && $male_type == 'Red Stitch Silvfox Beta'){
$female_type = 'Red Stitch Silvfox' && $male_type = 'Red Stitch Silvfox';}
$types = array($female_type, $male_type);
if ($female_type == 'White Stitch Silvfox Beta' && $male_type == 'White Stitch Silvfox Beta'){
$female_type = 'White Stitch Silvfox' && $male_type = 'White Stitch Silvfox';}
$types = array($female_type, $male_type);
if ($female_type == 'White Silvfox Beta' && $male_type == 'Red Stitch Silvfox Beta'){
$female_type = 'White Stitch Silvfox' && $male_type = 'Red Stitch Silvfox';}
$types = array($female_type, $male_type);
if ($female_type == 'Noctis Silvfox Beta' && $male_type == 'Red Stitch Silvfox Beta'){
$female_type = 'Noctis Silvfox' && $male_type = 'Red Stitch Silvfox';}
$types = array($female_type, $male_type);
if ($female_type == 'Noctis Silvfox Beta' && $male_type == 'White Stitch Silvfox Beta'){
$female_type = 'Noctis Silvfox' && $male_type = 'White Stitch Silvfox';}
$types = array($female_type, $male_type);
if ($female_type == 'Noctis Silvfox Beta' && $male_type != '$male_type'){
$female_type = 'Noctis Silvfox';
$types = array($female_type, $male_type);}
if ($female_type == 'Red Stitch Silvfox Beta' && $male_type != '$male_type'){
$female_type = 'Red Stitch Silvfox';
$types = array($female_type, $male_type);}
if ($female_type == 'White Stitch Silvfox Beta' && $male_type != '$male_type'){
$female_type = 'White Stitch Silvfox';
$types = array($female_type, $male_type);}
if ($female_type != '$female_type' && $male_type == 'Noctis Silvfox Beta'){
$male_type = 'Noctis Silvfox';
$types = array($female_type, $male_type);}
if ($female_type != '$female_type' && $male_type == 'Red Stitch Silvfox Beta'){
$male_type = 'Red Stitch Silvfox';
$types = array($female_type, $male_type);}
if ($female_type != '$female_type' && $male_type == 'White Stitch Silvfox Beta'){
$male_type = 'White Stitch Silvfox';
$types = array($female_type, $male_type);}
if ($female_type == 'Autumn Silvfox' && $male_type == 'Autumn Silvfox'){
$female_type = 'Winter Silvfox' && $male_type = 'Winter Silvfox';}
$types = array($female_type, $male_type);
if ($female_type == 'Autumn Silvfox' && $male_type != '$male_type'){
$female_type = 'Winter Silvfox';
$types = array($female_type, $male_type);}
if ($female_type != '$female_type' && $male_type == 'Autumn Silvfox'){
$male_type = 'Winter Silvfox';
$types = array($female_type, $male_type);}
$types = array($female_type, $male_type);
$typerand = rand(0,1);
// we choose the gender
$genders = array('f', 'm');
$genderrand = rand(0,1);
$code = rand(1, 20000);
// MESSY - I'm blanking out on how to find the actual alt status stuff right now, any help would be lovely.
$alts = getaltstatus($aid, 0, 0);
if($genders[$genderrand] == 'f') { $alts = 'yes';}
$time = time();
$bredtemp = rand(0,100);
if($bredtemp <= $bredchance){
$article_content = "These two don't seem very interested in each other right now. Try again in a week.";
}
else{
$newquery = "INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$types[$typerand]', 'Unnamed', '$loggedinname', '0', '0', '$code', '', '$alts', 'notfortrade', 'no', '$genders[$genderrand]', '$lastbred', '$lastinfluence', '$lastbite', 'sort', '$maleid', '$femaleid', '$desc', '$date', '','yes', '$biterid', 'no')";
runquery($newquery);
unset($_SESSION["breeding"]);
// END the actual adoption process
}
$article_content = "Congratulations! Breeding is successful, you have acquired a baby ".$types[$typerand]." from breeding center.
<br><a href='myadopts.php'>Manage your new {$types[$typerand]} now!</a></p>";
}
runquery("UPDATE ".$prefix."owned_adoptables SET lastbred = '$time' WHERE aid = '$femaleid'");
runquery("UPDATE ".$prefix."owned_adoptables SET lastbred = '$time' WHERE aid = '$maleid'");
} // we end the place where it goes on if the levels are ok
} //this bracket ends the else where we find the male/female id's
}// this is the end of if($isloggedin == "yes")
else {
$article_content .= "You are not logged in. Please log in to use this feature.";
}
}
|