# Search Function as URL



## trxclw (Apr 22, 2013)

Hello everyone,

I always use the search function when browsing, but I find it tiring to click all the options for sorting, time, type, ect.
Because of this, I use a bookmarked URL that already contains all the search terms I normally search for. It works like this:
http://www.furaffinity.net/search/@keywords mykeyword1 | @keywords mykeyword2 & @keywords mykeyword3

However, this doesn't include any of the additional options, such as not having photos in it or sorting by date. Does anybody know how to put these things into the URL, too?

Thanks!


----------



## DUVMik (Apr 22, 2013)

Not directly... however, you can do it with a little HTML and JavaScript magic.

If you're interested I can make something for you. I have already made one with the "browse artwork" page and I was planning to make one with search to.


----------



## trxclw (Apr 22, 2013)

I'm quite sure that it does work directly, because back in the old days, the URL shown in the address bar changed when options were used. It wasn't hidden like it is now and I remember I had the code to make some things happen via a bookmark. There is just no way I know of to find out what the code is.
Would be cool if you could code something like that, though. That other thingy of yours is terrific!!


----------



## DUVMik (Apr 23, 2013)

I began working on this search thingy and then I thought, if the search function accepts search queries in the address bar, maybe it accepts other things... 

It does! This changes everything. 

If you want change any of the other options in search. You just have to make the right link, like this,
http://www.furaffinity.net/search/?...sic=&type-story=on&type-poetry=&mode=extended
That's very interesting. I'm wondering if it's intentional or just a coincidence. Anyway, I've made the first draft of my search bookmark thing 

```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>
body {
    background: #2E3B41;
    font-size: 12px;
    font-family: Verdana;
    color: #cfcfcf;
}
</style>
<title>Search</title>
<link rel="shortcut icon" href="http://www.furaffinity.net/favicon.ico">
<SCRIPT language="JavaScript">
function UpdateText()
{
document.getElementById("link").innerHTML=("<A HREF='http://www.furaffinity.net/search/?q=" + document.replyform.q.value + "&page=" + document.replyform.page.value + "&perpage=" + document.replyform.perpage.value + "&order-by=" + document.replyform.orderby.value + "&order-direction=" + document.replyform.orderdirection.value + "&range=" + document.replyform.range.value + "&rating-general=" + document.replyform.ratinggeneral.value + "&rating-mature=" + document.replyform.ratingmature.value + "&rating-adult=" + document.replyform.ratingadult.value + "&type-art=" + document.replyform.typeart.value + "&type-flash=" + document.replyform.typeflash.value + "&type-photo=" + document.replyform.typephoto.value + "&type-music=" + document.replyform.typemusic.value + "&type-story=" + document.replyform.typestory.value + "&type-poetry=" + document.replyform.typepoetry.value + "&mode=" + document.replyform.mode.value + "'>link</A>");
}
</SCRIPT>
</head>
<body>
<form name="replyform" id="search-form" method="post" action="FAMakeSearchBookmark.html">
<input class="textbox" name="q" id="q" value="" type="text">
                        &nbsp;&nbsp;&nbsp;&nbsp;

                        page <input class="textbox" name="page" id="page" value="1" size="3" type="text">,
                        <select name="perpage" class="listbox">
<option value="24">24</option>
<option value="36" selected="selected">36</option>
<option value="48">48</option>
<option value="60">60</option>
</select> results per page,
                        sort by <select name="orderby" class="listbox">
<option value="relevancy" selected="selected">relevancy</option>
<option value="date">date</option>
<option value="popularity">popularity</option>
</select>                        in the <select name="orderdirection" class="listbox">
<option value="asc">asc</option>
<option value="desc" selected="selected">desc</option>
</select> order
                        
<fieldset>
<legend>Time range</legend>

<label><select name="range" class="listbox">
<option value="day">A Day</option>
<option value="3days">3 Days </option>
<option value="week">A Week </option>
<option value="month">A Month </option>
<option value="all" selected="selected">All time </option>
</select>

</fieldset>
<br>                        
<fieldset>
<legend>Rating</legend>
<label><select name="ratinggeneral" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>General </label><br>
<label><select name="ratingmature" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Mature  </label><br>
<label><select name="ratingadult" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Adult  </label><br>
</fieldset>
<br>
<fieldset>
<legend>Type</legend>
<label><select name="typeart" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Art </label><br>
<label><select name="typeflash" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Flash </label><br>
<label><select name="typephoto" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Photography </label><br>
<label><select name="typemusic" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Music </label><br>
<label><select name="typestory" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Story </label><br>
<label><select name="typepoetry" class="listbox">
<option value="on">on</option>
<option value="">off</option>
</select>Poetry </label><br>
</fieldset>
<br>
<fieldset>
<legend>Match mode</legend>
<label><select name="mode" class="listbox">
<option value="all">All of the  words  </option>
<option value="any">Any of the words </option>
<option value="extended" selected="selected"> Extended (see help [?])</option>
</select>
</fieldset>
<br>
<center><input type="button" name="go" value="Update" onclick='UpdateText()'></center>
<br>
<center><p id=link></p></center>
</body>
</html>
```
It should work, but you still need some refinement.
I'll probably make one later with proper instructions, but so far it's pretty self-explanatory.


----------



## trxclw (Apr 23, 2013)

That's fantastic!!
As I said, the full address used to be shown back before the major design update of FA.


