001: <?php
002:
003: /*
004: ** Parties de code � adapter � yN :
005: ** - Appels � mysql_connect et mysql_select_db � ajouter (lignes 106 et 107)
006: ** - Fonctions showCadre (ligne 11) et showError (ligne 47) � remplacer
007: ** - Nom des tables et des champs dans les requ�tes SQL
008: ** --- topics.forum : ID du forum d'appartenance du topic
009: ** --- topics.id : ID du topic
010: ** --- topics.posts : nombre de post dans le topic
011: ** --- topics.title : titre du topic
012: ** --- posts.num : num�ro du post dans le topic (de 0 � N - 1 pour un topic de N posts)
013: ** --- posts.topic : ID du topic auquel appartient le post
014: ** --- last_post.num : num�ro du dernier post lu dans le topic
015: ** --- last_post.topic : ID du topic auquel appartient le post
016: ** - Indexes de la variable $topic (adapter aux noms des champs de la table topics)
017: */
018:
019: ?>
020:
021: <?php function showCadre ($title, $text) { ?>
022:
023: <?xml version="1.0" encoding="windows-1252"?>
024: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
025: <html lang="fr">
026: <head>
027: <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
028: <meta name="Author" content="yAro" />
029: <meta name="Description" content="Vous cherchez des forums, un endroit pour discuter ? C'est ici ! Actualit�, blogs, bd, cin�, programmation, jeux vid�o, consoles, calculettes TI, �tudes ... y'a too :) Attention ... addictif ! :D" />
030: <meta name="Keywords" content="forum,discussion,forums,board,chat,gratuit,free,actualite,news,rss,blogs,blog,journal,chat,discuter,ti89,ti,calculette,console,cuisine,recettes,pocket,gba,gp32,zodiac,n-gage,lynx,nintendo,sega,sony,psp,playstation,atari,aide,informatique,d�panage,jeux,r�tro,retrogaming,videolud�lisme,petite,annonce,petites,annonces,citations,annuaire,selection,multimedia,images,video,musique,dvd,mp3,cin�ma,bd,livres,manga,liens,favoris,hors,sujet,divers,t�l�,tv,real,humour,blagues,newbie,portables,logiciel,windows,web,irc,ressources,webmasters,services,adulte" />
031: <meta name="Identifier-URL" content="http://www.yaronet.com" />
032: <meta name="Reply-to" content="webmaster@yaronet.com" />
033: <meta name="revisit-after" content="15 days" />
034: <meta name="robots" content="index, follow" />
035: <title><?php echo $title; ?></title>
036: <link type='text/css' rel='stylesheet' href='http://www.yaronet.com/v31/defaut/styles.css' />
037: <link type='text/css' rel='stylesheet' href='http://www.yaronet.com/v31/gfx/global.css' />
038: <script language="JavaScript" type="text/javascript" src="http://www.yaronet.com/v31/defaut/styles.js"></script>
039: <script language="JavaScript" type="text/javascript" src="http://www.yaronet.com/xcite.js"></script>
040: <script language="JavaScript" type="text/javascript" src="http://www.yaronet.com/v31/gfx/js/scripts2.js"></script>
041: </head>
042: <body>
043: <a name='haut'></a>
044: <div id='bulle' style='position:absolute; visibility: hidden; z-index:3;'></div>
045: <div id='mylinks' style='top:0;left:0;position:absolute;z-index:1;visibility: hidden; display:inline;'></div>
046: <script language='JavaScript' type="text/javascript" src='http://www.yaronet.com/bulle.js'></script>
047: <img src='http://www.yaronet.com/v31/defaut/null.gif' height='10' alt='' />
048: <div class='cadre'>
049: <h1>» <?php echo $title; ?></h1>
050: <br />
051: <?php echo $text; ?>
052: </div>
053: </body>
054: </html>
055:
056: <?php } ?>
057: <?php function showError ($msg, $url = '') { ?>
058:
059: <?xml version="1.0" encoding="windows-1252"?>
060: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
061: <html lang="fr">
062: <head>
063: <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
064: <meta name="Author" content="yAro" />
065: <meta name="Description" content="Vous cherchez des forums, un endroit pour discuter ? C'est ici ! Actualit�, blogs, bd, cin�, programmation, jeux vid�o, consoles, calculettes TI, �tudes ... y'a too :) Attention ... addictif ! :D" />
066: <meta name="Keywords" content="forum,discussion,forums,board,chat,gratuit,free,actualite,news,rss,blogs,blog,journal,chat,discuter,ti89,ti,calculette,console,cuisine,recettes,pocket,gba,gp32,zodiac,n-gage,lynx,nintendo,sega,sony,psp,playstation,atari,aide,informatique,d�panage,jeux,r�tro,retrogaming,videolud�lisme,petite,annonce,petites,annonces,citations,annuaire,selection,multimedia,images,video,musique,dvd,mp3,cin�ma,bd,livres,manga,liens,favoris,hors,sujet,divers,t�l�,tv,real,humour,blagues,newbie,portables,logiciel,windows,web,irc,ressources,webmasters,services,adulte" />
067: <meta name="Identifier-URL" content="http://www.yaronet.com" />
068: <meta name="Reply-to" content="webmaster@yaronet.com" />
069: <meta name="revisit-after" content="15 days" />
070: <meta name="robots" content="index, follow" />
071: <link type='text/css' rel='stylesheet' href='http://www.yaronet.com/v31/defaut/styles.css' />
072: <script language="JavaScript" type="text/javascript" src="http://www.yaronet.com/v31/defaut/styles.js"></script>
073: <title>Error</title>
074: </head>
075: <body>
076: <a name='haut'></a>
077: <div id='bulle' style='position:absolute; visibility: hidden; z-index:3;'></div>
078: <div id='mylinks' style='top:0;left:0;position:absolute;z-index:1;visibility: hidden; display:inline;'></div>
079: <script language='JavaScript' type='text/javascript' src='http://www.yaronet.com/bulle.js'></script>
080: <img src='http://www.yaronet.com/v31/defaut/null.gif' height='10' alt='' />
081: <div class='error'>
082: <h1><!\ Erreur</h1>
083: <br />
084: <br />
085: <?php echo $msg; ?><br />
086: <br />
087: <a href='<?php echo $url; ?>'>
088: <img src='http://www.yaronet.com/v31/defaut/okw.gif' alt='OK' title='OK' />
089: </a>
090: </div>
091: <br />
092: </body>
093: </html>
094:
095: <?php } ?>
096: <?php
097:
098: if (!is_numeric ($_GET['s']) || !is_numeric ($_GET['p1']))
099: {
100: header ('Location: index.php');
101:
102: exit (0);
103: }
104:
105: /*
106: mysql_connect (...);
107: mysql_select_db (...);
108: */
109:
110: if (!($handle = mysql_query ('SELECT forum, id, posts, title FROM topics WHERE id = \'' . $_GET['s'] . '\''))
111: || !($topic = mysql_fetch_assoc ($handle)))
112: showError ('Le sujet n�' . $_GET['s'] . ' n\'a pas �t� trouv�.');
113: else if ($_GET['p1'] < 0 || $_GET['p1'] >= $topic['posts'])
114: showError ('Le num�ro du premier post � extraire est invalide.');
115: else if (!is_numeric ($_POST['p2']))
116: {
117: $options = '';
118:
119: for ($i = min ($topic['posts'], $_GET['p1'] + 20); $i > $_GET['p1']; --$i)
120: $options = '<option value="' . ($i - 1) . '">' . ($i - 1) . '</option>' . $options;
121:
122: showCadre ('S�parer un sujet', '
123: <form action="?s=' . $_GET['s'] . '&p1=' . $_GET['p1'] . '" method="post">
124: <b>Topic � s�parer :</b> ' . htmlentities ($topic['title']) . '<br />
125: <br />
126: <b>Premier post :</b> ./' . $_GET['p1'] . '<br />
127: <br />
128: <b>Dernier post :</b> ./<select name="p2">' . $options . '</select><br />
129: <br />
130: <b>Nouveau titre : </b> <input maxlength="100" name="title" size="50" type="text" value="' . htmlentities ('Fork de "' . $topic['title'] . '"') . '" /><br />
131: <br />
132: <input type="submit" value="S�parer le topic" />
133: </form>');
134: }
135: else if ($_POST['p2'] < $_GET['p1'] || $_POST['p2'] >= $topic['posts'])
136: showError ('Le num�ro du dernier post � extraire est invalide.');
137: else
138: {
139: $p1 = $_GET['p1'];
140: $p2 = $_POST['p2'];
141:
142: // Cr�e le nouveau topic
143: mysql_query ('INSERT INTO topics (forum, title) VALUES (\'' . $topic['forum'] . '\', \'' . mysql_real_escape_string ($_POST['title']) . '\'') or die;
144:
145: $id = mysql_insert_id ();
146:
147: // Affecte les posts fork�s au nouveau topic
148: mysql_query ('UPDATE posts SET topic = \'' . $id . '\' WHERE topic = \'' . $topic['id'] . '\' AND num >= \'' . $p1 . '\' AND NUM <= \'' . $p2 . '\'');
149:
150: // Corrige la num�rotation des posts dans le nouveau topic
151: mysql_query ('UPDATE posts SET num = (num - ' . $p1 . ') WHERE topic = \'' . $id . '\'');
152:
153: // Corrige la num�rotation des posts dans l'ancien topic
154: mysql_query ('UPDATE posts SET num = (num - ' . ($p2 - $p1 + 1) . ') WHERE topic = \'' . $topic['id'] . '\' AND num > \'' . $p2 . '\'');
155:
156: // Corrige les infos sur le dernier post lu dans l'ancien topic
157: mysql_query ('UPDATE last_post SET num = (num - ' . ($p2 - $p1 + 1) . ') WHERE topic = \'' . $topic['id'] . '\' AND num > \'' . $p2 . '\'');
158:
159: // FIXME: Post de Boo dans l'ancien topic pour pr�venir du fork et fournir un lien vers le nouveau topic ?
160:
161: showCadre ('OK !', '
162: Topic s�par� !
163: <div style="text-align: center;">
164: <a href="javascript:window.close();">
165: <img title="OK" alt="OK" src="http://www.yaronet.com/v31/defaut/okw.gif"/>
166: </a>
167: </div>');
168: }
169:
170: ?>