PCCS MySQLDatabase Admin Tool version 1.3.4


/ -> mysqldb_app_includes.php

1  <?php
2  ////////////////////////////////////////////////////////////////////////////////////////////////////////////
3  // coder: Chauncey Thorn
4  // email: cthorn
5  /************************************************************************
6  PCCS MySQLDatabase Admin Tool
7  Copyright (C) Chauncey Thorn
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 2
12  of the License, or (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA , USA.
22  **************************************************************************/
23  // Filename: mysqldb_app_includes.php
24  // Function: will become central location for include files
25  // will include as require('mysqldb_app_includes.php');
26  //
27  // updated 10-23-2000
28  // -- attempt to make windows friendly
29  // you can change this if you want. I think its a good hash string
30  // IP address and date eg 192.168.2.8810262000
31  // if you change this you will need to change it also in the
32  // dologin.php
33  // so leave it be ... (+:
34 
35  $private_hash = $REMOTE_ADDR . date("mdY");
36 
37  // Function for logging
38  $ip = $REMOTE_ADDR;
39  function logAction($action,$logfile_name) {
40  global $db_user, $ip;
41 
42          if(file_exists("logs/$logfile_name")) {
43           $logfile = fopen("logs/$logfile_name","a");
44           fputs($logfile,$ip.",".date("dS of F Y h:i:s A")."," . $db_user .",". $action ."\n");
45           fclose($logfile);
46          } else {
47          exec ("touch logs/$logfile_name");
48           $logfile = fopen("logs/$logfile_name","a");
49           fputs($logfile,$ip.",".date("dS of F Y h:i:s A")."," . $db_user .",". $action ."\n");
50           fclose($logfile);
51       }
52     }
53 
54 
55 
56  // Get OSTYPE to make this work
57  $os_type = $HTTP_ENV_VARS["OSTYPE"];
58 
59 
60 
61 
62  //
63  // Making windows friendly
64  //
65  if (eregi("Win",$os_type)) {
66    // I haven't tested the windows portion of this code
67    // don't have a mysql windows setup
68    // It should work ... let me know if it doesn't
69    $doc_root = $DOCUMENT_ROOT . "\\pccsmysqladm\\";
70    $incs_dir = $doc_root . "incs\\";
71  } else {
72 
73  $app_logs = $DOCUMENT_ROOT . "/pccsmysqladm/logs";
74 
75    // Check to see if application is installed correctly
76    // Unix system not needed for windows
77    // If you are running Linux *BSD UNIX and ran the fix_perm.sh
78    // this .INSTALLED should be in the logs/
79    // Check to see if file exsit if not force them to run fix_perm.sh
80    if(!file_exists($app_logs ."/.INSTALLED")) {
81       die("<H3>Application Not installed completely. Please run bin/fix_perm.sh</H3>");
82     }
83 
84    $doc_root = $DOCUMENT_ROOT . "/pccsmysqladm/";
85    $incs_dir = $doc_root . "incs/";
86  }
87 
88 
89  $URL = $SERVER_HOST . "/pccsmysqladm/login.php";
90 
91  // See if person connecting to system is logged into web application
92  // Logon Manager
93  //
94  // if not logged in redir to login.php
95  if(isset($LOGGEDIN) == FALSE) {
96 
97        header ("Location: $URL");
98 
99   } else {
100 
101    // Check to see if userid_hash matches
102    // This is a cookie set via the dologin.php
103    
104    $hash=md5($db_user.$private_hash);
105     if ($hash == $userid_hash) {
106          // Do nothing ...
107          } else {
108         //hashed didn't match - must be a hack attempt?
109         // this should be logged ...
110         // with remote_addr and userid of attempt
111         // will code later.. (+:
112         // for now redir them to login.php
113         // updated
114         // -- logging this possible hack
115         logAction("hashed didn't match - must be a hack attempt?","dblog.txt");
116       header ("Location: $URL");
117          }
118 
119  }
120 
121  // Now include the files that contain functions, etc for this
122  // application.
123  // Do not change the order files
124   // updated
125   // Getting variable $whichlang from global.vars.php
126   // more lang file friendly
127   
128   require($incs_dir . 'dbconnect.php');
129   require($incs_dir . 'global.vars.php');
130   require($incs_dir . 'lang-' . $whichlang . '.include.php');
131   require($incs_dir . 'logging_function.php');
132   require($incs_dir . 'mysqldb_functions.php');
133 
134 
135  ?>
136 


Generated: Sat Jan 27 15:40:36 2001 Generated by PHPXref 0.1.2
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002