public static function deleteFeedbackByNode($node_whole, $idc) { if ($node_whole === NULL || $idc === NULL) { QconfMgrLog::err(__FILE__, __LINE__, "Parameter 'node_whole' or 'idc' is NULL"); return FALSE; } ArgsUtil::setSQLEscape($node_whole); ArgsUtil::setSQLEscape($idc); $update = "delete from qconf_feedback where node_whole='{$node_whole}' and idc='{$idc}'"; $res = self::executeQuery($update); if ($res === FALSE) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC {$update} failed!"); return FALSE; } return TRUE; }
public static function recordOp($op_type_code, $hostname, $node_whole, $idc, $data_type, $value_md5, $update_time) { $op_time = date('Y-m-d H:i:s', time()); ArgsUtil::setSQLEscape($op_type_code); ArgsUtil::setSQLEscape($hostname); ArgsUtil::setSQLEscape($node_whole); ArgsUtil::setSQLEscape($idc); ArgsUtil::setSQLEscape($data_type); ArgsUtil::setSQLEscape($value_md5); ArgsUtil::setSQLEscape($update_time); ArgsUtil::setSQLEscape($op_time); $query = "insert into qconf_feedback_op (op_type_code, hostname, node_whole, idc, data_type, value_md5, update_time, op_time) \n values ('{$op_type_code}', '{$hostname}', '{$node_whole}', '{$idc}', '{$data_type}', '{$value_md5}', '{$update_time}', '{$op_time}')"; $res = self::executeQuery($query); if ($res === FALSE) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC '{$query}' failed!"); return FALSE; } return TRUE; }
/** * modify feedback with feedback_id */ public static function modifyFeedback($fd_id, $ip, $value_md5, $value, $update_time) { if ($fd_id === NULL || $value_md5 === NULL) { QconfMgrLog::err(__FILE__, __LINE__, "fd_id or value_md5 is NULL"); return FALSE; } $exist = self::existFeedback($fd_id); if ($exist === FALSE) { QconfMgrLog::err(__FILE__, __LINE__, "feedback item with id({$fd_id}) does not exist!"); return FALSE; } ArgsUtil::setSQLEscape($ip); ArgsUtil::setSQLEscape($value_md5); ArgsUtil::setSQLEscape($value); ArgsUtil::setSQLEscape($update_time); $update = "update qconf_feedback set ip = '{$ip}', value_md5 = '{$value_md5}'," . " value = '{$value}', update_time = '{$update_time}' where feedback_id = '{$fd_id}'"; $res = self::executeQuery($update); if ($res === FALSE) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC '{$query}' failed!"); return FALSE; } return TRUE; }
public static function insert($parent_node_id, $node, $node_type_code, $node_whole, $main_buss_id, $sub_buss_id, $idc, $note) { ArgsUtil::setSQLEscape($node); ArgsUtil::setSQLEscape($node_whole); ArgsUtil::setSQLEscape($idc); ArgsUtil::setSQLEscape($note); ArgsUtil::setSQLEscape($node_type_code); ArgsUtil::setVal($parent_node_id); ArgsUtil::setVal($main_buss_id); $p_query = "select * from qconf_node where node_id = '{$parent_node_id}'"; $p_res = self::executeQuery($p_query); if ($p_res === FALSE) { return FALSE; } $p_num = mysql_num_rows($p_res); if ($p_num === 0) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC '{$p_query}' failed!"); return FALSE; } $p_row = mysql_fetch_array($p_res, MYSQL_ASSOC); $p_level = $p_row["node_level"]; $node_level = intval($p_level) + 1; $cal_node_level = PathUtil::calNodeLevel($node_whole); $query = "insert into qconf_node values(NULL, '{$parent_node_id}', '{$node}', '{$node_type_code}'," . " '{$node_whole}', '{$cal_node_level}', {$main_buss_id}, {$sub_buss_id}, '{$idc}', '{$note}')"; $ret = self::executeQuery($query); if ($ret === FALSE) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC '{$query}' failed!"); return FALSE; } // update the parent node type if ($p_row["node_type_code"] == InfoDescUtil::NODE_TYPE_NORMAL) { $update = "update qconf_node set node_type_code = '" . InfoDescUtil::NODE_TYPE_NORMAL_FATHER . "' where node_id = '{$parent_node_id}'"; $ret = self::executeQuery($update); if ($ret === FALSE) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC '{$update}' failed!"); return FALSE; } } return TRUE; }
public static function delPermByIdc($perm_node, $main_buss_id, $idc) { if ($perm_node === NULL || $perm_node === "" || $main_buss_id === NULL || $main_buss_id === "" || $idc === NULL || $idc === "") { QconfMgrLog::err(__FILE__, __LINE__, "perm_node, main_buss_id or idc is NULL"); return FALSE; } ArgsUtil::setSQLEscape($perm_node); ArgsUtil::setSQLEscape($main_buss_id); ArgsUtil::setSQLEscape($idc); $query = "select * from qconf_perm where node = '{$perm_node}' and main_buss_id = '{$main_buss_id}'"; $res = self::executeQuery($query); if ($res === FALSE) { return FALSE; } // 1. not found the perm $num = mysql_num_rows($res); if ($num === 0) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC '{$query}' failed!"); return FALSE; } $row = mysql_fetch_array($res, MYSQL_ASSOC); $perm_id = $row["perm_id"]; $idc_list = preg_split("/[,]+/", $row['idc']); foreach ($idc_list as $idc_tmp) { if (strcmp($idc, $idc_tmp) !== 0) { $idc_left .= ",{$idc_tmp}"; } } if (!isset($idc_left)) { $query = "delete from qconf_perm where perm_id = '{$perm_id}'"; } else { $idc_left = trim($idc_left, ","); $query = "update qconf_perm set idc = '{$idc_left}' where perm_id = '{$perm_id}'"; } // 2. update the idc info $res = self::executeQuery($query); if ($res === FALSE) { QconfMgrLog::err(__FILE__, __LINE__, "EXEC {$query} failed!"); return FALSE; } return TRUE; }
/** * insert a record into the database */ public static function insert($op_type_code, $node, $idc, $op_status_code, $main_buss_id, $sub_buss_id, $op_user, $msg) { $op_id = GuidUtil::guidGenerator(); $op_time = date('Y-m-d H:i:s', time()); ArgsUtil::setSQLEscape($op_type_code); ArgsUtil::setSQLEscape($node); ArgsUtil::setSQLEscape($idc); ArgsUtil::setSQLEscape($op_status_code); ArgsUtil::setVal($main_buss_id); ArgsUtil::setVal($sub_buss_id); ArgsUtil::setSQLEscape($op_user); ArgsUtil::setSQLEscape($msg); $query = "insert into qconf_op values (NULL, '{$op_id}', '{$op_type_code}', '{$node}', '{$idc}', '{$op_time}',\n '{$op_status_code}', {$main_buss_id}, {$sub_buss_id}, '{$op_user}', '{$msg}');"; return self::executeQuery($query); }
public function deleteNormal($normal_user, $node_whole) { if ($normal_user === NULL || $normal_user === "" || $node_whole === NULL || $node_whole === "") { QconfMgrLog::err(__FILE__, __LINE__, "normal_user or node is NULL"); return FALSE; } $node_whole = "/" . trim($node_whole, "/") . "/"; ArgsUtil::setSQLEscape($normal_user); ArgsUtil::setSQLEscape($node_whole); $query = "select count(*) from qconf_normal_perm where binary user_name = '{$normal_user}' and binary node = '{$node_whole}'"; $res = self::executeQuery($query); if ($res === FALSE) { return FALSE; } $ret_arr = mysql_fetch_array($res, MYSQL_NUM); if ($ret_arr[0] <= 0) { return InfoDescUtil::ERR_USER_PERM_NODE_NOT_EXIST; } $query = "delete from qconf_normal_perm where binary user_name = '{$normal_user}' and binary node = '{$node_whole}'"; $res = self::executeQuery($query); if ($res === FALSE) { return FALSE; } return InfoDescUtil::QCONF_OK; }