/** * Set the time when the session will tiemout * * @param integer $sess Session ID * @return void */ private function _setTimeout($sess) { $mwdb = \Components\Tools\Helpers\Utils::getMWDBO(); $ms = new \Components\Tools\Tables\Session($mwdb); $ms->load($sess); $ms->timeout = 1209600; $ms->store(); }
/** * Saves the name of a session (AJAX) * * @return void */ public function renameTask() { $mwdb = \Components\Tools\Helpers\Utils::getMWDBO(); $id = Request::getInt('id', 0); $name = trim(Request::getVar('name', '')); if ($id && $name) { $ms = new \Components\Tools\Tables\Session($mwdb); $ms->load($id); $ms->sessname = $name; $ms->store(); } echo $name; }
/** * Generate a Windows tool invoke URL to redirect to * * @param string $option Name of the component * @param string $appid * @param object $user * @param string $ip * @return string */ public function generateInvokeUrl($option, $appid = null, $user = null, $ip = null) { $appid = $appid ?: Request::getVar('appid'); if (!$appid) { return ''; } $user = $user ?: User::getInstance(); $ip = $ip ?: Request::ip(); // Get summary usage data $startdate = new \DateTime('midnight first day of this month'); $enddate = new \DateTime('midnight first day of next month'); $db = App::get('db'); $sql = 'SELECT truncate(sum(walltime)/60/60,3) as totalhours FROM `sessionlog` '; $sql .= 'WHERE start >' . $db->quote($startdate->format('Y-m-d H:i:s')) . ' '; $sql .= 'AND start <' . $db->quote($enddate->format('Y-m-d H:i:s')); $db->setQuery($sql); $totalUsageFigure = $db->loadObjectList(); $params = Component::params('com_tools'); $maxhours = $params->get('windows_monthly_max_hours', '100'); if (floatval($totalUsageFigure[0]->totalhours) > floatval($maxhours)) { return ''; } // Get the middleware database $mwdb = \Components\Tools\Helpers\Utils::getMWDBO(); // Get the session table $ms = new \Components\Tools\Tables\Session($mwdb); $ms->bind(array('username' => $user->get('username'), 'remoteip' => $ip)); // Save the entry $ms->store(); // Get back the ID $sessionID = $ms->sessnum; // Opaque data $od = "username="******",email=" . $user->get('email'); $od = $od . ",userip=" . $ip; $od = $od . ",sessionid=" . $sessionID; $od = $od . ",ts=" . (new \DateTime())->format('Y.m.d.H.i.s'); $eurl = exec("/usr/bin/hz-aws-appstream getentitlementurl --appid '" . $appid . "' --opaquedata '" . $od . "'"); return $eurl; }