<?php
header('Content-Type: text/html; charset=utf-8');

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);

drupal_maintenance_theme();


if(isset($_POST["trun_sbt"]))
{
    $tbls = array("ediary_comments",
                "ediary_events",
                "ediary_final_events",
                "ediary_final_marks",
                "ediary_groups",
                "ediary_groups_pupils",
                "ediary_groups_terms",
                "ediary_lessons",
                "ediary_marks",
                "ediary_missings",
                "ediary_pupils",
                "ediary_pupils_accounts",
                "ediary_results",
                "ediary_schoolyears",
                "ediary_shifts",
                "ediary_subjects",
                "ediary_teachers",
                "ediary_terms",
                "ediary_term_types",
                "ediary_parent"
            );
            
    foreach($tbls as $tb)
    {
        db_truncate($tb)->execute();
    }
    
    $slash = substr($_SERVER['DOCUMENT_ROOT'], -1);
    if ($slash == "/") {
        $docroot = $_SERVER['DOCUMENT_ROOT'];
    } else {
        $docroot = $_SERVER['DOCUMENT_ROOT'] . "/";
    }
    
    if($handle = opendir($docroot.'xml/'))
    {
        while(false !== ($file = readdir($handle)))
        {
            if($file != "." && $file != "..")
                unlink($docroot.'xml/'.$file);
        }
        closedir($handle);
    }
    
    drupal_goto("/");
    
    die();
}
?>

<form action="" method="post">
    <input type="submit" name="trun_sbt" value="Очистить дневник" />
</form>

<?
die();
?>



