public function download($value, $ext = array('jpg', 'gif', 'jpeg', 'png'), $mid = 0, $fileSavePath = null)
 {
     if (!extension_exists('curl')) {
         return $value;
     }
     $fileSavePath = $this->setSavePath($fileSavePath);
     $uploadModel = M('upload');
     if (!function_exists('curl_init')) {
         return $value;
     }
     $ext = implode('|', $ext);
     $curl = curl_init();
     if (!preg_match_all('/(href|src)=([\'"]?)([^\'">]+\\.(' . $ext . '))\\2/is', $value, $matchData, PREG_PATTERN_ORDER)) {
         return $value;
     }
     //远程文件
     $remoteData = array();
     $oldPath = $newPath = array();
     foreach ($matchData[3] as $match) {
         if (strpos($match, '://') == false) {
             continue;
         }
         //扩展名
         $fileInfo = pathinfo($match);
         $newFileName = mt_rand(1, 10000) . time();
         $newfile = $this->getFileName(array('filename' => $newFileName, 'extension' => '.' . $fileInfo['extension'], 'dirname' => $fileSavePath));
         $oldPath[] = $match;
         $newPath[] = __ROOT__ . '/' . $newfile;
         curl_setopt($curl, CURLOPT_URL, $match);
         curl_setopt($curl, CURLOPT_HEADER, 0);
         //超时时间
         curl_setopt($curl, CURLOPT_TIMEOUT, 10);
         //结果保存在字符串中
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
         $fileData = curl_exec($curl);
         if ($fileData != false && curl_getinfo($curl, CURLINFO_HTTP_CODE) == 200) {
             $state = $this->saveFile($newfile, $fileData);
             if ($state) {
                 $isImage = preg_match('/jpeg|jpg|png|gif/i', $match);
                 $TableData = array('name' => $fileInfo['filename'], 'filename' => $newFileName, 'basename' => $newFileName . $fileInfo['extension'], 'path' => $fileSavePath . '/' . $newFileName . '.' . $fileInfo['extension'], 'ext' => $fileInfo['extension'], 'image' => $isImage, 'size' => filesize($newfile), 'uptime' => time(), 'state' => 0, 'uid' => $_SESSION['uid'], 'mid' => $mid);
                 $uploadModel->add($TableData);
                 $value = str_replace($oldPath, $newPath, $value);
             }
         }
     }
     return $value;
 }
