Project

General

Profile

« Previous | Next » 

Revision 1301

Added by Dietmar over 14 years ago

Tickets #932 change deprecated eregi functions
Tickets #948 fixed Multiple use of same parametrised droplet - parameter handling
Upgrade Droplets to Version 1.0.3
update some headerinfos
non existing pages, will be created if clicking save in page settings

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.8.1 -------------------------------------
14
07-Mar-2010 Dietmar Woellbrink (Luisehahne)
15
#	Tickets #932 change deprecated eregi functions 
16
#	Tickets #948 fixed Multiple use of same parametrised droplet - parameter handling
17
!	Upgrade Droplets to Version 1.0.3
18
!	update some headerinfos
19
!	non existing pages will be created if clicking save in page settings
20
07-Mar-2010 Dietmar Woellbrink (Luisehahne)
14 21
#	Ticket #950 missing classes in theme.css ( Tks to Ruebenwurzel )
15 22
!	update jquery-min.js to version 1.4.2
16 23
20-Feb-2010 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/include/phpmailer/class.phpmailer.php
583 583
   * @access private
584 584
   * @return bool
585 585
   */
586
  function SmtpConnect() {
587
    if($this->smtp == NULL) {
586
  function SmtpConnect()
587
  {
588
    if($this->smtp == NULL)
589
    {
588 590
      $this->smtp = new SMTP();
589 591
    }
590 592

  
......
594 596
    $connection = ($this->smtp->Connected());
595 597

  
596 598
    /* Retry while there is no connection */
597
    while($index < count($hosts) && $connection == false) {
599
    while($index < count($hosts) && $connection == false)
600
    {
598 601
      $hostinfo = array();
599
      if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) {
602
      if(preg_match('/(.+):([0-9]+)/', $hosts[$index], $hostinfo))
603
      {
600 604
        $host = $hostinfo[1];
601 605
        $port = $hostinfo[2];
602 606
      } else {
branches/2.8.x/wb/include/captcha/captchas/ttf_image.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
require_once("../../../config.php");
27
require_once(WB_PATH.'/include/captcha/captcha.php');
28

  
29
if(!isset($_SESSION['captcha_time']))
30
	exit;
31
unset($_SESSION['captcha_time']);
32

  
33
// get lists of fonts and backgrounds
34
require_once(WB_PATH.'/framework/functions.php');
35
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');
36
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');
37
$fonts = array();
38
$bgs = array();
39
foreach($t_fonts as $file) if(eregi('\.ttf$',$file)) $fonts[]=$file;
40
foreach($t_bgs as $file) if(eregi('\.png$',$file)) $bgs[]=$file;
41

  
42
// make random string
43
if(!function_exists('randomString')) {
44
	function randomString($len) {
45
		list($usec, $sec) = explode(' ', microtime());
46
		mt_srand((float)$sec + ((float)$usec * 100000));
47
		//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789";
48
		$possible="abdfhkrsvwxz23456789";
49
		$str="";
50
		while(strlen($str)<$len) {
51
			$str.=substr($possible,(mt_rand()%(strlen($possible))),1);
52
		}
53
		return($str);
54
	}
55
}
56
$text = randomString(5); // number of characters
57
$_SESSION['captcha'] = $text; 
58

  
59
// choose a font and background
60
$font = $fonts[array_rand($fonts)];
61
$bg = $bgs[array_rand($bgs)];
62
// get image-dimensions
63
list($width, $height, $type, $attr) = getimagesize($bg);
64

  
65
// create reload-image
66
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay
67

  
68
if(mt_rand(0,2)==0) { // 1 out of 3
69

  
70
	// draw each character individualy
71
	$image = ImageCreateFromPNG($bg); // background image
72
	$grey = mt_rand(0,50);
73
	$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
74
	$ttf = $font;
75
	$ttfsize = 25; // fontsize
76
	$count = 0;
77
	$image_failed = true;
78
	$angle = mt_rand(-15,15);
79
	$x = mt_rand(10,25);
80
	$y = mt_rand($height-10,$height-2);
81
	do {
82
		for($i=0;$i<strlen($text);$i++) {
83
			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
84
			$angle = mt_rand(-15,15);
85
			$x = mt_rand($res[4],$res[4]+10);
86
			$y = mt_rand($height-15,$height-5);
87
		}
88
		if($res[4] > $width) {
89
			$image_failed = true;
90
		} else {
91
			$image_failed = false;
92
		}
93
		if(++$count > 4) // too many tries! Use the image
94
			break;
95
	} while($image_failed);
96
	
97
} else {
98
	
99
	// draw whole string at once
100
	$image_failed = true;
101
	$count=0;
102
	do {
103
		$image = ImageCreateFromPNG($bg); // background image
104
		$grey = mt_rand(0,50);
105
		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
106
		$ttf = $font;
107
		$ttfsize = 25; // fontsize
108
		$angle = mt_rand(0,5);
109
		$x = mt_rand(5,30);
110
		$y = mt_rand($height-10,$height-2);
111
		$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text);
112
		// check if text fits into the image
113
		if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
114
			 ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 
115
			 ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 
116
			 ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)
117
		) {
118
			$image_failed = false;
119
		}
120
		if(++$count > 4) // too many tries! Use the image
121
			break;
122
	} while($image_failed);
123
	
124
}
125

  
126
imagealphablending($reload, TRUE);
127
imagesavealpha($reload, TRUE);
128

  
129
// overlay
130
imagecopy($reload, $image, 0,0,0,0, 140,40);
131
imagedestroy($image);
132
$image = $reload;
133

  
134
captcha_header();
135
ob_start();
136
imagepng($image);
137
header("Content-Length: ".ob_get_length()); 
138
ob_end_flush();
139
imagedestroy($image);
140

  
1
<?php

2

  
3
// $Id$

4

  
5
/*

6

  
7
 Website Baker Project <http://www.websitebaker.org/>

8
 Copyright (C) 2004-2009, Ryan Djurovich

9

  
10
 Website Baker is free software; you can redistribute it and/or modify

11
 it under the terms of the GNU General Public License as published by

12
 the Free Software Foundation; either version 2 of the License, or

13
 (at your option) any later version.

14

  
15
 Website Baker is distributed in the hope that it will be useful,

16
 but WITHOUT ANY WARRANTY; without even the implied warranty of

17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

18
 GNU General Public License for more details.

19

  
20
 You should have received a copy of the GNU General Public License

21
 along with Website Baker; if not, write to the Free Software

22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

23

  
24
*/

25

  
26
require_once("../../../config.php");

27
require_once(WB_PATH.'/include/captcha/captcha.php');

28

  
29
if(!isset($_SESSION['captcha_time']))

30
	exit;

31
unset($_SESSION['captcha_time']);

32

  
33
// get lists of fonts and backgrounds

34
require_once(WB_PATH.'/framework/functions.php');

35
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');

36
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');

37
$fonts = array();

38
$bgs = array();

39
foreach($t_fonts as $file) { if(preg_match('/\.ttf/',$file)) { $fonts[]=$file; } }

40
foreach($t_bgs as $file) { if(preg_match('/\.png/',$file)) { $bgs[]=$file; } }

41

  
42
// make random string

43
if(!function_exists('randomString')) {

44
	function randomString($len) {

45
		list($usec, $sec) = explode(' ', microtime());

46
		mt_srand((float)$sec + ((float)$usec * 100000));

47
		//$possible="ABCDEFGHJKLMNPRSTUVWXYZabcdefghkmnpqrstuvwxyz23456789";

48
		$possible="abdfhkrsvwxz23456789";

49
		$str="";

50
		while(strlen($str)<$len) {

51
			$str.=substr($possible,(mt_rand()%(strlen($possible))),1);

52
		}

53
		return($str);

54
	}

55
}

56
$text = randomString(5); // number of characters

57
$_SESSION['captcha'] = $text; 

58

  
59
// choose a font and background

60
$font = $fonts[array_rand($fonts)];

61
$bg = $bgs[array_rand($bgs)];

62
// get image-dimensions

63
list($width, $height, $type, $attr) = getimagesize($bg);

64

  
65
// create reload-image

66
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay

67

  
68
if(mt_rand(0,2)==0) { // 1 out of 3

69

  
70
	// draw each character individualy

71
	$image = ImageCreateFromPNG($bg); // background image

72
	$grey = mt_rand(0,50);

73
	$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color

74
	$ttf = $font;

75
	$ttfsize = 25; // fontsize

76
	$count = 0;

77
	$image_failed = true;

78
	$angle = mt_rand(-15,15);

79
	$x = mt_rand(10,25);

80
	$y = mt_rand($height-10,$height-2);

81
	do {

82
		for($i=0;$i<strlen($text);$i++) {

83
			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});

84
			$angle = mt_rand(-15,15);

85
			$x = mt_rand($res[4],$res[4]+10);

86
			$y = mt_rand($height-15,$height-5);

87
		}

88
		if($res[4] > $width) {

89
			$image_failed = true;

90
		} else {

91
			$image_failed = false;

92
		}

93
		if(++$count > 4) // too many tries! Use the image

94
			break;

95
	} while($image_failed);

96
	
97
} else {

98
	
99
	// draw whole string at once

100
	$image_failed = true;

101
	$count=0;

102
	do {

103
		$image = ImageCreateFromPNG($bg); // background image

104
		$grey = mt_rand(0,50);

105
		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color

106
		$ttf = $font;

107
		$ttfsize = 25; // fontsize

108
		$angle = mt_rand(0,5);

109
		$x = mt_rand(5,30);

110
		$y = mt_rand($height-10,$height-2);

111
		$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text);

112
		// check if text fits into the image

113
		if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 

114
			 ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 

115
			 ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 

116
			 ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)

117
		) {

118
			$image_failed = false;

119
		}

