Hallo,
voor mijn website gebruik ik het cms script van Syndeo.
Nu heb ik problemen met de code die statistieken registreert.
Op mijn site heb ik een openbaar gedeelte (dit is public=0) en een besloten gedeelte (dit is public=1)
Nu ondervind ik problemen met de statistieken van het besloten gedeelte. Of ik nou pagina's in het openbare gedeelte of het besloten gedeelte bezoek de code schrijft ten alle tijde naar mijn database public=0
dat zou niet moeten. Ik kan alleen de fout niet ontdekken. Wie kan me helpen?
De code is;
<?php
/*
* Syndeo CMS (former Site@School)
* is a website management system designed for primary schools.
* =============================================================================== *
* History Site@School:
* Original idea, coding (version 1.0) and design : Mark de Haan ([email protected])
* Ideas, improvements, expansions (versions 1.1 - 2.4):
* Karin Abma, Dirk Schouten and Fred Stuurman
* Coding version 1.1 - 2.4.10 Fred Stuurman
* =============================================================================== *
* Syndeo CMS Software Version: 3.0.01
* Copyright (C) 2007-2011: Fred Stuurman ([email protected])
* Core function:
* stats.php: last changed 27/12/2011 by Fred Stuurman ([email protected])
* $Id$
* =============================================================================== *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License in the starnet directory for more details.
*/
if (!defined('IN_SAS'))
{
die("Hacking attempt");
}
$modoption = "view"; //default choice
if (IsSet ($_GET['modoption']))
{
$modoption = sanitize($_GET['modoption'], 15, 'A');
}
if (IsSet ($_GET['s']))
{
$s = intval($_GET['s']);
}
else
{
$s = 0;
}
if (IsSet ($_GET['addip']))
{
$addip = $_GET['addip'];
}
else
{
$addip = "";
}
if (IsSet ($_GET['suboption']))
{
$suboption = sanitize($_GET['suboption'], 15, 'A');
}
else
{
$suboption = "remote";
}
if (IsSet ($_POST['ipfilter']))
{
$ipfilter = $_POST['ipfilter']; //array
$ipnames = $_POST['ipnames']; //array
}
else
{
$ipfilter = explode(",", $sas_config['stats_ip_filter']);
$ipnames = explode(",", $sas_config['stats_ip_names']);
}
if (IsSet ($_POST['remote']))
{
$remote = sanitize($_POST['remote'], 3, 'A');
}
if (IsSet ($_POST['local']))
{
$local = sanitize($_POST['local'], 3, 'A');
}
if (IsSet ($_POST['protected']))
{
$protected = sanitize($_POST['protected'], 3, 'A');
}
$table_stats = $dbprefix . "stats";
//setup sort for table query
if ((IsSet ($s) == False) OR ($s == 0))
{
$sort = "count DESC";
} //default sort is the count field
if ($s == 1)
{
$sort = "p.name";
}
//if($s==2) {$sort="p.id";}
if ($s == 3)
{
$sort = "e.name";
}
if ($s == 4)
{
$sort = "count DESC";
}
if ($s == 5)
{
$sort = "p.createdate DESC";
}
if ($s == 6)
{
$sort = "p.lastvisitdate DESC";
}
if ($s == 7)
{
$sort = "p.lastupdate DESC";
}
$i = 0;
if (($ipfilter[0] == "") AND ($suboption == "local")) //no local ip adresses given
{
$where_clause = " WHERE s.ip LIKE ('999.9.9.999')"; //for local we need at least one dummy IP
}
elseif ($ipfilter[0] == "")
{
$where_clause = "";
}
else
{
foreach ($ipfilter as $ip) //create the WHERE clause from ipfilter
{
if ($suboption == "local")
{
if ($i > 0)
{
$where_clause .= " OR s.ip LIKE ('$ip%')";
}
else
{
$where_clause = " WHERE s.ip LIKE ('$ip%')";
}
}
if ($suboption == "remote")
{
if ($i > 0)
{
$where_clause .= " AND s.ip NOT LIKE ('$ip%')";
}
else
{
$where_clause = " WHERE s.ip NOT LIKE ('$ip%')";
}
}
$i++;
}
}
if ($suboption == "local")
{
$result = mysql_query("SELECT p.id, p.name, SUM(s.count) as count, e.name, UNIX_TIMESTAMP(p.createdate),
UNIX_TIMESTAMP(p.lastvisitdate) ,
p.section , UNIX_TIMESTAMP(p.lastupdate), s.pageid
FROM $table_stats s
LEFT JOIN $table_pages p ON s.pageid=p.id
LEFT JOIN $table_sections e ON p.section=e.id
$where_clause AND s.public = 0
GROUP BY s.pageid
ORDER BY $sort");
}
if ($suboption == "remote")
{
$result = mysql_query("SELECT p.id, p.name, SUM(s.count) as count, e.name,
UNIX_TIMESTAMP(p.createdate), UNIX_TIMESTAMP(p.lastvisitdate) ,
p.section , UNIX_TIMESTAMP(p.lastupdate), s.pageid
FROM $table_stats s
LEFT JOIN $table_pages p ON s.pageid=p.id
LEFT JOIN $table_sections e ON p.section=e.id
$where_clause AND s.public = 0
GROUP BY s.pageid
ORDER BY $sort");
}
if ($suboption == "protected")
{
$table_sections = $dbprefix . "prot_sections";
$table_pages = $dbprefix . "prot_pages";
$result = mysql_query("SELECT p.id, p.name, SUM(s.count) as count, e.name,
UNIX_TIMESTAMP(p.createdate), UNIX_TIMESTAMP(p.lastvisitdate) ,
p.section , UNIX_TIMESTAMP(p.lastupdate), s.pageid
FROM $table_stats s
LEFT JOIN $table_pages p ON s.pageid=p.id
LEFT JOIN $table_sections e ON p.section=e.id
WHERE s.public = 1
GROUP BY s.pageid
ORDER BY $sort");
}
if (($modoption == "print") AND (substr($access, 3, 1) == "1"))
{
print "<html><body onload=\"window.print();\"><table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
print "<tr><td><font size=\"5\"><b>$sitename</b></font></td><td>";
if ($suboption == "local")
{
print "<font size=\"4\">" . $sas_lang['stats_local'] . "</font>";
}
elseif ($suboption == "remote")
{
print "<font size=\"4\">" . $sas_lang['stats_remote'] . "</font>";
}
elseif ($suboption == "protected")
{
print "<font size=\"4\">" . $sas_lang['protected_area'] . "</font>";
}
print "</td><td colspan=\"4\" align=\"right\"> </td></tr>";
print " <tr bgcolor=\"#0886BD\">
<td width=\"200\"><br><font color=\"white\"><b>" . $sas_lang['stats_col1'] . "</b></td>
<td align=\"left\" width=\"150\"><br><font color=\"white\"><b>" . $sas_lang['stats_col3'] . "</b></font></td>
<td align=\"right\" width=\"80\"><font color=\"white\"><b>" . $sas_lang['stats_col4'] . "</b></font></td>
<td align=\"right\" width=\"100\"><font color=\"white\"><b>" . $sas_lang['stats_col5'] . "</b></font></td>
<td align=\"right\" width=\"100\"><font color=\"white\"><b>" . $sas_lang['stats_col6'] . "</b></font></td>
<td align=\"right\" width=\"100\"><font color=\"white\"><b>" . $sas_lang['stats_col7'] . "</b></font></td>
</tr>";
$i = 0;
while ($stats_list = mysql_fetch_array($result))
{
$date1 = strftime($sas_config['dateformat'], $stats_list[4]);
$date2 = strftime($sas_config['dateformat'], $stats_list[5]);
$date3 = strftime($sas_config['dateformat'], $stats_list[7]);
if ($i == 0) //even row
{
print "<tr bgcolor=\"#F7F7F7\"><td>$stats_list[1]</td>";
$i = 1;
}
else //odd row
{
print "<tr bgcolor=\"#E7E7EF\"> <td>$stats_list[1]</td>";
$i = 0;
}
print "<td align=\"left\">$stats_list[3]</td>
<td align=\"right\">$stats_list[2]</td>
<td align=\"right\">$date1</td>
<td align=\"right\">$date2</td>
<td align=\"right\">$date3</td>
</tr>";
}
print "</table></body></html>";
exit;
}
include ("interface/header.inc.php");
include ("interface/menubar.inc.php");
include ("interface/menustart.inc.php");
if (substr($access, 3, 1) == "0") //bit 4 off the accessrights
{
include ("interface/menuend.inc.php");
include ("interface/pagestart.inc.php");
print "<span class=\"sas_module_title\">" . $sas_lang['noaccess'] . "<br></span>";
print "" . $sas_lang['noaccess_introduction'] . "</span><br><br><br>";
include ("interface/pageend.inc.php");
include ("interface/footer.inc.php");
exit;
}
print "<span class=\"sas_module_title\">" . $sas_lang['filemanager_menu'] . "</span><br><br>";
print "<a href=\"index.php?option=stats&site=protected&suboption=local\">" . $sas_lang['stats_local'] . "</a><p>
<a href=\"index.php?option=stats&suboption=remote\">" . $sas_lang['stats_remote'] . "</a><p>
<a href=\"index.php?option=stats&suboption=protected\">" . $sas_lang['protected_area'] . "</a><p>
<a href=\"index.php?option=stats&modoption=config\">" . $sas_lang['configuration'] . "</a><p>
<a href=\"index.php?option=stats&modoption=clear\">" . $sas_lang['clear_stats'] . "</a><p></span>";
include ("interface/menuend.inc.php");
include ("interface/pagestart.inc.php");
print "<center><span class=\"sas_module_title\">" . $sas_lang['stats'] . "<br></span></center>";
switch ($modoption) // start of switch
{
case view :
if ($suboption == "local")
{
print "<span class=\"sas_module_title\">" . $sas_lang['stats_local'] . "</span><br>";
}
elseif ($suboption == "remote")
{
print "<span class=\"sas_module_title\">" . $sas_lang['stats_remote'] . "</span><br>";
}
elseif ($suboption == "protected")
{
print "<span class=\"sas_module_title\">" . $sas_lang['protected_area'] . "</span><br>";
}
print "" . $sas_lang['stats_introduction'] . "</span><br><br>";
print "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
print "<tr><td colspan=\"6\" align=\"right\">
<button onclick=\"javascript:parent.location='index.php?option=stats&suboption=$suboption&s=$s&modoption=print'\" type=\"button\" class=\"button\"><em><span>Print</em></span></button></td></tr>";
print " <tr bgcolor=\"#0886BD\">
<td width=\"200\"><br><a href=index.php?option=stats&suboption=$suboption&s=1\" STYLE=\"color: white; font-size: 10pt\"><b>" . $sas_lang['stats_col1'] . "</b></a></td>
<td align=\"left\" width=\"150\"><b><br><a href=\"index.php?option=stats&suboption=$suboption&s=3\" STYLE=\"color: white; font-size: 10pt\">" . $sas_lang['stats_col3'] . "</b></font></td>
<td align=\"right\" width=\"80\"><b><a href=\"index.php?option=stats&suboption=$suboption&s=4\" STYLE=\"color: white; font-size: 10pt\">" . $sas_lang['stats_col4'] . "</b></font></td>
<td align=\"right\" width=\"100\"><b><a href=\"index.php?option=stats&suboption=$suboption&s=5\" STYLE=\"color: white; font-size: 10pt\">" . $sas_lang['stats_col5'] . "</b></font></td>
<td align=\"right\" width=\"100\"><b><a href=\"index.php?option=stats&suboption=$suboption&s=6\" STYLE=\"color: white; font-size: 10pt\">" . $sas_lang['stats_col6'] . "</b></font></td>
<td align=\"right\" width=\"100\"><b><a href=\"index.php?option=stats&suboption=$suboption&s=7\" STYLE=\"color: white; font-size: 10pt\">" . $sas_lang['stats_col7'] . "</b></font></td>
</tr>";
$i = 0;
while ($stats_list = mysql_fetch_array($result))
{
$date1 = strftime($sas_config['dateformat'], $stats_list[4]);
$date2 = strftime($sas_config['dateformat'], $stats_list[5]);
$date3 = strftime($sas_config['dateformat'], $stats_list[7]);
if ($i == 0)
{
if (trim($stats_list[1]) == "")
{
print "<tr bgcolor=\"#F7F7F7\">
<td><a href=\"index.php?option=stats&suboption=$suboption&modoption=delete&pageid=$stats_list[8]\">
[" . $sas_lang['delete'] . "]</span></a></td>";
}
else
{
print "<tr bgcolor=\"#F7F7F7\">
<td><a href=\"../index.php?section=$stats_list[6]&page=$stats_list[0]\">$stats_list[1]</span></a></td>";
}
$i = 1;
}
else
{
if (trim($stats_list[1]) == "")
{
print "<tr bgcolor=\"#E7E7EF\">
<td><a href=\"index.php?option=stats&suboption=$suboption&modoption=delete&pageid=$stats_list[8]\">
[" . $sas_lang['delete'] . "]</span></a></td>";
}
else
{
print "<tr bgcolor=\"#E7E7EF\">
<td><a href=\"../index.php?section=$stats_list[6]&page=$stats_list[0]\">$stats_list[1]</span></a></td>";
}
$i = 0;
}
print "<td align=\"left\">$stats_list[3]</span></td>
<td align=\"right\">$stats_list[2]</span></td>
<td align=\"right\">$date1</span></td>
<td align=\"right\">$date2</span></td>
<td align=\"right\">$date3</span></td>
</tr>";
}
print "</table>";
break;
case save_config :
$i = 0;
$ip_filter_new = "";
$ip_names_new = "";
while ($i < count($ipfilter))
{
if ($ipfilter[$i] != "")
{
$ip_filter_new .= $ipfilter[$i] . ",";
$ip_names_new .= $ipnames[$i] . ",";
}
$i++;
}
$ip_filter_new = substr($ip_filter_new, 0, strlen($ip_filter_new) - 1); //strip last comma
mysql_query("UPDATE $table_configuration SET config_value='$ip_filter_new' WHERE config_key='stats_ip_filter'");
mysql_query("UPDATE $table_configuration SET config_value='$ip_names_new' WHERE config_key='stats_ip_names'");
print "" . $sas_lang['configuration_saved'] . "<br>";
print "<br><br><input type=\"button\" value=\" " . $sas_lang['goback'] . "\" name=\"backbutton\" onClick=\"javascript:parent.location='index.php?option=stats';\" class=\"backbutton\">";
break;
case config :
$ip = $_SERVER["REMOTE_ADDR"]; //get your own ip address
print "<br><span class=\"sas_module_title\">" . $sas_lang['configuration'] . "</span><br>\n
(" . $sas_lang['stats_own_ip'] . "<b>$ip</b>)
<p>" . $sas_lang['stats_ip_introduction'] . "</span><p>\n";
print "<FORM METHOD=\"POST\" ACTION=\"index.php?option=stats&modoption=save_config\">\n";
print "<table><tr><td> </td><td>IP:</span></td><td>".$sas_lang['fullname'].":</span></td></tr>";
$i = 0;
while ($i < count($ipfilter))
{
print "<tr><td align=\"right\">IP$i:</span></td>\n";
print "<td><input tabindex=\"2\" type=\"text\" size=\"15\" class=\"textfield\" name=\"ipfilter[$i]\" value=\"$ipfilter[$i]\"></td>
<td><input tabindex=\"3\" type=\"text\" size=\"35\" class=\"textfield\" name=\"ipnames[$i]\" value=\"$ipnames[$i]\"></td>
</tr>\n";
$i++;
}
if ($addip == "yes")
{
print "<tr><td align=\"right\">IP$i:</span></td>\n";
print "<td><input tabindex=\"2\" type=\"text\" size=\"15\" class=\"textfield\" name=\"ipfilter[$i]\"></td>
<td><input tabindex=\"3\" type=\"text\" size=\"35\" class=\"textfield\" name=\"ipnames[$i]\"></td></tr>\n";
}
print "</table><input type=hidden name=\"number\" value=\"$i\">\n";
print "<br><br><input type=\"button\" value=\" " . $sas_lang['cancel'] . "\" name=\"backbutton\"
onClick=\"javascript:parent.location='index.php?option=stats';\" class=\"backbutton\">";
print "\n <input type=\"button\" value=\" " . $sas_lang['stats_add_ip'] . "\" name=\"addbutton\"
onClick=\"javascript:parent.location='index.php?option=stats&modoption=config&addip=yes';\" class=\"savebutton\">";
print "\n <button type=\"submit\" class=\"button\"><em><span>".$sas_lang['save']."</em></span></button>";
print "</span></form>";
break;
case clear:
print "\n<FORM METHOD=\"POST\" ACTION=\"index.php?option=stats&modoption=clear_stats\"><br>\n";
print "<span class=\"sas_module_title\">" . $sas_lang['clear_stats'] . ":</span><br>\n";
print "<p><table><tr><td colspan=\"2\">" . $sas_lang['stats_clear_info'] . "</span></td></tr>\n";
print "<tr><td colspan=\"2\"> </td></tr>";
print "<tr><td>" . $sas_lang['stats_local'] . "</span></td><td><input type=\"checkbox\" name=\"local\" value=\"yes\"></td></tr>";
print "<tr><td>" . $sas_lang['stats_remote'] . "</span></td><td><input type=\"checkbox\" name=\"remote\" value=\"yes\"></td></tr>";
print "<tr><td>" . $sas_lang['protected_area'] . "</span></td><td><input type=\"checkbox\" name=\"protected\" value=\"yes\"></td></tr>";
print "</table>";
print "<br><br><input type=\"button\" value=\" " . $sas_lang['cancel'] . "\" name=\"backbutton\" onClick=\"javascript:parent.location='index.php?option=stats';\" class=\"backbutton\">";
print "\n <button type=\"submit\" class=\"button\"><em><span>".$sas_lang['save']."</em></span></button>";
print "</span></form>";
include ("interface/pageend.inc.php");
include ("interface/footer.inc.php");
break;
case delete:
if (IsSet ($_GET['pageid']))
{
$pageid = intval($_GET['pageid']);
}
mysql_query("DELETE FROM $table_stats WHERE pageid = '$pageid'");
print "<script language='javascript'>window.location = 'index.php?option=configuration&option=stats&suboption=$suboption'</script>";
break;
case clear_stats:
$i = 0;
if (($ipfilter[0] == "") AND ($suboption == "local")) //no local ip adresses given
{
$where_clause = " WHERE public = 0 AND s.ip LIKE ('999.9.9.999')"; //for local we need at least one dummy IP
}
foreach ($ipfilter as $ip) //create the WHERE clause from ipfilter
{
if ($local == "yes")
{
if ($i > 0)
{
$where_clause_local .= " OR ip LIKE ('$ip%')";
}
else
{
$where_clause_local = " WHERE public = 0 AND ip LIKE ('$ip%')";
}
}
if ($remote == "yes")
{
if ($i > 0)
{
$where_clause_remote .= " AND ip NOT LIKE ('$ip%')";
}
else
{
$where_clause_remote = " WHERE public = 0 AND ip NOT LIKE ('$ip%')";
}
}
$i++;
}
if ($local == "yes")
{
mysql_query("DELETE FROM $table_stats $where_clause_local");
print "<p>Local: " . $sas_lang['stats_cleared'] . "</span>";
}
if ($remote == "yes")
{
mysql_query("DELETE FROM $table_stats $where_clause_remote");
mysql_query("UPDATE $table_pages SET count = 0 WHERE id > 0") ;
print "<p>Remote:" . $sas_lang['stats_cleared'] . "</span>";
}
if ($protected == "yes")
{
mysql_query("DELETE FROM $table_stats WHERE public = 1");
$table_pages = $dbprefix . "prot_pages";
mysql_query("UPDATE $table_pages SET count = 0 WHERE id > 0") ;
print "<p>" . $sas_lang['protected_area'] . ": " . $sas_lang['stats_cleared'] . "</span>";
}
print "<br><br><input type=\"button\" value=\" " . $sas_lang['goback'] . "\" name=\"backbutton\" onClick=\"javascript:parent.location='index.php?option=stats';\" class=\"backbutton\">";
break;
}
include ("interface/pageend.inc.php");
include ("interface/footer.inc.php");
?>
[size=xsmall]Toevoeging op 24/10/2012 16:57:50:[/size]
Wanneer ik in de database zelf de waarde public=0 wijzig in public=1 dan geeft hij deze statistiek wel weer.
2.436 views