Example #1
0
 public static function delete($id)
 {
     $sql = sprintf("DELETE FROM `permissions` WHERE `formID`='%s'", mfcs::$engine->openDB->escape($id));
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     return TRUE;
 }
Example #2
0
 public static function insert($action, $objectID = 0, $formID = 0, $info = NULL)
 {
     $sql = sprintf("INSERT INTO `logs` (`username`,`IP`,`action`,`objectID`,`formID`,`info`,`date`) VALUES('%s','%s','%s','%s','%s','%s','%s')", mfcs::$engine->openDB->escape(users::user('username')), mfcs::$engine->openDB->escape($_SERVER['REMOTE_ADDR']), mfcs::$engine->openDB->escape($action), mfcs::$engine->openDB->escape($objectID), mfcs::$engine->openDB->escape($formID), mfcs::$engine->openDB->escape($info), time());
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     return TRUE;
 }
Example #3
0
 public static function updateFormNav($groupings)
 {
     $groupings = json_decode($groupings, TRUE);
     if (!is_empty($groupings)) {
         foreach ($groupings as $I => $grouping) {
             $positions[$I] = $grouping['position'];
         }
         array_multisort($positions, SORT_ASC, $groupings);
     }
     $groupings = encodeFields($groupings);
     $sql = sprintf("UPDATE `forms` SET `navigation`='%s' WHERE `ID`='%s'", mfcs::$engine->openDB->escape($groupings), mfcs::$engine->cleanGet['MYSQL']['id']);
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         errorHandle::newError(__METHOD__ . "() - " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     return TRUE;
 }
Example #4
0
 public static function updateDupeTable($formID, $objectID, $data)
 {
     // trans begin
     $result = mfcs::$engine->openDB->transBegin("objects");
     if ($result !== TRUE) {
         errorHandle::newError(__METHOD__ . "() - unable to start database transactions", errorHandle::DEBUG);
         return FALSE;
     }
     // wipe the old dupe information
     $sql = sprintf("DELETE FROM `dupeMatching` WHERE `formID`='%s' AND `objectID`='%s'", mfcs::$engine->openDB->escape($formID), mfcs::$engine->openDB->escape($objectID));
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         mfcs::$engine->openDB->transRollback();
         mfcs::$engine->openDB->transEnd();
         errorHandle::newError(__METHOD__ . "() - removing from duplicate table: " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     //insert data
     foreach ($data as $name => $raw) {
         if (!isset(mfcs::$engine->cleanPost['MYSQL'][$name]) || isempty(mfcs::$engine->cleanPost['MYSQL'][$name])) {
             if (!isempty($raw)) {
                 http::setPost($name, $raw);
                 $postSet = TRUE;
             } else {
                 continue;
             }
         }
         $sql = sprintf("INSERT INTO `dupeMatching` (`formID`,`objectID`,`field`,`value`) VALUES('%s','%s','%s','%s')", mfcs::$engine->openDB->escape($formID), mfcs::$engine->openDB->escape($objectID), mfcs::$engine->openDB->escape($name), mfcs::$engine->cleanPost['MYSQL'][$name]);
         $sqlResult = mfcs::$engine->openDB->query($sql);
         if (isset($postSet) && $postSet === TRUE) {
             http::setPost($name, "");
         }
         if (!$sqlResult['result']) {
             mfcs::$engine->openDB->transRollback();
             mfcs::$engine->openDB->transEnd();
             errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
             return FALSE;
         }
     }
     // trans commit
     mfcs::$engine->openDB->transCommit();
     mfcs::$engine->openDB->transEnd();
     return TRUE;
 }
Example #5
0
 public static function getUsers()
 {
     $sql = sprintf("SELECT `ID` FROM `users`");
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     $users = array();
     while ($row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC)) {
         if (($user = self::get($row['ID'])) == FALSE) {
             return FALSE;
         }
         $users[] = $user;
     }
     return $users;
 }
Example #6
0
 public static function retrieveData($formID, $fieldName = NULL)
 {
     $sql = sprintf("SELECT * FROM `objectsData` WHERE `formID`='%s'", mfcs::$engine->openDB->escape($formID));
     if (!isnull($fieldName)) {
         $sql .= "AND `fieldName`='" . mfcs::$engine->openDB->escape($fieldName) . "'";
     }
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     $data = array();
     while ($row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC)) {
         if (!isnull($fieldName) && $row['fieldName'] != $fieldName) {
             continue;
         }
         if ($row['encoded'] == "1") {
             $row['value'] = decodeFields($row['value']);
         }
         $data[] = $row;
     }
     return $data;
 }
