Jump to content

Checking if website is installed


_Unique_

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.