Re: [PHP] [? BUG ?] weird thing;downloading from a php script stops at exactly 2.000.000 bytes

2005-06-11 Thread Catalin Trifu
Hi,

There is not a big speed difference between the two.
The only thing is that it was frustrating to find out the limitations
on readfile.
I used it before with large files and it was ok; only to find out now
that on 5.0.4 it doesn't work as it used to.
As php manual states readfile should be the way to spit a file out
the wire.
btw:
$fp = fopen('somefile');
fpassthru($fp);
is also stopping at 2.000.000 bytes, which definetely drives me
to think there is a bug somewhere.


Catalin


Richard Lynch wrote:
> On Thu, June 9, 2005 4:12 pm, Catalin Trifu said:
> 
>>  Tried it and it works indeed, but it's quite annoying to make such
>>tricks
>>and is not the best solution either; fopen and fread are "expensive".
>>   I can't say if it's a bug in PHP or some config option.
> 
> 
> You may want to benchmark the difference between readfile and fopen/fread
> for a 1.9M file.
> 
> If it ain't much, don't worry about it.
> 
> One posible work-around:
> 
> `cat filename`;
> 
> This MIGHT be cheaper than fopen/fread -- Or not, since it has to build a
> shell of some kind, I think.
> 
> PS File a bug report, if you haven't already.
> 

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



[PHP] Returned mail: Data format error

2005-06-11 Thread Mail Administrator
ALERT!

This e-mail, in its original form, contained one or more attached files that 
were infected with a virus, worm, or other type of security threat. This e-mail 
was sent from a Road Runner IP address. As part of our continuing initiative to 
stop the spread of malicious viruses, Road Runner scans all outbound e-mail 
attachments. If a virus, worm, or other security threat is found, Road Runner 
cleans or deletes the infected attachments as necessary, but continues to send 
the original message content to the recipient. Further information on this 
initiative can be found at http://help.rr.com/faqs/e_mgsp.html.
Please be advised that Road Runner does not contact the original sender of the 
e-mail as part of the scanning process. Road Runner recommends that if the 
sender is known to you, you contact them directly and advise them of their 
issue. If you do not know the sender, we advise you to forward this message in 
its entirety (including full headers) to the Road Runner Abuse Department, at 
[EMAIL PROTECTED]



file attachment: Text.cmd

This e-mail in its original form contained one or more attached files that were 
infected with the [EMAIL PROTECTED] virus or worm. They have been removed.
For more information on Road Runner's virus filtering initiative, visit our 
Help & Member Services pages at http://help.rr.com, or the virus filtering 
information page directly at http://help.rr.com/faqs/e_mgsp.html. 
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Howto implement atomical actions

2005-06-11 Thread Andy Pieters
Hi all

I am developing a web interface to patch a program.  The user uploads the 
patch and after uncompressing and verification of signature, the update 
should take place.  However I do not want users to be able to start an update 
and then abort the process by stopping to load the page.  

I imagine that by calling a program externally from php that it would be 
possible but there are limitations because of the distribution.   The systems 
are installed on php+mysql+apache servers but no shell access is granted.

I greatly appreciate help in this matter.


With kind regards


Andy

-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C$(+++) UL>$ P-(+)>++
L+++>$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>$@ h++(*) r-->++ y--()>
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--


pgp3YPb0noml1.pgp
Description: PGP signature


Re: [PHP] Re: Getting help on using the PHP lists

2005-06-11 Thread Paul Waring
On 6/10/05, Leila Lappin <[EMAIL PROTECTED]> wrote:
> Have you tried changing the subscription options through the website?  I
> think you can do it by just checking the type of list you're interested in
> subscribing.

I don't know about other people, but I've had lots of problems trying
to subscribe through the web site - I never got the confirmation
emails and in the end I just subscribed via email using
php-general-subscribe.

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Howto implement atomical actions

2005-06-11 Thread Chris Shiflett

Andy Pieters wrote:

I am developing a web interface to patch a program. The user uploads
the patch and after uncompressing and verification of signature, the
update should take place. However I do not want users to be able to
start an update and then abort the process by stopping to load the
page.


You can ignore user aborts:

http://php.net/ignore_user_abort

This has very little to do with atomic actions, but maybe it answers 
your question. :-)


Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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



Re: [PHP] using require

2005-06-11 Thread Christian Heinrich

Hi,

this depends on which connection-function you've used. If you've decided 
to use pg_pconnect(), there is just one connection.
If you use pg_connect, everytime a new connection is established (and 
after finishing the script, it's closed though)


HTH
Christian


hi all,


i have my web site working something like this: in every php script i have require(auth.php). this auth.php has my connection to my postgresql server and database along with some other stuff i need for the user to be authenticated to my web site. when i log on, this auth.php connects to the dbserver and checks if my username and password are stored and then i go to a home page. my connection is stored in $dbh. 
what happens when i start moving through all these web pages (php scripts), each requires auth.php, with respect to the connection? is a new connection established for every web page i go into that uses my $dbh for querying purposes or is it the same connection i originally made when i first logged into the web site?



any info will be highly appreciated!!


thanx.
 



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



[PHP] news php 5.0.5/5.1

2005-06-11 Thread mbneto
Hi,

I've looked at php.net but could not find info regarding if/when are
we going to have further 5.0.x versions and what will change in php
5.1.

Any pointers (besides the php-devel) ?

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



[PHP] Re: Howto implement atomical actions

2005-06-11 Thread Manuel Lemos

Hello,

on 06/11/2005 10:46 AM Andy Pieters said the following:
I am developing a web interface to patch a program.  The user uploads the 
patch and after uncompressing and verification of signature, the update 
should take place.  However I do not want users to be able to start an update 
and then abort the process by stopping to load the page.  


You can try using flock in exclusive mode on a lock file of a fixed file 
name.


--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html

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



Re: [PHP] fwrite/fopen

2005-06-11 Thread Mister Jack
fwrite failed for "quota disc exceeded", so I end up with empty file.

the algorithm is something like : 

if (! $fp = @fopen($config['pagecachedir'].$path.$tmp_value,'wb')) {
 $errorLog .= "Writing problem for ".$config['pagecachedir'].
"$path$tmp_value!\n";
   } else {
  $txt_length = strlen($txt);
  if (@fwrite($fp,$txt,$txt_length) != $txt_length) {
  $errorLog .= "Writing problem in file !\n";
  @fclose($fp);
  @unlink($config['pagecachedir'].$path.$tmp_value);
  } else {
  //everything is OK
   @fclose($fp);
   }


On 6/11/05, Richard Lynch <[EMAIL PROTECTED]> wrote:
> 
> You would probably have to fclose it before you can unlink it, and if it's
> fargled enough that fwrite failed, you probably can't fclose it
> successfully...
> 
> Your best bet would be to put the filename into a database table, then run
> a cron job that deletes all the files in that table, and only takes them
> out of the table if they are successfully deleted.
> 
> Course, you then want to be sure you have UNIQUE filenames so you don't
> delete a good file later.
> 
> 
> 
> On Fri, June 10, 2005 4:03 pm, Mister Jack said:
> > Hi,
> >
> > I having a problem at the moment, I open a file, try to write in it,
> > and then remove the file if the write goes wrong (if write count != of
> > my initial buffer length). But I still get some empty file (and then a
> > blank page). Could possibly fopen (with a 'wb' flag, and under freebsd
> > 4.11) failed but still create that empty file ?
> >
> > Where could I get more info on the behavior of fopen/fwrite ?
> >
> > Thanks for your help.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> --
> Like Music?
> http://l-i-e.com/artists.htm
> 
>

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



Re: [PHP] Howto implement atomical actions

2005-06-11 Thread Richard Lynch
On Sat, June 11, 2005 6:46 am, Andy Pieters said:
> I am developing a web interface to patch a program.  The user uploads the
> patch and after uncompressing and verification of signature, the update
> should take place.  However I do not want users to be able to start an
> update
> and then abort the process by stopping to load the page.
>
> I imagine that by calling a program externally from php that it would be
> possible but there are limitations because of the distribution.   The
> systems
> are installed on php+mysql+apache servers but no shell access is granted.

Perhaps it would be best to take PHP out of the picture entirely after the
upload.

For example, upload to a temporary directory, and, as your last PHP step,
use http://php.net/rename to move the uploaded file to a "to_be_installed"
directory.

Then you can have cron job 2 minutes that installs anything it finds in
that directory.

At that point, nothing the user can do can interfere.

That wouldn't necessarily make the operation atomic...

What makes a "patch" atomic?...

You'd be looking at something like subversion for that, I should think...

I don't think even tar -xzf guarantees atomicity, but I dunno.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Is there a big speed difference...

2005-06-11 Thread Richard Lynch
On Thu, June 9, 2005 10:06 am, Brian Dunning said:
>
> On Jun 9, 2005, at 9:48 AM, bruce wrote:
>
>> bian...
>>
>> giave a psuedocode example of what you're trying to compare.. i
>> think i know
>> what you're asking, but i want to be sure..
>
> OK, this is *pseudocode* remember...  :)
>
> Is either of these SIGNIFICANTLY slower:
>
> === Example 1 ===
>
> while(loops 5000 times)
> {
>  include(myfunction.php);

Assuming there is not function in myfunction.php, and it's just raw
PHP/HTML code...

This is slower, UNLESS you have something like Zend Cache (or whatever
it's called now) *AND* that is configured to not check filemtime on every
hit...

At that point, this could probably be faster.

> }
>
> ...where myfunction.php contains some code.
>
> === Example 2 ===
>
> include_once(myfunction.php);
> while(loops 5000 times)
> {
>  myfunction(xxx);
> }
>
> ...where myfunction.php defines the function myfunction().

The overhead for a function is not zero, but it also depends a little bit
on what arguments you are passing to the function.

Have you actually tried it yet, either way?

Cuz I suspect you are worrying over a lot of nothing...

Try it the cleanest most maintainable way.

Worry about performance after it fails.

"Look before you leap" is good advice, but not when don't have enough data
to "look" -- Find out if it's "too slow" then make an informed decision.

Especially for 6 lines of code.

5,000 iterations isn't gonna kill you, I'll bet.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] http to https session problem

2005-06-11 Thread Richard Lynch
On Thu, June 9, 2005 7:43 am, Joe Harman said:
> I am having a little problem with users keeping the same session id
> when they go from http to https... is there a work around for this...
> I don't appear to have this problem when using openSSL just when the
> site has it's own certificate.
>
> should I store the session id in a cookie??? or is there another way or
> setting

A Cookie would be a fine way to pass it, or in the URL.

You probably have a very clear user-interaction-path into and out of SSL
anyway, so you'd only be changing a couple lines of code, in a
well-designed application.

Essentially, it's probably best to think of your HTTP and HTTPS as two
totally different servers, with nothing in common, even when, in fact,
they are the same server with the same files in the same exact hard drive
and all that.

Some hosts split HTTPS off on another box ; Some don't.

If you're ready for the split, you're more mobile.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] http to https session problem

