mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Use !empty instead of != ''
This commit is contained in:
@@ -65,22 +65,33 @@ if (!class_exists('registrations')) {
|
||||
//get the default settings
|
||||
$sql = "select sip_profile_name from v_sip_profiles ";
|
||||
$sql .= "where sip_profile_enabled = 'true' ";
|
||||
if ($profile != 'all' && $profile != '') {
|
||||
if (!empty($profile) && $profile != 'all') {
|
||||
$sql .= "and sip_profile_name = :sip_profile_name ";
|
||||
$parameters['sip_profile_name'] = $profile;
|
||||
}
|
||||
$sql .= "and sip_profile_enabled = 'true' ";
|
||||
$database = new database;
|
||||
$sip_profiles = $database->select($sql, $parameters ?? null, 'all');
|
||||
if (is_array($sip_profiles) && @sizeof($sip_profiles) != 0) {
|
||||
if (!empty($sip_profiles) && @sizeof($sip_profiles) != 0) {
|
||||
foreach ($sip_profiles as $field) {
|
||||
|
||||
//get sofia status profile information including registrations
|
||||
$cmd = "api sofia xmlstatus profile '".$field['sip_profile_name']."' reg";
|
||||
$xml_response = trim(event_socket_request($fp, $cmd));
|
||||
|
||||
//show an error message
|
||||
if ($xml_response == "Invalid Profile!") {
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//show the error message
|
||||
$xml_response = "<error_msg>".escape($text['label-message'])."</error_msg>";
|
||||
}
|
||||
|
||||
//santize the XML
|
||||
if (function_exists('iconv')) { $xml_response = iconv("utf-8", "utf-8//IGNORE", $xml_response); }
|
||||
$xml_response = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/u', '', $xml_response);
|
||||
if ($xml_response == "Invalid Profile!") { $xml_response = "<error_msg>".!empty($text['label-message'])."</error_msg>"; }
|
||||
$xml_response = str_replace("<profile-info>", "<profile_info>", $xml_response);
|
||||
$xml_response = str_replace("</profile-info>", "</profile_info>", $xml_response);
|
||||
$xml_response = str_replace("<", "", $xml_response);
|
||||
@@ -142,13 +153,13 @@ if (!class_exists('registrations')) {
|
||||
if (isset($call_id_array[1])) {
|
||||
$agent = $row['agent'];
|
||||
$lan_ip = $call_id_array[1];
|
||||
if (false !== stripos($agent, 'grandstream')) {
|
||||
if (!empty($agent) && false !== stripos($agent, 'grandstream')) {
|
||||
$lan_ip = str_ireplace(
|
||||
array('A','B','C','D','E','F','G','H','I','J'),
|
||||
array('0','1','2','3','4','5','6','7','8','9'),
|
||||
$lan_ip);
|
||||
}
|
||||
elseif (1 === preg_match('/\ACL750A/', $agent)) {
|
||||
elseif (!empty($agent) && 1 === preg_match('/\ACL750A/', $agent)) {
|
||||
//required for GIGASET Sculpture CL750A puts _ in it's lan ip account
|
||||
$lan_ip = preg_replace('/_/', '.', $lan_ip);
|
||||
}
|
||||
@@ -242,11 +253,7 @@ if (!class_exists('registrations')) {
|
||||
//filter out unchecked registrations
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
foreach($records as $record) {
|
||||
if (
|
||||
$record['checked'] == 'true' &&
|
||||
$record['user'] != '' &&
|
||||
$record['profile'] != ''
|
||||
) {
|
||||
if ($record['checked'] == 'true' && !empty($record['user']) && !empty($record['profile'])) {
|
||||
$registrations[] = $record;
|
||||
}
|
||||
}
|
||||
@@ -271,7 +278,7 @@ if (!class_exists('registrations')) {
|
||||
foreach ($registrations as $registration) {
|
||||
|
||||
//validate the submitted profile
|
||||
if ($registration['profile'] != '' && is_array($sip_profiles) && @sizeof($sip_profiles) != 0) {
|
||||
if (!empty($registration['profile']) && is_array($sip_profiles) && @sizeof($sip_profiles) != 0) {
|
||||
foreach ($sip_profiles as $field) {
|
||||
if ($field['name'] == $registration['profile']) {
|
||||
$profile = $registration['profile'];
|
||||
@@ -285,22 +292,22 @@ if (!class_exists('registrations')) {
|
||||
}
|
||||
|
||||
//validate the submitted user
|
||||
if ($registration['user'] != '') {
|
||||
if (!empty($registration['user'])) {
|
||||
$user = preg_replace('#[^a-zA-Z0-9_\-\.\@]#', '', $registration['user']);
|
||||
}
|
||||
|
||||
//validate the submitted host
|
||||
if ($registration['host'] != '') {
|
||||
if (!empty($registration['host'])) {
|
||||
$host = preg_replace('#[^a-zA-Z0-9_\-\.]#', '', $registration['host']);
|
||||
}
|
||||
|
||||
//lookup vendor by agent
|
||||
if ($registration['agent'] != '') {
|
||||
if (!empty($registration['agent'])) {
|
||||
$vendor = device::get_vendor_by_agent($registration['agent']);
|
||||
}
|
||||
|
||||
//prepare the api command
|
||||
if ($profile && $user) {
|
||||
if (!empty($profile) && $user) {
|
||||
switch ($action) {
|
||||
case 'unregister':
|
||||
$command = "sofia profile ".$profile." flush_inbound_reg ".$user." reboot";
|
||||
@@ -325,7 +332,7 @@ if (!class_exists('registrations')) {
|
||||
}
|
||||
|
||||
//send the api command
|
||||
if ($command && $fp) {
|
||||
if (!empty($command) && $fp) {
|
||||
$response_api[$registration['user']]['command'] = event_socket_request($fp, "api ".$command);
|
||||
$response_api[$registration['user']]['log'] = event_socket_request($fp, "api log notice ".$command);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user