Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Galerry Avatar hack
Lwie_Serce_
post
Post #1





Grupa: Zarejestrowani
Postów: 38
Pomógł: 0
Dołączył: 2.12.2004
Skąd: Tarnów

Ostrzeżenie: (10%)
X----


Pisze poniewaz pojawil sie u mnie problemik, ktory do tej pory niemial oakzji u mnie goscic. Mianowicie instaluje sobie modyfikacje "Avatar gallery hack". dzięki której raz wybrany przez użytkownika avatar znika z galerii i nie może być ponownie wybrany, i pojawia sie niespodzianka po kliknieciu w profil->Pokaż galerię, wyswietla sie samo tlo mojego forum zamiast galerii avatarow. I nie wiem co jest nie tak, robie wszystko wedlug instrukcji i mimo to nie dziala sad.gif
Instalacja moda Avatar gallery hack:

Otwieram
  1. <?php
  2. includes&#092;usercp_avatar.php
  3. ?>

Znajduje
  1. <?php
  2. $dir = @opendir($board_config['avatar_gallery_path']);
  3. ?>

Dodaje przed
  1. <?php
  2. $my_counter = 0;
  3. $my_checker = 0;
  4. $sql = &#092;"SELECT user_avatar
  5.     FROM &#092;" . USERS_TABLE . \"
  6.     WHERE user_avatar_type=3&#092;";
  7.  
  8. if( !($result = $db->sql_query($sql)) )
  9. {
  10.     message_die(GENERAL_ERROR, 'Could not query users', '', __LINE__, __FILE__, $sql);
  11. }
  12.  
  13. while( $row = $db->sql_fetchrow($result) )
  14. {
  15.     $my_counter++;
  16.     $my_used_list[$my_counter] = $row['user_avatar'];        
  17. }
  18.  
  19. $db->sql_freeresult($result);
  20. ?>


Znajduje
  1. <?php
  2. while( $sub_file = @readdir($sub_dir) )
  3. {
  4.     if( preg_match('/(.gif$|.png$|.jpg|.jpeg)$/is', $sub_file) )
  5.     {
  6.         $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . '/' . $sub_file; 
  7.         $avatar_name[$file][$avatar_row_count][$avatar_col_count] = ucfirst(str_replace(&#092;"_\", \" \", preg_replace('/^(.*)..*$/', '1', $sub_file)));
  8.  
  9.         $avatar_col_count++;
  10.         if( $avatar_col_count == 5 )
  11.         {
  12.             $avatar_row_count++;
  13.             $avatar_col_count = 0;
  14.         }
  15.     }
  16. }
  17. ?>


Zamieniam na
  1. <?php
  2. while( $sub_file = @readdir($sub_dir) )
  3. {
  4. $my_checker = 0;
  5. for ($i = 1; $i<= $my_counter; $i++ )
  6. {
  7.     $my_temp = $file . '/' . $sub_file;
  8.     if ($my_temp == $my_used_list[$i]) $my_checker=1;
  9.     if ($my_checker==1) break;
  10. }
  11.     if ($my_checker == 0)        
  12.     {
  13.         if( preg_match('/(.gif$|.png$|.jpg|.jpeg)$/is', $sub_file) )
  14.         {
  15.             $avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . '/' . $sub_file; 
  16.             $avatar_name[$file][$avatar_row_count][$avatar_col_count] = ucfirst(str_replace(&#092;"_\", \" \", preg_replace('/^(.*)..*$/', '1', $sub_file)));
  17.  
  18.             $avatar_col_count++;
  19.             if( $avatar_col_count == 5 )
  20.             {
  21.                 $avatar_row_count++;
  22.                 $avatar_col_count = 0;
  23.             }
  24.         }
  25.     }
  26. }
  27. ?>


Zamykam i zapisuje wszystko, wgrywam plik na serwer, ktory po edycji wyglada tak:
Kod 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
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
<?php
function check_image_type(&$type, &$error, &$error_msg)
{
global
$lang;

switch(
$type )
{
case
'jpeg':
case
'pjpeg':
case
'jpg':
return
'.jpg';
break;
case
'gif':
return
'.gif';
break;
case
'png':
return
'.png';
break;
default:
$error = true;
$error_msg = (!empty($error_msg)) ? $error_msg . '<br />' . $lang['Avatar_filetype'] : $lang['Avatar_filetype'];
break;
}

return
false;
}

function
user_avatar_delete($avatar_type, $avatar_file)
{
global
$board_config, $userdata;

if (
$avatar_type == USER_AVATAR_UPLOAD && $avatar_file != '' )
{
if ( @
file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $avatar_file)) )
{
@
unlink('./' . $board_config['avatar_path'] . '/' . $avatar_file);
}
}

return
", user_avatar = '', user_avatar_type = " . USER_AVATAR_NONE;
}

function
user_avatar_gallery($mode, &$error, &$error_msg, $avatar_filename)
{
global
$board_config;
if (
file_exists(@phpbb_realpath($board_config['avatar_gallery_path'] . '/' . $avatar_filename)) && ($mode == 'editprofile') )
{
$return = ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_GALLERY;
}
else
{
$return = '';
}
return
$return;
}

function
user_avatar_url($mode, &$error, &$error_msg, $avatar_filename)
{
if ( !
preg_match('#^(http)|(ftp):\/\/#i', $avatar_filename) )
{
$avatar_filename = 'http://' . $avatar_filename;
}

if ( !
preg_match("#^((ht|f)tp://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png))$)#is", $avatar_filename) )
{
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format'];
return;
}

return (
$mode == 'editprofile' ) ? ", user_avatar = '" . str_replace("\'", "''", $avatar_filename) . "', user_avatar_type = " . USER_AVATAR_REMOTE : '';

}

function
user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_type, &$error, &$error_msg, $avatar_filename, $avatar_realname, $avatar_filesize, $avatar_filetype)
{
global
$board_config, $db, $lang;

$ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';

if (
$avatar_mode == 'remote' && preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $avatar_filename, $url_ary) )
{
if ( empty(
$url_ary[4]) )
{
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['Incomplete_URL'] : $lang['Incomplete_URL'];
return;
}

$base_get = '/' . $url_ary[4];
$port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;

if ( !(
$fsock = @fsockopen($url_ary[2], $port, $errno, $errstr)) )
{
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['No_connection_URL'] : $lang['No_connection_URL'];
return;
}

@
fputs($fsock, "GET $base_get HTTP/1.1\r\n");
@
fputs($fsock, "HOST: " . $url_ary[2] . "\r\n");
@
fputs($fsock, "Connection: close\r\n\r\n");

unset(
$avatar_data);
while( !@
feof($fsock) )
{
$avatar_data .= @fread($fsock, $board_config['avatar_filesize']);
}
@
fclose($fsock);

if (!
preg_match('#Content-Length\: ([0-9]+)[^ /][\s]+#i', $avatar_data, $file_data1) || !preg_match('#Content-Type\: image/[x\-]*([a-z]+)[\s]+#i', $avatar_data, $file_data2))
{
$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $lang['File_no_data'] : $lang['File_no_data'];
return;
}

$avatar_filesize = $file_data1[1];
$avatar_filetype = $file_data2[1];

if ( !
$error && $avatar_filesize > 0 && $avatar_filesize < $board_config['avatar_filesize'] )
{
$avatar_data = substr($avatar_data, strlen($avatar_data) - $avatar_filesize, $avatar_filesize);

$tmp_path = ( !@$ini_val('safe_mode') ) ? '/tmp' : './' . $board_config['avatar_path'] . '/tmp';
$tmp_filename = tempnam($tmp_path, uniqid(rand()) . '-');

$fptr = @fopen($tmp_filename, 'wb');
$bytes_written = @fwrite($fptr, $avatar_data, $avatar_filesize);
@
fclose($fptr);

if (
$bytes_written != $avatar_filesize )
{
@
unlink($tmp_filename);
message_die(GENERAL_ERROR, 'Could not write avatar file to local storage. Please contact the board administrator with this message', '', __LINE__, __FILE__);
}

list(
$width, $height) = @getimagesize($tmp_filename);
}
else
{
$l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));

$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}
}
else if ( (
file_exists(@phpbb_realpath($avatar_filename)) ) && preg_match('/\.(jpg|jpeg|gif|png)$/i', $avatar_realname) )
{
if (
$avatar_filesize <= $board_config['avatar_filesize'] && $avatar_filesize > 0 )
{
preg_match('#image\/[x\-]*([a-z]+)#', $avatar_filetype, $avatar_filetype);
$avatar_filetype = $avatar_filetype[1];
}
else
{
$l_avatar_size = sprintf($lang['Avatar_filesize'], round($board_config['avatar_filesize'] / 1024));

$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
return;
}

list(
$width, $height) = @getimagesize($avatar_filename);
}

