diff options
author | zotlabs <mike@macgirvin.com> | 2017-06-18 22:25:41 -0700 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-06-19 16:09:07 +0200 |
commit | 1472f85b162ea6f1ab9e19e94b86fc4a8ef074be (patch) | |
tree | 5bcfc4803bb4305790d7cce894cc96a072e86840 /include/channel.php | |
parent | 3d6255ae24310a935caf4e74729aa7165f94aeda (diff) | |
download | volse-hubzilla-1472f85b162ea6f1ab9e19e94b86fc4a8ef074be.tar.gz volse-hubzilla-1472f85b162ea6f1ab9e19e94b86fc4a8ef074be.tar.bz2 volse-hubzilla-1472f85b162ea6f1ab9e19e94b86fc4a8ef074be.zip |
allow moderated comments like wordpress if permissions are compatible
Diffstat (limited to 'include/channel.php')
-rw-r--r-- | include/channel.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/include/channel.php b/include/channel.php index 2284b3004..50cc90178 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2323,3 +2323,70 @@ function channel_codeallowed($channel_id) { return false; } + +function anon_identity_init($reqvars) { + + $x = [ 'request_vars' => $reqvars, 'xchan' => null, 'success' => 'unset' ]; + call_hooks('anon_identity_init',$x); + if($x['success'] !== 'unset' && intval($x['success']) && $x['xchan']) + return $x['xchan']; + + // allow a captcha handler to over-ride + if($x['success'] !== 'unset' && (intval($x['success']) === 0)) + return false; + + + $anon_name = strip_tags(trim($reqvars['anonname'])); + $anon_email = strip_tags(trim($reqvars['anonmail'])); + $anon_url = strip_tags(trim($reqvars['anonurl'])); + + if(! ($anon_name && $anon_email)) { + logger('anonymous commenter did not complete form'); + return false; + } + + if(! validate_email($anon_email)) { + logger('enonymous email not valid'); + return false; + } + + if(! $anon_url) + $anon_url = z_root(); + + $x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' limit 1", + dbesc($anon_email), + dbesc($anon_email) + ); + + if(! $x) { + xchan_store_lowlevel([ + 'xchan_guid' => $anon_email, + 'xchan_hash' => $anon_email, + 'xchan_name' => $anon_name, + 'xchan_url' => $anon_url, + 'xchan_network' => 'unknown', + 'xchan_name_date' => datetime_convert() + ]); + + $x = q("select * from xchan where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' limit 1", + dbesc($anon_email), + dbesc($anon_email) + ); + + $photo = z_root() . '/' . get_default_profile_photo(300); + $photos = import_xchan_photo($photo,$anon_email); + $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_guid = '%s' and xchan_hash = '%s' and xchan_network = 'unknown' ", + dbesc(datetime_convert()), + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc($photos[3]), + dbesc($anon_email), + dbesc($anon_email) + ); + + } + + return $x[0]; + +} |