aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php1
-rw-r--r--mod/zregister.php219
-rw-r--r--version.inc2
-rw-r--r--view/theme/duepuntozero/style.css21
-rw-r--r--view/zregister.tpl45
5 files changed, 287 insertions, 1 deletions
diff --git a/boot.php b/boot.php
index ab34b37f8..a9da0eee5 100644
--- a/boot.php
+++ b/boot.php
@@ -352,6 +352,7 @@ function startup() {
if(! class_exists('App')) {
class App {
+ public $account;
public $module_loaded = false;
public $query_string;
public $config;
diff --git a/mod/zregister.php b/mod/zregister.php
new file mode 100644
index 000000000..e55c9f5ba
--- /dev/null
+++ b/mod/zregister.php
@@ -0,0 +1,219 @@
+<?php
+
+if(! function_exists('register_post')) {
+function register_post(&$a) {
+
+ global $lang;
+
+ $verified = 0;
+ $blocked = 1;
+
+ $arr = array('post' => $_POST);
+ call_hooks('register_post', $arr);
+
+ $max_dailies = intval(get_config('system','max_daily_registrations'));
+ if($max_dailies) {
+ $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
+ if($r && $r[0]['total'] >= $max_dailies) {
+ return;
+ }
+ }
+
+ switch($a->config['register_policy']) {
+
+
+ case REGISTER_OPEN:
+ $blocked = 0;
+ $verified = 1;
+ break;
+
+ case REGISTER_APPROVE:
+ $blocked = 1;
+ $verified = 0;
+ break;
+
+ default:
+ case REGISTER_CLOSED:
+ if((! x($_SESSION,'authenticated') && (! x($_SESSION,'administrator')))) {
+ notice( t('Permission denied.') . EOL );
+ return;
+ }
+ $blocked = 1;
+ $verified = 0;
+ break;
+ }
+
+ require_once('include/user.php');
+
+ $arr = $_POST;
+
+ $arr['blocked'] = $blocked;
+ $arr['verified'] = $verified;
+
+ $result = create_user($arr);
+
+ if(! $result['success']) {
+ notice($result['message']);
+ return;
+ }
+
+ $user = $result['user'];
+
+ if($netpublish && $a->config['register_policy'] != REGISTER_APPROVE) {
+ $url = $a->get_baseurl() . '/profile/' . $user['nickname'];
+ proc_run('php',"include/directory.php","$url");
+ }
+
+ $using_invites = get_config('system','invitation_only');
+ $num_invites = get_config('system','number_invites');
+ $invite_id = ((x($_POST,'invite_id')) ? notags(trim($_POST['invite_id'])) : '');
+
+
+ if( $a->config['register_policy'] == REGISTER_OPEN ) {
+
+ if($using_invites && $invite_id) {
+ q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
+ set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
+ }
+
+ $email_tpl = get_intltext_template("register_open_eml.tpl");
+ $email_tpl = replace_macros($email_tpl, array(
+ '$sitename' => $a->config['sitename'],
+ '$siteurl' => $a->get_baseurl(),
+ '$username' => $user['username'],
+ '$email' => $user['email'],
+ '$password' => $result['password'],
+ '$uid' => $user['uid'] ));
+
+ $res = mail($user['email'], sprintf(t('Registration details for %s'), $a->config['sitename']),
+ $email_tpl,
+ 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
+ . 'Content-type: text/plain; charset=UTF-8' . "\n"
+ . 'Content-transfer-encoding: 8bit' );
+
+
+ if($res) {
+ info( t('Registration successful. Please check your email for further instructions.') . EOL ) ;
+ goaway(z_root());
+ }
+ else {
+ notice( t('Failed to send email message. Here is the message that failed.') . $email_tpl . EOL );
+ }
+ }
+ elseif($a->config['register_policy'] == REGISTER_APPROVE) {
+ if(! strlen($a->config['admin_email'])) {
+ notice( t('Your registration can not be processed.') . EOL);
+ goaway(z_root());
+ }
+
+ $hash = random_string();
+ $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language` ) VALUES ( '%s', '%s', %d, '%s', '%s' ) ",
+ dbesc($hash),
+ dbesc(datetime_convert()),
+ intval($user['uid']),
+ dbesc($result['password']),
+ dbesc($lang)
+ );
+
+ $r = q("SELECT `language` FROM `user` WHERE `email` = '%s' LIMIT 1",
+ dbesc($a->config['admin_email'])
+ );
+ if(count($r))
+ push_lang($r[0]['language']);
+ else
+ push_lang('en');
+
+ if($using_invites && $invite_id) {
+ q("delete * from register where hash = '%s' limit 1", dbesc($invite_id));
+ set_pconfig($user['uid'],'system','invites_remaining',$num_invites);
+ }
+
+ $email_tpl = get_intltext_template("register_verify_eml.tpl");
+ $email_tpl = replace_macros($email_tpl, array(
+ '$sitename' => $a->config['sitename'],
+ '$siteurl' => $a->get_baseurl(),
+ '$username' => $user['username'],
+ '$email' => $user['email'],
+ '$password' => $result['password'],
+ '$uid' => $user['uid'],
+ '$hash' => $hash
+ ));
+
+ $res = mail($a->config['admin_email'], sprintf(t('Registration request at %s'), $a->config['sitename']),
+ $email_tpl,
+ 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
+ . 'Content-type: text/plain; charset=UTF-8' . "\n"
+ . 'Content-transfer-encoding: 8bit' );
+
+ pop_lang();
+
+ if($res) {
+ info( t('Your registration is pending approval by the site owner.') . EOL ) ;
+ goaway(z_root());
+ }
+
+ }
+
+ return;
+}}
+
+
+
+
+
+
+
+function zregister_content(&$a) {
+
+
+ if((! local_user()) && ($a->config['register_policy'] == REGISTER_CLOSED)) {
+ notice("Permission denied." . EOL);
+ return;
+ }
+
+ $max_dailies = intval(get_config('system','max_daily_registrations'));
+ if($max_dailies) {
+ $r = q("select count(*) as total from account where account_created > UTC_TIMESTAMP - INTERVAL 1 day");
+ if($r && $r[0]['total'] >= $max_dailies) {
+ logger('max daily registrations exceeded.');
+ notice( t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
+ return;
+ }
+ }
+
+
+ $email = ((x($_REQUEST,'email')) ? $_REQUEST['email'] : "" );
+ $password = ((x($_REQUEST,'password')) ? $_REQUEST['password'] : "" );
+ $password2 = ((x($_REQUEST,'password2')) ? $_REQUEST['password2'] : "" );
+ $invite_code = ((x($_REQUEST,'invite_code')) ? $_REQUEST['invite_code'] : "" );
+
+ $tosurl = get_config('system','tos_url');
+ if(! $tosurl)
+ $tosurl = $a->get_baseurl() . '/help/TOS';
+
+ $toslink = '<a href="' . $tosurl . '" >' . t('Terms of Service') . '</a>';
+
+ $o = replace_macros(get_markup_template('zregister.tpl'), array(
+
+ '$title' => t('Registration'),
+ '$registertext' => get_config('system','register_text'),
+ '$invitations' => get_config('system','invitation_only'),
+ '$invite_desc' => t('Membership on this site is by invitation only.'),
+ '$label_invite' => t('Please enter your invitation code'),
+ '$invite_id' => $invite_id,
+
+ '$label_email' => t('Your email address'),
+ '$label_pass1' => t('Choose a password'),
+ '$label_pass2' => t('Please re-enter your password'),
+ '$label_tos' => sprintf( t('I have read and accept the %s for this website'), $toslink),
+
+ '$email' => $email,
+ '$pass1' => $password,
+ '$pass2' => $password2,
+ '$submit' => t('Register')
+ ));
+
+ return $o;
+
+}
+
diff --git a/version.inc b/version.inc
index 42dd2d535..4441bb0e1 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2012-07-20.21
+2012-07-21.22
diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css
index c804c63b5..2e1c45fbf 100644
--- a/view/theme/duepuntozero/style.css
+++ b/view/theme/duepuntozero/style.css
@@ -3304,4 +3304,25 @@ ul.menu-popup {
position: relative;
left: 5%;
width: 90%;
+}
+
+
+#zregister-form {
+ font-size: 1.4em;
+}
+
+.zregister-label {
+ float: left;
+ width: 275px;
+}
+
+.zregister-input {
+ float: left;
+ width: 275px;
+ padding: 5px;
+}
+
+.zregister-field-end {
+ clear: both;
+ margin-bottom: 20px;
} \ No newline at end of file
diff --git a/view/zregister.tpl b/view/zregister.tpl
new file mode 100644
index 000000000..35415eae5
--- /dev/null
+++ b/view/zregister.tpl
@@ -0,0 +1,45 @@
+<h2>$title</h2>
+
+<form action="zregister" method="post" id="zregister-form">
+
+{{ if $registertext }}
+<div id="zregister-desc" class="descriptive-paragraph">$registertext</div>
+{{ endif }}
+
+{{ if $invitations }}
+ <p id="register-invite-desc">$invite_desc</p>
+
+ <label for="zregister-invite" id="label-zregister-invite" class="zregister-label">$label_invite</label>
+ <input type="text" maxlength="72" size="32" name="invite_id" id="zregister-invite" class="zregister-input" value="$invite_id" >
+ </div>
+ <div id="zregister-invite-feedback" class="zregister-feedback"></div>
+ <div id="zregister-invite-end" class="zregister-field-end"></div>
+
+{{ endif }}
+
+
+ <label for="zregister-email" id="label-zregister-email" class="zregister-label" >$label_email</label>
+ <input type="text" maxlength="72" size="32" name="email" id="zregister-email" class="zregister-input" value="$email" >
+ <div id="zregister-email-feedback" class="zregister-feedback"></div>
+ <div id="zregister-email-end" class="zregister-field-end"></div>
+
+ <label for="zregister-password" id="label-zregister-password" class="zregister-label" >$label_pass1</label>
+ <input type="text" maxlength="72" size="32" name="password" id="zregister-password" class="zregister-input" value="$pass1" >
+ <div id="zregister-password-feedback" class="zregister-feedback"></div>
+ <div id="zregister-password-end" class="zregister-field-end"></div>
+
+ <label for="zregister-password2" id="label-zregister-password2" class="zregister-label" >$label_pass2</label>
+ <input type="text" maxlength="72" size="32" name="password2" id="zregister-password2" class="zregister-input" value="$pass2" >
+ <div id="zregister-password2-feedback" class="zregister-feedback"></div>
+ <div id="zregister-password2-end" class="zregister-field-end"></div>
+
+
+ <input type="checkbox" name="tos" id="zregister-tos" value="1" >
+ <label for="zregister-tos" id="label-zregister-tos">$label_tos</label>
+ <div id="zregister-tos-feedback" class="zregister-feedback"></div>
+ <div id="zregister-tos-end" class="zregister-field-end"></div>
+
+ <input type="submit" name="submit" id="zregister-submit-button" value="$submit" />
+ <div id="zregister-submit-end" class="zregister-field-end"></div>
+
+</form>