Просмотр файла info.php

Размер файла: 14.59Kb
<?php
//
//  info.php
//  rev014
//
include('config.php');
include('lang/'.$idioma.'.php');
include('funciones.php');
include('data/'.$ID.'info.php');

if($modo=="") { //Generamos los frames que hagan falta.
	if($enableComment) {
	    $HTML.='<html><head>';
		$HTML.='<title>'.$web.'</title>';
	    $HTML.='<frameset rows="*" cols="310,*" frameborder="NO" border="0" framespacing="0">';
	    $HTML.='<frame name="stats" noresize scrolling="NO" src="info.php?modo=stats&ID='.$ID.'">';
		$HTML.='<frame name="comments" noresize src="info.php?modo=comments&ID='.$ID.'" marginheight="0">';
	    $HTML.='</frameset>';
	    $HTML.='</head></html>';
	    echo $HTML;
	    exit();
	} else {
		$modo='stats';
	}
}

if($modo=="stats") {
    $datos=datos("read",$ID,0);
    if($enableRate) $notas=notas("stats",$ID,0,0);
    $HTML.='<table width="99%" align="center" border="0" cellspacing="1" cellpadding="2">';
    $HTML.='<caption><span class="titulo">'.$_Stats_.'</span></caption>';
    $HTML.='<tr class="2"><td align="right">&nbsp;</td><td align="right" class="texto1">'.$_InOut_.'</td></tr>';
    $HTML.='<tr valign="top" class="texto0"><td align="right" class="1">'.$_DateJoin_.'</td><td align="left" class="0">'.date($_DateFormat_,$ID).'<br><span class="minitexto0">'.media("dias",time(),$ID,0).$_DaysInTop_.'</span></td></tr>';
    $HTML.='<tr valign="top" class="texto0"><td align="right" class="1">'.$_In_.'<br><span class="minitexto0"><b>'.$_LastIN_.'</b></span></td><td align="left" class="0">'.$datos[0].' <span class="minitexto0">(~'.media("pordia",$tiempoResetLast,time(),$datos[0]).'/'.$_day_.')</span> / '.$datos[2].' <span class="minitexto0">(~'.media("pordia",$ID,time(),$datos[2]).'/'.$_day_.')</span><br><span class="minitexto0">'.date($_DateFormat_." (H:i)",$datos[7]).'</span></td></tr>';
    $HTML.='<tr valign="top" class="texto0"><td align="right" class="1">'.$_Out_.'<br><span class="minitexto0"><b>'.$_LastOUT_.'</b></span></td><td align="left" class="0">'.$datos[1].' <span class="minitexto0">(~'.media("pordia",$tiempoResetLast,time(),$datos[1]).'/'.$_day_.')</span> / '.$datos[3].' <span class="minitexto0">(~'.media("pordia",$ID,time(),$datos[3]).'/'.$_day_.')</span><br><span class="minitexto0">'.date($_DateFormat_." (H:i)",$datos[8]).'</span></td></tr>';
    $HTML.='<tr valign="top" class="texto0"><td align="right" class="1">'.$_RatioParcial_.'<br>'.$_RatioTotal_.'</td><td class="0">'.barra("ratio",150,$datos[0],$datos[1]).barra("ratio",150,$datos[2],$datos[3]).'</td></tr>';
	if($enableRate) {
	    $HTML.='<tr class="2"><td align="right">&nbsp;</td><td align="right" class="texto1">'.$_Rates_.'</td></tr>';
	    $HTML.='<tr class="texto0"><td align="right" class="1">'.$_Average_.'</td><td align="left" class="0"><img src="gif/star'.number_format($notas[13],0,'.','').'.gif" border="0">&nbsp;'.$notas[13].'&nbsp;<span class="minitexto0">('.$notas[11].' '.$_Rates_.')</span></td></tr>';
	    $HTML.='<tr class="texto0"><td align="right" class="1">';
	    for($i=10;$i>=0;$i--) {
	        $HTML.='<img src="gif/star'.$i.'.gif" border="0"> ('.$i.')';
	        if($i<>0) $HTML.='</br>';
	    }
	    $HTML.='</td><td align="left" class="0">';
	    for($i=10;$i>=0;$i--) {
	        $HTML.=barra("simple",125,$notas[$i],$notas[$notas[14]]).'&nbsp;'.$notas[$i];
	        if($i<>0) $HTML.='</br>';
	    }
		$HTML.='</td></tr>';
	}
    $HTML.='</table>';
}

if($modo=="comments") {
    if($paso=="") {
        $comentarios=comentarios("read",$ID,0,0);
        $HTML.='<table width="99%" align="center" border="0" cellspacing="1" cellpadding="2">';
		$HTML.="<caption><span class=\"titulo\">".$_Comments_."</span><BR><INPUT type=\"button\" class=\"boton\" value=\"".$_AddComment_."\" onClick=\"window.open('".$topURL."info.php?modo=comments&paso=1&ID=".$ID."','comments')\"></caption>";
        if($comentarios==0) {
            $HTML.='<tr class="2"><td align="center" class="texto1">'.$_NoComment_.'</td></tr>';
        } else {
            foreach($comentarios as $raw) {
                $i++;
                $aux=explode("||",$raw);
                $nota=notas("search",$ID,$aux[0],0);
                $HTML.='<tr class="'.($i%2).'"><td class="texto0">'.$aux[2];
                if(strlen($aux[4])>6) $HTML.='&nbsp;<a href="mailto:'.$aux[4].'" target="_blank"><img src="gif/icon_email.gif" border="0" width="32" height="16"></a>';
                if(strlen($aux[3])>10) $HTML.='&nbsp;<a href="'.$aux[3].'" target="_blank"><img src="gif/icon_www.gif" border="0" width="32" height="16"></a>';
                $HTML.='</td></tr>';
                $HTML.='<tr class="'.($i%2).'"><td class="minitexto0"><i>'.$aux[5].'</i></td></tr>';
                $HTML.='<tr class="'.($i%2).'"><td class="minitexto0" align="right"><img src="gif/star'.$nota[1].'.gif" border="0">&nbsp;'.date($_DateFormat_,$aux[1]);
				if($cookieLogin==$adminLogin AND $cookiePass==$adminPass) $HTML.="<br><b>IP:</b> ".$aux[0]."&nbsp;<INPUT type=\"button\" class=\"miniboton\" value=\"".$_Delete_."\" onClick=\"window.open('".$topURL."info.php?modo=comments&paso=3&deleteID=".$aux[1]."&ID=".$ID."','comments')\">";
				$HTML.='</td></tr>';				
            }
        }
        $HTML.='</table>';
    }
    if($paso==1) {
        $HTML='<form action="info.php" method="post">';
        $HTML.='<table width="95%" align="center" border="0" cellspacing="1" cellpadding="5">';
        $HTML.='<caption><span class="titulo">'.$_Comments_.'</span></caption>';
        $HTML.='<tr class="1"><td align="left" class="texto0">'.$_YourName_.'<BR>';
        $HTML.='<INPUT TYPE="TEXT" name="yourname" maxlength="50" size="40"></td></tr>';
        $HTML.='<tr class="0"><td align="left" class="texto0">'.$_YourWeb_.'&nbsp;<img src="gif/icon_www.gif" border="0" width="32" height="16"><BR>';
        $HTML.='<INPUT TYPE="TEXT" name="yourweb" value="http://" maxlength="50" size="40"></td></tr>';
        $HTML.='<tr class="1"><td align="left" class="texto0">'.$_YourEmail_.'&nbsp;<img src="gif/icon_email.gif" border="0" width="32" height="16"><BR>';
        $HTML.='<INPUT TYPE="TEXT" name="youremail" maxlength="50" size="40"></td></tr>';
        $HTML.='<tr class="0"><td align="left" class="texto0">'.$_YourComment_.'<BR>';
        $HTML.='<TEXTAREA name="comment" value="comment" rows="7" cols="38" wrap="VIRTUAL"></TEXTAREA></td></tr>';
        $HTML.='<tr class="1"><td align="left" class="texto0">'.$_YourRate_.'&nbsp;';
        $HTML.='<SELECT name="rate">';
        for($i=0;$i<=10;$i++) $HTML.='<OPTION value="'.$i.'">'.$i.'</OPTION>';
        $HTML.='</SELECT></td></tr>';
        $HTML.='<INPUT TYPE="HIDDEN" name="modo" value="comments">';
        $HTML.='<INPUT TYPE="HIDDEN" name="paso" value="2">';
        $HTML.='<INPUT TYPE="HIDDEN" name="ID" value="'.$ID.'">';
        $HTML.='<tr class="0"><td align="center"><input type="button" class="boton" value="'.$_Return_.'" onClick="history.go(-1)">&nbsp;<input type="submit" class="boton"></td></tr>';
        $HTML.='</table></form>';
    }
    if($paso==2) {
        $comentario[0]=$REMOTE_ADDR;
        $comentario[1]=time();
        $comentario[2]=$yourname;
        $comentario[3]=$yourweb;
        $comentario[4]=$youremail;
        $comentario[5]=ereg_replace("(\r\n|\n|\r)","<br>",htmlentities($comment));
		$comentario[5]=str_replace('\\','',$comentario[5]);
        if($comentario[2]=="" OR $comentario[5]=="") {
            $HTML='<form action="info.php" method="post">';
            $HTML.='<table align="center" border="0" cellspacing="1" cellpadding="5">';
            $HTML.='<caption><span class="titulo">'.$topNombre.'</span></caption>';
            $HTML.='<tr class="1"><td align="center" valign="middle" class="texto0">'.$_Comments_.'</td></tr>';
            $HTML.='<tr class="0"><td align="center" valign="middle" class="texto0">'.$_CommentInvalid_.'</td></tr>';
            $HTML.='<tr class="1"><td align="center" valign="middle"><br><INPUT TYPE="SUBMIT" class="boton" value="'.$_Return_.'"><br>&nbsp;</td></tr>';
            $HTML.='<INPUT TYPE="HIDDEN" name="modo" value="comments">';
            $HTML.='<INPUT TYPE="HIDDEN" name="paso" value="">';
            $HTML.='<INPUT TYPE="HIDDEN" name="ID" value="'.$ID.'">';
            $HTML.='</table></form>';
            include('html/header.php');
            echo $HTML;
            echo '</body></html>';
            exit();
        }
        $comentarioOLD=comentarios("search",$ID,$comentario[0],0);
        if($comentarioOLD) {
            comentarios("update",$ID,$comentario,$comentarioOLD);
			//$comentarioSUMA=0;
            $HTML='<form action="info.php" method="post">';
            $HTML.='<table align="center" border="0" cellspacing="1" cellpadding="5">';
            $HTML.='<caption><span class="titulo">'.$topNombre.'</span></caption>';
            $HTML.='<tr class="1"><td align="center" valign="middle" class="texto0">'.$_Comments_.'</td></tr>';
            $HTML.='<tr class="0"><td align="center" valign="middle" class="texto0">'.$_CommentUpdate_.'</td></tr>';
            $HTML.='<tr class="1"><td align="center" valign="middle"><br><INPUT TYPE="SUBMIT" class="boton" value="'.$_Return_.'"><br>&nbsp;</td></tr>';
            $HTML.='<INPUT TYPE="HIDDEN" name="modo" value="comments">';
            $HTML.='<INPUT TYPE="HIDDEN" name="paso" value="">';
            $HTML.='<INPUT TYPE="HIDDEN" name="ID" value="'.$ID.'">';
            $HTML.='</table></form>';
        } else {
            comentarios("write",$ID,$comentario,0);
			//$comentarioSUMA=1;
            $HTML='<form action="info.php" method="post">';
            $HTML.='<table width="95%" align="center" border="0" cellspacing="1" cellpadding="5">';
            $HTML.='<caption><span class="titulo">'.$topNombre.'</span></caption>';
            $HTML.='<tr class="1"><td align="center" valign="middle" class="texto0">'.$_Comments_.'</td></tr>';
            $HTML.='<tr class="0"><td align="center" valign="middle" class="texto0">'.$_CommentAdded_.'</td></tr>';
            $HTML.='<tr class="1"><td align="center" valign="middle"><br><INPUT TYPE="SUBMIT" class="boton" value="'.$_Return_.'"><br>&nbsp;</td></tr>';
            $HTML.='<INPUT TYPE="HIDDEN" name="modo" value="comments">';
            $HTML.='<INPUT TYPE="HIDDEN" name="paso" value="">';
            $HTML.='<INPUT TYPE="HIDDEN" name="ID" value="'.$ID.'">';
            $HTML.='</table></form>';
        }
        $anterior=notas("search",$ID,$comentario[0],0);
        if($anterior==-1) {
            notas("write",$ID,$comentario[0],$rate);
            $aux=datos("read",$ID,0);
            $aux[4]=$aux[4]+$rate;
            $aux[5]++;
			$aux[6]=comentarios("count",$ID,0,0);
            //if($comentarioSUMA) $aux[6]++;
            datos("write",$ID,$aux);
        } else {
            notas("update",$ID,$comentario[0],$rate);
            $aux=datos("read",$ID,0);
            $aux[4]=$aux[4]+$rate-$anterior[1];
			$aux[6]=comentarios("count",$ID,0,0);
			//if($comentarioSUMA) $aux[6]++;
            datos("write",$ID,$aux);
        }
    }
    if($paso==3) {
		$ok=comentarios("delete",$ID,$deleteID,0);
	    if($ok) {
            $aux=datos("read",$ID,0);
			$aux[6]=comentarios("count",$ID,0,0);
            //$aux[6]--;
            datos("write",$ID,$aux);
        }
        $HTML.='<form action="info.php" method="post">';		
        $HTML.='<table align="center" border="0" cellspacing="1" cellpadding="5">';
        $HTML.='<caption><span class="titulo">'.$topNombre.'</span></caption>';
        $HTML.='<tr class="1"><td align="center" valign="middle" class="texto0">'.$_Comments_.'</td></tr>';
        $HTML.='<tr class="0"><td align="center" valign="middle" class="texto0">'.$_CommentDeleted_.'</td></tr>';
        $HTML.='<tr class="1"><td align="center" valign="middle"><br><INPUT TYPE="SUBMIT" class="boton" value="'.$_Return_.'"><br>&nbsp;</td></tr>';
        $HTML.='<INPUT TYPE="HIDDEN" name="modo" value="comments">';
        $HTML.='<INPUT TYPE="HIDDEN" name="paso" value="">';
        $HTML.='<INPUT TYPE="HIDDEN" name="ID" value="'.$ID.'">';
        $HTML.='</table></form>';
    }
}

if($modo=="puntuar") {
    if($paso==1) {
        $HTML='<form action="info.php" method="post">';
        $HTML.='<br><table width="90%" align="center" border="0" cellspacing="1" cellpadding="5">';
        $HTML.='<caption><span class="titulo">'.$topNombre.'</span></caption>';
        $HTML.='<tr class="1"><td align="center" class="texto0">'.$_Rate_.$web.'</td></tr>';
        $HTML.='<tr class="0"><td align="center" class="texto0"><SELECT name="nota">';
        for($i=0;$i<=10;$i++) $HTML.='<OPTION value="'.$i.'">'.$i.'</OPTION>';
        $HTML.='</SELECT></td></tr>';
        $HTML.='<INPUT TYPE="HIDDEN" name="modo" value="puntuar">';
        $HTML.='<INPUT TYPE="HIDDEN" name="paso" value="2">';
        $HTML.='<INPUT TYPE="HIDDEN" name="ID" value="'.$ID.'">';
        $HTML.='<tr class="1"><td align="center"><input type="submit" class="boton"></td></tr>';
        $HTML.='</table></form>';
    }
    if($paso==2) {
        $anterior=notas("search",$ID,$REMOTE_ADDR,0);
        if($anterior==-1) {
            notas("write",$ID,$REMOTE_ADDR,$nota);
            $aux=datos("read",$ID,0);
            $aux[4]=$aux[4]+$nota;
            $aux[5]++;
            datos("write",$ID,$aux);
            $HTML.='<table width="90%" align="center" border="0" cellspacing="1" cellpadding="5">';
            $HTML.='<caption><span class="titulo">'.$topNombre.'</span></caption>';
            $HTML.='<tr class="1"><td align="center" valign="middle" class="texto0">'.$_RateCount_.'</td></tr>';
            $HTML.='<tr class="0"><td align="center" valign="middle" class="texto0">'.$web.'<br>'.$_RateShown_.'<br><img src="gif/star'.$nota.'.gif" border="0"></td></tr>';
            $HTML.='<INPUT TYPE="HIDDEN" name="ID" value="'.$ID.'">';
            $HTML.='</table>';
        } else {
            notas("update",$ID,$REMOTE_ADDR,$nota);
            $aux=datos("read",$ID,0);
            $aux[4]=$aux[4]+$nota-$anterior[1];
            datos("write",$ID,$aux);
            $HTML.='<table width="90%" align="center" border="0" cellspacing="1" cellpadding="5">';
            $HTML.='<caption><span class="titulo">'.$topNombre.'</span></caption>';
            $HTML.='<tr class="1"><td align="center" valign="middle" class="texto0">'.$_RateUpdate_.'</td></tr>';
            $HTML.='<tr class="0"><td align="center" valign="middle" class="texto0">'.$web.'<br>'.$_RateShown_.'<br><img src="gif/star'.$nota.'.gif" border="0"><br>'.$_RateShownBefore_.'<br><img src="gif/star'.$anterior[1].'.gif" border="0"></td></tr>';
            $HTML.='</table>';
        }
    }
}

include('html/header.php');
echo $HTML;
echo '</body></html>';
?>