View Single Post
  #1  
Old 01-23-2011, 04:14 AM
fadillzzz fadillzzz is offline
Dev Staff
 
Join Date: Jan 2010
Posts: 501
Gender: Male
Credits: 32,846
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 12:10 PM.
Reply With Quote