Phone number support
This commit is contained in:
parent
c41c2c2383
commit
c650e561cf
|
@ -1,8 +1,9 @@
|
|||
<?php
|
||||
require 'core.php';
|
||||
use Spatie\ArrayToXml\ArrayToXml;
|
||||
|
||||
init_class(false);
|
||||
use Brick\PhoneNumber\PhoneNumber;
|
||||
use Brick\PhoneNumber\PhoneNumberFormat;
|
||||
use Brick\PhoneNumber\PhoneNumberParseException;
|
||||
|
||||
$user_info = [];
|
||||
|
||||
|
@ -94,9 +95,19 @@ $dispatcher = FastRoute\simpleDispatcher(
|
|||
$driver = isset($_POST["driver"]) ? $_POST["driver"]==1 : false;
|
||||
$hidden = isset($_POST["hidden"]) ? $_POST["hidden"]==1 : false;
|
||||
$disabled = isset($_POST["disabled"]) ? $_POST["disabled"]==1 : false;
|
||||
if(isset($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"])) {
|
||||
if(isset($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["phone_number"], $_POST["birthday"])) {
|
||||
try {
|
||||
$phone_number = PhoneNumber::parse($_POST["phone_number"]);
|
||||
if (!$phone_number->isValidNumber()) {
|
||||
return ["status" => "error", "message" => "Bad phone number"];
|
||||
} else {
|
||||
$phone_number = $phone_number->format(PhoneNumberFormat::E164);
|
||||
}
|
||||
} catch (PhoneNumberParseException $e) {
|
||||
return ["status" => "error", "message" => "Bad phone number"];
|
||||
}
|
||||
try{
|
||||
$userId = $user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"], $chief, $driver, $hidden, $disabled, $user_info["id"]);
|
||||
$userId = $user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $phone_number, $_POST["birthday"], $chief, $driver, $hidden, $disabled, $user_info["id"]);
|
||||
} catch (\Delight\Auth\InvalidEmailException $e) {
|
||||
return ["status" => "error", "message" => "Invalid email address"];
|
||||
} catch (\Delight\Auth\InvalidPasswordException $e) {
|
||||
|
@ -170,34 +181,36 @@ $uri = rawurldecode($uri);
|
|||
|
||||
// Get response format
|
||||
if (isset($_GET["xml"])) {
|
||||
$response = "xml";
|
||||
$responseType = "application/xml";
|
||||
$responseFormat = "xml";
|
||||
$responseFormatType = "application/xml";
|
||||
} else if (isset($_GET["json"])) {
|
||||
$response = "json";
|
||||
$responseType = "application/json";
|
||||
$responseFormat = "json";
|
||||
$responseFormatType = "application/json";
|
||||
} else if (false !== strpos($uri, 'xml')) {
|
||||
$response = "xml";
|
||||
$responseType = "application/xml";
|
||||
$responseFormat = "xml";
|
||||
$responseFormatType = "application/xml";
|
||||
$uri = str_replace(".xml", "", $uri);
|
||||
} else if (false !== strpos($uri, 'json')) {
|
||||
$response = "json";
|
||||
$responseType = "application/json";
|
||||
$responseFormat = "json";
|
||||
$responseFormatType = "application/json";
|
||||
$uri = str_replace(".json", "", $uri);
|
||||
} else {
|
||||
$response = "json";
|
||||
$responseType = "application/json";
|
||||
$responseFormat = "json";
|
||||
$responseFormatType = "application/json";
|
||||
}
|
||||
|
||||
header("Content-type: ".$responseFormatType);
|
||||
init_class(false); //initialize classes (and Tracy) after Content-type header
|
||||
|
||||
$routeInfo = $dispatcher->dispatch($httpMethod, $uri);
|
||||
|
||||
function responseApi($content, $status_code=200)
|
||||
{
|
||||
global $response, $responseType;
|
||||
global $responseFormat, $responseFormatType;
|
||||
if($status_code !== 200) {
|
||||
http_response_code($status_code);
|
||||
}
|
||||
header("Content-type: ".$responseType);
|
||||
if($response == "json") {
|
||||
if($responseFormat == "json") {
|
||||
echo(json_encode($content));
|
||||
} else {
|
||||
echo(ArrayToXml::convert($content));
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
"nikic/fast-route": "^2.0@dev",
|
||||
"spatie/array-to-xml": "^2.16",
|
||||
"ezyang/htmlpurifier": "^4.13",
|
||||
"netpromotion/profiler": "^1.3"
|
||||
"netpromotion/profiler": "^1.3",
|
||||
"brick/phonenumber": "^0.2.2"
|
||||
},
|
||||
"license": "GPL-3.0-or-later",
|
||||
"authors": [
|
||||
|
|
|
@ -4,8 +4,53 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a08da53d92ef70a673e30865170c49a0",
|
||||
"content-hash": "6d344201550b8148fe93819367e4bfb4",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/phonenumber",
|
||||
"version": "0.2.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/brick/phonenumber.git",
|
||||
"reference": "8bce37b0a4e569bae773fc2a254892acd0eb05d1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/brick/phonenumber/zipball/8bce37b0a4e569bae773fc2a254892acd0eb05d1",
|
||||
"reference": "8bce37b0a4e569bae773fc2a254892acd0eb05d1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"giggsey/libphonenumber-for-php": "7.* || 8.*",
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"php-coveralls/php-coveralls": "2.*",
|
||||
"phpunit/phpunit": "7.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Brick\\PhoneNumber\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Phone number library",
|
||||
"keywords": [
|
||||
"brick",
|
||||
"phone",
|
||||
"phone number",
|
||||
"phonenumber"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/brick/phonenumber/issues",
|
||||
"source": "https://github.com/brick/phonenumber/tree/master"
|
||||
},
|
||||
"time": "2020-02-06T21:38:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "delight-im/auth",
|
||||
"version": "v8.2.2",
|
||||
|
@ -45,6 +90,10 @@
|
|||
"login",
|
||||
"security"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/delight-im/PHP-Auth/issues",
|
||||
"source": "https://github.com/delight-im/PHP-Auth/tree/v8.2.2"
|
||||
},
|
||||
"time": "2020-09-30T18:40:54+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -86,6 +135,10 @@
|
|||
"encoding",
|
||||
"url"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/delight-im/PHP-Base64/issues",
|
||||
"source": "https://github.com/delight-im/PHP-Base64/tree/master"
|
||||
},
|
||||
"time": "2017-07-24T18:59:51+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -127,6 +180,10 @@
|
|||
"samesite",
|
||||
"xss"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/delight-im/PHP-Cookie/issues",
|
||||
"source": "https://github.com/delight-im/PHP-Cookie/tree/v3.4.0"
|
||||
},
|
||||
"time": "2020-04-16T11:01:26+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -168,6 +225,10 @@
|
|||
"sql",
|
||||
"sqlite"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/delight-im/PHP-DB/issues",
|
||||
"source": "https://github.com/delight-im/PHP-DB/tree/v1.3.1"
|
||||
},
|
||||
"time": "2020-02-21T10:46:03+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -204,6 +265,10 @@
|
|||
"http",
|
||||
"https"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/delight-im/PHP-HTTP/issues",
|
||||
"source": "https://github.com/delight-im/PHP-HTTP/tree/v2.0.0"
|
||||
},
|
||||
"time": "2016-07-21T15:05:01+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -254,8 +319,138 @@
|
|||
"keywords": [
|
||||
"html"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/ezyang/htmlpurifier/issues",
|
||||
"source": "https://github.com/ezyang/htmlpurifier/tree/master"
|
||||
},
|
||||
"time": "2020-06-29T00:56:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "giggsey/libphonenumber-for-php",
|
||||
"version": "8.12.15",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/giggsey/libphonenumber-for-php.git",
|
||||
"reference": "c1f328bface2745ff1a292639dd68cafc673a456"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/giggsey/libphonenumber-for-php/zipball/c1f328bface2745ff1a292639dd68cafc673a456",
|
||||
"reference": "c1f328bface2745ff1a292639dd68cafc673a456",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"giggsey/locale": "^1.7",
|
||||
"php": ">=5.3.2",
|
||||
"symfony/polyfill-mbstring": "^1.17"
|
||||
},
|
||||
"require-dev": {
|
||||
"pear/pear-core-minimal": "^1.9",
|
||||
"pear/pear_exception": "^1.0",
|
||||
"pear/versioncontrol_git": "^0.5",
|
||||
"phing/phing": "^2.7",
|
||||
"php-coveralls/php-coveralls": "^1.0|^2.0",
|
||||
"symfony/console": "^2.8|^3.0",
|
||||
"symfony/phpunit-bridge": "^4.2 || ^5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"libphonenumber\\": "src/"
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/src/data/",
|
||||
"/src/carrier/data/",
|
||||
"/src/geocoding/data/",
|
||||
"/src/timezone/data/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joshua Gigg",
|
||||
"email": "giggsey@gmail.com",
|
||||
"homepage": "https://giggsey.com/"
|
||||
}
|
||||
],
|
||||
"description": "PHP Port of Google's libphonenumber",
|
||||
"homepage": "https://github.com/giggsey/libphonenumber-for-php",
|
||||
"keywords": [
|
||||
"geocoding",
|
||||
"geolocation",
|
||||
"libphonenumber",
|
||||
"mobile",
|
||||
"phonenumber",
|
||||
"validation"
|
||||
],
|
||||
"support": {
|
||||
"irc": "irc://irc.appliedirc.com/lobby",
|
||||
"issues": "https://github.com/giggsey/libphonenumber-for-php/issues",
|
||||
"source": "https://github.com/giggsey/libphonenumber-for-php"
|
||||
},
|
||||
"time": "2020-12-15T10:15:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "giggsey/locale",
|
||||
"version": "1.9",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/giggsey/Locale.git",
|
||||
"reference": "b07f1eace8072ccc61445ad8fbd493ff9d783043"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/giggsey/Locale/zipball/b07f1eace8072ccc61445ad8fbd493ff9d783043",
|
||||
"reference": "b07f1eace8072ccc61445ad8fbd493ff9d783043",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"pear/pear-core-minimal": "^1.9",
|
||||
"pear/pear_exception": "^1.0",
|
||||
"pear/versioncontrol_git": "^0.5",
|
||||
"phing/phing": "~2.7",
|
||||
"php-coveralls/php-coveralls": "^1.0|^2.0",
|
||||
"phpunit/phpunit": "^4.8|^5.0",
|
||||
"symfony/console": "^2.8|^3.0|^4.0",
|
||||
"symfony/filesystem": "^2.8|^3.0|^4.0",
|
||||
"symfony/finder": "^2.8|^3.0|^4.0",
|
||||
"symfony/process": "^2.8|^3.0|^4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Giggsey\\Locale\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Joshua Gigg",
|
||||
"email": "giggsey@gmail.com",
|
||||
"homepage": "http://giggsey.com/"
|
||||
}
|
||||
],
|
||||
"description": "Locale functions required by libphonenumber-for-php",
|
||||
"support": {
|
||||
"issues": "https://github.com/giggsey/Locale/issues",
|
||||
"source": "https://github.com/giggsey/Locale/tree/master"
|
||||
},
|
||||
"time": "2020-07-07T11:16:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "netpromotion/profiler",
|
||||
"version": "v1.3.0",
|
||||
|
@ -306,6 +501,10 @@
|
|||
}
|
||||
],
|
||||
"description": "Profiler with adapter for Tracy",
|
||||
"support": {
|
||||
"issues": "https://github.com/netpromotion/profiler/issues",
|
||||
"source": "https://github.com/netpromotion/profiler/tree/master"
|
||||
},
|
||||
"time": "2016-10-05T09:25:18+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -335,6 +534,7 @@
|
|||
"phpstan/phpstan-strict-rules": "^0.12",
|
||||
"phpunit/phpunit": "^7.5 || ^8.5"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
@ -364,6 +564,10 @@
|
|||
"router",
|
||||
"routing"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nikic/FastRoute/issues",
|
||||
"source": "https://github.com/nikic/FastRoute/tree/master"
|
||||
},
|
||||
"time": "2020-09-28T10:21:28+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -405,6 +609,10 @@
|
|||
],
|
||||
"description": "PHP profiler",
|
||||
"homepage": "https://petrknap.github.io/docs/php-profiler.html",
|
||||
"support": {
|
||||
"issues": "https://github.com/petrknap/php-profiler/issues",
|
||||
"source": "https://github.com/petrknap/php-profiler/tree/master"
|
||||
},
|
||||
"time": "2017-05-29T10:14:28+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -446,6 +654,10 @@
|
|||
],
|
||||
"description": "Singleton pattern for PHP",
|
||||
"homepage": "https://github.com/petrknap/php-singleton",
|
||||
"support": {
|
||||
"issues": "https://github.com/petrknap/php-singleton/issues",
|
||||
"source": "https://github.com/petrknap/php-singleton/tree/master"
|
||||
},
|
||||
"time": "2016-09-22T07:59:18+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -496,6 +708,10 @@
|
|||
"convert",
|
||||
"xml"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/array-to-xml/issues",
|
||||
"source": "https://github.com/spatie/array-to-xml/tree/2.16.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://spatie.be/open-source/support-us",
|
||||
|
@ -568,6 +784,9 @@
|
|||
"polyfill",
|
||||
"portable"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
|
@ -645,6 +864,9 @@
|
|||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
|
@ -729,6 +951,10 @@
|
|||
"nette",
|
||||
"profiler"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nette/tracy/issues",
|
||||
"source": "https://github.com/nette/tracy/tree/v2.8.0"
|
||||
},
|
||||
"time": "2020-12-16T23:28:40+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -791,6 +1017,10 @@
|
|||
"keywords": [
|
||||
"templating"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/twigphp/Twig/issues",
|
||||
"source": "https://github.com/twigphp/Twig/tree/v3.1.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
|
@ -847,6 +1077,10 @@
|
|||
],
|
||||
"description": "Command line arguments parser for PHP 5.4 - 7.3",
|
||||
"homepage": "http://getopt-php.github.io/getopt-php",
|
||||
"support": {
|
||||
"issues": "https://github.com/getopt-php/getopt-php/issues",
|
||||
"source": "https://github.com/getopt-php/getopt-php/tree/v3.4.0"
|
||||
},
|
||||
"time": "2020-07-14T06:09:04+00:00"
|
||||
}
|
||||
],
|
||||
|
@ -886,6 +1120,10 @@
|
|||
}
|
||||
],
|
||||
"description": "phpcs-security-audit is a set of PHP_CodeSniffer rules that finds vulnerabilities and weaknesses related to security in PHP code",
|
||||
"support": {
|
||||
"issues": "https://github.com/FloeDesignTechnologies/phpcs-security-audit/issues",
|
||||
"source": "https://github.com/FloeDesignTechnologies/phpcs-security-audit/tree/master"
|
||||
},
|
||||
"time": "2019-08-05T19:34:55+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -937,6 +1175,11 @@
|
|||
"phpcs",
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
|
||||
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
|
||||
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
|
||||
},
|
||||
"time": "2020-10-23T02:01:07+00:00"
|
||||
}
|
||||
],
|
||||
|
@ -949,5 +1192,5 @@
|
|||
"prefer-lowest": false,
|
||||
"platform": [],
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "1.1.0"
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
||||
|
|
|
@ -588,7 +588,7 @@ class user
|
|||
}
|
||||
}
|
||||
|
||||
public function add_user($email, $name, $username, $password, $birthday, $chief, $driver, $hidden, $disabled, $inserted_by)
|
||||
public function add_user($email, $name, $username, $password, $phone_number, $birthday, $chief, $driver, $hidden, $disabled, $inserted_by)
|
||||
{
|
||||
$this->tools->profiler_start("Add user");
|
||||
$userId = $this->auth->admin()->createUserWithUniqueUsername($email, $password, $username);
|
||||
|
@ -597,8 +597,8 @@ class user
|
|||
$disabled = $disabled ? 1 : 0;
|
||||
$chief = $chief ? 1 : 0;
|
||||
$driver = $driver ? 1 : 0;
|
||||
$sql = "INSERT INTO `%PREFIX%_profiles` (`hidden`, `disabled`, `name`, `chief`, `driver`) VALUES (:hidden, :disabled, :name, :chief, :driver)";
|
||||
$this->database->exec($sql, false, [":hidden" => $hidden, ":disabled" => $disabled, ":name" => $name, ":chief" => $chief, ":driver" => $driver]);
|
||||
$sql = "INSERT INTO `%PREFIX%_profiles` (`hidden`, `disabled`, `name`, `phone_number`, `chief`, `driver`) VALUES (:hidden, :disabled, :name, :phone_number, :chief, :driver)";
|
||||
$this->database->exec($sql, false, [":hidden" => $hidden, ":disabled" => $disabled, ":name" => $name, ":phone_number" => $phone_number, ":chief" => $chief, ":driver" => $driver]);
|
||||
if($chief == 1) {
|
||||
$this->auth->admin()->addRoleForUserById($userId, Role::FULL_VIEWER);
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ class user
|
|||
return $userId;
|
||||
} else {
|
||||
$this->tools->profiler_stop();
|
||||
return $false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
<?php
|
||||
require_once 'ui.php';
|
||||
use Brick\PhoneNumber\PhoneNumber;
|
||||
use Brick\PhoneNumber\PhoneNumberFormat;
|
||||
use Brick\PhoneNumber\PhoneNumberParseException;
|
||||
function debug(){
|
||||
echo("<pre>"); var_dump($_POST); echo("</pre>"); exit();
|
||||
}
|
||||
if($tools->validate_form("mod", "add")) {
|
||||
if($tools->validate_form(['mail', 'name', 'username', 'password', 'birthday', 'token'])) {
|
||||
if($tools->validate_form(['mail', 'name', 'username', 'password', 'phone_number', 'birthday', 'token'])) {
|
||||
if($_POST["token"] == $_SESSION['token']) {
|
||||
bdump("adding user");
|
||||
bdump($_POST);
|
||||
|
@ -12,7 +15,19 @@ if($tools->validate_form("mod", "add")) {
|
|||
$driver = isset($_POST["driver"]) ? 1 : 0;
|
||||
$hidden = isset($_POST["visible"]) ? 0 : 1;
|
||||
$disabled = isset($_POST["enabled"]) ? 0 : 1;
|
||||
$user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $_POST["birthday"], $chief, $driver, $hidden, $disabled, $user->name());
|
||||
try {
|
||||
$phone_number = PhoneNumber::parse($_POST["phone_number"]);
|
||||
if (!$phone_number->isValidNumber()) {
|
||||
echo("Bad phone number. <a href='javascript:window.history.back()'>Go back</a>"); //TODO: better form validation
|
||||
exit();
|
||||
} else {
|
||||
$phone_number = $phone_number->format(PhoneNumberFormat::E164);
|
||||
}
|
||||
} catch (PhoneNumberParseException $e) {
|
||||
echo("Bad phone number. <a href='javascript:window.history.back()'>Go back</a>"); //TODO: better form validation
|
||||
exit();
|
||||
}
|
||||
$user->add_user($_POST["mail"], $_POST["name"], $_POST["username"], $_POST["password"], $phone_number, $_POST["birthday"], $chief, $driver, $hidden, $disabled, $user->name());
|
||||
$tools->redirect("list.php");
|
||||
} else {
|
||||
debug();
|
||||
|
|
|
@ -42,8 +42,8 @@ foreach($risultato as $row){
|
|||
(time()-$row["online_time"])<=30 ? "<u>".$firstCell."</u>" : $firstCell,
|
||||
$secondCell,
|
||||
$row['driver'] ? "<img alt='driver' src='./resources/images/wheel.png' width='20px'>" : "",
|
||||
$row['phone_number'] ? "<a href='tel:+".$row['phone_number']."'><i class='fa fa-phone'></i></a>" : "",
|
||||
$row['phone_number'] ? "<a href='https://api.whatsapp.com/send?phone=+".$row['phone_number']."text=ALLERTA IN CORSO.%20Mettiti%20in%20contatto%20con%20$name_encoded'><i class='fa fa-whatsapp' style='color:green'></i></a>" : "",
|
||||
!empty($row['phone_number']) ? "<a href='tel:".$row['phone_number']."'><i class='fa fa-phone'></i></a>" : "",
|
||||
!empty($row['phone_number']) ? "<a href='https://api.whatsapp.com/send?phone=".$row['phone_number']."&text=ALLERTA IN CORSO.%20Mettiti%20in%20contatto%20con%20$name_encoded'><i class='fa fa-whatsapp' style='color:green'></i></a>" : "",
|
||||
$row['services'],
|
||||
$row['availability_minutes'],
|
||||
"<a href='user_details.php?user=".$row['id']."'><p>".t("Altri dettagli", false)."</p></a>"
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
<input id="password" type="text" name="password" required>
|
||||
<br>
|
||||
<br>
|
||||
<label><b>{{ 'Phone number'|t }}</b></label>
|
||||
<input id="phone_number" type="tel" name="phone_number" required>
|
||||
<br>
|
||||
<br>
|
||||
<label><b>{{ 'Birthday'|t }}</b></label>
|
||||
<div class="input-group">
|
||||
<input placeholder="DD/MM/YYY" autocomplete="off" name="birthday" data-provide="datepicker"
|
||||
|
|
Loading…
Reference in New Issue