Example #1
0
         case "POST":
             $results = $commentIO->createComment($args);
             break;
         case "PUT":
             $results = $commentIO->updateComment($args);
             break;
         case "DELETE":
             $results = $commentIO->deleteComment($args);
             break;
         default:
             $results = $io->methodNotAllowed($args);
             break;
     }
     break;
 case "users":
     $userIO = new UserIO($io);
     //Get renewToken
     if (isset($path[1]) && trim($path[1]) != "") {
         $args["renewToken"] = $path[1];
     }
     switch ($verb) {
         case "GET":
             $results = $userIO->getUser($args);
             break;
         case "POST":
             if (isset($args["renewToken"])) {
                 $results = $userIO->renewToken($args);
             } else {
                 $results = $userIO->createUser($args);
             }
             break;
Example #2
0
 public function getUserID($args)
 {
     if (!isset($args["accessToken"])) {
         return -1;
     }
     $accessToken = $args["accessToken"];
     $user = new UserIO($this);
     if ($user->accessTokenValid($accessToken)) {
         $userId = $user->getUserIdForAccessToken($accessToken);
     } else {
         $userId = 0;
     }
     return $userId;
 }
Example #3
0
 /**
  * @param string $alias
  * @throws BaseModuleDialogMethodNotFoundException
  * @throws BaseModuleDialogClassNotFoundException
  * @throws BaseModuleDialogFileNotFoundException
  * @throws BaseModuleDialogMissingException
  */
 public static function io_handler($alias)
 {
     global $user;
     if (isset($_GET['run']) and $_GET['run'] == "common_dialog" and isset($_GET['dialog'])) {
         require_once "common.request.php";
         CommonRequest::common_dialog();
     } else {
         switch ($alias) {
             case "search":
                 switch ($_GET['run']) {
                     case "search":
                         require_once "io/search.io.php";
                         SearchIO::search($_GET['dialog']);
                         break;
                     case "header_search":
                         require_once "io/search.io.php";
                         SearchIO::header_search($_POST['string'], $_POST['current_module']);
                         break;
                     default:
                         require_once "io/search.io.php";
                         SearchIO::main();
                         break;
                 }
                 break;
             default:
                 if (isset($_GET['run'])) {
                     switch ($_GET['run']) {
                         // BASE
                         case "sysmsg":
                             require_once "io/base.io.php";
                             BaseIO::list_system_messages();
                             break;
                         case "system_info":
                             require_once "io/base.io.php";
                             BaseIO::system_info();
                             break;
                         case "software_info":
                             require_once "io/base.io.php";
                             BaseIO::software_info();
                             break;
                         case "license":
                             require_once "io/base.io.php";
                             BaseIO::license();
                             break;
                         case "base_user_lists":
                             if ($_GET['dialog']) {
                                 $module_dialog = ModuleDialog::get_by_type_and_internal_name("base_user_lists", $_GET['dialog']);
                                 if (file_exists($module_dialog['class_path'])) {
                                     require_once $module_dialog['class_path'];
                                     if (class_exists($module_dialog['class'])) {
                                         if (method_exists($module_dialog['class'], $module_dialog['method'])) {
                                             $module_dialog['class']::$module_dialog['method']();
                                         } else {
                                             throw new BaseModuleDialogMethodNotFoundException();
                                         }
                                     } else {
                                         throw new BaseModuleDialogClassNotFoundException();
                                     }
                                 } else {
                                     throw new BaseModuleDialogFileNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleDialogMissingException();
                             }
                             break;
                             // USER
                         // USER
                         case "user_profile":
                             require_once "io/user.io.php";
                             UserIO::profile();
                             break;
                         case "user_details":
                             require_once "io/user.io.php";
                             UserIO::details();
                             break;
                         case "user_change_personal":
                             require_once "io/user.io.php";
                             UserIO::change_personal();
                             break;
                         case "user_change_my_settings":
                             require_once "io/user.io.php";
                             UserIO::change_my_settings();
                             break;
                         case "user_change_password":
                             require_once "io/user.io.php";
                             UserIO::change_password();
                             break;
                         default:
                             require_once "io/home.io.php";
                             break;
                     }
                 } else {
                     require_once "io/home.io.php";
                 }
                 break;
         }
     }
 }
Example #4
0
 /**
  * Main Controller for reqeusts via index.php
  * @throws BaseModuleControllerClassNotFoundException
  * @throws BaseModuleControllerFileNotFoundException
  */
 public static function io()
 {
     global $session, $user, $transaction;
     $template = new HTMLTemplate("index_header.html");
     if (!isset($GLOBALS['fatal_error'])) {
         $unique_id = uniqid();
         $css_directory = constant("WWW_DIR") . "/css";
         if (file_exists($css_directory)) {
             $css_directory_array = scandir($css_directory);
             if (is_array($css_directory_array)) {
                 $index_css = "";
                 foreach ($css_directory_array as $key => $value) {
                     if (strpos(strrev($value), "ssc.") === 0 and strpos(strrev($value), "ssc.gubed") === false and $value != "main.css") {
                         if (is_file($css_directory . "/" . $value)) {
                             if (constant("AVOID_CSS_CACHE") == true) {
                                 $index_css .= "<link rel='stylesheet' type='text/css' href='css/" . $value . "?" . $unique_id . "' title='Style' />\n";
                             } else {
                                 $index_css .= "<link rel='stylesheet' type='text/css' href='css/" . $value . "' title='Style' />\n";
                             }
                         }
                     }
                 }
             }
             $template->set_var("INDEX_CSS", $index_css);
         }
         $index_js = "";
         $js_lib_directory = constant("WWW_DIR") . "/js/lib";
         if (file_exists($js_lib_directory)) {
             $js_lib_directory_array = scandir($js_lib_directory);
             if (is_array($js_lib_directory_array)) {
                 $index_js = "";
                 foreach ($js_lib_directory_array as $key => $value) {
                     if (strpos(strrev($value), "sj.") === 0) {
                         if (is_file($js_lib_directory . "/" . $value)) {
                             if (constant("AVOID_JS_CACHE") == true) {
                                 $index_js .= "<script type='text/javascript' src='js/lib/" . $value . "?" . $unique_id . "'></script>\n";
                             } else {
                                 $index_js .= "<script type='text/javascript' src='js/lib/" . $value . "'></script>\n";
                             }
                         }
                     }
                 }
             }
         }
         $js_modules_directory = constant("WWW_DIR") . "/js/modules";
         if (file_exists($js_modules_directory)) {
             $js_modules_directory_array = scandir($js_modules_directory);
             if (is_array($js_modules_directory_array)) {
                 foreach ($js_modules_directory_array as $key => $value) {
                     if (strpos(strrev($value), "sj.") === 0) {
                         if (is_file($js_modules_directory . "/" . $value)) {
                             if (constant("AVOID_JS_CACHE") == true) {
                                 $index_js .= "<script type='text/javascript' src='js/modules/" . $value . "?" . $unique_id . "'></script>\n";
                             } else {
                                 $index_js .= "<script type='text/javascript' src='js/modules/" . $value . "'></script>\n";
                             }
                         }
                     }
                 }
             }
         }
         if ($index_js) {
             $template->set_var("INDEX_JS", $index_js);
         } else {
             $template->set_var("INDEX_JS", " ");
         }
     } else {
         $template->set_var("INDEX_CSS", "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/base.css\" title=\"Style\" />\n<link rel=\"stylesheet\" type=\"text/css\" href=\"css/login.css\" title=\"Style\" />");
         $template->set_var("INDEX_JS", "");
     }
     if (!isset($GLOBALS['fatal_error'])) {
         $template->set_var("INDEX_TITLE", Registry::get_value("base_html_title"));
         if (Cron::check() == true) {
             $template->set_var("CRON", true);
         } else {
             $template->set_var("CRON", false);
         }
         $template->output();
         $max_ip_errors = (int) Registry::get_value("base_max_ip_failed_logins");
         if (!is_numeric($max_ip_errors) or $max_ip_errors < 3) {
             $max_ip_errors = 3;
         }
         if (Security::ip_error_count() < $max_ip_errors) {
             $session_valid_array = $session->is_valid();
             if ($session_valid_array[0] === true) {
                 $template = new HTMLTemplate("main_header.html");
                 $sub_menu = array();
                 $module_dialog_array = ModuleDialog::list_dialogs_by_type("base_user_lists");
                 if (is_array($module_dialog_array) and count($module_dialog_array) >= 1) {
                     foreach ($module_dialog_array as $key => $value) {
                         $paramquery['username'] = $_GET['username'];
                         $paramquery['session_id'] = $_GET['session_id'];
                         $paramquery['nav'] = "base";
                         $paramquery['run'] = "base_user_lists";
                         $paramquery['dialog'] = $value['internal_name'];
                         $params = http_build_query($paramquery, '', '&#38;');
                         $temp_array = array();
                         $temp_array['params'] = $params;
                         $temp_array['title'] = Language::get_message($value['language_address'], "dialog");
                         array_push($sub_menu, $temp_array);
                         unset($temp_array);
                     }
                 }
                 $template->set_var("sub_menu", $sub_menu);
                 $my_profile_paramquery['username'] = $_GET['username'];
                 $my_profile_paramquery['session_id'] = $_GET['session_id'];
                 $my_profile_paramquery['nav'] = "base";
                 $my_profile_paramquery['run'] = "user_profile";
                 $my_profile_params = http_build_query($my_profile_paramquery, '', '&#38;');
                 $template->set_var("my_profile_params", $my_profile_params);
                 $system_messages_paramquery['username'] = $_GET['username'];
                 $system_messages_paramquery['session_id'] = $_GET['session_id'];
                 $system_messages_paramquery['nav'] = "base";
                 $system_messages_paramquery['run'] = "sysmsg";
                 $system_messages_params = http_build_query($system_messages_paramquery, '', '&#38;');
                 $template->set_var("system_messages_params", $system_messages_params);
                 $about_paramquery['username'] = $_GET['username'];
                 $about_paramquery['session_id'] = $_GET['session_id'];
                 $about_paramquery['nav'] = "base";
                 $about_paramquery['run'] = "system_info";
                 $about_params = http_build_query($about_paramquery, '', '&#38;');
                 $template->set_var("about_params", $about_params);
                 $template->set_var("username", $user->get_full_name(true));
                 $header_search_paramquery['username'] = $_GET['username'];
                 $header_search_paramquery['session_id'] = $_GET['session_id'];
                 $header_search_paramquery['nav'] = "base.search";
                 $header_search_paramquery['run'] = "header_search";
                 $header_search_paramquery['nextpage'] = "1";
                 $header_search_params = http_build_query($header_search_paramquery, '', '&#38;');
                 $template->set_var("header_search_params", $header_search_params);
                 $template->set_var("header_search_current_module", $_GET['nav']);
                 $template->output();
                 try {
                     // Navigation
                     require_once "base/io/navigation.io.php";
                     Navigation_IO::main();
                     Navigation_IO::left();
                     $template = new HTMLTemplate("content_header.html");
                     $template->output();
                     if ($session->read_value("must_change_password") == true) {
                         require_once "core/modules/base/io/user.io.php";
                         UserIO::change_password_on_login();
                     } else {
                         if ($_GET['nav']) {
                             $module_controller_array = SystemHandler::get_module_controller($_GET['nav']);
                             $module_controller_path = "core/modules/" . $module_controller_array['path'];
                             if (file_exists($module_controller_path)) {
                                 require_once $module_controller_path;
                                 if (class_exists($module_controller_array['class'])) {
                                     $module_controller_array['class']::io_handler($module_controller_array['alias']);
                                 } else {
                                     throw new BaseModuleControllerClassNotFoundException();
                                 }
                             } else {
                                 throw new BaseModuleControllerFileNotFoundException();
                             }
                         } else {
                             include "core/modules/base/io/home.io.php";
                         }
                     }
                 } catch (DatabaseQueryFailedException $e) {
                     $transaction->force_rollback();
                     $error_io = new Error_IO($e);
                     $error_io->display_error();
                 } catch (BaseException $e) {
                     $error_io = new Error_IO($e);
                     $error_io->display_error();
                 }
                 $template = new HTMLTemplate("content_footer.html");
                 $template->output();
                 $template = new HTMLTemplate("main_footer.html");
                 $template->output();
             } else {
                 require_once "base/io/login.io.php";
                 if ($session_valid_array[1] === true) {
                     Login_IO::output(true);
                 } else {
                     Login_IO::output(false);
                 }
             }
         } else {
             Error_IO::security_out_of_box_error("Your IP was blocked by server!");
         }
     } else {
         $template->set_var("INDEX_TITLE", "Open-LIMS");
         $template->output();
         Error_IO::fatal_error($GLOBALS['fatal_error']);
     }
     $template = new HTMLTemplate("index_footer.html");
     $template->output();
 }