
Forum » » Version future » » une fonction pour le forum
Posté : 08-10-2012 09:57 
<?PHP
/************************************************************************/
/* NPDS : Nuke Permanent Double-Side Web P ortal System CentralBoard */
/* =========================== & nbsp; &n bsp; */
/* From CentralBoard version 1.0 pour myPHPNuke 1.8 &nbs p; */
/* Copyright © 2001, Hervé LAINE & nbsp; &n bsp; */
/* webmaster@clubados.com - http://www.clubados.com&nbs p;   ; */
/* &nb sp; &nbs p;   ; & nbsp; */
/* Original Copyright (c) 2001 by Francisco&nbs p;Burzi (fburzi@ncc.org.ve) */
/* http://phpnuke.org &nb sp; &nbs p;   ; */
/* &nb sp; &nbs p;   ; & nbsp; */
/* This version name NPDS Copyright (c) 20 01 by Philippe Brunier */
/* &nb sp; &nbs p;   ; & nbsp; */
/* This program is free software. You can& nbsp;redistribute it and/or modify */
/* it under the terms of the GNU Gene ral Public License as published by */
/* the Free Software Foundation; either version 2 of the License.   ;*/
/************************************************************************/
if(!IsSet($mainfile)) { !include! ("mainfile.php& quot;); }
// !include! cache manager classe
!include!_once('cache.class.php');
// P. Brunier Permanent double-side theme
global $pdsts;
$pdst="1";
!include! ("modules/$ModPath/CentralBoard.conf.php");
!include! ("modules/$ModPath/CentralBoard.lang.php");
!include! ("modules/$ModPath/cache.timings.php");
function writeblock($title, $go, $corps, $foot, $sta tik){
global $site_font,$bgcolor2,$textcolor1, $bgcolorblock,$textcolorro uge ;
// Ajout gilles pub perso
//!include! ("static/facebook_jaime_compte_vivrenu_ferme.html&a mp;quot;);
//!include! ("static/facebook_jaime.html");
echo "<table width=100% align=left valign=top border=0 cellpading=0 cellsapcing=5 bgcolor=$bgcolorblock><tr><td align=left&g t;";
echo "<font size=2 face=\" ;tahoma,$site_font\" color=$textcolor1>$title</font ></td>";
echo "<td align=right><fo nt size=2 face=\"tahoma,$site_font\" color=$te xtcolor1>$go</font></td></tr>& amp;quot;;
echo "<tr><td colspan=2&a mp;gt; ";
echo "<table align=center&n bsp;border=0 bgcolor=$bgcolor2 cellpadding=1 cellspacing=0 Width=100%><tr><td>";
echo "<table align=center&n bsp;border=0 bgcolor=$bgcolorblock cellpadding=5 cellspacing=0&n bsp;Width=100%>";
echo "<tr><td& gt;";
echo "<font size=2 fac e=\"tahoma,$site_font\" color=$textcolor1> & amp;quot; ;
if ($statik){
!include!($corps);
} else{
echo $corps ;
}
echo "</font></td& amp;gt;</tr></table>";
echo "</td></tr&am p;gt;</table>";
echo "</td></tr&am p;gt;";
echo "<tr><td  ;colspan=2> " ;
echo "<font size=2 fac e=\"tahoma,$site_font\" color=$textcolor1>$foot&a mp;lt;/td></tr></table> "  ;;
}
function LastTopicsForum(){
global $bgcolorblock,$bgcolor4, $bgcolor3, $bgcolor2, $bg color1;
global $maxcount, $textcolor1 ;
global $user ;
$foot = "<a href=\"forum.php\&quo t;>[Voir tous les forums Thématiques]</a& ;gt;";
$go="";
// recherche du numéro user ($userdata[0]) et& nbsp;du code user ($userdata[1]).
$userX=base_64_decode($user);
$userdata=explode(":",$userX);
//rajouté par gilles (modele marc)
$corps = "";
searchblockcorps();
// fin ajout
// affichage du code user ($userdata[1]) .
$corps .= "<table width=\" ;100%\" border=0 bordercolor=$bgcolor4 cellpadding=2&nb sp;cellspacing=0 bgcolor=$bgcolorblock>";
$corps .= "<tr align=center b gcolor=$bgcolor2>";
$corps .= "<td width=3%>&am p;amp;nbsp;</td>";
$corps .= "<td width=64%>&a mp;lt;font size=2><b>Sujet</b></ font></td>";
$corps .= "<td width=5%>&am p;lt;font size=2><b>Rép.</b></f ont></td>";
$corps .= "<td width=15%>&a mp;lt;font size=2><b>Dernier message</b&a mp;gt;</font></td></tr>";
$groupes="'Z'";
// Controle du User pour voir s'il& nbsp;appartient au Groupe 7 (membres confirmés)
$affichgroup7=false;
$tab_groupe=valid_group($user);
for ($i=0; $i<=9; $i++) {
$groupes .=",'$tab_groupe[$ i]'";
if ($tab_groupe[$i]==7) {
$affichgroup7=tru e;
}
}
// Controle du User pour voi r s'il appartient au Groupe 35 (membres insc rits)
$affichgroup35=false;
$tab_groupe=valid_group($user);
for ($i=0; $i<=40; $i++) {
$groupes .=",'$tab_groupe[$ i]'";
if ($tab_groupe[$i]==35) {
$affichgroup7=tru e;
}
}
// Controle du User pour voi r s'il appartient au Groupe 6 (redacteur/moderate ur/admin)
$affichgroup6=false;
$tab_groupe=valid_group($user);
for ($i=0; $i<=9; $i++) {
if ($tab_groupe[$i]==6) {
$affichgroup6=tru e;
break;
}
}
// Controle du User p our voir s'il appartient au Groupe 12 (Club& nbsp;ANO d'EURONAT)
$affichgroup12=false;
$tab_groupe=valid_group($user);
for ($i=0; $i<=9; $i++) {
if ($tab_groupe[$i]==12) {
$affichgroup12=tr ue;
break;
}
}
// Début des modifications Grunt 1.03
< br /> if ($affichgroup7) // Groupe des confirm és
{
// Afficher les forums Type Public ou (Type 9 et forum 23) ou (Type 7 et (Groupes))
$conditions_acces =" (f.foru m_type = 0) ";
$conditions_acces .=" or&nbs p;(f.forum_type=9 and (f.forum_id = '23'))";
$conditions_acces .=" or&nbs p;(f.forum_type=7 and (f.forum_pass in ($groupes)))&quo t;;
}
else
{
$conditions_acces =" (f.foru m_type='0' and forum_access<'2') ";
}
$query ="select t.topic_id, t .topic_title, t.forum_id, t.topic_poster, t.topic_time, f.f orum_type, f.forum_name";
$query .=" from forumtopics&n bsp;t, forums f";
$query .=" where (t.forum_id= f.forum_id)";
$query .=" and ( &qu ot;;
$query .= $conditions_acces;
$query .=" )";
$query .=" order by topi c_time desc limit $maxcount";
// Fin des modifications Grunt&nb sp;1.03
$result = mysql_query($query);
if (!$count) {
$count=mysql_num_rows($result);
}
if ($count>$maxcount){$count=$maxcount;}
$ibid=0;
$forum_limit=0;
// --- Début Ajout Grunt 1/3: pour correc tion dernières contributions. ---
// Déclarations récupérées de viewtopic.php &nbs p;
settype($start,"integer");
settype($posts_per_page,"integer");
// $posts_per_page est une constante pré-établie,& nbsp;je suppose: elle doit venir d'un !include!.& nbsp;Sinon:
$posts_per_page=30;
echo("<!-- Marquage: Cette version du&nbs p;site a été modifiée par Grunt. 1.02 --& amp;gt;");
// --- Fin Ajout Grunt 1/3: pour correctio n dernières contributions. ---
while ($forum_limit<$count){
list($topic_id, $topic_t itle, $forum_id, $poster_id, $topic_time, $forum_type,  ;$forum_name) = mysql_fetch_row($result);
$topic_title=stripslashes($to pic_title);
$forum_limit++; &n bsp; // t opic_title
$query ="select post_time, poster_id, post_aff from posts where& nbsp;topic_id='$topic_id' order by post_id desc limit& nbsp;0,1";
$result_P = mysql_q uery($query);
list($post_time, $poster _id, $post_aff) = mysql_fetch_row($result_P);
$post_time_mmjjhh=substr($pos t_time,5,11);
// Auteur
if ($poster_id!=0) {
list( $uname) = mysql_fetch_row(mysql_query("select uname&nbs p;from users where uid=$poster_id"));
}
if ($ibid==0) {
$ibid=1;
$bcolor=$bg color1;
} else {
$ibid=0;
$bcolor=$bg color3;
}
$corps .= " ;<tr align=center bgcolor=$bcolor>" ;
// if ($ibid=theme_image("forum/icons/hot_red_ folder.gif")) {$imgtmpHR=$ibid;} else {$imgtmpHR=&q uot;images/forum/icons/hot_red_folder.gif";}
$imgtmpHR="images/fo rum/icons/hot_red_folder.gif";
// if ($ibid=theme_image("forum/icons/hot_fold er.gif")) {$imgtmpH=$ibid;} else {$imgtmpH="im ages/forum/icons/hot_folder.gif";}
$imgtmpH="images/for um/icons/hot_folder.gif";
// if ($ibid=theme_image("forum/icons/red_fold er.gif")) {$imgtmpR=$ibid;} else {$imgtmpR="im ages/forum/icons/red_folder.gif";}
$imgtmpR="images/for um/icons/red_folder.gif";
// if ($ibid=theme_image("forum/icons/folder.g if")) {$imgtmpF=$ibid;} else {$imgtmpF="images /forum/icons/folder.gif";}
$imgtmpF="images/for um/icons/folder.gif";
// if ($ibid=theme_image("forum/icons/lock.gif ")) {$imgtmpL=$ibid;} else {$imgtmpL="images/f orum/icons/lock.gif";}
$imgtmpL="images/for um/icons/lock.gif";
// if ($ibid=theme_image("forum/icons/lock.gif ")) {$imgtmpL=$ibid;} else {$imgtmpL="images/f orum/icons/lock.gif";}
$imgtmpRi="images/do wnload/right.gif";
// if ($ibid=theme_image("forum/icons/posticon .gif")) {$imgtmpP=$ibid;} else {$imgtmpP="imag es/forum/icons/posticon.gif";}
// if ($ibid=theme_image("box/right.gif&qu ot;)) {$imgtmpRi=$ibid;} else {$imgtmpRi="images/downlo ad/right.gif";}
// $replys = g et_total_posts($forum_id, $myrow[$topic_id], "topic" ;, $Mmod);
$replys = get _total_posts($forum_id, $topic_id, "topic", $M mod);
$replys--;
$sqlR = "select rid from forum_read where&nbs p;forum_id='$forum_id' and uid='$userdata[0]' and topicid=' $topic_id' and status!='0'";
$hot_ threshold=20;
if&nb sp;($replys >= $hot_threshold) {
  ; if (mysql_num_rows(mysql_query($sqlR))==0)
  ; $image = $imgtmpHR;
  ; else
  ; $image = $imgtmpH;
}&nbs p;else {
  ; if (mysql_num_rows(mysql_query($sqlR))==0)
  ; $image = $imgtmpR;
  ; else
  ; $image = $imgtmpF;
}
if&nb sp;($myrow[topic_status] == 1)
  ; $image = $imgtmpL;
$textcolor_aff = $textcolor1;
if ($post_aff==0) {
$text color_aff = "0000FF#";
}
if ($post_aff==1) {
$post_aff = &qu ot; ";
}
// --- Début Ajout Grunt 2/ 3: pour correction dernières contributions. ---
// Nous faisons le calcul sa uvage d'un start avec les moyens du bord.
// ($replys / $posts_per_p age) fait une division au résulat entier et perd le reste.
// en remultipliant par&nb sp;$posts_per_page, on attend un multiple de $pos ts_per_page: 0,20,40,60...
$start=$replys / $posts_per_page;
settype($start,"integer");
$start=$start * $posts_per_page;
// --- Fin Ajout Grunt 2/3:& nbsp;pour correction dernières contributions. ---
$corps .= " ;<td align=center><img src=$image>< ;/td>";
$corps .= " ;<td align=left><font size=2 face=\&a mp;quot;tahoma,$site_font\" color=$textcolor_aff>$post_aff &nbsp;<a href=\"viewtopic.php?topic=$topic_id& amp;forum=$forum_id\"><b>$topic_title</b&a mp;gt;</a></font>";
$corps .= " ;<font size=1 face=\"tahoma,$site_font\"&nbs p;color=$textcolor1>&nbsp;[<a href=\"viewfo rum.php?forum=$forum_id\">$forum_name</a>]< ;/font></td>";
// --- Début Modification Grunt& nbsp;3/3: pour correction dernières contributions. -- -
$corps .= "& lt;td align=right><font size=1 face=\"tah oma,$site_font\" color=$textcolor1><a href=\&a mp;quot;viewtopic.php?topic=$topic_id&forum=$forum_id\" & nbsp;title=\"Premières contributions\" >$re plys</a></font>&nbsp;<a href=\& amp;quot;viewtopic.php?topic=$topic_id&start=$start&forum=$foru m_id#last-post\" ><img src=\"$imgtmpR i\" border=\"0\" align=\"middle\& amp;quot; alt=\"".translate("Last Posts&am p;quot;)."\" /></a>&nbsp;&a mp;lt;/td> " ;
// $corps .= &qu ot;<td align=right><font size=1 face=\& quot;tahoma,$site_font\" color=$textcolor1><a href=\"viewtopic.php?topic=$topic_id&forum=$forum_id\" ; title=\"Premières contributions\" &am p;gt;$replys</a></font>&nbsp;<a  ;href=\"viewtopic.php?topic=$topic_id&forum=$forum_id#last-pos t\" ><img src=\"$imgtmpRi\"& nbsp;border=\"0\" align=\"middle\"&nbs p;alt=\"".translate("Last Posts").& ;quot;\" /></a>&nbsp;</td& ;gt; ";
// --- Fin Modification Grunt&nbs p;3/3: pour correction dernières contributions. ---
< br />
$corps .= " ;<td align=center><font size=1 face=\&q uot;tahoma,$site_font\" color=$textcolor1>$post_time_mmjjh h <a href=\"user.php?op=userinfo&uname=$uname \">$uname</a></font></td& ;gt;</tr>";
}
$corps .="& lt;/table>";
//ajout marc
searchblock();
//fin ajout marc
WriteBlock($title,$go,$corps,$foot,false);
}
function main($op){
global $catid_b1,$catid_b5;
// bloc N°4 - Le forums
echo "<table width=100% border=0 cellspac ing=5 cellpading=0><tr><td>";
LastTopicsForum();
echo "</td></tr></table& gt;";
!include!("footer.php");
}
//ajouté par marc
function searchblock(){
echo "<table width=\"100 %\" cellspacing=\"0\" cellpadding=\&qu ot;4\" border=\"0\">
<form action=\"searchbb.php\" method=\"post\"><tr><td&nbs p;nowrap class=\"HEADER\">
<input type=\"hidden\" n ame=\"addterm\" value=\"any\">
<input type=\"hidden\" n ame=\"sortby\" value=\"p.post_id\"& ;gt;";
//ajouté par gilles
echo "<center><b>
<a href=\"viewtopic.php?topic=2132&forum=10\& ;quot;>[Centres naturistes à 100% ]</a&g t;&nbsp;
<a href=\"forum.php\">[Tous les&nbs p;Forums ]</a>&nbsp;&nbsp;&nbsp;& ;quot;.translate('Search')."</b>&nbsp;&n bsp;<input class=\"TEXTBOX_STANDARD\" type=\ "text\" name=\"term\" size=\& quot;10\">&nbsp;&nbsp;<input class= \"BOUTON_STANDARD\" type=\"submit\"&nb sp;name=\"submit\" Value=\"".translate ("Submit")."\"></center&g t;";
echo "</td></tr>& amp;lt;/form></table>";
}
function searchblockcorps(){
$corps .= "<br />& ;lt;table width=\"100%\" cellspacing=\"0\& amp;quot; cellpadding=\"4\" border=\"0\&am p;quot;>";
$corps .= "<form action=\&am p;quot;searchbb.php\" method=\"post\">&a mp;lt;tr><td nowrap class=\"HEADER\"& amp;gt;";
$corps .= "<input type=\& ;quot;hidden\" name=\"addterm\" value=\&am p;quot;any\">";
$corps .= "<input type=\& ;quot;hidden\" name=\"sortby\" value=\& ;quot;p.post_id\">";
$corps .= "<center>< ;b>".translate('Search')."</b>&n bsp;&nbsp;<input class=\"TEXTBOX_STANDARD\&quo t; type=\"text\" name=\"term\"&nb sp;size=\"50\">&nbsp;&nbsp;<inp ut class=\"BOUTON_STANDARD\" type=\"submit \" name=\"submit\" Value=\"&q uot;.translate("Submit")."\">< ;/center>";
$corps .= "</td></t r></form></table><br />&a mp;quot;;
}
// !include!('functions.php');
function get_total_posts($fid, $tid, $type, $ Mmod) {
if ($Mmod) {
$post_aff="";
} else {
$post_aff=" and post_a ff='1'";
}
switch($type) {
case 'forum':
$sql = "SELECT count(*) AS total FROM posts&nb sp;WHERE forum_id='$fid'$post_aff";
break;
case 'topic':
$sql = "SELECT count(*) AS total FROM posts&nb sp;WHERE topic_id='$tid'$post_aff";
break;
case 'user':
forumerror( 0031);
}
if (!$result = mysql_query($sql))
return("ERROR");
if (!$myrow = mysql_fetch_array($result))
return("0");
mysql_free_result($result);
return($myrow[total]);
}
// fin ajout marc
// début programme principal
!include!("header.php");
switch ($op) {
case "edito":
write_edito($txtname);
main($op);
break;
default:
main($op);
break;
}
?>
Cet article provient de NPDS REvolution 16
https://lab.grottes-et-karsts-de-chine.org/viewtopic.php?topic=25274&forum=4