MarkT Posted December 31, 2013 Share Posted December 31, 2013 Hello, I have the following code: Checklicense.php (Remote Server): <?PHP$con = mysqli_connect("*******");$domain = $_SERVER['HTTP_HOST'];$query = mysqli_query($con,"SELECT status FROM licenses WHERE domain = '{$domain}'");$query2 = mysqli_fetch_array($query); if($query2 == "Expired") { echo "<div id='warning'>THIS SOFTWARE IS NULLED <br> PLEASE BUY A LICENSE HERE</div>";} else {} ?> Index.html: <?PHPecho file_get_contents("./licensing/checklicense.php"); ?> However when it's all in the same file it works, basically my aim is to achieve a licensing system where the script contacts the remote server, which then checks the licenses table to see whether the status is active or expired. If it's expired it shows the warning, if not it allows the script to appear normally. My licenses table has a domain column, which I want the query to check for in the database and then return Active or Expired, for the index page to show the warning dialog of it being nulled. My code will be encrypted. I would be grateful if anyone can help me achieve my aims. Also, Happy new year everyone. Link to comment Share on other sites More sharing options...
abdelelbouhy Posted January 4, 2014 Share Posted January 4, 2014 (edited) Hi, in your code thereis an issue when you fetch the result $query2 = mysqli_fetch_array($query,MYSQLI_ASSOC); note the second arg MYSQLI_ASSOC the next step is to get the status field from the result like that $result = $query2['status']; then test it if($result == "Expired"); and here is a link explain it http://uk3.php.net/mysqli_fetch_array Edited January 4, 2014 by abdelelbouhy Link to comment Share on other sites More sharing options...
MarkT Posted January 5, 2014 Author Share Posted January 5, 2014 Hi, in your code thereis an issue when you fetch the result $query2 = mysqli_fetch_array($query,MYSQLI_ASSOC); note the second arg MYSQLI_ASSOC the next step is to get the status field from the result like that $result = $query2['status']; then test it if($result == "Expired"); and here is a link explain it http://uk3.php.net/mysqli_fetch_array Sorry, I don't get it, please can you show me by editing my code? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 6, 2014 Share Posted January 6, 2014 If your code is going to be running on a variety of servers then you need to account for that. If the server has cURL installed, check for that and use it. If not, check if it has the fopen HTTP wrappers enabled, and if so then you can use file_get_contents to open the remote HTTP file. You might be able to package cURL with your code in case it is not installed, but the server will still need to allow you to make remote connections with sockets or other things. There are PHP configurations in restrictive shared hosting environments that would have all of those options disabled. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now