示例#1
0
<?php

function __autoload($class_name)
{
    require_once $class_name . ".php";
}
error_reporting(0);
$u = null;
try {
    $u = new user();
} catch (Exception $e) {
    header("Location: login.php");
}
$tpl = new Templates('templates');
$tpl->set('home', 'user', $u->get_login());
$tpl->set('main', 'body', $tpl->parse('home'));
print $tpl->parse('main');
示例#2
0
        $cs = "";
        foreach ($snapshot->contacts as $c) {
            $tpl->set('contact', array('id' => $c['id'], 'name' => $c['name'], 'email' => $c['email']));
            $cs = $cs . $tpl->parse('contact');
        }
        $tpl->set('contacts', 'list', $cs);
        $tpl->set('main', 'content', $tpl->parse('contacts'));
        print $tpl->parse('main');
        break;
    case 'enter':
        $u = $_POST['user'];
        $p = $_POST['pass'];
        $gm->setLoginInfo($u, $p, 1.0);
        if ($gm->connect()) {
            $gm->saveCookieToBrowser();
            header("Location: ?mode=list");
        } else {
            die("f**k");
            header("Location: ?");
        }
        break;
    case 'logout':
        $gm->removeCookieFromBrowser();
        header("Location: ?");
        break;
    default:
        $tpl = new Templates('tpls');
        $tpl->set('main', 'content', $tpl->parse('login'));
        print $tpl->parse('main');
        break;
}
示例#3
0
            if ($pm == '' or $pc == '') {
                throw new Exception('Żadne z podanych haseł nie może być puste.');
            }
            if ($pm != $pc) {
                throw new Exception('Podane hasła nie są jednakowe.');
            }
            $u = new user($l, $pm, true);
            header("Location: ?");
        } catch (Exception $e) {
            $tpl = new Templates('templates');
            $tpl->set('error', 'message', $e->getMessage());
            print $tpl->parse('error');
            exit;
        }
        break;
    case 'logout':
        session_start();
        unset($_SESSION['user']);
        session_destroy();
        header("Location: index.php");
        break;
    default:
        $tpl = new Templates('templates');
        $page = $tpl->parse('login');
        $tpl->set('main', 'body', $page);
        print $tpl->parse('main');
        break;
}
?>