Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.2.x Mods

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-13-2011, 04:41 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 32,816
fadillzzz is an unknown quantity at this point
Default Secure Random Adoption V2

This mod is intended for people who already or wanted to have a random adoption process on their adoptables site.

Compatibility: Mys V1.2.x
NOTE:Please make a backup of your files before installing this mod!


1. Open your adopt.php and find
PHP Code:
    $query "SELECT * FROM ".$prefix."adoptables"
replace it with the code below to fetch only 1 random adoptables from the database
PHP Code:
    $query "SELECT * FROM ".$prefix."adoptables ORDER BY RAND() LIMIT 1"
2. A few lines after that, find
PHP Code:
    $article_content .= "<form name='form1' method='get' action='doadopt.php'> 
replace it with this
PHP Code:
    $article_content .= "<form name='form1' method='post' action='adopt.php'> 
3. And then, go find this code
PHP Code:
        if($canadopt == "yes"){
            
//If we can adopt the adoptable, show the image and adoption link...
            
$article_content .= "<tr>
            <td><input type='radio' name='id' id='id' value='
{$aid}' /></td>
            <td style='text-align: center'><img src='"
.$eggimage."' /></td>

            <td><strong>
{$type}</strong> -  {$row['cost']} {$GLOBALS['settings']['cost']}.<br  />{$description}</td></tr>";
        } 
Since we only want to show 1 adoptables and obviously without any information for randomness, replace that code with
PHP Code:
        if($canadopt == "yes"){
            
//If we can adopt the adoptable, show the image and adoption link...
            
$article_content .= "<tr>
            <td style='text-align: center'><img src='"
.$eggimage."' /></td>";
        }
        else{
            
$eresult runquery("SELECT * FROM ".$prefix."adoptables WHERE whenisavail='always' ORDER BY RAND() LIMIT 1");
            while(
$erow mysql_fetch_array($eresult)){
                
$aid=$erow['id']; //The adoptable's ID
                
$type=$erow['type'];
                
$description=$erow['description'];
                
$eggimage=$erow['eggimage'];
                
$article_content .= "<tr>

                <td style='text-align: center'><img src='"
.$eggimage."' /></td>";
            }

        } 
You may notice that I put an else statement. The else statement is used in case the first query fetch an adoptables that you can't adopt because you haven't met the necessary requirement. It will fetch an adoptables with the always available condition.
Anyway, let's move on.
4. Find the following
PHP Code:
    $query "SELECT * FROM ".$prefix."adoptables WHERE id='$id' LIMIT 1"
and replace it with
PHP Code:
    $query "SELECT * FROM ".$prefix."adoptables WHERE id='$id' AND whenisavail='promo' LIMIT 1"
Restrict the GET method only for adopting adoptables with promo code
5. Finally, find the last closing curly bracket
PHP Code:
// This bracket ends the else statements for whether or not an ID was entered 
and below that add this code
PHP Code:
if($_POST)
{
$id $aid;
$name $_POST["name"];

    if(
$isloggedin == "yes"){
        
// I guess the first thing to do is see if we have a valid adoptable ID submitted...
        
if($id == "" or !is_numeric($id)){
            
$article_title $err_idnoexist;
            
$article_content $err_idnoexist_text;
        }
        else{
            
// The adoptable ID appears to be valid, so we need to  double check that it is valid by pulling up the adoptable in the DB

            
$query "SELECT * FROM ".$prefix."adoptables WHERE id='$id'";
            
$result runquery($query);

            
$result runquery($query);
            
$row mysql_fetch_array($result);

            
$aid $row['id'];
            
$type=$row['type'];
            
$description=$row['description'];
            
$eggimage=$row['eggimage'];

            if(
$id == $aid){
                
// The ID submitted matches an existing adoptable type
                
$canadopt canadopt($aid"adopting"$promocode$row);

                
// 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 "Mystery Egg";
                        }

                        
// Now we determine if we are using alternate images or not

                        
$alts getaltstatus($id00);

                        
// We need a unique code for the adoptable so we can show it to the user when we're done here...

                        
$code rand(120000);
                        
$genders = array('f''m');
                        
$rand rand(0,1);
                        
                        
runquery("INSERT INTO  ".$prefix."owned_adoptables VALUES ('', '$type',  '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no',  '$genders[$rand]','0')");

                        
// Adoption complete, show the user a confirmation screen...

                        
$query "SELECT * FROM ".$prefix."owned_adoptables WHERE code='$code' and owner='$loggedinname'";
                        
$result runquery($query);
                        
$num mysql_numrows($result);
                         
                        
$id=@mysql_result($result,0,"aid"); 

                        
$article_title $name." adopted successfully";
                        
$article_content "<img  src='".$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!";

                        
// 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.";
                    }
                }
                else {
                    
$article_title $accden;
                    
$article_content $adoptnoper;
                }
            } 
// End the if for if $id == $aid
            
else {
                
// Adoptable does not exist, show an error.

                
$article_title $err_idnoexist;
                
$article_content $err_idnoexist_text;
            } 
// End the else for if $id == $aid
        
// End the valid ID input else test statement (bulk of code goes above here)
    
// End the log in check IF
    
else {
        
// Guests cannot adopt pets, so why bother...
        
$article_title $guesttitleerror;
        
$article_content $guesterror;
    } 
// End the log in check ELSE 


6.
Now, to prevent some users from cheating. Open your doadopt.php, we'll just do a slight query modification.
Find this query
PHP Code:
        $query "SELECT * FROM ".$prefix."adoptables WHERE id='$id'"
replace that query with this one
PHP Code:
        $query "SELECT * FROM ".$prefix."adoptables WHERE id='$id' AND whenisavail = 'promo'"
We just restricted the doadopt.php file to only work with adoptables with promo code.

Done!

Let me know if there's any problem with this mod. :)
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adoption Problems Kamalya Questions and Supports 8 01-27-2013 01:15 PM
Secure Random Adoption Process fadillzzz Mys v1.1.x Mods 19 02-14-2011 11:12 AM
Random Adoption nitrogen Questions and Supports 4 05-10-2009 09:10 AM
Random 5 is not realy random! RipJawWolfFang Questions and Supports 9 04-30-2009 06:03 AM


All times are GMT -5. The time now is 03:46 PM.

Currently Active Users: 596 (0 members and 596 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636