Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[Addon] Error Log for 2.07 and svn
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2011-11-18 15:02:04
Ok here is an mod I been using for an while about the new mysql wrapper in 2.07+

I love the new wrapper but as people notice it has no real ability to view the sql error if you get 1.

So I came up with this addon, as people prob realize its for 2.07+ and svn only,

I guess with some major mods could work for older versions but its mostly directed at the newer versions.

1st: sql

 DROP TABLE IF EXISTS `log_error`;

CREATE TABLE IF NOT EXISTS `log_error` (

  `id` int(10) NOT NULL auto_increment,

  `added` datetime default NULL,

  `txt` text,

  `type` text,

  `minclass` tinyint(2) NOT NULL default '5',

  `ip` varchar(70) NOT NULL default '',

  `username` varchar(70) NOT NULL default '',

  PRIMARY KEY  (`id`),

  KEY `added` (`added`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
2nd: add the following function to backend/functions.php


 function write_errorlog($text)

{

$ip = $_SERVER['REMOTE_ADDR'];

$text1 = $text ." On: ". $ip;

$text = sqlesc($text1);

$added = sqlesc(get_date_time());

$type = "error_log";

SQL_Query_exec("INSERT INTO log_error (added, txt, type) VALUES($added, $text, '$type')");

}





3: add the following function to languages/english.php



 $LANG["LOG_ERROR"] = "Error Log";





4: find in backend/mysql.class.php



		 error_log($msg);



and after add:



		 write_errorlog($msg);





That basically the hard part, now to link to the errorlog,  I personally use an link in blocks/navigate_block.php

makes it easier to find due to the fact its on every page but in thory if wanted to could add it to the main control panel for staff.

but in this post I will show how to do it in the navigate block

now some place in blocks/navigate_block.php add:



 if ($CURUSER && $CURUSER["edit_users"]=="yes")

{

echo "<li><a href='errorlog.php'>".T_("LOG_ERROR")."</a></li>";

}



now create the following page in the root of your site:

errorlog.php



 <?

error_reporting(E_ALL ^ E_NOTICE);

require_once("backend/functions.php");

dbconn(false);

loggedinonly();

global $site_config;

global $CURUSER;



$staff_page = T_("LOG_ERROR");

if (!$CURUSER || $CURUSER["edit_users"]!="yes"){

 show_error_msg(T_("ERROR"), T_("SORRY_NO_RIGHTS_TO_ACCESS"), 1);

}

stdhead("$staff_page");



$res = SQL_Query_exec("SELECT COUNT(*) FROM log_error WHERE type='error_log'");

$row = mysql_fetch_array($res);

$count = $row[0];



$perpage = 100;



list($pagertop, $pagerbottom, $limit) = pager(100, $count, "errorlog.php?");



$res = SQL_Query_exec("SELECT added, txt FROM log_error WHERE type='error_log' ORDER BY added DESC $limit");

if (mysql_num_rows($res) == 0)





print("<b>".T_("LOG_IS_EMPTY")."</b> For: $staff_page\n");

else

{



echo $pagertop;



print("<table border=1 cellspacing=0 cellpadding=5>\n");

print("<tr><td class=tabletitle align=left>Date</td><td class=tabletitle align=left>Time</td><td class=tabletitle align=left>Event</td></tr>\n");

while ($arr = mysql_fetch_assoc($res))

{

$color = '#ececec';

if (strpos($arr['txt'],T_("WAS_CREATED"))) $color = "#ececec";

if (strpos($arr['txt'],T_("WAS_DELETED_BY"))) $color = "#ececec";

if (strpos($arr['txt'],T_("WAS_UPLOADED_BY"))) $color = "#ececec";

if (strpos($arr['txt'],T_("WAS_EDITED_BY"))) $color = "#ececec";

$date = substr($arr['added'], 0, strpos($arr['added'], " "));

$time = substr($arr['added'], strpos($arr['added'], " ") + 1);





print("<tr class=tableb><td style=background-color:$color><font color=black>$date</td><td style=background-color:$color><font color=black>$time</td><td style=background-color:$color align=left><font color=black>".$arr['txt']."</font></font></font></td></tr>\n");

}

print("</table>");

}

echo $pagerbottom;



print("<p>Times are in GMT.</p>\n");

stdfoot();



?>



That should be it, some people might ask why another db table, well keeps the error logs out of the main log table and makes it easier if really want to look at them in what ever you use to view the sql.

2011_11_18_0844.png
2011_11_18_0844.png
Unknown User
2011-11-18 17:38:24
Nice work Is it ok to add to core?
Unknown User
2011-11-18 18:07:37
fine with me
Unknown User
2011-11-18 19:43:30
gdgd il add it to core before it's released as it could be very handy for when people come here saying they have a SQL Error has they could just copy the error message here.
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728