[PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-22 Thread Dee Ayy
The following code has been working for about 6 years.  The only
change I am aware of is that now it is being served from a server
requiring SSL to access it.

header("Content-type: $type");
header("Content-length: $size");
header("Content-Disposition: attachment; filename=\"$name\"");
echo $data;

It still works in FF, so I assume the variables are being filled in.
For example:
header("Content-type: application/pdf");
header("Content-length: 75485");
header("Content-Disposition: attachment; filename=\"test.pdf\"");

In DebugBar HTTP(S) after the GET request which had to be authorized
by htaccess it reports:
HTTP/1.1 200 OK
Date: Fri, 22 May 2009 14:38:18 GMT
Server: Apache/2.0.50 (Fedora)
X-Powered-By: PHP/5.1.6
Set-Cookie: PHPSESSID=743ba4d8e056873c4da52b123df4b1ad; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-length: 7359
Content-Disposition: attachment; filename="test.pdf"
Connection: close
Content-Type: application/pdf

Should "HTTP/1.1 200 OK" be "HTTPS/1.1 200 OK"?  If so, how can I get
that set?  Is there some funky header I need?

Oh, the IE 7 error is:
Internet Explorer cannot download my_php_file.php?a_name=a_value from
my.site.com.

Internet Explorer was not able to open this Internet site.  The
requested site is either unavailable or cannot be
found.  Please try again later.

FYI: If the user cannot choose a filename to save as, it gets saved as
"my_php_file.php" which needs to be renamed to extension ".pdf" to be
viewed in a PDF viewer.
So if you have any helpful headers to force the filename, I'd
appreciate that too.  Apparently Content-Disposition: attachment;
filename="test.pdf" doesn't work (on FF and maybe other browsers).

There is an issue with Internet Explorer 6
http://support.microsoft.com/?kbid=816037 that seems to relate, but
this is for IE 7, and I can't verify if it is also failing on IE 6.
But I found this (which didn't work for me)
http://www.vistaheads.com/forums/microsoft-public-internetexplorer-general/313324-downloading-ftp-files-ie7.html

Regards.

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-22 Thread Dee Ayy
Kyle,
Well I guess that is good news.  But I don't trust these headers since
the filename is not being set.  But that was even before this IE
issue.

Bastien,
I don't understand how I could "save the file to the hard disk" from
IE.  But yes, I save the file (it gets saved as my_php_file.php on the
hard disk when using FF) which I then rename to my_php_file.pdf, and
then I open that in a PDF viewer.  But IE claims that the "site is
either unavailable or cannot be found".

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-22 Thread Dee Ayy
I went with this, modified from http://php.he.net/readfile docs example 1:

header('Content-Description: File Transfer');
header('Content-Type: '.$type);
header('Content-Disposition: attachment; filename='.basename($name));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.$size);
echo $data;

And it works in FF 3.0.10 and IE 7 and Safari 3.2.1.
I thought it would be some header magic.



Bastien,
I think because I was not urlencoding or not basenaming the filename,
it would come through as the name of the script if the name had a
space in it.  test.pdf actually came through with the name test.pdf.
But the real filenames are like "QUOTE Part 1-2 Prospect Name.pdf".

Thanks everybody.

I was looking up those other header names and case sensitivity when I
found the readfile example.  DebugBar reports a different case than
what I sent, so I thought that could be an issue too (like
Content-Length versus Content-length).  Moot for me now though.

Re-RTFM I guess.

Regards.

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-22 Thread Dee Ayy
Acceptable results, but could be better.

basename works correctly for only Safari (filenames with spaces are correct).
FF truncates the name starting with the first space.
IE puts an underscore in place of a space.

urlencode puts a plus sign in place of a space for all 3 browsers.

But I've always had a note telling the user to rename the file to
something useful, so I'll keep basename and not check the agent.

Thoughts?

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



Re: [PHP] urgent CSS question

2009-05-22 Thread Dee Ayy
Find the "Computed Style" and how it was inherited (cascaded).

In Safari, use Web Inspector.
In Firefox, use Firebug.
In Internet Explorer, use DebugBar.

All free as in $0.

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-22 Thread Dee Ayy
>> Thoughts?
>>
>> --
>
> what about just CamelCasing the name? no spaces.
>
> --
>
> Bastien

I've asked the user to use underscores, but they really shouldn't have
to.  Safari gets it right.

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-22 Thread Dee Ayy
On Fri, May 22, 2009 at 1:24 PM, Eddie Drapkin  wrote:
> or even just str_replace(' ' , '_', $name) consistent and works, no?

Good one.

Put it back on me rather than the browser developers.

But that's in line with my requesting the user to use underscores.
I'll implement this str_replace.  Thanks.

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-22 Thread Dee Ayy
That's what I had in my first post.  What are the rest of your headers?

This is what is now deployed and I consider this issue resolved, but
allowing spaces in the filename across IE, FF, and Safari browsers
would be the real solution.  It's untested on other browsers:

header('Content-Description: File Transfer');
header('Content-Type: '.$type);
header('Content-Disposition: attachment;
filename='.basename(str_replace(' ', '_', $name)));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.$size);
echo $data;

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



Re: [PHP] urgent CSS question

2009-05-22 Thread Dee Ayy
I had an id killing me the other day.  Turned out I was going blind.
A different font or glasses would have helped me see that I was not
using the id I thought I was.

Just a thought.

The following are 5 different characters:

iIl1!

Also, the debug tools I mentioned should confirm that they have the
same computed styles.  Then you can continue pulling your hair out if
they do.  I also had an issue where "px" was not included and it was
not defaulting to "px".

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-26 Thread Dee Ayy
Ashley,
Don't scare me like that.  I know I'm losing my eye sight, but a
copy-paste-diff shows your
header("Content-Disposition: attachment; filename=\"$filename\"");
differs from my original post's
header("Content-Disposition: attachment; filename=\"$name\"");
by only the text "file".  This method (with the other headers I used
in my original post) fails on IE with the lame error:
Internet Explorer was not able to open this Internet site.  The
requested site is either unavailable or cannot be
found.  Please try again later.

Hence the reason for my post in the first place.  If you would show
your other headers for the \" quoted method, I'd be happy to test
them.  Maybe you were comparing your method to my single tick method?


Mike,
rawurlencode (sounded promising) but did in fact leave it saved on the
hard drive as %20 rather than + or the desired "space".  I find the
str_replace spaces to underscores more readable, although saving to
the hard drive with spaces would be best.  Thanks though.

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



Re: [PHP] IE can't download, FF can: SSL ? Need special headers?

2009-05-28 Thread Dee Ayy
Andrea and Ashley,
Thanks ladies.

Originally, IE claimed that the server wasn't even there (with that
wacky IE error).  I was lacking headers (which was fine for 6 years
prior).

The code below is consistent across the 3 browsers I tried (Safari,
FF, IE).  However, it converts spaces to underscores.  I'm keeping
this code:
header('Content-Description: File Transfer');
header('Content-Type: '.$type);
header('Content-Disposition: attachment;
filename='.basename(str_replace(' ', '_', $name)));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.$size);
echo $data;

If I use
header('Content-Disposition: attachment; filename="'.basename($name).'"');
of the 3 browsers tested, only IE will replace spaces with
underscores.  Safari and FF pass through correctly.  But I'll go with
consistency and avoid the "if browser-war" clauses.

Thanks all.

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



Re: [PHP] Confirmation email caught by spam filter

2009-05-29 Thread Dee Ayy
Are you sure it's a PHP thing?

The way I have some of my email accounts setup is that I only accept
email from folks in my address book.  If I just registered a new
account somewhere, chances are I do not have them in my address book,
so it will go to the Junk/Spam folder.

If this is your issue, educate your users to make sure they check
their Junk/Spam folder depending upon their Junk/Spam filtering
settings when they are first registering.

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



Re: [PHP] Re: PHP vs ASP.NET

2009-06-01 Thread Dee Ayy
> ASP.NET is not a language. It is more like a framework that can run
> multiple languages. It can run VB.NET, C# and even PHP (although it is
> not usual).

I'm going to shoot from a (90's?) hip on this one.

Isn't ".NET" the framework, and ".NET" the language?

ASP.NET uses ASP to access the .NET framework.
VB.NET uses VB to access the .NET framework.
.NET uses  to
access the .NET framework.


And how _IS_ Mono coming along?  Last I checked, 1.x stuff worked on
Linux, but the goodies I wanted were in the 2.x framework.

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



Re: [PHP] PHP vs ASP.NET

2009-06-01 Thread Dee Ayy
>    "Will Assembly be replaced by LOLCODE?"  Nonsense - they're
> separate entities.
KTHXBYE

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



Re: [PHP] Source Code Analysis

2009-06-07 Thread Dee Ayy
On Wed, Oct 22, 2008 at 4:30 PM, Dee Ayy wrote:
> Thanks regarding the error_reporting.  I may have to go this route for
> this specific issue.
> ...
> ...  And not only for this specific issue.

I have another need for a SCA tool.
Is there an existing tool similar to a broken link checker, but
instead of looking for links, it would look for "include" and
"require" type commands and list a hierarchy of all files used in the
project, starting from a given input file?

It should get a list of files used in a production deployment
beginning from say "index.php", and compare that to a list of files
used in a project undergoing development from say "index_dev.php"?  At
a minimum, (from what I can think of), it would have to resolve
define's that may be referenced in "include/require" as well as links
as in a broken link checker tool.

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



Re: [PHP] Re: SHOULD I NOT USE "ELSE" IN IF STATEMENTS....?

2009-06-08 Thread Dee Ayy
It's for better code.

Personally, I'm trying to get away from multiple return/exit paths,
and practice more OOC/Eiffel-like coding (I haven't sprung for the
book Object Oriented Construction yet
http://archive.eiffel.com/doc/oosc/page.html ) and I'm not quite
taking advantage of Design By Contract in my Eiffel coding yet though
either.

At a minimum, I would change this:

function doThisAndThat($bTrueOrFalse)
{
if ($bTrueOrFalse)
{
return 'It is true';
}

/* If the above is true we can be sure it's NOT true here. */
return 'It is false';
}

to this:

function doThisAndThat($bTrueOrFalse)
{
   $return_value = 'It is false';   // Set your default state here.
if ($bTrueOrFalse)
{
$return_value = 'It is true';  //  Update state.
}

return $return_value; // Only 1 exit path.
}

I've also noticed that, for the most part, PHP itself codes
functions_or_variables_like_this, while coming from Java, my PHP code
looksLikeThis.

Slightly more readable for say do_www_design versus doWWWDesign versus
do_wwwd_esign for those times when you run into such names.

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



Re: [PHP] php applications

2009-06-08 Thread Dee Ayy
tedd,
You can check out MacPorts http://www.macports.org/ and the port
package php5-gtk

But Xcode and Interface Builder are your friends for native/fast apps.

Although you probably get Cross-OS portability going the php-gtk route.

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



Re: [PHP] php applications

2009-06-08 Thread Dee Ayy
> I'm used to an IDE where you write code, run, and debug it. When you get it
> where you want and want to create an application, then you compile the code
> and there's an application -- a stand alone application -- done!

You may be looking for glade http://glade.gnome.org/
It's in MacPorts as glade and glade3
port search whatever
like
port search glade

man port
and check out "variants"

I don't recall if Glade has debugging.

Remember PHP is a scripting language.  You don't compile.  But I have
seen something that compiles PHP to a stand alone app
google says this today for "compile php stand alone"
http://www.devx.com/opensource/Article/21235

> In both cases they are very verbose about command line stuff, but short on
> how to use php to create an application. I just don't see it. Maybe my
> terminology is not correct. My applications stand by themselves and run when
> clicked -- no command line is needed.

http://glade.gnome.org/manual/index.html
It's been a while since I toyed with this.
Google "glade tutorial"
http://www.micahcarrick.com/12-24-2007/gtk-glade-tutorial-part-1.html

I would think there is a way to create a YourApp.app bundle for Mac
and have it run when clicked.  I just saw something about creating
your own YourApp.app bundle the other day.  It was not about PHP, but
I'm sure it could be done.  It was something to do with a tool
that...ahh it was about the open source iPhone tool chain.  It did not
create a TheApp.app bundle but showed how to do so manually.  I would
think that you would do something with #!/usr/bin/php -q
More like #!/opt/local/bin/php for MacPorts and make some part of the
bundle point to the executable PHP script.

Not as smooth as Xcode and Interface Builder eh?

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



Re: [PHP] key for in_array()

2009-06-08 Thread Dee Ayy
array_search
in the See Also section for in_array docs?

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



Re: [PHP] php applications

2009-06-08 Thread Dee Ayy
> Not as smooth as Xcode and Interface Builder eh?

I had interesting results with my first custom MyApp.app bundle.
>From 
>http://developer.apple.com/documentation/CoreFOundation/Conceptual/CFBundles/Concepts/BundleAnatomy.html#//apple_ref/doc/uid/20001119-104977-TPXREF4
I made a new folder named "Test" and made a sub directory "Contents"
then another sub to that "MacOS" then put a PHP script with no
extension named "test" containing code from
http://gtk.php.net/manual/en/tutorials.helloworld.php to which I added
the top line #!/opt/local/bin/php -q
like so:

#!/opt/local/bin/php -q
set_title('Hello world');
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));

$lblHello = new GtkLabel("Just wanted to say\r\n'Hello world!'");
$wnd->add($lblHello);

$wnd->show_all();
Gtk::main();
?>

Rename Test folder to Test.app
It should take on the default App icon.
Don't click on it until you read the WARNING below so you can show
Desktop (should not matter here yet though).  If you try it now, it
may tell you that you need gtk installed "Please load the php-gtk2
module in your php.ini".

>From MacPorts I did:
sudo port install php5-gtk

I was surprised that it installed apache, but I didn't do any post
install apache step (I'll just wipe /opt/local anyway).  I did however
do
sudo cp /opt/local/etc/php.ini-dist /opt/local/etc/php.ini
in response to this line during the port build
* copy  /opt/local/etc/php.ini-dist to  /opt/local/etc/php.ini

I then did a
sudo vi /opt/local/etc/php.ini

Changed
;extension_dir = "./"
extension_dir = "/opt/local//lib/php/extensions/no-debug-non-zts-20060613/"

and added
extension=php_gtk2.so
at the end, although it should probably be in the extension area.

WARNING:
I have my Expose set to show the desktop if I move my mouse to a
corner. (Active Screen Corners)
Without that, I would have been stuck after a launch.

I launched Test but it kicked in X11, then showed the Hello World GTK
window.  I closed the window and was left with a blank X11 screen
(WITH NO DOCK !!!).  Now I recovered by moving my mouse to the active
screen corner to show the Desktop (WHICH HAD MY HARDDRIVE icon there.
When I opened my Hard Drive icon Macintosh HD, the X11 app icon
appeared along with the Dock.)  Then I Quit X11 from the Dock and was
back to normal.

Anyway, you can do any post install stuff if you really want to setup
properly or do port uninstall and friends, but there is also this:
http://guide.macports.org/#installing.macports.uninstalling

But after the WWDC today, I see it's high time to get into iPhone development.

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



[PHP] Testing "Broken Pipe" Recovery?

2009-09-22 Thread Dee Ayy
How do I intentionally break a pipe so that I can test recovering
under this eventuality?

I saw this post "[PHP] Pushing the limits of stream_socket_server()
and stream_select()" but my intermittent broken pipe occurs with 1
client, so I don't want to to create a 252 client situation.

I'm actually testing a client against a remote 3rd party server.  I
was thinking of creating my own server; connect my client to that; and
maybe just killing my server process while it's connected (rather than
using fclose which may be too clean).  Is that the right approach?

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



[PHP] Can't find existing file

2010-11-22 Thread Dee Ayy
1)
Warning: getimagesize("./photos/HPR-130-260_HD-3070-1.jpg"): failed to
open stream: No such file or directory in ... on line ...

ls ./photos/HPR-130-260_HD-3070-1.jpg
./photos/HPR-130-260_HD-3070-1.jpg

ls "./photos/HPR-130-260_HD-3070-1.jpg"
./photos/HPR-130-260_HD-3070-1.jpg


2) Similarly...
Also trying
$cmd = 'cp '.$src.' '.$dst;
exec($cmd);

And some files failed to copy.  I assumed it was due to spaces in the
name, so I double quoted them.  For example:
cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such
file or directory

ls "./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG" FAILS THOUGH

cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG ... ALSO FAILS

Help.

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



Re: [PHP] Can't find existing file

2010-11-22 Thread Dee Ayy
There are 2 separate issues numbered 1) and 2).

#1 deals with getimagesize operating on definitely existing files
verified by "ls".

#2 deals with escaping spaces in the name of the file and using the
exec command, which an example was given for a different file name
than in #1.

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



Re: [PHP] Can't find existing file

2010-11-22 Thread Dee Ayy
Hi Daniel,
Tell me if this isn't self explanatory:

cp ./photos/Nozzle\ 130\ Amp\ SS\ Alum\ 94-00994-06\ 220197.JPG
"./photossized/001196-220197-0.jpg"
cp: ./photos/Nozzle 130 Amp SS Alum 94-00994-06 220197.JPG: No such
file or directory

Thanks for trying.  Usually coders can read the error line and some
folks like to see what you have done to attack the problem, hence the
original "ls" line.  I could have omitted the original "Help" at the
bottom.  I didn't think it would confuse anyone by adding it.  And
maybe you haven't seen the "ls" command.

Solving issue #1:  The getimagesize command wants filenames unquoted
and unescaped.  Those quotes were an attempt to handle spaces in the
filename, but ended up introducing the error.

For issue #2, I think you meant "really does exist"; of course my code
is to blame; the script is in the same dir as the photos and
photossized dirs.  Thats what "./aDir" means -- but remember that only
some are failing; cases are preserved; yes, unlikely; the disk has a
lot of space; cp is on the path because "some" work; Obviously it's a
PEBKAC issue, that's why I came to this php list, to get it pointed
out; etc.

Solving issue #2 exec (or rather the shell) wants spaces escaped.  And
yes, some files were there, but the lookup table had single spaces
while the filename being compared had double spaces.

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



[PHP] file_exists fun

2011-12-02 Thread Dee Ayy
The following code:

$new_file = 
ADS_DIR_INTERNAL.'/'.$ad_info['id'].'_'.$ad_info['filename'];
echo "NEW_FILE:[".$new_file."]\n";
echo "file_exists Using 
VAR:[".file_exists($new_file)."]\n";
echo "file_exists Using Hard
Coded:[".file_exists('/home/fx/pads/ads_dir/1_rubik1920x1080lu0.jpg')."]\n";

