php-general Digest 1 Jan 2005 21:51:33 -0000 Issue 3203

Topics (messages 205450 through 205460):

Re: handling large files w/readfile
        205450 by: Sebastian
        205453 by: Curt Zirzow
        205456 by: Robin Getz

[ANN] Kwartz-php 0.3.0 - a template system for PHP, Ruby, and Java
        205451 by: Makoto Kuwata

PHP :: SSH2 ??
        205452 by: Pari Purna Chand Nannapaneni
        205455 by: M. Sokolewicz

php vs java....
        205454 by: Lewis LaCook
        205459 by: Greg Donald

Re: phpMyAdmin w/ winXP - IIS w/PHP 4.3 w/mysql 4.1.8
        205457 by: GH
        205458 by: Greg Donald
        205460 by: GH

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 ---
yea. all the files aren't 100MB though.. some are 2mb (even less) while some
files are over 300MB as well.
so, does this need to be adjusted depending on the filesize?

thanks.

----- Original Message ----- 
From: "Rory Browne" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Sebastian" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Friday, December 31, 2004 10:24 PM
Subject: Re: [PHP] handling large files w/readfile


> I'd go with Richards Basic idea, but if you're outputting a 100Mb file
> I'd use a hell of a lot bigger chunks than 4K. With the syscall and
> loop overhead, i'd go with at least half a megabyte, or more likely
> 2Mb depending on your amount of memory.
>
> To do this you'd change Richards
>
> echo fread($fp, 4096); //4K chunks
>
> to
>
> echo fread($fp, 2048000); // ~2Mb chunks (actually 2000KB but couldn't
> be bothered counting, and 2Mb is an arbitory figure anyway)
>
> Just make sure you don't have output buffering on.
>
>
> On Fri, 31 Dec 2004 15:17:51 -0800 (PST), Richard Lynch <[EMAIL PROTECTED]>
wrote:
> > Sebastian wrote:
> > > i'm working on a app which output files with readfile() and some
headers..
> > > i read a comment in the manual that says if your outputting a file php
> > > will
> > > use the same amount of memory as the size of the file. so, if the file
is
> > > 100MB php will use 100MB of memory.. is this true?
> > >
> > > if it is, how can i work around this?
> >
> > I don't know if it's STILL true (or ever was) that readfile() would suck
> > the whole file into RAM before spitting it out...  Seems real unlikely,
> > but...
> >
> > At any rate, you can simply do:
> >
> > $file = 'whatever.mb';
> > $fp = @fopen($file, 'r') or trigger_error("Could not read $file",
> > E_USER_ERROR);
> > while (!feof($fp)){
> >   echo fread($fp, 4096); //4K chunks
> > }
> >
> > http://php.net/fopen http://php.net/fread http://php.net/feof
> >
> > --
> > 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
> >
> >
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--- End Message ---
--- Begin Message ---
* Thus wrote Richard Lynch:
> Sebastian wrote:
> > i'm working on a app which output files with readfile() and some headers..
> > i read a comment in the manual that says if your outputting a file php
> > will
> > use the same amount of memory as the size of the file. so, if the file is
> > 100MB php will use 100MB of memory.. is this true?
> >
> > if it is, how can i work around this?
> 
> I don't know if it's STILL true (or ever was) that readfile() would suck
> the whole file into RAM before spitting it out...  Seems real unlikely,
> but...

Never was and still isn't.

using either readfile or fpassthru is the best route.


Curt
-- 
Quoth the Raven, "Nevermore."

--- End Message ---
--- Begin Message ---
Curt Zirzow wrote:
* Thus wrote Richard Lynch:
> Sebastian wrote:
> > i'm working on a app which output files with readfile() and some headers..
> > i read a comment in the manual that says if your outputting a file
> > php will use the same amount of memory as the size of the file. so,
> > if the file is 100MB php will use 100MB of memory.. is this true?
>
> I don't know if it's STILL true (or ever was) that readfile() would
> suck the whole file into RAM before spitting it out... Seems real
> unlikely, but...


Never was and still isn't.

using either readfile or fpassthru is the best route.

All I know that I am hosting a GForge site, and if I leave the download.php code as is, I will send up with apache processes that are 200+Meg. (the size of my download files).
http://gforge.org/plugins/scmcvs/cvsweb.php/gforge/www/frs/download.php?rev=1.6;content-type=text%2Fplain;cvsroot=cvsroot%2Fgforge


(which uses readfile)

I have tried fpassthru - same thing.

I have even tried:

$fp = fopen($sys_upload_dir.$group_name.'/'.$filename,'rb');
while (!feof($fp)) {
   $buff = fread($fp, 4096);
   print $buff;
}
fclose ($fp);

and I get the same thing. The only thing that seems to work is:

Header("Location: ".$html_pointer_to_fp);

which lets apache do the downloading.

I would do a apache_child_terminate, but the function does not seem to be available to me (see my previous question about this).

Any thoughts, or suggestions, I am open to try.

My next experiment is:
============================
var $buff;
while (!feof($fp)) {
$buff = fread($fp, 4096);
print $buff;
}
unset($buff);
fclose ($fp);
============================
Hopefully that will make sure that the var $buff is only created once, and that the memory is cleared after the function is done.


-Robin
--- End Message ---
--- Begin Message ---
Hi all, A HAPPY NEW YEAR!

I'm pleased to announce the release of Kwartz-php 0.3.0.
  http://www.kuwata-lab.com/kwartz-php

Kwartz-php is a template system which is available with multi
programming language (PHP, Ruby and Java).
And it is the first template system that realized the concept of
'Separation of Presentation Logic and Presentaion data' (SoPL/PD).

It is available to separate the presentation layer from the
main program with any template system. In addition, Kwartz-php
enables you to separate the presentation logics (iteration and
conditional branching) from the presentation data (HTML file).


Features:
  * Separates presentation logic from presentation data.
  * Runs very fast
  * Supports multiple programing languages (PHP/Ruby/Java)
  * Doesn't break HTML design at all
  * Handles any text file
  * Supports Auto-Sanitizing and Partial-Sanitizing


Example:

  * Presentation Data (example.html)
      - There is no iteration nor conditional branching
        in the presentation data file.
    --------------------
    <table>
      <tr id="mark:values">
        <td>@{$var}@</td>
      </tr>
    </table>
    --------------------
  
  * Presentation Logic (example.plogic)
      - There is no HTML tags in the presentation logic file.
    --------------------
    ## Re-define an element
    element values {              ## element
      foreach ($list as $var) {
        @stag;                    ## start tag
        @cont;                    ## content
        @etag;                    ## end tag
      }
    }
    --------------------

  * Compile
      - Generate an output script from presentation data
        and presentation logic.
    --------------------
    $ kwartz-php           -p example.plogic example.html > example.php
    
    $ kwartz-php -l eruby  -p example.plogic example.html > example.rhtml
    
    $ kwartz-php -l jstl11 -p example.plogic example.html > example.jsp
    --------------------

  * Output Script
    (PHP)
    --------------------
    <table>
    <?php foreach ($list as $var) { ?>
      <tr>
        <td><?php echo $var; ?></td>
      </tr>
    <?php } ?>
    </table>
    --------------------

    (eRuby)
    --------------------
    <table>
    <% for var in list do %>
      <tr>
        <td><%= var %></td>
      </tr>
    <% end %>
    </table>
    --------------------

    (JSTL)
    --------------------
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
    <table>
    <c:forEach var="var" items="${list}">
      <tr>
        <td><c:out value="${var}" escapeXml="false"/></td>
      </tr>
    </c:forEach>
    </table>
    --------------------
    
    The above examples shows:
     * Presentation data (= HTML file) doesn't contain any logics.
     * Presentation logic file doesn't contain any data.
     * These are separated from the main program.
     
    The command-line option '-e' escapes the HTML special chars
    with 'htmlspecialchars()' in PHP, 'CGI::escapeHTML()' in eRuby,
    and '<c:out/>' tag without 'escapeXml="false"' in JSTL.


Web Page:
  http://www.kuwata-lab.com/kwartz-php

Download:
  https://www.kuwata-lab.com/kwartz-php/download.html

Users Guide:
  http://www.kuwata-lab.com/kwartz-php/users-guide.en.html

Reference Manual:
  http://www.kuwata-lab.com/kwartz-php/reference.en.html

Changes from 0.2.0:
  * [enhance] support new functions (list_length(), str_toupper(), etc)
  * [enhance] support JSTL 1.1
  * [change]  indent format of output script is changed
  * [bugfix]  some bugs are fixed
  see http://www.kuwata-lab.com/kwartz-php/ChangeLog.html for details.


I hope you'd like it.

--
regards,
kwatch

# [off topic]
# I have submitted Kwartz-php to the Zend PHP5 contest, but ignored.
# I have also submitted the Code/App Gallery, but ignored again. Sol...

--- End Message ---
--- Begin Message ---
Can anybody give me a small example on using 
ssh2 functions ( http://pecl.php.net/package/ssh2 ).

I want to execute a command on the remote machine and 
want to get the ouput into a phpvariable.

Here is my php code ... 
<?php
$connection = ssh2_connect('127.0.0.1', 22);
ssh2_auth_password($connection, 'root', 'myrootpassword');
$stream = ssh2_exec($connection, 'uptime');
echo $stream;
?>

I'm getting some "Resource id #5" as output.
What does this mean. How to get the actual output of my remote command.

I'm using PHP-4.3.10

best regards,
/Chandu

--- End Message ---
--- Begin Message --- Pari Purna Chand Nannapaneni wrote:
Can anybody give me a small example on using ssh2 functions ( http://pecl.php.net/package/ssh2 ).

I want to execute a command on the remote machine and want to get the ouput into a phpvariable.

Here is my php code ... <?php
$connection = ssh2_connect('127.0.0.1', 22);
ssh2_auth_password($connection, 'root', 'myrootpassword');
$stream = ssh2_exec($connection, 'uptime');
echo $stream;
?>


I'm getting some "Resource id #5" as output.
What does this mean. How to get the actual output of my remote command.

I'm using PHP-4.3.10

best regards,
/Chandu

that is because it returns a stream (as is explained in the manual (CVS). However, the docs haven't been updated online yet, so that's why you can't find em...). To read from the stream, I *guess* you could use any normal stream-reading function. eg. fread() or fget().


trying to echo  a resource, will yield just that... 'Resource Id #n'.

$connection = ssh2_connect('127.0.0.1', 22);
ssh2_auth_password($connection, 'root', 'myrootpassword');
$stream = ssh2_exec($connection, 'uptime');
while(!feof($stream)) {
   $var .= fread($stream, 1024);
}

then you should have all in the $var.

hope that helps,
- Tul

--- End Message ---
--- Begin Message ---
...just looking for opinions: will PHP eclipse (IS PHP
eclipsing) Java? 

bliss
lewis lacook

=====


***************************************************************************

Lewis LaCook -->Poet-Programmer|||http://www.lewislacook.com/||| 

Web Programmer|||http://www.corporatepa.com/||| 

XanaxPop:Mobile Poem Blog-> http://www.lewislacook.com/xanaxpop/ 

Collective Writing Projects--> The Wiki--> http://www.lewislacook.com/wiki/ 
Appendix M ->http://www.lewislacook.com/AppendixM/






                
__________________________________ 
Do you Yahoo!? 
Send holiday email and support a worthy cause. Do good. 
http://celebrity.mail.yahoo.com

--- End Message ---
--- Begin Message ---
On Sat, 1 Jan 2005 10:07:20 -0800 (PST), Lewis LaCook <[EMAIL PROTECTED]> wrote:
> ...just looking for opinions: will PHP eclipse (IS PHP
> eclipsing) Java?

I'd like to see threads added to PHP.  Java has them, and Perl does as
well.  And I'm sure there are others that I don't know about.


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

--- End Message ---
--- Begin Message ---
It would be nice if phpMyAdmin would kindly note that on their website... 

Also, when I run a phpInfo()... it says i have the 3.23.49  could this
be a contributing factor?

On Sat, 1 Jan 2005 15:55:27 +0700, Willy Sudiarto Raharjo
<[EMAIL PROTECTED]> wrote:
> > Has anyone had any problems installing phpMyAdmin with the above
> > configuration? I get an error about the mySql client and
> > authentication methods? MySQL Error: 1251 : Client does not support
> > authentication protocol requested by server
> 
> MySQL 4.1.x is using a different authentication protocols so it may break
> phpmyadmin functionality. Use 4.0.x if you want to use phpmyadmin clearly or
> maybe you should wait for the next release
> 
> --
> Willy Sudiarto Raharjo
> Registered Linux User : 336579
> Public-key : http://www.informatix.or.id/willy/public-key.txt
> Blog : http://willysr.blogspot.com
> OOo Documentation Project (ID) : http://project.informatix.or.id
> 
>

--- End Message ---
--- Begin Message ---
On Sat, 1 Jan 2005 14:15:27 -0500, GH <[EMAIL PROTECTED]> wrote:
> It would be nice if phpMyAdmin would kindly note that on their website...

http://www.phpmyadmin.net/documentation/

<snip>
Note: phpMyAdmin's MySQL 4.1 support is experimental! 
</snip>


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

--- End Message ---
--- Begin Message ---
does anyone know of a simular tool that will work/has 4.1 support?

thanks


On Sat, 1 Jan 2005 14:33:05 -0600, Greg Donald <[EMAIL PROTECTED]> wrote:
> On Sat, 1 Jan 2005 14:15:27 -0500, GH <[EMAIL PROTECTED]> wrote:
> > It would be nice if phpMyAdmin would kindly note that on their website...
> 
> http://www.phpmyadmin.net/documentation/
> 
> <snip>
> Note: phpMyAdmin's MySQL 4.1 support is experimental!
> </snip>
> 
> --
> Greg Donald
> Zend Certified Engineer
> http://gdconsultants.com/
> http://destiney.com/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---

Reply via email to