php-general Digest 1 Jul 2012 06:34:38 -0000 Issue 7872

Topics (messages 318347 through 318355):

Re: Depreciation message I can't make out....
        318347 by: Gary Lebowitz
        318348 by: tamouse mailing lists

Re: log tailing
        318349 by: Daniel Brown
        318350 by: Daniel Brown
        318352 by: tamouse mailing lists

Re: php batch/queue framwork
        318351 by: Larry Garfield
        318355 by: Robert Williams

embedding php inside of php
        318353 by: Tim Dunphy
        318354 by: Bastien

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
By the way, I told GoDaddy about the # deprecation issue and they told me
that I could simply change my root directory php5.ini file. But the error
message is related to the PHP.ini file in /web/config, as I said. I could
almost hear them shrugging their shoulders, what-me-worry style. If anyone
with more might than i could explain this error might affect others when
multiplied hundreds of times it could be useful.
Am 30.06.2012 19:23 schrieb "Daniel Brown" <danbr...@php.net>:

> On Thu, Jun 28, 2012 at 8:37 PM, tamouse mailing lists
> <tamouse.li...@gmail.com> wrote:
> >
> > Just a quick followup -- # comments are deprecated for .ini files,
> > only, correct? They are still full citizens in php source, aren't
> > they?
>
>    Correct, Tam.
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sat, Jun 30, 2012 at 12:57 PM, Gary Lebowitz <gurqi...@gmail.com> wrote:
> By the way, I told GoDaddy about the # deprecation issue and they told me
> that I could simply change my root directory php5.ini file. But the error
> message is related to the PHP.ini file in /web/config, as I said. I could
> almost hear them shrugging their shoulders, what-me-worry style. If anyone
> with more might than i could explain this error might affect others when
> multiplied hundreds of times it could be useful.
>
> Am 30.06.2012 19:23 schrieb "Daniel Brown" <danbr...@php.net>:
>>
>> On Thu, Jun 28, 2012 at 8:37 PM, tamouse mailing lists
>> <tamouse.li...@gmail.com> wrote:
>> >
>> > Just a quick followup -- # comments are deprecated for .ini files,
>> > only, correct? They are still full citizens in php source, aren't
>> > they?
>>
>>    Correct, Tam.
>>
>> --
>> </Daniel P. Brown>
>> Network Infrastructure Manager
>> http://www.php.net/
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>

> By the way, I told GoDaddy about the # deprecation issue and they told me
> that I could simply change my root directory php5.ini file. But the error
> message is related to the PHP.ini file in /web/config, as I said. I could
> almost hear them shrugging their shoulders, what-me-worry style. If anyone
> with more might than i could explain this error might affect others when
> multiplied hundreds of times it could be useful.
>

Sadly, my only advice is to get away from GoDaddy.

--- End Message ---
--- Begin Message ---
On Fri, Jun 29, 2012 at 4:49 AM, Mihamina Rakotomandimby
<miham...@rktmb.org> wrote:
[snip!]
>
> Typically, a log line like:
> Jun 29 11:24:10 dev5 sshd[12775]: Accepted password \
>            for dev5 from 192.168.0.12 port 50544 ssh2
>
[snip!]
> So that I can:
>
> INSERT INTO ssh_activity \
>   VALUES ('2012-06-29 11:24:10', '192.168.0.12')
>
> I just need help on the right regexp function to use.
> Would you know some PHP/regexp tutorials for that?

    You could take the pattern-matching load off of PHP entirely if
you used something along these lines.  Just remember to adjust and
clean up as necessary.

<?php

$ssh_entries = explode(PHP_EOL,trim(`tail /var/log/syslog | awk
{'print $1,$2,$3 "|" $5 "|" $11'}`));

foreach ($ssh_entries as $s) {
        $l = explode('|',$s);

        // Remember to do whatever sanity necessary!
        $sql = "INSERT INTO ssh_activity
VALUES('".$l[0]."','".$l[1]."','".$l[2]."')";
}
?>

-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
On Sat, Jun 30, 2012 at 2:30 PM, Daniel Brown <danbr...@php.net> wrote:
>
> <?php
>
> $ssh_entries = explode(PHP_EOL,trim(`tail /var/log/syslog | awk
> {'print $1,$2,$3 "|" $5 "|" $11'}`));

    Actually, the above was intended to grab just sshd entries, so
instead of 'tail' you should use 'grep sshd' in the line above.


> foreach ($ssh_entries as $s) {
>        $l = explode('|',$s);
>
>        // Remember to do whatever sanity necessary!
>        $sql = "INSERT INTO ssh_activity
> VALUES('".$l[0]."','".$l[1]."','".$l[2]."')";
> }
> ?>
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/



-- 
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/

--- End Message ---
--- Begin Message ---
---------- Forwarded message ----------
From: "tamouse mailing lists" <tamouse.li...@gmail.com>
Date: Jun 30, 2012 4:35 PM
Subject: Re: [PHP] log tailing
To: "Daniel Brown" <danbr...@php.net>

On Jun 30, 2012 1:34 PM, "Daniel Brown" <danbr...@php.net> wrote:
>
> On Sat, Jun 30, 2012 at 2:30 PM, Daniel Brown <danbr...@php.net> wrote:
> >
> > <?php
> >
> > $ssh_entries = explode(PHP_EOL,trim(`tail /var/log/syslog | awk
> > {'print $1,$2,$3 "|" $5 "|" $11'}`));
>
>    Actually, the above was intended to grab just sshd entries, so
> instead of 'tail' you should use 'grep sshd' in the line above.
>
>
> > foreach ($ssh_entries as $s) {
> >        $l = explode('|',$s);
> >
> >        // Remember to do whatever sanity necessary!
> >        $sql = "INSERT INTO ssh_activity
> > VALUES('".$l[0]."','".$l[1]."','".$l[2]."')";
> > }
> > ?>
> >
> > --
> > </Daniel P. Brown>
> > Network Infrastructure Manager
> > http://www.php.net/
>
>
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Crud-- sent to Dan instead of list:

Or just let awk do it:

tail /var/log/syslog | awk '/sshd/{print($1,$2,$3 "|" $5 "|" $11)}'

--- End Message ---
--- Begin Message ---
On 06/29/2012 05:18 AM, Tom Sparks wrote:
Forwarded Message: php-general_318334.ezm
Re: php batch/queue framwork
Friday, 29 June, 2012 6:30 AM
From:
"Shailesh N. Humbad" <humb...@alum.mit.edu>
To:
php-gene...@lists.php.net
On 6/28/2012 11:58 AM, Tom Sparks wrote:
I am looking for a batch/queue framework that is database-centric?
I could write my own, but I want one that is mature

tom_a_sparks
"It's a nerdy thing I like to do"


You could try Amazon Simple Queue Service: http://aws.amazon.com/sqs/
Use the PHP SDK: http://aws.amazon.com/sdkforphp/
I was hoping for something that I could run local on my host

tom

Have a look at Beanstalk and Gearman. They're the most common run-yourself queues I've seen, and both have PHP libraries available.

ZeroMQ is also the darling of the queuing world these days, but I don't know off hand how good the PHP support is.

You won't find a GOOD "database-centric" queue framework, rather by definition. A queuing server may use a DB of some kind as a backend itself, but a queue server by definition pushes tasks to workers that are waiting for it. That's simply not how an SQL DB is designed. You would have to do a polling worker that polls a database for new tasks. You could write such a system -- Drupal comes with one as a default implementation since then you don't need a separate queueing program, for instance -- but it will always be greatly inferior to a real daemonized queue server.

--Larry Garfield

--- End Message ---
--- Begin Message ---
Zend Server includes a job queue.

<http://www.zend.com/en/products/server/zend-server-job-queue>

It supports queuing up jobs directly in the UI or via a PHP API, and it 
includes a variety of scheduling and load management options.

--
Bob Williams

Notice: This communication, including attachments, may contain information that 
is confidential. It constitutes non-public information intended to be conveyed 
only to the designated recipient(s). If the reader or recipient of this 
communication is not the intended recipient, an employee or agent of the 
intended recipient who is responsible for delivering it to the intended 
recipient, or if you believe that you have received this communication in 
error, please notify the sender immediately by return e-mail and promptly 
delete this e-mail, including attachments without reading or saving them in any 
manner. The unauthorized use, dissemination, distribution, or reproduction of 
this e-mail, including attachments, is prohibited and may be unlawful. If you 
have received this email in error, please notify us immediately by e-mail or 
telephone and delete the e-mail and the attachments (if any).

--- End Message ---
--- Begin Message ---
Hello,

 I am trying to get the hang of php using some examples that I found
in a book. I've been making progress lately, but one thing has me a
bit stumped.


In an HTML form that I am echoing through PHP I would like to embed
smaller chunks of php in the code like so:


 echo '<br /><br />
        <form method="post" action="sendemail.php">
        <label for="subject">Subject of email:</label><br />
        <input id="subject" name="subject" type="text" value="<?php
echo $subject;?>"><br />
        <label for="elvismail">Body of email:</label><br />
        <textarea id="elvismail" name="elvismail" rows="8"
cols="40">"<?php echo $text;?>"       </textarea><br />
        <input type="submit" name="Submit" value="Submit" />
        </form>';



If I do embed the smaller chunks of php in the form the way I've just
shown you the script instantly breaks and the web page shows only a
white screen of death.

And I see this in the web server logs

[Sat Jun 30 19:12:54 2012] [notice] child pid 7769 exit signal
Segmentation fault (11)


If I remove the smaller bits of php as I show here the web page starts
working again


 echo '<br /><br />
        <form method="post" action="sendemail.php">
        <label for="subject">Subject of email:</label><br />
        <input id="subject" name="subject" type="text"><br />
        <label for="elvismail">Body of email:</label><br />
        <textarea id="elvismail" name="elvismail" rows="8"
cols="40"></textarea><br />
        <input type="submit" name="Submit" value="Submit" />
        </form>';


Here, I'll show the entire script so you can get a better sense of what it does

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Make Me Elvis - Send Email</title>
  <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
  <img src="blankface.jpg" width="161" height="350" alt=""
style="float:right" />
  <img name="elvislogo" src="elvislogo.gif" width="229" height="32"
border="0" alt="Make Me Elvis" />
  <p><strong>Private:</strong> For Elmer's use ONLY<br /><br
  Write and send an email to mailing list members.</p>

