diff options
author | redmatrix <git@macgirvin.com> | 2016-04-18 20:38:38 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-04-18 20:38:38 -0700 |
commit | 2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289 (patch) | |
tree | 2376d950ba2bdc7753336a3e2b94865c95c238f2 /Zotlabs/Module/Pconfig.php | |
parent | 2a61817bad96526994c0499f1fc0a843a9cc9405 (diff) | |
download | volse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.tar.gz volse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.tar.bz2 volse-hubzilla-2a4e8972e0edfa3156d9ce54d68ce0e54c0ec289.zip |
module updates
Diffstat (limited to 'Zotlabs/Module/Pconfig.php')
-rw-r--r-- | Zotlabs/Module/Pconfig.php | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/Zotlabs/Module/Pconfig.php b/Zotlabs/Module/Pconfig.php new file mode 100644 index 000000000..01899ffdb --- /dev/null +++ b/Zotlabs/Module/Pconfig.php @@ -0,0 +1,122 @@ +<?php +namespace Zotlabs\Module; + + + + + +class Pconfig extends \Zotlabs\Web\Controller { + + function post() { + + if(! local_channel()) + return; + + + if($_SESSION['delegate']) + return; + + check_form_security_token_redirectOnErr('/pconfig', 'pconfig'); + + $cat = trim(escape_tags($_POST['cat'])); + $k = trim(escape_tags($_POST['k'])); + $v = trim($_POST['v']); + + if(in_array(argv(2),$this->disallowed_pconfig())) { + notice( t('This setting requires special processing and editing has been blocked.') . EOL); + return; + } + + if(strpos($k,'password') !== false) { + $v = z_obscure($v); + } + + set_pconfig(local_channel(),$cat,$k,$v); + build_sync_packet(); + + goaway(z_root() . '/pconfig/' . $cat . '/' . $k); + + } + + + function get() { + + if(! local_channel()) { + return login(); + } + + $content = '<h3>' . t('Configuration Editor') . '</h3>'; + $content .= '<div class="descriptive-paragraph">' . t('Warning: Changing some settings could render your channel inoperable. Please leave this page unless you are comfortable with and knowledgeable about how to correctly use this feature.') . '</div>' . EOL . EOL; + + + + if(argc() == 3) { + $content .= '<a href="pconfig">pconfig[' . local_channel() . ']</a>' . EOL; + $content .= '<a href="pconfig/' . escape_tags(argv(1)) . '">pconfig[' . local_channel() . '][' . escape_tags(argv(1)) . ']</a>' . EOL . EOL; + $content .= '<a href="pconfig/' . escape_tags(argv(1)) . '/' . escape_tags(argv(2)) . '" >pconfig[' . local_channel() . '][' . escape_tags(argv(1)) . '][' . escape_tags(argv(2)) . ']</a> = ' . get_pconfig(local_channel(),escape_tags(argv(1)),escape_tags(argv(2))) . EOL; + + if(in_array(argv(2),disallowed_pconfig())) { + notice( t('This setting requires special processing and editing has been blocked.') . EOL); + return $content; + } + else + $content .= $this->pconfig_form(escape_tags(argv(1)),escape_tags(argv(2))); + } + + + if(argc() == 2) { + $content .= '<a href="pconfig">pconfig[' . local_channel() . ']</a>' . EOL; + load_pconfig(local_channel(),escape_tags(argv(1))); + foreach(\App::$config[local_channel()][escape_tags(argv(1))] as $k => $x) { + $content .= '<a href="pconfig/' . escape_tags(argv(1)) . '/' . $k . '" >pconfig[' . local_channel() . '][' . escape_tags(argv(1)) . '][' . $k . ']</a> = ' . escape_tags($x) . EOL; + } + } + + if(argc() == 1) { + + $r = q("select * from pconfig where uid = " . local_channel()); + if($r) { + foreach($r as $rr) { + $content .= '<a href="' . 'pconfig/' . escape_tags($rr['cat']) . '/' . escape_tags($rr['k']) . '" >pconfig[' . local_channel() . '][' . escape_tags($rr['cat']) . '][' . escape_tags($rr['k']) . ']</a> = ' . escape_tags($rr['v']) . EOL; + } + } + } + return $content; + + } + + + function pconfig_form($cat,$k) { + + $o = '<form action="pconfig" method="post" >'; + $o .= '<input type="hidden" name="form_security_token" value="' . get_form_security_token('pconfig') . '" />'; + + $v = get_pconfig(local_channel(),$cat,$k); + if(strpos($k,'password') !== false) + $v = z_unobscure($v); + + $o .= '<input type="hidden" name="cat" value="' . $cat . '" />'; + $o .= '<input type="hidden" name="k" value="' . $k . '" />'; + + if(strpos($v,"\n")) + $o .= '<textarea name="v" >' . escape_tags($v) . '</textarea>'; + else + $o .= '<input type="text" name="v" value="' . escape_tags($v) . '" />'; + + $o .= EOL . EOL; + $o .= '<input type="submit" name="submit" value="' . t('Submit') . '" />'; + $o .= '</form>'; + + return $o; + + } + + + + function disallowed_pconfig() { + return array( + 'permissions_role' + ); + } + +} |