Beispiel #2
0
 public function set()
 {
     //set the global variable
     global $db;
     //determine whether to update the dial string
     $sql = "select * from v_extensions ";
     $sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
     $sql .= "and extension_uuid = '" . $this->extension_uuid . "' ";
     $prep_statement = $db->prepare(check_sql($sql));
     $prep_statement->execute();
     $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
     if (count($result) > 0) {
         foreach ($result as &$row) {
             $this->extension = $row["extension"];
             $this->accountcode = $row["accountcode"];
             $this->outbound_caller_id_name = $row["outbound_caller_id_name"];
             $this->outbound_caller_id_number = $row["outbound_caller_id_number"];
         }
     }
     //determine whether to update the dial string
     $sql = "select * from v_follow_me ";
     $sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
     $sql .= "and follow_me_uuid = '" . $this->follow_me_uuid . "' ";
     $prep_statement = $db->prepare(check_sql($sql));
     $prep_statement->execute();
     $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
     if (count($result) > 0) {
         foreach ($result as &$row) {
             $follow_me_uuid = $row["follow_me_uuid"];
             $this->cid_name_prefix = $row["cid_name_prefix"];
             $this->cid_number_prefix = $row["cid_number_prefix"];
         }
     }
     unset($prep_statement);
     //add follow me
     if (strlen($follow_me_uuid) == 0) {
         $this->add();
     }
     //is follow me enabled
     if ($this->follow_me_enabled == "true") {
         //set the extension dial string
         $sql = "select * from v_follow_me_destinations ";
         $sql .= "where follow_me_uuid = '" . $this->follow_me_uuid . "' ";
         $sql .= "order by follow_me_order asc ";
         $prep_statement_2 = $db->prepare(check_sql($sql));
         $prep_statement_2->execute();
         $result = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
         $dial_string = "{fail_on_single_reject=USER_BUSY";
         $dial_string .= ",instant_ringback=true";
         $dial_string .= ",ignore_early_media=true";
         $dial_string .= ",domain_uuid=" . $_SESSION['domain_uuid'];
         $dial_string .= ",sip_invite_domain=" . $_SESSION['domain_name'];
         $dial_string .= ",domain_name=" . $_SESSION['domain_name'];
         $dial_string .= ",domain=" . $_SESSION['domain_name'];
         $dial_string .= ",extension_uuid=" . $this->extension_uuid;
         $dial_string .= ",group_confirm_key=exec,group_confirm_file=lua confirm.lua";
         $dial_string_caller_id_name = "\${caller_id_name}";
         $dial_string_caller_id_number = "\${caller_id_number}";
         if (strlen($this->follow_me_caller_id_uuid) > 0) {
             $sql_caller = "select destination_number, destination_description from v_destinations where domain_uuid = '{$this->domain_uuid}' and destination_type = 'inbound' and destination_uuid = '{$this->follow_me_caller_id_uuid}'";
             $prep_statement_caller = $db->prepare($sql_caller);
             if ($prep_statement_caller) {
                 $prep_statement_caller->execute();
                 $row_caller = $prep_statement_caller->fetch(PDO::FETCH_ASSOC);
                 if (strlen($row_caller['destination_description']) > 0) {
                     $dial_string_caller_id_name = $row_caller['destination_description'];
                 }
                 if (strlen($row_caller['destination_number']) > 0) {
                     $dial_string_caller_id_number = $row_caller['destination_number'];
                 }
             }
         }
         if (strlen($this->cid_name_prefix) > 0) {
             $dial_string .= ",origination_caller_id_name=" . $this->cid_name_prefix . "#{$dial_string_caller_id_name}";
         } else {
             $dial_string .= ",origination_caller_id_name={$dial_string_caller_id_name}";
         }
         if (strlen($this->cid_number_prefix) > 0) {
             //$dial_string .= ",origination_caller_id_number=".$this->cid_number_prefix."";
             $dial_string .= ",origination_caller_id_number=" . $this->cid_number_prefix . "#dial_string_caller_id_number";
         } else {
             $dial_string .= ",origination_caller_id_number={$dial_string_caller_id_number}";
         }
         if (strlen($this->accountcode) > 0) {
             $dial_string .= ",sip_h_X-accountcode=" . $this->accountcode;
             $dial_string .= ",accountcode=" . $this->accountcode;
         }
         $dial_string .= "}";
         $x = 0;
         foreach ($result as &$row) {
             if ($x > 0) {
                 $dial_string .= ",";
             }
             if (extension_exists($row["follow_me_destination"])) {
                 //set the dial string
                 if (strlen($_SESSION['domain']['dial_string']['text']) == 0) {
                     $dial_string .= "[";
                     $dial_string .= "outbound_caller_id_number={$dial_string_caller_id_number},";
                     $dial_string .= "presence_id=" . $row["follow_me_destination"] . "@" . $_SESSION['domain_name'] . ",";
                     if ($row["follow_me_prompt"] == "1") {
                         $dial_string .= "group_confirm_key=exec,group_confirm_file=lua confirm.lua,confirm=true,";
                     }
                     $dial_string .= "leg_delay_start=" . $row["follow_me_delay"] . ",";
                     $dial_string .= "leg_timeout=" . $row["follow_me_timeout"] . "]";
                     $dial_string .= "\${sofia_contact(" . $row["follow_me_destination"] . "@" . $_SESSION['domain_name'] . ")}";
                 } else {
                     $replace_value = $row["follow_me_destination"];
                     if ($row["follow_me_prompt"] == "1") {
                         $replace_value .= "[group_confirm_key=exec,group_confirm_file=lua confirm.lua,confirm=true]";
                     }
                     $local_dial_string = $_SESSION['domain']['dial_string']['text'];
                     $local_dial_string = str_replace("\${dialed_user}", $replace_value, $local_dial_string);
                     $local_dial_string = str_replace("\${dialed_domain}", $_SESSION['domain_name'], $local_dial_string);
                     $local_dial_string = str_replace("\${call_timeout}", $row["follow_me_timeout"], $local_dial_string);
                     $local_dial_string = str_replace("\${leg_timeout}", $row["follow_me_timeout"], $local_dial_string);
                     $dial_string .= $local_dial_string;
                 }
             } else {
                 $dial_string .= "[";
                 if ($_SESSION['cdr']['follow_me_fix']['boolean'] == "true") {
                     $dial_string .= "outbound_caller_id_name=" . $this->outbound_caller_id_name;
                     $dial_string .= ",outbound_caller_id_number=" . $this->outbound_caller_id_number;
                     $dial_string .= ",origination_caller_id_name=" . $this->outbound_caller_id_name;
                     $dial_string .= ",origination_caller_id_number=" . $this->outbound_caller_id_number;
                 } else {
                     $dial_string .= "outbound_caller_id_number={$dial_string_caller_id_number}";
                 }
                 $dial_string .= ",presence_id=" . $this->extension . "@" . $_SESSION['domain_name'];
                 if ($row["follow_me_prompt"] == "1") {
                     $dial_string .= ",group_confirm_key=exec,group_confirm_file=lua confirm.lua,confirm=true,";
                 }
                 $dial_string .= ",leg_delay_start=" . $row["follow_me_delay"];
                 $dial_string .= ",leg_timeout=" . $row["follow_me_timeout"] . "]";
                 if (is_numeric($row["follow_me_destination"])) {
                     if ($_SESSION['domain']['bridge']['text'] == "outbound" || $_SESSION['domain']['bridge']['text'] == "bridge") {
                         $bridge = outbound_route_to_bridge($_SESSION['domain_uuid'], $row["follow_me_destination"]);
                         $dial_string .= $bridge[0] . ",";
                     } elseif ($_SESSION['domain']['bridge']['text'] == "loopback") {
                         $dial_string .= "loopback/" . $row["follow_me_destination"] . "/" . $_SESSION['domain_name'];
                     } elseif ($_SESSION['domain']['bridge']['text'] == "lcr") {
                         $dial_string .= "lcr/" . $_SESSION['lcr']['profile']['text'] . "/" . $_SESSION['domain_name'] . "/" . $row["follow_me_destination"];
                     } else {
                         $dial_string .= "loopback/" . $row["follow_me_destination"] . "/" . $_SESSION['domain_name'];
                     }
                 } else {
                     $dial_string .= $row["follow_me_destination"];
                 }
             }
             $x++;
         }
         $this->dial_string = $dial_string;
     } else {
         $this->dial_string = '';
     }
     $sql = "update v_follow_me set ";
     $sql .= "dial_string = '" . $this->dial_string . "' ";
     $sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
     $sql .= "and follow_me_uuid = '" . $this->follow_me_uuid . "' ";
     if ($this->debug) {
         echo $sql . "<br />";
     }
     $db->exec($sql);
     unset($sql);
     $sql = "update v_extensions set ";
     $sql .= "dial_string = '" . $this->dial_string . "', ";
     $sql .= "dial_domain = '" . $_SESSION['domain_name'] . "' ";
     $sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
     $sql .= "and follow_me_uuid = '" . $this->follow_me_uuid . "' ";
     if ($this->debug) {
         echo $sql . "<br />";
     }
     $db->exec($sql);
     unset($sql);
 }
     if ($autogen_users == "true") {
         $auto_user = $extension;
         for ($i = 1; $i <= $range; $i++) {
             $user_last_name = $auto_user;
             $user_password = generate_password();
             user_add($auto_user, $user_password, $user_email);
             $generated_users[$i]['username'] = $auto_user;
             $generated_users[$i]['password'] = $user_password;
             $auto_user++;
         }
         unset($auto_user);
     }
 }
 $j = 0;
 for ($i = 1; $i <= $range; $i++) {
     if (extension_exists($extension)) {
         //extension exists
     } else {
         //extension does not exist add it
         $extension_uuid = uuid();
         $password = generate_password();
         $sql = "insert into v_extensions ";
         $sql .= "(";
         $sql .= "domain_uuid, ";
         $sql .= "extension_uuid, ";
         $sql .= "extension, ";
         $sql .= "number_alias, ";
         $sql .= "password, ";
         if (if_group("superadmin") || if_group("admin") && $billing_app_exists) {
             $sql .= "accountcode, ";
         }
 private function content($fieldInfo, $value)
 {
     if (empty($value)) {
         return $value;
     }
     //下载内容图片
     if (isset($_POST['down_remote_pic']) && $_POST['down_remote_pic'] == 1 && extension_exists('curl')) {
         $Attachment = new Attachment();
         $value = $Attachment->download($value, array('jpg', 'gif', 'jpeg', 'png'), null, $this->mid);
     }
     return $value;
 }
Beispiel #5
0
 public function set()
 {
     //set the global variable
     global $db;
     //determine whether to update the dial string
     $sql = "select * from v_extensions ";
     $sql .= "where domain_uuid = '" . $this->domain_uuid . "' ";
     $sql .= "and extension_uuid = '" . $this->extension_uuid . "' ";
     $prep_statement = $db->prepare(check_sql($sql));
     $prep_statement->execute();
     $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
     if (count($result) > 0) {
         foreach ($result as &$row) {
             $this->extension = $row["extension"];
             $this->number_alias = $row["number_alias"];
             $this->accountcode = $row["accountcode"];
             $this->toll_allow = $row["toll_allow"];
             $this->outbound_caller_id_name = $row["outbound_caller_id_name"];
             $this->outbound_caller_id_number = $row["outbound_caller_id_number"];
         }
     }
     unset($prep_statement);
     //set the dial string
     if ($this->forward_all_enabled == "true") {
         $dial_string = "{presence_id=" . $this->forward_all_destination . "@" . $_SESSION['domain_name'];
         $dial_string .= ",instant_ringback=true";
         $dial_string .= ",domain_uuid=" . $_SESSION['domain_uuid'];
         $dial_string .= ",sip_invite_domain=" . $_SESSION['domain_name'];
         $dial_string .= ",domain_name=" . $_SESSION['domain_name'];
         $dial_string .= ",domain=" . $_SESSION['domain_name'];
         $dial_string .= ",extension_uuid=" . $this->extension_uuid;
         $dial_string .= ",toll_allow='" . $this->toll_allow . "'";
         if (strlen($this->accountcode) > 0) {
             $dial_string .= ",sip_h_X-accountcode=" . $this->accountcode;
             $dial_string .= ",accountcode=" . $this->accountcode;
         }
         if (strlen($this->forward_caller_id_uuid) > 0) {
             $sql_caller = "select destination_number, destination_description from v_destinations where domain_uuid = '{$this->domain_uuid}' and destination_type = 'inbound' and destination_uuid = '{$this->forward_caller_id_uuid}'";
             $prep_statement_caller = $db->prepare($sql_caller);
             if ($prep_statement_caller) {
                 $prep_statement_caller->execute();
                 $row_caller = $prep_statement_caller->fetch(PDO::FETCH_ASSOC);
                 if (strlen($row_caller['destination_description']) > 0) {
                     $dial_string_caller_id_name = $row_caller['destination_description'];
                     $dial_string .= ",origination_caller_id_name={$dial_string_caller_id_name}";
                 }
                 if (strlen($row_caller['destination_number']) > 0) {
                     $dial_string_caller_id_number = $row_caller['destination_number'];
                     $dial_string .= ",origination_caller_id_number={$dial_string_caller_id_number}";
                     $dial_string .= ",outbound_caller_id_number={$dial_string_caller_id_number}";
                 }
             }
         } else {
             if ($_SESSION['cdr']['call_forward_fix']['boolean'] == "true") {
                 $dial_string .= ",outbound_caller_id_name=" . $this->outbound_caller_id_name;
                 $dial_string .= ",outbound_caller_id_number=" . $this->outbound_caller_id_number;
                 $dial_string .= ",origination_caller_id_name=" . $this->outbound_caller_id_name;
                 $dial_string .= ",origination_caller_id_number=" . $this->outbound_caller_id_number;
             }
         }
         $dial_string .= "}";
         if (extension_exists($this->forward_all_destination)) {
             $dial_string .= "user/" . $this->forward_all_destination . "@" . $_SESSION['domain_name'];
         } else {
             if ($_SESSION['domain']['bridge']['text'] == "outbound" || $_SESSION['domain']['bridge']['text'] == "bridge") {
                 $bridge = outbound_route_to_bridge($_SESSION['domain_uuid'], $this->forward_all_destination);
                 $dial_string .= $bridge[0];
             } elseif ($_SESSION['domain']['bridge']['text'] == "lcr") {
                 $dial_string .= "lcr/" . $_SESSION['lcr']['profile']['text'] . "/" . $_SESSION['domain_name'] . "/" . $this->forward_all_destination;
             } elseif ($_SESSION['domain']['bridge']['text'] === "loopback") {
                 $dial_string .= "loopback/" . $this->forward_all_destination;
             } else {
                 $dial_string .= "loopback/" . $this->forward_all_destination;
             }
         }
         $this->dial_string = $dial_string;
     } else {
         $this->dial_string = '';
     }
     //update the extension
     $sql = "update v_extensions set ";
     if (strlen($this->forward_all_destination) == 0 || $this->forward_all_enabled == "false") {
         if (strlen($this->forward_all_destination) == 0) {
             $sql .= "forward_all_destination = null, ";
         }
         $sql .= "dial_string = null, ";
         $sql .= "forward_all_enabled = 'false' ";
     } else {
         $sql .= "forward_all_destination = '{$this->forward_all_destination}', ";
         $sql .= "dial_string = '" . check_str($this->dial_string) . "', ";
         $sql .= "forward_all_enabled = 'true' ";
     }
     $sql .= "where domain_uuid = '{$this->domain_uuid}' ";
     $sql .= "and extension_uuid = '{$this->extension_uuid}' ";
     if ($this->debug) {
         echo $sql;
     }
     $db->exec(check_sql($sql));
     unset($sql);
     //delete extension from memcache
     $cache = new cache();
     $cache->delete("directory:" . $this->extension . "@" . $this->domain_name);
     if (strlen($this->number_alias) > 0) {
         $cache->delete("directory:" . $this->number_alias . "@" . $this->domain_name);
     }
 }
 $sql .= "hunt_group_timeout_type = '{$hunt_group_timeout_type}', ";
 $sql .= "hunt_group_ringback = '{$hunt_group_ring_back}', ";
 $sql .= "hunt_group_cid_name_prefix = '{$hunt_group_cid_name_prefix}', ";
 $sql .= "hunt_group_pin = '{$hunt_group_pin}', ";
 $sql .= "hunt_group_call_prompt = '{$hunt_group_call_prompt}', ";
 $sql .= "hunt_group_caller_announce = '{$huntgroup_caller_announce}', ";
 $sql .= "hunt_group_user_list = '{$hunt_group_user_list}', ";
 $sql .= "hunt_group_enabled = '{$hunt_group_enabled}', ";
 $sql .= "hunt_group_description = '{$hunt_group_description}' ";
 $sql .= "where domain_uuid = '{$domain_uuid}' ";
 $sql .= "and hunt_group_uuid = '{$call_forward_uuid}'";
 $db->exec(check_sql($sql));
 unset($sql);
 //set the variables
 $destination_data = $call_forward_number;
 if (extension_exists($call_forward_number)) {
     $destination_type = 'extension';
 } else {
     $destination_type = 'sip uri';
 }
 $destination_profile = 'internal';
 $destination_timeout = '';
 $destination_order = '1';
 $destination_enabled = 'true';
 $destination_description = 'call forward';
 //delete related v_hunt_group_destinations
 $sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '{$call_forward_uuid}' ";
 $db->exec(check_sql($sql));
 //insert the v_hunt_group_destinations
 $hunt_group_destination_uuid = uuid();
 $sql = "insert into v_hunt_group_destinations ";
Beispiel #7
0
 public function add()
 {
     global $db;
     $domain_uuid = $this->domain_uuid;
     $domain_name = $this->domain_name;
     $extension = $this->extension;
     $number_alias = $this->number_alias;
     $password = $this->password;
     $autogen_users = $this->autogen_users;
     $provisioning_list = $this->provisioning_list;
     $vm_password = $this->vm_password;
     $accountcode = $this->accountcode;
     $effective_caller_id_name = $this->effective_caller_id_name;
     $effective_caller_id_number = $this->effective_caller_id_number;
     $outbound_caller_id_name = $this->outbound_caller_id_name;
     $outbound_caller_id_number = $this->outbound_caller_id_number;
     $limit_max = $this->limit_max;
     $limit_destination = $this->limit_destination;
     $vm_enabled = $this->vm_enabled;
     $vm_mailto = $this->vm_mailto;
     $vm_attach_file = $this->vm_attach_file;
     $vm_keep_local_after_email = $this->vm_keep_local_after_email;
     $user_context = $this->user_context;
     $toll_allow = $this->toll_allow;
     $call_group = $this->call_group;
     $hold_music = $this->hold_music;
     $auth_acl = $this->auth_acl;
     $cidr = $this->cidr;
     $sip_force_contact = $this->sip_force_contact;
     $sip_force_expires = $this->sip_force_expires;
     $nibble_account = $this->nibble_account;
     $mwi_account = $this->mwi_account;
     $sip_bypass_media = $this->sip_bypass_media;
     $enabled = $this->enabled;
     $description = $this->description;
     $db->beginTransaction();
     for ($i = 1; $i <= $range; $i++) {
         if (extension_exists($extension)) {
             //extension exists
         } else {
             //extension does not exist add it
             $password = generate_password();
             $sql = "insert into v_extensions ";
             $sql .= "(";
             $sql .= "domain_uuid, ";
             $sql .= "extension_uuid, ";
             $sql .= "extension, ";
             $sql .= "number_alias, ";
             $sql .= "password, ";
             $sql .= "provisioning_list, ";
             $sql .= "vm_password, ";
             $sql .= "accountcode, ";
             $sql .= "effective_caller_id_name, ";
             $sql .= "effective_caller_id_number, ";
             $sql .= "outbound_caller_id_name, ";
             $sql .= "outbound_caller_id_number, ";
             $sql .= "limit_max, ";
             $sql .= "limit_destination, ";
             $sql .= "vm_enabled, ";
             $sql .= "vm_mailto, ";
             $sql .= "vm_attach_file, ";
             $sql .= "vm_keep_local_after_email, ";
             $sql .= "user_context, ";
             $sql .= "toll_allow, ";
             $sql .= "call_group, ";
             $sql .= "hold_music, ";
             $sql .= "auth_acl, ";
             $sql .= "cidr, ";
             $sql .= "sip_force_contact, ";
             if (strlen($sip_force_expires) > 0) {
                 $sql .= "sip_force_expires, ";
             }
             if (strlen($nibble_account) > 0) {
                 $sql .= "nibble_account, ";
             }
             if (strlen($mwi_account) > 0) {
                 $sql .= "mwi_account, ";
             }
             $sql .= "sip_bypass_media, ";
             $sql .= "enabled, ";
             $sql .= "description ";
             $sql .= ")";
             $sql .= "values ";
             $sql .= "(";
             $sql .= "'{$domain_uuid}', ";
             $sql .= "'{$extension_uuid}', ";
             $sql .= "'{$extension}', ";
             $sql .= "'{$number_alias}', ";
             $sql .= "'{$password}', ";
             $sql .= "'{$provisioning_list}', ";
             $sql .= "'user-choose', ";
             $sql .= "'{$accountcode}', ";
             $sql .= "'{$effective_caller_id_name}', ";
             $sql .= "'{$effective_caller_id_number}', ";
             $sql .= "'{$outbound_caller_id_name}', ";
             $sql .= "'{$outbound_caller_id_number}', ";
             $sql .= "'{$limit_max}', ";
             $sql .= "'{$limit_destination}', ";
             $sql .= "'{$vm_enabled}', ";
             $sql .= "'{$vm_mailto}', ";
             $sql .= "'{$vm_attach_file}', ";
             $sql .= "'{$vm_keep_local_after_email}', ";
             $sql .= "'{$user_context}', ";
             $sql .= "'{$toll_allow}', ";
             $sql .= "'{$call_group}', ";
             $sql .= "'{$hold_music}', ";
             $sql .= "'{$auth_acl}', ";
             $sql .= "'{$cidr}', ";
             $sql .= "'{$sip_force_contact}', ";
             if (strlen($sip_force_expires) > 0) {
                 $sql .= "'{$sip_force_expires}', ";
             }
             if (strlen($nibble_account) > 0) {
                 $sql .= "'{$nibble_account}', ";
             }
             if (strlen($mwi_account) > 0) {
                 if (strpos($mwi_account, '@') === false) {
                     if (count($_SESSION["domains"]) > 1) {
                         $mwi_account .= "@" . $domain_name;
                     } else {
                         $mwi_account .= "@\$\${domain}";
                     }
                 }
                 $sql .= "'{$mwi_account}', ";
             }
             $sql .= "'{$sip_bypass_media}', ";
             $sql .= "'{$enabled}', ";
             $sql .= "'{$description}' ";
             $sql .= ")";
             $db->exec(check_sql($sql));
             unset($sql);
         }
         $extension++;
     }
     $db->commit();
 }