Nowa wersja webmasterska
git-svn-id: https://svn.pioder.pl/sg-svn@12 3ed2631f-fe0d-47e0-9194-a46bc0f18ee8
This commit is contained in:
113
robocze/init.php
113
robocze/init.php
@@ -1,105 +1,12 @@
|
||||
<?
|
||||
/**
|
||||
* @package Galeria Suczawa 2009
|
||||
* @file init.php
|
||||
* @version $Id$
|
||||
* @author chp1994 <chp1994@gmail.com>
|
||||
* @link http://suczawa.ath.cx/
|
||||
**/
|
||||
<?
|
||||
require_once('config.php');
|
||||
require_once('functions.php');
|
||||
$DB = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); #connect with the database
|
||||
|
||||
#dołącz plik konfiguracyjny oraz funkcje
|
||||
require('./config.php');
|
||||
require('./functions.php');
|
||||
|
||||
#sprawdź, czy jest wyłączone register globals oraz magic quotes?
|
||||
if (ini_get('register_globals') == 1)
|
||||
{
|
||||
ini_set('register_globals', '0');
|
||||
if (ini_get('register_globals') == 1)
|
||||
{
|
||||
blad('Could not disable register_globals.');
|
||||
}
|
||||
if ($DB->connect_error) { #check if there were any errors connecting
|
||||
showError('Could not connect do database server ('.$DB->connect_errno.'): '.$DB->connect_error);
|
||||
}
|
||||
|
||||
if (get_magic_quotes_gpc())
|
||||
{
|
||||
blad('Prosze wylaczyc magic_quotes_gpc w php.ini!');
|
||||
}
|
||||
|
||||
#połącz z bazą danych
|
||||
$DB = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
|
||||
#sprawdź pomyślność połączenia
|
||||
if ($DB->connect_error)
|
||||
{
|
||||
blad('Could not connect do database server ('.$DB->connect_errno.')'.$DB->connect_error);
|
||||
}
|
||||
if (!$DB->query("SET NAMES 'utf8'"))
|
||||
{
|
||||
blad('Could not set character to UTF-8');
|
||||
}
|
||||
|
||||
#pobierz id pierwszego zdjęcia
|
||||
$sql = "SELECT `id` FROM `photos` ORDER BY `id` LIMIT 1";
|
||||
if (!$result = $DB->query($sql))
|
||||
{
|
||||
blad('Nie mozna odczytac id pierwszego zdjecia!');
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$firstid = $row['id'];
|
||||
$result->free; //zwolnij pamięć
|
||||
unset($row);
|
||||
|
||||
#pobierz id ostatniego zdjęcia
|
||||
$sql = "SELECT `id` FROM `photos` ORDER BY `id` DESC LIMIT 1";
|
||||
if (!$result = $DB->query($sql))
|
||||
{
|
||||
blad('Nie mozna odczytac id ostatniego zdjecia!');
|
||||
}
|
||||
|
||||
$row = $result->fetch_assoc();
|
||||
$lastid = $row['id'];
|
||||
|
||||
$result->free; //zwolnij pamięć
|
||||
unset($row);
|
||||
|
||||
#pobierz liczbę zdjęć w galerii
|
||||
$sql = "SELECT COUNT(`id`) AS `count` FROM `photos`";
|
||||
|
||||
if (!$result = $DB->query($sql))
|
||||
{
|
||||
blad('Nie mozna odczytac liczby zdjec!');
|
||||
}
|
||||
$row = $result->fetch_assoc();
|
||||
$count = $row['count'];
|
||||
|
||||
$result->free; //zwolnij pamięć
|
||||
|
||||
//
|
||||
//wygeneruj strone
|
||||
//
|
||||
if (isset($_GET['page'])&&($_GET['page']!=1))
|
||||
{
|
||||
if (!is_numeric($_GET['page']))
|
||||
{
|
||||
die('Hacking attempt');
|
||||
}
|
||||
$value = ($_GET['page']-1)*$per_page;
|
||||
$limit = 'LIMIT '.$value . ', '.$per_page;
|
||||
$page = $_GET['page'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$limit = 'LIMIT 0, '.$per_page;
|
||||
$page=1;
|
||||
}
|
||||
$cnt = ceil($count / $per_page);
|
||||
if(isset($_GET['page']) && ($_GET['page']>$cnt))
|
||||
{
|
||||
blad('Podana strona nie istnieje!');
|
||||
}
|
||||
//
|
||||
//koniec generowania stron
|
||||
//
|
||||
?>
|
||||
if (!$DB->query("SET NAMES 'utf8'")) { #use utf-8
|
||||
showError('Could not set character to UTF-8');
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user