Created
April 19, 2022 14:27
-
-
Save woodwardtw/571686c249c63b7a2a5fb7dd58399f78 to your computer and use it in GitHub Desktop.
for our awkward ereserve export . . . generates an HTML page from the unzipped directory located at 'sample' relative to this file . . . could be expanded to handle all the folders
This file contains hidden or 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 | |
| $clean_folders = array_diff(scandir('sample'), array('..', '.', '.DS_Store')); | |
| foreach ($clean_folders as $folder) { | |
| if($folder) | |
| $path = 'sample/'. $folder; | |
| $sub_folders = array_diff(scandir('sample/'. $folder), array('..', '.', '.DS_Store')); | |
| //var_dump($sub_folders); | |
| foreach($sub_folders as $file){ | |
| if ($file === "Info.txt"){ | |
| $file_path = 'sample/' . $folder . '/Info.txt'; | |
| $txt_file = fopen($file_path,'r'); | |
| while ($line = fgets($txt_file)) { | |
| $text = url_checker($line); | |
| echo($text)."<br>"; | |
| } | |
| echo '<hr>'; | |
| fclose($txt_file); | |
| } | |
| } | |
| } | |
| function url_checker($line){ | |
| if(strpos($line, 'http') !== false){ | |
| return "<a href='{$line}'>{$line}</a>"; | |
| } | |
| if(strpos($line, 'Title') !== false){ | |
| return "<strong>{$line}</strong>"; | |
| } | |
| if(strpos($line, 'Document Information') !== false){ | |
| return ""; | |
| } | |
| else { | |
| return $line; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment