"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "lib_image.php3":
1.2.0_vs_1.2.1.
1 <?php
2 #----------------------------------------------------------------->
3 # $Id: lib_image.php3,v 1.6 2008/05/03 21:14:54 ldrolez Exp $
4 #
5 # Website: http://mythreads.sourceforge.net
6 #
7 # Desc: lib_image.php3. Image creation functions
8 #
9 # License: This code is released under the terms of the GNU GPL
10 # version 2 or later. Please refer to www.gnu.org for a copy
11 # of this license.
12 #
13 #----------------------------------------------------------------->
14
15 function ImageOutput($text)
16 {
17 srand();
18 $font = "./images/Vera.ttf";
19 $bgurl = rand(1, 3);
20 $im = ImageCreateFromJPEG("./images/bg".$bgurl.".jpg");
21
22
23 $size = rand(10, 13);
24 $angle = rand(-18, 18);
25 $color = ImageColorAllocate($im, rand(50, 120), rand(50, 120), rand(50, 120));
26
27 $textsize = imagettfbbox($size, $angle, $font, $text);
28 $twidth = abs($textsize[2]-$textsize[0]);
29 $theight = abs($textsize[5]-$textsize[3]);
30 $x = (imagesx($im)/2)-($twidth/2)+(rand(-20, 20));
31 $y = (imagesy($im))-($theight/2)-10;
32
33 for ($i = 0; $i < 3; $i++) {
34 ImageTTFText($im, $size, $angle, $x-$i, $y-$i, $color, $font, $text);
35 }
36
37 header("Content-Type: image/png");
38 ImagePNG($im);
39
40 imagedestroy($im);
41 }
42
43 #
44 #
45 #
46 function ImageGenSecret($len)
47 {
48 srand();
49 $chars = array("a","A","b","B","c","C","d","D","e","E","f","F","g","G",
50 "h","H","i","I","j","J","k",
51 "K","l","L","m","M","n","N","o","O","p","P","q","Q","r",
52 "R","s","S","t","T","u","U","v",
53 "V","w","W","x","X","y","Y","z","Z","1","2","3","4","5",
54 "6","7","8","9");
55 $chars = array("a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9");
56 $textstr = "";
57 for ($i=0; $i<$len; $i++) {
58 $textstr .= $chars[rand(0, count($chars)-1)];
59 }
60
61 return $textstr;
62 }
63
64 #
65 # Encrypt the secret
66 #
67 # Current algo used: XOR($secret, MD5(sql host + mythreads admin pass))
68 # I should use a crypto extension when available.
69 # But this XOR encryption is reasonably secure since it's nearly impossible
70 # to find the admin password from the MD5 hash.
71 #
72 function ImageGenSecretRef($secret)
73 {
74 global $config, $admin_password, $host;
75
76 $ret = "";
77
78 $pass = md5($host."X".$config['security_code']."X".date('Hz'));
79 // xor
80 for ($i = 0; $i < strlen($secret); $i++) {
81 $a = $pass[$i];
82 $b = $secret[$i];
83 $c = base_convert(intval($a, 16) ^ intval($b, 16), 10, 16);
84 // echo "$a $b $c\n";
85 $ret[$i] = strval($c);
86 }
87 return join($ret, "");
88 }
89
90 # test
91 if (0) {
92 $sec = ImageGenSecret(10);
93 ImageOutput($sec);
94 exit;
95 $sec = $sec;
96 echo $sec."\n";
97 $ref=ImageGenSecretRef($sec);
98 echo $ref."\n";
99 $ref=ImageGenSecretRef($ref);
100 echo $ref."\n";
101
102 }
103
104 ?>