<?php
/* ************************************************************************** *
 *																										*
 * osebne_nastavitve.php v3.1 by Slodave, maj 2008, http://www.zabec.net		*
 * -------- -------- -------- -------- -------- -------- -------- --------		*
 * 																									*
 * Datoteka, kjer se dogaja vse kar se tiče osebnih nastavitev						*
 * ************************************************************************** */

/* Generiranje boxa osebnih nastavitev														*
 * ************************************************************************** */
if ($_POST['action'] == "osebne_nastavitve") {
    $tpl = new TemplatePower($ajax . "templates/" . $settings['template'] . "/osebne_nastavitve.tpl");
    $tpl->prepare();
    $tpl->assignGlobal("template_dir", $ajax . "/templates/" . $settings['template']);

	 // vključimo jezik
    require('../lib_language.php');

    $result = $db->query("SELECT * FROM core_uporabniki WHERE id = '$_SESSION[id]'");
    $r = $result->fetch();
    $tpl->assign("uporabnik", $r['username']);
    $tpl->assign("ime_priimek", $r['ime_priimek']);
    $tpl->assign("num_results", $r['num_results']);

    $tpl->printToScreen();
}

/* Shranjevanje osebnih nastavitev															*
 * ************************************************************************** */
elseif ($_POST['action'] == "osebne_save") {

	 //preverimo spremenljivke
	 $clean['ime_priimek'] = inputXSScheck($_POST['ime_priimek']);
    $clean['num_results'] = intval($_POST['num_results']);
    if ($clean['num_results'] < 1) {
        $clean['num_results'] = 1;
    }
    //preverimo geslo
    if ($_POST['geslo_1'] != "staro_geslo" AND $_POST['geslo_1'] == $_POST['geslo_2']) {
        $clean['geslo'] = md5($_POST['geslo_1']);
        $geslo = ", password = '$clean[geslo]'";
    }

    $db->query("UPDATE core_uporabniki SET ime_priimek = '$clean[ime_priimek]', num_results = '$clean[num_results]'" . $geslo . " WHERE id = '$_SESSION[id]'");
}

?>