Mysidia Adoptables Support Forum  

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

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2011, 05:14 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 37,700
fadillzzz is an unknown quantity at this point
Default Secure Random Adoption Process

This mod is intended for people who already or wanted to have a random adoption process on their adoptables site.
This mod will use Session Value instead of the GET method to transfer the id of an adoptables from adopt.php to doadopt.php
That way people won't be able to manipulate the id of an adoptables to another id to get the adoptables they want.
You can use POST method but they can change it using the text editor. So with this mod, they have no idea how to do that.

NOTE:Please make a backup of your files before installing this mod!

Now, let's move on!
1. Open your adopt.php file, on line 2 just below the
PHP Code:
<?php
tag put this code
PHP Code:
session_start(); // This is important! 
2.(Skip this step if your site already limit the adopt.php to only show 1 random adoptables)
Go to line 86, replace this code

PHP Code:
$query "SELECT * FROM ".$prefix."adoptables"
with this
PHP Code:
$query "SELECT * FROM ".$prefix."adoptables WHERE whenisavail = 'always' ORDER BY RAND() LIMIT 1"// Only shows 1 random adoptables 
3. Put this code on line 98
PHP Code:
$_SESSION['id'] = $aid// This is what we use to transfer the aid value 
4. Then on line 119 find this code
PHP Code:
    $article_content $article_content."<p><b><a href='adopt.php?id=".$aid."'><img src='templates/icons/add.gif' border=0> Adopt ".$type."</a></b></p>"
And replace it with this
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='promocode' type='hidden' id='promocode' value='"
.$promocode."'>
  </p>
  <p>
    <input type='submit' name='Submit' value='Adopt Me'>
</p>
</form>"

5. After that, remove these 2 lines from the file (line 115 & 116)
PHP Code:
$article_content $article_content."<p><b><u><a href='adopt.php?id=".$aid."'>".$type.":</a></u></b></p>
<p><a href='adopt.php?id="
.$aid."'><img src='".$eggimage."' border='0'></a></p>"
We're done with adopt.php, let's continue with editing doadopt.php
1. Open your doadopt.php, on line 2 just below the
PHP Code:
<?php
tag put this code
PHP Code:
session_start(); // This is important! 
2. Find this code on line 65 -75
PHP Code:
$id $_GET["id"]; 
And replace it with
PHP Code:
if($_GET["id"] == ""){
$id $_SESSION['id'];
}elseif(
$_GET["id"] != ""){
$id $_GET["id"];

3. Find this code
PHP Code:
if($isloggedin == "yes"){ 
And before that line add this
PHP Code:
if($promocode != ""){ 

4.
And then before this
PHP Code:
// **********************************************************************
// Begin Template Definition
// ********************************************************************** 
Add this code
PHP Code:
}else{
$article_title $accden;
$acticle_content "Enter error message here";


NOTE:Don't forget to edit the "Enter error message here" text



That's it you're done! Now people will completely get unchangeable random adoptables!

If there's any error you encounter after installing this mod, please let me know! (This is my first mod)

Last edited by fadillzzz; 01-28-2011 at 01:10 PM.
Reply With Quote
  #2  
Old 01-23-2011, 05:22 AM
PokePets PokePets is offline
Premium Member
 
Join Date: Jun 2010
Posts: 228
Gender: Male
Credits: 22,445
PokePets
Default

Thank you =D
Reply With Quote
  #3  
Old 01-24-2011, 06:43 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 37,700
fadillzzz is an unknown quantity at this point
Default

First post updated!
Added a fix for the broken promo code page
Reply With Quote
  #4  
Old 01-24-2011, 09:07 AM
Kaeliah's Avatar
Kaeliah Kaeliah is offline
Premium Member
 
Join Date: Sep 2010
Location: Pennsylvania, United States
Posts: 485
Gender: Female
Credits: 38,414
Kaeliah will become famous soon enough
Send a message via AIM to Kaeliah Send a message via MSN to Kaeliah
Default

It would seem there's a conflict between your mod and the Gender Ratio mod that Famer has.
__________________
[My Shop] ♥ [My Blog] ♥ [Subscribe] ♥ [My Mods] ♥ [Mod TOS]
Reply With Quote
  #5  
Old 01-24-2011, 10:53 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 37,700
fadillzzz is an unknown quantity at this point
Default

I'll take a look into it, thanks for letting me know Kaeliah!
Reply With Quote
  #6  
Old 01-24-2011, 01:04 PM
RoconzaArt's Avatar
RoconzaArt RoconzaArt is offline
Member
 
Join Date: Jan 2011
Location: NJ Shore (and proud of it)
Posts: 479
Gender: Female
Credits: 57,291
RoconzaArt is an unknown quantity at this point
Default

Yes I checked this mod with HOF's Gender Ratio mod are giving a invaid ID error.
__________________
Reply With Quote
  #7  
Old 01-25-2011, 03:19 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 37,700
fadillzzz is an unknown quantity at this point
Default

First post updated!
I've updated the tutorial so it won't break the promo code feature, and it will work with any mod that will require the edit of adopt.php and doadopt.php such as HoF's gender ratio system.
EDIT: Updated again! I added a security fix to prevent the user from using the GET method to enter any ID of an adoptables (with the condition of whenisavail set to always) and fill in the promocode with random string to bypass the security..Hopefully this will be the last problem I found with this mod

Last edited by fadillzzz; 01-25-2011 at 01:14 PM.
Reply With Quote
  #8  
Old 01-28-2011, 12:28 PM
RoconzaArt's Avatar
RoconzaArt RoconzaArt is offline
Member
 
Join Date: Jan 2011
Location: NJ Shore (and proud of it)
Posts: 479
Gender: Female
Credits: 57,291
RoconzaArt is an unknown quantity at this point
Default

I have a few mods on already I don't know what to do could some one help me?
__________________
Reply With Quote
  #9  
Old 01-28-2011, 12:30 PM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 37,700
fadillzzz is an unknown quantity at this point
Default

Sure, I'll help.
Reply With Quote
  #10  
Old 01-28-2011, 12:36 PM
RoconzaArt's Avatar
RoconzaArt RoconzaArt is offline
Member
 
Join Date: Jan 2011
Location: NJ Shore (and proud of it)
Posts: 479
Gender: Female
Credits: 57,291
RoconzaArt is an unknown quantity at this point
Default

Thanks, I tried to add it but I already have HOF other two mods in place so going by line number is not work. I got a lot of errors the adopt page.

This what my adopt page looks like now without your mod. Were do I put the things I need?

PHP Code:
<?php

// **********************************************************************
// Mysidia Adoptables Script: adopt.php
// Copyright 2011 Mysidia Adoptables staff team
// For help and support: http://www.mysidiaadoptables.com/forum/
//
// Redistribution prohibited without written permission
// **********************************************************************


// Wake the sleeping giant

// **********************************************************************
// Basic Configuration Info
// **********************************************************************

include("inc/functions.php");
include(
"inc/config.php");
include(
"lang/lang.php");

$themeurl grabanysetting("themeurl");

// **********************************************************************
// Define our top links by calling getlinks()
// **********************************************************************

$links getlinks();

// **********************************************************************
// Define our ads by calling getads()
// **********************************************************************

$ads getads("any");

// **********************************************************************
// Grab any settings that we will need for the current page from the DB
// **********************************************************************

$browsertitle grabanysetting("browsertitle");
$sitename grabanysetting("sitename");
$slogan grabanysetting("slogan");

// **********************************************************************
// Check and see if the user is logged in to the site
// **********************************************************************

$loginstatus logincheck();
$isloggedin $loginstatus[loginstatus];
$loggedinname $loginstatus[username];

// **********************************************************************
// End Prepwork - Output the page to the user
// This page sets up the new adoptions and then forwards the user to
// a secondary page for adoptables processing.....
// **********************************************************************

$id $_GET["id"];
$id preg_replace("/[^a-zA-Z0-9s]/"""$id);
$id secure($id);

$promocode $_GET["promocode"];
$promocode preg_replace("/[^a-zA-Z0-9\\040.]/"""$promocode);
$promocode secure($promocode);

// Here we check if we have an ID that has been submitted or no

if($id == "" or !is_numeric($id)){

// We did not enter in an id, or it is not a number
// Show the available adoptables to the user...

$article_title $showingtitle;
$article_content $showing;

// 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...

$query "SELECT * FROM ".$prefix."adoptables";
$result mysql_query($query);
$num mysql_numrows($result);

//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");

// Call a function to check if we have the proper privledge level to adopt this pet
// This function checks all of the little conditions and makes sure they are present
// If they are not present, the adoptable is not shown here, as that would be cruel.
// We call the function with the showing flag to not deny the showing if the user is a guest.


if($promocode == ""){
$promocode "none";
}

$canadopt canadopt($aid"showing"$promocode); // 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 $article_content."<p><b><u><a href='adopt.php?id=".$aid."'>".$type.":</a></u></b></p>
<p><a href='adopt.php?id="
.$aid."'><img src='".$eggimage."' border='0'></a></p>";

    if(
$isloggedin == "yes"){
    
$article_content $article_content."<p><b><a href='adopt.php?id=".$aid."'><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++;
// End the looping out of all adoptables...

// 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
// Let the user name the adoptable, then forward them
// to an additional page that actually adds the adoptie
// to their account.

// Now we have to connect to the database and get information about the adoptable

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

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

$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");

$i++;
}

if(
$aid == $id){

//The adoptable exists and is valid

// Make sure again that we can adopt this adoptie...

$canadopt canadopt($aid"adopting"$promocode); 

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


// **********************************************************************
// Begin Template Definition
// **********************************************************************

//Define our current theme
$file $themeurl;

// Do the template changes and echo the ready template
$template file_get_contents($file);

$template replace(':ARTICLETITLE:',$article_title,$template);
$template replace(':ARTICLECONTENT:',$article_content,$template);
$template replace(':ARTICLEDATE:',$article_date,$template);

$template replace(':BROWSERTITLE:',$browsertitle,$template);
$template replace(':SITENAME:',$sitename,$template);

//Define our links
$template replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar getsidebar();
$template replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template replace(':ADS:',$ads,$template);

//Get the slogan info
$template replace(':SLOGAN:',$slogan,$template);


echo 
$template;

// **********************************************************************
// End Template Definition
// **********************************************************************



?>
__________________
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
Adoption Problems Kamalya Questions and Supports 8 01-27-2013 02:15 PM
Secure Random Adoption V2 fadillzzz Mys v1.2.x Mods 7 02-28-2012 02:57 PM
Random Adoption nitrogen Questions and Supports 4 05-10-2009 10:10 AM
Random 5 is not realy random! RipJawWolfFang Questions and Supports 9 04-30-2009 07:03 AM


All times are GMT -5. The time now is 07:12 AM.

Currently Active Users: 773 (0 members and 773 guests)
Threads: 4,081, Posts: 32,029, 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