Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
     }
     break;
 case "available":
     $addonId = $_POST["addonId"];
     $response = array();
     $status = 1;
     try {
         if (EnterpriseUtils::getInternetConnection() == 0) {
             throw new Exception("Enterprise Plugins Manager no connected to internet.");
         }
         ///////
         $licenseManager =& pmLicenseManager::getSingleton();
         $server = $licenseManager->server;
         $workspace = isset($licenseManager->workspace) ? $licenseManager->workspace : 'pmLicenseSrv';
         $url = "http://{$server}/sys" . $workspace . "/en/green/services/rest";
         if (EnterpriseUtils::checkConnectivity($url) == false) {
             throw new Exception("Server \"{$server}\" not available.");
         }
         ///////
         $boundary = "---------------------" . substr(G::encryptOld(rand(0, 32000)), 0, 10);
         $data = null;
         $data = $data . "--{$boundary}\n";
         $data = $data . "Content-Disposition: form-data; name=\"action\"\n\n" . "requestToSales" . "\n";
         $data = $data . "--{$boundary}\n";
         $data = $data . "Content-Disposition: form-data; name=\"OBJ_NAME\"\n\n" . $addonId . "\n";
         $data = $data . "--{$boundary}\n";
         ///////
         //$licenseManager = &pmLicenseManager::getSingleton();
         $activeLicense = $licenseManager->getActiveLicense();
         $data = $data . "Content-Disposition: form-data; name=\"licenseFile\"; filename=\"" . $licenseManager->file . "\"\n";
         $data = $data . "Content-Type: text/plain\n";
Exemplo n.º 3
0
 /**
  * Update this store information from the store location.
  *
  * @return bool true if updated, false otherwise
  */
 public function update($force = false, $type = 'plugin')
 {
     require_once PATH_CORE . 'classes' . PATH_SEP . 'class.pmLicenseManager.php';
     if (!class_exists('AddonsManagerPeer')) {
         require_once 'classes/model/AddonsManager.php';
     }
     //If we have any addon that is installing or updating, don't update store
     $criteria = new Criteria(AddonsManagerPeer::DATABASE_NAME);
     $criteria->add(AddonsManagerPeer::ADDON_STATE, '', Criteria::NOT_EQUAL);
     $criteria->add(AddonsManagerPeer::ADDON_TYPE, $type);
     if (AddonsManagerPeer::doCount($criteria) > 0) {
         return false;
     }
     $this->clear($type);
     //Fill with local information
     //List all plugins installed
     $oPluginRegistry =& PMPluginRegistry::getSingleton();
     $aPluginsPP = array();
     if (file_exists(PATH_DATA_SITE . 'ee')) {
         $aPluginsPP = unserialize(trim(file_get_contents(PATH_DATA_SITE . 'ee')));
     }
     $pmLicenseManagerO =& pmLicenseManager::getSingleton();
     $localPlugins = array();
     if ($type == 'plugin') {
         foreach ($aPluginsPP as $aPlugin) {
             $sClassName = substr($aPlugin['sFilename'], 0, strpos($aPlugin['sFilename'], '-'));
             if (file_exists(PATH_PLUGINS . $sClassName . '.php')) {
                 require_once PATH_PLUGINS . $sClassName . '.php';
                 $oDetails = $oPluginRegistry->getPluginDetails($sClassName . '.php');
                 if ($oDetails) {
                     $sStatus = $oDetails->enabled ? G::LoadTranslation('ID_ENABLED') : G::LoadTranslation('ID_DISABLED');
                     if (isset($oDetails->aWorkspaces)) {
                         if (!in_array(SYS_SYS, $oDetails->aWorkspaces)) {
                             continue;
                         }
                     }
                     if ($sClassName == "pmLicenseManager" || $sClassName == "pmTrial") {
                         continue;
                     }
                     $sEdit = $oDetails->sSetupPage != '' && $oDetails->enabled ? G::LoadTranslation('ID_SETUP') : ' ';
                     $aPlugin = array();
                     $aPluginId = $sClassName;
                     $aPluginTitle = $oDetails->sFriendlyName;
                     $aPluginDescription = $oDetails->sDescription;
                     $aPluginVersion = $oDetails->iVersion;
                     if (@in_array($sClassName, $pmLicenseManagerO->features)) {
                         $aPluginStatus = $sStatus;
                         $aPluginLinkStatus = 'pluginsChange?id=' . $sClassName . '.php&status=' . $oDetails->enabled;
                         $aPluginEdit = $sEdit;
                         $aPluginLinkEdit = 'pluginsSetup?id=' . $sClassName . '.php';
                         $aPluginStatusA = $sStatus == "Enabled" ? "installed" : 'disabled';
                         $enabledStatus = true;
                     } else {
                         $aPluginStatus = "";
                         $aPluginLinkStatus = '';
                         $aPluginEdit = '';
                         $aPluginLinkEdit = '';
                         $aPluginStatusA = 'minus-circle';
                         $enabledStatus = false;
                     }
                     $addon = new AddonsManager();
                     //G::pr($addon);
                     $addon->setAddonId($aPluginId);
                     $addon->setStoreId($this->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName($aPluginId);
                     $addon->setAddonDescription($aPluginDescription);
                     $addon->setAddonNick($aPluginTitle);
                     $addon->setAddonVersion("");
                     $addon->setAddonStatus($aPluginStatusA);
                     $addon->setAddonType("plugin");
                     $addon->setAddonPublisher("Colosa");
                     $addon->setAddonDownloadUrl("");
                     $addon->setAddonDownloadMd5("");
                     $addon->setAddonReleaseDate(null);
                     $addon->setAddonReleaseType('localRegistry');
                     $addon->setAddonReleaseNotes("");
                     $addon->setAddonState("");
                     $addon->save();
                     $localPlugins[$aPluginId] = $addon;
                 }
             }
         }
     } else {
         $list = unserialize($pmLicenseManagerO->licensedfeaturesList);
         if (is_array($list)) {
             foreach ($list['addons'] as $key => $feature) {
                 $addon = new AddonsManager();
                 $addon->setAddonId($feature['name']);
                 $addon->setStoreId($feature['guid']);
                 $addon->setAddonName($feature['name']);
                 $addon->setAddonDescription($feature['description']);
                 $addon->setAddonNick($feature['nick']);
                 $addon->setAddonVersion("");
                 $addon->setAddonStatus($feature['status']);
                 $addon->setAddonType("features");
                 $addon->setAddonPublisher("Colosa");
                 $addon->setAddonDownloadUrl("");
                 $addon->setAddonDownloadMd5("");
                 $addon->setAddonReleaseDate(null);
                 $addon->setAddonReleaseType('localRegistry');
                 $addon->setAddonReleaseNotes("");
                 $addon->setAddonState("");
                 $addon->save();
             }
         }
     }
     $this->setStoreLastUpdated(time());
     $this->save();
     $url = $this->getStoreLocation();
     //Validate url
     $licenseInfo = $pmLicenseManagerO->getActiveLicense();
     $licenseId = str_replace('.dat', '', str_replace('license_', '', basename($licenseInfo['LICENSE_PATH'])));
     $url = explode('&', $url);
     $url[count($url) - 1] = 'licId=' . urlencode($licenseId);
     $url = implode('&', $url);
     if (EnterpriseUtils::getInternetConnection() == 1 && EnterpriseUtils::checkConnectivity($url) == true) {
         $option = array("http" => array("method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded\r\n", "content" => http_build_query(array("pmVersion" => System::getVersion(), "version" => STORE_VERSION))));
         // Proxy settings
         $sysConf = System::getSystemConfiguration();
         if (isset($sysConf['proxy_host'])) {
             if ($sysConf['proxy_host'] != '') {
                 if (!is_array($option['http'])) {
                     $option['http'] = array();
                 }
                 $option['http']['request_fulluri'] = true;
                 $option['http']['proxy'] = 'tcp://' . $sysConf['proxy_host'] . ($sysConf['proxy_port'] != '' ? ':' . $sysConf['proxy_port'] : '');
                 if ($sysConf['proxy_user'] != '') {
                     if (!isset($option['http']['header'])) {
                         $option['http']['header'] = '';
                     }
                     $option['http']['header'] .= 'Proxy-Authorization: Basic ' . base64_encode($sysConf['proxy_user'] . ($sysConf['proxy_pass'] != '' ? ':' . $sysConf['proxy_pass'] : ''));
                 }
             }
         }
         $context = stream_context_create($option);
         //This may block for a while, always use AJAX to call this method
         $url = $url . '&type=' . strtoupper($type);
         $data = file_get_contents($url, false, $context);
         if ($data === false) {
             throw new Exception("Could not contact store");
         }
         $serverData = G::json_decode($data);
         //Don't trust external data
         if (empty($serverData)) {
             throw new Exception("Store data invalid ('{$data}')");
         }
         if (isset($serverData->error)) {
             throw new Exception("Store sent us an error: {$serverData->error}");
         }
         if (!isset($serverData->version)) {
             throw new Exception("Store version not found");
         }
         if ($serverData->version != STORE_VERSION) {
             throw new Exception("Store version '{$serverData->version}' unsupported");
         }
         if (!isset($serverData->addons)) {
             throw new Exception("Addons not found on store data");
         }
         $this->clear($type);
         try {
             //Add each item to this stores addons
             $addons = @get_object_vars($serverData->addons);
             if (!empty($addons)) {
                 foreach (get_object_vars($serverData->addons) as $addonId => $addonInfo) {
                     $addon = new AddonsManager();
                     $addon->setAddonId($addonId);
                     $addon->setStoreId($this->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName(isset($addonInfo->name) ? $addonInfo->name : $addonId);
                     $addon->setAddonDescription(isset($addonInfo->description) ? $addonInfo->description : "");
                     $addon->setAddonNick(isset($addonInfo->nick) ? $addonInfo->nick : "");
                     $addon->setAddonVersion(isset($addonInfo->version) ? $addonInfo->version : "");
                     $addon->setAddonStatus(isset($addonInfo->status) ? $addonInfo->status : "");
                     $addon->setAddonType(isset($addonInfo->type) ? $addonInfo->type : "");
                     $addon->setAddonPublisher(isset($addonInfo->publisher) ? $addonInfo->publisher : "");
                     $workspace = isset($pmLicenseManagerO->workspace) ? $pmLicenseManagerO->workspace : 'pmLicenseSrv';
                     $addon->setAddonDownloadUrl(isset($addonInfo->download_url) ? $addonInfo->download_url : "http://" . $pmLicenseManagerO->server . "/sys" . $workspace . "/en/green/services/rest?action=getPlugin&OBJ_UID=" . $addonInfo->guid);
                     $addon->setAddonDownloadMd5(isset($addonInfo->download_md5) ? $addonInfo->download_md5 : "");
                     $addon->setAddonReleaseDate(isset($addonInfo->release_date) ? $addonInfo->release_date : "");
                     $addon->setAddonReleaseType(isset($addonInfo->release_type) ? $addonInfo->release_type : '');
                     $addon->setAddonReleaseNotes(isset($addonInfo->release_notes) ? $addonInfo->release_notes : "");
                     $addon->setAddonState("");
                     $addon->save();
                     if (isset($localPlugins[$addonId])) {
                         unset($localPlugins[$addonId]);
                     }
                 }
                 foreach ($localPlugins as $keyPlugin => $addonA) {
                     //G::pr($addonA );
                     //$addonA->save();
                     $addon = new AddonsManager();
                     //G::pr($addon);
                     $addon->setAddonId($addonA->getAddonId());
                     $addon->setStoreId($addonA->getStoreId());
                     //Don't trust external data
                     $addon->setAddonName($addonA->getAddonName());
                     $addon->setAddonDescription($addonA->getAddonDescription());
                     $addon->setAddonNick($addonA->getAddonNick());
                     $addon->setAddonVersion("");
                     $addon->setAddonStatus($addonA->getAddonStatus());
                     $addon->setAddonType($addonA->getAddonType());
                     $addon->setAddonPublisher($addonA->getAddonPublisher());
                     $addon->setAddonDownloadUrl($addonA->getAddonDownloadUrl());
                     $addon->setAddonDownloadMd5($addonA->getAddonDownloadMd5());
                     $addon->setAddonReleaseDate(null);
                     $addon->setAddonReleaseType('localRegistry');
                     $addon->setAddonReleaseNotes("");
                     $addon->setAddonState("");
                     $addon->save();
                 }
             }
             $this->setStoreLastUpdated(time());
             $this->save();
         } catch (Exception $e) {
             //If we had issues, don't keep only a part of the items
             $this->clear($type);
             throw $e;
         }
     }
     return true;
 }
 public function getExpireInLabel()
 {
     $linkText = null;
     if ($this->getExpireIn() != "NEVER" && (int) $this->getExpireIn() <= 30 && (int) $this->getExpireIn() > 0) {
         $infoO = $this->getLicenseInfo();
         $infoText = $infoO['infoText'];
         $js = EnterpriseUtils::skinIsUx() == 1 ? "Ext.MessageBox.show({title: '', msg: '{$infoText}', buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO});" : "msgBox('{$infoText}');";
         $linkText = $linkText . "<a href=\"javascript:;\" onclick=\"{$js} return (false);\"><span style=\"color: red;\">" . G::LoadTranslation('ID_EXPIRES_IN') . " " . $this->getExpireIn() . " " . G::LoadTranslation('ID_DAYS') . "</span></a>";
     } else {
         if ($this->getExpireIn() != "NEVER" && (int) $this->getExpireIn() <= 0) {
             $infoO = $this->getLicenseInfo();
             $infoText = $infoO['infoText'];
             $infoLabel = $infoO['infoLabel'];
             $js = EnterpriseUtils::skinIsUx() == 1 ? "Ext.MessageBox.show({title: '', msg: '{$infoText}', buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.INFO});" : "msgBox('{$infoText}');";
             $linkText = $linkText . "<a href=\"javascript:;\" onclick=\"{$js} return (false);\"><span style=\"color: red;\">" . $infoLabel . "</span></a>";
         }
     }
     if (class_exists('pmTrialPlugin')) {
         $linkText = $linkText . "<a href='/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/pmTrial/services/buyNow?n=true" . "'> <img align='absmiddle' src='/plugin/pmLicenseManager/btn_buy_now.gif' border='0' /></a>";
     }
     if (isset($_SESSION["__ENTERPRISE_SYSTEM_UPDATE__"]) && $_SESSION["__ENTERPRISE_SYSTEM_UPDATE__"] == 1) {
         $aOnclick = "onclick=\"this.href='" . EnterpriseUtils::getUrlServerName() . "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN . "/setup/main?s=PMENTERPRISE';\"";
         if (EnterpriseUtils::skinIsUx() == 1) {
             $aOnclick = "onclick=\"Ext.ComponentMgr.get('mainTabPanel').setActiveTab('pm-option-setup'); Ext.ComponentMgr.get('pm-option-setup').setLocation(Ext.ComponentMgr.get('pm-option-setup').defaultSrc + 's=PMENTERPRISE', true); return (false);\"";
         }
         $linkText = $linkText . ($linkText != null ? " | " : null) . "<a href=\"javascript:;\" {$aOnclick} style=\"color: #008000;\">" . G::LoadTranslation('ID_UPGRADE_SYSTEM') . "</a>";
     }
     $linkText = $linkText != null ? $linkText . (EnterpriseUtils::skinIsUx() == 1 ? null : " |") : null;
     return $linkText;
 }
Exemplo n.º 5
0
 public function enterpriseSystemUpdate($data)
 {
     if (count(glob(PATH_DATA_SITE . 'license/*.dat')) == 0) {
         return;
     }
     require_once "classes/model/Users.php";
     $user = $data;
     $criteria = new Criteria("workflow");
     //SELECT
     $criteria->addSelectColumn(UsersPeer::USR_UID);
     //FROM
     //WHERE
     $criteria->add(UsersPeer::USR_USERNAME, $user->lName);
     //$user->lPassword
     $criteria->add(UsersPeer::USR_ROLE, "PROCESSMAKER_ADMIN");
     //query
     $rsSQLUSR = UsersPeer::doSelectRS($criteria);
     $rsSQLUSR->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $sw = 0;
     if (UsersPeer::doCount($criteria) > 0) {
         //if ($rsSQLUSR->getRecordCount() > 0) {
         $sw = 1;
     }
     /*
     $cnn = Propel::getConnection("workflow");
     $stmt = $cnn->createStatement();
     
     $sql = "SELECT USR.USR_UID
             FROM   USERS AS USR
             WHERE  USR.USR_USERNAME = '******' AND USR.USR_ROLE = 'PROCESSMAKER_ADMIN'";
     $rsSQLUSR = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     
     $sw = 0;
     
     if ($rsSQLUSR->getRecordCount() > 0) {
         $sw = 1;
     }
     */
     if ($sw == 1) {
         //Upgrade available
         $swUpgrade = 0;
         $addonList = AddonsStore::addonList();
         $addon = $addonList["addons"];
         if (count($addon) > 0) {
             $status = array("ready", "upgrade", "available");
             $pmVersion = EnterpriseUtils::pmVersion(PM_VERSION);
             foreach ($addon as $index => $value) {
                 if ($addon[$index]["id"] == "processmaker") {
                     if (version_compare($pmVersion . "", EnterpriseUtils::pmVersion($addon[$index]["version"]) . "", "<")) {
                         $swUpgrade = 1;
                         break;
                     }
                 } else {
                     if (in_array($addon[$index]["status"], $status)) {
                         $swUpgrade = 1;
                         break;
                     }
                 }
             }
         }
         if ($swUpgrade == 1) {
             $_SESSION["__ENTERPRISE_SYSTEM_UPDATE__"] = 1;
         }
     }
 }
Exemplo n.º 6
0
    $oHeadPublisher->assign("license_expires", $licenseManager->expireIn);
    $oHeadPublisher->assign("license_message", $licenseManager->status["message"]);
    $oHeadPublisher->assign("licensed", false);
} else {
    $oHeadPublisher->assign("license_user", "");
    $oHeadPublisher->assign("license_name", "<b>Unlicensed</b>");
    $oHeadPublisher->assign("license_server", "<b>no server</b>");
    $oHeadPublisher->assign("license_expires", "");
    $currentLicenseStatus = $licenseManager->getCurrentLicenseStatus();
    $oHeadPublisher->assign("license_message", $currentLicenseStatus["message"]);
    $oHeadPublisher->assign("license_start_date", "");
    $oHeadPublisher->assign("license_end_date", "");
    $oHeadPublisher->assign("license_span", "");
    $oHeadPublisher->assign("licensed", false);
}
$oHeadPublisher->assign("license_serial", isset($licenseManager->licenseSerial) ? $licenseManager->licenseSerial : '');
$oHeadPublisher->assign("SUPPORT_FLAG", isset($licenseManager->supportStartDate) && $licenseManager->supportStartDate == '' || !isset($licenseManager->supportStartDate) ? true : false);
$oHeadPublisher->assign("supportStartDate", isset($licenseManager->supportStartDate) ? $licenseManager->supportStartDate : '');
$oHeadPublisher->assign("supportEndDate", isset($licenseManager->supportEndDate) ? $licenseManager->supportEndDate : '');
G::LoadClass("system");
$oHeadPublisher->assign("PROCESSMAKER_VERSION", System::getVersion());
$oHeadPublisher->assign("PROCESSMAKER_URL", "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN);
$oHeadPublisher->assign("SYS_SKIN", SYS_SKIN);
$oHeadPublisher->assign("URL_PART_LOGIN", substr(SYS_SKIN, 0, 2) == "ux" && SYS_SKIN != "uxs" ? "main/login" : "login/login");
$oHeadPublisher->assign("URL_PART_SETUP", EnterpriseUtils::getUrlPartSetup());
$oHeadPublisher->assign("PATH_PLUGINS_WRITABLE", is_writable(PATH_PLUGINS) ? 1 : 0);
$oHeadPublisher->assign("PATH_PLUGINS_WRITABLE_MESSAGE", "The directory " . PATH_PLUGINS . " have not writable.");
$oHeadPublisher->assign("SKIN_IS_UX", EnterpriseUtils::skinIsUx());
$oHeadPublisher->assign("INTERNET_CONNECTION", EnterpriseUtils::getInternetConnection());
$oHeadPublisher->addExtJsScript("enterprise/addonsStore", true);
G::RenderPage("publish", "extJs");
Exemplo n.º 7
0
 /**
  * Returns the currently installed version of this addon.
  *
  * @return string the installed version or an empty string otherwise.
  */
 public function getInstalledVersion()
 {
     if ($this->isCore()) {
         G::LoadClass("system");
         return EnterpriseUtils::pmVersion(System::getVersion());
     } else {
         if ($this->isPlugin()) {
             if (!$this->isInstalled()) {
                 return null;
             }
             $oPluginRegistry =& PMPluginRegistry::getSingleton();
             $details = $oPluginRegistry->getPluginDetails($this->getAddonName() . ".php");
             $v = !($details == null) ? $details->iVersion : null;
             if ($v != "") {
                 return $v;
             }
             if (file_exists(PATH_PLUGINS . $this->getAddonName() . PATH_SEP . "VERSION")) {
                 return trim(file_get_contents(PATH_PLUGINS . $this->getAddonName() . PATH_SEP . "VERSION"));
             }
         } else {
             if ($this->getAddonType() == "core") {
                 throw new Exception("Addon type \"" . $this->getAddonType() . "\" unsupported");
             }
         }
     }
 }