public function validate_and_configure_new_user() { if (strlen($this->DATA["EMail"]) > 0) { $func_out = validate_EMail($this->DATA["EMail"]); if ($func_out != 100) { return $func_out; } } if (strlen($this->DATA["PhoneNumber"]) > 0) { list($fun_out, $this->DATA["PhoneNumber"]) = validate_PhoneNumber($this->DATA["PhoneNumber"]); if ($func_out != 100) { return $func_out; } } if (strlen($this->DATA["Password"]) > 0) { $this->DATA["Salt"] = md5(rand(1, 999) . microtime() / rand(1, 999) . rand(1, 999)); $this->DATA["PasswordHash"] = md5($this->DATA["Password"] . $this->DATA["Salt"]); return true; } else { return "Please provide a Password"; } }
<?php /*********************************************** DAVE PHP API https://github.com/evantahler/PHP-DAVE-API Evan Tahler | 2011 I am an example function to Edit a user ***********************************************/ // do some special input filtering if (strlen($PARAMS["EMail"]) > 0 && $ERROR == 100) { $func_out = validate_EMail($PARAMS["EMail"]); if ($func_out != 100) { $ERROR = $func_out; } } if ($ERROR == 100 && strlen($PARAMS["PhoneNumber"]) > 0) { list($func_out, $PARAMS["PhoneNumber"]) = validate_PhoneNumber($PARAMS["PhoneNumber"]); if ($func_out != 100) { $ERROR = $func_out; } } if ($ERROR == 100) { $AuthResp = AuthenticateUser(); if ($AuthResp[0] !== true) { $ERROR = $AuthResp[1]; } else { list($msg, $ReturnedUsers) = _VIEW("users", array("UserID" => $PARAMS['UserID'], "ScreenName" => $PARAMS['ScreenName'], "EMail" => $PARAMS['EMail'])); if ($msg == false) { $ERROR = $ReturnedUsers; } elseif (count($ReturnedUsers) == 1) {