Example #1
0
function exec_install_dist()
{
	$etape = _request('etape');
	$deja = (_FILE_CONNECT AND analyse_fichier_connection(_FILE_CONNECT));

	// Si deja installe, on n'a plus le droit qu'a l'etape chmod
	// pour chgt post-install ou aux etapes supplementaires 
	// de declaration de base externes.
	// Mais alors il faut authentifier car ecrire/index.php l'a omis

	if ($deja AND in_array($etape, array('chmod', 'sup1', 'sup2'))) {

		$auth = charger_fonction('auth', 'inc');
		if (!$auth()) {
			verifier_visiteur();
			$deja = (!autoriser('configurer'));
		}
	}
	if ($deja) {
		// Rien a faire ici
	  	echo minipres();
	} else {
		include_spip('base/create');
		$fonc = charger_fonction("etape_$etape", 'install');
		$fonc();
	}
}
Example #2
0
/**
 * Fonction d'initialisation, appellée dans inc_version ou mes_options
 *
 * Elle définit les répertoires et fichiers non partageables
 * et indique dans $test_dirs ceux devant être accessibles en écriture
 * mais ne touche pas à cette variable si elle est déjà définie
 * afin que mes_options.php puisse en spécifier d'autres.
 *
 * Elle définit ensuite les noms des fichiers et les droits.
 * Puis simule un register_global=on sécurisé.
 *
 * @param string $pi Répertoire permanent inaccessible
 * @param string $pa Répertoire permanent accessible
 * @param string $ti Répertoire temporaire inaccessible
 * @param string $ta Répertoire temporaire accessible
 */
