Commit a6518ac4 authored by RemyD's avatar RemyD

Update setup.php

parent 186c2080
<?php
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
require_once('lib/class.csti.php');
......@@ -9,153 +8,4 @@ $app->auth->check_module_permissions('hosted');
echo '<p>&nbsp;</p><p>&nbsp;</p><p class="frmTextHead" style="text-align:left;"><h3>Realease Notes :</h3><br> For a full detailled release notes, please go on the project page :<a href="'.$_SESSION['$_SITE_SOURCE'].'" target="_blank">'.$_SESSION['$_SITE_SOURCE'].' </a></p>';
// check if already installed before.
$v = new cstiConfig();
print_r($v->getVersion());
$ver= ($v->version);
$rev =($v->revision);
$sub = ($v->subversion);
if (CheckTable("hosted_Setup")== FALSE) {
echo "<p>Create SETUP table</p>";
$thisres = $v->CheckSetupTable(0);
foreach($thisres as $sql){
$app->db->query($sql);
}
echo "<p>Init app Table</p>";
$thisres = $v->CheckSetupTable(1);
foreach($thisres as $sql){
$app->db->query($sql);
}
// force Init
$_SESSION['MOD_HOSTED_VERSION']= 0;
$_SESSION['MOD_HOSTED_REVISION']= 0;
$_SESSION['MOD_HOSTED_SUBVERSION']=0;
$_SESSION['MOD_HOSTED_DEV_LEVEL']= 0;
} else {
// set the actual version of this app.
// echo "<p>Check version APP</p>";
$dbVer=$app->db->queryOneRecord("select AppVersion,AppRevision,AppSubversion,AppDevVersion from hosted_Setup order by id desc limit 1");
$_SESSION['MOD_HOSTED_VERSION']= $dbVer['AppVersion'];
$_SESSION['MOD_HOSTED_REVISION']= $dbVer['AppRevision'];
$_SESSION['MOD_HOSTED_SUBVERSION']=$dbVer['AppSubversion'];
$_SESSION['MOD_HOSTED_DEV_LEVEL']= $dbVer['AppDevVersion'];
}
$thisver =$_SESSION['MOD_HOSTED_VERSION'].'.'.$_SESSION['MOD_HOSTED_REVISION'].'.'.$_SESSION['MOD_HOSTED_SUBVERSION'].'-'.$_SESSION['MOD_HOSTED_DEV_LEVEL'];
$message='<br><br><h3> Version:';
$bad='<font color="RED">You need to update to the latest version (';
$ok='<font color="GREEN">You use the latest version (Online:';
// value 0 Not installed , 1 Need Update , 2 Need minor Update , 3 Uptodate
$update=0;
if ($_SESSION['MOD_HOSTED_VERSION']==0) {
// not installed
$update=0;
} else {
// installed
$update=1;
if ($rev <= $_SESSION['MOD_HOSTED_REVISION'])
{
if ($sub <= $_SESSION['MOD_HOSTED_SUBVERSION']) {
$message.= $ok.$ver.'.'.$rev.'.'.$sub.' - '.$thisver ;
$update=3;
} else {
$message.= $bad.$ver.'.'.$rev.'.'.$sub.'#'.$thisver;
$update=2;
}
} else {
$update=1;
$message.= $bad.$ver.'.'.$rev.'.'.$sub.'#'.$thisver;
}
}
echo $message.')</h3></FONT>';
//
if ($update==0) {
//need install
if (CheckTable("hosted")== FALSE) {
$thisArr = $v->CheckHostedable($update);
execSQL($thisArr, '<p><font color="GREEN">Installing and Updating hosted </font></p><br>');
unset($thisArr);
}
if (CheckTable("hosted_events")== FALSE) {
$thisArr = $v->CheckEventsTable($update);
execSQL($thisArr, '<p><font color="GREEN">Installing and Updating Events Table </font></p><br>');
unset($thisArr);
}
if (CheckTable("hosted_log")== FALSE) {
$thisArr = $v->CheckLogTable($update);
execSQL($thisArr, '<p><font color="GREEN">Installing and Updating Log Table </font></p><br>');
unset($thisArr);
}
if (CheckTable("hosted_snapshots")== FALSE) {
$thisArr = $v->CheckSnapshotTable($update);
execSQL($thisArr, '<p><font color="GREEN">Installing and Updating Snapshots Table </font></p><br>');
unset($thisArr);
}
$thisres = $v->CheckSetupTable(2);
execSQL($thisres,'<p><font color="GREEN"> Updating General application </font></p><br>');
unset($thisres);
} else if (($update==1) || ($update==2)) {
if ($update==1)
{
$mess='<p><font color="GREEN"> Major Updating (' .$update.')';
}
if ($update==2)
{
$mess='<p><font color="GREEN"> Minor Updating ('.$update.')';
}
////////////////////////////////////////
//// Need Update /////////////////
//////////////////////////////////////
$thisArr = $v->CheckHostedable($update);
execSQL($thisArr, $mess.' hosted </font></p><br>');
unset($thisArr);
$thisArr = $v->CheckEventsTable($update);
execSQL($thisArr, $mess.' Events </font></p><br>');
unset($thisArr);
$thisArr = $v->CheckLogTable($update);
execSQL($thisArr, $mess.' Log </font></p><br>');
unset($thisArr);
$thisArr = $v->CheckSnapshotTable($update);
execSQL($thisArr, $mess.' Snapshots </font></p><br>');
unset($thisArr);
$thisres = $v->CheckSetupTable(2);
execSQL($thisres,'<p><font color="GREEN"> Updating General application </font></p><br>');
unset($thisres);
} else {
echo "no update needed";
//header('Location: Statistics_list.php');
}
unset($v);
function execSQL($thisArr,$mess){
global $app;
$upsql="";
foreach ($thisArr as $upsql) {
if (strlen($upsql) >2) {
echo $mess;
echo "<br>". "$upsql" . "<br>";
$app->db->query($upsql);
}
}
}
function CheckTable($tableName){
global $app;
$is=$app->db->queryOneRecord("SHOW TABLES LIKE '".$tableName."'") ;
if ($is['Tables_in_dbispconfig ('.$tableName.')'] !=$tableName) {
return FALSE;
} else {
return TRUE;
}
}
// 1.4.5
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment