Pagina 1 van 1

Probleem met avatar-gallery

Geplaatst: 22 jun 2004, 22:30
door Jivisstudios
Ik heb een probleem met de avatar-gallery.
Als ik een categorie wil selecteren en op "go" klik, blijft hij bij de eerste categorie hangen.

Dit zijn de files:

profile_avatar_gallery.tpl:

Code: Selecteer alles

<form action="{S_PROFILE_ACTION}" method="post">
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
  <tr> 
	<td align="left"><span class="nav"><a href="{U_INDEX}" class="nav">{L_INDEX}</a></span></td>
  </tr>
</table>

<table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
	<tr> 
	  <th class="thHead" colspan="{S_COLSPAN}" height="25" valign="middle">{L_AVATAR_GALLERY}</th>
	</tr>
	<tr> 
		  <td class="row1" align="center" valign="middle" colspan="6" height="28"><span class="genmed">{L_AVATAR_DISCLAIMER}</span></td>
	</tr>
	<tr> 
	  <td class="catBottom" align="center" valign="middle" colspan="6" height="28"><span class="genmed">{L_CATEGORY}:&nbsp;{S_CATEGORY_SELECT}&nbsp;<input type="submit" class="liteoption" value="{L_GO}" name="avatargallery" /></span></td>
	</tr>
	<!-- BEGIN avatar_row -->
	<tr> 
	<!-- BEGIN avatar_column -->
		<td class="row1" align="center"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td>
	<!-- END avatar_column -->
	</tr>
	<tr>
	<!-- BEGIN avatar_option_column -->
		<td class="row2" align="center"><input type="radio" name="avatarselect" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td>
	<!-- END avatar_option_column -->
	</tr>

	<!-- END avatar_row -->
	<tr> 
	  <td class="catBottom" colspan="{S_COLSPAN}" align="center" height="28">{S_HIDDEN_FIELDS} 
		<input type="submit" name="submitavatar" value="{L_SELECT_AVATAR}" class="mainoption" />
		&nbsp;&nbsp; 
		<input type="submit" name="cancelavatar" value="{L_RETURN_PROFILE}" class="liteoption" />
	  </td>
	</tr>
  </table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td><span class="nav">{PAGE_NUMBER}</span></td>
    <td align="right"><span class="nav">{PAGINATION}</span></td>
  </tr>
</table></form>
usercp_avatar:

Code: Selecteer alles

<?php
/***************************************************************************
 *                             usercp_avatar.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: usercp_avatar.php,v 1.8.2.17 2003/03/04 21:02:36 acydburn Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *
 ***************************************************************************/

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('#^((http)|(ftp):\/\/[\w\-]+?\.([\w\-]+\.)+[\w]+(:[0-9]+)*\/.*?\.(gif|jpg|jpeg|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['sig_max_img_av_files_size'] ) ? $board_config['sig_max_img_av_files_size'] : $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 ( ( $avatar_filesize > 0 && $avatar_filesize < $board_config['avatar_filesize']) || $board_config['sig_max_img_av_files_size']
 )
		{
			$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) || $board_config['sig_max_img_av_files_size'] )
		{
			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, &$websitename
, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popup_pm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$rankset, &$dateformat, &$firstname, &$gethere)
{
	global $board_config, $db, $template, $lang, $images, $theme, $start;
	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', '', __LINE__, __FILE__, $sql);
}

while( $row = $db->sql_fetchrow($result) )
{
	$my_counter++;
	$my_used_list[$my_counter] = $row['user_avatar'];
}

