php-general Digest 29 Sep 2008 07:58:34 -0000 Issue 5708

Topics (messages 281076 through 281080):

Re: Regular Expression Backreference in subpattern.
        281076 by: Nathan Rixham

Re: error warning while connecting to posgreSQL
        281077 by: Nathan Rixham

Re: Concatenating PDF using FPDI
        281078 by: Bastien Koert

Re: Questions regarding limits of processes launched by system, exec, passthru 
...
        281079 by: Bastien Koert
        281080 by: Valentin Schmid - ICSurselva AG

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 ---
Shiplu wrote:
Sorry The previous code was wrong,
Its the correct version,

$x = "a b;c d;e f;";
preg_match('/(?P<keys>\w) (?P<values>\w)/',$x,$m);
print_r($m);

Now I am using backrefrence \1 in in ?P option like (?P<\1>\d+).

and I got the error.


thought I best update for courtesy sake; I spent a good chunk of time on this yesterday, read all the regex stuff I could find, and the closest I could get was to use recursive sub patterns, however there was no way to make a named subpattern name (<keys>) be a backreference / variable.. ie <$1> <\1> <\\1> will never work.

even using this method you're still going to have to combine the two arrays to get what you want ($m['keys'] with $m['values'])

Regards & do let me know if you manage!

Nathan

ps: there may be something in the ?>&name syntax; I don't think so though..

--- End Message ---
--- Begin Message ---
Alain Roger wrote:
Hi,

i try to understand the error_reporting statement and to avoid all warning
or error messages.
for example i stop the postgresql service and i try to connect to it.
when error_reporting is set to E_ALL, i get the following warning :
*Warning*: pg_connect()
[function.pg-connect<https://192.168.1.2/se_admin/en/logon/function.pg-connect>]:
Unable to connect to PostgreSQL server: could not connect to server:
Connection refused (0x0000274D/10061) Is the server running on host
"localhost" and accepting TCP/IP connections on port 5432? in *
L:\Webserver\se\log\checklogin.php* on line *48*
Couldn't Connect:

but if i have the error_reporting set to 0, i only get my die message
"Couldn't connect".

i would like to know if i let the setting "E_ALL" do i have a way how to not
display the warning message to end users but to display only "Couldn't
connect" ?
in fact to have the same behavior as error_reporting set to 0.
thx.


additionally.. the @ operator (suppress errors)

@pg_connect(...) = no error displayed only die('message shown')

--- End Message ---
--- Begin Message ---
On Sun, Sep 28, 2008 at 3:33 AM, giga501 <[EMAIL PROTECTED]> wrote:

>
> Hi -
>
> I am trying to attach a pre-defined PDF to a file generated at runtime
> (invoice.pdf).
> I have attached the test.php that I used to concatenate 2 pdfs.
> http://www.nabble.com/file/p19709464/test.php test.php
>
> I have also verified that I have the latest version of FPDF and FPDI.
> However, here is the error I get on executing the file on my server (shared
> host using CPanel) :
> FPDF error: Unable to find xref table - Maybe a Problem with
> 'auto_detect_line_endings'
>
> The functionality works fine on my localhost (WAMPServer, WinXP), so I am
> wondering if there are any other server parameters to look at ?
>
> Any ideas on what is wrong here? Thanks in advance.
> --
> View this message in context:
> http://www.nabble.com/Concatenating-PDF-using-FPDI-tp19709464p19709464.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Its a setting in the php.ini file that may need to be changed. Line endings
change from Winblows to Unix/Linux servers, so it may need to be reset

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
On Sat, Sep 27, 2008 at 12:50 PM, Richard Lynch <[EMAIL PROTECTED]> wrote:

> memory_limit and time_limit are implemented down in the guts of the PHP
> interpreter; They are not magic.
>
> They can't do diddly when PHP is running some other binary...
> ________________________________________
> From: Thodoris [EMAIL PROTECTED]
> Sent: Saturday, September 27, 2008 8:24 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] Questions regarding limits of processes launched by
> system, exec,                passthru ...
>
> > Hello all,
> >
> > Is there a way to limit the memory consumption and / or the CPU
> > consumption of processes launched by the php functions system,
> > exec, passthru, proc_open and shell_exec?
> >
> > We use mod_php with an apache (mpm-prefork) on Linux.
> >
> > The following settings don't have any effect at all:
> > PHP:
> >   max_execution_time 30
> >   memory_limit 8M
> > Apache:
> >   RLimitCPU 30 30
> >   RLimitMEM 8388608 8388608
> >
> > The limits above do have effect on php-scripts (without system calls)
> > and on CGIs (as well on processes launched by CGIs).
> >
> > Any Ideas?
> >
> > Kind Regards
> > valli
> >
> >
> > PS: I tested it with the following two scripts:
> > system_memorytest.php
> > =====================
> > <html>
> > <head>
> >   <title>php-systemcall-memory test</title>
> > </head>
> > <body>
> >   php-systemcall-memory test<br>
> >   ... and here's the system call:<br>
> >   <pre>
> > <?php
> >    $cmd = '/usr/bin/perl -e \'
> >       $| = 1;
> >       print "start of the systemcall<br>\n";
> >       $s = "teststr_";
> >       while (1) {
> >          print "len=".length($s)."<br>\n";
> >          sleep(1);
> >          $s .= $s;
> >       }
> >    \'';
> >    print htmlspecialchars($cmd);
> > ?>
> >   </pre>
> > <?php
> >   ob_flush();
> >   flush();
> >   system($cmd);
> > ?>
> > </body>
> > </html>
> >
> >
> > system_timeouttest.php
> > ======================
> > <html>
> > <head>
> >   <title>php-systemcall-timeout test</title>
> > </head>
> > <body>
> >   php-systemcall-timeout test<br>
> >   ... and here's the system call:<br>
> >   <pre>
> > <?php
> >    $cmd = '/usr/bin/perl -e \'
> >       $| = 1;
> >       print "start of the systemcall<br>\n";
> >       $i = 0;
> >       while (1) {
> >          if (($i % 10000000) == 0) {
> >             print "i=".$i."<br>\n";
> >          }
> >          $i += 1;
> >       }
> >    \'';
> >    print htmlspecialchars($cmd);
> > ?>
> >   </pre>
> > <?php
> >   ob_flush();
> >   flush();
> >   system($cmd);
> > ?>
> > </body>
> > </html>
> >
> >
> >
> >
> >
>
> Well as far as I know there are already memory limits to every php
> process and you define this in php.ini. I recently made a script that
> used to exhaust all the given memory and I needed to increase the limit.
>
> memory_limit = 16M
>
> You can change this to whatever you wish to control.  You can also
> change these if you want to control execution time:
>
> max_execution_time = 30     ; Maximum execution time of each script, in
> seconds
> max_input_time = 60     ; Maximum amount of time each script may spend
> parsing request data
>
>
> I haven't seen a way to control disk access space but I guess there are
> two ways to do that. One is quota the space that php writes in or do
> this by the programming way (meaning that you may check the space before
> you write something).
>
> As for the CPU I think there are OS specific techniques to control
> resource usage in general but it depends on what *nix system you use
> (FreeBSD, Linux etc).
>
>
> ------------
> Thodoris
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> _______________________________________________________
>
> The  information in this email or in any file attached
> hereto is intended only for the personal and confiden-
> tial  use  of  the individual or entity to which it is
> addressed and may contain information that is  propri-
> etary  and  confidential.  If you are not the intended
> recipient of this message you are hereby notified that
> any  review, dissemination, distribution or copying of
> this message is strictly prohibited.  This  communica-
> tion  is  for information purposes only and should not
> be regarded as an offer to sell or as  a  solicitation
> of an offer to buy any financial product. Email trans-
> mission cannot be guaranteed to be  secure  or  error-
> free. P6070214
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Assuming a linux hosted server, see about getting a user created with ulimit
(which limits the resources on calls to system) if you can use that user

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Hello all again,

It seems that Problem can only be solved by one of the following ways:

1. Don't use mod_php; use CGI or FastCGI instead. Then it would be
   possible to limit the resources via RLimitCPU / RLimitMEM.

2. Use one of the following apache core patch
    http://archives.neohapsis.com/archives/openbsd/2005-12/1436.html
   or the following apache module:
    http://www.ucc.asn.au/~dagobah/things/mod_rlimit.c
   (Unfortunately only for apache 1.3)

Thanks for all your answers.

Kind regards
valli

Valentin Schmid - ICSurselva AG wrote:
Hello all,

Is there a way to limit the memory consumption and / or the CPU
consumption of processes launched by the php functions system,
exec, passthru, proc_open and shell_exec?

We use mod_php with an apache (mpm-prefork) on Linux.

The following settings don't have any effect at all:
PHP:
  max_execution_time 30
  memory_limit 8M
Apache:
  RLimitCPU 30 30
  RLimitMEM 8388608 8388608

The limits above do have effect on php-scripts (without system calls)
and on CGIs (as well on processes launched by CGIs).

Any Ideas?

Kind Regards
valli


PS: I tested it with the following two scripts:
system_memorytest.php
=====================
<html>
<head>
  <title>php-systemcall-memory test</title>
</head>
<body>
  php-systemcall-memory test<br>
  ... and here's the system call:<br>
  <pre>
<?php
   $cmd = '/usr/bin/perl -e \'
      $| = 1;
      print "start of the systemcall<br>\n";
      $s = "teststr_";
      while (1) {
         print "len=".length($s)."<br>\n";
         sleep(1);
         $s .= $s;
      }
   \'';
   print htmlspecialchars($cmd);
?>
  </pre>
<?php
  ob_flush();
  flush();
  system($cmd);
?>
</body>
</html>


system_timeouttest.php
======================
<html>
<head>
  <title>php-systemcall-timeout test</title>
</head>
<body>
  php-systemcall-timeout test<br>
  ... and here's the system call:<br>
  <pre>
<?php
   $cmd = '/usr/bin/perl -e \'
      $| = 1;
      print "start of the systemcall<br>\n";
      $i = 0;
      while (1) {
         if (($i % 10000000) == 0) {
            print "i=".$i."<br>\n";
         }
         $i += 1;
      }
   \'';
   print htmlspecialchars($cmd);
?>
  </pre>
<?php
  ob_flush();
  flush();
  system($cmd);
?>
</body>
</html>




--- End Message ---

Reply via email to