/** * This function is the constructor of the PMLicensedFeatures class * param * * @return void */ public function __construct() { $criteria = new Criteria(); $criteria->addAscendingOrderByColumn(AddonsManagerPeer::ADDON_ID); $criteria->add(AddonsManagerPeer::ADDON_TYPE, 'feature', Criteria::EQUAL); $addons = AddonsManagerPeer::doSelect($criteria); foreach ($addons as $addon) { $this->features[] = $addon->getAddonId(); $detail = new featuresDetail($addon->getAddonNick(), $addon->getAddonDescription()); $this->featuresDetails[$addon->getAddonId()] = $detail; } }
*/ $task = str_replace("\"", null, $task); $data = explode(" ", $task); $elem = array_shift($data); //delete first element run_addon_core_install($data); } try { if (isset($_REQUEST["action"])) { $action = $_REQUEST["action"]; } else { throw new Exception("Action undefined"); } if (isset($_REQUEST['addon']) && isset($_REQUEST['store'])) { require_once PATH_CORE . 'classes/model/AddonsManagerPeer.php'; $addon = AddonsManagerPeer::retrieveByPK($_REQUEST['addon'], $_REQUEST['store']); $addonId = $_REQUEST['addon']; $storeId = $_REQUEST['store']; if ($addon === null) { throw new Exception("Unable to find addon (id: '{$_REQUEST['addon']}', store: '{$_REQUEST['store']}')"); } } else { $addon = null; } $result = array(); switch (strtolower($action)) { case "importlicense": if (sizeof($_FILES) > 0) { $aInfoLoadFile = $_FILES["upLicense"]; $aExtentionFile = explode(".", $aInfoLoadFile["name"]); //validating the extention before to upload it
/** * 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; }
function run_addon_core_install($args) { try { if (!extension_loaded("mysql")) { if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN") { dl("mysql.dll"); } else { dl("mysql.so"); } } /////// /* if (!CLI2) { $args = $opts; } */ $workspace = $args[0]; $storeId = $args[1]; $addonName = $args[2]; if (!defined("SYS_SYS")) { define("SYS_SYS", $workspace); } if (!defined("PATH_DATA_SITE")) { define("PATH_DATA_SITE", PATH_DATA . "sites/" . SYS_SYS . "/"); } if (!defined("DB_ADAPTER")) { define("DB_ADAPTER", $args[3]); } /////// //***************** Plugins ************************** G::LoadClass("plugin"); //Here we are loading all plugins registered //the singleton has a list of enabled plugins $sSerializedFile = PATH_DATA_SITE . "plugin.singleton"; $oPluginRegistry =& PMPluginRegistry::getSingleton(); if (file_exists($sSerializedFile)) { $oPluginRegistry->unSerializeInstance(file_get_contents($sSerializedFile)); } /////// //echo "** Installation starting... (workspace: $workspace, store: $storeId, id: $addonName)\n"; $ws = new workspaceTools($workspace); $ws->initPropel(false); require_once PATH_CORE . 'methods' . PATH_SEP . 'enterprise' . PATH_SEP . 'enterprise.php'; require_once PATH_CORE . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'AddonsManagerPeer.php'; $addon = AddonsManagerPeer::retrieveByPK($addonName, $storeId); if ($addon == null) { throw new Exception("Id {$addonName} not found in store {$storeId}"); } //echo "Downloading...\n"; $download = $addon->download(); //echo "Installing...\n"; $addon->install(); if ($addon->isCore()) { $ws = new workspaceTools($workspace); $ws->initPropel(false); $addon->setState("install-finish"); } else { $addon->setState(); } } catch (Exception $e) { $addon->setState("error"); //fwrite(STDERR, "\n[ERROR: {$e->getMessage()}]\n"); //fwrite(STDOUT, "\n[ERROR: {$e->getMessage()}]\n"); } //echo "** Installation finished\n"; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = AddonsManagerPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setAddonId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setStoreId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setAddonName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setAddonNick($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setAddonDownloadFilename($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setAddonDescription($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setAddonState($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setAddonStateChanged($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setAddonStatus($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setAddonVersion($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setAddonType($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setAddonPublisher($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setAddonReleaseDate($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setAddonReleaseType($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setAddonReleaseNotes($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setAddonDownloadUrl($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setAddonDownloadProgress($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setAddonDownloadMd5($arr[$keys[17]]); } }
/** * Retrieve object using using composite pkey values. * * @param string $addon_id * @param string $store_id * * @param Connection $con * @return AddonsManager */ public static function retrieveByPK($addon_id, $store_id, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(); $criteria->add(AddonsManagerPeer::ADDON_ID, $addon_id); $criteria->add(AddonsManagerPeer::STORE_ID, $store_id); $v = AddonsManagerPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }