Ejemplo n.º 1
0
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.abbr.js', true);
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'maborak/core/module.dashboard.js', true);
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/js-calendar/js-calendar.js');
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/suggest/bsn.AutoSuggest_2.1.3.js');
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/tooltip/pmtooltip.js');
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'thirdparty/krumo/krumo.js');
$oHeadPublisher->addMaborakFile(PATH_GULLIVER_HOME . 'js' . PATH_SEP . 'widgets/calendar/pmcalendar.js', true);
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases.js', true);
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'cases/core/cases_Step.js', true);
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'processmap/core/processmap.js', true);
$oHeadPublisher->addMaborakFile(PATH_CORE . 'js' . PATH_SEP . 'appFolder/core/appFolderList.js', true);
$oHeadPublisher->addMaborakFile(PATH_THIRDPARTY . 'htmlarea/editor.js', true);
//check if it is a installation instance
if (!defined('PATH_C')) {
    // is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily
    define('PATH_C', rtrim(G::sys_get_temp_dir(), PATH_SEP) . PATH_SEP);
    define('PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/');
}
// defining Virtual URLs
$virtualURITable = array();
$virtualURITable['/plugin/(*)'] = 'plugin';
$virtualURITable['/(sys*)/(*.js)'] = 'jsMethod';
$virtualURITable['/js/(*)'] = PATH_GULLIVER_HOME . 'js/';
$virtualURITable['/jscore/(*)'] = PATH_CORE . 'js/';
if (defined('PATH_C')) {
    $virtualURITable['/jsform/(*.js)'] = PATH_C . 'xmlform/';
    $virtualURITable['/extjs/(*)'] = PATH_C . 'ExtJs/';
}
$virtualURITable['/htmlarea/(*)'] = PATH_THIRDPARTY . 'htmlarea/';
$virtualURITable['/sys[a-zA-Z][a-zA-Z0-9]{0,}()/'] = 'sysNamed';
$virtualURITable['/(sys*)'] = FALSE;
Ejemplo n.º 2
0
 /**
  * render a smarty template
  *
  * @author Erik Amaru Ortiz <*****@*****.**>
  * @param $template string containing the template filename on /gulliver/templates/ directory
  * @param $data associative array containig the template data
  */
 public function renderTemplate($template, $data = array())
 {
     if (!defined('PATH_THIRDPARTY')) {
         throw new Exception('System constant (PATH_THIRDPARTY) is not defined!');
     }
     require_once PATH_THIRDPARTY . 'smarty/libs/Smarty.class.php';
     $fInfo = pathinfo($template);
     $tplExists = true;
     // file has absolute path
     if (strpos($template, PATH_TRUNK) === false) {
         $template = PATH_TPL . $template;
     }
     // fix for template that have dot in its name but is not a valid extension
     if (isset($fInfo['extension']) && ($fInfo['extension'] != 'tpl' || $fInfo['extension'] != 'html')) {
         unset($fInfo['extension']);
     }
     if (!isset($fInfo['extension'])) {
         if (file_exists($template . '.tpl')) {
             $template .= '.tpl';
         } elseif (file_exists($template . '.html')) {
             $template .= '.html';
         } else {
             $tplExists = false;
         }
     } else {
         if (!file_exists($template)) {
             $tplExists = false;
         }
     }
     if (!$tplExists) {
         throw new Exception("Template: {$template}, doesn't exist!");
     }
     $smarty = new Smarty();
     $smarty->compile_dir = G::sys_get_temp_dir();
     $smarty->cache_dir = G::sys_get_temp_dir();
     $smarty->config_dir = PATH_THIRDPARTY . 'smarty/configs';
     $smarty->template_dir = PATH_TEMPLATE;
     $smarty->force_compile = true;
     foreach ($data as $key => $value) {
         $smarty->assign($key, $value);
     }
     $smarty->display($template);
 }
Ejemplo n.º 3
0
 /**
  * @covers G::sys_get_temp_dir
  * @todo   Implement testSys_get_temp_dir().
  */
 public function testSys_get_temp_dir()
 {
     $tmpDir = G::sys_get_temp_dir();
     $this->assertFileExists($tmpDir);
     $this->assertTrue(is_writable($tmpDir));
 }
Ejemplo n.º 4
0
 /**
  * This function removes a temporal file
  *
  *
  * @name deleteTmpfile
  *
  * param
  * @return void
  */
 private function deleteTmpfile()
 {
     if ($this->sessionId == NULL) {
         throw new Exception('session id was not set.');
     }
     $this->tmpfile = G::sys_get_temp_dir() . PATH_SEP . "pm-rg-{$this->sessionId}";
     @unlink($this->tmpfile);
 }
Ejemplo n.º 5
0
         if (is_object($result)) {
             $_SESSION['WS_SESSION_ID'] = '';
             $fields['status_code'] = $result->status_code;
             $fields['message'] = $result->message;
             $fields['time_stamp'] = date("Y-m-d H:i:s");
             $G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/wsShowResult', null, $fields);
         }
     }
     G::RenderPage('publish', 'raw');
     break;
 case "wsSendFiles":
     if (isset($_FILES['form'])) {
         foreach ($_FILES['form']['name'] as $sFieldName => $vValue) {
             if ($_FILES['form']['error'][$sFieldName] == 0) {
                 file_put_contents(G::sys_get_temp_dir() . PATH_SEP . $_FILES['form']['name'][$sFieldName], file_get_contents($_FILES['form']['tmp_name'][$sFieldName]));
                 $filename = G::sys_get_temp_dir() . PATH_SEP . $_FILES['form']['name'][$sFieldName];
             }
         }
     }
     //                              G::pr ( $_SESSION );
     if (!isset($_POST['form']['INPUT_DOCUMENT'])) {
         $_POST['form']['INPUT_DOCUMENT'] = '';
     }
     if (isset($_SESSION['_DBArray']['inputDocument'])) {
         foreach ($_SESSION['_DBArray']['inputDocument'] as $inputDocument) {
             if ($inputDocument['guid'] == $_POST['form']['INPUT_DOCUMENT']) {
                 $doc_uid = $inputDocument['docId'];
             }
         }
     } else {
         $doc_uid = "default";
Ejemplo n.º 6
0
function run_workspace_backup($task, $args)
{
    throw new Exception("Gulliver backup is no longer supported, use processmaker command-line instead.");
    try {
        ini_set('display_errors', 'on');
        ini_set('error_reporting', E_ERROR);
        // the environment for poedit always is Development
        define('G_ENVIRONMENT', G_DEV_ENV);
        /* Look for -c and --compress in arguments */
        $compress = array_search('-c', $args);
        if ($compress === false) {
            $compress = array_search('--compress', $args);
        }
        if ($compress !== false) {
            unset($args[$compress]);
            /* We need to reorder the args if we removed the compress switch */
            $args = array_values($args);
            $compress = true;
        }
        /* Look for -c and --compress in arguments */
        $overwrite = array_search('-o', $args);
        if ($overwrite === false) {
            $overwrite = array_search('--overwrite', $args);
        }
        if ($overwrite !== false) {
            unset($args[$overwrite]);
            /* We need to reorder the args if we removed the compress switch */
            $args = array_values($args);
            $overwrite = true;
        }
        if (array_search('compress', $args)) {
            echo pakeColor::colorize("Compress is no longer an option, check if this is what you want\n", 'ERROR');
        }
        if (count($args) > 2 || count($args) == 0) {
            throw new Exception('wrong arguments specified');
        }
        $workspace = $args[0];
        /* Use system gzip if not in Windows */
        if ($compress && strtolower(reset(explode(' ', php_uname('s')))) != "windows") {
            /* Find the system gzip */
            exec("whereis -b gzip", $whereisGzip);
            $gzipPaths = explode(' ', $whereisGzip[0]);
            if (isset($gzipPaths[1])) {
                $gzipPath = $gzipPaths[1];
            }
            if (isset($gzipPath)) {
                echo "Using system gzip in {$gzipPath}\n";
            }
        }
        if (isset($args[1])) {
            $fileTar = $args[1];
            /* Check if the second argument is an absolute filename. If it is, use
             * it as the backup filename. Otherwise, use it as a filename relative
             * to the backups directory. This makes migration from previous versions
             * easier, which always expects a relative filename, while still accepting
             * absolute filenames.
             */
            if (dirname($fileTar) == '.') {
                printf("Using %s as root. Use an absolute filename to change it.\n", pakeColor::colorize(PATH_TRUNK . 'backups', 'INFO'));
                G::mk_dir(PATH_DATA . 'backups');
                $fileTar = PATH_DATA . 'backups' . PATH_SEP . $fileTar . '.tar';
                if ($compress) {
                    $fileTar .= '.gz';
                }
            }
            printf("Backing up workspace %s to %s\n", pakeColor::colorize($workspace, 'INFO'), pakeColor::colorize($fileTar, 'INFO'));
            if (!$overwrite && file_exists($fileTar)) {
                $overwrite = strtolower(prompt('Backup file already exists, do you want to overwrite? [Y/n]'));
                if (array_search(trim($overwrite), array("y", "")) === false) {
                    die;
                }
                $overwrite = true;
            }
        } else {
            G::mk_dir(PATH_DATA . 'backups');
            $fileBase = PATH_DATA . 'backups' . PATH_SEP . $workspace . '.tar';
            $fileTar = $fileBase;
            if ($compress) {
                $fileTar .= '.gz';
            }
            printf("Backing up workspace %s to %s\n", pakeColor::colorize($workspace, 'INFO'), pakeColor::colorize($fileTar, 'INFO'));
            /* To avoid confusion, we remove both .tar and .tar.gz */
            if (!$overwrite && (file_exists($fileBase) || file_exists($fileBase . '.gz'))) {
                $overwrite = strtolower(prompt('Backup file already exists, do you want to overwrite? [Y/n]'));
                if (array_search(trim($overwrite), array("y", "")) === false) {
                    die;
                }
                $overwrite = true;
            }
            if (file_exists($fileBase)) {
                unlink($fileBase);
            }
            if (file_exists($fileBase . ".gz")) {
                unlink($fileBase . '.gz');
            }
        }
        /* Remove the backup file before backing up. Previous versions didn't do
         * this, so backup files would increase indefinetely as new data was
         * appended to the tar file instead of replaced.
         */
        if (file_exists($fileTar)) {
            unlink($fileTar);
        }
        /* If using the system gzip, create the tar using a temporary filename */
        if (isset($gzipPath)) {
            $gzipFinal = $fileTar;
            $fileTar = tempnam(__FILE__, '');
        }
        $aSerializeData = get_infoOnPM($workspace);
        $dbFile = PATH_DB . $workspace . PATH_SEP . 'db.php';
        if (!file_exists($dbFile)) {
            throw new Exception("Invalid workspace, the db file does not exist, {$dbFile}");
        }
        $dbOpt = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
        G::LoadSystem('dbMaintenance');
        $oDbMaintainer = new DataBaseMaintenance($dbOpt[0], $dbOpt[1], $dbOpt[2]);
        try {
            $oDbMaintainer->connect("mysql");
        } catch (Exception $e) {
            echo "Problems contacting the database with the administrator user\n";
            echo "The response was: {$e->getMessage()}\n";
        }
        require_once $dbFile;
        require_once "propel/Propel.php";
        G::LoadSystem('templatePower');
        Propel::init(PATH_CORE . "config/databases.php");
        $configuration = Propel::getConfiguration();
        $connectionDSN = $configuration['datasources']['workflow']['connection'];
        printf("using DSN Connection %s \n", pakeColor::colorize($connectionDSN, 'INFO'));
        $con = Propel::getConnection('workflow');
        $sql = "show variables like 'datadir'";
        $stmt = $con->createStatement();
        $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
        $rs->next();
        $row = $rs->getRow();
        if (!is_array($row)) {
            throw new Exception("unable to execute query in database");
        }
        $dataDir = $row['Value'];
        if ($dataDir[count($dataDir) - 1] == '/') {
            $dataDir = substr($dataDir, count($dataDir) - 1);
        }
        printf("MySQL data dir %s \n", pakeColor::colorize($dataDir, 'INFO'));
        $sql = "SELECT VERSION();";
        $stmt = $con->createStatement();
        $rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_NUM);
        $rs->next();
        $row = $rs->getRow();
        $mysqlVersion = $row[0];
        $aSerializeData['DATABASE'] = $mysqlVersion;
        //new db restore rotines, by Erik <*****@*****.**> on May 17th, 2010
        //set the temporal directory for all tables into wf, rb, and rp databases
        $tmpDir = G::sys_get_temp_dir() . PATH_SEP . 'pmDbBackup' . PATH_SEP;
        //create the db maintenance temporal dir
        G::mk_dir($tmpDir);
        $fileMetadata = $tmpDir . 'metadata.txt';
        $sMetadata = file_put_contents($fileMetadata, serialize($aSerializeData));
        if ($sMetadata === false) {
            throw new Exception("Metadata file could not be written");
        }
        G::LoadThirdParty('pear/Archive', 'Tar');
        $tar = new Archive_Tar($fileTar);
        if (!isset($gzipPath)) {
            $tar->_compress = $compress;
        }
        /*** WORKFLOW DATABASE BACKUP ***/
        $dbSettings = getDataBaseConfiguration($configuration['datasources']['workflow']['connection']);
        backupDB($dbOpt[0], $dbOpt[1], $dbOpt[2], $dbSettings['dbname'], $tmpDir);
        printf("Copying folder: %s \n", pakeColor::colorize($tmpDir, 'INFO'));
        backupAddTarFolder($tar, $tmpDir . $dbSettings['dbname'] . PATH_SEP, $tmpDir);
        /*** RBAC DATABASE BACKUP ***/
        $dbSettings = getDataBaseConfiguration($configuration['datasources']['rbac']['connection']);
        backupDB($dbOpt[0], $dbOpt[1], $dbOpt[2], $dbSettings['dbname'], $tmpDir);
        printf("Copying folder: %s \n", pakeColor::colorize($tmpDir, 'INFO'));
        backupAddTarFolder($tar, $tmpDir . $dbSettings['dbname'] . PATH_SEP, $tmpDir);
        /*** RP DATABASE BACKUP ***/
        $dbSettings = getDataBaseConfiguration($configuration['datasources']['rp']['connection']);
        backupDB($dbOpt[0], $dbOpt[1], $dbOpt[2], $dbSettings['dbname'], $tmpDir);
        printf("Copying folder: %s \n", pakeColor::colorize($tmpDir, 'INFO'));
        backupAddTarFolder($tar, $tmpDir . $dbSettings['dbname'] . PATH_SEP, $tmpDir);
        $pathSharedBase = PATH_DATA . 'sites' . PATH_SEP . $workspace . PATH_SEP;
        printf("copying folder: %s \n", pakeColor::colorize($pathSharedBase, 'INFO'));
        backupAddTarFolder($tar, $pathSharedBase, PATH_DATA . 'sites');
        backupAddTarFolder($tar, $fileMetadata, dirname($fileMetadata));
        unlink($fileMetadata);
        $aFiles = $tar->listContent();
        $total = 0;
        foreach ($aFiles as $key => $val) {
            //    printf( " %6d %s \n", $val['size'], pakeColor::colorize( $val['filename'], 'INFO') );
            $total += $val['size'];
        }
        /* If using system gzip, compress the temporary tar to the original
         * filename.
         */
        if (isset($gzipPath)) {
            exec("gzip -c \"{$fileTar}\" > {$gzipFinal}", $output, $ret);
            if ($ret != 0) {
                /* The error message is in stderr, which should be displayed already */
                echo pakeColor::colorize("Error compressing backup", "ERROR") . "\n";
                die(1);
            }
            unlink($fileTar);
            $fileTar = $gzipFinal;
        }
        printMetadata($aSerializeData);
        printf("%20s %s \n", 'Backup File', pakeColor::colorize($fileTar, 'INFO'));
        printf("%20s %s \n", 'Files in Backup', pakeColor::colorize(count($aFiles), 'INFO'));
        printf("%20s %s \n", 'Total Filesize', pakeColor::colorize(sprintf("%5.2f MB", $total / 1024 / 1024), 'INFO'));
        printf("%20s %s \n", 'Backup Filesize', pakeColor::colorize(sprintf("%5.2f MB", filesize($fileTar) / 1024 / 1024), 'INFO'));
    } catch (Exception $e) {
        printf("Error: %s\n", pakeColor::colorize($e->getMessage(), 'ERROR'));
        exit(0);
    }
}
Ejemplo n.º 7
0
 /**
  * On this method have some sys env, configuration, and other fixes
  */
 public function fixEnvironment()
 {
     // IIS Compatibility, SERVER_ADDR doesn't exist on that env, so we need to define it.
     $_SERVER['SERVER_ADDR'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['SERVER_NAME'];
     //check if it is a installation instance
     if (!defined('PATH_C')) {
         // is a intallation instance, so we need to define PATH_C and PATH_LANGUAGECONT constants temporarily
         define('PATH_C', rtrim(G::sys_get_temp_dir(), PATH_SEP) . PATH_SEP);
         define('PATH_LANGUAGECONT', PATH_HOME . 'engine/content/languages/');
     }
 }