Esempio n. 1
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;
 }
         //}
         $result["status"] = "OK";
     } catch (Exception $e) {
         $result["message"] = $e->getMessage();
         $status = 0;
     }
     if ($status == 0) {
         $result["status"] = "ERROR";
     }
     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";
Esempio n. 3
0
    $oHeadPublisher->assign("license_expires", $licenseManager->expireIn);
    $oHeadPublisher->assign("license_message", $licenseManager->status["message"]);
    $oHeadPublisher->assign("licensed", false);
} else {
    $oHeadPublisher->assign("license_user", "");
    $oHeadPublisher->assign("license_name", "<b>Unlicensed</b>");
    $oHeadPublisher->assign("license_server", "<b>no server</b>");
    $oHeadPublisher->assign("license_expires", "");
    $currentLicenseStatus = $licenseManager->getCurrentLicenseStatus();
    $oHeadPublisher->assign("license_message", $currentLicenseStatus["message"]);
    $oHeadPublisher->assign("license_start_date", "");
    $oHeadPublisher->assign("license_end_date", "");
    $oHeadPublisher->assign("license_span", "");
    $oHeadPublisher->assign("licensed", false);
}
$oHeadPublisher->assign("license_serial", isset($licenseManager->licenseSerial) ? $licenseManager->licenseSerial : '');
$oHeadPublisher->assign("SUPPORT_FLAG", isset($licenseManager->supportStartDate) && $licenseManager->supportStartDate == '' || !isset($licenseManager->supportStartDate) ? true : false);
$oHeadPublisher->assign("supportStartDate", isset($licenseManager->supportStartDate) ? $licenseManager->supportStartDate : '');
$oHeadPublisher->assign("supportEndDate", isset($licenseManager->supportEndDate) ? $licenseManager->supportEndDate : '');
G::LoadClass("system");
$oHeadPublisher->assign("PROCESSMAKER_VERSION", System::getVersion());
$oHeadPublisher->assign("PROCESSMAKER_URL", "/sys" . SYS_SYS . "/" . SYS_LANG . "/" . SYS_SKIN);
$oHeadPublisher->assign("SYS_SKIN", SYS_SKIN);
$oHeadPublisher->assign("URL_PART_LOGIN", substr(SYS_SKIN, 0, 2) == "ux" && SYS_SKIN != "uxs" ? "main/login" : "login/login");
$oHeadPublisher->assign("URL_PART_SETUP", EnterpriseUtils::getUrlPartSetup());
$oHeadPublisher->assign("PATH_PLUGINS_WRITABLE", is_writable(PATH_PLUGINS) ? 1 : 0);
$oHeadPublisher->assign("PATH_PLUGINS_WRITABLE_MESSAGE", "The directory " . PATH_PLUGINS . " have not writable.");
$oHeadPublisher->assign("SKIN_IS_UX", EnterpriseUtils::skinIsUx());
$oHeadPublisher->assign("INTERNET_CONNECTION", EnterpriseUtils::getInternetConnection());
$oHeadPublisher->addExtJsScript("enterprise/addonsStore", true);
G::RenderPage("publish", "extJs");