ToutSurTout.biz
FluxBB : Mod reflet avatar


.: MOD Reflet Avatar :.

Testé sur FluxBB 1.2.22 et 1.2.23 smile

Cette modification permet d'afficher un reflet sous l'avatar dans la page profile.php, viewtopic.php et pms_list.php activable/désactivable par l'onglet Affichage dans le profil du membre.



Requête SQL a exécuter dans PHPMYADMIN ou MySQLDumper:

Code :

ALTER TABLE 'users' ADD 'show_reflet' TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1' AFTER 'show_sig'

Ouvrez profile.php:

Cherchez:

Code :

if ($pun_config['o_avatars'] == '1') { if ($user['use_avatar'] == '1') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.gif" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.jpg" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.png" '.$img_size[3].' alt="" />'; else $avatar_field = $lang_profile['No avatar']; } else $avatar_field = $lang_profile['No avatar']; }

A remplacer par:

Code :

// Commencement du MOD Réflection Avatar if ($pun_user['show_reflet'] =='1') { if ($pun_config['o_avatars'] == '1') { if ($user['use_avatar'] == '1') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.gif" '.$img_size[3].' alt="Avatar de '.pun_htmlspecialchars($cur_post['username']).'" class="reflect rheight33" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.jpg" '.$img_size[3].' alt="Avatar de '.pun_htmlspecialchars($cur_post['username']).'" class="reflect rheight33" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.png" '.$img_size[3].' alt="Avatar de '.pun_htmlspecialchars($cur_post['username']).'" class="reflect rheight33" />'; else $avatar_field = $lang_profile['No avatar']; } else $avatar_field = $lang_profile['No avatar']; } } elseif ($pun_user['show_reflet'] =='0') { if ($pun_config['o_avatars'] == '1') { if ($user['use_avatar'] == '1') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.gif')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.gif" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.jpg')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.jpg" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$id.'.png')) $avatar_field = '<img src="'.$pun_config['o_avatars_dir'].'/'.$id.'.png" '.$img_size[3].' alt="" />'; else $avatar_field = $lang_profile['No avatar']; } else $avatar_field = $lang_profile['No avatar']; } } else '' ; // Fin du MOD Réflection Avatar

Cherchez:

Code :

<label><input type="checkbox" name="form[show_img_sig]" value="1"<?php if ($user['show_img_sig'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Show images sigs'] ?><br /></label>

Ajoutez ensuite:

Code :

<label><input type="checkbox" name="form[show_reflet]" value="1"<?php if ($user['show_reflet'] == '1') echo ' checked="checked"' ?> /><?php echo $lang_profile['Show images reflet'] ?><br /></label>

Cherchez:

Code :

$form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig', 'style'));

Remplacez par:

Code :

$form = extract_elements(array('disp_topics', 'disp_posts', 'show_smilies', 'show_img', 'show_img_sig', 'show_avatars', 'show_sig','show_reflet', 'style'));

Cherchez:

Code :

if (!isset($form['show_sig']) || $form['show_sig'] != '1') $form['show_sig'] = '0';

Ajouté après:

Code :

if (!isset($form['show_reflet']) || $form['show_reflet'] != '1') $form['show_reflet'] = '0';

Cherchez:

Code :

$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());

Remplacez par:

Code :

$result = $db->query('SELECT u.username, u.email, u.title, u.realname, u.url, u.jabber, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.signature, u.disp_topics, u.disp_posts, u.email_setting, u.save_pass, u.notify_with_post, u.show_smilies, u.show_img, u.show_img_sig, u.show_avatars, u.show_sig, u.show_reflet, u.timezone, u.language, u.style, u.num_posts, u.last_post, u.registered, u.registration_ip, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());

Ouvrez viewtopic.php:

Cherchez:

Code :

if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="" />'; } else $user_avatar = '';

Remplacez par:

Code :

// Commencement du MOD Reflcetion Avatar if ($pun_user['show_reflet'] =='1') { if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="Avatar de '.pun_htmlspecialchars($cur_post['username']).'" class="reflect rheight33" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="Avatar de '.pun_htmlspecialchars($cur_post['username']).'" class="reflect rheight33" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="Avatar de '.pun_htmlspecialchars($cur_post['username']).'" class="reflect rheight33" />'; } } elseif ($pun_user['show_reflet'] =='0') { if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="" />'; else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="" />'; } } else $user_avatar = ''; //Fin Du mod reflection Avatar

Cherchez:

Code :

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

Remplacez par:

Code :

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, u.show_reflet, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

Ouvrez header.php:

Cherchez:

Code :

<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />

Ajoutez après:

Code :

<!-- Commencement du MOD Reflection Avatar --> <script type="text/javascript" src="js/reflection.js"></script> <!-- Fin du MOD Reflection Avatar -->

OPTIONNEL, AFFICHER LE REFLET DANS LES MESSAGES PRIVES

Ouvrez pms_list.php

Cherchez:

Code :

if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.gif')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.gif" '.$img_size[3].' alt="" />'; elseif ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.jpg')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.jpg" '.$img_size[3].' alt="" />'; elseif ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.png')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.png" '.$img_size[3].' alt="" />'; } else $user_avatar = '';

Remplacez par:

Code :

// Commencement du MOD Reflection Avatar if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0' && $pun_user['show_reflet']== '1') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.gif')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.gif" '.$img_size[3].' alt="" " class="reflect rheight33"/>'; elseif ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.jpg')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.jpg" '.$img_size[3].' alt="" " class="reflect rheight33"/>'; elseif ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.png')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.png" '.$img_size[3].' alt="" " class="reflect rheight33"/>'; } elseif ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0' && $pun_user['show_reflet']== '0') { if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.gif')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.gif" '.$img_size[3].' alt="" />'; elseif ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.jpg')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.jpg" '.$img_size[3].' alt="" />'; elseif ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.png')) $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['id'].'.png" '.$img_size[3].' alt="" />'; } else $user_avatar = ''; // Fin du MOD Reflection Avatar

Cherchez:

Code :

$result = $db->query('SELECT m.id AS mid, m.subject, m.sender_ip, m.message, m.smileys, m.posted, m.showed, u.id, u.group_id as g_id, g.g_user_title, u.username, u.registered, u.email, u.title, u.url, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.email_setting, u.num_posts, u.admin_note, u.signature, o.user_id AS is_online FROM '.$db->prefix.'messages AS m,'.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.idle=0) LEFT JOIN '.$db->prefix.'groups AS g ON (u.group_id = g.g_id) WHERE '.$where.' AND m.id='.$mid.' GROUP BY m.id') or error('Impossible de trouver le message et les informations de l\'utilisateur', __FILE__, __LINE__, $db->error());

Remplacez par:

Code :

$result = $db->query('SELECT m.id AS mid, m.subject, m.sender_ip, m.message, m.smileys, m.posted, m.showed, u.id, u.group_id as g_id, g.g_user_title, u.username, u.registered, u.email, u.title, u.url, u.icq, u.msn, u.aim, u.yahoo, u.location, u.use_avatar, u.show_reflet, u.email_setting, u.num_posts, u.admin_note, u.signature, o.user_id AS is_online FROM '.$db->prefix.'messages AS m,'.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.idle=0) LEFT JOIN '.$db->prefix.'groups AS g ON (u.group_id = g.g_id) WHERE '.$where.' AND m.id='.$mid.' GROUP BY m.id') or error('Impossible de trouver le message et les informations de l\'utilisateur', __FILE__, __LINE__, $db->error());

Fichier "reflection.js" a enregistrer dans le répertoire "js":

Code :

if (!document.myGetElementsByClassName) { document.myGetElementsByClassName = function(className) { var children = document.getElementsByTagName('*') || document.all; var elements = new Array(); for (var i = 0; i < children.length; i++) { var child = children[i]; var classNames = child.className.split(' '); for (var j = 0; j < classNames.length; j++) { if (classNames[j] == className) { elements.push(child); break; } } } return elements; } } var Reflection = { defaultHeight : 0.5, defaultOpacity: 0.5, add: function(image, options) { Reflection.remove(image); doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity } if (options) { for (var i in doptions) { if (!options[i]) { options[i]= doptions[i]; } } } else { options = doptions; } try { var d = document.createElement('div'); var p = image; var classes = p.className.split(' '); var newClasses = ''; for (j=0;j<classes.length;j++) { if (classes[j] != "reflect") { if (newClasses) { newClasses += ' ' } newClasses += classes[j]; } } var reflectionHeight = Math.floor(p.height*options['height']); var divHeight = Math.floor(p.height*(1+options['height'])); var reflectionWidth = p.width; if (document.all && !window.opera) { /* Fix hyperlinks */ if(p.parentElement.tagName == 'A') { var d = document.createElement('a'); d.href = p.parentElement.href; } /* Copy original image's classes & styles to div */ d.className = newClasses; p.className = 'reflected'; d.style.cssText = p.style.cssText; p.style.cssText = 'vertical-align: bottom'; var reflection = document.createElement('img'); reflection.src = p.src; reflection.style.width = reflectionWidth+'px'; reflection.style.display = 'block'; reflection.style.height = p.height+"px"; reflection.style.marginBottom = "-"+(p.height-reflectionHeight)+'px'; reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')'; d.style.width = reflectionWidth+'px'; d.style.height = divHeight+'px'; p.parentNode.replaceChild(d, p); d.appendChild(p); d.appendChild(reflection); } else { var canvas = document.createElement('canvas'); if (canvas.getContext) { /* Copy original image's classes & styles to div */ d.className = newClasses; p.className = 'reflected'; d.style.cssText = p.style.cssText; p.style.cssText = 'vertical-align: bottom'; var context = canvas.getContext("2d"); canvas.style.height = reflectionHeight+'px'; canvas.style.width = reflectionWidth+'px'; canvas.height = reflectionHeight; canvas.width = reflectionWidth; d.style.width = reflectionWidth+'px'; d.style.height = divHeight+'px'; p.parentNode.replaceChild(d, p); d.appendChild(p); d.appendChild(canvas); context.save(); context.translate(0,image.height-1); context.scale(1,-1); context.drawImage(image, 0, 0, reflectionWidth, image.height); context.restore(); context.globalCompositeOperation = "destination-out"; var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight); gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)"); gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")"); context.fillStyle = gradient; context.rect(0, 0, reflectionWidth, reflectionHeight*2); context.fill(); } } } catch (e) { } }, remove : function(image) { if (image.className == "reflected") { image.className = image.parentNode.className; image.parentNode.parentNode.replaceChild(image, image.parentNode); } } } function addReflections() { var rimages = document.myGetElementsByClassName('reflect'); for (i=0;i<rimages.length;i++) { var rheight = null; var ropacity = null; var classes = rimages[i].className.split(' '); for (j=0;j<classes.length;j++) { if (classes[j].indexOf("rheight") == 0) { var rheight = classes[j].substring(7)/100; } else if (classes[j].indexOf("ropacity") == 0) { var ropacity = classes[j].substring(8)/100; } } Reflection.add(rimages[i], { height: rheight, opacity : ropacity}); } } var previousOnload = window.onload; window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }

Quelques images de la mod:

Reflet dans le viewtopic:

http://img11.imageshack.us/img11/2686/refletviewtopic.jpg

Reflet dans le profil:

http://img140.imageshack.us/img140/8540/refletprofil.jpg

Reflet dans les MPs:

http://img214.imageshack.us/img214/787/refletmp.jpg

Activer ou non le reflet dans le profil:

http://img291.imageshack.us/img291/7231/affichageprofil.jpg



Si vous avez des problèmes je suis disponible wink