OXID eShop CE  4.10.6
 All Classes Namespaces Files Functions Variables Pages
shop_license.php
Go to the documentation of this file.
1 <?php
2 
8 class Shop_License extends Shop_Config
9 {
10 
16  protected $_sThisTemplate = "shop_license.tpl";
17 
18 
26  protected $_aVersionCheckLinks = array(
27  "EE" => "http://admin.oxid-esales.com/EE/onlinecheck.php",
28  "PE" => "http://admin.oxid-esales.com/PE/onlinecheck.php",
29  "CE" => "http://admin.oxid-esales.com/CE/onlinecheck.php"
30  );
31 
32 
39  public function render()
40  {
41  $myConfig = $this->getConfig();
42  if ($myConfig->isDemoShop()) {
44  $oSystemComponentException = oxNew("oxSystemComponentException", "license");
45  throw $oSystemComponentException;
46  }
47 
49 
50  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
51  if ($soxId != "-1" && isset($soxId)) {
52  // load object
53  $oShop = oxNew("oxshop");
54  $oShop->load($soxId);
55  $this->_aViewData["edit"] = $oShop;
56  }
57 
58  $this->_aViewData["version"] = $myConfig->getVersion();
59 
60 
61  $this->_aViewData['aCurVersionInfo'] = $this->_fetchCurVersionInfo($this->_aVersionCheckLinks["CE"]);
62 
63  if (!$this->_canUpdate()) {
64  $this->_aViewData['readonly'] = true;
65  }
66 
67  return $this->_sThisTemplate;
68  }
69 
70 
76  protected function _canUpdate()
77  {
78  $myConfig = $this->getConfig();
79 
80  $blIsMallAdmin = oxRegistry::getSession()->getVariable('malladmin');
81  if (!$blIsMallAdmin) {
82  return false;
83  }
84 
85  if ($myConfig->isDemoShop()) {
86  return false;
87  }
88 
89  return true;
90  }
91 
99  protected function _fetchCurVersionInfo($sUrl)
100  {
101  $aParams = array("myversion" => $this->getConfig()->getVersion());
102  $oLang = oxRegistry::getLang();
103  $iLang = $oLang->getTplLanguage();
104  $sLang = $oLang->getLanguageAbbr($iLang);
105 
106  $oCurl = oxNew('oxCurl');
107  $oCurl->setMethod("POST");
108  $oCurl->setUrl($sUrl . "/" . $sLang);
109  $oCurl->setParameters($aParams);
110  $sOutput = $oCurl->execute();
111 
112  $sOutput = strip_tags($sOutput, "<br>, <b>");
113  $aResult = explode("<br>", $sOutput);
114  if (strstr($aResult[5], "update")) {
115  $sUpdateLink = 'http://oxidforge.org/en/downloads-en';
116  $aResult[5] = "<a id='linkToUpdate' href='$sUpdateLink' target='_blank'>" . $aResult[5] . "</a>";
117  }
118  $sOutput = implode("<br>", $aResult);
119 
120  return $sOutput;
121  }
122 }