Created
June 30, 2016 18:10
-
-
Save emasters/7e4dc60b3e073aa5d0048de45e9d5aa1 to your computer and use it in GitHub Desktop.
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 | |
| error_reporting(E_ALL); | |
| session_start(); | |
| $UploadFolder = "../guides/"; | |
| if (($tempName=$_FILES['file']['tmp_name'])!="") | |
| { | |
| //logmsg("tempName=$tempName"); | |
| $name= str_replace(" ","_",$_FILES['file']['name']); | |
| //logmsg("name=$name"); | |
| // create a folder to stash the zip into | |
| $dirname = $PHPSESSID; | |
| mkdir($UploadFolder.$dirname,0777); | |
| // move the zip to the new folder | |
| move_uploaded_file($tempName,$UploadFolder.$dirname.'/'.$name); | |
| // unzip the file | |
| $zipfile = $UploadFolder.$dirname.'/'.$name; | |
| // get the absolute path to $file | |
| $path = pathinfo(realpath($zipfile), PATHINFO_DIRNAME); | |
| $zip = new ZipArchive; | |
| $res = $zip->open($zipfile); | |
| if ($res === TRUE) { | |
| // extract it to the path we determined above | |
| $zip->extractTo($path); | |
| $zip->close(); | |
| $strURL = "http://a2j.freelawreporter.org/A2JFileInfo.php?UploadDir=$path&UploadedFile=$name"; | |
| } else { | |
| $strURL = "http://a2j.freelawreporter.org/A2JFileInfo.php?UploadedFile=it_didnt_work"; | |
| } | |
| } | |
| // generate viewer link with proper query params | |
| //$xmlGuideUrl = 'index.html?templateURL=../guides/'.$guideId.'/Guide.xml&fileDataURL=../guides/'.$guideId; | |
| // redirect and launch newly uploaded guide | |
| // if ($copySuccess) { | |
| //header("Location: " . $xmlGuideUrl); | |
| //exit(); | |
| //} | |
| ?> | |
| <!-- Create a clickable list of all guides, launching the guide/viewer --> | |
| <h3>Current Guide List</h3> | |
| <ul> | |
| <?php foreach (glob('../guides/*', GLOB_ONLYDIR) as $directoryName) : ?> | |
| <?php $viewerUrl = 'index.html?templateURL=../guides/'. $directoryName .'/Guide.xml&fileDataURL=../guides/'. $directoryName; ?> | |
| <li> | |
| <a href="?delete=<?php echo $directoryName; ?>">[Delete]</a> | |
| <a href="<?php echo $viewerUrl; ?>"> | |
| <?php echo basename($directoryName); ?> | |
| </a> | |
| </li> | |
| <?php endforeach; ?> | |
| </ul> | |
| <!-- Form for uploading/posting guides --> | |
| <h3>Upload New Guide</h3> | |
| <p>Choose a .zip file exported from the A2J Author:</p> | |
| <form action="dashboardERM.php" method="post" target="_self" enctype="multipart/form-data"> | |
| <input type="file" name="file" accept=".zip"> | |
| <input type="submit" value="Upload"> | |
| </form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment