Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-03-2007, 06:02 PM   PM User | #1
Troy297
Regular Coder

 
Troy297's Avatar
 
Join Date: Oct 2006
Location: Earth
Posts: 314
Thanks: 10
Thanked 0 Times in 0 Posts
Troy297 is an unknown quantity at this point
File_Get_Contents Question

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!
__________________
Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
Radio DJ Panel v3 - It's Here!
Troy297 is offline   Reply With Quote
Old 08-03-2007, 06:06 PM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Are you using your own hosted mysql server or are you just using localhost? Also what errors are you getting? It would help if you posted those.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 08-03-2007, 06:09 PM   PM User | #3
Troy297
Regular Coder

 
Troy297's Avatar
 
Join Date: Oct 2006
Location: Earth
Posts: 314
Thanks: 10
Thanked 0 Times in 0 Posts
Troy297 is an unknown quantity at this point
Well... the errors are irrelevant... You see the problem is that I need to basically have the file on my update server run itself before it is retrieved by the check file....

And the files on the update server are all being run through localhost mysql (and my host wont allow remote mysql connections).
__________________
Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
Radio DJ Panel v3 - It's Here!
Troy297 is offline   Reply With Quote
Old 08-03-2007, 07:53 PM   PM User | #4
matak
Banned

 
Join Date: Apr 2007
Posts: 428
Thanks: 29
Thanked 5 Times in 5 Posts
matak is on a distinguished road
Do you need to run a certain function from the file or file has some other scripts than PHP?

If that's the case maybe you could run a function before displaying content

PHP Code:
if($content = @file_get_contents("http://update.quickscriptz.ca/?a=$a&v=$v&l=$l&k=$k")){
        include 
"http://update.quickscriptz.ca/?a=$a&v=$v&l=$l&k=$";
        
run_function_from included file();
        echo 
$content
matak is offline   Reply With Quote
Old 08-03-2007, 08:21 PM   PM User | #5
Troy297
Regular Coder

 
Troy297's Avatar
 
Join Date: Oct 2006
Location: Earth
Posts: 314
Thanks: 10
Thanked 0 Times in 0 Posts
Troy297 is an unknown quantity at this point
Well... you see the problem again is that I need some sql queries run on the update server before it is retrieved by the check file... so like this would be ideal:

Have a piece of code that parses the file on the update.quickscriptz.ca server and then it only echos the result that the file gives...

Any ideas? Thanks for suggestions... +Rep
__________________
Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
Radio DJ Panel v3 - It's Here!
Troy297 is offline   Reply With Quote
Old 08-03-2007, 08:41 PM   PM User | #6
matak
Banned

 
Join Date: Apr 2007
Posts: 428
Thanks: 29
Thanked 5 Times in 5 Posts
matak is on a distinguished road
Store Latest information from update(localhost) server in file---(sha1(latest$id))
Store Latest information from toupdate(web) server in file---(sha1(latest$id))

Compare those two values with file_Get_contents
---if !==
connect to your localhost database, and retrive information
show content
---else
show content
matak is offline   Reply With Quote
Old 08-04-2007, 03:09 AM   PM User | #7
Troy297
Regular Coder

 
Troy297's Avatar
 
Join Date: Oct 2006
Location: Earth
Posts: 314
Thanks: 10
Thanked 0 Times in 0 Posts
Troy297 is an unknown quantity at this point
Alright... I've figured out how I'm going to do it... but a couple of problems have arisen....

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")){
        echo 
$response;
    }else{
        echo 
"<td><img src='images/update_error.gif' /></td>
<td>$update_error</td>"
;
    }
echo 
'</tr></table></div>';

Now my only problem is how to pass the variable "$response" from update.quickscriptz.ca to the local server using the file_get_contents.... so in other words how can i use the var $reponse by simply using file_get_contents on my update server?

Thanks!

Edit: If its any help I was trying to work out something with the explode() function where the beginning is "//Start Response//" and the end is "//End Response//" but I am unfamiliar with the function (yes i checked php.net)
__________________
Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
Radio DJ Panel v3 - It's Here!

Last edited by Troy297; 08-04-2007 at 03:14 AM..
Troy297 is offline   Reply With Quote
Old 08-04-2007, 07:51 PM   PM User | #8
Troy297
Regular Coder

 
Troy297's Avatar
 
Join Date: Oct 2006
Location: Earth
Posts: 314
Thanks: 10
Thanked 0 Times in 0 Posts
Troy297 is an unknown quantity at this point
[bump] I've tried using the explode() function but it doesn't work due to the fact that the code must be parsed in order for it to get a response to echo out... so ya...

Any help is great!
__________________
Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
Radio DJ Panel v3 - It's Here!
Troy297 is offline   Reply With Quote
Old 08-07-2007, 12:29 AM   PM User | #9
Troy297
Regular Coder

 
Troy297's Avatar
 
Join Date: Oct 2006
Location: Earth
Posts: 314
Thanks: 10
Thanked 0 Times in 0 Posts
Troy297 is an unknown quantity at this point
[bump] Anyone have any ideas?
__________________
Everyone hears what you say, friends listen to what you say, best friends listen to what you don't say.
Radio DJ Panel v3 - It's Here!
Troy297 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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


All times are GMT +1. The time now is 03:00 AM.


Advertisement
Log in to turn off these ads.