Changeset 16813 for trunk/FACT++
- Timestamp:
- 06/12/13 11:43:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/shift/calendar.php
r15155 r16813 2 2 3 3 require_once("config.php"); 4 5 function log_sql_error($query, $error) 6 { 7 if (!file_exists("log/")) 8 mkdir("log/", 0777, true); 9 10 $file = fopen("log/mysql.log", "a"); 11 fwrite($file, date("Y-m-d H:i:s")."\n".$query."\n".$error."\n\n"); 12 fclose($file); 13 14 return header('HTTP/1.0 500 '.$error); 15 } 4 16 5 17 function login() … … 74 86 75 87 if (!mysql_connect($dbhost, $dbuser, $dbpass)) 76 return header('HTTP/1.0 500 '.mysql_error());88 return log_sql_error("connect: ".$dbhost."[".$dbuser."]", mysql_error()); 77 89 78 90 if (!mysql_select_db($dbname)) 79 return header('HTTP/1.0 500 '.mysql_error());91 return log_sql_error("select_db: ".$dbname, mysql_error()); 80 92 81 93 if (isset($_GET['comment'])) … … 87 99 $result = mysql_query($query); 88 100 if (!$result) 89 return header('HTTP/1.0 500 '.mysql_error());101 return log_sql_error($query, mysql_error()); 90 102 91 103 if (isset($_GET['d'])) … … 126 138 $c = $_GET['c']; 127 139 128 if (!mysql_query("DELETE FROM Comments WHERE y=".$y." AND m=".$m." AND d=".$d)) 129 return header('HTTP/1.0 500 '.mysql_error()); 140 $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()); 130 143 131 if (strlen($c)>0) 132 if (!mysql_query("INSERT Comments SET y=".$y.", m=".$m.", d=".$d.", c='".$c."'")) 133 return header('HTTP/1.0 500 '.mysql_error()); 144 if (strlen($c)<=0) 145 return; 146 147 $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()); 150 134 151 return; 135 152 } … … 137 154 $u = isset($_GET['u']) ? $_GET['u'] : $_SERVER['PHP_AUTH_USER']; 138 155 139 if (!mysql_query("DELETE FROM Data WHERE y=".$y." AND m=".$m." AND d=".$d." AND u='".$u."'")) 140 return header('HTTP/1.0 500 '.mysql_error()); 156 $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()); 141 159 142 160 if (mysql_affected_rows()==0) 143 161 { 144 $x = $_GET['x']; 145 if (!mysql_query("INSERT Data SET y=".$y.", m=".$m.", d=".$d.", x=".$x.", u='".$u."'")) 146 return header('HTTP/1.0 500 '.mysql_error()); 162 $x = $_GET['x']; 163 164 $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()); 147 167 } 148 168 } … … 154 174 $result = mysql_query($query); 155 175 if (!$result) 156 return header('HTTP/1.0 500 '.mysql_error()); 176 if (!mysql_query($query)) 177 return log_sql_error($query, mysql_error()); 157 178 158 179 while ($row = mysql_fetch_array($result, MYSQL_NUM))
Note:
See TracChangeset
for help on using the changeset viewer.