Update myDBR

Updating myDBR is a routine practice to ensure you have the latest bug fixes and new functionality. If your server has a connection to mydbr.com, an update notification is displayed when a new major version is available. It's recommended to run the updater promptly to keep your reports running smoothly.

Automatic updater using a web interface

The preferred method for updating myDBR is using the built-in automatic update feature. myDBR checks for new versions periodically and notifies the admin user on the main page. To update, go to Admin Tools -> About / Update -> Update now.... If your license has expired, and you cannot access the Admin Tools section, click on the myDBR logo in the top left corner to open the "About / Update" dialog.

During the automatic update, myDBR replaces the application and updates the reporting database with the latest changes, preserving all reports and user-specific modifications under the user directory (logos, settings, etc.).

The automatic updater uses HTTPS (443) and HTTP (80) ports for updates from the domain 'www.mydbr.com.'

If your server is behind a firewall and cannot contact the myDBR update server, enter the proxy settings in the Environment settings. Ensure that php_curl is installed if you encounter issues updating myDBR with the correct proxy settings.

Update between major PHP versions (SourceGuardian/ionCube change) / Manual update

A manual update must be applied if your server does not have a connection to mydbr.com (direct or through a proxy). A manual update is also required to update the PHP version so that the required SourceGuardian/ionCube loader changes (see myDBR download page). To perform a manual update, do the following:

  • Update the PHP extensions (SourceGuardian/ionCube and ChartDirector in your PHP installation)
  • Save the myDBR configuration by mydbr_config.php (contains the login information to the database)
  • Save /mydbr/user-directory (contains your customizations)
  • Download the myDBR zip package from https://mydbr.com/download
  • Replace the existing myDBR install with the new unzipped content of the zip package
  • Restore the saved mydbr_config.php and the /mydbr/user-directory
  • Access myDBR through the web server

myDBR will now see the updated application and guide the rest of the installation through the update wizard. All your reports will stay intact.

Scripting the automatic updater

The automatic updater can also be scripted.

To get the current version as JSON, run the following URL:

% curl "https://myserver.mydomain.com/mydbr/index.php?a=version&export=json"

The result for the version query will be:

{
  "version":"4.3.2",
  "build":"2534"
}

The version query URL also supports JSONP, so if your query type is JSONP and you add a callback parameter to the query:

% curl "https://myserver.mydomain.com/mydbr/index.php?a=version&export=jsonp&callback=mycallback"

The result for the version query will be:

mycallback(
{
  "version":"4.3.2",
  "build":"2534",
  "key":"bfb61ab9c7"
}
);

The key will be last the 10 characters of your license. You can use this in your script to verify that the server uses the latest license.

When the update URL (see example) is called, authentication is done using HTTP basic access authentication. myDBR defines, by default, the username 'mydbr_updater' to be used with scripted updates. This is defined in defaults.php and can be overridden in user/defaults.php.

To activate the username (mydbr_updater) to be used in scripts, the username must be added to myDBR users. Usernames defined as updater-usernames are limited to the update function only. They cannot be used as normal login users.

The update URL is called using basic access authentication (replace the myserver.mydomain.com/mydbr with your definition):

% curl -H "X-MYDBR-AUTH: 1" -u mydbr_updater:mydbr_updater_password "https://myserver.mydomain.com/mydbr/install/index.php?controller=update&action=update"

The result for the updater is a JSON object with the following fields:

If there is an error in the update process, an "error" entry will be added to the JSON object. The entry has an error message that caused the update to fail.

{
  "host":"myserver.mydomain.com",
  "expiration":"2015-12-22",
  "version": {
    "before_update":"4.3.2\/2534",
    "after_update":"4.4.0\/2697"
  }
}

The update URL also supports JSONP, so that you can use the call in a report's JavaScript. To use JSONP, include the 'callback'-parameter to the URL.

% curl -H "X-MYDBR-AUTH: 1" -u mydbr_updater:mydbr_updater_password "https://myserver.mydomain.com/mydbr/install/index.php?controller=update&action=update&callback=mycallback"
mycallback({
  "host":"myserver.mydomain.com",
  "expiration":"2015-12-22",
  "version": {
    "before_update":"4.3.2\/2534",
    "after_update":"4.4.0\/2697"
  }
});

