Created
July 14, 2020 17:05
-
-
Save djamol/9b6011540a2d6b563a7cf90e1723bbae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$MainPath='./'; | |
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; | |
} | |
if($_GET['pdf']=='pdf'){//pdf first page snapshot for preview | |
//echo $_GET['url']; | |
$im = new imagick(urldecode($_GET['url']).'[0]');//'file.pdf[0]' | |
$im->setImageFormat('jpg'); | |
header('Content-Type: image/jpeg'); | |
echo $im; | |
}else{ | |
$ob = (dua_get_files($MainPath));$iList=0; | |
//echo '<!-- Created By Amol --><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, '.') || endsWith($item, 'CopyTERA')) { | |
} else { | |
if (file_exists($item . "/index.php")) { | |
$url = 'http://martechgrp.com/' . str_ireplace('./', '', $item); | |
$title =str_replace("\n",'',getTitle($url)); | |
// echo '<tr><td><a href="' . $url . '">' . $url . '</a></td><td>' . getTitle($url) . '</td>'; | |
echo $iList.',"'.$url . '","'.$title."\"";//pdfsnap | |
if (file_exists($item . "/conf.php")) {include ($item . "/conf.php"); | |
$sp= 'http://martechgrp.com/t.php?i='.$iList.'&pdf=pdf&url='.urlencode($item.'/'.$pdfloc); | |
echo ',"'.$sp.'"'; | |
copy($sp,'pdfsnap/'.$iList.'.jpg'); | |
} | |
echo "\n"; | |
$iList++; | |
} | |
} | |
} | |
} | |
//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 PDFfirstPage($urlpdf){ | |
//$im = new imagick($urlpdf.'[0]');//'file.pdf[0]' | |
//$im->setImageFormat('jpg'); | |
//header('Content-Type: image/jpeg'); | |
//return $im; | |
} | |
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