diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-22 09:48:19 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-22 09:48:19 +0000 |
| commit | 6fe8d2457fa96e4eff0f67379b7def24c8d47664 (patch) | |
| tree | abbc80d8f0abdee02cb270ab450fa91214f8a864 /frontends/php | |
| parent | 0fe7cbe5d251a09ff32a32ea0ce2792b9884bffe (diff) | |
- fixed authorisation (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2870 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/include/copt.lib.php | 24 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 15 | ||||
| -rw-r--r-- | frontends/php/include/perm.inc.php | 47 | ||||
| -rw-r--r-- | frontends/php/index.php | 11 | ||||
| -rw-r--r-- | frontends/php/tr_status.php | 4 |
5 files changed, 48 insertions, 53 deletions
diff --git a/frontends/php/include/copt.lib.php b/frontends/php/include/copt.lib.php index 38f915b2..3154867e 100644 --- a/frontends/php/include/copt.lib.php +++ b/frontends/php/include/copt.lib.php @@ -104,15 +104,21 @@ if(defined('USE_PROFILING')) /* protected static $starttime[]=array(); */ - /* protected static */ function getmicrotime() - { - list($usec, $sec) = explode(' ',microtime()); - return ((float)$usec + (float)$sec); + /* protected static */ function getmicrotime() { +if(defined('USE_TIME_PROF')) { + list($usec, $sec) = explode(' ',microtime()); return ((float)$usec + (float)$sec); +}else { + return 0; +} } - /* protected static */ function getmemoryusage() - { + + /* protected static */ function getmemoryusage() { +if(defined('USE_MEM_PROF')) { return memory_get_usage('memory_limit'); +} else { + return 0; +} } /* protected static */ function mem2str($size) @@ -132,14 +138,8 @@ if(defined('USE_PROFILING')) if(is_null($type)) $type='global'; -if(defined('USE_TIME_PROF')) -{ $starttime[$type] = COpt::getmicrotime(); -} -if(defined('USE_MEM_PROF')) -{ $memorystamp[$type] = COpt::getmemoryusage(); -} if(defined('USE_SQLREQUEST_PROF')) { $sqlmark[$type] = count($sqlrequests); diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 958e4c44..c2c4337c 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -22,14 +22,14 @@ // DATABASE CONFIGURATION -// $DB_TYPE ="ORACLE"; + $DB_TYPE ="ORACLE"; // $DB_TYPE ="POSTGRESQL"; - $DB_TYPE ="MYSQL"; +// $DB_TYPE ="MYSQL"; $DB_SERVER ="localhost"; - $DB_DATABASE ="zabbix"; +// $DB_DATABASE ="zabbix"; // $DB_DATABASE ="osmiy"; - $DB_USER ="root"; - $DB_PASSWORD =""; + $DB_USER ="scott"; + $DB_PASSWORD ="tiger"; // END OF DATABASE CONFIGURATION // $USER_DETAILS =""; @@ -279,6 +279,9 @@ COpt::savesqlrequest($query); function zbx_dbstr($var) { - return "'".addslashes($var)."'"; + $result = "'".addslashes($var)."'"; +//SDI($result); + return $result; + //return "'".addslashes($var)."'"; } ?> diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php index a2e79767..bb98a3f7 100644 --- a/frontends/php/include/perm.inc.php +++ b/frontends/php/include/perm.inc.php @@ -33,31 +33,36 @@ define("GROUP_RIGHT", 0); global $_COOKIE; global $_REQUEST; - $USER_DETAILS = array("alias"=>"- unknown -","userid"=>0); + $USER_DETAILS = NULL; $USER_RIGHTS = array(); - if(isset($_COOKIE["sessionid"])) $sessionid = $_COOKIE["sessionid"]; - else unset($sessionid); - - if(isset($sessionid)) + if(isset($_COOKIE["sessionid"])) { - $sql = "select u.* from sessions s,users u". + $sessionid = $_COOKIE["sessionid"]; + $USER_DETAILS = DBfetch(DBselect("select u.*,s.* from sessions s,users u". " where s.sessionid=".zbx_dbstr($sessionid)." and s.userid=u.userid". - " and ((s.lastaccess+u.autologout>".time().") or (u.autologout=0))"; - } else { - $sql = "select u.* from users u where u.alias='guest'"; - } + " and ((s.lastaccess+u.autologout>".time().") or (u.autologout=0))")); - $db_users = DBselect($sql); - $USER_DETAILS = DBfetch($db_users); - if(!$USER_DETAILS) - { - unset($sessionid); - unset($_COOKIE["sessionid"]); + if(!$USER_DETAILS) + { + $USER_DETAILS = array("alias"=>"- unknown -","userid"=>0); + + setcookie("sessionid",$sessionid,time()-3600); + unset($_COOKIE["sessionid"]); + unset($sessionid); - $db_users = DBselect("select u.* from users u where u.alias='guest'"); - $USER_DETAILS = DBfetch($db_users); + show_header("Login",0,0,1); + show_error_message("Session was ended, please relogin!"); + show_page_footer(); + exit; + } + } else { + setcookie("sessionid",$sessionid,time()-3600); + unset($sessionid); + unset($_COOKIE["sessionid"]); + $USER_DETAILS = DBfetch(DBselect("select u.* from users u where u.alias='guest'")); } + if($USER_DETAILS) { if(isset($sessionid)) @@ -79,13 +84,11 @@ define("GROUP_RIGHT", 0); array_push($USER_RIGHTS,$usr_right); } - return; } else { - echo 'guest user can\'t be found'; - exit; + $USER_DETAILS = array("alias"=>"- unknown -","userid"=>0); } // Incorrect login @@ -96,7 +99,6 @@ define("GROUP_RIGHT", 0); unset($_COOKIE["sessionid"]); } - //TODO make a javascript function for redirection!!! if($page["file"]!="index.php") { echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">"; @@ -107,7 +109,6 @@ define("GROUP_RIGHT", 0); insert_login_form(); show_page_footer(); - //Redirect("index.php"); //TODO make a javascript function for redirection!!! //END TODO exit; } diff --git a/frontends/php/index.php b/frontends/php/index.php index 06a5dc2b..8916ff07 100644 --- a/frontends/php/index.php +++ b/frontends/php/index.php @@ -39,20 +39,11 @@ check_fields($fields); ?> <?php - - if(isset($_COOKIE["sessionid"])) - { - $sessionid=$_COOKIE["sessionid"]; - } - else - unset($sessionid); - - if(isset($_REQUEST["reconnect"]) && isset($sessionid)) + if(isset($_REQUEST["reconnect"]) && isset($_COOKIE["sessionid"])) { DBexecute("delete from sessions where sessionid=".zbx_dbstr($sessionid)); setcookie("sessionid",$sessionid,time()-3600); unset($_COOKIE["sessionid"]); - unset($sessionid); } if(isset($_REQUEST["enter"])&&($_REQUEST["enter"]=="Enter")) diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php index b5712710..756ff87a 100644 --- a/frontends/php/tr_status.php +++ b/frontends/php/tr_status.php @@ -335,14 +335,14 @@ $sql="select t.priority,count(*) as cnt from triggers t,hosts h,items i,functions f".$groupname. " where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid". " and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE. - " and t.triggerid=f.triggerid and t.description $select_cond $cond $groupcond group by 1"; + " and t.triggerid=f.triggerid and t.description $select_cond $cond $groupcond group by t.priority"; } else { $sql="select t.priority,count(*) as cnt from triggers t,hosts h,items i,functions f".$groupname. " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.status=0". " and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE. - " and t.description $select_cond $cond $groupcond group by 1"; + " and t.description $select_cond $cond $groupcond group by t.priority"; } $result=DBselect($sql); $p0=$p1=$p2=$p3=$p4=$p5=0; |