----------



## fwbrown61 (Apr 23, 2013)

In a word, search queries sure as hell can be stuffed into [ url] [ /url] tags.

A typical url looks like this:

 [ url=/search/@lower^rhino003$?&perpage=60&order-by=date&order-direction=desc&range=all&rating-general=0&rating-mature=0&rating-adult=1&type-art=0&type-flash=0&type-photo=0&type-music=0&type-story=1&type-poetry=0&mode=extended]All Stories by rhino003[ /url]

 This link takes advantage of FA's 'short URL' feature. You don't need to enter 'http://www.furaffinity.net/' in the link.


The thing has four parts to it:

1) @lower^rhino003$
This is the search string, same as you'd type into the Search Query field. This example is using the @lower operator and the ^ and $ field delimiters to produce an exact match on the username.​ 


2) ?&perpage=60&order-by=date&order-direction=desc&range=all&rating-general=0&rating-mature=0&rating-adult=1
The ? marks the start of the parameter string. 

     Perpage can be 24, 36, 48, or 60.

     Order-by can be date, popularity or relevancy.

     Order-direction can be asc (for ascending) or desc (for descending)

     Range can be day, 3days, week, month, or all (for all time)

 The three rating switches control what Sphinx will look at, as far as rating goes. Set the rating to 1 to include, 0 to filter out. This example selects all adult-rated subs and filters out general and mature.​ 


3) &type-art=0&type-flash=0&type-photo=0&type-music=0&type-story=1&type-poetry=0
These parms specify which type of sub to match. There are six types on FA.

Set the type to 1 for the subs you want to find, and 0 for the ones to filter out. This example selects for story subs only and filters out the rest.​


4) &mode=extended
 This turns on Sphinx's extended search mode. It can be all, any, or extended. Usually left on extended.​


What you end up with is a loooong string of text between the [ url] and [ /url] tag. But it works exactly as if you used Search.

As for how well it works, check this out:


The FA Writers Directory v1.0


Whole thing's based on the above. And it works *well.* :- )


----------



## kayfox (Apr 25, 2013)

DUVMik said:


> I'm wondering if it's intentional or just a coincidence.



Many web applications, especially those written in PHP, don't enforce any difference between GET and POST.  This (and a failure to make things POST when appropriate) is mainly why many sites have issues with preview applications and why this site has seen so many CSRF hacks.

GET: For actions that DO NOT cause a change.
POST: For actions that DO cause a change.

RFC2616 Section 9.1 

```
9.1.1 Safe Methods

   Implementors should be aware that the software represents the user in
   their interactions over the Internet, and should be careful to allow
   the user to be aware of any actions they might take which may have an
   unexpected significance to themselves or others.

   In particular, the convention has been established that the GET and
   HEAD methods SHOULD NOT have the significance of taking an action
   other than retrieval. These methods ought to be considered "safe".
   This allows user agents to represent other methods, such as POST, PUT
   and DELETE, in a special way, so that the user is made aware of the
   fact that a possibly unsafe action is being requested.

   Naturally, it is not possible to ensure that the server does not
   generate side-effects as a result of performing a GET request; in
   fact, some dynamic resources consider that a feature. The important
   distinction here is that the user did not request the side-effects,
   so therefore cannot be held accountable for them.
```

 ~ Your friendly neighborhood Web Application Firewall repairman.


----------



## fwbrown61 (Apr 26, 2013)

That Sphinx accepts both the GET and POST method could be seen as a vulnerabilty.  Browse is POST only. 

 Although it does seem that Sphinx strictly 'whitelists' all input, and won't accept commands per se. If it's not a parsable search query Sphinx ignores it.

That said, no user authentication is needed to submit a query. Could be trouble with this. DoSing Sphinx looks too easy.



On the other paw, because GET works, this enables every sub on FA to have that little list of keywords. These are in fact search queries set up as ordinary links.

If there's an easier way to set up a keyword system, can't think of it at the moment. Drawback: Lousy accuracy on searches, since everybody's free to put *anything* in the keyword list.



Being able to put search queries into [ url] [/url] tags, however: This is an idea that has some utility. Like all software techniques, better documentation needed. Duh. :- )

FB.


----------



## DUVMik (May 15, 2013)

I have uploaded the finished version of the search thing, http://www.furaffinity.net/view/10603251/

there, now I can stop thinking about it.


----------



## kayfox (May 17, 2013)

The last outage was said to have been caused by too complex search terms being used:

<yak[away]> ended up being some guy sendind a lot of complicated and search requests for common terms


----------



## fwbrown61 (Jun 25, 2013)

kayfox said:


> <yak[away]> ended up being some guy sendind a lot of complicated and
> search requests for common terms




Crap, have to pay more attention to Forums. Should've pounced on that a month ago.

Tried looking, can't find that comment here. Where, repeat where'd that come from?


99% chance Yak's talking about me and the damned FAWD. Ergo I double-damnwell better talk to him, and
faster 'n lightspeed.

Assistance appreciated in advance.

FB.


----------



## kayfox (Jun 26, 2013)

irc.furnet.org #furaffinity-dev


----------



## fwbrown61 (Jun 27, 2013)

kayfox said:


> irc.furnet.org #furaffinity-dev



Gracias and TY. Now to find a log or archive, talk to Yak, find out what the hell's going on. 

Sigh. Crisis, what crisis? :- /


----------

