„Proti hluposti se bojovat musí, ale vyhrát se nedá!“ Jan Werich
assign('new', true); break; } $filter = ' AND '.$filter; } else { $filter = ' AND pohlavi <> \'new\''; } require_once("paginator.class.php"); $pages = new Paginator(); $pages->items_total = mysql_num_rows(mysql_query("SELECT modelky.id AS id, modelky.jmeno, modelky.vek, modelky.popis, images.id AS iid, images.filename FROM modelky LEFT JOIN images ON (modelky.id = images.mid) WHERE images.filename <> '' $filter GROUP BY modelky.id ORDER BY modelky.buy_up ASC, modelky.id DESC")); $pages->mid_range = 7; $pages->paginate(); $smarty->assign("pages",$pages->display_pages()); $smarty->assign('data',get_db_data_sql("SELECT modelky.id AS id, modelky.jmeno, modelky.vek, modelky.popis, images.id AS iid, images.filename FROM modelky LEFT JOIN images ON (modelky.id = images.mid) WHERE images.filename <> '' $filter GROUP BY modelky.id ORDER BY modelky.buy_up ASC, modelky.id DESC $pages->limit")); $smarty->display('uvod.tpl'); } //zobrazeni registrace function show_registrace() { global $smarty; $smarty->display('registrace.tpl'); } function registration() { unset($error); $data = get_db_data_sql("SELECT id FROM modelky WHERE email='".$_POST['email']."' LIMIT 1"); //kontrola e-mailove adresy if (count($data) == 1) { $error[] = 'E-mailov adresa je ji zaregistrovna.'; } //kontrola delky hesla if (strlen($_POST['password']) < 5) { $error[] = 'Heslo je pli krtk. Minimln dlka je 5 znak'; } //kontrola hesla na preklepy if ($_POST['password'] != $_POST['password_valid']) { $error[] = 'Heslo a heslo pro oven nesouhlas!'; } if (count($error) == 0) { $db = new dbinsert('modelky'); $db->add('password', md5($_POST['password'])); $db->add('pohlavi'); $db->add('jmeno'); $db->add('ulice'); $db->add('psc'); $db->add('obec'); $db->add('email'); $db->add('telefon'); $db->add('miry'); $db->add('vyska'); $db->add('vaha'); $db->add('konf_velikost'); $db->add('oci'); $db->add('vlasy'); $db->add('popis'); $db->add('zajmy'); $db->add('zkusenosti'); $db->add('vek'); $db->insert(); header('location: index.php?a=reg_ok'); } else { $_SESSION['reg_form'] = $_POST; $_SESSION['error'] = $error; header('location: index.php?a=registrace'); } } //Registrace uspesna function registration_ok() { global $smarty; $smarty->display('registration_ok.tpl'); } //login function login() { user_login($_POST['username'], $_POST['password']); header('location: index.php'); } //logout function logout() { user_logout(); header('location: index.php'); } //nastaveni modelky function settings() { global $smarty; $smarty->assign('images', get_db_data_sql("SELECT id,filename FROM images WHERE mid='".$_SESSION['user']['data']['id']."'")); $smarty->display('settings.tpl'); } //Pridat obrazek do galerie modelky function image_add() { //zkontrolovat, zda-li uzivatel muze vlozit dalsi obrazky $u = get_db_data_sql("SELECT count(*) AS pocet FROM images WHERE mid = ".$_SESSION['user']['data']['id']); $pocet = intval($u[0]['pocet']); $count_ok = false; if ( (($_SESSION['user']['data']['buy_photo'] == 'y') && ($pocet < 12)) || ( ($_SESSION['user']['data']['buy_photo'] == 'n') && ($pocet < 4) ) ) { $count_ok = true; } else { $count_ok = false; $_SESSION['error'] = 'Pekraujete limit pro poet fotografi ve fotogalerii.'; header('location: index.php?a=settings'); die(); } //zkontrolovat velikost vkladane fotografie if (filesize($_FILES['image']['tmp_name']) > 1024*1024) { $_SESSION['error'] = 'Vkldan obrzek je vt, ne 1MB, zmenete jej.'; header('location: index.php?a=settings'); die(); } if (eregi('.jpg$', $_FILES['image']['name'])) { $adr = 'images/modelky'; $result = mysql_query("INSERT INTO images(mid,filename) VALUES('".$_SESSION['user']['data']['id']."','".$_FILES['image']['name']."')"); if ($result) { $id = mysql_insert_id(); $ftmp = $_FILES['image']['tmp_name']; $fname = $adr.'/'.$id.'_'.$_FILES['image']['name']; move_uploaded_file($ftmp, $fname); } }else $_SESSION['error'] = 'Obrzek mus bt ve formtu JPG!!'; header('location: index.php?a=settings'); } //Editovat udaje modelky function edit() { global $smarty; $smarty->assign('data', get_db_data_id('modelky', $_SESSION['user']['data']['id'])); $smarty->display('edit.tpl'); } //Provest editaci v DB function editing() { $db = new dbedit('modelky', $_SESSION['user']['data']['id']); $db->edit('pohlavi'); $db->edit('jmeno'); $db->edit('ulice'); $db->edit('psc'); $db->edit('obec'); $db->edit('telefon'); $db->edit('miry'); $db->edit('vyska'); $db->edit('vaha'); $db->edit('konf_velikost'); $db->edit('oci'); $db->edit('vlasy'); $db->edit('popis'); $db->edit('zajmy'); $db->edit('zkusenosti'); $db->edit('vek'); $db->update(); header('location: index.php?a=settings'); } //zrusit galerii function delete() { global $smarty; $smarty->display('zrusit_potvrzeni.tpl'); } //smazat vsechna data - zrusit aktualni ucet function deleting() { $images = get_db_data_sql("SELECT id,filename FROM images WHERE mid='".$_SESSION['user']['data']['id']."'"); for($x = 0; $x < count($images); $x++) { unlink('images/modelky/'.$images[$x]['id'].'_'.$images[$x]['filename']); } mysql_query("DELETE FROM images WHERE mid='".$_SESSION['user']['data']['id']."'"); mysql_query("DELETE FROM modelky WHERE id='".$_SESSION['user']['data']['id']."'"); user_logout(); header('location: index.php'); } //zobrazit detail galerie function detail() { global $smarty; $smarty->assign('data', get_db_data_id('modelky', $_GET['id'])); $smarty->assign('images', get_db_data_sql("SELECT id,filename FROM images WHERE mid='".intval($_GET['id'])."'")); $smarty->display('detail.tpl'); } //zobrazit velky nahled function fullimage() { global $smarty; $smarty->assign('data', get_db_data_id('modelky', $_GET['id'])); $smarty->assign('image', get_db_data_id('images', $_GET['pic'])); $smarty->display('fullimage.tpl'); } //smazat foto z galerie function delete_image() { $id = intval($_GET['id']); $data = get_db_data_id('images', $id); if ($data['mid'] == $_SESSION['user']['data']['id']) { //smazat vygenerovane obrazky $temp = get_db_data_sql("SELECT filename FROM gallery WHERE iid = $id"); for($x = 0; $x < count($temp); $x++) { @unlink('./images/modelky_temp/'.$temp[$x]['filename']); } //smazat hlavni obrazek @unlink('./images/modelky/'.$data['id'].'_'.$data['filename']); mysql_query("DELETE FROM images WHERE id = $id"); mysql_query("DELETE FROM gallery WHERE iid = $id"); }else { //pokus smazat cizi fotku die('nemate dostatecna prava pro odstraneni teto fotografie.'); } header('location: index.php?a=settings'); } //zobrazit prikoupeni function buy() { global $smarty; $accept = array('top', 'up', 'detail', 'photo'); if (!in_array($_GET['what'], $accept)) { header('location: index.php?a=settings'); } $smarty->display('buy_'.$_GET['what'].'.tpl'); } //prikoupit function buying() { global $smarty; require('libs/email/email_message.php'); $accept = array('top', 'up', 'detail', 'photo'); $prices = array(400, 55, 100, 90); if (!in_array($_GET['what'], $accept)) { header('location: index.php?a=settings'); } //ziskat cenu for($x = 0; $x < count($accept); $x++) if ($accept[$x] == $_GET['what']) $price = $prices[$x]; //vlozit pozadavek do db $db = new dbinsert('buy'); $db->add('mid', $_SESSION['user']['data']['id']); $db->add('what' , $_GET['what']); $db->add('price', $price); $db->add('date', 'now()'); $db->insert(); $vs = '111' . $db->lastid(); //odeslat e-mail s informacemi k platbe $smarty->assign('price', $price); $smarty->assign('vs', $vs); $smarty->assign('what', $_GET['what']); $m = new email_message_class(); $m->SetEncodedEmailHeader("To", $_SESSION['user']['data']['email'], $_SESSION['user']['data']['email']); // $m->SetEncodedEmailHeader("To", 'info@quickmoto.cz', 'info@quickmoto.cz'); $m->SetEncodedEmailHeader("From", 'PublicRevelation@email.cz', 'PublicRevelation@email.cz'); // $m->SetEncodedEmailHeader("From", 'info@quickmoto.cz', 'info@quickmoto.cz'); $m->SetHeader("Subject",StrTr('Modelky.com - priobjednavka sluzeb',"\x8A\x8D\x8E\x9A\x9D\x9E","\xA9\xAB\xAE\xB9\xBB\xBE")); $m->AddQuotedPrintableTextPart($smarty->fetch('email_priobjednavka.tpl'),"win-1250"); //odeslat e-mail if (!strcmp($m->Send(),"")) $smarty->display('priobjednavka_ok.tpl'); } function login_spolecnice(){ $jmeno = $_POST['username2']; $heslo = sha1($_POST['password2']); $url = ""; $heslo_z_databaze = mysql_query("SELECT * FROM `heslo`;"); while ($zaznamy = MySQL_Fetch_Array($heslo_z_databaze)) { $hesloDB = $zaznamy['heslo']; } if($heslo == $hesloDB) { $strana = mysql_query("SELECT * FROM `uvodni_strana`;"); while ($zaznamy = MySQL_Fetch_Array($strana)) { $url = $zaznamy['strana']; } $ins = mysql_query("INSERT INTO `ukazse`.`log` (`ID` ,`URL` ,`EMAIL`) VALUES (NULL, '$url', '$jmeno');"); Ob_end_clean(); header("Location: $url"); } else{ Ob_end_clean(); header("Location: $_Server[HTTP_HOST]/str.php?id=101"); } } ?>