Location: PHPKode > projects > PhpScheduler > PhpScheduler/index.php
<?php
/**
 * 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 3 of the License, or
 *     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, see <http://www.gnu.org/licenses/>.
 */


/**
 * PhpScheduler by Polymorf and Mitz
 */
/**
 * Include du template
 */


/**
 * Si le fichier config n'existe pas on affiche l'installeur
 */
if ( !file_exists( "conf/config.php" ) ) {
	header( 'Location: install/install.php' );
}

/**
 * Include des librairie
 */
$basedir = dirname( __FILE__ );
require_once( $basedir . "/template/index.template.php" );
require_once( $basedir . "/lib/user.php" );
require_once( $basedir . "/lib/io.php" );

session_start();
if ( isset( $_COOKIE["phpscheduler"] ) ) {
	if ( $_COOKIE["phpscheduler"] != "" ) {
		$user = unserialize( stripslashes( $_COOKIE["phpscheduler"] ) );
		$_SESSION["user"] = serialize( $user );
	}
}
/**
 * Si l'utilisateur demande une deconnection on detruit la session
 */
if ( isset( $_GET["disconnect"] ) ) {
	unset( $_SESSION["user"] );
	setcookie( 'phpscheduler', "", ( time() - 3600 ) );
	header( 'Location: index.php' );
}



/**
 * Changement de mot de passe
 */
if ( isset( $_POST["newpassword1"] ) && isset( $_POST["newpassword2"] ) ) {
	$newpass1 = $_POST["newpassword1"];
	$newpass2 = $_POST["newpassword2"];
	if ( $newpass1 == $newpass2 ) {
		if ( strlen( $newpass1 ) > 5 ) {
			$user = unserialize( $_SESSION["user"] );
			if ( $user -> logged ) {
				$user -> update_password( $newpass1 );
				echo "<div class=\"useraddok\">Mot de passe modifier</div>";
			}
			unset( $user );
		}else {
			echo "<div class=\"error\">Le mot de passe doit faire 6 caract�res minimum</div>";
		}
	}else {
		echo "<div class=\"error\">Les mots de passe ne sont pas les memes</div>";
	}

}
/**
 * Creation du template
 */
$template = new Index_Template();
/**
 * Si l'utilisateur s'inscrit
 */
if ( isset( $_POST["inscription"] ) ) {
	inscription();
}
/**
 * Affichage de la page demander
 */

$template -> print_html_header();
if ( file_exists( $basedir . "/conf/config.php" ) ) {
	if ( file_exists( $basedir . "/install/install.php" ) ) {
		if ( DEBUG_MODE == 0 ) {
			echo "<div class=\"debug_error\">supprimer le fichier install/install.php</div>";
		}
	}
	if ( isset( $_GET["page"] ) ) {
		$template -> print_body( $_GET["page"] );
	}
	else {
		$template -> print_body( "" );
	}
	$template -> print_footer();
	$template -> print_html_footer();
}
function inscription()
{
	global $template;
	/**
	 * Include de la classe user
	 */
	$basedir = dirname( __FILE__ );
	require_once( $basedir . "/lib/user.php" );

	$template -> print_html_header();
	/**
	 * recuperation des donner du formulaire
	 */
	$login = addslashes( $_POST["register_login"] );
	$password = addslashes( $_POST["register_pass1"] );
	$password2 = addslashes( $_POST["register_pass2"] );
	$email = addslashes( $_POST["register_email1"] );
	$email2 = addslashes( $_POST["register_email2"] );
	$nom = addslashes( $_POST["register_nom"] );
	$prenom = addslashes( $_POST["register_prenom"] );
	$adresse = addslashes( $_POST["register_adresse"] );

	/**
	 * Affectation des donn�e de l'objet $user
	 */
	$success = true;
	if ( strlen($login) < 4 ){
		$success = false;
		echo "<div class=\"error\">Identifiant trop court</div>";
	}
	if ( $password != $password2 ) {
		$success = false;
		echo "<div class=\"error\">Les Mots de passe ne sont pas les meme</div>";
	}
	if ( $email != $email2 ) {
		$success = false;
		echo "<div class=\"error\">Les emails ne sont pas les meme</div>";
	}
	if ( $success ) {
		$user = new user( $login, $password );
		if ( $user -> exist() ) {
			echo "<div class=\"error\">cet utilisateur existe deja, merci de choisir un autre login</div>";
		}else {
			$user -> email = $email;
			$user -> nom = $nom;
			$user -> prenom = $prenom;
			$user -> adresse = $adresse;
			echo "<div class=\"error\">Login = </div>";
			if ( $user -> add() ) {
				echo "<div class=\"useraddok\">Compte cr&eacute;&eacute;</div>";
			}

			unset( $user );
		}
	}


	$template -> print_body( "" );
	$template -> print_footer();
	$template -> print_html_footer();
	exit();
}
?>
Return current item: PhpScheduler