Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Soufian SoufianAkh

🎯
Focusing
View GitHub Profile
@SoufianAkh
SoufianAkh / textparser.php
Last active May 26, 2020
Commandline and GET request based text grep peformer
View textparser.php
<?php
if(isset($argv[1]) && isset($argv[2])) {
$inputFile = $argv[1];
$query = $argv[2];
$newLineChar = "\n";
} else if(isset($_GET['input_file']) && isset($_GET['query'])) {
$inputFile = $_GET['input_file'];
$query = $_GET['query'];
$newLineChar = "<br>";
} else {
@SoufianAkh
SoufianAkh / GetDomainFromSubdomain.php
Last active Mar 11, 2020
[PHP] Get main - root domain from URL - Link
View GetDomainFromSubdomain.php
<?php
function GetDomainFromSubdomain($host){
$myhost = strtolower(trim($host));
$count = substr_count($myhost, '.');
if($count === 2){
if(strlen(explode('.', $myhost)[1]) > 3) $myhost = explode('.', $myhost, 2)[1];
} else if($count > 2){
$myhost = get_domain(explode('.', $myhost, 2)[1]);
}
return $myhost;
@SoufianAkh
SoufianAkh / ElasticCrud.class.php
Last active Feb 14, 2020
Simple and basic ElasticSearch CRUD PHP class. This is not made with the purpose to be perfect for everyone, it is made to use in my own project and so it only contains the specific functions that I needed. Feel free to modify it, but credits are always appreciated.
View ElasticCrud.class.php
<?php
/*
Version: 1.0.0
Date: 14-02-2020
Author: Soufian
Github: Github.com/SoufianAkh
Requirements:
* Composer
* ElasticSearch PHP (https://github.com/elastic/elasticsearch-php)