Changeset 1423

Show
Ignore:
Timestamp:
03/16/07 10:16:26 (2 years ago)
Author:
jm3
Message:

ibehind in committing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • feedmelinks/modules/header.inc.php

    r1415 r1423  
    4444  if( ! $noFAJAX ) { 
    4545?> 
    46         <script language="javascript" src="script/fajax.js"></script> 
     46        <script language="javascript" src="/script/fajax.js"></script> 
    4747        <script language="javascript"> 
    4848                        fml.user = "<%= $u %>"; 
  • feedmelinks/modules/main-controller.inc.php

    r1336 r1423  
    2323        } else if( $op == "makeNewFolderAndSubmit" ) { 
    2424                if( $debug ) 
    25                         echo "DEBUG: ADDING <b>$linkName</b> ($url)TO NEW FOLDER $newFolderName<br />\n"; 
     25                        echo "DEBUG: ADDING <b>$linkName</b> ($url) TO NEW FOLDER $newFolderName<br />\n"; 
    2626                if( $url && $linkName ) { 
    2727                        if( $newFolderName ) { 
     
    3030                                $name = urlencode( $linkName ); 
    3131                                $userid = urlencode( $u ); 
    32                                 $isPrivate = $isPrivate ? 1 : "NULL"
     32                                $isPrivate = ($isPrivate && $isPrivate != "NULL" && $isPrivate!= "0" && isPrivate != "no" ) ? 1 : 0
    3333 
    3434                                # first we create the new category 
     
    4141 
    4242                                # then we add the link: 
    43                                 $q = addLinkSimple( $url, $name, $userid, $isPrivate ); 
     43                                $q = addLinkSimple( $url, $name, $userid, $isPrivate, ($from = $from ? $from : "makeNewFolderAndSubmit") ); 
    4444                                if( $q ) { 
    4545                                        echo "link added!<br />\n";  
     
    7878                        } 
    7979                        $userid = urlencode( $u ); 
    80                         $isPrivate = $isPrivate ? 1 : "NULL"
     80                        $isPrivate = ($isPrivate && $isPrivate != "NULL" && $isPrivate!= "0" && isPrivate != "no" ) ? 1 : 0
    8181                        $options = ""; # not yet implemented 
    8282 
     
    8686--> 
    8787<?php 
    88                         $q = addLinkSimple( $url, $name, $userid, $isPrivate ); 
     88                        $q = addLinkSimple( $url, $name, $userid, $isPrivate, ($from = $from ? $from : "main-controller-submit") ); 
    8989                        if( $q ) { 
    9090                                echo "link added!<br />\n";  
     
    153153                        $createDate = urlencode( $createDate ); 
    154154                        $userid = urlencode( $u ); 
    155                         $isPrivate = $isPrivate ? 1 : "NULL"
     155                        $isPrivate = ($isPrivate && $isPrivate != "NULL") ? 1 : 0
    156156 
    157157    $qs = "REPLACE INTO links VALUES($id, '$url', '$name', '$createDate', NULL, '$userid', $groupid, $isPrivate);"; 
  • feedmelinks/modules/my-recent.inc.php

    r1388 r1423  
    6161                        <?= makeLink( $id, "/t/$id", urldecode( mysql_result($q,$i,"name")), $url, "", "" ) ?> 
    6262                        <?= makePermaLink( $id ) ?> 
     63                        <?= makeDeleteLink( $id ) ?> 
    6364<?php echo "\n"; ?>             <div style="text-align: right;"> 
    6465<?php $cats = getShortCategoriesForLinkAsHTML( $id, $u, 0, 0 ); ?> <?= $cats ? "in: $cats" : "(<a href='/f/unfiled'>" . getUnCattedName() . "</a>)" ?>  
  • feedmelinks/modules/utils.inc.php

    r1410 r1423  
    1111define( "IDLENESS", 1 ); 
    1212define( "SPAMMING", 2 ); 
     13 
     14function get_links_tagged_for_me( $user ) { 
     15        $links = array(); 
     16        $qs = getQuery( "links_tagged_for_me", "$user" ); 
     17        $q = run_query( $qs ); 
     18        $c = mysql_num_rows($q); 
     19        echo "<p>$user has " . ($c ? $c : 0 ) . " links tagged!</p>"; 
     20        while( $row = mysql_fetch_assoc( $q )) { 
     21                $ID = urldecode( $row["ID"] ); 
     22                $name = urldecode( $row["name"] ); 
     23                $links[$ID] = $name; 
     24        } 
     25        return $links; 
     26} 
    1327 
    1428function has_me_as_a_peep( $them, $me ) { 
     
    100114} 
    101115 
     116function encode_for_xml( $s ) { 
     117        if( ! $s ) 
     118                return; 
     119        return preg_replace( "/_FML_AMP_/", "&amp;", preg_replace( "/_FML_EQUALS_/", "=", urlencode( preg_replace( "/&/", "_FML_AMP_", preg_replace( "/=/", "_FML_EQUALS_", $s ))))); 
     120} 
     121 
    102122function encode_url_for_xml( $url ) { 
    103123        $pieces = explode("?", $url); 
    104         return count( $pieces ) > 1 ? $pieces[0] . "?" . preg_replace( "/_FML_AMP_/", "&amp;", preg_replace( "/_FML_EQUALS_/", "=", urlencode( preg_replace( "/&/", "_FML_AMP_", preg_replace( "/=/", "_FML_EQUALS_", $pieces[1] ))))) : $url; 
     124        return count( $pieces ) > 1 ? $pieces[0] . "?" . encode_for_xml( $pieces[1] ) : $url; 
     125
     126 
     127function encode_as_text_node( $s ) { 
     128#  %C3%A5 
     129 
     130        return encodeAmps( $s ); 
     131        # the five legal builtin XML entities: 
     132        return preg_replace( "/&amp;amp;/", "&amp;", o( $s )); # FIXME: if this is breaking elsewhere then that's a sign that we need to move the amo escaping into o() 
     133        if(  
     134                preg_match( "/&[^a][^m][^p][^;]/", $s ) 
     135                || preg_match( "/&[^q][^u][^o][^t][^;]/", $s ) 
     136                || preg_match( "/&[^a][^p][^o][^s][^;]/", $s ) 
     137                || preg_match( "/&[^l][^t][^;]/", $s ) 
     138                || preg_match( "/&[^g][^t][^;]/", $s ) 
     139                ) 
     140                $s = encodeAmps( $s ); 
     141        return utf8_encode( $s ); 
    105142} 
    106143 
     
    416453} 
    417454 
    418 function re_enable_user( $u ) { 
    419         notify_returning( $u ); 
    420   return( get_simple_rs( getQuery( "re-enable_user", $u ))); 
     455function re_enable_user( $u, $manual = false ) { 
     456        if( ! $u || user_enabled( $u )) 
     457                return 0; 
     458        notify_returning( $u, $manual ); 
     459  return( run_query( getQuery( "re-enable_user", $u ))); 
    421460} 
    422461 
     
    472511function report_spammer( $alleged_spammer, $reporter ) { 
    473512        $reporter = $reporter ? $reporter : "anonymous"; 
    474         log_mesg_to( get_ip() . ": $reporter reported $alleged_spammer as a spammer", "security" ); 
     513        log_mesg_to( "[spammer reported] $alleged_spammer reported by $reporter, " . get_ip(), "security" ); 
    475514  $body = "$alleged_spammer was reported as a spammer (gasp!). 
    476515http://feedmelinks.com/u/$alleged_spammer 
     
    554593  $q = run_query( getQuery( "snuff_user", $user )); 
    555594 
    556   log_mesg_to( get_ip() . ": " . get_user() . " snuffed out user $user", "security" ); 
     595  log_mesg_to( "[snuffed] $user by " . get_user(), "security" ); 
    557596  echo get_snuffed_mesg(); 
    558597?> 
     
    741780} 
    742781 
    743 function notify_returning( $u ) { 
     782function notify_returning( $u, $manual = false ) { 
    744783        $site = get_site(); 
    745   $body = "Hello $u -- welcome back! We're stoked that you've decided to keep using Feed Me Links. 
     784        if( $manual ) { 
     785                $body = "Hi $u. This is the Feed Me Links Robot speaking. 
     786         
     787I want to apologize on behalf of jm3 for his hairbrained scheme to rid Feed Me Links of spammers. This same scheme, which has overall, worked quite well, also inadvertently expired the accounts of a few legitimate users without warning. Including yours. :-( 
     788 
     789Although no data was lost and no links were disabled, this was quite an embarassing turn of events for us, and very inconvenient for those users whose accounts were expired. We are manually verifying and renabling each legitimate account right now. 
     790 
     791Your account has been re-enabled, and for reference purposes, your password is: " . getPasswdForUser( $u ) ." 
     792 
     793If you would like to re-set your account password, just click here: $site/account 
     794 
     795Thank you, and welcome [back] to Feed Me Links.  
     796If you have any questions or concerns, feel free to email me (jm3) directly at jm3@feedmelinks.com 
     797 
     798-- 
     799 
     800The Feed Me Links Robot"; 
     801        } else { 
     802                $body = "Hello $u -- welcome back! We're stoked that you've decided to keep using Feed Me Links. 
    746803         
    747804You can start using Feed Me Links immediately; your current account password is: " . getPasswdForUser( $u ) ." 
     
    753810 
    754811The Feed Me Links Robot"; 
     812} 
    755813  $headers = get_mail_headers(); 
    756814  $to = getEmailAddressForUser( $u ); 
    757815  $success = mail( $to, "Welcome back to Feed Me Links!", $body, $headers); 
    758816  if( $success ) 
    759     log_mesg_to( "sent welcome back mail to $to", "mail" ); 
     817    log_mesg_to( "sent " . ($manual ? "[MANUAL] " : "" ) . "welcome back mail to $to", "mail" ); 
    760818  return $success; 
    761819} 
     
    10931151 
    10941152    $qs = getQuery( "add_new_category_xref", $newLinkID, $catNum ); 
    1095     if( $debug ) 
    1096       echo "DEBUG: $qs"; 
    10971153    $q = mysql_query( $qs ); 
    10981154    if( ! $q ) { 
    10991155      $e = mysql_error($con); 
    11001156      $tok = get_mysql_dupe_error(); 
    1101       if( ! strstr( $e, $tok)) { 
     1157      if( $e && (!strstr( $e, $tok))) { 
    11021158%> 
    11031159<div class="attention warning"> 
     
    11051161Error was: <%= $e %> 
    11061162</div> 
    1107 <% 
     1163<?php 
    11081164        break; 
    11091165      } else { 
     
    11221178 
    11231179  function dumpParams() { 
    1124   %
    1125   <% 
     1180  ?
     1181  <?php 
    11261182    foreach( $_GET as $pname => $pval ) { e( $pname . " = " . $pval ); } 
    11271183    e( "" ); 
    11281184    foreach( $_POST as $pname => $pval ) { e( $pname . " = " . $pval ); } 
    1129     %> 
    1130     <% 
    1131   } 
     1185    ?> 
     1186    <?php 
     1187  } 
     1188 
     1189        function similar_to_recent( $url ) { 
     1190                return false; # FIXME 
     1191        } 
    11321192 
    11331193  # search to see if the URL exists anywhere public 
    11341194  function link_exists( $url ) { 
    1135     $qs = getQuery( "get_id_for_existing_link", $url ); 
    1136     $q = mysql_query( $qs ); 
     1195    $q = mysql_query( getQuery( "get_id_for_existing_link", $url )); 
    11371196    if( $q && mysql_num_rows($q) ) 
    11381197      return mysql_result( $q, 0, "id" ); 
     
    12791338 
    12801339  function fatal( $m ) { 
    1281     l( "FATAL ERROR.", $m ); 
     1340    log_mesg_to( "[FATAL ERROR] $m", "global" ); 
    12821341    return tell( "Darn! ", $m ); 
    12831342  } 
     
    16831742 
    16841743function get_peeps_feed( $user, $user_key ) { 
    1685         #echo "<br>"; 
    1686         #echo "user is: $user<br>"; 
    1687         #echo "user_key is: $user_key<br>"; 
    1688         #echo "get_feed_key($user)  is: " . get_feed_key( $user ) . "<br>"; 
    1689         #echo "<br>"; 
    16901744        $users = get_someone_elses_contacts( $user ); 
    1691         #print_r( $users ); 
    1692         #echo "<br>"; 
    16931745        if( ! $user || $user_key != get_feed_key( $user )) { 
    16941746                echo "no user or invalid key."; 
     
    16971749        } 
    16981750 
    1699         #echo "no done yet!!!<br>"; 
    17001751        $users = get_someone_elses_contacts( $user ); 
    17011752        Header( "Content-type: Text/XML" ); 
     
    23962447                        SELECT * FROM tags WHERE name = 'private' AND userid = '" . urlencode( $args[1] ) . "';"; 
    23972448 
     2449        } else if( $argWhichQuery  == "links_tagged_for_me" ) { 
     2450                $me = urlencode( $args[1] ); 
     2451    return " 
     2452                SELECT * FROM tags, links, links_tags_xref WHERE tags.name = 'for:$me' AND links_tags_xref.tagID = tags.ID AND links_tags_xref.linkID = links.ID AND (links.isPrivate is NULL OR links.isPrivate = 0) LIMIT 15;"; 
     2453 
    23982454        } else if( $argWhichQuery  == "rude_solo_im_name" ) { 
    23992455    return " 
     
    24512507    return " 
    24522508    INSERT INTO spam_IPs VALUES ( '" . urlencode($args[1]) . "', '" . urlencode($args[2]) . "', '" . urlencode($args[3]) . "', NULL, NULL ) "; 
     2509 
     2510  } else if( $argWhichQuery  == "add_spammer_domain" ) { 
     2511    return " 
     2512    INSERT INTO spam_domains VALUES ( NULL, '" . urlencode($args[1]) . "');"; 
    24532513 
    24542514  } else if( $argWhichQuery  == "links_per_user" ) { 
     
    24642524    SELECT * FROM tags WHERE userId = '" . urlencode($args[1]) . "' ORDER BY name ASC;"; 
    24652525 
     2526  } else if( $argWhichQuery  == "recent_public" ) { 
     2527    return " 
     2528    SELECT ID, name, url, createDate, userid FROM links WHERE IsPrivate IS NULL ORDER BY ID DESC LIMIT " . mysql_real_escape_string($args[1]) . ";"; 
     2529   
     2530        } else if( $argWhichQuery  == "simple_recent_for_user" ) { 
     2531    return " 
     2532    SELECT ID, name, url, createDate FROM links WHERE IsPrivate IS NULL AND userid = '" . urlencode($args[2]) . "' ORDER BY ID DESC LIMIT " . mysql_real_escape_string($args[1]) . ";"; 
     2533   
    24662534  } else if( $argWhichQuery  == "most_recent_link_for_user" ) { 
    24672535    return " 
     
    25132581   
    25142582  } else if( $argWhichQuery  == "get_id_for_existing_link" ) { 
    2515     return "SELECT id FROM links WHERE url = '" . urlencode( $args[1] ) . "' AND isPrivate IS NULL;"; 
     2583                $url = urlencode( $args[1] ); 
     2584                $without_slash = preg_replace( "/%2F$/", "", $url ); 
     2585    return "SELECT id FROM links WHERE (LOWER(url) = LOWER('$url') OR LOWER(url) = LOWER('$without_slash')) AND isPrivate IS NULL;"; 
    25162586 
    25172587  } else if( $argWhichQuery  == "tag" ) { 
     
    25692639   
    25702640  } else if( $argWhichQuery  == "add_link" ) { 
    2571                 if( $args[4] == "NULL" || !$args[4] ) 
    2572                         run_heuristics( $argWhichQuery, $args[3], array( "url" => $args[1], "name" => $args[2] )); # TODO: it May be a problem that we're not passing the tags too... 
    2573     return " 
    2574                 INSERT INTO links VALUES(NULL,'" . urlencode( $args[1] ) . "','" . urlencode(escapeQuotes($args[2])) . "', NULL, NULL,'" . urlencode( $args[3] ) . "', NULL, " . $args[4] . ");"; 
     2641                $isPrivate = $args[4]; 
     2642                if( !$isPrivate && $isPrivate != "checked" ) 
     2643                        run_heuristics( $argWhichQuery, $args[3], array( "url" => $args[1], "name" => $args[2], "from" => $args[5] )); # TODO: it May be a problem that we're not passing the tags too... 
     2644                $isPrivate = ($isPrivate == 0) ? "NULL" : 1; 
     2645    $qs = " 
     2646                INSERT INTO links VALUES(NULL,'" . urlencode( $args[1] ) . "','" . urlencode(escapeQuotes($args[2])) . "', NULL, NULL,'" . urlencode( $args[3] ) . "', NULL, $isPrivate);"; 
     2647                return $qs; 
    25752648 
    25762649  } else if( $argWhichQuery  == "add_tag" ) { 
     
    26402713function encodeAmps( $argS ) { 
    26412714  # replace any unescaped ampersands 
    2642   return preg_replace( "/(&)([^(amp;)])/", "&amp;$2", $argS ); 
     2715  return preg_replace( "/</", "&lt;", preg_replace( "/>/", "&gt;", preg_replace( "/(&)([^(amp;)])/", "&amp;$2", $argS ))); 
    26432716} 
    26442717 
     
    30153088# judge, jury, and executioner 
    30163089function isJJE( $u ) { 
    3017   if( $u == "jm3" || $u == get_bot_user() ) 
     3090  if( $u == "jm3" || $u == get_bot_puppetmaster_user() ) 
    30183091    return true; 
    30193092  else 
     
    30223095 
    30233096function isSuperUser( $u ) { 
    3024   if( $u == "jm3" || $u == "pheezy" || $u == get_bot_user() ) 
     3097  if( $u == "jm3" || $u == "pheezy" || $u == get_bot_puppetmaster_user() ) 
    30253098    return 1; 
    30263099  else 
     
    33813454  if( $num_rows > 1 ) { 
    33823455    #disabled because it got too noisy: 
    3383     log_mesg_to( "$ip: potential spammer $argUserId ($argEmail) creating multiple accounts from the same IP", "security" ); 
     3456    log_mesg_to( "[account creation attempt] $argUserId, $argEmail, $ip", "security" ); 
    33843457    $q = run_query( getQuery( "log_ip", $argUserId, $argEmail, $ip )); 
    33853458    return; 
     
    35113584} 
    35123585 
    3513 function addLinkSimple( $argUrl, $argName, $argSubmitter, $isPrivate = "NULL", $debug = 0 ) { 
     3586function addLinkSimple( $argUrl, $argName, $argSubmitter, $isPrivate, $from, $debug = 0 ) { 
    35143587  if( !( $argUrl &&  $argName && $argSubmitter ))  
    35153588    return 0; 
     
    35223595  if( get_tag_to_link_ratio( $argSubmitter ) > get_max_ttl_ratio() ) { # this could be contraversial 
    35233596    $isPrivate = 1; 
    3524     log_mesg_to( get_ip() . ": privatizing new link from $argSubmitter due to T:L ratio", "security" ); 
     3597    log_mesg_to( "[privatize new link from spammer] $argSubmitter, " . get_ip() . ", via:$from due to T:L ratio", "security" ); 
    35253598        } 
    35263599 
    3527         $qs = getQuery( "add_link", $argUrl, $argName, $argSubmitter, $isPrivate ); 
     3600        $qs = getQuery( "add_link", $argUrl, $argName, $argSubmitter, $isPrivate, $from ); 
    35283601  if( $debug )  
    35293602    echo "qs: $qs<br>"; 
    35303603  $q = mysql_query( $qs ); 
    35313604  $id = $q ? mysql_insert_id() : 0; 
     3605        log_mesg_to( "[$from] (" . ($isPrivate ? "private" : "public") . ")  $argUrl, $argName, $argSubmitter", "links" ); 
    35323606  conClose(); 
    35333607  return $id; 
     
    35353609 
    35363610# deprecated; call addLinkSimple() instead 
    3537 function addLink( $argUrl, $argName, $argSubmitter, $argFolderId, $argPrivate, $argOptions ) { 
     3611function addLink( $argUrl, $argName, $argSubmitter, $argFolderId, $argPrivate, $from, $argOptions ) { 
    35383612  if(  !( $argUrl &&  $argName && $argSubmitter )) 
    35393613    return 0; 
     
    35423616    return 0; # FIXME: signal this error back to the user!!!! 
    35433617   
    3544         $q = addLinkSimple( urldecode( $argUrl ), urldecode( $argName ), urldecode( $argSubmitter ) ); 
     3618        log_mesg_to( "[$from] $argUrl, $argName, $argSubmitter, $argPrivate", "links" ); 
     3619        $q = addLinkSimple( urldecode( $argUrl ), urldecode( $argName ), urldecode( $argSubmitter ), $argPrivate, $from ); 
    35453620  return $q; 
    35463621} 
     
    40524127 
    40534128function get_tag_IDs_as_string( $argId, $argUserId ) { 
    4054   if( $argId && $argUserId ) { 
    4055     return( implode( ", ",  getCategoriesForLink( $argId ))); 
    4056   } 
     4129  if( $argId && $argUserId ) 
     4130    return( implode( ", ",  get_tags( $argId, $argUserId ))); 
     4131
     4132 
     4133# consistency wrapper  
     4134function get_tag_names_as_string( $argId, $argUserId ) { 
     4135  if( $argId && $argUserId ) 
     4136    return( implode( ", ",  get_tag_names( $argId, $argUserId ))); 
    40574137} 
    40584138 
     
    40684148  $cats = preg_replace( "/a> /", "a>&#160;", $cats ); 
    40694149  return $cats; 
     4150} 
     4151 
     4152# deprecated, call get_tags() instead 
     4153function getCategoriesForLink( $link_ID, $user ) { 
     4154        return get_tags( $link_ID, $user ); 
     4155} 
     4156 
     4157function get_tags( $link_ID, $user ) { 
     4158        return get_tag_names( $link_ID, $user ); 
    40704159} 
    40714160 
  • feedmelinks/modules/view-link.inc.php

    r1397 r1423  
    7171        <div ftype="name" fid="<%= $l %>"> 
    7272                <a  
    73                         class="biglink" title="Click to view"  
     73                        class="biglink" title="<?= $name ?>"  
    7474                        onMouseOver="window.status='<?= $link ?>'; return true;" 
    7575                        onMouseOut="window.status=''; return true;"