Skip to content

Commit

Permalink
new methode to update ocsreports
Browse files Browse the repository at this point in the history
  • Loading branch information
airoine committed Aug 1, 2014
1 parent 7fa1987 commit 54d6d3c
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 14 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Revision history for ocsreports
* Migrate menus, urls and js config to XML files
* Add new menu for computer sections
* Add new menu for main sections
* Add update methode

2.1.1
* fix https://bugs.launchpad.net/ocsinventory-ocsreports/+bug/1283089
Expand Down
18 changes: 18 additions & 0 deletions files/update/7006.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE battery (
`ID` int(11) not null AUTO_INCREMENT,
`HARDWARE_ID` int(11),
`LOCATION` varchar(255) default null,
`MANUFACTURER` varchar(255) default null,
`MANUFACTURER_DATE` varchar(10) default null,
`SERIALNUMBER` varchar(255) default null,
`NAME` varchar(255) default null,
`CHEMISTRY` varchar(20) default null,
`DESIGNCAPACITY` varchar(10) default null,
`DESIGNVOLTAGE` varchar(20) default null,
`SBDSVERSION` varchar(255) default null,
`MAXERROR` int(10) default null,
`OEMSPECIFIC` varchar(255) default null,
PRIMARY KEY (`ID`,`HARDWARE_ID`),
key `NAME` (`NAME`),
key `MANUFACTURER` (`MANUFACTURER`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
6 changes: 6 additions & 0 deletions plugins/language/english/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <
2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable


5000 [DEBUG]computers insertions request =>[DEBUG]
Expand Down
6 changes: 6 additions & 0 deletions plugins/language/french/french.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,12 @@
2104 VOUS ETES SUR LA VERSION DE DEMO LA
2105 Votre base de données est à jour.<br>Aucune action a effectuer.
2106 La configuration max_allowed_packet de MySQL n'autorise que des fichiers de <
2107 La version de votre interface WEB est inférieur à la version de la base de données
2108 La version de la base de données doit <b>OBLIGATOIREMENT</b> être inférieure ou égale à la version de l'interface WEB
2109 Version actuelle
2110 Version attendue
2111 Effectuer la mise à jour
2112 Le fichier suivant n'est pas présent ou n'est pas accessible en lecture


5000 [DEBUG]requête d'insertion de machines =>[DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/german/german.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,12 @@
2104 DIES IST DER DEMO-MODUS VON:
2105 Ihre Datenbank ist OK.<br>Keine Änderungen vorgenommen.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/hungarian/hungarian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/italian/italian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,12 @@
2104 STAI UTILIZZANDO LA VERSIONE DIMOSTRATIVA DI
2105 Il database è aggiornato.<br>Nessuna modifica apportata.
2106 la configurazione di MySQL, variabile 'max_allowed_packet', permette file grandi fino a <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/polish/polish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Twoja baza danych jest poprawna.<br>Nie podjeto żadnej akcji
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/portuguese/portuguese.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/russian/russian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/slovenian/slovenian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/spanish/spanish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 6 additions & 1 deletion plugins/language/turkish/turkish.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,12 @@
2104 YOU ARE WATCHING THE DEMO VERSION OF
2105 Your database is OK.<br>No action taken.
2106 in MySQL configuration, the variable 'max_allowed_packet' allows only file size <

2107 The version of WEB interface is lower than the version of the database
2108 The version of the database <b> MUST </b> be less than or equal to the version of the web interface
2109 Current version
2110 Expected version
2111 Perform the update
2112 The following file is not present or is not readable

5000 [DEBUG]computers insertions request =>[DEBUG]
5001 [DEBUG]REQUEST MADE => [DEBUG]
Expand Down
7 changes: 5 additions & 2 deletions require/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@
$_SESSION['OCS']['SQL_BASE_VERS']=$values['tvalue']['GUI_VERSION'];
}
if (GUI_VER != $_SESSION['OCS']['SQL_BASE_VERS']){
unset($_SESSION['OCS']['SQL_BASE_VERS']);
$fromAuto = true;
require('install.php');
if ($_SESSION['OCS']['SQL_BASE_VERS'] < 7005){
unset($_SESSION['OCS']['SQL_BASE_VERS']);
require('install.php');
}else
require('update.php');
die();
}

Expand Down
102 changes: 102 additions & 0 deletions update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
//====================================================================================
// OCS INVENTORY REPORTS
// Copyleft Erwan GOALOU 2014 (erwan(at)ocsinventory-ng(pt)org)
// Web: http://www.ocsinventory-ng.org
//
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
//====================================================================================

if (!isset($debut))
die('FORBIDDEN');
error_reporting(E_ALL & ~E_NOTICE);
if (isset($_GET['debug']))
$_SESSION['OCS']['DEBUG'] = 'ON';
require_once('require/fichierConf.class.php');
require_once('require/function_commun.php');
require_once('require/function_files.php');
require_once('var.php');
html_header(true);
if (!isset($_SESSION['OCS']['LANGUAGE']) or !isset($_SESSION['OCS']["LANGUAGE_FILE"])){
if (isset($_COOKIE['LANG']))
$_SESSION['OCS']['LANGUAGE']=$_COOKIE['LANG'];
if (!isset($_COOKIE['LANG']))
$_SESSION['OCS']['LANGUAGE']=DEFAULT_LANGUAGE;
$_SESSION['OCS']["LANGUAGE_FILE"]=new language($_SESSION['OCS']['LANGUAGE']);
}


$l = $_SESSION['OCS']["LANGUAGE_FILE"];
$version_database=$_SESSION['OCS']['SQL_BASE_VERS'];
$form_name='form_update';
$rep_maj='files/update/';

//search all sql files for update
$list_fichier=ScanDirectory($rep_maj,"sql");
echo "<form name='".$form_name."' id='".$form_name."' method='POST'>";
msg_info($l->g(2057));

if (GUI_VER < $_SESSION['OCS']['SQL_BASE_VERS']){
msg_error($l->g(2107)."<br>".$l->g(2108)."<br>".$l->g(2109).":".$version_database."=>".$l->g(2110).":".GUI_VER);
echo "</form>";
require_once('require/footer.php');
die();
}


$msg_info=$l->g(2109).":".$version_database."=>".$l->g(2110).":".GUI_VER;
msg_info($msg_info);


echo "<br><input type=submit name='update' value='".$l->g(2111)."'>";

if (isset($_POST['update'])){
while ($version_database < GUI_VER){

$version_database++;
if (in_array($version_database.".sql", $list_fichier['name'])){
if ( $_SESSION['OCS']['DEBUG'] == 'ON')
msg_success("Mise à jour effectuée: ".$version_database.".sql");
exec_fichier_sql($rep_maj.'/'.$version_database.".sql");
$sql="update config set tvalue='%s' where name='GUI_VERSION'";
$arg=$version_database;
$res_column=mysql2_query_secure($sql,$_SESSION['OCS']["writeServer"],$arg);
$_SESSION['OCS']['SQL_BASE_VERS']=$version_database;
}

}
msg_success($l->g(1121));
echo "<br><br><br><b><a href='index.php'>".$l->g(2051)."</a></b>";
}
echo "</form>";
if (isset($_GET['debug']))
unset($_SESSION['OCS']['DEBUG']);
require_once('require/footer.php');
/*
* function to execute sql file
*
*/
function exec_fichier_sql($fichier){
$db_file=$fichier;
$dbf_handle = @fopen($db_file, "r");

if (!$dbf_handle){
msg_error($l->g(2112)." : ".$fichier);
return true;
}else{
if (filesize($db_file) > 0){
$sql_query = fread($dbf_handle, filesize($db_file));
fclose($dbf_handle);
$data_sql=explode(";", $sql_query);
foreach ($data_sql as $k=>$v){
if (trim($v) != "")
mysql2_query_secure($v,$_SESSION['OCS']["writeServer"]);
}
return false;
}
return true;
}
}
?>
4 changes: 2 additions & 2 deletions var.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
//====================================================================================

@session_start();
define("GUI_VER", "7005"); // Version of the database
define("GUI_VER_SHOW","2.2"); // Version of the GUI
define("GUI_VER", "7006"); // Version of the database
define("GUI_VER_SHOW","2.2"); // Version of the GUI
define("MAC_FILE", "files/oui.txt"); // File containing MAC database
define("DEFAULT_LANGUAGE","english"); // Default language
define("PAG_INDEX","function"); // define name in url (like multi=32)
Expand Down

0 comments on commit 54d6d3c

Please sign in to comment.