/** * Standard function. */ function dh_fpp_helper($args) { $file_name = dirname(__FILE__) . '/dhfpp_' . escape_value($args['order_id'], 'file_name') . '.php'; $function_name = 'fpp_' . $args['order_id']; if (file_exists($file_name)) { include_once $file_name; } if (function_exists($function_name)) { return $function_name($args); } elseif (is_dev_mode()) { sys_notify('Unrecognized task was encountered by dh_fpp_helper.', 'warning'); return FALSE; } }
<?php require_once 'includes/initialize.php'; $user_id = escape_value(get_user_id()); $sql = "SELECT id, profilename FROM users"; $users = $mysqli->query($sql); while ($user = $users->fetch_object()) { if ($user->id == $user_id) { $user_name = $user->profilename; break; } } if (!isset($user_name)) { redirect_to("logout.php"); } ?> <!doctype html> <html> <head> <meta charset="utf-8" /> <title>Home Page</title> </head> <body> <h1>Home Page</h1> <h2>Welcome, <?php echo $user_name; ?> </h2> <button type="button" value="Logout" onClick="window.location= 'logout.php'">Click2Logout</button> </body> </html>
function build_function_def($name, $return, $args, $flags = DefaultFlags) { $fargs = array(); $have_first_optional = false; $required_arg_count = 0; foreach ($args as $arg_name => $arg) { $farg = array('name' => strtolower($arg_name)); if (is_array($arg)) { $farg['type'] = $arg[0]; if (!is_string($arg[1]) || $arg[1] === '') { die('default value needs to be a non-empty string for ' . $name . '(..' . $arg_name . '..)'); } $default = $arg[1]; $farg['default'] = $default; $default = escape_value($default); $farg['default_escaped'] = $default; } else { $farg['type'] = $arg; } if ($farg['type'] & Optional) { $have_first_optional = true; } else { ++$required_arg_count; if ($have_first_optional) { die('Required parameters cannot follow optional parameters (function ' . $name . ', param ' . $arg_name . ')'); } } if ($farg['type'] & Reference) { $farg['ref'] = true; $farg['type'] = Variant | $farg['type'] & ~TypeMask; } $fargs[] = $farg; } $func = array('name' => strtolower($name), 'return' => $return, 'args' => $fargs, 'required_args' => $required_arg_count, 'flags' => $flags); if ($return & Reference) { $func['ref'] = true; $func['return'] = Variant; } return $func; }
<?php require_once 'includes/initialize.php'; // Var for error messages $message = ""; if (isset($_POST['submit']) && isset($_POST['username']) && isset($_POST['password'])) { // Login form submitted if (!empty($_POST['username']) && !empty($_POST['password'])) { // Login fields are submitted // Setting form submitted data to vars $username = escape_value($_POST['username']); $password = escape_value($_POST['password']); $sql = "SELECT * FROM users "; $users = mysqli_query($mysqli, $sql); while ($user = $users->fetch_object()) { if ($username == $user->username & md5($password) == $user->password) { // Matching form input with DB values $login_successful = true; login_user($user->id); } } if (!isset($login_successful)) { // We never let the user know if the username matched or not so we check both at the same time $message .= "Please check the spelling of the username and the password<br />"; $message .= "Note that the password is case-sensitive"; } } else { $message .= "Please fill in all form fields"; } } ?>