[COLDFUSION] Habbo Imager (w. caching)
As I'm developing Roc CF with Aaron and Oleg, I thought it'd be a great idea to implement an imager. Having never understood how one would achieve such, and being unable to find an existing Coldfusion alternative - I set to work on writing my own.
Live preview: http://local.mabbohotel.net:8500/roc...ze=&action=lay
PHP Code:
action=
std [default]
wav
wlk
sit
lay
drk=1
crr=1
crr=2
crr=3
crr=5
crr=6
crr=9
crr=33
crr=42
crr=43
crr=4
crr=667
drk=2
drk=3
drk=33
drk=5
drk=6
drk=9
drk=42
drk=43
drk=44
drk=667
gesture=
std [default]
sml
sad
spk
eyb
agr
srp
direction=
1
2 [default]
3
4
5
6
7
8
head_direction=
1
2 [default]
3
4
5
6
7
8
size=
s
l [default]
Now I doubt this is the most effective way of doing so, but it works - and it's pretty neat. Without further a-do.
PHP Code:
<cfset hosts = ["http://habbo.de/", "http://habbo.com/", "http://habbo.es/", "http://habbo.nl/", "http://habbo.au/", "http://habbo.ca/"]>
<cfif not StructKeyExists(URL, "user")>
Please input a username.
<cfabort>
</cfif>
<cfquery name="getUserLook" datasource="#config.DSN#">
SELECT look
FROM users
WHERE username = <cfqueryparam value="#user#" cfsqltype="CF_SQL_CHAR" maxLength="50">
</cfquery>
<cfset args = "">
<cfif StructKeyExists(URL, "direction")>
<cfset args = "&direction=#direction#">
</cfif>
<cfif StructKeyExists(URL, "head_direction")>
<cfset args = "#args#&head_direction=#head_direction#">
</cfif>
<cfif StructKeyExists(URL, "gesture")>
<cfset args = "#args#&gesture=#gesture#">
</cfif>
<cfif StructKeyExists(URL, "size")>
<cfset args = "#args#&size=#size#">
</cfif>
<cfif StructKeyExists(URL, "img_format")>
<cfset args = "#args#&img_format=#img_format#">
</cfif>
<cfif StructKeyExists(URL, "action")>
<cfset args = "#args#&action=#action#">
</cfif>
<cfif not FileExists("#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png")>
<cfif getUserLook.RecordCount>
<cfset data = [user, getUserLook.look]>
<!--- Loop through supplied hosts. --->
<cfloop from="1" to="#arraylen(hosts)#" index="u">
<!--- Call the host. --->
<cfhttp method="head" url="#hosts[u]#" resolveurl="no" throwonerror="no" />
<!--- If called host responds with a status code --->
<cfif IsDefined("CFHTTP.responseHeader.status_code")>
<!--- Providing the host does not respond with error 403 or 404, then proceed. --->
<cfif CFHTTP.responseHeader.status_code neq "403" or CFHTTP.responseHeader.status_code neq "404">
<!--- The host loads, so let's now verify that it isn't on maintenance or closed by looking for the image. --->
<cffile action="read" file="#hosts[u]#habbo-imaging/avatarimage?figure=#getUserLook.look##args#" variable="imageValidation" />
<!--- CFFILE, having read the image's source and trimmed to the first 3 characters, is now checking it is a PNG. --->
<cfif left(imageValidation, 4) contains "PNG">
<cfimage action="write" source="#hosts[u]#habbo-imaging/avatarimage?figure=#getUserLook.look##args#" destination="#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png" overwrite="no">
<cfbreak>
</cfif>
Whoops, PNG error!
<cfabort>
</cfif>
Whoops, 403/ 404!
<cfabort>
</cfif>
Didn't respond!
<cfabort>
</cfloop>
<cfcontent type="image/png" file="#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png">
<cfelse>
Username does not exist.
</cfif>
<cfelse>
<cfset existingAvatar = "#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png">
<cfcontent type="image/png" file="#existingAvatar#">
</cfif>
If the above did not work on your web server - Aaron identified some issues when developing on Roc. Use the following - thanks to Sojoboob.
PHP Code:
<cfset hosts = ["http://habbo.de/", "http://habbo.com/", "http://habbo.es/", "http://habbo.nl/", "http://habbo.au/", "http://habbo.ca/"]>
<cfif not StructKeyExists(URL, "user")>
Please input a username.
<cfabort>
</cfif>
<cfquery name="getUserLook" datasource="#config.DSN#">
SELECT look
FROM users
WHERE username = <cfqueryparam value="#user#" cfsqltype="CF_SQL_CHAR" maxLength="50">
</cfquery>
<cfset args = "">
<cfif StructKeyExists(URL, "direction")>
<cfset args = "&direction=#direction#">
</cfif>
<cfif StructKeyExists(URL, "head_direction")>
<cfset args = "#args#&head_direction=#head_direction#">
</cfif>
<cfif StructKeyExists(URL, "gesture")>
<cfset args = "#args#&gesture=#gesture#">
</cfif>
<cfif StructKeyExists(URL, "size")>
<cfset args = "#args#&size=#size#">
</cfif>
<cfif StructKeyExists(URL, "img_format")>
<cfset args = "#args#&img_format=#img_format#">
</cfif>
<cfif StructKeyExists(URL, "action")>
<cfset args = "#args#&action=#action#">
</cfif>
<cfif not FileExists("#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png")>
<cfif getUserLook.RecordCount>
<cfset data = [user, getUserLook.look]>
<!--- Loop through supplied hosts. --->
<cfloop from="1" to="#arraylen(hosts)#" index="u">
<!--- Call the host. --->
<cfhttp method="head" url="#hosts[u]#" resolveurl="no" throwonerror="no" />
<!--- If called host responds with a status code --->
<cfif IsDefined("CFHTTP.responseHeader.status_code")>
<!--- Providing the host does not respond with error 403 or 404, then proceed. --->
<cfif CFHTTP.responseHeader.status_code neq "403" or CFHTTP.responseHeader.status_code neq "404">
<!--- The host loads, so let's now verify that it isn't on maintenance or closed by looking for the image. --->
<cfset grabthis = "#hosts[u]#habbo-imaging/avatarimage?figure=#getUserLook.look##args#">
<cfhttp method="get" url="#grabthis#" useragent="#CGI.http_user_agent#" timeout="5" getasbinary="yes" result="objGET">
<cfhttpparam type="HEADER" name="referer" value="http://habbo.com/Home/Shorty-234-Otaku-toas"/>
</cfhttp>
<cfif find("200", objGet.statusCode)>
<cfimage action="write" source="#objGet.FileContent#" destination="#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png" overwrite="no">
<cfcontent type="image/gif" variable="#objGet.FileContent#">
<cfbreak>
<cfelse>
<cfoutput>#objGet.statusCode#</cfoutput>
</cfif>
Whoops, PNG error!
<cfabort>
</cfif>
Whoops, 403/ 404!
<cfabort>
</cfif>
Didn't respond!
<cfabort>
</cfloop>
<cfcontent type="image/png" file="#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png">
<cfelse>
Username does not exist.
<cfabort>
</cfif>
<cfelse>
<cfset existingAvatar = "#GetCurrentTemplatePath()#/../avatar_cache/#Hash("#getUserLook.look##args#", "SHA-1")#.png">
<cfcontent type="image/png" file="#existingAvatar#">
</cfif>
Do ensure that in the query, #config.DSN# refers to your datasource! Please also create a folder in the same directory labelled "avatar_cache" for the cached images! :)
Re: [COLDFUSION] Habbo Imager (w. caching)
It sure is nice!
You just showed me the preview on MSN. Still cant believe you did it, lol!
Greetz,
Re: [COLDFUSION] Habbo Imager (w. caching)
Thanks for sharing this, much appreciated may use this when I'm working on my own ColdFusion projects.
Re: [COLDFUSION] Habbo Imager (w. caching)
Coldfusion, still dont know how it works lol. Maybe if I got some time left I'll start learning it cause it looks pretty awesome =D
Nice release for the coldfusion developers around here :)
Re: [COLDFUSION] Habbo Imager (w. caching)
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
Makarov
Now explain to me what hotel runs a cold fusion web application?
Sent from my DROID RAZR using Tapatalk 2
Most hotels that do are foreign - but the point is; coldfusion CMS' do exist, and they still need supporting. This community doesn't have to be anti-Coldfusion like the rest. :):
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
n0minal
Most hotels that do are foreign - but the point is; coldfusion CMS' do exist, and they still need supporting. This community doesn't have to be anti-Coldfusion like the rest. :):
Habboon is using coldfusion right?
Also I think if there are more coldfusion developers here will be more coldfusion releases. Coldfusion seems interesting too me :)
Re: [COLDFUSION] Habbo Imager (w. caching)
Wait, so this just mirrors Habbo's imager? Not really a genuine "imager", but, eh, it's useful for caching avatar images.
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
Reimu
Wait, so this just mirrors Habbo's imager? Not really a genuine "imager", but, eh, it's useful for caching avatar images.
Yeah, I plan on writing a full imager soon. :):
Re: [COLDFUSION] Habbo Imager (w. caching)
Thank you n0minal, i am getting it to work now ^^
Re: [COLDFUSION] Habbo Imager (w. caching)
Verry nice thanks you i get work with this
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
Nilenz
Verry nice thanks you i get work with this
You're welcome!
Re: [COLDFUSION] Habbo Imager (w. caching)
Haha! That's so good! But you need learn to me how to use ColdFusion, Sir. n0minal haha
+1 :)
Re: [COLDFUSION] Habbo Imager (w. caching)
Lovely, nice of you to build upon. :)
Re: [COLDFUSION] Habbo Imager (w. caching)
I don't get why people hate on ColdFusion, in my opinion it's better than PHP. It's not a very well-known language therefore it's brilliant! :D
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
ησвяαιη
I don't get why people hate on ColdFusion, in my opinion it's better than PHP. It's not a very well-known language therefore it's brilliant! :D
It's pretty expensive but an alternative is Railo which is free and supports CFML. Most people don't like it because nothing decent has been released coded in ColdFusion. You remember when PhoenixCF was first released? Lots of hotels used it because it was good and didn't care about the language (frankly it's a lot easier than PHP [html-like] so noob friendly) they just needed a good solid CMS to use.
I think that when a decent CMS comes out for ColdFusion people will use it just like they did with PhoenixCF. Until then PHP will most likely be the language of choice for most hotels.
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
Hejula
It's pretty expensive but an alternative is Railo which is free and supports CFML. Most people don't like it because nothing decent has been released coded in ColdFusion. You remember when PhoenixCF was first released? Lots of hotels used it because it was good and didn't care about the language (frankly it's a lot easier than PHP [html-like] so noob friendly) they just needed a good solid CMS to use.
I think that when a decent CMS comes out for ColdFusion people will use it just like they did with PhoenixCF. Until then PHP will most likely be the language of choice for most hotels.
We're planning to implement all of the features from PhoenixCF into Roc. The drawback to developing in Coldfusion is that it's a pain in the ass to install on Linux.. however, since all current emulators require Windows and thus 99% of popular hotels run on their own hardware (VPS or dedicated server) then installing and using Coldfusion is simply an easy choice to make - there are no drawbacks.
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
Sojobo
We're planning to implement all of the features from PhoenixCF into Roc. The drawback to developing in Coldfusion is that it's a pain in the ass to install on Linux.. however, since all current emulators require Windows and thus 99% of popular hotels run on their own hardware (VPS or dedicated server) then installing and using Coldfusion is simply an easy choice to make - there are no drawbacks.
But that's wrong.
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
Makarov
All the most recent emulators are built in Java?
Sent from my DROID RAZR using Tapatalk 2
Never heard of any or seen any in use. I was talking about popular emulators, ie; Phoenix, Butterfly, Habbo Latino, Uber & all other Uber edits
Re: [COLDFUSION] Habbo Imager (w. caching)
Quote:
Originally Posted by
Makarov
Those won't be popular after HH, sierra, Grizzly come out.
Sent from my DROID RAZR using Tapatalk 2
Aaron was referring to current emulators.
Re: [COLDFUSION] Habbo Imager (w. caching)
Ok, let's wait a couple more years