mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 10:08:05 +00:00
Fix #11 Remove table creation and removal + related code as it is now handled by FlexiAPI
This commit is contained in:
parent
d2328e9580
commit
9e577de92a
9 changed files with 1 additions and 345 deletions
|
|
@ -8,7 +8,7 @@
|
|||
#%define _datadir %{_datarootdir}
|
||||
#%define _docdir %{_datadir}/doc
|
||||
|
||||
%define build_number 79
|
||||
%define build_number 80
|
||||
%define var_dir /var/opt/belledonne-communications
|
||||
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager
|
||||
|
||||
|
|
|
|||
|
|
@ -69,47 +69,6 @@ class Account
|
|||
return substr($to_string, 0, -2);
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
$query = "DROP TABLE IF EXISTS " . ACCOUNTS_DB_TABLE;
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Dropping table " . ACCOUNTS_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
$query = "CREATE TABLE IF NOT EXISTS " . ACCOUNTS_DB_TABLE . " (
|
||||
id INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
username VARCHAR(64) NOT NULL,
|
||||
domain VARCHAR(64) NOT NULL,
|
||||
email VARCHAR(64) DEFAULT NULL,
|
||||
activated VARCHAR(1) NOT NULL DEFAULT '0',
|
||||
confirmation_key VARCHAR(14) DEFAULT NULL,
|
||||
ip_address VARCHAR(39) NOT NULL,
|
||||
user_agent VARCHAR(256) NOT NULL,
|
||||
creation_time DATETIME NOT NULL,
|
||||
expire_time DATETIME,
|
||||
PRIMARY KEY (id), UNIQUE KEY identity (username, domain))";
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Creating table " . ACCOUNTS_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$query = "DELETE FROM " . ACCOUNTS_DB_TABLE . " WHERE id = ?";
|
||||
|
|
|
|||
|
|
@ -50,37 +50,6 @@ class Alias
|
|||
return substr($to_string, 0, -2);
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
$query = "DROP TABLE IF EXISTS " . ALIAS_DB_TABLE;
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Dropping table " . ALIAS_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
$query = "CREATE TABLE IF NOT EXISTS " . ALIAS_DB_TABLE . " (
|
||||
id INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
account_id INTEGER(11) UNSIGNED NOT NULL,
|
||||
alias VARCHAR(64) NOT NULL,
|
||||
domain VARCHAR(64) NOT NULL,
|
||||
PRIMARY KEY (id), UNIQUE KEY identity (alias, domain))";
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Creating table " . ALIAS_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$query = "DELETE FROM " . ALIAS_DB_TABLE;
|
||||
|
|
|
|||
|
|
@ -58,43 +58,6 @@ class Device
|
|||
return substr($to_string, 0, -2);
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
$query = "DROP TABLE IF EXISTS " . DEVICES_DB_TABLE;
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Dropping table " . DEVICES_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
$query = "CREATE TABLE IF NOT EXISTS " . DEVICES_DB_TABLE . " (
|
||||
id INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
manufacturer VARCHAR(64) NOT NULL,
|
||||
model VARCHAR(34) NOT NULL,
|
||||
status VARCHAR(34) NOT NULL,
|
||||
delay INTEGER(4) NOT NULL DEFAULT 0,
|
||||
hardware_echo_canceller TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id))";
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Creating table " . DEVICES_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$query = "DELETE FROM " . DEVICES_DB_TABLE . " WHERE id = ?";
|
||||
|
|
|
|||
|
|
@ -50,41 +50,6 @@ class Password
|
|||
return substr($to_string, 0, -2);
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
$query = "DROP TABLE IF EXISTS " . ACCOUNTS_ALGO_DB_TABLE;
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Dropping table " . ACCOUNTS_ALGO_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
$query = "CREATE TABLE IF NOT EXISTS " . ACCOUNTS_ALGO_DB_TABLE . " (
|
||||
id INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
account_id INTEGER(11) UNSIGNED NOT NULL,
|
||||
password VARCHAR(255) NOT NULL,
|
||||
algorithm VARCHAR(10) NOT NULL DEFAULT 'MD5',
|
||||
PRIMARY KEY (id), UNIQUE KEY account (account_id, algorithm))";
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Creating table " . ACCOUNTS_ALGO_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$query = "DELETE FROM " . ACCOUNTS_ALGO_DB_TABLE;
|
||||
|
|
|
|||
|
|
@ -50,41 +50,6 @@ class SMS
|
|||
return substr($to_string, 0, -2);
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
$query = "DROP TABLE IF EXISTS " . SMS_DB_TABLE;
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Dropping table " . SMS_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
$query = "CREATE TABLE IF NOT EXISTS " . SMS_DB_TABLE . " (
|
||||
id INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
phone VARCHAR(64),
|
||||
last_sms BIGINT(15) UNSIGNED DEFAULT 0,
|
||||
count TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (id), UNIQUE KEY phone (phone))";
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Creating table " . SMS_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$query = "DELETE FROM " . SMS_DB_TABLE . " WHERE id = ?";
|
||||
|
|
|
|||
|
|
@ -66,45 +66,6 @@ class UserInfo
|
|||
return substr($to_string, 0, -2);
|
||||
}
|
||||
|
||||
public function dropTable()
|
||||
{
|
||||
$query = "DROP TABLE IF EXISTS " . USER_INFO_DB_TABLE;
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Dropping table " . USER_INFO_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createTable()
|
||||
{
|
||||
$query = "CREATE TABLE IF NOT EXISTS " . USER_INFO_DB_TABLE . " (
|
||||
id INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
account_id INTEGER(11) UNSIGNED NOT NULL,
|
||||
firstname VARCHAR(128) NOT NULL,
|
||||
lastname VARCHAR(128) NOT NULL,
|
||||
gender enum('male','female') NOT NULL,
|
||||
country_code VARCHAR(32),
|
||||
country_name VARCHAR(512),
|
||||
subscribe enum('0','1') NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (id))";
|
||||
|
||||
$this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$stmt = $this->conn->prepare($query);
|
||||
|
||||
Logger::getInstance()->debug("Creating table " . USER_INFO_DB_TABLE);
|
||||
if ($stmt->execute()) {
|
||||
return true;
|
||||
}
|
||||
Logger::getInstance()->error($stmt->errorInfo());
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$query = "DELETE FROM " . USER_INFO_DB_TABLE . " WHERE id = ?";
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
|
||||
<?php
|
||||
|
||||
/*
|
||||
Flexisip Account Manager is a set of tools to manage SIP accounts.
|
||||
Copyright (C) 2020 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/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';
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
|
||||
$account = new Account($db);
|
||||
if (!$account->createTable()) {
|
||||
Logger::getInstance()->error("Couldn't create account table");
|
||||
}
|
||||
|
||||
$alias = new Alias($db);
|
||||
if (!$alias->createTable()) {
|
||||
Logger::getInstance()->error("Couldn't create alias table");
|
||||
}
|
||||
|
||||
$device = new Device($db);
|
||||
if (!$device->createTable()) {
|
||||
Logger::getInstance()->error("Couldn't create device table");
|
||||
}
|
||||
|
||||
$password = new Password($db);
|
||||
if (!$password->createTable()) {
|
||||
Logger::getInstance()->error("Couldn't create password table");
|
||||
}
|
||||
|
||||
$sms = new SMS($db);
|
||||
if (!$sms->createTable()) {
|
||||
Logger::getInstance()->error("Couldn't create sms table");
|
||||
}
|
||||
|
||||
$user_info = new UserInfo($db);
|
||||
if (!$user_info->createTable()) {
|
||||
Logger::getInstance()->error("Couldn't create user_info table");
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
#!/usr/bin/env php
|
||||
|
||||
<?php
|
||||
|
||||
/*
|
||||
Flexisip Account Manager is a set of tools to manage SIP accounts.
|
||||
Copyright (C) 2020 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/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';
|
||||
|
||||
$database = new Database();
|
||||
$db = $database->getConnection();
|
||||
|
||||
$account = new Account($db);
|
||||
if (!$account->dropTable()) {
|
||||
Logger::getInstance()->error("Couldn't drop account table");
|
||||
}
|
||||
|
||||
$alias = new Alias($db);
|
||||
if (!$alias->dropTable()) {
|
||||
Logger::getInstance()->error("Couldn't drop alias table");
|
||||
}
|
||||
|
||||
$device = new Device($db);
|
||||
if (!$device->dropTable()) {
|
||||
Logger::getInstance()->error("Couldn't drop device table");
|
||||
}
|
||||
|
||||
$password = new Password($db);
|
||||
if (!$password->dropTable()) {
|
||||
Logger::getInstance()->error("Couldn't drop password table");
|
||||
}
|
||||
|
||||
$sms = new SMS($db);
|
||||
if (!$sms->dropTable()) {
|
||||
Logger::getInstance()->error("Couldn't drop sms table");
|
||||
}
|
||||
|
||||
$user_info = new UserInfo($db);
|
||||
if (!$user_info->dropTable()) {
|
||||
Logger::getInstance()->error("Couldn't drop user_info table");
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Reference in a new issue