script schrijft niet goed naar SQL database?

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

HJ Zomer

HJ Zomer

24/10/2012 16:55:19
Quote Anchor link
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;

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<?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\">&nbsp;</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]\">
                            &nbsp;&nbsp;["
. $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]\">
                            &nbsp;&nbsp;["
. $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=\"&nbsp;&nbsp;&nbsp;" . $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>&nbsp;</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=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['cancel'] . "\" name=\"backbutton\"
                onClick=\"javascript:parent.location='index.php?option=stats';\" class=\"backbutton\">"
;
        print "\n&nbsp;<input type=\"button\" value=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['stats_add_ip'] . "\" name=\"addbutton\"
                onClick=\"javascript:parent.location='index.php?option=stats&modoption=config&addip=yes';\" class=\"savebutton\">"
;
        print "\n&nbsp;<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\">&nbsp;</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=\"&nbsp;&nbsp;&nbsp;" . $sas_lang['cancel'] . "\" name=\"backbutton\" onClick=\"javascript:parent.location='index.php?option=stats';\" class=\"backbutton\">";
        print "\n&nbsp;<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=\"&nbsp;&nbsp;&nbsp;" . $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");
?>


Toevoeging op 24/10/2012 16:57:50:

Wanneer ik in de database zelf de waarde public=0 wijzig in public=1 dan geeft hij deze statistiek wel weer.
 
PHP hulp

PHP hulp

29/03/2024 09:26:02
 
- Ariën  -
Beheerder

- Ariën -

24/10/2012 16:59:26
Quote Anchor link
Iemand eventjes 514 regels door laten spitten is overigens ook niet mals.
Kan je de code even inknippen tot relevante code?
 
HJ Zomer

HJ Zomer

24/10/2012 17:04:04
Quote Anchor link
Sorry, wellicht wat onnozel maar heb zelf al verschillende dingen geprobeerd in het script te wijzigen. Weet alleen zelf niet waar de fout zit. Het lijkt te moeten werken, ,maar dat doet het dus niet. Vandaar dat ik dacht mik ze alle 514 maar in het topic.

op hoop van zegen dat iemand het script al kent.

Maar zal ff een poging doen
Gewijzigd op 24/10/2012 17:05:02 door HJ Zomer
 
- SanThe -

- SanThe -

24/10/2012 17:09:27
Quote Anchor link
Ik zie nergens een UPDATE of een INSERT met public er in.
 
HJ Zomer

HJ Zomer

24/10/2012 17:11:12
Quote Anchor link
dacht zelf dat de fout hier ergens zit

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

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"
);
}


?>
 
- SanThe -

- SanThe -

24/10/2012 17:15:19
Quote Anchor link
Dat zijn alle drie SELECT query's, daar wordt niets mee gewijzigd in de database.
 
HJ Zomer

HJ Zomer

24/10/2012 17:19:02
Quote Anchor link
thanks ..

of moet ik hier beter naar kijken?

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

    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>";
        }


?>


Al gaat dat volgens mij over het verwijderen van alle counts uit de database

Toevoeging op 24/10/2012 17:20:13:

- SanThe - op 24/10/2012 17:09:27:
Ik zie nergens een UPDATE of een INSERT met public er in.


Dit is wel een goeie... maar hoe kan het dat hij public=0 wel wegschrijft dan?
 
- Ariën  -
Beheerder

- Ariën -

24/10/2012 17:22:33
Quote Anchor link
Tja, eigenlijk kan je dit het beste debuggen.
Zet eens heir en daar wat echo's zodat je weet welke route je script aflegt door de code heen.
 
- SanThe -

- SanThe -

24/10/2012 17:24:58
Quote Anchor link
HJ Zomer op 24/10/2012 17:19:02:
maar hoe kan het dat hij public=0 wel wegschrijft dan?


Dat zie ik nergens gebeuren in bovenstaand script.
 
HJ Zomer

HJ Zomer

24/10/2012 17:27:18
Quote Anchor link
Thanks! ga wel ff opzoek dan of ik kan vinden waar dat dan wel gebeurd. Wellicht moet ik ergens anders kijken...

Toevoeging op 24/10/2012 17:33:57:

Een laatste dingetje...

Mocht het INSERT of UPDATE commando in een ander bestand staan moet je in deze code toch een verwijzing kunnen terug vinden naar dat bestand?

als zijnde een include of require?


Toevoeging op 24/10/2012 17:45:33:

Sorry.. de vraag stellen is hem beantwoorden...
Gewijzigd op 24/10/2012 17:37:38 door HJ Zomer
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.