2005-06-11 Thread Joe Harman
On 6/11/05, Joe Harman <[EMAIL PROTECTED]> wrote:
> On 6/11/05, Richard Lynch <[EMAIL PROTECTED]> wrote:
> > On Thu, June 9, 2005 7:43 am, Joe Harman said:
> > > I am having a little problem with users keeping the same session id
> > > when they go from http to https... is there a work around for this...
> > > I don't appear to have this problem when using openSSL just when the
> > > site has it's own certificate.
> > >
> > > should I store the session id in a cookie??? or is there another way or
> > > setting
> >
> > A Cookie would be a fine way to pass it, or in the URL.
> >
> > You probably have a very clear user-interaction-path into and out of SSL
> > anyway, so you'd only be changing a couple lines of code, in a
> > well-designed application.
> >
> > Essentially, it's probably best to think of your HTTP and HTTPS as two
> > totally different servers, with nothing in common, even when, in fact,
> > they are the same server with the same files in the same exact hard drive
> > and all that.
> >
> > Some hosts split HTTPS off on another box ; Some don't.
> >
> > If you're ready for the split, you're more mobile.
> >
> > --
> > Like Music?
> > http://l-i-e.com/artists.htm
> >
> >
> 
> Yep... i am going to have to keep something in a cookie to identify
> the user if they come back to the site... I was trying to avoid the
> whole P3P things with cookies... not that it's hard... it's jsut a
> pain in the butt :o)
> 
> Thanks! Cheers!
> 

