Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ini_set('error_reporting', E_ALL);
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- */
- $host='localhost';
- $bd_user='';
- $bd_pass='';
- $bd_base='';
- $mysqli=mysqli_connect($host,$bd_user,$bd_pass,$bd_base);
- function f($sql){
- global $mysqli;
- $q=$mysqli->query($sql);
- return $q->fetch_array();
- }
- function num($sql){
- global $mysqli;
- $q=$mysqli->query($sql);
- return $q->num_rows;
- }
- function q($sql){
- global $mysqli;
- $q=$mysqli->query($sql);
- return $q;
- }
- function text($a){
- global $mysqli;
- return $mysqli->real_escape_string(htmlspecialchars(trim($a)));
- }
- function msg($text){
- echo '<div class=menu><div class=c><font color=indianred><b>Ошибка:</b> '.$text.'</font></div></div>';
- }
- function info($text){
- echo '<div class=menu><div class=c><font color=green>'.$text.'</font></div></div>';
- }
- function reload($url){
- header('Location: '.$url);
- exit();
- }
- $user=f("SELECT * FROM `user` WHERE `login`='".text($_SESSION['login'])."' and `pass`='".text($_SESSION['pass'])."'");
- function auth(){
- global $user;
- if($user) reload('/user/index.php');
- }
- function noauth(){
- global $user;
- if(!$user) reload('/user/auth.php');
- }
- function adm(){
- global $user;
- if($user['id']!='1') reload('/user/');
- }
- function img($src){
- return $src='<img src=/img/'.$src.'.png width=16px> ';
- }
- function nav($adm=null){
- if($adm) echo '<a class=lin href=/panel/>'.img('ico').'Обратно в панель</a>';
- echo '<a class=lin href=/user/><img src="/img/home.png"> На главную</a>';
- }
- function user($id){
- $obj=f("select `login`,`id`,`online` from `user` where `id`='$id'");
- if($obj==true){
- if($obj['online']>=(time()-600)) $onl='<font color=green>[on]</font>';
- else $onl='<font color=indianred>[off]</font>';
- return $id='<a href=/user/user.php?id='.$obj['id'].'><font color=brown>'.$obj['login'].'</font> '.$onl.'</a>';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement