Poprawki w PHP i ścieżki do katalogu
git-svn-id: https://svn.pioder.pl/sg-svn@13 3ed2631f-fe0d-47e0-9194-a46bc0f18ee8
This commit is contained in:
@@ -1,12 +1,78 @@
|
||||
<?
|
||||
require_once('config.php');
|
||||
require_once('functions.php');
|
||||
<?php
|
||||
/**
|
||||
* @package Galeria Suczawa 2009
|
||||
* @file init.php
|
||||
* @version $Id$
|
||||
**/
|
||||
|
||||
#dołącz plik konfiguracyjny oraz funkcje
|
||||
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!');
|
||||
}
|
||||
|
||||
$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
|
||||
showError('Could not connect do database server ('.$DB->connect_errno.'): '.$DB->connect_error);
|
||||
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'")) { #use utf-8
|
||||
showError('Could not set character to UTF-8');
|
||||
}
|
||||
?>
|
||||
|
||||
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
|
||||
//
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user