Current installed version ".$valUpd["tvalue"]." is lower than this version (".GUI_VER.") automatic install launched
"; /* if(!isset($_POST["name"])) { if( $hnd = @fopen("dbconfig.inc.php", "r") ) { fclose($hnd); include("dbconfig.inc.php"); $_POST["name"] = $_SESSION["COMPTE_BASE"]; $_POST["pass"] = $_SESSION["PSWD_BASE"]; $_POST["host"] = $_SESSION["SERVEUR_SQL"]; } else { $_POST["name"] = "root"; $_POST["pass"] = ""; $_POST["host"] = "localhost"; } $firstAttempt=true; }*/ if(!function_exists('session_start')) { echo "
ERROR: Sessions for PHP is not properly installed.
Try installing the php4-session package.
"; die(); } if(!function_exists('xml_parser_create')) { echo "
WARNING: XML for PHP is not properly installed, you will not be able to use ipdiscover-util.
"; } if(!function_exists('mysql_connect')) { echo "
ERROR: MySql for PHP is not properly installed.
Try installing mysql for php package (Debian: php4-mysql)
"; die(); } if(!function_exists('imagefontwidth')) { echo "
WARNING: GD for PHP is not properly installed.
You will not be able to see any graphical display
Try uncommenting \";extension=php_gd2.dll\" (windows) by removing the semicolon in file php.ini, or try installing the php4-gd package (Linux).
"; } if(!function_exists('openssl_open')) { echo "
WARNING: OpenSSL for PHP is not properly installed.
Some automatic deployment features won't be available
Try uncommenting \";extension=php_openssl.dll\" (windows) by removing the semicolon in file php.ini, or try installing the php4-openssl package (Linux).
"; } @mkdir($_SERVER["DOCUMENT_ROOT"]."/download"); $pms = "post_max_size"; $umf = "upload_max_filesize"; $valTpms = ini_get( $pms ); $valTumf = ini_get( $umf ); $valBpms = return_bytes( $valTpms ); $valBumf = return_bytes( $valTumf ); if( $valBumf>$valBpms ) $MaxAvail = $valTpms; else $MaxAvail = $valTumf; echo "
WARNING: You will not be able to build any auto deployment package with size greater than $MaxAvail.
You must raise both post_max_size and upload_max_filesize in your php.ini to correct this.
"; include ('fichierConf.class.php'); $l = new FichierConf("english"); // on cr�e l'instance pour avoir les mots dans la langue choisie if( isset($_POST["name"])) { if( (!$link=@mysql_connect($_POST["host"],$_POST["name"],$_POST["pass"]))) { $firstAttempt=false; echo "
ERROR: ".$l->g(249)." (host=".$_POST["host"]." name=".$_POST["name"]." pass=".$_POST["pass"].")
Mysql error: ".mysql_error()."
"; } else $instOk = true; } if( ! $instOk ) { if( $hnd = @fopen("dbconfig.inc.php", "r") ) { fclose($hnd); include("dbconfig.inc.php"); $valNme = $_SESSION["COMPTE_BASE"]; $valPass = $_SESSION["PSWD_BASE"]; $valServ = $_SESSION["SERVEUR_SQL"]; } echo "
".$l->g(247)." :    
".$l->g(248)." :    
".$l->g(250)." :    
 
        
"; die(); } if($firstAttempt==true && $_POST["pass"] == "") { echo "
WARNING: your the default root password is set on your mysql server. Change it asap. (using root password=blank)
"; } if(!mysql_query("set global max_allowed_packet=2097152;")) { echo "
WARNING: The user you typed does not seem to be root
If you encounter any problem with files insertion, try setting the global max_allowed_packet mysql value to at least 2M in your server config file.
"; } mysql_select_db("ocsweb"); if(isset($_POST["label"])) { if($_POST["label"]!="") { @mysql_query( "DELETE FROM deploy WHERE NAME='label'"); $query = "INSERT INTO deploy VALUES('label','".$_POST["label"]."');"; mysql_query($query) or die(mysql_error()); echo "
Label added
"; } else { echo "
Label NOT added (not tag will be asked on client launch)
"; } } if($_POST["fin"]=="fin") { if(!@mysql_connect($_POST["host"],"ocs","ocs")) { if(mysql_errno()==0) { echo "
ERROR: MySql authentication problem. You must add the 'old-passwords' in your mysql configuration file (my.ini). Then restart mysql, and relaunch install.php
"; die(); } else echo "
ERROR: MySql authentication problem. (using host=".$_POST["host"]." login=ocs pass=ocs).
"; echo "
ERROR: The installer ended unsuccessfully, rerun install.php once problems are corrected
"; unlink("dbconfig.inc.php"); } else { echo "
Installation finished you can log in index.php with login=admin and pass=admin

