public function update($id, array $data, $log = true) { $data['updated_at'] = get_time(); if (is_session('user_id')) { $data['updated_by'] = get_session('user_id'); } $where = $this->getAdapter()->quoteInto('id = ?', $id); parent::update($data, $where); if ($log) { log_sql($this->_name, $id, 'updated', $data); set_session('notice', 'current record saved'); } }
/** * $.ajax({ method: check_session }); * * status: ok * message: x...x * data: x...x */ private function check_session($data) { $error = ''; if (!is_session('user_id')) { $error = 'Session is gone'; } $return = array(); if (is_empty($error)) { $return['status'] = 'ok'; $return['data'] = $this->get_user_data(); } else { $return['status'] = 'error'; $return['message'] = $error; } echo json_encode($return); }
function user_has_tag($name) { if (!is_session('user_id')) { return false; } $db = Zend_Registry::get('db'); /* $sql = 'SELECT id' . ' FROM Controls' . ' WHERE control_set = "UT"' . ' AND control_name = "' . $tag . '"' ; $control_id = $db->fetchOne( $sql ); if( !$control_id ) return false; */ $sql = 'SELECT id' . ' FROM Tags' . ' WHERE parent_name = "Users"' . ' AND parent_id = ' . get_session('user_id') . ' AND name = "' . $name . '"'; $tag_id = $db->fetchOne($sql); if (!$tag_id) { return false; } else { return true; } }
include 'app/controllers/session.php'; }); $f3->route('GET /logout', function ($f3) { end_session($f3); $f3->reroute('/session'); }); $f3->route('POST /session', function ($f3) { if (verif_session($f3->get('POST.api')) == 'true') { $f3->reroute('/'); } else { $f3->set('ESCAPE', FALSE); $f3->set('message', '<div class="alert alert-danger">Invalid <a class="alert-link" href="#">Girudatsu API Key</a>.'); include 'app/controllers/session.php'; } }); $f3->route('GET /api/stripe', function ($f3) { is_session($f3); include 'app/controllers/api.stripe.php'; }); $f3->route('GET /api/paypal', function ($f3) { is_session($f3); //include 'app/controllers/api.paypal.php'; echo 'maintenance'; }); $f3->route('GET /api/wish', function ($f3) { is_session($f3); include 'app/controllers/api.wish.php'; }); $f3->route('GET /heartbeat', function ($f3) { echo 'heartbeat'; });
function dispatch(&$data) { $db =& new CDatabase(); if (function_exists("config_database")) { config_database($db); } $sanitize =& new CSanitize(); $validate =& new CValidate(); if (function_exists('config_controller_class')) { $controllername = config_controller_class(); $controller = new $controllername(); } else { $controller = new CController(); } $controller->RequestHandle(); $controller->SetDatabase($db); $controller->SetSanitize($sanitize); $controller->SetValidate($validate); if (function_exists("config_models")) { config_models($controller); } if (function_exists('config_components')) { config_components($controller); } if (!function_exists('is_session') || is_session()) { session_start(); } $this->_check_secure($controller); if (function_exists("config_controller")) { config_controller($controller); } if (function_exists("action")) { action($controller); } if (function_exists('after_action')) { after_action($controller); } $template = $controller->GetTemplateFile(); $viewfile = $controller->GetViewFile(); $variable = $controller->GetVariable(); $sqllog = $controller->GetSqlLog(); $is_debug = $controller->GetDebug(); if (function_exists('config_view_class')) { $viewname = config_view_class(); $view = new $viewname(); } else { $view = new CView(); } $view->SetFile($template, $viewfile); $view->SetVariable($variable); $view->SetSanitize($sanitize); $view->SetController($controller); $view->SetDebug($is_debug); $view->SetSqlLog($sqllog); $view->display(); if (function_exists('after_render')) { after_render($controller); } $data = $variable; return $controller; }