<?php
|
|
/**
|
|
* @package Galeria Suczawa 2009
|
|
* @file init.php
|
|
* @version $Id$
|
|
**/
|
|
|
|
#dołącz plik konfiguracyjny oraz funkcje
|
|
if (defined('IN_ACP'))
|
|
{
|
|
require_once('./../config.php');
|
|
require_once('./../functions.php');
|
|
}
|
|
else
|
|
{
|
|
require_once('./config.php');
|
|
require_once('./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 (get_magic_quotes_gpc())
|
|
{
|
|
blad('Prosze wylaczyc magic_quotes_gpc w php.ini!');
|
|
}
|
|
|
|
ini_set('session.cookie_lifetime', 259200); #expire time - 1 month
|
|
|
|
session_start(); #starting session
|
|
if (empty($_SESSION['logged']))
|
|
{
|
|
$_SESSION['logged'] = false;
|
|
}
|
|
|
|
$DB = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); #connect with the database
|
|
|
|
if ($DB->connect_error)
|
|
{ #check if there were any errors connecting
|
|
blad('Could not connect do database server ('.$DB->connect_errno.'): '.$DB->connect_error);
|
|
}
|
|
|
|
if (!$DB->query("SET NAMES 'utf8'")) #użyj utf-8
|
|
{
|
|
blad('Could not set character to UTF-8');
|
|
}
|
|
$page = (isset($_GET['page'])) ? intval($_GET['page']) : 1;
|
|
|
|
#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ęć
|
|
|
|
if (!is_numeric($page))
|
|
{
|
|
blad('Podana strona nie istnieje!');
|
|
}
|
|
|
|
if ($page < 1)
|
|
{
|
|
blad('Podana strona nie istnieje!');
|
|
}
|
|
|
|
//
|
|
//wygeneruj strone
|
|
//
|
|
if ($page != 1)
|
|
{
|
|
$value = ($page-1)*PERPAGE;
|
|
$limit = 'LIMIT '.$value . ', '.PERPAGE;
|
|
}
|
|
else
|
|
{
|
|
$limit = 'LIMIT 0, '.PERPAGE;
|
|
}
|
|
|
|
$cnt = ceil($count / PERPAGE);
|
|
$cnt = ($cnt == 0) ? 1 : $cnt;
|
|
|
|
if($page > $cnt)
|
|
{
|
|
blad('Podana strona nie istnieje!');
|
|
}
|
|
//
|
|
//koniec generowania stron
|
|
//
|
|
?>
|