Location: PHPKode > projects > ADP Forum > adp-forum/template.php
<?php
session_start();
include ("config.php");
include ("lang/$lang.php");
include ("function.php");
// cookie
if(session_is_registered("user") or session_is_registered("out")){}
elseif(isset($Forum)){
$member="$Forum[name]";
$ml="$Forum[email]";
$user="$Forum[user]";
$pasw="$Forum[passw]";
$logged="in";
session_register ("member");
session_register ("ml");
session_register ("user");
session_register ("pasw");
session_register ("logged");
}

if (!isset($mode)) {
  $mode = "template";
  if(!isset($pgc)){$pgc=0;}
}
switch($mode) {  

case("template"):
if(ereg("/",$nm)) {header("Location: index.php");}else{}
include ("header.php"); 

	$messread = fopen("$mess_dir/$nm.txt", "r");
    $messaggio = fread($messread, filesize("$mess_dir/$nm.txt"));
    fclose($messread);
	
	$dati = explode("|", $messaggio);
	$num=$dati[0];
    $nome=$dati[1];
	$mail=$dati[2];
	$oggetto=$dati[3];
	$testo=$dati[4];
	$modified=$dati[9];
	
	$oggetto=LimitazioneOggetto($oggetto, $limsbj);
	$testo=Limitazione($testo, $postlim);
	if($html=="1"){$testo=Html($testo);}
	else{$testo=HtmlOff($testo);}
	if($smiley=="1"){$testo=Smiley($testo);}
	else{$testo=SmileyOff($testo);}
	if($link_option=="1"){$testo=CLink($testo);}
	else{$testo=RLink($testo);}
	
	$data=$dati[5];
	$ora=$dati[6];
	$min=$dati[7];
	$username=$dati[8];
	
  //////se l'autore è un membro scrive lo status
  if($username=="0"){$profile_image="";$aut="<font size=2><b>$nome</b></font>";$mail_image="";}
  else{
   if(file_exists("users/$username.txt")){
  $member_read = fopen("users/$username.txt", "r");
  $membri = fread($member_read, filesize("users/$username.txt"));
  fclose($member_read);
  // numero membri
  $dati_member = explode("\n", $membri);
  $status=$dati_member[1];
  $numero_messaggi=$dati_member[2];
  $avatar=$dati_member[3];
  $web=$dati_member[4];
  $mail=$dati_member[5];
  $icq=$dati_member[6];
  $date_reg=$dati_member[7];
  $nome=$dati_member[8];
  $code=$dati_member[10];
  $profile_image= "<a href=\"members.php?mode=profile&id=$code\"><img src=\"images/profile_image.gif\" border=\"0\"></a>\n";
  $aut = "<a href=\"members.php?mode=write_member&id=$code\"><font size=2><b>$nome</b></font></a> ";
  $mail_image = "<a href=\"members.php?mode=write_member&id=$code\"><IMG SRC=\"images/mail_image.gif\" BORDER=\"0\"></a> ";
   }else{$profile_image="";$aut="<font size=2><b>$nome</b></font>";$mail_image="";}
  } 
	if ($web != "") {$web_image = "<a href=\"$web\" style=\"background:$bgtab4;\"><IMG SRC=images/web_image.gif BORDER=0></a> ";}
    else {$web_image = "";}
	
if($pgc=="0"){
        eval("echo(\"".gettemplate("post_page1")."\");");
}else{eval("echo(\"".gettemplate("post_page1r")."\");");}
if($pgc=="0"){
	
    if($username=="0"){}
    else{
	if(file_exists("users/$username.txt")){
	if($avatar=="0"){
	echo"\n";
    }
    else{
	echo"<IMG SRC=$avatar BORDER=0><br>\n";
    }
	if($username==$admin_user){
	echo"$admin<br>\n";
	}
	else{
	echo"$status<br>\n";
	}
	if($status==$new_member){
	if($username==$admin_user){$k=$mk+1;}
	else{$k=$nk;}
	}
    if($status==$junior_member){
	if($username==$admin_user){$k=$mk+1;}
	else{$k=$jk;}
	}
    if($status==$senior_member){
	if($username==$admin_user){$k=$mk+1;}
	else{$k=$sk;}
	}
    if($status==$master_member){
	if($username==$admin_user){$k=$mk+1;}
	else{$k=$mk;}
	}
	for($m=1;$m<=$k;$m++){
	echo"<IMG SRC=images/pal.gif BORDER=0>\n";
	}
        eval("echo(\"".gettemplate("post_page2")."\");");
	}
	}
        eval("echo(\"".gettemplate("post_page3")."\");");

	if (session_is_registered("logged") && $logged == "in"){
        if (session_is_registered("user") && $user==$admin_user){
        eval("echo(\"".gettemplate("post_page4")."\");");
        }
        elseif(session_is_registered("user")){
		                                 if($user==$username){
                                                 eval("echo(\"".gettemplate("post_page5")."\");");
										 
										 }
                                         else{
                                         eval("echo(\"".gettemplate("post_page6")."\");");
										 
										 }
        }
    }
	else{eval("echo(\"".gettemplate("post_page7")."\");");}
        
        eval("echo(\"".gettemplate("post_page8")."\");");
	
}
//else{
 //   eval("echo(\"".gettemplate("post_page9")."\");");
    
//}
//tira fuori le risposte relative al messaggio
$namerisp=array();

$handle=opendir('risposte');
while (false !== ($file = readdir($handle))) {
    if ($file != "." && $file != "..") { 
	
	$rispread = fopen("risposte/$file", "r");
    $risposte = fread($rispread, filesize("risposte/$file"));
    fclose($rispread);
	
	$mespread = fopen("messaggi/$nm.txt", "r");
    $messaggi= fread($mespread, filesize("messaggi/$nm.txt"));
    fclose($mespread);
	
	$valorim = explode("|", $messaggi);
	$valori = explode("|", $risposte);
	$cl=$valori[0];
	$cod=$valorim[0];
	if($cl==$cod){
	$namerisp[]=$file;
    }else{}
	} 
}
//se esiste almeno una risposta
// if ($namerisp[0]==0)  {echo"</table>";}
if ($namerisp[0]<>0)  {

natsort ($namerisp);
$n_a=0;
$output=array();
while (list ($chiave, $valore) = each ($namerisp)) {
$output[$n_a]=$valore;
$n_a++;
}
    //ordina i messaggi per numero 
    $total=count($output);

	$page=array();
	
	for($r=$pgc; $r<($pgc+$rgp);$r++){
	if($output[$r]==0){}
	else{$page[]=$output[$r];
	}
	}
    ////////fine contatore

//reset ($namerisp);
while (list ($chiave, $valore) = each ($page)) {
	$rispread = fopen("risposte/$valore", "r");
    $datir = fread($rispread, filesize("risposte/$valore"));
    fclose($rispread);
	$datirisp = explode("|", $datir);
	$numr=$datirisp[0];
	$nr=$datirisp[1];
	$nomer=$datirisp[2];
	$mailr=$datirisp[3];
	$oggettor=$datirisp[4];
	$risposta=$datirisp[5];
	$modifiedr=$datirisp[10];
	
	$oggettor=LimitazioneOggetto($oggettor, $limsbj);
	$risposta=Limitazione($risposta, $postlim);
	
	if($html=="1"){$risposta=Html($risposta);}
	else{$risposta=HtmlOff($risposta);}
	if($smiley=="1"){$risposta=Smiley($risposta);}
	else{$risposta=SmileyOff($risposta);}
	if($link_option=="1"){$risposta=CLink($risposta);}
	else{$risposta=RLink($risposta);}
	$risposta = str_replace("[Q]", "<center><table cellspacing=0 cellpadding=3 border=0 width=90%><tr><td width=100% align=left><h4><font size=1>quote :</font><hr width=100%><b>", $risposta);
	$risposta = str_replace("[/Q]", "</b><hr width=100%></h4></td></tr></table></center>", $risposta);
	
	$datar=$datirisp[6];
	$orar=$datirisp[7];
	$minutir=$datirisp[8];
	$username_risp=$datirisp[9];

	//////se l'autore è un membro scrive lo status
  if($username_risp=="0"){$profile_imager="";$autr="<font size=2><b>$nomer</b></font>";$mail_imager="";}
  else{
   if(file_exists("users/$username_risp.txt")){
  $member_read = fopen("users/$username_risp.txt", "r");
  $membri = fread($member_read, filesize("users/$username_risp.txt"));
  fclose($member_read);
  // numero membri
  $dati_member = explode("\n", $membri);
  $status=$dati_member[1];
  $numero_messaggir=$dati_member[2];
  $avatar=$dati_member[3];
  $webr=$dati_member[4];
  $mailr=$dati_member[5];
  $icqr=$dati_member[6];
  $date_regr=$dati_member[7];
  $nomer=$dati_member[8];
  $coder=$dati_member[10];
  $profile_imager= "<a href=\"members.php?mode=profile&id=$coder\"><img src=\"images/profile_image.gif\" border=\"0\"></a>\n";
  $autr = "<a href=\"members.php?mode=write_member&id=$coder\"><font size=2><b>$nomer</b></font></a>";
  $mail_imager = "<a href=\"members.php?mode=write_member&id=$coder\"><IMG SRC=images/mail_image.gif BORDER=0></a> ";
   }else{$profile_imager="";$autr="<font size=2><b>$nomer</b></font>";$mail_imager="";}
  }

	if ($webr != "") {
	$web_imager = "<a href=\"$webr\"><IMG SRC=images/web_image.gif BORDER=0></a> ";
    }
    else {
	$web_imager = "";
    }
	
	if($np==0){
	$bganswer=$bg2index;
	eval("echo(\"".gettemplate("post_page10")."\");");
	
    if($username_risp=="0"){}
    else{
	if(file_exists("users/$username_risp.txt")){
	if($avatar=="0"){
	echo"\n";
    }
    else{
    echo"<IMG SRC=$avatar BORDER=0><br>\n";
    }
	if($username_risp==$admin_user){
	echo"$admin<br>\n";
	}
	else{
	echo"$status<br>\n";
	}
	if($status==$new_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$nk;}
	}
    if($status==$junior_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$jk;}
	}
    if($status==$senior_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$sk;}
	}
    if($status==$master_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$mk;}
	}
	for($m=1;$m<=$k;$m++){
	echo"<IMG SRC=images/pal.gif BORDER=0>\n";
	}
	eval("echo(\"".gettemplate("post_page11")."\");");
	
	}
	}
        eval("echo(\"".gettemplate("post_page12")."\");");
	
	if (session_is_registered("logged") && $logged == "in"){
        if (session_is_registered("user") && $user==$admin_user){
        eval("echo(\"".gettemplate("post_page13")."\");");
        }
        elseif(session_is_registered("user")){
		                                 if($user==$username_risp){
                                                 eval("echo(\"".gettemplate("post_page14")."\");");
										 
                                         }
                                         else{eval("echo(\"".gettemplate("post_page15")."\");");}
        }
    }
	else{eval("echo(\"".gettemplate("post_page16")."\");");}
        eval("echo(\"".gettemplate("post_page17")."\");");
	
	$np++;
	}
	else{
	$bganswer=$bg1index;
	eval("echo(\"".gettemplate("post_page10")."\");");
	
    if($username_risp=="0"){}
    else{
	if(file_exists("users/$username_risp.txt")){
	if($avatar=="0"){
	echo"\n";
    }
    else{
    echo"<IMG SRC=$avatar BORDER=0><br>\n";
    }
	if($username_risp==$admin_user){
	echo"$admin<br>\n";
	}
	else{
	echo"$status<br>\n";
	}
	if($status==$new_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$nk;}
	}
    if($status==$junior_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$jk;}
	}
    if($status==$senior_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$sk;}
	}
    if($status==$master_member){
	if($username_risp==$admin_user){$k=$mk+1;}
	else{$k=$mk;}
	}
	for($m=1;$m<=$k;$m++){
	echo"<IMG SRC=images/pal.gif BORDER=0>\n";
	}
        eval("echo(\"".gettemplate("post_page11")."\");");
	
	}
	}
	eval("echo(\"".gettemplate("post_page12")."\");");
	if (session_is_registered("logged") && $logged == "in"){
        if (session_is_registered("user") && $user==$admin_user){
        eval("echo(\"".gettemplate("post_page13")."\");");
        
        }
        elseif(session_is_registered("user")){
		                                 if($user==$username_risp){
						 eval("echo(\"".gettemplate("post_page14")."\");");
						
                                         }
                                         else{eval("echo(\"".gettemplate("post_page15")."\");");}
        }
    }
	else{eval("echo(\"".gettemplate("post_page16")."\");");}
	eval("echo(\"".gettemplate("post_page17")."\");");
	$np--;
	}

	}
}
else{}
echo"</table>";
//////////////////elenco pagine
$pagarray=$namerisp;
 
	//ordina i messaggi per numero 
	natsort($pagarray);
    $out_put = array_reverse ($pagarray);
    $to_tal=count($out_put);

	$pg_p=$rgp;
	$e=($to_tal/$pg_p)+1;

	$pg_c=0;

	$pa_ge=array();
	
	
	
	echo"<table cellspacing=\"1\" cellpadding=\"6\" border=\"0\" width=\"100%\" bgcolor=\"$bodycol\">\n";
    echo"<tr>\n";
	echo"<td width=25%></td>";
    echo"<td width=\"50%\" height=\"10\" bgcolor=\"$bodycol\"><h3>\n";
	$conto_risposte=count($pagarray);
	if($conto_risposte>="1"){}
	for($s=1;$s<=$e;$s++){
	for($r1=$pg_c; $r1<($pg_c+$pg_p);$r1++){
	if($out_put[$r1]==0){}
	else{$pa_ge[]=$out_put[$r1];
	}
	}
	$o=$s-1;
	$per=($o*$pg_p);
	$pgnum=($pgc/$rgp)+1;
	if(($pg_c+$pg_p)<=($to_tal+$rgp-1)){
	 if($pgnum==$s){echo"<b><font size=\"1\" color=\"$bg3index\">$s</font></b> ";}
	 else{echo"<a href=template.php?nm=$nm&pgc=$per&rgp=$pg_p><font size=\"1\" color=\"$bg3index\"><u>$s</u></font></a> ";}
	}
	else{
	
	//exit;
	}
	$pg_c=$s*$pg_p;
	}
    echo"</h3></td>\n";
	echo"<td width=25%>";

    echo"<h3><div align=right><font color=$bg3index><a href=reply.php?nm=$nm><font color=$bg3index size=2><b>[$pr]</b></font></a> - <a href=\"post.php\"><font color=$bg3index size=2><b>[$n_p]</b></font></a></font></div></h3>\n";

	echo"</td>";
	echo"</tr>\n";
	echo"</table>\n";
/////////////fine conteggio pagine

include ("footer.php");
break;
}
?>
Return current item: ADP Forum