public function run() { $login = new login(session::getSID()); if ($login->logged_in() === true) { header("Location: /index.php?logout=1"); } }
public function run() { $login = new login(session::getSID()); if ($login->logged_in() === true) { $user = new users(); $profilePicture = $user->getProfilePicture($_SESSION['userdata']['id']); $tpl = new template(); $tpl->assign("profilePicture", $profilePicture); $tpl->assign("userName", $_SESSION['userdata']['name']); $tpl->assign("userEmail", $_SESSION['userdata']['mail']); $tpl->display("general.loginInfo"); } }
/** * start - renders applicaiton and routes to correct template, writes content to output buffer * * @access public static * @return void */ public function start() { $config = new config(); $login = new login(session::getSID()); $frontController = frontcontroller::getInstance(ROOT); if ($login->logged_in() === false) { if (isset($_GET['export']) === true) { ob_start(); $frontController->run(); $toRender = ob_get_clean(); } else { ob_start(); include 'includes/templates/' . TEMPLATE . '/login.php'; $toRender = ob_get_clean(); } } else { ob_start(); include 'includes/templates/' . TEMPLATE . '/content.php'; $toRender = ob_get_clean(); } $this->render($toRender); }
public function run() { $login = new login(session::getSID()); if ($login->logged_in() === true) { $tpl = new template(); //Messages $message = new messages(); $messages = $message->getInbox($_SESSION['userdata']['id'], 5, 0); $messageCount = count($messages); if ($messageCount) { $mailOptions = array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'href' => '#'); } else { $mailOptions = array('class' => 'dropdown-toggle'); } $tpl->assign("mailOptions", $mailOptions); $tpl->assign("messagecount", $messageCount); $tpl->assign("messages", $messages); $tpl->assign("helper", new helper()); //Tickets $tickets = new tickets(); $newTickets = $tickets->getUnreadTickets($_SESSION['userdata']['id']); $ticketCount = count($newTickets); if (count($newTickets)) { $ticketOptions = array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'data-target' => '#'); } else { $ticketOptions = array('class' => 'dropdown-toggle'); } if (is_array($newTickets) === true) { $limitedTicketItems = array_slice($newTickets, 0, 5); } else { $limitedTicketItems = array(); } $tpl->assign("tickeOptions", $ticketOptions); $tpl->assign("ticketCount", $ticketCount); $tpl->assign("newTickets", $limitedTicketItems); $tpl->display("general.headMenu"); } }
<?php define('VERSION', '0.6'); define('RESTRICTED', TRUE); define('PUBLIC', TRUE); define('MYFILE', basename($_SERVER['PHP_SELF'], ".d")); define('TEMPLATE', 'zypro'); $root = dirname(__FILE__); define('ROOT', $root); include_once 'config/settings.php'; include_once 'core/class.autoload.php'; include_once 'config/configuration.php'; $login = new login(session::getSID()); ob_start(); if ($login->logged_in() !== true) { $login->showLogin(); $loginContent = ob_get_clean(); ob_start(); } else { $loginContent = ''; } $application = new application(); $application->start(); ob_end_flush();
/** * run - display template and edit data * * @access public * */ public function run() { $login = new login(session::getSID()); //Check if user is logged in if ($login->logged_in() !== true) { exit; } $helper = new helper(); $projects = new projects(); $tickets = new tickets(); $module = $_GET['module']; //Organize ajax handlers by module and action if ($module == "tickets.showAll") { // AJAX status change if (isset($_POST['ticketId'])) { $ticketId = $_POST['ticketId']; $newStatus = $_POST['newStatus']; if ($tickets->getAccessRights($ticketId)) { if ($tickets->changeStatus($ticketId, $newStatus) === true) { echo "Status was changed"; } else { echo "Error with change"; } } else { echo "You have no rights to do that."; } } } else { if ($module == "tickets.showTicket") { $users = new users(); $id = $_GET['id']; $results = $tickets->getTimelineHistory($id); $ticket = $tickets->getTicket($id); $jsonArr = array(); $description = strip_tags($ticket['description']); $description = str_replace("\n", "", $description); $description = str_replace("\r", "", $description); $json = '{"timeline": { "headline":"Ticket History for ' . $ticket['headline'] . '", "type":"default", "text":"' . $description . '", "startDate":"' . $ticket['timelineDate'] . '", "date": [ '; //Creation Date $items[] = '{ "startDate":"' . $ticket['timelineDate'] . '", "headline":"Ticket Created", "text":"<p>Ticket created by ' . $ticket['userFirstname'] . ', ' . $ticket['userLastname'] . '</p>", "asset": { "media":"", "credit":"", "caption":"" } }'; foreach ($results as $row) { $items[] = '{ "startDate":"' . $row['date'] . '", "headline":"Ticket Update", "text":"<p>' . $row['firstname'] . ', ' . $row['lastname'] . ' changed ' . $row['changeType'] . ' to ' . $row['changeValue'] . '</p>", "asset": { "media":"' . $users->getProfilePicture($row['userId']) . '", "credit":"' . $row['firstname'] . ', ' . $row['lastname'] . '", "caption":"" } }'; } $comments = new comments(); $allcomments = $comments->getComments('ticket', $id); foreach ($allcomments as $comment) { $items[] = '{ "startDate":"' . $comment['timelineDate'] . '", "headline":"New Comment", "text":' . json_encode('<p>' . $comment['firstname'] . ', ' . $comment['lastname'] . ' said:<br /> </p>' . $comment['text']) . ', "asset": { "media":"' . $users->getProfilePicture($comment['userId']) . '", "credit":"' . $comment['firstname'] . ', ' . $comment['lastname'] . '", "caption":"" } }'; } $file = new files(); $files = $file->getFilesByModule('ticket', $id); $tempStr = ''; $tempStr3 = ''; $imgExtensions = array('jpg', 'jpeg', 'png', 'gif', 'psd', 'bmp', 'tif', 'thm', 'yuv'); foreach ($files as $fileRow) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/userdata/' . $fileRow['module'] . '/' . $fileRow['encName'] . '.' . $fileRow['extension'])) { $tempStr3 .= "<img style='max-height: 50px; max-width: 70px;' src='userdata/" . $fileRow["module"] . "/" . $fileRow['encName'] . "." . $fileRow["extension"] . "' />"; $filepath = "userdata/" . $fileRow["module"] . "/" . $fileRow['encName'] . "." . $fileRow["extension"] . ""; } else { $tempStr3 .= "<img style='max-height: 50px; max-width: 70px;' src='userdata/file.png' />"; $filepath = "userdata/file.png"; } $tempStr = '{ "startDate":"' . $fileRow['timelineDate'] . '", "headline":"New File", "text":"' . $fileRow['firstname'] . ', ' . $fileRow['lastname'] . ' uploaded:<br /><a href=\'' . $filepath . '\'>' . $fileRow['realName'] . '.' . $fileRow['extension'] . '</a>",'; $tempStr3 .= '<span class=\'filename\'>' . $fileRow['realName'] . '.' . $fileRow['extension'] . '</span> </a>",'; $tempStr .= ' "asset": { "media":"' . $filepath . '", "credit":"' . $fileRow['realName'] . '.' . $fileRow['extension'] . '", "caption":"" } }'; $items[] = $tempStr; } $json .= implode(",", $items); $json .= ' ] } }'; header('Content-type: text/json'); header('Content-type: application/json'); echo $json; } else { echo "There are no ajax actions for this module"; } } }
* Flatnet2 Projekt */ echo '<' . '?xml version="1.0" encoding="utf-8"?' . '>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" id='profil'> <div id="wrapper"> <?php # Wrapper start ?> <head> <?php # Check ob User eingeloggt ist: $checkIfLoggedIn = new login(); $checkIfLoggedIn->logged_in("redirect", "index.php"); # Benutzername: $benutzername = $_SESSION['username']; $usermanager->userHasRightPruefung("8"); ?> <title><?php echo $benutzername . "'s Emails"; ?> </title> </head> <body> <div class='mainbody'> <div class="topBody">
/** * Logg inn en bruker * @param string $email kan også være brukerid * @param string $pass * @param integer $expire_type * @param boolean $md5 skal passordet krypteres? * @param boolean $secure_only skal vi fortsette å bruke ssl etter innlogging? * @return boolean */ public static function do_login_handle($u_id, $user = NULL, $expire_type = LOGIN_TYPE_TIMEOUT, $secure_only = false) { global $__server; // prøver vi å sette cookies uten HTTPS? if ($__server['https_support'] && !HTTPS) { throw new HSException("Kan ikke sette logg inn cookies uten sikret tilkobling."); } // må hente data? $u_id = (int) $u_id; if (!$user) { $result = \Kofradia\DB::get()->query("\n\t\t\t\tSELECT u_id, u_email, u_online_time, u_online_ip, u_access_level, u_force_ssl\n\t\t\t\tFROM users\n\t\t\t\tWHERE u_id = {$u_id}"); $user = $result->fetch(); unset($result); } if (!$user || $u_id != $user['u_id']) { return false; } // ikke aktivert? if ($user['u_access_level'] == 0) { return false; } // lag unik id $hash = uniqid(""); $hash_pub = mb_substr(md5($hash), 0, 13); // timeout tid $timeout = 900; // secure only $secure_only = $__server['https_support'] && ($secure_only || $user['u_access_level'] != 1 && $user['u_access_level'] != 0 || $user['u_force_ssl'] != 0 || defined("FORCE_HTTPS_ALWAYS")); $expire_type = (int) $expire_type; $expire = $expire_type == LOGIN_TYPE_BROWSER ? time() + 60 * 60 * 48 : ($expire_type == LOGIN_TYPE_TIMEOUT ? time() + $timeout : time() + 31536000); // legg til session $ip = \Kofradia\DB::quote($_SERVER['REMOTE_ADDR']); $browsers = \Kofradia\DB::quote($_SERVER['HTTP_USER_AGENT']); \Kofradia\DB::get()->exec("INSERT INTO sessions SET ses_u_id = {$user['u_id']}, ses_hash = " . \Kofradia\DB::quote($hash) . ", ses_expire_time = {$expire}, ses_expire_type = {$expire_type}, ses_created_time = " . time() . ", ses_ip_list = {$ip}, ses_last_ip = {$ip}, ses_browsers = {$browsers}, ses_secure = " . ($secure_only ? 1 : 0)); // hent session id $ses_id = \Kofradia\DB::get()->lastInsertId(); // sett cookie $cookie_expire = $expire_type == LOGIN_TYPE_BROWSER ? 0 : time() + 31536000; setcookie($__server['cookie_prefix'] . "id", "{$ses_id}:{$user['u_id']}", $cookie_expire, $__server['cookie_path'], $__server['cookie_domain'], $secure_only); setcookie($__server['cookie_prefix'] . "h", $secure_only ? $hash : $hash_pub, $cookie_expire, $__server['cookie_path'], $__server['cookie_domain'], $secure_only, true); setcookie($__server['cookie_prefix'] . "s", $secure_only ? 1 : 0, $cookie_expire, $__server['cookie_path'], $__server['cookie_domain']); // sett cookie for reauth if (!$secure_only && $__server['https_support']) { setcookie($__server['cookie_prefix'] . "ra", $hash, $cookie_expire, $__server['cookie_path'], $__server['cookie_domain'], true, true); } self::$logged_in = true; self::$info = array("ses_id" => $ses_id, "ses_u_id" => $user['u_id'], "ses_hash" => $hash, "ses_expire_type" => $expire_type, "ses_expire_time" => $expire, "ses_browsers" => $_SERVER['HTTP_USER_AGENT'], "ses_phpsessid" => session_id(), "ses_last_ip" => $_SERVER['REMOTE_ADDR'], "ses_last_time" => time(), "ses_secure" => $secure_only, "u_online_time" => $user['u_online_time'], "u_online_ip" => $user['u_online_ip'], "u_access_level" => $user['u_access_level'], "u_force_ssl" => $user['u_force_ssl']); $date = ess::$b->date->get(); $time = $date->format("U") - $date->format("i") * 60 - $date->format("s"); self::$info['secs_hour'] = $time; // last inn bruker self::load_user($user['u_id']); return true; }