Ejemplo n.º 1
0
 public function __construct($prjUid)
 {
     $this->prjUid = $prjUid;
     $this->bpmnProject = Project\Bpmn::load($prjUid);
     $this->projectData = $this->bpmnProject->getProject();
     $this->metadata = array("vendor_version" => \System::getVersion(), "vendor_version_code" => "Michelangelo", "export_timestamp" => date("U"), "export_datetime" => date("Y-m-d\\TH:i:sP"), "export_server_addr" => isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] . ":" . $_SERVER["SERVER_PORT"] : "Unknown", "export_server_os" => PHP_OS, "export_server_php_version" => PHP_VERSION_ID);
 }
Ejemplo n.º 2
0
 public static function isApplicable()
 {
     patch::$isPathchable = false;
     $con = Propel::getConnection("workflow");
     $stmt = $con->prepareStatement("describe TASK;");
     $rs = $stmt->executeQuery();
     $rs->next();
     while ($row = $rs->getRow()) {
         if ($row['Field'] == "TAS_GROUP_VARIABLE") {
             $version = System::getVersion();
             $version = explode('-', $version);
             if ($version[0] == '2.5.1') {
                 echo "Version " . $version[0] . " Patch\n";
                 patch::$isPathchable = true;
             }
             break;
         }
         $rs->next();
     }
     return patch::$isPathchable;
 }
