HOWTO:Set up a demo site
e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page
If you have a plugin or theme that you want your users to test out. It's nice to have a demo site running. However if people keep changing settings, the site will turn into a mess in no-time.
In this article I will be explaining how to setup a demo site, that will reset to its original state after a certain timelimit. For this to work your webhost needs to allow you to run cronjobs and have SSH access. Since I think this article is for the advanced users, I will not go into to many specifics on how use ssh. There are allot of ssh tutorials to find on google.
This article only describes how restore the database after a certain amount of time. All files on you web server will not be modified nor touched.
The first thing to do of course is to install e107 on your demo page. I found it logical to call the folder "demo". for example:
After you have installed e107 you need to create a new user. This account will be used by your visitors. So give it a simple name and password. Something like:
username: demo password: demo or 1234
Make this user an admin and give him the limited permissions for only viewing you plugin or specified page.
Registration and login
Now go to site preferences and disable the registration system and enable image-code verification for login.
download the Page Restriction plugin by lisa and install it.
restrict usersettings.php for everyone.
When your site is finished, with finished I mean ready to be a demo site and no adjustments need be made, create a backup of you database. You can do this via phpmyadmin or via ssh.
You can find a tutorial here how to export via phpmyadmin. Export it as a sql file. Don't zip it. Place the sql file in the root directory of you webserver.
ssh mysql dump
This code is used to create a backup of you database and dumb it on you webserver.
It might not be necessary to use the -h parameter (host).
Create a new file called restore_data.sh and make sure it is not in public_html folder. give it full permissions (chmod) 777. Paste the following code in this file.
The shell script first deletes all your tables in your database and afterwards in restores the backup sql file.
to test it out you can run it by typing
if you are working on a windows machine and you try to run the script you might get the following error:
/bin/sh^M: bad interpreter: No such file or directory
This problem is caused by the of dos vs unix. you can convert the fill in ssh by typing:
dos2unix (inputfile) (outputfile)
if it is not installed you can convert it on this website.
scheduled task through Cronjob
You can find a tutorial here on how to create a cronjob