franta-hg@3
|
1 |
<?php
|
franta-hg@3
|
2 |
|
franta-hg@3
|
3 |
require('nastaveni.php');
|
franta-hg@3
|
4 |
|
franta-hg@3
|
5 |
$zacatek = getMicrotime();
|
franta-hg@3
|
6 |
|
franta-hg@3
|
7 |
function exception_handler($exception) {
|
franta-hg@3
|
8 |
html("Došlo k chybě: " . $exception->getMessage());
|
franta-hg@3
|
9 |
//header("Location: chyba_db.php");
|
franta-hg@3
|
10 |
exit();
|
franta-hg@3
|
11 |
}
|
franta-hg@3
|
12 |
|
franta-hg@3
|
13 |
set_exception_handler('exception_handler');
|
franta-hg@3
|
14 |
|
franta-hg@3
|
15 |
|
franta-hg@3
|
16 |
if (empty($_SERVER['HTTP_ACCEPT'])) {
|
franta-hg@3
|
17 |
$mimeTyp = 'application/xhtml+xml';
|
franta-hg@3
|
18 |
} else {
|
franta-hg@3
|
19 |
$mimeTyp = (( stristr( $_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml' ) && !preg_match("/application\/xhtml\+xml;\s*q=0(\.0)?\s*(,|$)/",$_SERVER['HTTP_ACCEPT']) ) ? 'application/xhtml+xml' : 'text/html' );
|
franta-hg@3
|
20 |
}
|
franta-hg@3
|
21 |
header("Content-Type: $mimeTyp");
|
franta-hg@3
|
22 |
|
franta-hg@3
|
23 |
/** $nadpis = titulek stránky + h1 */
|
franta-hg@4
|
24 |
function zahlavi($nadpis) {
|
franta-hg@3
|
25 |
global $mimeTyp;
|
franta-hg@3
|
26 |
|
franta-hg@3
|
27 |
html('<?xml version="1.0" encoding="UTF-8"?>
|
franta-hg@3
|
28 |
<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
franta-hg@3
|
29 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
|
franta-hg@3
|
30 |
<head>
|
franta-hg@3
|
31 |
<meta http-equiv="content-language" content="cs"/>
|
franta-hg@3
|
32 |
<meta http-equiv="content-type" content="' . $mimeTyp . '; charset=UTF-8"/>
|
franta-hg@3
|
33 |
<meta name="GOOGLEBOT" content="NOINDEX, NOFOLLOW"/>
|
franta-hg@3
|
34 |
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW"/>
|
franta-hg@3
|
35 |
<link href="styl.css" type="text/css" rel="StyleSheet"/>
|
franta-hg@3
|
36 |
<title>' . $nadpis . '</title>
|
franta-hg@3
|
37 |
</head>
|
franta-hg@3
|
38 |
<body>
|
franta-hg@3
|
39 |
<h1>' . $nadpis . '</h1>');
|
franta-hg@3
|
40 |
}
|
franta-hg@3
|
41 |
|
franta-hg@4
|
42 |
function zapati() {
|
franta-hg@4
|
43 |
html('</body>');
|
franta-hg@4
|
44 |
htmlInfoKomentar();
|
franta-hg@4
|
45 |
html('</html>');
|
franta-hg@3
|
46 |
}
|
franta-hg@3
|
47 |
|
franta-hg@3
|
48 |
function htmlInfoKomentar() {
|
franta-hg@3
|
49 |
global $zacatek, $mimeTyp, $NASTAVENI;
|
franta-hg@11
|
50 |
$konec = getMicrotime();
|
franta-hg@11
|
51 |
html('<!--');
|
franta-hg@11
|
52 |
html('Stránka: ' . $_SERVER['REQUEST_URI']);
|
franta-hg@11
|
53 |
html('Klient: ' . $_SERVER['REMOTE_ADDR']);
|
franta-hg@11
|
54 |
html('MIME: ' . $mimeTyp);
|
franta-hg@11
|
55 |
html("Začátek zpracování: $zacatek");
|
franta-hg@11
|
56 |
html("Konec zpracování: $konec");
|
franta-hg@13
|
57 |
html('Doba zpracování: ' . ($konec - $zacatek) . 's');
|
franta-hg@13
|
58 |
html('Není potřeba hackovat, zdrojáky jsou k dispozici ;-)');
|
franta-hg@13
|
59 |
html('http://hg.vps.frantovo.cz/veverka.ch/');
|
franta-hg@11
|
60 |
html('-->');
|
franta-hg@3
|
61 |
}
|
franta-hg@3
|
62 |
|
franta-hg@3
|
63 |
function htmlOdstavec($text) {
|
franta-hg@3
|
64 |
html("<p>\n$text\n</p>");
|
franta-hg@3
|
65 |
}
|
franta-hg@3
|
66 |
|
franta-hg@3
|
67 |
function html($text) {
|
franta-hg@3
|
68 |
global $stranka;
|
franta-hg@3
|
69 |
/** Odstraníme odkazy, které vedou na tutéž stránku */
|
franta-hg@3
|
70 |
$text = str_replace(' href="' . $stranka . '"', '', $text);
|
franta-hg@3
|
71 |
|
franta-hg@3
|
72 |
echo("$text\n");
|
franta-hg@3
|
73 |
}
|
franta-hg@3
|
74 |
|
franta-hg@3
|
75 |
function htmlZnacka($znacka, $text) {
|
franta-hg@3
|
76 |
html("<$znacka>$text</$znacka>");
|
franta-hg@3
|
77 |
}
|
franta-hg@3
|
78 |
|
franta-hg@3
|
79 |
function htmlTlacitkovyOdkaz($url, $text) {
|
franta-hg@3
|
80 |
html('<form action="' . $url . '"><fieldset><button>' . $text . '</button></fieldset></form>');
|
franta-hg@3
|
81 |
}
|
franta-hg@3
|
82 |
|
franta-hg@3
|
83 |
function sqlZjistiHodnotu($dotaz, $parametry = null) {
|
franta-hg@3
|
84 |
global $db;
|
franta-hg@3
|
85 |
|
franta-hg@3
|
86 |
$dotaz = $db->prepare($dotaz);
|
franta-hg@3
|
87 |
|
franta-hg@3
|
88 |
if ($parametry != null) {
|
franta-hg@3
|
89 |
for($i = 0; $i < count($parametry); $i++) {
|
franta-hg@3
|
90 |
$dotaz->bindParam($i+1, $parametry[$i]);
|
franta-hg@3
|
91 |
}
|
franta-hg@3
|
92 |
}
|
franta-hg@3
|
93 |
|
franta-hg@3
|
94 |
$dotaz->execute();
|
franta-hg@3
|
95 |
$r = $dotaz->fetchAll();
|
franta-hg@3
|
96 |
|
franta-hg@3
|
97 |
foreach ($r as $x) {
|
franta-hg@3
|
98 |
return $x[0];
|
franta-hg@3
|
99 |
}
|
franta-hg@3
|
100 |
return null;
|
franta-hg@3
|
101 |
}
|
franta-hg@3
|
102 |
|
franta-hg@15
|
103 |
function sqlDotaz($dotaz, $parametry = null) {
|
franta-hg@15
|
104 |
global $db;
|
franta-hg@15
|
105 |
try {
|
franta-hg@15
|
106 |
$dotaz = $db->prepare($dotaz);
|
franta-hg@15
|
107 |
|
franta-hg@15
|
108 |
if ($parametry != null) {
|
franta-hg@15
|
109 |
for($i = 0; $i < count($parametry); $i++) {
|
franta-hg@15
|
110 |
$dotaz->bindParam($i+1, $parametry[$i]);
|
franta-hg@15
|
111 |
}
|
franta-hg@15
|
112 |
}
|
franta-hg@15
|
113 |
|
franta-hg@15
|
114 |
$dotaz->execute();
|
franta-hg@15
|
115 |
$r = $dotaz->fetchAll();
|
franta-hg@15
|
116 |
|
franta-hg@15
|
117 |
return $r;
|
franta-hg@15
|
118 |
} catch (PDOException $e) {
|
franta-hg@15
|
119 |
logujChybu("sqlDotaz($dotaz)");
|
franta-hg@15
|
120 |
}
|
franta-hg@15
|
121 |
}
|
franta-hg@15
|
122 |
|
franta-hg@15
|
123 |
function echoClanek($id, $nadpis = 'h2') {
|
franta-hg@15
|
124 |
$r = sqlDotaz("SELECT * FROM clanek WHERE id = ?", $id);
|
franta-hg@15
|
125 |
foreach ($r as $x) {
|
franta-hg@15
|
126 |
htmlZnacka($nadpis, $x['nadpis']);
|
franta-hg@15
|
127 |
echo($x['text']);
|
franta-hg@15
|
128 |
}
|
franta-hg@15
|
129 |
}
|
franta-hg@15
|
130 |
|
franta-hg@3
|
131 |
function getMicrotime(){
|
franta-hg@3
|
132 |
list($usec, $sec) = explode(" ",microtime());
|
franta-hg@3
|
133 |
return ((float)$usec + (float)$sec);
|
franta-hg@3
|
134 |
}
|
franta-hg@3
|
135 |
|
franta-hg@3
|
136 |
function logujChybu($popis, $chyba = null) {
|
franta-hg@3
|
137 |
htmlOdstavec($popis);
|
franta-hg@3
|
138 |
}
|
franta-hg@3
|
139 |
|
franta-hg@3
|
140 |
?>
|