*

Recent

Author Topic: Default Avatar  (Read 10669 times)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Default Avatar
« on: October 21, 2011, 11:43:56 PM »
I have completely revamped this, this is my first major mod! This now uses the Admin panel under settings. You have the option to have it on or off. If only default avatar is on no mater what sex the user is it will be the same generic avatar. If you have both gender and avatar on it will display the avatar depending on the gender(male,female or undisclosed) Also, if it is turned off then it will display like it would without this mod. *NOTE* BOTH GENDER AND AVATAR HAVE TO BE ON FOR GENDER TO WORK

Variables to add through out (posting here so i dont need to keep re-typeing it)

Code: [Select]
, $avatar_on, $gender_on, $aimg, $fimg, $mimg


First things first run this SQL code in your database
Code: [Select]
ALTER TABLE `dd_settings` ADD `avatar_on` int(11) NOT NULL DEFAULT '0';
ALTER TABLE `dd_settings` ADD `aimg` varchar(250) NOT NULL DEFAULT '';
ALTER TABLE `dd_settings` ADD `gender_on` int(11) NOT NULL DEFAULT '0';
ALTER TABLE `dd_settings` ADD `mimg` varchar(250) NOT NULL DEFAULT '';
ALTER TABLE `dd_settings` ADD `fimg` varchar(250) NOT NULL DEFAULT '';

In your template modify these files

myaccount.php

Add the variables at top of the page here

Code: [Select]
function account(){
global

Search for

Code: [Select]
if ($avatar == "1" ) { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$avatarfile.'\' height=\'100\' width=\'100\'>'; } else { $avatarfileurl = ''; };
Replace with

Code: [Select]
if ($avatar == "1" ) { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$avatarfile.'\' height=\'100\' width=\'100\'>'; } elseif ($avatar_on == "1" && $gender_on == "1") { if ($sex == "u" || $sex == "") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$aimg.'\' height=\'100\' width=\'100\'>';} elseif ($sex == "m") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$mimg.'\' height=\'100\' width=\'100\'>';}elseif ($sex == "f") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$fimg.'\' height=\'100\' width=\'100\'>';} } elseif ($avatar_on == "1") { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$aimg.'\' height=\'100\' width=\'100\'>';} else { $avatarfileurl = ''; };
play.php

Add the variables at top of the page here

Code: [Select]
function writebody() {
global

Search for

Code: [Select]
if ( $rra['avatar'] == '1' ) { $avatarfileurl = '<p><img src=\''.$domain.'/avatars/'.$rra['avatarfile'].'\' height=\'100\' width=\'100\' border=\'0\'>'; } else { $avatarfileurl = ''; };
Replace with

Code: [Select]
if ( $rra['avatar'] == '1' ) { $avatarfileurl = '<p><img src=\''.$domain.'/avatars/'.$rra['avatarfile'].'\' height=\'100\' width=\'100\' border=\'0\'>'; } elseif ($avatar_on == "1" && $gender_on == "1") { if ($rra['sex'] == "u" || $rra['sex'] == "") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$aimg.'\' height=\'100\' width=\'100\'>';} elseif ($rra['sex'] == "m") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$mimg.'\' height=\'100\' width=\'100\'>';}elseif ($rra['sex'] == "f") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$fimg.'\' height=\'100\' width=\'100\'>';} } elseif ($avatar_on == "1") { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$aimg.'\' height=\'100\' width=\'100\'>';} else { $avatarfileurl = ''; };
showprofile.php

Add the variables at top of the page here

Code: [Select]
function writebody() {
global

Search for

Code: [Select]
if ($avatar == "1" ) { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$avatarfile.'\' height=\'100\' width=\'100\'>'; } else { $avatarfileurl = ''; };
Replace with

Code: [Select]
if ($avatar == "1" ) { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$avatarfile.'\' height=\'100\' width=\'100\'>'; } elseif ($avatar_on == "1" && $gender_on == "1") { if ($sex == "u" || $sex == "") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$aimg.'\' height=\'100\' width=\'100\'>';} elseif ($sex == "m") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$mimg.'\' height=\'100\' width=\'100\'>';}elseif ($sex == "f") {$avatarfileurl = '<img src=\''.$domain.'/avatars/'.$fimg.'\' height=\'100\' width=\'100\'>';} } elseif ($avatar_on == "1") { $avatarfileurl = '<img src=\''.$domain.'/avatars/'.$aimg.'\' height=\'100\' width=\'100\'>';} else { $avatarfileurl = ''; };
In pages/admin modify these files

Index.php

Add the variables at top of the page here