Click here to enter OCS-NG GUI
"; } die(); } if(!$ch = @fopen("dbconfig.inc.php","w")) { echo "
ERROR: can't write in directory (on dbconfig.inc.php), please set the required rights in order to install ocsinventory (you should remove the write mode after the installation is successfull)
"; die(); } fwrite($ch,""); fclose($ch); echo "
MySql config file successfully written
"; $db_file = "ocsbase.sql"; if($dbf_handle = @fopen($db_file, "r")) { echo "
Please wait, database update may take up to 30 minutes..."; flush(); $sql_query = fread($dbf_handle, filesize($db_file)); fclose($dbf_handle); $dejaLance=0; $li = 0; foreach ( explode(";", "$sql_query") as $sql_line) { $li++; if(!mysql_query($sql_line)) { if( mysql_errno()==1062 || mysql_errno()==1061 || mysql_errno()==1044 || mysql_errno()==1065 || mysql_errno()==1060 || mysql_errno()==1054 || mysql_errno()==1091 || mysql_errno()==1061) continue; if( mysql_errno()==1071 ) { echo "
ERROR: line $li: query:[$sql_line] failed, KEY was too long
You need to redo this query later or you will experience severe performance issues.

"; continue; } if(mysql_errno()==1007 || mysql_errno()==1050) { $dejaLance = 1; continue; } echo "
ERROR: line $li: query:[$sql_line] failed
"; echo "mysql error: ".mysql_error()." (err:".mysql_errno().")
"; $nberr++; } echo "."; flush(); } echo "
"; if(!$nberr&&!$dejaLance) echo "
Database successfully generated
"; } else { echo "
ERROR: $db_file needed
"; die(); } if($dejaLance>0) echo "
Existing database updated
"; echo "
Database engine checking..."; flush(); $tableEngines = array("hardware"=>"InnoDB","accesslog"=>"InnoDB","bios"=>"InnoDB","memories"=>"InnoDB","slots"=>"InnoDB", "registry"=>"InnoDB","monitors"=>"InnoDB","ports"=>"InnoDB","storages"=>"InnoDB","drives"=>"InnoDB","inputs"=>"InnoDB", "modems"=>"InnoDB","networks"=>"InnoDB","printers"=>"InnoDB","sounds"=>"InnoDB","videos"=>"InnoDB","softwares"=>"InnoDB", "accountinfo"=>"InnoDB","netmap"=>"InnoDB","devices"=>"InnoDB", "locks"=>"HEAP"); $nbconv = 0; $erralter = false; foreach( $tableEngines as $tbl=>$eng ) { if( $res = mysql_query("show table status like '$tbl'") ) { $val = mysql_fetch_array( $res ); if( $val["Engine"] == $eng ) { echo "."; flush(); } else { $nbconv++; echo "."; flush(); if( ! $resAlter = mysql_query("ALTER TABLE $tbl engine='$eng'") ) { $nberr++; $erralter = true; echo "

ERROR: Alter query failed
"; echo "mysql error: ".mysql_error()." (err:".mysql_errno().")
"; } } } else { echo "

