\n"; $headers .= "X-Sender: <".$from.">\n"; $headers .= "X-Mailer: PHP\n"; // mailov� klient $headers .= "X-Priority: 1\n"; // Urgentn� vzkaz! mail($to,$subject,$body,$headers); } // funkce pro tvorbu a vyhledavani stringu ----------------------------------------------------- $toasc = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~����������S�STZZ����������s�stzz ��L�A����S����Z���l�����as�L�lzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTSraaaalccceeeeiiddnnoooo�ruuuuyt�"; $addvars['a'] = '�������㥹'; $addvars['c'] = '������'; $addvars['d'] = '����'; $addvars['e'] = '��������'; $addvars['i'] = '����'; $addvars['l'] = '�弾��'; $addvars['n'] = '����'; $addvars['o'] = '��������'; $addvars['r'] = '����'; $addvars['s'] = '�������'; $addvars['t'] = '����'; $addvars['u'] = '��������'; $addvars['y'] = '��'; $addvars['z'] = '������'; function buildSearchPattern($s) { global $toasc, $addvars; $ss = ""; for ($i=0; $i1) $ccc = '['.$ccc.']'; $ss .= $ccc; } return $ss; } // select text from tabylka where text like "%trpacek%" and text not rlike '\<.*trpacek.*\>' function do_and_clause ($table_columns, $str,$tab){ global $and_clause; global $search_words; # $TABLE_COLUMNS = array ($src.".nazev", $src.".cinnost", $src.".vyrobky", $src.".www", $src.".mesto"); $words = split("[ \t\r\n]+", $str); $search_words = array(); $and_clause = array(); foreach ($words as $word) { $or_clause = array(); $search_word = buildSearchPattern($word); $search_words[] = $search_word; foreach ($table_columns as $column) { if($tab=="www"){ $vycet="[0-9a-zA-Z\ \=\'\\\"\%]"; $or_clause[] = "($column RLIKE '".$search_word."') and ".$column." NOT RLIKE '[\\<]".$vycet."*".$search_word.$vycet."*[\\>]'"; } else { $or_clause[] = "($column REGEXP '".$search_word."')"; } } $or_clause = '('.join(" OR ", $or_clause).')'; $and_clause[] = $or_clause; } $and_clause = join(" AND ", $and_clause); return $and_clause; } // ------------------------------------------------------- function odkaz ($zprava) { $znak=66; $slovo = Split("[[:blank:]]+", $zprava); //rozdeleni textu na slova for($y=0;$y\\1 ", $slovo[$y]); elseif (EregI("^(http://.+..)$", $slovo[$y]))://jedna se odkaz typu http://....... $odkaz = EregI_Replace("^(http://.+\..+\..+)$", "\\1 ", $slovo[$y]); else: $odkaz = $slovo[$y] . " "; //jedna se o normalni slovo endif; $celek .= $odkaz; //spojime vsechny slova opet dohromady else: $delit = Ceil(StrLen($slovo[$y])/$znak); //delime dlouhe slovo for($z=0;$z<$delit;$z++): $cast = Substr($slovo[$y], $z*$znak, $znak); $celek .= $cast . " - "; //na konec jednotlivych casti pridame pomlcku endfor; endif; endfor; return $celek; } function id($nazev) {GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; $nazev=str_replace(".cz ",".cz",$nazev); $nazev=str_replace("/","",$nazev); $nazev=str_replace("_"," ",$nazev); //$q3="SELECT * FROM `$obsah_tab` WHERE nazev".$lang." Collate utf8_general_ci='$nazev' OR nazev Collate utf8_general_ci='$nazev'"; $q3="SELECT * FROM `$obsah_tab` WHERE nazev".$lang." Collate utf8_general_ci like '$nazev'"; $vysledek3=mysql_query($q3,$connect); while ($zaznam3 = @mysql_fetch_array($vysledek3)) { $id=$zaznam3["id"]; } if ($id=="") { $nazev=strtolower($nazev); $nazev=str_replace(" ","_",$nazev); $q3="select id,nazev_cz as odkaz_en,nazev".$lang." as odkaz from $obsah_tab"; $vysledek3=mysql_query($q3,$connect); while ($zaznam3 = @mysql_fetch_array($vysledek3)) { if ($zaznam3["odkaz"]=="") { if ($nazev==cistka($zaznam3["odkaz_en"])) $id=$zaznam3["id"]; } else { if ($nazev==cistka($zaznam3["odkaz"])) $id=$zaznam3["id"]; } } } if (!$id) $id=1; return $id; } function nadpis ($id) {GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; $q="select ".vyrobnazev("nazev",$lang)." from $obsah_tab where id='$id'"; $vysledek=mysql_query($q,$connect); while ($zaznam = @mysql_fetch_array($vysledek)) { $obsah_tab_v=$zaznam["nazev"]; } return $obsah_tab_v;} function obsah ($id) {GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; GLOBAL $lng; $q="select ".vyrobnazev("obsah",$lang).",id from $obsah_tab where id='$id'"; $vysledek=mysql_query($q,$connect); while ($zaznam = mysql_fetch_array($vysledek)) { $obsah_tab_v=$zaznam["obsah"]; return str_replace("Arial","Verdana",$obsah_tab_v);; } } function nazev ($id) { GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; $q="select ".vyrobnazev("nazev",$lang)." from $obsah_tab where id='$id'"; $vysledek=mysql_query($q,$connect); while ($zaznam = @mysql_fetch_array($vysledek)) { if (strlen($zaznam["nazev"])<1) {return $zaznam["nazev_en"];} else { return $zaznam["nazev"];} } } function nadpisp ($slovo) { GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; $q="select ".vyrobnazev("nazev",$lang)." from $obsah_tab where nazev='".$slovo."'"; $vysledek=mysql_query($q,$connect); while ($zaznam = @mysql_fetch_array($vysledek)) { return $zaznam["nazev"]; } } /************************************************************* * Vraci prelozeny text. * Pokud je novy, prida ho (bez prekladu) do databaze. * Pokud preklad neexistuje vrati se original. **********************************************************/ function slovnik ($slovo, $verbose=false) { // parametr verbose=true jenom pro autoslovnikator/debug GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; //P�idat pokud neexistuje @extract(@mysql_fetch_array(@mysql_query("select count(*) as pocet from vtc_slovnik where nazev='".slashes($slovo)."' limit 0,1"))); if($pocet==0){ @mysql_query("INSERT INTO vtc_slovnik SET nazev='".slashes($slovo)."';"); if($verbose) echo "".$slovo." p�id�no do slovn�ku.
"; } @extract(@mysql_fetch_array(@mysql_query("select ".vyrobnazev("nazev",$lang)." from vtc_slovnik where nazev='".slashes($slovo)."' limit 0,1"))); if (empty($nazev)) return $slovo; // kdyz neni prelozeno vratime original return $nazev; } function vyrobnazev ($vyber,$lang) { return "IF(".$vyber."".$lang."!='',".$vyber."".$lang.",".$vyber."_cz) as ".$vyber; //select IF(nazev_fr='',nazev_fr,nazev) as nazev from $obsah_tab where id=2 } function cesta ($id) { if ($id==1) return; GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; $i=0; while ($id<>0) { $q="select ". vyrobnazev("nazev",$lang).",id,nadrazeny from $obsah_tab where id='$id';"; $vysledek=@mysql_query($q,$connect); if (mysql_num_rows($vysledek)==0) {break;} while ($zaznam = @mysql_fetch_array($vysledek)) { $obsah_tab=" > " .strip_tags($zaznam["nazev"]) .""; $o[$i]=$obsah_tab; $i++; $id=$zaznam["nadrazeny"]; //if ($nadrazeny==0) {$nadrazeny=$id;} } //if ($nadrazeny==0) {$id=0;break;} } for($j=$i-1;$j>=0;$j--) {$oo.=$o[$j];} return $oo; } function hl_menu ($nad) { GLOBAL $connect; GLOBAL $lang; GLOBAL $obsah_tab; GLOBAL $lng; GLOBAL $id; if (!$nad) $nad=0; $v=" "; } /********************************************************* * Formatovani datumu pro vystup * parametry: int timestamp - default:aktualni **********************************************************/ function datum($timestamp=0) { if($timestamp==0){$timestamp=time();} return date('l dS \o\f F Y h:i:s A', $timestamp); } /********************************************************* * Zkontroluje spravnost (format) emailove adresy * autor: zogulus (?) * zdroj: http://www.phpfreaks.com/quickcode/function_for_email_validation_(best_one)/192.php?topic_id=6426#top * parametry: string emailova_adresa **********************************************************/ function valid_email($address) { // check an email address is possibly valid return preg_match('/^[a-z0-9.+_-]+@([a-z0-9-]+.)+[a-z]+$/i', $address); } /********************************************************* * Vygeneruje n�hodn� heslo * autor: Jon Haworth (upraveno) * zdroj: http://www.laughing-buddha.net/jon/php/password/ * parametry: int minimalni_delka_hesla, [int maximalni_delka] *********************************************************/ function random_pass ($min = 6, $max=10) { $length = mt_rand($min, $max); $password = ""; $possible = "23456789abcdefghjkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ"; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } /********************************************************* * Ochrana proti sql injection * parametry: string *********************************************************/ function slashes($str) { return (get_magic_quotes_gpc() ? $str : addslashes($str)); } /********************************************************* * P�ihla�ovac� funkce * Pouziva se session promenna $_SESSION["logged"] ve ktery je id * logged() - Vrac� FALSE, kdy� neni p�ihl�en, jinak to co se zada jako parametr (def. ID) * parametry: string {id,fullname,email,prava} default:id *********************************************************/ function logged($ret="id"){ if(empty($_SESSION['logged'])){ return false; } /*elseif($_SESSION['logged']['ip']!=$_SERVER['REMOTE_ADDR']){ // odhlasit kdyz se zmenila IP - kradez susenek! .-) logout(); return false; } */else { return $_SESSION['logged'][$ret]; } } function logout(){ unset($_SESSION['logged']); //session_destroy(); header("Location: index.php"); exit; } function login(){ $vysledek=mysql_query("SELECT count(id) as pocet, id, email, jmeno, prijmeni, prava FROM users WHERE email='".slashes($_POST['login_email'])."' and heslo='".md5($_POST['login_heslo'])."' GROUP BY id; "); $row = @mysql_fetch_array($vysledek); if($row['pocet']>1) {die("Fatal error: duplicated login.");} if($row['pocet']==1) { //prihlasit $_SESSION['logged']['id']=$row['id']; $_SESSION['logged']['email']=$row['email']; $_SESSION['logged']['fullname']=$row['jmeno']." ".$row['prijmeni']; $_SESSION['logged']['prava']=$row['prava']; $_SESSION['logged']['ip']=$_SERVER['REMOTE_ADDR']; } else logout(); } /********************************************************* * Vraci string: mailto-odkaz pripadne s nahrazenym zavinacem * parametry: string:e-mail *********************************************************/ function mail_link($mail){ //$mail = str_replace("@","[at]",$mail); return "$mail"; } function admin_menu ($id,$lang,$class) //vytahne nazvy sekc� z db a p�izp�sob� je admin menu { GLOBAL $connect; GLOBAL $obsah_tab; if (!$id) $id = 0; $v=" "; } function uloz ($nadpis, $obsah, $id,$lang) //ulo�en� obsahu do db { GLOBAL $connect; GLOBAL $obsah_tab; $q="update $obsah_tab set nazev$lang='$nadpis', obsah$lang='$obsah' where id=$id;"; return @mysql_query($q,$connect); } function vypis_galerie($adr,$ix) { $adr.=$ix; if ($adr[strlen($adr)-1]!="/") $adr.="/"; if (!is_dir($adr)) return "neplatn� adresa"; $handle2=opendir($adr); while (false!=($file = readdir($handle2))) { if (($file!=".") && ($file!="..") ) { list($width, $height, $type, $attr) = @getimagesize($adr.$file); if ($width>100) { $width=150; $height=150; $image = @exif_thumbnail($adr.$file, $width, $height, $type); //$x.=""; $x.="\n"; } } } closedir($handle2); return $x; } function seznam_galerii($adr) { global $ix; global $connect; if ($adr[strlen($adr)-1]!="/") $adr.="/"; $handle2=opendir($adr); $v="
"; } function seznam_video() { global $ix; $v=""; $q="SELECT * FROM `video` order by poradi"; $res=mysql_query($q); while ($row = mysql_fetch_array($res)) { $file=$row["id"]; $nazev=$row["nazev"]; if ($ix==$file) $c=" style='color:#ED1C24'"; else $c=""; if (!$ix) $ix=$file; $v.="$nazev / "; } return $v.""; } function vypis_akt($pocet, $strip_tags,$param) { GLOBAL $connect; GLOBAL $obsah_tab; if (!$pocet) $pocet=3; $q="SELECT * FROM `aktuality` where zverejnit=1 ORDER BY datum limit 0,$pocet"; $res=mysql_query($q); $w=""; $v=""; while ($row = @mysql_fetch_array($res)) { if ($param[plny]) $w.=" akt4"; $v.="
"; if (!$param[tema]) $v.="

".$row[tema]."

"; if (!$param[datum]) $v.="

".$row[datum]."

"; $v.="
"; $text=$row[popis]; if ($strip_tags) $text=strip_tags($text); $delka=$param[zkratit]; if ($delka>0) {$text=substr($text,0,$delka)."...

>>>

";$w=" akt2";} if (!$param[content]) $v.="

".$text."

"; $v.="
"; } return $v; } function get_time_difference( $start, $end ) { $uts['start'] = strtotime( $start ); $uts['end'] = strtotime( $end ); if( $uts['start']!==-1 && $uts['end']!==-1 ) { if( $uts['end'] >= $uts['start'] ) { $diff = $uts['end'] - $uts['start']; if( $days=intval((floor($diff/86400))) ) $diff = $diff % 86400; if( $hours=intval((floor($diff/3600))) ) $diff = $diff % 3600; if( $minutes=intval((floor($diff/60))) ) $diff = $diff % 60; $diff = intval( $diff ); return( array('days'=>$days, 'hours'=>$hours, 'minutes'=>$minutes, 'seconds'=>$diff) ); } else { //trigger_error( "Ending date/time is earlier than the start date/time", E_USER_WARNING ); } } else { //trigger_error( "Invalid date/time data detected", E_USER_WARNING ); } return( false ); } ?>