comparison admin.php @ 0:629389204276

Import initial
author Franck Deroche <webmaster@defr.org>
date Sat, 20 Oct 2007 14:15:10 +0200
parents
children ec0c926a78a6
comparison
equal deleted inserted replaced
-1:000000000000 0:629389204276
1 <?php
2 if(!is_null($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml'))
3 header('Content-Type: application/xhtml+xml; charset=UTF-8');
4 else
5 header('Content-Type: text/html; charset=UTF-8');
6
7 include("classes.php");
8 $Data=new DataAccess;
9 $Req = new Requete;
10
11 $mode = $Req->get('mode');
12 switch($mode) {
13 case 'nvBrouillon':
14 $nvTitre = $Req->get('Titre', 'POST');
15 $nvContenu = $Req->get('Contenu', 'POST');
16 $Data->debugQuery("INSERT INTO Brouillons SET Titre='{$nvTitre}', Contenu='{$nvContenu}'");
17 break;
18
19 case 'nvTache':
20 $nvThing = $Req->get('Tache');
21 $Data->Query("INSERT INTO ToDo SET Thing='{$nvThing}'");
22 break;
23
24 case 'nvPost':
25 $id = $Req->get('id', 'POST');
26 $versionAc = $Req->get('versionAc', 'POST');
27 $newVersion = $Req->get('newVersion', 'POST');
28 $mood = $Req->get('mood', 'POST');
29 $tbAddress = $Req->get('tb', 'POST');
30 if($versionAc == 'Version 10' && $newVersion != 'Nouvelle version ?' && !empty($newVersion))
31 $version = $newVersion;
32 else
33 $version = $versionAc;
34 $Data->Query("SELECT * FROM Brouillons WHERE id_brouillon={$id}");
35 $row = $Data->GetRow();
36 $row['Titre'] = addslashes($row['Titre']);
37 $row['Contenu'] = addslashes($row['Contenu']);
38 $datePost = gmdate("Y-m-d H:i:s", time() + 3600);
39 $Data->Query("
40 INSERT INTO Mess(Titre, DatePost, num_version, Message, Emot)
41 VALUES('{$row['Titre']}', '{$datePost}', '{$version}', '{$row['Contenu']}', '{$mood}')");
42 $Data->Query("DELETE FROM Brouillons WHERE id_brouillon={$id}");
43 $Data->Query("SELECT num_mess, Message FROM Mess ORDER BY num_mess DESC LIMIT 0, 1");
44 $id_row = $Data->GetRow();
45 // Gestion des tags
46 $arTags = TextUtils::SplitTags($Req->get('Tags'));
47 foreach($arTags as $tagAj)
48 {
49 $n = $Data->Query("SELECT idTag FROM Tags WHERE Tag='{$tagAj}'");
50 if($n == 0)
51 {
52 // Si le tag n'existe pas, on le crée
53 $Data->Query("INSERT INTO Tags SET Tag='{$tagAj}'");
54 $Data->Query("SELECT idTag FROM Tags WHERE Tag='{$tagAj}'");
55 }
56 $row_tag = $Data->GetRow();
57 $Data->Query
58 ("
59 INSERT INTO Lien_Tags_Posts
60 SET idMess={$id_row['num_mess']}, idTag={$row_tag['idTag']}
61 ");
62 }
63 // Génération de trackbacks
64 if(!empty($tbAddress) && substr($tbAddress, 0, 4)=='http') {
65 $ar_tbAddress = parse_url($tbAddress);
66 if(!array_key_exists('port', $ar_tbAddress)) $ar_tbAddress['port'] = 80;
67 if(!array_key_exists('path', $ar_tbAddress)) $ar_tbAddress['path'] = '/';
68 if(array_key_exists('query', $ar_tbAddress)) $ar_tbAddress['query'] = '?' . $ar_tbAddress['query'];
69 $fp = fsockopen($ar_tbAddress['host'], $ar_tbAddress['port'], $errno, $errstr, 15);
70 if($fp) {
71 $genToSend = "POST {$ar_tbAddress['path']}{$ar_tbAddress['query']} HTTP/1.0\r\n";
72 $genToSend .= "Host: {$ar_tbAddress['host']}\r\n";
73 $genToSend .= "Content-Type: application/x-www-form-urlencoded \n";
74
75 // Essai de récuperation de l'encodage...Envoie en iso si pas d'indication d'UTF...
76 $argToSend = "__info=1";
77 $toSend = $genToSend . "Content-Length: " . strlen($argToSend) . "\n\n";
78 $toSend .= $argToSend;
79 echo("<pre>$toSend</pre>");
80 fwrite($fp, $toSend);
81 while(!feof($fp))
82 $result .= fgets($fp, 128);
83 fclose($fp);
84 if(!preg_match('/<encoding>(UTF-8|utf-8)<\/encoding>/msU',$result)) {
85 $row['Titre'] = utf8_decode($row['Titre']);
86 $row['Message'] = utf8_decode($row['Message']);
87 }
88
89 $fp = fsockopen($ar_tbAddress['host'], 80, $errno, $errstr, 15);
90 $argToSend = "title=" . htmlentities(urlencode($row['Titre'])) . "&blog_name=Dual+Blog";
91 $argToSend .= "&url=http://defr.org/blog/posts/{$row['num_mess']}&excerpt="
92 . htmlentities(urlencode(substr(strip_tags($row['Message']), 0, 255) . "..."));
93
94 $toSend = $genToSend . "Content-Length: " . strlen($argToSend) . "\n\n";
95 $toSend .= $argToSend;
96 echo("<pre><![CDATA[$toSend]]></pre>");
97 echo("<![CDATA[");
98 fwrite($fp, $toSend);
99 while (!feof($fp)) {
100 echo fgets($fp, 128);
101 }
102 echo("]]>");
103 fclose($fp);
104 }
105 }
106 break;
107 }
108 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
109
110 <html xmlns='http://www.w3.org/1999/xhtml'>
111 <head>
112 <title>Administration : Conception &amp; Design</title>
113 <link rel='StyleSheet' type='Text/CSS' href='css/admin.css' />
114 <script type='text/javascript' src='admin.js'>/* Die IE, diiie */</script>
115 </head>
116
117 <body>
118 <h3>Administration de Dual Blog</h3>
119 <ul id='Menu'>
120 <li><div id='Brouillons'>Brouillons</div></li>
121 <li><div id='Posts'>Posts publiés</div></li>
122 <li><div id='Designs'>Designs</div></li>
123 <li><div id='ToDo'>To-Do</div></li>
124 </ul>
125 <div id='GestPosts'>
126 <ul>
127 <?php
128 $Data->Connect();
129 $Data->Query("SELECT * FROM Mess ORDER BY num_version, num_mess DESC LIMIT 0, 10");
130 $versionAc="";
131 $i=0;
132 $ar_Version = array();
133 while(0!==($val=$Data->GetRow())) {
134 if($val['num_version']!=$versionAc) {
135 if($i!=0) echo("</ul>\n</li>");
136 echo(" <li>{$val['num_version']} :\n <ul>");
137 $versionAc=$val['num_version'];
138 $ar_Version[] = $versionAc;
139 $i++;
140 }
141 $Titre=$Data->utf8_ensure($val['Titre']);
142 echo("
143 \t <li>{$Titre}<span class='Admin'><a href='#id={$val['num_mess']}'>Editer</a> -- <a href='#id={$val['num_mess']}'>Supprimer</a> -- <a href='?id={$val['num_mess']}'>Gérer les commentaires</a></span></li>");
144 }
145 echo("\n </ul>\n </li>\n");
146 ?>
147 </ul>
148 </div>
149
150 <div id='GestDesigns'>
151 <ul>
152 <li class='Add'><a href='#'>Ajouter un nouveau design au weblog</a></li>
153 <li>Modifier les designs déja existants</li>
154 </ul>
155 </div>
156
157 <div id='GestBrouillons'>
158 <ul>
159 <li class='Add'><a href='#'>Ajouter un nouveau brouillon</a>
160 <form method='post' action='admin.php'>
161 <div>
162 <input type='hidden' name='mode' value='nvBrouillon' />
163 <input type='text' name='Titre' value='Titre' />
164 <textarea name='Contenu' rows='10' cols='30'></textarea>
165 <input type='submit' value='Valider ce brouillon' />
166 </div>
167 </form>
168 </li>
169 <?
170 $Data->Query("SELECT * FROM Brouillons ORDER BY id_brouillon DESC");
171 while(0!==($val=$Data->GetRow())) {
172 echo("
173 <li>{$val['Titre']} <span class='Admin'><a href='#id={$val['id_brouillon']}'>Editer</a> -- <a href='#id={$val['id_brouillon']}'>Publier</a> -- <a href='?id={$val['id_brouillon']}'>Supprimer</a></span></li>");
174 }
175 ?>
176 </ul>
177 </div>
178
179 <div id='GestToDo'>
180 <ul>
181 <li class='Add'><a href='#'>Ajouter une nouvelle tâche</a>
182 <form method='post' action='admin.php'>
183 <div>
184 <input type='hidden' name='mode' value='nvTache' />
185 <input type='text' name='Tache' />
186 <input type='submit' value='Ajouter cette tâche' />
187 </div>
188 </form></li>
189 <?php
190 $Data->Query("SELECT * FROM ToDo ORDER By num_thing DESC");
191 while(0!==($val=$Data->GetRow())) {
192 echo("
193 <li>{$val['Thing']} <span class='Admin'><a href='#'>Fait</a> -- <a href='#'>Editer</a> -- <a href='#'>Supprimer</a></span></li>");
194 }
195 $Data->Close();
196 ?>
197 </ul>
198 </div>
199
200 <form method='post' action='#' id='editPost'>
201 <div>
202 <input type='hidden' name='mode' value='editBrouillon' />
203 <p><input type='text' name='Titre' value='Titre' /></p>
204 <p><textarea name='Contenu' rows='10' cols='30'></textarea></p>
205 <p><select name='mood' id='mood'>
206 <?php
207 $handle = opendir('mood');
208 while($file = readdir($handle))
209 {
210 if(strlen($file) > 3 && substr($file, -3) == 'png')
211 {
212 $short = substr($file, 0, -4);
213 echo("\t\t<option value='$short'><img src='mood/25/$file' alt='' />" . $short . "</option>\n");
214 }
215 }
216 closedir($handle);
217 ?>
218 </select></p>
219 <p><input type='text' name='Tags' value='Tags' /></p>
220 <input type='button' name='Save' value='Sauver la modification' />
221 </div>
222 </form>
223
224 <form method='post' action='admin.php' id='whichVersion'>
225 <div>
226 <!--a onclick='javascript:hidePubForm()'>Hide</a-->
227 <input type='hidden' name='mode' value='nvPost' />
228 <input type='hidden' name='id' />
229 <fieldset>
230 <legend>Catégorie du post</legend>
231 <label for='vAc'>Pour poster le post dans une catégorie déja existante, veuillez la choisir dans la liste ci-dessous :<br /></label>
232 <select name='versionAc' id='vAc'>
233 <option>Version 10</option>
234 <option>DeFr.org news</option>
235 </select>
236 <label for='nvCat'><br />Pour poster le post dans une catégorie n'existant pas encore, veuillez
237 entrer son nom : <br /></label>
238 <input type='text' name='newVersion' id='nvCat' value='Nouvelle version ?' />
239 </fieldset>
240 <fieldset>
241 <legend>Tags</legend>
242 <label for='Tags'>Histoire d'organiser les posts, et de pouvoir filtrer par centres d'interet, veuillez
243 préciser les <em>tags</em> à attribuer à ce post :<br /></label>
244 <input type='text' name='Tags' id='Tags' />
245 </fieldset>
246 <fieldset>
247 <legend>Mood / Emots</legend>
248 <label for='mood'>Pour assurer un minimum d'attrait aux posts, et leur attribuer un aspect graphique
249 sympathique, veuillez selectionner une emoticone pour le post, dans la liste suivante :<br /></label>
250 <select name='mood' id='mood'>
251 <?php
252 $handle = opendir('mood');
253 while($file = readdir($handle))
254 {
255 if(strlen($file) > 3 && substr($file, -3) == 'png')
256 {
257 $short = substr($file, 0, -4);
258 echo("\t\t\t<option value='$short'><img src='mood/25/$file' alt='' />" . $short . "</option>\n");
259 }
260 }
261 closedir($handle);
262 ?>
263 </select>
264 </fieldset>
265 <fieldset>
266 <legend>Trackback</legend>
267 <label for='tb'>Pour effectuer un trackback vers un autre post, rentrer son URL :<br /></label>
268 <input type='text' name='tb' id='tb' value='TrackBack ?' />
269 </fieldset>
270 <fieldset>
271 <legend>Publication</legend>
272 <label id='pubComment' for='pubButton' />
273 <input type='submit' name="pubButton" id="pubButton" value='Publier' />
274 </fieldset>
275 </div>
276 </form>
277
278 <div id='Infos'>
279 Administration de Dual Blog - Par DeFr - Icones &copy; David Lanham - The IconFactory -
280 Valide <a href="http://validator.w3.org/check?uri=referer">XHTML 1.1</a> et <a href='http://jigsaw.w3.org/css-validator/check/referer'>CSS 3</a>
281 </div>
282 </body>
283 </html>