Scripting the license installation

The most common way to install the license is to copy/paste the license into the license view. Suppose you have many installations. In that case, you should script the license installation to manage all licenses and all versions from a single server. You define one of the installations as a license server and manage other servers from this server. To get the licenses into the license server, you can copy/paste all purchased licenses at once. If you copy the licenses under the 'Copy all licenses'-link in myDBR Shop's order HTML page (https://shop.mydbr.com/index.php?a=order&a=order&id=XXX).

To define an installation as a license server (a server that will contain the latest license and serve those to other servers per request), set the server status to true in user/defaults.php and create a license server user into myDBR (by default, 'license_checker', can be overridden in the defaults)-

$mydbr_defaults['license_server']['is_server'] = true;

To let the client's server know the existence of the license server, add the following to the client's server's user/defaults.php (it can be the same for all clients).

$mydbr_defaults['license_server']['server_url'] = 'https://myserver.mydomain.com/mydbr';

To issue a license retrieval call to the client use syntax:

% curl -H "X-MYDBR-AUTH: 1" -u license_checker:license_checker_password "https://myclient.mydomain.com/mydbr/index.php?a=license_service&update=1"

When the call is successful, the response will be:

{"status":"ok"}

If there is a problem with the call, the response will look like this:

{"success":"error" errors = {"array of errors"}}

Again, this URL supports JSONP with the additional 'callback' parameter to the URL.

Managing a large number of installations

When managing a large number of installations, you can automate the license installing and upgrading process. You can use a scheduled report in clients to ask for new licenses and script the updates. Alternatively, you can use a report to manage license distribution and server updates.

Automating license distribution

A sample report running is on a defined license server. It fetches the version and license information from the client's servers and allows remote license distribution and version updates. With the report, you can handle a large number of servers from one interface without needing to log in to individual servers.

Preparation

  1. Add user mydbr_updater and license_checker to client's server as normal myDBR users (defaults names defined in $mydbr_defaults['updater_users] and in $mydbr_defaults['license_users])
  2. Add user license_checker to license server as normal myDBR users (defined in client servers $mydbr_defaults['license_server']['username'] and $mydbr_defaults['license_server']['password'])
  3. Add url to license server for each client ($mydbr_defaults['license_server']['server_url'])
  4. Define the license server by adding $mydbr_defaults['license_server']['is_server'] = true; to user/defaults.php
  5. Copy all the licenses to the license server's licenses functionality
  6. Add the report below to the license server

What happens during the update:

  1. Make sure the update server is running the latest version and build
  2. The server calls the client to obtain information about the version/build and the used license. It will compare this with its own info.
  3. The user clicks for the version update.
  4. The Update server calls the client server's update process using JSONP and authenticates with Basic Access Authentication (BA). The username and password are in the report's JavaScript script.
  5. The client checks that the update call's BA username using BA belongs to the update user's group $mydbr_defaults['updater_users']
  6. The client performs the update and returns version numbers before and after the update to the update server

What happens during the license update:

  1. Ensure that the client's new license is installed in the server's licenses.
  2. Make sure that the license server has myDBR local user $mydbr_defaults['license_server']['username'] defined with the password used in the script or defined in $mydbr_defaults['license_server']['password']
  3. Make sure that the client's server has myDBR local user defined in $mydbr_defaults['license_users], and that is the one that the script uses
  4. The server calls the client to obtain information about the version/build and the used license. It will compare this with its own info.
  5. The user clicks for the license update.
  6. The license server calls the client's server's license update process authenticating with Basic Access Authentication (BA). The username and the password are in the report's JavaScript script
  7. The client's server calls back to the license server to obtain the license. The call is made using BA and with a username defined in $mydbr_defaults['license_server']['username'] and $mydbr_defaults['license_server']['password']. If no password is defined, the client's server uses the same password as the license server to initiate the call.
  8. The client installs the new license and returns the success info to the server.
create procedure sp_DBR_update_license(
inVersionBuild varchar(20)
)
begin

select 'dbr.css', '
.license_status {
text-align: center;
}
.license_update, .version_update {
cursor: pointer;
background-color: green;
padding: 3px 6px 3px 6px;
border-radius: 6px;
color: white;
}
.red {
background-color: red;
}
.version {
text-align:center;
}
.version .ajaxspin {
margin: auto;
}
';

select 'dbr.colclass', 'host', 'host';
select 'dbr.colclass', 'license_status', 'license_status';
select 'dbr.colclass', 'version', 'version';
select 'dbr.colclass', 'errors', 'errors';
select 'dbr.html5data', 'host', 'license_key', 'license-key';
select 'dbr.html5data', 'host', 'license_host', 'license-host';
select 'dbr.html5data', 'version', 'version_build', 'version';

select 
  concat('https://', host) as 'Installation URL[host]', 
  l.host as 'license_host',
  l.license_key,
  '' as 'Version[version]',
  '' as 'License OK[license_status]',
  inVersionBuild as 'version_build',
  '' as '[errors]'
from mydbr_licenses l
where host != 'mylicenseserver.mydomain.com';

select 'dbr.javascript',
"$(document).ready(function() {
  // Get installed versions and last 10 characters from the installed license
  $('.host').each( function() {
    var $tr = $(this).closest('tr'),
    url = $(this).text()+'/index.php?a=version&export=jsonp&callback=?';
    $.ajax({
      url: url,
      dataType: 'jsonp',
      success: function(v) {
        // Query returns 10 last characters from the license. Enough for the matching
        var $v, vb, key_ok = (v.key == $tr.find('.host').attr('data-license-key').substr(-10));
        $v = $tr.find('.version');
        vb = v.version+'/'+v.build;
        if ($v.data('version') !== vb) {
          $v.html('<span class=\"version_update\">'+vb+'</span>');
        } else {
          $v.text(v.version+'/'+v.build);
        }
        if (key_ok) {
          $tr.find('.license_status').text('OK');
        } else {
          $tr.find('.license_status').html('<span class=\"license_update\">Newer license available</span>');
        }
      },
      error: function(e, status, error) {
        $tr.find('.version').text('Unknown');
        $tr.find('.errors').text(e.status+'/'+error);
      }
    });
  });

  // Ask the installation to update the license from the license server
  $(document).on('click', '.license_update', function() {
    var url, $tr = $(this).closest('tr');
    url=$tr.find('.host').text()+'/index.php?a=license_service&update=1&callback=?';
    $.ajax({
      url: url,
      beforeSend: function(xhr) {
        xhr.withCredentials = true;
        xhr.setRequestHeader('X-MYDBR-AUTH', '1');
        xhr.setRequestHeader('Authorization', 'Basic ' + btoa('license_checker:pass'));
      },
      dataType: 'jsonp',
      success: function(r) {
        var i,e='';
        if (r.status=='ok') {
          $tr.find('.license_status').text('OK');
        } else {
          $tr.find('.license_status .license_update').addClass('red');
          for(i=0; i<r.errors.length; i++){
            e += '<div>'+r.errors[i]+'</div>';
          }
          $tr.find('.errors').html(e);
        }
      },
      error: function(e, status, error) {
        $tr.find('.errors').text(e.status+'/'+error);
      }

    });
  });

  // Ask the installation to run the updater
  $(document).on('click', '.version_update', function() {
    if (confirm('Update version?')) {
      var url, $tr = $(this).closest('tr'), $v = $tr.find('.version');
      url=$tr.find('.host').text()+'/install/index.php?controller=update&action=update&callback=?';
      $v.html('<div class=\"ajaxspin\"></div>');
      $.ajax({
        url: url,
        beforeSend: function(xhr) {
          xhr.withCredentials = true;
          xhr.setRequestHeader('X-MYDBR-AUTH', '1');
          xhr.setRequestHeader('Authorization', 'Basic ' + btoa('mydbr_updater:pass'));
        },
        dataType: 'jsonp',
        success: function(r) {
          if (r.error) {
            $v.text(r.error);
          } else {
            if (r.version.after_update) {
              $v.text(r.version.after_update);
            } else {
              $v.text('Unknown error');
            }
          }
        },
        error: function(e, status, error) {
          $tr.find('.errors').text(e.status+'/'+error);
        }
      });
    }
  });

});
";
end