I place this code on external SITE to try to call my PHP file.
Code: Select all
<script type="text/javascript" src="http://somedomain.com/pet.php?petID=5"></script><
Code: Select all
?php
class pet
{
//construct
function __construct()
{
$this->petDisplay();
}
//show pet
function petView($petData)
{
//vars to replace in looper file
$replacers = array("{NAME}", "{IMG}", "{LVL}", "{LID}");
//open template file
$first_sec = file_get_contents("template/pet.htm");
$template = str_replace($replacers, $petData, $first_sec);
Header("content-type: application/x-javascript");
echo $template;
}
//get all user pets
function petDisplay()
{
require_once('mysql.class.php');
//vars
$mysql = new mysql();
$petID = $_GET['petID'];
$petUserID = $_GET['petUserID'];
//get pet
$mysql->query("SELECT pets.petID, pets.petName, pets.petFileType, userpets.upPetID, userpets.upHits FROM userpets, pets WHERE userpets.upID='$petID' AND pets.petID=userpets.upPetID");
$data = mysql_fetch_assoc($mysql->result);
$hits = $data['upHits'] + 1;
$petsID = $data['upPetID'];
//get potential new pet
$mysql->query("SELECT petID, petReq, petName, petFileType FROM pets WHERE petParentID='$petsID'");
$dataNew = mysql_fetch_assoc($mysql->result);
//LEVEL UP!!
if($hits >= $dataNew['petReq'] && $dataNew['petReq'] != 0)
{
$newPetID = $dataNew['petID'];
//update user pet sql data
$mysql->unreturnquery("UPDATE userpets SET upPetID='$newPetID', upHits='1' WHERE upID='$petID'");
//send email about LEVEL UP!!
$msg = "Your pet has advanced to " . $dataNew['petName'] . ". View your new pet at somedomain.com/mypets.php";
$header = "From: SECRET SITE <admin@somedomain.com>\n\r";
mail($email, "Congradulations on Pet Advance", $msg, $header);
//set data
$pet = array($dataNew['petName'], "pets/" . $dataNew['petName'] . '.' . $dataNew['petFileType'], 1);
}
else
{
$mysql->unreturnquery("UPDATE userpets SET upHits='$hits' WHERE upID='$petID'");
//set data
$pet = array($data['petName'], "pets/" . $data['petName'] . '.' . $data['petFileType'], $hits);
}
$this->petView($pet);
}
}
?>Any ideas. If I call pet.php by itself. It will output my template which is just an image. ;]