PDA

View Full Version : [Release] Custom Image Under User Name


12-06-2000, 07:02 PM
This hack allows the user to specify an image from anywhere on the internet to appear under their user name. It was initially requested here (http://www.vbulletin.com/forum/showthread.php?threadid=5282).

This is my first public hack that serves a purpose, so be gentle. It's a little rough around the edges, possibly my good friends Mike or freddie could take a look and see if I forgot anything.

Here is an example:

http://www.bronx-bombers.com/vb114/showthread.php?threadid=2

Here is the code:

First, run the following SQL query to create a new field in the user table:

ALTER TABLE user ADD imgurl VARCHAR (100) not null


Next, open showthread.php:


Find:

$temps=$DB_site->query("SELECT title,template
FROM template
WHERE title='error_invalidid' OR title='error_nopermission' OR

title='$foruminfo[rulestemplate]'
OR title='forumrules' OR title='error_forumclosed' OR

title='showthread_numpages'
OR title='postbit_useremail' OR title='icq' OR title='aim' OR

title='yahoo'
OR title='postbit_homepage' OR title='postbit_profile' OR

title='$usetemplatebit'
OR title='firstunread' OR title='showthread_nextnewestthread'
OR title='showthread_nextoldestthread' OR

title='$foruminfo[headertemplate]'
OR title='$foruminfo[footertemplate]' OR title='$usetemplate'");
while ($temp=$DB_site->fetch_array($temps)) {
$templatecache["$temp[title]"]=$temp[template];
}


Replace With:


$temps=$DB_site->query("SELECT title,template
FROM template
WHERE title='error_invalidid' OR title='error_nopermission' OR

title='$foruminfo[rulestemplate]'
OR title='forumrules' OR title='error_forumclosed' OR

title='showthread_numpages'
OR title='postbit_useremail' OR title='icq' OR title='aim' OR

title='yahoo' OR title='custom_img'
OR title='postbit_homepage' OR title='postbit_profile' OR

title='$usetemplatebit'
OR title='firstunread' OR title='showthread_nextnewestthread'
OR title='showthread_nextoldestthread' OR

title='$foruminfo[headertemplate]'
OR title='$foruminfo[footertemplate]' OR title='$usetemplate'");
while ($temp=$DB_site->fetch_array($temps)) {
$templatecache["$temp[title]"]=$temp[template];
}






Find:

$posts=$DB_site->query("SELECT post.dateline as dateline,post.postid as postid,post.pagetext as

pagetext,
post.allowsmilie as allowsmilie,post.signature AS

showsignature,post.title as title,
post.ipaddress as ipaddress,post.iconid as iconid,post.username as

fakename,
post.userid as userid,
user.userid as userid,user.email as email,user.username as username,
user.usertitle as usertitle,user.signature as

signature,user.showemail as showemail,
user.homepage as homepage,user.icq as icq,user.aim as aim,user.yahoo

as yahoo,
user.joindate as joindate,user.posts as posts
FROM post
LEFT JOIN user ON (user.userid = post.userid)
WHERE post.threadid=$threadid AND visible=1
ORDER BY dateline $postorder
LIMIT $limitlower,$perpage");


And Replace With:
$posts=$DB_site->query("SELECT post.dateline as dateline,post.postid as postid,post.pagetext

as pagetext,
post.allowsmilie as allowsmilie,post.signature AS

showsignature,post.title as title,
post.ipaddress as ipaddress,post.iconid as iconid,post.username as

fakename,
post.userid as userid,
user.userid as userid,user.email as email,user.username as username,
user.usertitle as usertitle,user.signature as

signature,user.showemail as showemail,
user.homepage as homepage,user.icq as icq,user.aim as aim,user.yahoo

as yahoo,user.imgurl as imgurl,
user.joindate as joindate,user.posts as posts
FROM post
LEFT JOIN user ON (user.userid = post.userid)
WHERE post.threadid=$threadid AND visible=1
ORDER BY dateline $postorder
LIMIT $limitlower,$perpage");




Find:


if ($userinfo[icq]!="") {
$icqnumber=$userinfo[icq];
eval("\$icq = \"".gettemplate("icq")."\";");
} else {
$icqnumber="";
$icq="";
}


And After It, Add This:


if ($userinfo[imgurl]!="") {
$custom_img=$userinfo[imgurl];
eval("\$imgurl = \"".gettemplate("custom_img")."\";");
} else {
$custom_img="";
$imgurl="";
}





Save and close showthread.php.

Open member.php


In the "Modify Profile" function, find:

$timezoneoffset=$userinfo[timezoneoffset];

After it, add:

$imgurl=htmlspecialchars($userinfo[imgurl]);



In the "Update Profile" Section, Find:


$DB_site->query("UPDATE user
SET password='".addslashes($password)."',email='".addslashes($email)."',


parentemail='".addslashes($parentemail)."',coppauser=$coppauser,homepage='".addslashes($homepage)."

',


icq='".addslashes($icq)."',aim='".addslashes($aim)."',yahoo='".addslashes($yahoo)."',


biography='".addslashes($biography)."',signature='".addslashes($signature)."',adminemail=$adminemai

l,


showemail=$showemail,invisible=$invisible,cookieus er=$cookieuser,daysprune=$prunedays,
timezoneoffset=$timezoneoffset,emailnotification=$ emailnotification
WHERE userid=$userid");


And replace with:


$DB_site->query("UPDATE user
SET password='".addslashes($password)."',email='".addslashes($email)."',


parentemail='".addslashes($parentemail)."',coppauser=$coppauser,homepage='".addslashes($homepage)."

',


icq='".addslashes($icq)."',aim='".addslashes($aim)."',yahoo='".addslashes($yahoo)."',


biography='".addslashes($biography)."',signature='".addslashes($signature)."',adminemail=$adminemai

l,imgurl='".addslashes($imgurl)."',


showemail=$showemail,invisible=$invisible,cookieus er=$cookieuser,daysprune=$prunedays,
timezoneoffset=$timezoneoffset,emailnotification=$ emailnotification
WHERE userid=$userid");


Go ahead and update those files, now we have to edit templates:

Open the "modifyprofile" template, and put the following code in there somewhere:

<tr bgcolor="#DEDEDE">

<td><B><FONT face="verdana, arial, helvetica" size="2" >Custom Image URL:</font></B></td>
<td><INPUT TYPE="TEXT" NAME="imgurl" VALUE="$imgurl" SIZE=30 MAXLENGTH=100></td>

</tr>

Save That.

Open the "postbit" template, and add this wherever you want to put the image, specifying the proper height and width:

<img src="$custom_img" height="xx" width="xx">

That's it, you're all done.


I just noticed that for users that don't specify an image, you get an red x - I'll try to fix that now.

Other than that, I can't provide a lot of support, because I forgot half of what I did :).

-jim

12-06-2000, 07:13 PM
How about setting a default image for everybody then all they have to do is change it. that way you wouldn't get a red x

12-06-2000, 07:19 PM
I could do that, but I want to have it so it only appears if there is a URL specified, like the way the homepage link is setup.

-jim

12-06-2000, 07:21 PM
Originally posted by Philly
How about setting a default image for everybody then all they have to do is change it. that way you wouldn't get a red x


Oh there's a red x? No, no I would rather prefere no images at all if not specified by the user.
BTW tnx for this great hack JimF!!!! :thumbup:

12-06-2000, 08:08 PM
Originally posted by JimF
First, run the following SQL query to create a new field in the user table:

ALTER TABLE user ADD imgurl VARCHAR (100) not null

Er... actually the table "user" does not exist.
Also, instead of the image I got a broken image URL linked to my board url (like "http://www.mydomain.com/forums/").

12-06-2000, 08:13 PM
Also
I noticed that the URL image cannot be saved on the profile: everytime I go back to my profile, the "Custom Image URL" field is empty.
Maybe does it depend on the missing MySQL table field?

12-06-2000, 08:14 PM
Is this on your site, or on my demo site?

You need to create the row in MySQL or it won't work.

-jim

12-06-2000, 08:20 PM
Originally posted by JimF
Is this on your site, or on my demo site?

You need to create the row in MySQL or it won't work.

-jim

It's on my site but I'm realizing just now that something may have been fu**ed up. There are some tables missing on my DB! Or maybe phpMyAdmin went crazy... :confused:

12-06-2000, 08:32 PM
OK, le't say I made clear that the DB is still working properly. I've only a strange phpMyAdmin problem which is not reporting all tables... :confused:
Anyway, I can remember that when I inserted your MySQL command I got a confirm message that everything went fine. :)
Now, the only thing is the fact that instead of the image I get that broken img linked to my board index...

12-07-2000, 12:37 AM
There is always my Avatar hack which sets a default of no image, instructions for using it w 1.1.4 are at the end of the thread

http://www.vbulletin.com/forum/showthread.php?threadid=2127

12-07-2000, 09:35 AM
Originally posted by freddie
There is always my Avatar hack which sets a default of no image, instructions for using it w 1.1.4 are at the end of the thread

http://www.vbulletin.com/forum/showthread.php?threadid=2127

Oh good. If it's not so difficoult to "recycle" on this hack I'll give it a try. :)
Anyway, I solved the phpMyAdmin bug. Actually it was selfsolved: when I recalled phpMyAdmin this morning... tja... all tables were shown.

ALSO
the hack is working well...
Dunno maybe the server was getting some problems or there are some ghost around there? :confused:

12-07-2000, 10:06 AM
Originally posted by freddie
There is always my Avatar hack which sets a default of no image, instructions for using it w 1.1.4 are at the end of the thread

http://www.vbulletin.com/forum/showthread.php?threadid=2127

Er... I gave a look to that "very short" thread and also to the instructions but as I'm not used to handle properly PHP stuff, could you/someone plz post here what to do to add the "no image" feature?

[Edited by Cr4z33 on 12-07-2000 at 07:09 AM]

12-07-2000, 10:09 AM
Look at the beginning and the end, then if you have any problems with teh hack I am willing to bet that the answer to your question is in pages 1-10

12-07-2000, 10:09 AM
I will add that if I could install this hack with out a prob, than anyone can do it.

12-07-2000, 01:58 PM
Hi! I´ve got a userpic hack by westi at westi.gulli.com

but it user upload insteat links

look for a demo at: board.gulli.com

cu bIGaXE

[Edited by bIGaXE on 12-07-2000 at 11:02 AM]

12-07-2000, 02:03 PM
Originally posted by freddie
There is always my Avatar hack which sets a default of no image, instructions for using it w 1.1.4 are at the end of the thread

http://www.vbulletin.com/forum/showthread.php?threadid=2127

This is different than the Avatar hack in that the user can specify any image from any website, by providing a URL in their profile.

Possibly I can steal some of your code to set the default to no image...

-jim

12-07-2000, 02:36 PM
Originally posted by bIGaXE
Hi! I?ve got a userpic hack by westi at westi.gulli.com

but it user upload insteat links

look for a demo at: board.gulli.com

cu bIGaXE

[Edited by bIGaXE on 12-07-2000 at 11:02 AM]

No tnx, I'm trying to avoid to overload the db with images data... :D

12-07-2000, 03:16 PM
thnx JimF! this works great.. but the red cross.. hmm.. mabey if you set a standard pic.. and set it to a transparant pixel gif?

12-07-2000, 10:10 PM
Originally posted by JimF
Originally posted by freddie
There is always my Avatar hack which sets a default of no image, instructions for using it w 1.1.4 are at the end of the thread

http://www.vbulletin.com/forum/showthread.php?threadid=2127

This is different than the Avatar hack in that the user can specify any image from any website, by providing a URL in their profile.

Possibly I can steal some of your code to set the default to no image...

-jim

Perhaps you guys can't read but my hack allows you to make the user specify a link for a picture OR allow them to upload a picture OR select a picture from the server. I do really think I covered it all. Perhaps I need to put all my hacks back in my sig as I see requests for stuff I have already done 3 months ago.

12-08-2000, 06:41 AM
Originally posted by freddie
OR allow them to upload a picture OR select a picture from the server. I do really think I covered it all. Perhaps I need to put all my hacks back in my sig as I see requests for stuff I have already done 3 months ago. [/B]

Perhaps YOU freddie can't read. :D
If YOU read above you'll notice that I wrote that I don't want to upload images into the db 'cause they dramatically slows it down...
Anyway, I've already seen your hack it and it's a good one https://vborg.vbsupport.ru/

12-08-2000, 01:11 PM
You either set it to allow the user to UL an image OR you set it to allow them to type in an URL, not both at the same time. It is all a moot point as John has put Avatars in v2.0.

12-08-2000, 01:26 PM
You're misunderstanding me. I'm not refusing the Avatar hack just 'cause I thought it doesn't have the img URL or 'cause it's too heavy for my db (even if my hoster db su*). I'm refusing it as I'm not a PHP profi and dunno which parts to cut/use/delete/etc. :)
Anyway, the hack by JimF is just OK for me. I've only to wait as I dunno how to crop the noimage code from the Avatar hack...

12-08-2000, 01:36 PM
Originally posted by freddie
Perhaps you guys can't read but my hack allows you to make the user specify a link for a picture OR allow them to upload a picture OR select a picture from the server. I do really think I covered it all. Perhaps I need to put all my hacks back in my sig as I see requests for stuff I have already done 3 months ago.

How'd you guess? How did I ever fool those SAT proctors?? :D

I think what you should have said was "Perhaps you guys didn't read past page 27 of the Avatar hack thread". Freddie, take a deep breath. Count to 10. We all feel better now, don't we?

Why didn't you mention your hack in the thread requesting this? You can read, right? If you had, I wouldn't have had to spend an afternoon working on a hack that I'll never use.

-jim

[Edited by JimF on 12-08-2000 at 11:53 AM]

12-08-2000, 06:08 PM
Um because by the time I saw that thread you had already done it. I don't always come here every day as I am in a down period waiting for 2.0 to be released so I am not hacking 1.1.4 anymore.

12-09-2000, 12:41 AM
Okay, cuz JimF was so kind to post the code
to have a picture under the username, without
having to install the bloated Avatar hack,
I wanted to do something back :)

With JimF's hack, when a user doesn't select
a picture, there's a red cross. I've fixed it :)


Open showthread.php

Find:


$useremail="";


and place this under it:


$custom_img="";


Find:


if ($userinfo[imgurl]!="") {
$custom_img=$userinfo[imgurl];
eval("\$imgurl = \"".gettemplate("custom_img")."\";");
} else {
$custom_img="";
$imgurl="";
}


and replace it with:


if ($userinfo[imgurl]!="") {
$custom_img=($userinfo[imgurl]);
$custom_img="<img src=\"$custom_img\" height=\"60\" width=\"60\" border=\"1\">";
eval("\$imgurl = \"".gettemplate("custom_img")."\";");
} else {
$custom_img="";
$imgurl="";
}


Replace the 60's with the numbers you desire,
and if you don't want a border just remove the
border=\"1\" bit.

Save and Close showthread.php.

Open the postbit template

Find:


<img src="$custom_img" height="xx" width="xx">

the "xx" is what you filled in,
just search for a part of this line,
but do REPLACE THE WHOLE LINE!!

and replace it with:


$custom_img


Done :)

No ugly red crosses, not even with guest users :)

