Skip to content

Instantly share code, notes, and snippets.

@djamol
Created July 12, 2020 07:20
Show Gist options
  • Save djamol/a6e92a362ce0bcde791673eb49364e86 to your computer and use it in GitHub Desktop.
Save djamol/a6e92a362ce0bcde791673eb49364e86 to your computer and use it in GitHub Desktop.
<?php
function dua_get_files($path)
{ //deep scan directory path
$data = array();
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $file)
{
if (is_dir($file) === true)
{
$data[] = strval($file);
}
}
return $data;
}
$ob= (dua_get_files('./'));
echo '<table><tr><th>URL</th><th>Title</th></tr>';
foreach($ob as $item){//|| endsWith($item,'NODEJS') || endsWith($item,'NodeJS_Engine') || endsWith($item,'bb_files')
if(endsWith($item,'.') ){}else{
if(file_exists($item."/index.php")){
$url = 'http://martechgrp.com/'.str_ireplace('./','',$item);
echo '<tr><td><a href="'.$url .'">'.$url .'</a></td><td>'.getTitle($url).'</td>';
}
}
}
echo '</table>';
function getTitle($url) {
$page = file_get_contents($url);
$title = preg_match('/<title[^>]*>(.*?)<\/title>/ims', $page, $match) ? $match[1] : null;
return $title;
}
function startsWith($haystack, $needle)
{
$length = strlen($needle);
return (substr($haystack, 0, $length) === $needle);
}
function endsWith($haystack, $needle)
{
$length = strlen($needle);
if ($length == 0) {
return true;
}
return (substr($haystack, -$length) === $needle);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment