<?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']))
|
|
{
|
|
$_SESSSION['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');
|
|
}
|
|
|
|
|
|
#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)*PERPAGE;
|
|
$limit = 'LIMIT '.$value . ', '.PERPAGE;
|
|
$page = $_GET['page'];
|
|
}
|
|
else
|
|
{
|
|
$limit = 'LIMIT 0, '.PERPAGE;
|
|
$page=1;
|
|
}
|
|
$cnt = ceil($count / PERPAGE);
|
|
if(isset($_GET['page']) && ($_GET['page']>$cnt))
|
|
{
|
|
blad('Podana strona nie istnieje!');
|
|
}
|
|
//
|
|
//koniec generowania stron
|
|
//
|
|
?>
|