Changeset 20048 for trunk/FACT++
- Timestamp:
- 03/24/21 22:03:31 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/shift/calendar.php
r16813 r20048 7 7 if (!file_exists("log/")) 8 8 mkdir("log/", 0777, true); 9 10 if (!is_writable("log/mysql.log")) 11 return header('HTTP/1.0 500 Unable to write log'); 9 12 10 13 $file = fopen("log/mysql.log", "a"); … … 24 27 $password = $_SERVER['PHP_AUTH_PW']; 25 28 26 $con = @ldap_connect( $ldaphost);29 $con = @ldap_connect("ldap://".$ldaphost); 27 30 if (!$con) 28 31 return "ldap_connect failed to ".$ldaphost; … … 61 64 $srData = @ldap_get_entries($con, $sr); 62 65 if ($srData["count"]==0) 63 return "No results returned by ldap_get_entries for dn= ".$dn.".";66 return "No results returned by ldap_get_entries for dn='".$dn."'."; 64 67 65 68 @ldap_unbind($con); 66 69 67 70 $found = false; 68 foreach ($srData[0]['member'] as $member) 69 if (strpos($member, "cn=".$userCommonName.",")===0) 71 foreach ($srData[0]['member'] as $member) { 72 if (strpos($member, "cn=".$userCommonName.",")===0) { 70 73 return ""; 74 } 75 } 71 76 72 return " Sorry, your credentials don't match!";77 return "You need to be in the Operations group to access this page"; 73 78 } 74 79 75 80 if (isset($_GET['logout'])) 76 81 { 77 Header( "HTTP/1.0 401 Logout successfull!");78 exit();82 header( "HTTP/1.0 401 Logout successfull!"); 83 return; 79 84 } 80 85 … … 85 90 $m = $_GET['m']; 86 91 87 if (!mysql_connect($dbhost, $dbuser, $dbpass)) 88 return log_sql_error("connect: ".$dbhost."[".$dbuser."]", mysql_error()); 92 $sql = new mysqli($dbhost, $dbuser, $dbpass); 89 93 90 if (!mysql_select_db($dbname)) 91 return log_sql_error("select_db: ".$dbname, mysql_error()); 94 if ($sql->connect_error) 95 return log_sql_error("connect: ".$dbhost."[".$dbuser."]", $sql->connect_error); 96 97 if (!$sql->select_db($dbname)) 98 return log_sql_error("select_db: ".$dbname, $sql->error); 92 99 93 100 if (isset($_GET['comment'])) … … 97 104 $query .= " AND d=".$_GET['d']; 98 105 99 $result = mysql_query($query);106 $result = $sql->query($query); 100 107 if (!$result) 101 return log_sql_error($query, mysql_error());108 return log_sql_error($query, $sql->error); 102 109 103 110 if (isset($_GET['d'])) 104 111 { 105 $row = mysql_fetch_array($result, MYSQL_NUM); 106 print($row[1]); 112 $row = $result->fetch_array(); 113 if ($row) 114 print($row[1]); 107 115 return; 108 116 } 109 117 110 while ($row = mysql_fetch_array($result, MYSQL_NUM))118 while ($row = $result->fetch_array()) 111 119 { 112 120 printf("%04d%02d%s", strlen($row[1]), $row[0], $row[1]); … … 139 147 140 148 $query = "DELETE FROM Comments WHERE y=".$y." AND m=".$m." AND d=".$d; 141 if (! mysql_query($query))142 return log_sql_error($query, mysql_error());149 if (!$sql->query($query)) 150 return log_sql_error($query, $sql->error); 143 151 144 152 if (strlen($c)<=0) … … 146 154 147 155 $query = "INSERT Comments SET y=".$y.", m=".$m.", d=".$d.", c='".$c."'"; 148 if (! mysql_query($query))149 return log_sql_error($query, mysql_error());156 if (!$sql->query($query)) 157 return log_sql_error($query, $sql->error); 150 158 151 159 return; … … 155 163 156 164 $query = "DELETE FROM Data WHERE y=".$y." AND m=".$m." AND d=".$d." AND u='".$u."'"; 157 if (! mysql_query($query))158 return log_sql_error($query, mysql_error());165 if (!$sql->query($query)) 166 return log_sql_error($query, $sql->error); 159 167 160 if ( mysql_affected_rows()==0)168 if ($sql->affected_rows==0) 161 169 { 162 170 $x = $_GET['x']; 163 171 164 172 $query = "INSERT Data SET y=".$y.", m=".$m.", d=".$d.", x=".$x.", u='".$u."'"; 165 if (! mysql_query($query))166 return log_sql_error($query, mysql_error());173 if (!$sql->query($query)) 174 return log_sql_error($query, $sql->error); 167 175 } 168 176 } … … 172 180 $query .= " AND d=".$_GET['d']; 173 181 174 $result = mysql_query($query);182 $result = $sql->query($query); 175 183 if (!$result) 176 if (! mysql_query($query))177 return log_sql_error($query, mysql_error());184 if (!$sql->query($query)) 185 return log_sql_error($query, $sql->error); 178 186 179 while ($row = mysql_fetch_array($result, MYSQL_NUM))187 while ($row = $result->fetch_array()) 180 188 print($row[0]."\t".$row[1]."\t".$row[2]."\n"); 181 189 ?>
Note:
See TracChangeset
for help on using the changeset viewer.