ERROR: Show table status query failed
"; echo "mysql error: ".mysql_error()." (err:".mysql_errno().")
"; $nberr++; $erralter = true; } } $oneFailed = false; foreach( $tableEngines as $tbl=>$eng ) { if( $res = mysql_query("show table status like '$tbl'") ) { $val = mysql_fetch_array( $res ); if( (strcasecmp($val["Engine"],$eng) != 0) && (strcasecmp($eng,"InnoDB") == 0) && $oneFailed == false ) { echo "

ERROR: InnoDB conversion failed, install InnoDB mysql engine support on your server
or you will experience severe performance issues.
(Try to uncomment \"#skip-innodb\" in your mysql config file.)
Reinstall when corrected.

"; $oneFailed = true; } if ( (strcasecmp($val["Engine"],$eng)!=0) && (strcasecmp($eng,"HEAP")) && (strcasecmp($val["Engine"],"MEMORY")!=0) ) { echo "

ERROR: HEAP conversion failed, install HEAP mysql engine support on your server
or you will experience severe performance issues.

"; } } else { echo "

ERROR: Show table status query failed
"; echo "mysql error: ".mysql_error()." (err:".mysql_errno().")
"; $nberr++; $erralter = true; } } if( ! $erralter ) { echo "

Database engine successfully updated ($nbconv table(s) altered)
"; } if($nberr) { echo "
ERROR: The installer ended unsuccessfully, rerun install.php once problems are corrected
"; unlink("dbconfig.inc.php"); die(); } $nberr=0; $dir = "files"; $filenames = Array("ocsagent.exe"); $dejaLance=0; $filMin = ""; mysql_query("DELETE FROM deploy"); mysql_select_db("ocsweb"); foreach($filenames as $fil) { $filMin = $fil; if ( $ledir = @opendir("files")) { while($filename = readdir($ledir)) { if(strcasecmp($filename,$fil)==0 && strcmp($filename,$fil)!=0 ) { //echo "
$fil case is '$filename'
"; $fil = $filename; } } closedir($ledir); } else { echo "
WARNING: 'files' directory missing, can't import $fil from it
"; } if($fd = @fopen($dir."/".$fil, "r")) { $contents = fread($fd, filesize ($dir."/".$fil)); fclose($fd); $binary = addslashes($contents); $query = "INSERT INTO deploy VALUES('$filMin','$binary');"; if(!mysql_query($query)) { if(mysql_errno()==1007 || mysql_errno()==1050 || mysql_errno()==1062) { $dejaLance++; continue; } if(mysql_errno()==2006) { echo "
ERROR: $fil was not inserted. You need to set the max_allowed_packet mysql value to at least 2M
"; echo "
ERROR: The installer ended unsuccessfully, rerun install.php once problems are corrected
"; unlink("dbconfig.inc.php"); die(); } echo "
ERROR: $fil not inserted
"; echo "mysql error: ".mysql_error()."
"; $nberr++; } } else { echo "
WARNING: ".$dir."/".$fil." missing, if you do not reinstall the DEPLOY feature won't be available
"; $errNorm = true; } } if($dejaLance>0) echo "
WARNING: One or more files were already inserted
"; if(!$nberr&&!$dejaLance&&!$errNorm) echo "
Deploy files successfully inserted
"; mysql_query("DELETE FROM files"); $nbDeleted = mysql_affected_rows(); if( $nbDeleted > 0) echo "
Table 'files' truncated
"; else echo "
Table 'files' was empty
"; if($nberr) { echo "
ERROR: The installer ended unsuccessfully, rerun install.php once problems are corrected
"; unlink("dbconfig.inc.php"); die(); } $row = 1; $handle = @fopen("subnet.csv", "r"); if( ! $handle ) { echo "
No subnet.csv file to import
"; } else { $errSub = 0; $resSub = 0; $dejSub = 0; echo "

Inserting subnet.csv networks
"; while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { $ipValide = "(([0-9]{1,3}\.){3}[0-9]{1,3})"; $masqueEntier = "([0-9]{1,3})"; $masqueValide = "(($ipValide|$masqueEntier)[ ]*$)"; $exp = $ipValide."[ ]*/[ ]*".$masqueValide; if( preg_match("/$exp/",$data[2],$res) ) { if( @mysql_query("INSERT INTO subnet(netid, name, id, mask) VALUES ('".$res[1]."','".$data[0]."','".$data[1]."','".$res[4]."')") ) { $resSub++; //echo "
//Network => name: ".$data[0]." ip: ".$res[1]." mask: ".$res[4]." id: ".$data[1]." successfully inserted
"; } else { if( mysql_errno() != 1062) { $errSub++; echo "
ERROR: Could not insert network ".$data[0]." in the subnet table, error ".mysql_errno().": ".mysql_error()."
"; } else $dejSub++; } } else { $errSub++; echo "
WARNING: Network ".$data[0]." was not inserted (invalid ip or mask: ".$data[2].")
"; } } fclose($handle); echo "
Subnet was imported=> $resSub successful, $dejSub were already imported, $errSub failed

"; } echo "
Network netid computing. Please wait...
"; flush(); $reqDej = "SELECT COUNT(id) as nbid FROM networks WHERE ipsubnet IS NOT NULL"; $resDej = mysql_query($reqDej) or die(mysql_error()); $valDej = mysql_fetch_array($resDej); $errNet = 0; $sucNet = 0; $dejNet = $valDej["nbid"]; $reqNet = "SELECT hardware_id, id, ipaddress, ipmask FROM networks WHERE ipsubnet='' OR ipsubnet IS NULL"; $resNet = mysql_query($reqNet) or die(mysql_error()); while ($valNet = mysql_fetch_array($resNet) ) { $netid = getNetFromIpMask( $valNet["ipaddress"], $valNet["ipmask"] ); if( !$netid || $valNet["ipaddress"]=="" || $valNet["ipmask"]=="" ) { $errNet++; } else { mysql_query("UPDATE networks SET ipsubnet='$netid' WHERE hardware_id='".$valNet["hardware_id"]."' AND id='".$valNet["id"]."'"); if( mysql_errno() != "") { $errNet++; echo "
ERROR: Could not update netid to $netid, error ".mysql_errno().": ".mysql_error()."
"; } else { $sucNet++; } } } echo "
Network netid was computed=> $sucNet successful, $dejNet were already computed, $errNet were not computable
"; echo "
Netmap netid computing. Please wait...
"; flush(); $reqDej = "SELECT COUNT(mac) as nbid FROM netmap WHERE netid IS NOT NULL"; $resDej = mysql_query($reqDej) or die(mysql_error()); $valDej = mysql_fetch_array($resDej); $errNet = 0; $sucNet = 0; $dejNet = $valDej["nbid"]; $reqNet = "SELECT mac, ip, mask FROM netmap WHERE netid='' OR netid IS NULL"; $resNet = mysql_query($reqNet) or die(mysql_error()); while ($valNet = mysql_fetch_array($resNet) ) { $netid = getNetFromIpMask( $valNet["ip"], $valNet["mask"] ); if( !$netid || $valNet["ip"]=="" || $valNet["mask"]=="" ) { $errNet++; } else { mysql_query("UPDATE netmap SET netid='$netid' WHERE mac='".$valNet["mac"]."' AND ip='".$valNet["ip"]."'"); if( mysql_errno() != "") { $errNet++; echo "
ERROR: Could not update netid to $netid, error ".mysql_errno().": ".mysql_error()."
"; } else { $sucNet++; } } } echo "
Netmap netid was computed=> $sucNet successful, $dejNet were already computed, $errNet were not computable
"; function printEnTeteInstall($ent) { echo "
".$ent."
"; } ?>
Please enter the label of the windows client tag input box:
(Leave empty if you don't want a popup to be shown on each agent launch).