예제 #1
0
 /**
  * create_site
  *
  * @param array $config
  * @param boolean $confirmed
  * @return void
  */
 public function create_site($config = array(), $confirmed = false)
 {
     $this->options = G::array_concat(array('isset' => false, 'password' => G::generate_password(12), 'path_data' => @PATH_DATA, 'path_compiled' => @PATH_C, 'name' => $config['name'], 'database' => array(), 'admin' => array('username' => 'admin', 'password' => 'admin'), 'advanced' => array('ao_db_wf' => 'wf_' . $config['name'], 'ao_db_rb' => 'rb_' . $config['name'], 'ao_db_rp' => 'rp_' . $config['name'], 'ao_db_drop' => false)), $config);
     $a = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
     $this->options['database'] = G::array_concat(array('username' => @$a[1], 'password' => @$a[2], 'hostname' => @$a[0]), $this->options['database']);
     return $confirmed === true ? $this->make_site() : $this->create_site_test();
 }
function pagedTable_BeforeQuery(&$ntable)
{
    $file = G::decrypt($ntable->xmlForm->values['URL'], URL_KEY);
    /* Start Block: Defines the virtual XMLDB*/
    G::LoadClass('xmlDb');
    define('DB_XMLDB_HOST', PATH_DYNAFORM . $file . '.xml');
    define('DB_XMLDB_USER', '');
    define('DB_XMLDB_PASS', '');
    define('DB_XMLDB_NAME', '');
    define('DB_XMLDB_TYPE', 'myxml');
    /* End Block*/
}
예제 #3
0
 /**
  * Send a mail using phpmailer
  * this method use the global smtp server connection stored on Configuration table
  * this information is retrieved by the PMFunction getEmailConfiguration()
  *
  * @author Erik Amaru Ortiz <*****@*****.**>
  * @param string $from address that is sending the email
  * @param string $fromName name of sender
  * @param mixed $address the possibles values are:
  *        string
  *        array('email1', 'some name <email2>')
  *        array('to'=>array('email1', 'some name <email2>'), 'cc'=>array(...), 'bcc'=>array(...))
  * @param string $subject contains the email subject
  * @param string $body contains the email body (text plain or html)
  * @return mixed boolean or string : if the email was sent successfully returns true, otherwise returns a string within error message
  */
 public function sendMail($from, $fromName, $address, $subject, $body)
 {
     // require_once "classes/class.pmFunctions.php";
     G::LoadClass("pmFunctions");
     G::LoadThirdParty('phpmailer', 'class.phpmailer');
     $setup = getEmailConfiguration();
     if ($setup['MESS_RAUTH'] == false || is_string($setup['MESS_RAUTH']) && $setup['MESS_RAUTH'] == 'false') {
         $setup['MESS_RAUTH'] = 0;
     } else {
         $setup['MESS_RAUTH'] = 1;
     }
     if (count($setup) == 0 || !isset($setup['MESS_ENGINE']) || !isset($setup['MESS_SERVER']) || !isset($setup['MESS_ENABLED']) || !isset($setup['MESS_RAUTH']) || $setup['MESS_SERVER'] == '') {
         return G::LoadTranslation('ID_EMAIL_ENGINE_IS_NOT_CONFIGURED');
     }
     if (!$setup['MESS_ENABLED']) {
         return G::LoadTranslation('ID_EMAIL_ENGINE_IS_NOT_ENABLED');
     }
     $passwd = $setup['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);
         }
     }
     $setup['MESS_PASSWORD'] = $passwd;
     $mail = new PHPMailer(true);
     $mail->From = $from != '' && $from ? $from : $setup['MESS_ACCOUNT'];
     $mail->FromName = $fromName;
     $mail->Subject = $subject;
     $mail->Body = $body;
     $mail->IsHTML(true);
     $mail->IsSMTP();
     $mail->Host = $setup['MESS_SERVER'];
     $mail->Port = $setup['MESS_PORT'];
     $mail->SMTPAuth = isset($setup['MESS_RAUTH']) && $setup['MESS_RAUTH'] ? true : false;
     $mail->Username = $setup['MESS_ACCOUNT'];
     $mail->Password = $setup['MESS_PASSWORD'];
     $mail->SMTPSecure = $setup['SMTPSecure'];
     $emailAddressList = G::envelopEmailAddresses($address);
     foreach ($emailAddressList['to'] as $emails) {
         $mail->AddAddress($emails[0], $emails[1]);
     }
     foreach ($emailAddressList['cc'] as $emails) {
         $mail->AddCC($emails[0], $emails[1]);
     }
     foreach ($emailAddressList['bcc'] as $emails) {
         $mail->AddBCC($emails[0], $emails[1]);
     }
     return $mail->Send() ? true : $mail->ErrorInfo;
 }
예제 #4
0
 /**
  * Checks if a dynaform was changed
  *
  * @param file $A
  * @param string $DYN_UID
  * @return array
  */
 public function is_modified($A, $DYN_UID)
 {
     $file = G::decrypt($A, URL_KEY);
     try {
         /* Compare Properties */
         $dynaform = new dynaform();
         $dynaform->load($DYN_UID);
         $form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
         $sp = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, 'ENABLETEMPLATE' => $form->enableTemplate, 'MODE' => $form->mode);
         $P = self::get_properties($A, $DYN_UID);
         if (!isset($P['DYN_TITLE'])) {
             $P['DYN_TITLE'] = $sp['DYN_TITLE'];
         }
         if (!isset($P['DYN_TYPE'])) {
             $P['DYN_TYPE'] = $sp['DYN_TYPE'];
         }
         if (!isset($P['DYN_DESCRIPTION'])) {
             $P['DYN_DESCRIPTION'] = $sp['DYN_DESCRIPTION'];
         }
         if (!isset($P['WIDTH'])) {
             $P['WIDTH'] = $sp['WIDTH'];
         }
         if (!isset($P['ENABLETEMPLATE'])) {
             $P['ENABLETEMPLATE'] = $sp['ENABLETEMPLATE'];
         }
         if (!isset($P['MODE'])) {
             $P['MODE'] = $sp['MODE'];
         }
         $modPro = $sp['DYN_TITLE'] != $P['DYN_TITLE'] || $sp['DYN_TYPE'] != $P['DYN_TYPE'] || $sp['DYN_DESCRIPTION'] != $P['DYN_DESCRIPTION'];
         /* ||
            ($sp['WIDTH']!=$P['WIDTH']) ||
            ($sp['ENABLETEMPLATE']!=$P['ENABLETEMPLATE']) ||
            ($sp['MODE']!=$P['MODE']) */
         /* Compare copies */
         $fileOrigen = dynaformEditor::_getFilename($file);
         $copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
         $origen = implode('', file(PATH_DYNAFORM . $fileOrigen . '.xml'));
         $copyHTML = file_exists(PATH_DYNAFORM . $file . '.html') ? implode('', file(PATH_DYNAFORM . $file . '.html')) : false;
         $origenHTML = file_exists(PATH_DYNAFORM . $fileOrigen . '.html') ? implode('', file(PATH_DYNAFORM . $fileOrigen . '.html')) : false;
         $modFile = $copy !== $origen || $origenHTML && $copyHTML !== $origenHTML;
         //Return
         //return array("*message"=>sprintf("%s, (%s= %s %s):", $modPro?"1":"0" , $modFile?"1":"0", ($copy!==$origen)?"1":"0" , ($origenHTML && ($copyHTML!==$origenHTML))?"1":"0" ));
         //die("c'est fini");
         return $modPro || $modFile;
     } catch (Exception $e) {
         return (array) $e;
     }
 }
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
    return $RBAC_Response;
    //G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = '******' );
}
G::LoadInclude('ajax');
G::LoadClass('dynaform');
G::LoadClass('xmlDb');
$dbc = new DBConnection();
$ses = new DBSession($dbc);
//$dynaform = new dynaform( $dbc );
if ($_POST['form']['DYN_UID'] === '') {
    unset($_POST['form']['DYN_UID']);
}
$Fields = $_POST['form'];
if (!isset($Fields['DYN_UID'])) {
    return;
}
$file = G::decrypt($Fields['A'], URL_KEY);
$Fields['DYN_FILENAME'] = strcasecmp(substr($file, -5), '_tmp0') == 0 ? substr($file, 0, strlen($file) - 5) : $file;
$_SESSION['CURRENT_DYNAFORM'] = $Fields;
//$dynaform->Save( $Fields );
$dbc2 = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses2 = new DBSession($dbc2);
if (!isset($Fields['ENABLETEMPLATE'])) {
    $Fields['ENABLETEMPLATE'] = "0";
}
$ses2->execute(G::replaceDataField("UPDATE . SET WIDTH = @@WIDTH WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
$ses2->execute(G::replaceDataField("UPDATE . SET ENABLETEMPLATE = @@ENABLETEMPLATE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
$ses2->execute(G::replaceDataField("UPDATE . SET MODE = @@MODE WHERE XMLNODE_NAME = 'dynaForm' ", $Fields));
        $caseFields = $cases->loadCase(G::decrypt($_REQUEST['APP_UID'], URL_KEY),G::decrypt($_REQUEST['DEL_INDEX'], URL_KEY));
    
        //
        $criteria = new Criteria();
        $criteria->addSelectColumn(DynaformPeer::DYN_CONTENT);
        $criteria->addSelectColumn(DynaformPeer::PRO_UID);
        $criteria->add(DynaformPeer::DYN_UID, G::decrypt($_REQUEST['DYN_UID'], URL_KEY));
        $result = DynaformPeer::doSelectRS($criteria);
        $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        $result->next();
        $configuration = $result->getRow();
        
        $action = 'ActionsByEmailDataFormPost.php?APP_UID=' . $_REQUEST['APP_UID'] . '&DEL_INDEX=' . $_REQUEST['DEL_INDEX'] . '&ABER=' . $_REQUEST['ABER'];
        $record['DYN_CONTENT'] = $configuration['DYN_CONTENT'];
        $record['PRO_UID']     = $configuration['PRO_UID'];
        $record['CURRENT_DYNAFORM'] = G::decrypt($_REQUEST['DYN_UID'], URL_KEY);
        $record['APP_UID'] = $_REQUEST['APP_UID'];
        $record['DEL_INDEX'] = $_REQUEST['DEL_INDEX'];
        $record['ABER'] = $_REQUEST['ABER'];
        if (is_null($caseFields['DEL_FINISH_DATE'])) {
            $a = new pmDynaform($record);
            $a->printABE($action,$record);
        } else {
            $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', array('MESSAGE' => '<strong>The form has already been filled and sent.</strong>'));
        }
    } catch (Exception $error) {
        $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', array('MESSAGE' => $error->getMessage()));
    }
    
    G::RenderPage('publish', 'blank');
}
 if (isset($_GET['OUT_DOC_UID'])) {
     $aFields = $ooutputDocument->load($_GET['OUT_DOC_UID']);
 } else {
     $aFields = array();
     $aFields['PRO_UID'] = $_GET['PRO_UID'];
 }
 $type = isset($aFields['OUT_DOC_TYPE']) ? $aFields['OUT_DOC_TYPE'] : 'HTML';
 $aFields['OUT_DOC_TAGS'] = isset($aFields['OUT_DOC_TAGS']) ? $aFields['OUT_DOC_TAGS'] : 'OUTPUT';
 $aFields['OUT_DOC_VERSIONING'] = strval($aFields['OUT_DOC_VERSIONING']);
 $aFields['OUT_DOC_LANDSCAPE'] = strval($aFields['OUT_DOC_LANDSCAPE']);
 if (isset($aFields['OUT_DOC_PDF_SECURITY_ENABLED'])) {
     $aFields['OUT_DOC_PDF_SECURITY_ENABLED'] = strval($aFields['OUT_DOC_PDF_SECURITY_ENABLED']);
 }
 if (isset($aFields['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD']) && $aFields['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD'] != "") {
     $aFields['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD'] = G::decrypt($aFields['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD'], $_GET['OUT_DOC_UID']);
     $aFields['OUT_DOC_PDF_SECURITY_OWNER_PASSWORD'] = G::decrypt($aFields['OUT_DOC_PDF_SECURITY_OWNER_PASSWORD'], $_GET['OUT_DOC_UID']);
 }
 G::LoadClass('xmlfield_InputPM');
 $G_PUBLISH = new Publisher();
 switch ($type) {
     case 'HTML':
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'outputdocs/outputdocs_Properties', '', $aFields, '../outputdocs/outputdocs_Save');
         break;
     case 'JRXML':
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'outputdocs/outputdocs_Properties', '', $aFields, '../outputdocs/outputdocs_Save');
         /*
         //  	     $G_PUBLISH->AddContent('xmlform', 'xmlform', 'outputdocs/outputdocsDynaformList', '', $aFields , '../outputdocs/outputdocs_Save');
         require_once 'classes/model/Process.php';
         G::LoadClass( 'processMap');
         $sProcessUID = $aFields['PRO_UID'];
         $oProcess = new Process();
예제 #8
0
 public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "")
 {
     try {
         require_once 'classes/model/Configuration.php';
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration['CFG_VALUE']);
                 $passwd = $aConfiguration['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);
                     }
                 }
                 $aConfiguration['MESS_PASSWORD'] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         $oUser = new Users();
         $aUser = $oUser->load($usrUid);
         $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
         G::LoadClass('case');
         $oCase = new Cases();
         $aFields = $oCase->loadCase($appUid);
         $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE ";
         $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}";
         /*
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         */
         if (isset($aConfiguration['MESS_FROM_NAME']) && $aConfiguration['MESS_FROM_NAME'] != '') {
             $sFrom = $aConfiguration['MESS_FROM_NAME'];
         }
         $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match);
         if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
             if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
                 $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
             } else {
                 if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                     $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
                 } else {
                     if ($aConfiguration['MESS_SERVER'] != '') {
                         if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                             $sFrom .= ' <info@' . $sAux . '>';
                         } else {
                             $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                         }
                     } else {
                         $sFrom .= ' <*****@*****.**>';
                     }
                 }
             }
         }
         $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields);
         $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields));
         G::LoadClass('spool');
         $oUser = new Users();
         $recipientsArray = explode(",", $noteRecipients);
         foreach ($recipientsArray as $recipientUid) {
             $aUser = $oUser->load($recipientUid);
             $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
             $oSpool = new spoolRun();
             if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
                 $aConfiguration['MESS_RAUTH'] = 0;
             } else {
                 $aConfiguration['MESS_RAUTH'] = 1;
             }
             $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''));
             $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 0, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending'));
             if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') {
                 $oSpool->sendMail();
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
 /**
  * Function getPassWithoutEncrypt
  *
  * @author krlos Pacha C. <*****@*****.**>
  * @access public
  * @param string passw
  * @return string
  */
 public function getPassWithoutEncrypt($aInfoCon)
 {
     $passw = '';
     if ($aInfoCon['DBS_PASSWORD'] != '') {
         $aPassw = explode('_', $aInfoCon['DBS_PASSWORD']);
         $passw = $aPassw[0];
         $flagTns = $aInfoCon["DBS_TYPE"] == "oracle" && $aInfoCon["DBS_CONNECTION_TYPE"] == "TNS" ? 1 : 0;
         if (sizeof($aPassw) > 1 && $flagTns == 0) {
             $passw = $passw == "none" ? "" : G::decrypt($passw, $aInfoCon["DBS_DATABASE_NAME"]);
         } else {
             $passw = $passw == "none" ? "" : G::decrypt($passw, $aInfoCon["DBS_TNS"]);
         }
     }
     return $passw;
 }
 
     if ($_REQUEST['DEL_INDEX'] == '') {
         throw new Exception('The parameter DEL_INDEX is empty.');
     }
 
     if ($_REQUEST['ABER'] == '') {
         throw new Exception('The parameter ABER is empty.');
     }
 
     if (!isset($_REQUEST['form'])) {
         $_REQUEST['form'] = array();
     }
 
     $_REQUEST['APP_UID']   = G::decrypt($_REQUEST['APP_UID'],   URL_KEY);
     $_REQUEST['DEL_INDEX'] = G::decrypt($_REQUEST['DEL_INDEX'], URL_KEY);
     $_REQUEST['ABER']      = G::decrypt($_REQUEST['ABER'],      URL_KEY);
     G::LoadClass('case');
 
     $case = new Cases();
     $casesFields = $case->loadCase($_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX']);
 
     $casesFields['APP_DATA'] = array_merge($casesFields['APP_DATA'], $_REQUEST['form']);
 
     //Get user info
     $current_user_uid = null;
     $currentUsrName   = null;
 
     $criteria = new Criteria("workflow");
 
     $criteria->addSelectColumn(AppDelegationPeer::USR_UID);
     $criteria->add(AppDelegationPeer::APP_UID, $_REQUEST["APP_UID"]);
예제 #11
0
     $_REQUEST['APP_UID'] = '';
 }
 if (!isset($_REQUEST['DEL_INDEX'])) {
     $_REQUEST['DEL_INDEX'] = '';
 }
 if ($_REQUEST['APP_UID'] == '') {
     throw new Exception('The parameter APP_UID is empty.');
 }
 if ($_REQUEST['DEL_INDEX'] == '') {
     throw new Exception('The parameter DEL_INDEX is empty.');
 }
 $_REQUEST['APP_UID'] = G::decrypt(urldecode(utf8_encode($_REQUEST['APP_UID'])), URL_KEY);
 $_REQUEST['DEL_INDEX'] = G::decrypt(urldecode(utf8_encode($_REQUEST['DEL_INDEX'])), URL_KEY);
 $_REQUEST['FIELD'] = G::decrypt(urldecode(utf8_encode($_REQUEST['FIELD'])), URL_KEY);
 $_REQUEST['VALUE'] = G::decrypt(urldecode(utf8_encode($_REQUEST['VALUE'])), URL_KEY);
 $_REQUEST['ABER'] = G::decrypt(urldecode(utf8_encode($_REQUEST['ABER'])), URL_KEY);
 G::LoadClass('case');
 $cases = new Cases();
 $caseFieldsABE = $cases->loadCase($_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX']);
 if (is_null($caseFieldsABE['DEL_FINISH_DATE'])) {
     $dataField = array();
     $dataField[$_REQUEST['FIELD']] = $_REQUEST['VALUE'];
     $caseFieldsABE['APP_DATA'] = array_merge($caseFieldsABE['APP_DATA'], $dataField);
     $dataResponses = array();
     $dataResponses['ABE_REQ_UID'] = $_REQUEST['ABER'];
     $dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
     $dataResponses['ABE_RES_DATA'] = serialize($_REQUEST['VALUE']);
     $dataResponses['ABE_RES_STATUS'] = 'PENDING';
     $dataResponses['ABE_RES_MESSAGE'] = '';
     try {
         require_once 'classes/model/AbeResponses.php';
예제 #12
0
 /**
  * loadFields for email configuration
  * @autor Alvaro  <*****@*****.**>
  */
 public function loadFields()
 {
     G::loadClass('configuration');
     $oConfiguration = new Configurations();
     $oConfiguration->loadConfig($x, 'Emails', '', '', '', '');
     $fields = $oConfiguration->aConfig;
     if (count($fields) > 0) {
         $this->success = count($fields) > 0;
         $passwd = $fields['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);
             }
         }
         $fields['MESS_PASSWORD'] = $passwd;
     }
     $this->data = $fields;
 }
 public function getActiveFeatures()
 {
     if (file_exists(PATH_PLUGINS . 'enterprise/data/default')) {
         return array();
     }
     return unserialize(G::decrypt($this->serial, file_get_contents(PATH_PLUGINS . 'enterprise/data/default')));
 }
예제 #14
0
    ?>
	</div>
	<script>
        parent.document.getElementById('light').style.display='none';
        parent.document.getElementById('fade').style.display='none';
	</script>
<?php 
    die;
}
$elements = $oXxml->result['dynaForm']['__CONTENT__'];
$dynaformAttributes = $oXxml->result['dynaForm']['__ATTRIBUTES__'];
$dynaformType = $dynaformAttributes['type'];
foreach ($elements as $node_name => $node) {
    if ($node_name == "___pm_boot_strap___") {
        $boot_strap = $elements[$node_name];
        $hidden_fields = G::decrypt($boot_strap['__ATTRIBUTES__']['meta'], 'dynafieldsHandler');
        //echo $hidden_fields;
        $hidden_fields_list = explode(',', $hidden_fields);
        unset($elements[$node_name]);
        ?>
      <script>
        parent.jsMeta = "<?php 
        echo $boot_strap['__ATTRIBUTES__']['meta'];
        ?>
";
      </script>
      <?php 
    }
}
?>
	<body>
예제 #15
0
    }
} else {
    $_POST['form']['PME_SAVELABEL'] = 0;
}
if (isset($_POST['form']['PME_SAVELABEL']) && isset($_POST['form']['PME_CODE']) && $_POST['form']['PME_TYPE'] === 'javascript') {
    $sType = $_POST['form']['PME_TYPE'];
    $A = $_POST['form']['PME_A'];
    $fieldName = $_POST['form']['PME_XMLNODE_NAME'];
    $pmeCode = $_POST['form']['PME_CODE'];
    $_POST['form']['PME_CODE'] = '';
    //    $pmeCode = str_replace("'", "''", $pmeCode);
    //    $pmeCode = str_replace('"', '""', $pmeCode);
    //    $pmeCode = preg_replace("/\)\s*\n/", ") //\n", $pmeCode);
    //    $_POST['form']['PME_CODE'] = $pmeCode;
}
$file = G::decrypt($_POST['form']['PME_A'], URL_KEY);
define('DB_XMLDB_HOST', PATH_DYNAFORM . $file . '.xml');
define('DB_XMLDB_USER', '');
define('DB_XMLDB_PASS', '');
define('DB_XMLDB_NAME', '');
define('DB_XMLDB_TYPE', 'myxml');
if (isset($_POST['form']['PME_XMLNODE_VALUE'])) {
    $_POST['form']['PME_XMLNODE_VALUE'] = str_replace("'", "''", $_POST['form']['PME_XMLNODE_VALUE']);
}
if (file_exists(PATH_XMLFORM . 'dynaforms/fields/' . $type . '.xml')) {
    $form = new Form('dynaforms/fields/' . $type, PATH_XMLFORM);
    //TODO: Verify why validatePost removes PME_XMLGRID.
    $isGrid = isset($_POST['form']['PME_XMLGRID']);
    if ($isGrid) {
        $xmlGrid = $_POST['form']['PME_XMLGRID'];
    }
예제 #16
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.
 *
 */
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
    return $RBAC_Response;
}
//G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = '******' );
G::LoadClass('dynaFormField');
if (!(isset($_GET['A']) && $_GET['A'] !== '')) {
    return;
}
$file = G::decrypt($_GET['A'], URL_KEY);
$dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
$ses = new DBSession($dbc);
//TODO: Improve how to obtain the PRO_UID.
$aFile = explode('/', str_replace('\\', '/', $file));
$proUid = $aFile[0];
$dynUid = str_replace("_tmp0", "", $aFile[1]);
require_once 'classes/model/Dynaform.php';
$k = new Criteria('workflow');
$k->addSelectColumn(DynaformPeer::DYN_TYPE);
$k->add(DynaformPeer::DYN_UID, $dynUid);
$ods = DynaformPeer::doSelectRS($k);
$ods->next();
$row = $ods->getRow();
$dynType = $row[0];
$Fields['PME_DYN_TYPE'] = $dynType;
예제 #17
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)
 {
     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");
     }
     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 (!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));
         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");
             $workspace->createDBUser($dbName, $db->pass, "localhost", $dbName);
             $workspace->createDBUser($dbName, $db->pass, "%", $dbName);
         }
         $workspace->upgradeCacheView(false);
         mysql_close($link);
     }
     CLI::logging("Removing temporary files\n");
     G::rm_dir($tempDirectory);
     CLI::logging(CLI::info("Done restoring") . "\n");
 }
예제 #18
0
 public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "")
 {
     try {
         $applicationData = $this->loadCase($sApplicationUID);
         $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"];
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]);
                 $passwd = $aConfiguration["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);
                     }
                 }
                 $aConfiguration["MESS_PASSWORD"] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         //Send derivation notification - Start
         $oTask = new Task();
         $aTaskInfo = $oTask->load($sCurrentTask);
         if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') {
             return false;
         }
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match);
         if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
             if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
                 $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
             } else {
                 if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                     $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
                 } else {
                     if ($aConfiguration['MESS_SERVER'] != '') {
                         if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                             $sFrom .= ' <info@' . $sAux . '>';
                         } else {
                             $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                         }
                     } else {
                         $sFrom .= ' <*****@*****.**>';
                     }
                 }
             }
         }
         if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {
             $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields);
         } else {
             $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');
         }
         //erik: new behaviour for messages
         G::loadClass('configuration');
         $oConf = new Configurations();
         $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
         $conf = $oConf->aConfig;
         $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP;
         $swtplDefault = 0;
         $sBody = null;
         if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") {
             if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") {
                 $swtplDefault = 1;
             }
             $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"];
             if (!file_exists($fileTemplate)) {
                 throw new Exception("Template file \"{$fileTemplate}\" does not exist.");
             }
             $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields);
         } else {
             $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields));
         }
         G::LoadClass("tasks");
         G::LoadClass("groups");
         G::LoadClass("spool");
         $task = new Tasks();
         $group = new Groups();
         $oUser = new Users();
         foreach ($aTasks as $aTask) {
             $sTo = null;
             $sCc = null;
             switch ($aTask["TAS_ASSIGN_TYPE"]) {
                 case "SELF_SERVICE":
                     if ($swtplDefault == 1) {
                         G::verifyPath($pathEmail, true);
                         //Create if it does not exist
                         $fileTemplate = $pathEmail . "unassignedMessage.html";
                         if (!file_exists($fileTemplate)) {
                             @copy(PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $fileTemplate);
                         }
                         $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
                     }
                     if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {
                         $arrayTaskUser = array();
                         $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayGroup) {
                             $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]);
                             foreach ($arrayAux2 as $arrayUser) {
                                 $arrayTaskUser[] = $arrayUser["USR_UID"];
                             }
                         }
                         $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayUser) {
                             $arrayTaskUser[] = $arrayUser["USR_UID"];
                         }
                         $criteria = new Criteria("workflow");
                         $criteria->addSelectColumn(UsersPeer::USR_UID);
                         $criteria->addSelectColumn(UsersPeer::USR_USERNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_EMAIL);
                         $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN);
                         $rsCriteria = UsersPeer::doSelectRs($criteria);
                         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                         $to = null;
                         $cc = null;
                         $sw = 1;
                         while ($rsCriteria->next()) {
                             $row = $rsCriteria->getRow();
                             $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">";
                             if ($sw == 1) {
                                 $to = $toAux;
                                 $sw = 0;
                             } else {
                                 $cc = $cc . ($cc != null ? "," : null) . $toAux;
                             }
                         }
                         $sTo = $to;
                         $sCc = $cc;
                     }
                     break;
                 default:
                     if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
                         $aUser = $oUser->load($aTask["USR_UID"]);
                         $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">";
                     }
                     break;
             }
             if ($sTo != null) {
                 $oSpool = new spoolRun();
                 if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
                     $aConfiguration['MESS_RAUTH'] = 0;
                 } else {
                     $aConfiguration['MESS_RAUTH'] = 1;
                 }
                 $oSpool->setConfig(array("MESS_ENGINE" => $aConfiguration["MESS_ENGINE"], "MESS_SERVER" => $aConfiguration["MESS_SERVER"], "MESS_PORT" => $aConfiguration["MESS_PORT"], "MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"], "MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"], "SMTPAuth" => $aConfiguration["MESS_RAUTH"] == "1" ? true : false, "SMTPSecure" => isset($aConfiguration["SMTPSecure"]) ? $aConfiguration["SMTPSecure"] : ""));
                 $oSpool->create(array("msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending"));
                 if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") {
                     $oSpool->sendMail();
                 }
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
예제 #19
0
 public static function getSystemConfiguration($globalIniFile = '', $wsIniFile = '', $wsName = '')
 {
     $readGlobalIniFile = false;
     $readWsIniFile = false;
     if (empty($globalIniFile)) {
         $globalIniFile = PATH_CORE . 'config' . PATH_SEP . 'env.ini';
     }
     if (empty($wsIniFile)) {
         if (defined('PATH_DB')) {
             // if we're on a valid workspace env.
             if (empty($wsName)) {
                 $uriParts = explode('/', getenv("REQUEST_URI"));
                 if (isset($uriParts[1])) {
                     if (substr($uriParts[1], 0, 3) == 'sys') {
                         $wsName = substr($uriParts[1], 3);
                     }
                 }
             }
             $wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
         }
     }
     $readGlobalIniFile = file_exists($globalIniFile) ? true : false;
     $readWsIniFile = file_exists($wsIniFile) ? true : false;
     if (isset($_SESSION['PROCESSMAKER_ENV'])) {
         $md5 = array();
         if ($readGlobalIniFile) {
             $md5[] = md5_file($globalIniFile);
         }
         if ($readWsIniFile) {
             $md5[] = md5_file($wsIniFile);
         }
         $hash = implode('-', $md5);
         if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
             $_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
             return $_SESSION['PROCESSMAKER_ENV'];
         }
     }
     // default configuration
     $config = array('debug' => 0, 'debug_sql' => 0, 'debug_time' => 0, 'debug_calendar' => 0, 'wsdl_cache' => 1, 'memory_limit' => "256M", 'time_zone' => 'America/New_York', 'memcached' => 0, 'memcached_server' => '', 'default_skin' => 'neoclassic', 'default_lang' => 'en', 'proxy_host' => '', 'proxy_port' => '', 'proxy_user' => '', 'proxy_pass' => '', 'size_log_file' => 5000000, 'number_log_file' => 5, 'ie_cookie_lifetime' => 1, 'safari_cookie_lifetime' => 1);
     // read the global env.ini configuration file
     if ($readGlobalIniFile && ($globalConf = @parse_ini_file($globalIniFile)) !== false) {
         $config = array_merge($config, $globalConf);
     }
     // Workspace environment configuration
     if ($readWsIniFile && ($wsConf = @parse_ini_file($wsIniFile)) !== false) {
         $config = array_merge($config, $wsConf);
     }
     // validation debug config, only binary value is valid; debug = 1, to enable
     $config['debug'] = $config['debug'] == 1 ? 1 : 0;
     if ($config['proxy_pass'] != '') {
         $config['proxy_pass'] = G::decrypt($config['proxy_pass'], 'proxy_pass');
     }
     $md5 = array();
     if ($readGlobalIniFile) {
         $md5[] = md5_file($globalIniFile);
     }
     if ($readWsIniFile) {
         $md5[] = md5_file($wsIniFile);
     }
     $hash = implode('-', $md5);
     $_SESSION['PROCESSMAKER_ENV'] = $config;
     $_SESSION['PROCESSMAKER_ENV_HASH'] = $hash;
     return $config;
 }
