Hay Jenkin. Glad to hear you like the idea! Just gotta get it working now :)
I've added that code change got the scrip to load. Problem now is it's not loading any data. It just return loads of blank rows in 1.2.6 and in 1.3.0.2
"Fatal error: Maximum execution time of 60 seconds exceeded in /home/***/***/***/admin/searchlog.php on line 196".
It's seem stuck in a loop.
I echoed out the SQL that is being run and if I run it via PHPMYADMIN and it works, but not via the script:
Code:
SELECT id, date, searchterm, count(*) AS Number FROM zen_search_log WHERE searchterm is not null AND searchterm not like '' GROUP BY searchterm ORDER BY Number DESC LIMIT 0, 15
It also doesn't appear to be loading the language file either.
This is a the code I've got so far:
By the way I'm trying this on 1.2.6 + 1.3.0.2
Code:
<?php
//
// +----------------------------------------------------------------------+
// |zen-cart Open Source E-commerce |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 The zen-cart developers |
// | |
// | http://www.zen-cart.com/index.php |
// | |
// | Portions Copyright (c) 2003 osCommerce |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the GPL license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.zen-cart.com/license/2_0.txt. |
// | If you did not receive a copy of the zen-cart license and are unable |
// | to obtain it through the world-wide-web, please send a note to |
// | [email protected] so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// $Id: sales_log.php,v 0.1 2006/07/08 15:02:25 wilt Exp $
// Revised by: TheOracle.
require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();
$languages_id = $_SESSION['languages_id'];
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<link rel="stylesheet" href="cal/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<SCRIPT type="text/javascript" src="cal/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js?random=20060118"></script>
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<script type="text/javascript">
<!--
function init()
{
cssjsmenu('navbar');
if (document.getElementById)
{
var kill = document.getElementById('hoverJS');
kill.disabled = true;
}
}
// -->
</script>
</head>
<body onLoad="init()">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<br/>
<table width="100%" border="0" cellspacing="0" cellpadding="8">
<tr>
<td align="center" bgcolor="#CCCCCC"><?php echo DATE_RANGE. ' ' . MATCH_SEARCH_TERM; ?></td>
<td align="center" bgcolor="#CCCCCC"><?php echo MATCH_SEARCH; ?></td>
<td align="center" bgcolor="#CCCCCC"><?php echo GLOBAL_ACTIONS; ?></td>
<td width="25%" bgcolor="#FF9900"><?php echo INFO; ?></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#CCCCCC">
<?php echo COMING_SOON; ?>
<?php $mydate = date("Y-m-d"); ?>
<!--<form name="form1" method="post" action="">
<label>First Date
<input type="text" value="<?php echo $mydate; ?>" name="theDate">
<input name="button" type="button" onClick="displayCalendar(document.forms[0].theDate,'yyyy-mm-dd',this)" value="Cal">
</label>
<label>
<br>
Second Date:
<input type="text" value="<?php echo $mydate; ?>" name="theDate2">
<input name="button2" type="button" onClick="displayCalendar(document.forms[0].theDate,'yyyy-mm-dd',this)" value="Cal">
</label>
<br>
<br>
<input type="submit" name="submit" type="<?php echo SEARCHLOG_SUBMIT; ?>">
</form>--></td>
<td align="center" valign="top" bgcolor="#CCCCCC"><p><?php echo COMING_SOON; ?></p></td>
<td align="center" valign="top" bgcolor="#CCCCCC"><p><?php echo COMING_SOON; ?></p></td>
<td width="25%" valign="top" bgcolor="#FF9900"><p><?php echo COPYRIGHT_AUTHOR_URL; ?></p>
<p><?php zen_href_link('#', '', 'NONSSL'); ?></a></p></td>
</tr>
</table>
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
<tr>
<!-- body_text //-->
<td width="100%" valign="top">
<?php
if (isset($_GET['id']) || isset($_POST['id'])) {
$id = (isset($_POST['id'])) ? intval(trim(zen_db_prepare_input($_POST['id']))) : 0;
} else {
$id = 0;
} ###### End of if statement.
switch( $_GET['action'] ) {
case "delete":
if ($_SESSION['admin_id'] && !empty($id)) {
$sql_delete = $db->Execute("delete from '" . TABLE_SEARCHLOG . "' where id = ".(int)$id);
if ($sql_delete) {
$messageStack->add_session(ENTRY_SEARCHLOG_DELETE_SUCCESSFUL. ' ' .$id, 'success');
} else {
$messageStack->add_session(ENTRY_SEARCHLOG_DELETE_FAILED. ' ' .$id, 'error');
} ###### End of if statement.
} else {
$messageStack->add_session(ENTRY_SEARCHLOG_ID_NOT_FOUND, 'error');
} ###### End of if statement.
break;
case "deleteall":
if ($_SESSION['admin_id'] && !empty($id)) {
$sql_delete = $db->Execute("delete from '" . TABLE_SEARCHLOG . "' where id = ".$id);
if ($sql_delete) {
$messageStack->add_session(ENTRY_SEARCHLOG_DELETE_SUCCESSFUL. ' ' .$id, 'success');
} else {
$messageStack->add_session(ENTRY_SEARCHLOG_DELETE_FAILED. ' ' .$id, 'error');
} ###### End of if statement.
} else {
$messageStack->add_session(ENTRY_SEARCHLOG_ID_NOT_FOUND, 'error');
} ###### End of if statement.
break;
} ###### End of switch case statement.
?>
<table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\">
<tr>
<td width=\"110\"><?php echo SEARCH_TERM; ?></td>
<td><?php echo NUMBER_TIMES_SEARCHED_FOR; ?></td>
<td><?php echo SEARCHLOG_DATE; ?></td>
<td><?php echo SEARCHLOG_ACTION; ?></td>
</tr>
<?php
$color1 = "#BFD8BC";
$color2 = "#E0E0E0";
$row_count = 0;
if (!isset($_GET['page']) || empty($_GET['page'])) {
$page = 1;
} else {
$page = $_GET['page'];
} ###### End of if statement.
// Define the number of results per page
if (isset($resultcount) && $resultcount != 0) {
$max_results = $resultcount;
} else {
$max_results = 15;
} ###### End of if statement.
// Figure out the limit for the query based
// on the current page number.
$set_page = intval(trim($page));
$set_max_results = intval(trim($max_results));
$from = (($set_page * $set_max_results) - $set_max_results);
$set_from = (isset($from)) ? trim($from) : '';
// Perform MySQL query on only the current page number's results
if ($_SESSION['admin_id'] && isset($theDate) && isset($theDate2) && $theDate != "0000-00-00" && $theDate2 != "0000-00-00") {
$sql = "SELECT id, date, searchterm, count(*) AS Number
FROM " . TABLE_SEARCHLOG . "
WHERE searchterm is not null AND searchterm not like '' AND date BETWEEN '".$theDate."' AND '".$theDate2."'
GROUP BY searchterm
ORDER BY Number DESC
LIMIT ".$set_from.", ".$set_max_results;
} else {
$sql = "SELECT id, date, searchterm, count(*) AS Number
FROM " . TABLE_SEARCHLOG . "
WHERE searchterm is not null AND searchterm not like ''
GROUP BY searchterm
ORDER BY Number DESC
LIMIT ".$set_from.", ".$set_max_results;
} ###### End of if statement.
$sql_select = $db->Execute($sql);
echo $sql;
if ($sql_select) {
while (!$searchlog_row->EOF) {
$search_id = (isset($searchlog_row->fields['id'])) ? intval(trim($searchlog_row->fields['id'])) : 0;
$mydatea = (isset($searchlog_row->fields['date'])) ? trim($searchlog_row->fields['date']) : "0000-00-00";
$searchterm = (isset($searchlog_row->fields['searchterm'])) ? (strip_tags(trim($searchlog_row->fields['searchterm']))) : "";
$number = (isset($searchlog_row->fields['Number'])) ? intval(trim($searchlog_row->fields['Number'])) : 0;
/* Now we do this small line which is basically going to tell
PHP to alternate the colors between the two colors we defined above. */
$row_color = ($row_count % 2) ? trim($color1) : trim($color2);
// Echo your table row and table data that you want to be looped over and over here.
if ($_SESSION['admin_id'] && !empty($search_id) && $search_id != 0 && !empty($mydatea) && $mydatea != "0000-00-00" && !empty($searchterm) && !empty($number) && $number != 0) {
?>
<tr>
<td width="110" bgcolor="<?php echo $row_color; ?>" nowrap><?php echo $searchterm; ?></td>
<td bgcolor="<?php echo $row_color; ?>"><?php echo $number; ?></td>
<td bgcolor="<?php echo $row_color; ?>"><?php echo $mydatea; ?></td>
<td width="100" bgcolor="<?php echo $row_color; ?>"><?php zen_href_link(FILENAME_SEARCH_LOG, 'action=delete&id='.intval(trim($search_id)), 'NONSSL'). ENTRY_DELETE_LINK; ?></a><br /></td>
</tr>
<?php
// Add 1 to the row count
$row_count++;
} ###### End of if statement.
} ###### End of while statement.
}else {
$messageStack->add_session(SEARCHLOG_FAILED_TO_SELECT_FIELDS, 'error');
} ###### End of if statement.
// Close out your table.
?>
</table>
<?php
if (isset($dateone) && isset($datetwo) && !empty($dateone) && $dateone != "0000-00-00" && !empty($datetwo) && $datetwo != "0000-00-00") {
$total_results = $db->Execute("SELECT count(DISTINCT searchterm) FROM " . TABLE_SEARCHLOG . " WHERE searchterm IS NOT NULL AND date BETWEEN '".$theDate."' and '".$theDate2."' AND searchterm NOT LIKE '' ");
} else {
$total_results = $db->Execute("SELECT count(DISTINCT searchterm) FROM " . TABLE_SEARCHLOG . " WHERE searchterm IS NOT NULL AND searchterm NOT LIKE '' ");
} ###### End of if statement.
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
#echo "Total number of distinct search terms: ". $total_results ."";
// Build Page Number Hyperlinks
echo trim(SEARCHLOG_SELECT_PAGE)."<br />";
// Build Previous Link
if ($_SESSION['admin_id'] && isset($page) && $page > 1) {
$prev = ($page - 1);
zen_href_link(FILENAME_SEARCH_LOG, 'page='.intval(trim($prev)), 'NONSSL'). SEARCHLOG_PREVIOUS_PAGE . '</a> ';
} ###### End of if statement.
for ($i = 1; $i <= $total_pages; $i++) {
if(($page) == $i) {
echo "$i ";
} else {
zen_href_link(FILENAME_SEARCH_LOG, 'page='.$i, 'NONSSL') . '$i</a> ';
} ###### End of if statement.
} ###### End of for statement.
// Build Next Link
if ($_SESSION['admin_id'] && $page < $total_pages) {
$next = ($page + 1);
zen_href_link(FILENAME_SEARCH_LOG, 'page='.intval(trim($next)), 'NONSSL'). SEARCHLOG_NEXT_PAGE . '</a> ';
} ###### End of if statement.
?>
</td>
<!-- body_text_eof //-->
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>