120
		if(++$count > 4) // too many tries! Use the image

121
			break;

122
	} while($image_failed);

123
	
124
}

125

  
126
imagealphablending($reload, TRUE);

127
imagesavealpha($reload, TRUE);

128

  
129
// overlay

130
imagecopy($reload, $image, 0,0,0,0, 140,40);

131
imagedestroy($image);

132
$image = $reload;

133

  
134
captcha_header();

135
ob_start();

136
imagepng($image);

137
header("Content-Length: ".ob_get_length()); 

138
ob_end_flush();

139
imagedestroy($image);

140

  
141 141
?>
142 142

  
branches/2.8.x/wb/include/captcha/captchas/calc_ttf_image.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
require_once("../../../config.php");
27
require_once(WB_PATH.'/include/captcha/captcha.php');
28

  
29
if(!isset($_SESSION['captcha_time']))
30
	exit;
31
unset($_SESSION['captcha_time']);
32

  
33
// get lists of fonts and backgrounds
34
require_once(WB_PATH.'/framework/functions.php');
35
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');
36
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');
37
$fonts = array();
38
$bgs = array();
39
foreach($t_fonts as $file) if(eregi('\.ttf$',$file)) $fonts[]=$file;
40
foreach($t_bgs as $file) if(eregi('\.png$',$file)) $bgs[]=$file;
41

  
42
// Captcha
43
$_SESSION['captcha'] = '';
44
mt_srand((double)microtime()*1000000);
45
$n = mt_rand(1,3);
46
switch ($n) {
47
	case 1:
48
		$x = mt_rand(1,9);
49
		$y = mt_rand(1,9);
50
		$_SESSION['captcha'] = $x + $y;
51
		$cap = "$x+$y"; 
52
		break; 
53
	case 2:
54
		$x = mt_rand(10,20);
55
		$y = mt_rand(1,9);
56
		$_SESSION['captcha'] = $x - $y; 
57
		$cap = "$x-$y"; 
58
		break;
59
	case 3:
60
		$x = mt_rand(2,10);
61
		$y = mt_rand(2,5);
62
		$_SESSION['captcha'] = $x * $y; 
63
		$cap = "$x*$y"; 
64
		break;
65
}
66
$text = $cap;
67

  
68
// choose a font and background
69
$font = $fonts[array_rand($fonts)];
70
$bg = $bgs[array_rand($bgs)];
71
// get image-dimensions
72
list($width, $height, $type, $attr) = getimagesize($bg);
73

  
74
// create reload-image
75
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay
76

  
77
if(mt_rand(0,2)==0) { // 1 out of 3
78

  
79
	// draw each character individualy
80
	$image = ImageCreateFromPNG($bg); // background image
81
	$grey = mt_rand(0,50);
82
	$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
83
	$ttf = $font;
84
	$ttfsize = 25; // fontsize
85
	$count = 0;
86
	$image_failed = true;
87
	$angle = mt_rand(-10,10);
88
	$x = mt_rand(20,35);
89
	$y = mt_rand($height-10,$height-2);
90
	do {
91
		for($i=0;$i<strlen($text);$i++) {
92
			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});
93
			$angle = mt_rand(-10,10);
94
			$x = mt_rand($res[4],$res[4]+10);
95
			$y = mt_rand($height-12,$height-7);
96
		}
97
		if($res[4] > $width) {
98
			$image_failed = true;
99
		} else {
100
			$image_failed = false;
101
		}
102
		if(++$count > 4) // too many tries! Use the image
103
			break;
104
	} while($image_failed);
105
	
106
} else {
107
	
108
	// draw whole string at once
109
	$image_failed = true;
110
	$count=0;
111
	do {
112
		$image = ImageCreateFromPNG($bg); // background image
113
		$grey = mt_rand(0,50);
114
		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color
115
		$ttf = $font;
116
		$ttfsize = 25; // fontsize
117
		$angle = mt_rand(0,5);
118
		$x = mt_rand(20,35);
119
		$y = mt_rand($height-10,$height-2);
120
		$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text);
121
		// check if text fits into the image
122
		if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 
123
			 ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 
124
			 ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 
125
			 ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)
126
		) {
127
			$image_failed = false;
128
		}
129
		if(++$count > 4) // too many tries! Use the image
130
			break;
131
	} while($image_failed);
132
	
133
}
134

  
135
imagealphablending($reload, TRUE);
136
imagesavealpha($reload, TRUE);
137

  
138
// overlay
139
imagecopy($reload, $image, 0,0,0,0, 140,40);
140
imagedestroy($image);
141
$image = $reload;
142

  
143
captcha_header();
144
ob_start();
145
imagepng($image);
146
header("Content-Length: ".ob_get_length()); 
147
ob_end_flush();
148
imagedestroy($image);
149

  
1
<?php

2

  
3
// $Id$

4

  
5
/*

6

  
7
 Website Baker Project <http://www.websitebaker.org/>

8
 Copyright (C) 2004-2009, Ryan Djurovich

9

  
10
 Website Baker is free software; you can redistribute it and/or modify

11
 it under the terms of the GNU General Public License as published by

12
 the Free Software Foundation; either version 2 of the License, or

13
 (at your option) any later version.

14

  
15
 Website Baker is distributed in the hope that it will be useful,

16
 but WITHOUT ANY WARRANTY; without even the implied warranty of

17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

18
 GNU General Public License for more details.

19

  
20
 You should have received a copy of the GNU General Public License

21
 along with Website Baker; if not, write to the Free Software

22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

23

  
24
*/

25

  
26
require_once("../../../config.php");

27
require_once(WB_PATH.'/include/captcha/captcha.php');

28

  
29
if(!isset($_SESSION['captcha_time']))

30
	exit;

31
unset($_SESSION['captcha_time']);

32

  
33
// get lists of fonts and backgrounds

34
require_once(WB_PATH.'/framework/functions.php');

35
$t_fonts = file_list(WB_PATH.'/include/captcha/fonts');

36
$t_bgs = file_list(WB_PATH.'/include/captcha/backgrounds');

37
$fonts = array();

38
$bgs = array();

39
foreach($t_fonts as $file) { if(preg_match('/\.ttf/',$file)) { $fonts[]=$file; } }

40
foreach($t_bgs as $file) { if(preg_match('/\.png/',$file)) { $bgs[]=$file; } }

41

  
42
// Captcha

43
$_SESSION['captcha'] = '';

44
mt_srand((double)microtime()*1000000);

45
$n = mt_rand(1,3);

46
switch ($n) {

47
	case 1:

48
		$x = mt_rand(1,9);

49
		$y = mt_rand(1,9);

50
		$_SESSION['captcha'] = $x + $y;

51
		$cap = "$x+$y"; 

52
		break; 

53
	case 2:

54
		$x = mt_rand(10,20);

55
		$y = mt_rand(1,9);

56
		$_SESSION['captcha'] = $x - $y; 

57
		$cap = "$x-$y"; 

58
		break;

59
	case 3:

60
		$x = mt_rand(2,10);

61
		$y = mt_rand(2,5);

62
		$_SESSION['captcha'] = $x * $y; 

63
		$cap = "$x*$y"; 

64
		break;

65
}

66
$text = $cap;

67

  
68
// choose a font and background

69
$font = $fonts[array_rand($fonts)];

70
$bg = $bgs[array_rand($bgs)];

71
// get image-dimensions

72
list($width, $height, $type, $attr) = getimagesize($bg);

73

  
74
// create reload-image

75
$reload = ImageCreateFromPNG(WB_PATH.'/include/captcha/reload_140_40.png'); // reload-overlay

76

  
77
if(mt_rand(0,2)==0) { // 1 out of 3

78

  
79
	// draw each character individualy

80
	$image = ImageCreateFromPNG($bg); // background image

81
	$grey = mt_rand(0,50);

82
	$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color

83
	$ttf = $font;

84
	$ttfsize = 25; // fontsize

85
	$count = 0;

86
	$image_failed = true;

87
	$angle = mt_rand(-10,10);

88
	$x = mt_rand(20,35);

89
	$y = mt_rand($height-10,$height-2);

90
	do {

91
		for($i=0;$i<strlen($text);$i++) {

92
			$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text{$i});

93
			$angle = mt_rand(-10,10);

94
			$x = mt_rand($res[4],$res[4]+10);

95
			$y = mt_rand($height-12,$height-7);

96
		}

97
		if($res[4] > $width) {

98
			$image_failed = true;

99
		} else {

100
			$image_failed = false;

101
		}

102
		if(++$count > 4) // too many tries! Use the image

103
			break;

104
	} while($image_failed);

105
	
106
} else {

107
	
108
	// draw whole string at once

109
	$image_failed = true;

110
	$count=0;

111
	do {

112
		$image = ImageCreateFromPNG($bg); // background image

113
		$grey = mt_rand(0,50);

114
		$color = ImageColorAllocate($image, $grey, $grey, $grey); // font-color

115
		$ttf = $font;

116
		$ttfsize = 25; // fontsize

117
		$angle = mt_rand(0,5);

118
		$x = mt_rand(20,35);

119
		$y = mt_rand($height-10,$height-2);

120
		$res = imagettftext($image, $ttfsize, $angle, $x, $y, $color, $ttf, $text);

121
		// check if text fits into the image

122
		if(($res[0]>0 && $res[0]<$width) && ($res[1]>0 && $res[1]<$height) && 

123
			 ($res[2]>0 && $res[2]<$width) && ($res[3]>0 && $res[3]<$height) && 

124
			 ($res[4]>0 && $res[4]<$width) && ($res[5]>0 && $res[5]<$height) && 

125
			 ($res[6]>0 && $res[6]<$width) && ($res[7]>0 && $res[7]<$height)

126
		) {

127
			$image_failed = false;

128
		}

129
		if(++$count > 4) // too many tries! Use the image

130
			break;

131
	} while($image_failed);

132
	
133
}

