Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Tutorials and Tips

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2011, 10:57 AM
Chibi_Chicken Chibi_Chicken is offline
Niwatori Kami
 
Join Date: Jun 2011
Posts: 63
Gender: Unknown/Other
Credits: 5,045
Chibi_Chicken is on a distinguished road
Default Promo code with Disposable keys

Lets say you have an adoptable that you want to limit to the users, with this mod you can assign a key with that promo code and when they enter it and adopt
the pet. It will delete the key so they can cant get more than the one pet.
Since the new version of Mysidia may be coming out in a few months with a new modding system, I am just going to release this as a how to find and replace.

The files you need to edit are
functions.php - You will be modifying the canadopt.
adopt.php - You will be adding another input value and altering a function call and some form values that are sent out
doadopt.php - You will be adding another input value and altering a function call and adding a sql query to remove the key
promo.php - You will be adding another input value and altering how it checks the promo code if it is valid


To start off with run this Sql command:
CREATE TABLE adopts_promo_keys (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, promo_code varchar(50), promo_key varchar(50));

This is where you will add in any keys that you want users to have when adopting pets.

next open up inc/functions.php
find
PHP Code:
    if($row['whenisavail'] == "promo" and $promocode != $row['promocode']) {
        return 
"no";
    } 
And REPLACE with
PHP Code:
//------------
//promo mod
//-----------    
    
if($row['whenisavail'] == "promo"){
        
//we are using promo codes so now we need to get the key and check if the promo and key match else return false
        
$query "SELECT * FROM ".$GLOBALS['prefix']."promo_keys WHERE promo_code='$promocode'     AND promo_key='$pkey'";
        
$result = @mysql_query($query);
        
$num = @mysql_numrows($result);
        
        if(
$num<1){
            return 
"no";
        }
    
    }
//------------
//end promo mod
//----------- 
Save and close.
Next open up promo.php

Find
PHP Code:
$promocode $_GET["promocode"]; 
After Add
PHP Code:
//------------
//promo mod
//-----------
if (!empty($_POST['promokey']) || !empty($_GET['promokey']))
{
    
$pkey = (!empty($_POST['promokey'])) ? $_POST['promokey'] : $_GET['promokey'];
}
else
{
    
$pkey '';
}
//------------
//end promo mod
//----------- 
Next Find
PHP Code:
$article_content $lang_enter_code."<br><form name='form1' method='get' action='promo.php'>
  <p>Your Promo Code: 
    <input name='promocode' type='text' id='promocode'>
</p>
  <p>
    <input type='submit' name='Submit' value='Submit'>
</p>
</form>"

And REPLACE with
PHP Code:
//------------
//promo mod
//-----------
$article_content $lang_enter_code."<br><form name='form1' method='get' action='promo.php'>
  <p>Your Promo Code: 
    <input name='promocode' type='text' id='promocode'>
</p>
  
  <p>Your Promo Key: 
    <input name='promokey' type='text' id='promokey'>
</p>

  <p>
    <input type='submit' name='Submit' value='Submit'>
</p>
</form>"
;
//--------------
//end promo mod
//-------------- 
Next Find
PHP Code:
if($num 0){

// There is a match

$article_title $showingtitle;
$article_content $lang_promo_avail."<br>";

//Loop out code
$i=0;
while (
$i $num) {

$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");

$article_content $article_content."<p><b><u><a href='adopt.php?id=".$aid."&promocode=".$promocode."'>".$type.":</a></u></b></p>
<p><a href='adopt.php?id="
.$aid."&promocode=".$promocode."'><img src='".$eggimage."' border='0'></a></p>";

    if(
$isloggedin == "yes"){
    
$article_content $article_content."<p><b><a href='adopt.php?id=".$aid."&promocode=".$promocode."'><img src='templates/icons/add.gif' border=0> Adopt ".$type."</a></b></p>";
    }
    else{
    
$article_content $article_content."<p><img src='templates/icons/no.gif' border=0> <b>".$guesterror."</b></p>";
    }

$i++;
}


And REPLACE with
PHP Code:
//--------------
//promo mod
//--------------
if($num 0){

// There is a match

//now check if their is a key with the promo code

$query "SELECT * FROM ".$prefix."promo_keys WHERE promo_code='$promocode' AND promo_key='$pkey'";
$result2 runquery($query);
$num2 mysql_numrows($result2);

if(
$num2 0){
//we have both a promo code and a key that match so display the pets to the user to adopt

$article_title $showingtitle;
$article_content $lang_promo_avail."<br>";

//Loop out code
$i=0;
while (
$i $num) {

$aid=@mysql_result($result,$i,"id"); //The adoptable's ID
$type=@mysql_result($result,$i,"type");
$description=@mysql_result($result,$i,"description");
$eggimage=@mysql_result($result,$i,"eggimage");

$article_content $article_content."<p><b><u><a href='adopt.php?id=".$aid."&promocode=".$promocode."&promokey=".$pkey."'>".$type.":</a></u></b></p>
<p><a href='adopt.php?id="
.$aid."&promocode=".$promocode."&promokey=".$pkey."'><img src='".$eggimage."' border='0'></a></p>";

    if(
$isloggedin == "yes"){
    
$article_content $article_content."<p><b><a href='adopt.php?id=".$aid."&promocode=".$promocode."&promokey=".$pkey."'><img src='templates/icons/add.gif' border=0> Adopt ".$type."</a></b></p>";
    }
    else{
    
$article_content $article_content."<p><img src='templates/icons/no.gif' border=0> <b>".$guesterror."</b></p>";
    }

$i++;
}
}
else{

// their was no key with the promo code so display the error to the user

$article_title $lang_promo_fail_title;
$article_content $lang_promo_fail;

}
//--------------
//end promo mod
//-------------- 
Save and close that file now open adopt.php

Find
PHP Code:
$promocode $_GET["promocode"]; 
After Add
PHP Code:
//------------
//promo mod
//-----------
if (!empty($_POST['promokey']) || !empty($_GET['promokey']))
{
    
$pkey = (!empty($_POST['promokey'])) ? $_POST['promokey'] : $_GET['promokey'];
}
else
{
    
$pkey '';
}
//------------
//end promo mod
//----------- 
Next Find
PHP Code:
        $canadopt canadopt($aid"showing"$promocode$row); // Feed an adoptable ID and showing, to show the adopt to guests... 
Replace with
PHP Code:
//------------
//promo mod
//-----------
        
$canadopt canadopt($aid"showing"$promocode$row$pkey); // Feed an adoptable ID and showing, to show the adopt to guests...
//------------
//end promo mod
//----------- 
Next Find

PHP Code:
    $article_content .= "</table>
    <h3>Adopt</h3>
              <p>Adoptable Name: <input name='name' type='text' id='name' />
                <input name='promocode' type='hidden' id='promocode' value='"
.$promocode."'>
              </p>
              <p>
                <input type='submit' name='Submit' value='Adopt Me'>
            </p>
    </form>"

Repace with

PHP Code:
//------------
//promo mod
//-----------    
    
$article_content .= "</table>
    <h3>Adopt</h3>
              <p>Adoptable Name: <input name='name' type='text' id='name' />
                <input name='promocode' type='hidden' id='promocode' value='"
.$promocode."'>
                <input name='promokey' type='hidden' id='promokey' value='"
.$pkey."'>
                </p>
              <p>
                <input type='submit' name='Submit' value='Adopt Me'>
            </p>
    </form>"
;
//------------
//end promo mod
//----------- 
Next Find
PHP Code:
        $canadopt canadopt($aid"adopting"$promocode$row); 
And Replace with
PHP Code:
//------------
//promo mod
//-----------
        
$canadopt canadopt($aid"adopting"$promocode$row$pkey); 
//------------
//end promo mod
//----------- 
Next Find
PHP Code:
            $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>"

REPLACE with
PHP Code:
//------------
//promo mod
//-----------
            
$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."'>
                <input name='promokey' type='hidden' id='promokey' value='"
.$pkey."'>
              </p>
              <p>
                <input type='submit' name='Submit' value='Adopt Me'>
            </p>
            </form>"
;
//------------
//end promo mod
//----------- 
Save and close, Open doadopt.php

Find
PHP Code:
$name $_GET["name"]; 
After Add
PHP Code:
//------------
//promo mod
//-----------
if (!empty($_POST['promokey']) || !empty($_GET['promokey']))
{
    
$pkey = (!empty($_POST['promokey'])) ? $_POST['promokey'] : $_GET['promokey'];
}
else
{
    
$pkey '';
}
//------------
//end promo mod
//----------- 
Next Find
PHP Code:
                $canadopt canadopt($aid"adopting"$promocode$row); 
Replace with
PHP Code:
//-----------
//promo mod
//-----------
                
$canadopt canadopt($aid"adopting"$promocode$row,$pkey);
//-----------
//end promo mod
//----------- 
Next find
PHP Code:
runquery("INSERT INTO ".$prefix."owned_adoptables VALUES ('', '$type', '$name','$loggedinname','0','0', '$code', '','$alts','fortrade','no', '$genders[$rand]','0')"); 
After Add
PHP Code:
//------------
//promo mod
//-----------
                        //now we need to remove the key from the db so that they cant adopt another pet
                        
$query "DELETE FROM ".$prefix."promo_keys WHERE promo_code='$promocode' AND promo_key='$pkey'";
                        echo 
$query;
                        
runquery($query);
//------------
//end promo mod
//----------- 
Save and you are done modding.

With this mod even if the user has the promo code they cant adopt or view the pet. If more than one pet has the same promo code to it then it will display all of them for the user to adopt. To add keys you need to use PhpMyAdmin.
Any questions or comments please post them here.

Last edited by Chibi_Chicken; 08-07-2011 at 05:47 PM. Reason: changes the code tags to php
Reply With Quote
  #2  
Old 10-24-2011, 08:00 PM
Lopels Lopels is offline
Member
 
Join Date: Oct 2011
Posts: 11
Gender: Female
Credits: 954
Lopels is on a distinguished road
Default

mm.. I like this.... I just don't have a host and i don't know how to install the mys script onto the host
Reply With Quote
  #3  
Old 04-18-2012, 04:20 PM
Alaric Alaric is offline
Mod
 
Join Date: Nov 2011
Posts: 112
Gender: Male
Credits: 312,489
Alaric is on a distinguished road
Default

Will this work on version 1.3.1 ?
Reply With Quote
  #4  
Old 04-18-2012, 04:23 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 334,072
Hall of Famer is on a distinguished road
Default

I believe not, the entire promocode system is overhauled in Mys v1.3.1.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


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
Promo Code Questions! parayna Questions and Supports 4 10-07-2014 03:12 PM
Show Gender while Naming Pet & Name Promo Code Pets Kyttias Questions and Supports 5 07-11-2014 02:12 PM
Only show egg image with promo code RoconzaArt Questions and Supports 5 03-25-2011 12:51 PM
Invite Code/Alpha Code Shex Questions and Supports 0 03-07-2011 04:08 AM
1 Promo per person Xius Questions and Supports 4 09-21-2009 05:55 PM


All times are GMT -5. The time now is 11:54 AM.

Currently Active Users: 9849 (0 members and 9849 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