Vikidia:Achille/sources/index.php

Aller à : navigation, rechercher
Version 0.1.5 (c)
Ces pages sont données pour consultation. Si vous souhaitez utiliser Achille, téléchargez de préférence les sources au format zip


<?php
/*
	Achille
	GPL v3
	Thomas Pimmel 2008
*/
 session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <link rel="shortcut icon" href="images/icone.png" type="image/png" />
  <link href="achille.css" rel="stylesheet" type="text/css" />
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Achille le robot</title>
<script type="text/javascript">
function masque (divid)
{
	var target;
	target = document.getElementById(divid) ;
	if (target.style.display == "none")
	{
		target.style.display = "" ;
	}
	 else
	{
		target.style.display = "none" ;
	}
}
function masqueaide (divid)
{
	var target;
	target = document.getElementById(divid) ;
	if (target.style.display == "none")
	{
		target.style.display = "" ;
		document.getElementById('taideid').innerHTML='Masquer l\'aide';
	}
	 else
	{
		target.style.display = "none" ;
		document.getElementById('taideid').innerHTML='Afficher l\'aide';
	}
}
function chgp (pid,text)
{
	document.getElementById(pid).innerHTML = text ;
}
</script>
</head>
<body>
<?php
//include
require ("includes/const.php");
//require ("includes/wiki.php");
require ("includes/form.php");
require ("includes/util.php");
require ("includes/user.php");
require ("includes/aide.php");
require ("includes/wiki.php");

//test du niveau d'identification
// 0=non identifié
// 1=identifié
// 2=admin
// 3=démonstration
$identlevel=identify();
$command=$_SESSION['command'];
$identifiant=$_SESSION['user'];
// afficher déconnexion
form_connect();
// Affichage du menu
switch ($command)
{
	case CMD_PASSWORD:
		form_mdp();
		break;
	case CMD_MAIN_MENU:
		// Menu administrateur
		if ($identlevel==2)	form_admin();
		else			form_user();
		break;
	case CMD_GESTION:
		//Afficher la listes des utilisateurs du robot
		form_userlist();
		form_mainmenu();
		break;
	case CMD_PREFS:
		//Afficher la listes des préférences
		form_prefs();
		form_mainmenu();
		break;
	case CMD_DEL_USER:
		// effectuer la destruction
		if ($_SESSION['argu'])
		{
			$arg=$_SESSION['argu'];
			us_deluser($arg);
			form_retour("Utilisateur $arg supprim&eacute");
			$_SESSION['argu']='';
		}
		break;
	case CMD_ADD_USER:
		//Ajouter un utilisateur
		$user=$_POST['user'];
		if ($user && us_adduser_mdp($user,$_POST['passwd'],$_POST['passwd2'],$_POST['stat']))
		{
			// retour
			form_retour("Utilisateur $user Ajouté");
		}
		else
		{
			// formulaire d'ajout
			form_add_user();
		}
		break;
	case CMD_CTC_WIKI:
		// Connexion à vikidia
		if (isset($_SESSION['ctc']))
		{
			w_Logout();
		}
		else				$result=w_Login($_SESSION['user'],$_SESSION['passwd']);
		$_SESSION['command']=CMD_MAIN_MENU;
		form_user();
		break;
		// préférences utilisateur
	case CMD_USER_PREFS:
		// changement de mot de passe ?
		$result=false;
		if (isset($_POST['newpassword']))
		{
			$identifiant=$_SESSION['user'];
			$newpass=$_POST['newpassword'];
			$newpass2=$_POST['password2'];
			$result=change_password($identifiant,$newpass,$newpass2);
		}
		if (!$result)
		{
			form_userprefs();
			form_mainmenu();
		}
		else
		{
			$_SESSION['command']=CMD_MAIN_MENU;
			if ($identlevel==2)	form_admin();
			else			form_user();
		}
		break;
	case CMD_USER_ANNONCES:
		if (isset($_POST['annonce']))
		{
			switch ($_POST['annonce'])
			{
			case "preview":
				// sauvegarde des données
				$_SESSION['msg']['texte']=stripslashes($_POST['message']);
				$_SESSION['msg']['section']=stripslashes($_POST['section']);
				$_SESSION['msg']['category']=stripslashes($_POST['category']);
				$_SESSION['msg']['from']='';
				// affichage pour contrôle
				form_preview($_SESSION['msg']);
				form_mainmenu();
				break;
			case "annonce":
				// boucler sur les messages
				$_SESSION['msg']['result']="continue";
				annonce_loop ();
				if ($_SESSION['msg']['result']=='error')
				{
					$_SESSION['msg']['from']='';
					form_annonce($_SESSION['msg']['category'],$_SESSION['msg']['section'],$_SESSION['msg']['texte']);
					form_mainmenu();
				}
				else
				{
					form_annonce('','','');
					form_mainmenu();
				}
				break;
			case "correction":
				form_annonce($_SESSION['msg']['category'],$_SESSION['msg']['section'],$_SESSION['msg']['texte']);
				form_mainmenu();
				break;
			default:
				break;
			}
		}
		else
		{
			form_annonce('','','');
			form_mainmenu();
		}
		break;
	case CMD_RN_CAT:
		if (isset($_POST['select']))	$_POST['select']=antislash($_POST['select']);
		if (isset($_POST['rncat']))
		{
			switch ($_POST['rncat'])
			{
			case "preview":
				$_SESSION['rncat']['from']=stripslashes($_POST['from']);
				$_SESSION['rncat']['to']=stripslashes($_POST['to']);
				$_SESSION['rncat']['com']=stripslashes($_POST['com']);
				unset ($_SESSION['rncat']['list']);
				$_SESSION['rncat']['list']=form_rn_preview(0);
				form_mainmenu();
				break;
			case "correction":
				unset ($_SESSION['rncat']['list']);
				form_rncat($_SESSION['rncat']['from'],$_SESSION['rncat']['to'],$_SESSION['rncat']['com']);
				form_mainmenu();
				break;
			case "selall":
				form_rn_preview(0);
				form_mainmenu();
				break;
			case "selno":
				form_rn_preview(1);
				form_mainmenu();
				break;
			case "selinv":
				form_rn_preview(2);
				form_mainmenu();
				break;
			case "rncat":
				$_SESSION['rncat']['select']=$_POST['select'];
				rn_change();
				unset ($_SESSION['rncat']['list']);
				form_rncat('','','');
				form_mainmenu();
				break;
			}
		}
		else
		{
			form_rncat('','','');
			form_mainmenu();
		}
		break;
	case CMD_USER_REPLACE:
		if (isset($_POST['select']))	$_POST['select']=antislash($_POST['select']);
		if (isset($_POST['sr']))
		{
			switch ($_POST['sr'])
			{
			case "preview":
				$_SESSION['sr']['search']=stripslashes($_POST['search']);
				$_SESSION['sr']['replace']=stripslashes($_POST['replace']);
				$_SESSION['sr']['com']=stripslashes($_POST['com']);
				$_SESSION['sr']['case']=$_POST['case'];
				$_SESSION['sr']['maj']=$_POST['maj'];
				$_SESSION['sr']['cat']=stripslashes($_POST['cat']);
				$_SESSION['sr']['namesp']=$_POST['model']|$_POST['image'];
				unset ($_SESSION['sr']['list']);
				unset ($_SESSION['sr']['details']);
				$_SESSION['sr']['list']=form_sr_preview(0);
				form_mainmenu();
				break;
			case "details":
				if (isset($_SESSION['sr']['details']))
				{
					unset ($_SESSION['sr']['details']);
					form_sr_preview(4);
				}
				else
				{
					$_SESSION['sr']['details']=GetDetails($_SESSION['sr']['list'],$_SESSION['sr']['search'],$_SESSION['sr']['case']);
					form_sr_preview(3);
				}
				form_mainmenu();
				break;
			case "correction":
				unset ($_SESSION['sr']['list']);
				unset ($_SESSION['sr']['details']);
				form_sr($_SESSION['sr']['search'],
					$_SESSION['sr']['replace'],
					$_SESSION['sr']['com'],
					$_SESSION['sr']['case'],
					$_SESSION['sr']['maj'],
					$_SESSION['sr']['cat'],
					$_SESSION['sr']['namesp']);
				form_mainmenu();
				break;
			case "allart":
				form_sr_preview(0);
				form_mainmenu();
				break;
			case "noart":
				form_sr_preview(1);
				form_mainmenu();
				break;
			case "invart":
				form_sr_preview(2);
				form_mainmenu();
				break;
			case "sr":
				$_SESSION['sr']['select']=$_POST['select'];
				sr_loop();
				unset ($_SESSION['sr']['list']);
				unset ($_SESSION['sr']['details']);
				form_sr('','','',false,true,'',0);
				form_mainmenu();
				break;
			}
		}
		else
		{
			form_sr('','','',false,true,'');
			form_mainmenu();
		}
		break;
	case CMD_READ_MAIL:
		$page=w_ReadMail(false);	// on élimine vous avez reçu un message
		$page=w_ReadMail(true);
		print("<div class='divmail'>$page</div>");
		form_mainmenu();
		break;
	case CMD_READ_LOG:
		$page=w_ReadMail(true,"Utilisateur:","/logs");
		print("<div class='divmail'>$page</div>");
		form_mainmenu();
		break;
	case CMD_READ_REQ:
		$page=w_ReadMail(true,"Vikidia:","/demandes","Achille");
		print("<div class='divmail'>$page</div>");
		form_mainmenu();
		break;
	case CMD_USER_WIKIF:
		if (isset($_POST['select']))	$_POST['select']=antislash($_POST['select']);
		if (isset($_POST['wikif']))
		{
			switch ($_POST['wikif'])
			{
			case "preview":
				$_SESSION['wikif']['mot']=stripslashes($_POST['mot']);
				$_SESSION['wikif']['com']=stripslashes($_POST['com']);
				$_SESSION['wikif']['pluriel']=$_POST['pluriel'];
				unset ($_SESSION['wikif']['list']);
				unset ($_SESSION['wikif']['details']);
				$_SESSION['wikif']['list']=form_wikif_preview(0);
				form_mainmenu();
				break;
			case "correction":
				unset ($_SESSION['wikif']['list']);
				form_wikif($_SESSION['wikif']['mot'],
					$_SESSION['wikif']['com'],
					$_SESSION['wikif']['pluriel']);
				form_mainmenu();
				break;
			case "allart":
				form_wikif_preview(0);
				form_mainmenu();
				break;
			case "noart":
				form_wikif_preview(1);
				form_mainmenu();
				break;
			case "invart":
				form_wikif_preview(2);
				form_mainmenu();
				break;
			case "wikif":
				$_SESSION['wikif']['select']=$_POST['select'];
				wikif_loop();
				unset ($_SESSION['wikif']['list']);
				form_wikif('','',true);
				form_mainmenu();
				break;
			case "details":
				if (isset($_SESSION['wikif']['details']))
				{
					unset ($_SESSION['wikif']['details']);
					form_wikif_preview(4);
				}
				else
				{
					$_SESSION['wikif']['details']=GetDetailsWikif(	$_SESSION['wikif']['list'],
											$_SESSION['wikif']['mot'],
											$_SESSION['wikif']['pluriel']);
					form_wikif_preview(3);
				}
				form_mainmenu();
				break;
			}
		}
		else
		{
			form_wikif('','',true);
			form_mainmenu();
		}
		break;
	case CMD_USER_IMAGE:
		if ($_POST['mif'])
		{
			$_SESSION['mif']['from']=stripslashes($_POST['from']);
			$_SESSION['mif']['nbr']=$_POST['nbr'];
			$_SESSION['mif']['jours']=$_POST['jours'];
			$_SESSION['mif']['heures']=$_POST['heures'];
			$_SESSION['mif']['flags']=$_POST['chmef']+$_POST['chlicence']+$_POST['chsource']+$_POST['chcat'];
			mif_loop();
			form_verif_image($_SESSION['mif']['from'],$_SESSION['mif']['nbr'],$_SESSION['mif']['flags'],$_SESSION['mif']['jours'],$_SESSION['mif']['heures']);
			form_mainmenu();
		}
		else
		{
			form_verif_image();
			form_mainmenu();
		}
		break;
	case CMD_USER_INTER:
		if ($_POST['inter'])
		{
			$_SESSION['inter']['from']=stripslashes($_POST['from']);
			$_SESSION['inter']['nbr']=$_POST['nbr'];
			$_SESSION['inter']['jours']=$_POST['jours'];
			$_SESSION['inter']['heures']=$_POST['heures'];
			loop_inter();
			form_inter($_SESSION['inter']['from'],$_SESSION['inter']['nbr'],$_SESSION['inter']['jours'],$_SESSION['inter']['heures']);
			form_mainmenu();
		}
		else
		{
			form_inter();
			form_mainmenu();
		}
		break;
	case CMD_USER_TYPO:
		if ($_POST['typo'])
		{
			$_SESSION['typo']['from']=stripslashes($_POST['from']);
			$_SESSION['typo']['nbr']=$_POST['nbr'];
			$_SESSION['typo']['jours']=$_POST['jours'];
			$_SESSION['typo']['heures']=$_POST['heures'];
			$_SESSION['typo']['flags']=$_POST['chpon']+$_POST['chgui']+$_POST['chtir']+$_POST['chmod'];
			loop_typo();
			//VerifBeeh();
			form_typo($_SESSION['typo']['from'],$_SESSION['typo']['nbr'],$_SESSION['typo']['flags'],$_SESSION['typo']['jours'],$_SESSION['typo']['heures']);
			form_mainmenu();
		}
		else
		{
			form_typo();
			form_mainmenu();
		}
		break;
	case CMD_USER_TEST:
		form_test();
		form_mainmenu();
		break;
	case CMD_USER_IMPORT:
		if (isset($_POST['import']))
		{
			switch ($_POST['import'])
			{
			case "first":
				$_SESSION['import']['url']=stripslashes($_POST['url']);
				if ($_POST['othercat'])	$_SESSION['import']['cat']=stripslashes($_POST['othercat']);
				else			$_SESSION['import']['cat']=stripslashes($_POST['maincat']);
				$_SESSION['import']['day']=$_POST['day'];
				$_SESSION['import']['reduce']=$_POST['reduce'];
				$_SESSION['import']['nb']=0;
				unset ($_SESSION['import']['list']);
				unset ($_SESSION['import']['catlist']);
				$_SESSION['import']['list']=make_import_list($_SESSION['import']['url']);
				if (!isset($_SESSION['import']['list']))
				{
					form_import	($_SESSION['import']['url'],$_SESSION['import']['cat'],
							$_SESSION['import']['reduce'],$_SESSION['import']['day']);
					form_mainmenu();
				}
				else
				{
					// chercher catégorie de départ
					print ("<div id='msgid' style='width=100%'><center>
					Chargement des catégories... veuillez patienter</center></div>");
					flush();
					@ob_flush();
					$_SESSION['import']['catlist']=GetCatList($_SESSION['import']['cat']);
					print ("<script type='text/javascript'>masque('msgid')</script>");
					flush();
					@ob_flush();
					form_next_image();
					form_mainmenu();
				}
				break;
			case "import":
				if ($_POST['catbis'])	$cat=$_POST['catbis'];
				else			$cat=$_POST['cat'];
				ImportImage	($_POST['imagedes'],$_POST['licence1'],$_POST['licence2'],$_POST['licence3'],
						$_POST['auteur'],$_POST['date'],$_POST['imagered'],$_POST['imagefull'],$cat);
			case "pass":
				$_SESSION['import']['nb']++;
				form_next_image();
				form_mainmenu();
				break;
			}
		}
		else
		{
			form_import();
			form_mainmenu();
		}
		break;
		form_mainmenu();
		break;
	case CMD_USER_POD:
		if (isset($_POST['date']) && isset($_POST['podlist']))
		{
			$pod=str_replace(array("\r\n","\r"),"\n",$_POST['podlist']);
			MakePOD($_POST['date'],stripslashes($pod));
		}
		else				form_pod();
		form_mainmenu();
		break;
	case CMD_USER_CATO:
		if ($_POST['cato'])
		{
			$_SESSION['cato']['from']=stripslashes($_POST['from']);
			$_SESSION['cato']['nbr']=$_POST['nbr'];
			$_SESSION['cato']['jours']=$_POST['jours'];
			$_SESSION['cato']['heures']=$_POST['heures'];
			$_SESSION['cato']['flags']=$_POST['illplus']+$_POST['illmoins']+$_POST['missplus']+$_POST['missmoins'];
			$_SESSION['cato']['categ']=$_POST['categ'];
			loop_cato();
			form_cato($_SESSION['cato']['from'],$_SESSION['cato']['nbr'],$_SESSION['cato']['flags'],$_SESSION['cato']['jours'],
				$_SESSION['cato']['heures'],$_SESSION['categ']);
			form_mainmenu();
		}
		else
		{
			form_cato();
			form_mainmenu();
		}
		break;
	case CMD_USER_TMP:
		form_mainmenu();
		break;
	//défaut
	default:
		$user=$_SESSION['argu'];
		print("Commande : $command / Argument : $user<br>");
		form_mainmenu();
		break;
}

//Pied de page
require ("includes/foot.php");
?>
</body>
</html>