134

  
135
imagealphablending($reload, TRUE);

136
imagesavealpha($reload, TRUE);

137

  
138
// overlay

139
imagecopy($reload, $image, 0,0,0,0, 140,40);

140
imagedestroy($image);

141
$image = $reload;

142

  
143
captcha_header();

144
ob_start();

145
imagepng($image);

146
header("Content-Length: ".ob_get_length()); 

147
ob_end_flush();

148
imagedestroy($image);

149

  
150 150
?>
151 151

  
branches/2.8.x/wb/admin/pages/settings.php
277 277

  
278 278
		while($page = $get_pages->fetchRow())
279 279
        {
280
			if($admin->page_is_visible($page)==false)
281
				continue;
280
			if($admin->page_is_visible($page)==false) { continue; }
281

  
282 282
			$template->set_var('FLAG_CODE_ICON',' none ');
283 283
			if( $page['parent'] == 0 )
284 284
            {
285 285
				$template->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
286 286
			}
287

  
287 288
			// If the current page cannot be parent, then its children neither
288 289
			$list_next_level = true;
289 290
			// Stop users from adding pages with a level of more than the set page level limit
......
314 315
                // $space = str_repeat('&nbsp;', 3);  $space.'&lt;'..'&gt;'
315 316
				$template->set_var(array(
316 317
										'VALUE' => $page['page_code'],
317
                                        'PAGE_VALUE' => $title_prefix.$page['page_code'],
318
										'PAGE_CODE' => $title_prefix.$page['menu_title']
318
                                        'PAGE_VALUE' => $title_prefix.$page['menu_title'],
319
										'PAGE_CODE' => $title_prefix.$page['page_id']
319 320
										)
320 321
								);
321
				if($results_array['page_code'] == $page['page_code']) {
322
				if($results_array['page_code'] == $page['page_code'])
323
                {
322 324
					$template->set_var('SELECTED', ' selected="selected"');
323
				} elseif($results_array['page_code'] == $page['page_code']) {
325
				} elseif($results_array['page_code'] == $page['page_code'])
326
                {
324 327
					$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
325 328
					$list_next_level=false;
326
				} elseif($can_modify != true) {
329
				} elseif($can_modify != true)
330
                {
327 331
					$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
328 332
				} else {
329 333
					$template->set_var('SELECTED', '');
branches/2.8.x/wb/admin/pages/settings2.php
34 34
require_once(WB_PATH.'/framework/functions.php');
35 35

  
36 36
// Get values
37
$page_title = $admin->get_post_escaped('page_title');
38
$page_title = htmlspecialchars($page_title);
39
$menu_title = $admin->get_post_escaped('menu_title');
40
$menu_title = htmlspecialchars($menu_title);
37
$page_title = htmlspecialchars($admin->get_post_escaped('page_title') );
38
$menu_title = htmlspecialchars($admin->get_post_escaped('menu_title') );
41 39
$page_code = $admin->get_post_escaped('page_code');
42
$page_code = htmlspecialchars($page_code);
43
$description = htmlspecialchars($admin->add_slashes($admin->get_post('description')));
44
$keywords = htmlspecialchars($admin->add_slashes($admin->get_post('keywords')));
40
$description = htmlspecialchars($admin->add_slashes($admin->get_post('description')) );
41
$keywords = htmlspecialchars($admin->add_slashes($admin->get_post('keywords')) );
45 42
$parent = $admin->get_post_escaped('parent');
46 43
$visibility = $admin->get_post_escaped('visibility');
47 44
$template = $admin->get_post_escaped('template');
......
81 78
$field_set = $field_sql->numRows();
82 79

  
83 80
$in_old_group = FALSE;
84
foreach($admin->get_groups_id() as $cur_gid){
85
    if (in_array($cur_gid, $old_admin_groups)) {
81
foreach($admin->get_groups_id() as $cur_gid)
82
{
83
    if (in_array($cur_gid, $old_admin_groups))
84
    {
86 85
	$in_old_group = TRUE;
87 86
    }
88 87
}
......
194 193
$sql .= '`language` = "'.$language.'", ';
195 194
$sql .= '`admin_groups` = "'.$admin_groups.'", ';
196 195
$sql .= '`viewing_groups` = "'.$viewing_groups.'"';
197
$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php')) ? ', `page_code` = "'.$page_code.'" ' : ' ';
196
$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php')) ? ', `page_code` = '.(int)$page_code.' ' : ' ';
198 197
$sql .= 'WHERE `page_id` = '.$page_id;
199 198
$database->query($sql);
200 199

  
......
216 215
{
217 216
	$admin->print_error($MESSAGE['PAGES']['CANNOT_CREATE_ACCESS_FILE']);
218 217
} else {
218
    $old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
219 219
	// First check if we need to create a new file
220
	if($old_link != $link)
220
	if(($old_link != $link) || (!file_exists($old_filename)))
221 221
    {
222 222
		// Delete old file
223 223
		$old_filename = WB_PATH.PAGES_DIRECTORY.$old_link.PAGE_EXTENSION;
branches/2.8.x/wb/admin/pages/add.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Create new admin object and print admin header
27
require('../../config.php');
28
require_once(WB_PATH.'/framework/class.admin.php');
29
$admin = new admin('Pages', 'pages_add');
30

  
31
// Include the WB functions file
32
require_once(WB_PATH.'/framework/functions.php');
33

  
34
// Get values
35
$title = $admin->get_post_escaped('title');
36
$title = htmlspecialchars($title);
37
$module = $admin->get_post('type');
38
$parent = $admin->get_post('parent');
39
$visibility = $admin->get_post('visibility');
40
$admin_groups = $admin->get_post('admin_groups');
41
$viewing_groups = $admin->get_post('viewing_groups');
42

  
43
// add Admin to admin and viewing-groups
44
$admin_groups[] = 1;
45
$viewing_groups[] = 1;
46

  
47
if ($parent!=0) {
48
	if (!$admin->get_page_permission($parent,'admin'))
49
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
50
} elseif (!$admin->get_permission('pages_add_l0','system')) {
51
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
52
}	
53

  
54
// Validate data
55
if($title == '' || substr($title,0,1)=='.') {
56
	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
57
}
58

  
59
// Check to see if page created has needed permissions
60
if(!in_array(1, $admin->get_groups_id())) {
61
	$admin_perm_ok = false;
62
	foreach ($admin_groups as $adm_group) {
63
		if (in_array($adm_group, $admin->get_groups_id())) {
64
			$admin_perm_ok = true;
65
		}
66
	}
67
	if ($admin_perm_ok == false) {
68
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
69
	}
70
	$admin_perm_ok = false;
71
	foreach ($viewing_groups as $view_group) {
72
		if (in_array($view_group, $admin->get_groups_id())) {
73
			$admin_perm_ok = true;
74
		}
75
	}
76
	if ($admin_perm_ok == false) {
77
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
78
	}
79
}
80

  
81
$admin_groups = implode(',', $admin_groups);
82
$viewing_groups = implode(',', $viewing_groups);
83

  
84
// Work-out what the link and page filename should be
85
if($parent == '0') {
86
	$link = '/'.page_filename($title);
87
	// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
88
	if($link == '/index' || $link == '/intro') {
89
		$link .= '_0';
90
		$filename = WB_PATH .PAGES_DIRECTORY .'/' .page_filename($title) .'_0' .PAGE_EXTENSION;
91
	} else {
92
		$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($title).PAGE_EXTENSION;
93
	}
94
} else {
95
	$parent_section = '';
96
	$parent_titles = array_reverse(get_parent_titles($parent));
97
	foreach($parent_titles AS $parent_title) {
98
		$parent_section .= page_filename($parent_title).'/';
99
	}
100
	if($parent_section == '/') { $parent_section = ''; }
101
	$link = '/'.$parent_section.page_filename($title);
102
	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($title).PAGE_EXTENSION;
103
	make_dir(WB_PATH.PAGES_DIRECTORY.'/'.$parent_section);
104
}
105

  
106
// Check if a page with same page filename exists
107
$get_same_page = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE link = '$link'");
108
if($get_same_page->numRows() > 0 OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION) OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.'/')) {
109
	$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']);
110
}
111

  
112
// Include the ordering class
113
require(WB_PATH.'/framework/class.order.php');
114
$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent');
115
// First clean order
116
$order->clean($parent);
117
// Get new order
118
$position = $order->get_new($parent);
119

  
120
// Work-out if the page parent (if selected) has a seperate template or language to the default
121
$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'");
122
if($query_parent->numRows() > 0) {
123
	$fetch_parent = $query_parent->fetchRow();
124
	$template = $fetch_parent['template'];
125
	$language = $fetch_parent['language'];
126
} else {
127
	$template = '';
128
	$language = DEFAULT_LANGUAGE;
129
}
130

  
131
// Insert page into pages table
132
$query = "INSERT INTO ".TABLE_PREFIX."pages (page_title,menu_title,parent,template,target,position,visibility,searching,menu,language,admin_groups,viewing_groups,modified_when,modified_by) VALUES ('$title','$title','$parent','$template','_top','$position','$visibility','1','1','$language','$admin_groups','$viewing_groups','".time()."','".$admin->get_user_id()."')";
133
$database->query($query);
134
if($database->is_error()) {
135
	$admin->print_error($database->get_error());
136
}
137

  
138
// Get the page id
139
$page_id = $database->get_one("SELECT LAST_INSERT_ID()");
140

  
141
// Work out level
142
$level = level_count($page_id);
143
// Work out root parent
144
$root_parent = root_parent($page_id);
145
// Work out page trail
146
$page_trail = get_page_trail($page_id);
147

  
148
// Update page with new level and link
149
$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$link', level = '$level', root_parent = '$root_parent', page_trail = '$page_trail' WHERE page_id = '$page_id'");
150

  
151
// Create a new file in the /pages dir
152
create_access_file($filename, $page_id, $level);
153

  
154
// add position 1 to new page
155
$position = 1;
156

  
157
// Add new record into the sections table
158
$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,position,module,block) VALUES ('$page_id','$position', '$module','1')");
159

  
160
// Get the section id
161
$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
162

  
163
// Include the selected modules add file if it exists
164
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
165
	require(WB_PATH.'/modules/'.$module.'/add.php');
166
}
167

  
168
// Check if there is a db error, otherwise say successful
169
if($database->is_error()) {
170
	$admin->print_error($database->get_error());
171
} else {
172
	$admin->print_success($MESSAGE['PAGES']['ADDED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
173
}
174

  
175
// Print admin footer
176
$admin->print_footer();
177

  
1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2010, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 4.3.4 and higher
13
 * @version         $Id$
14
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16
 *
17
 */
18

  
19
// Create new admin object and print admin header
20
require('../../config.php');
21
require_once(WB_PATH.'/framework/class.admin.php');
22
$admin = new admin('Pages', 'pages_add');
23

  
24
// Include the WB functions file
25
require_once(WB_PATH.'/framework/functions.php');
26

  
27
// Get values
28
$title = $admin->get_post_escaped('title');
29
$title = htmlspecialchars($title);
30
$module = $admin->get_post('type');
31
$parent = $admin->get_post('parent');
32
$visibility = $admin->get_post('visibility');
33
$admin_groups = $admin->get_post('admin_groups');
34
$viewing_groups = $admin->get_post('viewing_groups');
35

  
36
// Work-out if we should check for existing page_code
37
$sql = 'DESCRIBE `'.TABLE_PREFIX.'pages` `page_code`';
38
$field_sql = $database->query($sql);
39
$field_set = $field_sql->numRows();
40

  
41
// add Admin to admin and viewing-groups
42
$admin_groups[] = 1;
43
$viewing_groups[] = 1;
44

  
45
if ($parent!=0) {
46
	if (!$admin->get_page_permission($parent,'admin'))
47
    {
48
        $admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
49
    }
50

  
51
} elseif (!$admin->get_permission('pages_add_l0','system'))
52
{
53
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
54
}	
55

  
56
// Validate data
57
if($title == '' || substr($title,0,1)=='.')
58
{
59
	$admin->print_error($MESSAGE['PAGES']['BLANK_PAGE_TITLE']);
60
}
61

  
62
// Check to see if page created has needed permissions
63
if(!in_array(1, $admin->get_groups_id()))
64
{
65
	$admin_perm_ok = false;
66
	foreach ($admin_groups as $adm_group)
67
    {
68
		if (in_array($adm_group, $admin->get_groups_id()))
69
        {
70
			$admin_perm_ok = true;
71
		}
72
	}
73
	if ($admin_perm_ok == false)
74
    {
75
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
76
	}
77
	$admin_perm_ok = false;
78
	foreach ($viewing_groups as $view_group)
79
    {
80
		if (in_array($view_group, $admin->get_groups_id()))
81
        {
82
			$admin_perm_ok = true;
83
		}
84
	}
85
	if ($admin_perm_ok == false)
86
    {
87
		$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
88
	}
89
}
90

  
91
$admin_groups = implode(',', $admin_groups);
92
$viewing_groups = implode(',', $viewing_groups);
93

  
94
// Work-out what the link and page filename should be
95
if($parent == '0')
96
{
97
	$link = '/'.page_filename($title);
98
	// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
99
	if($link == '/index' || $link == '/intro')
100
    {
101
		$link .= '_0';
102
		$filename = WB_PATH .PAGES_DIRECTORY .'/' .page_filename($title) .'_0' .PAGE_EXTENSION;
103
	} else {
104
		$filename = WB_PATH.PAGES_DIRECTORY.'/'.page_filename($title).PAGE_EXTENSION;
105
	}
106
} else {
107
	$parent_section = '';
108
	$parent_titles = array_reverse(get_parent_titles($parent));
109
	foreach($parent_titles AS $parent_title)
110
    {
111
		$parent_section .= page_filename($parent_title).'/';
112
	}
113
	if($parent_section == '/') { $parent_section = ''; }
114
	$link = '/'.$parent_section.page_filename($title);
115
	$filename = WB_PATH.PAGES_DIRECTORY.'/'.$parent_section.page_filename($title).PAGE_EXTENSION;
116
	make_dir(WB_PATH.PAGES_DIRECTORY.'/'.$parent_section);
117
}
118

  
119
// Check if a page with same page filename exists
120
$get_same_page = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE link = '$link'");
121
if($get_same_page->numRows() > 0 OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.PAGE_EXTENSION) OR file_exists(WB_PATH.PAGES_DIRECTORY.$link.'/'))
122
{
123
	$admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']);
124
}
125

  
126
// Include the ordering class
127
require(WB_PATH.'/framework/class.order.php');
128
$order = new order(TABLE_PREFIX.'pages', 'position', 'page_id', 'parent');
129
// First clean order
130
$order->clean($parent);
131
// Get new order
132
$position = $order->get_new($parent);
133

  
134
// Work-out if the page parent (if selected) has a seperate template or language to the default
135
$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'");
136
if($query_parent->numRows() > 0)
137
{
138
	$fetch_parent = $query_parent->fetchRow();
139
	$template = $fetch_parent['template'];
140
	$language = $fetch_parent['language'];
141
} else {
142
	$template = '';
143
	$language = DEFAULT_LANGUAGE;
144
}
145

  
146
// Insert page into pages table
147
$sql  = 'INSERT INTO `'.TABLE_PREFIX.'pages` SET ';
148
$sql .= '`parent` = '.$parent.', ';
149
$sql .= '`target` = "_top", ';
150
$sql .= '`page_title` = "'.$title.'", ';
151
$sql .= '`menu_title` = "'.$title.'", ';
152
$sql .= '`template` = "'.$template.'", ';
153
$sql .= '`visibility` = "'.$visibility.'", ';
154
$sql .= '`position` = '.$position.', ';
155
$sql .= '`menu` = 1, ';
156
$sql .= '`language` = "'.$language.'", ';
157
$sql .= '`searching` = 1, ';
158
$sql .= '`modified_when` = '.time().', ';
159
$sql .= '`modified_by` = '.$admin->get_user_id().', ';
160
$sql .= '`admin_groups` = "'.$admin_groups.'", ';
161
$sql .= '`viewing_groups` = "'.$viewing_groups.'"';
162

  
163
$database->query($sql);
164
/*
165
$query = "INSERT INTO ".TABLE_PREFIX."pages
166
(page_title,menu_title,parent,template,target,position,visibility,searching,menu,language,admin_groups,viewing_groups,modified_when,modified_by) VALUES
167
('$title','$title','$parent','$template','_top','$position','$visibility','1','1','$language','$admin_groups','$viewing_groups','".time()."','".$admin->get_user_id()."')";
168
$database->query($query);
169
*/
170
if($database->is_error())
171
{
172
	$admin->print_error($database->get_error());
173
}
174

  
175
// Get the page id
176
$page_id = $database->get_one("SELECT LAST_INSERT_ID()");
177

  
178
// Work out level
179
$level = level_count($page_id);
180
// Work out root parent
181
$root_parent = root_parent($page_id);
182
// Work out page trail
183
$page_trail = get_page_trail($page_id);
184

  
185
// Update page with new level and link
186
$sql  = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
187
$sql .= '`root_parent` = '.$root_parent.', ';
188
$sql .= '`level` = '.$level.', ';
189
$sql .= '`link` = "'.$link.'", ';
190
$sql .= '`page_trail` = "'.$page_trail.'"';
191
$sql .= (defined('PAGE_LANGUAGES') && PAGE_LANGUAGES)
192
         && $field_set
193
         && ($language == DEFAULT_LANGUAGE)
194
         && (file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php')
195
         )
196
         ? ', `page_code` = '.(int)$page_id.' ' : ' ';
197
$sql .= 'WHERE `page_id` = '.$page_id;
198
$database->query($sql);
199
/*
200
$database->query("UPDATE ".TABLE_PREFIX."pages SET link = '$link', level = '$level', root_parent = '$root_parent', page_trail = '$page_trail' WHERE page_id = '$page_id'");
201
*/
202
if($database->is_error())
203
{
204
	$admin->print_error($database->get_error());
205
}
206
// Create a new file in the /pages dir
207
create_access_file($filename, $page_id, $level);
208

  
209
// add position 1 to new page
210
$position = 1;
211

  
212
// Add new record into the sections table
213
$database->query("INSERT INTO ".TABLE_PREFIX."sections (page_id,position,module,block) VALUES ('$page_id','$position', '$module','1')");
214

  
215
// Get the section id
216
$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
217

  
218
// Include the selected modules add file if it exists
219
if(file_exists(WB_PATH.'/modules/'.$module.'/add.php')) {
220
	require(WB_PATH.'/modules/'.$module.'/add.php');
221
}
222

  
223
// Check if there is a db error, otherwise say successful
224
if($database->is_error()) {
225
	$admin->print_error($database->get_error());
226
} else {
227
	$admin->print_success($MESSAGE['PAGES']['ADDED'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
228
}
229

  
230
// Print admin footer
231
$admin->print_footer();
232

  
178 233
?>
179 234

  
branches/2.8.x/wb/admin/settings/save.php
25 25
// Print admin header
26 26
require('../../config.php');
27 27
require_once(WB_PATH.'/framework/class.admin.php');
28
if($advanced == '') {
28
if($advanced == '')
29
{
29 30
	$admin = new admin('Settings', 'settings_basic');
30 31
	$_POST['database_password'] = DB_PASSWORD;
31 32
} else {
......
39 40
if(isset($_POST['server_email']))
40 41
{
41 42
	$_POST['server_email'] = strip_tags($_POST['server_email']);
42
	if(!eregi("^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$", $_POST['server_email'])) {
43
    $pattern = '/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9]([-a-z0-9_]?[a-z0-9])*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z]{2})|([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3})(:[0-9]{1,5})?\r/im';
44
    // $pattern = '/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,6}))$/';
45
    if(false == preg_match($pattern, $_POST['server_email']))
46
    {
43 47
		$admin->print_error($MESSAGE['USERS']['INVALID_EMAIL'].
44 48
			'<br /><strong>Email: '.htmlentities($_POST['server_email']).'</strong>', $js_back);
45 49
	}
branches/2.8.x/wb/search/search_modext.php
17 17
 */
18 18

  
19 19
// make the url-string for highlighting
20
function make_url_searchstring($search_match, $search_url_array) {
20
function make_url_searchstring($search_match, $search_url_array)
21
{
21 22
	$link = "";
22
	if ($search_match != 'exact') {
23
	if ($search_match != 'exact')
24
    {
23 25
		$str = implode(" ", $search_url_array);
24 26
		$link = "?searchresult=1&amp;sstring=".urlencode($str);
25 27
	} else {
......
30 32
}
31 33

  
32 34
// make date and time for "last modified by... on ..."-string
33
function get_page_modified($page_modified_when) {
35
function get_page_modified($page_modified_when)
36
{
34 37
	global $TEXT;
35
	if($page_modified_when > 0) {
38
	if($page_modified_when > 0)
39
    {
36 40
		$date = gmdate(DATE_FORMAT, $page_modified_when+TIMEZONE);
37 41
		$time = gmdate(TIME_FORMAT, $page_modified_when+TIMEZONE);
38 42
	} else {
......
43 47
}
44 48

  
45 49
// make username and displayname for "last modified by... on ..."-string
46
function get_page_modified_by($page_modified_by, $users) {
50
function get_page_modified_by($page_modified_by, $users)
51
{
47 52
	global $TEXT;
48 53
	// check for existing user-id
49 54
	if(!isset($users[$page_modified_by]))
50
		$page_modified_by = 0;
51
	
55
    {
56
        $page_modified_by = 0;
57
    }
58

  
52 59
	$username = $users[$page_modified_by]['username'];
53 60
	$displayname = $users[$page_modified_by]['display_name'];
54 61
	return array($username, $displayname);
55 62
}
56 63

  
57 64
// checks if _all_ searchwords matches
58
function is_all_matched($text, $search_words) {
65
function is_all_matched($text, $search_words)
66
{
59 67
	$all_matched = true;
60
	foreach ($search_words AS $word) {
61
		if(!preg_match('/'.$word.'/ui', $text)) {
68
	foreach ($search_words AS $word)
69
    {
70
		if(!preg_match('/'.$word.'/ui', $text))
71
        {
62 72
			$all_matched = false;
63 73
			break;
64 74
		}
......
67 77
}
68 78

  
69 79
// checks if _any_ of the searchwords matches
70
function is_any_matched($text, $search_words) {
80
function is_any_matched($text, $search_words)
81
{
71 82
	$any_matched = false;
72 83
	$word = '('.implode('|', $search_words).')';
73
	if(preg_match('/'.$word.'/ui', $text)) {
84
	if(preg_match('/'.$word.'/ui', $text))
85
    {
74 86
		$any_matched = true;
75 87
	}
76 88
	return $any_matched;
77 89
}
78 90

  
79 91
// collects the matches from text in excerpt_array
80
function get_excerpts($text, $search_words, $max_excerpt_num) {
92
function get_excerpts($text, $search_words, $max_excerpt_num)
93
{
81 94
	$match_array = array();
82 95
	$excerpt_array = array();
83 96
	$word = '('.implode('|', $search_words).')';
84 97

  
85 98
	//Filter droplets from the page data
86 99
	preg_match_all('~\[\[(.*?)\]\]~', $text, $matches);
87
	foreach ($matches[1] as $match) {
100
	foreach ($matches[1] as $match)
101
    {
88 102
		$text = str_replace('[['.$match.']]', '', $text);					
89 103
	}
90 104

  
91 105
	// Build the regex-string
92
	if(strpos(strtoupper(PHP_OS), 'WIN')===0) { // windows -> see below
106
	if(strpos(strtoupper(PHP_OS), 'WIN')===0)  // windows -> see below
107
    {
93 108
		$str1=".!?;";
94 109
		$str2=".!?;";
95 110
	} else { // linux & Co.
......
104 119
	) { // this may crash windows server, so skip if on windows
105 120
		// jump from match to match, get excerpt, stop if $max_excerpt_num is reached
106 121
		$last_end = 0; $offset = 0;
107
		while(preg_match('/'.$word.'/uis', $text, $match_array, PREG_OFFSET_CAPTURE, $last_end)) {
122
		while(preg_match('/'.$word.'/uis', $text, $match_array, PREG_OFFSET_CAPTURE, $last_end))
123
        {
108 124
			$offset = ($match_array[0][1]-206 < $last_end)?$last_end:$match_array[0][1]-206;
109
			if(preg_match($regex, $text, $matches, PREG_OFFSET_CAPTURE, $offset)) {
125
			if(preg_match($regex, $text, $matches, PREG_OFFSET_CAPTURE, $offset))
126
            {
110 127
				$last_end = $matches[1][1]+strlen($matches[1][0])-1;
111 128
				if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $matches[1][0])) // skip excerpts with email-addresses
112
					$excerpt_array[] = trim($matches[1][0]);
113
				if(count($excerpt_array)>=$max_excerpt_num) {
129
				{
130
				  $excerpt_array[] = trim($matches[1][0]);
131
                }
132
				if(count($excerpt_array)>=$max_excerpt_num)
133
                {
114 134
					$excerpt_array = array_unique($excerpt_array);
115
					if(count($excerpt_array) >= $max_excerpt_num)
116
						break;
135
					if(count($excerpt_array) >= $max_excerpt_num) { break; }
117 136
				}
118 137
			} else { // problem: preg_match failed - can't find a start- or stop-sign
119 138
				$last_end += 201; // jump forward and try again
120 139
			}
121 140
		}
122 141
	} else { // compatible, but may be very slow with large pages
123
		if(preg_match_all($regex, $text, $match_array)) {
124
			foreach($match_array[1] AS $string) {
142
		if(preg_match_all($regex, $text, $match_array))
143
        {
144
			foreach($match_array[1] AS $string)
145
            {
125 146
				if(!preg_match('/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\./', $string))  // skip excerpts with email-addresses
126
					$excerpt_array[] = trim($string);
127
				
147
				{
148
				  $excerpt_array[] = trim($string);
149
                }
150

  
128 151
			}
129 152
		}
130 153
	}
......
132 155
}
133 156

  
134 157
// makes excerpt_array a string ready to print out
135
function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num) {
158
function prepare_excerpts($excerpt_array, $search_words, $max_excerpt_num)
159
{
136 160
	// excerpts: text before and after a single excerpt, html-tag for markup
137 161
	$EXCERPT_BEFORE =       '...&nbsp;';
138 162
	$EXCERPT_AFTER =        '&nbsp;...<br />';
......
141 165
	// remove duplicate matches from $excerpt_array, if any.
142 166
	$excerpt_array = array_unique($excerpt_array);
143 167
	// use the first $max_excerpt_num excerpts only
144
	if(count($excerpt_array) > $max_excerpt_num) {
168
	if(count($excerpt_array) > $max_excerpt_num)
169
    {
145 170
		$excerpt_array = array_slice($excerpt_array, 0, $max_excerpt_num);
146 171
	}
147 172
	// prepare search-string
......
149 174
	// we want markup on search-results page,
150 175
	// but we need some 'magic' to prevent <br />, <b>... from being highlighted
151 176
	$excerpt = '';
152
	foreach($excerpt_array as $str) {
177
	foreach($excerpt_array as $str)
178
    {
153 179
		$excerpt .= '#,,#'.preg_replace("/($string)/iu","#,,,,#$1#,,,,,#",$str).'#,,,#';
154 180
	}
155 181
	$excerpt = str_replace(array('&','<','>','"','\'',"\xC2\xA0"), array('&amp;','&lt;','&gt;','&quot;','&#039;','&nbsp;'), $excerpt);
156 182
	$excerpt = str_replace(array('#,,,,#','#,,,,,#'), array($EXCERPT_MARKUP_START,$EXCERPT_MARKUP_END), $excerpt);
157 183
	$excerpt = str_replace(array('#,,#','#,,,#'), array($EXCERPT_BEFORE,$EXCERPT_AFTER), $excerpt);
158 184
	// prepare to write out
159
	if(DEFAULT_CHARSET != 'utf-8') {
185
	if(DEFAULT_CHARSET != 'utf-8')
186
    {
160 187
		$excerpt = umlauts_to_entities($excerpt, 'UTF-8');
161 188
	}
162 189
	return $excerpt;
163 190
}
164 191

  
165 192
// work out what the link-anchor should be
166
function make_url_target($page_link_target, $text, $search_words) {
193
function make_url_target($page_link_target, $text, $search_words)
194
{
167 195
	// 1. e.g. $page_link_target=="&monthno=5&year=2007" - module-dependent target. Do nothing.
168 196
	// 2. $page_link_target=="#!wb_section_..." - the user wants the section-target, so do nothing.
169 197
	// 3. $page_link_target=="#wb_section_..." - try to find a better target, use the section-target as fallback.
170 198
	// 4. $page_link_target=="" - do nothing
171
	if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_') {
199
	if(version_compare(PHP_VERSION, '4.3.3', ">=") && substr($page_link_target,0,12)=='#wb_section_')
200
    {
172 201
		$word = '('.implode('|', $search_words).')';
173 202
		preg_match('/'.$word.'/ui', $text, $match, PREG_OFFSET_CAPTURE);
174
		if($match && is_array($match[0])) {
203
		if($match && is_array($match[0]))
204
        {
175 205
			$x=$match[0][1]; // position of first match
176 206
			// is there an anchor nearby?
177
			if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iU', substr($text,0,$x), $match, PREG_OFFSET_CAPTURE)) {
207
			if(preg_match_all('/<(?:[^>]+id|\s*a[^>]+name)\s*=\s*"(.*)"/iU', substr($text,0,$x), $match, PREG_OFFSET_CAPTURE))
208
            {
178 209
				$anchor='';
179
				foreach($match[1] AS $array) {
180
					if($array[1] > $x) {
210
				foreach($match[1] AS $array)
211
                {
212
					if($array[1] > $x)
213
                    {
181 214
						break;
182 215
					}
183 216
					$anchor = $array[0];
184 217
				}
185
				if($anchor != '') {
218
				if($anchor != '')
219
                {
186 220
					$page_link_target = '#'.$anchor;
187 221
				}
188 222
			}
189 223
		}
190
	}
191
	elseif(substr($page_link_target,0,13)=='#!wb_section_') {
224
	} elseif(substr($page_link_target,0,13)=='#!wb_section_') {
192 225
		$page_link_target = '#'.substr($page_link_target, 2);
193 226
	}
194 227
	
195 228
	// since wb 2.7.1 the section-anchor is configurable - SEC_ANCHOR holds the anchor name
196
	if(substr($page_link_target,0,12)=='#wb_section_') {
197
		if(defined('SEC_ANCHOR') && SEC_ANCHOR!='') {
229
	if(substr($page_link_target,0,12)=='#wb_section_')
230
    {
231
		if(defined('SEC_ANCHOR') && SEC_ANCHOR!='')
232
        {
198 233
			$sec_id = substr($page_link_target, 12);
199 234
			$page_link_target = '#'.SEC_ANCHOR.$sec_id;
200 235
		} else { // section-anchors are disabled
......
206 241
}
207 242

  
208 243
// wrapper for compatibility with old print_excerpt()
209
function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="") {
244
function print_excerpt($page_link, $page_link_target, $page_title, $page_description, $page_modified_when, $page_modified_by, $text, $max_excerpt_num, $func_vars, $pic_link="")
245
{
210 246
	$mod_vars = array(
211 247
		'page_link' => $page_link,
212 248
		'page_link_target' => $page_link_target,
......
228 264
 * list_files_dirs() - lists all files and dirs below a given directory
229 265
 * clear_filelist() - keeps only wanted or removes unwanted entries in file-list.
230 266
 */
231
 
267

  
232 268
// prints the excerpts for one section
233
function print_excerpt2($mod_vars, $func_vars) {
269
function print_excerpt2($mod_vars, $func_vars)
270
{
234 271
	extract($func_vars, EXTR_PREFIX_ALL, 'func');
235 272
	extract($mod_vars, EXTR_PREFIX_ALL, 'mod');
236 273
	global $TEXT;
237 274
	// check $mod_...vars
238
	if(!isset($mod_page_link))          $mod_page_link = $func_page_link;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff