Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Avatar caching error
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Proximity" data-source="post: 358065" data-attributes="member: 43026"><p>So I am trying to avatar cache for my radio it will grab the user name from the db and their look and show it</p><p></p><p>So I am using this script it puts the avatar into the directory but it doesn't show the avatar</p><p></p><p>[code]</p><p><?phperror_reporting(-1);</p><p>?></p><p> <?php</p><p>// Report all PHP errors</p><p></p><p> // Copyright Clawed.</p><p> // Got bored to be honest.</p><p> </p><p> function filter( $string ) {</p><p> return mysql_real_escape_string( $string );</p><p> }</p><p> </p><p> define( "HOSTNAME", "localhost" );</p><p> define( "USERNAME", "root" );</p><p> define( "PASSWORD", "" );</p><p> define( "DATABASE", "" );</p><p> </p><p> if( !mysql_connect( HOSTNAME, USERNAME, PASSWORD ) ) die( mysql_error() );</p><p> if( !mysql_select_db( DATABASE ) ) die( mysql_error() );</p><p> </p><p> $url = "http://habbo.ca/";</p><p> </p><p> if( !filter( $_GET['username'] ) ) {</p><p> die( "<h1>Error</h1><hr>Username required.<hr>" );</p><p> }</p><p> </p><p> $query = mysql_query( "SELECT look,username FROM users WHERE username = '" . filter( $_GET['username'] ) . "'" ) or die( mysql_error() );</p><p> if( mysql_num_rows( $query ) < 1 ) { die( "Username does not exists." ); }</p><p> $array = mysql_fetch_assoc( $query );</p><p> $url = $url . "habbo-imaging/avatarimage?figure=" . $array['look'];</p><p> </p><p> if( filter( $_GET['direction'] ) ) {</p><p> $url = $url . "&direction=" . filter( $_GET['direction'] );</p><p> }</p><p> </p><p> if( filter( $_GET['gesture'] ) ) {</p><p> $url = $url . "&gesture=" . filter( $_GET['gesture'] );</p><p> }</p><p> </p><p> if( filter( $_GET['size'] ) ) {</p><p> $url = $url . "&size=" . filter( $_GET['size'] );</p><p> }</p><p> </p><p> if( filter( $_GET['img_format'] ) ) {</p><p> $url = $url . "&img_format=" . filter( $_GET['img_format'] );</p><p> }</p><p> </p><p> if( filter( $_GET['action'] ) ) {</p><p> $url = $url . "&action=" . filter( $_GET['action'] );</p><p> }</p><p> </p><p> $dir = "./avatars/";</p><p> $open = fopen( $url, "r" );</p><p> $hash = filter( $array['username'] ) . "-" . md5( $array['look'] );</p><p> $path = $dir . $hash . ".png";</p><p> </p><p> if( !file_exists( $path ) ) {</p><p> if( $open ) {</p><p> file_put_contents( $path, $open );</p><p> $image = file_get_contents( $path );</p><p> fclose( $open );</p><p> }</p><p> }else{</p><p> $image = file_get_contents( $path );</p><p> }</p><p> </p><p> header( "Content-Type: image/png" );</p><p> exit( $image );</p><p></p><p>?></p><p>[/code]</p><p>[doublepost=1448364716,1448362302][/doublepost]UPDATE:</p><p></p><p>This is the error message in the log:</p><p></p><p>[code]</p><p>[24-Nov-2015 12:30:32 Europe/Belgrade] PHP Notice: Undefined index: username in C:\inetpub\wwwroot\avatarimage.php on line 51</p><p>[24-Nov-2015 12:30:32 Europe/Belgrade] PHP Notice: Undefined variable: image in C:\inetpub\wwwroot\avatarimage.php on line 65</p><p>[24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: direction in C:\inetpub\wwwroot\avatarimage.php on line 32</p><p>[24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: gesture in C:\inetpub\wwwroot\avatarimage.php on line 36</p><p>[24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: size in C:\inetpub\wwwroot\avatarimage.php on line 40</p><p>[24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: img_format in C:\inetpub\wwwroot\avatarimage.php on line 44</p><p>[24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: action in C:\inetpub\wwwroot\avatarimage.php on line 48</p><p>[24-Nov-2015 12:30:53 Europe/Belgrade] PHP Warning: fopen(http://habbo.nl/habbo-imaging/avatarimage?figure=sh-295-82.ch-210-82.hd-180-1.lg-275-89.hr-125-47): failed to open stream: HTTP request failed! HTTP/1.1 463 </p><p> in C:\inetpub\wwwroot\avatarimage.php on line 53</p><p>[24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined variable: image in C:\inetpub\wwwroot\avatarimage.php on line 68</p><p>[/code]</p></blockquote><p></p>
[QUOTE="Proximity, post: 358065, member: 43026"] So I am trying to avatar cache for my radio it will grab the user name from the db and their look and show it So I am using this script it puts the avatar into the directory but it doesn't show the avatar [code] <?phperror_reporting(-1); ?> <?php // Report all PHP errors // Copyright Clawed. // Got bored to be honest. function filter( $string ) { return mysql_real_escape_string( $string ); } define( "HOSTNAME", "localhost" ); define( "USERNAME", "root" ); define( "PASSWORD", "" ); define( "DATABASE", "" ); if( !mysql_connect( HOSTNAME, USERNAME, PASSWORD ) ) die( mysql_error() ); if( !mysql_select_db( DATABASE ) ) die( mysql_error() ); $url = "http://habbo.ca/"; if( !filter( $_GET['username'] ) ) { die( "<h1>Error</h1><hr>Username required.<hr>" ); } $query = mysql_query( "SELECT look,username FROM users WHERE username = '" . filter( $_GET['username'] ) . "'" ) or die( mysql_error() ); if( mysql_num_rows( $query ) < 1 ) { die( "Username does not exists." ); } $array = mysql_fetch_assoc( $query ); $url = $url . "habbo-imaging/avatarimage?figure=" . $array['look']; if( filter( $_GET['direction'] ) ) { $url = $url . "&direction=" . filter( $_GET['direction'] ); } if( filter( $_GET['gesture'] ) ) { $url = $url . "&gesture=" . filter( $_GET['gesture'] ); } if( filter( $_GET['size'] ) ) { $url = $url . "&size=" . filter( $_GET['size'] ); } if( filter( $_GET['img_format'] ) ) { $url = $url . "&img_format=" . filter( $_GET['img_format'] ); } if( filter( $_GET['action'] ) ) { $url = $url . "&action=" . filter( $_GET['action'] ); } $dir = "./avatars/"; $open = fopen( $url, "r" ); $hash = filter( $array['username'] ) . "-" . md5( $array['look'] ); $path = $dir . $hash . ".png"; if( !file_exists( $path ) ) { if( $open ) { file_put_contents( $path, $open ); $image = file_get_contents( $path ); fclose( $open ); } }else{ $image = file_get_contents( $path ); } header( "Content-Type: image/png" ); exit( $image ); ?> [/code] [doublepost=1448364716,1448362302][/doublepost]UPDATE: This is the error message in the log: [code] [24-Nov-2015 12:30:32 Europe/Belgrade] PHP Notice: Undefined index: username in C:\inetpub\wwwroot\avatarimage.php on line 51 [24-Nov-2015 12:30:32 Europe/Belgrade] PHP Notice: Undefined variable: image in C:\inetpub\wwwroot\avatarimage.php on line 65 [24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: direction in C:\inetpub\wwwroot\avatarimage.php on line 32 [24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: gesture in C:\inetpub\wwwroot\avatarimage.php on line 36 [24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: size in C:\inetpub\wwwroot\avatarimage.php on line 40 [24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: img_format in C:\inetpub\wwwroot\avatarimage.php on line 44 [24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined index: action in C:\inetpub\wwwroot\avatarimage.php on line 48 [24-Nov-2015 12:30:53 Europe/Belgrade] PHP Warning: fopen(http://habbo.nl/habbo-imaging/avatarimage?figure=sh-295-82.ch-210-82.hd-180-1.lg-275-89.hr-125-47): failed to open stream: HTTP request failed! HTTP/1.1 463 in C:\inetpub\wwwroot\avatarimage.php on line 53 [24-Nov-2015 12:30:53 Europe/Belgrade] PHP Notice: Undefined variable: image in C:\inetpub\wwwroot\avatarimage.php on line 68 [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Avatar caching error
Top