|
Cookbook /
WikiBoxSummary: Allow posting to and reading from PmWiki via email
Version: 2008-08-17
Prerequisites: 2.2.x beta, PHP5
Status: Alpha
Maintainer: Peter Bowers
Download: wikibox.phpΔ
Questions answered by this recipe
DescriptionAllow posting to and reading from PmWiki pages via email. Hey! There's an ongoing alpha (actually probably it's up to beta by now) test going on over at www.qdk.org. If you're interested in taking part (or at least seeing what wikibox looks like in real life) feel free to check it out. You can send an email to wikibox@qdk.org with the subject "usage" to get a broad overview. Or you can go and visit http://www.qdk.org/pmwiki/pmwiki.php?n=WikiBox.WikiBox if you want to see a really quick overview of how the testing is organized, what pages are involved, etc. Installation
include_once("$FarmD/cookbook/toolbox.php");
include_once("$FarmD/cookbook/SecLayer.php");
include_once("$FarmD/cookbook/wikibox.php");
include_once("$FarmD/cookbook/wikimail.php");
$wbModerator = 'moderator@localhost'; // replace this with the email address of the moderator
// you can also make it an array of addresses if more than 1
# Normally this call to wmMkProfilePOP3() would be on a single line
wmMkProfilePOP3('wikibox', //name of the profile - must be wikibox unless you change $wbPOP3Profile
'pop3.mydomain.com', // host where WikiBox will pick up mail
'myusername', // username WikiBox will use to pick up mail
'secret'); // password WikiBox will use to pick up mail
# There are several other optional parameters you can also set in the profile, but these 3 usually suffice
Note the need to edit the moderator address from the current
all=overwrite,insert,create,read edit = overwrite, create, insert Test.*:all
moderator@localhost:::1:0:xyz:::::: Make SURE that you replace
$wbControl['Write'] = array('Receive', 'UserConfirm','Moderate','Complete'); // default
$wbControl['Write'] = array('Receive', 'UserConfirm','Complete'); // no moderator requirement
$wbControl['Write'] = array('Receive', 'Complete'); // no moderator nor user confirmation requirement
echo "Checking..." wget -N --no-cache -E "http://www.qdk.org/pmwiki/pmwiki.php?n=WikiBox.Check" >/dev/null 2>&1 #sed -n -e 's/<[^>]*>//g' -e '/WIKIBOX PROCESSING/,/WIKIBOX COMPLETE/p' pmwiki.php\?n\=WikiBox.Check.html (The last line is useful if you are running it from the command line rather than through CRON -- if you remove the "#" at the start of that last line then it will give you a quick summary of the output of wikibox during the run.) Then in /etc/crontab you would need entries like this: # Every 15 minutes between 8am and 5pm Mon-Fri 0,15,30,45 8-17 * * 1-5 root /usr/local/bin/checkqdk # Every 30 minutes before 8am and after 5pm Mon-Fri 0,30 0-8,17-23 * * 1-5 root /usr/local/bin/checkqdk # Every hour on weekends 0 0-23 * * 6-7 root /usr/local/bin/checkqdk Obviously you would need to determine what schedule worked for you. Do note that while this cron job can be on the hosting server it by no means must be on that machine. You can run that script from a home machine, from your friend's machine that has linux on it, etc. The only requirements are (a) the machine has to keep running, (b) it has to be a machine with cron (usually linux although cygwin might have something for windows?) and (c) it has to have network access to your site (usually this means simply being connected to the internet). NotesEmails consist of a subject and the body of the email. For WikiBox the subject becomes a command specifying where and how the body of the email should be placed on a given page. The body of the email should be plaintext as it will be inserted into the page character-for-character as it appears in the body of the email. Various valid initiating commands (placed in the subject) follow:
Each write command is made up of a main command, optional filler words, a pagename, and then (if the main command was "insert") a location and a pattern. Main Write Commands
Filler wordsFiller words like "on", "in", "to", "into", "at the top of", "at the bottom of", etc between the main command and the name of the page are optional and ignored. They just make the command a little more readable. Do note that the filler words are really ignored. "Insert at the top of PageThe page must be specified as Email BodyText only at the current time. I suppose it goes without saying, but markup is text, so any valid pmwiki markup can be placed in the body of the email. If you send HTML or some other format email then only the text portion will be pulled out. If you want to format your page, put pmwiki markup in your text. Attachments can be automatically uploaded to whatever page is being written to (only valid on a request that writes to a page). Simply follow these instructions:
Following the examples above, here is an email you could send with an attachment named "prettypicture.jpg": SUBJECT: wikibox-passwd:mysecretpass wikibox-attach:prettypicture.jpg Hey! Take a look at this pretty picture! Attach:prettypicture.jpg (Everything below this line is just for fun to show the possibility that other markup can be included and written to the page -- the 1st 3 lines above, in combination with the subject and the attachment, are what are required to make uploading via attachment work.) * and ** a *** list '''boldfaced''' and ''italicized'' text [[Test.Link|+]] to put a link and any other markup I would like to do Markup / UsageWikibox does nothing until the page with the appropriate markup on it is loaded. The markup used is If you wish to place a signup form on a page somewhere (WikiBox.Signup is the standard and recommended) then simply create that page and place Note that the authorization of the user loading the page with the Release Notes
See AlsoContributorsRoadmap
CommentsIn my config.php, the line calling wmMkProfilePOP3 seems to be problematic. My wiki goes blank and ceases to funtion (HTTP 500 Internal Server Error) when it is present. I have checked it several times and also used the lines copied directly out of this page - which, though incorrectly configured, should still produce a functional site. What could be wrong? How do I test it? DavidBessler February 27, 2009, at 08:49 AM Are you with PHP5 or PHP4? PHP5 is a requirement for this recipe. Please drop me a line or leave me some way to get in touch with you and we can chase it down together... Peter Bowers February 27, 2009, at 02:06 PM
I figured it out. I'm using PHP5 on a standard godaddy hosting account, by the way. I turned on error reporting on my php5.ini file, and saw that php was not finding the cookbook files. I replaced the single quotes around the path names in the include_once statements in config.php with double quotes--like the rest of my include_once statements, and it worked. DavidBessler March 03, 2009, at 08:21 AM You're absolutely right. I've fixed those in the example config above now.
Now I'm getting the following error: wbWriteToPage(): RetrieveAuthPage() Failure. Returning FALSE DavidBessler March 03, 2009, at 09:11 AM Please check in WikiBox.ErrorLog and see if the error messages there help clarify any problems. Typically this is an authorization problem.
Can I not use wikibox with password-protected pages? DavidBessler March 03, 2009, at 01:46 PM Yes, you can. But the ID you're using to submit changes has to have the appropriate authorizations. A user signed up through email rather than the form interface has no authorization (just as if he was not logged in at all). Whereas a user who signs up through the form interface gains any authorization that was present at the moment of signing up. Note paragraphs #2 and #3 under the "markup" section. Also quoting from the release notes:
Also if the user signs up using the form interface a snapshot of their current authorizations will be made and that will be used for any future read/edit operations from that email address.
Having said that, I've got to apologize for the documentation on this recipe. It needs a lot of work... Any improvements you would like to make are greatly appreciated.
Brilliant! Got it working. Now I have to work on my CRON script. This will revolutionize my journaling. I'll try to tidy up the documentation.DavidBessler I keep getting this error with my cron script: /home/content/a/b/c/abcusername/html/abcusername/wiki/mywikipostchecker: line 2: 1 : ambiguous redirect (I've anonymized the path and filename) Any ideas? DavidBessler March 03, 2009, at 09:57 PM Can you show me more of your cron script? What operating system are you running under. (The fact you mention cron suggests linux, but I just want to make sure.) Is your cron running on the same machine that is hosting your pmwiki installation or is it remote? Are you trying to use wget to load the page or are you going to try to call php directly on pmwiki.php with the appropriate setup? I've used wget successfully in different contexts but I've never tried the latter, although it should work fine (and be more efficient) once you figure out the ins and outs. The wget can be as simple as the word wget followed by a space followed by whatever URL you put in your address bar to access the page with the markup... But whatever wget uses will need to start with http:// or whatever...
For some reason, trying to cron the script directly yields a "file not found" error which I couldn't get past. I used the script/wget method with just: wget "http://wiki.xxxxxxxx.com/pmwiki.php?n=WikiBox.Check" and that is working. So now, it looks like I have the whole thing set up. Thanks so much for your help. DavidBessler March 04, 2009, at 02:32 AM Glad it worked out in the end and hope it continues to do well by you. FYI cron has a very minimalistic environment when it runs scripts. I.e., you may not have the appropriate $PATH and you may not even be running bash -- you may be running some slimmed down shell. If you're interested in chasing it down let me know which file was not found and we can follow up. If you're pleased with the way it's working now then I'm happy too.
PS If you do decide to use this on an ongoing basis could you be sure to "sign" the WikiBox-Users page? (It's still not fully implemented but it looks like that is the most likely way recipes are going to be rated in the future...) Thanks!
It's been some time since I worked with this recipe, so the details are kind of fuzzy, but take a look at WikiMail configuration and you'll see setup for $WikiMailSMTP. If that doesn't work let me know and I'll look into it in more detail.
Thanks, I will look into it.
I must have messed up the config somehow. The mails being sent to the user or the moderator for action are being sent with the From: and Reply-to: set to _www@portfolio.paladin.local, which my local web server on my mac. Shouldn't this be set to the mailbox WikiBox.Check looks at instead? Here's my config.php section: ## Adding stuff for wikibox - to allow addition of wiki pages by email
## http://www.pmwiki.org/wiki/Cookbook/WikiBox
include_once("My SiteAdmin.WikiBoxEmailAuth has in it: tamara@locahost:::1:0:--------::::::
tamouse June 14, 2011, at 12:47 AM User notes +4: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |