author | Dan Fuhry <dan@fuhry.us> |
Fri, 11 Jan 2013 05:41:41 -0500 | |
changeset 4 | 2212b2ded8bf |
parent 3 | a044870a9d3d |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
||
3 |
function display_template($tpl, $assign = array()) |
|
4 |
{ |
|
5 |
$smarty = new Smarty(); |
|
6 |
||
7 |
$smarty->setTemplateDir(ACCOUNTS . 'includes/templates/'); |
|
8 |
$smarty->setCompileDir(ACCOUNTS . 'includes/templates/compiled/'); |
|
9 |
$smarty->setConfigDir(ACCOUNTS . 'includes/templates/'); |
|
10 |
$smarty->setCacheDir(ACCOUNTS . 'includes/templates/cache/'); |
|
11 |
||
12 |
$smarty->assign('session', $_SESSION); |
|
13 |
||
14 |
$smarty->assign('user', isset($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] : false); |
|
15 |
if ( isset($_SERVER['REMOTE_USER']) ) |
|
16 |
$smarty->assign('userinfo', $ui = ldap_get_user($_SERVER['REMOTE_USER'])); |
|
17 |
||
3 | 18 |
$smarty->assign('is_admin', IS_ADMIN); |
19 |
||
0 | 20 |
if ( $ui === false ) |
21 |
redirect('/logout'); |
|
22 |
||
23 |
$smarty->assign('msgcodes', array( |
|
24 |
'error' => E_ERROR |
|
25 |
, 'warning' => E_WARNING |
|
26 |
, 'notice' => E_NOTICE |
|
27 |
)); |
|
28 |
||
4
2212b2ded8bf
Added OpenSSH public key support in LDAP
Dan Fuhry <dan@fuhry.us>
parents:
3
diff
changeset
|
29 |
global $ssh_key_lengths; |
2212b2ded8bf
Added OpenSSH public key support in LDAP
Dan Fuhry <dan@fuhry.us>
parents:
3
diff
changeset
|
30 |
$smarty->assign('ssh_key_lengths', $ssh_key_lengths); |
2212b2ded8bf
Added OpenSSH public key support in LDAP
Dan Fuhry <dan@fuhry.us>
parents:
3
diff
changeset
|
31 |
|
0 | 32 |
foreach ( $assign as $key => $value ) |
33 |
{ |
|
34 |
$smarty->assign($key, $value); |
|
35 |
} |
|
36 |
||
37 |
$smarty->display("$tpl.tpl"); |
|
38 |
} |
|
39 |
||
40 |
function parse_template($tpl, $assign = array()) |
|
41 |
{ |
|
42 |
$smarty = new Smarty(); |
|
43 |
||
44 |
$smarty->setTemplateDir(ACCOUNTS . 'includes/templates/'); |
|
45 |
$smarty->setCompileDir(ACCOUNTS . 'includes/templates/compiled/'); |
|
46 |
$smarty->setConfigDir(ACCOUNTS . 'includes/templates/'); |
|
47 |
$smarty->setCacheDir(ACCOUNTS . 'includes/templates/cache/'); |
|
48 |
||
49 |
foreach ( $assign as $key => $value ) |
|
50 |
{ |
|
51 |
$smarty->assign($key, $value); |
|
52 |
} |
|
53 |
||
54 |
return $smarty->fetch("$tpl.tpl"); |
|
55 |
} |
|
56 |
||
57 |
function smarty_function_clear_messages($params) |
|
58 |
{ |
|
59 |
$_SESSION['messages'] = array(); |
|
60 |
} |