Changeset 1394

Show
Ignore:
Timestamp:
03/05/07 22:39:36 (2 years ago)
Author:
jm3
Message:
  • domain name TLD addition (.nu) for the big spaceship cats
  • privatizing tag fix for best beta tester ever bri cors: tagging something private will make the link private, and vise versa; making something private will tag it private
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • feedmelinks/lib/FeedMeLinks/Bot.pm

    r1391 r1394  
    6060                $message =~ m/(ftp|gopher|https?):\/\//  
    6161                || $message =~ m/www\./  
    62                 || $message =~ m/\.(com|org|net|biz|info|gov|mil|edu|uk|es|jp|mx|it|am|ca|de)\/?$/  
     62                || $message =~ m/\.(com|org|net|biz|info|gov|mil|edu|uk|es|jp|mx|it|am|ca|de|nu|tv)\/?$/  
    6363                ) { 
    6464                if( $sessions_ref->{ $sender }->{ "validated" } ) { 
     
    561561        my %messages = ( 
    562562                "add_tags" => "To add tags, just type them, separated by commas", 
    563                 "rename" => "To rename it, type it: <em>new name...</em>" 
     563                "rename" => "To rename it, just type <b>rename: <em>new name...</em></b>" 
    564564        ); 
    565565        return $messages{ "$m" }; 
  • feedmelinks/modules/utils.inc.php

    r1392 r1394  
    986986} 
    987987 
     988function apply_tag_by_ID( $link_ID, $tag_ID ) { 
     989        log_mesg_to( "apply_tag_by_ID( $link_ID, $tag_ID )", "global" ); 
     990        run_query( getQuery( "add_new_category_xref", $link_ID, $tag_ID )); 
     991} 
     992 
    988993function add_tags_from_request( $u, $newLinkID, $known_tag_IDs, $con, $possibly_new_tag_names, $link_is_private ) { 
    989994        if( $u != getOwnerForLink( $newLinkID )) { 
     
    10201025  if( count( $new_tag_names )) { 
    10211026    foreach( $new_tag_names as $newCategoryName ) { 
     1027 
     1028                        if( $newCategoryName == "private" ) 
     1029                                 setPrivate( $newLinkID ); 
     1030 
    10221031      if( $debug ) 
    10231032        echo "First we add any tags that are actually new, then we tag the link w/all the remaining existing tags:<br />"; 
     
    13421351  } 
    13431352 
    1344   function get_uni_pattern() { 
    1345     return "/%u([A-Fa-f0-9]{4}|[A-Fa-f0-9]{2})/"; 
    1346   } 
    1347  
    1348   function toggle_link_privacy( $arg_user, $arg_link_id ) { 
    1349     if( $arg_user && $arg_link_id ) { 
    1350       $qs = "SELECT isPrivate FROM links WHERE ID = $arg_link_id AND userid = '$arg_user'"; 
    1351       $con_toggle_link_privacy = mysql_connect(); 
    1352       mysql_selectdb( getDBName() ); 
    1353       $q = mysql_query( $qs ); 
    1354       if( $q ) { 
    1355         $old = mysql_result($q, 0, "isPrivate" ); 
    1356         $old = $old ? $old : "NULL"; 
    1357         $new = $old == 1 ? "NULL" : 1; 
    1358         $new_label = $new == 1 ? "private" : "public"; 
    1359                                 if( $new == "NULL" ) 
    1360                                         run_heuristics( "publicize_link", $arg_user, array( "link" => $arg_link_id )); 
    1361  
    1362         $qs = "UPDATE links SET isPrivate = $new WHERE id = $arg_link_id AND userid = '$arg_user';"; 
    1363         $q = mysql_query( $qs ); 
    1364         if( $q ) { 
    1365           conClose( $con_toggle_link_privacy ); 
    1366           return "Made link $arg_link_id $new_label."; 
    1367         } 
    1368       } 
    1369       conClose( $con_toggle_link_privacy ); 
    1370     } else 
    1371       return "error!"; 
    1372   } 
    1373  
    1374  
    1375   function get_linkpocket( $argUser ) { 
    1376     if( $argUser ) { 
    1377       $con_getLinkpocket = mysql_connect(); 
    1378       mysql_selectdb( getDBName() ); 
    1379       $qs =  
    1380       "SELECT ID FROM tags  
    1381         WHERE  
    1382           name = 'linkpocket' 
    1383           AND userid = '$argUser';"; 
    1384       $q = mysql_query( $qs ); 
    1385       if( $q ) 
    1386         $id = mysql_result($q, 0, "ID" ); 
    1387       $qs = "SELECT COUNT(*) AS count FROM links_tags_xref WHERE tagID = $id"; 
    1388       $q = mysql_query( $qs ); 
    1389       if( $q ) 
    1390         $count = mysql_result($q, 0, "count" ); 
    1391  
    1392       conClose( $con_getLinkpocket ); 
    1393       return array( "id" => $id, "count" => $count ); 
    1394     } 
    1395   } 
    1396  
    1397         function get_entities() { 
    1398      return array( 
    1399          128 => '&#8364;', 
    1400          130 => '&#8218;', 
    1401          131 => '&#402;', 
    1402          132 => '&#8222;', 
    1403          133 => '&#8230;', 
    1404          134 => '&#8224;', 
    1405          135 => '&#8225;', 
    1406          136 => '&#710;', 
    1407          137 => '&#8240;', 
    1408          138 => '&#352;', 
    1409          139 => '&#8249;', 
    1410          140 => '&#338;', 
    1411          142 => '&#381;', 
    1412          145 => '&#8216;', 
    1413          146 => '&#8217;', 
    1414          147 => '&#8220;', 
    1415          148 => '&#8221;', 
    1416          149 => '&#8226;', 
    1417          150 => '&#8211;', 
    1418          151 => '&#8212;', 
    1419          152 => '&#732;', 
    1420          153 => '&#8482;', 
    1421          154 => '&#353;', 
    1422          155 => '&#8250;', 
    1423          156 => '&#339;', 
    1424          158 => '&#382;', 
    1425          159 => '&#376;'); 
     1353function get_uni_pattern() { 
     1354        return "/%u([A-Fa-f0-9]{4}|[A-Fa-f0-9]{2})/"; 
     1355
     1356 
     1357function toggle_link_privacy( $arg_user, $arg_link_id ) { 
     1358        if( $arg_user && $arg_link_id ) { 
     1359                $qs = "SELECT isPrivate FROM links WHERE ID = $arg_link_id AND userid = '$arg_user'"; 
     1360                $con_toggle_link_privacy = mysql_connect(); 
     1361                mysql_selectdb( getDBName() ); 
     1362                $q = mysql_query( $qs ); 
     1363                if( $q ) { 
     1364                        $old = mysql_result($q, 0, "isPrivate" ); 
     1365                        $old = $old ? $old : "NULL"; 
     1366                        $new = $old == 1 ? "NULL" : 1; 
     1367                        $new_label = $new == 1 ? "private" : "public"; 
     1368                        if( $new == "NULL" ) 
     1369                                run_heuristics( "publicize_link", $arg_user, array( "link" => $arg_link_id )); 
     1370                        else 
     1371                                apply_tag_by_ID( $arg_link_id, get_private_tag_ID( get_user())); 
     1372 
     1373                        $qs = "UPDATE links SET isPrivate = $new WHERE id = $arg_link_id AND userid = '$arg_user';"; 
     1374                        $q = mysql_query( $qs ); 
     1375                        if( $q ) { 
     1376                                conClose( $con_toggle_link_privacy ); 
     1377                                return "Made link $arg_link_id $new_label."; 
     1378                        } 
     1379                } 
     1380                conClose( $con_toggle_link_privacy ); 
     1381        } else 
     1382                return "error!"; 
     1383
     1384 
     1385function get_private_tag_ID( $user ) { 
     1386        $tag_id = get_simple_rs( getQuery( "find_private_tag", $user )); 
     1387        log_mesg_to( "get_private_tag_ID: $user : $tag_id", "global" ); 
     1388        return $tag_id; 
     1389
     1390 
     1391function get_linkpocket( $argUser ) { 
     1392        if( $argUser ) { 
     1393                $con_getLinkpocket = mysql_connect(); 
     1394                mysql_selectdb( getDBName() ); 
     1395                $qs =  
     1396                "SELECT ID FROM tags  
     1397                        WHERE  
     1398                                name = 'linkpocket' 
     1399                                AND userid = '$argUser';"; 
     1400                $q = mysql_query( $qs ); 
     1401                if( $q ) 
     1402                        $id = mysql_result($q, 0, "ID" ); 
     1403                $qs = "SELECT COUNT(*) AS count FROM links_tags_xref WHERE tagID = $id"; 
     1404                $q = mysql_query( $qs ); 
     1405                if( $q ) 
     1406                        $count = mysql_result($q, 0, "count" ); 
     1407 
     1408                conClose( $con_getLinkpocket ); 
     1409                return array( "id" => $id, "count" => $count ); 
    14261410        } 
    1427  
    1428   # strips slashes, and converts special characters to HTML equivalents for string defined in $var 
    1429   function o( $s ){ 
    1430      $chars = get_entities(); 
    1431      return hateration( unicode_fix( str_replace(array_map('chr', array_keys($chars)), $chars, htmlentities(stripslashes($s))))); 
    1432   } 
    1433  
    1434   function hateration( $s ) { 
    1435     return unEscapeQuotes( preg_replace( "/&amp;#x/", "&#x", $s )); 
    1436   } 
    1437  
    1438   # replace things which look like ghastly php entities with cute lil hex escapes 
    1439   function unicode_fix( $s ) { 
    1440     return preg_replace( get_uni_pattern(), "&#x$1;", $s ); 
    1441   } 
     1411
     1412 
     1413function get_entities() { 
     1414         return array( 
     1415                         128 => '&#8364;', 
     1416                         130 => '&#8218;', 
     1417                         131 => '&#402;', 
     1418                         132 => '&#8222;', 
     1419                         133 => '&#8230;', 
     1420                         134 => '&#8224;', 
     1421                         135 => '&#8225;', 
     1422                         136 => '&#710;', 
     1423                         137 => '&#8240;', 
     1424                         138 => '&#352;', 
     1425                         139 => '&#8249;', 
     1426                         140 => '&#338;', 
     1427                         142 => '&#381;', 
     1428                         145 => '&#8216;', 
     1429                         146 => '&#8217;', 
     1430                         147 => '&#8220;', 
     1431                         148 => '&#8221;', 
     1432                         149 => '&#8226;', 
     1433                         150 => '&#8211;', 
     1434                         151 => '&#8212;', 
     1435                         152 => '&#732;', 
     1436                         153 => '&#8482;', 
     1437                         154 => '&#353;', 
     1438                         155 => '&#8250;', 
     1439                         156 => '&#339;', 
     1440                         158 => '&#382;', 
     1441                         159 => '&#376;'); 
     1442
     1443 
     1444# strips slashes, and converts special characters to HTML equivalents for string defined in $var 
     1445function o( $s ){ 
     1446         $chars = get_entities(); 
     1447         return hateration( unicode_fix( str_replace(array_map('chr', array_keys($chars)), $chars, htmlentities(stripslashes($s))))); 
     1448
     1449 
     1450function hateration( $s ) { 
     1451        return unEscapeQuotes( preg_replace( "/&amp;#x/", "&#x", $s )); 
     1452
     1453 
     1454# replace things which look like ghastly php entities with cute lil hex escapes 
     1455function unicode_fix( $s ) { 
     1456        return preg_replace( get_uni_pattern(), "&#x$1;", $s ); 
     1457
    14421458 
    14431459function get_thumb( $u, $linkUrl ) { 
     
    23312347                        SELECT COUNT(*) AS lc, links.userid AS u FROM links, users WHERE users.userid = links.userid AND isPrivate IS NULL AND snuffed IS NULL GROUP BY links.userid ORDER BY lc DESC LIMIT " . $args[1] . ";"; 
    23322348 
     2349        } else if( $argWhichQuery  == "find_private_tag" ) { 
     2350    return " 
     2351                        SELECT * FROM tags WHERE name = 'private' AND userid = '" . urlencode( $args[1] ) . "';"; 
     2352 
    23332353        } else if( $argWhichQuery  == "rude_solo_im_name" ) { 
    23342354    return " 
     
    24792499 
    24802500  } else if( $argWhichQuery  == "edit_link_privacy" ) { 
    2481                 if( $args[1] == 1 ) 
     2501                if( $args[1] != 1 ) 
    24822502                        run_heuristics( "publicize_link", $args[3], array( "link" => $link )); 
     2503                else 
     2504                        apply_tag_by_ID( $args[2], get_private_tag_ID($args[3])); 
    24832505    return " 
    24842506    UPDATE links SET isPrivate = " . $args[1] . " WHERE ID = " .$args[2] . " AND userid = '" . $args[3] . "'"; 
     
    33363358 
    33373359function addFolder( $argFolderName, $argUserId ) { 
    3338   return addFolderDriver( $argFolderName, $argUserId, 1 ); 
     3360  return addFolderDriver( $argFolderName, $argUserId, 0 ); 
    33393361} 
    33403362 
     
    33453367function addFolderDriver( $argFolderName, $argUserId, $argIsPrivate ) { 
    33463368  if( $argFolderName &&  $argUserId ) { 
     3369 
     3370                if( $argFolderName == "private" ) 
     3371                        $argIsPrivate = 1; 
    33473372 
    33483373    $con_addFolderDriver = mysql_connect(); 
     
    36853710 
    36863711function setPrivate( $argId ) { 
     3712        apply_tag_by_ID( $argId, get_private_tag_ID( get_user())); 
    36873713  togglePrivate( $argId, 1 ); 
    36883714}