function main() { if ($_SERVER['REQUEST_METHOD'] === 'POST') { print_r($_POST); echo "<br />"; // Required Fields in the POST data // if (!isset($_POST['_type'])) { return; } if (!isset($_POST['_subtype'])) { return; } if (!isset($_POST['_name'])) { return; } if (!isset($_POST['_mail'])) { return; } if (!isset($_POST['_password'])) { return; } if (!isset($_POST['_publish'])) { return; } // Node Type // $type = sanitize_NodeType($_POST['_type']); if (empty($type)) { return; } $subtype = sanitize_NodeType($_POST['_subtype']); // Name/Title // $name = $_POST['_name']; // TODO: Sanitize // Slug // if (empty($_POST['_slug'])) { $slug = $_POST['_name']; } else { $slug = $_POST['_slug']; } $slug = sanitize_Slug($slug); if (empty($slug)) { return; } // TODO: Confirm slug is legal // Body // $body = $_POST['_body']; // TODO: Sanitize // Do we publish? // $publish = mb_strtolower($_POST['_publish']) == "true"; // Email // $mail = sanitize_Email($_POST['_mail']); if (empty($mail)) { return; } // Password // $password = $_POST['_password']; if (empty($password)) { return; } $id = node_Add($type, $subtype, $slug, $name, $body, 0, 2, $publish); user_Add($id, $mail, $password); echo "Added " . $id . ".<br />"; echo "<br />"; } }
if (isset($_POST['mail'])) { $mail = coreSanitize_Mail($_POST['mail']); } else { json_EmitFatalError_BadRequest("'mail' not found in POST", $RESPONSE); } $RESPONSE['mail'] = $mail; // Is the email provided even a valid e-mail address? if (!coreValidate_Mail($mail)) { json_EmitFatalError_BadRequest("Invalid e-mail address", $RESPONSE); } /// @todo Add e-mail blacklist checking here // Is the email provided one that is allowed to create a new account? if (user_CountByMail($mail) || plugin_Call('api_user_create_mail_allowed', $mail)) { json_EmitFatalError_Server("Address unavailable", $RESPONSE); } else { $user = user_Add($mail); if ($user) { // NOTE! YOU SHOULD NOT DO THIS! IT DEFEATS THE EMAIL CHECK! $RESPONSE['id'] = $user['id']; $RESPONSE['key'] = $user['auth_key']; // Send an e-mail $RESPONSE['sent'] = intval(sendMail_UserAdd($user['id'], $mail, $user['auth_key'])); // Successfully Created. json_RespondCreated(); } else { json_EmitFatalError_Server(null, $RESPONSE); } } break; // Fully activate a user // Fully activate a user