_Unique_ Posted June 30, 2015 Share Posted June 30, 2015 Hello, I am creating a CMS, I am currently wanting to create a function which checks if the website is installed. I have attempted this before, by checking if a database connection existed, if it did, then the website was installed, if there wasn't, then the user will be automatically redirected to the installer. However, after creating all of that, I realized that this wouldn't work, simply because if the database server is offline or the database was renamed, or whatever reason, the website would think that it isn't installed, therefore could break the website. Plus, this restricted me adding more functions to the website, such as database repair, etc. However, I have reached a brick wall. I cannot figure out a way I can go about doing this. I searched via Wordpress as they have created an installation that checks if the blog is installed, but that did not help as it just reached off to different functions, etc, and I didn't know how they made every page check if the website was installed, without having to include/require the file on every page, which would require the user more work when creating more pages because then they have to start copying and pasting lines from other pages, etc, just for the page to be fully functional, which really, really is inefficient, and a really bad idea, especially when this could go public, depending on the progress, etc. Thanks in advance, Unique P.S - I hope this is clear enough, if it is too vague, make sure too tell me. Quote Link to comment https://forums.phpfreaks.com/topic/297127-checking-if-website-is-installed/ Share on other sites More sharing options...
scootstah Posted June 30, 2015 Share Posted June 30, 2015 Usually the installer would create a config file. You can simply check that some values exist in this config file to determine if it is installed. Quote Link to comment https://forums.phpfreaks.com/topic/297127-checking-if-website-is-installed/#findComment-1515328 Share on other sites More sharing options...
JenniferLawrence Posted June 30, 2015 Share Posted June 30, 2015 What I did was check to see if the installation folder existed first. If it did, it would proceed to the installation process. If the database configuration does not exist in the configuration file, I would redirect the client back to the installation folder. If they happen to remove the installation folder, it would tell them that they are missing the installation folder and that the configuration database does not exist. Quote Link to comment https://forums.phpfreaks.com/topic/297127-checking-if-website-is-installed/#findComment-1515329 Share on other sites More sharing options...
_Unique_ Posted July 1, 2015 Author Share Posted July 1, 2015 Okay, thanks for the replies. I decided to create an install.tmp file, my script when then check if the file exists, if it does not exist, then continue to load the web page. If it does exist, then redirect to the installer. Once the user has installed the website, the install.tmp file will automatically be deleted. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/297127-checking-if-website-is-installed/#findComment-1515360 Share on other sites More sharing options...
ginerjm Posted July 1, 2015 Share Posted July 1, 2015 "I decided to create an install.tmp file..." - Sounds backwards Quote Link to comment https://forums.phpfreaks.com/topic/297127-checking-if-website-is-installed/#findComment-1515372 Share on other sites More sharing options...
scootstah Posted July 1, 2015 Share Posted July 1, 2015 What is your installer actually doing? Is it a typical installer where the user would enter in the database credentials and such? If so, the easiest way IMO is to just have a config value in that file saying that the site is installed. However, after creating all of that, I realized that this wouldn't work, simply because if the database server is offline or the database was renamed, or whatever reason, the website would think that it isn't installed, therefore could break the website. The database should return error codes if a connection could not be made. You can use these error codes to determine what is wrong. You will be able to differentiate the server being offline vs the database not existing. Quote Link to comment https://forums.phpfreaks.com/topic/297127-checking-if-website-is-installed/#findComment-1515375 Share on other sites More sharing options...
CroNiX Posted July 1, 2015 Share Posted July 1, 2015 On an installer we created, after everything is set up as part of the install process it creates a /version.php file, that just contains the current version, ie "2.00.03" as well as sends an email stating that the install succeeded, or failed and if failed it provides the reasons/tracebacks. We ping that file for all of our client domains on a daily basis to see if it's present and what version is returned so we can offer clients an upgrade path if they wish to upgrade or autoupgrade it for them depending on the services they purchased (major releases/minor releases, etc) Quote Link to comment https://forums.phpfreaks.com/topic/297127-checking-if-website-is-installed/#findComment-1515384 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.