Ejemplo n.º 3
0
    $oHeadPublisher->assign("license_expires", $licenseManager->expireIn);
    $oHeadPublisher->assign("license_message", $licenseManager->status["message"]);
    $oHeadPublisher->assign("licensed", false);
} else {
    $oHeadPublisher->assign("license_user", "");
    $oHeadPublisher->assign("license_name", "<b>Unlicensed</b>");
    $oHeadPublisher->assign("license_server", "<b>no server</b>");
    $oHeadPublisher->assign("license_expires", "");
    $currentLicenseStatus = $licenseManager->getCurrentLicenseStatus();
    $oHeadPublisher->assign("license_message", $currentLicenseStatus["message"]);
    $oHeadPublisher->assign("license_start_date", "");
    $oHeadPublisher->assign("license_end_date", "");
    $oHeadPublisher->assign("license_span", "");
    $oHeadPublisher->assign("licensed", false);
}
$oHeadPublisher->assign("license_serial", isset($licenseManager->licenseSerial) ? $licenseManager->licenseSerial : '');
$oHeadPublisher->assign("SUPPORT_FLAG", isset($licenseManager->supportStartDate) && $licenseManager->supportStartDate == '' || !isset($licenseManager->supportStartDate) ? true : false);
$oHeadPublisher->assign("supportStartDate", isset($licenseManager->supportStartDate) ? $licenseManager->supportStartDate : '');
$oHeadPublisher->assign("supportEndDate", isset($licenseManager->supportEndDate) ? $licenseManager->supportEndDate : '');
G::LoadClass("system");
$oHeadPublisher->assign("PROCESSMAKER_VERSION", System::getVersion());
$oHeadPublisher->assign("PROCESSMAKER_URL", "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN);
$oHeadPublisher->assign("SYS_SKIN", SYS_SKIN);
$oHeadPublisher->assign("URL_PART_LOGIN", substr(SYS_SKIN, 0, 2) == "ux" && SYS_SKIN != "uxs" ? "main/login" : "login/login");
$oHeadPublisher->assign("URL_PART_SETUP", EnterpriseUtils::getUrlPartSetup());
$oHeadPublisher->assign("PATH_PLUGINS_WRITABLE", is_writable(PATH_PLUGINS) ? 1 : 0);
$oHeadPublisher->assign("PATH_PLUGINS_WRITABLE_MESSAGE", "The directory " . PATH_PLUGINS . " have not writable.");
$oHeadPublisher->assign("SKIN_IS_UX", EnterpriseUtils::skinIsUx());
$oHeadPublisher->assign("INTERNET_CONNECTION", EnterpriseUtils::getInternetConnection());
$oHeadPublisher->addExtJsScript("enterprise/addonsStore", true);
G::RenderPage("publish", "extJs");
Ejemplo n.º 4
0
 /**
  * Export PM tables
  *
  * @author : Erik Amaru Ortiz <*****@*****.**>
  */
 public function export($httpData)
 {
     require_once 'classes/model/AdditionalTables.php';
     $at = new AdditionalTables();
     $tablesToExport = G::json_decode(stripslashes($httpData->rows));
     try {
         G::LoadCLass('net');
         $net = new NET(G::getIpAddress());
         G::LoadClass("system");
         $META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n" . " @Ver: 1.0 Oct-2009\n" . " @Processmaker version: " . System::getVersion() . "\n" . " -------------------------------------------------------\n" . " @Export Date: " . date("l jS \\of F Y h:i:s A") . "\n" . " @Server address: " . getenv('SERVER_NAME') . " (" . getenv('SERVER_ADDR') . ")\n" . " @Client address: " . $net->hostname . "\n" . " @Workspace: " . SYS_SYS . "\n" . " @Export trace back:\n\n";
         $EXPORT_TRACEBACK = array();
         $c = 0;
         foreach ($tablesToExport as $table) {
             $tableRecord = $at->load($table->ADD_TAB_UID);
             $tableData = $at->getAllData($table->ADD_TAB_UID, null, null, false);
             $table->ADD_TAB_NAME = $tableRecord['ADD_TAB_NAME'];
             $rows = $tableData['rows'];
             $count = $tableData['count'];
             array_push($EXPORT_TRACEBACK, array('uid' => $table->ADD_TAB_UID, 'name' => $table->ADD_TAB_NAME, 'num_regs' => $tableData['count'], 'schema' => $table->_SCHEMA ? 'yes' : 'no', 'data' => $table->_DATA ? 'yes' : 'no'));
         }
         $sTrace = "TABLE UID                        TABLE NAME\tREGS\tSCHEMA\tDATA\n";
         foreach ($EXPORT_TRACEBACK as $row) {
             $sTrace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n";
         }
         $META .= $sTrace;
         ///////////////EXPORT PROCESS
         $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
         $filenameOnly = strtolower('SYS-' . SYS_SYS . "_" . date("Y-m-d") . '_' . date("Hi") . ".pmt");
         $filename = $PUBLIC_ROOT_PATH . $filenameOnly;
         $fp = fopen($filename, "wb");
         $bytesSaved = 0;
         $bufferType = '@META';
         $fsData = sprintf("%09d", strlen($META));
         $fsbufferType = sprintf("%09d", strlen($bufferType));
         $bytesSaved += fwrite($fp, $fsbufferType);
         //writing the size of $oData
         $bytesSaved += fwrite($fp, $bufferType);
         //writing the $oData
         $bytesSaved += fwrite($fp, $fsData);
         //writing the size of $oData
         $bytesSaved += fwrite($fp, $META);
         //writing the $oData
         foreach ($tablesToExport as $table) {
             if ($table->_SCHEMA) {
                 $oAdditionalTables = new AdditionalTables();
                 $aData = $oAdditionalTables->load($table->ADD_TAB_UID, true);
                 $bufferType = '@SCHEMA';
                 $SDATA = serialize($aData);
                 $fsUid = sprintf("%09d", strlen($table->ADD_TAB_UID));
                 $fsData = sprintf("%09d", strlen($SDATA));
                 $fsbufferType = sprintf("%09d", strlen($bufferType));
                 $bytesSaved += fwrite($fp, $fsbufferType);
                 //writing the size of $oData
                 $bytesSaved += fwrite($fp, $bufferType);
                 //writing the $oData
                 $bytesSaved += fwrite($fp, $fsUid);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $table->ADD_TAB_UID);
                 //writing the xmlfile
                 $bytesSaved += fwrite($fp, $fsData);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $SDATA);
                 //writing the xmlfile
             }
             if ($table->_DATA) {
                 //export data
                 $oAdditionalTables = new additionalTables();
                 $tableData = $oAdditionalTables->getAllData($table->ADD_TAB_UID, null, null, false);
                 $SDATA = serialize($tableData['rows']);
                 $bufferType = '@DATA';
                 $fsbufferType = sprintf("%09d", strlen($bufferType));
                 $fsTableName = sprintf("%09d", strlen($table->ADD_TAB_NAME));
                 $fsData = sprintf("%09d", strlen($SDATA));
                 $bytesSaved += fwrite($fp, $fsbufferType);
                 //writing type size
                 $bytesSaved += fwrite($fp, $bufferType);
                 //writing type
                 $bytesSaved += fwrite($fp, $fsTableName);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $table->ADD_TAB_NAME);
                 //writing the xmlfile
                 $bytesSaved += fwrite($fp, $fsData);
                 //writing the size of xml file
                 $bytesSaved += fwrite($fp, $SDATA);
                 //writing the xmlfile
             }
         }
         fclose($fp);
         $filenameLink = "pmTables/streamExported?f={$filenameOnly}";
         $size = round($bytesSaved / 1024, 2) . " Kb";
         $meta = "<pre>" . $META . "</pre>";
         $filename = $filenameOnly;
         $link = $filenameLink;
         $result->success = true;
         $result->filename = $filenameOnly;
         $result->link = $link;
         $result->message = "Generated file: {$filenameOnly}, size: {$size}";
     } catch (Exception $e) {
         $result->success = false;
         $result->message = $e->getMessage();
     }
     return $result;
 }
 $template->assign('processUid', $sPRO_UID);
 $template->assign('dynaformUid', $sDYNAFORM);
 $template->assign('taskUid', $sTASKS);
 $template->assign('wsUser', $sWS_USER);
 $template->assign('wsPass', Bootstrap::hashPassword($sWS_PASS, '', true));
 $template->assign('wsRoundRobin', $sWS_ROUNDROBIN);
 G::auditLog('WebEntry', 'Generate web entry with web services (' . $dynTitle . '.php) in process "' . $resultProcess['PRO_TITLE'] . '"');
 if ($sWE_USR == "2") {
     $template->assign('USR_VAR', "\$cInfo = ws_getCaseInfo(\$caseId);\n\t  \$USR_UID = \$cInfo->currentUsers->userId;");
 } else {
     $template->assign('USR_VAR', '$USR_UID = -1;');
 }
 $template->assign('dynaform', $dynTitle);
 $template->assign('timestamp', date('l jS \\of F Y h:i:s A'));
 $template->assign('ws', SYS_SYS);
 $template->assign('version', System::getVersion());
 $fileName = $pathProcess . $dynTitle . 'Post.php';
 file_put_contents($fileName, $template->getOutputContent());
 //creating the third file, only if this wsClient.php file doesn't exist.
 $fileName = $pathProcess . 'wsClient.php';
 $pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "wsClient.php";
 if (file_exists($fileName)) {
     if (filesize($fileName) != filesize($pluginTpl)) {
         @copy($fileName, $pathProcess . 'wsClient.php.bck');
         @unlink($fileName);
         $template = new TemplatePower($pluginTpl);
         $template->prepare();
         file_put_contents($fileName, $template->getOutputContent());
     }
 } else {
     $template = new TemplatePower($pluginTpl);
Ejemplo n.º 6
0
 public function export()
 {
     G::LoadSystem('i18n_po');
     G::LoadClass("system");
     //get labels MichelangeloFE
     try {
         $oTranslation = new Translation();
         $MichelangeloFE = PATH_HOME . "../workflow/public_html/lib/js";
         if (file_exists($MichelangeloFE)) {
             $labels = self::readLabelsDirectory($MichelangeloFE, true);
             foreach ($labels as $label) {
                 $oTranslation->addTranslation('LABEL', 'ID_MAFE_' . G::encryptOld($label), 'en', $label);
             }
         }
     } catch (Exception $e) {
         error_log($e->getMessage());
     }
     //creating the .po file
     $sPOFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . MAIN_POFILE . '.' . $_GET['LOCALE'] . '.po';
     $poFile = new i18n_PO($sPOFile);
     $poFile->buildInit();
     $language = new Language();
     $locale = $_GET['LOCALE'];
     $_TARGET_LANG = $_GET['LOCALE'];
     $_BASE_LANG = 'en';
     if (strpos($locale, Translation::$localeSeparator) !== false) {
         list($LAN_ID, $IC_UID) = explode(Translation::$localeSeparator, $_GET['LOCALE']);
         $iCountry = new IsoCountry();
         $iCountryRecord = $iCountry->findById($IC_UID);
         if (!isset($iCountryRecord['IC_UID'])) {
             throw new Exception("Country Target ID '{$_GET['LAN_ID']}' doesn't exist!");
         }
         $sCountry = $iCountryRecord['IC_NAME'];
     } else {
         $LAN_ID = $locale;
         $sCountry = $IC_UID = '';
     }
     $langRecord = $language->findById($LAN_ID);
     if (!isset($langRecord['LAN_NAME'])) {
         throw new Exception("Language Target ID \"{$LAN_ID}\" doesn't exist!");
     }
     $sLanguage = $langRecord['LAN_NAME'];
     //setting headers
     $poFile->addHeader('Project-Id-Version', 'ProcessMaker ' . System::getVersion());
     $poFile->addHeader('POT-Creation-Date', '');
     $poFile->addHeader('PO-Revision-Date', date('Y-m-d H:i:s'));
     $poFile->addHeader('Last-Translator', '');
     $poFile->addHeader('Language-Team', 'Colosa Developers Team <*****@*****.**>');
     $poFile->addHeader('MIME-Version', '1.0');
     $poFile->addHeader('Content-Type', 'text/plain; charset=utf-8');
     $poFile->addHeader('Content-Transfer_Encoding', '8bit');
     $poFile->addHeader('X-Poedit-Language', ucwords($sLanguage));
     $poFile->addHeader('X-Poedit-Country', ucwords($sCountry));
     $poFile->addHeader('X-Poedit-SourceCharset', 'utf-8');
     $poFile->addHeader('Content-Transfer-Encoding', '8bit');
     $aLabels = array();
     $aMsgids = array('' => true);
     // selecting all translations records of base language 'en' on TRANSLATIONS table
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(TranslationPeer::TRN_CATEGORY);
     $oCriteria->addSelectColumn(TranslationPeer::TRN_ID);
     $oCriteria->addSelectColumn(TranslationPeer::TRN_VALUE);
     $oCriteria->add(TranslationPeer::TRN_LANG, 'en');
     $oDataset = TranslationPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $targetLangRecords = array();
     // retrieve the translation for the target language
     if ($LAN_ID != 'en') {
         // only if it is different language than base language 'en'
         $c = new Criteria('workflow');
         $c->addSelectColumn(TranslationPeer::TRN_CATEGORY);
         $c->addSelectColumn(TranslationPeer::TRN_ID);
         $c->addSelectColumn(TranslationPeer::TRN_VALUE);
         $c->add(TranslationPeer::TRN_LANG, $_GET['LOCALE']);
         $ds = TranslationPeer::doSelectRS($c);
         $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         while ($ds->next()) {
             $row = $ds->getRow();
             $targetLangRecords[$row['TRN_CATEGORY'] . '/' . $row['TRN_ID']] = $row['TRN_VALUE'];
         }
     }
     // get the respective translation for each english label
     while ($oDataset->next()) {
         $aRow1 = $oDataset->getRow();
         $trnCategory = trim($aRow1['TRN_CATEGORY']);
         # Validation, validate that the TRN_CATEGORY contains valid characteres
         preg_match("/^[0-9a-zA-Z_-]+/", $trnCategory, $sTestResult);
         // IF the translations id "TRN_ID" has invalid characteres or has not accepted categories
         if ($sTestResult[0] !== $trnCategory || $trnCategory != 'LABEL' && $trnCategory != 'JAVASCRIPT') {
             $oTranslation = new Translation();
             $oTranslation->remove($aRow1['TRN_CATEGORY'], $aRow1['TRN_ID'], 'en');
             //remove not accepted translations
             continue;
             //jump to next iteration
         }
         // retrieve the translation for the target language
         if ($LAN_ID != 'en') {
             // only if it is different language than base language 'en'
             if (isset($targetLangRecords[$aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']])) {
                 $msgstr = $targetLangRecords[$aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']] != '' ? $targetLangRecords[$aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']] : $aRow1['TRN_VALUE'];
             } else {
                 $msgstr = $aRow1['TRN_VALUE'];
             }
         } else {
             //if not just copy the same
             $msgstr = $aRow1['TRN_VALUE'];
         }
         $msgid = trim($aRow1['TRN_VALUE']);
         $msgstr = trim($msgstr);
         if (isset($aMsgids[$msgid])) {
             $msgid = '[' . $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] . '] ' . $msgid;
         }
         $poFile->addTranslatorComment('TRANSLATION');
         $poFile->addTranslatorComment($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
         $poFile->addReference($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
         $poFile->addTranslation(stripcslashes($msgid), stripcslashes($msgstr));
         $aMsgids[$msgid] = true;
     }
     //$timer->setMarker('end making 1th .po from db');
     //find all xml files into PATH_XMLFORM
     $aXMLForms = glob(PATH_XMLFORM . '*/*.xml');
     //from a sublevel to
     $aXMLForms2 = glob(PATH_XMLFORM . '*/*/*.xml');
     $aXMLForms = array_merge($aXMLForms, $aXMLForms2);
     $aEnglishLabel = array();
     $aOptions = array();
     $nodesNames = array();
     G::loadSystem('dynaformhandler');
     foreach ($aXMLForms as $xmlFormPath) {
         $xmlFormFile = str_replace(chr(92), '/', $xmlFormPath);
         $xmlFormFile = str_replace(PATH_XMLFORM, '', $xmlFormPath);
         $dynaForm = new dynaFormHandler($xmlFormPath);
         $dynaNodes = $dynaForm->getFields();
         //get all fields of each xmlform
         foreach ($dynaNodes as $oNode) {
             $sNodeName = $oNode->nodeName;
             //$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG));
             $arrayNode = $dynaForm->getArray($oNode);
             //if has not native language translation
             if (!isset($arrayNode[$_BASE_LANG]) || !isset($arrayNode['type']) || isset($arrayNode['type']) && in_array($arrayNode['type'], $this->exceptionFields)) {
                 continue;
                 //just continue with the next node
             }
             // Getting the Base Origin Text
             if (!is_array($arrayNode[$_BASE_LANG])) {
                 $originNodeText = trim($arrayNode[$_BASE_LANG]);
             } else {
                 $langNode = $arrayNode[$_BASE_LANG][0];
                 $originNodeText = $langNode['__nodeText__'];
             }
             // Getting the Base Target Text
             if (isset($arrayNode[$_TARGET_LANG])) {
                 if (!is_array($arrayNode[$_TARGET_LANG])) {
                     $targetNodeText = trim($arrayNode[$_TARGET_LANG]);
                 } else {
                     $langNode = $arrayNode[$_TARGET_LANG][0];
                     $targetNodeText = $langNode['__nodeText__'];
                 }
             } else {
                 $targetNodeText = $originNodeText;
             }
             $nodeName = $arrayNode['__nodeName__'];
             $nodeType = $arrayNode['type'];
             $msgid = $originNodeText;
             // if the nodeName already exists in the po file, we need to create other msgid
             if (isset($aMsgids[$msgid])) {
                 $msgid = '[' . $xmlFormFile . '?' . $nodeName . '] ' . $originNodeText;
             }
             $poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName);
             $poFile->addTranslatorComment($xmlFormFile);
             $poFile->addReference($nodeType . ' - ' . $nodeName);
             $poFile->addTranslation(stripslashes($msgid), stripslashes($targetNodeText));
             $aMsgids[$msgid] = true;
             //if this node has options child nodes
             if (isset($arrayNode[$_BASE_LANG]) && isset($arrayNode[$_BASE_LANG][0]) && isset($arrayNode[$_BASE_LANG][0]['option'])) {
                 $originOptionNode = $arrayNode[$_BASE_LANG][0]['option'];
                 //get the options
                 $targetOptionExists = false;
                 if (isset($arrayNode[$_TARGET_LANG]) && isset($arrayNode[$_TARGET_LANG][0]) && isset($arrayNode[$_TARGET_LANG][0]['option'])) {
                     $targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option'];
                     $targetOptionExists = true;
                 }
                 if (!is_array($originOptionNode)) {
                     if (is_string($originOptionNode)) {
                         $poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-' . $originOptionNode);
                         $poFile->addTranslatorComment($xmlFormFile);
                         $poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $originOptionNode);
                         $poFile->addTranslation(stripslashes($msgid), stripslashes($originOptionNode));
                     }
                 } else {
                     foreach ($originOptionNode as $optionNode) {
                         $optionName = $optionNode['name'];
                         $originOptionValue = $optionNode['__nodeText__'];
                         if ($targetOptionExists) {
                             $targetOptionValue = getMatchDropdownOptionValue($optionName, $targetOptionNode);
                             if ($targetOptionValue === false) {
                                 $targetOptionValue = $originOptionValue;
                             }
                         } else {
                             $targetOptionValue = $originOptionValue;
                         }
                         $msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
                         $poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-' . $optionName);
                         $poFile->addTranslatorComment($xmlFormFile);
                         $poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
                         $poFile->addTranslation($msgid, stripslashes($targetOptionValue));
                     }
                 }
             }
         }
         //end foreach
     }
     G::auditLog("ExportLanguage", "Language: " . $_GET['LOCALE']);
     G::streamFile($sPOFile, true);
 }
Ejemplo n.º 7
0
 $sSubject = G::LoadTranslation('ID_RESET_PASSWORD') . ' - ProcessMaker';
 $msg = '<h3>ProcessMaker Forgot password Service</h3>';
 $msg .= '<p>' . G::LoadTranslation('ID_YOUR_USERMANE_IS') . ' :  <strong>' . $userData['USR_USERNAME'] . '</strong></p>';
 $msg .= '<p>' . G::LoadTranslation('ID_YOUR_PASSWORD_IS') . ' :  <strong>' . $newPass . '</strong></p>';
 switch ($aSetup['MESS_ENGINE']) {
     case 'MAIL':
         $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1');
         break;
     case 'PHPMAILER':
         $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2');
         break;
     case 'OPENMAIL':
         $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3');
         break;
 }
 $sBody = "\n  <table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>\n  <tbody><tr><td><img id='logo' src='http://" . $_SERVER['SERVER_NAME'] . "/images/processmaker.logo.jpg' /></td></tr>\n  <tr><td style='font-size: 14px;'>{$msg}</td></tr>\n  <tr><td style='vertical-align:middel;'>\n  <br /><hr><b>This Business Process is powered by ProcessMaker ver. " . System::getVersion() . ".<b><br />\n  <a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>\n  </tr></tbody></table>";
 G::LoadClass('spool');
 $oSpool = new spoolRun();
 if ($aSetup['MESS_RAUTH'] == false || is_string($aSetup['MESS_RAUTH']) && $aSetup['MESS_RAUTH'] == 'false') {
     $aSetup['MESS_RAUTH'] = 0;
 } else {
     $aSetup['MESS_RAUTH'] = 1;
 }
 $oSpool->setConfig(array('MESS_ENGINE' => $aSetup['MESS_ENGINE'], 'MESS_SERVER' => $aSetup['MESS_SERVER'], 'MESS_PORT' => $aSetup['MESS_PORT'], 'MESS_ACCOUNT' => $aSetup['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aSetup['MESS_PASSWORD'], 'SMTPAuth' => $aSetup['MESS_RAUTH'], 'SMTPSecure' => $aSetup['SMTPSecure']));
 $passwd = $oSpool->config['MESS_PASSWORD'];
 $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
 $auxPass = explode('hash:', $passwdDec);
 if (count($auxPass) > 1) {
     if (count($auxPass) == 2) {
         $passwd = $auxPass[1];
     } else {
Ejemplo n.º 8
0
 $sContent = str_ireplace('PATH_PLUGINS', "'" . $path . "'", $sContent);
 $sContent = preg_replace("/\\\$oPluginRegistry\\s*=\\s*&\\s*PMPluginRegistry::getSingleton\\s*\\(\\s*\\)\\s*;/i", null, $sContent);
 $sContent = preg_replace("/\\\$oPluginRegistry->registerPlugin\\s*\\(\\s*[\"\\']" . $sClassName . "[\"\\']\\s*,\\s*__FILE__\\s*\\)\\s*;/i", null, $sContent);
 //header('Content-Type: text/plain');var_dump($sClassName, $sContent);die;
 file_put_contents($path . $pluginFile, $sContent);
 $sAux = $sAux . '_';
 include $path . $pluginFile;
 $oClass = new $sAux($sClassName);
 $fVersionNew = $oClass->iVersion;
 if (!isset($oClass->iPMVersion)) {
     $oClass->iPMVersion = 0;
 }
 if ($oClass->iPMVersion > 0) {
     G::LoadClass("system");
     if (System::getVersion() > 0) {
         if ($oClass->iPMVersion > System::getVersion()) {
             //throw new Exception('This plugin needs version ' . $oClass->iPMVersion . ' or higher of ProcessMaker');
         }
     }
 }
 if (!isset($oClass->aDependences)) {
     $oClass->aDependences = null;
 }
 if (!empty($oClass->aDependences)) {
     foreach ($oClass->aDependences as $aDependence) {
         if (file_exists(PATH_PLUGINS . $aDependence['sClassName'] . '.php')) {
             require_once PATH_PLUGINS . $aDependence['sClassName'] . '.php';
             if (!$oPluginRegistry->getPluginDetails($aDependence['sClassName'] . '.php')) {
                 $sDependence = $aDependence['sClassName'];
                 throw new Exception(G::loadTranslation('ID_PLUGIN_DEPENDENCE_PLUGIN', SYS_LANG, array("Dependence" => $sDependence)));
             }
Ejemplo n.º 9
0
 function save($params)
 {
     require_once 'classes/model/Event.php';
     global $G_FORM;
     $sPRO_UID = $params->pro_uid;
     $sEVN_UID = $params->evn_uid;
     $sDYNAFORM = $params->initDyna;
     $sWS_USER = trim($params->username);
     $sWS_PASS = trim($params->password);
     $sWS_ROUNDROBIN = '';
     $sWE_USR = '';
     $xDYNA = $params->dynaform;
     if ($xDYNA != '') {
         $pro_uid = $params->pro_uid;
         $filename = $xDYNA;
         $filename = $filename . '.php';
         unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $pro_uid . PATH_SEP . $filename);
         unlink(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $pro_uid . PATH_SEP . str_replace(".php", "Post", $filename) . ".php");
     }
     //return $params;
     G::LoadClass("system");
     $pathProcess = PATH_DATA_SITE . 'public' . PATH_SEP . $sPRO_UID . PATH_SEP;
     G::mk_dir($pathProcess, 0777);
     $oEvent = new Event();
     $oEvent->load($sEVN_UID);
     $sTASKS = $oEvent->getEvnTasUidTo();
     $oTask = new Task();
     $oTask->load($sTASKS);
     $tas_title = $oTask->getTasTitle();
     if (G::is_https()) {
         $http = 'https://';
     } else {
         $http = 'http://';
     }
     $sContent = '';
     $SITE_PUBLIC_PATH = '';
     if (file_exists($SITE_PUBLIC_PATH . '')) {
     }
     require_once 'classes/model/Dynaform.php';
     $oDynaform = new Dynaform();
     $aDynaform = $oDynaform->load($sDYNAFORM);
     $dynTitle = str_replace(' ', '_', str_replace('/', '_', $aDynaform['DYN_TITLE']));
     $sContent = "<?php\n";
     $sContent .= "global \$_DBArray;\n";
     $sContent .= "if (!isset(\$_DBArray)) {\n";
     $sContent .= "  \$_DBArray = array();\n";
     $sContent .= "}\n";
     $sContent .= "\$_SESSION['PROCESS'] = '" . $sPRO_UID . "';\n";
     $sContent .= "\$_SESSION['CURRENT_DYN_UID'] = '" . $sDYNAFORM . "';\n";
     $sContent .= "\$G_PUBLISH = new Publisher;\n";
     $sContent .= "\$G_PUBLISH->AddContent('dynaform', 'xmlform', '" . $sPRO_UID . '/' . $sDYNAFORM . "', '', array(), '" . $dynTitle . 'Post.php' . "');\n";
     $sContent .= "G::RenderPage('publish', 'blank');";
     file_put_contents($pathProcess . $dynTitle . '.php', $sContent);
     //creating the second file, the  post file who receive the post form.
     $pluginTpl = PATH_CORE . 'templates' . PATH_SEP . 'processes' . PATH_SEP . 'webentryPost.tpl';
     $template = new TemplatePower($pluginTpl);
     $template->prepare();
     $template->assign('wsdlUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2');
     $template->assign('wsUploadUrl', $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/upload');
     $template->assign('processUid', $sPRO_UID);
     $template->assign('dynaformUid', $sDYNAFORM);
     $template->assign('taskUid', $sTASKS);
     $template->assign('wsUser', $sWS_USER);
     $template->assign('wsPass', 'md5:' . md5($sWS_PASS));
     $template->assign('wsRoundRobin', $sWS_ROUNDROBIN);
     if ($sWE_USR == "2") {
         $template->assign('USR_VAR', "\$cInfo = ws_getCaseInfo(\$caseId);\n\t  \$USR_UID = \$cInfo->currentUsers->userId;");
     } else {
         $template->assign('USR_VAR', '$USR_UID = -1;');
     }
     $template->assign('dynaform', $dynTitle);
     $template->assign('timestamp', date('l jS \\of F Y h:i:s A'));
     $template->assign('ws', SYS_SYS);
     $template->assign('version', System::getVersion());
     $fileName = $pathProcess . $dynTitle . 'Post.php';
     file_put_contents($fileName, $template->getOutputContent());
     //creating the third file, only if this wsClient.php file doesn't exists.
     $fileName = $pathProcess . 'wsClient.php';
     $pluginTpl = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . 'ws' . PATH_SEP . 'wsClient.php';
     if (file_exists($fileName)) {
         if (filesize($fileName) != filesize($pluginTpl)) {
             @copy($fileName, $pathProcess . 'wsClient.php.bck');
             @unlink($fileName);
             $template = new TemplatePower($pluginTpl);
             $template->prepare();
             file_put_contents($fileName, $template->getOutputContent());
         }
     } else {
         $template = new TemplatePower($pluginTpl);
         $template->prepare();
         file_put_contents($fileName, $template->getOutputContent());
     }
     require_once 'classes/model/Event.php';
     $oEvent = new Event();
     $aDataEvent = array();
     $aDataEvent['EVN_UID'] = $sEVN_UID;
     $aDataEvent['EVN_RELATED_TO'] = 'MULTIPLE';
     $aDataEvent['EVN_ACTION'] = $sDYNAFORM;
     $aDataEvent['EVN_CONDITIONS'] = $sWS_USER;
     $output = $oEvent->update($aDataEvent);
     $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sPRO_UID . '/' . $dynTitle . '.php';
     $this->success = true;
     $this->msg = G::LoadTranslation('ID_WEB_ENTRY_SUCCESS_NEW');
     $this->W_LINK = $link;
     $this->TAS_TITLE = $tas_title;
     $this->DYN_TITLE = $dynTitle;
     $this->USR_UID = $sWS_USER;
 }
Ejemplo n.º 10
0
            die;
            break;
        default:
            G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
            G::header('location: ../login/login');
            die;
            break;
    }
}
//calculating the max upload file size;
$POST_MAX_SIZE = ini_get('post_max_size');
$mul = substr($POST_MAX_SIZE, -1);
$mul = $mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1));
$postMaxSize = (int) $POST_MAX_SIZE * $mul;
$UPLOAD_MAX_SIZE = ini_get('upload_max_filesize');
$mul = substr($UPLOAD_MAX_SIZE, -1);
$mul = $mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1));
$uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul;
if ($postMaxSize < $uploadMaxSize) {
    $uploadMaxSize = $postMaxSize;
}
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'setup';
$G_ID_MENU_SELECTED = 'SETUP';
$G_ID_SUB_MENU_SELECTED = 'UPGRADE';
G::LoadClass("system");
$Fields['PM_VERSION'] = System::getVersion();
$Fields['MAX_FILE_SIZE'] = $uploadMaxSize . " (" . $UPLOAD_MAX_SIZE . ") ";
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/upgrade', '', $Fields, 'upgrade_System');
G::RenderPage('publishBlank', 'blank');
Ejemplo n.º 11
0
 /**
  * restore an archive into a workspace
  *
  * Restores any database and files included in the backup, either as a new
  * workspace, or overwriting a previous one
  *
  * @param string $filename the backup filename
  * @param string $newWorkspaceName if defined, supplies the name for the
  * workspace to restore to
  */
 public static function restore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true, $lang = 'en')
 {
     G::LoadThirdParty('pear/Archive', 'Tar');
     $backup = new Archive_Tar($filename);
     //Get a temporary directory in the upgrade directory
     $tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));
     $parentDirectory = PATH_DATA . "upgrade";
     if (is_writable($parentDirectory)) {
         mkdir($tempDirectory);
     } else {
         throw new Exception("Could not create directory:" . $parentDirectory);
     }
     //Extract all backup files, including database scripts and workspace files
     if (!$backup->extract($tempDirectory)) {
         throw new Exception("Could not extract backup");
     }
     //Search for metafiles in the new standard (the old standard would contain
     //txt files).
     $metaFiles = glob($tempDirectory . "/*.meta");
     if (empty($metaFiles)) {
         $metaFiles = glob($tempDirectory . "/*.txt");
         if (!empty($metaFiles)) {
             return workspaceTools::restoreLegacy($tempDirectory);
         } else {
             throw new Exception("No metadata found in backup");
         }
     } else {
         CLI::logging("Found " . count($metaFiles) . " workspaces in backup:\n");
         foreach ($metaFiles as $metafile) {
             CLI::logging("-> " . basename($metafile) . "\n");
         }
     }
     if (count($metaFiles) > 1 && !isset($srcWorkspace)) {
         throw new Exception("Multiple workspaces in backup but no workspace specified to restore");
     }
     if (isset($srcWorkspace) && !in_array("{$srcWorkspace}.meta", array_map(BASENAME, $metaFiles))) {
         throw new Exception("Workspace {$srcWorkspace} not found in backup");
     }
     $version = System::getVersion();
     $version = explode('-', $version);
     $versionPresent = isset($version[0]) ? $version[0] : '';
     CLI::logging(CLI::warning("\n            Note.- If you try to execute a restore from a generated backup on a recent version of Processmaker\n            than version you are using currently to restore it, it may be occur errors on the restore process,\n            it shouldn't be restaured generated backups on later versions than version when the restore is executed") . "\n");
     foreach ($metaFiles as $metaFile) {
         $metadata = G::json_decode(file_get_contents($metaFile));
         if ($metadata->version != 1) {
             throw new Exception("Backup version {$metadata->version} not supported");
         }
         $backupWorkspace = $metadata->WORKSPACE_NAME;
         if (isset($dstWorkspace)) {
             $workspaceName = $dstWorkspace;
             $createWorkspace = true;
         } else {
             $workspaceName = $metadata->WORKSPACE_NAME;
             $createWorkspace = false;
         }
         if (isset($srcWorkspace) && strcmp($metadata->WORKSPACE_NAME, $srcWorkspace) != 0) {
             CLI::logging(CLI::warning("> Workspace {$backupWorkspace} found, but not restoring.") . "\n");
             continue;
         } else {
             CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n");
         }
         $workspace = new workspaceTools($workspaceName);
         if ($workspace->workspaceExists()) {
             if ($overwrite) {
                 CLI::logging(CLI::warning("> Workspace {$workspaceName} already exist, overwriting!") . "\n");
             } else {
                 throw new Exception("Destination workspace already exist (use -o to overwrite)");
             }
         }
         if (file_exists($workspace->path)) {
             G::rm_dir($workspace->path);
         }
         foreach ($metadata->directories as $dir) {
             CLI::logging("+> Restoring directory '{$dir}'\n");
             if (file_exists("{$tempDirectory}/{$dir}" . "/ee")) {
                 G::rm_dir("{$tempDirectory}/{$dir}" . "/ee");
             }
             if (file_exists("{$tempDirectory}/{$dir}" . "/plugin.singleton")) {
                 G::rm_dir("{$tempDirectory}/{$dir}" . "/plugin.singleton");
             }
             if (!rename("{$tempDirectory}/{$dir}", $workspace->path)) {
                 throw new Exception("There was an error copying the backup files ({$tempDirectory}/{$dir}) to the workspace directory {$workspace->path}.");
             }
         }
         CLI::logging("> Changing file permissions\n");
         $shared_stat = stat(PATH_DATA);
         if ($shared_stat !== false) {
             workspaceTools::dirPerms($workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode']);
         } else {
             CLI::logging(CLI::error("Could not get the shared folder permissions, not changing workspace permissions") . "\n");
         }
         list($dbHost, $dbUser, $dbPass) = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
         $aParameters = array('dbHost' => $dbHost, 'dbUser' => $dbUser, 'dbPass' => $dbPass);
         CLI::logging("> Connecting to system database in '{$dbHost}'\n");
         $link = mysql_connect($dbHost, $dbUser, $dbPass);
         @mysql_query("SET NAMES 'utf8';");
         @mysql_query("SET FOREIGN_KEY_CHECKS=0;");
         if (!$link) {
             throw new Exception('Could not connect to system database: ' . mysql_error());
         }
         $newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace);
         foreach ($metadata->databases as $db) {
             $dbName = $newDBNames[$db->name];
             CLI::logging("+> Restoring database {$db->name} to {$dbName}\n");
             $workspace->executeSQLScript($dbName, "{$tempDirectory}/{$db->name}.sql", $aParameters);
             $workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);
             $workspace->createDBUser($dbName, $db->pass, "%", $dbName);
         }
         $version = explode('-', $metadata->PM_VERSION);
         $versionOld = isset($version[0]) ? $version[0] : '';
         CLI::logging(CLI::info("{$versionOld} < {$versionPresent}") . "\n");
         if ($versionOld < $versionPresent) {
             $start = microtime(true);
             CLI::logging("> Updating database...\n");
             $workspace->upgradeDatabase();
             $stop = microtime(true);
             $final = $stop - $start;
             CLI::logging("<*>   Database Upgrade Process took {$final} seconds.\n");
         }
         $start = microtime(true);
         CLI::logging("> Updating cache view...\n");
         $workspace->upgradeCacheView(true, false, $lang);
         $stop = microtime(true);
         $final = $stop - $start;
         CLI::logging("<*>   Updating cache view Process took {$final} seconds.\n");
         mysql_close($link);
     }
     CLI::logging("Removing temporary files\n");
     G::rm_dir($tempDirectory);
     CLI::logging(CLI::info("Done restoring") . "\n");
 }
Ejemplo n.º 12
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
//$oHeadPublisher = & headPublisher::getSingleton();
global $RBAC;
$RBAC->requirePermissions('PM_FACTORY');
G::loadClass('configuration');
$conf = new Configurations();
$pmVersion = preg_match("/^([\\d\\.]+).*\$/", System::getVersion(), $arrayMatch) ? $arrayMatch[1] : "";
//Otherwise: Branch master
$arrayFlagImportFileExtension = array("pm", "pmx", "bpmn");
$arrayFlagMenuNewOption = array("pm" => true, "bpmn" => true);
if ($pmVersion != "") {
    $arrayFlagImportFileExtension = version_compare($pmVersion . "", "3", ">=") ? $arrayFlagImportFileExtension : array("pm");
    $arrayFlagMenuNewOption = version_compare($pmVersion . "", "3", ">=") ? array("bpmn" => true) : array("pm" => true);
}
$pluginRegistry =& PMPluginRegistry::getSingleton();
$arrayMenuNewOptionPlugin = array();
$arrayContextMenuOptionPlugin = array();
foreach ($pluginRegistry->getDesignerMenu() as $value) {
    if (file_exists($value->file)) {
        require_once $value->file;
        $className = "DesignerMenu" . $value->pluginName;
        if (class_exists($className)) {
Ejemplo n.º 13
0
    $Fields['DATABASE'] = $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')';
    $Fields['DATABASE_SERVER'] = DB_HOST;
    $Fields['DATABASE_NAME'] = DB_NAME;
    $Fields['AVAILABLE_DB'] = $availdb;
} else {
    $Fields['DATABASE'] = "Not defined";
    $Fields['DATABASE_SERVER'] = "Not defined";
    $Fields['DATABASE_NAME'] = "Not defined";
    $Fields['AVAILABLE_DB'] = "Not defined";
}
$eeT = "";
if (class_exists('pmLicenseManager')) {
    $eeT = " - Enterprise Edition";
}
$Fields['PHP'] = phpversion();
$Fields['FLUID'] = System::getVersion() . $eeT;
$Fields['IP'] = lookup($ip);
$Fields['ENVIRONMENT'] = defined("SYS_SYS") ? SYS_SYS : "Not defined";
$Fields['SERVER_SOFTWARE'] = getenv('SERVER_SOFTWARE');
$Fields['SERVER_NAME'] = getenv('SERVER_NAME');
$Fields['SERVER_PROTOCOL'] = getenv('SERVER_PROTOCOL');
$Fields['SERVER_PORT'] = getenv('SERVER_PORT');
$Fields['REMOTE_HOST'] = getenv('REMOTE_HOST');
$Fields['SERVER_ADDR'] = getenv('SERVER_ADDR');
$Fields['HTTP_USER_AGENT'] = getenv('HTTP_USER_AGENT');
$Fields['TIME_ZONE'] = defined('TIME_ZONE') ? TIME_ZONE : "Unknown";
if (!defined('SKIP_RENDER_SYSTEM_INFORMATION')) {
    $G_PUBLISH = new Publisher();
    $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/dbInfo', '', $Fields, 'appNew2');
    G::RenderPage('publish', 'raw');
}
Ejemplo n.º 14
0
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */

//$oHeadPublisher = & headPublisher::getSingleton();
global $RBAC;
$RBAC->requirePermissions( 'PM_FACTORY' );

G::loadClass( 'configuration' );
$conf = new Configurations();

$pmVersion = (preg_match("/^([\d\.]+).*$/", System::getVersion(), $arrayMatch))? $arrayMatch[1] : ""; //Otherwise: Branch master

$arrayFlagImportFileExtension = array("pm", "pmx", "bpmn");
$arrayFlagMenuNewOption       = array("pm" => true, "bpmn" => true);

if ($pmVersion != "") {
    $arrayFlagImportFileExtension = (version_compare($pmVersion . "", "3", ">="))? $arrayFlagImportFileExtension : array("pm");
    $arrayFlagMenuNewOption       = (version_compare($pmVersion . "", "3", ">="))? array("bpmn" => true) : array("pm" => true);
}

$pluginRegistry = &PMPluginRegistry::getSingleton();

$arrayMenuNewOptionPlugin     = array();
$arrayContextMenuOptionPlugin = array();

foreach ($pluginRegistry->getDesignerMenu() as $value) {
Ejemplo n.º 15
0
 public function enterprisePlugin($sNamespace, $sFilename = null)
 {
     $pathPluginTrunk = PATH_CORE . "enterprise";
     $VERSION = System::getVersion();
     $res = parent::PMPlugin($sNamespace, $sFilename);
     $this->sFriendlyName = "ProcessMaker Enterprise Core Edition";
     $this->sDescription = "ProcessMaker Enterprise Core Edition {$VERSION}";
     $this->sPluginFolder = "enterprise";
     $this->sSetupPage = "../enterprise/addonsStore.php";
     $this->iVersion = $VERSION;
     $this->iPMVersion = "2.0.31";
     $this->aDependences = null;
     $this->aWorkspaces = null;
     $this->database = "workflow";
     $this->table = array("ADDONS_STORE", "ADDONS_MANAGER", "LICENSE_MANAGER");
     if (!isset($_SESSION["__EE_INSTALLATION__"])) {
         $_SESSION["__EE_INSTALLATION__"] = 0;
     }
     if (!isset($_SESSION["__EE_SW_PMLICENSEMANAGER__"])) {
         $_SESSION["__EE_SW_PMLICENSEMANAGER__"] = 1;
     }
     $sw = 1;
     $msgf = null;
     $msgd = null;
     if (file_exists(PATH_CORE . "plugins" . PATH_SEP . "pmLicenseManager.php")) {
         $_SESSION["__EE_INSTALLATION__"] = 1;
         $_SESSION["__EE_SW_PMLICENSEMANAGER__"] = 0;
         $plugin = "pmLicenseManager";
         $this->pluginUninstall($plugin);
         if (file_exists(PATH_CORE . "plugins" . PATH_SEP . $plugin . ".php") || file_exists(PATH_CORE . "plugins" . PATH_SEP . $plugin)) {
             $msgf = $msgf . ($msgf != null ? ", " : null) . $plugin . ".php";
             $msgd = $msgd . ($msgd != null ? ", " : null) . $plugin;
             $sw = 0;
         }
         $plugin = "enterprise";
         $this->pluginUninstall($plugin);
         if (file_exists(PATH_CORE . "plugins" . PATH_SEP . $plugin . ".php") || file_exists(PATH_CORE . "plugins" . PATH_SEP . $plugin)) {
             $msgf = $msgf . ($msgf != null ? ", " : null) . $plugin . ".php";
             $msgd = $msgd . ($msgd != null ? ", " : null) . $plugin;
             $sw = 0;
         }
         $this->uninstall();
     } else {
         $_SESSION["__EE_INSTALLATION__"] = $_SESSION["__EE_INSTALLATION__"] + 1;
     }
     if ($sw == 0) {
         unset($_SESSION["__EE_INSTALLATION__"]);
         unset($_SESSION["__EE_SW_PMLICENSEMANAGER__"]);
         ///////
         $js = "window.open(\"/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/setup/main?s=PLUGINS\", \"_top\", \"\");";
         if (substr(SYS_SKIN, 0, 2) == "ux" && SYS_SKIN != "uxs") {
             //$js = "parent.window.location.href = \"/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/setup/main_init?s=PLUGINS\";";
             //$js = "window.location.href = \"/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/setup/pluginsImport\";";
             $js = "window.open(\"/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/main\", \"_top\", \"\");";
         }
         ///////
         G::SendMessageText("ProcessMaker Enterprise plug-in can't delete the files \"{$msgf}\" and directories \"{$msgd}\" of \"" . (PATH_CORE . "plugins") . "\". Before proceeding with the installation of the plug-in must remove them.", "INFO");
         echo "<script type=\"text/javascript\">" . $js . "</script>";
         exit(0);
     }
     if ($_SESSION["__EE_SW_PMLICENSEMANAGER__"] == 0 && $_SESSION["__EE_INSTALLATION__"] == 2) {
         unset($_SESSION["__EE_INSTALLATION__"]);
         unset($_SESSION["__EE_SW_PMLICENSEMANAGER__"]);
         $this->install();
     }
     ///////
     return $res;
 }
Ejemplo n.º 16
0
 private function _getSystemInfo()
 {
     G::LoadClass("system");
     if (getenv('HTTP_CLIENT_IP')) {
         $ip = getenv('HTTP_CLIENT_IP');
     } else {
         if (getenv('HTTP_X_FORWARDED_FOR')) {
             $ip = getenv('HTTP_X_FORWARDED_FOR');
         } else {
             $ip = getenv('REMOTE_ADDR');
         }
     }
     $redhat = '';
     if (file_exists('/etc/redhat-release')) {
         $fnewsize = filesize('/etc/redhat-release');
         $fp = fopen('/etc/redhat-release', 'r');
         $redhat = trim(fread($fp, $fnewsize));
         fclose($fp);
     }
     $redhat .= " (" . PHP_OS . ")";
     if (defined("DB_HOST")) {
         G::LoadClass('net');
         G::LoadClass('dbConnections');
         $dbNetView = new NET(DB_HOST);
         $dbNetView->loginDbServer(DB_USER, DB_PASS);
         $dbConns = new dbConnections('');
         $availdb = '';
         foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
             if ($availdb != '') {
                 $availdb .= ', ';
             }
             $availdb .= $val['name'];
         }
         try {
             $sMySQLVersion = $dbNetView->getDbServerVersion(DB_ADAPTER);
         } catch (Exception $oException) {
             $sMySQLVersion = '?????';
         }
     }
     $sysSection = G::loadTranslation('ID_SYSTEM_INFO');
     $pmSection = 'ProcessMaker Information';
     $properties = array();
     $ee = class_exists('pmLicenseManager') ? " - Enterprise Edition" : '';
     $properties[] = array('ProcessMaker Ver.', System::getVersion() . $ee, $pmSection);
     $properties[] = array('Operating System', $redhat, $sysSection);
     $properties[] = array('Time Zone', defined('TIME_ZONE') ? TIME_ZONE : "Unknown", $sysSection);
     $properties[] = array('Web Server', getenv('SERVER_SOFTWARE'), $sysSection);
     $properties[] = array('Server Name', getenv('SERVER_NAME'), $pmSection);
     $properties[] = array('Server IP Address', $this->lookup($ip), $sysSection);
     $properties[] = array('PHP Version', phpversion(), $sysSection);
     if (defined("DB_HOST")) {
         $properties[] = array('Data Base', $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')', $pmSection);
         $properties[] = array('Data Base Server', DB_HOST, $pmSection);
         $properties[] = array('Data Base Name', DB_NAME, $pmSection);
         $properties[] = array('Available DB Engines', $availdb, $sysSection);
     } else {
         $properties[] = array('Data Base', "Not defined", $pmSection);
         $properties[] = array('Data Base Server', "Not defined", $pmSection);
         $properties[] = array('Data Base Name', "Not defined", $pmSection);
         $properties[] = array('Available DB Engines', "Not defined", $sysSection);
     }
     $properties[] = array('Workspace', defined("SYS_SYS") ? SYS_SYS : "Not defined", $pmSection);
     $properties[] = array('Server Protocol', getenv('SERVER_PROTOCOL'), $sysSection);
     $properties[] = array('Server Port', getenv('SERVER_PORT'), $sysSection);
     //$properties[] = array('Remote Host', getenv ('REMOTE_HOST'), $sysSection);
     $properties[] = array('Server Addr.', getenv('SERVER_ADDR'), $sysSection);
     $properties[] = array('User\'s Browser', getenv('HTTP_USER_AGENT'), $sysSection);
     return $properties;
 }
Ejemplo n.º 17
0
 private function _getSystemInfo()
 {
     G::LoadClass("system");
     if (getenv('HTTP_CLIENT_IP')) {
         $ip = getenv('HTTP_CLIENT_IP');
     } else {
         if (getenv('HTTP_X_FORWARDED_FOR')) {
             $ip = getenv('HTTP_X_FORWARDED_FOR');
         } else {
             $ip = getenv('REMOTE_ADDR');
         }
     }
     $redhat = '';
     if (file_exists('/etc/redhat-release')) {
         $fnewsize = filesize('/etc/redhat-release');
         $fp = fopen('/etc/redhat-release', 'r');
         $redhat = trim(fread($fp, $fnewsize));
         fclose($fp);
     }
     $redhat .= " (" . PHP_OS . ")";
     if (defined("DB_HOST")) {
         G::LoadClass('net');
         G::LoadClass('dbConnections');
         $dbNetView = new NET(DB_HOST);
         $dbNetView->loginDbServer(DB_USER, DB_PASS);
         $dbConns = new dbConnections('');
         $availdb = '';
         foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
             if ($availdb != '') {
                 $availdb .= ', ';
             }
             $availdb .= $val['name'];
         }
         try {
             $sMySQLVersion = $dbNetView->getDbServerVersion(DB_ADAPTER);
         } catch (Exception $oException) {
             $sMySQLVersion = '?????';
         }
     }
     if (file_exists(PATH_HTML . "lib/versions")) {
         $versions = json_decode(file_get_contents(PATH_HTML . "lib/versions"), true);
         $pmuiVer = $versions["pmui_ver"];
         $mafeVer = $versions["mafe_ver"];
         $pmdynaformVer = $versions["pmdynaform_ver"];
     } else {
         $pmuiVer = $mafeVer = $pmdynaformVer = "(unknown)";
     }
     $sysSection = G::loadTranslation('ID_SYSTEM_INFO');
     $pmSection = G::LoadTranslation('ID_PROCESS_INFORMATION');
     $properties = array();
     $ee = class_exists('pmLicenseManager') ? " - Enterprise Edition" : '';
     $systemName = 'ProcessMaker';
     if (defined('SYSTEM_NAME')) {
         $systemName = SYSTEM_NAME;
     }
     $properties[] = array($systemName . ' Ver.', System::getVersion() . $ee, $pmSection);
     $properties[] = array("PMUI JS Lib. Ver.", $pmuiVer, $pmSection);
     $properties[] = array("MAFE JS Lib. Ver.", $mafeVer, $pmSection);
     $properties[] = array("PM Dynaform JS Lib. Ver.", $pmdynaformVer, $pmSection);
     if (file_exists(PATH_DATA . 'log/upgrades.log')) {
         $properties[] = array(G::LoadTranslation('ID_UPGRADES_PATCHES'), '<a href="#" onclick="showUpgradedLogs(); return false;">' . G::LoadTranslation('ID_UPGRADE_VIEW_LOG') . '</a>', $pmSection);
     } else {
         $properties[] = array(G::LoadTranslation('ID_UPGRADES_PATCHES'), G::LoadTranslation('ID_UPGRADE_NEVER_UPGRADE'), $pmSection);
     }
     $properties[] = array(G::LoadTranslation('ID_OPERATING_SYSTEM'), $redhat, $sysSection);
     $properties[] = array(G::LoadTranslation('ID_TIME_ZONE'), defined('TIME_ZONE') ? TIME_ZONE : "Unknown", $sysSection);
     $properties[] = array(G::LoadTranslation('ID_WEB_SERVER'), getenv('SERVER_SOFTWARE'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_NAME'), getenv('SERVER_NAME'), $pmSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_IP'), $this->lookup($ip), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_PHP_VERSION'), phpversion(), $sysSection);
     if (defined("DB_HOST")) {
         $properties[] = array(G::LoadTranslation('ID_DATABASE'), $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')', $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_SERVER'), DB_HOST, $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_NAME'), DB_NAME, $pmSection);
         $properties[] = array(G::LoadTranslation('ID_AVAILABLE_DB'), $availdb, $sysSection);
     } else {
         $properties[] = array(G::LoadTranslation('ID_DATABASE'), "Not defined", $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_SERVER'), "Not defined", $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_NAME'), "Not defined", $pmSection);
         $properties[] = array(G::LoadTranslation('ID_AVAILABLE_DB'), "Not defined", $sysSection);
     }
     $properties[] = array(G::LoadTranslation('ID_WORKSPACE'), defined("SYS_SYS") ? SYS_SYS : "Not defined", $pmSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_PROTOCOL'), getenv('SERVER_PROTOCOL'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_PORT'), getenv('SERVER_PORT'), $sysSection);
     //$sysSection[] = array('Remote Host', getenv ('REMOTE_HOST'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_NAME'), getenv('SERVER_ADDR'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_USER_BROWSER'), getenv('HTTP_USER_AGENT'), $sysSection);
     return $properties;
 }
Ejemplo n.º 18
0
$oConf = unserialize(file_get_contents($fileObj));
$oConf->version += 1;
file_put_contents($fileObj, serialize($oConf));
$pathHome = PATH_DATA . 'skins' . PATH_SEP . $id . PATH_SEP;
$pathBase = PATH_DATA . 'skins' . PATH_SEP . $id . PATH_SEP . $id . PATH_SEP;
$pathPublic = $pathBase . 'data' . PATH_SEP . 'public_html' . PATH_SEP;
$pathImages = PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'images' . PATH_SEP;
G::mk_dir($pathBase);
G::mk_dir($pathBase . 'data');
G::mk_dir($pathPublic);
G::mk_dir($pathPublic . 'images');
//  file_put_contents ( PATH_DATA . 'skins' . PATH_SEP . $id  , "hello world" );
$fields['className'] = $id;
$fields['version'] = $oConf->version;
$fields['description'] = $oConf->description;
$fields['PMversion'] = System::getVersion();
savePluginFile('skinPluginMainClass', $pathHome . $id . '.php', $fields);
savePluginFile('skinPluginClass', $pathBase . 'class.' . $id . '.php', $fields);
copyFile(PATH_SKINS . $id . '.php', $pathBase . 'data');
copyFile(PATH_SKINS . $id . '.html', $pathBase . 'data');
copyFile(PATH_SKINS . $id . '.cnf', $pathBase . 'data');
copyFile(PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'iepngfix.htc', $pathPublic);
copyFile(PATH_HTML . 'skins' . PATH_SEP . $id . PATH_SEP . 'style.css', $pathPublic);
$aFiles = array();
if ($handle = opendir($pathImages)) {
    while (false !== ($file = readdir($handle))) {
        if (substr($file, 0, 1) != '.') {
            if (isset($aFiles[$file])) {
                $aFiles[$file] = 0;
            }
            copyFile($pathImages . $file, $pathPublic . 'images' . PATH_SEP);
Ejemplo n.º 19
0
 /**
  * for send email configuration
  * @autor Alvaro  <*****@*****.**>
  */
 public function sendTestMail()
 {
     global $G_PUBLISH;
     G::LoadClass("system");
     G::LoadClass('spool');
     $sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>';
     $sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT');
     $msg = G::LoadTranslation('ID_MESS_TEST_BODY');
     switch ($_POST['MESS_ENGINE']) {
         case 'MAIL':
             $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1');
             break;
         case 'PHPMAILER':
             $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2');
             break;
         case 'OPENMAIL':
             $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3');
             break;
     }
     $sBodyPre = new TemplatePower(PATH_TPL . 'admin' . PATH_SEP . 'email.tpl');
     $sBodyPre->prepare();
     $sBodyPre->assign('server', $_SERVER['SERVER_NAME']);
     $sBodyPre->assign('date', date('H:i:s'));
     $sBodyPre->assign('ver', System::getVersion());
     $sBodyPre->assign('engine', $engine);
     $sBodyPre->assign('msg', $msg);
     $sBody = $sBodyPre->getOutputContent();
     $oSpool = new spoolRun();
     $oSpool->setConfig(array('MESS_ENGINE' => $_POST['MESS_ENGINE'], 'MESS_SERVER' => $_POST['MESS_SERVER'], 'MESS_PORT' => $_POST['MESS_PORT'], 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], 'SMTPAuth' => $_POST['SMTPAuth'], 'SMTPSecure' => isset($_POST['SMTPSecure']) ? $_POST['SMTPSecure'] : 'none'));
     $oSpool->create(array('msg_uid' => '', 'app_uid' => '', 'del_index' => 0, 'app_msg_type' => 'TEST', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $_POST['TO'], 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending', 'app_msg_attach' => ''));
     $oSpool->sendMail();
     $G_PUBLISH = new Publisher();
     if ($oSpool->status == 'sent') {
         $o->status = true;
         $o->success = true;
         $o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS');
     } else {
         $o->status = false;
         $o->success = false;
         $o->msg = $oSpool->error;
     }
     return $o;
 }
Ejemplo n.º 20
0
 /**
  * Send a test email
  *
  * @param array $arrayData Data
  *
  * return array Return array with result of send test mail
  */
 public function sendTestMail(array $arrayData)
 {
     try {
         \G::LoadClass("system");
         \G::LoadClass("spool");
         $aConfiguration = array("MESS_ENGINE" => $arrayData["MESS_ENGINE"], "MESS_SERVER" => $arrayData["MESS_SERVER"], "MESS_PORT" => (int) $arrayData["MESS_PORT"], "MESS_ACCOUNT" => $arrayData["MESS_ACCOUNT"], "MESS_PASSWORD" => $arrayData["MESS_PASSWORD"], "MESS_FROM_NAME" => $arrayData["FROM_NAME"], "MESS_FROM_MAIL" => $arrayData["FROM_EMAIL"], "MESS_RAUTH" => (int) $arrayData["MESS_RAUTH"], "SMTPSecure" => isset($arrayData["SMTPSecure"]) ? $arrayData["SMTPSecure"] : "none");
         $sFrom = \G::buildFrom($aConfiguration);
         $sSubject = \G::LoadTranslation("ID_MESS_TEST_SUBJECT");
         $msg = \G::LoadTranslation("ID_MESS_TEST_BODY");
         switch ($arrayData["MESS_ENGINE"]) {
             case "MAIL":
                 $engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_1");
                 break;
             case "PHPMAILER":
                 $engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_2");
                 break;
             case "OPENMAIL":
                 $engine = \G::LoadTranslation("ID_MESS_ENGINE_TYPE_3");
                 break;
         }
         $sBodyPre = new \TemplatePower(PATH_TPL . "admin" . PATH_SEP . "email.tpl");
         $sBodyPre->prepare();
         $sBodyPre->assign("server", $_SERVER["SERVER_NAME"]);
         $sBodyPre->assign("date", date("H:i:s"));
         $sBodyPre->assign("ver", \System::getVersion());
         $sBodyPre->assign("engine", $engine);
         $sBodyPre->assign("msg", $msg);
         $sBody = $sBodyPre->getOutputContent();
         $oSpool = new \spoolRun();
         $oSpool->setConfig($aConfiguration);
         $oSpool->create(array("msg_uid" => "", "app_uid" => "", "del_index" => 0, "app_msg_type" => "TEST", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $arrayData["TO"], "app_msg_body" => $sBody, "app_msg_cc" => "", "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending", "app_msg_attach" => ""));
         $oSpool->sendMail();
         //Return
         $arrayTestMailResult = array();
         if ($oSpool->status == "sent") {
             $arrayTestMailResult["status"] = true;
             $arrayTestMailResult["success"] = true;
             $arrayTestMailResult["msg"] = \G::LoadTranslation("ID_MAIL_TEST_SUCCESS");
         } else {
             $arrayTestMailResult["status"] = false;
             $arrayTestMailResult["success"] = false;
             $arrayTestMailResult["msg"] = $oSpool->error;
         }
         return $arrayTestMailResult;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 21
0
 /**
  * Update this store information from the store location.
  *
  * @return bool true if updated, false otherwise
  */
 public function update($force = false, $type = 'plugin')
 {
     require_once PATH_CORE . 'classes' . PATH_SEP . 'class.pmLicenseManager.php';
     if (!class_exists('AddonsManagerPeer')) {
         require_once 'classes/model/AddonsManager.php';
     }
     //If we have any addon that is installing or updating, don't update store
     $criteria = new Criteria(AddonsManagerPeer::DATABASE_NAME);
     $criteria->add(AddonsManagerPeer::ADDON_STATE, '', Criteria::NOT_EQUAL);
     $criteria->add(AddonsManagerPeer::ADDON_TYPE, $type);
     if (AddonsManagerPeer::doCount($criteria) > 0) {
         return false;
     }
     $this->clear($type);
     //Fill with local information
     //List all plugins installed
     $oPluginRegistry =& PMPluginRegistry::getSingleton();
     $aPluginsPP = array();
     if (file_exists(PATH_DATA_SITE . 'ee')) {
         $aPluginsPP = unserialize(trim(file_get_contents(PATH_DATA_SITE . 'ee')));
     }
     $pmLicenseManagerO =& pmLicenseManager::getSingleton();
     $localPlugins = array();
     if ($type == 'plugin') {
         foreach ($aPluginsPP as $aPlugin) {
             $sClassName = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-'));
             if (file_exists(PATH_PLUGINS . $sClassName . '.php')) {
                 require_once PATH_PLUGINS . $sClassName . '.php';
                 $oDetails = $oPluginRegistry->getPluginDetails($sClassName . '.php');
                 if ($oDetails) {
                     $sStatus = $oDetails->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED');
                     if (isset($oDetails->aWorkspaces)) {
                         if (!in_array(SYS_SYS, $oDetails->aWorkspaces)) {
                             continue;
                         }
                     }
                     if ($sClassName == "pmLicenseManager" || $sClassName == "pmTrial") {
                         continue;
                     }
                     $sEdit = $oDetails->sSetupPage != '' && $oDetails->enabled ? G::LoadTranslation('ID_SETUP') : ' ';
                     $aPlugin = array();
                     $aPluginId = $sClassName;
                     $aPluginTitle = $oDetails->sFriendlyName;
                     $aPluginDescription = $oDetails->sDescription;
                     $aPluginVersion = $oDetails->iVersion;
                     if (@in_array($sClassName, $pmLicenseManagerO->features)) {
                         $aPluginStatus = $sStatus;
                         $aPluginLinkStatus = 'pluginsChange?id=' . $sClassName . '.php&status=' . $oDetails->enabled;
                         $aPluginEdit = $sEdit;
                         $aPluginLinkEdit = 'pluginsSetup?id=' . $sClassName . '.php';
                         $aPluginStatusA = $sStatus == "Enabled" ? "installed" : 'disabled';
                         $enabledStatus = true;
                     } else {
                         $aPluginStatus = "";
                         $aPluginLinkStatus = '';
                         $aPluginEdit = '';
                         $aPluginLinkEdit = '';
                         $aPluginStatusA = 'minus-circle';
                         $enabledStatus = false;
                     }
                     $addon = new AddonsManager();
                     //G::pr($addon);
                     $addon->setAddonId($aPluginId);
                     $addon->setStoreId($this->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName($aPluginId);
                     $addon->setAddonDescription($aPluginDescription);
                     $addon->setAddonNick($aPluginTitle);
                     $addon->setAddonVersion("");
                     $addon->setAddonStatus($aPluginStatusA);
                     $addon->setAddonType("plugin");
                     $addon->setAddonPublisher("Colosa");
                     $addon->setAddonDownloadUrl("");
                     $addon->setAddonDownloadMd5("");
                     $addon->setAddonReleaseDate(null);
                     $addon->setAddonReleaseType('localRegistry');
                     $addon->setAddonReleaseNotes("");
                     $addon->setAddonState("");
                     $addon->save();
                     $localPlugins[$aPluginId] = $addon;
                 }
             }
         }
     } else {
         $list = unserialize($pmLicenseManagerO->licensedfeaturesList);
         if (is_array($list)) {
             foreach ($list['addons'] as $key => $feature) {
                 $addon = new AddonsManager();
                 $addon->setAddonId($feature['name']);
                 $addon->setStoreId($feature['guid']);
                 $addon->setAddonName($feature['name']);
                 $addon->setAddonDescription($feature['description']);
                 $addon->setAddonNick($feature['nick']);
                 $addon->setAddonVersion("");
                 $addon->setAddonStatus($feature['status']);
                 $addon->setAddonType("features");
                 $addon->setAddonPublisher("Colosa");
                 $addon->setAddonDownloadUrl("");
                 $addon->setAddonDownloadMd5("");
                 $addon->setAddonReleaseDate(null);
                 $addon->setAddonReleaseType('localRegistry');
                 $addon->setAddonReleaseNotes("");
                 $addon->setAddonState("");
                 $addon->save();
             }
         }
     }
     $this->setStoreLastUpdated(time());
     $this->save();
     $url = $this->getStoreLocation();
     //Validate url
     $licenseInfo = $pmLicenseManagerO->getActiveLicense();
     $licenseId = str_replace('.dat', '', str_replace('license_', '', basename($licenseInfo['LICENSE_PATH'])));
     $url = explode('&', $url);
     $url[count($url) - 1] = 'licId=' . urlencode($licenseId);
     $url = implode('&', $url);
     if (EnterpriseUtils::getInternetConnection() == 1 && EnterpriseUtils::checkConnectivity($url) == true) {
         $option = array("http" => array("method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded\r\n", "content" => http_build_query(array("pmVersion" => System::getVersion(), "version" => STORE_VERSION))));
         // Proxy settings
         $sysConf = System::getSystemConfiguration();
         if (isset($sysConf['proxy_host'])) {
             if ($sysConf['proxy_host'] != '') {
                 if (!is_array($option['http'])) {
                     $option['http'] = array();
                 }
                 $option['http']['request_fulluri'] = true;
                 $option['http']['proxy'] = 'tcp://' . $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '');
                 if ($sysConf['proxy_user'] != '') {
                     if (!isset($option['http']['header'])) {
                         $option['http']['header'] = '';
                     }
                     $option['http']['header'] .= 'Proxy-Authorization: Basic ' . base64_encode($sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
                 }
             }
         }
         $context = stream_context_create($option);
         //This may block for a while, always use AJAX to call this method
         $url = $url . '&type=' . strtoupper($type);
         $data = file_get_contents($url, false, $context);
         if ($data === false) {
             throw new Exception("Could not contact store");
         }
         $serverData = G::json_decode($data);
         //Don't trust external data
         if (empty($serverData)) {
             throw new Exception("Store data invalid ('{$data}')");
         }
         if (isset($serverData->error)) {
             throw new Exception("Store sent us an error: {$serverData->error}");
         }
         if (!isset($serverData->version)) {
             throw new Exception("Store version not found");
         }
         if ($serverData->version != STORE_VERSION) {
             throw new Exception("Store version '{$serverData->version}' unsupported");
         }
         if (!isset($serverData->addons)) {
             throw new Exception("Addons not found on store data");
         }
         $this->clear($type);
         try {
             //Add each item to this stores addons
             $addons = @get_object_vars($serverData->addons);
             if (!empty($addons)) {
                 foreach (get_object_vars($serverData->addons) as $addonId => $addonInfo) {
                     $addon = new AddonsManager();
                     $addon->setAddonId($addonId);
                     $addon->setStoreId($this->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName(isset($addonInfo->name) ? $addonInfo->name : $addonId);
                     $addon->setAddonDescription(isset($addonInfo->description) ? $addonInfo->description : "");
                     $addon->setAddonNick(isset($addonInfo->nick) ? $addonInfo->nick : "");
                     $addon->setAddonVersion(isset($addonInfo->version) ? $addonInfo->version : "");
                     $addon->setAddonStatus(isset($addonInfo->status) ? $addonInfo->status : "");
                     $addon->setAddonType(isset($addonInfo->type) ? $addonInfo->type : "");
                     $addon->setAddonPublisher(isset($addonInfo->publisher) ? $addonInfo->publisher : "");
                     $workspace = isset($pmLicenseManagerO->workspace) ? $pmLicenseManagerO->workspace : 'pmLicenseSrv';
                     $addon->setAddonDownloadUrl(isset($addonInfo->download_url) ? $addonInfo->download_url : "http://" . $pmLicenseManagerO->server . "/sys" . $workspace . "/en/green/services/rest?action=getPlugin&OBJ_UID=" . $addonInfo->guid);
                     $addon->setAddonDownloadMd5(isset($addonInfo->download_md5) ? $addonInfo->download_md5 : "");
                     $addon->setAddonReleaseDate(isset($addonInfo->release_date) ? $addonInfo->release_date : "");
                     $addon->setAddonReleaseType(isset($addonInfo->release_type) ? $addonInfo->release_type : '');
                     $addon->setAddonReleaseNotes(isset($addonInfo->release_notes) ? $addonInfo->release_notes : "");
                     $addon->setAddonState("");
                     $addon->save();
                     if (isset($localPlugins[$addonId])) {
                         unset($localPlugins[$addonId]);
                     }
                 }
                 foreach ($localPlugins as $keyPlugin => $addonA) {
                     //G::pr($addonA );
                     //$addonA->save();
                     $addon = new AddonsManager();
                     //G::pr($addon);
                     $addon->setAddonId($addonA->getAddonId());
                     $addon->setStoreId($addonA->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName($addonA->getAddonName());
                     $addon->setAddonDescription($addonA->getAddonDescription());
                     $addon->setAddonNick($addonA->getAddonNick());
                     $addon->setAddonVersion("");
                     $addon->setAddonStatus($addonA->getAddonStatus());
                     $addon->setAddonType($addonA->getAddonType());
                     $addon->setAddonPublisher($addonA->getAddonPublisher());
                     $addon->setAddonDownloadUrl($addonA->getAddonDownloadUrl());
                     $addon->setAddonDownloadMd5($addonA->getAddonDownloadMd5());
                     $addon->setAddonReleaseDate(null);
                     $addon->setAddonReleaseType('localRegistry');
                     $addon->setAddonReleaseNotes("");
                     $addon->setAddonState("");
                     $addon->save();
                 }
             }
             $this->setStoreLastUpdated(time());
             $this->save();
         } catch (Exception $e) {
             //If we had issues, don't keep only a part of the items
             $this->clear($type);
             throw $e;
         }
     }
     return true;
 }
Ejemplo n.º 22
0
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */

//$oHeadPublisher = & headPublisher::getSingleton();
global $RBAC;
$RBAC->requirePermissions( 'PM_FACTORY' );

G::loadClass( 'configuration' );
$conf = new Configurations();

if (preg_match("/^([\d\.]+).*$/", System::getVersion(), $arrayMatch)) {
    $pmVersion = $arrayMatch[1];
} else {
    $pmVersion = ""; //Branch master
}

$arrayImportFileExtension = array("pm", "pmx", "bpmn");
$arrayMenuNewOption       = array("pm" => true, "bpmn" => true);

if ($pmVersion != "") {
    $arrayImportFileExtension = (version_compare($pmVersion . "", "3", ">="))? $arrayImportFileExtension : array("pm");
    $arrayMenuNewOption       = (version_compare($pmVersion . "", "3", ">="))? array("bpmn" => true) : array("pm" => true);
}

$oHeadPublisher->addExtJsScript( 'processes/main', true ); //adding a javascript file .js
$oHeadPublisher->addContent( 'processes/main' ); //adding a html file  .html.
Ejemplo n.º 23
0
    /**

     * restore an archive into a workspace

     *

     * Restores any database and files included in the backup, either as a new

     * workspace, or overwriting a previous one

     *

     * @param string $filename the backup filename

     * @param string $newWorkspaceName if defined, supplies the name for the

     * workspace to restore to

     */

    static public function restore($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true, $lang = 'en', $port = '')

    {

        G::LoadThirdParty('pear/Archive', 'Tar');

        $backup = new Archive_Tar($filename);

        //Get a temporary directory in the upgrade directory

        $tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));

        $parentDirectory = PATH_DATA . "upgrade";

        if (is_writable($parentDirectory)) {

            mkdir($tempDirectory);

        } else {

            throw new Exception("Could not create directory:" . $parentDirectory);

        }

        //Extract all backup files, including database scripts and workspace files

        if (!$backup->extract($tempDirectory)) {

            throw new Exception("Could not extract backup");

        }

        //Search for metafiles in the new standard (the old standard would contain

        //txt files).

        $metaFiles = glob($tempDirectory . "/*.meta");

        if (empty($metaFiles)) {

            $metaFiles = glob($tempDirectory . "/*.txt");

            if (!empty($metaFiles)) {

                return workspaceTools::restoreLegacy($tempDirectory);

            } else {

                throw new Exception("No metadata found in backup");

            }

        } else {

            CLI::logging("Found " . count($metaFiles) . " workspaces in backup:\n");

            foreach ($metaFiles as $metafile) {

                CLI::logging("-> " . basename($metafile) . "\n");

            }

        }

        if (count($metaFiles) > 1 && (!isset($srcWorkspace))) {

            throw new Exception("Multiple workspaces in backup but no workspace specified to restore");

        }

        if (isset($srcWorkspace) && !in_array("$srcWorkspace.meta", array_map(BASENAME, $metaFiles))) {

            throw new Exception("Workspace $srcWorkspace not found in backup");

        }



        $version = System::getVersion();

        $version = explode('-', $version);

        $versionPresent = ( isset($version[0])) ? $version[0] : '';

        CLI::logging(CLI::warning("

            Warning: A workspace from a newer version of ProcessMaker can NOT be restored in an older version of

            ProcessMaker. For example, restoring from v.3.0 to v.2.5 will not work. However, it may be possible

            to restore a workspace from an older version to an newer version of ProcessMaker, although error

            messages may be displayed during the restore process. Make sure to run the \"processmaker cacheview-repair\"

            and \"processmaker migrate-new-cases-lists\" commands after restoring a workspace.") . "\n");



        foreach ($metaFiles as $metaFile) {

            $metadata = G::json_decode(file_get_contents($metaFile));

            if ($metadata->version != 1) {

                throw new Exception("Backup version {$metadata->version} not supported");

            }

            $backupWorkspace = $metadata->WORKSPACE_NAME;



            if (strpos($metadata->DB_RBAC_NAME, 'rb_') === false) {

                $onedb = true;

                $oldDatabases = 1;

            } else {

                $onedb = false;

                $oldDatabases = 3;

            }



            if (isset($dstWorkspace)) {

                $workspaceName = $dstWorkspace;

                $createWorkspace = true;

            } else {

                $workspaceName = $metadata->WORKSPACE_NAME;

                $createWorkspace = false;

            }

            if (isset($srcWorkspace) && strcmp($metadata->WORKSPACE_NAME, $srcWorkspace) != 0) {

                CLI::logging(CLI::warning("> Workspace $backupWorkspace found, but not restoring.") . "\n");

                continue;

            } else {

                CLI::logging("> Restoring " . CLI::info($backupWorkspace) . " to " . CLI::info($workspaceName) . "\n");

            }

            $workspace = new workspaceTools($workspaceName);



            if ($workspace->workspaceExists()) {



                if ($overwrite) {

                    if ($workspace->dbInfo['DB_NAME'] == $workspace->dbInfo['DB_RBAC_NAME']) {

                        $newDatabases = 1;

                    } else {

                        $newDatabases = 3;

                    }



                    if ($newDatabases != $oldDatabases) {

                        throw new Exception("We can't overwrite this workspace because it has a different amount of databases. Not only the 'source' but also the 'target' must have the same amount of databases.");

                    }

                    CLI::logging(CLI::warning("> Workspace $workspaceName already exist, overwriting!") . "\n");

                } else {

                    throw new Exception("Destination workspace already exist (use -o to overwrite)");

                }

            }

            if (file_exists($workspace->path)) {

                G::rm_dir($workspace->path);

            }

            foreach ($metadata->directories as $dir) {

                CLI::logging("+> Restoring directory '$dir'\n");



                if (file_exists("$tempDirectory/$dir" . "/ee")) {

                    G::rm_dir("$tempDirectory/$dir" . "/ee");

                }

                if (file_exists("$tempDirectory/$dir" . "/plugin.singleton")) {

                    G::rm_dir("$tempDirectory/$dir" . "/plugin.singleton");

                }

                if (!rename("$tempDirectory/$dir", $workspace->path)) {

                    throw new Exception("There was an error copying the backup files ($tempDirectory/$dir) to the workspace directory {$workspace->path}.");

                }

            }



            CLI::logging("> Changing file permissions\n");

            $shared_stat = stat(PATH_DATA);

            if ($shared_stat !== false) {

                workspaceTools::dirPerms($workspace->path, $shared_stat['uid'], $shared_stat['gid'], $shared_stat['mode']);

            } else {

                CLI::logging(CLI::error("Could not get the shared folder permissions, not changing workspace permissions") . "\n");

            }

            list ($dbHost, $dbUser, $dbPass) = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));

            if($port != ''){

               $dbHost = $dbHost.$port; //127.0.0.1:3306

            }

            $aParameters = array('dbHost'=>$dbHost,'dbUser'=>$dbUser,'dbPass'=>$dbPass);

            CLI::logging("> Connecting to system database in '$dbHost'\n");

            $link = mysql_connect($dbHost, $dbUser, $dbPass);

            @mysql_query("SET NAMES 'utf8';");

            @mysql_query("SET FOREIGN_KEY_CHECKS=0;");

            if (!$link) {

                throw new Exception('Could not connect to system database: ' . mysql_error());

            }



            $dbName = '';

            $newDBNames = $workspace->resetDBInfo($dbHost, $createWorkspace, $onedb);



            foreach ($metadata->databases as $db) {

                if ($dbName != $newDBNames[$db->name]) {

                    $dbName = $newDBNames[$db->name];



                    if (mysql_select_db($dbName, $link)) {

                        if(!$overwrite) {

                            throw new Exception("Destination Database already exist (use -o to overwrite)");

                        }

                    }



                    CLI::logging("+> Restoring database {$db->name} to $dbName\n");

                    $workspace->executeSQLScript($dbName, "$tempDirectory/{$db->name}.sql",$aParameters);

                    $workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);

                    $workspace->createDBUser($dbName, $db->pass, "%", $dbName);

                }

            }



            $version = explode('-', $metadata->PM_VERSION);

            $versionOld = ( isset($version[0])) ? $version[0] : '';

            CLI::logging(CLI::info("$versionOld < $versionPresent") . "\n");



            $start = microtime(true);

            CLI::logging("> Verify files enterprise old...\n");

            $workspace->verifyFilesOldEnterprise($workspaceName);

            $stop = microtime(true);

            $final = $stop - $start;

            CLI::logging("<*>   Verify took $final seconds.\n");



            if ( $versionOld < $versionPresent || strpos($versionPresent, "Branch")) {

                $start = microtime(true);

                CLI::logging("> Updating database...\n");

                $workspace->upgradeDatabase($onedb);

                $stop = microtime(true);

                $final = $stop - $start;

                CLI::logging("<*>   Database Upgrade Process took $final seconds.\n");

            }

            $start = microtime(true);

            CLI::logging("> Verify License Enterprise...\n");

            $workspace->verifyLicenseEnterprise($workspaceName);

            $stop = microtime(true);

            $final = $stop - $start;

            CLI::logging("<*>   Verify took $final seconds.\n");



            $workspace->checkMafeRequirements($workspaceName, $lang);



            /*----------------------------------********---------------------------------*/



            mysql_close($link);

        }



        CLI::logging("Removing temporary files\n");



        G::rm_dir($tempDirectory);



        CLI::logging(CLI::info("Done restoring") . "\n");

    }
Ejemplo n.º 24
0
 /**
  * Set value in WE_DATA
  *
  * @param string $webEntryUid Unique id of Web Entry
  *
  * return void
  */
 public function setWeData($webEntryUid)
 {
     try {
         //Verify data
         $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]);
         //Set variables
         $arrayWebEntryData = $this->getWebEntry($webEntryUid, true);
         $processUid = $arrayWebEntryData["PRO_UID"];
         $taskUid = $arrayWebEntryData["TAS_UID"];
         $dynaFormUid = $arrayWebEntryData["DYN_UID"];
         $webEntryMethod = $arrayWebEntryData["WE_METHOD"];
         $webEntryInputDocumentAccess = $arrayWebEntryData["WE_INPUT_DOCUMENT_ACCESS"];
         $webEntryData = "";
         $wsRoundRobin = 0;
         //0, 1 //0 - Cyclical Assignment
         $pathDataPublicProcess = PATH_DATA_PUBLIC . $processUid;
         //Delete previous files
         if (trim($arrayWebEntryData["WE_DATA"]) != "") {
             $fileName = str_replace(".php", "", trim($arrayWebEntryData["WE_DATA"]));
             $file = $pathDataPublicProcess . PATH_SEP . $fileName . ".php";
             if (is_file($file) && file_exists($file)) {
                 unlink($file);
                 unlink($pathDataPublicProcess . PATH_SEP . $fileName . "Post.php");
             }
         }
         //Create files
         \G::mk_dir($pathDataPublicProcess, 0777);
         $http = \G::is_https() ? "https://" : "http://";
         switch ($webEntryMethod) {
             case "WS":
                 require_once PATH_RBAC . "model" . PATH_SEP . "RbacUsers.php";
                 $user = new \RbacUsers();
                 $arrayUserData = $user->load($arrayWebEntryData["USR_UID"]);
                 $usrUsername = $arrayUserData["USR_USERNAME"];
                 $usrPassword = $arrayUserData["USR_PASSWORD"];
                 $dynaForm = new \Dynaform();
                 $arrayDynaFormData = $dynaForm->Load($arrayWebEntryData["DYN_UID"]);
                 //Creating sys.info;
                 $sitePublicPath = "";
                 if (file_exists($sitePublicPath . "")) {
                 }
                 //Creating the first file
                 $weTitle = $this->sanitizeFilename($arrayWebEntryData["WE_TITLE"]);
                 $fileName = $weTitle;
                 $fileContent = "<?php\n";
                 $fileContent .= "global \$_DBArray;\n";
                 $fileContent .= "if (!isset(\$_DBArray)) {\n";
                 $fileContent .= "  \$_DBArray = array();\n";
                 $fileContent .= "}\n";
                 $fileContent .= "\$_SESSION[\"PROCESS\"] = \"" . $processUid . "\";\n";
                 $fileContent .= "\$_SESSION[\"CURRENT_DYN_UID\"] = \"" . $dynaFormUid . "\";\n";
                 $fileContent .= "\$G_PUBLISH = new Publisher();\n";
                 $fileContent .= "G::LoadClass(\"pmDynaform\");\n";
                 $fileContent .= "\$a = new pmDynaform(array(\"CURRENT_DYNAFORM\" => \"" . $arrayWebEntryData["DYN_UID"] . "\"));\n";
                 $fileContent .= "if (\$a->isResponsive()) {";
                 $fileContent .= "  \$a->printWebEntry(\"" . $fileName . "Post.php\");";
                 $fileContent .= "} else {";
                 $fileContent .= "  \$G_PUBLISH->AddContent(\"dynaform\", \"xmlform\", \"" . $processUid . PATH_SEP . $dynaFormUid . "\", \"\", array(), \"" . $fileName . "Post.php\");\n";
                 $fileContent .= "  G::RenderPage(\"publish\", \"blank\");";
                 $fileContent .= "}";
                 file_put_contents($pathDataPublicProcess . PATH_SEP . $fileName . ".php", $fileContent);
                 //Creating the second file, the  post file who receive the post form.
                 $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentryPost.tpl";
                 $template = new \TemplatePower($pluginTpl);
                 $template->prepare();
                 $template->assign("wsdlUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/wsdl2");
                 $template->assign("wsUploadUrl", $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/upload");
                 $template->assign("processUid", $processUid);
                 $template->assign("dynaformUid", $dynaFormUid);
                 $template->assign("taskUid", $taskUid);
                 $template->assign("wsUser", $usrUsername);
                 $template->assign("wsPass", \Bootstrap::getPasswordHashType() . ':' . $usrPassword);
                 $template->assign("wsRoundRobin", $wsRoundRobin);
                 if ($webEntryInputDocumentAccess == 0) {
                     //Restricted to process permissions
                     $template->assign("USR_VAR", "\$cInfo = ws_getCaseInfo(\$caseId);\n\t  \$USR_UID = \$cInfo->currentUsers->userId;");
                 } else {
                     //No Restriction
                     $template->assign("USR_VAR", "\$USR_UID = -1;");
                 }
                 $template->assign("dynaform", $arrayDynaFormData["DYN_TITLE"]);
                 $template->assign("timestamp", date("l jS \\of F Y h:i:s A"));
                 $template->assign("ws", SYS_SYS);
                 $template->assign("version", \System::getVersion());
                 $fileName = $pathDataPublicProcess . PATH_SEP . $weTitle . "Post.php";
                 file_put_contents($fileName, $template->getOutputContent());
                 //Creating the third file, only if this wsClient.php file doesn't exist.
                 $fileName = $pathDataPublicProcess . PATH_SEP . "wsClient.php";
                 $pluginTpl = PATH_CORE . "templates" . PATH_SEP . "processes" . PATH_SEP . "wsClient.php";
                 if (file_exists($fileName)) {
                     if (filesize($fileName) != filesize($pluginTpl)) {
                         copy($fileName, $pathDataPublicProcess . PATH_SEP . "wsClient.php.bak");
                         unlink($fileName);
                         $template = new \TemplatePower($pluginTpl);
                         $template->prepare();
                         file_put_contents($fileName, $template->getOutputContent());
                     }
                 } else {
                     $template = new \TemplatePower($pluginTpl);
                     $template->prepare();
                     file_put_contents($fileName, $template->getOutputContent());
                 }
                 //Event
                 $task = new \Task();
                 $arrayTaskData = $task->load($arrayWebEntryData["TAS_UID"]);
                 $weEventUid = $task->getStartingEvent();
                 if ($weEventUid != "") {
                     $event = new \Event();
                     $arrayEventData = array();
                     $arrayEventData["EVN_UID"] = $weEventUid;
                     $arrayEventData["EVN_RELATED_TO"] = "MULTIPLE";
                     $arrayEventData["EVN_ACTION"] = $dynaFormUid;
                     $arrayEventData["EVN_CONDITIONS"] = $usrUsername;
                     $result = $event->update($arrayEventData);
                 }
                 //WE_DATA
                 $webEntryData = $weTitle . ".php";
                 break;
             case "HTML":
                 global $G_FORM;
                 if (!class_exists("Smarty")) {
                     $loader = \Maveriks\Util\ClassLoader::getInstance();
                     $loader->addClass("Smarty", PATH_THIRDPARTY . "smarty" . PATH_SEP . "libs" . PATH_SEP . "Smarty.class.php");
                 }
                 $G_FORM = new \Form($processUid . "/" . $dynaFormUid, PATH_DYNAFORM, SYS_LANG, false);
                 $G_FORM->action = $http . $_SERVER["HTTP_HOST"] . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/services/cases_StartExternal.php";
                 $scriptCode = "";
                 $scriptCode = $G_FORM->render(PATH_TPL . "xmlform" . ".html", $scriptCode);
                 $scriptCode = str_replace("/controls/", $http . $_SERVER["HTTP_HOST"] . "/controls/", $scriptCode);
                 $scriptCode = str_replace("/js/maborak/core/images/", $http . $_SERVER["HTTP_HOST"] . "/js/maborak/core/images/", $scriptCode);
                 //Render the template
                 $pluginTpl = PATH_TPL . "processes" . PATH_SEP . "webentry.tpl";
                 $template = new \TemplatePower($pluginTpl);
                 $template->prepare();
                 $step = new \Step();
                 $sUidGrids = $step->lookingforUidGrids($processUid, $dynaFormUid);
                 $template->assign("URL_MABORAK_JS", \G::browserCacheFilesUrl("/js/maborak/core/maborak.js"));
                 $template->assign("URL_TRANSLATION_ENV_JS", \G::browserCacheFilesUrl("/jscore/labels/" . SYS_LANG . ".js"));
                 $template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]);
                 $template->assign("sysSys", SYS_SYS);
                 $template->assign("sysLang", SYS_LANG);
                 $template->assign("sysSkin", SYS_SKIN);
                 $template->assign("processUid", $processUid);
                 $template->assign("dynaformUid", $dynaFormUid);
                 $template->assign("taskUid", $taskUid);
                 $template->assign("dynFileName", $processUid . "/" . $dynaFormUid);
                 $template->assign("formId", $G_FORM->id);
                 $template->assign("scriptCode", $scriptCode);
                 if (sizeof($sUidGrids) > 0) {
                     foreach ($sUidGrids as $k => $v) {
                         $template->newBlock("grid_uids");
                         $template->assign("siteUrl", $http . $_SERVER["HTTP_HOST"]);
                         $template->assign("gridFileName", $processUid . "/" . $v);
                     }
                 }
                 //WE_DATA
                 $html = str_replace("</body>", "</form></body>", str_replace("</form>", "", $template->getOutputContent()));
                 $webEntryData = $html;
                 break;
         }
         //Update
         //Update where
         $criteriaWhere = new \Criteria("workflow");
         $criteriaWhere->add(\WebEntryPeer::WE_UID, $webEntryUid);
         //Update set
         $criteriaSet = new \Criteria("workflow");
         $criteriaSet->add(\WebEntryPeer::WE_DATA, $webEntryData);
         \BasePeer::doUpdate($criteriaWhere, $criteriaSet, \Propel::getConnection("workflow"));
     } catch (\Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 25
0
 /**
  * Get checksum from multiple files
  *
  * @author erik amaru ortiz <*****@*****.**>
  */
 public function getCheckSum($files)
 {
     Bootstrap::LoadClass('system');
     $key = System::getVersion();
     if (!is_array($files)) {
         $tmp = $files;
         $files = array();
         $files[0] = $tmp;
     }
     $checkSum = '';
     foreach ($files as $file) {
         if (is_file($file)) {
             $checkSum .= md5_file($file);
         }
     }
     return md5($checkSum . $key);
 }
Ejemplo n.º 26
0
function run_upgrade($command, $args)
{
    CLI::logging("UPGRADE", PROCESSMAKER_PATH . "upgrade.log");
    CLI::logging("Checking files integrity...\n");
    //setting flag to true to check into sysGeneric.php
    $flag = G::isPMUnderUpdating(1);
    //start to upgrade
    $checksum = System::verifyChecksum();
    if ($checksum === false) {
        CLI::logging(CLI::error("checksum.txt not found, integrity check is not possible") . "\n");
        if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) {
            CLI::logging("Upgrade failed\n");
            $flag = G::isPMUnderUpdating(0);
            die;
        }
    } else {
        if (!empty($checksum['missing'])) {
            CLI::logging(CLI::error("The following files were not found in the installation:") . "\n");
            foreach ($checksum['missing'] as $missing) {
                CLI::logging(" {$missing}\n");
            }
        }
        if (!empty($checksum['diff'])) {
            CLI::logging(CLI::error("The following files have modifications:") . "\n");
            foreach ($checksum['diff'] as $diff) {
                CLI::logging(" {$diff}\n");
            }
        }
        if (!(empty($checksum['missing']) || empty($checksum['diff']))) {
            if (!CLI::question("Integrity check failed, do you want to continue the upgrade?")) {
                CLI::logging("Upgrade failed\n");
                $flag = G::isPMUnderUpdating(0);
                die;
            }
        }
    }
    CLI::logging("Clearing cache...\n");
    if (defined('PATH_C')) {
        G::rm_dir(PATH_C);
        G::mk_dir(PATH_C, 0777);
    }
    $workspaces = get_workspaces_from_args($command);
    $count = count($workspaces);
    $first = true;
    $errors = false;
    $countWorkspace = 0;
    $buildCacheView = array_key_exists("buildACV", $args);
    foreach ($workspaces as $index => $workspace) {
        if (!defined("SYS_SYS")) {
            define("SYS_SYS", $workspace->name);
        }
        if (!defined("PATH_DATA_SITE")) {
            define("PATH_DATA_SITE", PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP);
        }
        try {
            $countWorkspace++;
            CLI::logging("Upgrading workspaces ({$countWorkspace}/{$count}): " . CLI::info($workspace->name) . "\n");
            $workspace->upgrade($first, $buildCacheView, $workspace->name);
            $workspace->close();
            $first = false;
        } catch (Exception $e) {
            CLI::logging("Errors upgrading workspace " . CLI::info($workspace->name) . ": " . CLI::error($e->getMessage()) . "\n");
            $errors = true;
        }
    }
    // SAVE Upgrades/Patches
    $arrayPatch = glob(PATH_TRUNK . 'patch-*');
    if ($arrayPatch) {
        foreach ($arrayPatch as $value) {
            if (file_exists($value)) {
                // copy content the patch
                $names = pathinfo($value);
                $nameFile = $names['basename'];
                $contentFile = file_get_contents($value);
                $contentFile = preg_replace("[\n|\r|\n\r]", '', $contentFile);
                CLI::logging($contentFile . ' installed (' . $nameFile . ')', PATH_DATA . 'log/upgrades.log');
                // move file of patch
                $newFile = PATH_DATA . $nameFile;
                G::rm_dir($newFile);
                copy($value, $newFile);
                G::rm_dir($value);
            }
        }
    } else {
        CLI::logging('ProcessMaker ' . System::getVersion() . ' installed', PATH_DATA . 'log/upgrades.log');
    }
    //Safe upgrade for JavaScript files
    CLI::logging("\nSafe upgrade for files cached by the browser\n\n");
    G::browserCacheFilesSetUid();
    //Status
    if ($errors) {
        CLI::logging("Upgrade finished but there were errors upgrading workspaces.\n");
        CLI::logging(CLI::error("Please check the log above to correct any issues.") . "\n");
    } else {
        CLI::logging("Upgrade successful\n");
    }
    //setting flag to false
    $flag = G::isPMUnderUpdating(0);
}
Ejemplo n.º 27
0
    /**

     * get system information

     *

     * @param string sessionId : The session ID (which was obtained at login)

     * @return $eturns information about the WAMP/LAMP stack, the workspace database, the IP number and version

     * of ProcessMaker, and the IP number and version of web browser of the user

     */

    public function systemInformation ()

    {

        try {

            define( 'SKIP_RENDER_SYSTEM_INFORMATION', true );



            require_once (PATH_METHODS . 'login' . PATH_SEP . 'dbInfo.php');



            $result->status_code = 0;

            $result->message = G::loadTranslation( 'ID_SUCESSFUL' );

            $result->timestamp = date( 'Y-m-d H:i:s' );

            G::LoadClass( "system" );

            $result->version = System::getVersion();

            $result->operatingSystem = $redhat;

            $result->webServer = getenv( 'SERVER_SOFTWARE' );

            $result->serverName = getenv( 'SERVER_NAME' );

            $result->serverIp = $Fields['IP']; //lookup ($ip);

            $result->phpVersion = phpversion();

            $result->databaseVersion = $Fields['DATABASE'];

            $result->databaseServerIp = $Fields['DATABASE_SERVER'];

            $result->databaseName = $Fields['DATABASE_NAME'];

            $result->availableDatabases = $Fields['AVAILABLE_DB'];

            $result->userBrowser = $Fields['HTTP_USER_AGENT'];

            $result->userIp = $Fields['IP'];



            return $result;

        } catch (Exception $e) {

            $result = new wsResponse( 100, $e->getMessage() );



            return $result;

        }

    }
function buildData()
{
    require_once "classes/model/Users.php";
    G::LoadClass("serverConfiguration");
    G::LoadClass("system");
    $oServerConf =& serverConf::getSingleton();
    $os = '';
    if (file_exists('/etc/redhat-release')) {
        $fnewsize = filesize('/etc/redhat-release');
        $fp = fopen('/etc/redhat-release', 'r');
        $os = trim(fread($fp, $fnewsize));
        fclose($fp);
    }
    $os .= " (" . PHP_OS . ")";
    $params = array();
    $params['ip'] = getenv('SERVER_ADDR');
    $oServerConf->setHeartbeatProperty('HB_BEAT_INDEX', intval($oServerConf->getHeartbeatProperty('HB_BEAT_INDEX', 'HEART_BEAT_CONF')) + 1, 'HEART_BEAT_CONF');
    $params['index'] = $oServerConf->getHeartbeatProperty('HB_BEAT_INDEX', 'HEART_BEAT_CONF');
    //$this->index;
    $params['beatType'] = is_null($oServerConf->getHeartbeatProperty('HB_BEAT_TYPE', 'HEART_BEAT_CONF')) ? "starting" : $oServerConf->getHeartbeatProperty('HB_BEAT_TYPE', 'HEART_BEAT_CONF');
    //1;//$this->beatType;
    $params['date'] = date('Y-m-d H:i:s');
    $params['host'] = getenv('SERVER_NAME');
    $params['os'] = $os;
    $params['webserver'] = getenv('SERVER_SOFTWARE');
    $params['php'] = phpversion();
    $params['pmVersion'] = System::getVersion();
    if (class_exists('pmLicenseManager')) {
        $params['pmProduct'] = 'PMEE';
    } else {
        $params['pmProduct'] = 'PMCE';
    }
    $params['logins'] = $oServerConf->logins;
    $params['workspaces'] = serialize($oServerConf->getWSList());
    $params['plugins'] = serialize($oServerConf->getPluginsList());
    $params['dbVersion'] = $oServerConf->getDBVersion();
    //$params ['errors'] = serialize( $oServerConf->errors );
    if ($licInfo = $oServerConf->getProperty('LICENSE_INFO')) {
        $params['license'] = serialize($licInfo);
    }
    ///////
    $criteria = new Criteria("workflow");
    $criteria->addSelectColumn("COUNT(USERS.USR_UID) AS USERS_NUMBER");
    $criteria->add(UsersPeer::USR_UID, null, Criteria::ISNOTNULL);
    $rs = UsersPeer::doSelectRS($criteria);
    $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
    $rs->next();
    $row = $rs->getRow();
    $params["users"] = $row["USERS_NUMBER"];
    ///////
    $ee = null;
    if (file_exists(PATH_PLUGINS . "enterprise" . PATH_SEP . "VERSION")) {
        $ee = trim(file_get_contents(PATH_PLUGINS . "enterprise" . PATH_SEP . "VERSION"));
    } else {
        $pluginRegistry =& PMPluginRegistry::getSingleton();
        $details = $pluginRegistry->getPluginDetails("enterprise.php");
        $ee = !($details == null) ? $details->iVersion : null;
    }
    $params["ee"] = $ee;
    ///////
    $addonNumber = 0;
    $addonEnabledNumber = 0;
    $pluginRegistry =& PMPluginRegistry::getSingleton();
    $arrayAddon = array();
    if (file_exists(PATH_DATA_SITE . "ee")) {
        $arrayAddon = unserialize(trim(file_get_contents(PATH_DATA_SITE . "ee")));
        $arrayAddon["enterprise"] = array("sFilename" => "enterprise-1.tar");
    }
    foreach ($arrayAddon as $addon) {
        $sFileName = substr($addon["sFilename"], 0, strpos($addon["sFilename"], "-"));
        if (file_exists(PATH_PLUGINS . $sFileName . ".php")) {
            $addonDetails = $pluginRegistry->getPluginDetails($sFileName . ".php");
            $enabled = 0;
            if ($addonDetails) {
                $enabled = $addonDetails->enabled ? 1 : 0;
            }
            if ($enabled == 1) {
                $addonEnabledNumber = $addonEnabledNumber + 1;
            }
            $addonNumber = $addonNumber + 1;
        }
    }
    $params["addonNumber"] = $addonNumber;
    $params["addonEnabledNumber"] = $addonEnabledNumber;
    ///////
    $licenseID = null;
    $licenseType = null;
    $licenseDomainWorkspace = null;
    $licenseNumber = 0;
    if (file_exists(PATH_PLUGINS . "enterprise" . PATH_SEP . "class.pmLicenseManager.php")) {
        $licenseManager =& pmLicenseManager::getSingleton();
        preg_match("/^license_(.*).dat\$/", $licenseManager->file, $matches);
        $licenseID = $matches[1];
        $licenseType = $licenseManager->type;
        $licenseDomainWorkspace = $licenseManager->info["DOMAIN_WORKSPACE"];
        ///////
        $criteria = new Criteria("workflow");
        $criteria->addSelectColumn("COUNT(LICENSE_MANAGER.LICENSE_UID) AS LICENSE_NUMBER");
        $criteria->add(LicenseManagerPeer::LICENSE_UID, null, Criteria::ISNOTNULL);
        $rs = LicenseManagerPeer::doSelectRS($criteria);
        $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $rs->next();
        $row = $rs->getRow();
        ///////
        $licenseNumber = $row["LICENSE_NUMBER"] > 0 ? $row["LICENSE_NUMBER"] : count(glob(PATH_DATA_SITE . "licenses" . PATH_SEP . "*.dat"));
    }
    $params["licenseID"] = $licenseID;
    $params["licenseType"] = $licenseType;
    $params["licenseDomainWorkspace"] = $licenseDomainWorkspace;
    $params["licenseNumber"] = $licenseNumber;
    ///////
    return $params;
}
Ejemplo n.º 29
0
 /**
  * Get checksum from multiple files
  *
  * @author erik amaru ortiz <*****@*****.**>
  */
 public function getCheckSum($files)
 {
     G::LoadClass('system');
     $key = System::getVersion();
     if (!is_array($files)) {
         $tmp = $files;
         $files = array();
         $files[0] = $tmp;
     }
     $checkSum = '';
     foreach ($files as $file) {
         if (is_file($file)) {
             $checkSum .= G::encryptFileOld($file);
         }
     }
     return G::encryptOld($checkSum . $key);
 }
Ejemplo n.º 30
0
function sendTestMail()
{
    G::LoadClass("system");
    $sFrom = ($_POST['FROM_NAME'] != '' ? $_POST['FROM_NAME'] . ' ' : '') . '<' . $_POST['FROM_EMAIL'] . '>';
    $sSubject = G::LoadTranslation('ID_MESS_TEST_SUBJECT');
    $msg = G::LoadTranslation('ID_MESS_TEST_BODY');
    switch ($_POST['MESS_ENGINE']) {
        case 'MAIL':
            $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1');
            break;
        case 'PHPMAILER':
            $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_2');
            break;
        case 'OPENMAIL':
            $engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_3');
            break;
    }
    $sBody = "\n  <table style=\"background-color: white; font-family: Arial,Helvetica,sans-serif; color: black; font-size: 11px; text-align: left;\" cellpadding='10' cellspacing='0' width='100%'>\n  <tbody><tr><td><img id='logo' src='http://" . $_SERVER['SERVER_NAME'] . "/images/processmaker.logo.jpg' /></td></tr>\n  <tr><td style='font-size: 14px;'>{$msg} [" . date('H:i:s') . "] - {$engine}</td></tr>\n  <tr><td style='vertical-align:middel;'>\n  <br /><hr><b>This Business Process is powered by ProcessMaker ver. " . System::getVersion() . ".<b><br />\n  <a href='http://www.processmaker.com' style='color:#c40000;'>www.processmaker.com</a><br /></td>\n  </tr></tbody></table>";
    G::LoadClass('spool');
    $oSpool = new spoolRun();
    $passwd = $_POST['MESS_PASSWORD'];
    $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
    $auxPass = explode('hash:', $passwdDec);
    if (count($auxPass) > 1) {
        if (count($auxPass) == 2) {
            $passwd = $auxPass[1];
        } else {
            array_shift($auxPass);
            $passwd = implode('', $auxPass);
        }
    }
    $_POST['MESS_PASSWORD'] = $passwd;
    $oSpool->setConfig(array('MESS_ENGINE' => $_POST['MESS_ENGINE'], 'MESS_SERVER' => $_POST['MESS_SERVER'], 'MESS_PORT' => $_POST['MESS_PORT'], 'MESS_ACCOUNT' => $_POST['MESS_ACCOUNT'], 'MESS_PASSWORD' => $_POST['MESS_PASSWORD'], 'SMTPAuth' => $_POST['SMTPAuth'], 'SMTPSecure' => isset($_POST['SMTPSecure']) ? $_POST['SMTPSecure'] : 'none'));
    $oSpool->create(array('msg_uid' => '', 'app_uid' => '', 'del_index' => 0, 'app_msg_type' => 'TEST', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $_POST['TO'], 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending', 'app_msg_attach' => ''));
    $oSpool->sendMail();
    global $G_PUBLISH;
    $G_PUBLISH = new Publisher();
    if ($oSpool->status == 'sent') {
        $o->status = true;
        $o->msg = G::LoadTranslation('ID_MAIL_TEST_SUCCESS');
    } else {
        $o->status = false;
        $o->msg = $oSpool->error;
    }
    return $o;
}