compile_check = true; function utf2win($s) { $s = preg_replace('#[^\x00-\x7F\xa0\xa4\xa6-\xa9\xab-\xae\xb0\xb1\xb4-\xb8\xbb\xc1\xc2\xc4\xc7\xc9\xcb\xcd\xce\xd3\xd4\xd6\xd7\xda\xdc\xdd\xdf\xe1\xe2\xe4\xe7\xe9\xeb\xed\xee\xf3\xf4\xf6\xf7\xfa\xfc\xfd\x{102}-\x{107}\x{10c}-\x{111}\x{118}-\x{11b}\x{139}\x{13a}\x{13d}\x{13e}\x{141}-\x{144}\x{147}\x{148}\x{150}\x{151}\x{154}\x{155}\x{158}-\x{15b}\x{15e}-\x{165}\x{16e}-\x{171}\x{179}-\x{17e}\x{2c7}\x{2d8}\x{2d9}\x{2db}\x{2dd}\x{2013}\x{2014}\x{2018}-\x{201a}\x{201c}-\x{201e}\x{2020}-\x{2022}\x{2026}\x{2030}\x{2039}\x{203a}\x{20ac}\x{2122}]#u', '', $s); static $tbl = array("\xe2\x82\xac"=>"\x80","\xe2\x80\x9a"=>"\x82","\xe2\x80\x9e"=>"\x84","\xe2\x80\xa6"=>"\x85","\xe2\x80\xa0"=>"\x86","\xe2\x80\xa1"=>"\x87","\xe2\x80\xb0"=>"\x89","\xc5\xa0"=>"\x8a","\xe2\x80\xb9"=>"\x8b","\xc5\x9a"=>"\x8c","\xc5\xa4"=>"\x8d","\xc5\xbd"=>"\x8e","\xc5\xb9"=>"\x8f","\xe2\x80\x98"=>"\x91","\xe2\x80\x99"=>"\x92","\xe2\x80\x9c"=>"\x93","\xe2\x80\x9d"=>"\x94","\xe2\x80\xa2"=>"\x95","\xe2\x80\x93"=>"\x96","\xe2\x80\x94"=>"\x97","\xe2\x84\xa2"=>"\x99","\xc5\xa1"=>"\x9a","\xe2\x80\xba"=>"\x9b","\xc5\x9b"=>"\x9c","\xc5\xa5"=>"\x9d","\xc5\xbe"=>"\x9e","\xc5\xba"=>"\x9f","\xc2\xa0"=>"\xa0","\xcb\x87"=>"\xa1","\xcb\x98"=>"\xa2","\xc5\x81"=>"\xa3","\xc2\xa4"=>"\xa4","\xc4\x84"=>"\xa5","\xc2\xa6"=>"\xa6","\xc2\xa7"=>"\xa7","\xc2\xa8"=>"\xa8","\xc2\xa9"=>"\xa9","\xc5\x9e"=>"\xaa","\xc2\xab"=>"\xab","\xc2\xac"=>"\xac","\xc2\xad"=>"\xad","\xc2\xae"=>"\xae","\xc5\xbb"=>"\xaf","\xc2\xb0"=>"\xb0","\xc2\xb1"=>"\xb1","\xcb\x9b"=>"\xb2","\xc5\x82"=>"\xb3","\xc2\xb4"=>"\xb4","\xc2\xb5"=>"\xb5","\xc2\xb6"=>"\xb6","\xc2\xb7"=>"\xb7","\xc2\xb8"=>"\xb8","\xc4\x85"=>"\xb9","\xc5\x9f"=>"\xba","\xc2\xbb"=>"\xbb","\xc4\xbd"=>"\xbc","\xcb\x9d"=>"\xbd","\xc4\xbe"=>"\xbe","\xc5\xbc"=>"\xbf","\xc5\x94"=>"\xc0","\xc3\x81"=>"\xc1","\xc3\x82"=>"\xc2","\xc4\x82"=>"\xc3","\xc3\x84"=>"\xc4","\xc4\xb9"=>"\xc5","\xc4\x86"=>"\xc6","\xc3\x87"=>"\xc7","\xc4\x8c"=>"\xc8","\xc3\x89"=>"\xc9","\xc4\x98"=>"\xca","\xc3\x8b"=>"\xcb","\xc4\x9a"=>"\xcc","\xc3\x8d"=>"\xcd","\xc3\x8e"=>"\xce","\xc4\x8e"=>"\xcf","\xc4\x90"=>"\xd0","\xc5\x83"=>"\xd1","\xc5\x87"=>"\xd2","\xc3\x93"=>"\xd3","\xc3\x94"=>"\xd4","\xc5\x90"=>"\xd5","\xc3\x96"=>"\xd6","\xc3\x97"=>"\xd7","\xc5\x98"=>"\xd8","\xc5\xae"=>"\xd9","\xc3\x9a"=>"\xda","\xc5\xb0"=>"\xdb","\xc3\x9c"=>"\xdc","\xc3\x9d"=>"\xdd","\xc5\xa2"=>"\xde","\xc3\x9f"=>"\xdf","\xc5\x95"=>"\xe0","\xc3\xa1"=>"\xe1","\xc3\xa2"=>"\xe2","\xc4\x83"=>"\xe3","\xc3\xa4"=>"\xe4","\xc4\xba"=>"\xe5","\xc4\x87"=>"\xe6","\xc3\xa7"=>"\xe7","\xc4\x8d"=>"\xe8","\xc3\xa9"=>"\xe9","\xc4\x99"=>"\xea","\xc3\xab"=>"\xeb","\xc4\x9b"=>"\xec","\xc3\xad"=>"\xed","\xc3\xae"=>"\xee","\xc4\x8f"=>"\xef","\xc4\x91"=>"\xf0","\xc5\x84"=>"\xf1","\xc5\x88"=>"\xf2","\xc3\xb3"=>"\xf3","\xc3\xb4"=>"\xf4","\xc5\x91"=>"\xf5","\xc3\xb6"=>"\xf6","\xc3\xb7"=>"\xf7","\xc5\x99"=>"\xf8","\xc5\xaf"=>"\xf9","\xc3\xba"=>"\xfa","\xc5\xb1"=>"\xfb","\xc3\xbc"=>"\xfc","\xc3\xbd"=>"\xfd","\xc5\xa3"=>"\xfe","\xcb\x99"=>"\xff"); return strtr($s, $tbl); } function iso2ascii($text) { return StrTr($text, "\xC1\xC8\xCF\xC9\xCC\xCD\xD2\xD3\xD8\xA9\xAB\xDA\xD9\xDD\xAE\xE1\xE8\xEF\xE9\xEC\xED\xF2\xF3\xF8\xB9\xBB\xFA\xF9\xFD\xBE", "\x41\x43\x44\x45\x45\x49\x4E\x4F\x52\x53\x54\x55\x55\x59\x5A\x61\x63\x64\x65\x65\x69\x6E\x6F\x72\x73\x74\x75\x75\x79\x7A" ); } function iso2win($text) { return StrTr($text, "\xA9\xAB\xAE\xB9\xBB\xBE\xA5\xB5", "\x8A\x8D\x8E\x9A\x9D\x9E\xBC\xBE" ); } function win2iso($text) { return StrTr($text, "\x8A\x8D\x8E\x9A\x9D\x9E\xBC\xBE", "\xA9\xAB\xAE\xB9\xBB\xBE\xA5\xB5" ); } function win2ascii($text) { return iso2ascii(win2iso($text)); } if(isset($_GET['article_id']) && $_GET['article_id']) { $article_id = explode('/', $_GET['article_id']); $article_id = intval($article_id[1]); $q = "select article.id, article.topic, article.vytah, article.datum, authors.full_name, article.text from article, authors where article.author = authors.id and article.family in (1,2) and article.id={$article_id} order by datum"; $rs = $conn->execute($q); if($rs !== false) { /*if($rs->fields[4] == 'Marek Fábry') { $rs->fields[4] = 'Marek Fábry'; }*/ $rs->fields[5] = str_replace('art/', '/art/', $rs->fields[5]); $article_data = array('id'=>$rs->fields[0], 'title'=>($rs->fields[1]), 'vytah'=>($rs->fields[2]), 'date'=>date("d.m.Y H:i", $rs->fields[3]), 'date_dm'=>date("d.m", $rs->fields[3]), 'date_y'=>date("Y", $rs->fields[3]), 'text'=>($rs->fields[5]), 'author'=>$rs->fields[4]); $rs->close(); $smarty->assign('article', $article_data); $smarty->assign('article_url', urlencode('http://www.dm-museo.cz'.$_SERVER['REQUEST_URI'])); $smarty->display('article.tpl'); } } else { if(isset($_POST['search_query']) && $_POST['search_query']) { $q = "select article.id, article.topic, article.vytah, article.datum, authors.full_name from article, authors where unconfirmed = 0 and article.author = authors.id and article.family in (1,2) and (lower(concat(article.vytah, article.text)) like ".$conn->qstr('%'.strtolower($_POST['search_query']).'%').") order by datum"; $smarty->assign('search_query', htmlspecialchars($_POST['search_query'])); } else { $q = "select article.id, article.topic, article.vytah, article.datum, authors.full_name from article, authors where unconfirmed = 0 and article.author = authors.id and article.family in (1,2) order by datum"; } $rs = $conn->execute($q); if($rs !== false) { //$article_data = array(); $article_cnt = $ad_cnt = 0; while(!$rs->EOF) { $url = win2ascii($rs->fields[1]); $url = strip_tags($url); $url = trim(str_replace(".", ' ', $url)); $url = trim(str_replace("/", ' ', $url)); $url = trim(str_replace(">", ' ', $url)); $url = trim(str_replace("<", ' ', $url)); $url = str_replace("'", '', $url); $url = str_replace("+", '', $url); $url = str_replace("(", '', $url); $url = str_replace(")", '', $url); $url = str_replace("!", '', $url); $url = str_replace("&", '', $url); $url = str_replace(":", '', $url); $url = str_replace("*", '', $url); $url = str_replace("?", '', $url); $url = str_replace(",", '', $url); $url = str_replace('"', '', $url); $url = str_replace(' ', '-', trim($url)); $url = str_replace('--', '-', $url); $url = str_replace('--', '-', $url); $url = str_replace('--', '-', $url); $url = str_replace('--', '-', $url); $url = strtolower($url); $url .= "/".$rs->fields[0]; $article_cnt++; if($article_cnt >= 30 && $ad_cnt < 4) { $ad = 1; $article_cnt = 0; $ad_cnt++; } else { $ad = 0; } $article_data[] = array('id'=>$rs->fields[0], 'ad'=>$ad, 'title'=>($rs->fields[1]), 'vytah'=>($rs->fields[2]), 'date'=>date("d.m.y", $rs->fields[3]), 'date_dm'=>date("d.m", $rs->fields[3]), 'date_y'=>date("Y", $rs->fields[3]), 'author'=>$rs->fields[4], 'url'=>$url); $rs->movenext(); } $rs->close(); $smarty->assign('article_data', $article_data); $smarty->assign('articles_total', sizeof($article_data)); $smarty->display('index.tpl'); } } ?>