|
@@ -0,0 +1,513 @@
|
|
|
+/*
|
|
|
+============================================================================
|
|
|
+Name : generate_paging_conf.sh
|
|
|
+Author : ssc
|
|
|
+Version : v1.0
|
|
|
+Copyright : ZYCOO copyright
|
|
|
+Description : Generate paging info from mysql to paging conf file
|
|
|
+============================================================================
|
|
|
+*/
|
|
|
+
|
|
|
+#include <stdio.h>
|
|
|
+#include <stdlib.h>
|
|
|
+#include <string.h>
|
|
|
+#include <errno.h>
|
|
|
+#include <assert.h>
|
|
|
+#include <time.h>
|
|
|
+#include <ctype.h>
|
|
|
+#include <cjson/cJSON.h>
|
|
|
+
|
|
|
+#include <mysql/mysql.h>
|
|
|
+
|
|
|
+MYSQL *g_conn; // mysql 连接
|
|
|
+MYSQL_RES *g_res; // mysql group记录集
|
|
|
+MYSQL_ROW g_row; // 字符串数组,mysql 记录行
|
|
|
+MYSQL_RES *d_res; // mysql device记录集
|
|
|
+MYSQL_ROW d_row; // 字符串数组,mysql 记录行
|
|
|
+
|
|
|
+#define MAX_TRUNK_SIZE 256
|
|
|
+#define MAX_SIZE 2048
|
|
|
+#define MIDLE_SIZE 512
|
|
|
+#define MINI_SIZE 64
|
|
|
+#define MYSQL_CONNECT_CONF "/etc/asterisk/exten_gen.ini"
|
|
|
+#define EXTEN_PAGING_FILE "/etc/asterisk/extensions_paging_custom.conf"
|
|
|
+#define EXTEN_EXTENS_FILE "/etc/asterisk/extensions_extens_custom.conf"
|
|
|
+#define EXTEN_IPPHONES_FILE "/etc/asterisk/extensions_phones_custom.conf"
|
|
|
+#define KEYVALLEN 100
|
|
|
+#define VERSION "V1.0.1"
|
|
|
+
|
|
|
+#define QUERY_PAGING_GROUP_SQL "select id,name,exten from t_paging_groups"
|
|
|
+
|
|
|
+char g_host_name[MINI_SIZE];
|
|
|
+char g_user_name[MINI_SIZE];
|
|
|
+char g_password[MINI_SIZE];
|
|
|
+char g_db_name[MINI_SIZE];
|
|
|
+const unsigned int g_db_port = 3306;
|
|
|
+char sql_tmp[MIDLE_SIZE];
|
|
|
+char exten_tmp[MAX_SIZE];
|
|
|
+char dest_tmp[MAX_SIZE];
|
|
|
+
|
|
|
+//读取配置文件函数----功能:删除左边空格
|
|
|
+char *l_trim(char *szOutput, const char *szInput)
|
|
|
+{
|
|
|
+ assert(szInput != NULL);
|
|
|
+ assert(szOutput != NULL);
|
|
|
+ assert(szOutput != szInput);
|
|
|
+ for (NULL; *szInput != '\0' && isspace(*szInput); ++szInput)
|
|
|
+ {
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ return strcpy(szOutput, szInput);
|
|
|
+}
|
|
|
+
|
|
|
+// 删除右边的空格
|
|
|
+char *r_trim(char *szOutput, const char *szInput)
|
|
|
+{
|
|
|
+ char *p = NULL;
|
|
|
+ assert(szInput != NULL);
|
|
|
+ assert(szOutput != NULL);
|
|
|
+ assert(szOutput != szInput);
|
|
|
+ strcpy(szOutput, szInput);
|
|
|
+ for(p = szOutput + strlen(szOutput) - 1; p >= szOutput && isspace(*p); --p)
|
|
|
+ {
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ *(++p) = '\0';
|
|
|
+ return szOutput;
|
|
|
+}
|
|
|
+
|
|
|
+// 删除两边的空格
|
|
|
+char *a_trim(char *szOutput, const char *szInput)
|
|
|
+{
|
|
|
+ char *p = NULL;
|
|
|
+ assert(szInput != NULL);
|
|
|
+ assert(szOutput != NULL);
|
|
|
+ l_trim(szOutput, szInput);
|
|
|
+ for (p = szOutput + strlen(szOutput) - 1; p >= szOutput && isspace(*p); --p)
|
|
|
+ {
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ *(++p) = '\0';
|
|
|
+ return szOutput;
|
|
|
+}
|
|
|
+//main函数接口 参数1:配置文件路径 参数2:配置文件的那一部分,如general 参数3:键名 参数4:键值
|
|
|
+int GetProfileString(char *profile, char *AppName, char *KeyName, char *KeyVal )
|
|
|
+{
|
|
|
+ char appname[32], keyname[32];
|
|
|
+ char *buf, *c;
|
|
|
+ char buf_i[KEYVALLEN], buf_o[KEYVALLEN];
|
|
|
+ FILE *fp;
|
|
|
+ int found = 0; /* 1 AppName 2 KeyName */
|
|
|
+ if( (fp = fopen( profile, "r" )) == NULL )
|
|
|
+ {
|
|
|
+ printf( "openfile [%s] error [%s]\n", profile, strerror(errno) );
|
|
|
+ return(-1);
|
|
|
+ }
|
|
|
+ fseek( fp, 0, SEEK_SET );
|
|
|
+ memset( appname, 0, sizeof(appname) );
|
|
|
+ sprintf( appname, "[%s]", AppName );
|
|
|
+
|
|
|
+ while( !feof(fp) && fgets( buf_i, KEYVALLEN, fp ) != NULL )
|
|
|
+ {
|
|
|
+ l_trim(buf_o, buf_i);
|
|
|
+ if( strlen(buf_o) <= 0 )
|
|
|
+ continue;
|
|
|
+ buf = NULL;
|
|
|
+ buf = buf_o;
|
|
|
+
|
|
|
+ if( found == 0 )
|
|
|
+ {
|
|
|
+ if( buf[0] != '[' )
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else if ( strncmp(buf, appname, strlen(appname)) == 0 )
|
|
|
+ {
|
|
|
+ found = 1;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if( found == 1 )
|
|
|
+ {
|
|
|
+ if( buf[0] == '#' )
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else if ( buf[0] == '[' )
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if( (c = (char *)strchr(buf, '=')) == NULL )
|
|
|
+ continue;
|
|
|
+ memset( keyname, 0, sizeof(keyname) );
|
|
|
+
|
|
|
+ sscanf( buf, "%[^=|^ |^\t]", keyname );
|
|
|
+ if( strcmp(keyname, KeyName) == 0 )
|
|
|
+ {
|
|
|
+ sscanf( ++c, "%[^\n]", KeyVal );
|
|
|
+ char *KeyVal_o = (char *)malloc(strlen(KeyVal) + 1);
|
|
|
+ if(KeyVal_o != NULL)
|
|
|
+ {
|
|
|
+ memset(KeyVal_o, 0, sizeof(KeyVal_o));
|
|
|
+ a_trim(KeyVal_o, KeyVal);
|
|
|
+ if(KeyVal_o && strlen(KeyVal_o) > 0)
|
|
|
+ strcpy(KeyVal, KeyVal_o);
|
|
|
+ free(KeyVal_o);
|
|
|
+ KeyVal_o = NULL;
|
|
|
+ }
|
|
|
+ found = 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fclose( fp );
|
|
|
+ if( found == 2 )
|
|
|
+ return(0);
|
|
|
+ else
|
|
|
+ return(-1);
|
|
|
+}
|
|
|
+
|
|
|
+char * mytime(){
|
|
|
+ time_t my_time;
|
|
|
+ time(&my_time);
|
|
|
+ char *time_string = ctime(&my_time);
|
|
|
+ if (time_string[strlen(time_string) - 1] == '\n')
|
|
|
+ {
|
|
|
+ time_string[strlen(time_string) - 1] = '\0';
|
|
|
+ }
|
|
|
+ return time_string;
|
|
|
+}
|
|
|
+
|
|
|
+void print_mysql_error(const char *msg) { // 打印最后一次错误
|
|
|
+if (msg)
|
|
|
+ printf("%s: %s\n", msg, mysql_error(g_conn));
|
|
|
+else
|
|
|
+ puts(mysql_error(g_conn));
|
|
|
+}
|
|
|
+
|
|
|
+int executesql(const char * sql) {
|
|
|
+/*query the database according the sql*/
|
|
|
+if (mysql_real_query(g_conn, sql, strlen(sql))) // 如果失败
|
|
|
+ return -1; // 表示失败
|
|
|
+
|
|
|
+return 0; // 成功执行
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+int init_mysql() { // 初始化连接
|
|
|
+// init the database connection
|
|
|
+g_conn = mysql_init(NULL);
|
|
|
+
|
|
|
+/* connect the database */
|
|
|
+if(!mysql_real_connect(g_conn, g_host_name, g_user_name, g_password, g_db_name, g_db_port, NULL, 0)) // 如果失败
|
|
|
+ return -1;
|
|
|
+
|
|
|
+// 是否连接已经可用
|
|
|
+if (executesql("set names utf8")) // 如果失败
|
|
|
+ return -1;
|
|
|
+
|
|
|
+return 0; // 返回成功
|
|
|
+}
|
|
|
+
|
|
|
+//对比license文件 by dingyu
|
|
|
+static int check_license(void)
|
|
|
+{
|
|
|
+ char g_host_name[64];
|
|
|
+ char g_user_name[64] = "root";
|
|
|
+ char g_password[64];
|
|
|
+ char g_db_name[64] = "init_db";
|
|
|
+ char sql[256];
|
|
|
+ const unsigned int g_db_port = 3306;
|
|
|
+ MYSQL *g_conn;
|
|
|
+ MYSQL_RES *g_res;
|
|
|
+ MYSQL_ROW g_row;
|
|
|
+ cJSON *pJson;
|
|
|
+ FILE *fp; //文件1指针
|
|
|
+ FILE *fp2; //文件2指针
|
|
|
+ int line=0;
|
|
|
+ int i;
|
|
|
+ struct MD5Context md5;
|
|
|
+ unsigned char sum[16];
|
|
|
+ char file_str[1024];
|
|
|
+ char file_str2[1024];
|
|
|
+ char file_str3[1024];
|
|
|
+ char sumbuf[128];
|
|
|
+
|
|
|
+ memset(limited_datetime,'\0', sizeof(limited_datetime));
|
|
|
+ memset(serveruuid,'\0',sizeof(serveruuid));
|
|
|
+ strcpy(g_host_name,getenv("MYSQL"));
|
|
|
+ strcpy(g_password,getenv("MYSQL_ROOT_PASSWORD"));
|
|
|
+
|
|
|
+ g_conn = mysql_init(NULL);
|
|
|
+ if(mysql_real_connect(g_conn, g_host_name, g_user_name, g_password, g_db_name, g_db_port, NULL, 0))
|
|
|
+ {
|
|
|
+ /*query the database according the sql*/
|
|
|
+ mysql_query(g_conn, "set names utf8");
|
|
|
+ memset(sql,'\0', sizeof(sql));
|
|
|
+ sprintf(sql, "select * from D_T_S_Z_L where prop_key='SYSTEM_UUID'");
|
|
|
+ if (mysql_real_query(g_conn, sql, strlen(sql)) != 0){
|
|
|
+ mysql_close(g_conn); // 关闭链接
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ g_res = mysql_store_result(g_conn);
|
|
|
+ if(mysql_num_rows(g_res) == 0){
|
|
|
+ mysql_free_result(g_res); //释放结果
|
|
|
+ mysql_close(g_conn); // 关闭链接
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ g_row=mysql_fetch_row(g_res);
|
|
|
+
|
|
|
+ if(g_row[2] == NULL){
|
|
|
+ mysql_free_result(g_res); //释放结果
|
|
|
+ mysql_close(g_conn); // 关闭链接
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ strcpy(serveruuid,g_row[2]);
|
|
|
+ memset(sql,'\0', sizeof(sql));
|
|
|
+ sprintf(sql, "select * from D_T_S_Z_L where prop_key='LIMITED_DATETIME'");
|
|
|
+ if (mysql_real_query(g_conn, sql, strlen(sql)) != 0){
|
|
|
+ mysql_close(g_conn); // 关闭链接
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ g_res = mysql_store_result(g_conn);
|
|
|
+ if(mysql_num_rows(g_res) == 0){
|
|
|
+ mysql_free_result(g_res); //释放结果
|
|
|
+ mysql_close(g_conn); // 关闭链接
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ g_row=mysql_fetch_row(g_res);
|
|
|
+
|
|
|
+ if(g_row[2] == NULL){
|
|
|
+ mysql_free_result(g_res); //释放结果
|
|
|
+ mysql_close(g_conn); // 关闭链接
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ strcpy(limited_datetime,g_row[2]);
|
|
|
+ mysql_free_result(g_res);
|
|
|
+ mysql_close(g_conn);
|
|
|
+ fp=fopen("/music/license","r");//创建的文件
|
|
|
+ if(fp==NULL)
|
|
|
+ {
|
|
|
+ printf("open error\n");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ memset(file_str3,'\0',sizeof(file_str3));
|
|
|
+ if(fgets(file_str3,sizeof(file_str3),fp)){
|
|
|
+ if (file_str3[strlen(file_str3) - 1] == '\n')
|
|
|
+ {
|
|
|
+ file_str3[strlen(file_str3) - 1] = '\0';
|
|
|
+ }
|
|
|
+ pJson = cJSON_Parse(file_str3);
|
|
|
+ if ( !pJson ) {
|
|
|
+ printf( "parse failed!\n");
|
|
|
+ fclose(fp);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ maxclients = cJSON_GetObjectItem(pJson, "number")->valueint;
|
|
|
+ cJSON_Delete(pJson);
|
|
|
+
|
|
|
+ memset(file_str,'\0',sizeof(file_str));
|
|
|
+ sprintf(file_str,"%s+%d+8675309-Zycoo-nwcavertingoureyes@Coocenter.com",serveruuid,maxclients);
|
|
|
+ MD5Init(&md5);
|
|
|
+ MD5Update(&md5, (unsigned char *) file_str, strlen(file_str));
|
|
|
+ MD5Final(sum, &md5);
|
|
|
+ char tmp[16];
|
|
|
+ memset(sumbuf,0,sizeof(sumbuf));
|
|
|
+ memset(file_str2,0,sizeof(file_str2));
|
|
|
+ for(i=0;i<16;i++)
|
|
|
+ {
|
|
|
+ memset(tmp,0,sizeof(tmp));
|
|
|
+ sprintf(tmp,"%02x",sum[i]);
|
|
|
+ strcat(sumbuf,tmp);
|
|
|
+ }
|
|
|
+ fp2=fopen("/init/sql/.limited","r");//创建的文件
|
|
|
+ if(fp2==NULL)
|
|
|
+ {
|
|
|
+ printf("open error\n");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ while(fgets(file_str2,sizeof(file_str2),fp2))//逐行循环读取文件,直到文件结束
|
|
|
+ {
|
|
|
+ line++;
|
|
|
+ if(strstr(file_str2,sumbuf)) //检查字符串是否在该行中,如果在,则输出该行
|
|
|
+ {
|
|
|
+ fclose(fp2);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fclose(fp2);//关闭文件,结束
|
|
|
+ }
|
|
|
+ fclose(fp);//关闭文件,结束
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int main(int argc, char **argv) {
|
|
|
+ if(!check_license()){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+/*
|
|
|
+memset(g_host_name, 0, sizeof(g_host_name));
|
|
|
+memset(g_user_name, 0, sizeof(g_user_name));
|
|
|
+memset(g_password, 0, sizeof(g_password));
|
|
|
+memset(g_db_name, 0, sizeof(g_db_name));
|
|
|
+
|
|
|
+GetProfileString(MYSQL_CONNECT_CONF, "general", "dbserverip", g_host_name);
|
|
|
+GetProfileString(MYSQL_CONNECT_CONF, "general", "dbuser", g_user_name);
|
|
|
+GetProfileString(MYSQL_CONNECT_CONF, "general", "dbpasswd", g_password);
|
|
|
+GetProfileString(MYSQL_CONNECT_CONF, "general", "dbname", g_db_name);
|
|
|
+*/
|
|
|
+strcpy(g_host_name,getenv("MYSQL"));
|
|
|
+strcpy(g_user_name,getenv("MYSQL_USER"));
|
|
|
+strcpy(g_password,getenv("MYSQL_PASSWORD"));
|
|
|
+strcpy(g_db_name,getenv("MYSQL_DATABASE"));
|
|
|
+if (init_mysql()){
|
|
|
+ print_mysql_error(NULL);
|
|
|
+ exit(1);
|
|
|
+}
|
|
|
+
|
|
|
+if (executesql(QUERY_PAGING_GROUP_SQL)){
|
|
|
+ print_mysql_error(NULL);
|
|
|
+ exit(1);
|
|
|
+}
|
|
|
+
|
|
|
+g_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
|
|
|
+FILE *conf_paging_fp = fopen(EXTEN_PAGING_FILE, "w+");
|
|
|
+FILE *conf_extens_fp = fopen(EXTEN_EXTENS_FILE, "w+");
|
|
|
+FILE *conf_ipphones_fp = fopen(EXTEN_IPPHONES_FILE, "w+");
|
|
|
+
|
|
|
+if (conf_paging_fp == NULL){
|
|
|
+ perror("Open paging conf file Error: ");
|
|
|
+ exit(1);
|
|
|
+}
|
|
|
+
|
|
|
+ fprintf(conf_paging_fp, ";!\n\
|
|
|
+;! Automatically generated configuration file\n\
|
|
|
+;! Filename: extensions_paging_custom.conf (/etc/asterisk/extensions_paging_custom.conf)\n\
|
|
|
+;! Generator: Generator Paging\n\
|
|
|
+;! Creation Date: %s\n\
|
|
|
+;!\n\n\
|
|
|
+",\
|
|
|
+mytime()\
|
|
|
+);
|
|
|
+
|
|
|
+if (conf_extens_fp == NULL){
|
|
|
+ perror("Open extens conf file Error: ");
|
|
|
+ exit(1);
|
|
|
+}
|
|
|
+
|
|
|
+ fprintf(conf_extens_fp, ";!\n\
|
|
|
+;! Automatically generated configuration file\n\
|
|
|
+;! Filename: extensions_extens_custom.conf (/etc/asterisk/extensions_extens_custom.conf)\n\
|
|
|
+;! Generator: Generator Extens\n\
|
|
|
+;! Creation Date: %s\n\
|
|
|
+;!\n\n\
|
|
|
+",\
|
|
|
+mytime()\
|
|
|
+);
|
|
|
+
|
|
|
+if (conf_ipphones_fp == NULL){
|
|
|
+ perror("Open ipphones conf file Error: ");
|
|
|
+ exit(1);
|
|
|
+}
|
|
|
+
|
|
|
+ fprintf(conf_ipphones_fp, ";!\n\
|
|
|
+;! Automatically generated configuration file\n\
|
|
|
+;! Filename: extensions_phones_custom.conf (/etc/asterisk/extensions_phones_custom.conf)\n\
|
|
|
+;! Generator: Generator phones\n\
|
|
|
+;! Creation Date: %s\n\
|
|
|
+;!\n\n\
|
|
|
+",\
|
|
|
+mytime()\
|
|
|
+);
|
|
|
+while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
|
|
|
+ if (g_row[0] == NULL || g_row[1] == NULL || g_row[2] == NULL){
|
|
|
+ printf("some feild is empty!\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ fprintf(conf_extens_fp, "[extens-group-%s]\n",g_row[2]);
|
|
|
+ fprintf(conf_ipphones_fp, "[phones-group-%s]\n",g_row[2]);
|
|
|
+ memset(sql_tmp,0,sizeof(sql_tmp));
|
|
|
+ sprintf(sql_tmp,"select exten,type_id,allowed_pa from t_paging_deviceGroups JOIN t_paging_devices on t_paging_devices.id = t_paging_deviceGroups.DeviceId\
|
|
|
+ where GroupId = %s and t_paging_devices.type_id in('1','2','3','5') and t_paging_devices.user_id is NULL",g_row[0]);
|
|
|
+ if (executesql(sql_tmp)){
|
|
|
+ print_mysql_error(NULL);
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+ d_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
|
|
|
+ memset(exten_tmp,0,sizeof(exten_tmp));
|
|
|
+ memset(dest_tmp,0,sizeof(dest_tmp));
|
|
|
+ while ((d_row=mysql_fetch_row(d_res))){ // 打印结果集
|
|
|
+ if (d_row[0] == NULL || d_row[1] == NULL){
|
|
|
+ printf("some feild is empty!\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(strcmp(d_row[2],"yes") == 0){
|
|
|
+ sprintf(exten_tmp, "%sSIP/%s&", exten_tmp, d_row[0]);
|
|
|
+ sprintf(dest_tmp, "%s%s|", dest_tmp, d_row[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ int id = atoi(d_row[1]);
|
|
|
+ switch(id){
|
|
|
+ case 1:
|
|
|
+ fprintf(conf_extens_fp, "exten => %s,1,Macro(page,%s,SIP/%s)\n",d_row[0],d_row[0],d_row[0]);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ fprintf(conf_extens_fp, "exten => %s,1,Macro(intercom,%s,SIP/%s)\n",d_row[0],d_row[0],d_row[0]);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ case 7:
|
|
|
+ fprintf(conf_ipphones_fp, "exten => %s,1,Macro(stdexten,%s,SIP/%s)\n",d_row[0],d_row[0],d_row[0]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(strlen(exten_tmp) > 0){
|
|
|
+ exten_tmp[strlen(exten_tmp) - 1] = '\0';
|
|
|
+ dest_tmp[strlen(dest_tmp) - 1] = '\0';
|
|
|
+ }
|
|
|
+
|
|
|
+ fprintf(conf_extens_fp, "\n");
|
|
|
+
|
|
|
+ fprintf(conf_paging_fp, "\
|
|
|
+[paging-group-%s]\n\
|
|
|
+exten => %s,1,NoOp(%s)\n\
|
|
|
+same => n,MSet(__SRCEXTEN=${CALLERID(num)},__DESTS=%s,DATE=${STRFTIME(${EPOCH},,%%Y%%m%%d)},__UUID=${UNIQUEID},ALERTINFO=Alert-Info: Ring Answer,CALLINFO=Call-Info: <uri>\\;answer-after=0)\n\
|
|
|
+same => n,SIPAddHeader(${ALERTINFO})\n\
|
|
|
+same => n,SIPAddHeader(${CALLINFO})\n\
|
|
|
+same => n,System(/bin/sh /etc/scripts/shell_scripts.sh mkrcdir paging ${DATE})\n\
|
|
|
+same => n,Set(FILENAME=paging/${DATE}/paging-${SRCEXTEN}-${UUID}.wav)\n\
|
|
|
+same => n,MixMonitor(${FILENAME},b)\n\
|
|
|
+same => n,Macro(get-user-level,${SRCEXTEN},)\n\
|
|
|
+same => n,AGI(agi://${AGISERVERHOST}:${AGISERVERPORT},paging,${DESTS},${SESSION_LEVEL},${SESSION_USERID})\n\
|
|
|
+same => n,ExecIf(${ISNULL(${DESTS})}?Hangup())\n\
|
|
|
+same => n,ExecIf($['foo${enPaging_prompt_start}'='fooyes']?Set(STARTPROMPT=qA(start)))\n\
|
|
|
+same => n,UserEvent(controlEvent,sessionlevel:${SESSION_LEVEL},sessionuserid:${SESSION_USERID},src:${SRCEXTEN},dest:${DESTS},uuid:${UUID},status:stop)\n\
|
|
|
+same => n,Wait(1)\n\
|
|
|
+same => n,GotoIf(${ISNULL(${DESTCHANS})}?default)\n\
|
|
|
+same => n,MSet(startT=${STRFTIME(${EPOCH},,%%s)},__CALLEE=${DESTS},__calltype=paging)\n\
|
|
|
+same => n,Page(${DESTCHANS},b(paging-update-status^s^1)${STARTPROMPT})\n\
|
|
|
+same => n,Hangup\n\
|
|
|
+same => n(default),Page(%s,b(paging-update-status^s^1)${STARTPROMPT})\n\
|
|
|
+same => n,Hangup\
|
|
|
+\n\n", \
|
|
|
+g_row[2],\
|
|
|
+g_row[2],\
|
|
|
+g_row[1],\
|
|
|
+dest_tmp,\
|
|
|
+exten_tmp\
|
|
|
+);
|
|
|
+ }
|
|
|
+fclose(conf_paging_fp);
|
|
|
+fclose(conf_extens_fp);
|
|
|
+mysql_free_result(g_res); // 释放结果集
|
|
|
+mysql_free_result(d_res);
|
|
|
+mysql_close(g_conn); // 关闭链接
|
|
|
+}
|