function spip_initialisation_core($pi = NULL, $pa = NULL, $ti = NULL, $ta = NULL)
{
    static $too_late = 0;
    if ($too_late++) {
        return;
    }
    // Declaration des repertoires
    // le nom du repertoire plugins/ activables/desactivables
    if (!defined('_DIR_PLUGINS')) {
        define('_DIR_PLUGINS', _DIR_RACINE . "plugins/");
    }
    // le nom du repertoire des extensions/ permanentes du core, toujours actives
    if (!defined('_DIR_PLUGINS_DIST')) {
        define('_DIR_PLUGINS_DIST', _DIR_RACINE . "plugins-dist/");
    }
    // le nom du repertoire des librairies
    if (!defined('_DIR_LIB')) {
        define('_DIR_LIB', _DIR_RACINE . "lib/");
    }
    if (!defined('_DIR_IMG')) {
        define('_DIR_IMG', $pa);
    }
    if (!defined('_DIR_LOGOS')) {
        define('_DIR_LOGOS', $pa);
    }
    if (!defined('_DIR_IMG_ICONES')) {
        define('_DIR_IMG_ICONES', _DIR_LOGOS . "icones/");
    }
    if (!defined('_DIR_DUMP')) {
        define('_DIR_DUMP', $ti . "dump/");
    }
    if (!defined('_DIR_SESSIONS')) {
        define('_DIR_SESSIONS', $ti . "sessions/");
    }
    if (!defined('_DIR_TRANSFERT')) {
        define('_DIR_TRANSFERT', $ti . "upload/");
    }
    if (!defined('_DIR_CACHE')) {
        define('_DIR_CACHE', $ti . "cache/");
    }
    if (!defined('_DIR_CACHE_XML')) {
        define('_DIR_CACHE_XML', _DIR_CACHE . "xml/");
    }
    if (!defined('_DIR_SKELS')) {
        define('_DIR_SKELS', _DIR_CACHE . "skel/");
    }
    if (!defined('_DIR_AIDE')) {
        define('_DIR_AIDE', _DIR_CACHE . "aide/");
    }
    if (!defined('_DIR_TMP')) {
        define('_DIR_TMP', $ti);
    }
    if (!defined('_DIR_VAR')) {
        define('_DIR_VAR', $ta);
    }
    if (!defined('_DIR_ETC')) {
        define('_DIR_ETC', $pi);
    }
    if (!defined('_DIR_CONNECT')) {
        define('_DIR_CONNECT', $pi);
    }
    if (!defined('_DIR_CHMOD')) {
        define('_DIR_CHMOD', $pi);
    }
    if (!isset($GLOBALS['test_dirs'])) {
        // Pas $pi car il est bon de le mettre hors ecriture apres intstall
        // il sera rajoute automatiquement si besoin a l'etape 2 de l'install
        $GLOBALS['test_dirs'] = array($pa, $ti, $ta);
    }
    // Declaration des fichiers
    if (!defined('_CACHE_PLUGINS_PATH')) {
        define('_CACHE_PLUGINS_PATH', _DIR_CACHE . "charger_plugins_chemins.php");
    }
    if (!defined('_CACHE_PLUGINS_OPT')) {
        define('_CACHE_PLUGINS_OPT', _DIR_CACHE . "charger_plugins_options.php");
    }
    if (!defined('_CACHE_PLUGINS_FCT')) {
        define('_CACHE_PLUGINS_FCT', _DIR_CACHE . "charger_plugins_fonctions.php");
    }
    if (!defined('_CACHE_PIPELINES')) {
        define('_CACHE_PIPELINES', _DIR_CACHE . "charger_pipelines.php");
    }
    if (!defined('_CACHE_CHEMIN')) {
        define('_CACHE_CHEMIN', _DIR_CACHE . "chemin.txt");
    }
    # attention .php obligatoire pour ecrire_fichier_securise
    if (!defined('_FILE_META')) {
        define('_FILE_META', $ti . 'meta_cache.php');
    }
    if (!defined('_DIR_LOG')) {
        define('_DIR_LOG', _DIR_TMP . 'log/');
    }
    if (!defined('_FILE_LOG')) {
        define('_FILE_LOG', 'spip');
    }
    if (!defined('_FILE_LOG_SUFFIX')) {
        define('_FILE_LOG_SUFFIX', '.log');
    }
    // Le fichier de connexion a la base de donnees
    // tient compte des anciennes versions (inc_connect...)
    if (!defined('_FILE_CONNECT_INS')) {
        define('_FILE_CONNECT_INS', 'connect');
    }
    if (!defined('_FILE_CONNECT')) {
        define('_FILE_CONNECT', @is_readable($f = _DIR_CONNECT . _FILE_CONNECT_INS . '.php') ? $f : (@is_readable($f = _DIR_RESTREINT . 'inc_connect.php') ? $f : false));
    }
    // Le fichier de reglages des droits
    if (!defined('_FILE_CHMOD_INS')) {
        define('_FILE_CHMOD_INS', 'chmod');
    }
    if (!defined('_FILE_CHMOD')) {
        define('_FILE_CHMOD', @is_readable($f = _DIR_CHMOD . _FILE_CHMOD_INS . '.php') ? $f : false);
    }
    if (!defined('_FILE_LDAP')) {
        define('_FILE_LDAP', 'ldap.php');
    }
    if (!defined('_FILE_TMP_SUFFIX')) {
        define('_FILE_TMP_SUFFIX', '.tmp.php');
    }
    if (!defined('_FILE_CONNECT_TMP')) {
        define('_FILE_CONNECT_TMP', _DIR_CONNECT . _FILE_CONNECT_INS . _FILE_TMP_SUFFIX);
    }
    if (!defined('_FILE_CHMOD_TMP')) {
        define('_FILE_CHMOD_TMP', _DIR_CHMOD . _FILE_CHMOD_INS . _FILE_TMP_SUFFIX);
    }
    // Definition des droits d'acces en ecriture
    if (!defined('_SPIP_CHMOD') and _FILE_CHMOD) {
        include_once _FILE_CHMOD;
    }
    // Se mefier des fichiers mal remplis!
    if (!defined('_SPIP_CHMOD')) {
        define('_SPIP_CHMOD', 0777);
    }
    if (!defined('_DEFAULT_CHARSET')) {
        /** Le charset par défaut lors de l'installation */
        define('_DEFAULT_CHARSET', 'utf-8');
    }
    if (!defined('_ROOT_PLUGINS')) {
        define('_ROOT_PLUGINS', _ROOT_RACINE . "plugins/");
    }
    if (!defined('_ROOT_PLUGINS_DIST')) {
        define('_ROOT_PLUGINS_DIST', _ROOT_RACINE . "plugins-dist/");
    }
    if (!defined('_ROOT_PLUGINS_SUPPL') && defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) {
        define('_ROOT_PLUGINS_SUPPL', _ROOT_RACINE . str_replace(_DIR_RACINE, '', _DIR_PLUGINS_SUPPL));
    }
    // La taille des Log
    if (!defined('_MAX_LOG')) {
        define('_MAX_LOG', 100);
    }
    // Sommes-nous dans l'empire du Mal ?
    // (ou sous le signe du Pingouin, ascendant GNU ?)
    if (isset($_SERVER['SERVER_SOFTWARE']) and strpos($_SERVER['SERVER_SOFTWARE'], '(Win') !== false) {
        if (!defined('_OS_SERVEUR')) {
            define('_OS_SERVEUR', 'windows');
        }
        if (!defined('_SPIP_LOCK_MODE')) {
            define('_SPIP_LOCK_MODE', 1);
        }
        // utiliser le flock php
    } else {
        if (!defined('_OS_SERVEUR')) {
            define('_OS_SERVEUR', '');
        }
        if (!defined('_SPIP_LOCK_MODE')) {
            define('_SPIP_LOCK_MODE', 1);
        }
        // utiliser le flock php
        #if (!defined('_SPIP_LOCK_MODE')) define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip mais link() est tres souvent interdite
    }
    // Langue par defaut
    if (!defined('_LANGUE_PAR_DEFAUT')) {
        define('_LANGUE_PAR_DEFAUT', 'fr');
    }
    //
    // Module de lecture/ecriture/suppression de fichiers utilisant flock()
    // (non surchargeable en l'etat ; attention si on utilise include_spip()
    // pour le rendre surchargeable, on va provoquer un reecriture
    // systematique du noyau ou une baisse de perfs => a etudier)
    include_once _ROOT_RESTREINT . 'inc/flock.php';
    // charger tout de suite le path et son cache
    load_path_cache();
    // *********** traiter les variables ************
    //
    // Securite
    //
    // Ne pas se faire manger par un bug php qui accepte ?GLOBALS[truc]=toto
    if (isset($_REQUEST['GLOBALS'])) {
        die;
    }
    // nettoyer les magic quotes \' et les caracteres nuls %00
    spip_desinfecte($_GET);
    spip_desinfecte($_POST);
    spip_desinfecte($_COOKIE);
    spip_desinfecte($_REQUEST);
    // Par ailleurs on ne veut pas de magic_quotes au cours de l'execution
    @set_magic_quotes_runtime(0);
    // Si les variables sont passees en global par le serveur,
    // il faut faire quelques verifications de base
    $avertir_register_globals = false;
    if (test_valeur_serveur(@ini_get('register_globals'))) {
        // ne pas desinfecter les globales en profondeur car elle contient aussi les
        // precedentes, qui seraient desinfectees 2 fois.
        spip_desinfecte($GLOBALS, false);
        if (include_spip('inc/php3')) {
            spip_register_globals(true);
        }
        $avertir_register_globals = true;
    }
    // appliquer le cookie_prefix
    if ($GLOBALS['cookie_prefix'] != 'spip') {
        include_spip('inc/cookie');
        recuperer_cookies_spip($GLOBALS['cookie_prefix']);
    }
    //
    // Capacites php (en fonction de la version)
    //
    $GLOBALS['flag_ob'] = function_exists("ob_start") && function_exists("ini_get") && !strstr(@ini_get('disable_functions'), 'ob_');
    $GLOBALS['flag_sapi_name'] = function_exists("php_sapi_name");
    $GLOBALS['flag_get_cfg_var'] = @get_cfg_var('error_reporting') != "";
    $GLOBALS['flag_upload'] = !$GLOBALS['flag_get_cfg_var'] || get_cfg_var('upload_max_filesize') > 0;
    // Compatibilite avec serveurs ne fournissant pas $REQUEST_URI
    if (isset($_SERVER['REQUEST_URI'])) {
        $GLOBALS['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
    } else {
        $GLOBALS['REQUEST_URI'] = $_SERVER['PHP_SELF'];
        if (!empty($_SERVER['QUERY_STRING']) and !strpos($_SERVER['REQUEST_URI'], '?')) {
            $GLOBALS['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
        }
    }
    // Duree de validite de l'alea pour les cookies et ce qui s'ensuit.
    if (!defined('_RENOUVELLE_ALEA')) {
        define('_RENOUVELLE_ALEA', 12 * 3600);
    }
    // charger les meta si possible et renouveller l'alea au besoin
    // charge aussi effacer_meta et ecrire_meta
    $inc_meta = charger_fonction('meta', 'inc');
    $inc_meta();
    // on a pas pu le faire plus tot
    if ($avertir_register_globals) {
        avertir_auteurs("register_globals", _L("Problème de sécurité : register_globals=on; dans php.ini à corriger."));
    }
    // nombre de repertoires depuis la racine
    // on compare a l'adresse de spip.php : $_SERVER["SCRIPT_NAME"]
    // ou a defaut celle donnee en meta ; (mais si celle-ci est fausse
    // le calcul est faux)
    if (!_DIR_RESTREINT) {
        $GLOBALS['profondeur_url'] = 1;
    } else {
        $uri = isset($_SERVER['REQUEST_URI']) ? explode('?', $_SERVER['REQUEST_URI']) : '';
        $uri_ref = $_SERVER["SCRIPT_NAME"];
        if (!$uri_ref or $ti !== _NOM_TEMPORAIRES_INACCESSIBLES) {
            if (isset($GLOBALS['meta']['adresse_site'])) {
                $uri_ref = parse_url($GLOBALS['meta']['adresse_site']);
                $uri_ref = $uri_ref['path'] . '/';
            } else {
                $uri_ref = "";
            }
        }
        if (!$uri or !$uri_ref) {
            $GLOBALS['profondeur_url'] = 0;
        } else {
            $GLOBALS['profondeur_url'] = max(0, substr_count($uri[0], '/') - substr_count($uri_ref, '/'));
        }
    }
    // s'il y a un cookie ou PHP_AUTH, initialiser visiteur_session
    if (_FILE_CONNECT) {
        if (verifier_visiteur() == '0minirezo' and !isset($_COOKIE['spip_admin'])) {
            clear_path_cache();
        }
    }
}
Example #3
0
/**
 * Loger un auteur suite a son identification
 *
 * @param array $auteur
 * @return bool
 */
function auth_loger($auteur)
{
    if (!is_array($auteur) or !count($auteur)) {
        return false;
    }
    // initialiser et poser le cookie de session
    unset($_COOKIE['spip_session']);
    auth_init_droits($auteur);
    // initialiser les prefs
    $p = $GLOBALS['visiteur_session']['prefs'];
    $p['cnx'] = $auteur['cookie'] == 'oui' ? 'perma' : '';
    sql_updateq('spip_auteurs', array('prefs' => serialize($p)), "id_auteur=" . $auteur['id_auteur']);
    // Si on est admin, poser le cookie de correspondance
    include_spip('inc/cookie');
    if ($auteur['statut'] == '0minirezo') {
        spip_setcookie('spip_admin', '@' . $auteur['login'], time() + 7 * 24 * 3600);
    } else {
        spip_setcookie('spip_admin', '', 1);
    }
    //  bloquer ici le visiteur qui tente d'abuser de ses droits
    verifier_visiteur();
    return true;
}
Example #4
0
        lcm_setcookie('lcm_session', $cookie_session);
    }
    $prefs = $row_author['prefs'] ? unserialize($row_author['prefs']) : array();
    $prefs['cnx'] = $session_remember == 'yes' ? 'perma' : '';
    lcm_query("UPDATE lcm_author \n\t\t\t\tSET prefs = '" . addslashes(serialize($prefs)) . "' \n\t\t\t\tWHERE id_author = " . $row_author['id_author']);
}
// Change the language of the private area (or login)
// [ML] I once wanted to put this in a function, and it did a hell
// of a mess because of the session handling stuff..
if (isset($_REQUEST['var_lang_lcm'])) {
    // ex: bg, fr, en, en_uk, etc. nothing else is accepted
    if (preg_match("/^[_A-Za-z]+[0-9]*\$/", $_REQUEST['var_lang_lcm'])) {
        include_lcm('inc_lang');
        include_lcm('inc_session');
        $new_lang = clean_input($_REQUEST['var_lang_lcm']);
        $valid_author = verifier_visiteur();
        if (lcm_set_language($new_lang)) {
            lcm_setcookie('lcm_lang', $new_lang, time() + 365 * 24 * 3600);
            // Save language preference only if we are installed and if author connected
            if ($valid_author && include_config_exists('inc_connect')) {
                include_lcm('inc_admin');
                lcm_query("UPDATE lcm_author \n\t\t\t\t\t\tSET lang = '" . $new_lang . "' \n\t\t\t\t\t\tWHERE id_author = " . $GLOBALS['author_session']['id_author']);
                $author_session['lang'] = $new_lang;
                lcm_add_session($author_session, $_COOKIE['lcm_session']);
            } else {
                lcm_log("Not valid_author ({$valid_author}) or not yet installed");
            }
            $cible->delvar('lang');
            $cible->addvar('lang', $new_lang);
        } else {
            lcm_log("lcm_set_language() is not happy, wrong lang code?");
Example #5
0
function show_login($cible, $prive = 'prive', $message_login = '')
{
    $error = '';
    $login = _request('var_login');
    $logout = _request('var_logout');
    // If the cookie fails, inc_auth tried to redirect to lcm_cookie who
    // then tried to put a cookie. If it is not there, it is "cookie failed"
    // who is there, and it's probably a bookmark on privet=yes and not
    // a cookie failure.
    $cookie_failed = "";
    if (_request('var_cookie_failed')) {
        $cookie_failed = $_COOKIE['lcm_session'] != 'cookie_test_failed';
    }
    global $author_session;
    global $lcm_session;
    global $clean_link;
    if (!$cible) {
        // cible = destination
        $cible = new Link(_request('var_url', 'index.php'));
    }
    $cible->delVar('var_erreur');
    $cible->delVar('var_url');
    $cible->delVar('var_cookie_failed');
    $clean_link->delVar('var_erreur');
    $clean_link->delVar('var_login');
    $clean_link->delVar('var_cookie_failed');
    $url = $cible->getUrl();
    // This populates the $author_session variable
    include_lcm('inc_session');
    verifier_visiteur();
    if ($author_session and !$logout and ($author_session['status'] == 'admin' or $author_session['status'] == 'normal')) {
        if ($url != $GLOBALS['clean_link']->getUrl()) {
            lcm_header("Location: " . $cible->getUrlForHeader());
        }
        // [ML] This is making problems for no reason, we use login only
        // for one mecanism (entering the system).
        // echo "<a href='$url'>"._T('login_this_way')."</a>\n";
        echo "<a class='content_link' href='index.php'>" . _T('login_this_way') . "</a>\n";
        return;
    }
    if (_request('var_erreur') == 'pass') {
        $error = _T('login_password_incorrect');
    }
    // The login is memorized in the cookie for a possible future admin login
    if (!$login && isset($_COOKIE['lcm_admin'])) {
        if (preg_match("/^@(.*)\$/", $_COOKIE['lcm_admin'], $regs)) {
            $login = $regs[1];
        }
    } else {
        if ($login == '-1') {
            $login = '';
        }
    }
    // other sources for authentication
    $flag_autres_sources = isset($GLOBALS['ldap_present']) ? $GLOBALS['ldap_present'] : '';
    // What informations to pass?
    if ($login) {
        $status_login = 0;
        // unknown status
        $login = clean_input($login);
        $query = "SELECT id_author, status, password, prefs, alea_actuel, alea_futur \n\t\t\t\t\tFROM lcm_author \n\t\t\t\t\tWHERE username='******'";
        $result = lcm_query($query);
        if ($row = lcm_fetch_array($result)) {
            if ($row['status'] == 'trash' or $row['password'] == '') {
                $status_login = -1;
                // deny
            } else {
                $status_login = 1;
                // known login
                // Which infos to pass for the javascript ?
                $id_author = $row['id_author'];
                $alea_actuel = $row['alea_actuel'];
                // for MD5
                $alea_futur = $row['alea_futur'];
                // Button for lenght of connection
                if ($row['prefs']) {
                    $prefs = unserialize($row['prefs']);
                    $rester_checked = $prefs['cnx'] == 'perma' ? ' checked=\'checked\'' : '';
                }
            }
        }
        // Unknown login (except LDAP) or refused
        if ($status_login == -1 or $status_login == 0 and !$flag_autres_sources) {
            $error = _T('login_identifier_unknown', array('login' => htmlspecialchars(clean_output($login))));
            $login = '';
            // [ML] Not sure why this was here, but headers are already sent
            // therefore it causes an error message (which is not shown, but
            // might make a mess, knowing how PHP runs differently everywhere..)
            // @lcm_setcookie('lcm_admin', '', time() - 3600);
        }
    }
    // Javascript for the focus
    if ($login) {
        $js_focus = 'document.form_login.session_password.focus();';
    } else {
        $js_focus = 'document.form_login.var_login.focus();';
    }
    // [ML] we should probably add a help link here, since tech, but let's see
    // how many users complain first, since this should affect only tech users
    if ($cookie_failed == "yes") {
        $error = _T('login_warning_cookie');
    }
    echo open_login();
    // [ML] Looks like there is no reason why to use $clean_link (defined in inc_version.php)
    // It would cause very strange bugs when the "feed_globals()" were removed from inc_version
    // and in the end, well, it looks rather useless.
    //
    // Strange bugs were caused because $action would be "./" and therefore it
    // would call index.php -> listcases.php -> includes inc_auth.php who then
    // calls auth(), who redirects to the login page.
    $action = $clean_link->getUrl();
    // $action = "lcm_login.php";
    if ($login) {
        // Shows the login form, including the MD5 javascript
        $flag_challenge_md5 = true;
        if ($flag_challenge_md5) {
            echo '<script type="text/javascript" src="inc/md5.js"></script>';
        }
        echo "\n";
        echo '<form name="form_login" action="lcm_cookie.php" method="post"';
        if ($flag_challenge_md5) {
            echo " onsubmit='if (this.session_password.value) {\n\t\t\t\tthis.session_password_md5.value = calcMD5(\"{$alea_actuel}\" + this.session_password.value);\n\t\t\t\tthis.next_session_password_md5.value = calcMD5(\"{$alea_futur}\" + this.session_password.value);\n\t\t\t\tthis.session_password.value = \"\"; }'";
        }
        echo ">\n";
        echo "<div class='main_login_box' style='text-align:" . $GLOBALS["lcm_lang_left"] . ";'>\n";
        if ($error) {
            echo "<div style='color:red;'><b>" . _T('login_access_denied') . " {$error}</b></div><br />\n";
        }
        if ($flag_challenge_md5) {
            // This is printed with javascript so that it is hidden from navigators not
            // using JS, since they will see the username field anyway.
            echo "<script type=\"text/javascript\"><!--\n" . "document.write('" . addslashes(_T('login_login')) . " <b>{$login}</b><br/>" . "<font size=\\'2\\'><a href=\\'lcm_cookie.php?cookie_admin=no&amp;url=" . rawurlencode($action) . "\\' class=\\'link_btn\\'>" . _T('login_other_identifier') . "</a></font>');\n" . "//--></script>\n";
            // If javascript is active, we pass the login in the hidden field
            echo "<input type='hidden' name='session_login_hidden' value='{$login}' />";
            // If javascript is not active, the login is still modifiable
            // (since the challenge is not used)
            echo "<noscript>";
        }
        echo "\t<label for='session_login'><b>" . _T('login_login') . "</b> (" . _T('login_info_login') . ")<br /></label>";
        echo "\t<input type='text' name='session_login' id='session_login' class='forml' value=\"{$login}\" size='40' />\n";
        if ($flag_challenge_md5) {
            echo "</noscript>\n";
        }
        echo "\t<p />\n";
        echo "\t<label for='session_password'><b>" . _T('login_password') . "</b><br /></label>";
        echo "\t<input type='password' name='session_password' id='session_password' class='forml' value=\"\" size='40' />\n";
        echo "\t<input type='hidden' name='essai_login' value='oui' />\n";
        echo "\t<br />&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' name='session_remember' value='yes' id='session_remember'{$rester_checked} /> ";
        echo "\t<label for='session_remember'>" . _T('login_remain_logged_on') . "</label>";
        echo "\t<input type='hidden' name='url' value='{$url}' />\n";
        echo "\t<input type='hidden' name='session_password_md5' value='' />\n";
        echo "\t<input type='hidden' name='next_session_password_md5' value='' />\n";
        echo "<div align='right'><input class='button_login' type='submit' value='" . _T('button_validate') . "' /></div>\n";
        echo "</div>";
        echo "</form>";
    } else {
        // Ask only for the login/username
        $action = quote_amp($action);
        echo "<form name='form_login' action='{$action}' method='post'>\n";
        echo "<div class='main_login_box' style='text-align:" . $GLOBALS["lcm_lang_left"] . ";'>";
        if ($error) {
            echo "<span style='color:red;'><b>" . _T('login_access_denied') . " {$error}</b></span><p />";
        }
        echo "<label><b>" . _T('login_login') . '</b> (' . _T('login_info_login') . ')' . "<br /></label>";
        echo "<input type='text' name='var_login' class='forml' value=\"\" size='40' />\n";
        echo "<input type='hidden' name='var_url' value='{$url}' />\n";
        echo "<div align='right'><input class='button_login' type='submit' value='" . _T('button_validate') . "' /></div>\n";
        echo "</div>";
        echo "</form>";
    }
    // Focus management
    echo "<script type=\"text/javascript\"><!--\n" . $js_focus . "\n//--></script>\n";
    // Start the login footer
    echo "<div align='left' style='font-size: 12px;' >";
    echo "<div class='lang_combo_box'>" . menu_languages() . "</div>\n";
    // button for "forgotten password"
    include_lcm('inc_mail');
    if (server_can_send_email()) {
        echo '<a href="lcm_pass.php?pass_forgotten=yes" target="lcm_pass" onclick="' . "javascript:window.open(this.href, 'lcm_pass', 'scrollbars=yes, resizable=yes, width=640, height=280'); return false;\" class=\"link_btn\">" . _T('login_password_forgotten') . '</a>';
    }
    $register_popup = 'href="lcm_pass.php?register=yes" target="lcm_pass" ' . ' onclick="' . "javascript:window.open('lcm_pass.php?register=yes', 'lcm_pass', 'scrollbars=yes, resizable=yes, width=640, height=500'); return false;\"";
    $open_subscription = read_meta("site_open_subscription");
    if ($open_subscription == 'yes' || $open_subscription == 'moderated') {
        echo "&nbsp;&nbsp;&nbsp;<a {$register_popup} class=\"link_btn\">" . _T('login_register') . '</a>';
    }
    echo "</div>\n";
    echo close_login();
}
Example #6
0
 /**
  * Loger un auteur suite a son identification
  *
  * @param array $auteur
  */
 function auth_loger($auteur, $refuse_cookie_admin=false){
	if (!is_array($auteur) OR !count($auteur))
		return false;

	$session = charger_fonction('session', 'inc');
	$session($auteur);
	$p = ($auteur['prefs']) ? unserialize($auteur['prefs']) : array();
	$p['cnx'] = ($auteur['cookie'] == 'oui') ? 'perma' : '';
	$p = array('prefs' => serialize($p));
	sql_updateq('spip_auteurs', $p, "id_auteur=" . $auteur['id_auteur']);

	if ($auteur['statut'] == 'nouveau') {
		$session(); // charger la session car on va la modifier
		$auteur['statut'] = acces_statut($auteur['id_auteur'], $auteur['statut'], $auteur['bio']);
	}

	// Si on est admin, poser le cookie de correspondance
	include_spip('inc/cookie');
	if (!$refuse_cookie_admin AND $auteur['statut'] == '0minirezo') {
		spip_setcookie('spip_admin', '@'.$auteur['login'],
		time() + 7 * 24 * 3600);
	}
	// sinon le supprimer ...
	else {
		spip_setcookie('spip_admin', '',1);
	}

	//  bloquer ici le visiteur qui tente d'abuser de ses droits
	verifier_visiteur();
	return true;
}