1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
| <div id="container">
<?php
$base = mysql_connect ('******', '******', '*******');
mysql_select_db('********', $base);
$sql = "SELECT * FROM wa_mur, wa_communaute WHERE id_membre=id ORDER BY date DESC;";
$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
$nb = mysql_num_rows($req);
function getRelativeTime($date)
{
$date_a_comparer = new DateTime($date);
$date_actuelle = new DateTime("now");
$intervalle = $date_a_comparer->diff($date_actuelle);
if ($date_a_comparer > $date_actuelle)
{
$prefixe = 'Dans ';
}
else
{
$prefixe = 'Il y a ';
}
$ans = $intervalle->format('%y');
$mois = $intervalle->format('%m');
$jours = $intervalle->format('%d');
$heures = $intervalle->format('%h');
$minutes = $intervalle->format('%i');
$secondes = $intervalle->format('%s');
if ($ans != 0)
{
$relative_date = $prefixe . $ans . ' an' . (($ans > 1) ? 's' : '');
if ($mois >= 6) $relative_date .= ' et demi';
}
elseif ($mois != 0)
{
$relative_date = $prefixe . $mois . ' mois';
if ($jours >= 15) $relative_date .= ' et demi';
}
elseif ($jours != 0)
{
$relative_date = $prefixe . $jours . ' jour' . (($jours > 1) ? 's' : '');
}
elseif ($heures != 0)
{
$relative_date = $prefixe . $heures . ' heure' . (($heures > 1) ? 's' : '');
}
elseif ($minutes != 0)
{
$relative_date = $prefixe . $minutes . ' minute' . (($minutes > 1) ? 's' : '');
}
else
{
$relative_date = $prefixe . ' quelques secondes';
}
return $relative_date;
}
?>
<ul class="user-data" style="margin-bottom: 20px;list-style-type: none;">
<?php
if ($nb == 0) {
echo '<div style="text-align: center;font-size: 11px;color: #666;">Aucune actualités pour l\'instant</div>';
}
else {
while ($data = mysql_fetch_assoc($req)) { ?>
<li class="user-item" style="float: left;padding: 13px 10px 10px;width: 460px;border-top: 1px solid #cecece;word-wrap: break-word;">
<div class="user-avatar float-l" style="margin-right: 10px;">
<a href="/<?php echo htmlentities(trim($data['pseudo'])); ?>"><img src="../img/upload/<?php echo htmlentities(trim($data['id'])); ?>-mini.png" width="50" height="50" alt="" /></a>
</div>
<div class="user-title" style="margin-bottom: 5px;font-weight: bold;">
<a href="/<?php echo htmlentities(trim($data['pseudo'])); ?>" style="color: #005B83;"><?php echo htmlentities(trim($data['prenom'])); ?> <?php echo htmlentities(trim($data['nom'])); ?></a>
</div>
<div class="user-content" style="margin-left: 60px;">
<p><?php echo htmlentities(nl2br(trim($data['poster']))); ?></p>
</div>
<div class="sub-userContent" style="margin-left: 60px;">
<div class="sub-userFooter" style="margin-top: 6px;">
<p class="size11" style="color: #777;"><a href="" class="sub-userFooter-link" style="color: #0D5085;">J'aime</a> - <a href="" class="sub-userFooter-link" style="color: #0D5085;">Commenter</a> - <?php echo getRelativeTime($data['date']); ?></p>
</div>
<ul class="sub-userData" style="list-style-type: none;">
<li>
<i class="sub-userArrow" style="background: url(../img/top-sub-user.png);background-repeat: no-repeat;height: 5px;display: block;margin-top: 5px;margin-left: 60px;"></i>
</li>
<?php
$base = mysql_connect ('*********', '***********', '**********');
mysql_select_db('*******', $base);
$sql1 = "SELECT * FROM wa_comment, wa_mur WHERE id_post = id_com ORDER BY wa_comment.date DESC;";
$req1 = mysql_query($sql1) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
while ($data1 = mysql_fetch_assoc($req1)) { ?>
<li class="sub-userItem" style="background-color: #bebebe;margin: 0;padding: 4px;margin: 0 0 1px;">
<p><?php echo $data1['msg_com']; ?></p>
</li>
<? } ?>
<li class="sub-userItem" style="background-color: #bebebe;margin: 0;padding: 4px;min-height: 32px;">
<div class="user-avatarCom" style="float: left;padding: 0;margin: 0;">
<img style="margin-right: 4px;" src="../img/upload/<?php echo $result['id']; ?>-mini.png" width="32" height="32" alt="" />
</div>
<form action="" method="post" onsubmit="return false;" class="form_com">
<input type="hidden" name="<?php echo $data['pseudo']; ?>" />
<input type="hidden" name="<?php echo $data['post_id']; ?>" />
<textarea name="msg_comment" class="" style="border: 1px solid #999;font-size: 11px; margin-left: 5px; height: 26px; padding: 5px; width: 343px;resize: none;font-family: Tahoma;position: relative;overflow: hidden;display: block;" id="<?php echo $data['pseudo']; ?>" placeholder="Écrire un commentaire"></textarea>
</form>
<script type="text/javascript">J(".form_com").keypress(function(e) { if(e.which == 13) { var = J('.').val();if( == '') { return false; } else { J('span.load-refresh').show(); J.ajax({ url: "ajax/add_comment.php", type: J(this).attr('method'), data: J(this).serialize(), success: function(html) { J('.').html(html); J('span.load-refresh').hide(); return false; } }); } return false; } });</script>
<script type="text/javascript">window.addEvent('domready', function() {new DynamicTextarea('<?php echo $data['pseudo']; ?>');});</script>
</li>
</ul>
</div>
</li>
<?php }
}
?>
</ul>
</div> |
Partager