Skip to content

Instantly share code, notes, and snippets.

View danvaly's full-sized avatar

Valentin Ghica danvaly

View GitHub Profile
@danvaly
danvaly / extract-emails.php
Last active May 23, 2018 13:52
Tools to extract unique emails from text files. Ex: php extract-emails.php -f text.txt -o emails.txt
<?php
/* Tools to process end extract log data from text files
* Ex: php extract-emails.php -f text.txt -o emails.txt
*/
function extract_emails ($from_text = "")
{
$emails = [];
if(!empty($from_text)) {
$res = preg_match_all(
"/[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}/i",
@danvaly
danvaly / extract-log.php
Last active May 23, 2018 13:27
Search and extract data from server log files
<?php
/**
* Tools to process end extract log data from Proftpd.log files
* Ex: php extract.php -f ftp_in.log -s PUT-o ftp_out.log
*/
$options = getopt("f:s:o:");
if (isset($options['f']) && isset($options['o']) && $options['s'] && strlen($options['s'])>0 ){
if (!file_exists($options['f'])){
die("Eroare: Nu am gasit fisierul pentru citire!");