function admin_controller() { require "Models/feed_model.php"; global $session, $action, $format; $output['content'] = ""; $output['message'] = ""; //--------------------------------------------------------------------------------------------------------- // Gets the user list and user memory use // http://yoursite/emoncms/admin/users //--------------------------------------------------------------------------------------------------------- if ($action == '' && $session['write'] && $session['admin']) { $userlist = get_user_list(); $total_memuse = 0; for ($i = 0; $i < count($userlist); $i++) { $user = $userlist[$i]; $stats = get_statistics($user['userid']); $user['uphits'] = $stats['uphits']; $user['dnhits'] = $stats['dnhits']; $user['memuse'] = $stats['memory']; $total_memuse += $user['memuse']; $userlist[$i] = $user; } usort($userlist, 'user_sort'); // sort by highest memory user first $output['content'] = view("admin/admin_view.php", array('userlist' => $userlist, 'total_memuse' => $total_memuse)); } return $output; }
/* * Loop from the start of the courses till the last record on dayly base */ $interval = DateInterval::createFromDateString('1 day'); $period = new DatePeriod($date_start_day, $interval, $date_end_day); foreach ($period as $date) { // init data fields $days[$date->format('Y-m-d')]['header'] = $date->format('Y-m-d'); $days[$date->format('Y-m-d')]['male'] = 0; $days[$date->format('Y-m-d')]['female'] = 0; $days[$date->format('Y-m-d')]['18-24'] = 0; $days[$date->format('Y-m-d')]['25-34'] = 0; $days[$date->format('Y-m-d')]['35-44'] = 0; $days[$date->format('Y-m-d')]['45-54'] = 0; $days[$date->format('Y-m-d')]['55plus'] = 0; $request = get_statistics($date, $lesson_id); if (count($request) == 0) { $days[$date->format('Y-m-d')]['archive'] = 0; $days[$date->format('Y-m-d')]['forum'] = 0; $days[$date->format('Y-m-d')]['webinarTT'] = 0; $days[$date->format('Y-m-d')]['webinarSF'] = 0; $days[$date->format('Y-m-d')]['webinarPH'] = 0; $days[$date->format('Y-m-d')]['webinarMS'] = 0; $days[$date->format('Y-m-d')]['webinarVS'] = 0; } else { foreach ($request as $element) { switch ($element["for_item_type"]) { case 'archive': $days[$date->format('Y-m-d')]['archive'] = $element["COUNT(*)"]; break; case 'forum':
// Set template file $template->set_filenames(array('body' => 'meeting_stat_block_ajax.html')); /** Show result */ $hidden_fields = build_hidden_fields(array('fact_km' => $fact_km, 'plain_km' => $plain_km, 'author_id' => $author_id)); $template->assign_vars(array('S_STAT' => TRUE, 'S_STAT_BLOCK' => TRUE, 'STAT_AV' => $speed_av, 'STAT_MX' => $speed_mx, 'STAT_TM_MOVE' => $time_movie, 'STAT_TM_STOP' => $time_stop, 'STAT_UP' => $climbing, 'STAT_DOWN' => $descent, 'STAT_MAX' => $altmax, 'STAT_MIN' => $altmin, 'STAT_FIN' => $finance, 'STAT_COMENT' => $orgcomment, 'STAT_LINK' => $link, 'STAT_DIAP' => $altmax - $altmin, 'STAT_FULL_LINK' => $link ? 'http://www.gpsies.com/map.do?fileId=' . $link : '', 'STAT_HIDDEN_FIELDS' => $hidden_fields)); // Output results $template->display('body'); $_RESULT['success'] = true; } else { if ($mode == 'stat_form') { $user->setup(array('posting', 'lang_meeting')); include $phpbb_root_path . 'portal/includes/functions_meeting.' . $phpEx; $id = request_var('id', 0); get_statistics($id); $s_stat = FALSE; $field = array('meeting_id', 'plain_km', 'fact_km', 'user_id'); // Ne otobrazhaemye polya if ($statistics) { foreach ($statistics as $key => $val) { if (!in_array($key, $field) && $val != $id && $val != 0 && $val !== '' && $val !== null) { $s_stat = TRUE; break; } } } $statistics['link'] = $statistics['link'] == 'null' ? '' : $statistics['link']; // Set template file $template->set_filenames(array('body' => 'meeting_stat_block_form_ajax.html')); // Show result
function user_controller() { global $session, $action, $format, $allowusersregister; $output['content'] = ""; $output['message'] = ""; //-------------------------------------------------------------------------- // Login user (PUBLIC ACTION) // http://yoursite/emoncms/user/login?name=john&pass=test //-------------------------------------------------------------------------- if ($action == 'login') { if (isset($_POST['name']) && isset($_POST['pass']) && ($_POST['name'] && $_POST['pass'])) { $username = preg_replace('/[^\\w\\s-.]/', '', $_POST['name']); // filter out all except for alphanumeric white space and dash $username = db_real_escape_string($username); $password = db_real_escape_string($_POST['pass']); $result = user_logon($username, $password); if ($result == 0) { $output['message'] = _('Invalid username or password'); $output['content'] = view("user/login_block.php", array()); } else { $output['message'] = _('Welcome, you are now logged in'); if ($format == 'html') { header('Location: ../dashboard/list'); } } } else { $output['content'] = view('user/login_block.php', array()); } } elseif ($action == 'create' && $allowusersregister) { $username = preg_replace('/[^\\w\\s-.]/', '', $_POST["name"]); // filter out all except for alphanumeric white space and dash $username = db_real_escape_string($username); $password = db_real_escape_string($_POST["pass"]); // New option to return apikey on register - for use with drupal auth integration if ($_GET['returnapikey'] == true) { $returnapikey = true; } else { $returnapikey = false; } if (get_user_id($username) != 0) { $output['message'] = _("Sorry username already exists"); } elseif (strlen($username) < 4 || strlen($username) > 30) { $output['message'] = _("Please enter a username that is 4 to 30 characters long") . "<br/>"; } elseif (strlen($password) < 4 || strlen($password) > 30) { $output['message'] = _("Please enter a password that is 4 to 30 characters long") . "<br/>"; } else { $user = create_user($username, $password); if (!$returnapikey) { $result = user_logon($username, $password); $output['message'] = _("Your new account has been created"); } else { $output['message'] = $user['readapikey']; } if ($format == 'html') { header("Location: ../dashboard/list"); } if ($_SESSION['write']) { create_user_statistics($_SESSION['userid']); } } } elseif ($action == 'changepass' && $_SESSION['write']) { $oldpass = db_real_escape_string($_POST['oldpass']); $newpass = db_real_escape_string($_POST['newpass']); if (strlen($newpass) < 4 || strlen($newpass) > 30) { $output['message'] = _("Please enter a password that is 4 to 30 characters long") . "<br/>"; } elseif (change_password($_SESSION['userid'], $oldpass, $newpass)) { $output['message'] = _("Your password has been changed"); } else { $output['message'] = _("Invalid password"); } } elseif ($action == 'changedetails' && $_SESSION['write']) { $username = preg_replace('/[^\\w\\s-.]/', '', $_POST["username"]); $username = db_real_escape_string($username); $email = preg_replace('/[^\\w\\s-.@]/', '', $_POST["email"]); $email = db_real_escape_string($email); $id = get_user_id($username); if ($id && $id != $_SESSION['userid']) { $output['message'] = _("Sorry username already exists"); } elseif (strlen($username) < 4 || strlen($username) > 30) { $output['message'] = _("Please enter a username that is 4 to 30 characters long") . "<br/>"; } elseif (!$email) { $output['message'] = _("No email address present") . "<br/>"; } else { set_user_username($_SESSION['userid'], $username); set_user_email($_SESSION['userid'], $email); } } elseif ($action == 'newapiread' && $session['write']) { $apikey_read = md5(uniqid(mt_rand(), true)); set_apikey_read($session['userid'], $apikey_read); $output['message'] = _("New read apikey: ") . $apikey_read; if ($format == 'html') { header("Location: view"); } } elseif ($action == 'newapiwrite' && $session['write']) { $apikey_write = md5(uniqid(mt_rand(), true)); set_apikey_write($session['userid'], $apikey_write); $output['message'] = _("New write apikey: ") . $apikey_write; if ($format == 'html') { header("Location: view"); } } elseif ($action == 'logout' && $session['read']) { if ($_POST['CSRF_token'] == $_SESSION['CSRF_token']) { user_logout(); $output['message'] = _("You are logged out"); } else { reset_CSRF_token(); $output['message'] = _("Invalid token"); } if ($format == 'html') { header("Location: ../"); } } elseif ($action == 'getapiread' && $session['read']) { $apikey_read = get_apikey_read($session['userid']); $output = $apikey_read; } elseif ($action == 'getapiwrite' && $session['write']) { $apikey_write = get_apikey_write($session['userid']); $output = $apikey_write; } elseif ($action == 'view' && $session['write']) { $user = get_user($session['userid']); $stats = get_statistics($session['userid']); if ($format == 'json') { $output['content'] = json_encode($user); } if ($format == 'html') { $output['content'] = view("user_view.php", array('user' => $user, 'stats' => $stats)); } } elseif ($action == 'setlang' && $session['write']) { // Store userlang in database set_user_lang($session['userid'], $_GET['lang']); // Reload the page if ($format == 'html') { header("Location: view"); } } return $output; }