Jump to content

Squirrel*Salad

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by Squirrel*Salad

  1. I am currently doing a download page on my site. In the admin control area when a new file is submitted the script automatically should obtain the size of the file. now before we say use filesize() it wont work .. this is because the file may or maynot be on the same server as the php script. filesize needs a realpath ( c:\dir\file.zip ) as it doesn't work with a url ( [a href=\"http://www.site.com/file.zip\" target=\"_blank\"]http://www.site.com/file.zip[/a] ). How else can i obtain the file size?
  2. here is what i do to stop faults like this in a file called mainfile.php that is included on each page i have the following. /** * Disable magic_quotes_runtime */ set_magic_quotes_runtime( 0 ); /** * Addslashes to variables if magic_quote_gpc is set to off */ if ( !get_magic_quotes_gpc() ) { if ( is_array( $HTTP_GET_VARS ) ) { while ( list( $k, $v ) = each( $HTTP_GET_VARS ) ) { if ( is_array( $HTTP_GET_VARS[$k] ) ) { while ( list( $k2, $v2 ) = each( $HTTP_GET_VARS[$k] ) ) { $HTTP_GET_VARS[$k][$k2] = addslashes( $v2 ); } @reset( $HTTP_GET_VARS[$k] ); } else { $HTTP_GET_VARS[$k] = addslashes( $v ); } } @reset( $HTTP_GET_VARS ); } if ( is_array( $HTTP_POST_VARS ) ) { while ( list( $k, $v ) = each( $HTTP_POST_VARS ) ) { if ( is_array( $HTTP_POST_VARS[$k] ) ) { while ( list( $k2, $v2 ) = each( $HTTP_POST_VARS[$k] ) ) { $HTTP_POST_VARS[$k][$k2] = addslashes( $v2 ); } @reset( $HTTP_POST_VARS[$k] ); } else { $HTTP_POST_VARS[$k] = addslashes( $v ); } } @reset( $HTTP_POST_VARS ); } if ( is_array( $HTTP_COOKIE_VARS ) ) { while ( list( $k, $v ) = each( $HTTP_COOKIE_VARS ) ) { if ( is_array( $HTTP_COOKIE_VARS[$k] ) ) { while ( list( $k2, $v2 ) = each( $HTTP_COOKIE_VARS[$k] ) ) { $HTTP_COOKIE_VARS[$k][$k2] = addslashes( $v2 ); } @reset( $HTTP_COOKIE_VARS[$k] ); } else { $HTTP_COOKIE_VARS[$k] = addslashes( $v ); } } @reset( $HTTP_COOKIE_VARS ); } } this way i know all data has had slashes added. then you only have to use strip slashes when displaying data and not when adding to database.
  3. [!--quoteo(post=349353:date=Feb 25 2006, 07:06 PM:name=cameron)--][div class=\'quotetop\']QUOTE(cameron @ Feb 25 2006, 07:06 PM) [snapback]349353[/snapback][/div][div class=\'quotemain\'][!--quotec--] That checks if it is a bot, correct? Does this work well for most SE bots? (eg: google, yahoo, msn) Any browsers this may cuase a problem for? [/quote] I use the following on my site to determin browser type which also detects bots ( google, slurp etc ) you can modify it for your own needs. [code] if ((ereg('Nav', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) || (ereg('Gold', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) || (ereg('X11', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) || (ereg('Mozilla', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) || (ereg('Netscape', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) AND (!ereg('MSIE', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) AND (!ereg('Konqueror', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) AND (!ereg('Yahoo', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) AND (!ereg('Firefox', $HTTP_SERVER_VARS['HTTP_USER_AGENT']))) {     $browser = 'Netscape'; } elseif( ereg('Firefox', $_SERVER['HTTP_USER_AGENT']) ) {     $browser = 'FireFox'; } elseif( ereg('MSIE', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) {     $browser = 'MSIE'; } elseif( ereg('Lynx', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) {     $browser = 'Lynx'; } elseif( ereg('Opera', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) {     $browser = 'Opera'; } elseif( ereg('WebTV', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) {     $browser = 'WebTV'; } elseif( ereg('Konqueror', $HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {     $browser = 'Konqueror'; } elseif( ( eregi('bot', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) || ( ereg('Google', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) || ( ereg('Slurp', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) || ( ereg('Scooter', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) || ( eregi('Spider', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) || ( eregi('Infoseek', $HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) ) {     $browser = 'Bot'; } else {     $browser = 'Other'; } [/code] hope it helps
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.