$db->sql_freeresult($result);

	$dir = @opendir($board_config['avatar_gallery_path']);

	$avatar_images = array();
	while( $file = @readdir($dir) )
	{
		if( $file != '.' && $file != '..' && !is_file($board_config['avatar_gallery_path'] . '/' . $file) && !is_link($board_config['avatar_gallery_path'] . '/' . $file) )
		{
			$sub_dir = @opendir($board_config['avatar_gallery_path'] . '/' . $file);

			$avatar_row_count = 0;
			$avatar_col_count = 0;
			while( $sub_file = @readdir($sub_dir) )
			{
			$my_checker = 0;
			for ($i = 1; $i<= $my_counter; $i++ )
			{
				$my_temp = $file . '/' . $sub_file;
				if ($my_temp == $my_used_list[$i]) $my_checker=1;
				if ($my_checker==1) break;
			}
				if ($my_checker == 0)
				{
					if( preg_match('/(\.gif$|\.png$|\.jpg|\.jpeg)$/is', $sub_file) )
					{
						$avatar_images[$file][$avatar_row_count][$avatar_col_count] = $file . '/' . $sub_file;
						$avatar_name[$file][$avatar_row_count][$avatar_col_count] = ucfirst(str_replace("_", " ", preg_replace('/^(.*)\..*$/', '\1', $sub_file)));

						$avatar_col_count++;
						if( $avatar_col_count == 5 )
						{
							$avatar_row_count++;
							$avatar_col_count = 0;
						}
					}
				}
}
		}
	}


	@closedir($dir);

	@ksort($avatar_images);
	@reset($avatar_images);

	if( empty($category) )
	{
		list($category, ) = each($avatar_images);
	}
	@reset($avatar_images);

	$s_categories = '<select name="avatarcategory">';
	while( list($key) = each($avatar_images) )
	{
		$selected = ( $key == $category ) ? ' selected="selected"' : '';
		if( count($avatar_images[$key]) )
		{
			$s_categories .= '<option value="' . $key . '"' . $selected . '>' . ucfirst($key) . '</option>';
		}
	}
	$s_categories .= '</select>';

	$s_colspan = 0;
	for($i = $start / 5; $i < $start / 5  + $board_config['avatars_per_page'] / 5; $i++)
	{
		$template->assign_block_vars("avatar_row", array());

		$s_colspan = max($s_colspan, count($avatar_images[$category][$i]));

		for($j = 0; $j < count($avatar_images[$category][$i]); $j++)

		{
			$template->assign_block_vars('avatar_row.avatar_column', array(
				"AVATAR_IMAGE" => $board_config['avatar_gallery_path'] . '/' . $avatar_images[$category][$i][$j],
				"AVATAR_NAME" => $avatar_name[$category][$i][$j],
				"AVATAR_RANDOM" => $plaatjes = array('$randompath'))
			);


			$template->assign_block_vars('avatar_row.avatar_option_column', array(
				"S_OPTIONS_AVATAR" => $avatar_images[$category][$i][$j])
			);
		}
	}

	$params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'websitename', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'allow_mass_pm', 'popup_pm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'rankset', 'dateformat', 'firstname', 'gethere', 'no_pm', 'custom_rank', 'birthday');

	$s_hidden_vars = '<input type="hidden" name="sid" value="' . $session_id . '" /><input type="hidden" name="agreed" value="true" />';

	for($i = 0; $i < count($params); $i++)
	{
		$s_hidden_vars .= '<input type="hidden" name="' . $params[$i] . '" value="' . str_replace('"', '"', $$params[$i]) . '" />';
	}

	if (!is_array($xdata))
	{
		$xdata = array();
	}

	$xd_meta = get_xd_metadata();
	while ( list($code_name, ) = each($xd_meta) )
	{
		if ( isset($xdata[$code_name]) )
		{
			$s_hidden_vars .= '<input type="hidden" name="'. $code_name . '" value="' . str_replace('"', '"', $xdata[$code_name]) . '" />';
		}
}

	$total = count($avatar_images[$category]) * 5;
		$pagination = ( $total > $board_config['avatars_per_page'] ) ? generate_pagination("profile.$phpEx?mode=editprofile&avatargallery=true&category=$category&sid=$session_id", $total, $board_config['avatars_per_page'], $start). '&nbsp;' : '&nbsp;';

		$template->assign_vars(array(
			'PAGINATION' => $pagination,
			'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['avatars_per_page'] ) + 1 ), ceil( $total / $board_config['avatars_per_page'] )),

		'L_AVATAR_GALLERY' => $lang['Avatar_gallery'],
		'L_AVATAR_DISCLAIMER' => $lang['Avatar_disclaimer'],
		'L_SELECT_AVATAR' => $lang['Select_avatar'],
		'L_AVATAR_CATEGORY' => $lang['Avatar_category'],
		'L_RETURN_PROFILE' => $lang['Return_profile'],
		'L_CATEGORY' => $lang['Select_category'],

		'S_CATEGORY_SELECT' => $s_categories,
		'S_COLSPAN' => $s_colspan,
		'S_PROFILE_ACTION' => append_sid("profile.$phpEx?mode=$mode"),
		'S_HIDDEN_FIELDS' => $s_hidden_vars)
	);

	return;
}

?>
Weet iemand wat er mis is? Ik snap er niks van, ik heb het ook al met vervangende files geprobeerd, maar het wil gewoon niet werken...[/code]

Re: Probleem met avatar-gallery

Geplaatst: 22 jun 2004, 22:32
door mosymuis
Jivisstudios schreef:Ik snap er niks van, ik heb het ook al met vervangende files geprobeerd, maar het wil gewoon niet werken...
Als het met de originele phpBB bestanden ook niet werkt zit het hem dus niet in je bestanden, en heeft het weinig nut ze hier te posten. ;)

Geplaatst: 22 jun 2004, 22:36
door Podium4
Staat javascript aan in je browser?

Geplaatst: 22 jun 2004, 22:50
door mosymuis
Javascript heeft er niets mee te maken, er wordt simpelweg een formulier verzonden.

Geplaatst: 22 jun 2004, 23:01
door DaMnNaTiOn
Ik heb ook zo'n soort probleem alleen dan niet in de avatar gallery.
De jumpbox werkt bij mij niet in forums maar raar genoeg wel op andere plekken zoals in topics!

Forum: http://forum.frankyang.net/forum-2.html
Topic: http://forum.frankyang.net/about90.html

Geplaatst: 23 jun 2004, 09:29
door Jivisstudios
Maar is er iets aan te doen? Want ik heb die avatargallery echt dringend nodig...

Geplaatst: 23 jun 2004, 16:13
door Jivisstudios
Goed, het lukt met die categorieën, alleen doet zich nu weer een ander probleem voor...als ik een avatar heb geselecteerd en terugga naar het profiel wist hij een aantal velden. Niet de velden die er standaard zijn, maar de velden die ik toegevoegd heb door middel van mods.
Ik snap niet wat er fout is. Hier is de code van usercp_register.php:

http://www.athelas-online.nl/usercp_register.txt

Geplaatst: 23 jun 2004, 16:21
door WebSiteNet
Door welke mods? Heb je die wel helemaal uitgevoerd?

Normaal moet je ook aanpassingen maken in uservp_avatar.php voor die mods.

Geplaatst: 23 jun 2004, 16:35
door Jivisstudios
Ik geloof wel dat ik ze allemaal heb uitgevoerd, maar ik zal het nog eens nalopen...

Geplaatst: 23 jun 2004, 17:32
door mosymuis
Jivisstudios schreef:Niet de velden die er standaard zijn, maar de velden die ik toegevoegd heb door middel van mods.
Dat zit hem in deze stukjes:

Code: Selecteer alles

display_avatar_gallery(
in usercp_register en

Code: Selecteer alles

function display_avatar_gallery(

Code: Selecteer alles

$params = array(
in usercp_avatar. Voeg daar de variabele namen toe, en het is opgelost.

Geplaatst: 23 jun 2004, 18:51
door Jivisstudios
Dat heb ik gedaan (vast niet goed), maar wat zit er dan fout:

Code: Selecteer alles

display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, &$new_password, &$cur_password, $password_confirm, $icq, $aim, $msn, $yim, $website, $websitename, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popup_pm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies,$showavatars, $showsignatures, $allowviewonline, $user_style, $user_lang, $user_timezone, $rankset, $user_dateformat, $no_pm, $firstname, $gethere, $userdata['session_id'], $xdata, $birthday);

Code: Selecteer alles

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, &$websitename, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popup_pm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$rankset, &$dateformat, &$firstname, &$gethere, &$no_pm, &$session_id, $xdata = false, &$birthday)

Code: Selecteer alles

$params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'websitename', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'allow_mass_pm', 'popup_pm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'rankset', 'dateformat', 'no_pm', 'gethere', 'firstname', 'birthday');
Ik krijg ook steeds de melding dat "ik alle verplichte velden nog niet heb ingevuld" terwijl ik niet eens verplichte velden heb :S