Feel free to comment, cuz this is the first time i've coded in php :)

Greetz.


I've tested it on my board, and it works fine there, but i KNOW there MUST be some programming flaws in there, so if you see one, please post the fix... Thnx.. :)



[Edited by X-PhoeniX on 12-11-2000 at 05:21 PM]

12-09-2000, 07:01 AM
Tnx man!
I didn't want to disturb JimF too and was waiting for a fix. :D
I'm gonna test it right now and if there're bugs I'll report it into 5 mins...

12-09-2000, 01:23 PM
Originally posted by Cr4z33
I'm gonna test it right now and if there're bugs I'll report it into 5 mins...

so, no bugs? :)

12-09-2000, 01:39 PM
Originally posted by X-PhoeniX
[QUOTE]so, no bugs? :)

I could not test it atm. The table "forumpermission" is corrupted and I'm still waiting for a reply by the support... :(
BTW do you know the syntax to use on phpMyAdmin to fix it? I only know that I've to use isamchk as the corrupted file is "forumpermission.ISM"...

12-09-2000, 02:10 PM
Originally posted by Cr4z33
Originally posted by X-PhoeniX
[QUOTE]so, no bugs? :)

I could not test it atm. The table "forumpermission" is corrupted and I'm still waiting for a reply by the support... :(
BTW do you know the syntax to use on phpMyAdmin to fix it? I only know that I've to use isamchk as the corrupted file is "forumpermission.ISM"...