<?php

  error_reporting(E_ALL);
  ini_set('display_errors', 'On');

   if (isset($_POST['Submit'])) {

     $from = 'bluethu...@mydomain.com';
     $subject = $_POST['subject'];
     $text = $_POST['elvismail'];
     $output_form = "false";

     if (empty($subject) && empty($text)) {
     echo 'You forgot the email subject and body.<br />';
     $output_form = 'true';

    }


     if (empty($subject) && !empty($text)) {
     echo 'You forgot the email subject.<br />';
     $output_form="true";

    }

    if ((!empty($subject)) && empty($text)) {

    echo 'You forgot the email body text.<br />';
    $output_form="true";


    }

}  else {

      $output_form = 'true';

   }



   if ($output_form == 'true') {


  echo '<br /><br />
        <form method="post" action="sendemail.php">
        <label for="subject">Subject of email:</label><br />
        <input id="subject" name="subject" type="text"><br />
        <label for="elvismail">Body of email:</label><br />
        <textarea id="elvismail" name="elvismail" rows="8"
cols="40"></textarea><br />
        <input type="submit" name="Submit" value="Submit" />
        </form>';


  } else {

  $dbc = mysqli_connect('127.0.0.1', 'admin', 'secret

', 'elvis_store')
    or die('Error connecting to MySQL server.');

  $query = "SELECT * FROM email_list";
  $result = mysqli_query($dbc, $query)
    or die('Error querying database.');

  while ($row = mysqli_fetch_array($result)){
    $to = $row['email'];
    $first_name = $row['first_name'];
    $last_name = $row['last_name'];
    $msg = "Dear $first_name $last_name,\n$text";
    mail($to, $subject, $msg, 'From:' . $from);
    echo 'Email sent to: ' . $to . '<br />';
  }

  mysqli_close($dbc);

 }


?>

</body>
</html>


I was hoping that someone might be out there that could understand
this problem and point out where I'm going wrong.

Thanks!

-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

--- End Message ---
--- Begin Message ---

Bastien Koert

On 2012-06-30, at 8:00 PM, Tim Dunphy <bluethu...@gmail.com> wrote:

> Hello,
> 
> I am trying to get the hang of php using some examples that I found
> in a book. I've been making progress lately, but one thing has me a
> bit stumped.
> 
> 
> In an HTML form that I am echoing through PHP I would like to embed
> smaller chunks of php in the code like so:
> 
> 
> echo '<br /><br />
>        <form method="post" action="sendemail.php">
>        <label for="subject">Subject of email:</label><br />
>        <input id="subject" name="subject" type="text" value="<?php
> echo $subject;?>"><br />
>        <label for="elvismail">Body of email:</label><br />
>        <textarea id="elvismail" name="elvismail" rows="8"
> cols="40">"<?php echo $text;?>"       </textarea><br />
>        <input type="submit" name="Submit" value="Submit" />
>        </form>';
> 
> 
> 
> If I do embed the smaller chunks of php in the form the way I've just
> shown you the script instantly breaks and the web page shows only a
> white screen of death.
> 
> And I see this in the web server logs
> 
> [Sat Jun 30 19:12:54 2012] [notice] child pid 7769 exit signal
> Segmentation fault (11)
> 
> 
> If I remove the smaller bits of php as I show here the web page starts
> working again
> 
> 
> echo '<br /><br />
>        <form method="post" action="sendemail.php">
>        <label for="subject">Subject of email:</label><br />
>        <input id="subject" name="subject" type="text"><br />
>        <label for="elvismail">Body of email:</label><br />
>        <textarea id="elvismail" name="elvismail" rows="8"
> cols="40"></textarea><br />
>        <input type="submit" name="Submit" value="Submit" />
>        </form>';
> 
> 
> Here, I'll show the entire script so you can get a better sense of what it 
> does
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
> <head>
>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>  <title>Make Me Elvis - Send Email</title>
>  <link rel="stylesheet" type="text/css" href="style.css" />
> </head>
> <body>
>  <img src="blankface.jpg" width="161" height="350" alt=""
> style="float:right" />
>  <img name="elvislogo" src="elvislogo.gif" width="229" height="32"
> border="0" alt="Make Me Elvis" />
>  <p><strong>Private:</strong> For Elmer's use ONLY<br /><br
>  Write and send an email to mailing list members.</p>
> 
> <?php
> 
>  error_reporting(E_ALL);
>  ini_set('display_errors', 'On');
> 
>   if (isset($_POST['Submit'])) {
> 
>     $from = 'bluethu...@mydomain.com';
>     $subject = $_POST['subject'];
>     $text = $_POST['elvismail'];
>     $output_form = "false";
> 
>     if (empty($subject) && empty($text)) {
>     echo 'You forgot the email subject and body.<br />';
>     $output_form = 'true';
> 
>    }
> 
> 
>     if (empty($subject) && !empty($text)) {
>     echo 'You forgot the email subject.<br />';
>     $output_form="true";
> 
>    }
> 
>    if ((!empty($subject)) && empty($text)) {
> 
>    echo 'You forgot the email body text.<br />';
>    $output_form="true";
> 
> 
>    }
> 
> }  else {
> 
>      $output_form = 'true';
> 
>   }
> 
> 
> 
>   if ($output_form == 'true') {
> 
> 
>  echo '<br /><br />
>        <form method="post" action="sendemail.php">
>        <label for="subject">Subject of email:</label><br />
>        <input id="subject" name="subject" type="text"><br />
>        <label for="elvismail">Body of email:</label><br />
>        <textarea id="elvismail" name="elvismail" rows="8"
> cols="40"></textarea><br />
>        <input type="submit" name="Submit" value="Submit" />
>        </form>';
> 
> 
>  } else {
> 
>  $dbc = mysqli_connect('127.0.0.1', 'admin', 'secret
> 
> ', 'elvis_store')
>    or die('Error connecting to MySQL server.');
> 
>  $query = "SELECT * FROM email_list";
>  $result = mysqli_query($dbc, $query)
>    or die('Error querying database.');
> 
>  while ($row = mysqli_fetch_array($result)){
>    $to = $row['email'];
>    $first_name = $row['first_name'];
>    $last_name = $row['last_name'];
>    $msg = "Dear $first_name $last_name,\n$text";
>    mail($to, $subject, $msg, 'From:' . $from);
>    echo 'Email sent to: ' . $to . '<br />';
>  }
> 
>  mysqli_close($dbc);
> 
> }
> 
> 
> ?>
> 
> </body>
> </html>
> 
> 
> I was hoping that someone might be out there that could understand
> this problem and point out where I'm going wrong.
> 
> Thanks!
> 
> -- 
> GPG me!!
> 
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

You can't have an echo inside and echo. Properly quote and concatenate the 
additional echo and you'll be fine

--- End Message ---

Reply via email to