Yep... i am going to have to keep something in a cookie to identify
the user if they come back to the site... I was trying to avoid the
whole P3P things with cookies... not that it's hard... it's jsut a
pain in the butt :o)

Thanks! Cheers!
-- 
Joe Harman
-
Do not go where the path may lead, go instead where there is no path
and leave a trail. - Ralph Waldo Emerson

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



Re: [PHP] The "goto" discussion on the Internals List

2005-06-11 Thread Richard Lynch
On Thu, June 9, 2005 6:49 am, Jochem Maas said:
> Richard Lynch wrote:
>> And, for the record, *I* sure as hell don't want to see a GoTo in PHP.
>
> whats your take on ifsetor()?, personally I would like to see it. I think
> its a great way to teach newbies about checking vars before use (if
> nothing
> else)

This probably doesn't belong on this list, but I was asked here, so I'll
answer here. [Plus I'm not on the internals list.]  Re-direct followups
off-list or back to -internals or ...

I don't think ifsetor is going to encourage newbies to check variables
before use.

In fact, I think it's just going to confuse newbies with one more extra
way to do the same thing.

Only turning E_ALL on by default (which I asked for in PHP 4.0 and PHP 5.0
and will ask again for PHP 6.0 and 7.0 and 8.0 ...) will actually educate
newbies that they are doing something fundamentaly "wrong" in their
Programming to use variables they haven't initialized.
Spare the rod, spoil the child.
Spare the E_NOTICE, spoil the newbie.

There's currently NOTHING other than 10,000 pages of docs to tell a newbie
they NEED to check vars.

The quickie examples everybody rattles off don't check vars.

The MANUAL doesn't even consistently use good programming practices in its
examples -- though it gets better over time, mostly.

Then people want to "simplify" the examples down to just the
function/feature in question, and we go back to Bad Code.

ifsetor doesn't really seem to add much value to me.

$foo $: $default;
$foo = ifsetor($default);
$foo = isset($foo) ? $foo : $default;

What?  15 to 20 characters, depending on the ifsetor syntax?

I'll pass.

I don't think ifsetor adds enough value to the language to be worth the
confusion of having a second way to do the same thing in ~20 more
characters, personally.

[shrug]

If it gets added, I'll probably never even bother to use it.  I've been
typing the isset() ? : construct for so many years, that I'm not gonna
switch for the sake of a few less keystrokes.  Sorry.

I certainly don't want to be the one answering the 10,000 emails to this
list:

Which is better? isset() ? : or ifsetor?

Which one is faster?

Why are there two ways to do this?

What's this ifsetor thing? / What's this isset() ? : thing?

And then the arguments between the experts (self included) over which one
is "better" and why.

Cuz I'll tell you right here, right now, that's one consequence of this
proposed change.  10,000 more emails to php-general in the next year or
two, just about 'ifsetor'.

My vote, if anybody cares to count it:

-1

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Compilation trouble on OS X

2005-06-11 Thread Richard Lynch
On Thu, June 9, 2005 5:32 am, Marcus Bointon said:
> I've been beating my head against this  - I've done this so many
> times on BSD and Linux but I just can't get PHP 5.0.4 to compile on
> OS X. Even the simplest case:
>
> ./configure
> make
>
> fails with:
>
> /usr/bin/ld: Undefined symbols:
> _mbstring_globals
> _php_mb_encoding_translation

I vaguely recall an issue with mb_* where people saw this nifty new
feature and turned it on having no idea what it was, and, well, they
didn't really want that feature turned on at all...

This could be the same thing.

Or not.

Try ./configure --without-mbstring

Only you'll have to check ./configure --help | grep mb

and see how to actually turn it off.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] weird thing; downloading from a php script stops at exactly 2.000.000 bytes

