mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Added methods and renamed user-info files
This commit is contained in:
parent
09a95c1a1b
commit
52b1377e18
7 changed files with 195 additions and 5 deletions
|
|
@ -236,6 +236,9 @@ class Account {
|
|||
} else if (!empty($this->email)) {
|
||||
$query = $query . " WHERE ac.email = ?";
|
||||
$this->email = htmlspecialchars(strip_tags($this->email));
|
||||
} else if (!empty($this->confirmation_key)) {
|
||||
$query = $query . " WHERE ac.confirmation_key = ?";
|
||||
$this->confirmation_key = htmlspecialchars(strip_tags($this->confirmation_key));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -253,6 +256,8 @@ class Account {
|
|||
}
|
||||
} else if (!empty($this->email)) {
|
||||
$stmt->bindParam(1, $this->email);
|
||||
} else if (!empty($this->confirmation_key)) {
|
||||
$stmt->bindParam(1, $this->confirmation_key);
|
||||
}
|
||||
|
||||
Logger::getInstance()->debug("GetOne " . (string)$this);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ include_once __DIR__ . '/../objects/alias.php';
|
|||
include_once __DIR__ . '/../objects/device.php';
|
||||
include_once __DIR__ . '/../objects/password.php';
|
||||
include_once __DIR__ . '/../objects/sms.php';
|
||||
include_once __DIR__ . '/../objects/user-info.php';
|
||||
include_once __DIR__ . '/../objects/user_info.php';
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ include_once __DIR__ . '/../objects/alias.php';
|
|||
include_once __DIR__ . '/../objects/device.php';
|
||||
include_once __DIR__ . '/../objects/password.php';
|
||||
include_once __DIR__ . '/../objects/sms.php';
|
||||
include_once __DIR__ . '/../objects/user-info.php';
|
||||
include_once __DIR__ . '/../objects/user_info.php';
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ include_once __DIR__ . '/../objects/alias.php';
|
|||
include_once __DIR__ . '/../objects/device.php';
|
||||
include_once __DIR__ . '/../objects/password.php';
|
||||
include_once __DIR__ . '/../objects/sms.php';
|
||||
include_once __DIR__ . '/../objects/user-info.php';
|
||||
include_once __DIR__ . '/../objects/user_info.php';
|
||||
include_once __DIR__ . '/../misc/utilities.php';
|
||||
|
||||
$database = new Database();
|
||||
|
|
@ -101,7 +101,7 @@ while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
|||
$user_info->gender = $gender;
|
||||
$user_info->subscribe = $subscribe;
|
||||
if (!$user_info->create()) {
|
||||
Logger::getInstance()->error("Failed to create user-info !");
|
||||
Logger::getInstance()->error("Failed to create user_info !");
|
||||
}
|
||||
|
||||
$pwd = new Password($db);
|
||||
|
|
|
|||
183
src/xmlrpc/user_info.php
Normal file
183
src/xmlrpc/user_info.php
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Flexisip Account Manager is a set of tools to manage SIP accounts.
|
||||
Copyright (C) 2019 Belledonne Communications SARL, All rights reserved.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
include_once __DIR__ . '/../database/database.php';
|
||||
|
||||
include_once __DIR__ . '/../objects/account.php';
|
||||
include_once __DIR__ . '/../objects/password.php';
|
||||
include_once __DIR__ . '/../objects/alias.php';
|
||||
include_once __DIR__ . '/../objects/user_info.php';
|
||||
|
||||
include_once __DIR__ . '/../misc/utilities.php';
|
||||
|
||||
include_once __DIR__ . '/results_values.php';
|
||||
|
||||
// args = [username, ha1, [domain], [algo]]
|
||||
function xmlrpc_get_email_account($method, $args) {
|
||||
$username = $args[0];
|
||||
$ha1 = $args[1];
|
||||
$domain = get_domain($args[2]);
|
||||
$algo = get_algo($args[3]);
|
||||
|
||||
Logger::getInstance()->message("[XMLRPC] xmlrpc_get_email_account(" . $username . ")");
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
|
||||
$account = new Account($db);
|
||||
$account->username = $username;
|
||||
$account->domain = $domain;
|
||||
|
||||
if (!$account->getOne()) {
|
||||
return ACCOUNT_NOT_FOUND;
|
||||
}
|
||||
|
||||
$password = new Password($db);
|
||||
$password->account_id = $account->id;
|
||||
$password->algorithm = $algo;
|
||||
|
||||
if (!$password->getOne()) {
|
||||
return PASSWORD_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!password_match($ha1, $password->password)) {
|
||||
return PASSWORD_DOESNT_MATCH;
|
||||
}
|
||||
|
||||
$user_info = new UserInfo($db);
|
||||
$user_info->account_id = $account->id;
|
||||
|
||||
$result = array(
|
||||
"id" => $account->id,
|
||||
"username" => $account->username,
|
||||
"domain" => $account->domain,
|
||||
"email" => $account->email,
|
||||
"alias" => $account->alias,
|
||||
"activated" => $account->activated,
|
||||
"firstname" => $user_info->firstname,
|
||||
"lastname" => $user_info->lastname,
|
||||
"gender" => $user_info->gender,
|
||||
"subscribe" => $user_info->subscribe
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// args = [tel, ha1, [domain], [algo]]
|
||||
function xmlrpc_get_phone_account($method, $args) {
|
||||
$phone = $args[0];
|
||||
$ha1 = $args[1];
|
||||
$domain = get_domain($args[2]);
|
||||
$algo = get_algo($args[3]);
|
||||
|
||||
Logger::getInstance()->message("[XMLRPC] xmlrpc_get_phone_account(" . $phone . ")");
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
|
||||
$alias = new Alias($db);
|
||||
$alias->alias = $phone;
|
||||
$alias->domain = $domain;
|
||||
|
||||
$account = new Account($db);
|
||||
|
||||
if (!$alias->getOne()) {
|
||||
$account->username = $phone;
|
||||
$account->domain = $domain;
|
||||
} else {
|
||||
$account->id = $alias->account_id;
|
||||
}
|
||||
|
||||
if (!$account->getOne()) {
|
||||
return ACCOUNT_NOT_FOUND;
|
||||
}
|
||||
|
||||
$password = new Password($db);
|
||||
$password->account_id = $account->id;
|
||||
$password->algorithm = $algo;
|
||||
|
||||
if (!$password->getOne()) {
|
||||
return PASSWORD_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!password_match($ha1, $password->password)) {
|
||||
return PASSWORD_DOESNT_MATCH;
|
||||
}
|
||||
|
||||
$user_info = new UserInfo($db);
|
||||
$user_info->account_id = $account->id;
|
||||
|
||||
$result = array(
|
||||
"id" => $account->id,
|
||||
"username" => $account->username,
|
||||
"domain" => $account->domain,
|
||||
"email" => $account->email,
|
||||
"alias" => $account->alias,
|
||||
"activated" => $account->activated,
|
||||
"firstname" => $user_info->firstname,
|
||||
"lastname" => $user_info->lastname,
|
||||
"gender" => $user_info->gender,
|
||||
"subscribe" => $user_info->subscribe
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// args = [confirmation_key, [algo]]
|
||||
function xmlrpc_get_account_by_confirmation_key($method, $args) {
|
||||
$confirmation_key = $args[0];
|
||||
$algo = get_algo($args[1]);
|
||||
|
||||
Logger::getInstance()->message("[XMLRPC] xmlrpc_get_account_by_confirmation_key(" . $confirmation_key . ")");
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
|
||||
$account = new Account($db);
|
||||
$account->confirmation_key = $confirmation_key;
|
||||
|
||||
if (!$account->getOne()) {
|
||||
return ACCOUNT_NOT_FOUND;
|
||||
}
|
||||
|
||||
$user_info = new UserInfo($db);
|
||||
$user_info->account_id = $account->id;
|
||||
|
||||
$result = array(
|
||||
"id" => $account->id,
|
||||
"username" => $account->username,
|
||||
"domain" => $account->domain,
|
||||
"email" => $account->email,
|
||||
"alias" => $account->alias,
|
||||
"activated" => $account->activated,
|
||||
"firstname" => $user_info->firstname,
|
||||
"lastname" => $user_info->lastname,
|
||||
"gender" => $user_info->gender,
|
||||
"subscribe" => $user_info->subscribe
|
||||
);
|
||||
}
|
||||
|
||||
function xmlrpc_user_info_register_methods($server) {
|
||||
xmlrpc_server_register_method($server, 'get_email_account', 'xmlrpc_get_email_account'); // args = [username, ha1, [domain], [algo]]
|
||||
xmlrpc_server_register_method($server, 'get_phone_account', 'xmlrpc_get_phone_account'); // args = [tel, ha1, [domain], [algo]]
|
||||
xmlrpc_server_register_method($server, 'get_account_by_confirmation_key', 'xmlrpc_get_account_by_confirmation_key'); // args = [confirmation_key, [algo]]
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -19,12 +19,14 @@
|
|||
*/
|
||||
|
||||
include_once __DIR__ . '/../database/database.php';
|
||||
|
||||
include_once __DIR__ . '/../misc/utilities.php';
|
||||
|
||||
include_once __DIR__ . '/authentication.php';
|
||||
include_once __DIR__ . '/accounts.php';
|
||||
include_once __DIR__ . '/aliases.php';
|
||||
include_once __DIR__ . '/devices.php';
|
||||
include_once __DIR__ . '/user-info.php';
|
||||
include_once __DIR__ . '/user_info.php';
|
||||
include_once __DIR__ . '/compatibility.php';
|
||||
|
||||
$request = file_get_contents("php://input");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue