Ejemplo n.º 1
0
/**
 * Method to create the tdc-app-config.php file, get small company image file, save image file to disk, and
 * write the image file location to tdc-app-config.php file
 * @param $userRecordHandle FileMaker record handle to current user
 * @param $imageDir Name of image directory (img or images)
 * @param $imageSmallFileName File name where the image must be stored
 * @param $propertySmallName Name of property where the location of the image file is written
 * @param $imageSplashFileName Name of property where splash image is found
 * @param $propertySplashName = Name of property name for Splash image
 * @param $configFileName Name of configuration file (currently td-app-config.php)
 *
 */
function writeFilesDynamically($userRecordHandle, $imageDir, $imageSmallFileName, $propertySmallName, $imageSplashFileName, $propertySplashName, $configFileName)
{
    global $log, $fmOrderDB, $root;
    $log->debug("--> Start Configuration write and get images from FileMaker");
    $log->debug("Get Small image from FileMaker");
    $logoSmallUrl = $userRecordHandle->getField('z_SYS_Client_Logo_Print_Small_cc');
    $fileTypeSmall = getFileMakerContainerFileExtension($logoSmallUrl);
    $log->debug("Small Logo URL: " . $logoSmallUrl);
    $fullSmallImagePath = $imageDir . "/" . $imageSmallFileName . $fileTypeSmall;
    $fullSmallImageWritePath = $root . $imageDir . "/" . $imageSmallFileName . $fileTypeSmall;
    //Get the actual image object from the container and then save image to filesystem
    $smallImage = $fmOrderDB->getContainerData($logoSmallUrl);
    $log->debug("Have Small image file, type, and path: " . $fullSmallImagePath);
    $log->debug("Get Splash image from FileMaker");
    $logoSplashURL = $userRecordHandle->getField("z_SYS_Client_Logo_Splash_Screen_cc");
    $fileTypeSplash = getFileMakerContainerFileExtension($logoSplashURL);
    $fullSplashImagePath = $imageDir . "/" . $imageSplashFileName . $fileTypeSplash;
    $fullSplashImageWritePath = $root . $imageDir . "/" . $imageSplashFileName . $fileTypeSplash;
    $splashImage = $fmOrderDB->getContainerData($logoSplashURL);
    $log->debug("Have Splash image file, type, and path: " . $fullSplashImagePath);
    //If the image exists then write the image file to image directory then create app-config file
    //should this page fail then the user will see the alt text of logo image tag
    if (isset($smallImage) && !empty($smallImage) && (isset($splashImage) && !empty($splashImage))) {
        $log->debug("Got Small image from FileMaker now write the image: " . $fullSmallImagePath . " to disk");
        $log->debug("Got Splash image from FileMaker now write the image: " . $fullSplashImagePath . " to disk");
        $fp = fopen($fullSmallImageWritePath, "w") or $log->error("Unable to open Small file " . $fullSmallImageWritePath);
        fwrite($fp, $smallImage);
        fclose($fp);
        $fp = fopen($fullSplashImageWritePath, "w") or $log->error("Unable to open Splash file " . $fullSplashImageWritePath);
        fwrite($fp, $splashImage);
        fclose($fp);
        //Now create the app-config file
        $phpHeader = "<?php" . PHP_EOL;
        $phpFooter = "?>";
        $propertyOut = $propertySmallName . " \"" . $fullSmallImagePath . "\"" . ";" . PHP_EOL;
        $propertySplashOut = $propertySplashName . " \"" . $fullSplashImagePath . "\"" . ";" . PHP_EOL;
        $fp = fopen($root . $configFileName, "w") or $log->error("Unable to open file: " . $root . $configFileName);
        fwrite($fp, $phpHeader);
        fwrite($fp, $propertyOut);
        fwrite($fp, $propertySplashOut);
        fwrite($fp, $phpFooter);
        fclose($fp);
        $log->debug("Finished writing both Small and Splash images and app-config files");
    } else {
        $log->error("Image Small or Splash within FileMaker container was empty for user:  "******"--> End Configuration file write amd image save method");
}
Ejemplo n.º 2
0
 * User: Bill
 * Date: 8/14/2015
 * Time: 10:09 AM
 *
 * This code is used to display an image directly from the FileMaker database. This code is not in use at the time this
 * file was generated. However, it is expected that at some point this functionality might be required.
 *
 */
include_once "onspot-config.php";
include_once $fmfiles . "work.db.php";
include_once $utilities . "utility.php";
if (isset($_GET['url'])) {
    $url = $_GET['url'];
}
if (isset($url) && !empty($url)) {
    $fileType = getFileMakerContainerFileExtension($url);
    if ($fileType == 'jpg') {
        header("Content-type: image/jpeg");
    } else {
        if ($fileType == "gif") {
            header("Content-type: image/gif");
        } else {
            if ($fileType == "png") {
                header("Content-type image/png");
            } else {
                if ($fileType == "bmp") {
                    header("Content-type image/bmp");
                } elseif ($fileType == "ico") {
                    header("Content-type image/x-icon");
                } else {
                    $log->warn("File type is not supported: " . $fileType);
Ejemplo n.º 3
0
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>
                    &nbsp;<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>
                    &nbsp;<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>
                    &nbsp;<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 
}
Ejemplo n.º 4
0
 $removeMethodName = "removeFile" . $questionNum;
 $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>";
Ejemplo n.º 5
0
        $message = "A serious error has occurred, please contact Thought Development Support to correct the issue.";
        $log->error("Customer Message: " . $message . " FileMaker Error: " . $spotRecords->getMessage() . " User: "******"";
$videoType = "";
$fullVideoLink = "";
//TODO modify this record to use the container if URL exists for container if not then use full path ct field
if (!empty($record->getField('z_ONSPOT_Rough_Media_Store_con'))) {
    $container_url = $record->getField('z_ONSPOT_Rough_Media_Store_con');
    $ext = getFileMakerContainerFileExtension($container_url);
    $videoType = getVideoSourceType($ext);
    $getContainerUrl = $fmWorkDB->getContainerDataURL($container_url);
    $fullVideoLink = getUserVideoUrl($getContainerUrl, $serverIP);
    $log->debug("URL from Container value: " . $fullVideoLink . " video type: " . $videoType);
} else {
    $fullPathField = "z_ONSPOT_Rough_Full_Path_ct";
    $fullVideoLink = $record->getField($fullPathField);
    $ext = getFileExtensionFromURL($fullVideoLink);
    $videoType = getVideoSourceType($ext);
    $log->debug("URL from field Full Path value: " . $fullVideoLink . " video type: " . $videoType);
}
//This will now extract Spot Image full path from FileMaker without injecting path information manually
//----> At this point if viewOnly is true then we want to skip the query for user notes or loading any value lists. <----////
if (!$bypass) {
    //Approval Value List
Ejemplo n.º 6
0
function writeLogosWithLdap()
{
    global $log, $fmOrderDB, $root, $appConfigName;
    $companyLogoSmallPropertyName = '$companyLogoSmall =';
    $companyLogoSplashPropertyName = '$companyLogoSplash =';
    $imageDir = "images";
    $imageSmallFileName = "company_logo_small.";
    $imageSplashFileName = "company_logo_splash.";
    $userNamePropertyField = '$username = ""';
    $baseDnPropertyName = '$baseDnValue = ';
    $companyDomainPropertyName = '$companyDomainValue = ';
    $ldapServerPropertyName = '$ldapServerValue = ';
    $ldapPortPropertyName = '$ldapPortValue = ';
    $ldapGroupNamePropertyName = '$ldapGroupNameValue = ';
    $ldapFieldsToSearchPropertyName = '$ldapfieldsToSearchValue = ';
    $ldapRawFilterPropertyName = '$ldapRawFilterValue = ';
    $hasLdapInfoPropertyName = '$hasLdapInfo =';
    $fieldNameArray = array("baseDnField", "companyDomainField", "ldapServerField", "ldapPortField", "groupNamesField", "fieldsToSearchField", "ldapRawFilterField");
    $loginLayout = '[WEB] Login';
    $allRecordSearch = $fmOrderDB->newFindAllCommand($loginLayout);
    $results = $allRecordSearch->execute();
    if (FileMaker::isError($results)) {
        $log->error("FindAll user records failed with error message: " . $results->getMessage());
        //for now
        exit;
    }
    $loginRecord = $results->getFirstRecord();
    //*** Start Image fetch and write operation
    $log->debug("--> Start Configuration write and get images from FileMaker");
    $log->debug("Get Small image from FileMaker");
    $logoSmallUrl = $loginRecord->getField('z_SYS_Client_Logo_Print_Small_cc');
    $fileTypeSmall = getFileMakerContainerFileExtension($logoSmallUrl);
    $log->debug("Small Logo URL: " . $logoSmallUrl);
    $fullSmallImagePath = $imageDir . "/" . $imageSmallFileName . $fileTypeSmall;
    $fullSmallImageWritePath = $root . $imageDir . "/" . $imageSmallFileName . $fileTypeSmall;
    //Get the actual image object from the container and then save image to filesystem
    $smallImage = $fmOrderDB->getContainerData($logoSmallUrl);
    $log->debug("Have Small image file, type, and path: " . $fullSmallImagePath);
    $log->debug("Get Splash image from FileMaker");
    $logoSplashURL = $loginRecord->getField("z_SYS_Client_Logo_Splash_Screen_cc");
    $fileTypeSplash = getFileMakerContainerFileExtension($logoSplashURL);
    $fullSplashImagePath = $imageDir . "/" . $imageSplashFileName . $fileTypeSplash;
    $fullSplashImageWritePath = $root . $imageDir . "/" . $imageSplashFileName . $fileTypeSplash;
    $splashImage = $fmOrderDB->getContainerData($logoSplashURL);
    $log->debug("Have Splash image file, type, and path: " . $fullSplashImagePath);
    //*** End Image fetch and right
    //Start loading LDAP information from the [WEB} Login layout
    $baseDnField = $loginRecord->getField("ONWEB_LDAP_base_dn_ct");
    $companyDomainField = $loginRecord->getField('ONWEB_LDAP_company_domain_ct');
    $ldapServerField = $loginRecord->getField('ONWEB_LDAP_server_ct');
    $ldapPortField = $loginRecord->getField('ONWEB_LDAP_port_ct');
    $groupNamesField = array($loginRecord->getField('ONWEB_LDAP_group_name_ct'));
    $fieldsToSearchField = array($loginRecord->getField('ONWEB_LDAP_fieldsToSearch_ct'));
    $ldapRawFilterField = html_entity_decode($loginRecord->getField('ONWEB_LDAP_filter_ct'));
    //End loading LDAP information
    $fieldsNotNull = 1;
    foreach ($fieldNameArray as $fieldName) {
        if (!isset(${$fieldName}) || empty(${$fieldName})) {
            $fieldsNotNull = 0;
        }
    }
    //If the image exists then write the image file to image directory then create app-config file
    //should this page fail then the user will see the alt text of logo image tag
    if (isset($smallImage) && !empty($smallImage) && (isset($splashImage) && !empty($splashImage))) {
        $log->debug("Got Small image from FileMaker now write the image: " . $fullSmallImagePath . " to disk");
        $log->debug("Got Splash image from FileMaker now write the image: " . $fullSplashImagePath . " to disk");
        $fp = fopen($fullSmallImageWritePath, "w") or $log->error("Unable to open Small file " . $fullSmallImageWritePath);
        fwrite($fp, $smallImage);
        fclose($fp);
        $fp = fopen($fullSplashImageWritePath, "w") or $log->error("Unable to open Splash file " . $fullSplashImageWritePath);
        fwrite($fp, $splashImage);
        fclose($fp);
        //Now create the app-config file
        $phpHeader = "<?php" . PHP_EOL;
        $phpFooter = "?>";
        $propertyOut = $companyLogoSmallPropertyName . " \"" . $fullSmallImagePath . "\"" . ";" . PHP_EOL;
        $propertySplashOut = $companyLogoSplashPropertyName . " \"" . $fullSplashImagePath . "\"" . ";" . PHP_EOL;
        $fp = fopen($root . $appConfigName, "w") or $log->error("Unable to open file: " . $root . $appConfigName);
        fwrite($fp, $phpHeader);
        fwrite($fp, $propertyOut);
        fwrite($fp, $propertySplashOut);
        fwrite($fp, $baseDnPropertyName . "\"" . $baseDnField . "\"" . ";" . PHP_EOL);
        fwrite($fp, $userNamePropertyField . ";" . PHP_EOL);
        fwrite($fp, $companyDomainPropertyName . "\"" . $companyDomainField . "\"" . ";" . PHP_EOL);
        fwrite($fp, $ldapServerPropertyName . "\"" . $ldapServerField . "\"" . ";" . PHP_EOL);
        fwrite($fp, $ldapPortPropertyName . "\"" . $ldapPortField . "\"" . ";" . PHP_EOL);
        fwrite($fp, $ldapGroupNamePropertyName . "\"" . implode(",", $groupNamesField) . "\"" . ";" . PHP_EOL);
        fwrite($fp, $ldapFieldsToSearchPropertyName . '\'' . implode(",", $fieldsToSearchField) . '\'' . ";" . PHP_EOL);
        fwrite($fp, $ldapRawFilterPropertyName . "\"" . $ldapRawFilterField . "\"" . ";" . PHP_EOL);
        fwrite($fp, $hasLdapInfoPropertyName . " " . $fieldsNotNull . ";" . PHP_EOL);
        fwrite($fp, $phpFooter);
        fclose($fp);
        $log->debug("Finished writing both Small and Splash images to include LDAP information and app-config files");
    } else {
        $log->error("Image Small or Splash within FileMaker container was empty at time of login");
    }
    $log->debug("Finished loading logos and LDAP information to tdc-app-config.php file");
}