Click here to Skip to main content
15,936,633 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionContact form - Bootstrap Error Validation Pin
bigcdh4-Aug-13 8:13
bigcdh4-Aug-13 8:13 
AnswerRe: Contact form - Bootstrap Error Validation Pin
Peter_in_27808-Aug-13 15:42
professionalPeter_in_27808-Aug-13 15:42 
AnswerRe: Contact form - Bootstrap Error Validation Pin
vbmike23-Aug-13 9:12
vbmike23-Aug-13 9:12 
GeneralRe: Contact form - Bootstrap Error Validation Pin
bigcdh23-Aug-13 9:22
bigcdh23-Aug-13 9:22 
QuestionPHP find all occurrences of string in file Pin
MicahC5-Jul-13 6:44
MicahC5-Jul-13 6:44 
AnswerRe: PHP find all occurrences of string in file Pin
Graham Breach5-Jul-13 21:20
Graham Breach5-Jul-13 21:20 
GeneralRe: PHP find all occurrences of string in file Pin
MicahC7-Jul-13 19:52
MicahC7-Jul-13 19:52 
GeneralRe: PHP find all occurrences of string in file Pin
MicahC10-Jul-13 5:56
MicahC10-Jul-13 5:56 
If I have this entry in my log file
Quote:
Jul 10 10:32:04 dnsmasq[29137]: query[A] RASPBERRYPI.domain.actdsltmp from 192.168.1.106


I can use this code to find how many entries I have for the current month and day
$queries = preg_match_all(" /".$cur_month."\s+".$cur_day_nf ."/", $getText);


If I wanted to take this a step further and find all occurrences of an entry with a specified IP and matching string... example:
find all occurrences where ip = 192.168.1.106 and query = A return month, day and domain.

Jul 17 10:32:04 dnsmasq[29137]: query[A] RASPBERRYPI.domain.actdsltmp from 192.168.1.106

This example will only return an exact match... and not all entries have query[A]

<?php
  # URL that generated this code:
  # http://txt2re.com/index-php.php3?s=Jul%2010%2010:32:04%20dnsmasq[29137]:%20query[A]%20RASPBERRYPI.domain.actdsltmp%20from%20192.168.1.106&-2&19&32&20

  //$txt='Jul 10 10:32:04 dnsmasq[29137]: query[A] RASPBERRYPI.domain.actdsltmp from 192.168.1.106';

$getText = file_get_contents("/sda1/user/dns/log/dnsmasq.log", true);


  $re1='((?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Sept|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?))';	# Month 1
  $re2='.*?';	# Non-greedy match on filler
  $re3='((?:(?:[0-2]?\\d{1})|(?:[3][01]{1})))(?![\\d])';	# Day 1
  $re4='.*?';	# Non-greedy match on filler
  $re5='\\[.*?\\]';	# Uninteresting: sbraces
  $re6='.*?';	# Non-greedy match on filler
  $re7='(\\[.*?\\])';	# Square Braces 1
  $re8='.*?';	# Non-greedy match on filler
  $re9='(192\\.168\\.1\\.106)';	# IPv4 IP Address 1

  if ($c=preg_match_all ("/".$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9."/is", $getText, $matches))
  {
      $month1=$matches[1][0];
      $day1=$matches[2][0];
      $sbraces1=$matches[3][0];
      $ipaddress1=$matches[4][0];
      print "($month1) ($day1) ($sbraces1) ($ipaddress1) \n";
  }

  #-----
  # Paste the code into a new php file. Then in Unix:
  # $ php x.php 
  #-----
?>


Any additional help is greatly appreciated.
QuestionNot much traffic here is there..... Pin
Erudite_Eric16-Jun-13 23:40
Erudite_Eric16-Jun-13 23:40 
AnswerRe: Not much traffic here is there..... Pin
Ali Al Omairi(Abu AlHassan)7-Jul-13 22:18
professionalAli Al Omairi(Abu AlHassan)7-Jul-13 22:18 
QuestionCounting Menu Items & Determining If First/Last Pin
NickBogi7-Jun-13 13:20
NickBogi7-Jun-13 13:20 
AnswerGot It Working Pin
NickBogi10-Jun-13 8:29
NickBogi10-Jun-13 8:29 
QuestionUrgent !!! Looking for the best solution Pin
MacAriel15-May-13 8:43
MacAriel15-May-13 8:43 
AnswerRe: Urgent !!! Looking for the best solution Pin
herlon21423-Jul-13 9:59
herlon21423-Jul-13 9:59 
QuestionVideo Gallery for wordpress site. Pin
Neha Pandal12-May-13 10:03
professionalNeha Pandal12-May-13 10:03 
AnswerRe: Video Gallery for wordpress site. Pin
Archie22is30-Jun-13 21:07
Archie22is30-Jun-13 21:07 
Questionhow to store QR Code image in mysql with php Pin
blertaaa2-May-13 22:43
blertaaa2-May-13 22:43 
AnswerRe: how to store QR Code image in mysql with php Pin
Prasad Khandekar21-May-13 4:56
professionalPrasad Khandekar21-May-13 4:56 
AnswerRe: how to store QR Code image in mysql with php Pin
Resalat Haque Prodhan27-Jun-13 2:02
Resalat Haque Prodhan27-Jun-13 2:02 
AnswerRe: how to store QR Code image in mysql with php Pin
Rony Sur2-Jul-13 0:04
professionalRony Sur2-Jul-13 0:04 
QuestionHow to install xampp or Lamp in Ubuntu 8 Pin
Member 992947820-Mar-13 20:55
Member 992947820-Mar-13 20:55 
AnswerRe: How to install xampp or Lamp in Ubuntu 8 Pin
Richard MacCutchan20-Mar-13 22:54
mveRichard MacCutchan20-Mar-13 22:54 
AnswerRe: How to install xampp or Lamp in Ubuntu 8 Pin
Mohibur Rashid30-Apr-13 17:19
professionalMohibur Rashid30-Apr-13 17:19 
GeneralRe: How to install xampp or Lamp in Ubuntu 8 Pin
Rony Sur2-Jul-13 0:09
professionalRony Sur2-Jul-13 0:09 
AnswerRe: How to install xampp or Lamp in Ubuntu 8 Pin
Tushar Guru8-Sep-14 22:17
Tushar Guru8-Sep-14 22:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.