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;
}
 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;
 }