Skip to content
Extraits de code Groupes Projets
Valider 88928979 rédigé par Fil's avatar Fil
Parcourir les fichiers

un mutualiseur integre d'office

Comment ca marche, la mutualisation :
- on peut faire http://www.spip.net/fr_article3514.html
- on peut faire aussi, desormais, dans mes_options.php
<?php 
include_spip('inc/mutualiser');
demarrer_site(['HTTP_HOST']);
?>

et meme, pour ne pas se fouler:
<?php
include_spip('inc/mutualiser');
demarrer_site(['HTTP_HOST'], array('creer_site' => true));
?>

les options sont :
- creer_site (false par defaut), cree le repertoire sites/xxxx/ et les 4 sous-repertoires IMG, local, tmp et config
- cookie_prefix (true par defaut) ajoute un cookie_prefix
- table_prefix (true par defaut) ajoute un table_prefix

le script charge automagiquement le fichier sites/xxx/config/mes_options.php s'il exsite, et positionne la variable des squelettes sur sites/xxx/squelettes/

enjoy!
parent fba0b0d0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -579,6 +579,7 @@ ecrire/inc/maintenance.php -text
ecrire/inc/message_select.php -text
ecrire/inc/minipres.php -text
ecrire/inc/modifier.php -text
ecrire/inc/mutualiser.php -text
ecrire/inc/notifications.php -text
ecrire/inc/petitionner.php -text
ecrire/inc/plonger.php -text
......
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2007 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
// Demarrer un site dans le sous-repertoire sites/$f/
// Options :
// creer_site => on va creer les repertoires qui vont bien (defaut: false)
// cookie_prefix, table_prefix => regler les prefixes (defaut: true)
function demarrer_site($site, $options = array()) {
$options = array_merge(
array(
'creer_site' => false,
'cookie_prefix' => true,
'table_prefix' => true
),
$options
);
// Le prefixe = max 10 caracteres a-z0-9, qui ressemblent au domaine
if ($options['cookie_prefix'] OR $options['table_prefix']) {
$prefix = preg_replace(',^www\.|[^a-z0-9],', '', strtolower($site));
$prefix = substr($prefix, 0, 10);
if ($options['cookie_prefix'])
$GLOBALS['cookie_prefix'] = $prefix;
if ($options['table_prefix'])
$GLOBALS['table_prefix'] = $prefix;
}
if (!is_dir($e = _DIR_RACINE . 'sites/' . $site . '/')) {
spip_initialisation();
echec_init_mutualisation($e, $options);
exit;
}
define('_SPIP_PATH',
$e . ':' .
_DIR_RACINE .':' .
_DIR_RACINE .'dist/:' .
_DIR_RESTREINT
);
spip_initialisation(
($e . _NOM_PERMANENTS_INACCESSIBLES),
($e . _NOM_PERMANENTS_ACCESSIBLES),
($e . _NOM_TEMPORAIRES_INACCESSIBLES),
($e . _NOM_TEMPORAIRES_ACCESSIBLES)
);
if (is_dir($e.'squelettes'))
$GLOBALS['dossier_squelettes'] = $e.'squelettes';
if (is_readable($f = $e._NOM_PERMANENTS_INACCESSIBLES._NOM_CONFIG.'.php'))
include($f); // attention cet include n'est pas en globals
}
function echec_init_mutualisation($e, $options) {
include_spip('inc/minipres');
if ($options['creer_site']) {
$ok = mkdir($e, _SPIP_CHMOD)
AND chmod($e, _SPIP_CHMOD)
AND mkdir($e._NOM_PERMANENTS_INACCESSIBLES, _SPIP_CHMOD)
AND mkdir($e._NOM_PERMANENTS_ACCESSIBLES, _SPIP_CHMOD)
AND mkdir($e._NOM_TEMPORAIRES_INACCESSIBLES, _SPIP_CHMOD)
AND mkdir($e._NOM_TEMPORAIRES_ACCESSIBLES, _SPIP_CHMOD)
AND chmod($e._NOM_PERMANENTS_INACCESSIBLES, _SPIP_CHMOD)
AND chmod($e._NOM_PERMANENTS_ACCESSIBLES, _SPIP_CHMOD)
AND chmod($e._NOM_TEMPORAIRES_INACCESSIBLES, _SPIP_CHMOD)
AND chmod($e._NOM_TEMPORAIRES_ACCESSIBLES, _SPIP_CHMOD);
echo minipres(
_L('Creation du r&eacute;pertoire du site (<tt>'.$e.'</tt>)'),
"<div><img alt='SPIP' src='" . _DIR_IMG_PACK . "logo-spip.gif' /></div>\n"
.'<h3>'.($ok
? _L('OK, vous pouvez <a href="'.generer_url_ecrire('install').'">installer votre site</a>.')
: _L('erreur')
).'</h3>'
);
} else {
echo minipres(
_L('Le r&eacute;pertoire du site (<tt>'.$e.'</tt>) n\'existe pas'),
"<div><img alt='SPIP' src='" . _DIR_IMG_PACK . "logo-spip.gif' /></div>\n".
'<h3>'
._L('Veuillez créer le répertoire '.$e.' et ses sous répertoires:')
.'</h3>'
.'<ul>'
.'<li>'.$e._NOM_PERMANENTS_INACCESSIBLES.'</li>'
.'<li>'.$e._NOM_PERMANENTS_ACCESSIBLES.'</li>'
.'<li>'.$e._NOM_TEMPORAIRES_INACCESSIBLES.'</li>'
.'<li>'.$e._NOM_TEMPORAIRES_ACCESSIBLES.'</li>'
.'</ul>'
);
}
}
?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter