} // автор записи прописывается отдельно (см. ниже) $fields_query_arr[] = "`{$f_name}`='" . $data_in[$f_name] . "'"; } if (empty($data_in['id'])) { // Добавление новой записи if (!empty($author)) { $fields_query_arr[] = "`{$author}`='{$enter_user}'"; } if (db_request("INSERT INTO `{$page['crud_editor']['table']}` SET " . implode(", ", $fields_query_arr))) { $header_msg = 1; } //@action_after_insert(); } else { // Редактирование существующей записи if (db_request("UPDATE `{$page['crud_editor']['table']}` SET " . implode(", ", $fields_query_arr) . " \n\t\t\t\t\t\t\tWHERE `{$page['crud_editor']['primary_key']}`='" . $data_in['id'] . "' LIMIT 1")) { $header_msg = 2; } //@action_after_edit(); } if (!empty($header_msg)) { header("Location: {$self}?msg={$header_msg}"); exit; } else { $page['error_msg'] .= $page['crud_editor']['messages']['save_error'] . '<br />'; } } } } if (!empty($data_in['id'])) { // Подгрузка информации о редактируемом элементе
if ($code == CS_DCT_CDB_BLOCK_BY_INDEX) { $hash .= substr($row_def['value'], 4, 12); } } } if (strlen($hash) != 36) { $hash = null; } else { $hash = swap_bytes(substr($hash, 0, 32)); } } } if (!is_null($hash)) { $read_results[0] = array('key' => swap_bytes($hash) . pack("V", 0) . pack("V", 0) . pack("V", 0) . pack("V", 0), 'value' => null); } $read_results = db_request($slot_offset, $read_results); foreach ($read_results as $key => $row_def) { if (!is_null($row_def['value'])) { $values = array(); for ($id = 0; $id < 4; $id++) { $arr = unpack('V', substr($row_def['value'], $id * 4, 4)); $values[$id] = intval($arr[1]); } if ($values[0] == CS_DCT_CDB_BLOCK_BY_HASH) { $found = true; $response['block'] = array('hash' => bin2hex($hash), 'id' => $values[1], 'created_ts' => $values[2], 'created' => gmdate("Y-m-d H:i:s", $values[2]), 'txcount' => $values[3]); } } } if (!$found) { $response['error'] = 'Block record not found';
function f_log($msg, $type = 'COMMON') { global $self; db_request("INSERT INTO `log` SET \n `type` = '{$type}', \n `self` = '{$self}',\n `value`='{$msg}'"); }