wa4u / open-demo-reset

Open source script for resetting demo sites

Home Page:http://jesobreira.github.io/open-demo-reset

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Open Demo Reset

Download

Demo will reset in: 23:41:13

Do you sell or host the online demo of some script? Tired of child-ish people who post that pictures and things? Here you go!

This script creates a draggable countdown widget at the bottom of the page, telling the user how many minutes are remaining until the next demo reset update.

Once the time is reached (you can set the reset interval) it removes all files and folders from your script and copies new files from a backup folder specified by you. Also, it will remove all MySQL tables and re-install your script through a SQL file provided by you (it can be a phpMyAdmin dump). Finally, it will remove all existing sessions and user cookies.

And the best part: NO cronjob used :)

How to install

  • Copy the "odr" folder onto your demo site root. You can modify the folder name if you want so.

  • Open "config.inc.php" with a code editor and set this up:

<?php

/////////////////////
// Open Demo Reset //
/////////////////////

define('TIME_INTERVAL', 60*60*24); // interval, in seconds, for each update
define('DEMO_FOLDER', '../'); // where your demo site is located
define('BACKUP_FOLDER', 'backup/'); // where your backup site is located
define('MYSQL_DUMP', 'backup.sql'); // where your phpMyAdmin dump is located

$ignore_files_n_folders = array('../README.md', '../.git/*'); // files you want to ignore (you don't need to include "odr" folder, even if you have changed the folder name)

// Now, set up your MySQL server, user, password and database:
$db = new mysqli('localhost', 'root', '', 'opendemoreset');
  • Include the following HTML code for each file your users will run (if you have a template engine, use MVC or just have a header or footer separated, that's a lot easier):
<!-- odr -->
<link rel="stylesheet" href="odr/style.css" type="text/css" />
<script type="text/javascript" src="odr/odr.js.php"></script>
<!-- /odr -->

(Note that, if you changed the "odr" folder name, you must change it on the code above too)

  • Copy your clean demo install to the "backup" folder. You can (and must, for security reason) change this folder name. Remember to tell what name you chose in config.inc.php file (BACKUP_FOLDER constant).

  • Do a MySQL dump of your favorite MySQL administration tool (phpMyAdmin, Adminer etc.). Do not create the "CREATE DATABASE", nor the "DROP DATABASE". You don't have to create the "DROP TABLE" as it's already done by ODR, but it's not a problem if you do (it's just meaningless).

  • Give writting permission (CHMOD 777) in ALL your demo site, using your FTP or SSH client. This includes your script as well as the Open Demo Reset folder. Do not forget anything.

  • That's all.

About

Open source script for resetting demo sites

http://jesobreira.github.io/open-demo-reset


Languages

Language:PHP 88.0%Language:CSS 12.0%