too bad..

(BTW: does anyone have the fix for this irritating quote bug, as you can see? when i quote someone who has quoted someone who has quoted someone etc.. there are like 3 quotes... they suck... but back to the point ;))

euh.. nope, sorry... never dealed with a corrupted db be4.. can't help ya m8..

12-09-2000, 02:16 PM
Originally posted by X-PhoeniX
too bad..

(BTW: does anyone have the fix for this irritating quote bug, as you can see? when i quote someone who has quoted someone who has quoted someone etc.. there are like 3 quotes... they suck... but back to the point ;))

euh.. nope, sorry... never dealed with a corrupted db be4.. can't help ya m8..



Np, as soon as I fix the problem I'll let ya know. :)
Could someone tell me if I can safely delete and recreate the table "forumpermission" without troubles on the board? Note that's the test board so I'm the only user there. :)

12-09-2000, 02:47 PM
Originally posted by Cr4z33
Np, as soon as I fix the problem I'll let ya know. :)
Could someone tell me if I can safely delete and recreate the table "forumpermission" without troubles on the board? Note that's the test board so I'm the only user there. :)
[/B]
Okz :)

Euh... yeah, ya can.. i think..:) but you must reproduce it the same as it was before (without the corruption ofcourse;)), and there can't be any other users on your board as i know of, cuz mabey it'll be corrupted again then...

12-09-2000, 08:42 PM
Originally posted by X-PhoeniX
so, no bugs? :)

No bugs at all. It works great!!
Tnx again to you and JimF! https://vborg.vbsupport.ru/

12-10-2000, 01:08 AM
Originally posted by Cr4z33
Originally posted by X-PhoeniX
so, no bugs? :)

No bugs at all. It works great!!
Tnx again to you and JimF! https://vborg.vbsupport.ru/

Np :)
Thnx JimF, for the original code :)

12-10-2000, 07:08 AM
i can't find this code in showthread


$temps=$DB_site->query("SELECT title,template
FROM template
WHERE title='error_invalidid' OR title='error_nopermission' OR

title='$foruminfo[rulestemplate]'
OR title='forumrules' OR title='error_forumclosed' OR

title='showthread_numpages'
OR title='postbit_useremail' OR title='icq' OR title='aim' OR

title='yahoo'
OR title='postbit_homepage' OR title='postbit_profile' OR

title='$usetemplatebit'
OR title='firstunread' OR title='showthread_nextnewestthread'
OR title='showthread_nextoldestthread' OR

title='$foruminfo[headertemplate]'
OR title='$foruminfo[footertemplate]' OR title='$usetemplate'");
while ($temp=$DB_site->fetch_array($temps)) {
$templatecache["$temp[title]"]=$temp[template];


:(

12-10-2000, 11:59 AM
ReMaZ:

What version do you have? 1.1.4?
Then just look for
$temps=$DB_site->query("SELECT title,template
and add
OR title='custom_img'
after
OR title='yahoo'

Okay?

12-10-2000, 09:32 PM
Thanks X-Phoenix, I was going to make a fix this weekend, but I had to go out of town unexpectedly.

-jim

12-11-2000, 07:23 PM
Originally posted by JimF
Thanks X-Phoenix, I was going to make a fix this weekend, but I had to go out of town unexpectedly.

-jim
np JimF :)

12-11-2000, 09:45 PM
Originally posted by X-PhoeniX
[b]ReMaZ:

What version do you have? 1.1.4?


No, i have 1.1.3 :(

12-12-2000, 04:32 PM
Then I can't help you, sorry.. (cuz i'm currently running 1.1.4)

12-12-2000, 04:43 PM
Originally posted by ReMaZ
No, i have 1.1.3

I would upgrade to 1.1.4 ASAP - there are some major code tweaks that dramatically reduce MySQL queries, and will consequently make your site run much better. The upgrade is a sinch, and there are no real template changes to make. Just upload the new scripts and run the upgrade.php file. 1.1.4 has been available in the member's area for quite some time now.

-jim

12-14-2000, 02:22 PM
JimF:


Please note: I love receiving email, but for the benefit of the entire
community, questions should be directed towards the vBulletin Community forum.

Have you checked out vBulletin's awesome MySQL powered Search
Engine (http://www.vbulletin.com/forum/search.php) yet?

Hahaha nice sig :)

12-14-2000, 03:28 PM
Is there an easy way to upgrade from 1.13 to 1.14 even when you have hacks on 1.13 but I don't really care if I lose them just as long as i don't lose the messages.

12-14-2000, 11:57 PM
I use 1.1.3 in the EXSites forums (lazy to do an upgrade, maybe next week) - http://www.exhardware.com/forums

I use my custom Avatar script which is based on Jim's hack here :) Just simpler... lol Check it out

12-30-2000, 08:29 PM
When I add

<TR bgcolor="{secondaltcolor}"><td><normalfont><B>Custom Image URL:</B></normalfont></td>
<td><INPUT TYPE="TEXT" NAME="imgurl" VALUE="$imgurl" SIZE=30 MAXLENGTH=100></td>
</tr>

to the editprofile template if there is a value for imgurl in the DB it will not show the value in the modify form. My quess is the value has to be set in global.php but I can't find it.... Any suggestions?

12-30-2000, 08:41 PM
Found it...

In member.php find

$userinfo=$DB_site->query_first("SELECT parentemail,coppauser,email,password,homepage,icq, aim,yahoo,biography,signature,adminemail,showemail ,invisible,cookieuser,daysprune,timezoneoffset,ema ilnotification FROM user WHERE userid=$userid");

and change it to

$userinfo=$DB_site->query_first("SELECT parentemail,coppauser,email,password,homepage,icq, aim,yahoo,biography,signature,adminemail,showemail ,invisible,cookieuser,daysprune,timezoneoffset,ema ilnotification,imgurl FROM user WHERE userid=$userid");

Add the ,imgurl to the end of the statment so it pulls that from the DB.



[Edited by WreckRman2 on 12-30-2000 at 05:45 PM]