2005-06-11 Thread Richard Lynch


I just noticed the eaccelerator bit in this thread.

Just disabling eaccelerator isn't the same as not compiling it in in the
first place...

Try that before reporting a bug to http://bugs.php.net

On Thu, June 9, 2005 1:59 am, Catalin Trifu said:
>   Hi,
>
>I installed php5 using the configue below. I tried with apache2 as well
> and same things.
>
> './configure' '--prefix=/usr/local/php5'
> '--with-apxs=/usr/local/apache/bin/apxs' '--disable-cgi'
> '--with-config-file-path=/etc/php5' '--with-dom' '--with-gd'
> '--enable-sockets' '--enable-exif'
> '--with-freetype2' '--with-freetype-dir=/usr/include/freetype2'
> '--enable-gd-native-ttf'
> '--with-zlib-dir=/usr' '--with-curl' '--with-curlwrappers' '--enable-ftp'
> '--with-mysql=/usr'
> '--with-xsl' '--with-libxml-dir=/usr'
>
>I have a script which generates a temporary catalog file, which is
> generated correctly having
> 4.7MB on disk.
>Then I push up the wire with readfile($filname):
>
>header("Content-Type: text/csv");
>header("Content-Disposition: attachment; filename=somfilename.csv");
>header("Content-Length: ". filesize($file));
>
>readfile($file);
>
>
>As expected the browser starts the download and reports it is expecting
> a file of 4.7MB.
>However, the download stops at 2.000.000 bytes no matter what browser I
> use (normally i use
> Firefox on Linux), no matter if php runs on apache2 or apache1.3
>
>Is there some php config option I missed ?
>Where could this come from ?
>
>
> Thanks,
> Catalin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] output buffering / output compression

2005-06-11 Thread Richard Lynch
On Thu, June 9, 2005 12:22 am, Paul Birnstihl said:
> I have recently set up a machine with PHP with both buffering and
> compression turned on. Some of the pages being served include up to 3MB
> of HTML.
>
> Can someone explain the benefit(s) of setting these ini directives to
> values (ie. larger than 4kb) rather than "On" ?
>
> I've played around with it as I thought it might speed things up by
> using a bigger buffer etc. but the only difference I noticed is a big
> jump in memory usage.

If you somehow manage to spew out more than 3MB before you try to call
header() or session_start() or whatever, then the buffer got dumped, and
it's too late.

At least, that's how I think it would work...

But I never turn buffering on anyway, so what do I know?

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Converting a query for use in a form

2005-06-11 Thread Richard Lynch
On Wed, June 8, 2005 9:59 pm, [EMAIL PROTECTED] said:
> I hope you can all help me. I want to take the information I get from a
> query and use it is a form as a dropdown select box. For example I want to
> pull the colors from a table and list them in a drop down box and then
> when
> a user selects a color it will pass the colorID for use in writing to
> another table. I hope that comes across the way I mean. :-( Anyway, I
> think
> I used to use something called wddx with java to do this when I was coding
> in ColdFusion.

\n";
  while (list($c) = mysql_fetch_row($colors)){
//Cheap and easy data scrubbing:
if ($c == $color) $kosher = true;
$selected = $c == $color ? 'SELECTED' : '';
echo "$c\n";
  }
  echo "\n";
  //If they didn't pick a valid color, make it white
  if (!$kosher) $color = 'white';
  //Or log their IP
  //Or raise a Red Alert.
  //Or Whatever.
?>

-- 
Like Music?
http://l-i-e.com/artists.htm

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