Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-10-2005, 08:01 PM Valid image.
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
nevermind
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.

Last edited by VToria; 04-29-2005 at 12:50 PM..
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
 
Register now for full access!
Old 04-10-2005, 08:54 PM
Skilled Talker

Posts: 62
Trades: 0
what you are doing now is just checking what it is called, and based on the url of the image.
This does nothing for checking if it is a valid image or not.

What you need to do is check the MIME TYPE of the image.
The Jasong is offline
Reply With Quote
View Public Profile
 
Old 04-10-2005, 09:01 PM
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
Well...that is all i want really i think, the thread title is probably misleading. Unless i misunderstood what you said.

All i want it to do is make sure what they enter into the 'Button URL' box ends in jpg, gif, bmp or png...
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.

Last edited by VToria; 04-10-2005 at 10:59 PM..
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
Old 04-12-2005, 01:14 PM
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
Anyone?
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
Old 04-12-2005, 01:58 PM
lajkonik86's Avatar
Ultra Talker

Posts: 389
Trades: 0
well i don't really know much about the preg_match function
what i would do
is use this
$pointies = explode($button);
$ext = $pointies[count($pointies)-1];
$ext = strtolower($ext);
For optimal security you could use mime types aswell. But never really sollely on mime types.
Pretty sure the above will work. Good luck!

I'm having some problems with a random affiliate script.
You know something about that?
http://www.webmaster-talk.com/showthread.php?t=27483
__________________
Know what to Download

Please login or register to view this content. Registration is FREE
lajkonik86 is offline
Reply With Quote
View Public Profile
 
Old 04-12-2005, 02:41 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
This should work to check for the MIME type:

PHP Code:
$arr=array(IMAGETYPE_GIFIMAGETYPE_JPEGIMAGETYPE_PNGIMAGETYPE_BMP);

$valid false;

foreach (
$arr as $value)
{
  if(
exif_imagetype($button) == $value
  {
    
$valid true;
  }
}
if(
$valid)
{
  
// File is valid, carry on
}
else
{
  echo 
'This is not a valid file';
  exit;

What that does is make sure somebody doesn't take a .php file, or any other evil file, and just rename it to .jpg and upload it.
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-20-2005, 07:34 PM
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
^^ Great thanks
However when a non valid file type is posted i just get a bunch of failed to open stream messages eg:

Warning: exif_imagetype(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(http://dfsdsdfsgf): failed to open stream: Success in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(http://dfsdsdfsgf): failed to open stream: Success in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(http://dfsdsdfsgf): failed to open stream: Success in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(http://dfsdsdfsgf): failed to open stream: Success in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Any idea how to rectify that?
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
Old 04-20-2005, 08:50 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Shouldn't be too hard to fix. Post your code if you can (especially around line 28, but preferably all of it).
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-21-2005, 01:17 PM
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
nevermind
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.

Last edited by VToria; 04-29-2005 at 12:51 PM..
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
Old 04-21-2005, 02:57 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Okay, just change this:
PHP Code:
// Check if they entered a valid image.
$arr=array(IMAGETYPE_GIFIMAGETYPE_JPEGIMAGETYPE_PNGIMAGETYPE_BMP);

$valid false;

foreach (
$arr as $value)
{
  if(
exif_imagetype($button) == $value)
  {
    
$valid true;
  }
}
if(
$valid)
{
  
// File is valid, carry on
}
else
{
  echo 
'This is not a valid file';
  exit;

To this:
PHP Code:
// Check if they entered a valid image.
$arr=array(IMAGETYPE_GIFIMAGETYPE_JPEGIMAGETYPE_PNGIMAGETYPE_BMP);

$valid false;

foreach (
$arr as $value)
{
  if(
exif_imagetype($button) == $value)
  {
    
$valid true;
  }
}
if(!
$valid)
{
  echo 
'Invalid file type.';
  exit;

That's the easiest way to fix it. You can replace 'Invalid file type.' with the error message you want to give when it's invalid.
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-21-2005, 09:33 PM
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
Same error messages

Warning: exif_imagetype(http://x2.putfile.com/3/8005355887.if): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(http://x2.putfile.com/3/8005355887.if): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(http://x2.putfile.com/3/8005355887.if): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/starlet/public_html/plugboard/pboard/plug.php on line 28

Warning: exif_imagetype(http://x2.putfile.com/3/8005355887.if): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/starlet/public_html/plugboard/pboard/plug.php on line 28
Invalid file type.
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
Old 04-22-2005, 02:34 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
Oh, I see they're just putting the button URL, I thought they were uploading the image... it probably won't work then, but I don't really know, somebody else here might know.

Checking whether it ends in jpg, gif or bmp is probably good enough.
__________________

Please login or register to view this content. Registration is FREE

Last edited by Phaedrus; 04-22-2005 at 02:38 AM..
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-22-2005, 10:36 AM
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
aah right, no they just enter the url yeah.
Thanks for the help any way, much appreciated
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
Old 04-24-2005, 01:29 PM
VToria's Avatar
Extreme Talker

Posts: 151
Name: Viki
Location: West Yorkshire
Trades: 0
code removed

Is it perhaps something to do with numbers? I've noticed if the button url has a number before the .ext then it works, otherwise it does not.
__________________

Please login or register to view this content. Registration is FREE
- Reality TV videos, news and opinions.


Please login or register to view this content. Registration is FREE
- Bargains from a dedicated UK bargain hunter.

Last edited by VToria; 04-29-2005 at 12:51 PM..
VToria is offline
Reply With Quote
View Public Profile Visit VToria's homepage!
 
Reply     « Reply to Valid image.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41168 seconds with 12 queries