/** * Retrieve user preferences * * @access private */ private function get_prefs() { try { $to_read['table'] = 'setting'; $to_read['columns'] = array('SETTING_ID'); $to_read['condition_columns'][':t'] = 'setting_type'; $to_read['condition_select_types'][':t'] = '='; $to_read['condition_values'][':t'] = 'user_' . VSession::user_id(); $to_read['value_types'][':t'] = 'str'; $pref = $this->_db->read($to_read); if (empty($pref)) { $this->_prefs = new Setting(); $this->_prefs->_name = 'User preferences for "' . VSession::username() . '"'; $this->_prefs->_type = 'user_' . VSession::user_id(); $this->_prefs->_data = json_encode(array('last_visit' => date('Y-m-d H:i:s'), 'timeline' => array(array('title' => 'Lynxpress Demo', 'url' => 'http://demo.lynxpress.org/')))); $this->_prefs->create(); } else { $this->_prefs = new Setting($pref[0]['SETTING_ID']); } $this->_prefs->_data = json_decode($this->_prefs->_data, true); } catch (Exception $e) { $this->_action_msg = ActionMessages::custom_wrong($e->getMessage()); } }
/** * Check if the session is correct, else logout the user * * @access public */ public function verify_session() { if (VSession::user_id()) { $to_read['table'] = 'user'; $to_read['columns'] = array('user_username'); $to_read['condition_columns'][':id'] = 'USER_ID'; $to_read['condition_types'][':id'] = 'AND'; $to_read['condition_select_types'][':id'] = '='; $to_read['condition_values'][':id'] = VSession::user_id(); $to_read['value_types'][':id'] = 'int'; $user = $this->_db->read($to_read); if ($user === false || empty($user)) { session_destroy(); header('Location: index.php?ns=session&ctl=login'); } else { if ($user[0]['user_username'] != VSession::username()) { session_destroy(); header('Location: index.php?ns=session&ctl=login'); } else { $this->_verified = true; } } } else { session_destroy(); header('Location: index.php?ns=session&ctl=login'); } }
<?php $plugins = Helper::plugins_infos(); if (!empty($plugins)) { echo '<ul id="mplg">'; foreach ($plugins as $plg) { echo '<li><a href="index.php?ns=' . $plg['namespace'] . '&ctl=' . $plg['entry_point'] . '">' . $plg['name'] . '</a></li>'; } echo '</ul>'; } ?> </li> <?php if ($page->settings) { echo '<li>' . '<a href="index.php?ns=settings&ctl=manage">Settings</a>' . '<ul>' . '<li><a href="index.php?ns=categories&ctl=manage">Categories</a></li>' . '<li><a href="index.php?ns=posts&ctl=settingpage">Posts</a></li>' . '<li>' . '<a href="index.php?ns=users&ctl=manage">Users</a>' . '<ul>' . '<li><a href="index.php?ns=users&ctl=add">Add</a></li>' . '</ul>' . '</li>' . '<li><a href="index.php?ns=roles&ctl=manage">Roles</a></li>' . '<li><a href="index.php?ns=social&ctl=manage">Social Buttons</a></li>' . '<li><a href="index.php?ns=defaultpage&ctl=manage">Default Page</a></li>' . '<li>' . '<a href="index.php?ns=templates&ctl=manage">Templates</a>' . '<ul>' . '<li><a href="index.php?ns=templates&ctl=add">Add</a></li>' . '<li><a href="index.php?ns=templates&ctl=library">Library</a></li>' . '</ul>' . '</li>' . '<li>' . '<a href="index.php?ns=plugins&ctl=manage">Plugins</a>' . '<ul>' . '<li><a href="index.php?ns=plugins&ctl=add">Add</a></li>' . '<li><a href="index.php?ns=plugins&ctl=library">Library</a></li>' . '</ul>' . '</li>' . '<li>' . '<a href="index.php?ns=links&ctl=manage">Links</a>' . '<ul>' . '<li><a href="index.php?ns=links&ctl=add">Add</a></li>' . '</ul>' . '</li>' . '<li><a href="index.php?ns=activity&ctl=manage">Activity</a></li>' . '<li><a href="index.php?ns=update&ctl=manage">Update</a></li>' . '</ul>' . '<li>'; } ?> <li id="right"> Hi <?php echo Session::username(); ?> | <a href="index.php?ns=session&ctl=logout">Logout</a> </li> </ul> </header> <section id="wrapper">