Silnik strony + galerii zdjęć Suczawa 2009
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.0 KiB

  1. <?php
  2. /**
  3. * @package Galeria Suczawa 2009
  4. * @file init.php
  5. * @version $Id$
  6. **/
  7. #dołącz plik konfiguracyjny oraz funkcje
  8. if (defined('IN_ACP'))
  9. {
  10. require_once('./../config.php');
  11. require_once('./../functions.php');
  12. }
  13. else
  14. {
  15. require_once('./config.php');
  16. require_once('./functions.php');
  17. }
  18. #sprawdź, czy jest wyłączone register globals oraz magic quotes?
  19. if (ini_get('register_globals') == 1)
  20. {
  21. ini_set('register_globals', '0');
  22. if (ini_get('register_globals') == 1)
  23. {
  24. blad('Could not disable register_globals.');
  25. }
  26. }
  27. if (get_magic_quotes_gpc())
  28. {
  29. blad('Prosze wylaczyc magic_quotes_gpc w php.ini!');
  30. }
  31. ini_set('session.cookie_lifetime', 259200); #expire time - 1 month
  32. session_start(); #starting session
  33. if (empty($_SESSION['logged']))
  34. {
  35. $_SESSION['logged'] = false;
  36. }
  37. $DB = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); #connect with the database
  38. if ($DB->connect_error)
  39. { #check if there were any errors connecting
  40. blad('Could not connect do database server ('.$DB->connect_errno.'): '.$DB->connect_error);
  41. }
  42. if (!$DB->query("SET NAMES 'utf8'")) #użyj utf-8
  43. {
  44. blad('Could not set character to UTF-8');
  45. }
  46. $page = (isset($_GET['page'])) ? intval($_GET['page']) : 1;
  47. #pobierz liczbę zdjęć w galerii
  48. $sql = "SELECT COUNT(`id`) AS `count` FROM `photos`";
  49. if (!$result = $DB->query($sql))
  50. {
  51. blad('Nie mozna odczytac liczby zdjec!');
  52. }
  53. $row = $result->fetch_assoc();
  54. $count = $row['count'];
  55. $result->free(); //zwolnij pamięć
  56. if (!is_numeric($page))
  57. {
  58. blad('Podana strona nie istnieje!');
  59. }
  60. if ($page < 1)
  61. {
  62. blad('Podana strona nie istnieje!');
  63. }
  64. //
  65. //wygeneruj strone
  66. //
  67. if ($page != 1)
  68. {
  69. $value = ($page-1)*PERPAGE;
  70. $limit = 'LIMIT '.$value . ', '.PERPAGE;
  71. }
  72. else
  73. {
  74. $limit = 'LIMIT 0, '.PERPAGE;
  75. }
  76. $cnt = ceil($count / PERPAGE);
  77. $cnt = ($cnt == 0) ? 1 : $cnt;
  78. if($page > $cnt)
  79. {
  80. blad('Podana strona nie istnieje!');
  81. }
  82. //
  83. //koniec generowania stron
  84. //
  85. ?>