aboutsummaryrefslogtreecommitdiffstats
path: root/mod/zentity.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-07-30 21:51:25 -0700
committerfriendica <info@friendica.com>2012-07-30 21:51:25 -0700
commit65160ffd12500260ffd723bcffe721a3cc38d7da (patch)
tree334d60dccab197ebf64f1092222f65ba42ae8c75 /mod/zentity.php
parent02cc436ec7cf0cfca5fc9b5166cc537bbee53671 (diff)
downloadvolse-hubzilla-65160ffd12500260ffd723bcffe721a3cc38d7da.tar.gz
volse-hubzilla-65160ffd12500260ffd723bcffe721a3cc38d7da.tar.bz2
volse-hubzilla-65160ffd12500260ffd723bcffe721a3cc38d7da.zip
functions to generate and check webbies interactively
Diffstat (limited to 'mod/zentity.php')
-rw-r--r--mod/zentity.php71
1 files changed, 62 insertions, 9 deletions
diff --git a/mod/zentity.php b/mod/zentity.php
index 32170a642..4963d7190 100644
--- a/mod/zentity.php
+++ b/mod/zentity.php
@@ -7,22 +7,75 @@ function zentity_init(&$a) {
$cmd = ((argc() > 1) ? argv(1) : '');
- if($cmd === 'email_check.json') {
+ if($cmd === 'autofill.json') {
+ require_once('library/urlify/URLify.php');
$result = array('error' => false, 'message' => '');
- $email = $_REQUEST['email'];
+ $n = trim($_REQUEST['name']);
- if(! allowed_email($email))
- $result['message'] = t('Your email domain is not among those allowed on this site');
- if((! valid_email($email)) || (! validate_email($email)))
- $result['message'] .= t('Not a valid email address') . EOL;
- if($result['message'])
- $result['error'] = true;
+ $x = strtolower(URLify::transliterate($n));
+
+ $test = array();
+
+ // first name
+ $test[] = legal_webbie(substr($x,0,strpos($x,' ')));
+ if($test[0]) {
+ // first name plus first initial of last
+ $test[] = ((strpos($x,' ')) ? $test[0] . legal_webbie(trim(substr($x,strpos($x,' '),2))) : '');
+ // first name plus random number
+ $test[] = $test[0] . mt_rand(1000,9999);
+ }
+ // fullname
+ $test[] = legal_webbie($x);
+ // fullname plus random number
+ $test[] = legal_webbie($x) . mt_rand(1000,9999);
+
+ header('content-type: application/json');
+ echo json_encode(check_webbie($test));
+ killme();
+ }
+
+ if($cmd === 'checkaddr.json') {
+ require_once('library/urlify/URLify.php');
+ $result = array('error' => false, 'message' => '');
+ $n = trim($_REQUEST['addr']);
+
+ $x = strtolower(URLify::transliterate($n));
+
+ $test = array();
+
+ $n = legal_webbie($x);
+ if(strlen($n)) {
+ $test[] = $n;
+ $test[] = $n . mt_rand(1000,9999);
+ }
+
+ for($y = 0; $y < 100; $y ++)
+ $test[] = 'id' . mt_rand(1000,9999);
+
+//print_r($test);
header('content-type: application/json');
- echo json_encode($result);
+ echo json_encode(check_webbie($test));
killme();
}
+
+
+
+// print_r($test);
+
+// if(! allowed_email($email))
+// $result['message'] = t('Your email domain is not among those allowed on this site');
+// if((! valid_email($email)) || (! validate_email($email)))
+// $result['message'] .= t('Not a valid email address') . EOL;
+// if($result['message'])
+// $result['error'] = true;
+
+// header('content-type: application/json');
+// echo json_encode($result);
+// killme();
+
+
$pw1 = t("Password too short");
$pw2 = t("Passwords do not match");