Skip to content

Instantly share code, notes, and snippets.

@bugsysop
Forked from bastianallgeier/paneluser.php
Created December 7, 2013 22:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugsysop/7850212 to your computer and use it in GitHub Desktop.
Save bugsysop/7850212 to your computer and use it in GitHub Desktop.
<?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;
}
?>
<?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