Created
June 1, 2012 10:37
-
-
Save bastianallgeier/2851074 to your computer and use it in GitHub Desktop.
Put paneluser.php in site/plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
s::start(); | |
function panelUser() { | |
$cookie = cookie::get('auth'); | |
if(!$cookie) return false; | |
$info = s::get($cookie); | |
if(!$info) return false; | |
$file = c::get('root.site') . '/panel/accounts/' . a::get($info, 'username') . '.php'; | |
// check for an existing user account file | |
if(!file_exists($file)) return false; | |
$content = f::read($file); | |
$content = str_replace('<?php if(!defined(\'KIRBY\')) exit ?>', '', $content); | |
$user = yaml($content); | |
unset($user['password']); | |
return $user; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = panelUser(); | |
if($user) { | |
// the user is logged in | |
echo 'hello ' . $user['username']; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment