question_type,
				question_difficulty,
				question_enabled,
				question_position,
				question_timer,
				question_fullscreen,
				question_inline_answers,
				question_auto_next
				) VALUES (
				' . $question_subject_id . ',
				\'' . F_escape_sql($question_description) . '\',
				' . F_empty_to_null($question_explanation) . ',
				\'' . $question_type . '\',
				\'' . $question_difficulty . '\',
				\'' . $question_enabled . '\',
				' . F_zero_to_null($question_position) . ',
				\'' . $question_timer . '\',
				\'' . $question_fullscreen . '\',
				\'' . $question_inline_answers . '\',
				\'' . $question_auto_next . '\'
				)';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
            } else {
                $question_id = F_db_insert_id($db, K_TABLE_QUESTIONS, 'question_id');
            }
            $sql = 'COMMIT';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
                break;
            }
    /**
     * Add a new answer if not exist.
     * @private
     */
    private function addAnswer()
    {
        global $l, $db;
        require_once '../config/tce_config.php';
        if ($this->level_data['module']['module_id'] === false) {
            return;
        }
        if ($this->level_data['subject']['subject_id'] === false) {
            return;
        }
        if (isset($this->level_data['answer']['answer_id']) and $this->level_data['answer']['answer_id'] > 0) {
            return;
        }
        // check if this answer already exist
        $sql = 'SELECT answer_id
			FROM ' . K_TABLE_ANSWERS . '
			WHERE ';
        if (K_DATABASE_TYPE == 'ORACLE') {
            $sql .= 'dbms_lob.instr(answer_description, \'' . $this->level_data['answer']['answer_description'] . '\',1,1)>0';
        } else {
            $sql .= 'answer_description=\'' . $this->level_data['answer']['answer_description'] . '\'';
        }
        $sql .= ' AND answer_question_id=' . $this->level_data['question']['question_id'] . ' LIMIT 1';
        if ($r = F_db_query($sql, $db)) {
            if ($m = F_db_fetch_array($r)) {
                // get existing subject ID
                $this->level_data['answer']['answer_id'] = $m['answer_id'];
            } else {
                $sql = 'START TRANSACTION';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error();
                }
                $sql = 'INSERT INTO ' . K_TABLE_ANSWERS . ' (
					answer_question_id,
					answer_description,
					answer_explanation,
					answer_isright,
					answer_enabled,
					answer_position,
					answer_keyboard_key
					) VALUES (
					' . $this->level_data['question']['question_id'] . ',
					\'' . $this->level_data['answer']['answer_description'] . '\',
					' . F_empty_to_null($this->level_data['answer']['answer_explanation']) . ',
					\'' . $this->boolval[$this->level_data['answer']['answer_isright']] . '\',
					\'' . $this->boolval[$this->level_data['answer']['answer_enabled']] . '\',
					' . F_zero_to_null($this->level_data['answer']['answer_position']) . ',
					' . F_empty_to_null($this->level_data['answer']['answer_keyboard_key']) . '
					)';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error(false);
                    F_db_query('ROLLBACK', $db);
                } else {
                    // get new answer ID
                    $this->level_data['answer']['answer_id'] = F_db_insert_id($db, K_TABLE_ANSWERS, 'answer_id');
                }
                $sql = 'COMMIT';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error();
                }
            }
        } else {
            F_display_db_error();
        }
    }
Esempio n. 3
0
/**
 * Copy selected question to another topic
 * @author Nicola Asuni
 * @since 2008-11-26
 * @param $question_id (int) question ID
 * @param $new_subject_id (int) new subject ID
 */
function F_question_copy($question_id, $new_subject_id)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    $question_id = intval($question_id);
    $new_subject_id = intval($new_subject_id);
    // check authorization
    $sql = 'SELECT subject_module_id FROM ' . K_TABLE_SUBJECTS . ' WHERE subject_id=' . $new_subject_id . ' LIMIT 1';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_array($r)) {
            $subject_module_id = $m['subject_module_id'];
            // check user's authorization for parent module
            if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $subject_module_id, 'module_user_id')) {
                return;
            }
        }
    } else {
        F_display_db_error();
        return;
    }
    $q = F_question_get_data($question_id);
    if ($q !== false) {
        if (K_DATABASE_TYPE == 'ORACLE') {
            $chksql = 'dbms_lob.instr(question_description,\'' . F_escape_sql($db, $q['question_description']) . '\',1,1)>0';
        } elseif (K_DATABASE_TYPE == 'MYSQL' and defined('K_MYSQL_QA_BIN_UNIQUITY') and K_MYSQL_QA_BIN_UNIQUITY) {
            $chksql = 'question_description=\'' . F_escape_sql($db, $q['question_description']) . '\' COLLATE utf8_bin';
        } else {
            $chksql = 'question_description=\'' . F_escape_sql($db, $q['question_description']) . '\'';
        }
        if (F_check_unique(K_TABLE_QUESTIONS, $chksql . ' AND question_subject_id=' . $new_subject_id . '')) {
            $sql = 'START TRANSACTION';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
                break;
            }
            // adjust questions ordering
            if ($q['question_position'] > 0) {
                $sql = 'UPDATE ' . K_TABLE_QUESTIONS . ' SET
					question_position=question_position+1
					WHERE question_subject_id=' . $new_subject_id . '
						AND question_position>=' . $q['question_position'] . '';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error(false);
                    F_db_query('ROLLBACK', $db);
                    // rollback transaction
                }
            }
            $sql = 'INSERT INTO ' . K_TABLE_QUESTIONS . ' (
				question_subject_id,
				question_description,
				question_explanation,
				question_type,
				question_difficulty,
				question_enabled,
				question_position,
				question_timer,
				question_fullscreen,
				question_inline_answers,
				question_auto_next
				) VALUES (
				' . $new_subject_id . ',
				\'' . F_escape_sql($db, $q['question_description']) . '\',
				\'' . F_escape_sql($db, $q['question_explanation']) . '\',
				\'' . $q['question_type'] . '\',
				\'' . $q['question_difficulty'] . '\',
				\'' . $q['question_enabled'] . '\',
				' . F_zero_to_null($q['question_position']) . ',
				\'' . $q['question_timer'] . '\',
				\'' . $q['question_fullscreen'] . '\',
				\'' . $q['question_inline_answers'] . '\',
				\'' . $q['question_auto_next'] . '\'
				)';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
            } else {
                $new_question_id = F_db_insert_id($db, K_TABLE_QUESTIONS, 'question_id');
            }
            // copy associated answers
            $sql = 'SELECT *
				FROM ' . K_TABLE_ANSWERS . '
				WHERE answer_question_id=' . $question_id . '';
            if ($r = F_db_query($sql, $db)) {
                while ($m = F_db_fetch_array($r)) {
                    $sqli = 'INSERT INTO ' . K_TABLE_ANSWERS . ' (
						answer_question_id,
						answer_description,
						answer_explanation,
						answer_isright,
						answer_enabled,
						answer_position,
						answer_keyboard_key
						) VALUES (
						' . $new_question_id . ',
						\'' . F_escape_sql($db, $m['answer_description']) . '\',
						\'' . F_escape_sql($db, $m['answer_explanation']) . '\',
						\'' . $m['answer_isright'] . '\',
						\'' . $m['answer_enabled'] . '\',
						' . F_zero_to_null($m['answer_position']) . ',
						' . F_empty_to_null($m['answer_keyboard_key']) . '
						)';
                    if (!($ri = F_db_query($sqli, $db))) {
                        F_display_db_error(false);
                        F_db_query('ROLLBACK', $db);
                        // rollback transaction
                    }
                }
            } else {
                F_display_db_error();
            }
            $sql = 'COMMIT';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
                break;
            }
        }
    }
}
            }
            $sql = 'INSERT INTO ' . K_TABLE_ANSWERS . ' (
				answer_question_id,
				answer_description,
				answer_explanation,
				answer_isright,
				answer_enabled,
				answer_position,
				answer_keyboard_key
				) VALUES (
				' . $answer_question_id . ',
				\'' . F_escape_sql($answer_description) . '\',
				' . F_empty_to_null($answer_explanation) . ',
				\'' . $answer_isright . '\',
				\'' . $answer_enabled . '\',
				' . F_zero_to_null($answer_position) . ',
				' . F_empty_to_null($answer_keyboard_key) . '
				)';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
                F_db_query('ROLLBACK', $db);
                // rollback transaction
            } else {
                $answer_id = F_db_insert_id($db, K_TABLE_ANSWERS, 'answer_id');
            }
            $sql = 'COMMIT';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
                break;
            }
        }
Esempio n. 5
0
/**
 * Import questions from TSV file (tab delimited text).
 * The format of TSV is the same obtained by exporting data from TCExam interface.
 * @param $tsvfile (string) TSV (tab delimited text) file name
 * @return boolean TRUE in case of success, FALSE otherwise
 */
function F_TSVQuestionImporter($tsvfile)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    require_once '../../shared/code/tce_functions_auth_sql.php';
    $qtype = array('S' => 1, 'M' => 2, 'T' => 3, 'O' => 4);
    // get file content as array
    $tsvrows = file($tsvfile, FILE_IGNORE_NEW_LINES);
    // array of TSV lines
    if ($tsvrows === FALSE) {
        return FALSE;
    }
    $current_module_id = 0;
    $current_subject_id = 0;
    $current_question_id = 0;
    $current_answer_id = 0;
    $questionhash = array();
    // for each row
    while (list($item, $rowdata) = each($tsvrows)) {
        // get user data into array
        $qdata = explode("\t", $rowdata);
        switch ($qdata[0]) {
            case 'M':
                // MODULE
                $current_module_id = 0;
                if (!isset($qdata[2]) or empty($qdata[2])) {
                    break;
                }
                $module_enabled = intval($qdata[1]);
                $module_name = F_escape_sql($db, F_tsv_to_text($qdata[2]), false);
                // check if this module already exist
                $sql = 'SELECT module_id
					FROM ' . K_TABLE_MODULES . '
					WHERE module_name=\'' . $module_name . '\'
					LIMIT 1';
                if ($r = F_db_query($sql, $db)) {
                    if ($m = F_db_fetch_array($r)) {
                        // get existing module ID
                        if (!F_isAuthorizedUser(K_TABLE_MODULES, 'module_id', $m['module_id'], 'module_user_id')) {
                            // unauthorized user
                            $current_module_id = 0;
                        } else {
                            $current_module_id = $m['module_id'];
                        }
                    } else {
                        // insert new module
                        $sql = 'INSERT INTO ' . K_TABLE_MODULES . ' (
							module_name,
							module_enabled,
							module_user_id
							) VALUES (
							\'' . $module_name . '\',
							\'' . $module_enabled . '\',
							\'' . $_SESSION['session_user_id'] . '\'
							)';
                        if (!($r = F_db_query($sql, $db))) {
                            F_display_db_error();
                        } else {
                            // get new module ID
                            $current_module_id = F_db_insert_id($db, K_TABLE_MODULES, 'module_id');
                        }
                    }
                } else {
                    F_display_db_error();
                }
                break;
            case 'S':
                // SUBJECT
                $current_subject_id = 0;
                if ($current_module_id == 0) {
                    return;
                }
                if (!isset($qdata[2]) or empty($qdata[2])) {
                    break;
                }
                $subject_enabled = intval($qdata[1]);
                $subject_name = F_escape_sql($db, F_tsv_to_text($qdata[2]), false);
                $subject_description = '';
                if (isset($qdata[3])) {
                    $subject_description = F_empty_to_null(F_tsv_to_text($qdata[3]));
                }
                // check if this subject already exist
                $sql = 'SELECT subject_id
					FROM ' . K_TABLE_SUBJECTS . '
					WHERE subject_name=\'' . $subject_name . '\'
						AND subject_module_id=' . $current_module_id . '
					LIMIT 1';
                if ($r = F_db_query($sql, $db)) {
                    if ($m = F_db_fetch_array($r)) {
                        // get existing subject ID
                        $current_subject_id = $m['subject_id'];
                    } else {
                        // insert new subject
                        $sql = 'INSERT INTO ' . K_TABLE_SUBJECTS . ' (
							subject_name,
							subject_description,
							subject_enabled,
							subject_user_id,
							subject_module_id
							) VALUES (
							\'' . $subject_name . '\',
							' . $subject_description . ',
							\'' . $subject_enabled . '\',
							\'' . $_SESSION['session_user_id'] . '\',
							' . $current_module_id . '
							)';
                        if (!($r = F_db_query($sql, $db))) {
                            F_display_db_error();
                        } else {
                            // get new subject ID
                            $current_subject_id = F_db_insert_id($db, K_TABLE_SUBJECTS, 'subject_id');
                        }
                    }
                } else {
                    F_display_db_error();
                }
                break;
            case 'Q':
                // QUESTION
                $current_question_id = 0;
                if ($current_module_id == 0 or $current_subject_id == 0) {
                    return;
                }
                if (!isset($qdata[5])) {
                    break;
                }
                $question_enabled = intval($qdata[1]);
                $question_description = F_escape_sql($db, F_tsv_to_text($qdata[2]), false);
                $question_explanation = F_empty_to_null(F_tsv_to_text($qdata[3]));
                $question_type = $qtype[$qdata[4]];
                $question_difficulty = intval($qdata[5]);
                if (isset($qdata[6])) {
                    $question_position = F_zero_to_null($qdata[6]);
                } else {
                    $question_position = F_zero_to_null(0);
                }
                if (isset($qdata[7])) {
                    $question_timer = intval($qdata[7]);
                } else {
                    $question_timer = 0;
                }
                if (isset($qdata[8])) {
                    $question_fullscreen = intval($qdata[8]);
                } else {
                    $question_fullscreen = 0;
                }
                if (isset($qdata[9])) {
                    $question_inline_answers = intval($qdata[9]);
                } else {
                    $question_inline_answers = 0;
                }
                if (isset($qdata[10])) {
                    $question_auto_next = intval($qdata[10]);
                } else {
                    $question_auto_next = 0;
                }
                // check if this question already exist
                $sql = 'SELECT question_id
					FROM ' . K_TABLE_QUESTIONS . '
					WHERE ';
                if (K_DATABASE_TYPE == 'ORACLE') {
                    $sql .= 'dbms_lob.instr(question_description,\'' . $question_description . '\',1,1)>0';
                } elseif (K_DATABASE_TYPE == 'MYSQL' and K_MYSQL_QA_BIN_UNIQUITY) {
                    $sql .= 'question_description=\'' . $question_description . '\' COLLATE utf8_bin';
                } else {
                    $sql .= 'question_description=\'' . $question_description . '\'';
                }
                $sql .= ' AND question_subject_id=' . $current_subject_id . ' LIMIT 1';
                if ($r = F_db_query($sql, $db)) {
                    if ($m = F_db_fetch_array($r)) {
                        // get existing question ID
                        $current_question_id = $m['question_id'];
                        return;
                    }
                } else {
                    F_display_db_error();
                }
                if (K_DATABASE_TYPE == 'MYSQL') {
                    // this section is to avoid the problems on MySQL string comparison
                    $maxkey = 240;
                    $strkeylimit = min($maxkey, strlen($question_description));
                    $stop = $maxkey / 3;
                    while (in_array(md5(strtolower(substr($current_subject_id . $question_description, 0, $strkeylimit))), $questionhash) and $stop > 0) {
                        // a similar question was already imported, so we change it a little bit to avoid duplicate keys
                        $question_description = '_' . $question_description;
                        $strkeylimit = min($maxkey, $strkeylimit + 1);
                        $stop--;
                        // variable used to avoid infinite loop
                    }
                    if ($stop == 0) {
                        F_print_error('ERROR', 'Unable to get unique question ID');
                        return;
                    }
                }
                $sql = 'START TRANSACTION';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error();
                }
                // insert question
                $sql = 'INSERT INTO ' . K_TABLE_QUESTIONS . ' (
					question_subject_id,
					question_description,
					question_explanation,
					question_type,
					question_difficulty,
					question_enabled,
					question_position,
					question_timer,
					question_fullscreen,
					question_inline_answers,
					question_auto_next
					) VALUES (
					' . $current_subject_id . ',
					\'' . $question_description . '\',
					' . $question_explanation . ',
					\'' . $question_type . '\',
					\'' . $question_difficulty . '\',
					\'' . $question_enabled . '\',
					' . $question_position . ',
					\'' . $question_timer . '\',
					\'' . $question_fullscreen . '\',
					\'' . $question_inline_answers . '\',
					\'' . $question_auto_next . '\'
					)';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error(false);
                } else {
                    // get new question ID
                    $current_question_id = F_db_insert_id($db, K_TABLE_QUESTIONS, 'question_id');
                    if (K_DATABASE_TYPE == 'MYSQL') {
                        $questionhash[] = md5(strtolower(substr($current_subject_id . $question_description, 0, $strkeylimit)));
                    }
                }
                $sql = 'COMMIT';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error();
                }
                break;
            case 'A':
                // ANSWER
                $current_answer_id = 0;
                if ($current_module_id == 0 or $current_subject_id == 0 or $current_question_id == 0) {
                    return;
                }
                if (!isset($qdata[4])) {
                    break;
                }
                $answer_enabled = intval($qdata[1]);
                $answer_description = F_escape_sql($db, F_tsv_to_text($qdata[2]), false);
                $answer_explanation = F_empty_to_null(F_tsv_to_text($qdata[3]));
                $answer_isright = intval($qdata[4]);
                if (isset($qdata[5])) {
                    $answer_position = F_zero_to_null($qdata[5]);
                } else {
                    $answer_position = F_zero_to_null(0);
                }
                if (isset($qdata[6])) {
                    $answer_keyboard_key = F_empty_to_null(F_tsv_to_text($qdata[6]));
                } else {
                    $answer_keyboard_key = F_empty_to_null('');
                }
                // check if this answer already exist
                $sql = 'SELECT answer_id
					FROM ' . K_TABLE_ANSWERS . '
					WHERE ';
                if (K_DATABASE_TYPE == 'ORACLE') {
                    $sql .= 'dbms_lob.instr(answer_description, \'' . $answer_description . '\',1,1)>0';
                } elseif (K_DATABASE_TYPE == 'MYSQL' and K_MYSQL_QA_BIN_UNIQUITY) {
                    $sql .= 'answer_description=\'' . $answer_description . '\' COLLATE utf8_bin';
                } else {
                    $sql .= 'answer_description=\'' . $answer_description . '\'';
                }
                $sql .= ' AND answer_question_id=' . $current_question_id . ' LIMIT 1';
                if ($r = F_db_query($sql, $db)) {
                    if ($m = F_db_fetch_array($r)) {
                        // get existing subject ID
                        $current_answer_id = $m['answer_id'];
                    } else {
                        $sql = 'START TRANSACTION';
                        if (!($r = F_db_query($sql, $db))) {
                            F_display_db_error();
                        }
                        $sql = 'INSERT INTO ' . K_TABLE_ANSWERS . ' (
							answer_question_id,
							answer_description,
							answer_explanation,
							answer_isright,
							answer_enabled,
							answer_position,
							answer_keyboard_key
							) VALUES (
							' . $current_question_id . ',
							\'' . $answer_description . '\',
							' . $answer_explanation . ',
							\'' . $answer_isright . '\',
							\'' . $answer_enabled . '\',
							' . $answer_position . ',
							' . $answer_keyboard_key . '
							)';
                        if (!($r = F_db_query($sql, $db))) {
                            F_display_db_error(false);
                            F_db_query('ROLLBACK', $db);
                        } else {
                            // get new answer ID
                            $current_answer_id = F_db_insert_id($db, K_TABLE_ANSWERS, 'answer_id');
                        }
                        $sql = 'COMMIT';
                        if (!($r = F_db_query($sql, $db))) {
                            F_display_db_error();
                        }
                    }
                } else {
                    F_display_db_error();
                }
                break;
        }
        // end of switch
    }
    // end of while
    return TRUE;
}
Esempio n. 6
0
/**
 * Import the specifed server object.
 * @param $srv (array) array containing object data.
 * @return true in case of success, false otherwise
 */
function F_importServerObj($srv)
{
    global $l, $db;
    require_once '../config/tce_config.php';
    if (!isset($srv['serial']) or empty($srv['serial'])) {
        F_print_error('ERROR', 'missing serial');
        return false;
    }
    // get ID of the object with the same serial number
    $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ' WHERE obj_tag=\'' . F_escape_sql($srv['serial']) . '\' LIMIT 1';
    if ($r = F_db_query($sql, $db)) {
        if ($m = F_db_fetch_assoc($r)) {
            $obj_id = $m['obj_id'];
        } else {
            // this object do not exist.
            F_print_error('ERROR', $srv['serial']);
            return false;
        }
    } else {
        F_display_db_error(false);
        return false;
    }
    // attribute map
    $srvattrmap = array('hostname' => 66, 'os release' => 68, 'os type' => 67, 'kernel name' => 69, 'kernel release' => 70, 'kernel version' => 71, 'kernel architecture' => 72, 'product' => 17, 'uuid' => 26);
    // for each attribute
    foreach ($srvattrmap as $k => $v) {
        if (isset($srv[$k]) and strlen($srv[$k]) > 0) {
            $value = $srv[$k];
            if ($k == 'product' and isset($srv['manufacturer']) and !empty($srv['manufacturer'])) {
                $value = $srv['manufacturer'] . ' ' . $value;
            }
            // add or update attribute value
            $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
				atv_obj_id,
				atv_atb_id,
				atv_value
				) VALUES (
				' . $obj_id . ',
				' . $v . ',
				\'' . F_escape_sql($value) . '\'
				)';
            if (!($ra = F_db_query($sqla, $db))) {
                F_display_db_error(false);
                return false;
            }
        }
    }
    // cpu attribute map
    $cpuattrmap = array('Socket Designation' => 92, 'Family' => 94, 'ID' => 93, 'Architecture' => 56, 'CPU op-mode(s)' => 83, 'Byte Order' => 84, 'Thread(s) per core' => 85, 'Core(s) per socket' => 55, 'Vendor ID' => 86, 'CPU family' => 87, 'Model' => 88, 'Stepping' => 89, 'CPU MHz' => 25, 'Virtualization' => 90, 'L1d cache' => 81, 'L1i cache' => 82, 'L1 cache' => 57, 'L2 cache' => 58, 'L3 cache' => 59);
    // cpu
    if (isset($srv['dmi']['Processor Information']) and !empty($srv['dmi']['Processor Information'])) {
        $cpucount = 0;
        foreach ($srv['dmi']['Processor Information'] as $cpu) {
            ++$cpucount;
            $cpuname = sprintf('CPU%02d', $cpucount);
            // check if CPU exist
            $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
				WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $obj_id . ' AND obj_obt_id=58 AND obj_name=\'' . $cpuname . '\'
				ORDER BY obj_name';
            if ($r = F_db_query($sql, $db)) {
                if ($m = F_db_fetch_assoc($r)) {
                    // update existing object
                    $cpu_obj_id = $m['obj_id'];
                } else {
                    // create new object
                    $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
						obj_obt_id,
						obj_name,
						obj_description,
						obj_label,
						obj_tag,
						obj_mnf_id,
						obj_owner_id,
						obj_tenant_id
						) VALUES (
						58,
						\'' . $cpuname . '\',
						' . F_empty_to_null('') . ',
						' . F_empty_to_null('') . ',
						' . F_empty_to_null('') . ',
						' . F_zero_to_null(0) . ',
						' . F_zero_to_null(0) . ',
						' . F_zero_to_null(0) . '
						)';
                    if (!($ro = F_db_query($sqlo, $db))) {
                        F_display_db_error(false);
                        return false;
                    } else {
                        $cpu_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                    }
                    // set object map
                    $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
						omp_parent_obj_id,
						omp_child_obj_id
						) VALUES (
						' . $obj_id . ',
						' . $cpu_obj_id . '
						)';
                    if (!($rm = F_db_query($sqlm, $db))) {
                        F_display_db_error(false);
                        return false;
                    }
                }
                // for each attribute
                foreach ($cpuattrmap as $k => $v) {
                    $value = '';
                    if (isset($cpu[$k])) {
                        $value = $cpu[$k];
                    } elseif (isset($srv['cpu'][$k])) {
                        $value = $srv['cpu'][$k];
                    }
                    if (preg_match('/([0-9\\.]+)[\\s]?([KMGT][B]?)/', $value, $vmtch) > 0) {
                        $value = $vmtch[1];
                    }
                    if (strlen($value) > 0) {
                        // add or update attribute value
                        $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
							atv_obj_id,
							atv_atb_id,
							atv_value
							) VALUES (
							' . $cpu_obj_id . ',
							' . $v . ',
							\'' . F_escape_sql($value) . '\'
							)';
                        if (!($ra = F_db_query($sqla, $db))) {
                            F_display_db_error(false);
                            return false;
                        }
                    }
                }
            } else {
                F_display_db_error(false);
                return false;
            }
        }
    }
    // memory attribute map
    $memattrmap = array('Total Width' => 95, 'Data Width' => 96, 'Size' => 52, 'Form Factor' => 97, 'Locator' => 99, 'Type' => 98, 'Speed' => 61);
    // memory
    if (isset($srv['ram']) and !empty($srv['ram'])) {
        // get total ram in gigabytes
        $totalram = round(floatval($srv['ram']) / 1024 / 1024 / 1024);
        // check if RAM object exist
        $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
				WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $obj_id . ' AND obj_obt_id=59
				ORDER BY obj_name';
        if ($r = F_db_query($sql, $db)) {
            if ($m = F_db_fetch_assoc($r)) {
                // update existing object
                $ram_obj_id = $m['obj_id'];
            } else {
                // create new object
                $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
						obj_obt_id,
						obj_name,
						obj_description,
						obj_label,
						obj_tag,
						obj_mnf_id,
						obj_owner_id,
						obj_tenant_id
						) VALUES (
						59,
						\'RAM\',
						' . F_empty_to_null('') . ',
						' . F_empty_to_null('') . ',
						' . F_empty_to_null('') . ',
						' . F_zero_to_null(0) . ',
						' . F_zero_to_null(0) . ',
						' . F_zero_to_null(0) . '
						)';
                if (!($ro = F_db_query($sqlo, $db))) {
                    F_display_db_error(false);
                    return false;
                } else {
                    $ram_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                }
                // set object map
                $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
						omp_parent_obj_id,
						omp_child_obj_id
						) VALUES (
						' . $obj_id . ',
						' . $ram_obj_id . '
						)';
                if (!($rm = F_db_query($sqlm, $db))) {
                    F_display_db_error(false);
                    return false;
                }
            }
            // add or update attribute value
            $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
					atv_obj_id,
					atv_atb_id,
					atv_value
					) VALUES (
					' . $ram_obj_id . ',
					60,
					\'' . F_escape_sql($totalram) . '\'
					)';
            if (!($ra = F_db_query($sqla, $db))) {
                F_display_db_error(false);
                return false;
            }
        } else {
            F_display_db_error(false);
            return false;
        }
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        if (isset($srv['dmi']['Memory Device']) and !empty($srv['dmi']['Memory Device'])) {
            $memcount = 0;
            foreach ($srv['dmi']['Memory Device'] as $mem) {
                ++$memcount;
                $memname = sprintf('SLOT%02d', $memcount);
                // check if object exist
                $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
					WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $ram_obj_id . ' AND obj_obt_id=60 AND obj_name=\'' . $memname . '\'
					ORDER BY obj_name';
                if ($r = F_db_query($sql, $db)) {
                    if ($m = F_db_fetch_assoc($r)) {
                        // update existing memory slot object
                        $mem_obj_id = $m['obj_id'];
                    } else {
                        // create new object
                        $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
							obj_obt_id,
							obj_name,
							obj_description,
							obj_label,
							obj_tag,
							obj_mnf_id,
							obj_owner_id,
							obj_tenant_id
							) VALUES (
							60,
							\'' . $memname . '\',
							' . F_empty_to_null('') . ',
							' . F_empty_to_null('') . ',
							' . F_empty_to_null('') . ',
							' . F_zero_to_null(0) . ',
							' . F_zero_to_null(0) . ',
							' . F_zero_to_null(0) . '
							)';
                        if (!($ro = F_db_query($sqlo, $db))) {
                            F_display_db_error(false);
                            return false;
                        } else {
                            $mem_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                        }
                        // set object map
                        $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
							omp_parent_obj_id,
							omp_child_obj_id
							) VALUES (
							' . $ram_obj_id . ',
							' . $mem_obj_id . '
							)';
                        if (!($rm = F_db_query($sqlm, $db))) {
                            F_display_db_error(false);
                            return false;
                        }
                    }
                    // for each memory attribute
                    foreach ($memattrmap as $k => $v) {
                        $value = '';
                        if (isset($mem[$k])) {
                            $value = $mem[$k];
                            if ($k == 'Size' or $k == 'Speed') {
                                $value = intval($value);
                            }
                            // add or update attribute value
                            $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
								atv_obj_id,
								atv_atb_id,
								atv_value
								) VALUES (
								' . $mem_obj_id . ',
								' . $v . ',
								\'' . F_escape_sql($value) . '\'
								)';
                            if (!($ra = F_db_query($sqla, $db))) {
                                F_display_db_error(false);
                                return false;
                            }
                        }
                    }
                } else {
                    F_display_db_error(false);
                    return false;
                }
            }
        }
    }
    // end srv['ram']
    // network attribute map
    $netattrmap = array('device' => 74, 'mac' => 9, 'ipv4' => 10, 'bcast' => 75, 'mask' => 76, 'ipv6' => 73, 'encap' => 77, 'scope' => 78, 'mtu' => 79, 'metric' => 80);
    // network
    if (isset($srv['network']) and !empty($srv['network'])) {
        $netcount = 0;
        foreach ($srv['network'] as $net) {
            if (preg_match('/^eth[0-9]+$/', $net['device']) > 0) {
                ++$netcount;
                $netname = sprintf('ETH%02d', $netcount);
                // check if device exist
                $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
					WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $obj_id . ' AND obj_obt_id=37 AND obj_name=\'' . $netname . '\'
					ORDER BY obj_name';
                if ($r = F_db_query($sql, $db)) {
                    if ($m = F_db_fetch_assoc($r)) {
                        // update existing object
                        $net_obj_id = $m['obj_id'];
                    } else {
                        // create new object
                        $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
							obj_obt_id,
							obj_name,
							obj_description,
							obj_label,
							obj_tag,
							obj_mnf_id,
							obj_owner_id,
							obj_tenant_id
							) VALUES (
							37,
							\'' . $netname . '\',
							' . F_empty_to_null('') . ',
							' . F_empty_to_null('') . ',
							' . F_empty_to_null('') . ',
							' . F_zero_to_null(0) . ',
							' . F_zero_to_null(0) . ',
							' . F_zero_to_null(0) . '
							)';
                        if (!($ro = F_db_query($sqlo, $db))) {
                            F_display_db_error(false);
                            return false;
                        } else {
                            $net_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                        }
                        // set object map
                        $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
							omp_parent_obj_id,
							omp_child_obj_id
							) VALUES (
							' . $obj_id . ',
							' . $net_obj_id . '
							)';
                        if (!($rm = F_db_query($sqlm, $db))) {
                            F_display_db_error(false);
                            return false;
                        }
                    }
                    // for each attribute
                    foreach ($netattrmap as $k => $v) {
                        $value = '';
                        if (isset($net[$k])) {
                            $value = $net[$k];
                        } elseif (isset($srv['net'][$k])) {
                            $value = $srv['net'][$k];
                        }
                        if (strlen($value) > 0) {
                            // add or update attribute value
                            $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
								atv_obj_id,
								atv_atb_id,
								atv_value
								) VALUES (
								' . $net_obj_id . ',
								' . $v . ',
								\'' . F_escape_sql($value) . '\'
								)';
                            if (!($ra = F_db_query($sqla, $db))) {
                                F_display_db_error(false);
                                return false;
                            }
                        }
                    }
                } else {
                    F_display_db_error(false);
                    return false;
                }
            }
        }
    }
    // disk controller (8) attribute map
    $ctrlattrmap = array('Bus Interface' => 100, 'Slot' => 101, 'Cache Serial Number' => 102, 'Hardware Revision' => 103, 'Firmware Version' => 104, 'Total Cache Size' => 105, 'Total Cache Memory Available' => 106);
    // disk array (65) attribute map
    $darrattrmap = array('Interface Type' => 122);
    // logical drive (66) attribute map
    $logdrvattrmap = array('Size' => 123, 'Fault Tolerance' => 107, 'Heads' => 108, 'Sectors Per Track' => 109, 'Cylinders' => 110, 'Strip Size' => 111, 'Full Stripe Size' => 112, 'Caching' => 113, 'Unique Identifier' => 114, 'Disk Name' => 115, 'Mount Points' => 116, 'Logical Drive Label' => 117, 'Drive Type' => 118);
    // physical drive (66) attribute map
    $phydrvattrmap = array('Port' => 119, 'Box' => 120, 'Bay' => 121, 'Drive Type' => 118, 'Interface Type' => 122, 'Size' => 123, 'Rotational Speed' => 124, 'Firmware Revision' => 104, 'Model' => 125, 'PHY Transfer Rate' => 126);
    $disknum = 0;
    $logdrvdisks = array();
    // list physical disks that belongs to logical drives
    // hp disk controller data
    if (isset($srv['hpdisks']) and !empty($srv['hpdisks'])) {
        $ctrlcount = 0;
        foreach ($srv['hpdisks'] as $ctrl) {
            ++$ctrlcount;
            $ctrlname = sprintf('DISKCTRL%02d', $ctrlcount);
            // check if device exist
            $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
				WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $obj_id . ' AND obj_obt_id=8 AND obj_name=\'' . $ctrlname . '\'
				ORDER BY obj_name';
            if ($r = F_db_query($sql, $db)) {
                if ($m = F_db_fetch_assoc($r)) {
                    // update existing object
                    $ctrl_obj_id = $m['obj_id'];
                } else {
                    // create new object
                    $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
						obj_obt_id,
						obj_name,
						obj_description,
						obj_label,
						obj_tag,
						obj_mnf_id,
						obj_owner_id,
						obj_tenant_id
						) VALUES (
						8,
						\'' . $ctrlname . '\',
						' . F_empty_to_null($ctrl['item']) . ',
						' . F_empty_to_null('') . ',
						' . F_empty_to_null($ctrl['Serial Number']) . ',
						' . F_zero_to_null(0) . ',
						' . F_zero_to_null(0) . ',
						' . F_zero_to_null(0) . '
						)';
                    if (!($ro = F_db_query($sqlo, $db))) {
                        F_display_db_error(false);
                        return false;
                    } else {
                        $ctrl_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                    }
                    // set object map
                    $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
						omp_parent_obj_id,
						omp_child_obj_id
						) VALUES (
						' . $obj_id . ',
						' . $ctrl_obj_id . '
						)';
                    if (!($rm = F_db_query($sqlm, $db))) {
                        F_display_db_error(false);
                        return false;
                    }
                }
                // for each attribute
                foreach ($ctrlattrmap as $k => $v) {
                    $value = '';
                    if (isset($ctrl[$k]) and strlen($ctrl[$k]) > 0) {
                        $value = $ctrl[$k];
                        if (preg_match('/([0-9\\.]+)[\\s]?([KMGT]B|Gbps)/', $value, $vmtch) > 0) {
                            $value = $vmtch[1];
                        }
                        // add or update attribute value
                        $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
							atv_obj_id,
							atv_atb_id,
							atv_value
							) VALUES (
							' . $ctrl_obj_id . ',
							' . $v . ',
							\'' . F_escape_sql($value) . '\'
							)';
                        if (!($ra = F_db_query($sqla, $db))) {
                            F_display_db_error(false);
                            return false;
                        }
                    }
                }
            } else {
                F_display_db_error(false);
                return false;
            }
            // - - - - - - - - - -
            // disk arrays
            foreach ($ctrl as $ck => $darr) {
                if (is_array($darr) and $darr['item'] == 'Array') {
                    $diskarrayname = sprintf('ARRAY%02d', $ck + 1);
                    // check if device exist
                    $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
						WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $ctrl_obj_id . ' AND obj_obt_id=65 AND obj_name=\'' . $diskarrayname . '\'
						ORDER BY obj_name';
                    if ($r = F_db_query($sql, $db)) {
                        if ($m = F_db_fetch_assoc($r)) {
                            // update existing object
                            $darr_obj_id = $m['obj_id'];
                        } else {
                            // create new object
                            $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
								obj_obt_id,
								obj_name,
								obj_description,
								obj_label,
								obj_tag,
								obj_mnf_id,
								obj_owner_id,
								obj_tenant_id
								) VALUES (
								65,
								\'' . $diskarrayname . '\',
								' . F_empty_to_null($darr['item']) . ',
								' . F_empty_to_null('') . ',
								' . F_empty_to_null($darr['value']) . ',
								' . F_zero_to_null(0) . ',
								' . F_zero_to_null(0) . ',
								' . F_zero_to_null(0) . '
								)';
                            if (!($ro = F_db_query($sqlo, $db))) {
                                F_display_db_error(false);
                                return false;
                            } else {
                                $darr_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                            }
                            // set object map
                            $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
								omp_parent_obj_id,
								omp_child_obj_id
								) VALUES (
								' . $ctrl_obj_id . ',
								' . $darr_obj_id . '
								)';
                            if (!($rm = F_db_query($sqlm, $db))) {
                                F_display_db_error(false);
                                return false;
                            }
                        }
                        // for each attribute
                        foreach ($darrattrmap as $k => $v) {
                            $value = '';
                            if (isset($darr[$k]) and strlen($darr[$k]) > 0) {
                                $value = $darr[$k];
                                // add or update attribute value
                                $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
									atv_obj_id,
									atv_atb_id,
									atv_value
									) VALUES (
									' . $darr_obj_id . ',
									' . $v . ',
									\'' . F_escape_sql($value) . '\'
									)';
                                if (!($ra = F_db_query($sqla, $db))) {
                                    F_display_db_error(false);
                                    return false;
                                }
                            }
                        }
                    } else {
                        F_display_db_error(false);
                        return false;
                    }
                    // - - - - - - - - - -
                    // logical (66) and physical (61) disks
                    foreach ($darr as $dk => $dsk) {
                        if (is_array($dsk)) {
                            if ($dsk['item'] == 'Logical Drive') {
                                $ldiskname = sprintf('LOGICALDRIVE%02d', $dk + 1);
                                // check if device exist
                                $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
									WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $darr_obj_id . ' AND obj_obt_id=66 AND obj_name=\'' . $ldiskname . '\'
									ORDER BY obj_name';
                                if ($r = F_db_query($sql, $db)) {
                                    if ($m = F_db_fetch_assoc($r)) {
                                        // update existing object
                                        $ldsk_obj_id = $m['obj_id'];
                                    } else {
                                        // create new object
                                        $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
											obj_obt_id,
											obj_name,
											obj_description,
											obj_label,
											obj_tag,
											obj_mnf_id,
											obj_owner_id,
											obj_tenant_id
											) VALUES (
											66,
											\'' . $ldiskname . '\',
											' . F_empty_to_null($dsk['item']) . ',
											' . F_empty_to_null('') . ',
											' . F_empty_to_null($dsk['value']) . ',
											' . F_zero_to_null(0) . ',
											' . F_zero_to_null(0) . ',
											' . F_zero_to_null(0) . '
											)';
                                        if (!($ro = F_db_query($sqlo, $db))) {
                                            F_display_db_error(false);
                                            return false;
                                        } else {
                                            $ldsk_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                                        }
                                        // set object map
                                        $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
											omp_parent_obj_id,
											omp_child_obj_id
											) VALUES (
											' . $darr_obj_id . ',
											' . $ldsk_obj_id . '
											)';
                                        if (!($rm = F_db_query($sqlm, $db))) {
                                            F_display_db_error(false);
                                            return false;
                                        }
                                    }
                                    // for each attribute
                                    foreach ($logdrvattrmap as $k => $v) {
                                        $value = '';
                                        if (isset($dsk[$k]) and strlen($dsk[$k]) > 0) {
                                            $value = $dsk[$k];
                                            if (preg_match('/([0-9\\.]+)[\\s]?([KMGT]B|Gbps)/', $value, $vmtch) > 0) {
                                                $value = $vmtch[1];
                                            }
                                            // add or update attribute value
                                            $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
												atv_obj_id,
												atv_atb_id,
												atv_value
												) VALUES (
												' . $ldsk_obj_id . ',
												' . $v . ',
												\'' . F_escape_sql($value) . '\'
												)';
                                            if (!($ra = F_db_query($sqla, $db))) {
                                                F_display_db_error(false);
                                                return false;
                                            }
                                        }
                                    }
                                } else {
                                    F_display_db_error(false);
                                    return false;
                                }
                                $logdrvdisks[$ldsk_obj_id] = array();
                            } elseif ($dsk['item'] == 'physicaldrive') {
                                ++$disknum;
                                $diskname = sprintf('DISK%02d', $disknum);
                                $logdrvdisks[$ldsk_obj_id][] = $diskname;
                                // check if device exist
                                $sql = 'SELECT obj_id FROM ' . K_TABLE_OBJECTS . ', ' . K_TABLE_OBJECTS_MAP . '
									WHERE obj_id=omp_child_obj_id AND omp_parent_obj_id=' . $ctrl_obj_id . ' AND obj_obt_id=61 AND obj_name=\'' . $diskname . '\'
									ORDER BY obj_name';
                                if ($r = F_db_query($sql, $db)) {
                                    if ($m = F_db_fetch_assoc($r)) {
                                        // update existing object
                                        $pdsk_obj_id = $m['obj_id'];
                                    } else {
                                        // create new object
                                        $sqlo = 'INSERT INTO ' . K_TABLE_OBJECTS . ' (
											obj_obt_id,
											obj_name,
											obj_description,
											obj_label,
											obj_tag,
											obj_mnf_id,
											obj_owner_id,
											obj_tenant_id
											) VALUES (
											61,
											\'' . $diskname . '\',
											' . F_empty_to_null($dsk['item']) . ',
											' . F_empty_to_null('') . ',
											' . F_empty_to_null($dsk['value']) . ',
											' . F_zero_to_null(0) . ',
											' . F_zero_to_null(0) . ',
											' . F_zero_to_null(0) . '
											)';
                                        if (!($ro = F_db_query($sqlo, $db))) {
                                            F_display_db_error(false);
                                            return false;
                                        } else {
                                            $pdsk_obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
                                        }
                                        // set object map
                                        $sqlm = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
											omp_parent_obj_id,
											omp_child_obj_id
											) VALUES (
											' . $ctrl_obj_id . ',
											' . $pdsk_obj_id . '
											)';
                                        if (!($rm = F_db_query($sqlm, $db))) {
                                            F_display_db_error(false);
                                            return false;
                                        }
                                    }
                                    // for each attribute
                                    foreach ($phydrvattrmap as $k => $v) {
                                        $value = '';
                                        if (isset($dsk[$k]) and strlen($dsk[$k]) > 0) {
                                            $value = $dsk[$k];
                                            if (preg_match('/([0-9\\.]+)[\\s]?([KMGT]B|Gbps)/', $value, $vmtch) > 0) {
                                                $value = $vmtch[1];
                                            }
                                            // add or update attribute value
                                            $sqla = 'REPLACE INTO ' . K_TABLE_ATTRIBUTE_VALUES . ' (
												atv_obj_id,
												atv_atb_id,
												atv_value
												) VALUES (
												' . $pdsk_obj_id . ',
												' . $v . ',
												\'' . F_escape_sql($value) . '\'
												)';
                                            if (!($ra = F_db_query($sqla, $db))) {
                                                F_display_db_error(false);
                                                return false;
                                            }
                                        }
                                    }
                                } else {
                                    F_display_db_error(false);
                                    return false;
                                }
                            }
                        }
                    }
                    // end of disks
                }
                // is array
            }
            // end of disk array
        }
        // end for each controller
        // add physical disks on the logical drives
        if (isset($logdrvdisks) and !empty($logdrvdisks)) {
            foreach ($logdrvdisks as $logdrvid => $disks) {
                $sql = 'UPDATE ' . K_TABLE_OBJECTS . ' SET
					obj_description=' . F_empty_to_null(implode(', ', $disks)) . '
					WHERE obj_id=' . $logdrvid . '';
                if (!($r = F_db_query($sql, $db))) {
                    F_display_db_error(false);
                }
            }
        }
    }
    return true;
}
Esempio n. 7
0
				obj_name,
				obj_description,
				obj_label,
				obj_tag,
				obj_mnf_id,
				obj_owner_id,
				obj_tenant_id
				) VALUES (
				' . $obj_obt_id . ',
				\'' . F_escape_sql($obj_name) . '\',
				' . F_empty_to_null($obj_description) . ',
				' . F_empty_to_null($obj_label) . ',
				' . F_empty_to_null($obj_tag) . ',
				' . F_zero_to_null($obj_mnf_id) . ',
				' . F_zero_to_null($obj_owner_id) . ',
				' . F_zero_to_null($obj_tenant_id) . '
				)';
            if (!($r = F_db_query($sql, $db))) {
                F_display_db_error(false);
            } else {
                $obj_id = F_db_insert_id($db, K_TABLE_OBJECTS, 'obj_id');
            }
            // update parent-child map
            if (!empty($omp_parent_obj_ids)) {
                foreach ($omp_parent_obj_ids as $parent_obj_id) {
                    $sql = 'INSERT INTO ' . K_TABLE_OBJECTS_MAP . ' (
						omp_parent_obj_id,
						omp_child_obj_id
						) VALUES (
						' . $parent_obj_id . ',
						' . $obj_id . '