php-general Digest 5 Aug 2007 16:37:06 -0000 Issue 4944

Topics (messages 260197 through 260208):

Rejecting File Upload
        260197 by: php mail
        260198 by: Michael Preslar
        260199 by: Steve Edberg
        260207 by: Tijnema

Problems with file_get_contents() and local PHP file
        260200 by: Mike
        260202 by: Jan Reiter

Re: Problem with php mail
        260201 by: Richard Heyes
        260204 by: Bastien Koert
        260206 by: Tijnema
        260208 by: Carlton Whitehead

Check for well formed html
        260203 by: tedd
        260205 by: Tijnema

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi All,

How do I prior check file's size in server side before the upload process
begin ?

Regards,

Feris

--- End Message ---
--- Begin Message ---
Check http://www.php.net/file_upload .. In specific, the MAX_FILE_SIZE
form field .. And then check
http://us3.php.net/manual/en/ini.core.php#ini.upload-max-filesize

On 8/4/07, php mail <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> How do I prior check file's size in server side before the upload process
> begin ?
>
> Regards,
>
> Feris
>

--- End Message ---
--- Begin Message ---
At 11:48 AM +0700 8/5/07, php mail wrote:
Hi All,

How do I prior check file's size in server side before the upload process
begin ?

Regards,

Feris


If you want file information for a file on the *server*, see

        http://www.php.net/manual/en/ref.filesystem.php

If you want file size information *before the upload begins*, that would be on the client side. There's no foolproof or general way to check file information on the client. I don't think you can do it with JavaScript; you might be able to do it on a Windows PC with VBScript, and Java could do it.

PHP can refuse to accept files larger than a specified size, which isn't exactly what you're asking:

        http://us.php.net/manual/en/features.file-upload.php

For more information, documentation sets in multiple languages are available here:

        http://www.php.net/docs.php

        -steve

--
+--------------- my people are the people of the dessert, ---------------+
| Steve Edberg                                http://pgfsun.ucdavis.edu/ |
| UC Davis Genome Center                            [EMAIL PROTECTED] |
| Bioinformatics programming/database/sysadmin             (530)754-9127 |
+---------------- said t e lawrence, picking up his fork ----------------+

--- End Message ---
--- Begin Message ---
On 8/5/07, php mail <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> How do I prior check file's size in server side before the upload process
> begin ?
>
> Regards,
>
> Feris
>

You can't do it with PHP, with PHP you can only check it after the
file has uploaded, you can only do it on the client side. This means
you have 3 options:
1) form field MAX_FILE_SIZE, which is the easiest thing to bypass.
Some browsers even ignore this.
2) Javascript check, this can also be bypassed quite easily.
3) Do it through a seperate program, like an JAVA applet, or a stand
alone application. Both can be bypassed too, though you need to have
knowledge of ASM and Reverse Engineering for that, which is not easy,
but once you know it, it can be quite easy to do it too ( I could do
it in less than 5 mins )

Tijnema
-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
Hey. My server is running PHP 4(Not actually my server so I don't know
the exact version) and I'm having trouble with getting an image from a
PHP file.

I have a file, flash_frames.php, which outputs an image composed of
the combination of a bunch of other images. Another file, flash.php,
takes this image and chops it up into frames and then animates it in a
flash file.

The problem is that originally this system was developed to be used
with PHP 5, and used fopen() and stream_get_contents() to retrieve the
image file from flash_frames.php. I thought I could just replace both
of those with file_get_contents(), but it appears to fail when doing
so. A quick test confirmed that file_get_contents(), when used
locally, returns the PHP source as opposed to the output of the file.

I didn't originally code this (I am but an inheritor who is learning
PHP as he goes :P), so I'm at a loss for what should be done to fix
this. I considered just converting the file into a function that
returns the image, but I cannot find out how to return an image (Or
convert the image to a string of bytes as the original code expected
it to be).
Any help is greatly appreciated. :)

-Mike

Original code for retrieving image:

//Replaces res_viewer to flash_frames since they both take the same
arguments
$img=rawurldecode($img);
$fl_imgsrc=str_replace('/res_viewer.php?','/flash_frames.php?scale='.
$scale.'&',rawurldecode($img));

//Grabs the generated image set up for the flash preview
$handle = fopen($fl_imgsrc, "rb");
$contents = stream_get_contents($handle);
$fl_map = new SWFBitmap($contents);
fclose($handle);
--- End Message ---
--- Begin Message ---
Hi!

If you want file_get_contents() to open the compiled data, force the server
to compile it first. ;-)
Do not open the file from filesystem, use the ULR
(http://server/flash_frames.php?...).
For this fopen() wrappers have to be enabled.
http://www.php.net/manual/en/function.file-get-contents.php
The tip in the blue box.

If you get uncompiled code with the url stated, you got a big security hole
in the server config!!

Hope this is, what you are searching for ... 

Jan



-----Original Message-----
From: Mike [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 05, 2007 8:38 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Problems with file_get_contents() and local PHP file

Hey. My server is running PHP 4(Not actually my server so I don't know
the exact version) and I'm having trouble with getting an image from a
PHP file.

I have a file, flash_frames.php, which outputs an image composed of
the combination of a bunch of other images. Another file, flash.php,
takes this image and chops it up into frames and then animates it in a
flash file.

The problem is that originally this system was developed to be used
with PHP 5, and used fopen() and stream_get_contents() to retrieve the
image file from flash_frames.php. I thought I could just replace both
of those with file_get_contents(), but it appears to fail when doing
so. A quick test confirmed that file_get_contents(), when used
locally, returns the PHP source as opposed to the output of the file.

I didn't originally code this (I am but an inheritor who is learning
PHP as he goes :P), so I'm at a loss for what should be done to fix
this. I considered just converting the file into a function that
returns the image, but I cannot find out how to return an image (Or
convert the image to a string of bytes as the original code expected
it to be). 

Any help is greatly appreciated. :)

-Mike

Original code for retrieving image:

//Replaces res_viewer to flash_frames since they both take the same
arguments
$img=rawurldecode($img);
$fl_imgsrc=str_replace('/res_viewer.php?','/flash_frames.php?scale='.
$scale.'&',rawurldecode($img));

//Grabs the generated image set up for the flash preview
$handle = fopen($fl_imgsrc, "rb");
$contents = stream_get_contents($handle);
$fl_map = new SWFBitmap($contents);
fclose($handle); 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
I'm having problem with php mail.  When I try to create an
> html message with only <a href='mydomain.com'>mydomain</a>,
gmail is registering it as a spam while yahoo is not.
Can you suggest solutions to my problem.

Try sending a real message. Messages being too small is one indicator of a message being junk.

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

--- End Message ---
--- Begin Message ---
Can you post the headers that you are using...they play a role how the message 
is viewed by the receiving agent

bastien




----------------------------------------
> Date: Sat, 4 Aug 2007 21:06:53 -0700
> From: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: [PHP] Problem with php mail
> 
> Hi Everyone,
>     I'm having problem with php mail.  When I try to create an html message 
> with only mydomain, gmail is registering it as a spam while yahoo is not.  
> Can you suggest solutions to my problem.
> 
> Thanks,
> Jason
> 
> 
> 
> Send instant messages to your online friends http://uk.messenger.yahoo.com 

_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

--- End Message ---
--- Begin Message ---
On 8/5/07, Jason Sia <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>    I'm having problem with php mail.  When I try to create an html message 
> with only <a href='mydomain.com'>mydomain</a>, gmail is registering it as a 
> spam while yahoo is not.  Can you suggest solutions to my problem.
>
> Thanks,
> Jason
>

There are a lot of things that can make emails go to spam, as already
noted the headers and the size of the message, but also a wrong title,
or wrong From: address (domain email != domain mail server) can make
the message go to spam

Tijnema

-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---
--- Begin Message ---
Jason,

There's a chance your domain link is listed on a spam URL realtime blocklist.  
Try using http://www.rulesemporium.com/cgi-bin/uribl.cgi to find out.

This might also be totally wrong, just throwing that around as a possibility 
since you mentioned the problem happens with URLs.  Does the problem also 
happen when you send an html email without any links?

It would be really helpful to find out what part of gmail's antispam solution 
doesn't like your message.  Does the message header information provide any 
clues?

(it probably isn't PHP's fault the message is getting blocked)

Regards,
Carlton Whitehead

----- Original Message -----
From: "Tijnema" <[EMAIL PROTECTED]>
To: "Jason Sia" <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED]
Sent: Sunday, August 5, 2007 11:22:13 AM (GMT-0500) America/New_York
Subject: Re: [PHP] Problem with php mail

On 8/5/07, Jason Sia <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>    I'm having problem with php mail.  When I try to create an html message 
> with only <a href='mydomain.com'>mydomain</a>, gmail is registering it as a 
> spam while yahoo is not.  Can you suggest solutions to my problem.
>
> Thanks,
> Jason
>

There are a lot of things that can make emails go to spam, as already
noted the headers and the size of the message, but also a wrong title,
or wrong From: address (domain email != domain mail server) can make
the message go to spam

Tijnema

-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hi gang:

I have a client who wants to include html tags in his CMS.

I know that I can limit what tags he can use, but how can I check if the text is well formed with the tags permitted before storing it in his CMS?

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On 8/5/07, tedd <[EMAIL PROTECTED]> wrote:
> Hi gang:
>
> I have a client who wants to include html tags in his CMS.
>
> I know that I can limit what tags he can use, but how can I check if
> the text is well formed with the tags permitted before storing it in
> his CMS?
>
> Cheers,
>
> tedd
>

Have a look at Example 1687 on the manual page for preg_match_all, I
think you can use it with a little modification :)


Tijnema
-- 
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--- End Message ---

Reply via email to