diff --git a/.gitattributes b/.gitattributes index 83fe1ae2272175b3599fb1b23909134c97a39c7f..2dce325c711285866153c68daaf5fe37d194f531 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/ecrire/inc/mutualiser.php b/ecrire/inc/mutualiser.php new file mode 100644 index 0000000000000000000000000000000000000000..fb522cdc3fa8939d7c3f2c9b85fea7fbcd26ec4f --- /dev/null +++ b/ecrire/inc/mutualiser.php @@ -0,0 +1,112 @@ +<?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é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é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>' + ); + } +} + + + +?>