if ( !(
$imgtype = check_image_type($avatar_filetype, $error, $error_msg)) )
{
return;
}

if (
$width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] )
{
$new_filename = uniqid(rand()) . $imgtype;

if (
$mode == 'editprofile' && $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' )
{
if (
file_exists(@phpbb_realpath('./' . $board_config['avatar_path'] . '/' . $current_avatar)) )
{
@
unlink('./' . $board_config['avatar_path'] . '/' . $current_avatar);
}
}

if(
$avatar_mode == 'remote' )
{
@
copy($tmp_filename, './' . $board_config['avatar_path'] . "/$new_filename");
@
unlink($tmp_filename);
}
else
{
if ( @
$ini_val('open_basedir') != '' )
{
if ( @
phpversion() < '4.0.3' )
{
message_die(GENERAL_ERROR, 'open_basedir is set and your php version does not allow move_uploaded_file', '', __LINE__, __FILE__);
}

$move_file = 'move_uploaded_file';
}
else
{
$move_file = 'copy';
}

$move_file($avatar_filename, './' . $board_config['avatar_path'] . "/$new_filename");
}

@
chmod('./' . $board_config['avatar_path'] . "/$new_filename", 0777);

$avatar_sql = ( $mode == 'editprofile' ) ? ", user_avatar = '$new_filename', user_avatar_type = " . USER_AVATAR_UPLOAD : "'$new_filename', " . USER_AVATAR_UPLOAD;
}
else
{
$l_avatar_size = sprintf($lang['Avatar_imagesize'], $board_config['avatar_max_width'], $board_config['avatar_max_height']);

$error = true;
$error_msg = ( !empty($error_msg) ) ? $error_msg . '<br />' . $l_avatar_size : $l_avatar_size;
}

return
$avatar_sql;
}

function
display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popup_pm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat, &$session_id)
{
global
$board_config, $db, $template, $lang, $images, $theme;
global
$phpbb_root_path, $phpEx;
$my_counter = 0;
$my_checker = 0;
$sql = "SELECT user_avatar
FROM "
. USERS_TABLE . "
WHERE user_avatar_type=3"
;

if( !(
$result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query users', ''
Ten post edytował Lwie_Serce_ 17.12.2004, 14:22:30
Go to the top of the page
+Quote Post

Posty w temacie
- Lwie_Serce_   Galerry Avatar hack   17.12.2004, 12:52:05


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 

RSS Aktualny czas: 19.08.2025 - 07:39