~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/data/System/CommandAndCGIScripts.txt

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%META:TOPICINFO{author="ProjectContributor" date="1231502400" format="1.1" version="1"}%
 
2
%STARTINCLUDE%
 
3
---+ CGI and Command Line Scripts
 
4
 
 
5
_Programs on the server performing actions such as rendering, saving and renaming topics._
 
6
 
 
7
These scripts are located in the =bin= and =tools= directories. This topic describes the interfaces to some of those scripts. All scripts in the =bin= directory can be called from the CGI ([[http://en.wikipedia.org/wiki/Common_Gateway_Interface][Common Gateway Interface]]) environment or from the command line. The scripts in the =tools= directory can only be called from the command line.
 
8
 
 
9
%TOC%
 
10
 
 
11
---++ CGI Scripts
 
12
Details on CGI scripts located in the =bin= directory.
 
13
 
 
14
---+++ General Information
 
15
---++++ CGI environment
 
16
In the CGI environment parameters are passed to the scripts via the URL and URL parameters. Environment variables are also used to determine the user performing the action. If the environment is not set up, the default user is used (usually =guest=).
 
17
---++++ Command-line
 
18
You *must* be have the =bin= directory on the perl path to run the scripts from the command line. To avoid issues with file permissions, run the scripts as the web server user such as =nobody= or =www=.
 
19
 
 
20
Parameters are passed on the command line using '-name' - for example,
 
21
<verbatim>
 
22
$ cd /usr/local/foswiki/bin
 
23
$ save -topic MyWeb.MyTopic -user admin -action save -text "New text of the topic"
 
24
</verbatim>
 
25
All parameters require a value, even if that is the empty string.
 
26
 
 
27
---++++ Common parameters
 
28
All the scripts accept a number of common parameters. The first two components of the URL after the script name are taken as the web and the topic, respectively. Standard URL parameters are:
 
29
 
 
30
| *Parameter* | *Description* | *Default* |
 
31
| =topic= | If this is set to a URL, %WIKITOOLNAME% will immediately redirect to that URL. Otherwise it overrides the URL and is taken as the topic name (you can pass Web.<nop>TopicName) | |
 
32
| =user= | Command-line only; set the name of the user performing the action. Note: this usage is inherently insecure, as it bypasses webserver login constraints. For this reason only authorised users should be allowed to execute scripts from the command line. | |
 
33
| =skin= | Overrides the default skin path (see [[Skins]]) | |
 
34
| =cover= | Specifies temporary skin path to prepend to the skin path for this script only (see [[Skins]]) | |
 
35
| =t= | While the =t= parameter is not actively used by any scripts, it is used throughout the links like =edit= to ensure that the browser doesn't cache the reply. | generally set to current time |
 
36
| =logout= | requests the LoginManager to log the current user out. (happens at the begining of the request so will terminate any other operation requested) |
 
37
 
 
38
---+++ =attach=
 
39
Despite the name, this script doesn't actually attach a file to a topic - for that, use =upload=. This script is part of the transactions sequence executed when a file is uploaded from the browser. it just generates the "new attachment" page for a topic.
 
40
 
 
41
| *Parameter* | *Description* | *Default* |
 
42
| =filename= | Name of existing attachment (if provided, this is a "manage attachment" action) | none (in which case this is a "new attachment" action) |
 
43
 
 
44
 
 
45
---+++ =changes=
 
46
Shows all the changes in the given web. 
 
47
 
 
48
The =changes= script can receive one parameter:
 
49
 
 
50
| *Parameter* | *Description* | *Default* |
 
51
| =minor= | If 0, show only major changes. If 1, show all the changes (both minor and major) | 0 |
 
52
 
 
53
The main difference between invoking this script and using WebChanges is that WebChanges is based on a =%<nop>SEARCH%=, while this script reads the =changes= file in each web, making it much faster.
 
54
 
 
55
*NOTE*: The result from =changes= script and the topic WebChanges can be different, if the =changes= file is deleted from a web. In particular, in new installations the =changes= script will return no results while the WebChanges topic will.
 
56
 
 
57
---+++ =configure=
 
58
=configure= is the browser script used for inspection of, and changes to, the site configuration. None of the parameters to this script are useable for any purpose except =configure=. See [[%SCRIPTURLPATH{"configure"}%][configure]].
 
59
 
 
60
---+++ =edit=
 
61
The =edit= script understands the following parameters, typically supplied by HTML input fields:
 
62
 
 
63
| *Parameter* | *Description* | *Default* |
 
64
| =action= | Optional. Use the editaction template instead of the standard edit. If action=text, then hide the form. If action=form hide the normal text area and only edit the form. You can change the Edit/Edit Raw buttons to always append the action parameter in skins like Pattern and Classic by setting the topic or [[PreferenceSettings][preference setting]] [[VarEDITACTION][EDITACTION]] to the value =text= or =form=. To edit the topic once the EDITACTION is defined as form simply remove the action=form from the browser URL of the edit script and reload the edit window | |
 
65
| =onlynewtopic= | If set, error if topic already exists | |
 
66
| =onlywikiname= | If set, error if topic name is not a WikiWord | |
 
67
| =templatetopic= | The name of the template topic, copied to get the initial content (new topic _only_) | |
 
68
| =text= | Initial text for the topic | |
 
69
| =topicparent= | The parent topic | |
 
70
| =formtemplate= | Name of the form to instantiate in the topic. Overrides the form set in the =templatetopic= if defined. (will remove the form is set to 'none') | |
 
71
| =contenttype= | Optional parameter that defines the application type to write into the CGI header. Defaults to =text/html=. May be used to invoke alternative client applications | |
 
72
| =anyname= | Any parameter can passed to the new topic; if the template topic contains =%<nop>URLPARAM{"anyname"}%=, it will be replaced by its value | |
 
73
| =breaklock= | If set, any lease conflicts will be ignored, and the edit will proceed even if someone is already editing the topic. | |
 
74
| =redirectto= | If the user continues from edit to save, and if the save (or cancels the edit) process is successful, save will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | |
 
75
 
 
76
Form field values are passed in parameters named 'field' - for example, if I have a field =Status= the parameter name is =Status=.
 
77
   1 The first sequence of ten or more =X= characters in the topic name will be converted on save to a number such that the resulting topic name is unique in the target web.
 
78
 
 
79
NOTE: most skins support the definition of =EDIT_SKIN=, which is used as the value of the =cover= parameter in =edit= URLs. This allows you to override the default edit skin on a web, topic or user basis.
 
80
 
 
81
---+++ =login=
 
82
Used for logging in with !TemplateLoginManager.
 
83
| *Parameter* | *Description* | *Default* |
 
84
| =origurl= | URL that was being accessed when an access violation occurred. the login process will redirect to this URL if it is successful | none |
 
85
| =username= | username of user logging in | none |
 
86
| =password= | password of user logging in | none |
 
87
 
 
88
---+++ =logon=
 
89
Used for logging in when Web Server authentication is being used (e.g. !ApacheLoginManager). The script does nothing; it is purely a placeholder for triggering the login process. The webserver will be set up to require a valid user to access this script, thus triggering the webserver login process.
 
90
 
 
91
---+++ =manage=
 
92
Performs a range of management functions.
 
93
 
 
94
*%X% Note:* The =manage= script can only be called via HTTP POST method. Make sure you specify =method="post"= if you call the =manage= script via a form action. It is not possible to call =manage= from an =&lt;A href= link.
 
95
 
 
96
| *Parameter* | *Description* | *Default* |
 
97
| =action= | One of =create=, =createweb=, =changePassowrd=, =resetPassword=, =bulkRegister=, =deleteUserAccount=, =editSettings=, =saveSettings=, =restoreRevision= | none |
 
98
 
 
99
---++++ =action=create=
 
100
Alternative entry point for creation, via =edit=, of a new topic, used by screens that support several actions using =manage=.
 
101
| *Parameter* | *Description* | *Default* |
 
102
| =topic= | Name of topic to create (can be web.topic) | none |
 
103
Other parameters are the same as for =edit=.
 
104
 
 
105
---++++ =action=createweb=
 
106
Create a new web
 
107
| *Parameter* | *Description* | *Default* |
 
108
| =newweb= | Name of the new web | '' |
 
109
| =baseweb= | Name of the web to copy to create the new web | '' |
 
110
| =webbgcolor= | value for WEBBGCOLOR | '' |
 
111
| =sitemapwhat= | Value for SITEMAPWHAT | '' |
 
112
| =sitemapuseto= | Value for SITEMAPUSETO | '' |
 
113
| =nosearchall= | Value for NOSEARCHALL | '' |
 
114
| =newtopic= | Value of %<nop>TOPIC% within the web creation message. Optionally used in some skins to signify a non-default home topic. |
 
115
 
 
116
---++++ =action=editSettings=
 
117
No parameters
 
118
 
 
119
---++++ =action=saveSettings=
 
120
| *Parameter* | *Description* | *Default* |
 
121
| =text= | Text of the topic | '' |
 
122
| =originalrev= | Revision that the edit started on | Most recent revision |
 
123
| =redirectto= | If the savesettings process is successful, save will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | 
 
124
All other parameters may be interpreted as form fields, depending on the current form definition in the topic.
 
125
 
 
126
---++++ =action=bulkRegister=
 
127
See BulkRegistration.
 
128
| *Parameter* | *Description* | *Default* |
 
129
| =OverwriteHomeTopics= | Whether to overwrite existing home topics or not | false |
 
130
| =EmailUsersWithDetails= | Whether to mail registered users or not | false |
 
131
| =LogTopic= | Topic to save the log in | Same as topic name, with 'Result' appended. |
 
132
 
 
133
---++++ =action=changePassword=
 
134
Change password, email address, or both, of a user.
 
135
| *Parameter* | *Description* | *Default* |
 
136
| =username= | god alone knows | _none_ |
 
137
| =oldpassword= | current password | _none_ |
 
138
| =password= | new password | _none_ |
 
139
| =passwordA= | new password confirmation | _none_ |
 
140
| =email= | new email address | _none_ |
 
141
=password, =passwordA= and =email= are optional. If neither or =password= and =passwordA= is set, then the user password is left unchanged. If =email= is unset, their email is left unchanged.
 
142
 
 
143
---++++ =action=resetPassword=
 
144
Reset the password for a single or multiple users
 
145
| *Parameter* | *Description* | *Default* |
 
146
| =LoginName= | *list* of usernames to reset | none - error if not set |
 
147
| =Introduction= | message to be sent alongside the reset, most often used to announce to the user that they have been given an account.  | '' |
 
148
 
 
149
This is used by BulkResetPassword and ResetPassword. Only administrators can provide a list of LoginNames, non-admins can only provide a single LoginName. 
 
150
 
 
151
BulkRegistration provides the means to create multiple accounts but it does not announce those accounts to the users who own them. BulkResetPassword is used to assign the passwords, the Introduction is used to explain why they are receiving the mail.
 
152
 
 
153
---++++ =action=deleteUserAccount=
 
154
Unregisters (removes) the currently logged-in user.
 
155
| *Parameter* | *Description* | *Default* |
 
156
| =password= | Users' password | none |
 
157
 
 
158
---++++ =action=restoreRevision=
 
159
Alternative entry point for =edit=, used by screens that support several actions using =manage. Parameters are as for =edit=.
 
160
 
 
161
---+++ =oops=
 
162
This script is mainly used for rendering pages containing error messages, though it is also used for some functional actions such as manage pages (move topic etc).
 
163
 
 
164
=oops= templates are used with the =oops= script to generate system messages. This is done to make internationalisation or other local customisations simple. 
 
165
 
 
166
The =oops= script supports the following parameters:
 
167
 
 
168
| *Parameter* | *Description* | *Default* |
 
169
| =template= | Name of the template file to display | |
 
170
| =def= | Optional, can be set to the name of a single definition within =template=. This definition will be instantiated in the =template= wherever =%<nop>INSTANTIATE%= is seen. This lets you use a single template file for many messages. For an example, see =oopsmanagebad.tmpl=. | |
 
171
| =paramN= | Where N is an integer from 1 upwards. These values will be substituted into =template= for =%<nop>PARAM1%= etc. | |
 
172
 
 
173
---+++ =preview=
 
174
This script is _deprecated_. Its functions are covered by the =save= script.
 
175
 
 
176
---+++ =rdiff=
 
177
Renders the differences between version of a topic
 
178
 
 
179
| *Parameter* | *Description* | *Default* |
 
180
| rev1 | the higher revision | |
 
181
| rev2 | the lower revision | |
 
182
| render | the rendering style {sequential, sidebyside, raw, debug} | DIFFRENDERSTYLE, =sequential= |
 
183
| type | {history, diff, last} history diff, version to version, last version to previous | =diff= |
 
184
| context | number of lines of context | |
 
185
TODO:
 
186
   * add a {word} render style
 
187
 
 
188
---+++ =register=
 
189
 
 
190
| *Parameter* | *Description* | *Default* |
 
191
| =action= | =register= or =verify= or =resetPassword= or =approve= | |
 
192
 
 
193
*%X% Note:* The =register= script can only be called via the HTTP POST method except when the action is =verify=. Make sure you specify =method="post"= if you call the =register= script via a form action. It is not possible to call =register= from an =&lt;A href= link. The =verify= action is an exception as it is used to verify registration by clicking a href link from an email.
 
194
 
 
195
---+++ =rename=
 
196
Used for renaming webs, topics and attachments.
 
197
 
 
198
| *Parameter* | *Description* | *Default* |
 
199
| =action= | =renameweb= or anything else | |
 
200
| =skin= | skin(s) to use | |
 
201
| =confirm= | if defined, requires a second level of confirmation | |
 
202
| =referring_topics= | (internal use only) list of topics that refer to the web or topic being renamed | |
 
203
| =redirectto= | If the rename process is successful, rename will redirect to this topic or URL. The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | |
 
204
 
 
205
---++++ =action="renameweb"=
 
206
Rename a web.
 
207
| *Parameter* | *Description* | *Default* |
 
208
| =newparentweb= | new parent web name | existing parent |
 
209
| =newsubweb= | new web name | |
 
210
 
 
211
---++++ =action=<i>anything else</i>=
 
212
Rename a topic or an attachment.
 
213
| *Parameter* | *Description* | *Default* |
 
214
| =newweb= | new web name | |
 
215
| =newtopic= | new topic name | |
 
216
| =attachment= | Attachment to move | =none= |
 
217
| =template= | template for error when an attachment doesn't exist, =deleteattachment= for when deleting an attachment | |
 
218
| =currentwebonly= | if defined, searches current web only for links to this topic | |
 
219
| =nonwikiword= | if defined, a non-wikiword is acceptable for the new topic name | |
 
220
 
 
221
*%X% Note:* The =rename= script can only be called via the HTTP POST method. Make sure you specify =method="post"= if you call the =rename= script via a form action. It is not possible to call =rename= from an =&lt;A href= link.
 
222
 
 
223
---+++ =rest=
 
224
This REST ([[http://en.wikipedia.org/wiki/REST][Representational State Transfer]]) script can be invoked via http in the same way as the other scripts (see *Invocation Examples*, below) to execute a function that is associated to a "subject" and a "verb" (see below). These functions are usually registered by plugins using the =Foswiki::Func::registerRESTHandler= method. The =rest= script will print the result directly to the browser unless the =endPoint= parameter is specified, in which case it will output a redirect to the given topic.
 
225
 
 
226
The =rest= script supports the following parameters:
 
227
| =username= | If =TemplateLogin=, or a similar login manager not embedded in the web server, is used, then you need to pass a username and password to the server. The =username= and =password= parameters are used for this purpose. |
 
228
| =password= | See =username= |
 
229
| =topic= | If defined as the full name (including web) of a topic, then when the script starts up plugins will be passed this as the "current" topic. If not defined, then [[%USERSWEB%.%HOMETOPIC%]] will be passed to plugins. |
 
230
| =endPoint= | Where to redirect the response once the request is served, in the form "Web.Topic" |
 
231
 
 
232
The function is free to use any other query parameters for its own purposes.
 
233
 
 
234
%X% The =rest= script should *always* require authentication in any site that has logins. Otherwise there is a risk of opening up major security holes. So make sure you add it to the list of authenticated scripts if you are using =ApacheLogin=.
 
235
 
 
236
---++++ Invocation Examples
 
237
 
 
238
The =rest= script assumes that it will be called with URL in the form:
 
239
 
 
240
=http://my.host/bin/rest/&lt;subject&gt;/&lt;verb&gt;=
 
241
 
 
242
where =&lt;subject&gt;= must be the WikiWord name of one of the installed [[Plugins]], and the =&lt;verb&gt;= is the alias for the function registered using the =Foswiki::Func::registerRESTHandler= method. The =&lt;subject&gt;= and =&lt;verb&gt;= are then used to lookup and call the registered function.
 
243
 
 
244
=&lt;subject&gt;= and =&lt;verb&gt;= are checked for illegal characters exactly in the same way as the web and topic names.
 
245
 
 
246
As an example, the EmptyPlugin has registered a function to be used with the =rest= script under the subject *EmptyPlugin* and the verb *example*. Click below to see the =rest= script in action (run as guest).
 
247
 
 
248
[[%SCRIPTURL{rest}%/EmptyPlugin/example?debugenableplugin=EmptyPlugin][Call the Plugin]]
 
249
 
 
250
Note that for Plugins to register REST handlers, they must be enabled in =configure=.
 
251
 
 
252
---+++ =save=
 
253
The =save= script performs a range of save-related functions, as selected by the =action= parameter.
 
254
 
 
255
| *Parameter* | *Description* | *Default* |
 
256
| =action_save=1= | *default*; save, return to view, dontnotify is =off= | |
 
257
| =action_quietsave=1= | save, and return to view, =dontnotify= is =on= | |
 
258
| =action_checkpoint= | save and redirect to the edit script, =dontnotify= is =on= | |
 
259
| =action_cancel= | exit without save, return to view | |
 
260
| =action_preview= | preview edited text | |
 
261
| =action_addform= | Redirect to the "change form" page. | |
 
262
| =action_replaceform...= | Redirect to the "change form" page. | |
 
263
| =action_delRev= | *Administrators only* delete the most recent revision of the topic - all other parameters are ignored. You have to be an administrator to use this, and not all store implementations will support it. | |
 
264
| =action_repRev= | *Administrators only* replace the text of the most recent revision of the topic with the text in the =text= parameter. =text= must included embedded meta-data tags. All other parameters are ignored. You have to be an administrator to use this, and not all store implementations will support it. | |
 
265
| =onlynewtopic= | If set, error if topic already exists | |
 
266
| =onlywikiname= | If set, error if topic name is not a WikiWord | |
 
267
| =dontnotify= | if defined, suppress change notification | |
 
268
| =templatetopic= | Name of a topic to use as a template for the text and form (new topic _only_) | |
 
269
| =text= | New text of the topic | |
 
270
| =forcenewrevision= | if set, forces a revision even if %WIKITOOLNAME% thinks one isn't needed | |
 
271
| =topicparent= | If 'none' remove any current topic parent. If the name of a topic, set the topic parent to this. | |
 
272
| =formtemplate= | if defined, use the named template for the form (will remove the form is set to 'none') | |
 
273
| =editaction= | When action is =checkpoint=, =add form= or =replace form...=, this is used as the =action= parameter to the =edit= script that is redirected to after the save is complete. | |
 
274
| =originalrev= | Revision on which the edit started. | |
 
275
| =edit= | The script to use to edit the topic when action is =checkpoint= | =edit= |
 
276
| =editparams= | The parameter string to use to edit the topic |  |
 
277
| =redirectto= | The save process will redirect to this topic or URL if it is successful. (Typically this would be the URL that was being viewed when edit was invoked). The parameter value can be a =TopicName=, a =Web.TopicName=, or a URL.%BR% *Note:* Redirect to a URL only works if it is enabled in =configure= (Miscellaneous ={AllowRedirectUrl}=). | view topic being edited |
 
278
 
 
279
Any errors will cause a redirect to an =oops= page.
 
280
 
 
281
The parameters are interpreted in according to the following rules.
 
282
 
 
283
   1 The first sequence of ten or more =X= characters in the topic name will be converted to a number such that the resulting topic name is unique in the target web.
 
284
   1 When the action is =save=, =checkpoint=, =quietsave=, or =preview=:
 
285
      1 The new text is taken from the =text= parameter, if it is defined,
 
286
         * otherwise it is taken from the =templatetopic=, if it is defined, (new topic _only_)
 
287
         * otherwise it is taken from the previous version of the topic, if any,
 
288
      1 The name of the new form is taken from the =formtemplate=, if defined
 
289
         * otherwise it is taken from the =templatetopic=, if defined, (new topic _only_)
 
290
         * otherwise it is taken from the previous version of the topic, if any,
 
291
         * otherwise no form is attached.
 
292
      1 The value for each field in the form is taken from the query, if it is defined
 
293
         * otherwise it is taken from the =templatetopic=, if defined, (new topic _only_)
 
294
         * otherwise it is taken from the previous version of the topic, if any,
 
295
         * otherwise it defaults to the empty string.
 
296
 
 
297
Merging is only enabled if the topic text comes from =text= and =originalrev= is &gt; 0 and is not the same as the revision number of the most recent revision. If merging is enabled both the topic and the meta-data are merged.
 
298
 
 
299
Form field values are passed in parameters named 'field' - for example, if I have a field =Status= the parameter name is =Status=.
 
300
 
 
301
*%X% Note:* The =save= script can only be called via HTTP POST method. Make sure you specify =method="post"= if you call the =save= script via a form action. Example:
 
302
<pre>
 
303
&lt;form name="new" action="%<nop>SCRIPTURLPATH{save}%/Sandbox/" method="post"&gt;
 
304
    ...
 
305
&lt;/form&gt;
 
306
</pre>
 
307
It is not possible to call =save= from an =&lt;A href= link.
 
308
 
 
309
---+++ =search=
 
310
CGI gateway to the =%<nop>SEARCH%= functionality driven by the following CGI parameters:
 
311
 
 
312
| *Parameter:* | *Description:* | *Default:* |
 
313
| ="text"= | Search term. Is a keyword search, literal search or regular expression search, depending on the =type= parameter. SearchHelp has more | required |
 
314
| =search="text"= | (Alternative to above) | N/A |
 
315
| =web="Name"= <br /> =web="%USERSWEB%, Know"= <br /> =web="all"= | Comma-separated list of webs to search. See [[%SYSTEMWEB%.Macros#VarSEARCH][Macros#VarSEARCH]] for more details. | Current web |
 
316
| =topic="%WEBPREFSTOPIC%"= <br /> =topic="*Bug"= | Limit search to topics: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. | All topics in a web |
 
317
| =excludetopic="Web*"= <br /> =excludetopic="%HOMETOPIC%, <nop>WebChanges"= | Exclude topics from search: A topic, a topic with asterisk wildcards, or a list of topics separated by comma. | None |
 
318
| =type="keyword"= <br /> =type="literal"= <br /> =type="regex"= | Do a keyword search like =soap "web service" -shampoo=; a literal search like =web service=; or RegularExpression search like =soap;web service;!shampoo= | =%<nop>SEARCHVAR- DEFAULTTYPE%= [[DefaultPreferences][preferences]] setting (%SEARCHVARDEFAULTTYPE%) |
 
319
| =scope="topic"= <br /> =scope="text"= <br /> =scope="all"= | Search topic name (title); the text (body) of topic; or all (both) | ="text"= |
 
320
| =order="topic"= <br /> =order="created"= <br />  =order="modified"= <br /> =order="editby"= <br /> =order=<br />&nbsp;"formfield(name)"= | Sort the results of search by the topic names, topic creation time, last modified time, last editor, or named field of DataForms. The sorting is done web by web; in case you want to sort across webs, create a [[FormattedSearch][formatted]] table and sort it with TablePlugin's initsort | Sort by topic name |
 
321
| =limit="all"= <br /> =limit="16"= | Limit the number of results returned. This is done after sorting if =order= is specified | All results |
 
322
| =date="..."= | limits the results to those pages with latest edit time in the given [[TimeSpecifications#TimeIntervals][time interval]].  | All results |
 
323
| =reverse="on"= | Reverse the direction of the search | Ascending search |
 
324
| =casesensitive="on"= | Case sensitive search | Ignore case |
 
325
| =bookview="on"= | BookView search, e.g. show complete topic text. Very resource demanding. Use only with small result sets | Show entire topic content of found topics |
 
326
| =nonoise="on"= | Shorthand for =nosummary="on" nosearch="on" nototal="on" zeroresults="off" noheader="on" noempty="on"= | Off |
 
327
| =nosummary="on"= | Show topic title only | Show topic summary |
 
328
| =nosearch="on"= | Suppress search string | Show search string |
 
329
| =noheader="on"= | Suppress search header <br /> <span style='background: #FFB0B0;'> *Topics: Changed: By:* </span> | Show search header |
 
330
| =nototal="on"= | Do not show number of topics found | Show number |
 
331
| =zeroresults="off"= | Suppress all output if there are no hits | =zeroresults="on"=, displays: "Number of topics: 0" |
 
332
| =noempty="on"= | Suppress results for webs that have no hits. | Show webs with no hits |
 
333
| =header="..."= <br /> =format="..."= | Custom format results: see *[[FormattedSearch]]* for usage &amp; examples | Results in table |
 
334
| =expandvariables="on"= | Expand embedded macros before applying a FormattedSearch on a search hit. Useful to show the expanded text, e.g. to show the result of a SpreadSheetPlugin =%<nop>CALC{}%= instead of the formula | Raw text |
 
335
| =multiple="on"= | Multiple hits per topic. Each hit can be [[FormattedSearch][formatted]]. The last token is used in case of a regular expression ";" _and_ search | Only one hit per topic |
 
336
| =nofinalnewline="on"= | If =on=, the result of the macro does not end in a line by itself. Any text continuing immediately after the search macro on the same line will be rendered as part of the table generated by the search, if appropriate. | =off= |
 
337
| =separator=", "= | Line separator between hits | Newline ="$n"= |
 
338
 
 
339
---+++ =statistics=
 
340
Refresh the WebStatistics topics in range of webs.
 
341
| *Parameter* | *Description* | *Default* |
 
342
| =webs= | comma-separated list of webs to run stats on | all accessible webs |
 
343
| =logdate= | YYYYMM to generate statistics for | current month |
 
344
 
 
345
for example:
 
346
   1 from browser %SCRIPTURL{"statistics"}% updates _all user webs_
 
347
   2 from browser %SCRIPTURL{"statistics"}%?webs=Userweb,Sandbox updates _Userweb,Sandbox_
 
348
   3 from browser %SCRIPTURL{"statistics"}%/%WEB% updates %WEB%
 
349
   4 from command line bin/statistics updates _all user webs_
 
350
   5 from command line bin/statistics -webs=Userweb,Sandbox updates _Userweb,Sandbox_
 
351
   6 from command line bin/statistics %WEB%.<nop>WebHome updates %WEB%
 
352
 
 
353
see SiteTools#WebStatistics_site_statistics for updating statistics using cron.
 
354
 
 
355
---+++ =upload=
 
356
Uploads an attachment to a topic. The HTTP request is expected to be in =multipart/form-data= format.
 
357
| *Parameter* | *Description* | *Default* |
 
358
| =hidefile= | if defined, will not show file in attachment table | |
 
359
| =filepath= | local (client) path name of the file being uploaded. This is used to look up the data for the file in the HTTP query. | |
 
360
| =filename= | deprecated, do not use | |
 
361
| =filecomment= | Comment to associate with file in attachment table | |
 
362
| =createlink= | if defined, will create a link to file at end of topic | |
 
363
| =changeproperties= | if defined, this is a property change operation *only* - no file will be uploaded. | null |
 
364
| =redirectto= | URL to redirect to after upload. ={AllowRedirectUrl}= \
 
365
     must be enabled in =configure=. The parameter value can be a \
 
366
     =TopicName=, a =Web.TopicName=, or a URL. Redirect to a URL only works \
 
367
     if it is enabled in =configure=, and is ignored if =noredirect= is \
 
368
     specified.%BR% *Note:* Redirect to a URL only works if it is enabled \
 
369
     in =configure= (Miscellaneous ={AllowRedirectUrl}=). |
 
370
| =noredirect= | Normally it will redirect to 'view' when the upload is \
 
371
     complete, but also designed to be useable for REST-style calling using \
 
372
     the 'noredirect' parameter. If this parameter is set it will return an \
 
373
     appropriate HTTP status code and print a message to STDOUT, starting \
 
374
     with 'OK' on success and 'ERROR' on failure. |
 
375
 
 
376
*Tips*
 
377
   * You can use a tool like =curl= to upload files from the command line using this script.
 
378
   * You can call upload easily from !XmlHttpRequest in Javascript.
 
379
 
 
380
*%X% Note:* The =upload= script can only be called via HTTP POST method. Make sure you specify =method="post"= if you call the =upload= script via a form action. It is not possible to call =upload= from an =&lt;A href= link.
 
381
 
 
382
---+++ =view=
 
383
Used for viewing topics.
 
384
 
 
385
| *Parameter* | *Description* | *Default* |
 
386
| =raw=on= | Shows the text of the topic in a scrollable textarea | |
 
387
| =raw=debug= | As =raw=on=, but also shows the metadata (forms etc) associated with the topic. | |
 
388
| =raw=text= | Shows only the source of the topic, as plain text (Content-type: text/plain). Only shows the body text, *not* the form or other meta-data. |
 
389
| =raw=all= | Shows only the source of the topic, as plain text (Content-type: text/plain), *with embedded meta-data*. This may be useful if you want to extract the source of a topic to a local file on disc. | |
 
390
| =section= | Allows to view only a part of the topic delimited by a named section (see %SYSTEMWEB%.VarSTARTSECTION). If the given section is not present, no topic content is displayed. | |
 
391
| =contenttype= | Allows you to specify a different *Content-Type:* (e.g. =contenttype=text/plain=) | |
 
392
| =rev= | Revision to view (e.g. =rev=45=) | |
 
393
| =template= | Allows you to specify a different skin template, overriding the 'view' template the view script would normally use. The default template is =view=. For example, you could specify [[%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?template=edit][%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?template=edit]]. This is mainly useful when you have specialised templates for a Wiki Application. | |
 
394
| =topic= | redirects (at the beging of the cgi script running) to show the spcified Web.Topic, or, redirects to a URL, if allowed by {AllowRedirectUrl} and {PermittedRedirectHostUrls} | |
 
395
 
 
396
%X% For historical reasons, the view script has a special interpretation of the =text= skin. This skin cannot be redefined.
 
397
 
 
398
---+++ =viewfile=
 
399
Used for viewing attachments. Normally, a site will publish the attachments (=pub=) directory using a URL. However if it contains sensitive information, you will want to protect attachments using [[AccessControl][AccessControls]]. In this case, you can use the =viewfile= script to give access to attachments while still checking access controls.
 
400
 
 
401
| *Parameter* | *Description* | *Default* |
 
402
| =filename= | name of attachment | |
 
403
| =rev= | Revision to view | |
 
404
 
 
405
Instead of using the =filename= parameter, you can append the attachment name
 
406
to the end of the URL path (after the topic) e.g. =%SCRIPTURL{viewfile}%/Webname/TopicName/Attachment.gif=
 
407
 
 
408
---++ Command Line Scripts
 
409
Details on command line scripts located in the =tools= directory.
 
410
 
 
411
---+++ =geturl.pl=
 
412
This is a very simple script to get the content of a web site. It is marked as _deprecated_ and might be removed (or enhanced) in a future release. Its functions are covered by the standard =wget= and =curl= commands.
 
413
   * Usage:    =geturl.pl &lt;host&gt; &lt;path&gt; [&lt;port&gt; [&lt;header&gt;]]=
 
414
   * Example:  =geturl.pl some.domain /some/dir/file.html 80=
 
415
   * Will get: =http://some.domain:80/some/dir/file.html=
 
416
 
 
417
---+++ =rewriteshebang.pl=
 
418
Simple script to rewrite the =#!/usr/bin/perl= shebang lines specific to your local Perl installation. It will rewrite the first line of all your cgi scripts so they use a different shebang line. Use it if your perl is in a non-standard location, or you want to use a different interpreter (such as 'speedy').
 
419
 
 
420
---+++ =tick_foswiki.pl=
 
421
This script executes a number of non-essential regular administration tasks that will help keep your site healthy and happy, such as removing expired sessions and lease files.
 
422
 
 
423
It is intended to be run as a cron job or a scheduled task once a week. Example crontab entry:%BR%
 
424
=0 0 * * 0 cd /usr/local/foswiki/bin && perl ../tools/tick_foswiki.pl=
 
425
 
 
426
*Note:* The script has to be run by a user who can write files created by the webserver user.
 
427
 
 
428
---
 
429
*Related Topics:* AdminDocumentationCategory, DeveloperDocumentationCategory