PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/include/db_mysql_error.inc.php

https://github.com/AlexChien/EY_BBS
PHP | 115 lines | 91 code | 18 blank | 6 comment | 17 complexity | 2dc725fd2f65b86b9b47aca76999882b MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. /*
  3. [Discuz!] (C)2001-2009 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: db_mysql_error.inc.php 17439 2008-12-22 04:27:17Z monkey $
  6. */
  7. if(!defined('IN_DISCUZ')) {
  8. exit('Access Denied');
  9. }
  10. $timestamp = time();
  11. $errmsg = '';
  12. $dberror = $this->error();
  13. $dberrno = $this->errno();
  14. if($dberrno == 1114) {
  15. ?>
  16. <html>
  17. <head>
  18. <title>Max Onlines Reached</title>
  19. </head>
  20. <body bgcolor="#FFFFFF">
  21. <table cellpadding="0" cellspacing="0" border="0" width="600" align="center" height="85%">
  22. <tr align="center" valign="middle">
  23. <td>
  24. <table cellpadding="10" cellspacing="0" border="0" width="80%" align="center" style="font-family: Verdana, Tahoma; color: #666666; font-size: 9px">
  25. <tr>
  26. <td valign="middle" align="center" bgcolor="#EBEBEB">
  27. <br /><b style="font-size: 10px">Forum onlines reached the upper limit</b>
  28. <br /><br /><br />Sorry, the number of online visitors has reached the upper limit.
  29. <br />Please wait for someone else going offline or visit us in idle hours.
  30. <br /><br />
  31. </td>
  32. </tr>
  33. </table>
  34. </td>
  35. </tr>
  36. </table>
  37. </body>
  38. </html>
  39. <?
  40. exit();
  41. } else {
  42. if($message) {
  43. $errmsg = "<b>Discuz! info</b>: $message\n\n";
  44. }
  45. if(isset($GLOBALS['_DSESSION']['discuz_user'])) {
  46. $errmsg .= "<b>User</b>: ".htmlspecialchars($GLOBALS['_DSESSION']['discuz_user'])."\n";
  47. }
  48. $errmsg .= "<b>Time</b>: ".gmdate("Y-n-j g:ia", $timestamp + ($GLOBALS['timeoffset'] * 3600))."\n";
  49. $errmsg .= "<b>Script</b>: ".$GLOBALS['PHP_SELF']."\n\n";
  50. if($sql) {
  51. $errmsg .= "<b>SQL</b>: ".htmlspecialchars($sql)."\n";
  52. }
  53. $errmsg .= "<b>Error</b>: $dberror\n";
  54. $errmsg .= "<b>Errno.</b>: $dberrno";
  55. echo "</table></table></table></table></table>\n";
  56. echo "<p style=\"font-family: Verdana, Tahoma; font-size: 11px; background: #FFFFFF;\">";
  57. echo nl2br(str_replace($GLOBALS['tablepre'], '[Table]', $errmsg));
  58. if($GLOBALS['adminemail']) {
  59. $errlog = array();
  60. if(@$fp = fopen(DISCUZ_ROOT.'./forumdata/dberror.log', 'r')) {
  61. while((!feof($fp)) && count($errlog) < 20) {
  62. $log = explode("\t", fgets($fp, 50));
  63. if($timestamp - $log[0] < 86400) {
  64. $errlog[$log[0]] = $log[1];
  65. }
  66. }
  67. fclose($fp);
  68. }
  69. if(!in_array($dberrno, $errlog)) {
  70. $errlog[$timestamp] = $dberrno;
  71. @$fp = fopen(DISCUZ_ROOT.'./forumdata/dberror.log', 'w');
  72. @flock($fp, 2);
  73. foreach(array_unique($errlog) as $dateline => $errno) {
  74. @fwrite($fp, "$dateline\t$errno");
  75. }
  76. @fclose($fp);
  77. if(function_exists('errorlog')) {
  78. errorlog('MySQL', basename($GLOBALS['_SERVER']['PHP_SELF'])." : $dberror - ".cutstr($sql, 120), 0);
  79. }
  80. if($GLOBALS['dbreport']) {
  81. echo "<br /><br />An error report has been dispatched to our administrator.";
  82. @sendmail($GLOBALS['adminemail'], '[Discuz!] MySQL Error Report',
  83. "There seems to have been a problem with the database of your Discuz! Board\n\n".
  84. strip_tags($errmsg)."\n\n".
  85. "Please check-up your MySQL server and forum scripts, similar errors will not be reported again in recent 24 hours\n".
  86. "If you have troubles in solving this problem, please visit Discuz! Community http://www.Discuz.net.");
  87. }
  88. } else {
  89. echo '<br /><br />Similar error report has been dispatched to administrator before.';
  90. }
  91. }
  92. echo '</p>';
  93. echo '<p style="font-family: Verdana, Tahoma; font-size: 12px; background: #FFFFFF;"><a href="http://faq.comsenz.com/?type=mysql&dberrno='.$dberrno.'&dberror='.rawurlencode($dberror).'" target="_blank">&#x5230; http://faq.comsenz.com &#x641c;&#x7d22;&#x6b64;&#x9519;&#x8bef;&#x7684;&#x89e3;&#x51b3;&#x65b9;&#x6848;</a></p>';
  94. exit();
  95. }
  96. ?>