Table of Contents
Updates
Updates help us and you keep your copy up-to-date. With updates, new features and other improvements are added to the script. Within a single update there can be different builds with minor fixes. The update and build number is written at the end of each page.
How to run update
Click Maintenance - Update in the admin panel or run in the shell
cd your_path_to/scj/admin/ php update.php
and the script will be updated to the current version
TCMS (Smartcj 2.X) Updates
SmartCJ v 1.X Updates
In version 1 each update had to be installed sequentially
cd your_path_to/scj/admin/ php update.php update_number for example if you are on 49 and need to reach 52 php update.php 50 php update.php 51 php update.php 52
- Base command to run all updates. It will update your script to the latest version
cd /path_to_scj/admin; env HTTP_HOST=yourdomain.com php update.php
How to run a specific update
cd /path_to_scj/admin; env HTTP_HOST=yourdomain.com php update.php update_number for example cd /home/vasya/domain.com/scj/admin; env HTTP_HOST=domain.com php update.php 45
update.php source code
<?php
require('../includes/prepare.php');
require('../includes/libs/http_functions.php');
// out of space fix
$df = disk_free_space("./");
if ($df < 5*1024*1024) {
die("No enough space for update");
}
// slow connection fix
$mysql_version = db_value('ver', 'select version() as ver');
if (stristr($d['ver'], '5.')) {
db_query("set wait_timeout=240");
}
if ($argv[1] != '') {
$num = (int) $argv[1];
if ($num > 0) {
ProcessUpdate($num);
exit;
}
}
$tmp = get_url("http://smartcj.com/smartnews.php?action=last_update");
if ($tmp['status'] != 200) {
die("Can not get last update number, please, contact support");
}
$last_script_version = $tmp['body'];
if ($last_script_version == $settings['last_update_number'] and !$_REQUEST['force_update']) die("You have the lastest version.");
while ($settings['last_update_number'] < $last_script_version) {
echo "Processing " . ($settings['last_update_number']+1) . "\n";
if (ProcessUpdate($settings['last_update_number']+1)) {
$settings['last_update_number']++;
}
}
function ProcessUpdate($update_id) {
global $settings;
$tmp = get_url("http://smartcj.com/updates/".(int)$update_id."/update.txt");
if ($tmp['status'] != 200) {
echo "Sorry, can not find update {$update_id}";
return false;
}
$_REQUEST['terms_read'] = true;
ob_start();
eval ('?>' . $tmp['body']);
$res = ob_get_clean();
$res = str_replace('<br>', "\n", $res);
echo strip_tags($res);
return true;
}
How to update all domains at once
You can create a file, for example update.sh, which contains lines like this:
cd /path_to_domain/scj/admin; env HTTP_HOST=yourdomain.com php update.php cd /path_to_domain2/scj/admin; env HTTP_HOST=yourdomain2.com php update.php
and so on for as many lines as needed. And run it from the shell
sh update.sh
During installation and update, the script does not write index.php or any files to the domain root, so as not to accidentally overwrite anything you have there. Accordingly, during updates, the question arises of copying the Smart index if it is used on the domain root. There are 2 options:
- add lines like cp ../cgi/index.php ../../index.php to update.sh
- or at installation time, do not copy the index, but make a symlink to the corresponding directory.
How to rollback an update
The only way is if you have a backup from the version you need.
You need to install the script of that version and upload the backup of the MySQL database from the same version.
You cannot just upload a backup of MySQL from version 44 to version 45 script for example.
How to update a site with a very large database
Update can be a fairly heavy procedure for the server, and some pages may be incorrectly cached, etc. Some services, for example in case of a major update release, usually do this at night and close the site, showing a standard message that the service will be available in a few hours. But if you don't want to interrupt operations, you can do it as follows. To do this you need to
- Install the script on another (sub)domain, ideally on a different server
- Upload the database from the main domain there
- Run the update on this separate subdomain
- All heavy database procedures will run there, while the main site remains unaffected
- Transfer the database from the auxiliary domain to the main one
- Perform the update on the main - it will go quickly as the database is already changed, you only need to download the files.
