Created
June 17, 2023 00:28
-
-
Save ambiorixg12/a440fd1913420b2199e89c6ea0f3ca7d to your computer and use it in GitHub Desktop.
asterisk realtime insert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------------------php code---- | |
php /home/ambiorix/insert_device.php 2222 | |
<?php | |
$link = mysqli_connect("localhost", "root", "mypass", "asterisk"); | |
/* check connection */ | |
if (mysqli_connect_errno()) { | |
printf("Connect failed: %s\n", mysqli_connect_error()); | |
exit(); | |
} | |
$sip_device ="$argv[1]"; | |
$query1 = "INSERT INTO `ps_aors` (`id`, `max_contacts`) VALUES ($sip_device, 1)"; | |
if (mysqli_query($link, $query1)) { | |
printf("Query 1 executed successfully.\n"); | |
} else { | |
printf("Error executing query 1: %s\n", mysqli_error($link)); | |
} | |
$query2 = "INSERT INTO `ps_auths` (`id`, `auth_type`, `password`, `username`) VALUES ($sip_device, 'userpass', $sip_device, $sip_device)"; | |
if (mysqli_query($link, $query2)) { | |
printf("Query 2 executed successfully.\n"); | |
} else { | |
printf("Error executing query 2: %s\n", mysqli_error($link)); | |
} | |
$query3 = "INSERT INTO `ps_endpoints` (`id`, `transport`, `aors`, `auth`, `context`, `disallow`, `allow`, `direct_media`) | |
VALUES ($sip_device, 'transport-udp', '$sip_device', '$sip_device', 'testing', 'all', 'g722', 'no')"; | |
if (mysqli_query($link, $query3)) { | |
printf("Query 3 executed successfully.\n"); | |
} else { | |
printf("Error executing query 3: %s\n", mysqli_error($link)); | |
} | |
/* close connection */ | |
mysqli_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment