Questions answered by this recipe
This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.
- How can I "crypt" text?
- How can I "hash" something (using sha1, md5, etc.)?
- How can I "hash_hmac" something (using sha1, md5, etc.)?
- How can I "crc32" text?
- How can I encode/decode something into/from base64?
- How can I find out a valid pagename from some text (makepagename)
- How can I write PTVs to pages
Implement miscellaneous PHP function by means of Markup Expressions.
Installation & Configuration
- Download MiscMX.phpΔ and put it in your cookbook.
- Put the usual
include_once("line in your config.php.
|crypt||Run crypt() on all arguments (imploded with space if there are multiple arguments). (accepts a salt=X or --salt:X option)|
|hash||First argument must be a valid algorithm for hash() (md5, sha1, etc.). hash() will be executed on all subsequent arguments (imploded with space if there are multiple arguments). Valid arguments are |
-f or --file which says that arguments are a page or a file rather than just text.
--raw which says to do a raw hash
|hash_hmac||Identical to hash (above) except for a required --key:"secret" option to set the key.|
|preg_quote||Calls PHP's preg_quote directly. No WikiSh compatibility mode.|
|crc32||Run crc32() on all arguments (imploded with space if there are multiple arguments). It is appropriately processed with sprint("%u"...).|
|base64_encode||Run base64_encode on arguments. Note that base64 encoded text often (always?) ends with a double-equals-sign. The PmWiki Markup Expression engine will interpret this as setting an option if you place this value as an argument to another MX. Thus you must be careful to protect the value with quotes, particularly if you are using base64_encode within backquotes or within a nested MX.|
|base64_decode||Run base64_decode on arguments.|
|makepagename||Run MakePageName on arguments. Recognizes REFPAGE=group.page if you want a different reference page.|
|trim||Run trim() (or rtrim() with -r or ltrim with -l) on an expression|
|writeptv||Write one or more PTVs to a page in a specified format. Expects one argument which will be the pagename. Accepts an optional fmt=X to specify (hidden, section, text, deflist) format of the PTV (default=hidden). Other options (specified var=value) will result in those PTVs being written|
NOTE: Requires Toolbox for writeptv to work
MiscMX can be used independently of WikiSh, but if it is included after WikiSh then it will allow additional functionality in a "WikiSh-Compatible" mode. The additional functionality follows:
- Receiving input from a pipe in wikish (either as a file or as an argument via --xargs)
- Redirecting output
- Setting options via -x or --longx or --longx:val
- Other general WikiSh options
If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".
- 2008-09-20 - Added trim. Made writeptv fail silently if no page specified.
- 2008-09-13 - Added preg_quote, added --salt:X option to crypt MX.
- 2008-08-21 - Added writeptv.
- 2008-08-03 - "Releaser's Remorse." I decided sendmail should really be named mailx and should be part of WikiSh. No more sendmail() here in MiscMX.
- 2008-08-02 - Fixing some function names that were changed in the 2008-07-31 release of Wikish, adding makepagename, adding sendmail
- 2008-05-13 - Initial Release