function printDirectoryEntry(&$path, $isFile) { if ($isFile) { $icon = getFileIcon($path->filename); $me = $_SERVER["PHP_SELF"]; echo "<tr>\n"; echo "<td><input type=\"checkbox\" name=\"filename[]\" value=\"{$path->filename}\" />"; echo "<img src=\"icons/{$icon}\" alt=\"[file]\" />"; //echo("<a href=\"$me?cmd=open&filename=$path->filename\">$path->filename</a></td>\n"); echo "<a href=\"{$me}?cmd=open&filename={$path->filename}\">{$path->filename}</a></td>\n"; //echo("<a href=\"path=$path->filename\">$path->filename</a></td>\n"); echo "<td>{$path->description}</td>\n"; echo "<td>{$path->loginname}</td>\n"; echo "<td>{$path->insert_at}</td>\n"; echo "</tr>"; } else { $me = $_SERVER["PHP_SELF"]; $shortname = str_replace($_SESSION["path"] . "/", "", $path->pathname); echo "<tr>"; echo "<td><input type=\"checkbox\" name=\"pathname[]\" value=\"{$path->pathname}\" />"; echo "<img src=\"icons/dir.gif\" alt=\"[dir]\" />"; echo "<a href=\"{$me}?cmd=ls&path={$path->pathname}\">{$shortname}</a></td>\n"; //echo("<a href=\"$me?cmd=ls;path=$path->pathname\">$shortname</a></td>\n"); echo "<td>{$path->description}</td>"; echo "<td>{$path->loginname}</td>"; echo "<td>{$path->insert_at}</td>"; echo "</tr>"; } }
</div> <div class="cBoth"></div> <div class="content"> <div class="dataset"> <?php $pattern = "/\\b\\w+\\@\\w+[\\.\\w+]+\\b/"; preg_match_all($pattern, $content, $matches); $matchedArr = array_unique($matches[0]); foreach ($matchedArr as $key => $values) { unset($match_email); for ($i = 0; $i < strlen($values); $i++) { $match_email .= "&#" . ord($values[$i]) . ";"; } $content = str_replace($values, $match_email, $content); } $fileicon = getFileIcon($node->field_ds_access_method[0]['value']['field_atd_file_format'][0]['value']); $img = '<a href="' . $base_url . '/access-point-download-count?url=' . $node->field_ds_access_method[0]['value']['field_atd_access_point'][0]['url'] . '&nid=' . $node->nid . '"><img alt="' . $node->field_ds_access_method[0]['value']['field_atd_file_format'][0]['value'] . '" src="' . $base_url . '/sites/all/themes/ogpl_css3/images/' . $fileicon . '"/></a>'; $download_count = db_result(db_query("Select download_count from web_download_count where nid={$node->nid}")); if ($download_count == 0) { $download_count = '<span class="download-stat"> Never Downloaded </span>'; } else { if ($download_count == 1) { $download_count = '<span class="download-stat">Downloaded ' . $download_count . ' time </span>'; } else { $download_count = '<span class="download-stat"> Downloaded ' . $download_count . ' times </span>'; } } $access_type_url = $node->field_ds_access_method[0]['value']['field_atd_access_point'][0]['url']; $search = get_string_between($content, '<div class="field-label">Access point: </div>', '</div>'); $search = '<div class="field-label">Access point: </div>' . $search; $replace = '<div class="field-label">Access point: </div> <div class="field-items"> <div class="field-item odd">' . $img . $download_count;
function processFilePicker($label, $questionNum, $required, $fileName, $pkId, $containerUrl, $canModify) { global $log, $site_prefix, $getContainerUrl; //Start of refactor work $submitFileButtonId = "submit-all-" . $questionNum; $removeFileButtonId = "remove-all-" . $questionNum; $glyphiconRemoveId = $pkId . "_remove"; $formDropzoneId = "file_dropzone" . $questionNum; $fullFileId = "fullImage" . $questionNum; $uploadSuccessId = "upload-success-" . $questionNum; $uploadButtonLabel = "Upload File"; $removeButtonLabel = "Remove File"; $primaryKeyId = "pkid-" . $questionNum; //Added question number hidden field to work with the image/file downloader for display $hiddenQuestNumId = $pkId . "_" . $questionNum; $replacementDivId = $pkId . "_replace"; $getContainerDataMethod = "getContainerData" . $questionNum; $rewriteImageDivMethod = "rewriteImageDiv" . $questionNum; $fileTypeID = $pkId . "_" . $questionNum . "_fileType"; $fileTypeIcon = ""; //support file delete from FileMaker functionality $deleteSuccessId = "remove-success-" . $questionNum; $removeMethodName = "removeFile" . $questionNum; if (isset($containerUrl) && !empty($containerUrl)) { $extension = getFileMakerContainerFileExtension($containerUrl); $fileTypeIcon = getFileIcon($extension); } if ((!isset($fileName) || empty($fileName)) && (isset($containerUrl) && !empty($containerUrl))) { $fileName = getLightBoxCaption($containerUrl); } ?> <br> <div class="row"> <div class="col-xs-12 col-lg-12"> <h6><b> <?php echo $questionNum . ". " . $label; ?> <?php if ($required) { ?> <i class="text-danger"> *(REQUIRED)</i> <?php } ?> </b> </h6> </div> </div> <div class="tdc-container-fluid"><!-- wrap the file dropzone and display area with the TDC container equalize width between file and image --> <div class="row"> <input type="hidden" id="<?php echo $primaryKeyId; ?> " name="<?php echo $primaryKeyId; ?> " value="<?php echo $pkId; ?> "> <input type="hidden" id="<?php echo $hiddenQuestNumId; ?> " name="<?php echo $hiddenQuestNumId; ?> " value="<?php echo $questionNum; ?> "> <input type="hidden" id="<?php echo $fileTypeID; ?> " name="<?php echo $fileTypeID; ?> " value="file"> <?php if ($canModify) { ?> <?php if (!empty($containerUrl)) { ?> <!-- container has data so display image in Lightbox--> <div id="<?php echo $replacementDivId; ?> " name="<?php echo $replacementDivId; ?> "><!-- start of image replacement div --> <div class="col-xs-6 col-md-6"><!-- move this outside of if() test to line 190 --> <span class="glyphicon glyphicon-remove pull-right remove-cross" title="Remove File From Server" data-toggle="tooltip" id="<?php echo $glyphiconRemoveId; ?> " onclick="<?php echo $removeMethodName; ?> ('<?php echo $primaryKeyId; ?> ');" style="margin-right: 10px;"> </span> <div class="image_container"> <a href="<?php echo $containerUrl; ?> " alt="Full File"> <img class="img-responsive preview-image" src="<?php echo $fileTypeIcon; ?> " align="left" id="<?php echo $fullFileId; ?> "> <!-- <p class="text-center" style="padding-left: 20px;"><?php echo urldecode($fileName); ?> </p> --> </a> </div> <div class="row text-left text-success tdc-display-none" id="<?php echo $deleteSuccessId; ?> "> <strong>File Successfully Deleted From FileMaker</strong><br> </div> </div><!-- end of first 6 column div --> <div class="col-xs-6 col-md-6 tdc-cell-spacing"> <div class="row"> <div id="<?php echo $formDropzoneId; ?> " class="decoration dropzone"></div> </div> <div class="row pull-right upload-btn-position"> <button type="button" id="<?php echo $submitFileButtonId; ?> " class="btn btn-primary upload-btn"><?php echo $uploadButtonLabel; ?> </button> <button type="button" id="<?php echo $removeFileButtonId; ?> " class="btn btn-danger upload-btn"><?php echo $removeButtonLabel; ?> </button> </div> <div class="row text-right text-success tdc-display-none" id="<?php echo $uploadSuccessId; ?> "> <strong>Image Successfully Uploaded</strong><br> <i class="text-info"><strong>The preview of the image is not immediate available.</strong></i> </div> </div><!-- end of second 6 column div --> </div><!-- end of replacement div --> <?php } else { if (empty($containerUrl) && !empty($fileName)) { ?> <!-- container is empty but the filename field exists --> <div id="<?php echo $replacementDivId; ?> " name="<?php echo $replacementDivId; ?> "><!-- start of image replacement div --> <div class="col-xs-6 col-md-6 empty_image_container"><!-- move this outside of if() test to line 190 --> <p class="text-center">Import still processing file <?php echo $fileName; ?> .</p> <p class="text-center"> Reload page when complete.</p> </div> <div class="col-xs-6 col-md-6"> <div class="row"> <div id="<?php echo $formDropzoneId; ?> " class="decoration dropzone"></div> </div> <div class="row pull-right upload-btn-position"> <button type="button" id="<?php echo $submitFileButtonId; ?> " class="btn btn-primary upload-btn"><?php echo $uploadButtonLabel; ?> </button> <button type="button" id="<?php echo $removeFileButtonId; ?> " class="btn btn-danger upload-btn"><?php echo $removeButtonLabel; ?> </button> </div> <div class="row text-right text-success tdc-display-none" id="<?php echo $uploadSuccessId; ?> "> <strong>Image Successfully Uploaded</strong><br> <i class="text-info"><strong>The preview of the image is not immediate available.</strong></i> </div> </div> </div><!-- end of replacement div --> <?php } else { ?> <!-- No container data or filename just display Dropzone box --> <div id="<?php echo $replacementDivId; ?> " name="<?php echo $replacementDivId; ?> "><!-- start of image replacement div --> <div class="col-xs-12 col-md-12"> <div class="row"> <div id="<?php echo $formDropzoneId; ?> " class="decoration dropzone"></div> </div> <div class="row pull-right upload-btn-position"> <button type="button" id="<?php echo $submitFileButtonId; ?> " class="btn btn-primary upload-btn"><?php echo $uploadButtonLabel; ?> </button> <button type="button" id="<?php echo $removeFileButtonId; ?> " class="btn btn-danger upload-btn"><?php echo $removeButtonLabel; ?> </button> </div> <div class="row text-right text-success tdc-display-none" id="<?php echo $uploadSuccessId; ?> "> <strong>Image Successfully Uploaded</strong><br> <i class="text-info"><strong>The preview of the image is not immediate available.</strong></i> </div> </div> </div><!-- end of replacement div --> <?php } } ?> <?php } else { ?> <!-- The user cannot remove or add the file downloaded from FileMaker or else just show empty bordered DIV --> <?php if ($containerUrl) { ?> <div class="col-xs-12 col-md-12 image_container"> <a href="<?php echo $containerUrl; ?> " alt="Full File"> <img class="img-responsive preview-image" src="<?php echo $fileTypeIcon; ?> " align="left" id="<?php echo $fullFileId; ?> "> <p class="text-center" style="padding-left: 20px;"><?php echo urldecode($fileName); ?> </p> </a> </div> <?php } else { ?> <div class="col-xs-12 col-md-12 image_container"></div> <?php } ?> <?php } ?> </div> </div><!-- end of tdc-container-fluid div --> <script> $(document).ready(function () { $('<?php echo '#' . $submitFileButtonId; ?> ').hide(); $('<?php echo '#' . $removeFileButtonId; ?> ').hide(); $('<?php echo '#' . $uploadSuccessId; ?> ').hide(); $('<?php echo '#' . $deleteSuccessId; ?> ').hide(); }); function <?php echo $removeMethodName; ?> (elmId){ var pkid = document.getElementById(elmId).value; console.log("PK: " + pkid); $.ajax({ data: 'pkId=' + pkid, url: 'processing/removeFileFM.php', method: 'POST', success: function(msg){ console.log(msg); }, error: function(msg){ console.log("Error: " + msg); } }); var fileSelected = document.getElementById('<?php echo $fullFileId; ?> '); fileSelected.parentNode.removeChild(fileSelected); $('<?php echo '#' . $deleteSuccessId; ?> ').fadeIn(100).delay(5000).fadeOut(500); } Dropzone.options.<?php echo getCamelCase($formDropzoneId); ?> = { //URL to submit the for //TODO make this more dynamic Remove all hardcoded path elements in this page url: '../uploaders/imageUploader.php', //Prevent dropzone from uploading files immediately autoProcessQueue: false, //Dropzone accepts the file types to upload acceptedFiles: ".pdf, .docx, .doc, .txt, .xls, .xlsx", init: function(){ var submitButton = document.querySelector('<?php echo '#' . $submitFileButtonId; ?> '); var myDropzone = this; //closure submitButton.addEventListener("click", function(){ console.log("Event listener fired"); myDropzone.processQueue(); //Tell Dropzone to process all queued files }); this.on("sending", function(file, xhr, data) { console.log("Adding Meta record PKID to Post array"); data.append("pkId", document.getElementById('<?php echo $primaryKeyId; ?> ').value); }); //if an error is found with mime type of file hide the submit button this.on("error", function(file, response){ console.log("Error has occurred"); $('<?php echo '#' . $submitFileButtonId; ?> ').hide(); }); this.on("success", function(file, response){ console.log("Successful upload"); $('<?php echo '#' . $submitFileButtonId; ?> ').hide(); $('<?php echo '#' . $removeFileButtonId; ?> ').hide(); $('<?php echo '#' . $uploadSuccessId; ?> ').fadeIn(100).delay(5000).fadeOut(500); //Now we need to get the flag to run get the 'Just' uploaded image/file URL var runContainerUrl = <?php echo $getContainerUrl ? 'true' : 'false'; ?> ; var jsonData = JSON.parse(response); if(jsonData && jsonData.container_status){ if(jsonData.container_status != '' && jsonData.container_status == 'empty'){ console.log("We have container status of empty so now get the container URL"); <?php echo $getContainerDataMethod; ?> (document.getElementById('<?php echo $primaryKeyId; ?> ').value, myDropzone); } } }); //When a file is dropped inside Dropzone show box show button controls //TODO would like to use the success return to ensure that the button will only show when mine // type matches what we expect this.on("addedfile", function(file){ var ext = file.name.split('.').pop(); console.log("File Extension for added file: " + ext); if(ext == 'pdf'){ $(file.previewElement).find(".dz-image img").attr("src", "../images/PDF-icon_128px_red.png"); }else if(ext.indexOf('doc') != -1) { //this test was doc or docx $(file.previewElement).find(".dz-image img").attr("src", "../images/Office-Word-icon_128px_blue.png"); }else if(ext.indexOf('xls') != -1) { //this test was xls or xslx console.log("Show excel icon"); $(file.previewElement).find(".dz-image img").attr("src", "../images/excel-icon-128px.png"); }else if(ext == 'txt'){ $(file.previewElement).find(".dz-image img").attr("src", "../images/text-icon_128px.png"); } $('<?php echo '#' . $removeFileButtonId; ?> ').show(); $('<?php echo '#' . $submitFileButtonId; ?> ').show(); }); //removes files previous loaded in the Dropzone upload box //Also hides upload and reset buttons document.querySelector("button#<?php echo $removeFileButtonId; ?> ").addEventListener("click", function(){ myDropzone.removeAllFiles(); $('<?php echo '#' . $submitFileButtonId; ?> ').hide(); $('<?php echo '#' . $removeFileButtonId; ?> ').hide(); }); } } /** * Method to recursively call a PHP file and get the container URL for a given META PK * @param pkId string value of the PK for a given meta record * Note: TODO: can this be a generic method to replace a DIV encapsulating a image or file */ function <?php echo $getContainerDataMethod; ?> (pkId, myDropzone){ var getFileTimer = setTimeout(function() { console.log("getContainerData called with PKID: " + pkId); $.ajax({ url: "../uploaders/urlReloader.php", //get the file name of PHP processor to get container URL data: {"pk":pkId}, type: "POST", success: function(response){ console.log("getContainerDataMethod Success " + response); var jsonData = JSON.parse(response); if(jsonData.container_status == "empty"){ console.log("Conatiner is empty so call method again"); <?php echo $getContainerDataMethod; ?> (pkId, myDropzone); //now run this method ever 5 seconds as a thread to release browser }else{ if(jsonData.container_url) { <?php echo $rewriteImageDivMethod; ?> (pkId, document.getElementById('<?php echo $hiddenQuestNumId; ?> ').value, jsonData.container_url,jsonData.filename, myDropzone, document.getElementById('<?php echo $fileTypeID; ?> ').value); clearTimeout(getFileTimer); return false; }else{ console.log("Strange condition - container status not empty without a URL in JSON array"); } } }, error: function(response){ console.log("Error: " + response); jsonErrorData = JSON.parse(response); if(jsonErrorData.status == "error"){ console.log("Error occurred kill get URL process"); clearTimeout(getFileTimer); return false; } } }); }, 5000); //This setup to run ever 5 seconds and this needs to be adjusted to more like 1 or 2 minute cycles } /** * Rewrite the Div srounding the Image or file and replace it with the URL from the FM container * @param pk Primary meta file record id/key UUID * @param questNum the meta question number associated with item * @param url the container URL * @param filename the filename of the object file/image uploaded */ function <?php echo $rewriteImageDivMethod; ?> (pk, questNum, url, filename, dzHandle, filetype){ console.log("rewriteImageDiv PK: " + pk + " Question Number: " + questNum + " URL: " + url); //Call the php file with POST format and query string attributes $('<?php echo '#' . $replacementDivId; ?> ').load('../uploaders/loadFileImageDiv.php', {'pk':pk, 'url':url, 'questNum':questNum, 'filename':filename,'filetype':filetype}, function(){ console.log("Load complete now hide buttons"); $('<?php echo '#' . $submitFileButtonId; ?> ').hide(); $('<?php echo '#' . $removeFileButtonId; ?> ').hide(); }); dzHandle.removeAllFiles(); } </script> <?php }
$fullFileId = "fullImage" . $questionNum; $submitFileButtonId = "submit-all-" . $questionNum; $removeFileButtonId = "remove-all-" . $questionNum; $submitFileButtonId = "submit-all-" . $questionNum; $removeFileButtonId = "remove-all-" . $questionNum; $primaryKeyId = "pkid-" . $questionNum; $glyphiconRemoveId = $pkId . "_remove"; $fileDropzoneId = "file_dropzone" . $questionNum; $initDzId = "#" . $fileDropzoneId; $rawUrl = $_POST['url']; $fileUrl = urlencode($_POST['url']); $log->debug("File operation URL: " . $fileUrl); $fileTypeIcon = ""; if (isset($rawUrl) && !empty($rawUrl)) { $extension = getFileMakerContainerFileExtension($rawUrl); $fileTypeIcon = getFileIcon($extension); $log->debug("File Extension is: " . $extension . " File Type icon is: " . $fileTypeIcon); } else { $log->error("File url is empty"); } //display replacement div for files echo "<div class='col-xs-6 col-md-6'><!-- move this outside of if() test to line 190 -->"; echo "<span class='glyphicon glyphicon-remove pull-right remove-cross' title='Remove File From Server' data-toggle='tooltip' "; echo "id='{$glyphiconRemoveId}' onclick='{$removeMethodName}(\"{$primaryKeyId}\");' style='margin-right: 10px;'></span>"; echo "<div class='image_container'>"; echo "<a href='{$fileUrl}' alt='Full File'>"; echo "<img class='img-responsive preview-image' src='{$fileTypeIcon}' align='left' id='{$fullFileId}'></a>"; echo "</div>"; echo "<div class='row text-left text-success tdc-display-none' id='{$deleteSuccessId}'>"; echo "<strong>File Successfully Deleted From FileMaker</strong><br>"; echo "</div>";
} if ($handle = opendir("files/")) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." && $entry != ".DS_Store" && $entry != ".htaccess" && $entry != ".htdocs") { $sum += filesize("files/" . $entry); $num = $num + 1; $filesize = filesize("files/" . $entry); $filesize = $filesize / 1024; $filesize = $filesize / 1024; $filesize = round($filesize, 3); ?> <tr> <td><i class="fa fa-<?php echo getFileIcon($entry); ?> "></i></td> <td><?php if (isFolder($entry)) { ?> <a href="?folder=<?php echo $entry; ?> "><?php } echo $entry; ?> </td> <td><?php echo $filesize;
} } if ($PATH != "/") { echo "<tr onclick=\"document.location = '..';\"><td><i class=\"zmdi zmdi-chevron-left zmdi-hc-fw zmdi-hc-2x\"></i></td><td>" . $lang['DIRUP'] . "</b></td><td>-</td><td>" . $lang['DIRECTORY'] . "</td>"; echo "</tr>"; } foreach ($directories as $dir) { if ($dir != "_gmapi") { if ($DIRECT_DOWNLOAD) { $DL = $dir; } else { $DL = $dir; } echo "<tr onclick=\"document.location = '" . $DL . "';\"><td width=\"5\"><i class=\"zmdi zmdi-folder zmdi-hc-fw zmdi-hc-2x\"></i></td><td>" . $dir . "</td><td>-</td><td>" . $lang['DIRECTORY'] . "</td>"; echo "</tr>"; } } foreach ($files_list as $fil) { if ($DIRECT_DOWNLOAD) { $DL = $fil; } else { $DL = realpath(".") . "/download.php?f=" . $fil . "&p=" . $PATH; } echo "<tr onclick=\"document.location = '" . $DL . "';\"><td width=\"5\"><i class=\"zmdi " . getFileIcon($fil) . " zmdi-hc-fw zmdi-hc-2x\"></i></td><td>" . $fil . "</td><td>" . FSV(filesize($RPATH . "/" . $fil)) . "</td><td>" . $lang['FILE'] . "</td>"; echo "</tr>"; } ?> </div> </BODY> </HTML>
</table> <table width=100% cellspacing=1 cellpadding=5 bgcolor=gray> <tr> <td bgcolor=white> <?php if ($CA[CA_FILE]) { $wSetUpArry = explode(';', $CA[CA_FILE]); echo "<div align=right><table>"; for ($x = 0; $x < sizeof($wSetUpArry); $x++) { if (!trim($wSetUpArry[$x])) { continue; } $tmp_Size = @filesize("./data/" . $wSetUpArry[$x]); echo "<tr>"; echo "<td><a href='./data/" . $wSetUpArry[$x] . "'><img src='" . getFileIcon($wSetUpArry[$x]) . "' align=absmiddle> <font class=Blink>" . $wSetUpArry[$x] . "</font></a></td>"; echo "<td>(" . getSizeFormat($tmp_Size, 1) . ")</td>"; echo "</tr>"; } echo "</table></div><p>"; } ?> <?php echo getContents($CA[CA_CONTENT], $CA[CA_HTML]); ?> <p> </td> </tr> </table> <p>