Gives this output:
NEW_FILE:[/home/fx/pads/ads_dir/1_rubik1920x1080lu0.jpg]
file_exists Using VAR:[]
file_exists Using Hard Coded:[1]

Why does it not work when using the variable in file_exists?

I thought I may need some safe_mode magic, safe_mode_include_dir, or
disable_functions, but I don't see any restrictions AND why does it
work when it is hard coded?
Warning
This function returns FALSE for files inaccessible due to safe mode
restrictions. However these files still can be included if they are
located in safe_mode_include_dir.

Current logic needs the following functions:
file_exists
md5_file
move_uploaded_file

Thanks.

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



[PHP] Re: file_exists fun

2011-12-02 Thread Dee Ayy
On Fri, Dec 2, 2011 at 1:30 PM, Dee Ayy  wrote:
> The following code:
>
>                        $new_file = 
> ADS_DIR_INTERNAL.'/'.$ad_info['id'].'_'.$ad_info['filename'];
>                        echo "NEW_FILE:[".$new_file."]\n";
>                        echo "file_exists Using 
> VAR:[".file_exists($new_file)."]\n";
>                        echo "file_exists Using Hard
> Coded:[".file_exists('/home/fx/pads/ads_dir/1_rubik1920x1080lu0.jpg')."]\n";
>
> Gives this output:
> NEW_FILE:[/home/fx/pads/ads_dir/1_rubik1920x1080lu0.jpg]
> file_exists Using VAR:[]
> file_exists Using Hard Coded:[1]
>
> Why does it not work when using the variable in file_exists?
>
> I thought I may need some safe_mode magic, safe_mode_include_dir, or
> disable_functions, but I don't see any restrictions AND why does it
> work when it is hard coded?
> Warning
> This function returns FALSE for files inaccessible due to safe mode
> restrictions. However these files still can be included if they are
> located in safe_mode_include_dir.
>
> Current logic needs the following functions:
> file_exists
> md5_file
> move_uploaded_file
>
> Thanks.

>From PHP, exec('whoami') says "www-data", so I created /home/www-data
and chown to www-data.
file_exists with a variable still fails.
Initial and future testing of !file_exists(ADS_DIR_INTERNAL) works to
create the directory only once as intended, however ONLY initial
creation of the file inside the directory works with
move_uploaded_file.
Attempting to overwrite an existing file with move_uploaded_file fails.
I then tried exec('mv '.$_FILES['my_file']['tmp_name'].' '.$new_file)
as well as mv -f
which DOES COPY the filename of tmp_name to the correct directory
ADS_DIR_INTERNAL, but keeps the tmp_name filename!  It is not renamed
as a true linux "mv".
I assume it is some protection due to being an uploaded file.

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



[PHP] Settings to Allow Precise File Upload Bytes

2012-01-20 Thread Dee Ayy
Please advise the proper settings (Apache/PHP/HTML/MySQL/Anything else
I missed) to allow a specific byte size upload and to deny 1 byte over
with error reporting in LAMP/AJAX.  I've heard of Flash and Gears
solutions, but these require additional installs for the user -- just
to know the file size before an upload.

The server is Apache 2.
PHP is 5.1.6
HTML has




PHP ini :
file_uploadsOn  On
upload_max_filesize 2M  2M
post_max_size   8M  8M

I believe MySQL max_allowed_packet 1,048,576 was affecting the MySQL
INSERT, so I changed MAX_FILE_SIZE to 103 above.

Now I am seeing cases where
if(isset($_FILES['attachment']) && $_FILES['attachment']['size'] > 0){
evaluates to FALSE

How can I know that a file upload was attempted yet failed or will fail?

My last test case had the web page still claiming it was busy, yet I
noticed that the above condition must have evaluated to FALSE, failing
silently due to missing error reporting on my part (or the system's
part).

I am willing to make 2 requests:
1) just to find out if the attempted upload will fail and inform the user.
2) for the actual upload if it should succeed.


TIA

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




[PHP] Re: Settings to Allow Precise File Upload Bytes

2012-01-20 Thread Dee Ayy
Obviously I don't want a Flash/Gears solution.

FYI: Your #6 should be:
The server uploads...

Even though I do not want a Flash/Gears solution, I would be happy
with your #8 stating:
I won't fail silently, I'll report the problem to the user.

Do you know the correct settings on any applicable LAMP/AJAX stack to
get the error you claim is available in your step #8 and where to look
for this error?  Is $_FILES['attachment'] supposed to be set and
hopefully something is in $_FILES['attachment']['error']?
I decided to post here instead of trying various permutations.

MySQL max_allowed_packet was mentioned because even if you correct #8,
MySQL can choke on what Apache allowed through, and I included the DB
list.

I never claimed I want to know the file size before upload, just that
some solutions may do this.


On Fri, Jan 20, 2012 at 11:50 AM, Maciek Sokolewicz
 wrote:
> Your problem here is the fact that you do not seem to grasp what is
> hapenning when a file is being uploaded, hence your question. So let me
> explain:
> 1. A user goes to your page by entering it into the browser.
> 2. The page is downloaded to the client, and the connection is closed.
> 3. The user chooses to upload a file via an HTML control (ie. an HTML input
> element of type="file".
> 4. The user submits the form
> 5. The browser makes a connection to the server containing a header saying
> "the following data is a file".
> 6. The server downloads all of the data from the user
> 7. The server parses the data, finds the header stating that the content is
> a file
> 8. The server invokes your PHP script, which decides "whoa! wait a minute,
> that file is too large" and shows an error.
> 9. The server removes the file from memory / temporary storage
> 10. The server sends back the error to the client, and closes the
> connection.
>
> The point I am trying to make here is the fact that the server does not know
> the size of the file, until it has fully downloaded it, since it is not
> given in any way. Good browsers let the server know what size to *expect*,
> but even then, you can't rely on it.
>
> All checking of how large a file is has to happen client-side. Due to
> security reasons, languages such as javascript are not allowed to view any
> details about files on your disk, and thus can't be used to determine the
> filesize before sending anything to the server.
>
> The reason flash and gears can do this, is because these are designed
> differently and actually form a separate program inside your browser, which
> is not limited in its activity, as javascript (and vbscript in IE) are.
>
> So... you can use Flash and Gears to prevent upload of a too large file to
> your server. But not plain HTML and/or javascript. Since the server does not
> check the size until AFTER it has fully downloaded the file, there is no
> setting in Apache, PHP, MySQL (which has absolutely nothing to do with
> uploading at all), etc. Which are all server-side and ran after the upload
> has finished.
>
> In other words: use the Flash/Gears solution, or just decide you don't mind
> if a large file is uploaded. In the last case you can always reject the file
> afterwards.
>
> - Tul
>
>
> On 20-01-2012 18:15, Dee Ayy wrote:
>>
>> Please advise the proper settings (Apache/PHP/HTML/MySQL/Anything else
>> I missed) to allow a specific byte size upload and to deny 1 byte over
>> with error reporting in LAMP/AJAX.  I've heard of Flash and Gears
>> solutions, but these require additional installs for the user -- just
>> to know the file size before an upload.
>>
>> The server is Apache 2.
>> PHP is 5.1.6
>> HTML has
>> 
>> 
>> 
>>
>> PHP ini :
>> file_uploads    On      On
>> upload_max_filesize     2M      2M
>> post_max_size   8M      8M
>>
>> I believe MySQL max_allowed_packet 1,048,576 was affecting the MySQL
>> INSERT, so I changed MAX_FILE_SIZE to 103 above.
>>
>> Now I am seeing cases where
>> if(isset($_FILES['attachment'])&&  $_FILES['attachment']['size']>  0){
>>
>> evaluates to FALSE
>>
>> How can I know that a file upload was attempted yet failed or will fail?
>>
>> My last test case had the web page still claiming it was busy, yet I
>> noticed that the above condition must have evaluated to FALSE, failing
>> silently due to missing error reporting on my part (or the system's
>> part).
>>
>> I am willing to make 2 requests:
>> 1) just to find out if the attempted upload will fail and inform the user.
>> 2) for the actual upload if it should succeed.
>>
>>
>> TIA
>
>

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



[PHP] Re: Settings to Allow Precise File Upload Bytes

2012-01-20 Thread Dee Ayy
My browser is claiming it is still busy from a 1MB (1030001 bytes)
upload where I was trying to find out if it is setting
$_FILES['attachment'].

Thanks Maciek.  It makes sense that I should be looking at
$_FILES['attachment']['error'] before the size.  I'm just surprised
it's still hanging.  I'm using jquery mobile which has extra file
upload concerns (although there is no problem when the file is small
enough).

The MySQL part was included so that this post could help others if
they missed a setting in their LAMP/AJAX stack, but I had narrowed my
specific issue down to PHP $_FILES['attachment'].

Thanks for all your help Jim.



On Fri, Jan 20, 2012 at 2:38 PM, Maciek Sokolewicz
 wrote:
> Answers are inside the mail
>
> On 20 January 2012 21:18, Dee Ayy  wrote:
>>
>> Obviously I don't want a Flash/Gears solution.
>>
>> FYI: Your #6 should be:
>> The server uploads...
>
> No, the server downloads, the client uploads. Downloading is performed by
> the receiving end (in this case, the server), while uploading is done by the
> serving end (in this case, the client). But that's a minor thing.
>
>>
>> Even though I do not want a Flash/Gears solution, I would be happy
>> with your #8 stating:
>> I won't fail silently, I'll report the problem to the user.
>>
>> Do you know the correct settings on any applicable LAMP/AJAX stack to
>> get the error you claim is available in your step #8 and where to look
>> for this error?  Is $_FILES['attachment'] supposed to be set and
>> hopefully something is in $_FILES['attachment']['error']?
>> I decided to post here instead of trying various permutations.
>
>
>>
>>
>> MySQL max_allowed_packet was mentioned because even if you correct #8,
>> MySQL can choke on what Apache allowed through, and I included the DB
>> list.
>
> After rereading your post I noticed I had failed to read correctly. I'm
> sorry. However, I still believe that the MySQL settings are not of any
> interest here. The limitation should IMO be performed by PHP (or even
> apache). By the time it gets to MySQL, all such checks should already have
> been done. So let's ignore MySQL for now.
>
> As for PHP:
> $_FILES['attachment']['error']  should be 0 if the file is uploaded
> correctly. If it's > 0, then you should throw an error regardless of size.
> So, assuming $_FILES['attachment']['error'] == 0,
> $_FILES['attachment']['size'] will give you the exact filesize in bytes.
> Check against this number, and you should be fine.
>
> However, if the upload size was higher than php.ini's upload_max_filesize,
> $_FILES['attachment']['error'] will have the value 1 (constant:
> UPLOAD_ERR_INI_SIZE), and will not be available to handle.
>
> So, in short, with code like:
>>
>> define('CUSTOM_MAX_UPLOAD_SIZE', (10*1024*1024) ); // 10MB
>> if( isset($_FILES['attachment']) && $_FILES['attachment']['error'] <= 1 )
>> {
>>    if( ($_FILES['attachment']['error'] == 1) or
>> ($_FILES['attachment']['error'] == 0 && $_FILES['attachment']['size'] >
>> CUSTOM_MAX_UPLOAD_SIZE) ) {
>>   exit('ERROR: upload too big');
>>    } else {
>>   // process the upload, store it, etc.
>>    }
>> } else {
>>    // something went wrong while uploading
>> }
>
>  You should be fine.
> Of course, you should also check that your max request body size is large
> enough in Apache, though usually it allows requests far larger than PHP
> does.
>
> Hope this helps, and sorry if I sounded rude at first,
> - Tul
>
>>
>> I never claimed I want to know the file size before upload, just that
>> some solutions may do this.
>>
>>
>> On Fri, Jan 20, 2012 at 11:50 AM, Maciek Sokolewicz
>>  wrote:
>> > Your problem here is the fact that you do not seem to grasp what is
>> > hapenning when a file is being uploaded, hence your question. So let me
>> > explain:
>> > 1. A user goes to your page by entering it into the browser.
>> > 2. The page is downloaded to the client, and the connection is closed.
>> > 3. The user chooses to upload a file via an HTML control (ie. an HTML
>> > input
>> > element of type="file".
>> > 4. The user submits the form
>> > 5. The browser makes a connection to the server containing a header
>> > saying
>> > "the follow

Re: [PHP] ini_set('memory_limit', '16M')

2007-11-28 Thread Dee Ayy
On Nov 28, 2007 4:05 PM, George Pitcher <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > On one script (pulling large amount of data from mysql) I'm getting error:
> > "Fatal error: Allowed memory size of 16777216 bytes exhausted..."
> > I put on the beginning of the page
> > ini_set('memory_limit', '64M');
> > but I'm still getting the same error message?!?
> >
>
> ini_set() returns the old value, so it might work if you assign the return
> value:
>
> $x = ini_set('memory_limit', '64M');
>
> George
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

http://php.he.net/manual/en/ini.core.php#ini.memory-limit
Prior to PHP 5.2.1, in order to use this directive it had to be
enabled at compile time by using -enable-memory-limit in the configure
line.

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



Re: [PHP] Can I create flash via php?

2007-11-28 Thread Dee Ayy
Go back and read Warren's reply to you.

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



[PHP] date CDT CST UTC

2008-03-26 Thread Dee Ayy
Today, we are in Central Daylight Time "CDT" in Dallas, Texas, USA -- yes?

"date" on:
mail server: Wed Mar 26 11:45:00 CDT 2008 (CORRECT)
web server: Wed Mar 26 11:45:00 CST 2008
Note CDT versus CST.

"date -u"
mail server: Wed Mar 26 16:45:00 UTC 2008 (CORRECT at 11:45 AM local
time [Central Daylight Time (CDT) is UTC minus 5 hours])
web server: Wed Mar 26 17:45:00 UTC 2008

>From a test CLI script and from the web page test script on the web server,
echo date("Y-m-d H:i:s");
returns "2008-03-26 11:45:00".

An application PHP script ran on the web server, uses date("Y-m-d
H:i:s") to generate a timestamp to put in the body of an email sent
with PHP mail().
I think the mail() command on the web server forwards to the actual
mail server (but I am not sure -- how do I verify this?).

An example email (only after we switched to daylight savings time on
3/10 and I'm sure our admin had to manually update the clock) shows
the email header as Mon, 10 Mar 2008 14:35:44 -0500
and in the email client without looking at raw source as Date: March
10, 2008 2:35:44 PM CDT, but the body of the email (which used PHP
date("Y-m-d H:i:s")) shows 2008-03-10 13:35:44.
Note 13 instead of 14.

I've asked the admin to make sure the web server reports CDT (I'm
still waiting), but it seems strange that date("Y-m-d H:i:s") from the
test scripts already shows the correct info before this change.

Any thoughts?

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



Re: [PHP] date CDT CST UTC

2008-04-07 Thread Dee Ayy
>  Daylight Savings Time must die!

Oh, by the way, thanks for your reply.

So last night my clock went forward an hour on this cool DST-aware
dual alarm clock radio I bought in 1999.  Apparently DST rules have
changed http://en.wikipedia.org/wiki/Year_2007_problem so now my clock
isn't as cool anymore.  Luckily I found out before I went to sleep.

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



[PHP] Source Code Analysis

2008-10-22 Thread Dee Ayy
Is there a tool that can analyze PHP source code and detect if the
code is relying on register_globals still being on?  Perhaps detecting
if a variable has not been initialized within the code?

These are my specific needs, but I'm also interested in general SCA
tools and features.

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



Re: [PHP] Source Code Analysis

2008-10-22 Thread Dee Ayy
Thanks regarding the error_reporting.  I may have to go this route for
this specific issue.

I was hoping a source code analyzer would report the same type
problem, perhaps much faster than Robert's method, and without having
a human attempt to test all functionality of the various PHP apps on
old servers.  I'm looking for automated methods where automated test
cases do not already exist.  And not only for this specific issue.

Also, I'm only assuming that finding uninitialized variables would
address this specific problem.  A SCA may test for problems I have not
considered.

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



[PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Dee Ayy
PHP Version 5.1.6
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/htmlfile.html"); 
//WORKS
$contents = file_get_contents("http://user:[EMAIL PROTECTED]/some/path/htmlfile
with spaces.html"); //FAILS(1)
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/nonhtmlfile.ext"); 
  //WORKS
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/nonhtmlfile
with spaces.ext");  //FAILS(2)
$contents = file_get_contents(urlencode("http://user:[EMAIL 
PROTECTED]/some/path/eitherfile
with spaces.ext")); //FAILS BUT I DON'T REALLY CARE
$contents = file_get_contents(urlencode("http://user:[EMAIL 
PROTECTED]/some/path/eitherfilenospaces.ext")); //FAILS
BUT I DON'T REALLY CARE
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/".urlencode("eitherfile
with spaces.ext")); //FAILS WTF(1)
$contents = file_get_contents("http://user:[EMAIL 
PROTECTED]/some/path/eitherfile+with+spaces.ext");//FAILS
WTF(2)


Warning:
file_get_contents(http://[EMAIL PROTECTED]/some/path/eitherfile+with+spaces.ext)
[function.file-get-contents]:
failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in
/the/script/index.php on line (the file_get_contents
line)

Yes, the files are there.

file_get_contents docs:
Note: If you're opening a URI with special characters, such as spaces,
you need to encode the URI with urlencode().

WTF?!?!
How do I get FAILS(1) and FAILS(2) to work, in light of FAILS WTF(1)
and FAILS WTF(2)?

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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Dee Ayy
My bad.

I urlencoded the %20 LOL

%20 works.

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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Dee Ayy
On Mon, Nov 10, 2008 at 5:26 PM, Dee Ayy <[EMAIL PROTECTED]> wrote:
> My bad.
>
> I urlencoded the %20 LOL
>
> %20 works.
>

And just in time to go home.
Thanks.

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



Re: [PHP] file_get_contents urlencode spaces: yeah right?

2008-11-10 Thread Dee Ayy
> Have you tried to output the result of urlencode and paste the whole
> thing in a browser to make sure that it works?

The FF 3.0.3 browser likes
http://user:[EMAIL PROTECTED]/some/path/eitherfile with spaces.ext
and
http://user:[EMAIL PROTECTED]/some/path/eitherfile%20with%20spaces.ext
but NOT
http://user:[EMAIL PROTECTED]/some/path/eitherfile+with+spaces.ext
like Jim Lucas said.

Any thoughts on agent or server settings?

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