<?php
// Created by Ardora www.webardora.net
//COMENTARIOS-functions
date_default_timezone_set("Europe/Madrid");
function showComment($arr,$user){
if ($user==""){
if (empty(trim($arr["usr"]))){echo '<div class="waveComment com-'.$arr['id'].'"><div class="commentP">';} else {echo '<div class="waveComment com-'.$arr['id'].'"><div class="comment">';}
if (!empty(trim($arr["usr"]))){echo '<div class="waveTime">'.waveTime($arr['dt']).'</div>';
echo '<div class="commentAvatar">';}
if (file_exists("ardoraWorkFiles/avatars/".$arr['usr'].".jpg")){$arquivo="ardoraWorkFiles/avatars/".$arr['usr'].".jpg";}else{$arquivo="ardoraWorkFiles/avatars/avatar.png";}
if (empty(trim($arr["usr"]))){echo '<div class="commentTextP"><span class="name"></span> '.$arr['comment'].'</div><div class="clear"></div></div>';}
else{echo '<img src="'.$arquivo.'" width="30" height="30" alt="'.$arr['usr'].'" />';
echo '</div><div class="commentText"><span class="name">'.$arr['usr'].':</span> '.$arr['comment'].'</div><div class="clear"></div></div>';}
}else{
if (empty(trim($arr["usr"]))){echo '<div class="waveComment com-'.$arr['id'].'"><div class="commentP">';}
else{echo '<div class="waveComment com-'.$arr['id'].'"><div class="comment">';}
if (!empty(trim($arr["usr"]))){echo '<div class="waveTime">'.waveTime($arr['dt']).'</div>';echo '<div class="commentAvatar">';}
if (file_exists("../ardoraWorkFiles/avatars/".$arr['usr'].".jpg")){$arquivo="../ardoraWorkFiles/avatars/".$arr['usr'].".jpg";}else{$arquivo="../ardoraWorkFiles/avatars/avatar.png";}
if (empty(trim($arr["usr"]))){echo '<div class="commentTextP"><span class="name"></span> '.$arr['comment'].'</div><div class="replyLink"><button class="ui-button ui-widget ui-state-default ui-corner-all"  onclick="addComment(this,'.$arr['id'].',\''.$user.'\')" style="margin-bottom:5px; margin-left:5px;"><span class="ui-icon ui-icon-plusthick"></span></button></div>';}
else{
echo '<img src="'.$arquivo.'" width="30" height="30" alt="'.$arr['usr'].'" />';echo   '</div><div class="commentText"><span class="name">'.$arr['usr'].':</span> '.$arr['comment'].'</div><div class="replyLink">
<button class="ui-button ui-widget ui-state-default ui-corner-all"  onclick="addComment(this,'.$arr['id'].',\''.$user.'\')" style="margin-bottom:5px; margin-left:5px;"><span class="ui-icon ui-icon-plusthick"></span></button></div>';}
if ($user==$arr['usr']){ echo '<div style="float:right"><button class="ui-button ui-widget ui-state-default ui-corner-all"  onclick="delComment(this,'.$arr['id'].',\''.$user.'\')" style="margin-bottom:5px; margin-left:5px;"><span class="ui-icon ui-icon-minusthick"></span></button></div>';} echo '<div class="clear"></div></div>';}
if($arr["replies"]){foreach($arr["replies"] as $r) showComment($r,$user);}echo "</div>";}
function waveTime($t){$t = strtotime($t); if(date('d')==date('d',$t)) return date('h:i A',$t); return date('F jS Y h:i A',$t);}
?>
