Hey All,
I am in the process of trying to make an updater/license validator for a web script I've made and was trying to use file_get_contents and it was working perfectly fine until I went to try and access the mysql db on my site that stores the licenses and stuff (we'll call it the update site).... it seems that the code to select the licenses from the database isn't parsed before it is retrieved and it then gives me errors because it can't find the license tables locally (thats because they are on the update site - remote).
So my question is how would you suggest I go about a license checker/updater so that it will perform the mysql queries on the remote database (update site's database) before retrieving the rest of the file :S Here's what I've got so far...
check.php (stored locally - this is what contacts my sites server to check)
PHP Code:
if($_SESSION['rp4_rank'] == "Administrator"){
echo "<b>» $update_stats</b>
<table><tr>";
$get = mysql_query("SELECT * FROM rp4_settings");
$i = mysql_fetch_array($get);
$a = "rdjp";
$v = $i['panelversion'];
$l = $i['license'];
if($content = @file_get_contents("http://update.quickscriptz.ca/?a=$a&v=$v&l=$l&k=$k")){
echo $content;
}else{
echo "<td><img src='images/update_error.gif' /></td>
<td>$update_error</td>";
}
echo '</tr></table></div>';
}
index.php (stored on my/update site)
PHP Code:
<?php
include('connect.php');
function updatecheck(){
if($_GET['a'] == "rdjp"&&$_GET['l'] != ""&&$_GET['v'] != ""){
###########################
# General
###########################
$lv = "4.0.0";
$l = $_GET['l'];
$v = $_GET['v'];
$getinfo = mysql_query("SELECT * FROM rp4_licenses");
$row = mysql_fetch_array($getinfo);
$count = mysql_query("SELECT COUNT(id) FROM rp4_licenses WHERE license='$l'");
$total = mysql_fetch_array($count);
if($total(COUNT(id)) == "1"){
###########################
# Version Check
###########################
if($v == "$lv"){
echo "<td><img src='images/update_no.gif' /></td><td>$update_uptodate</td></tr>";
}
if($v != "$lv"){
echo "<td><img src='images/update_yes.gif' /></td><td>$update_yes</td>";
echo "<tr><td><img src='images/update_license.gif' /></td><td>License Valid</td>";
echo "<tr><td><img src='images/update_download.gif' /></td><td>Download</td>";
}
}
}
}
?>
Any help is greatly appreciated and will be repped! Thanks!