Jump to content

Geting the regular expression from both the URL and the script.


strago

Recommended Posts

<?php
$user = $_GET['user'];
$request_url ="http://www.domain.com/logs.shtml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);

//THIS NEEDS CHANGED!!!!!
$regex='|$user - (.*?) - $user|';

preg_match_all($regex,$result,$parts);
$logs=$parts[1];
foreach($logs as $log){
	echo "<B>".$log."</B><br>";
}
curl_close($ch);
?>

 

The logs file looks like

 

username - log info - log info - log info - username

 

For a URL like

 

http-//www.domain.com/view-logs.php?user=strago

 

I want it to spit out just the lines from the log file that got

 

strago - log info - log info - log info - strago

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.