Register for your free account! | Forgot your password?

Go Back   elitepvpers > Off-Topics > Tutorials
You last visited: Today at 04:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Tutorial] How to make a changing Avatar for forum

Discussion on [Tutorial] How to make a changing Avatar for forum within the Tutorials forum part of the Off-Topics category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2004
Posts: 1,325
Received Thanks: 107
Because i always get from time to time pms asking about how do i make the avatar changing all the time i decided to write a little guide, its not that hard:

First you need webspace where you can run something like php and which allows you to use the mod rewrite or to change extensions.

Then you need to write a little script which handles the img output in my case it looks like this:

Code:
$mysql_host = "";
$mysql_user = "";
$mysql_password = "";
$mysql_db = "";
@mysql_connect($mysql_host, $mysql_user, $mysql_password);
@mysql_select_db($mysql_db);
$ran = rand(1,71);
$data = mysql_query('SELECT pic FROM images where id='.$ran);
$wfile = mysql_result($data,0,'pic');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-type: image/gif");
$img=file_get_contents('./img/'.$wfile);
echo $img;
it gets a random number between 1-71 which is the number of pictures i have in the database, and get the img and send the context to the browser.
It is important to send the Cache-Control so the browser dont cache that image, otherwise it would always show the same img untill the browser cache expires.

You should maybe builtin a referer check as well, so that your image isnt missused on other sites by other ppl.

Code:
$such = strpos($_SERVER['HTTP_REFERER'], 'elitepvpers.com');
if(isset($_SERVER['HTTP_REFERER']) && $such === false && $_SERVER['HTTP_REFERER']!=''){
 * * * *header("Cache-Control: no-cache, must-revalidate");
 * * * * header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
 * * * * header("Content-type: image/gif");
 * * * * $img=file_get_contents('./warning.gif');
 * * * * echo $img;

 * * * * exit;
}
if you want use such a check just put it in front of the other code, in this example it would check if the refer is set and is elitepvpers.com or empty if it doesnt match it would show the file warning.gif and stops the execution of the script.

The reason for the empty referer check is that some ppl use tools or browsers which clears the referer and we dont want to show them the warning.

Next todo is then to activate that the webserver redirect the image to the scripts, which you can define either in the config file of the webserver if you have the access to it or in the .htaccess

Code:
RewriteEngine on
RewriteRule ^image\.jpg$ image.php
this will redirect all to image.php and execute the script to print out the image.

a more advance version would be for example:

Code:
RewriteEngine on
RewriteRule ^image([0-9]{1,5})\.jpg$ image.php?p=$1
this would redirect image1.jpg to image.php?p=1 so that you can overgive paramters to the files to use 1 file for diff things, i use for example the same file for avatar and signature.
the [0-9] means all numbers between 0-9 are valid and the [1,5] that the number can be 1-5 positions long, so from 0-99999

If a request doesnt match that rule it wont rewrite it, for example image22222222.jpg will just look for that file.
NoName is offline  
Thanks
1 User
Old 06/26/2007, 16:25   #2
 
Tuxified's Avatar
 
elite*gold: 0
Join Date: Apr 2007
Posts: 591
Received Thanks: 30
Pretty nice and very helpfull (:

+k
Tuxified is offline  
Old 06/26/2007, 20:46   #3
 
elite*gold: 0
Join Date: Apr 2006
Posts: 2,524
Received Thanks: 74
nur ein "l" :P
alternativ: man kaufe sich fuer 5 dollar pro tag einen chinesen und zwinge ihn dazu.

ne, aber im ernst. super guide, weiter so ^^*gg*
4C1D^ is offline  
Old 06/28/2007, 23:57   #4
 
CrankG's Avatar
 
elite*gold: 10
Join Date: Feb 2007
Posts: 1,957
Received Thanks: 1,355
noch besser wäre es wenn du ein beispiel für kostenlosen webspace hättest wo das klappt
und ne deutsche übersetzung.
CrankG is offline  
Old 06/29/2007, 08:14   #5
 
elite*gold: 0
Join Date: Apr 2006
Posts: 2,524
Received Thanks: 74
ich wette coder benutzt den e*pvp server :P
hmm, gibt ja einige fuer 1 euro, is ja nich das problem ^^ (1 euro, dafuer kann man dann haufenweise **** drauf lagern)
4C1D^ is offline  
Old 07/13/2007, 13:50   #6
 
elite*gold: 0
Join Date: Aug 2004
Posts: 1,325
Received Thanks: 107
ich poste grundsätzlich sowas nur in englisch weil ich mir nicht die mühe mache etwas von ner sprache die eigentlich jeder aber ne gewissen alter können sollte zu übersetzen.

und mich kümmert webspace nicht so sehr da ich eh ne eigenen server seit jahren fahre
NoName is offline  
Old 07/14/2007, 22:24   #7
 
elite*gold: 0
Join Date: Jun 2007
Posts: 69
Received Thanks: 21
Code:
$mysql_host = "";
$mysql_user = "";
$mysql_password = "";
$mysql_db = "";
@mysql_connect($mysql_host, $mysql_user, $mysql_password);
@mysql_select_db($mysql_db);
$ran = rand(1,71);
$data = mysql_query('SELECT pic FROM images where id='.$ran);
$wfile = mysql_result($data,0,'pic');
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-type: image/gif");
$img=file_get_contents('./img/'.$wfile);
echo $img;
wieso machst du das mit mysql?

mach doch einfach

Code:
$ran = rand(1,2);
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-type: image/gif");
$img=file_get_contents('./img/'.$ran.'.gif');
echo $img;
und nenn die bilder im img ordner
1.gif
2.gif
3.gif
(...)
chin chin is offline  
Old 07/19/2007, 05:17   #8

 
Aeh''s Avatar
 
elite*gold: 2
Join Date: May 2007
Posts: 3,642
Received Thanks: 431
Jop... habe ich mich auch gefrag... naja fukt beides ;D
Aeh' is offline  
Old 07/19/2007, 19:37   #9
 
XxAnimusxX's Avatar
 
elite*gold: 0
Join Date: Dec 2005
Posts: 2,705
Received Thanks: 116
Also der Script an sich funzt ja prima, nur habe ich komischerweise Probs mit der htaccess, ich habe im ganzen server-root keine htaccess und dies ist die einzige, mit dem Inhalt wie oben beschrieben jedoch bekomme ich ständig nen Fehler:
"Serverfehler. Überprüfe Deine htaccess-Datei bzw. lösche diese."

Zu testzwecken sehen die verzeichnisse wie folgt aus:
./img_bla/ <- hier liegen die Bilder 1.jpg, 2.jpg usw
./.htaccess <- im root liegt die htaccess mit folgendem Inhalt:
Code:
&#60;Directory &#34;img_bla/&#34;>
RewriteEngine on
RewriteRule ^image&#092;.jpg&#036; ../image.php
&#60;/Directory>
Kann mir jemand weiterhelfen? :>
XxAnimusxX is offline  
Old 07/23/2007, 15:37   #10
 
elite*gold: 0
Join Date: Aug 2004
Posts: 106
Received Thanks: 7
""Serverfehler. Überprüfe Deine htaccess-Datei bzw. lösche diese.""

Nachdem ich mal nicht denke, dass du da keine tippfehler etc. drin hast, kann es auch gut sein, dass auf deinem server apache einfach kein mod_rewrite geladen hat.
(Oder in der apache config angegeben wurde, dass du mit der .htaccess die Konfiguration nicht ändern kannst. Ich bin mir jetzt da aber grad nicht 100% sicher, ob da die gleiche Fehlermeldung kommen würde)
pengpong is offline  
Old 08/10/2007, 00:13   #11
 
elite*gold: 0
Join Date: Aug 2007
Posts: 28
Received Thanks: 0
Serverfehler!

Die Anfrage kann nicht beantwortet werden, da im Server ein interner Fehler aufgetreten ist. Der Server ist entweder überlastet oder ein Fehler in einem CGI-Skript ist aufgetreten.

Sofern Sie dies für eine Fehlfunktion des Servers halten, informieren Sie bitte den Webmaster hierüber.
Error 500
127.0.0.1
08/10/07 00:12:33
Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.2

ich schätz mal das ist der selbe fehler nur in firefox^^ geht es denn nicht ohne, wenn das forum auch php dateien als ava unterstützt? *eigenes hab^^*
Xandaros is offline  
Old 08/10/2007, 11:47   #12
 
elite*gold: 0
Join Date: Aug 2004
Posts: 1,325
Received Thanks: 107
Quote:
wieso machst du das mit mysql?

mach doch einfach

und nenn die bilder im img ordner
1.gif
2.gif
3.gif
(...)
warum willst du circa 80 bilder umbennen die es bei mir sind und das ist nicht mal nötig. und kann man sicher ohne datenbank machen, mein eigenes script ist circa 4 mal länger und beinhaltet ne ecke mehr.

Quote:
<Directory "img_bla/">
RewriteEngine on
RewriteRule ^image&#092;.jpg&#036; ../image.php
</Directory>
wenn ich das richtig verstehe liegt die php auch im root?

sollte dann eher so aussehen:

Code:
RewriteEngine on
RewriteRule ^image&#092;.jpg&#036; image.php
merke gerade die directory angabe kann weg in htaccess dateien da diese ja bereits im verzeichnis liegen und direkt für dieses gelten (ich nutze selbst keine htaccess files, bevorzuge das aus zu haben für mehr performance )

Quote:
wenn das forum auch php dateien als ava unterstützt
das forum unterstützt kein php an sich als avatar, deswegen das umschreiben ^^

und da wird wohl etwas in deinem script falsch sein deshalb die fehlermeldung.
NoName is offline  
Reply


Similar Threads Similar Threads
[Tutorial] Changing NPC appearances
02/10/2012 - 12Sky2 Hacks, Bots, Cheats & Exploits - 17 Replies
Ever wanted to change a mob or boss it's appearance(Especially for the Wrath of Centaur cave) to gain an advantage in hunting Vengeful Centaurs (Aeriagames)? Than I have news for you , I have decided to post a tutorial about this because many people have asked me to altho those people were lurkers. Things you can do with changing appearance of a NPC : 1. Changing the NPC in a stone which makes them unable to attack you ^^ Godmode , but it still has that 15 seconds delay if you don't...
[Tutorial]For Changing Sql Password.In Case You Forgot it or ....
10/22/2009 - Dekaron Private Server - 4 Replies
Hello I made Small and fast Tut for changing sql password . in case you forgot it or you want just to change it . even if you forgot to set a password in setup you can set it from here ;) and in same way you can give access to anyone to the DB if you want to make them an co admin total time : 2:34 Min . Size 8.49MB ShocWave Flash Download : request an winrar Download Link : http://www.mediafire.com/file/ntwnnnintmm/Tut For Changing Password.rar Youtube link :...
[PK2] Changing PvP Voucher to Avatar
01/14/2009 - SRO Guides & Templates - 1 Replies
Note: I tried this edit at ECSRO, I don't play isro anymore, so I can't do it with isro avatar. This guide only to show you the basic idea. And if there already guide like this, feel free to delete this thread. Open the itemdata.txt in the media\server_dep\silkroad\ Using the find function in the notepad, find item\china\woman_item\frpvp_voucher_a.bsr (the blue woman cape) Replace it with item\china\woman_item\event_silsamo_f.bsr (the avatar that Assistant wear) I can't make...
Indented Avatar Tutorial
10/24/2005 - Artist Tutorials - 5 Replies
http://img415.imageshack.us/img415/7681/tut6ym.jpg Hoffe euch gefällts. Mit besseren Sprites siehts natürlich noch besser aus. Will paar Results sehen :rolleyes: +karma gewünscht danke ^^



All times are GMT +2. The time now is 04:42.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.