Пример #1
0
 /**
  * Check to see the installed version is up to date or not
  *
  * @return int 0 : error, 1 : Up to date, 2 : outof date
  */
 function check_update()
 {
     $installedVersion = OSMembershipHelper::getInstalledVersion();
     $result = array();
     $result['status'] = 0;
     if (function_exists('curl_init')) {
         $url = 'http://joomdonationdemo.com/versions/membershippro.txt';
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $latestVersion = curl_exec($ch);
         curl_close($ch);
         if ($latestVersion) {
             if (version_compare($latestVersion, $installedVersion, 'gt')) {
                 $result['status'] = 2;
                 $result['message'] = JText::sprintf('OSM_UPDATE_CHECKING_UPDATEFOUND', $latestVersion);
             } else {
                 $result['status'] = 1;
                 $result['message'] = JText::_('OSM_UPDATE_CHECKING_UPTODATE');
             }
         }
     }
     echo json_encode($result);
     JFactory::getApplication()->close();
 }