public function minify() { if ($this->contentType != 'text/css') { G::LoadThirdParty('jsmin', 'jsmin'); $this->content = JSMin::minify($this->content); } }
function install($file) { G::LoadThirdParty("pear/Archive", "Tar"); $result = array(); $status = 1; try { //Extract $tar = new Archive_Tar($file); $swTar = $tar->extract(PATH_OUTTRUNK); //true on success, false on error. //directory for extract //$swTar = $tar->extract(PATH_PLUGINS); if (!$swTar) { throw new Exception("Could not extract file."); } //Upgrade $option = array("http" => array("method" => "POST")); // 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); /////// $fileData = @fopen(EnterpriseUtils::getUrlServerName() . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/enterprise/services/processMakerUpgrade", "rb", false, $context); if ($fileData === false) { throw new Exception("Could not open services url."); } $resultAux = G::json_decode(stream_get_contents($fileData)); if ($resultAux->status == "OK") { $result["status"] = $resultAux->status; //OK $result["message"] = $resultAux->message; } else { throw new Exception($resultAux->message); } } catch (Exception $e) { $result["message"] = $e->getMessage(); $status = 0; } if ($status == 0) { $result["status"] = "ERROR"; } return $result; }
define("SYS_LANG", "en"); require_once PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths.php"; require_once PATH_TRUNK . "framework" . PATH_SEP . "src" . PATH_SEP . "Maveriks" . PATH_SEP . "Util" . PATH_SEP . "ClassLoader.php"; //Class Loader - /ProcessMaker/BusinessModel $classLoader = \Maveriks\Util\ClassLoader::getInstance(); $classLoader->add(PATH_TRUNK . "framework" . PATH_SEP . "src" . PATH_SEP, "Maveriks"); $classLoader->add(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "src" . PATH_SEP, "ProcessMaker"); $classLoader->add(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "src" . PATH_SEP); //Add vendors to autoloader //$classLoader->add(PATH_TRUNK . "vendor" . PATH_SEP . "luracast" . PATH_SEP . "restler" . PATH_SEP . "vendor", "Luracast"); //$classLoader->add(PATH_TRUNK . "vendor" . PATH_SEP . "bshaffer" . PATH_SEP . "oauth2-server-php" . PATH_SEP . "src" . PATH_SEP, "OAuth2"); $classLoader->addClass("Bootstrap", PATH_TRUNK . "gulliver" . PATH_SEP . "system" . PATH_SEP . "class.bootstrap.php"); $classLoader->addModelClassPath(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP); //Load classes G::LoadThirdParty("pear/json", "class.json"); G::LoadThirdParty("smarty/libs", "Smarty.class"); G::LoadSystem("error"); G::LoadSystem("dbconnection"); G::LoadSystem("dbsession"); G::LoadSystem("dbrecordset"); G::LoadSystem("dbtable"); G::LoadSystem("rbac"); G::LoadSystem("publisher"); G::LoadSystem("templatePower"); G::LoadSystem("xmlDocument"); G::LoadSystem("xmlform"); G::LoadSystem("xmlformExtension"); G::LoadSystem("form"); G::LoadSystem("menu"); G::LoadSystem("xmlMenu"); G::LoadSystem("dvEditor");
* * 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. * */ $unitFilename = $_SERVER['PWD'] . '/test/bootstrap/unit.php'; require_once $unitFilename; require_once PATH_THIRDPARTY . '/lime/lime.php'; require_once PATH_THIRDPARTY . 'lime/yaml.class.php'; require_once PATH_CORE . "config/databases.php"; require_once "propel/Propel.php"; Propel::init(PATH_CORE . "config/databases.php"); G::LoadThirdParty('smarty/libs', 'Smarty.class'); G::LoadSystem('error'); G::LoadSystem('xmlform'); G::LoadSystem('xmlDocument'); G::LoadSystem('form'); G::LoadSystem('dbconnection'); G::LoadSystem('dbsession'); G::LoadSystem('dbrecordset'); G::LoadSystem('dbtable'); G::LoadSystem('testTools'); G::LoadClass('appDelegation'); require_once PATH_CORE . '/classes/model/AppDelegation.php'; $dbc = new DBConnection(); $ses = new DBSession($dbc); $obj = new AppDelegation($dbc); $t = new lime_test(1, new lime_output_color());
switch ($_REQUEST['action']) { case 'searchUsers': require_once 'classes/model/Users.php'; $criteria = new Criteria('workflow'); $criteria->addSelectColumn(UsersPeer::USR_USERNAME); $criteria->add(UsersPeer::USR_STATUS, array('CLOSED'), Criteria::NOT_IN); $dataset = UsersPeer::DoSelectRs($criteria); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $dataset->next(); $pmUsers = array(); while ($row = $dataset->getRow()) { $pmUsers[] = $row['USR_USERNAME']; $dataset->next(); } $aFields = $RBAC->getAuthSource($_POST['sUID']); G::LoadThirdParty('pear/json', 'class.json'); $oJSON = new Services_JSON(); $i = 0; $oUser = new Users(); $aAux = $RBAC->searchUsers($_POST['sUID'], $_POST['sKeyword']); $aUsers = array(); // note added by gustavo cruz gustavo-at-colosa.com // changed the user data showed to accept FirstName and LastName variables $aUsers[] = array('Checkbox' => 'char', 'Username' => 'char', 'FullName' => 'char', 'FirstName' => 'char', 'LastName' => 'char', 'Email' => 'char', 'DistinguishedName' => 'char'); foreach ($aAux as $aUser) { if (!in_array($aUser['sUsername'], $pmUsers)) { // add replace to change D'Souza to D*Souza by krlos $sCheckbox = '<div align="center"><input type="checkbox" name="aUsers[' . $i . ']" id="aUsers[' . $i . ']" value=\'' . str_replace("\\'", "*", addslashes($oJSON->encode($aUser))) . '\' /></div>'; $i++; } else { $sCheckbox = G::LoadTranslation('ID_USER_REGISTERED') . ':<br />(' . $aUser['sUsername'] . ')';
/** * 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; } } } }
public static function hotfixInstall($file) { $result = array(); $dirHotfix = PATH_DATA . "hotfixes"; $arrayPathInfo = pathinfo($file); $f = ($arrayPathInfo["dirname"] == ".")? $dirHotfix . PATH_SEP . $file : $file; $swv = 1; $msgv = ""; if (!file_exists($dirHotfix)) { G::mk_dir($dirHotfix, 0777); } if (!file_exists($f)) { $swv = 0; $msgv = $msgv . (($msgv != "")? "\n": null) . "- The file \"$f\" does not exist"; } if ($arrayPathInfo["extension"] != "tar") { $swv = 0; $msgv = $msgv . (($msgv != "")? "\n": null) . "- The file extension \"$file\" is not \"tar\""; } if ($swv == 1) { G::LoadThirdParty("pear/Archive", "Tar"); //Extract $tar = new Archive_Tar($f); $swTar = $tar->extractModify(PATH_TRUNK, "processmaker"); //true on success, false on error if ($swTar) { $result["status"] = 1; $result["message"] = "- Hotfix installed successfully \"$f\""; } else { $result["status"] = 0; $result["message"] = "- Could not extract file \"$f\""; } } else { $result["status"] = 0; $result["message"] = $msgv; } return $result; }
$aTriggers[0] = $_SESSION['TRIGGER_DEBUG']; } //print_r($aTriggers);die; $triggersList = array(); $i = 0; foreach ($aTriggers as $aTrigger) { if ($aTrigger['NUM_TRIGGERS'] != 0) { foreach ($aTrigger['TRIGGERS_NAMES'] as $index => $name) { $triggersList[$i]['name'] = $name; $triggersList[$i]['execution_time'] = strtolower($aTrigger['TIME']); //$t_code = $aTrigger['TRIGGERS_VALUES'][$index]['TRI_WEBBOT']; //$t_code = str_replace('"', '\'',$t_code); //$t_code = addslashes($t_code); //$t_code = Only1br($t_code); //highlighting the trigger code using the geshi third party library G::LoadThirdParty('geshi', 'geshi'); $geshi = new GeSHi($aTrigger['TRIGGERS_VALUES'][$index]['TRI_WEBBOT'], 'php'); $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2); $geshi->set_line_style('background: #f0f0f0;'); $triggersList[$i]['code'] = $geshi->parse_code(); //$aTrigger['TRIGGERS_VALUES'][$index]['TRI_WEBBOT']; $i++; } } else { } } //print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']); die; $DEBUG_ERRORS = array_unique($_SESSION['TRIGGER_DEBUG']['ERRORS']); foreach ($DEBUG_ERRORS as $error) { if (isset($error['ERROR']) and $error['ERROR'] != '') { $triggersList[$i]['name'] = 'Error';
/** * Test connection by step * * @param array $arrayData Data * @param int $step Step * * return array Return array with result of test connection by step */ public function testConnectionByStep(array $arrayData, $step = 0) { try { \G::LoadClass("net"); \G::LoadThirdParty("phpmailer", "class.smtp"); //MAIL if ($arrayData["MESS_ENGINE"] == "MAIL") { $arrayDataMail = array(); $eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\\.[0-9a-zA-Z]{2,3}\$/"; $arrayDataMail["FROM_EMAIL"] = $arrayData["MESS_FROM_MAIL"] != "" && preg_match($eregMail, $arrayData["MESS_FROM_MAIL"]) ? $arrayData["MESS_FROM_MAIL"] : ""; $arrayDataMail["FROM_NAME"] = $arrayData["MESS_FROM_NAME"] != "" ? $arrayData["MESS_FROM_NAME"] : \G::LoadTranslation("ID_MESS_TEST_BODY"); $arrayDataMail["MESS_ENGINE"] = "MAIL"; $arrayDataMail["MESS_SERVER"] = "localhost"; $arrayDataMail["MESS_PORT"] = 25; $arrayDataMail["MESS_ACCOUNT"] = $arrayData["MAIL_TO"]; $arrayDataMail["MESS_PASSWORD"] = ""; $arrayDataMail["TO"] = $arrayData["MAIL_TO"]; $arrayDataMail["MESS_RAUTH"] = true; $arrayTestMailResult = array(); try { $arrayTestMailResult = $this->sendTestMail($arrayDataMail); } catch (Exception $e) { $arrayTestMailResult["status"] = false; $arrayTestMailResult["message"] = $e->getMessage(); } $arrayResult = array("result" => $arrayTestMailResult["status"], "message" => ""); if ($arrayTestMailResult["status"] == false) { $arrayResult["message"] = \G::LoadTranslation("ID_SENDMAIL_NOT_INSTALLED"); } //Return return $arrayResult; } //PHPMAILER $server = $arrayData["MESS_SERVER"]; $user = $arrayData["MESS_ACCOUNT"]; $passwd = $arrayData["MESS_PASSWORD"]; $fromMail = $arrayData["MESS_FROM_MAIL"]; $passwdHide = $arrayData["MESS_PASSWORD"]; if (trim($passwdHide) != "") { $passwd = $passwdHide; $passwdHide = ""; } $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); } } $arrayData["MESS_PASSWORD"] = $passwd; $port = (int) $arrayData["MESS_PORT"]; $auth_required = (int) $arrayData["MESS_RAUTH"]; $useSecureCon = $arrayData["SMTPSECURE"]; $sendTestMail = (int) $arrayData["MESS_TRY_SEND_INMEDIATLY"]; $mailTo = $arrayData["MAIL_TO"]; $smtpSecure = $arrayData["SMTPSECURE"]; $serverNet = new \NET($server); $smtp = new \SMTP(); $timeout = 10; $hostinfo = array(); $srv = $arrayData["MESS_SERVER"]; $arrayResult = array(); switch ($step) { case 1: $arrayResult["result"] = $serverNet->getErrno() == 0; $arrayResult["message"] = $serverNet->error; break; case 2: $serverNet->scannPort($port); $arrayResult["result"] = $serverNet->getErrno() == 0; $arrayResult["message"] = $serverNet->error; break; case 3: //Try to connect to host if (preg_match("/^(.+):([0-9]+)\$/", $srv, $hostinfo)) { $server = $hostinfo[1]; $port = $hostinfo[2]; } else { $host = $srv; } $tls = strtoupper($smtpSecure) == "tls"; $ssl = strtoupper($smtpSecure) == "ssl"; $arrayResult["result"] = $smtp->Connect(($ssl ? "ssl://" : "") . $server, $port, $timeout); $arrayResult["message"] = $serverNet->error; break; case 4: //Try login to host if ($auth_required == 1) { try { if (preg_match("/^(.+):([0-9]+)\$/", $srv, $hostinfo)) { $server = $hostinfo[1]; $port = $hostinfo[2]; } else { $server = $srv; } if (strtoupper($useSecureCon) == "TLS") { $tls = "tls"; } if (strtoupper($useSecureCon) == "SSL") { $tls = "ssl"; } $tls = strtoupper($useSecureCon) == "tls"; $ssl = strtoupper($useSecureCon) == "ssl"; $server = $arrayData["MESS_SERVER"]; if (strtoupper($useSecureCon) == "SSL") { $resp = $smtp->Connect("ssl://" . $server, $port, $timeout); } else { $resp = $smtp->Connect($server, $port, $timeout); } if ($resp) { $hello = $_SERVER["SERVER_NAME"]; $smtp->Hello($hello); if (strtoupper($useSecureCon) == "TLS") { $smtp->Hello($hello); } if ($smtp->Authenticate($user, $passwd)) { $arrayResult["result"] = true; } else { if (strtoupper($useSecureCon) == "TLS") { $arrayResult["result"] = true; } else { $arrayResult["result"] = false; $smtpError = $smtp->getError(); $arrayResult["message"] = $smtpError["error"]; } } } else { $arrayResult["result"] = false; $smtpError = $smtp->getError(); $arrayResult["message"] = $smtpError["error"]; } } catch (Exception $e) { $arrayResult["result"] = false; $arrayResult["message"] = $e->getMessage(); } } else { $arrayResult["result"] = true; $arrayResult["message"] = "No authentication required!"; } break; case 5: if ($sendTestMail == 1) { try { $arrayDataPhpMailer = array(); $eregMail = "/^[0-9a-zA-Z]+(?:[._][0-9a-zA-Z]+)*@[0-9a-zA-Z]+(?:[._-][0-9a-zA-Z]+)*\\.[0-9a-zA-Z]{2,3}\$/"; $arrayDataPhpMailer["FROM_EMAIL"] = $fromMail != "" && preg_match($eregMail, $fromMail) ? $fromMail : ""; $arrayDataPhpMailer["FROM_NAME"] = $arrayData["MESS_FROM_NAME"] != "" ? $arrayData["MESS_FROM_NAME"] : \G::LoadTranslation("ID_MESS_TEST_BODY"); $arrayDataPhpMailer["MESS_ENGINE"] = "PHPMAILER"; $arrayDataPhpMailer["MESS_SERVER"] = $server; $arrayDataPhpMailer["MESS_PORT"] = $port; $arrayDataPhpMailer["MESS_ACCOUNT"] = $user; $arrayDataPhpMailer["MESS_PASSWORD"] = $passwd; $arrayDataPhpMailer["TO"] = $mailTo; if ($auth_required == 1) { $arrayDataPhpMailer["MESS_RAUTH"] = true; } else { $arrayDataPhpMailer["MESS_RAUTH"] = false; } if (strtolower($arrayData["SMTPSECURE"]) != "no") { $arrayDataPhpMailer["SMTPSecure"] = $arrayData["SMTPSECURE"]; } $arrayTestMailResult = $this->sendTestMail($arrayDataPhpMailer); if ($arrayTestMailResult["status"] . "" == "1") { $arrayResult["result"] = true; } else { $arrayResult["result"] = false; $smtpError = $smtp->getError(); $arrayResult["message"] = $smtpError["error"]; } } catch (Exception $e) { $arrayResult["result"] = false; $arrayResult["message"] = $e->getMessage(); } } else { $arrayResult["result"] = true; $arrayResult["message"] = "Jump this step"; } break; } if (!isset($arrayResult["message"])) { $arrayResult["message"] = ""; } //Return return $arrayResult; } catch (\Exception $e) { $arrayResult = array(); $arrayResult["result"] = false; $arrayResult["message"] = $e->getMessage(); //Return return $arrayResult; } }
function workspaceRestore($backupFilename, $targetWorkspace, $overwrite) { $tempDirectory = tempnam(__FILE__, ''); if (file_exists($tempDirectory)) { unlink($tempDirectory); } if (file_exists($tempDirectory)) { G::rm_dir($tempDirectory); } G::mk_dir($tempDirectory); G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($backupFilename); $res = $tar->extract($tempDirectory); $metadataFilename = $tempDirectory . PATH_SEP . 'metadata.txt'; if (!file_exists($metadataFilename)) { /* Look for legacy backups, where metadata was stored as a file with the * workspace name, such as workflow.txt * This means the backup filename must be the same as the metadata file. */ $info = pathinfo($backupFilename); /* Check if it's a compressed backup, in which case we need to remove * both the gz and the tar extensions. */ if ($info['extension'] == "gz") { $info = pathinfo(basename($backupFilename, '.' . $info['extension'])); } $wsNameFromTar = basename($backupFilename, '.' . $info['extension']); $metadataFilename = $tempDirectory . PATH_SEP . $wsNameFromTar . '.txt'; if (!file_exists($metadataFilename)) { throw new Exception("Metadata file was not found in backup"); } } $metadata = unserialize(file_get_contents($metadataFilename)); $backupWorkspace = $metadata['WORKSPACE_NAME']; $changeWorkspace = isset($targetWorkspace); if (!$changeWorkspace) { $targetWorkspace = $backupWorkspace; } else { echo "Restoring from workspace: " . pakeColor::colorize($backupWorkspace, 'INFO') . "\n"; } echo "Restoring to workspace: " . pakeColor::colorize($targetWorkspace, 'INFO') . "\n"; //moving the site files $backupWorkspaceDir = $tempDirectory . PATH_SEP . $backupWorkspace; $targetWorkspaceDir = PATH_DATA . 'sites' . PATH_SEP . $targetWorkspace; if (!$overwrite && file_exists($targetWorkspaceDir)) { $overwrite = strtolower(prompt('Workspace already exists, do you want to overwrite? [Y/n]')); if (array_search(trim($overwrite), array("y", "")) === false) { die; } $overwrite = true; } printf("Moving files to %s \n", pakeColor::colorize($targetWorkspaceDir, 'INFO')); /* We already know we will be overwriting the new workspace if we reach this * point, so remove the workspace directory if it exists. */ if (file_exists($targetWorkspaceDir)) { G::rm_dir($targetWorkspaceDir); } if (!rename($backupWorkspaceDir, $targetWorkspaceDir)) { throw new Exception("There was an error moving from {$backupWorkspaceDir} to {$targetWorkspaceDir}"); } $dbOpt = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH)); $dbHostname = $dbOpt[0]; /* TODO: Check if database exists after updateDBfile */ $config = updateDBfile($targetWorkspaceDir, $targetWorkspace, $dbHostname, $changeWorkspace); G::LoadSystem('dbMaintenance'); $oDbMaintainer = new DataBaseMaintenance($dbOpt[0], $dbOpt[1], $dbOpt[2]); $dbName = $config['DB_NAME']; $dbUser = $config['DB_USER']; $dbPass = $config['DB_PASS']; restoreDB($dbHostname, $oDbMaintainer, $metadata['DB_NAME'], $dbName, $dbUser, $dbPass, $tempDirectory, $overwrite); $dbName = $config['DB_RBAC_NAME']; $dbUser = $config['DB_RBAC_USER']; $dbPass = $config['DB_RBAC_PASS']; restoreDB($dbHostname, $oDbMaintainer, $metadata['DB_RBAC_NAME'], $dbName, $dbUser, $dbPass, $tempDirectory, $overwrite); $dbName = $config['DB_REPORT_NAME']; $dbUser = $config['DB_REPORT_USER']; $dbPass = $config['DB_REPORT_PASS']; restoreDB($dbHostname, $oDbMaintainer, $metadata['DB_REPORT_NAME'], $dbName, $dbUser, $dbPass, $tempDirectory, $overwrite); echo "\n"; $wsInfo = getSysInfo(); $wsInfo['WORKSPACE_NAME'] = $targetWorkspace; $wsInfo = array_merge($wsInfo, $config); printInfoSites($metadata, $wsInfo); return true; }
function packPlugin($pluginName, $version) { $pathBase = PATH_DATA . 'skins' . PATH_SEP . $pluginName . PATH_SEP; $pathHome = PATH_DATA . 'skins' . PATH_SEP . $pluginName; $fileTar = PATH_DATA . 'skins' . PATH_SEP . $pluginName . '-' . $version . '.tar'; G::LoadSystem('templatePower'); /* $pluginDirectory = PATH_PLUGINS . $pluginName; $pluginOutDirectory = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $pluginName; $pluginHome = PATH_OUTTRUNK . 'plugins' . PATH_SEP . $pluginName; //verify if plugin exists, $pluginClassFilename = PATH_PLUGINS . $pluginName . PATH_SEP . 'class.' . $pluginName . '.php'; if ( !is_file ( $pluginClassFilename ) ) { printf("The plugin %s doesn't exist in this file %s \n", pakeColor::colorize( $pluginName, 'ERROR'), pakeColor::colorize( $pluginClassFilename, 'INFO') ); die ; } */ G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($fileTar); $tar->_compress = false; //$tar->createModify( $pathHome . PATH_SEP . $pluginName . '.php' ,'', $pathHome); addTarFolder($tar, $pathBase, $pathHome); $aFiles = $tar->listContent(); return $fileTar; }
<?php /** * @author Hugo Loza <*****@*****.**> * * This class Helps registering and implementing Wizard for Triggers */ G::LoadThirdParty('html2ps_pdf/classes', 'include'); G::LoadThirdParty('html2ps_pdf/classes/org/active-link/doc', 'PHPClass'); /** * @package workflow.engine.ProcessMaker */ class triggerLibrary { private $_aTriggerClasses_ = array(); private static $instance = NULL; /** * __construct * * @return void */ function __construct() { //Initialize the Library and register the Default $this->registerFunctionsFileToLibrary(PATH_CORE . "classes" . PATH_SEP . "class.pmFunctions.php", "ProcessMaker Functions"); //Register all registered PLugin Functions if (class_exists('folderData')) { //$folderData = new folderData($sProUid, $proFields['PRO_TITLE'], $sAppUid, $Fields['APP_TITLE'], $sUsrUid); $oPluginRegistry =& PMPluginRegistry::getSingleton(); $aAvailablePmFunctions = $oPluginRegistry->getPmFunctions(); foreach ($aAvailablePmFunctions as $key => $class) {
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ if (isset($_POST['form']['USER_ENV'])) { session_start(); $_SESSION['sysLogin'] = $_POST['form']; G::header('location: /sys' . $_POST['form']['USER_ENV'] . '/' . SYS_LANG . '/' . SYS_SKIN . '/login/sysLoginVerify'); die; } @session_destroy(); session_start(); session_regenerate_id(); //Required classes for dbArray work require_once "propel/Propel.php"; require_once "creole/Creole.php"; G::LoadThirdParty("pake", "pakeColor.class"); Propel::init(PATH_CORE . "config/databases.php"); Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); function getLangFiles() { $dir = PATH_LANGUAGECONT; $filesArray = array(); if (file_exists($dir)) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { $fileParts = explode(".", $file); if ($fileParts[0] == "translation") { $filesArray[$fileParts[1]] = $file; } } closedir($handle);
function BugsOpenByUser() { G::LoadThirdParty("libchart/classes", "libchart"); $chart = new VerticalBarChart(430, 220); $dataSet = $this->getBugsOpenByUser(); $dataPostSet = new XYDataSet(); $dataTopicSet = new XYDataSet(); foreach ($dataSet['label'] as $key => $label) { $dataPostSet->addPoint(new Point($label, $dataSet['data'][$key])); } $chart->setDataSet($dataPostSet); //$chart->setTitle( " Posts by User" ); $chart->render(); }
} require_once 'classes/model/AddonsStore.php'; AddonsStore::checkLicenseStore(); $licenseManager =& pmLicenseManager::getSingleton(); AddonsStore::updateAll(false); $message = G::loadTranslation('ID_ENTERPRISE_INSTALLED') . ' ' . G::loadTranslation('ID_LOG_AGAIN'); G::SendMessageText($message, "INFO"); $licenseManager =& pmLicenseManager::getSingleton(); die('<script type="text/javascript">parent.parent.location = "../login/login";</script>'); } } if (!$_FILES['form']['type']['PLUGIN_FILENAME'] == 'application/octet-stream') { $pluginFilename = $_FILES['form']['type']['PLUGIN_FILENAME']; throw new Exception(G::loadTranslation('ID_FILES_INVALID_PLUGIN_FILENAME', SYS_LANG, array("pluginFilename" => $pluginFilename))); } G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($path . $filename); $sFileName = substr($filename, 0, strrpos($filename, '.')); $sClassName = substr($filename, 0, strpos($filename, '-')); $sClassName = !empty($sClassName) ? $sClassName : $sFileName; $aFiles = $tar->listContent(); $bMainFile = false; $bClassFile = false; if (!is_array($aFiles)) { throw new Exception(G::loadTranslation('ID_FAILED_IMPORT_PLUGINS', SYS_LANG, array("filename" => $filename))); } foreach ($aFiles as $key => $val) { if (trim($val['filename']) == $sClassName . '.php') { $bMainFile = true; } if (trim($val['filename']) == $sClassName . PATH_SEP . 'class.' . $sClassName . '.php') {
/** * SysLogin */ public function sysLogin() { require_once "propel/Propel.php"; require_once "creole/Creole.php"; G::LoadClass('system'); G::LoadThirdParty("pake", "pakeColor.class"); Propel::init(PATH_CORE . "config/databases.php"); Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); // getting posibles errors passed by GET method $this->getInUrlError(); $availableWorkspace = $this->getWorkspacesAvailable(); $availableWorkspaceList = array(); foreach ($availableWorkspace as $ws) { $availableWorkspaceList[] = array($ws, $ws); } $aField['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG'); //Get Server Configuration G::LoadClass('serverConfiguration'); $oServerConf =& serverConf::getSingleton(); $availableLangArray = $this->getLanguagesList(); $this->includeExtJSLib('ux/virtualkeyboard'); $this->setJSVar('sysLang', SYS_LANG); $this->includeExtJS('main/sysLogin'); $this->setVar('logo_company', $this->getCompanyLogo()); $this->setVar('pmos_version', System::getVersion()); $footerText = G::LoadTranslation('ID_COPYRIGHT_FROM') . date('Y') . G::LoadTranslation('ID_COPYRIGHT_COL'); $adviseText = G::LoadTranslation('ID_COLOSA_AND_CERTIFIED_PARTNERS'); $this->setVar('footer_text', $footerText); $this->setVar('advise_text', $adviseText); //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() if (($flyNotify = $this->getFlyNotify()) !== false) { $this->setJSVar('flyNotify', $flyNotify); } $this->setJSVar('languages', $availableLangArray); $this->setJSVar('workspaces', $availableWorkspaceList); $this->setJSVar('wsPrivate', $oServerConf->getProperty('LOGIN_NO_WS')); $this->setJSVar('defaultLang', 'en'); $this->setJSVar('defaultWS', ''); $loginScript = $this->getHeadPublisher()->getExtJsLibraries(); $loginScript .= $this->getHeadPublisher()->getExtJsScripts(); $this->setVar("login_script", $loginScript); $this->setVar("login_vars", $this->getHeadPublisher()->getExtJsVariablesScript()); $this->setVar("URL_TRANSLATION_JS", G::browserCacheFilesUrl("/js/ext/translation.en.js")); $this->setLayout("pm-modern-login"); $this->render(); }
* published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * 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. * */ G::LoadThirdParty('phpmailer', 'class.phpmailer'); /* Send emails using the class "PHPMailer" * Email server configuration constants: * MAIL_MAILER mail/smtp * MAIL_HOST email.server.address * MAIL_SMTPAUTH true/false * MAIL_USERNAME Email Username (smtp) * MAIL_PASSWORD Email Password (smtp) * MAIL_TIMEOUT Email Timeout (smtp) * MAIL_CHARSET Email Charset "utf-8" * MAIL_ENCODING Email Encoding "base64" * Other required configuration constants: * PATH_HTMLMAIL Email templates path * @author David Callizaya <*****@*****.**> */ /**
* * This program is distributed in the hope that it will be useful, * 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. * */ //if (($RBAC_Response=$RBAC->userCanAccess("PM_SETUP"))!=1) return $RBAC_Response; require_once "class.charts.php"; G::LoadThirdParty("libchart/classes", "libchart"); header("Content-type: image/png"); //type of chart, pie, vertical bar, horizontal, etc. $type = isset($_GET['type']) ? $_GET['type'] : '1'; $chartType = isset($_GET['chart']) ? $_GET['chart'] : '1'; $user = isset($_GET['user']) ? $_GET['user'] : $_SESSION['USER_LOGGED']; $chartsObj = new chartsClass(); //$chart = new PieChart(450,300); switch ($type) { case '1': $chart = new VerticalBarChart(430, 280); break; case '2': $chart = new HorizontalBarChart(430, 200); break; case '3':
public function setPartner() { if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) { // Execute sql for partner $pathMysqlPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'mysql' . PATH_SEP; if (G::verifyPath($pathMysqlPartner)) { $res = array(); $filesSlq = glob($pathMysqlPartner . '*.sql'); foreach ($filesSlq as $value) { $this->mysqlFileQuery($value); } } // Execute to change of skin $pathSkinPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'skin' . PATH_SEP; if (G::verifyPath($pathSkinPartner)) { $res = array(); $fileTar = glob($pathSkinPartner . '*.tar'); foreach ($fileTar as $value) { $dataFile = pathinfo($value); $nameSkinTmp = $dataFile['filename']; G::LoadThirdParty( 'pear/Archive', 'Tar' ); $tar = new Archive_Tar( $value ); $pathSkinTmp = $pathSkinPartner . 'tmp' . PATH_SEP; G::rm_dir($pathSkinTmp); G::verifyPath($pathSkinTmp, true); chmod( $pathSkinTmp, 0777); $tar->extract($pathSkinTmp); $pathSkinName = $pathSkinTmp . $nameSkinTmp . PATH_SEP; chmod( $pathSkinName, 0777); G::verifyPath(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', true); $skinClassic = PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp' . PATH_SEP; if (is_dir($pathSkinName)) { $this->copyFile($pathSkinName, $skinClassic); } G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'base'); rename(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', PATH_CORE . 'skinEngine' . PATH_SEP . 'base'); G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp'); break; } } } }
/** * Run the CLI task, which will check which command is specified and run it. */ public static function run() { CLI::taskName("help"); CLI::taskRun(array('self', 'help')); global $argv; $args = $argv; $cliname = array_shift($args); $taskName = array_shift($args); while ($taskName[0] == '-') { $taskName = array_shift($args); } if (!$taskName) { echo self::error("Specify a task from the list below.") . "\n\n"; self::help(null, null); return; } $taskData = null; foreach (self::$tasks as $name => $data) { if (strcasecmp($name, $taskName) === 0) { $taskData = $data; break; } } if (!$taskData) { echo self::error("Command not found: '{$taskName}'") . "\n\n"; self::help(null, null); return; } G::LoadThirdParty('pear/Console', 'Getopt'); $short = "h" . $taskData['opt']['short']; $long = array_merge(array("help"), $taskData['opt']['long']); $getopt = Console_GetOpt::getopt2($args, $short, $long); if (!is_array($getopt)) { echo self::error("Invalid options (" . $getopt->getMessage() . ")") . "\n\n"; self::help($taskName); return; } list($options, $arguments) = $getopt; foreach ($taskData['opt']['descriptions'] as $optName => $optDescription) { $short = str_replace(":", "", $optDescription['short']); $long = str_replace("=", "", $optDescription['long']); $validOpts[$short] = $optName; $validOpts[$long] = $optName; } $taskOpts = array(); try { foreach ($options as $opt) { list($optName, $optArg) = $opt; if ($optName === "h" || $optName === "--help") { self::help($taskName); return; } if (strpos($optName, '--') === 0) { $optName = substr($optName, 2); } if (!array_key_exists($optName, $validOpts)) { throw new Exception("option not found: {$optName}"); } if (array_key_exists($validOpts[$optName], $taskOpts)) { throw new Exception("'{$optName}' specified more then once"); } $taskOpts[$validOpts[$optName]] = $optArg; } } catch (Exception $e) { echo self::error("Invalid options: " . $e->getMessage()) . "\n\n"; self::help($taskName); return; } try { call_user_func($taskData['function'], $arguments, $taskOpts); } catch (Exception $e) { echo self::error("\n Error executing '{$taskName}':\n\n {$e->getMessage()}\n") . "\n"; } }
/** * @covers G::LoadThirdParty * @todo Implement testLoadThirdParty(). */ public function testLoadThirdParty() { G::LoadThirdParty('lime', 'lime'); $this->assertTrue(class_exists('lime_test')); }
/** * SysLogin */ public function sysLogin() { require_once "propel/Propel.php"; require_once "creole/Creole.php"; G::LoadClass('system'); G::LoadThirdParty("pake", "pakeColor.class"); Propel::init(PATH_CORE . "config/databases.php"); Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection'); // getting posibles errors passed by GET method $this->getInUrlError(); $availableWorkspace = $this->getWorkspacesAvailable(); $availableWorkspaceList = array(); foreach ($availableWorkspace as $ws) { $availableWorkspaceList[] = array($ws, $ws); } $aField['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG'); //Get Server Configuration G::LoadClass('serverConfiguration'); $oServerConf =& serverConf::getSingleton(); $availableLangArray = $this->getLanguagesList(); $this->includeExtJSLib('ux/virtualkeyboard'); $this->setJSVar('sysLang', SYS_LANG); $this->includeExtJS('main/sysLogin'); $this->setVar('logo_company', $this->getCompanyLogo()); $this->setVar('pmos_version', System::getVersion()); $footerText = 'Copyright © 2003-' . date('Y') . ' Colosa, Inc. All rights reserved.'; $adviseText = 'Supplied free of charge with no support, certification, warranty, maintenance nor indemnity by Colosa and its Certified Partners. '; $this->setVar('footer_text', $footerText); $this->setVar('advise_text', $adviseText); //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() if (($flyNotify = $this->getFlyNotify()) !== false) { $this->setJSVar('flyNotify', $flyNotify); } $this->setJSVar('languages', $availableLangArray); $this->setJSVar('workspaces', $availableWorkspaceList); $this->setJSVar('wsPrivate', $oServerConf->getProperty('LOGIN_NO_WS')); $this->setJSVar('defaultLang', 'en'); $this->setJSVar('defaultWS', ''); $loginScript = $this->getHeadPublisher()->getExtJsLibraries(); $loginScript .= $this->getHeadPublisher()->getExtJsScripts(); $this->setVar('login_script', $loginScript); $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript()); $this->setLayout('pm-modern-login'); $this->render(); }
/** * 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"); }
/** * for Test email configuration * @autor Alvaro <*****@*****.**> */ public function testConnection($params) { G::LoadClass('net'); G::LoadThirdParty('phpmailer', 'class.smtp'); if ($_POST['typeTest'] == 'MAIL') { define("SUCCESSFUL", 'SUCCESSFUL'); define("FAILED", 'FAILED'); $mail_to = $_POST['mail_to']; $send_test_mail = $_POST['send_test_mail']; $_POST['FROM_NAME'] = $mail_to; $_POST['FROM_EMAIL'] = $mail_to; $_POST['MESS_ENGINE'] = 'MAIL'; $_POST['MESS_SERVER'] = 'localhost'; $_POST['MESS_PORT'] = 25; $_POST['MESS_ACCOUNT'] = $mail_to; $_POST['MESS_PASSWORD'] = ''; $_POST['TO'] = $mail_to; $_POST['SMTPAuth'] = true; try { $resp = $this->sendTestMail(); } catch (Exception $error) { $resp = new stdclass(); $resp->status = false; $resp->msg = $error->getMessage(); } $response = array('success' => $resp->status); if ($resp->status == false) { $response['msg'] = G::LoadTranslation('ID_SENDMAIL_NOT_INSTALLED'); } echo G::json_encode($response); die; } $step = $_POST['step']; $server = $_POST['server']; $user = $_POST['user']; $passwd = $_POST['passwd']; $passwdHide = $_POST['passwdHide']; if (trim($passwdHide) != '') { $passwd = $passwdHide; $passwdHide = ''; } $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['passwd'] = $passwd; $port = $_POST['port']; $auth_required = $_POST['req_auth']; $UseSecureCon = $_POST['UseSecureCon']; $SendaTestMail = $_POST['SendaTestMail']; $Mailto = $_POST['eMailto']; $SMTPSecure = $_POST['UseSecureCon']; $Server = new NET($server); $smtp = new SMTP(); $timeout = 10; $hostinfo = array(); $srv = $_POST['server']; switch ($step) { case 1: $this->success = $Server->getErrno() == 0; $this->msg = $this->result ? 'success' : $Server->error; break; case 2: $Server->scannPort($port); $this->success = $Server->getErrno() == 0; //'Successfull'.$smtp->status; $this->msg = $this->result ? '' : $Server->error; break; case 3: //try to connect to host if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { $server = $hostinfo[1]; $port = $hostinfo[2]; } else { $host = $srv; } $tls = strtoupper($SMTPSecure) == 'tls'; $ssl = strtoupper($SMTPSecure) == 'ssl'; $this->success = $smtp->Connect(($ssl ? 'ssl://' : '') . $server, $port, $timeout); $this->msg = $this->result ? '' : $Server->error; break; case 4: //try login to host if ($auth_required == 'true') { try { if (preg_match('/^(.+):([0-9]+)$/', $srv, $hostinfo)) { $server = $hostinfo[1]; $port = $hostinfo[2]; } else { $server = $srv; } if (strtoupper($UseSecureCon) == 'TLS') { $tls = 'tls'; } if (strtoupper($UseSecureCon) == 'SSL') { $tls = 'ssl'; } $tls = strtoupper($UseSecureCon) == 'tls'; $ssl = strtoupper($UseSecureCon) == 'ssl'; $server = $_POST['server']; if (strtoupper($UseSecureCon) == 'SSL') { $resp = $smtp->Connect('ssl://' . $server, $port, $timeout); } else { $resp = $smtp->Connect($server, $port, $timeout); } if ($resp) { $hello = $_SERVER['SERVER_NAME']; $smtp->Hello($hello); if (strtoupper($UseSecureCon) == 'TLS') { $smtp->Hello($hello); } if ($smtp->Authenticate($user, $passwd)) { $this->success = true; } else { $this->success = false; $this->msg = $smtp->error['error']; } } else { $this->success = false; $this->msg = $smtp->error['error']; } } catch (Exception $e) { $this->success = false; $this->msg = $e->getMessage(); } } else { $this->success = true; $this->msg = 'No authentication required!'; } break; case 5: if ($SendaTestMail == 'true') { try { $_POST['FROM_NAME'] = 'Process Maker O.S. [Test mail]'; $_POST['FROM_EMAIL'] = $user; $_POST['MESS_ENGINE'] = 'PHPMAILER'; $_POST['MESS_SERVER'] = $server; $_POST['MESS_PORT'] = $port; $_POST['MESS_ACCOUNT'] = $user; $_POST['MESS_PASSWORD'] = $passwd; $_POST['TO'] = $Mailto; if ($auth_required == 'true') { $_POST['SMTPAuth'] = true; } else { $_POST['SMTPAuth'] = false; } if (strtolower($_POST["UseSecureCon"]) != "no") { $_POST["SMTPSecure"] = $_POST["UseSecureCon"]; } if ($_POST['UseSecureCon'] == 'ssl') { $_POST['MESS_SERVER'] = 'ssl://' . $_POST['MESS_SERVER']; } $resp = $this->sendTestMail(); if ($resp->status == '1') { $this->success = true; } else { $this->success = false; $this->msg = $smtp->error['error']; } } catch (Exception $e) { $this->success = false; $this->msg = $e->getMessage(); } } else { $this->success = true; $this->msg = 'jump this step'; } break; } }
function exportSkin($skinToExport = "") { G::LoadSystem('inputfilter'); $filter = new InputFilter(); try { if (!isset($_REQUEST['SKIN_FOLDER_ID'])) { throw new Exception(G::LoadTranslation('ID_SKIN_NAME_REQUIRED')); } $skinName = $_REQUEST['SKIN_FOLDER_ID']; $skinFolderBase = PATH_CUSTOM_SKINS . $skinName; $skinFolder = $skinFolderBase . PATH_SEP; $skinTar = PATH_CUSTOM_SKINS . $skinName . '.tar'; $skinTar = $filter->xssFilterHard($skinTar, 'path'); if (!is_dir($skinFolder)) { throw new Exception(G::LoadTranslation('ID_SKIN_DOESNT_EXIST')); } if (!file_exists($skinFolder . "config.xml")) { throw new Exception(G::LoadTranslation('ID_SKIN_CONFIGURATION_MISSING')); } if (file_exists($skinTar)) { //try to delete if (!unlink($skinTar)) { throw new Exception(G::LoadTranslation('ID_SKIN_FOLDER_PERMISSIONS')); } } //Try to generate tar file G::LoadThirdParty('pear/Archive', 'Tar'); $tar = new Archive_Tar($skinTar); $tar->_compress = false; addTarFolder($tar, $skinFolder, PATH_CUSTOM_SKINS); $response['success'] = true; $response['message'] = $skinTar; G::auditLog("ExportSkin", "Skin Name: " . $skinName); $response = $filter->xssFilterHard($response); print_r(G::json_encode($response)); } catch (Exception $e) { $response['success'] = false; $response['message'] = $e->getMessage(); $response = $filter->xssFilterHard($response); print_r(G::json_encode($response)); } }
/** * set_partner * * @return void */ public function setPartner() { $partnerFlag = (defined('PARTNER_FLAG')) ? PARTNER_FLAG : false; if ($partnerFlag) { // Execute sql for partner $pathMysqlPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'mysql' . PATH_SEP; if (G::verifyPath($pathMysqlPartner)) { $res = array(); $filesSlq = glob($pathMysqlPartner . '*.sql'); foreach ($filesSlq as $value) { $this->query_sql_file($value, $this->connection_database); } } // Execute to change of skin $pathSkinPartner = PATH_CORE . 'data' . PATH_SEP . 'partner' . PATH_SEP . 'skin' . PATH_SEP; if (G::verifyPath($pathSkinPartner)) { $res = array(); $fileTar = glob($pathSkinPartner . '*.tar'); foreach ($fileTar as $value) { $dataFile = pathinfo($value); $nameSkinTmp = $dataFile['filename']; G::LoadThirdParty( 'pear/Archive', 'Tar' ); $tar = new Archive_Tar( $value ); $pathSkinTmp = $pathSkinPartner . 'tmp' . PATH_SEP; G::rm_dir($pathSkinTmp); G::verifyPath($pathSkinTmp, true); chmod( $pathSkinTmp, 0777); $tar->extract($pathSkinTmp); $pathSkinName = $pathSkinTmp . $nameSkinTmp . PATH_SEP; chmod( $pathSkinName, 0777); G::verifyPath(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', true); $skinClassic = PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp' . PATH_SEP; if (is_dir($pathSkinName)) { $this->copyFile($pathSkinName, $skinClassic); } G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'base'); rename(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp', PATH_CORE . 'skinEngine' . PATH_SEP . 'base'); G::rm_dir(PATH_CORE . 'skinEngine' . PATH_SEP . 'tmp'); break; } } //ACTIVE ENTERPRISE ini_set('max_execution_time', '0'); ini_set('memory_limit', '256M'); $serv = 'http://'; if (isset($_SERVER['HTTPS']) && trim($_SERVER['HTTPS']) != '') { $serv = 'https://'; } $serv .= $_SERVER['SERVER_NAME']; if (isset($_SERVER['SERVER_PORT']) && trim($_SERVER['SERVER_PORT']) != '') { $serv .= ':' . $_SERVER['SERVER_PORT']; } // create session $cookiefile = sys_get_temp_dir() . PATH_SEP . 'curl-session'; $fp = fopen($cookiefile, "w"); fclose($fp); chmod($cookiefile, 0777); $user = urlencode($this->options['admin']['username']); $pass = urlencode($this->options['admin']['password']); $workspace = $this->options['name']; $lang = SYS_LANG; $skinName = SYS_SKIN; $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "$serv/sys{$workspace}/{$lang}/{$skinName}/login/authentication"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, "form[USR_USERNAME]=$user&form[USR_PASSWORD]=$pass&form[USER_LANG]=$lang"); curl_setopt($ch, CURLOPT_TIMEOUT, 90); $output = curl_exec($ch); curl_close($ch); $ch = curl_init(); $postData = array(); // resolv the plugin name $plugins = glob(PATH_CORE."plugins/*.tar"); if (count($plugins) > 0) { $pluginName = $plugins[0]; // File to upload/post $postData['form[PLUGIN_FILENAME]'] = "@{$pluginName}"; curl_setopt($ch, CURLOPT_URL, "$serv/sys{$workspace}/{$lang}/{$skinName}/setup/pluginsImportFile"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_TIMEOUT, 90); $output = curl_exec($ch); curl_close($ch); } } }
/** * 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; }
/** * It Renders content according to Part['Type'] * @author Fernando Ontiveros Lira <*****@*****.**> * * @param intPos = 0 * @return void * */ function RenderContent0($intPos = 0, $showXMLFormName = false) { global $G_FORM; global $G_TABLE; global $G_TMP_TARGET; global $G_OP_MENU; global $G_IMAGE_FILENAME; global $G_IMAGE_PARTS; global $_SESSION; //Changed from $HTTP_SESSION_VARS global $G_OBJGRAPH; //For graphLayout component $this->intPos = $intPos; $Part = $this->Parts[$intPos]; $this->publishType = $Part['Type']; switch ($this->publishType) { case 'externalContent': $G_CONTENT = new Content(); if ($Part['Content'] != "") { $G_CONTENT = G::LoadContent($Part['Content']); } G::LoadTemplateExternal($Part['Template']); break; case 'image': $G_IMAGE_FILENAME = $Part['File']; $G_IMAGE_PARTS = $Part['Data']; break; case 'appform': global $APP_FORM; $G_FORM = $APP_FORM; break; case 'xmlform': case 'dynaform': global $G_FORM; if ($Part['AbsolutePath']) { $sPath = $Part['AbsolutePath']; } else { if ($this->publishType == 'xmlform') { $sPath = PATH_XMLFORM; } else { $sPath = PATH_DYNAFORM; } } //if the xmlform file doesn't exists, then try with the plugins folders if (!is_file($sPath . $Part['File'] . '.xml')) { $aux = explode(PATH_SEP, $Part['File']); //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment if (count($aux) > 2) { //Subfolders $filename = array_pop($aux); $aux0 = implode(PATH_SEP, $aux); $aux = array(); $aux[0] = $aux0; $aux[1] = $filename; } if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($response = $oPluginRegistry->isRegisteredFolder($aux[0])) { if ($response !== true) { $sPath = PATH_PLUGINS . $response . PATH_SEP; } else { $sPath = PATH_PLUGINS; } } } } if (!class_exists($Part['Template']) || $Part['Template'] === 'xmlform') { $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, false); } else { eval('$G_FORM = new ' . $Part['Template'] . ' ( $Part[\'File\'] , "' . $sPath . '");'); } if ($this->publishType == 'dynaform' && ($Part['Template'] == 'xmlform' || $Part['Template'] == 'xmlform_preview')) { $dynaformShow = isset($G_FORM->printdynaform) && $G_FORM->printdynaform ? 'gulliver/dynaforms_OptionsPrint' : 'gulliver/dynaforms_Options'; $G_FORM->fields = G::array_merges(array('__DYNAFORM_OPTIONS' => new XmlForm_Field_XmlMenu(new Xml_Node('__DYNAFORM_OPTIONS', 'complete', '', array('type' => 'xmlmenu', 'xmlfile' => $dynaformShow)), SYS_LANG, PATH_XMLFORM, $G_FORM)), $G_FORM->fields); } //Needed to make ajax calls //The action in the form tag. if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->action = urlencode(G::encrypt($Part['Target'], URL_KEY)); } else { $G_FORM->action = $Part['Target']; } if (!(isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '')) { if ($this->publishType == 'dynaform') { $Part['ajaxServer'] = '../gulliver/defaultAjaxDynaform'; } else { $Part['ajaxServer'] = '../gulliver/defaultAjax'; } } if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } $G_FORM->setValues($Part['Data']); $G_FORM->setValues(array('G_FORM_ID' => $G_FORM->id)); //Asegurese de que no entre cuando $Part['Template']=="grid" //de hecho soo deberia usarse cuando $Part['Template']=="xmlform" if ($this->publishType == 'dynaform' && $Part['Template'] == "xmlform" || $Part['Template'] == "xmlform") { $G_FORM->values = G::array_merges(array('__DYNAFORM_OPTIONS' => isset($Part['Data']['__DYNAFORM_OPTIONS']) ? $Part['Data']['__DYNAFORM_OPTIONS'] : ''), $G_FORM->values); if (isset($G_FORM->nextstepsave)) { switch ($G_FORM->nextstepsave) { // this condition validates if the next step link is configured to Save and Go the next step or show a prompt case 'save': // Save and Next only if there are no required fields can submit the form. $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {document.getElementById("' . $G_FORM->id . '").submit();}return false;'; break; case 'prompt': // Show Prompt only if there are no required fields can submit the form. $G_FORM->values['__DYNAFORM_OPTIONS']['NEXT_ACTION'] = 'if (document.getElementById("' . $G_FORM->id . '")&&validateForm(document.getElementById(\'DynaformRequiredFields\').value)) {new leimnud.module.app.confirm().make({label:"@G::LoadTranslation(ID_DYNAFORM_SAVE_CHANGES)",action:function(){document.getElementById("' . $G_FORM->id . '").submit();}.extend(this),cancel:function(){window.location = getField("DYN_FORWARD").href;}.extend(this)});return false;} return false;'; break; } } } if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } // by default load the core template if ($Part['Template'] == 'xmlform_preview') { $Part['Template'] = 'xmlform'; } $template = PATH_CORE . 'templates/' . $Part['Template'] . '.html'; //erik: new feature, now templates such as xmlform.html can be personalized via skins if (defined('SYS_SKIN') && strtolower(SYS_SKIN) != 'classic') { // first, verify if the template exists on base skins path if (is_file(G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { $template = G::ExpandPath("skinEngine") . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; } else { if (is_file(PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html')) { $template = PATH_CUSTOM_SKINS . SYS_SKIN . PATH_SEP . $Part['Template'] . '.html'; } } } //end new feature if ($Part['Template'] == 'grid') { print '<form class="formDefault">'; } $scriptCode = ''; if ($this->localMode != '') { // @# las modification by erik in 09/06/2008 $G_FORM->mode = $this->localMode; } print $G_FORM->render($template, $scriptCode); if ($Part['Template'] == 'grid') { print '</form>'; } $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addScriptFile($G_FORM->scriptURL); $oHeadPublisher->addScriptCode($scriptCode); /** * We've implemented the conditional show hide fields.. * @author Erik A. Ortiz <*****@*****.**> * @date Fri Feb 19, 2009 */ if ($this->publishType == 'dynaform') { if (isset($_SESSION['CURRENT_DYN_UID'])) { require_once "classes/model/FieldCondition.php"; $oFieldCondition = new FieldCondition(); #This dynaform has show/hide field conditions $ConditionalShowHideRoutines = $oFieldCondition->getConditionScript($_SESSION['CURRENT_DYN_UID']); } } if (isset($ConditionalShowHideRoutines) && $ConditionalShowHideRoutines) { G::evalJScript($ConditionalShowHideRoutines); } break; case 'pagedtable': global $G_FORM; //if the xmlform file doesn't exists, then try with the plugins folders $sPath = PATH_XMLFORM; if (!is_file($sPath . $Part['File'])) { $aux = explode(PATH_SEP, $Part['File']); if (count($aux) == 2) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; } } } $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true); if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } $G_FORM->setValues($Part['Data']); if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } G::LoadSystem('pagedTable'); $oTable = new pagedTable(); $oTable->template = 'templates/' . $Part['Template'] . '.html'; $G_FORM->xmlform = ''; $G_FORM->xmlform->fileXml = $G_FORM->fileName; $G_FORM->xmlform->home = $G_FORM->home; $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; $G_FORM->values = array_merge($G_FORM->values, $Part['Data']); $oTable->setupFromXmlform($G_FORM); if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') { $oTable->ajaxServer = $Part['ajaxServer']; } /* Start Block: Load user configuration for the pagedTable */ G::LoadClass('configuration'); $objUID = $Part['File']; $conf = new Configurations(); $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', ''); $oTable->__OBJ_UID = $objUID; /* End Block */ /* Start Block: PagedTable Right Click */ G::LoadClass('popupMenu'); $pm = new popupMenu('gulliver/pagedTable_PopupMenu'); $pm->name = $oTable->id; $fields = array_keys($oTable->fields); foreach ($fields as $f) { switch (strtolower($oTable->fields[$f]['Type'])) { case 'javascript': case 'button': case 'private': case 'hidden': case 'cellmark': break; default: $label = $oTable->fields[$f]['Label'] != '' ? $oTable->fields[$f]['Label'] : $f; $label = str_replace("\n", ' ', $label); $pm->fields[$f] = new XmlForm_Field_popupOption(new Xml_Node($f, 'complete', '', array('label' => $label, 'type' => 'popupOption', 'launch' => $oTable->id . '.showHideField("' . $f . '")'))); $pm->values[$f] = ''; } } $sc = ''; $pm->values['PAGED_TABLE_ID'] = $oTable->id; print $pm->render(PATH_CORE . 'templates/popupMenu.html', $sc); /* End Block */ $oTable->renderTable(); /* Start Block: Load PagedTable Right Click */ print '<script type="text/javascript">'; print $sc; print 'loadPopupMenu_' . $oTable->id . '();'; print '</script>'; /* End Block */ break; case 'propeltable': global $G_FORM; //if the xmlform file doesn't exists, then try with the plugins folders if ($Part['AbsolutePath']) { $sPath = ''; } else { $sPath = PATH_XMLFORM; } if (!is_file($sPath . $Part['File'])) { $aux = explode(PATH_SEP, $Part['File']); //search in PLUGINS folder, probably the file is in plugin if (count($aux) == 2) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $sPath = PATH_PLUGINS; // . $aux[0] . PATH_SEP ; } } //search in PATH_DYNAFORM folder if (!is_file($sPath . PATH_SEP . $Part['File'] . '.xml')) { $sPath = PATH_DYNAFORM; } } //PATH_DATA_PUBLIC ??? if (!file_exists($sPath . PATH_SEP . $Part['File'] . '.xml') && defined('PATH_DATA_PUBLIC')) { $sPath = PATH_DATA_PUBLIC; } $G_FORM = new Form($Part['File'], $sPath, SYS_LANG, true); if (defined('ENABLE_ENCRYPT') && ENABLE_ENCRYPT == 'yes') { $G_FORM->ajaxServer = urlencode(G::encrypt($Part['ajaxServer'], URL_KEY)); } else { $G_FORM->ajaxServer = $Part['ajaxServer']; } if (isset($_SESSION)) { $_SESSION[$G_FORM->id] = $G_FORM->values; } G::LoadClass('propelTable'); $oTable = new propelTable(); $oTable->template = $Part['Template']; $oTable->criteria = $Part['Content']; if (isset($Part['ajaxServer']) && $Part['ajaxServer'] !== '') { $oTable->ajaxServer = $Part['ajaxServer']; } $G_FORM->xmlform->fileXml = $G_FORM->fileName; $G_FORM->xmlform->home = $G_FORM->home; $G_FORM->xmlform->tree->attribute = $G_FORM->tree->attributes; if (is_array($Part['Data'])) { $G_FORM->values = array_merge($G_FORM->values, $Part['Data']); } $oTable->setupFromXmlform($G_FORM); /* Start Block: Load user configuration for the pagedTable */ G::LoadClass('configuration'); $objUID = $Part['File']; $conf = new Configurations($oTable); $conf->loadConfig($oTable, 'pagedTable', $objUID, '', isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '', ''); $oTable->__OBJ_UID = $objUID; //$oTable->__OBJ_UID = ''; /* End Block */ /* Start Block: PagedTable Right Click */ G::LoadClass('popupMenu'); $pm = new popupMenu('gulliver/pagedTable_PopupMenu'); $sc = $pm->renderPopup($oTable->id, $oTable->fields); /* End Block */ //krumo ( $Part ); if ($this->ROWS_PER_PAGE) { $oTable->rowsPerPage = $this->ROWS_PER_PAGE; } try { if (is_array($Part['Data'])) { $oTable->renderTable('', $Part['Data']); } else { $oTable->renderTable(); } print $sc; } catch (Exception $e) { $aMessage['MESSAGE'] = $e->getMessage(); $this->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage); } break; case 'panel-init': global $mainPanelScript; global $panelName; global $tabCount; G::LoadThirdParty('pear/json', 'class.json'); $json = new Services_JSON(); $tabCount = 0; $panelName = $Part['Template']; $data = $Part['File']; if (!is_array($data)) { $data = array(); } $data = G::array_merges(array('title' => '', 'style' => array(), 'left' => 'getAbsoluteLeft(mycontent)', 'top' => 'getAbsoluteTop(mycontent)', 'width' => 700, 'height' => 600, 'drag' => true, 'close' => true, 'modal' => true, 'roll' => false, 'resize' => false, 'tabWidth' => 120, 'tabStep' => 3, 'blinkToFront' => true, 'tabSpace' => 10), $data); $mainPanelScript = 'var ' . $panelName . '={},' . $panelName . 'Tabs=[];' . 'leimnud.event.add(window,"load",function(){' . $panelName . ' = new leimnud.module.panel();' . 'var mycontent=document.getElementById("' . $this->publisherId . '[' . $intPos . ']");' . $panelName . '.options={' . 'size:{w:' . $data['width'] . ',h:' . $data['height'] . '},' . 'position:{x:' . $data['left'] . ',y:' . $data['top'] . '},' . 'title:"' . addcslashes($data['title'], '\\"') . '",' . 'theme:"processmaker",' . 'statusBar:true,' . 'headerBar:true,' . 'control:{' . ' close:' . ($data['close'] ? 'true' : 'false') . ',' . ' roll:' . ($data['roll'] ? 'true' : 'false') . ',' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' resize:' . ($data['resize'] ? 'true' : 'false') . '},' . 'fx:{' . ' drag:' . ($data['drag'] ? 'true' : 'false') . ',' . ' modal:' . ($data['modal'] ? 'true' : 'false') . ',' . ' blinkToFront:' . ($data['blinkToFront'] ? 'true' : 'false') . '}' . '};' . $panelName . '.setStyle=' . $json->encode($data['style']) . ';' . $panelName . '.tab={' . 'width:' . ($data['tabWidth'] + $data['tabSpace']) . ',' . 'optWidth:' . $data['tabWidth'] . ',' . 'step :' . $data['tabStep'] . ',' . 'options:[]' . '};'; print ' '; break; case 'panel-tab': global $tabCount; global $mainPanelScript; global $panelName; $onChange = $Part['Content']; $beforeChange = $Part['Data']; if (SYS_LANG == 'es') { $mainPanelScript = str_replace("120", "150", $mainPanelScript); } else { $mainPanelScript = str_replace("150", "120", $mainPanelScript); } $mainPanelScript .= $panelName . 'Tabs[' . $tabCount . ']=' . 'document.getElementById("' . $Part['File'] . '");' . $panelName . '.tab.options[' . $panelName . '.tab.options.length]=' . '{' . 'title :"' . addcslashes($Part['Template'], '\\"') . '",' . 'noClear :true,' . 'content :function(){' . ($beforeChange != '' ? 'if (typeof(' . $beforeChange . ')!=="undefined") {' . $beforeChange . '();}' : '') . $panelName . 'Clear();' . $panelName . 'Tabs[' . $tabCount . '].style.display="";' . ($onChange != '' ? 'if (typeof(' . $onChange . ')!=="undefined") {' . $onChange . '();}' : '') . '}.extend(' . $panelName . '),' . 'selected:' . ($tabCount == 0 ? 'true' : 'false') . '};'; $tabCount++; break; case 'panel-close': global $mainPanelScript; global $panelName; global $tabCount; $mainPanelScript .= $panelName . '.make();'; $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . '.addContent(' . $panelName . 'Tabs[r]);'; $mainPanelScript .= '});'; $mainPanelScript .= 'function ' . $panelName . 'Clear(){'; $mainPanelScript .= 'for(var r=0;r<' . $tabCount . ';r++)' . 'if (' . $panelName . 'Tabs[r])' . $panelName . 'Tabs[r].style.display="none";}'; $oHeadPublisher =& headPublisher::getSingleton(); $oHeadPublisher->addScriptCode($mainPanelScript); break; case 'blank': print ' '; break; case 'varform': global $G_FORM; $G_FORM = new Form(); G::LoadSystem("varform"); $xml = new varForm(); //$xml->parseFile ( ); $xml->renderForm($G_FORM, $Part['File']); $G_FORM->Values = $Part['Data']; $G_FORM->SetUp($Part['Target']); $G_FORM->width = 500; break; case 'table': $G_TMP_TARGET = $Part['Target']; $G_TABLE = G::LoadRawTable($Part['File'], $this->dbc, $Part['Data']); break; case 'menu': $G_TMP_TARGET = $Part['Target']; $G_OP_MENU = new Menu(); $G_OP_MENU->Load($Part['File']); break; case 'smarty': //To do: Please check it 26/06/07 $template = new Smarty(); $template->compile_dir = PATH_SMARTY_C; $template->cache_dir = PATH_SMARTY_CACHE; $template->config_dir = PATH_THIRDPARTY . 'smarty/configs'; $template->caching = false; $dataArray = $Part['Data']; // verify if there are templates folders registered, template and method folders are the same $folderTemplate = explode('/', $Part['Template']); $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($folderTemplate[0])) { $template->templateFile = PATH_PLUGINS . $Part['Template'] . '.html'; } else { $template->templateFile = PATH_TPL . $Part['Template'] . '.html'; } // last change to load the template, maybe absolute path was given if (!is_file($template->templateFile)) { $template->templateFile = strpos($Part['Template'], '.html') !== false ? $Part['Template'] : $Part['Template'] . '.html'; } //assign the variables and use the template $template $template->assign($dataArray); print $template->fetch($template->templateFile); break; case 'template': //To do: Please check it 26/06/07 if (gettype($Part['Data']) == 'array') { G::LoadSystem('template'); //template phpBB $template = new Template(); $template->set_filenames(array('body' => $Part['Template'] . '.html')); $dataArray = $Part['Data']; if (is_array($dataArray)) { foreach ($dataArray as $key => $val) { if (is_array($val)) { foreach ($val as $key_val => $val_array) { $template->assign_block_vars($key, $val_array); } } else { $template->assign_vars(array($key => $val)); } } } $template->pparse('body'); } if (gettype($Part['Data']) == 'object' && strtolower(get_class($Part['Data'])) == 'templatepower') { $Part['Data']->printToScreen(); } return; break; case 'view': case 'content': //check if G_PLUGIN_CLASS is defined, because publisher can be called without an environment $aux = explode(PATH_SEP, $Part['Template']); if (count($aux) == 2 && defined('G_PLUGIN_CLASS')) { //if the template doesn't exists, then try it with the plugins folders, after the normal Template $userTemplate = G::ExpandPath('templates') . $Part['Template']; $globalTemplate = PATH_TEMPLATE . $Part['Template']; if (!is_file($userTemplate) && !is_file($globalTemplate)) { $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->isRegisteredFolder($aux[0])) { $pluginTemplate = PATH_PLUGINS . $Part['Template'] . '.php'; include $pluginTemplate; } } } break; case 'graphLayout': //Added by JHL to render GraphLayout component $G_OBJGRAPH = $Part['Data']; $G_TMP_TARGET = $Part['Target']; $G_TMP_FILE = $Part['File']; break; } //krumo( $Part['Template'] ); //check if this LoadTemplate is used, byOnti 12th Aug 2008 G::LoadTemplate($Part['Template']); $G_TABLE = NULL; }
/** * Install a plugin archive. If pluginName is specified, the archive will * only be installed if it contains this plugin. * * @return bool true if enabled, false otherwise */ function installPluginArchive($filename, $pluginName) { G::LoadThirdParty("pear/Archive", "Tar"); $tar = new Archive_Tar($filename); $files = $tar->listContent(); $plugins = array(); $namePlugin = array(); foreach ($files as $f) { //if (preg_match("/^([\w\.]*).ini$/", $f["filename"], $matches)) { if (preg_match("/^(.*pluginConfig)\\.ini\$/", $f["filename"], $matches)) { $plugins[] = $matches[1]; } if (preg_match("/^.*({$pluginName})\\.php\$/", $f["filename"], $matches)) { $namePlugin[] = $matches[1]; } } if (count($plugins) > 1) { throw new Exception("Multiple plugins in one archive are not supported currently"); } //if (isset($pluginName) && !in_array($pluginName, $plugins)) { if (isset($pluginName) && !in_array($pluginName, $namePlugin)) { throw new Exception("Plugin '{$pluginName}' not found in archive"); } //$pluginName = $plugins[0]; $pluginFile = "{$pluginName}.php"; /* $oldPluginStatus = $this->getStatusPlugin($pluginFile); if ($pluginStatus != 0) { $oldDetails = $this->getPluginDetails($pluginFile); $oldVersion = $oldDetails->iVersion; } else { $oldDetails = NULL; $oldVersion = NULL; } */ //$pluginIni = $tar->extractInString("$pluginName.ini"); //$pluginConfig = parse_ini_string($pluginIni); /* 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')) { throw new Exception('This plugin needs "' . $aDependence['sClassName'] . '" plugin'); } } else { throw new Exception('This plugin needs "' . $aDependence['sClassName'] . '" plugin'); } } } unset($oClass); if ($fVersionOld > $fVersionNew) { throw new Exception('A recent version of this plugin was already installed.'); } */ $res = $tar->extract(PATH_PLUGINS); if (!file_exists(PATH_PLUGINS . $pluginFile)) { throw new Exception("File \"{$pluginFile}\" doesn't exist"); } require_once PATH_PLUGINS . $pluginFile; $details = $this->getPluginDetails($pluginFile); $this->installPlugin($details->sNamespace); $this->setupPlugins(); $this->enablePlugin($details->sNamespace); $this->save(); }
if (!isset($_FILES["form"]["error"]["PLUGIN_FILENAME"]) || $_FILES["form"]["error"]["PLUGIN_FILENAME"] == 1) { $str = "There was an error uploading the file, probably the file size if greater than upload_max_filesize parameter in php.ini, please check this parameter and try again."; throw new Exception($str); } //save the file if ($_FILES["form"]["error"]["PLUGIN_FILENAME"] == 0) { $filename = $_FILES["form"]["name"]["PLUGIN_FILENAME"]; $path = PATH_DOCUMENT . "input" . PATH_SEP; $tempName = $_FILES["form"]["tmp_name"]["PLUGIN_FILENAME"]; G::uploadFile($tempName, $path, $filename); } if (!$_FILES["form"]["type"]["PLUGIN_FILENAME"] == "application/octet-stream") { $str = "the uploaded files are invalid, expected \"application/octect-stream\" mime type file (" . $_FILES["form"]["type"]["PLUGIN_FILENAME"] . ")"; throw new Exception($str); } G::LoadThirdParty("pear/Archive", "Tar"); $tar = new Archive_Tar($path . $filename); $sFileName = substr($filename, 0, strrpos($filename, ".")); $sClassName = substr($filename, 0, strpos($filename, "-")); $aFiles = $tar->listContent(); $bMainFile = false; $bClassFile = false; if (is_array($aFiles)) { foreach ($aFiles as $key => $val) { if ($val["filename"] == $sClassName . ".php") { $bMainFile = true; } if ($val["filename"] == $sClassName . PATH_SEP . "class." . $sClassName . ".php") { $bClassFile = true; } }