# rvm_privileged v0.5 # Use TXP admin user privileges on public side # # License: GNU GPLv2 or later # # Ruud van Melick # http://vanmelick.com/ # ...................................................................... # This is a plugin for Textpattern - http://textpattern.com/ # To install: textpattern > admin > plugins # Paste the following text into the 'Install plugin' box: # ...................................................................... YTo5OntzOjc6InZlcnNpb24iO3M6MzoiMC41IjtzOjY6ImF1dGhvciI7czoxNToiUnV1ZCB2 YW4gTWVsaWNrIjtzOjEwOiJhdXRob3JfdXJpIjtzOjIxOiJodHRwOi8vdmFubWVsaWNrLmNv bS8iO3M6MTE6ImRlc2NyaXB0aW9uIjtzOjQ0OiJVc2UgVFhQIGFkbWluIHVzZXIgcHJpdmls ZWdlcyBvbiBwdWJsaWMgc2lkZSI7czo0OiJ0eXBlIjtpOjA7czo0OiJuYW1lIjtzOjE0OiJy dm1fcHJpdmlsZWdlZCI7czo0OiJoZWxwIjtzOjM2MTU6IiA8c3R5bGU+CiAgIGxpIGNvZGUg e2ZvbnQtd2VpZ2h0OiBib2xkO30KICAgcHJlIHtwYWRkaW5nOiAwLjVlbSAxZW07IGJhY2tn cm91bmQ6ICNlZWU7IGJvcmRlcjogMXB4IGRhc2hlZCAjY2NjO30KICAgaDEsIGgyLCBoMywg aDMgY29kZSB7Zm9udC1mYW1pbHk6IHNhbnMtc2VyaWY7IGZvbnQtd2VpZ2h0OiBib2xkO30K ICAgaDEsIGgyLCBoMyB7bWFyZ2luLWxlZnQ6IC0xZW07fQogICBoMiwgaDMge21hcmdpbi10 b3A6IDJlbTt9CiAgIGgxIHtmb250LXNpemU6IDNlbTt9CiAgIGgyIHtmb250LXNpemU6IDJl bTt9CiAgIGgzIHtmb250LXNpemU6IDEuNWVtO30KICAgbGkgYSBjb2RlIHtmb250LXdlaWdo dDogbm9ybWFsO30KICAgLnJlcXVpcmVkLCAud2FybmluZyB7Y29sb3I6cmVkO30KIDwvc3R5 bGU+Cgo8aDE+UHJpdmlsZWdlZDwvaDE+Cgo8cD5SZXF1aXJlcyA8c3BhbiBj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