Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 13

Discussione: date e commenti

  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    8

    date e commenti

    Ciao ragazzi ho un problema, ho creato un piccolo sito questo è il link del sito: http://www.thewall.altervista.org/ il problema sta nel fatto che vorrei che i commenti andassero in ordine di data dal più recente al più vecchio, invece come sta adesso è il contrario, come posso risolverlo?? Grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Puoi postare il tuo codice? Se non sappiamo cosa usi non ti possiamo aiutare.

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    8
    a si certe scusate ma non sono molto esperto questo è il codice
    <?php
    // Settings:

    // File in which the entries will be saved (requires CHMOD 666):
    $comment_settings['comment_file'] = "comments.dat";

    // Admin E-mail for notifications (optional):
    $comment_settings['admin_email'] = "";

    // Add new comments at the top or at the bottom?
    $comment_settings['add_comments'] = "bottom";

    // How many comments per page?
    $comment_settings['comments_per_page'] = 999999999;

    // Make links clickable:
    $comment_settings['auto_link'] = true;

    // Length limitations:
    $comment_settings['text_maxlength'] = 500;
    $comment_settings['word_maxlength'] = 50;

    // If no name is entered:
    $comment_settings['anonym'] = "Mister x";

    // Time format:
    $comment_settings['time_format'] = ".%d.%m.%y, %H:%M";

    // Anker, where the comments are on your pages:
    $comment_settings['anker'] = "#comments";

    // replace wordwrap? (if no "
    "):
    $comment_settings['wordwrap'] = " - ";

    // Language settings:
    $comment_lang['language'] = "en";
    $comment_lang['title'] = "";
    $comment_lang['email_title'] = "E-mail to [name]";
    $comment_lang['hp_title'] = "Homepage: [homepage]";
    $comment_lang['no_comments_yet'] = "Nessun commento.";
    $comment_lang['comments_shown'] = "[comments] of [comments_total] comments (part [part])";
    $comment_lang['previous'] = "Previous part";
    $comment_lang['next'] = "Next part";
    $comment_lang['show_all'] = "Show all comments";
    $comment_lang['add_comment'] = "Scrivi il tuo messaggio sul muro di Laterza:";
    $comment_lang['name'] = "Nome:";
    $comment_lang['email_hp'] = "E-mail o Sito:";
    $comment_lang['ok'] = "Invia";
    $comment_lang['no_comments'] = "No comments";
    $comment_lang['one_comment'] = "1 comment";
    $comment_lang['several_comments'] = "[comments] comments";
    $comment_lang['comment_link_title'] = "Read or write comments";
    $comment_lang['email_subject'] = "Comment to [comment_to]";
    $comment_lang['email_text'] = "Comment to [comment_to] by [name]:\n\n[comment]\n\n\nLink to the comment:\n[link]";
    $comment_lang['error'] = "Errore:";
    $comment_lang['err_text_too_long'] = "the text is too long ([characters] characters - maximum is [characters_max] characters)";
    $comment_lang['err_word_too_long'] = "the word [word] is too long";


    // End of settings

    function comment_make_link($string)
    {
    $string = ' ' . $string;
    $string = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\">\\2</a>", $string);
    $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1<a href=\"http://\\2\">\\2</a>", $string);
    $string = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $string);
    $string = substr($string, 1);
    return $string;
    }


    function count_comments($comment_id, $text=0)
    {
    global $comment_settings, $comment_lang;
    $data = file($comment_settings['comment_file']);
    $comment_total_entries = count($data);
    // count entries:
    $comment_count = 0;
    for ($i = 0; $i < $comment_total_entries; $i++)
    {
    $parts = explode("|", $data[$i]);
    if ($parts[3] == $comment_id) $comment_count++;
    }
    if ($text == 0) return $comment_count;
    else
    {
    if ($comment_count == 0) $count_text = $comment_lang['no_comments'];
    elseif ($comment_count == 1) $count_text = $comment_lang['one_comment'];
    else $count_text = str_replace("[comments]", $comment_count, $comment_lang['several_comments']);
    return $count_text;
    }
    }

    if (isset($_GET['comment_id'])) $comment_id = $_GET['comment_id'];
    if (isset($_POST['comment_id'])) $comment_id = $_POST['comment_id'];
    if (isset($_GET['comment_popup'])) $comment_popup = $_GET['comment_popup'];
    if (isset($_POST['comment_popup'])) $comment_popup = $_POST['comment_popup'];

    if (empty($comment_popup) && empty($comment_id) && empty($_GET['comment_popup_link'])) $comment_id = basename($_SERVER["PHP_SELF"]);

    if (isset($comment_id))
    {
    if (isset($_GET['comment_page'])) $comment_page = $_GET['comment_page']; else $comment_page = 1;

    // if comment entered::
    if (isset($_POST['comment_text']) && trim($_POST['comment_text']) != "")
    {
    // check posted data:
    unset($errors);
    if (strlen($_POST['comment_text']) > $comment_settings['text_maxlength']) { $err_txt_too_lng = str_replace("[characters]", strlen($_POST['comment_text']), $comment_lang['err_text_too_long']); $err_txt_too_lng = str_replace("[characters_max]", $comment_settings['text_maxlength'], $err_txt_too_lng); $errors[] = $err_txt_too_lng; }
    $text_arr = str_replace("\n", " ", $_POST['comment_text']);
    $text_arr = explode(" ",$text_arr); for ($i=0;$i<count($text_arr);$i++) { trim($text_arr[$i]); $laenge = strlen($text_arr[$i]); if ($laenge > $comment_settings['word_maxlength']) { $errors[] = str_replace("[word]", "\"".htmlentities(stripslashes(substr($text_ar r[$i],0,$comment_settings['word_maxlength'])))."...\"", $comment_lang['err_word_too_long']); } }

    // look if double:
    $data = file($comment_settings['comment_file']);
    $row_count = count($data);
    for ($row = 0; $row < $row_count; $row++)
    {
    $parts = explode("|", $data[$row]);
    if ($parts[3] == $_POST['comment_id'] && urldecode($parts[4]) == trim($_POST['name']) && trim(urldecode($parts[6])) == trim($_POST['comment_text'])) { $double_entry = true; break; }
    }

    // save if no errors:
    if (empty($errors) && empty($double_entry))
    {
    $comment_text = urlencode(trim($_POST['comment_text']));
    $name = urlencode(trim($_POST['name']));
    $email_hp = trim($_POST['email_hp']);
    if (substr($email_hp,0,7) == "http://") $email_hp = substr($email_hp,7);
    $email_hp = urlencode(base64_encode($email_hp));

    $uniqid = uniqid("");
    if ($comment_settings['add_comments'] == "top")
    {
    $data = file($comment_settings['comment_file']);
    $c = count($data);
    $datei = fopen($comment_settings['comment_file'], 'w+');
    flock($datei, 2);
    fwrite($datei, $uniqid."|".time()."|".$_SERVER["REMOTE_ADDR"]."|".$_POST['comment_id']."|".$name."|".$email_hp."|".$comment_text."\n" );
    for ($i = 0; $i < $c; $i++) { fwrite($datei, trim($data[$i])."\n"); }
    flock($datei, 3);
    fclose($datei);
    }
    else
    {
    $datei = fopen($comment_settings['comment_file'], "a");
    flock($datei, 2);
    fwrite($datei, $uniqid."|".time()."|".$_SERVER["REMOTE_ADDR"]."|".$_POST['comment_id']."|".$name."|".$email_hp."|".$comment_text."\n" );
    flock($datei, 3);
    fclose($datei);
    }

    // E-mail notification to admin:
    if (isset($comment_settings['admin_email']) && $comment_settings['admin_email'] !="")
    {
    if (isset($comment_popup)) { $acid1="?comment_id=".$comment_id."&ampcomment_pop up=true"; $acid2="&comment_id=".$comment_id."&comment_popup= true"; } else { $acid1 = ""; $acid2 = ""; }
    $sender_name = trim($_POST['name']);
    if ($sender_name=="") $sender_name = $comment_settings['anonym'];
    if (preg_match("/^[^@]+@.+\.\D{2,5}$/", base64_decode(urldecode($email_hp)))) $sender_email = base64_decode(urldecode($email_hp)); else $sender_email = "no@email.xx";
    $comment_subject = str_replace("[comment_to]", $_POST['comment_id'], $comment_lang['email_subject']);
    $comment_email_text = str_replace("[comment_to]",$_POST['comment_id'],$comment_lang['email_text']);
    $comment_email_text = str_replace("[name]",stripslashes($sender_name),$comment_email_te xt);
    $comment_email_text = str_replace("[comment]",stripslashes($_POST['comment_text']),$comment_email_text);
    $emailbody = str_replace("[link]","http://".$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'].$acid1.$comment_settings['anker'],$comment_email_text);
    $header= "From: ".stripslashes($sender_name)." <".stripslashes($sender_email).">\n";
    $header .= "X-Mailer: PHP/" . phpversion(). "\n";
    $header .= "X-Sender-IP: ".$_SERVER["REMOTE_ADDR"]."\n";
    $header .= "Content-Type: text/plain";
    @mail($comment_settings['admin_email'], $comment_subject, $emailbody, $header);
    }
    }
    }

    // count:
    $data = file($comment_settings['comment_file']);
    $comment_total_entries = count($data);
    $comment_count = count_comments($comment_id);

    // Header for popup window:
    if (isset($comment_popup))
    {
    ?>xml:lang="<?php echo $comment_lang['language']; ?>"><head><title><?php echo $comment_lang['title']; ?></title><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /><style type="text/css">
    <!-- body {
    color: #0FF;
    background: #ffffff;
    margin: 15px;
    padding: 0px;
    font-family: verdana, arial, sans-serif;
    font-size: 13px;
    } p {

    font-family: verdana, arial, sans-serif; font-size: 13px; line-height: 19px; } h1 {
    font-family: verdana, arial, sans-serif;
    font-size: 9px;
    font-weight: bold;
    } -->
    </style></head><body>
    <?php
    }
    ?>
    <form name="form1" form method="post" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>">
    <div>
    <?php if (isset($comment_popup)) { ?><input type="hidden" name="comment_popup" value="true" /><?php } ?>
    <input type="hidden" name="comment_id" value="<?php echo $comment_id; ?>" />
    <input type="hidden" name="show_comments" value="true" />
    <table style="margin-top: 10px;" border="0" cellpadding="1" cellspacing="0">
    <tr>
    <td colspan="3"><?php echo $comment_lang['add_comment']; ?>
    <textarea style="width: 400px; background: #CF6;" name="comment_text" cols="45" rows="4"><?php if (isset($errors) && isset($_POST['comment_text'])) echo htmlentities(stripslashes($_POST['comment_text']));?>
    </textarea>
    </td>
    </tr>
    <tr>
    <td width="140" style="vertical-align: bottom; font: 14px verdana;"><?php echo $comment_lang['name']; ?>
    <input type="text" name="name" value="<?php if (isset($errors) && isset($_POST['name'])) echo htmlentities(stripslashes($_POST['name'])); else echo ""; ?>" size="23" maxlength="25" /></td>
    <td width="140" style="font-family: verdana, arial, sans-serif; font-size: 11px; vertical-align: bottom;"><?php echo $comment_lang['email_hp']; ?>
    <input type="text" name="email_hp" value="<?php if (isset($errors) && isset($_POST['email_hp'])) echo htmlentities(stripslashes($_POST['email_hp'])); else echo ""; ?>" size="23" maxlength="60" /></td>
    <td width="249" style="font-family: verdana, arial, sans-serif; font-size: 11px; vertical-align: bottom;"><input type="submit" value=" <?php echo $comment_lang['ok']; ?> " /></td>
    </tr>
    </table>
    <body>
    </div></form>
    </body>
    <h1><?php echo $comment_lang['title']; ?>
    <?php

  4. #4
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    8
    }

    // Footer for popup window:
    if (isset($comment_popup))
    {
    ?>
    <?php
    }

    // show comments:
    if (isset($_GET['show_comments'])) $show_comments = $_GET['show_comments'];
    if (isset($_POST['show_comments'])) $show_comments = $_POST['show_comments'];
    if (isset($show_comments) && isset($hide_comments)) unset($hide_comments);
    if (empty($hide_comments))
    {
    $comment_k = 0;
    $comment_a = 0;
    for ($i = 0; $i < $comment_total_entries; $i++)
    {
    $parts = explode("|", $data[$i]);
    if ($parts[3] == $comment_id)
    {
    $comment_k++;
    if ($parts[4] != "") $name = htmlentities(stripslashes(urldecode($parts[4]))); else $name = $comment_settings['anonym'];
    if ($parts[5] != "")
    {
    $email_hp = htmlentities(stripslashes(base64_decode(urldecode( $parts[5]))));
    if (preg_match("/^[^@]+@.+\.\D{2,5}$/", $email_hp))
    {
    $email_parts = explode("@", $email_hp);
    $email_name = $email_parts[0];
    $email_domain_tld = $email_parts[1];
    $domain_parts = explode(".", $email_domain_tld);
    $email_domain = "";
    for ($x = 0; $x < count($domain_parts)-1; $x++)
    {
    $email_domain .= $domain_parts[$x].".";
    }
    $email_tld = $domain_parts[$x];
    $email_title = str_replace("[name]",$name,$comment_lang['email_title']);
    $name = "<script type=\"text/javascript\">
    <!--
    document.write('<a href=\"mailto:');
    document.write('".$email_name."');
    document.write('@');
    document.write('".$email_domain."');
    document.write('".$email_tld."');
    document.write('\" title=\"".$email_title."\">');
    //-->
    </script>".$name."<script type=\"text/javascript\">
    <!--
    document.write('</a>');
    //-->
    </script>";
    }
    else
    {
    $hp_title = str_replace("[homepage]",$email_hp,$comment_lang['hp_title']);
    if (isset($comment_popup)) $name = ''.$name.'';
    else $name = ''.$name.'';
    }
    }
    $comment = htmlentities(stripslashes(urldecode($parts[6])));
    if (isset($comment_settings['wordwrap']) && $comment_settings['wordwrap'] != "") $comment = str_replace("\n", $comment_settings['wordwrap'], trim($comment));
    if (isset($comment_settings['auto_link']) && $comment_settings['auto_link']==true) $comment = comment_make_link($comment);
    $zeit = $parts[1];

    if ($comment_settings['add_comments'] == "top")
    {
    if ($comment_page=="show_all" || ($comment_k>($comment_page-1)*$comment_settings['comments_per_page'] && $comment_k<$comment_page*$comment_settings['comments_per_page']+1)) { ?>
    <span style="margin:0px 0px 5px 0px;"><?php echo $name; ?>:<?php echo $comment; ?></span><span style="margin:0px 0px 5px 0px;"><span style="font-size: 10px; color: #F00;"><?php echo strftime($comment_settings['time_format'], $parts[1]); ?></span></span><span style="margin:0px 0px 5px 0px; font: 22px;">
    <?php $comment_a++; }
    }
    else
    {
    if ($comment_page=="show_all" || ($comment_k > ( ($comment_count-$comment_settings['comments_per_page']) - ( ($comment_page-1) * $comment_settings['comments_per_page'] ) ) && $comment_k < (($comment_count-$comment_settings['comments_per_page'])-(($comment_page-1)*$comment_settings['comments_per_page']))+($comment_settings['comments_per_page']+1))) { ?>
    </span><span style="margin:0px 0px 5px 0px; background: #FFF;"><?php echo $name; ?>:<?php echo $comment; ?></span><span style="margin:0px 0px 5px 0px;"><span style="font-size: 10px; color: #690;"><?php echo strftime($comment_settings['time_format'], $parts[1]); ?></span></span><span style="margin:10px 0px 5px 0px; font: 18px;">
    <?php $comment_a++; }
    }
    }
    }

    $comments_shown = str_replace("[comments]", $comment_a, $comment_lang['comments_shown']);
    $comments_shown = str_replace("[comments_total]", $comment_count, $comments_shown);
    $comments_shown = str_replace("[part]", $comment_page, $comments_shown);
    if ($comment_k == 0) echo "

    ".$comment_lang['no_comments_yet']."</p>";
    if ($comment_settings['comments_per_page'] < $comment_count && $comment_page != "show_all") { ?>
    </span><span style="margin:10px 0px 3px 0px; font-family: verdana, arial, sans-serif; font-size: 11px;"><?php echo $comments_shown; ?></span><span style="margin:0px 0px 3px 0px; font: 11px verdana;">
    <?php
    if ($comment_settings['comments_per_page'] < $comment_count && $comment_page > 1) { ?>
    [ ?comment_id=<?php echo $comment_id; ?>&amp;comment_page=<?php echo $comment_page-1; if (isset($comment_popup)) echo "&amp;comment_popup=true"; if (isset($show_comments)) echo "&amp;show_comments=true"; echo $comment_settings['anker']; ?>" title="<?php echo $comment_lang['previous']; ?>">&laquo; ]
    <?php }
    if ($comment_settings['comments_per_page'] < $comment_count && $comment_page < (($comment_count/$comment_settings['comments_per_page']))) { ?>
    [ ?comment_id=<?php echo $comment_id; ?>&amp;comment_page=<?php echo $comment_page+1; if (isset($comment_popup)) echo "&amp;comment_popup=true"; if (isset($show_comments)) echo "&amp;show_comments=true"; echo $comment_settings['anker']; ?>" title="<?php echo $comment_lang['next']; ?>">&raquo; ]
    <?php }
    ?>
    [ ?comment_id=<?php echo $comment_id; ?>&amp;comment_page=show_all<?php if (isset($comment_popup)) echo "&amp;comment_popup=true"; if (isset($show_comments)) echo "&amp;show_comments=true"; echo $comment_settings['anker']; ?>" title="<?php echo $comment_lang['show_all']; ?>">* ]</span></h1>
    <p style="font-weight:bold;">
    <?php }
    if(isset($errors))
    {
    ?>
    <span style="color:red; font-weight:bold;"><?php echo $comment_lang['error']; ?></span></p>
    <ul>
    <?php foreach($errors as $f) { ?>[*]<?php echo $f; ?>[/list]
    <p style="color:red; font-weight:bold;"><span style="margin:0px 0px 5px 0px;"><span style="font-size: 10px; color: #999;">()</span></span></p>
    <p style="margin:0px 0px 5px 0px;"><span style="font-size: 10px; color: #808080;">()</span></p>
    <p style="margin:0px 0px 5px 0px;"></p>
    <p style="margin:0px 0px 5px 0px;"><span style="margin:10px 0px 3px 0px; font-family: verdana, arial, sans-serif; font-size: 11px;">></span></p>
    <p style="margin:0px 0px 5px 0px;"><span style="color:red; font-weight:bold;">[ "><?php echo count_comments($comment_id, 1); ?> ]</span>

    </p>
    <p style="margin:0px 0px 5px 0px;">

    </p>
    <p style="margin:10px 0px 3px 0px; font-family: verdana, arial, sans-serif; font-size: 11px;"></p>
    <p style="color:red; font-weight:bold;"></p>
    <ul>
    <?php } ?>[/list]

    </p></body></html><?php
    }
    }
    // JavaScript for popup window and link:
    if (isset($_GET['comment_popup_link']))
    {
    ?>function comment(id)
    {
    var page = "<?php echo $_SERVER['PHP_SELF']; ?>?comment_id=" + id + "&comment_popup=true";
    popwin = window.open(page,"","width=460,height=500,scrollba rs,resizable")
    popwin.focus();
    }
    document.open();
    document.write("[ <a href=\"javascript:comment('<?php echo $_GET['comment_popup_link']; ?>')\" title=\"<?php echo $comment_lang['comment_link_title']; ?>\"><?php echo count_comments($_GET['comment_popup_link'], 1); ?></a> ]");
    document.close();
    <?php
    }
    ?>

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Prova a cambiare questa parte:
    [PHP]
    // show comments:
    if (isset($_GET['show_comments'])) $show_comments = $_GET['show_comments'];
    if (isset($_POST['show_comments'])) $show_comments = $_POST['show_comments'];
    if (isset($show_comments) && isset($hide_comments)) unset($hide_comments);
    if (empty($hide_comments))
    {
    $comment_k = 0;
    $comment_a = 0;
    for ($i = $comment_total_entries; $i > 0; $i--)
    {
    $parts = explode("|", $data[$i]);
    [\PHP]

    Dovrebbe andare ma non ne sono sicuro.


  6. #6
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    8
    Grazieeeeeeeee Simo :-))) io no ne capivo nulla di nuovo grazie, ah senti se non ti è di disturbo volevo chiederti se era possibile inserire degli smilies nella textare o anche dei pulsanti per inserire grassetto corsivo

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Per quello c'è una guida di html.it.
    http://javascript.html.it/articoli/l...ditor-wysiwyg/

    Comunque non so se il codice lo supporta...

  8. #8
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    8
    dai ora ci provo, cmq di nuovo grazieee

  9. #9
    Utente di HTML.it
    Registrato dal
    Jul 2010
    Messaggi
    719
    Di nulla

  10. #10
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    8
    Simo intendi alla fine del massaggio prima della data giusto?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.