Esempio n. 1
0
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;
}
Esempio n. 2
0
<?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);
Esempio n. 3
0
//
//
//$remoteCnQry = "select * from tbl_process_db_access where pname='SMSGW'";
//$res = Sql_exec($cn, $remoteCnQry);
//$dt = Sql_fetch_array($res);
//
//$dbtype = $dt['db_type'];
//$Server = $dt['db_server'];
//$UserID = $dt['db_uid'];
//$Password = $dt['db_password'];
//$Database = $dt['db_name'];
//ClosedDBConnection($cn);
//
//$remoteCn = connectDB();
//
$remoteCn = remote_connectDB('SMSGW');
//$cn = connectDB();
$action = "";
$shortcode = "";
$keyword = "";
$SMSText = "";
$SrcType = "";
$URL = "";
$Status = "";
//$destination_context = "";
//$is_error = 1;
$action = mysql_real_escape_string(htmlspecialchars($_REQUEST['action']));
$data_info = isset($_REQUEST['info']) ? $_REQUEST['info'] : 'action';
if ($data_info != 'action') {
    $action = $data_info['action'];
    $deleted_id = $data_info['deleted_id'];
Esempio n. 4
0
<?php

require_once "../lib/common.php";
$info = $_POST['info'];
$remoteCn = remote_connectDB('CGW');
$action = mysql_real_escape_string(htmlspecialchars($info['action']));
$action_id = mysql_real_escape_string(htmlspecialchars($info['action_id']));
$time_slot_id = mysql_real_escape_string(htmlspecialchars($info['time_slot_id']));
$start_day = mysql_real_escape_string(htmlspecialchars($info['start_day']));
$end_day = mysql_real_escape_string(htmlspecialchars($info['end_day']));
$start_time = mysql_real_escape_string(htmlspecialchars($info['start_time']));
$end_time = mysql_real_escape_string(htmlspecialchars($info['end_time']));
$is_error = 0;
if ($action == "insert") {
    $qry = "INSERT INTO `timeslot` (`TimeSlotID`,`StartDay`,`EndDay`,`StartTime`,`EndTime`,`LastUpdate`,`is_active`)\n\t\t\t\tVALUES('{$time_slot_id}','{$start_day}','{$end_day}','{$start_time}','{$end_time}',NOW(),'active')";
} elseif ($action == "update") {
    $qry = "UPDATE timeslot \n\t\t\t\tSET\n\t\t\t\t\t`StartDay` = {$start_day} , \n\t\t\t\t\t`EndDay` = {$end_day} , \n\t\t\t\t\t`StartTime` = {$start_time} , \n\t\t\t\t\t`EndTime` = {$end_time},\n\t\t\t\t\t`LastUpdate`= NOW()\n\t\t\t\tWHERE TimeSlotID = '{$time_slot_id}'";
} elseif ($action == "delete") {
    $qry = "update `timeslot` set `is_active`='inactive' where `is_active`='active' and `TimeSlotID`='{$action_id}'";
    //$qry = "delete from `timeslot` where `TimeSlotID`='".$action_id."'";
}
try {
    $res = Sql_exec($remoteCn, $qry);
} catch (Exception $e) {
    $is_error = 1;
}
echo $is_error;
if ($remoteCn) {
    ClosedDBConnection($remoteCn);
}
Esempio n. 5
0
$cn = connectDB();
$query = "SELECT * FROM {$tbl_pre} where id={$id_pre}";
$result = Sql_exec($cn, $query);
if (!$result) {
    echo "err+" . $query . " in line " . __LINE__ . " of file" . __FILE__;
    exit;
}
$row = Sql_fetch_array($result);
$tbl = $row['table_name'];
$primary_key = $row['primary_key_column'];
$data = array();
$data = (array) json_decode($row['rowvalue']);
$key_value = $data[$primary_key];
unset($data[$primary_key]);
if ($row['pname'] != '' && $row['pname'] != null) {
    $cn = remote_connectDB($row['pname']);
    /*
        $query = "SELECT * FROM `tbl_process_db_access` where `pname`='" . $row['pname'] . "'";
        $result = Sql_exec($cn, $query);
        if (!$result) {
            echo "err+" . $query . " in line " . __LINE__ . " of file" . __FILE__;
            exit;
        }
    
        $row_2 = Sql_fetch_array($result);
    
        $dbtype = $row_2['db_type'];
        $UserID = $row_2['db_uid'];
        $Password = $row_2['db_password'];
        $Server = $row_2['db_server'];
        $Database = $row_2['db_name'];