YaWK  24.1
Yet another WebKit
signup.php
Go to the documentation of this file.
1 <script type="text/javascript" src="system/engines/jquery/jquery.validate.min.js"></script>
2 <script type="text/javascript" src="system/engines/jquery/messages_en.min.js"></script>
3 <script type="text/javascript" src="system/engines/jquery/notify/bootstrap-notify.min.js"></script>
4 <!-- <script type="text/javascript" src="system/plugins/signup/js/signup.js"></script> !-->
5 <link rel="stylesheet" href="system/engines/animateCSS/animate.min.css">
6 <?php
7 /** SIGNUP PLUGIN */
8 require_once 'system/plugins/signup/classes/signup.php';
9 require_once 'system/classes/backend.php';
10 $signup = new \YAWK\PLUGINS\SIGNUP\signup();
11 // if settings update is sent from frontend
12 if (isset($_POST['settings-update']) && $_POST['settings-update'] === '1')
13 { // check if user id is sent
14  if (isset($_POST['uid']) && is_numeric($_POST['uid']))
15  { // user id is set, datatype seems to be correct,
16  foreach ($_POST as $property => $value)
17  { // process every property in a loop
18  $value = \YAWK\sys::encodeChars($value); // encode chars (&Ouml, &Auml...)
19  if ($property != "settings-update"
20  && ($property != "sent")
21  && ($property != "submit")
22  && ($property != "newUsername")
23  && ($property != "profile-update")
24  && ($property != "newEmail")
25  && ($property != "newPassword1")
26  && ($property != "newPassword2")
27  && (!empty($value)))
28  { // set new user property
29  // echo "<h1>$property <small>$value</small></h1>";
30  \YAWK\user::setProperty($db, $_POST['uid'], $property, $value);
31  }
32  // store new user password
33  else if ($property = "newPassword2")
34  { // if a new paswword is set
35  if (!empty($_POST['newPassword2']))
36  { // if it's not empty
37  $newPassword = $db->quote($_POST['newPassword2']);
38  // create a new md5'ed password
39  \YAWK\user::setProperty($db, $_POST['uid'], "password", md5($newPassword));
40  }
41  }
42  // store new user password
43  else if ($property = "newEmail")
44  { // if a new paswword is set
45  if (!empty($_POST['newEmail']))
46  { // if it's not empty
47  $newEmail = $db->quote($_POST['newEmail']);
48  // create a new md5'ed password
49  \YAWK\user::setProperty($db, $_POST['uid'], "email", $newEmail);
50  }
51  }
52  // store new user password
53  else if ($property = "newUsername")
54  { // if a new paswword is set
55  if (!empty($_POST['newUsername']))
56  { // if it's not empty
57  $newUsername = $db->quote($_POST['newUsername']);
58  // create a new md5'ed password
59  \YAWK\user::setProperty($db, $_POST['uid'], "username", $newUsername);
60  }
61  }
62  // store privacy settings
63  else if ($property = "privacy")
64  { // if a new paswword is set
65  if (!empty($_POST['privacy']))
66  { // if it's not empty
67  $privacy = $db->quote($_POST['privacy']);
68  \YAWK\user::setProperty($db, $_POST['uid'], "privacy", $privacy);
69  }
70  }
71  // store new user password
72  else if ($property = "public_email")
73  { // if a new paswword is set
74  if (!empty($_POST['public_email']))
75  { // if it's not empty
76  $publicEmail = $db->quote($_POST['public_email']);
77  \YAWK\user::setProperty($db, $_POST['uid'], "public_email", $publicEmail);
78  }
79  }
80  }
81  }
82  else
83  { // user id is not set or type is not numeric...
85  \YAWK\alert::draw("danger", "Error", "Could not update user settings because User ID is missing or wrong type.", "","");
86  echo $signup->sayHello($db);
87  }
88 } // ./ if settings-update === true
89 
90 // if form is sent
91 if (isset($_POST['sent']) && $_POST['sent'] === '1')
92 {
93  // prepare vars
94  $username = $db->quote($_POST['username']);
95  $password1 = $db->quote($_POST['password1']);
96  $password2 = $db->quote($_POST['password2']);
97  $email = $db->quote($_POST['email']);
98 
99  if (isset($_POST['gid']))
100  { // if user is allowed to select user group
101  $gid = $_POST['gid'];
102  }
103  else
104  { // get default user group id from settings
105  $gid = \YAWK\settings::getSetting($db, "signup_defaultgid");
106  if (empty($gid))
107  { // could not fetch group id, throw error
108  \YAWK\alert::draw("warning", "Warning!", "Error fetching group ID settings. Default Group set to 2","","");
109  $gid = 2;
110  }
111  }
112  // execute create user function
113  if(\YAWK\user::createFromFrontend($db, $username, $password1, $password2, $email, $gid))
114  { // draw thank you page...
115  // \YAWK\backend::drawContentWrapper();
116  echo "<div style='text-align: center; margin-top: 20%; margin-bottom: 600px;'>
117  <h1>Hello ".$username."!<br><small>Thank you for your registration.</small></h1>
118  <p>Please, feel free to instant login! <br>";
119  echo \YAWK\user::drawLoginBox($username, $password1);
120  }
121  else
122  { // create user failed, so throw error
123  // YAWK\backend::drawContentWrapper();
124  print \YAWK\alert::draw("danger", "Fehler!", "The User <strong>".$username."</strong> could not be registered!","","");
125  // and display user registration form again...
126  echo $signup->sayHello($db);
127  }
128 }
129 else
130 { // default view:
131  // draw user signup form
132  // \YAWK\backend::drawContentWrapper();
133  echo $signup->sayHello($db);
134 }
static draw($type, $title, $text, $redirect, $delay)
Definition: alert.php:30
static drawContentWrapper()
Draw the AdminLTE Content Wrapper. Useful that view dont crash in situations where the DOM is not loa...
Definition: backend.php:144
static getSetting($db, $property)
Get and return value for property from settings database.
Definition: settings.php:470
static encodeChars($string)
convert german special chars and vowels into legal html
Definition: sys.php:1089
type
Definition: menu-new.php:35
This class serves methods to create backup from files.
Definition: AdminLTE.php:2
$signup
Definition: signup.php:10
$gid
Definition: user-new.php:104
$password2
Definition: user-new.php:93
$password1
Definition: user-new.php:92
$email
Definition: user-new.php:94
$value