Forum

> > Off Topic > PHP Problem.
Forums overviewOff Topic overviewLog in to reply

German PHP Problem.

No replies
To the start Previous 1 Next To the start

old PHP Problem.

Icereed
User Off Offline

Quote
Ich hätte da ein Problem...
Ich habe eine replace Funktion, aber wenn ich sie auf einer Seite 2 Mal verwende kommt ein Error:

Server has written
Fatal error: Cannot redeclare nojavascript1() (previously declared in C:\xampp\htdocs\php\homepage\inc\smiley.inc.php:2) in C:\xampp\htdocs\php\homepage\inc\smiley.inc.php on line 6


Der Code:
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
function nojavascript1($match) {
	if (!preg_match("/javascript:/i",$match[0])) {
		return '<a href="' . $match[1] . '">' . $match[1] . '</a>';
		}
}
function nojavascript2($match) {
	if (!preg_match("/javascript:/i",$match[0])) {
		return '<a href="' . $match[1] . '">' . $match[2] . '</a>';
	}
}
function replace_tags($eintrag){
// Suchmuster
$reg_Liste = array(
		"/\[image=([^]]*)\]/i",
		"[:roll:]",
                    "[:D]",
                    "[:\)]",
                    "[:\(]",
                    "[:shock:]",
                    "[:\?]",
                    "[8\)]",
                    "[:mrteeth:]",
               		"/\[center\]([^\f]*)\[\/center\]/i",
               		"/\[u\]([^\f]*)\[\/u\]/i",
					"/\[right\]([^\f]*)\[\/right\]/i",
					"/\[i\]([^\f]*)\[\/i\]/i"
		);

// Austausch
$tauschListe = array(
		'<img src="\1" border="0" alt="\1">',
		 					'<img src="http://images.icereed.net/smileys/icon_rolleyes.gif" alt=":-)" />',
 					'<img src="http://images.icereed.net/smileys/icon_biggrin.gif" alt=":-)" />',
 					'<img src="http://images.icereed.net/smileys/icon_smile.gif" alt=":-)" />',
 					'<img src="http://images.icereed.net/smileys/icon_sad.gif" alt=":-)" />',
 					'<img src="http://images.icereed.net/smileys/icon_eek.gif" alt=":-)" />',
 					'<img src="http://images.icereed.net/smileys/icon_confused.gif" alt=":-)" />',
 					'<img src="http://images.icereed.net/smileys/icon_cool.gif" alt=":-)" />',
 					'<img src="http://images.icereed.net/smileys/icon_mrgreen.gif" alt=":-)" />',
 					'<p style="text-align:center;margin-top:0px;padding:0px;">\1</p>',
 					'<u>\1</u>',
 					'<div style="text-align:right;margin-top:0px;padding:0px;">\1</div>',
 					'<font style="font-style:italic;">\1</font>'
 							);
 
// Suchmuster
$reg_muster2 = "/\[url=([^]]*)\]([^]]*)\[\/url\]/i";
$reg_muster1 = "/\[url=([^]]*)\]/i";
// Callback-Funktion

// Prüfen auf Tags
//$eintrag1 = preg_replace_callback($reg_muster2, "nojavascript2", $eintrag);
//$eintrag1 = preg_replace_callback($reg_muster1, "nojavascript1", $eintrag);
// Ausgabe
$res = preg_replace($reg_Liste, $tauschListe, $eintrag);			                    
 					    
   return $res;
}
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview