PHP Classes

File: sp_guard.php

Recommend this page to a friend!
  Classes of Alexander Selifonov   Site pages guard   sp_guard.php   Download  
File: sp_guard.php
Role: Example script
Content type: text/plain
Description: Working and ready-to-use sample
Class: Site pages guard
Monitor and restore damaged application files
Author: By
Last change:
Date: 14 years ago
Size: 2,849 bytes
 

Contents

Class file image Download
<?
/**
* sp_guard.php - sample for testing sitepages guard class (CSitePagesGuard)
* @author Alexander Selifonov < as-works [at] narod.ru >
*/
$thisversion = '1.001';
require_once(
'sitepages_guard.php');
$self = $_SERVER['PHP_SELF'];
$bckp_folder = 'E:/myphpbackup/'; # where to store backup (gzipped) copies
$root_folder = array('E:/myphp1/','E:/myphp2/');

#example of "virus signatures"
 
$virus_signatures = './sitepages.virusdef';

$guard = new CSitePagesGuard($root_folder,
  array(
'backupfolder'=>$bckp_folder)
);

$guard->SetMalwareSignatures($virus_signatures);
$guard->AddFileExtension('tpl');

echo
"<h4>SitePages Guard testing, creating initial registration v.$thisversion</h4>";
$action = isset($_GET['action']) ? $_GET['action'] : '';
$rdel = isset($_GET['rdel']) ? $_GET['rdel'] : 0;
$ch['regall'] = ($action==='regall')? 'checked="checked"':'';
$ch['update'] = ($action==='update')? 'checked="checked"':'';
$ch['check0'] = ($action==='check0')? 'checked="checked"':'';
$ch['check1'] = ($action==='check1')? 'checked="checked"':'';
$ch['check2'] = ($action==='check2')? 'checked="checked"':'';
$ch['rdel'] = ($rdel)? 'checked="checked"':'';
?>
<form method=get action="<?=$self?>">
<input type="radio" name="action" value="regall" <?=$ch['regall']?>/> Initial registrate all files<br />
<input type="radio" name="action" value="update" <?=$ch['update']?>/> Update info( register changed/new files)<br /><br />
<input type="radio" name="action" value="check0" <?=$ch['check0']?>/> Check for changes - no restoring<br />
<input type="radio" name="action" value="check1" <?=$ch['check1']?>/> Check for changes, restore only suspicious files<br />
<input type="radio" name="action" value="check2" <?=$ch['check2']?>/> Check for changes, restore ALL changed files<br />
<input type="checkbox" name="rdel" value="1" <?=$ch['rdel']?>/> Restore deleted files<br /><br />
<input type="submit" value="Do it !" style="width:100px;"/></form>
<div>
Backup folder: <b><?=$bckp_folder?></b><br />
Monitored folders:<br />
<?
foreach($root_folder as $fld) echo "-- <b>$fld</b><br />";
$action = isset($_GET['action']) ? $_GET['action'] : '';
echo
'</div>';
$result = '';
switch(
$action) {
    case
'regall':
       
$result = $guard->RegisterAllFiles(1);
        break;
    case
'update':
       
$result = $guard->UpdateFilesInfo(1);
        break;
    case
'check0':
       
$result = $guard->CheckFiles(CSitePagesGuard::RESTORE_NONE,0,1);
        break;
    case
'check1':
       
$result = $guard->CheckFiles(CSitePagesGuard::RESTORE_ONLY_SUSPICIOUS,$rdel,1);
        break;
    case
'check2':
       
$result = $guard->CheckFiles(CSitePagesGuard::RESTORE_ALL_CHANGED,$rdel,1);
        break;
}
if(
$result) echo "<div style='border:1x solid #aaf;'>Job results:<br />$result</div>";