Bonjour,
Je voulais savoir si je pouvais faire des optimisations dans ce code que j'ai déjà pas mal arrangé mais je suis encore un débutant.
Je vous remercie d'avance.

Réécriture du sujet.

Ps : Je sais que dans le Template.html les tableaux pour le design sont déconseillés mais c'est juste un thème que j'ai trouvé pour mes testes.

Template.html
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html>
	<head>
		<title>{WIKI_TITLE} | {PAGE_TITLE}</title>
		<meta charset="utf-8">
		<meta name="author" content="">
		<meta name="description" content="{DESCRIPTION}">
		<meta name="keywords" content="{KEYWORDS}">
		<meta name="viewport" content="width=device-width, maximum-scale=1">
		<link rel="stylesheet" type="text/css" href="{THEMES_DIR}{THEME}{CSS_FILE}">
		<link rel="shortcut icon" type="image/x-icon" href="{FAVICON_FILE}">
	</head>
	<body>
		<table width="100%" cellpadding="4" cellspacing="0" summary="{PAGE_TITLE}">
			<thead>
				<tr>
					<th colspan="3">
						<h1>{WIKI_TITLE} | {PAGE_TITLE}</h1>
						<p>{MOTTO}</p>
					</th>
				</tr>
				<tr>
					<td class="Links" colspan="2" align="left">
						{HOME}
					</td>
					<td class="Links" colspan="2" align="right">
						{EDIT} | {HELP}
					</td>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td id="Content" colspan="3">
						{CONTENT}
					</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td class="Links" align="left">
						{SEARCH}
					</td>
					<td class="Links" align="center">
						<p>{SOON}</p>
					</td>
					<td class="Links" align="right">
						{EDIT} | {HELP}
					</td>
				</tr>
			</tfoot>
		</table>
	</body>
</html>
Wik-Config.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
// CONFIGURATION !
    $WIKI_TITLE			=	'';
    $MOTTO              =   '';
    $DESCRIPTION        =   '';
    $KEYWORDS           =   '';
    $START_PAGE			=	'Accueil';
    $ADMIN_PAGE_NAME    =   'Admin';
    $PAGES_PAGE_NAME    =   'Liste des pages';
    $THEME              =   'default/';
// Boutons !
    $HOME_BUTTON        =   'Accueil';
    $HELP_BUTTON        =   'Aide';
    $EDIT_BUTTON        =   'Éditer';
    $DONE_BUTTON        =   'Valider';
    $PROTECTED_BUTTON   =   'Page verrouillé !';
// Erreurs !
    $MISSING_TEMPLATE   =   'Template.html est manquant !';
    $ERROR              =   'Erreur(s) !';
// Fichiers et dossiers !
    $THEMES_DIR         =   'themes/';
    $PAGES_DIR          =   'pages/';
    $CSS_FILE           =   'Styles.css';
    $TEMPLATE_FILE      =   'Template.html';
    $FAVICON_FILE       =   'favicon.ico';
?>
index.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
	include('Wik-Config.php');
 
	$CONTENT = '';
 
	$PAGE = isset($_GET['page']) ? $_GET['page'] : '';
	$ACTION = isset($_GET['action']) ? $_GET['action'] : '';
// Détermine la page à afficher !
	if (! $PAGE_TITLE = $PAGE) {
		if ($ACTION == "admin") {
			$PAGE_TITLE = $ADMIN_PAGE_NAME;
		}
		elseif ($ACTION == "pages") {
			$PAGE_TITLE = $PAGES_PAGE_NAME;
		}
		else {
			$PAGE_TITLE = $START_PAGE;
		}
	}
