/** * OpenLSS - Lighter Smarter Simpler * * This file is part of OpenLSS. * * OpenLSS is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * OpenLSS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the * GNU Lesser General Public License along with OpenLSS. * If not, see <http://www.gnu.org/licenses/>. */ function alert($msg, $success = true, $delayed = false) { //figure type if ($success === true) { $type = 'success'; } elseif ($success === false) { $type = 'error'; } else { $type = 'warning'; } //deal with delayed alerts if ($delayed) { $alert = session('delayed_alert'); if (!is_array($alert)) { $alert = array(); } $alert[$type][]['msg'] = $msg; session('delayed_alert', $alert); return true; //add to runtime alerts } else { if (!class_exists('\\LSS\\Tpl')) { throw new Exception('Tpl library must be available for alerts'); } $alert = \LSS\Tpl::_get()->get('alert'); if (!is_array($alert)) { $alert = array(); } $alert[$type][]['msg'] = $msg; \LSS\Tpl::_get()->set('alert', $alert); return true; } return false; }
function debug_dump() { if (php_sapi_name() != 'cli' && is_callable(array('\\LSS\\Tpl', 'addDebug'))) { if (ob_start()) { echo '<pre>'; call_user_func_array('var_dump', func_get_args()); echo '</pre>'; \LSS\Tpl::_get()->addDebug(ob_get_contents()); ob_end_clean(); } } else { call_user_func_array('var_dump', func_get_args()); } }
try { //get the client member $client = Client::fetchByEmail(post('email')); if (!$client) { throw new Exception('Client member doesnt exist'); } //check password if (!bcrypt_check(post('password'), $client['password'])) { throw new Exception('Password is invalid'); } //generate token and setup session $token = ClientSession::tokenCreate($client['client_id'], server('REMOTE_ADDR'), server('HTTP_USER_AGENT')); ClientSession::startSession($token); //update last login Client::updateLastLogin($client['client_id']); //redirect request if (session('login_referrer') && strpos(session('login_referrer'), Url::login()) === false) { redirect(session('login_referrer')); } else { redirect(Url::home()); } } catch (Exception $e) { alert($e->getMessage(), false); } } session('login_referrer', server('HTTP_REFERER')); $params = array(); $params['url_login'] = Url::login(); $params['page_title'] = Config::get('site_name') . ' - Admin Login'; Tpl::_get()->output('client_login', $params);
* * OpenLSS is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * OpenLSS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the * GNU Lesser General Public License along with OpenLSS. * If not, see <http://www.gnu.org/licenses/>. */ use LSS\Account\Client; use LSS\Account\ClientSession; use LSS\Tpl; use LSS\Url; if (post('edit')) { try { Client::update(post('client_id'), post()); alert('client profile updated successfully', true, true); redirect(Url::profile()); } catch (Exception $e) { alert($e->getMessage(), false); } } $params = array_merge(Client::fetch(ClientSession::get('client_id')), post()); Tpl::_get()->output('client_profile', $params);
* published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * OpenLSS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the * GNU Lesser General Public License along with OpenLSS. * If not, see <http://www.gnu.org/licenses/>. */ use LSS\Config; use LSS\Tpl; //load tpl $theme = Config::get('theme', 'name') ? Config::get('theme', 'name') : 'default'; Tpl::_get()->setPath(ROOT_GROUP . '/theme/' . $theme); Tpl::_get()->setUri('/theme/' . $theme . '/'); Tpl::_get()->set(array('lss_version' => LSS_VERSION, 'version' => VERSION, 'site_name' => Config::get('site_name'), 'site_title' => Config::get('site_name'), 'uri' => Config::get('url', 'uri'), 'url' => Config::get('url', 'url'), 'theme_path' => Tpl::_get()->uri, 'copyright' => '© ' . date('Y') . ' ' . Config::get('site_name'))); //set delayed alerts if (session('delayed_alert')) { $alert = Tpl::_get()->get('alert'); if (!is_array($alert)) { $alert = array(); } $alert = array_merge($alert, session('delayed_alert')); Tpl::_get()->set('alert', $alert); session('delayed_alert', ''); } //cleanup unset($theme);