%PDF- %PDF-
Direktori : /home/nailstv/public_html/ |
Current File : /home/nailstv/public_html/registration.php |
<?php require_once 'config/config.php'; //Registry::set('debug', true); $p['title'] = 'Nails Tv registration'; $p['desc'] = 'Registration to the surface of Nails.tv. The use of favourites and voting.'; $p['keywords'] = 'nails, nail artist, nail technician, Registration'; $p['pagename'] = 'Registration'; if (!empty($_SESSION[Registry::get('site')]['user_id'])) { $p['active'] = 'Adatmódosítás'; } else { $p['active'] = 'Regisztráció'; } $page = new Page(Registry::get('site'), false, $p); Registry::set('page', $page); $page->assign('content', content()); $page->display('page.tpl.html'); //////////////////////////////////////////////////////////////////////////////// function content() { //Registry::get('page')->assign('crop_img', 1); $db = Registry::get('db'); $c = new Content(); $v = new Inputvalidator; $c->assign('jobb_banner', Page::banner(2,'jobb')); $c->assign('top_cimkek', top_cimkek()); Page::seoFromDb(2); $table = 'felhasznalo'; if(isset($_SESSION['reg_ok']) && $_SESSION['reg_ok']) { $_SESSION['reg_ok'] = false; $c->assign('cim', 'Registration'); $c->assign('msg', 'Succesfull registration'); return $c->fetch('regisztracio.tpl.html'); } if($_POST && isset($_POST['func']) && $_POST['func'] == 'reg') { $rec = validate($_POST, $v); if($v->isError) { $c->assign('reg_error', $v->printError()); $c->assign('edit', $rec); } else { if(empty($_POST['id'])) { $rec['id'] = $db->GenID('_felhasznalo_id'); $rec['last_ip'] = $_SERVER['REMOTE_ADDR']; $db->insert($rec, $table); sendAdminMail($rec); if($rec['hirlevel'] == 't'){ $hl['datum'] = date("Y-m-d H:i:s"); $hl['nev'] = $rec['nev']; $hl['email'] = $rec['email']; $db->insert($hl, 'hirlevel_cimek'); } //User::pont($rec['id'], 1); if($rec['tipus'] == 'mukormos') { User::pont($rec['id'], 2); } if(!empty($rec['meghivo']) && $rec['tipus'] == 'mukormos'){ $bind = $rec['meghivo']; $sql = "SELECT id FROM felhasznalo WHERE email = ? AND storno = 'f'"; $hivo = $db->GetRow($sql, $bind); $sql = "select COUNT(id) AS num from felhasznalo where email = '". $rec['email'] ."'"; $volt_mar_regisztralva = $db->GetRow($sql); } $user = new User(Registry::get('site'), 'felhasznalo'); $user->checkLogin($rec['login'], $rec['not_crypted_pass'], 'login'); $ma = date("Y-m-d H:i:s"); $bind = array($ma, $rec['id']); $sql = "UPDATE felhasznalo SET last_login = ? WHERE id = ?"; $db->query($sql, $bind); $_SESSION['reg_ok'] = true; sendRegMail($rec); } else { $db->update($rec, $table); if($rec['hirlevel'] == 'f'){ $sql = "UPDATE hirlevel_cimek SET storno = 't' WHERE email = '" . $rec['email'] . "'"; $db->execute($sql); $sql = "DELETE FROM hirlevel_cimek WHERE email = '" . $rec['email'] . "'"; $db->execute($sql); } else { $hl['datum'] = date("Y-m-d H:i:s"); $hl['nev'] = $rec['nev']; $hl['email'] = $rec['email']; $db->insert($hl, 'hirlevel_cimek'); $sql = "UPDATE felhasznalo SET hirlevel = 't' WHERE id = '" . $_SESSION[Registry::get('site')]['user_id'] . "'"; $db->execute($sql); } } header('Location: ' . Registry::get('wwwroot'). '/registration'); die; } } if(!empty($_SESSION[Registry::get('site')]['user_id'])) { $c->assign('cim', 'Update profile'); } else { $c->assign('cim', 'Registration'); } if(!empty($_SESSION[Registry::get('site')]['user_id']) && empty($edit)) { $sql = "SELECT * FROM felhasznalo WHERE id = ?"; $edit = $db->GetRow($sql, array($_SESSION[Registry::get('site')]['user_id'])); $c->assign('edit', $edit); } return $c->fetch('regisztracio.tpl.html'); } function validate($rec, $v) { $db = Registry::get('db'); $l = Registry::get('lang'); // teljes név $msg = array('Full name is required.'); $rec['nev'] = $v->v($rec['nev'], 'required, stripHtml', $msg); // login $msg = array('Username is required.'); $rec['login'] = $v->v($rec['login'], 'required, stripHtml', $msg); if(!preg_match("/^[a-z0-9A-Z]{3,30}$/", $rec['login'])) { $v->addError('The username can contain only letters from the English alphabet, and it must be at least 3 and at last 10 characters long.'); } $sql = "SELECT id FROM felhasznalo WHERE login = ? AND storno = 'f'"; $bind = array($rec['login']); if(!empty($rec['id'])) { $sql .= " AND id != ?"; $bind[] = $rec['id']; } $row = $db->GetRow($sql, $bind); if(!empty($row['id'])) { $v->addError('This username is already taken, please choose another one.'); } // jelszó if(!empty($rec['pass']) && $rec['pass'] != $rec['pass2']) { $v->addError('The given two passwords do not matc.'); } else if(empty($rec['id']) && empty($rec['pass'])) { $v->addError('Jelszót közelező megadni.'); } else if(!empty($rec['pass'])) { $rec['not_crypted_pass'] = $rec['pass']; $rec['pass'] = String::cryptPass($rec['pass']); } else { unset($rec['pass']); } // email $msg = array('E-mail address is required.', 'Incorrect e-mail format.'); $rec['email'] = $v->v($rec['email'], 'required, email', $msg); $sql = "SELECT id FROM felhasznalo WHERE email = ? AND storno = 'f'"; $bind = array($rec['email']); if(!empty($rec['id'])) { $sql .= " AND id != ?"; $bind[] = $rec['id']; } $row = $db->GetRow($sql, $bind); if(!empty($row['id'])) { $v->addError('This e-mail address is already taken, please choose another one, or use our <a href=http://www.nails.tv/password_reminder><u>password reminder</u></a>.'); } $rec['hirlevel'] = 't'; if(!isset($_POST['tizenhat']) && empty($rec['id'])) { $v->addError('To register to Nails.tv you must be at least 16 years old. You have to state that you are over 16.'); } else { $rec['tizenhat'] = 't'; } if(!isset($_POST['elfogad']) && empty($rec['id'])) { $v->addError('You have to accept the general terms of use.'); } else { $rec['elfogad'] = 't'; } $rec['reg_date'] = date("Y-m-d H:i:s"); return $rec; } function sendRegMail($rec) { $c = new Content; $c->assign('rec', $rec); $mail = new PHPMailer(); $mail->CharSet = "utf-8"; /*$mail->IsSMTP(); $mail->Host = Registry::get('smtp_host'); $mail->SMTPAuth = true; $mail->Username = Registry::get('smtp_user'); $mail->Password = Registry::get('smtp_pass');*/ $mail->Subject = 'Sikeres regisztráció'; $mail->From = Registry::get('email'); $mail->FromName = Registry::get('from'); $mail->Body = $c->fetch('mail_regisztracio.tpl.html'); $mail->AddAddress($rec['email']); if(!$mail->Send()) { echo "A levél nem került elküldésre"; echo "A felmerült hiba: " . $mail->ErrorInfo; exit; } } function sendAdminMail($rec) { $db = Registry::get('db'); $c = new Content; $ip = $_SERVER['REMOTE_ADDR']; $email['subject'] = $ip . ' - Regisztráció a mukorom.tv-n - '. $rec['nev']; $email['from'] = Registry::get('email'); $email['fromname'] = Registry::get('from'); $email['to'] = Registry::get('email'); $c->assign('rec', $rec); $email['body'] = $c->fetch('admin/mail_admin_reg.tpl.html'); Page::sendEmail($email); } function top_cimkek() { $db = Registry::get('db'); $sql = "SELECT COUNT(ctv.id) as videoszam, c.nev, c.url, c.id FROM cimke_to_video ctv LEFT JOIN video v ON v.id = ctv.video_id LEFT JOIN cimkek c ON c.id = ctv.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' GROUP BY ctv.cimkek_id ORDER BY videoszam DESC LIMIT 0,10"; $top = $db->GetArray($sql); return $top; } ?>