Changeset 1286

Show
Ignore:
Timestamp:
12/30/06 15:44:39 (2 years ago)
Author:
jm3
Message:

comment deletion implemented with auto-return to the last page you were on, and a status message

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • feedmelinks/comments/delete.php

    r1285 r1286  
    2121<h1> Delete comment: </h1> 
    2222<?php 
    23                 if( getOwnerForLink( $link ) != $u ) 
    24                                bounceBack(); 
    25  
    26                 $comments = get_file_safe( get_comments_file( $link, $u )); 
     23                $owner = getOwnerForLink( $link ); 
     24                $comments = get_file_safe( get_comments_file( $link, $owner )); 
     25                 
     26                # verify that the comment being deleted exists: 
    2727                if( ! array_key_exists( $comment, $comments )) 
    2828                        bounceBack(); 
     29                 
     30                # extract the fields: 
     31                $c = parse_comment( $comments[ $comment ]); 
     32                $commenter = $c["user"]; 
     33 
     34                if( $owner != $u && $commenter != $u ) 
     35                                echo bounceBack(); 
    2936 
    3037                # cache it for displaying in any error messages 
    31                 $c = parse_comment( $comments[ $comment ]); 
    32                 echo '"' . $c["comment"] . '"' . " by " . getUserLink( $c["user"] ) . " from " . formatAsSimpleDate( $c["date"]) . " on " . getLink( $link ) . "</p>"; 
     38                echo '"' . $c["comment"] . '"' . " by " . getUserLink( $commenter ) . " from " . formatAsSimpleDate( $c["date"]) . " on " . getLink( $link ) . "</p>"; 
    3339 
    3440                if( $debug ) 
     
    3642 
    3743                # back up the comment file so the deletion can be un-done if necessary 
    38                 $undo_file = get_undo_file( $u, "comment", "delete" ); 
     44                $undo_file = get_undo_file( $u, "comment", "delete" ); # note that the COMMENTER owns the undo - not the link-owner 
    3945                file_append_contents( $undo_file, $link . ":" . $comments[ $comment ]); 
    4046 
     
    4854                 
    4955                # write the modified array back into the comment file 
    50                 file_put_contents( get_comments_file($link, $u), implode( "", $new_comments )); 
     56                file_put_contents( get_comments_file($link, $owner), implode( "", $new_comments )); 
    5157 
    5258                # send the user back to the link page with a note that the comment was deleted 
    53                 echo bounceTo( "/$link/m/Comment+deleted.", 1 ); 
     59                echo bounceTo( $from ? "$from?mesg=Comment+from+$commenter+deleted." : "/$link/m/Comment+from+$commenter+deleted.", 1 ); 
    5460?> 
    5561 
  • feedmelinks/comments/index.php

    r1285 r1286  
    1616 
    1717<style type="text/css"> 
    18         h3 { 
    19                 margin-bottom: 0px; 
    20         } 
    21         div { 
    22                 line-height: 1.5em; 
    23         } 
     18        h3 { margin-bottom: 0px; } 
     19        div { line-height: 1.5em; } 
    2420</style> 
    2521 
     
    2723                include( "$modules/header.inc.php" );  
    2824                $show_comments = true; 
     25 
     26                if( $mesg ) { 
    2927?> 
     28<br><div class="warning"><?= $mesg ?></div> 
     29<?php } ?> 
    3030 
    3131<h1> 
     
    3737?> 
    3838</h1> 
    39 <?php 
    40                 if( $show_comments ) { 
    41 ?> 
    4239 
    4340<div style="width: 630px; height: 400px;"> 
     
    4946 
    5047<?php 
    51         chdir( get_webserver_root() ); 
    52         $cmd = "find _comments/$user -type f | xargs -n1 grep -H -v $user | sort -rk 2"; 
    53         if( $debug ) 
    54                 echo "$cmd<br />"; 
    55         $n = exec( "$cmd | wc -l" ); 
    56         $o = exec( $cmd, $oba, $r ); 
    57         $c = 1; # counter 
    58         if( $debug ) 
    59                 echo "\$r: $r<br />"; 
    60          
    61          
    62         if( $r == 0 || $r == 1 ) { 
    63                 if( $debug ) 
    64                         echo "got here<br />"; 
     48        $others_comments = get_others_comments_on_my_links( $u ); 
     49        render_my_comments( $others_comments ); 
     50 
     51        if( $r != 0 && $r != 1 ) { 
    6552?> 
    66                 <b><?= $n ?> <?= $n == 1 ? "comment" : "comments" ?></b>:<br /> 
    67 <?php 
    68                  
    69                 foreach ($oba as $line) { 
    70          
    71                         preg_match("/comments\/$user\/(\d+).*:([^,]+), ([^,]+), (.*)$/", $line, $matches ); 
    72                         $linkId = $matches[1]; 
    73                         $commentor = $matches[2]; 
    74                         $date = $matches[3]; 
    75                         $comment = format_comment( $matches[4] ); 
    76          
    77                         echo "$c)  by "; 
    78                         echo makeUserLink( $commentor ) . " on "; 
    79                         echo formatTS( $date ) . " :\n"; 
    80                         echo "<br />\n"; 
    81                         echo "&nbsp; &nbsp; "; 
    82                         echo makeLinkOut( $linkId ) . " "; 
    83                         echo makePermaLink( $linkId ); 
    84                         echo "<br />\n"; 
    85                         echo "&nbsp; &nbsp; <em>$comment</em>\n"; 
    86                         echo " &nbsp; [" .  get_comment_delete_link( $linkId, $line_num ) . "]"; 
    8753 
    88                         echo "<br />\n"; 
    89                         echo "<br />\n"; 
    90                         $c++; 
    91                 } 
    92         } else { 
    93 ?> 
    94 <!-- DEBUG: 
    95 $o: <?= $o ?> 
    96 <?= $cmd ?> failed with code <?= $r ?> 
    97 --> 
    98  
    99 <center>(nobody's added comments to <?= $who ? "$user's" : "your" ?> links yet)</center> 
    100 <br /> 
     54        <center>(nobody's added comments to <?= $who ? "$user's" : "your" ?> links yet)</center><br /> 
    10155<?php 
    10256        } 
    10357?> 
    104  
    105         <br /> 
    106         <h3><?= $who ? ($who . "'s comments on his own links") : "Your comments on your own links" ?></h3> 
    107         <div class="onepxlline">&nbsp;</div> 
    108         <br /> 
    109  
    110 <?php 
    111         $c = 1; #counter 
    112         $the_dir = get_webserver_root() . '/_comments/' . $user; 
    113         if( is_dir( $the_dir )) { 
    114         chdir( $the_dir ); 
    115         $cmd = "grep -l '^$user' * | sort -rn"; 
    116         $n = exec( "$cmd | wc -l" ); 
    117         exec( $cmd, $oa, $r ); 
    118          
    119         echo "<b>$n comments</b><br />\n"; 
    120         foreach ($oa as $commentFile) { 
    121                 $id = substr( $commentFile, 0, -4 ); # trim the ".txt" extension 
    122                  
    123                 $cmd = "cat $commentFile | grep '^$user' | wc -l"; 
    124                 $yrComments = exec( $cmd ); 
    125  
    126                 if( $yrComments != 0 ) { 
    127          
    128                         $cmd = "wc -l $commentFile | awk '{print $1}'"; 
    129                         $totalComments = exec( $cmd ); 
    130                          
    131                         echo "$c : <a href=\"/$id\">$yrComments comment" . ($yrComments == 1 ? "" : "s" ) . "</a> on "; 
    132  
    133                         echo makeLinkOut( $id ) . " "; 
    134                         echo makePermaLink( $id ); 
    135                         if( $yrComments != $totalComments ) { 
    136                                 echo " ($totalComments total)\n"; 
    137                         } 
    138                         echo "<br />\n"; 
    139                                 $c++; 
    140                         } 
    141                 } 
    142         } else { 
    143 ?> 
    144 <!-- 
    145 DEBUG:  
    146 <?= $cmd ?> failed with code <?= $r?> ! 
    147 --> 
    148 <center> 
    149 (<?= $who ? "$who hasn't" : "you haven't" ?> any comments to your links) 
    150 </center> 
    151 <br /> 
    152 <?php 
    153         } # end if dir exists: 
    154 ?> 
    155  
    15658</div> 
    15759 
     
    16264 
    16365<?php 
    164         chdir( get_webserver_root() ); 
    165         $cmd = "find _comments/ -type f | sort -r | xargs -n1 grep -H $user, | grep -v comments/$user | sort -r -k 2"; 
    166         if( $debug ) 
    167                 echo "$cmd<p />"; 
    168         $n = exec( "$cmd | wc -l" ); 
    169         $o = exec( $cmd, $oca, $r ); 
    170         $c = 1; # counter 
    171          
    172         if( $n != 0 ) { 
    173                 echo "<b>$n comments</b><br />\n"; 
    174                 foreach ($oca as $line) { 
    175          
    176                         preg_match("/comments\/(\w+)\/(\d+).*:([^,]+), ([^,]+), (.*)$/", $line, $matches ); 
    177                         $linkId = $matches[2]; 
    178                         $commentor = $matches[1]; 
    179                         $date = $matches[4]; 
    180                         $comment = format_comment( $matches[5] ); 
    181          
    182                         echo "$c : on "; 
    183                         echo formatTS( $date ) . " :\n"; 
    184                         echo makeUserLink( $commentor ) . "'s\n"; 
    185                         echo makeLinkOut( $linkId ) . " "; 
    186                         echo makePermaLink( $linkId ); 
    187                         echo "<br />\n"; 
    188                         echo "&nbsp; &nbsp; <em>$comment</em>\n"; 
    189                         echo " &nbsp; " .  get_comment_delete_link( $linkId, $c - 1 ); 
    190                         echo "<br />\n<br />\n"; 
     66        $commented_links = get_users_comments_on_others_links( $u ); 
     67        render_my_comments( $commented_links, $u ); 
    19168 
    192                        $c++; 
    193                 } 
     69        if( count( $commented_links ) != 0 ) { 
     70                echo "<b>$num comments</b><br />\n"; 
    19471        } else { 
    19572?> 
     
    21794 
    21895<?php  
    219                 } 
    22096        } else {  ?> 
    22197<?= bounceTo( $site . "/login?bounceToPage=" . urlencode( "comments" )) ?> 
  • feedmelinks/modules/menu.inc.php

    r1266 r1286  
    1111You are logged in as:<a class="tn" href="/"><%= $u %></a> 
    1212<% } %> 
    13 <a class="tn" href="index">My Links</a> 
    14 <a class="tn" href="u/<%= $u %>/tags">My Tags</a> 
    15 <a class="tn" href="contacts/index">My Peeps</a> 
    16 <a class="tn" href="account">My Profile</a> 
     13<a class="tn" href="/index">My Links</a> 
     14<a class="tn" href="/u/<%= $u %>/tags">My Tags</a> 
     15<a class="tn" href="/contacts/index">My Peeps</a> 
     16<a class="tn" href="/account">My Profile</a> 
    1717 
    1818<br /> 
    1919 
    20 <a class="tn" href="install">Add more links</a> 
    21 <a class="tn" href="comments">View Recent Comments</a> 
    22 <a class="tn" href="import">Import my Favorites</a> 
    23 <a class="tn" href="faq">FAQ</a> 
     20<a class="tn" href="/install">Add more links</a> 
     21<a class="tn" href="/comments">View Recent Comments</a> 
     22<a class="tn" href="/import">Import my Favorites</a> 
     23<a class="tn" href="/faq">FAQ</a> 
    2424<a class="tn" href="javascript:;" onClick="openContactUs()">Send Feedback!</a> 
    2525 
    26 <% if($u ) { %><a class="tn" href="logout">Log me out</a><% } %> 
     26<% if($u ) { %><a class="tn" href="/logout">Log me out</a><% } %> 
    2727        <!-- <a class="tn" href="search"><img src="/img/mag-glass-tn.png" alt="search" align="top" border="0" /></a>  --> 
    2828        <form name="search_form" action="search"> 
  • feedmelinks/modules/utils.inc.php

    r1281 r1286  
    66include_once( "env.inc.php" ); 
    77include( get_root() . "/modules/prep-cache.inc.php" ); 
     8 
     9function dump( $var ) { 
     10        echo "<pre>"; 
     11        print_r( $var ); 
     12        echo "</pre>"; 
     13} 
    814 
    915function re_enable_user( $u ) { 
     
    24452451                return ; 
    24462452        $pieces = explode(", ", $c); 
    2447         return array( "user" => $pieces[0], "date" => $pieces[1], "comment" => $pieces[2]); 
    2448 
     2453        return array( "user" => $pieces[0], "date" => $pieces[1], "comment" => format_comment( $pieces[2] )); 
     2454
     2455 
     2456function get_num_comments_for_link( $link ) { 
     2457        if( ! $link ) 
     2458                return; 
     2459        $cmd = "wc -l " . get_comments_file( $link, getOwnerForLink( $link )) . " | awk '{print \$1}'"; 
     2460        $a = shell_exec( $cmd ); 
     2461        return $a; 
     2462
     2463 
     2464function render_my_comments( $commented_links, $argUser ) { 
     2465                foreach( $commented_links as $comment_file ) { 
     2466                        # parse the link id out of the filename 
     2467                        $s = preg_replace( "/^.*_comments\//", "", preg_replace( "/\.txt$/",  "", $comment_file ));  
     2468                        list( $owner, $link ) = explode( "/", $s ); 
     2469 
     2470                        $comments = file( $comment_file ); 
     2471                        $num = 0; 
     2472                        foreach( $comments as $comment ) { 
     2473                                $c = parse_comment( $comment ); 
     2474                                if( !$argUser || $c["user"] == $argUser ) { 
     2475                                        echo formatTS( $c["date"] ) . " :\n"; 
     2476                                        if( $c["user"] == $owner ) 
     2477                                                echo makeUserLink( $c["user"] ) . ": \n"; 
     2478                                        else 
     2479                                                echo getBareUserLink( $c["user"] ) . ": \n"; 
     2480                                        echo makeLinkOut( $link ) . " "; 
     2481                                        echo makePermaLink( $link ); 
     2482                                        echo "<br />\n"; 
     2483                                        echo "&nbsp; &nbsp; <em>" . $c["comment"] . "</em>\n"; 
     2484                                        echo " &nbsp; " .  get_comment_delete_link( $link, $num, "/comments"); 
     2485                                        echo "<br />\n<br />\n"; 
     2486                                } 
     2487                                $num++; 
     2488                        } 
     2489                } 
     2490        } 
    24492491 
    24502492function getCommentCSS() { 
     
    25542596            $comments = true; 
    25552597            list($user,$date,$comment) = explode(", ",$line, 3); 
     2598                                                $commenter = $user == $argUser ? true : false; 
    25562599                                                $comment = format_comment( $comment ); 
    25572600            if( $line_num ) 
     
    25752618            echo "<div class=\"$class\" id=\"comment_" . $argId . "_" . $line_num . "\" style=\"width: 40em;\">$comment"; 
    25762619                                                echo "<p/>"; 
    2577                                                 if( $yours
    2578                                                         echo "[<a href='/comments?op=delete&link=$argId&comment=$line_num'>delete</a>]"
     2620                                                if( $yours || $commenter
     2621                                                        echo get_comment_delete_link( $argId, $line_num )
    25792622                                                echo "</div><br />"; 
    25802623          } 
     
    28062849} 
    28072850 
     2851# returns an array of link comment files 
     2852function get_others_comments_on_my_links( $argUser ) { 
     2853        if( ! $argUser ) 
     2854                return; 
     2855        $safe = escapeshellcmd( $argUser ); 
     2856        $cmd = "find " . get_root() . "/_comments/$argUser -type f -name \*.txt | sort -r"; 
     2857        exec( $cmd, $out ); 
     2858        return $out; 
     2859} 
     2860 
     2861# returns an array of link comment files 
     2862function get_users_comments_on_others_links( $argUser ) { 
     2863        if( ! $argUser ) 
     2864                return; 
     2865        $safe = escapeshellcmd( $argUser ); 
     2866        $cmd = "find " . get_root() . "/_comments/ -type f -print -o -name $safe -prune  | sort -r | xargs -n1 grep -H '^$safe' | sort -r -k 2 | sed 's/:.*$//'"; 
     2867        exec( $cmd, $out ); 
     2868        return $out; 
     2869} 
     2870 
    28082871function addCommentToLink( $argId, $argComment, $commenter, $debug ) { 
     2872  log_mesg_to( "attempted comment: $argId, $argComment, $commenter, debug: $debug" , "global" ); 
     2873 
    28092874  $link = $argId; 
    28102875  $comment = $argComment; 
     
    28172882    if( ! isValidUser( $commenter )) { 
    28182883      $e = "$commenter is not a valid user"; 
     2884                        log_mesg_to( $e, "global" ); 
    28192885      return $e; 
    28202886    } else { 
    2821     if( strlen( $comment ) < $MAX_COMMENT_LENGTH ) { 
    2822       $owner = getOwnerForLink( $link ); 
    2823  
    2824       $folder = escapeshellcmd( $owner ) . "/"; 
    2825       $linkfolder = $dir . $folder; 
    2826       $linkfile = $dir . $folder . escapeshellcmd( $link ) . $ext; 
    2827  
    2828       if( !is_dir( $linkfolder ) || !is_writable( $linkfolder )) { 
    2829         mk_folder( $linkfolder ); 
    2830       } else 
    2831         if( $debug ) 
    2832           echo "(DEBUG: FOLDER $folder EXISTS AND IS EXECUTABLE/WRITABLE<br />"; 
    2833       if( !is_file( $linkfile ) || !is_writable( $linkfile )) { 
    2834         if( $debug ) 
    2835           echo "(DEBUG: COMMENTS FILE FOR LINK $link DOES NOT EXIST OR IS NOT WRITABLE, TRYING TO CREATE...)<br />";  
    2836       } 
    2837       if( $debug ) 
    2838         echo "(DEBUG: COMMENTS FILE $link$ext NOW EXISTS AND IS WRITABLE)<br />";  
    2839  
    2840       # fix the newlines: 
    2841       $comment = preg_replace( "/\n/", "___NEWLINE___", $comment ); 
    2842       $comment = hsc( $comment ); 
    2843       $comment = preg_replace( "/___NEWLINE___/", "<br />", $comment ); 
    2844  
    2845  
    2846       # FIXME: handle vignette and parened text.... 
    2847  
    2848       # convert any arbitrary html links 
    2849       $comment = preg_replace( "/link\( *(.+), *(.+)\)/", "<a href=\"\\1\">\\2</a>", $comment ); 
    2850  
    2851       # convert any user links 
    2852       $comment = preg_replace( "/user\( *([^\)]+) *\)/", "<a href=\"/u/\\1\">\\1</a>", $comment ); 
    2853  
    2854       # convert any Cf. footnotes 
    2855       function linkReplace_cb( $matches ) { 
    2856         ob_start(); 
    2857         makeUserLink( getOwnerForLink( $matches[1] )); 
    2858         echo "'s "; 
    2859         makeLinkOut( $matches[1] ); 
    2860         echo " "; 
    2861         makePermaLink( $matches[1] ); 
    2862         $linkOutHTML = ob_get_clean(); 
    2863         return $linkOutHTML; 
    2864       } 
    2865  
    2866       $comment =  
    2867         preg_replace_callback(  
    2868           "/\[([0-9]+)\]/", 
    2869           "linkReplace_cb", 
    2870           $comment 
    2871         ); 
    2872  
    2873       # LOCK HERE: 
    2874       ignore_user_abort(true); 
    2875       $f = fopen( $linkfile, 'a' ); 
    2876       flock( $f, LOCK_EX ); 
    2877  
    2878       # DO WORK 
    2879       if( $bytes_written = fwrite( $f, "$commenter, " . date( $DATE_FORMAT ) . ", $comment\n" )) { 
    2880         if( $debug )  
    2881           echo "(DEBUG: CHMOD-ING $linkfile to world-write)<br/>"; 
    2882         chmod( $linkfile, 0666 ); 
    2883         if( $debug ) 
    2884           echo "(DEBUG: WROTE $bytes_written BYTES TO $linkfile)<br />"; 
    2885         else 
    2886           echo "Adding your comment... done!<br />"; 
    2887          
    2888         # NOW WE SEND MAIL: 
    2889  
    2890         # for every commenter to this link, past and present... 
    2891         $recipients = getCommentersForLink( $link ); 
    2892  
    2893         # plus the link owner 
    2894         array_push( $recipients, $owner ); 
    2895  
    2896         # de-dupe it in case the owner commented in the past... 
    2897         $recipients = array_unique( $recipients ); 
    2898  
    2899         if( $debug ) { 
    2900           echo "(DEBUG: SENDING MAIL...)<br/>\n"; 
    2901           echo "(DEBUG: all recipients: "; 
    2902           print_r( $recipients ); 
    2903           echo ")<br/>\n"; 
    2904         } 
    2905         foreach ( $recipients as $recipient) { 
    2906           if( $debug ) 
    2907             echo "(DEBUG: &#160; this recipient: |$recipient|)<br/>\n"; 
    2908           # dont send mail to ourselves... 
    2909           if( $recipient != $commenter ) { 
    2910               #whose link is being commented: 
    2911               $to = getEmailAddressForUser( $recipient ); 
    2912               if( $to ) { 
    2913  
    2914                 $to = "$recipient <$to>"; 
    2915  
    2916                 $linkName = getTitleForLink( $link ); 
    2917                 $folderName = makePrettyFolderName( getNameForFolder( getFolderForLink( $link ))); 
    2918                
    2919                 $headers = ""; 
    2920                 $pronoun = $recipient == $owner ? "your" : "$owner's"; 
    2921                 $proFolder = $recipient == $owner ? " in your $folderName folder" : ""; 
    2922                 $subject = "$commenter commented on $pronoun link \"$linkName\""; 
    2923                 $body    = "$commenter just added the comment, 
    2924  
    2925 --------------------------------------- 
    2926  
    2927 $comment 
    2928  
    2929 --------------------------------------- 
    2930  
    2931 to $pronoun link \"$linkName\" $proFolder. 
    2932  
    2933 click to respond: " . getSiteURL() . "/$link 
    2934  
    2935 rock on, 
    2936  
    2937 -- Feed Me Links 
    2938 "; 
     2887                        if( strlen( $comment ) < $MAX_COMMENT_LENGTH ) { 
     2888                                $owner = getOwnerForLink( $link ); 
     2889 
     2890                                $folder = escapeshellcmd( $owner ) . "/"; 
     2891                                $linkfolder = $dir . $folder; 
     2892                                $linkfile = $dir . $folder . escapeshellcmd( $link ) . $ext; 
     2893 
     2894                                if( !is_dir( $linkfolder ) || !is_writable( $linkfolder )) { 
     2895                                        mk_folder( $linkfolder ); 
     2896                                } else 
     2897                                        if( $debug ) 
     2898                                                echo "(DEBUG: FOLDER $folder EXISTS AND IS EXECUTABLE/WRITABLE<br />"; 
     2899                                if( !is_file( $linkfile ) || !is_writable( $linkfile )) { 
     2900                                        log_mesg_to( "had to make $linkfile", "global" ); 
     2901                                        if( $debug ) 
     2902                                                echo "(DEBUG: COMMENTS FILE FOR LINK $link DOES NOT EXIST OR IS NOT WRITABLE, TRYING TO CREATE...)<br />";  
     2903                                } 
     2904                                if( $debug ) 
     2905                                        echo "(DEBUG: COMMENTS FILE $link$ext NOW EXISTS AND IS WRITABLE)<br />";  
     2906 
     2907                                # fix the newlines: 
     2908                                $comment = preg_replace( "/\n/", "___NEWLINE___", $comment ); 
     2909                                $comment = hsc( $comment ); 
     2910                                $comment = preg_replace( "/___NEWLINE___/", "<br />", $comment ); 
     2911 
     2912 
     2913                                # FIXME: handle vignette and parened text.... 
     2914 
     2915                                # convert any arbitrary html links 
     2916                                $comment = preg_replace( "/link\( *(.+), *(.+)\)/", "<a href=\"\\1\">\\2</a>", $comment ); 
     2917 
     2918                                # convert any user links 
     2919                                $comment = preg_replace( "/user\( *([^\)]+) *\)/", "<a href=\"/u/\\1\">\\1</a>", $comment ); 
     2920 
     2921                                # convert any Cf. footnotes 
     2922                                function linkReplace_cb( $matches ) { 
     2923                                        ob_start(); 
     2924                                        makeUserLink( getOwnerForLink( $matches[1] )); 
     2925                                        echo "'s "; 
     2926                                        makeLinkOut( $matches[1] ); 
     2927                                        echo " "; 
     2928                                        makePermaLink( $matches[1] ); 
     2929                                        $linkOutHTML = ob_get_clean(); 
     2930                                        return $linkOutHTML; 
     2931                                } 
     2932 
     2933                                $comment =  
     2934                                        preg_replace_callback(  
     2935                                                "/\[([0-9]+)\]/", 
     2936                                                "linkReplace_cb", 
     2937                                                $comment 
     2938                                        ); 
     2939 
     2940                                # LOCK HERE: 
     2941                                ignore_user_abort(true); 
     2942                                $f = fopen( $linkfile, 'a' ); 
     2943                                flock( $f, LOCK_EX ); 
     2944 
     2945                                # DO WORK 
     2946                                if( $bytes_written = fwrite( $f, "$commenter, " . date( $DATE_FORMAT ) . ", $comment\n" )) { 
     2947                                        if( $debug )  
     2948                                                echo "(DEBUG: CHMOD-ING $linkfile to world-write)<br/>"; 
     2949                                        chmod( $linkfile, 0666 ); 
     2950                                        if( $debug ) 
     2951                                                echo "(DEBUG: WROTE $bytes_written BYTES TO $linkfile)<br />"; 
     2952                                        else 
     2953                                                echo "Adding your comment... done!<br />"; 
     2954                                         
     2955                                        # NOW WE SEND MAIL: 
     2956 
     2957                                        # for every commenter to this link, past and present... 
     2958                                        $recipients = getCommentersForLink( $link ); 
     2959 
     2960                                        # plus the link owner 
     2961                                        array_push( $recipients, $owner ); 
     2962 
     2963                                        # de-dupe it in case the owner commented in the past... 
     2964                                        $recipients = array_unique( $recipients ); 
     2965 
     2966                                        if( $debug ) { 
     2967                                                echo "(DEBUG: SENDING MAIL...)<br/>\n"; 
     2968                                                echo "(DEBUG: all recipients: "; 
     2969                                                print_r( $recipients ); 
     2970                                                echo ")<br/>\n"; 
     2971                                        } 
     2972                                        foreach ( $recipients as $recipient) { 
     2973                                                if( $debug ) 
     2974                                                        echo "(DEBUG: &#160; this recipient: |$recipient|)<br/>\n"; 
     2975                                                # dont send mail to ourselves... 
     2976                                                if( $recipient != $commenter ) { 
     2977                                                                #whose link is being commented: 
     2978                                                                $to = getEmailAddressForUser( $recipient ); 
     2979                                                                if( $to ) { 
     2980 
     2981                                                                        $to = "$recipient <$to>"; 
     2982 
     2983                                                                        $linkName = getTitleForLink( $link ); 
     2984                                                                        $folderName = makePrettyFolderName( getNameForFolder( getFolderForLink( $link ))); 
     2985                                                                 
     2986                                                                        $headers = ""; 
     2987                                                                        $pronoun = $recipient == $owner ? "your" : "$owner's"; 
     2988                                                                        $proFolder = $recipient == $owner ? " in your $folderName folder" : ""; 
     2989                                                                        $subject = "$commenter commented on $pronoun link \"$linkName\""; 
     2990                                                                        $body    = "$commenter just added the comment, 
     2991 
     2992        --------------------------------------- 
     2993 
     2994        $comment 
     2995 
     2996        --------------------------------------- 
     2997 
     2998        to $pronoun link \"$linkName\" $proFolder. 
     2999 
     3000        click to respond: " . getSiteURL() . "/$link 
     3001 
     3002        rock on, 
     3003 
     3004        -- Feed Me Links 
     3005        "; 
    29393006 
    29403007          $headers = get_mail_headers(); 
    29413008          $mailSuccess = mail( $to, $subject, $body, $headers); 
     3009                                        log_mesg_to( "sent comment notifation email from $commenter to $to", "mail" ); 
    29423010          if( $debug ) 
    29433011            echo "(DEBUG: &#160;  mailSuccess to \"$to\" was: $mailSuccess)<br />\n"; 
     
    35743642} 
    35753643 
     3644function make_comment_delete_link( $linkId, $number, $from ) { 
     3645        echo get_comment_delete_link( $linkId, $number, $from ); 
     3646} 
     3647 
     3648function get_comment_delete_link( $linkId, $number, $from ) { 
     3649        return "[<a href='/comments/delete?link=$linkId&comment=$number&from=$from'>delete</a>]"; 
     3650} 
     3651 
    35763652function makeDeleteLink( $id ) { 
    35773653  %><a title="Delete this link?" href="javascript:openDelete('<%= $id %>');"><img src="img/delete_entry_16.png" valign="middle" height="16" width="16" alt="delete" border="0" /></a><% 
  • feedmelinks/modules/view-link.inc.php

    r1278 r1286  
    2828                        if( $mesg ) { 
    2929%> 
    30  
    3130<div class="warning"> 
    3231        <?= $mesg ?> 
    3332</div> 
    3433<% 
    35  
    3634                        } 
    3735                        if( $owned ) { 
  • feedmelinks/style/main.css

    r1278 r1286  
    360360        border-top: 1px solid #637459; 
    361361} 
     362 
     363.onepxlline { background-color: #666666; height: 1px; font-size:1px; line-height:1px; } 
     364 
     365.column { 
     366        border: 1px solid #708979; 
     367        width: 300px; 
     368        padding: 4px; 
     369        background-color: #EEEEEE; 
     370} 
     371