reutorah Posted January 23, 2016 Share Posted January 23, 2016 I want to make a page expire after 7 days from page loaded on the server without giving date and time, i mean auto expire php page after 7 days from page load, how can i do that, with what code. After 7 days page redirects to a url. I already tried and know some code in php which can expire php page on given day and time but i need a code which will expire php page after 7 days of time it is loaded on server. Can you please post with the code. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted January 23, 2016 Share Posted January 23, 2016 (edited) Whatever do you mean by "expire a page"? What does that mean to you? A "php page" is merely a script. It sits on the server and does something for you when called. That said, I find your question difficult to comprehend. Do you mean you want the script to no longer run when someone types in its url, as if the script had been deleted from the server? Edited January 23, 2016 by ginerjm Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted January 23, 2016 Share Posted January 23, 2016 Not sure why are making a php script expire, usually what is done is the url has parameters and is a dynamic script with different values. Something like using a database and checking a datetime for the value for insertion date would determine how old it was created. If you still want to make many php files and block access you would need to either include a script with code to all created pages or use dynamic page values that the script then includes. Use filetime, compare to see if modified date is older than last 7 days. If you stored all these files in a single folder, you can create a php script and create a cron job to run every day. The script would glob a folder and delete any files older than 7 days. Have your 404 error handling set up to either home page or a custom error page. This method would help keep your server cleaner and not have piles of files no longer needed. <?php $files = glob("/path/to/directory/*.php");//change to path you need $now = time(); foreach ($files as $file) { if (is_file($file)) { if ($now - filemtime($file) >= 60 * 60 * 24 * 7) { unlink($file); } } } ?> Quote Link to comment Share on other sites More sharing options...
reutorah Posted January 25, 2016 Author Share Posted January 25, 2016 i have a php script that i want to provide my visitors for free trial and i want to simply add php code encrypted in php page where my visitors will upload my script on there server and since the first time the page has been run i want it to expire exactly after 7 days. I mean i want the page to redirect to my website purchase page. What is the exact process ? is there a way i can test the code working with 5 seconds of expire ? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted January 25, 2016 Share Posted January 25, 2016 I can think of many people NOT wanting to upload any script of yours (or anyone's) to THEIR server. Thatis if they even HAVE a server of their own. I know I wouldn't and it's a good guess that those in the know on this very forum would not do it either. I'm thinking that you have some kind of registration process that would then lead to this "uploading" scheme of yours. Why not use that registration as an access method to the script on your server? When the registration occurs you save the date of it. When that date reaches an age that you wish to expire the user at, mark the user's reg record as expired and do your re-direct thing. You may argue that the registration can be cheated by a user who creates a fictitious second or third userid. Sure that can occur, but so can the process you envision where the user would be uploading the script to their server. 2 Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted January 25, 2016 Share Posted January 25, 2016 You want to destroy code on somebody else's server? This is, thankfully, impossible. Once it's on their server, it's under their control, and there's nothing you could do about that. If you don't want people to actually use your code, don't give it to them. Put it onto your own server and make it available after some registration procedure. Then you can easily block access after a certain trial period. 1 Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted January 25, 2016 Share Posted January 25, 2016 You want to let them upload your script their server and expires? One thing have to understand is that anything you write the person can edit their php file. You can try obfuscation to make it harder, all it will take is one determined person to reverse it and share with the world for free. http://www.zend.com/en/products/zend-guard http://www.phpprotect.info/ You want something that has to check a domain or key, alternately a required snippet of code from your own server for their script to work. Let me say a few possible ways can do it. Creating an api system, you allow domain or private key usage for the script. Tracking domains your server, they download a copy of the same script(only one version needed), the script connects to your server to determine if allowed. Write into the code a key, when the script is accessed it looks for that key. The way it would find the key is connecting to your server and check for it a list however you wanted to save such keys. Quote Link to comment Share on other sites More sharing options...
reutorah Posted January 28, 2016 Author Share Posted January 28, 2016 my script is phpsunchat www.phpsunchat.com its a instant messaging chat script i want to offer my chat script for free 7 day trial or possible 15 days trial. So what i want to do is i want my visitor to download my script from my website for free and when he uploads the php pages from the ftp software and when anyone from browser opens any page of the script it records the date and time the page loaded the first time and expires the page exactly after 7 days and redirects the pages to my website www.phpsunchat.com The time needs to be set on first load page bases and i just want to add few lines or php code in my pages and if they edit my code they cheat and i can any time complain there host so i am not worried on my chat script to be edited. I am concerned for those websites who have large chat traffic and optimize for public. Any code suggestions ? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted January 28, 2016 Share Posted January 28, 2016 You have already been told many reasons why you can't or shouldn't do this thing. #1 - if you give them your code you're done. They should send you a thank-note before they take your hard work and change it to suit them. (This would be very generous of you!). Do what others here have said. Sign people up for a free trial and record their individual start date and user id. Be sure to store your main code outside of your webtree so they can't steal it and let them play until their time runs out. Put the entry page in the web tree and get their login creds there. Anything else is just not gonna be good for you. Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted January 28, 2016 Share Posted January 28, 2016 (edited) Besides that, why on earth would anybody upload trial software to a public webserver? What are they supposed to do with it? Tell all their users about it and then take it offline 7 days later? I'm sorry, but your business model makes no sense. Also, why should I pay $50 per month when I can get an entire entry-level dedicated server plus a free(!) chat script for the same price? What makes your code so incredibly special compared to the thousands of open-source chat scripts on GitHub? Edited January 28, 2016 by Jacques1 Quote Link to comment Share on other sites More sharing options...
reutorah Posted January 29, 2016 Author Share Posted January 29, 2016 it will suit my requirements. If anyone can provide code please provide php code which does it. Thanks! Quote Link to comment Share on other sites More sharing options...
ginerjm Posted January 29, 2016 Share Posted January 29, 2016 Sorry. Won't give you code since that is not the focus of this forum. More importantly (as I have been told previously) it is not a good idea to promote "bad code" here, which your goal is to obtain. Quote Link to comment Share on other sites More sharing options...
reutorah Posted February 4, 2016 Author Share Posted February 4, 2016 ok i will hire a developer by paying few funds, its waste to ask for help here. Thanks! Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 4, 2016 Share Posted February 4, 2016 It's not a waste. You got very good advice. You have just chose to ignore it in your anger at being told what was wrong with your design. Don't feel bad - we all make mistakes when starting out. Of course your choice is going to cost you money. I'm pretty sure that your choice of developer is going to also agree with what you have been told here. If you pay him/her enough money he just may do what you want. But then when you eventually see the problems with your design, you'll have to pay him/her to correct it. Quote Link to comment Share on other sites More sharing options...
Lukeidiot Posted February 5, 2016 Share Posted February 5, 2016 $1000 for lifetime script access to a chatroom? Are you insane? lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.