Exemplo n.º 1
0
$ans = array('id' => $id, 'type' => $type, 'msg' => '');
if (in_array($type, array('admin'))) {
    if (!$submit) {
        $ans['admin'] = Access::admin();
    } else {
        $ans['admin'] = Access::admin(array(@$_REQUEST['login'], @$_REQUEST['pass']));
        if (!$ans['admin']) {
            if (isset($_REQUEST['login'])) {
                return Ans::err($ans, 'Неправильный пароль!');
            } else {
                return Ans::ret($ans, 'Вы успешно вышли!');
            }
        }
    }
}
if (!Access::admin()) {
    return Ans::err($ans, 'Вам нужно авторизоваться');
}
if (in_array($type, array('mvdir', 'mkdir', 'cpdir', 'rmdir'))) {
    if ($id[0] != '~') {
        return Ans::err($ans, 'Путь должен начинаться с ~');
    }
    if ($type === 'mkdir' && !Path::theme($id, 'snd')) {
        return Ans::err($ans, 'Нет папки в которой нужно создать');
    }
    if ($type === 'mvdir' && !Path::theme($id, 'snd')) {
        return Ans::err($ans, 'Нет папки которую нужно перенести');
    }
    if ($type === 'cpdir' && !Path::theme($id, 'snd')) {
        return Ans::err($ans, 'Нет папки которую нужно скопировать');
    }
Exemplo n.º 2
0
<?php

namespace infrajs\infra;

use infrajs\access\Access;
use infrajs\event\Event;
use infrajs\ans\Ans;
use infrajs\path\Path;
use infrajs\session\Session;
if (!is_file('vendor/autoload.php')) {
    chdir(explode('vendor/', __DIR__)[0]);
    require_once 'vendor/autoload.php';
}
Access::admin(true);
$ans = array();
if (isset($_GET['get'])) {
    $name = Ans::REQ('name');
    $ans['id'] = Session::getId();
    $ans['data'] = Session::get($name);
} else {
    if (isset($_GET['clear'])) {
        Session::clear();
    } else {
        if (isset($_GET['set'])) {
            $ans = array();
            $name = Path::toutf($_REQUEST['name']);
            $val = Path::toutf($_REQUEST['val']);
            Session::set($name, $val);
        }
    }
}
Exemplo n.º 3
0
<?php

use infrajs\ans\Ans;
use infrajs\access\Access;
use infrajs\nostore\Nostore;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../');
    require_once 'vendor/autoload.php';
}
Nostore::on();
$ans = array();
$ans['test'] = Access::test();
$ans['debug'] = Access::debug();
$ans['admin'] = Access::admin();
return Ans::ret($ans);
Exemplo n.º 4
0
			<p><a href="?">Проверить</a></p>
		</div>
<?php 
} elseif (isset($_REQUEST['logout'])) {
    Access::admin(false);
    ?>

		<div style="padding:50px 100px">

			<p>Вы обычный посетитель</p>
			<p><a href="?">Проверить</a></p>
		</div>

<?php 
} else {
    $r = Access::admin();
    if ($r) {
        Config::get('template');
        echo Template::parse('-admin/index.tpl');
        ?>
		<div style="padding:50px 100px">
			<p>Вы администратор</p>
			<p><a href="?logout">Выход</a></p>
		</div>
<?php 
    } else {
        ?>
		<div style="padding:50px 100px">
			<p>Вы обычный посетитель</p>
			<p><a href="?login">Вход</a></p>
		</div>
Exemplo n.º 5
0
use infrajs\load\Load;
use infrajs\access\Access;
use infrajs\ans\Ans;
if (!is_file('vendor/autoload.php')) {
    chdir('../../../');
    require_once 'vendor/autoload.php';
}
$ans = array();
$ans['title'] = 'Общая проверка';
Access::test(true);
$res = Load::loadJSON('-autoedit/autoedit.php?type=editfile&id=~.infra.json');
if (Access::admin()) {
    if (!$res['result'] || !$res['isfile']) {
        return Ans::err($ans, 'Неудалось получить информацию о файле .infra.json');
    }
} else {
    if (!$res || $res['result']) {
        return Ans::err($ans, 'Неудалось обратиться за файлом .infra.json');
    }
}
$res = Load::loadJSON('-autoedit/autoedit.php?type=editfolder&id=~');
if (Access::admin()) {
    if (!$res['result'] || !sizeof($res['list'])) {
        return Ans::err($ans, 'Неудалось прочитать папку');
    }
} else {
    if (!$res || $res['result']) {
        return Ans::err($ans, 'Неудалось обратиться к папке');
    }
}
return Ans::ret($ans, 'Вроде ок, прочитали папку, посмотрели файл');