function setHistory($options = array()) { $defaultOptions = array(); $defaultOptions['page_name'] = ''; $defaultOptions['action_type'] = ''; $defaultOptions['table'] = ''; $defaultOptions['id_name'] = 'id'; $defaultOptions['id_value'] = ''; $defaultOptions['remote'] = false; $defaultOptions['pname'] = ''; $options = array_merge($defaultOptions, $options); extract($options); $localcn = connectDB(); $user_id = $_SESSION['UserID']; $user_name = $_SESSION['UserName']; if ($localcn == '' || trim($action_type) == '' || trim($table) == '' || trim($id_value) == '' || trim($remote) == true && trim($pname) == '' || trim($action_type) != "add" && trim($action_type) != "delete" && trim($action_type) == 'edit') { return false; } $connection_string = $localcn; $remote_name = NULL; if ($remote === true) { $remoteCn = remote_connectDB($pname); $connection_string = $remoteCn; $remote_name = $pname; } $qry = "Select * from `{$table}` where {$id_name} = '{$id_value}'"; $res = Sql_exec($connection_string, $qry); $result = Sql_fetch_assoc($res); $value_json = json_encode($result); if ($remoteCn) { ClosedDBConnection($remoteCn); rollback_main_connectDB(); } if ($action_type == 'update') { $comments = 'Updated !'; } elseif ($action_type == 'add') { $comments = 'Inserted !'; } $row_value = $value_json; $action_command = $action_type; if ($page_name == "") { $page_name = $table; } $table_name = $table; $action_date = date("Y-m-d", strtotime("now")); $action_time = date("H:i:s", strtotime("now")); $ip_address = $_SERVER['REMOTE_ADDR']; $browser = $_SERVER['HTTP_USER_AGENT']; $referrer = $_SERVER['HTTP_REFERER']; $qry = "INSERT INTO tbl_audit_trail (user_id,user_name,action_command,pname,page_name,table_name,primary_key_column,action_date,action_time,rowvalue,comments,ip_address,browser,referer) VALUES"; $qry .= "('{$user_id}','{$user_name}','{$action_command}','{$remote_name}','{$page_name}','{$table_name}','{$id_name}','{$action_date}','{$action_time}','{$row_value}','{$comments}','{$ip_address}','{$browser}', '{$referrer}');"; $result = Sql_exec($localcn, $qry); $insert_id = Sql_insert_id($localcn); return $insert_id; }
$qry = "INSERT INTO `tbl_smsgw_contact_group` (`group_name`,`last_updated`)VALUES('{$group}',NOW())"; } elseif ($action == "update") { $qry = "UPDATE `tbl_smsgw_contact_group` SET `group_name`='{$group}' WHERE `id`='{$action_id}'"; } elseif ($action == "delete") { $qry = "UPDATE `tbl_smsgw_contact_group` SET `is_active` = 'inactive' WHERE `is_active`='active' AND `id`='{$action_id}'"; } try { $rs = Sql_exec($cn, $qry); if ($action != "delete") { if ($action == "update") { $options['page_name'] = "Bulk SMS Group"; $options['action_type'] = $action; $options['table'] = "tbl_smsgw_contact_group"; $options['id_value'] = $action_id; setHistory($options); } else { $action_id = Sql_insert_id($cn); $action = 'add'; $options['page_name'] = "Bulk SMS Group"; $options['action_type'] = $action; $options['table'] = "tbl_smsgw_contact_group"; $options['id_value'] = $action_id; setHistory($options); } } //$is_error = 0; } catch (Exception $e) { $is_error = 1; } ClosedDBConnection($cn); echo $is_error;
<?php require_once "../lib/common.php"; $remoteCn = remote_connectDB('ISMP'); $qry = "SELECT \t`app_id`,`app_name`,`config` FROM `tbl_smsgw_config` WHERE `app_id` = 1 AND `app_name` = 'smsgw'"; $res = Sql_exec($remoteCn, $qry); $dt = Sql_fetch_array($res); $decode = $dt['config']; $decode = json_decode($decode, true); $data = array(); foreach ($decode as $key => $val) { $data[$key] = $val; } $data['action_id'] = $dt['app_id']; echo json_encode($data); ClosedDBConnection($remoteCn);
function remote_connectDB($pname, $pname_field = 'pname', $table_name = 'tbl_process_db_access') { $cn = connectDB(); $remoteCnQry = "select * from {$table_name} where {$pname_field}='{$pname}'"; $res = Sql_exec($cn, $remoteCnQry); $dt = Sql_fetch_array($res); global $dbtype; global $UserID; global $Password; global $Server; global $Database; global $temp_dbtype; global $temp_UserID; global $temp_Password; global $temp_Server; global $temp_Database; $temp_dbtype = $dbtype; $temp_UserID = $UserID; $temp_Password = $Password; $temp_Server = $Server; $temp_Database = $Database; $dbtype = $dt['db_type']; $Server = $dt['db_server']; $UserID = $dt['db_uid']; $Password = $dt['db_password']; $Database = $dt['db_name']; ClosedDBConnection($cn); $cn = connectDB(); return $cn; }
} ClosedDBConnection($cn); if ($v_arr == NULL || count($v_arr) == 0) { echo json_encode($result_arr); exit; } $dbtype = $v_arr["db_type"]; $Server = $v_arr["server"]; $UserID = $v_arr["user_id"]; $Password = $v_arr["password"]; $Database = $v_arr["database"]; $newcn = connectDB(); if (!$newcn) { echo json_encode($result_arr); exit; } $qry = "SELECT `play_file` FROM `ivrmenu` WHERE `Service`='" . $serviceName . "' AND `play_file` LIKE '%/ismp/shared/%'"; $res = Sql_exec($newcn, $qry); if (!$res) { echo json_encode($result_arr); exit; } while ($dt = Sql_fetch_array($res)) { $play_file = $dt['play_file']; //$ServiceName = $dt['ServiceName']; $result_arr[$play_file] = $play_file; } ClosedDBConnection($newcn); echo json_encode($result_arr); } //end of else of serverId is empty