Example #1
0
<?php

/**
 * Created by PhpStorm.
 * User: konstantin
 * Date: 19.11.15
 * Time: 17.42
 */
require_once "../config/config.php";
require_once "../helpers/db.php";
require_once "../model/model.php";
$db = new DB();
$model = new Model($db);
$lostTables = $model->checkForLostTables(array("image"));
$urlToRedirect = "http://" . $_SERVER["SERVER_NAME"] . str_ireplace("/install", "", dirname($_SERVER["SCRIPT_NAME"])) . "/images/";
if (count($lostTables) > 0) {
    if (isset($_POST["action"]) && $_POST["action"] == "install") {
        $sql = file_get_contents("sql/axamit.sql");
        if ($sql) {
            if ($db->query($sql)) {
                header("Location: " . $urlToRedirect);
            } else {
                echo "Ошибка импорта в базу";
            }
        } else {
            echo "Ошибка загрузки файла импорта";
        }
    } else {
        $title = "Установка системы";
        ob_start();
        include ".." . DIRECTORY_SEPARATOR . "view" . DIRECTORY_SEPARATOR . "install.php";