HOWTO:Set up a demo site

From e107 Wiki
Jump to: navigation, search

e107 Wiki: English | Русский | Deutsch | Français | Magyar | Português | Български | Česky | Nederlands | Ελληνικά | Italiano | Norske | Polska | Slovenščina | Español | Svenska | Translate: Wiki | Page

logo_wiki.png

Current Release 1.0.4 | e107.org | Download | Changelog | Forum | Plugins | Themes | RSS Feed of Latest Changes | Atom Feed of Latest Changes


HOWTO:Set up a demo site
Main page > I : First Aid > II : Development > III : Administration > IV : How To's > V : Plugin Writing > VI : Theming & Shortcodes


Contents

Introduction

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.

Configuration

Preparations

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:

  http//demo.yourdomain.com

or

  http//www.yourdomain.com/demo/

Configure e107

Demo user

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.

Page restriction

download the Page Restriction plugin by lisa and install it.

restrict usersettings.php for everyone.

Database backup

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.

Code: Dump database
mysqldump -u (username) -p (password) -h (server) (database name) > (whateveryouwanttocallthefile).sql

It might not be necessary to use the -h parameter (host).

Restore Database

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.

Code: Dump database
#! /bin/sh
clear;
#fill in your database information here
user="";
password="";
server="";
database_name="";

#path to the backup database file
restore_file="";

#here the script deletes all your tables in the database
mysql --user=$user --password=$password -h $server -BNe "show tables" $database_name | tr '\n' ',' | sed -e 's/,$//' | awk '{print "SET FOREIGN_KEY_CHECKS = 0;DROP TABLE IF EXISTS " $1 ";SET
FOREIGN_KEY_CHECKS = 1;"}' | mysql --user=$user --password=$password -h $server $database_name;

echo "Database tables dropped!";
echo "Restoring database..";

#here the script restores the database
mysql --user=$user --password=$password --host=$server $database_name < $restore_file;

echo "Database is restored!";

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

  ./restore_database.sh

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