Пример #1
0
 function main()
 {
     \CO::RE()->header('content-type', 'text/html; charset=utf-8');
     \CO::SQL(new \DB\SQLi())->connect('188.120.227.83', 'root', 'kolkol123', 'test_sete_pw')->query("set names utf8;");
     \CO::AUTH(new Model\Auth('039hg0whas9w8bp3wg'));
     $this->router();
 }
Пример #2
0
    function content($data)
    {
        if ($data['accept']) {
            \CO::RE()->PUSH('js', '/assets/js/shop.common.js');
            ?>
<form id="order_form">

	<div>
		<div class="btn-group">
			<a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
				<span id="table_title">Столик</span>
				<span class="caret"></span>
			</a>
			<ul id="table" class="dropdown-menu">
				
			</ul>
		</div>

		<div class="btn-group">
			<a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
				<span id="set_title">Место</span>
				<span class="caret"></span>
			</a>
			<ul id="set" class="dropdown-menu">
				
			</ul>
		</div>

		<a id="order_add" class="btn btn-primary">Добавить в корзину</a>
	</div>

</form>
<?php 
        }
    }
Пример #3
0
 function __call($name, $args)
 {
     $class = "\\Application\\Test\\Model\\" . $args['0']['class'];
     if (\CO::AUTH()->admin() || \CO::AUTH()->user()) {
         if (class_exists($class)) {
             $apiClass = new $class();
             if (method_exists($apiClass, $name)) {
                 $query = $apiClass->{$name}(\CO::RE()->get);
                 if (isset($query[ApiConstants::$ERROR_CODE]) || isset($query[ApiConstants::$STATUS])) {
                     $this->data = $query;
                 } else {
                     if (count($query) > 0) {
                         $this->data[ApiConstants::$STATUS] = ApiConstants::$SUCCESS;
                         $this->data[ApiConstants::$RESPONSE] = $query;
                     } else {
                         $this->data = [ApiConstants::$STATUS => ApiConstants::$SUCCESS, ApiConstants::$RESPONSE => []];
                     }
                 }
             } else {
                 $this->data = [ApiConstants::$STATUS => ApiConstants::$ERROR, ApiConstants::$ERROR_MESSAGE => ApiConstants::$ERROR_NOT_FOUND_METHOD_STRING, ApiConstants::$ERROR_CODE => ApiConstants::$ERROR_NOT_FOUND_METHOD_CODE];
             }
         } else {
             $this->data = [ApiConstants::$STATUS => ApiConstants::$ERROR, ApiConstants::$ERROR_MESSAGE => ApiConstants::$ERROR_NOT_FOUND_CLASS_STRING, ApiConstants::$ERROR_CODE => ApiConstants::$ERROR_NOT_FOUND_CLASS_CODE];
         }
     } else {
         $this->data = [ApiConstants::$STATUS => ApiConstants::$ERROR, ApiConstants::$ERROR_MESSAGE => ApiConstants::$ERROR_AUTH__STRING, ApiConstants::$ERROR_CODE => ApiConstants::$ERROR_AUTH_CODE];
     }
 }
Пример #4
0
 function edit($vals)
 {
     $error = true;
     $needAuth = false;
     if (isset($vals['name'])) {
         \CO::AUTH()->who()->name = substr(strip_tags($vals['name']), 0, 255);
         $error = false;
     }
     if (isset($vals['passwd']) && isset($vals['passwdNew'])) {
         if (\CO::AUTH()->who()->passwd === \CO::AUTH()->getUserHash(\CO::AUTH()->who()->ID(), $vals['passwd'])) {
             $vals['passwd'] = trim(strip_tags($vals['passwd']));
             $vals['passwdNew'] = trim(strip_tags($vals['passwdNew']));
             if ($vals['passwd'] != $vals['passwdNew']) {
                 \CO::AUTH()->who()->passwd = \CO::AUTH()->getUserHash(\CO::AUTH()->who()->ID(), $vals['passwdNew']);
                 $needAuth = true;
                 $error = false;
             }
         }
     }
     if (!$error) {
         \CO::AUTH()->who()->UPDATE();
         if ($needAuth) {
             \CO::AUTH()->auth(\CO::AUTH()->who());
         }
         \CO::RE()->redirect('/user');
     }
 }
Пример #5
0
 function logout()
 {
     \CO::RE()->cookie('authid', '');
     \CO::RE()->cookie('authsh', '');
     unset($this->user);
     $this->level = 0;
     $this->user = new \Application\Test\Model\User();
 }
Пример #6
0
<?php

$data = CO::RE()->post;
$dataReturn = json_decode('{}');
$dataReturn->status = json_decode('{}');
if (isset($data['id'])) {
    $query = CO::SQL()->query("\nSELECT id_image as id, url, transition, user_id\nFROM images\nWHERE id_image = ?\n    ", [['i', (int) $data['id']]]);
    if (count($query) == 0) {
        $dataReturn->status = 'error';
    } else {
        foreach ($query as &$img) {
            $img['url'] = '/image/' . $img['url'] . '/origin';
        }
        CO::SQL()->query("\nUPDATE images\nSET transition = transition + 1\nWHERE id_image = ?\n    ", [['i', (int) $data['id']]]);
        $dataReturn->status = 'success';
        $dataReturn->response = $query[0];
    }
} else {
    $dataReturn->status = 'error';
}
echo json_encode($dataReturn);
Пример #7
0
 function userEdit()
 {
     $this->model->edit(['name' => \CO::RE()->post['name'], 'email' => \CO::RE()->post['email'], 'passwd' => \CO::RE()->post['passwd'], 'passwdNew' => \CO::RE()->post['passwd_new']]);
 }
Пример #8
0
<?php

require_once DIR_PRIVATE . 'core/first.php';
CO::RE()->processStart('Test');
CO::RE()->systemStop();
Пример #9
0
CO::ROUTER()->push('/^file-manager\\.php$/', function () {
    CO::RE()->www('file-manager.php');
});
CO::ROUTER()->push('/^image\\/(?P<url>.{32}\\.[a-zA-Z0-9]*)\\/(?P<format>.*)$/', function ($args) {
    include DIR_PRIVATE . 'transfer/download.php';
    CO::RE()->end();
});
CO::ROUTER()->push('/^view\\/(?P<url>.{32}\\.[a-zA-Z0-9]*)$/', function ($args) {
    CO::RE()->www('view.php', $args);
    CO::RE()->end();
});
CO::ROUTER()->push('/^upload.php$/', function ($args) {
    include DIR_PRIVATE . 'transfer/upload.php';
    CO::RE()->end();
});
CO::ROUTER()->push('/^(user\\.php)?$/', function () {
    CO::RE()->www('user.php');
});
CO::ROUTER()->push('/^login\\.php$/', function () {
    CO::RE()->www('login.php');
});
CO::ROUTER()->push('/^logout\\.php$/', function () {
    CO::AUTH()->logout();
    CO::RE()->redirect('/');
});
// 404
CO::ROUTER()->push('/^.*/', function () {
    echo '404. Not found: ' . strip_tags(CO::RE()->url) . PHP_EOL;
    echo 'Kernel by: sete.pw';
    CO::RE()->end();
});
Пример #10
0
<?php

