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

<?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');
<!-- 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)