예제 #20
0
 /**
  * Function getPassWithoutEncrypt
  * @author krlos Pacha C. <*****@*****.**>
  * @access public
  * @param string passw
  * @return string
  */
 public function getPassWithoutEncrypt($aInfoCon)
 {
     $passw = '';
     if ($aInfoCon['DBS_PASSWORD'] != '') {
         $aPassw = explode('_', $aInfoCon['DBS_PASSWORD']);
         $passw = $aPassw[0];
         if (sizeof($aPassw) > 1) {
             $passw = $passw == 'none' ? "" : G::decrypt($passw, $aInfoCon['DBS_DATABASE_NAME']);
         }
     }
     return $passw;
 }
예제 #21
0
}
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
    return $RBAC_Response;
}
/*NEXT LINE: Runs any configuration defined to be executed before dependent fields recalc*/
if (isset($_SESSION['CURRENT_PAGE_INITILIZATION'])) {
    eval($_SESSION['CURRENT_PAGE_INITILIZATION']);
}
//G::LoadSystem('json');
//require_once (PATH_THIRDPARTY . 'pear/json/class.json.php');
//$json = new Services_JSON();
$G_FORM = new form(G::getUIDName(urlDecode($_POST['form'])));
$G_FORM->id = urlDecode($_POST['form']);
$G_FORM->values = $_SESSION[$G_FORM->id];
G::LoadClass('xmlDb');
$file = G::decrypt($G_FORM->values['PME_A'], URL_KEY);
define('DB_XMLDB_HOST', PATH_DYNAFORM . $file . '.xml');
define('DB_XMLDB_USER', '');
define('DB_XMLDB_PASS', '');
define('DB_XMLDB_NAME', '');
define('DB_XMLDB_TYPE', 'myxml');
$newValues = Bootstrap::json_decode(urlDecode(stripslashes($_POST['fields'])));
//Resolve dependencies
//Returns an array ($dependentFields) with the names of the fields
//that depends of fields passed through AJAX ($_GET/$_POST)
$dependentFields = array();
$aux = array();
for ($r = 0; $r < sizeof($newValues); $r++) {
    $newValues[$r] = (array) $newValues[$r];
    $G_FORM->setValues($newValues[$r]);
    //Search dependent fields
예제 #22
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");

    }
예제 #23
0
 public function generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $aProperties = array())
 {
     define("MAX_FREE_FRACTION", 1);
     define('PATH_OUTPUT_FILE_DIRECTORY', PATH_HTML . 'files/' . $_SESSION['APPLICATION'] . '/outdocs/');
     G::verifyPath(PATH_OUTPUT_FILE_DIRECTORY, true);
     require_once PATH_THIRDPARTY . 'html2ps_pdf/config.inc.php';
     require_once PATH_THIRDPARTY . 'html2ps_pdf/pipeline.factory.class.php';
     parse_config_file(PATH_THIRDPARTY . 'html2ps_pdf/html2ps.config');
     $GLOBALS['g_config'] = array('cssmedia' => 'screen', 'media' => 'Letter', 'scalepoints' => false, 'renderimages' => true, 'renderfields' => true, 'renderforms' => false, 'pslevel' => 3, 'renderlinks' => true, 'pagewidth' => 800, 'landscape' => $sLandscape, 'method' => 'fpdf', 'margins' => array('left' => 15, 'right' => 15, 'top' => 15, 'bottom' => 15), 'encoding' => '', 'ps2pdf' => false, 'compress' => true, 'output' => 2, 'pdfversion' => '1.3', 'transparency_workaround' => false, 'imagequality_workaround' => false, 'draw_page_border' => isset($_REQUEST['pageborder']), 'debugbox' => false, 'html2xhtml' => true, 'mode' => 'html', 'smartpagebreak' => true);
     $GLOBALS['g_config'] = array_merge($GLOBALS['g_config'], $aProperties);
     $g_media = Media::predefined($GLOBALS['g_config']['media']);
     $g_media->set_landscape($GLOBALS['g_config']['landscape']);
     $g_media->set_margins($GLOBALS['g_config']['margins']);
     $g_media->set_pixels($GLOBALS['g_config']['pagewidth']);
     if (isset($GLOBALS['g_config']['pdfSecurity'])) {
         if (isset($GLOBALS['g_config']['pdfSecurity']['openPassword']) && $GLOBALS['g_config']['pdfSecurity']['openPassword'] != "") {
             $GLOBALS['g_config']['pdfSecurity']['openPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['openPassword'], $sUID);
         }
         if (isset($GLOBALS['g_config']['pdfSecurity']['ownerPassword']) && $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] != "") {
             $GLOBALS['g_config']['pdfSecurity']['ownerPassword'] = G::decrypt($GLOBALS['g_config']['pdfSecurity']['ownerPassword'], $sUID);
         }
         $g_media->set_security($GLOBALS['g_config']['pdfSecurity']);
         require_once HTML2PS_DIR . 'pdf.fpdf.encryption.php';
     }
     $pipeline = new Pipeline();
     if (extension_loaded('curl')) {
         require_once HTML2PS_DIR . 'fetcher.url.curl.class.php';
         $pipeline->fetchers = array(new FetcherURLCurl());
         if (isset($proxy)) {
             if ($proxy != '') {
                 $pipeline->fetchers[0]->set_proxy($proxy);
             }
         }
     } else {
         require_once HTML2PS_DIR . 'fetcher.url.class.php';
         $pipeline->fetchers[] = new FetcherURL();
     }
     $pipeline->data_filters[] = new DataFilterDoctype();
     $pipeline->data_filters[] = new DataFilterUTF8($GLOBALS['g_config']['encoding']);
     if ($GLOBALS['g_config']['html2xhtml']) {
         $pipeline->data_filters[] = new DataFilterHTML2XHTML();
     } else {
         $pipeline->data_filters[] = new DataFilterXHTML2XHTML();
     }
     $pipeline->parser = new ParserXHTML();
     $pipeline->pre_tree_filters = array();
     $header_html = '';
     $footer_html = '';
     $filter = new PreTreeFilterHeaderFooter($header_html, $footer_html);
     $pipeline->pre_tree_filters[] = $filter;
     if ($GLOBALS['g_config']['renderfields']) {
         $pipeline->pre_tree_filters[] = new PreTreeFilterHTML2PSFields();
     }
     if ($GLOBALS['g_config']['method'] === 'ps') {
         $pipeline->layout_engine = new LayoutEnginePS();
     } else {
         $pipeline->layout_engine = new LayoutEngineDefault();
     }
     $pipeline->post_tree_filters = array();
     if ($GLOBALS['g_config']['pslevel'] == 3) {
         $image_encoder = new PSL3ImageEncoderStream();
     } else {
         $image_encoder = new PSL2ImageEncoderStream();
     }
     switch ($GLOBALS['g_config']['method']) {
         case 'fastps':
             if ($GLOBALS['g_config']['pslevel'] == 3) {
                 $pipeline->output_driver = new OutputDriverFastPS($image_encoder);
             } else {
                 $pipeline->output_driver = new OutputDriverFastPSLevel2($image_encoder);
             }
             break;
         case 'pdflib':
             $pipeline->output_driver = new OutputDriverPDFLIB16($GLOBALS['g_config']['pdfversion']);
             break;
         case 'fpdf':
             $pipeline->output_driver = new OutputDriverFPDF();
             break;
         case 'png':
             $pipeline->output_driver = new OutputDriverPNG();
             break;
         case 'pcl':
             $pipeline->output_driver = new OutputDriverPCL();
             break;
         default:
             die('Unknown output method');
     }
     if (isset($GLOBALS['g_config']['watermarkhtml'])) {
         $watermark_text = $GLOBALS['g_config']['watermarkhtml'];
     } else {
         $watermark_text = '';
     }
     $pipeline->output_driver->set_watermark($watermark_text);
     if ($watermark_text != '') {
         $dispatcher =& $pipeline->getDispatcher();
     }
     if ($GLOBALS['g_config']['debugbox']) {
         $pipeline->output_driver->set_debug_boxes(true);
     }
     if ($GLOBALS['g_config']['draw_page_border']) {
         $pipeline->output_driver->set_show_page_border(true);
     }
     if ($GLOBALS['g_config']['ps2pdf']) {
         $pipeline->output_filters[] = new OutputFilterPS2PDF($GLOBALS['g_config']['pdfversion']);
     }
     if ($GLOBALS['g_config']['compress'] && $GLOBALS['g_config']['method'] == 'fastps') {
         $pipeline->output_filters[] = new OutputFilterGZip();
     }
     if (!isset($GLOBALS['g_config']['process_mode'])) {
         $GLOBALS['g_config']['process_mode'] = '';
     }
     if ($GLOBALS['g_config']['process_mode'] == 'batch') {
         $filename = 'batch';
     } else {
         $filename = $sFilename;
     }
     switch ($GLOBALS['g_config']['output']) {
         case 0:
             $pipeline->destination = new DestinationBrowser($filename);
             break;
         case 1:
             $pipeline->destination = new DestinationDownload($filename);
             break;
         case 2:
             $pipeline->destination = new DestinationFile($filename);
             break;
     }
     copy($sPath . $sFilename . '.html', PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
     try {
         $status = $pipeline->process((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/files/' . $_SESSION['APPLICATION'] . '/outdocs/' . $sFilename . '.html', $g_media);
         copy(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf', $sPath . $sFilename . '.pdf');
         unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.pdf');
         unlink(PATH_OUTPUT_FILE_DIRECTORY . $sFilename . '.html');
     } catch (Exception $e) {
         if ($e->getMessage() == 'ID_OUTPUT_NOT_GENERATE') {
             include_once 'classes/model/AppDocument.php';
             $dataDocument = explode('_', $sFilename);
             if (!isset($dataDocument[1])) {
                 $dataDocument[1] = 1;
             }
             $oAppDocument = new AppDocument();
             $oAppDocument->remove($dataDocument[0], $dataDocument[1]);
             G::SendTemporalMessage(G::LoadTranslation('ID_OUTPUT_NOT_GENERATE'), 'Error');
         }
     }
 }
예제 #24
0
 * 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.
 * 
 */
if (($RBAC_Response = $RBAC->userCanAccess("PM_FACTORY")) != 1) {
    return $RBAC_Response;
}
//G::genericForceLogin( 'WF_MYINFO' , 'login/noViewPage', $urlLogin = '******' );
G::LoadClass('toolBar');
G::LoadClass('dynaFormField');
if (!(isset($_POST['A']) && $_POST['A'] !== '')) {
    return;
}
$file = G::decrypt($_POST['A'], URL_KEY);
$G_PUBLISH = new Publisher();
$form = new Form($file, PATH_DYNAFORM, SYS_LANG, true);
switch (basename($form->template, '.html')) {
    case 'grid':
        $template = 'grid';
        break;
    default:
        $template = 'xmlform';
}
$G_PUBLISH->AddContent('dynaform', $template, $file, '', array('__DYNAFORM_OPTIONS' => array('PREVIOUS_STEP' => '#', 'NEXT_STEP' => '#', 'PREVIOUS_ACTION' => 'return false;', 'NEXT_ACTION' => 'return false;')), '');
G::RenderPage('publish', 'raw');
/* $toolbar = new ToolBar( '/dynaforms/dynaforms_Toolbar' , PATH_XMLFORM, SYS_LANG, false );

  print($toolbar->render( $toolbar->template , $script ));*/
//$form = new Form( $file , PATH_DYNAFORM, SYS_LANG, true );
예제 #25
0
 /**
  * this function gets all authentication source
  * Authentication Sources
  *
  * @access public
  *
  * @param string $sUID
  * @return $this->authSourcesObj->load
  */
 public function getAuthSource($sUID)
 {
     $data = $this->authSourcesObj->load($sUID);
     $pass = explode("_", $data['AUTH_SOURCE_PASSWORD']);
     foreach ($pass as $index => $value) {
         if ($value == '2NnV3ujj3w') {
             $data['AUTH_SOURCE_PASSWORD'] = G::decrypt($pass[0], $data['AUTH_SOURCE_SERVER_NAME']);
         }
     }
     $this->authSourcesObj->Fields = $data;
     return $this->authSourcesObj->Fields;
 }
예제 #26
0
 /**
  * @covers G::decrypt
  * @todo   Implement testDecrypt().
  */
 public function testDecrypt()
 {
     $encryptPassword = '******';
     $encryptResponse = G::decrypt('6czY7OLU688', 'key');
 }
예제 #27
0
 /**
  * Update data from a addTable record
  *
  * @param $row
  */
 public function _dataDestroy($row)
 {
     $row = G::decrypt($row, 'pmtable');
     $row = str_replace('"', '', $row);
     $keys = explode(',', $row);
     $params = array();
     foreach ($keys as $key) {
         $params[] = is_numeric($key) ? $key : "'{$key}'";
     }
     $obj = null;
     eval('$obj = ' . $this->classPeerName . '::retrieveByPk(' . implode(',', $params) . ');');
     if (is_object($obj)) {
         $obj->delete();
         return true;
     } else {
         return false;
     }
 }
예제 #28
0
 /**
  * handle and compose the email content and parameters
  *
  * @param none
  * @return none
  */
 private function handleMail ()
 {
     if (count( $this->fileData['envelope_to'] ) > 0) {
         if (array_key_exists('MESS_ENGINE',$this->config)) {
             switch ($this->config['MESS_ENGINE']) {
                 case 'MAIL':
                 case 'PHPMAILER':
                     G::LoadThirdParty( 'phpmailer', 'class.phpmailer' );
 
                     switch ($this->config['MESS_ENGINE']) {
                         case 'MAIL':
                             $oPHPMailer = new PHPMailer();
                             $oPHPMailer->Mailer = 'mail';
                             break;
                         case 'PHPMAILER':
                             $oPHPMailer = new PHPMailer( true );
                             $oPHPMailer->Mailer = 'smtp';
                             break;
                     }
 
                     $oPHPMailer->SMTPAuth = (isset( $this->config['SMTPAuth'] ) ? $this->config['SMTPAuth'] : '');
 
                     switch ($this->config['MESS_ENGINE']) {
                         case 'MAIL':
                             break;
                         case 'PHPMAILER':
                             //Posible Options for SMTPSecure are: "", "ssl" or "tls"
                             if (isset( $this->config['SMTPSecure'] ) && preg_match( '/^(ssl|tls)$/', $this->config['SMTPSecure'] )) {
                                 $oPHPMailer->SMTPSecure = $this->config['SMTPSecure'];
                             }
                             break;
                     }
 
                     $oPHPMailer->CharSet = "UTF-8";
                     $oPHPMailer->Encoding = "8bit";
                     $oPHPMailer->Host = $this->config['MESS_SERVER'];
                     $oPHPMailer->Port = $this->config['MESS_PORT'];
                     $oPHPMailer->Username = $this->config['MESS_ACCOUNT'];
                     $oPHPMailer->Password = $this->config['MESS_PASSWORD'];
                     $oPHPMailer->From = $this->fileData['from_email'];
                     $oPHPMailer->FromName = utf8_decode( $this->fileData['from_name'] );
                     if (isset($this->fileData['reply_to'])) {
                         if ($this->fileData['reply_to'] != '') {
                             $oPHPMailer->AddReplyTo($this->fileData['reply_to'], $this->fileData['reply_to_name']);
                         }
                     }
 
                     $msSubject = $this->fileData['subject'];
 
                     if (! (mb_detect_encoding( $msSubject, "UTF-8" ) == "UTF-8")) {
                         $msSubject = utf8_encode( $msSubject );
                     }
 
                     $oPHPMailer->Subject = $msSubject;
 
                     $msBody = $this->fileData['body'];
 
                     if (! (mb_detect_encoding( $msBody, "UTF-8" ) == "UTF-8")) {
                         $msBody = utf8_encode( $msBody );
                     }
 
                     $oPHPMailer->Body = $msBody;
 
                     $attachment = @unserialize($this->fileData['attachments']);
                     if ($attachment === false) {
                         $attachment = $this->fileData['attachments'];
                     }
                     if (is_array($attachment)) {
                         foreach ($attachment as $key => $fileAttach) {
                             if (file_exists( $fileAttach )) {
                                 $oPHPMailer->AddAttachment( $fileAttach, is_int( $key ) ? '' : $key );
                             }
                         }
                     }
 
                     foreach ($this->fileData['envelope_to'] as $sEmail) {
                         if (strpos( $sEmail, '<' ) !== false) {
                             preg_match( $this->longMailEreg, $sEmail, $matches );
                             $sTo = trim( $matches[3] );
                             $sToName = trim( $matches[1] );
                             $oPHPMailer->AddAddress( $sTo, $sToName );
                         } else {
                             $oPHPMailer->AddAddress( $sEmail );
                         }
                     }
 
                     //CC
                     foreach ($this->fileData['envelope_cc'] as $sEmail) {
                         if (strpos( $sEmail, '<' ) !== false) {
                             preg_match( $this->longMailEreg, $sEmail, $matches );
                             $sTo = trim( $matches[3] );
                             $sToName = trim( $matches[1] );
                             $oPHPMailer->AddCC( $sTo, $sToName );
                         } else {
                             $oPHPMailer->AddCC( $sEmail );
                         }
                     }
 
                     //BCC
                     foreach ($this->fileData['envelope_bcc'] as $sEmail) {
                         if (strpos( $sEmail, '<' ) !== false) {
                             preg_match( $this->longMailEreg, $sEmail, $matches );
                             $sTo = trim( $matches[3] );
                             $sToName = trim( $matches[1] );
                             $oPHPMailer->AddBCC( $sTo, $sToName );
                         } else {
                             $oPHPMailer->AddBCC( $sEmail );
                         }
                     }
 
                     $oPHPMailer->IsHTML($this->fileData["contentTypeIsHtml"]);
 
                     if ( $this->config['MESS_ENGINE'] == 'MAIL') {
                         $oPHPMailer->WordWrap = 300;
                     }
 
                     if ($oPHPMailer->Send()) {
                         $this->error = '';
                         $this->status = 'sent';
                     } else {
                         $this->error = $oPHPMailer->ErrorInfo;
                         $this->status = 'failed';
                     }
                     break;
                 case 'OPENMAIL':
                     G::LoadClass( 'package' );
                     G::LoadClass( 'smtp' );
                     $pack = new package( $this->fileData );
                     $header = $pack->returnHeader();
                     $body = $pack->returnBody();
                     $send = new smtp();
                     $send->setServer( $this->config['MESS_SERVER'] );
                     $send->setPort( $this->config['MESS_PORT'] );
                     $send->setUsername( $this->config['MESS_ACCOUNT'] );
 
                     $passwd = $this->config['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 );
                         }
                     }
 
                     $this->config['MESS_PASSWORD'] = $passwd;
                     $send->setPassword( $this->config['MESS_PASSWORD'] );
                     $send->setReturnPath( $this->fileData['from_email'] );
                     $send->setHeaders( $header );
                     $send->setBody( $body );
                     $send->setEnvelopeTo( $this->fileData['envelope_to'] );
                     if ($send->sendMessage()) {
                         $this->error = '';
                         $this->status = 'sent';
                     } else {
                         $this->error = implode( ', ', $send->returnErrors() );
                         $this->status = 'failed';
                     }
                     break;
             }
         }
     }
 }
예제 #29
0
     $oAppDocument->remove($_POST['DOC']);
     $oCase = new Cases();
     $oCase->getAllGeneratedDocumentsCriteria($_SESSION['PROCESS'], $_SESSION['APPLICATION'], $_SESSION['TASK'], $_SESSION['USER_LOGGED']);
     break;
     /* @Author Erik Amaru Ortiz <*****@*****.**> */
 /* @Author Erik Amaru Ortiz <*****@*****.**> */
 case 'resendMessage':
     //require_once 'classes/model/Configuration.php';
     G::LoadClass('spool');
     $oCase = new Cases();
     $data = $oCase->getHistoryMessagesTrackerView($_POST['APP_UID'], $_POST['APP_MSG_UID']);
     //print_r($data);
     G::LoadClass("system");
     $aSetup = System::getEmailConfiguration();
     $passwd = $aSetup['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);
         }
     }
     $aSetup['MESS_PASSWORD'] = $passwd;
     if ($aSetup['MESS_RAUTH'] == false || is_string($aSetup['MESS_RAUTH']) && $aSetup['MESS_RAUTH'] == 'false') {
         $aSetup['MESS_RAUTH'] = 0;
     } else {
         $aSetup['MESS_RAUTH'] = 1;
     }
    static public function letsRestore ($filename, $srcWorkspace, $dstWorkspace = null, $overwrite = true)
    {
        // Needed info:
        // TEMPDIR  /shared/workflow_data/upgrade/
        // BACKUPS  /shared/workflow_data/backups/
        // Creating command  cat myfiles_split.tgz_* | tar xz
        $DecommpressCommand = "cat " . $filename . ".* ";
        $DecommpressCommand .= " | tar xzv";

        $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
        CLI::logging( "Restoring into " . $tempDirectory . "\n" );
        chdir( $tempDirectory );
        echo exec( $DecommpressCommand );
        CLI::logging( "\nUncompressed into: " . $tempDirectory . "\n" );

        //Search for metafiles in the new standard (the old standard would contain meta 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" );
        }
        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 (! 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 ) );

            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" );
                $workspace->createDBUser( $dbName, $db->pass, "localhost", $dbName );
                $workspace->createDBUser( $dbName, $db->pass, "%", $dbName );
            }
            $workspace->upgradeCacheView( false );
            mysql_close( $link );

        }
        CLI::logging( "Removing temporary files\n" );
        G::rm_dir( $tempDirectory );
        CLI::logging( CLI::info( "Done restoring" ) . "\n" );
    }