%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/nailstv/public_html/es.nails.tv/
Upload File :
Create Path :
Current File : /home/nailstv/public_html/es.nails.tv/contrasena.php

<?php

require_once 'config/config.php';

$p['title'] = 'Nails Tv forgotten password';
$p['desc'] = 'If you have forgotten your password, please give your e-mail address you have used during the registration to Nails.tv.';
$p['keywords'] = 'forgotten password, nail, nail technician, nail artist';
$p['pagename'] = 'Forgotten password';

$page = new Page(Registry::get('site'), false, $p);
Registry::set('page', $page);
$page->assign('content', jelszo());
$page->display('page.tpl.html');

////////////////////////////////////////////////////////////////////////////////

function jelszo()
{

    $db = Registry::get('db');
    $c = new Content();
    $v = new Inputvalidator;
    $l = Registry::get('lang');

    $c->assign('jobb_banner', Page::banner(2,'jobb'));

    Page::seoFromDb(4);

    $table = 'felhasznalo';

    if(isset($_SESSION['send_ok']) && $_SESSION['send_ok'])
    {
        $_SESSION['send_ok'] = false;
        $c->assign('msg', 'Az új jelszót a megadott e-mail címre elküldtük.');
        return $c->fetch('jelszo.tpl.html');
    }

    if($_POST && isset($_POST['func']) && $_POST['func'] == 'jelszo')
    {
        $rec = validate($_POST, $v);

        if($v->isError)
        {
            $c->assign('error', $v->printError());
            $c->assign('edit', $rec);
        }
        else
        {
            sendPass($rec);
            $_SESSION['send_ok'] = 1;
            header("Location: " . Registry::get(wwwroot) . '/jelszo');
            die;
        }
    }

    return $c->fetch('jelszo.tpl.html');
}

function validate($rec, $v)
{
    $db = Registry::get('db');
    $l = Registry::get('lang');

    // email
    $msg = array('E-mail address is required.', 'Incorrect e-mail address.');
    $rec['email'] = $v->v($rec['email'], 'required, email', $msg);

    $sql = "SELECT id, email
            FROM felhasznalo
            WHERE email = ?
                AND storno = 'f'";
    $row = $db->GetRow($sql, array($rec['email']));

    if(empty($row['id']) && !$v->isError) {
        $v->addError('This e-mail address is not in the database.');
    }
    else {
        $rec['id'] = $row['id'];
    }

    return $rec;
}

function sendPass($rec)
{
    $db = Registry::get('db');
    $c = new Content;

    $pass = random_pass(6);
    $bind = array(String2::cryptPass($pass), $rec['id']);
    $sql = "UPDATE felhasznalo SET pass=? WHERE id=?";
    $db->query($sql, $bind);

    $bind = array($rec['id']);
    $sql = "SELECT id, nev, login, email
			FROM felhasznalo
			WHERE id = ?";
    $row = $db->GetRow($sql, $bind);
    $row['pass'] = $pass;

    $c->assign('rec', $row);

    $email['subject'] = Registry::get('sitename') . ' - Elfelejtett jelszó';
    $email['from'] = Registry::get('email');
    $email['fromname'] = Registry::get('from');
    $email['to'] = $row['email'];

    $c->assign('email', $email);

    $email['body'] = $c->fetch('mail_jelszo.tpl.html');

    Page::sendEmail($email);
}

function random_pass($int=4)
{
    $pass="";
    $string="qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM23456789";
    for ($i=0; $i < $int; $i++)
    {
        $pass .= $string[rand(0,59)];
    }
    return $pass;
}

?>

Zerion Mini Shell 1.0