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['author'])) { return; } if (!isset($_POST['parent'])) { 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; } // Body // $body = $_POST['body']; // TODO: Sanitize // Relationships // $author = intval($_POST['author']); $parent = intval($_POST['parent']); // Do we publish? // $publish = mb_strtolower($_POST['publish']) == "true"; $id = node_Add($type, $subtype, $slug, $name, $body, $author, $parent, $publish); echo "Added " . $id . ".<br />"; echo "<br />"; } }
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 />"; } }