| 1 |
<?php |
| 2 |
class ODB_Logger |
| 3 |
{ |
| 4 |
/******************************************************************************************** |
| 5 |
* CONSTRUCTOR |
| 6 |
********************************************************************************************/ |
| 7 |
function __construct() |
| 8 |
{ |
| 9 |
} // __construct() |
| 10 |
|
| 11 |
|
| 12 |
/******************************************************************************************** |
| 13 |
* WRITE RESULTS TO LOG FILE |
| 14 |
********************************************************************************************/ |
| 15 |
function write_log() |
| 16 |
{ |
| 17 |
global $odb_class; |
| 18 |
|
| 19 |
if($odb_class->odb_rvg_options['logging_on'] == "Y") |
| 20 |
{ $file = $odb_class->odb_logfile_path; |
| 21 |
if(!file_exists($file)) |
| 22 |
{ // NEW LOG FILE |
| 23 |
$html = ' |
| 24 |
<!doctype html> |
| 25 |
<html> |
| 26 |
<head> |
| 27 |
<meta charset="utf-8"> |
| 28 |
<title>Optimize Database after Deleting Revisions v'.$odb_class->odb_version.' - LOG</title> |
| 29 |
<style type="text/css"> |
| 30 |
body, td, th { |
| 31 |
font-family: Arial, Helvetica, sans-serif; |
| 32 |
font-size: 12px; |
| 33 |
} |
| 34 |
th { |
| 35 |
border-top:solid 1px #000; |
| 36 |
border-bottom:solid 1px #000; |
| 37 |
} |
| 38 |
td { |
| 39 |
padding-bottom:4px; |
| 40 |
border-bottom:dotted 1px #CCC; |
| 41 |
} |
| 42 |
#header { |
| 43 |
margin-left:6px; |
| 44 |
margin-bottom:8px; |
| 45 |
} |
| 46 |
#header a { |
| 47 |
text-decoration:none; |
| 48 |
font-weight:bold; |
| 49 |
} |
| 50 |
</style> |
| 51 |
</head> |
| 52 |
<body> |
| 53 |
<div id="header"> |
| 54 |
<h2><a href="https://wordpress.org/plugins/rvg-optimize-database/" target="_blank">Optimize Database after Deleting Revisions v'.$odb_class->odb_version.'</a></h2> |
| 55 |
'.__('A WordPress Plugin by','rvg-optimize-database').' <a href="http://cagewebdev.com" target="_blank"><span class="odb-bold">CAGE Web Design</span></a> | <a href="http://rvg.cage.nl" target="_blank"><span class="odb-bold">Rolf van Gelder</span></a>, Eindhoven, '.__('The Netherlands','rvg-optimize-database').'</span> |
| 56 |
</div> |
| 57 |
<table width="100%" border="0" cellspacing="6" cellpadding="1"> |
| 58 |
<tr> |
| 59 |
<th width="8%" align="left" valign="top">'.__('time','rvg-optimize-database').'</th> |
| 60 |
<th width="8%" align="right" valign="top">'.__('deleted<br />revisions','rvg-optimize-database').'</th> |
| 61 |
<th width="8%" align="right" valign="top">'.__('deleted<br />trash','rvg-optimize-database').'</th> |
| 62 |
<th width="8%" align="right" valign="top">'.__('deleted<br />spam','rvg-optimize-database').'</th> |
| 63 |
<th width="8%" align="right" valign="top">'.__('deleted<br />tags','rvg-optimize-database').'</th> |
| 64 |
<th width="8%" align="right" valign="top">'.__('deleted<br />transients','rvg-optimize-database').'</th> |
| 65 |
<th width="8%" align="right" valign="top">'.__('deleted<br />pingbacks<br />trackbacks','rvg-optimize-database').'</th> |
| 66 |
<th width="8%" align="right" valign="top">'.__('deleted<br />orphans','rvg-optimize-database').'</th> |
| 67 |
<th width="8%" align="right" valign="top">'.__('nr of optimized tables','rvg-optimize-database').'</th> |
| 68 |
<th width="8%" align="right" valign="top">'.__('database size BEFORE','rvg-optimize-database').'</th> |
| 69 |
<th width="8%" align="right" valign="top">'.__('database size AFTER','rvg-optimize-database').'</th> |
| 70 |
<th width="8%" align="right" valign="top">'.__('SAVINGS','rvg-optimize-database').'</th> |
| 71 |
</tr> |
| 72 |
</table> |
| 73 |
'; |
| 74 |
file_put_contents($file, $html, FILE_APPEND); |
| 75 |
} |
| 76 |
|
| 77 |
$html = ' |
| 78 |
<table width="100%" border="0" cellspacing="6" cellpadding="0"> |
| 79 |
<tr> |
| 80 |
<td width="8%" valign="top"><span class="odb-bold">'.$odb_class->log_arr["time"].'</span></td> |
| 81 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["revisions"].'</td> |
| 82 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["trash"].'</td> |
| 83 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["spam"].'</td> |
| 84 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["tags"].'</td> |
| 85 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["transients"].'</td> |
| 86 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["pingbacks"].'</td> |
| 87 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["orphans"].'</td> |
| 88 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["tables"].'</td> |
| 89 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["before"].'</td> |
| 90 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["after"].'</td> |
| 91 |
<td width="8%" align="right" valign="top">'.$odb_class->log_arr["savings"].'</td> |
| 92 |
</tr> |
| 93 |
</table> |
| 94 |
'; |
| 95 |
file_put_contents($file, $html, FILE_APPEND); |
| 96 |
} // if($odb_class->odb_rvg_options['logging_on'] == "Y") |
| 97 |
} // write_log() |
| 98 |
|
| 99 |
|
| 100 |
/******************************************************************************************** |
| 101 |
* ADD A MESSAGE TO THE DEBUG LOG FILE |
| 102 |
********************************************************************************************/ |
| 103 |
function write_debug_log($msg) |
| 104 |
{ |
| 105 |
global $odb_class; |
| 106 |
|
| 107 |
if (defined('WP_DEBUG') && WP_DEBUG) |
| 108 |
{ // ONLY USE THIS LOG IN DEBUG MODE |
| 109 |
$file = $odb_class->odb_logfile_debug_path; |
| 110 |
$txt = Date('Y/m/d H:i:s').' '.$msg."\n"; |
| 111 |
file_put_contents($file, $txt, FILE_APPEND); |
| 112 |
} |
| 113 |
} // write_debug_log() |
| 114 |
|
| 115 |
} // ODB_Logger |
| 116 |
|