franta-hg@3: getMessage()); franta-hg@3: //header("Location: chyba_db.php"); franta-hg@3: exit(); franta-hg@3: } franta-hg@3: franta-hg@3: set_exception_handler('exception_handler'); franta-hg@3: franta-hg@3: franta-hg@3: if (empty($_SERVER['HTTP_ACCEPT'])) { franta-hg@3: $mimeTyp = 'application/xhtml+xml'; franta-hg@3: } else { franta-hg@3: $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: } franta-hg@3: header("Content-Type: $mimeTyp"); franta-hg@3: franta-hg@3: /** $nadpis = titulek stránky + h1 */ franta-hg@4: function zahlavi($nadpis) { franta-hg@3: global $mimeTyp; franta-hg@3: franta-hg@3: html(' franta-hg@3: franta-hg@3: franta-hg@3: franta-hg@3: franta-hg@3: franta-hg@3: franta-hg@3: franta-hg@3: franta-hg@3: ' . $nadpis . ' franta-hg@3: franta-hg@3: franta-hg@3:

' . $nadpis . '

'); franta-hg@3: } franta-hg@3: franta-hg@4: function zapati() { franta-hg@4: html(''); franta-hg@4: htmlInfoKomentar(); franta-hg@4: html(''); franta-hg@3: } franta-hg@3: franta-hg@3: function htmlInfoKomentar() { franta-hg@3: global $zacatek, $mimeTyp, $NASTAVENI; franta-hg@11: $konec = getMicrotime(); franta-hg@11: html(''); franta-hg@3: } franta-hg@3: franta-hg@3: function htmlOdstavec($text) { franta-hg@3: html("

\n$text\n

"); franta-hg@3: } franta-hg@3: franta-hg@3: function html($text) { franta-hg@3: global $stranka; franta-hg@3: /** Odstraníme odkazy, které vedou na tutéž stránku */ franta-hg@3: $text = str_replace(' href="' . $stranka . '"', '', $text); franta-hg@3: franta-hg@3: echo("$text\n"); franta-hg@3: } franta-hg@3: franta-hg@3: function htmlZnacka($znacka, $text) { franta-hg@3: html("<$znacka>$text"); franta-hg@3: } franta-hg@3: franta-hg@3: function htmlTlacitkovyOdkaz($url, $text) { franta-hg@3: html('
'); franta-hg@3: } franta-hg@3: franta-hg@3: function sqlZjistiHodnotu($dotaz, $parametry = null) { franta-hg@3: global $db; franta-hg@3: franta-hg@3: $dotaz = $db->prepare($dotaz); franta-hg@3: franta-hg@3: if ($parametry != null) { franta-hg@3: for($i = 0; $i < count($parametry); $i++) { franta-hg@3: $dotaz->bindParam($i+1, $parametry[$i]); franta-hg@3: } franta-hg@3: } franta-hg@3: franta-hg@3: $dotaz->execute(); franta-hg@3: $r = $dotaz->fetchAll(); franta-hg@3: franta-hg@3: foreach ($r as $x) { franta-hg@3: return $x[0]; franta-hg@3: } franta-hg@3: return null; franta-hg@3: } franta-hg@3: franta-hg@15: function sqlDotaz($dotaz, $parametry = null) { franta-hg@15: global $db; franta-hg@15: try { franta-hg@15: $dotaz = $db->prepare($dotaz); franta-hg@15: franta-hg@15: if ($parametry != null) { franta-hg@15: for($i = 0; $i < count($parametry); $i++) { franta-hg@15: $dotaz->bindParam($i+1, $parametry[$i]); franta-hg@15: } franta-hg@15: } franta-hg@15: franta-hg@15: $dotaz->execute(); franta-hg@15: $r = $dotaz->fetchAll(); franta-hg@15: franta-hg@15: return $r; franta-hg@15: } catch (PDOException $e) { franta-hg@15: logujChybu("sqlDotaz($dotaz)"); franta-hg@15: } franta-hg@15: } franta-hg@15: franta-hg@15: function echoClanek($id, $nadpis = 'h2') { franta-hg@15: $r = sqlDotaz("SELECT * FROM clanek WHERE id = ?", $id); franta-hg@15: foreach ($r as $x) { franta-hg@15: htmlZnacka($nadpis, $x['nadpis']); franta-hg@15: echo($x['text']); franta-hg@15: } franta-hg@15: } franta-hg@15: franta-hg@3: function getMicrotime(){ franta-hg@3: list($usec, $sec) = explode(" ",microtime()); franta-hg@3: return ((float)$usec + (float)$sec); franta-hg@3: } franta-hg@3: franta-hg@3: function logujChybu($popis, $chyba = null) { franta-hg@3: htmlOdstavec($popis); franta-hg@3: } franta-hg@3: franta-hg@3: ?>