Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > Script Languages

Script Languages Perl/PHP/Python/Ruby so on and so forth.

Reply
 
Thread Tools Display Modes
Old 01-28-2007, 03:10 AM   #1 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default NEED HELP - Display Dynamic images

Ok I have a problem.... I created a script that generates images but I cant show them in the forums using BBCode or on websites. Is there a way that I can make links like

http://nottnetworks.com/gamertag/gts1.php/gamertag.png
(so if people replace gamertag in front of .png it would show their info....)


instead of

http://nottnetworks.com/gamertag/gts1.php?tag=Nott32




Image Generator:
PHP Code:
 <?php
//GamerTag generator style #1
//Scripted by Nott32
//Copyright (C) 2006 Nott Networks
include 'gamercard.php';

header('Content-type: image/png');
$string $gamertag;
$stringsc $gamerscore;
$im    imagecreatefrompng('1.png');
$orange imagecolorallocate($im00000000);
$px    = (imagesx($im) - 7.8 strlen($string)) / 2;
$pxsc    = (imagesx($im) - 7.8 strlen($stringsc)) / 1.4;
imagestring($im4$px17$string$orange);
imagestring($im4$pxsc37$stringsc$orange);
imagepng($im);
imagedestroy($im);
?>
GamerCard.php
PHP Code:
<?

/*
 *
 *    Gamercard.php [A small PHP file to retrieve the Gamertag infos ;)] -- Version 2.0
 *
 *    extracts $gamertagstyle (silver/gold), $gamertile (icon), $gamerrep, $gamerscore, $gamerscore_img, $gamerzone, $gamerarchievements (NEW!!) from http://gamercard.xbox.com/GAMERTAG.card
 *    Saves the information in gamercard_cache_GAMERTAG.txt for server load and speed purposes ;) The TTL for information in cache is set in $timeout
 *    Uses the Snoopy Plugin by Monte Ohrt - http://snoopy.sourceforge.net/
 *    files needed: ./snoopy.php
 *    files created by script: $gamercard_cache.txt
 *    You can rename gamercard.php to anything you like (for security reasons ;) )(PHP support depending on .htaccess then ;) )
 *
 *
 *    Original script by Consti (tag = Consti) http://www.consti.de
 *
 *  Modified by Oliver Baty (gamertag = ardamis) http://www.ardamis.com
 *
 *
 */


if (!($_GET['timeout'])) {
// Set the TTL for the cache here
$timeout 400;
}

if (!(
$_GET['tag'])) {
// Your name goes here
$tag "Nott32";
}
$tag str_replace(" ","%20",$tag);

$cache fopen ('./gamercard_cache_' $tag '.txt'"a");
fclose($cache);

$file1 file('./gamercard_cache_' $tag '.txt');
$file array_map('trim'$file1);

$abstand time() - $file[0];

if (
$abstand $timeout || $tag != $file[1]) {
include(
'./snoopy.php');
$snoopy = new Snoopy
if(
$snoopy->fetch("http://gamercard.xbox.com/"$tag .".card")) 
$in = ($snoopy->results);

preg_match('#<h3 class="XbcGamertag(.+?)">#',$in$gamertagstyle1); 
preg_match('#width="64" src="(.+?)" /></a>#',$in$gamertile1);
preg_match('#<img src="/xweb/lib/images/gc_repstars_external_(.+?).gif" />#',$in$gamerrep1);  
preg_match('#Gamerscore" src="(.+?)" />#',$in$gamerscore_img1);  
preg_match_all('#<span class="XbcFRAR">(.+?)</span>#',$in$gamer);
preg_match_all('#<div class="XbcgcGames">(.+?)</div>#',$in$gamesa);  

$gamerrep $gamerrep1[1];
$gamerscore_img "http://gamercard.xbox.com"$gamerscore_img1[1];
$gamerscore $gamer[1][1];
$gamerzone $gamer[1][2];
$gamerachievements $gamesa[1][0];

$cache_string time() ."\n"$tag ."\n"$gamertagstyle1[1] ."\n"$gamertile1[1] ."\n"$gamerrep ."\n"$gamerscore ."\n"$gamerscore_img ."\n"$gamerzone ."\n"$gamerachievements;

$cache fopen ('./gamercard_cache_' $tag '.txt'"w");
fwrite($cache$cache_string );
fclose($cache);

$gamertagstyle $gamertagstyle1[1];
$gamertile $gamertile1[1];
$gamertag str_replace("%20"," "$tag);

} else {

$tag $file[1];
$gamertag str_replace("%20"," "$tag);
$gamertagstyle $file[2];
$gamertile $file[3];
$gamerrep $file[4];
$gamerscore $file[5];
$gamerscore_img $file[6];
$gamerzone $file[7];
$gamerachievements $file[8];

}

// Reputation gauge with green stars on light grey background (from live.xbox.com navmenu gamercard) use $navgamerrep
$navgamerrep "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_nav_" $gamerrep ".gif";

// Reputation gauge with white stars on dark grey background (from default gamercard) use $normalgamerrep
$normalgamerrep "http://gamercard.xbox.com/xweb/lib/images/gc_repstars_external_" $gamerrep ".gif";

// Reputation gauge with green stars and transparent background (www.ardamis.com custom graphics) verify path and use $transpgamerrep
$transpgamerrep "gamercardimages/rep" $gamerrep ".png";

?>
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.

Last edited by Nott32; 01-28-2007 at 03:13 AM.
Nott32 is offline   Reply With Quote
Old 01-28-2007, 03:42 AM   #2 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

I just tried using it in a website and it worked fine when I linked to your example, are you sure it doesnt work?

Anyways, hopefully you are able to use htaccess and have an apache host and then this will work for you

Your .htaccess file
Code:
Options +FollowSymlinks
RewriteEngine on
 
RewriteRule ^gamertag/(.+).png gts.php?tag=$1 [nc]
just add that to a text file and when you save it, just save it as ".htaccess" and upload it to the directory you want this to work in.

Lets say you add this to: "http://nottnetworks.com/"
then when people go here : "http://nottnetworks.com/gamertag/Nott32.png" it will actually go to : "http://nottnetworks.com/gts.php?tag=Nott32"

To see it in action, I made a script call gts.php in my root folder (www.mordero.com) and when you go to "http://www.mordero.com/gamertag/{insert stuff here}.png" it will print what you put in there, like this
http://www.mordero.com/gamertag/test.png will print "test"

the only limitation I noticed was you cant have a question mark in the stuff you insert

edit: damn that stupid automatic titles, its so annoying

Last edited by mordero; 01-28-2007 at 03:46 AM.
mordero is offline   Reply With Quote
Old 01-28-2007, 03:47 AM   #3 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

Thanks! It seems to work now... You are a life saver!







__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.

Last edited by Nott32; 01-28-2007 at 03:49 AM.
Nott32 is offline   Reply With Quote
Old 01-28-2007, 03:51 AM   #4 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

yep, no problem
mordero is offline   Reply With Quote
Old 01-28-2007, 03:52 AM   #5 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

Still cant give u Rep+ >_<!
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Old 01-28-2007, 03:54 AM   #6 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

lol its no problem, still have problems with the other link thing?
mordero is offline   Reply With Quote
Old 01-28-2007, 03:56 AM   #7 (permalink)
Forum Expert
 
Nott32's Avatar
 
Join Date: Feb 2006
Location: In front of my computer...
Age: 16
Posts: 562
Send a message via MSN to Nott32 Send a message via Yahoo to Nott32
Default

No actually I figured out it was because I wasnt using the BBCode so the script didnt automatically parse http:// links and then when I tried yours it was messing with my images and I didnt need it anyways so theres no use working on it lol. But your help is greatly apreciated...sorry if im sound rude its 1AM and im cranky...
__________________
Everytime a puppy gets hit by a car from me smoking I take another drag, point, and laugh.
Nott32 is offline   Reply With Quote
Old 01-28-2007, 03:59 AM   #8 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 21
Posts: 2,911
Default

haha its fine
mordero is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5