<?php

if(!is_dir('interface') && !is_dir('sql')) die('Please enter the install sirectory before you execute the install.php script.'); 

// Copy the files
exec('chown -R ispconfig:ispconfig interface');
exec('cp -rf interface /usr/local/ispconfig');
exec('chmod 770 /usr/local/ispconfig/interface/invoices');
exec('chown ispconfig:ispconfig /usr/local/ispconfig/interface/invoices');

// Execute the SQL
include_once('/usr/local/ispconfig/server/lib/config.inc.php');
include_once('/usr/local/ispconfig/server/lib/mysql_clientdb.conf');

if(substr(ISPC_APP_VERSION,0,5) != '3.0.4') die('This Billing Module version requires ISPConfig 3.0.4');

/*
$clientdb_host                  = 'localhost';
$clientdb_user                  = 'root';
$clientdb_password              = 'xxxxx';
*/

$db_database = $conf['db_database'];

$command = "mysql -h $clientdb_host -u $clientdb_user -p$clientdb_password  $db_database < sql/ispconfig3_billing.sql";
exec($command);

echo "ISPConfig Billing module has been installed.\n";

?>