Commit 4df57d8521a14c58b0d11a438320c66c68ff5e55

Authored by Conrad Vermeulen
1 parent dd480f32

KTS-1687

"Double quote to single quote conversion"
Fixed. Minor string scan optimisation.
Reviewed by: Jalaloedien Abrahams

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6220 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 23 additions and 21 deletions
control.php
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 */ 25 */
26 26
27 // main library routines and defaults 27 // main library routines and defaults
28 -require_once("./config/dmsDefaults.php"); 28 +require_once('config/dmsDefaults.php');
29 29
30 /** 30 /**
31 * $Id$ 31 * $Id$
@@ -48,17 +48,17 @@ require_once("./config/dmsDefaults.php"); @@ -48,17 +48,17 @@ require_once("./config/dmsDefaults.php");
48 48
49 $action = $_REQUEST['action']; 49 $action = $_REQUEST['action'];
50 50
51 -if ($action != "login") { 51 +if ($action != 'login') {
52 52
53 // check the session, but don't redirect if the check fails 53 // check the session, but don't redirect if the check fails
54 $ret = checkSessionAndRedirect(false); 54 $ret = checkSessionAndRedirect(false);
55 if ($ret === true) { 55 if ($ret === true) {
56 //get around the problem with search 56 //get around the problem with search
57 - if (strcmp($_REQUEST['fForStandardSearch'], "yes") == 0) {  
58 - $action = "standardSearch"; 57 + if (strcmp($_REQUEST['fForStandardSearch'], 'yes') == 0) {
  58 + $action = 'standardSearch';
59 } else if (!isset($action)) { 59 } else if (!isset($action)) {
60 // session check succeeds, so default action should be the dashboard if no action was specified 60 // session check succeeds, so default action should be the dashboard if no action was specified
61 - $action = "dashboard"; 61 + $action = 'dashboard';
62 } 62 }
63 } else { 63 } else {
64 // session check fails, so default action should be the login form if no action was specified 64 // session check fails, so default action should be the login form if no action was specified
@@ -71,13 +71,13 @@ if ($action != "login") { @@ -71,13 +71,13 @@ if ($action != "login") {
71 } elseif ($action <> $dest) { 71 } elseif ($action <> $dest) {
72 // we have a controller link and auth has failed, so redirect to the login page 72 // we have a controller link and auth has failed, so redirect to the login page
73 // with the controller link as the redirect 73 // with the controller link as the redirect
74 - $url = generateControllerUrl("login");  
75 - $redirect = urlencode($_SERVER[PHP_SELF] . "?" . $_SERVER['QUERY_STRING']); 74 + $url = generateControllerUrl('login');
  75 + $redirect = urlencode($_SERVER[PHP_SELF] . '?' . $_SERVER['QUERY_STRING']);
76 if ((strlen($redirect) > 1)) { 76 if ((strlen($redirect) > 1)) {
77 - $url = $url . "&redirect=" . $redirect; 77 + $url = $url . '&redirect=' . $redirect;
78 } 78 }
79 if (PEAR::isError($ret)) { 79 if (PEAR::isError($ret)) {
80 - $url = $url . "&errorMessage=" . urlencode($ret->getMessage()); 80 + $url = $url . '&errorMessage=' . urlencode($ret->getMessage());
81 } 81 }
82 redirect($url); 82 redirect($url);
83 exit(0); 83 exit(0);
@@ -99,16 +99,16 @@ if (is_array($queryString)) { @@ -99,16 +99,16 @@ if (is_array($queryString)) {
99 99
100 if (empty($queryString)) { 100 if (empty($queryString)) {
101 // need to strip query string params from action before attempting to retrieve from sitemap 101 // need to strip query string params from action before attempting to retrieve from sitemap
102 - $queryString = ""; 102 + $queryString = '';
103 // check for the presence of additional params 103 // check for the presence of additional params
104 - if (strstr($_SERVER["QUERY_STRING"], "&")) { 104 + if (strstr($_SERVER['QUERY_STRING'], '&')) {
105 // strip and save the querystring 105 // strip and save the querystring
106 - $queryString = substr($_SERVER["QUERY_STRING"], strpos($_SERVER["QUERY_STRING"], "&")+1, strlen($_SERVER["QUERY_STRING"]));  
107 - } else if (strstr($_SERVER["QUERY_STRING"], "?")) { 106 + $queryString = substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], '&')+1, strlen($_SERVER['QUERY_STRING']));
  107 + } else if (strstr($_SERVER['QUERY_STRING'], '?')) {
108 // strip and save the querystring 108 // strip and save the querystring
109 - $queryString = substr($_SERVER["QUERY_STRING"], strpos($_SERVER["QUERY_STRING"], "?")+1, strlen($_SERVER["QUERY_STRING"])); 109 + $queryString = substr($_SERVER['QUERY_STRING'], strpos($_SERVER['QUERY_STRING'], '?')+1, strlen($_SERVER['QUERY_STRING']));
110 // update 110 // update
111 - $action = substr($_SERVER["QUERY_STRING"], 0, strpos($_SERVER["QUERY_STRING"], "?")); 111 + $action = substr($_SERVER['QUERY_STRING'], 0, strpos($_SERVER['QUERY_STRING'], '?'));
112 } 112 }
113 } 113 }
114 114
@@ -118,13 +118,13 @@ if ($action == &#39;dashboard&#39;) { @@ -118,13 +118,13 @@ if ($action == &#39;dashboard&#39;) {
118 } 118 }
119 119
120 // retrieve the page from the sitemap (checks whether this user has access to the requested page) 120 // retrieve the page from the sitemap (checks whether this user has access to the requested page)
121 -$page = $default->siteMap->getPage($action, isset($_SESSION["userID"]) ? $_SESSION["userID"] : ""); 121 +$page = $default->siteMap->getPage($action, isset($_SESSION['userID']) ? $_SESSION['userID'] : '');
122 122
123 if (!$page) { 123 if (!$page) {
124 // this user doesn't have permission to access the page 124 // this user doesn't have permission to access the page
125 // or there is no page mapping for the requested action 125 // or there is no page mapping for the requested action
126 // redirect to no permission page 126 // redirect to no permission page
127 - $default->log->error("control.php getPage failed for ($action, " . $_SESSION["userID"] . ")"); 127 + $default->log->error("control.php getPage failed for ($action, " . $_SESSION['userID'] . ")");
128 redirect("$default->uiUrl/noAccess.php"); 128 redirect("$default->uiUrl/noAccess.php");
129 } else { 129 } else {
130 $page = $default->rootUrl . $page; 130 $page = $default->rootUrl . $page;
@@ -132,15 +132,17 @@ if (!$page) { @@ -132,15 +132,17 @@ if (!$page) {
132 // strip querystring from the page returned from the sitemap 132 // strip querystring from the page returned from the sitemap
133 // before setting page authorisation flag (since checkSession checks page level 133 // before setting page authorisation flag (since checkSession checks page level
134 // access by checking $_SESSION["pageAccess"][$_SERVER["PHP_SELF"] ie. without querystring(?) 134 // access by checking $_SESSION["pageAccess"][$_SERVER["PHP_SELF"] ie. without querystring(?)
135 - if (strstr($page, "?")) {  
136 - $accessPage = substr($page, 0, strpos($page, "?")); 135 +
  136 + $paramStart=strpos($page, '?');
  137 + if ($paramStart !== false) {
  138 + $accessPage = substr($page, 0, $paramStart);
137 } else { 139 } else {
138 $accessPage = $page; 140 $accessPage = $page;
139 } 141 }
140 - $_SESSION["pageAccess"][$accessPage] = true; 142 + $_SESSION['pageAccess'][$accessPage] = true;
141 // if we have a querystring add it on 143 // if we have a querystring add it on
142 if (strlen($queryString) > 0) { 144 if (strlen($queryString) > 0) {
143 - $page = $page . (strstr($page, "?") ? "&$queryString" : "?$queryString"); 145 + $page = $page . (($paramStart !== false) ? "&$queryString" : "?$queryString");
144 $default->log->info("control.php: about to redirect to $page"); 146 $default->log->info("control.php: about to redirect to $page");
145 } 147 }
146 redirect($page); 148 redirect($page);