static function process(Mobile_API_Request $request) { $operation = $request->getOperation(); $sessionid = HTTP_Session::detectId(); //$request->getSession(); if (empty($operation)) { $operation = 'login'; } $response = false; if (isset(self::$opControllers[$operation])) { $operationFile = self::$opControllers[$operation]['file']; $operationClass = self::$opControllers[$operation]['class']; include_once dirname(__FILE__) . $operationFile; $operationController = new $operationClass(); $operationSession = false; if ($operationController->requireLogin()) { $operationSession = Mobile_API_Session::init($sessionid); if ($operationController->hasActiveUser() === false) { $operationSession = false; } //Mobile_WS_Utils::initAppGlobals(); } else { // By-pass login $operationSession = true; } if ($operationSession === false) { $response = new Mobile_API_Response(); $response->setError(1501, 'Login required'); } else { try { $response = $operationController->process($request); } catch (Exception $e) { $response = new Mobile_API_Response(); $response->setError($e->getCode(), $e->getMessage()); } } } else { $response = new Mobile_API_Response(); $response->setError(1404, 'Operation not found: ' . $operation); } if ($response !== false) { if ($response->hasError()) { include_once dirname(__FILE__) . '/ui/Error.php'; $errorController = new Mobile_UI_Error(); $errorController->setError($response->getError()); echo $errorController->process($request)->emitHTML(); } else { echo $response->emitHTML(); } } }
function handle_action() { $sm =& $this->_site_manager; $template =& $sm->get_template(); $um =& $sm->get_url_manager(); $dm =& $sm->get_dump_manager(); $action = $sm->execute_action(); $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ($action && !$um->isset_param('list_output')) { $dm->store_dump(md5($url)); HTTP_Session::pause(); header('Location: http://' . $url); exit; } }
/** * Initialize * * @static * @access private * @return void */ function _init() { // Disable auto-start of a sesion ini_set('session.auto_start', 0); // Set local name equal to the current script name HTTP_Session::localName($_SERVER['PHP_SELF']); }
/** * Set value for the key. */ static function set($key, $value) { HTTP_Session::set($key, $value); }
/** * Replicate session data to table specified in option 'replicateBeforeDestroy' * * @param string $targetTable Table to replicate to * @param string $id Id of record to replicate * * @access private * @return bool */ function replicate($targetTable, $id = null) { if (is_null($id)) { $id = HTTP_Session::id(); } // Check if table row already exists $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", $targetTable, $this->db->quoteSmart(md5($id))); $result = $this->db->getOne($query); if (DB::isError($result)) { new DB_Error($result->code, PEAR_ERROR_DIE); return false; } // Insert new row into dest table if (0 == intval($result)) { $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", $targetTable, $this->options['table'], $this->db->quoteSmart(md5($id))); } else { // Update existing row $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id AND src.id = %s", $targetTable, $this->options['table'], $this->db->quoteSmart(md5($id))); } $result = $this->db->query($query); if (DB::isError($result)) { new DB_Error($result->code, PEAR_ERROR_DIE); return false; } return true; }
function destroy() { HTTP_Session::destroy(); }
function useCookies() { return isset($_COOKIE[HTTP_Session::name()]); }
/** * setGcMaxLifetime() * * @access public * @param integer $iGcMaxLifetime * @return void */ function setGcMaxLifetime($iGcMaxLifetime) { $iCurrentGcMaxLifetime = parent::setGcMaxLifetime(); parent::setGcMaxLifetime($iCurrentGcMaxLifetime + $iGcMaxLifetime); }
$return = ini_get('session.gc_maxlifetime'); if (isset($gcMaxLifetime) && is_int($gcMaxLifetime) && $gcMaxLifetime >= 1) { ini_set('session.gc_maxlifetime', $gcMaxLifetime); } return $return; } /** * If optional parameter is specified it determines the * probability that the gc (garbage collection) routine is started * and session data is cleaned up * * It returns the previous value of this property * * @param bool $gcProbability If specified it will replace the previous value * of this property * * @static * @access public * @return bool The previous value of the property */ public static function setGcProbability($gcProbability = null) { $return = ini_get('session.gc_probability'); if (isset($gcProbability) && is_int($gcProbability) && $gcProbability >= 1 && $gcProbability <= 100) { ini_set('session.gc_probability', $gcProbability); } return $return; } } HTTP_Session::_init();
function process(Mobile_API_Request $request) { HTTP_Session::destroy(HTTP_Session::detectId()); header('Location: index.php'); exit; }
<?php header('Content-type: text/json'); chdir(dirname(__FILE__) . '/../../'); include_once dirname(__FILE__) . '/api/wsapi.php'; $sessionid = HTTP_Session::detectId(); session_id($sessionid); session_start(); $current_user_ID = $_SESSION['_authenticated_user_id']; $query = "SELECT case when (vtiger_users.user_name not like '') then CONCAT(vtiger_users.last_name,' ',vtiger_users.first_name) else vtiger_groups.groupname end as user_name, vtiger_activity.activityid , vtiger_activity.subject, vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date, vtiger_activity.time_start,vtiger_activity.time_end, vtiger_crmentity.crmid, vtiger_crmentity.description, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime, vtiger_recurringevents.recurringtype, case when (vtiger_activity.activitytype = 'Task') then vtiger_activity.status else vtiger_activity.eventstatus end as status, vtiger_seactivityrel.crmid as parent_id from vtiger_activity \ninner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_activity.activityid \nleft join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid \nleft join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid \nleft outer join vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid \nleft join vtiger_groups on vtiger_groups.groupid=vtiger_crmentity.smownerid \nwhere vtiger_crmentity.deleted = 0 and ((vtiger_activity.activitytype='Task' and vtiger_activity.status not in ('Completed','Deferred')) or (vtiger_activity.activitytype Not in ('Emails','Task') and vtiger_activity.eventstatus not in ('','Held'))) AND vtiger_users.id =? ORDER BY vtiger_activity.due_date ASC"; $params = array($current_user_ID); $result = $adb->pquery($query, $params); $numofrows = $adb->num_rows($result); // echo '['; $separator = ""; $tmp_arr = array(); $tmp_str = "["; for ($k = 0; $k < $adb->num_rows($result); $k++) { $descr = ''; $startdate = $adb->query_result($result, $k, "date_start"); //only European time format is currently supported $newStartDate = gmdate("d-m-Y h:m:s", strtotime($startdate)); $starttime = $adb->query_result($result, $k, "time_start"); $startDateTime = $startdate . ' ' . $starttime; //requires timestamp in miliseconds = unix time stamp * 1000 $startDateTime = strtotime($startDateTime) * 1000; $starttmp = $adb->query_result($result, $k, "time_start"); $endtime = $adb->query_result($result, $k, "time_end"); $subject = $adb->query_result($result, $k, "subject"); $activitytype = $adb->query_result($result, $k, "activitytype"); $activitytypetrans = getTranslatedString($adb->query_result($result, $k, "activitytype"), 'Calendar');