Browse Source

Logowanie już działa :)

git-svn-id: https://svn.pioder.pl/sg-svn@19 3ed2631f-fe0d-47e0-9194-a46bc0f18ee8
master
pioder 14 years ago
parent
commit
2e2c66152d
3 changed files with 94 additions and 13 deletions
  1. +14
    -12
      robocze/admin/index.php
  2. +60
    -1
      robocze/admin/login.php
  3. +20
    -0
      robocze/functions.php

+ 14
- 12
robocze/admin/index.php View File

@ -22,6 +22,8 @@ if (empty($_GET['mode']))
Przekieruj('index.php?mode=admin_gallery');
}
//NaglowekXHTML();
switch($_GET['mode'])
{
#logowanie
@ -76,20 +78,20 @@ switch($_GET['mode'])
case 'add':
{
require('./gallery_item_add.php';
break
require('./gallery_item_add.php');
break;
}
case 'edit':
{
require('./gallery_item_edit.php';
break
require('./gallery_item_edit.php');
break;
}
case 'delete':
{
require('./gallery_item_delete.php';
break
require('./gallery_item_delete.php');
break;
}
}
@ -117,20 +119,20 @@ switch($_GET['mode'])
case 'add':
{
require('./user_add.php';
break
require('./user_add.php');
break;
}
case 'edit':
{
require('./user_edit.php';
break
require('./user_edit.php');
break;
}
case 'delete':
{
require('./user_delete.php';
break
require('./user_delete.php');
break;
}
}

+ 60
- 1
robocze/admin/login.php View File

@ -5,4 +5,63 @@
* @version $Id$
**/
?>
$msg = '';
if (isset($_POST['nick'], $_POST['passwd']) && strlen(trim($_POST['nick']))>0 && strlen(trim($_POST['passwd']))>0 )
{
$sql = "SELECT * FROM `admins` WHERE `nick`='".strip_tags(addslashes($_POST['nick']))."'";
if (!$result = $DB->query($sql))
{
blad('Nie mozna sprawdzic tabeli administracyjnej!');
}
if ($result->num_rows==0)
{
$msg = 'Podany użytkownik nie istnieje w bazie!';
}
else
{
$row = $result->fetch_assoc();
if ($row['password'] == md5($_POST['passwd']))
{
$_SESSION['logged'] = true;
$sql = "UPDATE `admins` SET `IP`='".$_SERVER['REMOTE_ADDR']."' WHERE `id`='".$row['id']."'";
if (!$DB->query($sql))
{
blad('Nie mozna zaaktualizowac ostatniego IP!');
}
Przekieruj('index.php?mode=admin_gallery', 'Zostałeś poprawnie zalogowany! Przekierowywanie...');
}
else
{
$msg = 'Hasło jest nieprawidłowe!';
}
}
}
NaglowekPA('Logowanie');
?>
<div style="background-color: lightgray">Wpisz dane administratora, aby się zalogować</div>
<?php if ($msg!='') { ?>
<br />
<div style="background-color: #FFFF99"><span style="color: red">Wystąpiły błędy: <b><?php echo $msg; ?></b></span></div>
<?php } ?>
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
<table>
<tr>
<td align="right">Nazwa użytkownika:</td>
<td><input type="text" name="nick" /></td>
</tr>
<tr>
<td align="right">Hasło:</td>
<td><input type="password" name="passwd" /></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Zaloguj" />&nbsp;&nbsp;<input type="reset" value="Reset" />
</td>
</tr>
</table>
</form>

+ 20
- 0
robocze/functions.php View File

@ -93,4 +93,24 @@ function Przekieruj($url='index.php', $tresc='')
die('<meta http-equiv="refresh" content="0; url='.$url.'" />');
}
}
function NaglowekPA($nazwapodstrony)
{
global $xhtml;
echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
<head>
<title>ACP &bull; '.$nazwapodstrony.'</title>
<meta http-equiv="Content-Type" content="'.($xhtml?'application/xhtml+x':'text/ht').'ml; charset=utf-8" />
<style type="text/css">
body { font-family: Verdana; font-size: 10pt}
</style>
</head>
<body>
<center>
<div align="center" style="width: 900px">
<h1>Panel Administracyjny Galerii Zdjęć</h1>
';
}
?>

Loading…
Cancel
Save