foutmelding redeclaratie
Fatal error: Cannot redeclare prevent_multi_submit()
(previously declared in /data/home/******/domains/*****.be/public_html/
mafiagame/safe.php:17) in /data/home/******/domains/*****.be/public_html/
mafiagame/safe.php on line 38
(zonder de sterretjes dan he)
Dit is safe.php:
Code (php)
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
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
<?php
require("config.php");
include_once("connect.php");
if(isset($_SESSION['user_id'])) {
// Login ok, update last active
$sql = "UPDATE login SET lastactive=NOW(), counter=counter+1 WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'";
mysql_query($sql);
}else{
header("Location: index.php");
exit();
}
function prevent_multi_submit($type = "post") {
$string = "";
$posted_array = ($type == "get") ? $_GET : $_POST;
foreach ($posted_array as $val) {
$string .= $val;
}
if (isset($_SESSION['last'])) {
if ($_SESSION['last'] === md5($string) and time() <= $_SESSION['time'] ) {
return false;
} else {
$_SESSION['last'] = md5($string);
$_SESSION['time'] = md5(strtotime ("+1 minute"));
return true;
}
}
else {
$_SESSION['last'] = md5($string);
$_SESSION['time'] = md5(strtotime ("+1 minute"));
return true;
}
}
?>
require("config.php");
include_once("connect.php");
if(isset($_SESSION['user_id'])) {
// Login ok, update last active
$sql = "UPDATE login SET lastactive=NOW(), counter=counter+1 WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'";
mysql_query($sql);
}else{
header("Location: index.php");
exit();
}
function prevent_multi_submit($type = "post") {
$string = "";
$posted_array = ($type == "get") ? $_GET : $_POST;
foreach ($posted_array as $val) {
$string .= $val;
}
if (isset($_SESSION['last'])) {
if ($_SESSION['last'] === md5($string) and time() <= $_SESSION['time'] ) {
return false;
} else {
$_SESSION['last'] = md5($string);
$_SESSION['time'] = md5(strtotime ("+1 minute"));
return true;
}
}
else {
$_SESSION['last'] = md5($string);
$_SESSION['time'] = md5(strtotime ("+1 minute"));
return true;
}
}
?>
(hier komen nog zo'n 500 regels achter, maar de fout zou hierboven moeten inzitten)
Vind iemand de fout aub?
Alvast bedankt.
Gewijzigd op 01/01/1970 01:00:00 door Ruben Vanhoeyveld
Ruben Vanhoeyveld schreef op 21.09.2008 15:33:
Fatal error: Cannot redeclare prevent_multi_submit()
Je probeert twee keer dezelfde function te declareren/maken.
Include je dit bestand? Dan doe je dat vast twee keer.
Ik bekijk het even.
Edit: Neen, Safe.php wordt slecht 1 maal included in news.php.
Andere fouten?
Gewijzigd op 01/01/1970 01:00:00 door Ruben Vanhoeyveld
Staat die function ook nog in een ander bestand?
Ik include hem inderdaad dubbel...
Ik include top.php en safe.php in news.php. In beide staat die function. Waar doe ik deze nu best weg?
EDIT: Top.php wordt op elke pagina included...
thx
Gewijzigd op 01/01/1970 01:00:00 door Ruben Vanhoeyveld
Zet alle functions in een apart bestand en include dat helemaal aan het begin van je hoofdpagina.
Nu zit ik met een ander probleem in datzelfde news.php bestand...
Code (php)
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
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
<?php require("top.php"); require("safe.php");?>
<script type="text/javascript">
function smile(field,text)
{
document.shout.elements[field].value += " "+text+" ";
document.shout.elements[field].focus();
}
</script>
<?
require("usercheck.php");
if(isset($_POST['Post']) and in_array($name, $admin_array)){
if(empty($_POST['message'])){
echo "Je hebt geen bericht getypt.";
}else{
$sql = "INSERT INTO news SET id = '', message = '" .mysql_real_escape_string($_POST['message']). "', name = '" .mysql_real_escape_string($name). "',ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."'";
$res = mysql_query($sql);
}
}
if(isset($_POST['Delete']) and in_array($name, $admin_array) and in_array($_SERVER['REMOTE_ADDR'], $admin_ip_array)){
$id = $_POST['id'];
if(!empty($id)){
$delete = implode(",",$id);
$delete = explode(",",$delete);
for($a = 0; !empty($delete[$a]);$a++){
$sql = "DELETE FROM news WHERE `id`='".mysql_real_escape_string($delete[$a])."'";
$out = mysql_query($sql);
}
echo "Alle geselecteerde berichten zijn verwijderd.";
}else{
echo "Je hebt geen berichten geselecteerd.";
}
}
?>
<form name="shout" method="post">
<div style="width: 500px; text-align:left;">
<?php
#include_once('connect.php')
$presult = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 0,10 ") or die(mysql_error());
$b = 0;
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $presult )) {
// Print out the contents of each row into a table
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = sitefilter($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
$b = $b + 1;
if(in_array($name, $admin_array)){echo "<input type='checkbox' name='id[$b]' value='".$row['id']."' onfocus=\"if(this.blur)this.blur()\"/>";} echo "<a href=\"view_profile.php?name=". $row['name'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['name']."</a> ( ".$row['date']." )<hr class=\"hr\" />".$row['message']."<br /><br />";
}// while loop
?>
</div>
<?php if(in_array($name, $admin_array)){ ?>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="2" class="table">
<tr>
<td align="left" class="head">
Voeg nieuws toe. </td>
</tr>
<tr>
<td align="center" class="cell"><textarea name="message" rows="6" class="textbox" id="message">
<?php echo htmlspecialchars($_POST['message']); ?>
</textarea></td>
</tr>
<tr>
<td align="center" class="cell">
<?php smilielist(); // function to show the smilies.?>
</td>
</tr>
<tr>
<td align="right" class="submit"><input name="Post" type="submit" class="button" id="Post" value="Post." onfocus="if(this.blur)this.blur()" />
<input name="Delete" type="submit" class="button" id="Delete" value="Delete." onfocus="if(this.blur)this.blur()" /></td>
</tr>
</table>
<?php } ?>
</form>
<?php require("bottom.php"); ?>
<script type="text/javascript">
function smile(field,text)
{
document.shout.elements[field].value += " "+text+" ";
document.shout.elements[field].focus();
}
</script>
<?
require("usercheck.php");
if(isset($_POST['Post']) and in_array($name, $admin_array)){
if(empty($_POST['message'])){
echo "Je hebt geen bericht getypt.";
}else{
$sql = "INSERT INTO news SET id = '', message = '" .mysql_real_escape_string($_POST['message']). "', name = '" .mysql_real_escape_string($name). "',ip='".mysql_real_escape_string($_SERVER['REMOTE_ADDR'])."'";
$res = mysql_query($sql);
}
}
if(isset($_POST['Delete']) and in_array($name, $admin_array) and in_array($_SERVER['REMOTE_ADDR'], $admin_ip_array)){
$id = $_POST['id'];
if(!empty($id)){
$delete = implode(",",$id);
$delete = explode(",",$delete);
for($a = 0; !empty($delete[$a]);$a++){
$sql = "DELETE FROM news WHERE `id`='".mysql_real_escape_string($delete[$a])."'";
$out = mysql_query($sql);
}
echo "Alle geselecteerde berichten zijn verwijderd.";
}else{
echo "Je hebt geen berichten geselecteerd.";
}
}
?>
<form name="shout" method="post">
<div style="width: 500px; text-align:left;">
<?php
#include_once('connect.php')
$presult = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 0,10 ") or die(mysql_error());
$b = 0;
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $presult )) {
// Print out the contents of each row into a table
$row['message'] = htmlentities($row['message']);
$row['message'] = nl2br($row['message']);
$row['message'] = smilie($row['message']);
$row['message'] = sitefilter($row['message']);
$row['message'] = bbcodes($row['message']);
$row['message'] = stripslashes($row['message']);
$b = $b + 1;
if(in_array($name, $admin_array)){echo "<input type='checkbox' name='id[$b]' value='".$row['id']."' onfocus=\"if(this.blur)this.blur()\"/>";} echo "<a href=\"view_profile.php?name=". $row['name'] ."\" onFocus=\"if(this.blur)this.blur()\">".$row['name']."</a> ( ".$row['date']." )<hr class=\"hr\" />".$row['message']."<br /><br />";
}// while loop
?>
</div>
<?php if(in_array($name, $admin_array)){ ?>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="2" class="table">
<tr>
<td align="left" class="head">
Voeg nieuws toe. </td>
</tr>
<tr>
<td align="center" class="cell"><textarea name="message" rows="6" class="textbox" id="message">
<?php echo htmlspecialchars($_POST['message']); ?>
</textarea></td>
</tr>
<tr>
<td align="center" class="cell">
<?php smilielist(); // function to show the smilies.?>
</td>
</tr>
<tr>
<td align="right" class="submit"><input name="Post" type="submit" class="button" id="Post" value="Post." onfocus="if(this.blur)this.blur()" />
<input name="Delete" type="submit" class="button" id="Delete" value="Delete." onfocus="if(this.blur)this.blur()" /></td>
</tr>
</table>
<?php } ?>
</form>
<?php require("bottom.php"); ?>
Dit was de code. Ik zou normaal op een of andere manier een bericht moeten kunnen selecteren en zo verwijderen. Zo staat het toch in het script. Als ik dat doe, lukt het niet meer.
Gewijzigd op 01/01/1970 01:00:00 door Ruben Vanhoeyveld
Ok, kan je even zoeken waar ik iets moet toevoegen om berichten te verwijderen?
SanThe.
Ruben