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.

94 lines
1.9 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. $_SESSSION['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. #pobierz liczbę zdjęć w galerii
  47. $sql = "SELECT COUNT(`id`) AS `count` FROM `photos`";
  48. if (!$result = $DB->query($sql))
  49. {
  50. blad('Nie mozna odczytac liczby zdjec!');
  51. }
  52. $row = $result->fetch_assoc();
  53. $count = $row['count'];
  54. $result->free; //zwolnij pamięć
  55. //
  56. //wygeneruj strone
  57. //
  58. if (isset($_GET['page'])&&($_GET['page']!=1))
  59. {
  60. if (!is_numeric($_GET['page']))
  61. {
  62. die('Hacking attempt');
  63. }
  64. $value = ($_GET['page']-1)*PERPAGE;
  65. $limit = 'LIMIT '.$value . ', '.PERPAGE;
  66. $page = $_GET['page'];
  67. }
  68. else
  69. {
  70. $limit = 'LIMIT 0, '.PERPAGE;
  71. $page=1;
  72. }
  73. $cnt = ceil($count / PERPAGE);
  74. if(isset($_GET['page']) && ($_GET['page']>$cnt))
  75. {
  76. blad('Podana strona nie istnieje!');
  77. }
  78. //
  79. //koniec generowania stron
  80. //
  81. ?>