Giter VIP home page Giter VIP logo

open-demo-reset's Introduction

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.

open-demo-reset's People

Contributors

jesobreira avatar

Watchers

James Cloos avatar Mizanur Rahaman Mizan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.