php-general Digest 30 Jun 2012 17:23:01 -0000 Issue 7871

2012-06-30 Thread php-general-digest-help

php-general Digest 30 Jun 2012 17:23:01 - Issue 7871

Topics (messages 318345 through 318346):

Re: log tailing
318345 by: tamouse mailing lists

Re: Depreciation message I can't make out
318346 by: Daniel Brown

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


--
---BeginMessage---
On Fri, Jun 29, 2012 at 3:49 AM, Mihamina Rakotomandimby
miham...@rktmb.org wrote:
 I have a /var/log/messages and /var/log/syslog file to parse to extract
 information from.

 I have the to extract the date, and some information in the line.
[snip]
 I just need help on the right regexp function to use.
 Would you know some PHP/regexp tutorials for that?

The best documentation I've ever found on Regexes is O'Reilly's
Mastering Regular Expressions (3rd ed is 2006, but REs haven't
changed since then).

http://shop.oreilly.com/product/9780596528126.do

Only problem is it is hella expensive. (Well another problem is it is
hella big: 500 pages.)

Apart from that, there are *tons* of tutorials on the net. Just google
up regular expression tutorials and you should see pages and pages
of them.
---End Message---
---BeginMessage---
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/
---End Message---


Re: [PHP] Depreciation message I can't make out....

2012-06-30 Thread Daniel Brown
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



Re: [PHP] Depreciation message I can't make out....

2012-06-30 Thread Gary Lebowitz
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




Re: [PHP] Depreciation message I can't make out....

2012-06-30 Thread tamouse mailing lists
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.

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



Re: [PHP] log tailing

2012-06-30 Thread Daniel Brown
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/

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



Re: [PHP] log tailing

2012-06-30 Thread Daniel Brown
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



Re: [PHP] Re: php batch/queue framwork

2012-06-30 Thread Larry Garfield

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-general@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

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



Fwd: Re: [PHP] log tailing

2012-06-30 Thread tamouse mailing lists
-- 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)}'


Re: [PHP] embedding php inside of php

2012-06-30 Thread Bastien


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=subjectSubject of email:/labelbr /
input id=subject name=subject type=text value=?php
 echo $subject;?br /
label for=elvismailBody of email:/labelbr /
textarea id=elvismail name=elvismail rows=8
 cols=40?php echo $text;?   /textareabr /
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=subjectSubject of email:/labelbr /
input id=subject name=subject type=textbr /
label for=elvismailBody of email:/labelbr /
textarea id=elvismail name=elvismail rows=8
 cols=40/textareabr /
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 /
  titleMake 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 /
  pstrongPrivate:/strong For Elmer's use ONLYbr /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=subjectSubject of email:/labelbr /
input id=subject name=subject type=textbr /
label for=elvismailBody of email:/labelbr /
textarea id=elvismail name=elvismail rows=8
 cols=40/textareabr /
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php