if (!CO::AUTH()->user()) {
    CO::RE()->redirect('/login.php');
} else {
    CO::RE()->push('js', '/assets/js/upload.js');
    CO::RE()->push('css', '/assets/css/upload.css');
    ?>

<h1>
	Загрузка изображений
</h1>

<form class="form-horizontal" method="POST" action="/upload.php" enctype="multipart/form-data">
	<fieldset>
		<input type="file" name="image[]" id="file-dialog" multiple="true" />

		<div id="img-list" class="row"></div>

		<input id="download" type="submit" class="btn btn-primary" value="Загрузить">
	</fieldset>
</form>

<?php 
}
Пример #11
0
} else {
    if (isset(CO::RE()->post['delete'])) {
        $id = (int) CO::RE()->post['delete'];
        $file = CO::SQL()->query("SELECT *\n\t\t\t\tfrom images\n\t\t\t\twhere\n\t\t\t\t\tid_image = ?\n\t\t\t\tlimit 1;\n\t\t\t", [['i', $id]]);
        if (count($file)) {
            $file = $file[0]['url'];
            CO::SQL()->query("DELETE from images\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_image = ?\n\t\t\t\t\tlimit 1;\n\t\t\t\t", [['i', $id]]);
            unlink(DIR_PRIVATE . 'data/image/' . $file);
            unlink(DIR_PRIVATE . 'data/image-preview/' . $file);
        }
    }
    $onPage = 30;
    $startId = isset(CO::RE()->get['start']) ? (int) CO::RE()->get['start'] : 0;
    $list = CO::SQL()->query("SELECT *\n\t\t\tfrom images\n\t\t\twhere\n\t\t\t\tid_image > ?\n\t\t\torder by id_image desc\n\t\t\tlimit ?;\n\t\t", [['i', $startId], ['i', $onPage]]);
    CO::RE()->push('css', '/assets/css/file-manager.css');
    CO::RE()->push('js', '/assets/js/file-manager.css');
    ?>

<h1>
	Файловый менеджер
</h1>

<div class="row image-list">
	<?php 
    foreach ($list as $img) {
        $img['url_view'] = '/view/' . $img['url'];
        $img['url'] = '/image/' . $img['url'];
        $img['url_preview'] = $img['url'] . '/preview';
        ?>

	<a href="<?php 
Пример #12
0
<?php

define('DIR_LIB', DIR_PRIVATE . 'lib/');
include DIR_LIB . 'co.php';
include DIR_LIB . 'mysql.php';
include DIR_LIB . 'auth.php';
include DIR_LIB . 'router.php';
include DIR_LIB . 'resize.php';
CO::RE();
CO::PROJECT([name => 'WorkImage']);
CO::RE()->header('content-type', 'text/html; charset=utf-8');
CO::RE()->www = function ($file, $args = null) {
    CO::RE()->ARR('js');
    CO::RE()->ARR('css');
    include DIR_PRIVATE . 'www/' . $file;
    $content = ob_get_clean();
    ob_start();
    include DIR_PRIVATE . 'template.php';
    CO::RE()->end();
};
CO::SQL(new \DB\SQLi())->connect('test.sete.pw', 'root', 'kolkol123', 'test_images')->query("SET names utf8;\n\t");
CO::AUTH(new \Auth('fsdnoFi3h0W9ghGpsdi234E2'));
CO::ROUTER(new \Router());
include DIR_PRIVATE . 'init_router.php';
CO::ROUTER()->start(CO::RE()->url);
Пример #13
0
<?php

/**
 * Определяются рабочие директории
 * Предварительно должны быть определены:
 * DIR_PRIVATE - директория проекта
 * DIR_ASSETS - директория публичных ресурсов
 */
define('DIR_CORE', DIR_PRIVATE . 'core/');
define('DIR_APP', DIR_PRIVATE . 'application/');
define('DIR_LIB', DIR_PRIVATE . 'lib/');
/**
 * Подключение компонентов ядра
 */
require_once DIR_CORE . 'co.php';
require_once DIR_CORE . 'application.php';
require_once DIR_CORE . 'mvc.php';
require_once DIR_CORE . 'router.php';
require_once DIR_CORE . 'autoload.php';
/**
 * Инициализация
 */
CO::RE();
Пример #14
0
    function content($data)
    {
        $this->data = $data;
        ?>

<!DOCTYPE html>
<html lang="ru">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
	<title>Столики онлайн</title>

	<!-- Bootstrap -->
	<link href="/assets/libs/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet">

	<link href="/assets/css/main.css" rel="stylesheet">

	<?php 
        foreach (\CO::RE()->css as $css) {
            ?>
	<link href="<?php 
            echo $css;
            ?>
" rel="stylesheet">
	<?php 
        }
        ?>

	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
	  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>
<body>
	<nav class="navbar navbar-default navbar-static-top" role="navigation">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-navbar-collapse-1">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="/">Столики онлайн</a>
			</div>

			<div class="collapse navbar-collapse" id="bs-navbar-collapse-1">
				<ul class="nav navbar-nav">
					<li class="<?php 
        $this->active('index');
        ?>
"><a href="/"><span class="glyphicon glyphicon-home"></span>&nbsp;Главная</a></li>
					<li class="<?php 
        $this->active('shop');
        ?>
"><a href="/shop"><span class="glyphicon glyphicon-barcode"></span>&nbsp;Заказать онлайн</a></li>
				</ul>
				<ul class="nav navbar-nav navbar-right">
					<!-- ОДНО ИЗ ДВУХ ДОЛЖНО БЫТЬ -->
					<?php 
        if (\CO::AUTH()->user()) {
            ?>
					<li><a href="#binModal" data-toggle="modal"><span class="glyphicon glyphicon-shopping-cart"></span>&nbsp;Корзина&nbsp;<span id="bin_counter" class="badge">...</span></a></li>
					<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="glyphicon glyphicon-user">&nbsp;</span><?php 
            echo \CO::AUTH()->who()->name;
            ?>
<span class="caret"></span></a>
						<ul class="dropdown-menu" role="menu">
							<li class="<?php 
            $this->active('user');
            ?>
"><a href="/user"><span class="glyphicon glyphicon-user"></span>&nbsp;Мой аккаунт</a></li>
					<?php 
            if (\CO::AUTH()->admin()) {
                //если админ то добавить пункт меню
                ?>
				
					<li class="<?php 
                $this->active('admin');
                ?>
"><a href="/admin"><span class="glyphicon glyphicon-list-alt"></span>&nbsp;Очередь</a></li>
					<?php 
            }
            ?>
							<li class="divider"></li>
							<li><a href="/logout"><span class="glyphicon glyphicon-remove"></span>&nbsp;Выйти</a></li>
						</ul>
					</li>
					<?php 
        } else {
            ?>
					<li><a href="#loginModal" data-toggle="modal" class="text-success"> <span class="glyphicon glyphicon-lock text-success"></span>&nbsp;Войти</a></li>
					<?php 
        }
        ?>
				</ul>
			</div>
		</div>
	</nav>
		
	<div class="modal fade" id="loginModal" role="dialog">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span></button>
					<h4 class="modal-title">Вход</h4>
				</div>
				<div class="modal-body">		
					<form class="form-horizontal" method="POST" action="/login">
						<fieldset>
							<div class="form-group">
								<label for="inputEmail" class="col-lg-2 control-label">Email</label>
								<div class="col-lg-10">
									<input class="form-control" id="inputEmail" placeholder="Email" type="text" name="email">
								</div>
							</div>
							<div class="form-group">
								<label for="inputPassword" class="col-lg-2 control-label">Пароль</label>
								<div class="col-lg-10">
									<input class="form-control" id="inputPassword" placeholder="Пароль" type="password" name="passwd">
								</div>
							</div>
							<div class="form-group">
								<div class="col-lg-10 col-lg-offset-2">
									<button type="submit" class="btn btn-primary">Войти</button>
									<a class="btn btn-info" href="#reg">Регистрация</a>
								</div>
							</div>
						</fieldset>
					</form>
				</div>
			</div>
		</div>
	</div>

	<div class="modal fade" id="binModal" role="dialog">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span></button>
					<h2 class="modal-title">
						Корзина <span id="bin_title" class="text-primary"></span>
					</h2>
				</div>
				<div class="modal-body">		
					<div class="container-scroll">
						<table class="table table-striped table-hover">
							<thead>
								<tr>
									<th>Номер Заказа</th>
									<th>Место</th>
									<th>Стоимость</th>
									<th>Операции</th>
								</tr>
							</thead>
							<tbody id="bin_list">
								


							</tbody>
						</table> 
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="container" id="content">
		<?php 
        echo $data['content'];
        ?>
	</div>





	<!-- jQuery -->
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
	<!-- jQuery UI CSS -->
	<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
	<script src="/assets/libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>

	<script src="/assets/js/api.js"></script>
	<script src="/assets/js/common.js"></script>

	<?php 
        if (\CO::AUTH()->user()) {
            ?>
		<script src="/assets/js/bin.js"></script>
	<?php 
        }
        ?>
	
	<?php 
        foreach (\CO::RE()->js as $js) {
            ?>
		<!--SORT TABLE in panel admininstrator-->
		<script src="<?php 
            echo $js;
            ?>
"></script>
	<?php 
        }
        ?>

</body>
</html>

<?php 
    }
Пример #15
0
 function logout()
 {
     unset($this->user);
     CO::RE()->cookie('authid', '');
     CO::RE()->cookie('authsh', '');
 }
Пример #16
0
if (isset(CO::RE()->post['email']) && isset(CO::RE()->post['passwd'])) {
    CO::AUTH()->login(CO::RE()->post['email'], CO::RE()->post['passwd']);
    if (CO::AUTH()->who('email') === CO::RE()->post['email']) {
        CO::RE()->redirect('/');
    }
}
?>

<form class="form-horizontal col-md-offset-3 col-md-6" method="POST" action="/login.php">
	<fieldset>
		<div class="form-group">
			<label for="inputEmail" class="col-lg-2 control-label">Email</label>
			<div class="col-lg-10">
				<input class="form-control" id="inputEmail" placeholder="Email" type="text" name="email" value="<?php 
echo CO::RE()->post['email'];
?>
">
			</div>
		</div>
		<div class="form-group">
			<label for="inputPassword" class="col-lg-2 control-label">Пароль</label>
			<div class="col-lg-10">
				<input class="form-control" id="inputPassword" placeholder="Пароль" type="password" name="passwd">
			</div>
		</div>
		<div class="form-group">
			<div class="col-lg-10 col-lg-offset-2">
				<button type="submit" class="btn btn-primary">Войти</button>
			</div>
		</div>
Пример #17
0
<?php

$ApiCore = new ApiCore(CO::RE()->api, $_REQUEST);
echo $ApiCore->callMethod();
Пример #18
0
					<div class="form-group">
						<label for="inputPass" class="col-lg-4 control-label">Пароль</label>
						<div class="col-lg-8">
							<input type="password" name="passwd" class="form-control" id="inputPass" placeholder="Пароль">
						</div>
					</div>
					<div class="form-group">
						<label for="inputPassNew" class="col-lg-4 control-label">Новый пароль</label>
						<div class="col-lg-8">
							<input type="password" name="passwd_new" class="form-control" id="inputPassNew" placeholder="Новый пароль">
						</div>
					</div>
					<div class="form-group">
						<div class="col-lg-8 col-lg-offset-4">
							<button type="submit" class="btn btn-primary">Сохранить</button>
						</div>
					</div>
				</fieldset>
			</form>


		</div>

	</div>
</div>


<?php 
} else {
    CO::RE()->redirect('/login.php');
}
Пример #19
0
<?php

if (isset(CO::RE()->files['image'])) {
    $imgs = CO::RE()->files['image'];
    foreach ($imgs['type'] as $key => $type) {
        if (explode('/', $type)[0] == 'image') {
            do {
                $url = md5(date('Y-m-d H:i:s') . '->' . rand(-99999, 99999) . ':' . rand(-99999, 99999) . ':' . rand(-99999, 99999) . ':' . rand(-99999, 99999));
                $ext = explode('.', $imgs['name'][$key]);
                $ext = array_pop($ext);
                $url .= '.' . $ext;
                CO::SQL()->query("INSERT INTO images\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\turl_ext,\n\t\t\t\t\t\t\tcategory,\n\t\t\t\t\t\t\tuser_id\n\t\t\t\t\t\t)values(\n\t\t\t\t\t\t\t?,\n\t\t\t\t\t\t\t?,\n\t\t\t\t\t\t\t?,\n\t\t\t\t\t\t\t?\n\t\t\t\t\t\t);\n\t\t\t\t\t", [['s', $url], ['s', mb_strtolower(trim(strip_tags(CO::RE()->post['url_ext'][$key])), 'utf-8')], ['s', mb_strtolower(trim(strip_tags(CO::RE()->post['file'][$key])), 'utf-8')], ['i', CO::AUTH()->who('id_user')]]);
                $id = CO::SQL()->iid();
                if (!copy($imgs['tmp_name'][$key], DIR_PRIVATE . 'data/image/' . $url)) {
                    CO::SQL()->query("DELETE from images\n\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\tid_image = ?\n\t\t\t\t\t\t\tlimit 1;\n\t\t\t\t\t\t", [['i', $id]]);
                    break;
                }
                createPreview($url);
            } while ($id == 0);
        }
    }
}
CO::RE()->redirect('/file-manager.php');