Example #7
0
 public static function processObjectFiles($assetsID, $options)
 {
     // Disable PHP's max execution time
     set_time_limit(0);
     $saveBase = mfcs::config('convertedPath');
     $originalsFilepath = self::getSaveDir($assetsID, 'archive');
     $originalFiles = scandir($originalsFilepath);
     // Setup return array
     $return = array('processed' => array(), 'combine' => array(), 'thumbs' => array(), 'ocr' => array());
     // Remove dot files from array
     foreach ($originalFiles as $I => $filename) {
         if ($filename[0] == '.') {
             unset($originalFiles[$I]);
         }
     }
     // Needed to put the files in the right order for processing
     if (natcasesort($originalFiles) === FALSE) {
         return FALSE;
     }
     try {
         // If combine files is checked, read this image and add it to the combined object
         if (isset($options['combine']) && str2bool($options['combine'])) {
             try {
                 $errors = array();
                 $createThumb = TRUE;
                 // Create us some temp working space
                 $tmpDir = mfcs::config('mfcstmp') . DIRECTORY_SEPARATOR . uniqid();
                 mkdir($tmpDir, 0777, TRUE);
                 // Ensure that the HOCR file is created
                 if (!self::createHOCR("{$saveBase}/hocr.cfg")) {
                     return FALSE;
                 }
                 $gsTemp = $tmpDir . DIRECTORY_SEPARATOR . uniqid();
                 touch($gsTemp);
                 foreach ($originalFiles as $filename) {
                     // Figure some stuff out about the file
                     $originalFile = $originalsFilepath . DIRECTORY_SEPARATOR . $filename;
                     $_filename = pathinfo($originalFile);
                     $filename = $_filename['filename'];
                     $baseFilename = $tmpDir . DIRECTORY_SEPARATOR . $filename;
                     // Create a thumbnail of the first image
                     if ($createThumb === TRUE) {
                         if (($return['combine'][] = self::createThumbnail($originalFile, $filename, $options, $assetsID, TRUE)) === FALSE) {
                             throw new Exception("Failed to create thumbnail: " . $filename);
                         }
                         // Prevent making multiple thumbnails
                         $createThumb = FALSE;
                     }
                     // perform hOCR on the original uploaded file which gets stored in combined as an HTML file
                     $_exec = shell_exec(sprintf('tesseract %s %s -l eng %s 2>&1', escapeshellarg($originalFile), escapeshellarg($baseFilename), escapeshellarg("{$saveBase}/hocr.cfg")));
                     // If a new-line char is in the output, assume it's an error
                     // Tesseract failed, let's normalize the image and try again
                     if (strpos(trim($_exec), "\n") !== FALSE) {
                         $errors[] = "Unable to process OCR for " . basename($originalFile) . ". Continuing…";
                         errorHandle::warningMsg("Unable to process OCR for " . basename($originalFile) . ". Continuing…");
                         // Ensure HTML file exists
                         touch($baseFilename . ".html");
                     }
                     // Create an OCR'd pdf of the file
                     $_exec = shell_exec(sprintf('hocr2pdf -i %s -s -o %s < %s 2>&1', escapeshellarg($originalFile), escapeshellarg($baseFilename . ".pdf"), escapeshellarg($baseFilename . ".html")));
                     if (trim($_exec) !== 'Writing unmodified DCT buffer.') {
                         if (strpos($_exec, 'Warning:') !== FALSE) {
                             errorHandle::newError("hocr2pdf Warning: " . $_exec, errorHandle::DEBUG);
                         } else {
                             errorHandle::errorMsg("Failed to Create PDF: " . basename($filename, "jpg") . ".pdf");
                             throw new Exception("hocr2pdf Error: " . $_exec);
                         }
                     }
                     // Add this pdf to a temp file that will be read in by gs
                     file_put_contents($gsTemp, $baseFilename . ".pdf" . PHP_EOL, FILE_APPEND);
                     // We're done with this file, delete it
                     unlink($baseFilename . ".html");
                 }
                 // Combine all PDF files in directory
                 $_exec = shell_exec(sprintf('gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=%s @%s 2>&1', self::getSaveDir($assetsID, 'combine') . "combined.pdf", $gsTemp));
                 if (!is_empty($_exec)) {
                     errorHandle::errorMsg("Failed to combine PDFs into single PDF.");
                     throw new Exception("GhostScript Error: " . $_exec);
                 }
                 $return['combine'][] = array('name' => 'combined.pdf', 'path' => self::getSaveDir($assetsID, 'combine', FALSE), 'size' => filesize(self::getSaveDir($assetsID, 'combine') . 'combined.pdf'), 'type' => 'application/pdf', 'errors' => $errors);
                 // Lastly, we delete our temp working dir (always nice to cleanup after yourself)
                 if (self::cleanupTempDirectory($tmpDir) === FALSE) {
                     errorHandle::errorMsg("Unable to clean up temporary directory: " . $tmpDir);
                     throw new Exception("Unable to clean up temporary directory: " . $tmpDir);
                 }
             } catch (Exception $e) {
                 // We need to delete our working dir
                 if (isset($tmpDir) && is_dir($tmpDir)) {
                     if (self::cleanupTempDirectory($tmpDir) === FALSE) {
                         errorHandle::errorMsg("Unable to clean up temporary directory (in Exception): " . $tmpDir);
                     }
                 }
                 throw new Exception($e->getMessage(), $e->getCode(), $e);
             }
         }
         // If Combine
         // This conditional needs updated when different conversion options are added or removed.
         // If the file has no processing to do, don't do any ...
         if (!isset($options['convert']) && !isset($options['thumbnail']) && !isset($options['ocr']) && !isset($options['mp3'])) {
             return $return;
         }
         foreach ($originalFiles as $filename) {
             $originalFile = $originalsFilepath . DIRECTORY_SEPARATOR . $filename;
             $_filename = pathinfo($originalFile);
             $filename = $_filename['filename'];
             // Convert uploaded files into some ofhter size/format/etc
             if (isset($options['convert']) && str2bool($options['convert'])) {
                 // we create the Imagick object here so that we can pass it to thumbnail creation
                 $image = new Imagick();
                 $image->readImage($originalFile);
                 // Convert it
                 if (($image = self::convertImage($image, $options, $assetsID, $filename)) === FALSE) {
                     throw new Exception("Failed to create processed image: " . $originalFile);
                 }
                 $filename = $filename . '.' . strtolower($image->getImageFormat());
                 // Create a thumbnail that includes converted options
                 if (isset($options['thumbnail']) && str2bool($options['thumbnail'])) {
                     if (($return['thumbs'][] = self::createThumbnail($image, $filename, $options, $assetsID)) === FALSE) {
                         throw new Exception("Failed to create thumbnail: " . $filename);
                     }
                 }
                 // Set the return array
                 $return['processed'][] = array('name' => $filename, 'path' => self::getSaveDir($assetsID, 'processed', FALSE), 'size' => filesize(self::getSaveDir($assetsID, 'processed') . $filename), 'type' => self::getMimeType(self::getSaveDir($assetsID, 'processed') . $filename), 'errors' => '');
             } else {
                 if (isset($options['thumbnail']) && str2bool($options['thumbnail'])) {
                     if (($return['thumbs'][] = self::createThumbnail($originalFile, $filename, $options, $assetsID)) === FALSE) {
                         throw new Exception("Failed to create thumbnail: " . $filename);
                     }
                 }
             }
             // Create an OCR text file
             if (isset($options['ocr']) && str2bool($options['ocr'])) {
                 if (($return['ocr'][] = self::createOCRTextFile($originalFile, $assetsID, $filename)) === FALSE) {
                     errorHandle::errorMsg("Failed to create OCR text file: " . $filename);
                     throw new Exception("Failed to create OCR file for {$filename}");
                 }
             }
             // Create MP3
             if (isset($options['mp3']) && str2bool($options['mp3'])) {
                 $return['mp3'][] = self::createMP3($originalFile);
             }
         }
         // Foreach File
     } catch (Exception $e) {
         errorHandle::newError(__METHOD__ . "() - {$e->getMessage()} {$e->getLine()}:{$e->getFile()}", errorHandle::HIGH);
     }
     return $return;
 }
Example #8
0
            die(revisions::generateFieldDisplay($revision, $fields));
        }
    }
    ###############################################################################################################
    // Build the select list
    $selectARevision = "";
    foreach ($revisions->getSecondaryIDs($engine->cleanGet['MYSQL']['objectID'], 'DESC') as $revisionID) {
        $selectARevision .= sprintf('<option value="%s">%s</option>', $revisionID, date('D, M d, Y - h:i a', $revisionID));
    }
    localVars::add("selectARevision", $selectARevision);
    localvars::add("formName", $form['title']);
    localvars::add("objectID", $objectID);
    localvars::add("currentVersion", revisions::generateFieldDisplay($object, $fields));
} catch (Exception $e) {
    log::insert("Data Entry: Revision: Caught Exception", 0, 0, $e->getMessage());
    errorHandle::newError($e->getMessage(), errorHandle::DEBUG);
    errorHandle::errorMsg($e->getMessage());
}
localVars::add("results", displayMessages());
$engine->eTemplate("include", "header");
?>

<form id="revisionForm" action="" method="post">
	{engine name="csrf"}
	<input type="hidden" name="revisionID" id="revisionID" value="">
</form>


<header class="page-header">
	<h1>{local var="formName"}</h1>
</header>
Example #9
0
     $object = objects::get($engine->cleanGet['MYSQL']['objectID']);
     http::setGet('formID', $object['formID']);
 }
 // Object ID Validation
 if (objects::validID(TRUE) === FALSE) {
     throw new Exception("ObjectID Provided is invalid.");
 }
 if (forms::validID() === FALSE) {
     throw new Exception("No Form ID Provided.");
 }
 if (mfcsPerms::isViewer($engine->cleanGet['MYSQL']['formID']) === FALSE) {
     $permissions = FALSE;
     throw new Exception("Permission Denied to view objects created with this form.");
 }
 if (!objects::checkObjectInForm($engine->cleanGet['MYSQL']['formID'], $engine->cleanGet['MYSQL']['objectID'])) {
     errorHandle::newError("Object not from this form.", errorHandle::DEBUG);
     throw new Exception("Object not from this form");
 }
 log::insert("Data View: Object", $engine->cleanGet['MYSQL']['objectID'], $engine->cleanGet['MYSQL']['formID']);
 //////////
 // Metadata Tab Stuff
 $form = forms::get($engine->cleanGet['MYSQL']['formID']);
 if ($form === FALSE) {
     throw new Exception("Error retrieving form.");
 }
 localvars::add("formName", $form['title']);
 // build the form for displaying
 $builtForm = forms::build($engine->cleanGet['MYSQL']['formID'], $engine->cleanGet['MYSQL']['objectID']);
 if ($builtForm === FALSE) {
     throw new Exception("Error building form.");
 }
Example #10
0
 /**
  * Object cache manager
  *
  * This function identifies cache by the class by default. So each class gets 1 cache. If you
  * need more than 1 cache per class that should be handled internal to the calling class using
  * the $cachID to distinguish.
  *
  *
  * @param string $action create, update, delete, or get
  * @param $cacheID
  *        How the calling method/fucntion identifies the cache.<br>
  *        If the calling function or class will be using multiple<br>
  *        caches it should add cache name information to this as well.
  * @param mixed $value
  *        The value to be stored. (required for everything except "get")
  * @return bool
  */
 public function cache($action, $cacheID, $value = NULL)
 {
     // for security we have to determine the function ID ourselves.
     // otherwise a malicious module/object author could overwrite the permissions cache
     $trace = debug_backtrace();
     $caller = $trace[1];
     $functionID = isset($caller['class']) ? $caller['class'] : $caller['function'];
     if ($action == "create") {
         if (isnull($value)) {
             errorHandle::newError(__METHOD__ . "() - value not provided.", errorHandle::DEBUG);
             return FALSE;
         }
         if (isset($this->cache[$functionID][$cacheID])) {
             errorHandle::newError(__METHOD__ . "() - cachID found. use update", errorHandle::DEBUG);
             return FALSE;
         }
         $this->cache[$functionID][$cacheID] = $value;
     } else {
         if ($action == "update") {
             if (isnull($value)) {
                 errorHandle::newError(__METHOD__ . "() - value not provided.", errorHandle::DEBUG);
                 return FALSE;
             }
             if (!isset($this->cache[$functionID][$cacheID])) {
                 errorHandle::newError(__METHOD__ . "() - cachID not found. use create", errorHandle::DEBUG);
                 return FALSE;
             }
             $this->cache[$functionID][$cacheID] = $value;
         } else {
             if ($action == "delete") {
                 if (isnull($value)) {
                     errorHandle::newError(__METHOD__ . "() - value not provided.", errorHandle::DEBUG);
                     return FALSE;
                 }
                 if (!isset($this->cache[$functionID][$cacheID])) {
                     errorHandle::newError(__METHOD__ . "() - cachID not found. use create", errorHandle::DEBUG);
                     return FALSE;
                 }
                 unset($this->cache[$functionID][$cacheID]);
             } else {
                 if ($action == "get") {
                     if (isset($this->cache[$functionID][$cacheID])) {
                         return $this->cache[$functionID][$cacheID];
                     }
                     return NULL;
                 } else {
                     errorHandle::newError(__METHOD__ . "() - Action '" . $action . "' not allowed.", errorHandle::DEBUG);
                     return FALSE;
                 }
             }
         }
     }
     return TRUE;
 }