Code: [Select]
function writebody() {
global

Settings.php

Search for

Code: [Select]
if ( $showpages == "0" ) { $spsel = "selected" ; };
Add after

Code: [Select]
if ( $avatar_on == "0" ) { $avsel = "selected" ; } ;
if ( $gender_on == "0" ) { $gavsel = "selected" ; };

Search for

Code: [Select]
$metadescr = $_POST['metadescr'];
Add after

Code: [Select]
$savatar_on = clean($_POST['avatar_on']);
$saimg = clean($_POST['aimg'];
$sgender_on = clean($_POST['gender_on']);
$smimg = clean($_POST['mimg']);
$sfimg = clean($_POST['fimg']);

Search for

Code: [Select]
metadescr=\''.$metadescr.'\'
Add after

Code: [Select]
,
avatar_on=\''.$savatar_on.'\',
aimg=\''.$saimg.'\',
gender_on=\''.$sgender_on.'\',
mimg=\''.$smimg.'\',
fimg=\''.$sfimg.'\'

Search for

Code: [Select]
<td class=\'content5\'>Default Meta Description:
</td>
<td class=\'content5\'><input type=\'text\' name=\'metadescr\' size=\'40\' value=\''.$set['metadescr'].'\'></td>
</tr>

Add after

Code: [Select]
<tr>
<td class=\'content5\'>Default Avatar Enabled:</td>
<td class=\'content5\'><select type=\'dropdown\' name=\'avatar_on\'>
<option value=\'1\'>Yes</option>
<option value=\'0\' '.$avsel.'>No</option>
</select></td>
</tr>
<tr>
<td class=\'content5\' >Generic Avatar File:</td>
<td class=\'content5\'><input type=\'text\' name=\'aimg\' size=\'40\' value=\''.$set['aimg'].'\'></td>
</tr>
<tr>
<td class=\'content5\'>Gender Avatar Enabled:</td>
<td class=\'content5\'><select type=\'dropdown\' name=\'gender_on\'>
<option value=\'1\'>Yes</option>
<option value=\'0\' '.$gavsel.'>No</option>
</select></td>
</tr>
<tr>
<td class=\'content5\'>Male Avatar File:</td>
<td class=\'content5\'><input type=\'text\' name=\'mimg\' size=\'40\' value=\''.$set['mimg'].'\'></td>
</tr>
<tr>
<td class=\'content5\'>Female Avatar File:</td>
<td class=\'content5\'><input type=\'text\' name=\'fimg\' size=\'40\' value=\''.$set['fimg'].'\'></td>
</tr>

In the includes folder

Core.php

Search for

Code: [Select]
$pagetitle = $sitename ;
Add after

Code: [Select]
$avatar_on = $set['avatar_on'];
$aimg = $set['aimg'];
$gender_on = $set['gender_on'];
$mimg = $set['mimg'];
$fimg = $set['fimg'];

If you have any suggestions or you find that i forgot a page let me know and ill add support for it. Hope you guys enjoy this!
« Last Edit: November 02, 2011, 02:31:49 PM by spagetiokillers »

soulwebsites

  • Jr. Member
  • **
  • Posts: 71
  • Force: +0/-0
    • Jamsite
Re: Default Avatar
« Reply #1 on: October 23, 2011, 02:59:35 PM »
thanks spagetiokillers this is exactly what ive been wanting.

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Default Avatar
« Reply #2 on: October 23, 2011, 03:19:44 PM »
i have an idea to make this better :) back to work!

soulwebsites

  • Jr. Member
  • **
  • Posts: 71
  • Force: +0/-0
    • Jamsite
Re: Default Avatar
« Reply #3 on: October 23, 2011, 03:31:44 PM »
Is their a way of a male female default avatar?

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Default Avatar
« Reply #4 on: October 23, 2011, 04:41:20 PM »
Is their a way of a male female default avatar?

Good idea im going to get working on this.

am-fs

  • Owner
  • Developer
  • Full Member
  • ******
  • Posts: 228
  • Force: +1/-0
    • Great Flash Games
Re: Default Avatar
« Reply #5 on: October 23, 2011, 04:50:37 PM »
be nice to show avatar on the member list instead of there ID


Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Default Avatar
« Reply #6 on: October 23, 2011, 09:25:04 PM »
I got the update part way working. All i need is to get a fully automated SQL script and fix an error in the site settings.

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Default Avatar
« Reply #7 on: October 25, 2011, 03:54:55 PM »
Updated with the new stuffz. The gender gave me a hard time but i got it working. Let me know what you guys think of my hours of work and confusion!
« Last Edit: October 25, 2011, 04:08:23 PM by spagetiokillers »

soulwebsites

  • Jr. Member
  • **
  • Posts: 71
  • Force: +0/-0
    • Jamsite
Re: Default Avatar
« Reply #8 on: October 26, 2011, 06:23:27 AM »
 :o

Really didnt think it was going to be such a change - I will apply this to my site when i get a few minutes and let you know how it goes.

thanks for this spagetiokillers  ;D

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Default Avatar
« Reply #9 on: October 30, 2011, 10:55:57 AM »
Hmmm...... I just realized that if it is set to yes and you dont declare the file to use then itll show a broken link for the image. I need to add support for the check if the field is filled in when you hit update. Also, has anyone used this mod yet? feed back would be nice :)

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Default Avatar
« Reply #10 on: October 30, 2011, 04:16:47 PM »
Not yet? ;)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Default Avatar
« Reply #11 on: October 30, 2011, 04:28:39 PM »

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Default Avatar
« Reply #12 on: November 02, 2011, 02:33:04 PM »
Fixed some code in the first post that dealt with posts