// Écrit les changements sur la page, s'il y en a !
	if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		$FILE = fopen($PAGES_DIR . stripslashes($_POST['page']) . '.txt', 'r+');
		ftruncate ($FILE , 0);
		if (! $FILE = fopen($PAGES_DIR . stripslashes($_POST['page']) . '.txt', 'r+')) {
			echo $ERROR;
		}
		elseif (get_magic_quotes_gpc()) {
			fputs($FILE, trim(stripslashes($_POST['content'])));
		}
		else {
			fputs($FILE, trim($_POST['content']));	   
		}
		fclose($FILE);
		header('location: index.php?page=' . urlencode(stripslashes($_POST['page'])));
	}
// Lit et analyse le template !
	if (! $FILE = @fopen($THEMES_DIR . $THEME . $TEMPLATE_FILE, 'r')) {
		echo $MISSING_TEMPLATE;
	}
	$TEMPLATE = fread($FILE, filesize($THEMES_DIR . $THEME . $TEMPLATE_FILE));
	fclose($FILE);
// Détermine l'access mode !
	if ($ACTION == 'edit' || $ACTION <> '') {
		$HTML = preg_replace('/{EDIT}/', $EDIT_BUTTON, $TEMPLATE);
	}
	elseif (is_writable($PAGES_DIR . $PAGE_TITLE . '.txt')) {
		$HTML = preg_replace('/{EDIT}/', '<a href="index.php?page=' . $PAGE_TITLE . '&action=edit">' . $EDIT_BUTTON . '</a>', $TEMPLATE);
	}
	else {
		$HTML = preg_replace('/{EDIT}/', $EDIT_BUTTON, $TEMPLATE);
	}
 
	if (($FILE = @fopen($PAGES_DIR . $PAGE_TITLE . ".txt", "r")) || $ACTION <> "") {
		$CONTENT = "\n" . @fread($FILE, @filesize($PAGES_DIR . $PAGE_TITLE . ".txt")) . "\n";
		@fclose($FILE);
		$CONTENT = preg_replace("/\\$/Umsi", "$", $CONTENT);
		$CONTENT = preg_replace("/\\\/Umsi", "\", $CONTENT);
	}
// Remplace les valeurs du template !
	$HTML = preg_replace('/{FAVICON_FILE}/', $FAVICON_FILE, $HTML);
	$HTML = preg_replace('/{CSS_FILE}/', $CSS_FILE, $HTML);
	$HTML = preg_replace('/{MOTTO}/', $MOTTO, $HTML);
	$HTML = preg_replace('/{KEYWORDS}/', $KEYWORDS, $HTML);
	$HTML = preg_replace('/{DESCRIPTION}/', $DESCRIPTION, $HTML);
	$HTML = preg_replace('/{THEMES_DIR}/', $THEMES_DIR, $HTML);
	$HTML = preg_replace('/{THEME}/', $THEME, $HTML);
	$HTML = preg_replace('/{PAGE_TITLE}/', $PAGE_TITLE, $HTML);
	$HTML = preg_replace('/{HOME}/', '<a href="index.php">' . $HOME_BUTTON . '</a>', $HTML);
	$HTML = preg_replace('/{HELP}/', '<a href="index.php?page=' . $HELP_BUTTON . '">' . $HELP_BUTTON . '</a>', $HTML);
	$HTML = preg_replace('/{WIKI_TITLE}/', $WIKI_TITLE, $HTML);

	if ($ACTION == 'edit') {
		$CONTENT = '<form method="post" action="index.php"><textarea name="content" style="width: 100%; height: 300px; resize: none">' . $CONTENT . '</textarea><input type="hidden" name="page" value="' . $PAGE_TITLE . '" /><br /><input type="submit" value="' . $DONE_BUTTON . '" accesskey="s" /></form>';
	}
	elseif ($ACTION == 'admin') {
		$CONTENT = '<p>SOON</p>';
	}
	elseif ($ACTION == 'pages') {
		$CONTENT = "<p>SOON</p>";
	}
// Affiche la page !
	$HTML = preg_replace('/{CONTENT}/', $CONTENT, $HTML);
	echo $HTML;
?>