Changeset 1390
- Timestamp:
- 03/05/07 18:37:28 (2 years ago)
- Files:
-
- feedmelinks/.htaccess-global (modified) (1 diff)
- feedmelinks/FAQ/index.php (modified) (4 diffs)
- feedmelinks/aim/index.php (modified) (3 diffs)
- feedmelinks/folder-as-xml.php (modified) (5 diffs)
- feedmelinks/lib/FeedMeLinks/Bot.pm (modified) (19 diffs)
- feedmelinks/modules/utils.inc.php (modified) (1 diff)
- feedmelinks/script/form-validation.js (modified) (1 diff)
- feedmelinks/search-as-xml.php (modified) (6 diffs)
- feedmelinks/set-up/IM.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
feedmelinks/.htaccess-global
r1375 r1390 46 46 47 47 # xml API: 48 RewriteRule ^xml/authenticate(.*)$ /authenticate$1 [L] 49 RewriteRule ^xml/(f|tag)/([0-9a-z]+)$ /folder-as-xml?folder=$2 [L] 50 RewriteRule ^xml/tags$ /tags-as-xml [L] 51 RewriteRule ^xml/user/([0-9a-z]+)$ /users-links-as-xml?user=$1 [L] 52 RewriteRule ^xml/set/comment /api/comment 53 RewriteRule ^xml/peeps$ /peeps-as-xml [L] 54 RewriteRule ^api/backroom/(.*)$ /api/restricted/secure-call.php?call=$1 [L] 48 RewriteRule ^xml/authenticate(.*)$ /authenticate$1 [L] 49 RewriteRule ^xml/(f|tag)/(.+)$ /folder-as-xml?folder=$2 [L] 50 RewriteRule ^api/tag/(.+)$ /folder-as-xml?folder=$1 [L] 51 RewriteRule ^(xml|api)/tags$ /tags-as-xml [L] 52 RewriteRule ^xml/user/([0-9a-z]+)$ /users-links-as-xml?user=$1 [L] 53 RewriteRule ^xml/set/comment /api/comment 54 RewriteRule ^(xml|api)/peeps$ /peeps-as-xml [L] 55 RewriteRule ^api/backroom/(.*)$ /api/restricted/secure-call.php?call=$1 [L] 55 56 56 57 RewriteRule ^api/rename/(.*)$ /api/core/index.php?op=rename&user=$1 [L] 57 58 RewriteRule ^api/add_tags/(.*)$ /api/core/index.php?op=add_tags&user=$1 [L] 59 RewriteRule ^api/search(.*)$ /search-as-xml.php$1 [L] 58 60 59 61 # JSON API feedmelinks/FAQ/index.php
r1375 r1390 42 42 <li><a href="#q2_1">What the heck is a tag?</a></li> 43 43 </ol> 44 <li> External AccessQuestions</li>44 <li>Power-User Questions</li> 45 45 <ol> 46 46 <li><a href="#q6_0">What is the naming convention / url schema for Feed Me Links? </a></li> … … 401 401 <big>XML endpoints for the Feed Me Links REST API:</big> 402 402 <p/> 403 <code> 404 # <b>authenticate using <a href="http://httpd.apache.org/docs/1.3/howto/auth.html#basic">HTTP-Basic authentication</a></b>:<br /> 403 <b>authenticate using <a href="http://httpd.apache.org/docs/1.3/howto/auth.html#basic">HTTP-Basic authentication</a></b>:<br /> 405 404 <span class="subtle">http://feedmelinks.com</span>/xml/authenticate<br /> 406 405 (pass <code>user</code> and <code>password</code>) … … 408 407 <br /> 409 408 410 # <b>get allyour links as XML</b>:<br />409 <b>retrieve your links as XML</b>:<br /> 411 410 <span class="subtle">http://feedmelinks.com</span>/xml/user/<b>USERNAME</b><br /> 412 411 <br /> 413 414 # <b>get all your tags as XML</b>:<br /> 415 <span class="subtle">http://feedmelinks.com</span>/xml/tags<br /> 416 <br /> 417 418 # <b>rename a link</b>:<br /> 419 <span class="subtle">http://feedmelinks.com</span>/api/rename/USERNAME&id=LINK_ID&name=NAME<br /> 420 <br /> 421 422 # <b>add tags to a link</b>:<br /> 423 <span class="subtle">http://feedmelinks.com</span>/api/add_tags/USERNAME&id=LINK_ID&tags=COMMA,SEPARATED,TAGS<br /> 424 <br /> 425 426 # <b>get a tag's metadata as XML</b>:<br /> 427 <span class="subtle">http://feedmelinks.com</span>/xml/tag/<b>TAGNUM</b><br /> 428 (<small>or</small> /xml/f/<b>TAGNUM</b> - deprecated)<br /> 429 <br /> 412 413 <b>retrieve all your tags as XML</b>:<br /> 414 <span class="subtle">http://feedmelinks.com</span>/api/tags<br /> 415 <br /> 416 417 <b>retrieve all links tagged with a particular tag</b>:<br /> 418 <span class="subtle">http://feedmelinks.com</span>/api/tag/<b>TAGNUMBER</b><br /> 419 <br /> 420 421 <b>search Feed Me Links</b>:<br /> 422 <span class="subtle">http://feedmelinks.com</span>/api/search?q=<b>SEARCHWORD</b><br /> 423 <br /> 424 425 <b>rename a link</b>:<br /> 426 <span class="subtle">http://feedmelinks.com</span>/api/rename/<b>USERNAME</b>&id=<b>LINK_ID</b>&name=<b>NAME</b><br /> 427 <br /> 428 429 <b>add tags to a link</b>:<br /> 430 <span class="subtle">http://feedmelinks.com</span>/api/add_tags/<b>USERNAME</b>&id=<b>LINK_ID</b>&tags=<b>COMMA,SEPARATED,TAGS</b><br /> 431 <br /> 432 430 433 431 434 <!-- … … 441 444 442 445 # <b>get your peeps as XML</b>:<br /> 443 <span class="subtle">http://feedmelinks.com</span>/ xml/peeps<br />446 <span class="subtle">http://feedmelinks.com</span>/api/peeps<br /> 444 447 </code> 445 448 <p/> feedmelinks/aim/index.php
r1354 r1390 30 30 </dd> 31 31 32 <!-- 32 33 <dt> stalk (spy, on) : follow your friends' activity</dt> 33 34 <dd>whenever one of your peeps adds a public link, you'll receive the link in an IM with the username of who linked it (the stalkee must also have you as a peep for this to work)</dd> … … 38 39 <dt>recent (synonyms: links) : see recent activity</dt> 39 40 <dd>prints your last 10 links</dd> 40 41 --> 42 41 43 <dt>today : prints your last 10 links</dt> 42 44 <dd></dd> … … 47 49 <dt>anything but the above commands : aka the default</dt> 48 50 <dd> 49 if it matches one of your tags, it will show all your links with that tag 50 if it doesn't match any of your tags, it will search all your links for that string 51 if it starts with "all ...", it will search *all* of FML for that string 51 <ul> 52 <li>if it matches one of your tags, it will show all your links with that tag</li> 53 <li>if it doesn't match any of your tags, it will search all your links for that string</li> 54 <li>if it starts with "all ...", it will search *all* of FML for that string</li> 55 <ul> 56 </ul> 52 57 </dd> 53 58 feedmelinks/folder-as-xml.php
r1385 r1390 6 6 $u = $PHP_AUTH_USER ? $PHP_AUTH_USER : ( $user ? $user : $_COOKIE["c_uid"] ); 7 7 $tok = $authenticated = $_COOKIE["c_pass_token"]; 8 Header( "Content-type: text/xml"); 8 9 9 10 if( $u && ($pass && $pass == getPasswdForUser( $u ) || ($tok && $tok == md5( getPasswdForUser( $u ))))) { 11 if( getOwnerForFolder( $folder ) != $u ) { 12 $error = "No tag by that ID number or it's owned by someone else"; 13 echo "<rest><response code='failed'>$error</response></rest>"; 14 return; 15 } 10 16 11 17 if( $folder ) { … … 16 22 $q = mysql_query( $qs ); 17 23 if( $q && mysql_num_rows($q) ) { 18 Header( "Content-type: text/xml");19 24 echo "<?xml version='1.0' standalone='yes'?>\n"; 20 25 … … 23 28 $tag_name = makePrettyFolderName( $raw_tag_name ); 24 29 30 $numRows = mysql_num_rows($q); 25 31 %> 26 <posts tag="<%= $tag_name %>" is-public="<%= (! $isPrivate) ? 'true' : 'false' %>" tag-id="<%= $folder %>" user="<%= $u %>" >32 <posts tag="<%= $tag_name %>" is-public="<%= (! $isPrivate) ? 'true' : 'false' %>" tag-id="<%= $folder %>" user="<%= $u %>" num_links="<?= $numRows ?>"> 27 33 <% 28 $numRows = mysql_num_rows($q);29 34 if( $q && $numRows ) { 30 35 for( $i = 0; $i < $numRows; $i++ ) { … … 34 39 if( !strstr( $url, "&" )) 35 40 $url = str_replace( "&", "&", $url ); 36 $ts = format AsDCDate( mysql_result($q,$i,"createDate"));41 $ts = formatTS( mysql_result($q,$i,"createDate")); 37 42 38 43 %> … … 45 50 <% 46 51 } else 47 $error = " No tag by that ID, or it's owned by someone else";52 $error = "0_links"; 48 53 conClose( $con_xmlFolder ); 49 54 } else 50 $error = " no tag by that ID, or it's owned by someone else";55 $error = "0_links"; 51 56 if( $error ) { 52 Header("HTTP/1.0 404 Not Found"); 53 echo $error; 57 echo "<posts tag='" . getFieldForFolder( $folder, "name" ) . "' is-public='" . (getFieldForFolder( $folder, "isPrivate" ) == 1 ? "false" : "true") . "' tag-id='$folder' user='$u' num_links='0'/>"; 54 58 } 55 59 } else { feedmelinks/lib/FeedMeLinks/Bot.pm
r1388 r1390 18 18 open(LOG, ">>" . $logfile) or die "can't open log $logfile"; 19 19 20 # always flush write to the log file so we see them immediately 21 { 20 { # flush writes to the log so we see them immediately 22 21 my $ofh = select LOG; 23 22 $| = 1; 24 23 select $ofh; 25 24 } 26 27 25 log_mesg( \*LOG, "starting run" ); 28 26 27 my $num_recent = 5; 29 28 my $www = get_proxy( FeedMeLinks::Environment::get_bot_user(), FeedMeLinks::Environment::get_bot_password()); 30 29 my $site = "http://www." . FeedMeLinks::Environment::get_domain(); … … 35 34 36 35 my $user; 37 # AIM often wraps seemingly plaintext messages withshouty <HTML><FONT>...</FONT></HTML> crap. this strips that36 # AIM can wrap messages w/ shouty <HTML><FONT>...</FONT></HTML> crap. this strips that 38 37 $message = strip_html( $message ); 39 38 log_mesg( \*LOG, "debug", "command: $message" ); 40 41 print "handle_resopnse can see site = $site\n";42 39 43 40 # init user … … 45 42 $fml_username .= ""; # type coerce 46 43 if( ! $fml_username ) { 47 $sessions_ref->{"$sender"} = build_empty_session( $sender );48 if( $sessions_ref->{ $sender }{ "seen_welcome" } != 1 ) {49 $ aim->send_im($sender, h("<b>Hi! I am the Feed Me Links bot!</b>\nTo get started, you can type <b>links</b>, <b>help</b>, or click <b><a href='$site/set-up/IM?aim=$sender'>activate</a></b> to set up your account."));50 $sessions_ref->{ $sender }{ "seen_welcome" } = 1;44 if( $sessions_ref->{ $sender }{ "seen_welcome" } == 0 && !( $message =~ m/validate/ )) { 45 $aim->send_im($sender, h("<b>Hi! I am the Feed Me Links bot!</b>\nType '<b>help</b>' for more info or click <b><a href='$site/set-up/IM?aim=$sender'>activate</a></b> to start adding links.") ); 46 $sessions_ref->{"$sender"} = build_empty_session( $sender ); 47 $sessions_ref->{ $sender }{ "seen_welcome" } = 1; 51 48 } 52 49 } else { … … 59 56 } 60 57 61 # handle commands58 # COMMAND: ADD LINK ############################################################### 62 59 if( 63 60 $message =~ m/(ftp|gopher|https?):\/\// … … 96 93 97 94 $aim->send_im($sender, h("<b>Added</b>:\n<a href='$info'>$name</a>" )); 98 $aim->send_im($sender, h( "To add tags, just type them, separated by tags\nTo rename it, type it: <em>new name...</em>"));95 $aim->send_im($sender, h(get_message( "add_tags") . "\n" . get_message( "rename" ))); 99 96 } else { 100 97 if( $info =~ m/Duplicate/ ) { … … 109 106 # FIXME: should search and say "NN people have added this link -- click activate to add it" 110 107 log_mesg( \*LOG, "error:add link", "un-authenticated add request from $sender for $message" ); 111 $aim->send_im($sender, h("T hat looks like a link! To add links via IM, just <b><a href='$site/set-up/IM?aim=$sender'>activate your account</a></b> by clicking." ));108 $aim->send_im($sender, h("To start adding links, please click <b><a href='$site/set-up/IM?aim=$sender'>activate my account</a></b>." )); 112 109 } 113 110 111 # COMMAND: VALIDATE ############################################################### 114 112 } elsif( $message =~ m/validate:/ ) { 115 113 … … 143 141 #$aim->send_im($sender, "<b>Rebuilt an authenticated session for you</b>:\n" . Dumper( $sessions_ref )); 144 142 145 $aim->send_im($sender, "<b> All done -- that was easy</b>!\nNow your Feed Me Links account is linked to your AIM and you can start using Feed Me Links via AIM. To get started, paste any URL into this window." );143 $aim->send_im($sender, "<b>\n\nAll done -- that was easy</b>!\nNow your Feed Me Links account is linked to your AIM and you can start using Feed Me Links via AIM. To get started, paste any URL into this window." ); 146 144 } else { 147 145 $aim->send_im($sender, h("Darn, that doesn't match our records. Please try again, or <a href='$site/contact-us?subject=AIM+issues:+'>contact us</a>.") ); 148 146 } 149 147 148 # COMMAND: WHO ############################################################### 150 149 } elsif( $message =~ m/who/ || $message =~ m/lusers/ ) { 151 150 my $users = ""; … … 161 160 $aim->send_im($sender, h($users)); 162 161 163 } elsif( $message =~ m/peeps/ ) { 164 $aim->send_im($sender, "<b>what are you, SNACK FOOD?</b> (sorry, unfinished)\n" ); 162 # COMMAND: PEEPS ############################################################### 163 } elsif( $fml_username && $message =~ m/peeps/ ) { 164 $aim->send_im($sender, h("<b>what are you, SNACK FOOD?</b>\n(sorry, this part is unfinished, because I haven't decided what do with the peeps list yet. <a href='mailto:jm3\@feedmelinks.com'>What do you think</a>?)\n")); 165 165 my $u = $sessions_ref->{ $sender } -> { "fml_username" }; 166 166 … … 170 170 # FIXME: peeps list here for sharing 171 171 172 # COMMAND: VERSION ############################################################### 172 173 } elsif( $message =~ m/version/ ) { 173 174 log_mesg( \*LOG, "version", " $sender" ); 174 175 $aim->send_im($sender, get_version()); 175 176 177 # COMMAND: RECENT ############################################################### 176 178 } elsif( $message =~ m/(links|recent)/ ) { 177 179 log_mesg( \*LOG, "recent", " $sender" ); 178 180 $aim->send_im($sender, "recent links here, soon! (not finished yet, sorry"); 179 181 182 # COMMAND: LOG ############################################################### 180 183 } elsif( $message =~ m/(^log)/ ) { 181 184 log_mesg( \*LOG, "log test", " $message from $sender" ); 182 185 186 # COMMAND: HELP ############################################################### 183 187 } elsif( $message =~ m/help/ || $message =~ m/commands/ || $message =~ m/\?/ ) { 184 188 log_mesg( \*LOG, "help", " $sender" ); 185 189 186 $aim->send_im($sender, "<b>Instructions</b>: 187 <b>paste or type any link</b> (or try: who, version, credits, or help)" ); 188 190 $aim->send_im($sender, "<b>This is the Feed Me Links AIM Bot</b>: 191 From here, you can do most anything you can do on Feed Me Links. It's easy to get started. 192 <b>Paste</b> or <b>type a URL to begin</b>.\nother commands to try: who, version, credits, or help" ); 193 194 # COMMAND: STATUS ############################################################### 189 195 } elsif( $message =~ m/status/ ) { 190 196 log_mesg( \*LOG, "status", " $sender" ); … … 193 199 print Dumper( $sessions_ref ) . "\n"; 194 200 201 # COMMAND: CREDITS ############################################################### 195 202 } elsif( $message =~ m/credits/ ) { 196 203 log_mesg( \*LOG, "credits", " $sender" ); 197 204 $aim->send_im($sender, h("by <b><a href='http://jm3.net'>John Manoogian III / jm3</a></b>")); 198 205 199 } elsif( $sessions_ref->{$sender}->{"last_link"} && $sessions_ref->{$sender}->{"renamed"} == 0 && $message =~ m/rename(:| )/ ) { 206 # COMMAND: RENAME ############################################################### 207 } elsif( $fml_username && $sessions_ref->{$sender}->{"last_link"} && $sessions_ref->{$sender}->{"renamed"} == 0 && $message =~ m/rename(:| )/ ) { 200 208 $sessions_ref->{$sender}->{"last_action"} = "rename"; 201 209 $sessions_ref->{$sender}->{"renamed"} = 1; … … 216 224 if( $response_code == "success" ) { 217 225 $aim->send_im($sender, h("Thanks! We renamed <a href='$site/$link'><b>$pretty_name</b></a>.")); 226 if( $sessions_ref->{$sender}->{"added_tags"} == 0 ) { 227 $aim->send_im($sender, h(get_message( "add_tags"))); 228 } 218 229 } else { 219 230 $aim->send_im($sender, h("<b>Oops, the server screwed something up!</b>\n$response_code" )); … … 221 232 log_mesg( \*LOG, "debug", "response: $response_code renaming $link to $message" ); 222 233 223 } elsif( $sessions_ref->{$sender}->{"last_link"} && $sessions_ref->{$sender}->{"added_tags"} == 0 ) { 234 # COMMAND: TAG ############################################################### 235 } elsif( $fml_username && $sessions_ref->{$sender}{"last_link"} && $sessions_ref->{$sender}->{"added_tags"} == 0 ) { 224 236 $sessions_ref->{$sender}->{"last_action"} = "added_tags"; 225 237 $sessions_ref->{$sender}->{"added_tags"} = 1; … … 242 254 $tag_noun .= " <b>$message</b>"; 243 255 $aim->send_im($sender, h("Thanks! We added the tags <b>$message</b> to <a href='$site/" . $sessions_ref->{$sender}->{"last_link"} . "'>your link</a>")); 256 if( $sessions_ref->{$sender}->{"renamed"} == 0 ) { 257 $aim->send_im($sender, h(get_message( "rename"))); 258 } 244 259 } 260 261 # COMMAND: SHOW TAG ############################################################### 262 } elsif( $fml_username && $sessions_ref->{$sender}{"tags"}{$message} ) { 263 264 my $url = "$site/api/tag/" . encode( $sessions_ref->{$sender}{"tags"}{$message} ) 265 . "&user=" . encode( $sessions_ref->{$sender}{"fml_username"} ) 266 . "&password=" . encode($sessions_ref->{$sender}{"fml_password"}); 267 log_mesg( \*LOG, "debug", "found a tag, will get it with url: $url"); 268 my $response = $sessions_ref->{$sender}->{"proxy"}->get( $url , []); 269 270 my $num_links = "" . XML::XPath->new(xml => $response->content)->findnodes('/posts/@num_links'); 271 log_mesg( \*LOG, "debug", "got num links $num_links"); 272 if( $num_links != 0 ) { 273 my $link_nodes = XML::XPath->new(xml => $response->content)->findnodes('/posts/post'); 274 my $summary = ""; 275 my $max = $num_recent; 276 my $c = 0; 277 foreach my $link_node ($link_nodes->get_nodelist) { 278 if( $c < $max ) { 279 $summary .= 280 "<a href='" 281 . $link_node->findnodes( "./\@href" ) 282 . "'>" 283 . $link_node->findnodes( "./\@description" ) 284 . "</a>, "; 285 } 286 ++ $c; 287 } 288 $summary =~ s/, $//; 289 290 log_mesg( \*LOG, "debug", "summary: $summary" ); 291 $aim->send_im($sender, h("You have <a href='$site/u/" . encode( $sessions_ref->{$sender}{"fml_username"}) . "/tags/" . encode($message) . "'>$num_links links</a> tagged with $message, including $summary" )); 292 } 245 293 246 294 } else { 295 296 my $tags_ref = $sessions_ref->{$sender}{"tags"}; 247 297 log_mesg( \*LOG, "search", "$message by $sender" ); 248 $aim->send_im($sender, "<b>Hm, let me search for that on Feed Me Links</b>:\n(searching)");249 298 250 299 my $search_term = $message; 251 300 $search_term =~ s/^search(:|\s+)(\s*)?//; 252 my $url = "http://www.feedmelinks.com/search-as-xml?q=$search_term"; 301 302 if( length( $search_term ) < 3 ) { 303 $aim->send_im($sender, "I'm up in your AIM, feed me some links. (type <b>?</b> for help)"); 304 return; 305 } else { 306 $aim->send_im($sender, "<b>Hm, let me search for that on Feed Me Links</b>:\n(searching)"); 307 } 308 my $url = "$site/search-as-xml?q=$search_term"; 253 309 log_mesg( \*LOG, "debug", " $url" ); 254 310 255 my $response = $sessions_ref->{$sender}->{"proxy"}->get( $url, []); 311 if( 1 ) { 312 # FIXME EMERGENCY: if( $sessions_ref && $sessions_ref->{$sender} && $sessions_ref->{$sender}->{"proxy"}) { 313 my $response = $www->get( $url, []); 256 314 my $nodes = XML::XPath->new(xml => $response->content)->findnodes("/rest/response/link"); 257 #my $nodes = XML::XPath->new(xml => $response->content)->findnodes("/rest/response/link/name/text()");258 315 my $message = "" . XML::XPath->new(xml => $response->content)->findnodes("/rest/response/message"); 259 316 my $response_code = "" . XML::XPath->new(xml => $response->content)->findnodes("/rest/response/\@code"); 260 317 if( $response_code == "success" ) { 261 318 my $summary = ""; 262 my $max = 3;319 my $max = $num_recent; 263 320 my $c = 0; 264 321 foreach my $link_node ($nodes->get_nodelist) { … … 270 327 . $link_node->findnodes( "name/text()" ) 271 328 . "</a>, "; 272 log_mesg( \*LOG, XML::XPath::XMLParser::as_string($link_node));273 329 }; 274 330 ++ $c; 275 331 } 276 log_mesg( \*LOG, "debug", "summary: $summary" ); 277 log_mesg( \*LOG, scalar( $nodes->get_nodelist) . " links found" ); 332 #log_mesg( \*LOG, "debug", "summary: $summary" ); 278 333 log_mesg( \*LOG, "search", "found $message" ); 279 $aim->send_im($sender, "<b>$message</b> (<a href='$site/search?q=$search_term'>view all matches</a>)\nincluding: $summary"); 280 } 334 if( length( $summary ) > 3 ) { 335 $aim->send_im($sender, "<b>$message</b> (<a href='$site/search?q=$search_term'>view all matches</a>), including: $summary"); 336 } else { 337 $aim->send_im($sender, "<b>$message</b>"); 338 $aim->send_im($sender, "(perhaps you'd like to add some links on this subject? :-) )"); 339 } 340 } 341 } 281 342 } 282 343 … … 311 372 'last_action' => '', 312 373 'added_tags' => 0, 374 'tags' => (), 313 375 'renamed' => 0, 314 376 'fml_username' => "", 315 377 'fml_password' => "", 378 'proxy' => get_proxy( "", "" ), 316 379 'validated' => 0, 317 380 'seen_welcome' => 0 … … 328 391 print "> passing user: $u\n"; 329 392 print "> using url: $site/api/backroom/getPasswdForUser&user=$u\n"; 393 330 394 my $response = $www->get( "$site/api/backroom/getPasswdForUser&user=$u", []); 331 395 my $xp = XML::XPath->new(xml => $response->content); 332 396 my $p = "" . $xp->getNodeText("/rest/response"); 333 log_mesg( \*LOG, "debug", "got password $p" ); 397 398 my $url = "$site/api/tags?user=" . encode( $u ) . "&password=" . encode( $p ); 399 $response = $www->get( $url, []); 400 $xp = XML::XPath->new(xml => $response->content); 401 402 my $tag_nodes = $xp->findnodes("/tags/tag"); 403 my $tags_ref = (); 404 foreach my $tag_node ($tag_nodes->get_nodelist) { 405 my $tag_name = "" . $tag_node->findnodes("./\@name"); 406 $tag_name =~ s/\s*name="\s*//; 407 $tag_name =~ s/"\s*$//; 408 409 my $tag_id = "" . $tag_node->findnodes("./\@id"); 410 $tag_id =~ s/\s*id="\s*//; 411 $tag_id =~ s/"\s*$//; 412 $tags_ref->{ $tag_name } = $tag_id; 413 } 414 415 log_mesg( \*LOG, "debug", "found " . ( keys %$tags_ref ) . " tags for $u" ); 334 416 335 417 my $session = { … … 337 419 'last_action' => '', 338 420 'added_tags' => 0, 421 'tags' => $tags_ref, 339 422 'renamed' => 0, 340 423 'fml_username' => $u, … … 351 434 my( $u, $p ) = @_; 352 435 my $www = LWP::UserAgent->new; 353 $www->credentials( 354 "www." . FeedMeLinks::Environment::get_domain() . ":80", 355 'Feed_Me_Links_XML_API', 356 # FIXME: are we doing something wrong? tags is failing with no authroization... 357 $u => $p 358 ); 436 if( $u && $p ) { 437 $www->credentials( 438 "www." . FeedMeLinks::Environment::get_domain() . ":80", 439 'Feed_Me_Links_XML_API', 440 # FIXME: are we doing something wrong? tags is failing with no authroization... 441 $u => $p 442 ); 443 } 359 444 return $www; 360 445 } … … 452 537 } 453 538 539 sub get_message { 540 my $m = $_[0]; 541 my %messages = ( 542 "add_tags" => "To add tags, just type them, separated by commas", 543 "rename" => "To rename it, type it: <em>new name...</em>" 544 ); 545 return $messages{ "$m" }; 546 } 547 454 548 1; # modules must return a true value 455 549 feedmelinks/modules/utils.inc.php
r1388 r1390 2449 2449 return " 2450 2450 SELECT * FROM links, tags AS t, links_tags_xref AS x WHERE x.tagID = " . urlencode( $args[1] ) . " AND x.linkID = links.ID AND t.ID = x.tagID AND links.userid = '" 2451 . urlencode( $args[2] ) ."' ;";2451 . urlencode( $args[2] ) ."' ORDER BY links.createDate DESC;"; 2452 2452 2453 2453 } else if( $argWhichQuery == "recent_for_user" ) { feedmelinks/script/form-validation.js
r1350 r1390 17 17 function check_im( f ) { 18 18 var e = f.im.value; 19 var filter = /^[a-zA-Z0-9_\.\-\@ ]+$/;19 var filter = /^[a-zA-Z0-9_\.\-\@ ]+$/; 20 20 if( e == '' ) { 21 21 alert( "Please enter your AIM name." ); feedmelinks/search-as-xml.php
r1388 r1390 1 < %1 <?php 2 2 ob_start(); 3 3 include_once( "modules/class.gzip_encode.inc.php" ); … … 13 13 14 14 $searchTerm = $q ? $q : $searchTerm; 15 if( strlen( $searchTerm ) < 3 ) { 16 echo '<rest><request>Search Feed Me Links for "$searchTerm"</request><response code="failed"><message>search for something at least 3 characters long</message></response></rest>'; 17 #echo "hi"; 18 return; 19 } 15 20 $searchTerm = str_replace( " ", "%", $searchTerm ); 16 21 $searchTerm = str_replace( "'", "", $searchTerm ); … … 23 28 $searchWhat = $search_only; 24 29 30 function xml_text_node_fix( $s ) { 31 if( ! $s ) 32 return ""; 33 return preg_replace( "/</", "<", preg_replace( "/>/", ">", preg_replace( "/&([^a])/", "&\\1", unicode_fix( $s )))); 34 } 35 25 36 $qs2 = getQuery( "num_links" ); 26 37 $q2 = mysql_query( $qs2 ); 27 38 if( $q2 ) $totalNumLinks = mysql_result($q2,0); 28 %>29 << %= "?" %>xml version='1.0' encoding="UTF-8" standalone='yes'?>39 ?> 40 <<?= "?" ?>xml version='1.0' encoding="UTF-8" standalone='yes'?> 30 41 <rest> 31 42 <request>Search <%= $my ? "My Links" : "Feed Me Links" %> <%= $q ? "for '$q'" : "" %> … … 35 46 if( $search_only == "links" ) 36 47 $qs = $my ? 37 "SELECT * FROMlinks WHERE lcase(name) LIKE '%$searchTerm%' AND userid='$sessionUserId' ORDER BY createDate DESC"48 "SELECT * from links WHERE lcase(name) LIKE '%$searchTerm%' AND userid='$sessionUserId' ORDER BY createDate DESC" 38 49 # this query needs to pull from the master query, but the column names are different... 39 : "SELECT * FROM links WHERE lcase(name) LIKE '%$searchTerm%' AND (isPrivate is NULL ORuserid = '$u') ORDER BY createDate DESC";50 : "SELECT * FROM links, users WHERE links.userid = users.userid AND users.snuffed IS NULL AND lcase(links.name) LIKE '%$searchTerm%' AND (links.isPrivate is NULL OR links.userid = '$u') ORDER BY createDate DESC"; 40 51 else if( $search_only == "users" ) 41 $qs = "SELECT * FROM users WHERE lcase(userid) LIKE '%$searchTerm%'ORDER BY userid;";52 $qs = "SELECT * from users WHERE lcase(userid) LIKE '%$searchTerm%' and snuffed is NULL ORDER BY userid;"; 42 53 else if( $search_only == "tags" ) 43 54 $qs = "SELECT * FROM tags WHERE name LIKE '%$searchTerm%' AND (isPrivate IS NULL OR userid = '$u') ORDER BY name;"; … … 63 74 $url = urldecode( mysql_result($q,$i,"url")); 64 75 %> 65 <link >76 <link user="<?= $userid ?>"> 66 77 <% 67 78 $cats = get_tags_as_HTML( $id, $u, "add-trailing-noun=1", 0 ); … … 69 80 $name = preg_replace( "/'/", "'", $name ); 70 81 $url = preg_replace( "/&/", "&", $url ); 82 71 83 %> 72 <url><%= $url %></url>73 <name><%= preg_replace( "/&([^a])/", "&\\1", unicode_fix( $name )) %></name>84 <url><%= utf8_encode( xml_text_node_fix( $url )) %></url> 85 <name><%= utf8_encode( xml_text_node_fix( $name )) %></name> 74 86 <% 75 87 $cats = $cats ? "$cats" : "by $userid"; feedmelinks/set-up/IM.php
r1355 r1390 23 23 if( !$im ) 24 24 return; 25 $im = urlencode( $im );26 25 $success = run_query( "UPDATE users SET im = '$im' WHERE userId = '$u'" ); 27 26 $showForm = false; … … 33 32 <h1>Success! Your Validation Code is:</h1> 34 33 <input class="copyable" name="secret" value="validate: <?= $u . ", " . get_im_validation_phrase_for_user( $u ) ?>" size="32" /> 35 <small>Paste the above text into your AIM window to finish the setup process</small>34 <small>Paste the <b><big>entire</big></b> string above into your AIM window to finish validating your account.</small> 36 35 <br /><br /><br /><br /> 37 36 (All done, you can close this window now) … … 43 42 44 43 if( $showForm ) { 44 45 # handle the weirdo's with @ signs in their names: # FIXME: test from actual klaus aim session 46 #$aim = str_replace( " ", "", $aim ); 47 $aim = urlencode( $aim ); 48 $aim = str_replace( "%40", "@", $aim ); 49 $aim = str_replace( "%2540", "@", $aim ); 50 $aim = str_replace( "+", " ", $aim ); 45 51 ?> 46 52