Example #11
0
 private static function genLinkURLs($type, $objectID)
 {
     switch (trim(strtolower($type))) {
         case 'view':
             return sprintf('<a href="%sdataView/object.php?objectID=%s">View</a>', localvars::get("siteRoot"), $objectID);
             break;
         case 'edit':
             return sprintf('<a href="%sdataEntry/object.php?objectID=%s">Edit</a>', localvars::get("siteRoot"), $objectID);
             break;
         case 'revisions':
             $revisions = new revisionControlSystem('objects', 'revisions', 'ID', 'modifiedTime');
             return $revisions->hasRevisions($objectID) ? sprintf('<a href="%sdataEntry/revisions/index.php?objectID=%s">View</a>', localvars::get("siteRoot"), $objectID) : '<span style="font-style:italic; color:#ccc;">View</span>';
             break;
         default:
             errorHandle::newError(__METHOD__ . "() - Invalid type passed!", errorHandle::LOW);
             return '';
             break;
     }
 }
Example #12
0
 public static function insertObjectData($objectID, $data, $formID)
 {
     if (!is_array($data)) {
         return FALSE;
     }
     if (mfcs::$engine->openDB->transBegin("objectsData") !== TRUE) {
         errorHandle::newError(__METHOD__ . "() - unable to start database transactions", errorHandle::DEBUG);
         return FALSE;
     }
     // remove old data
     $sql = sprintf("DELETE FROM `objectsData` WHERE `objectID`='%s'", $objectID);
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         mfcs::$engine->openDB->transRollback();
         mfcs::$engine->openDB->transEnd();
         errorHandle::newError(__METHOD__ . "() - " . $sql . " -- " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     // insert new data
     foreach ($data as $I => $V) {
         $encoded = 0;
         if (is_array($V)) {
             // encode it
             $V = encodeFields($V);
             $encoded = 1;
         }
         $sql = sprintf("INSERT INTO `objectsData` (formID,objectID,fieldName,value,encoded) VALUES('%s','%s','%s','%s','%s')", mfcs::$engine->openDB->escape($formID), mfcs::$engine->openDB->escape($objectID), mfcs::$engine->openDB->escape($I), mfcs::$engine->openDB->escape($V), mfcs::$engine->openDB->escape($encoded));
         $sqlResult = mfcs::$engine->openDB->query($sql);
         if (!$sqlResult['result']) {
             mfcs::$engine->openDB->transRollback();
             mfcs::$engine->openDB->transEnd();
             errorHandle::newError(__METHOD__ . "() - " . $sql . " -- " . $sqlResult['error'], errorHandle::DEBUG);
             return FALSE;
         }
     }
     mfcs::$engine->openDB->transCommit();
     mfcs::$engine->openDB->transEnd();
     return TRUE;
 }
Example #13
0
    }
} catch (Exception $e) {
    errorHandle::errorMsg($e->getMessage());
}
// Get List of existing watermarks
$sql = sprintf("SELECT * FROM `watermarks` ORDER BY `name`");
$sqlResult = $engine->openDB->query($sql);
if ($sqlResult['result']) {
    $tmp = NULL;
    while ($row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC)) {
        try {
            $i = new Imagick();
            $i->readImageBlob($row['data']);
            $tmp .= sprintf('<li><a href="?id=%s">%s<br><img src="data:image/%s;base64,%s"></a></li>', htmlSanitize($row['ID']), htmlSanitize($row['name']), strtolower($i->getImageFormat()), base64_encode($row['data']));
        } catch (Exception $e) {
            errorHandle::newError("readImageBlob failed - {$e->getMessage()}", errorHandle::HIGH);
            errorHandle::errorMsg("Failed to load watermark.");
        }
    }
    localVars::add("existingWatermarks", $tmp);
    unset($tmp);
}
// Get List of existing watermarks
if (!isnull($ID)) {
    localVars::add("headerText", "Update Watermark");
    localVars::add("submitBtn", '<button type="submit" name="update" class="btn">Update</button><button type="submit" name="delete" class="btn">Delete</button>');
    $sql = sprintf("SELECT * FROM `watermarks` WHERE ID='%s' LIMIT 1", $engine->openDB->escape($ID));
    $sqlResult = $engine->openDB->query($sql);
    if ($sqlResult['result']) {
        $row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC);
        localVars::add("nameVal", $row['name']);
Example #14
0
            ${$targetVar} .= sprintf('<li data-type="metadataForm" data-formid="%s"><a href="#" class="btn btn-block">%s</a></li>', htmlSanitize($form['formID']), htmlSanitize($form['title']));
        }
        localvars::add("selectedMetadataForms", $selectedMetadataForms);
        if (!empty($metadataFormsEven) || !empty($metadataFormsOdd)) {
            localvars::add("metadataForms", sprintf('
				<h3>Metadata Forms</h3>
				<div class="row-fluid">
					<ul class="unstyled draggable span6">%s</ul>
					<ul class="unstyled draggable span6">%s</ul>
				</div>', $metadataFormsEven, $metadataFormsOdd));
        }
        // Get existing groupings
        $sql = sprintf("SELECT * FROM `forms` WHERE `ID`='%s' LIMIT 1", $engine->openDB->escape($formID));
        $sqlResult = $engine->openDB->query($sql);
        if (!$sqlResult['result']) {
            errorHandle::newError("MySQL Error - Error getting project ({$sqlResult['error']})", errorHandle::DEBUG);
            throw new Exception("Error getting navigation");
        }
        $row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC);
        if (!is_empty($row['navigation'])) {
            $tmp = decodeFields($row['navigation']);
            $groupings = array();
            $preview = NULL;
            // Get all groupings needed
            foreach ($tmp as $I => $V) {
                if (!is_empty($V['grouping'])) {
                    $groupings[$V['grouping']] = array("type" => "grouping", "grouping" => $V['grouping']);
                }
            }
            $positionOffset = 0;
            foreach ($tmp as $I => $V) {
Example #15
0
require "engineInclude.php";
if (!isCLI()) {
    recurseInsert("acl.php", "php");
}
recurseInsert("dbTableList.php", "php");
$engine->dbConnect("database", "mfcs", TRUE);
// Load the mfcs class
require_once "includes/index.php";
mfcs::singleton();
// Quick and dirty Checks check
// @TODO this needs to be more formalized in a class to easily include other checks as well
if (!isCLI()) {
    $sql_check = sprintf("SELECT `value` FROM `checks` WHERE `name`='uniqueIDCheck'");
    $sqlResult_check = mfcs::$engine->openDB->query($sql_check);
    if (!$sqlResult_check['result']) {
        errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
        print "<p>Error checking MFCS sanity. Aborting.</p>";
        exit;
    }
    $row_check = mysql_fetch_array($sqlResult_check['result'], MYSQL_ASSOC);
    if ($row_check['value'] == "0") {
        // notify systems via email
        print "<h1>ERROR!</h1>";
        print "<p>MFCS Failed idno sanity check. Please contact systems Immediately.</p>";
        print "<p>Please jot down the steps you took getting to this point. Be as specific as possible.</p>";
        print "<p>Aborting.</p>";
        exit;
    }
}
// End Checks
$mfcsSearch = new mfcsSearch();
Example #16
0
 public static function getForms($projectID, $form = FALSE)
 {
     $sql = sprintf("SELECT `formID` FROM `forms_projects` WHERE `projectID`='%s'", mfcs::$engine->openDB->escape($projectID));
     $sqlResult = mfcs::$engine->openDB->query($sql);
     if (!$sqlResult['result']) {
         errorHandle::newError(__METHOD__ . "() - : " . $sqlResult['error'], errorHandle::DEBUG);
         return FALSE;
     }
     $formIDs = array();
     while ($row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC)) {
         if ($form === TRUE) {
             if (($formIDs[$row['formID']] = forms::get($row['formID'])) === FALSE) {
                 return FALSE;
             }
         } else {
             $formIDs[] = $row['formID'];
         }
     }
     return $formIDs;
 }
Example #17
0
            throw new Exception("New Form Title is required.");
        }
        // Get all fields from the forms table except the primary key
        $fields = mfcs::$engine->openDB->listFields("forms", FALSE);
        // Remove unique field
        foreach ($fields as $I => $field) {
            if ($field == 'title') {
                unset($fields[$I]);
            }
        }
        mfcs::$engine->openDB->transBegin();
        log::insert("Form Creator: Copy: ", 0, mfcs::$engine->cleanPost['MYSQL']['formSelect'], mfcs::$engine->cleanPost['MYSQL']['newTitle']);
        $sql = sprintf("INSERT INTO `forms` (`title`,`%s`) (SELECT '%s',`%s` FROM `forms` WHERE `ID`='%s' LIMIT 1)", implode('`,`', $fields), mfcs::$engine->cleanPost['MYSQL']['newTitle'], implode('`,`', $fields), mfcs::$engine->cleanPost['MYSQL']['formSelect']);
        $sqlResult = mfcs::$engine->openDB->query($sql);
        if (!$sqlResult['result']) {
            errorHandle::newError("Error copying form - " . $sqlResult['error'], errorHandle::DEBUG);
            throw new Exception("Error copying form");
        }
        errorHandle::successMsg("Form copied successfully.");
        mfcs::$engine->openDB->transCommit();
        mfcs::$engine->openDB->transEnd();
    }
} catch (Exception $e) {
    errorHandle::errorMsg($e->getMessage());
    mfcs::$engine->openDB->transRollback();
    mfcs::$engine->openDB->transEnd();
}
localVars::add("results", displayMessages());
$engine->eTemplate("include", "header");
?>