<?php
/*
Copyright (C) 2007 Mercier Benjamin

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
*/

// Annulation de la connexion MySql locale :
$ConnexionLocale = "non";

// Inclusion du core
require ('system/core.php');

$ListUser = $ConnexionPanel->Select ("*", "utilisateur", "", "", "", "", "");
if ( $ListUser != FALSE )
	{
	$CountUser = count($ListUser);
	
	for ($i=0; $i < $CountUser; $i++)
		{
		echo "Vhost de ".$ListUser[$i]["Utilisateur"];
		
		$Vhost = '

#DEBUT: '.$ListUser[$i]["Utilisateur"].'.kelio.org
<VirtualHost *>
<Directory "/var/www/web/'.$ListUser[$i]["Utilisateur"].'/public/">
AllowOverride All
Options -ExecCGI -MultiViews SymLinksIfOwnerMatch -Indexes
Order allow,deny
Allow from all
</Directory>
ServerName '.$ListUser[$i]["Utilisateur"].'.kelio.org
DocumentRoot /var/www/web/'.$ListUser[$i]["Utilisateur"].'/public/
php_admin_value open_basedir "/var/www/web/'.$ListUser[$i]["Utilisateur"].'/public/:/tmp/"
ErrorLog /var/www/logs/error/'.$ListUser[$i]["Utilisateur"].'.kelio.org.log
CustomLog /var/www/logs/access/'.$ListUser[$i]["Utilisateur"].'.kelio.org.log combined
CustomLog /var/www/logs/trafic/'.$ListUser[$i]["Utilisateur"].'.kelio.org.log trafic
CBandRemoteSpeed 50kb/s 3 3
</VirtualHost>
#FIN: '.$ListUser[$i]["Utilisateur"].'.kelio.org

';

		$InsertVhost = file_put_contents("/var/www/vhost/".$ListUser[$i]["Utilisateur"],$Vhost);
		sleep(0.5);
		if ( $InsertVhost != FALSE )
			{
			echo "\t\t\t[OK]\n";
			}
		else
			{
			echo "\t\t\t[ERREUR 1]\n";
			}		
		}
	}

?>

