function delete_type_file($id_download = false, $id_type = false) { if ($id_download && $id_type) { $result = process_sql_delete("tdownload_type_file", array('id_download' => $id_download, 'id_type' => $id_type)); } elseif ($id_download) { $result = process_sql_delete("tdownload_type_file", array('id_download' => $id_download)); } elseif ($id_type) { $result = process_sql_delete("tdownload_type_file", array('id_type' => $id_type)); } else { $result = false; } return $result; }
//********************************************************************** // Tabs //********************************************************************** print_inventory_tabs('relationships', $id, $inventory_name); $delete_link = get_parameter ('delete_link', 0); $add_link = get_parameter ('add_link', 0); $ids_str = ''; if ($delete_link) { $id_src = get_parameter('id_src'); $id_dst = get_parameter('id_dst'); $result = process_sql_delete ('tinventory_relationship', array ('id_object_src' => $id_src, 'id_object_dst' => $id_dst)); if ($result) { echo ui_print_success_message (__("Inventory relationship deleted"), '', true, 'h3', true); } else { echo ui_print_error_message (__("Error deleting inventory relationship"), '', true, 'h3', true); } } if ($add_link) { $id_dst = get_parameter('link', 0); $id_src = get_parameter('id_src'); $sql = "INSERT INTO tinventory_relationship (id_object_src, id_object_dst) VALUES ($id_src, $id_dst)"; $result = process_sql($sql);
if (!give_acl($config["id_user"], 0, "PM")) { audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access external table management"); require "general/noaccess.php"; exit; } $external_table = get_parameter('external_table'); $id_object_type = get_parameter('id'); $delete_row = get_parameter('delete_row', 0); $update_row = get_parameter('update_row', 0); $add_row = get_parameter('add_row', 0); //add new line to enter data $insert_row = get_parameter('insert_row', 0); if ($delete_row) { $key = get_parameter('key'); $key_value = get_parameter('key_value'); $result = process_sql_delete($external_table, array($key => $key_value)); if ($result) { echo "<h3 class='suc'>" . __('Deleted row') . "</h3>"; } else { echo "<h3 class='error'>" . __('There was a problem deleting row') . "</h3>"; } } if ($update_row) { $key = get_parameter('key'); $key_value = get_parameter('key_value'); $fields = get_db_all_rows_sql("DESC " . $external_table); if ($fields == false) { $fields = array(); } foreach ($fields as $field) { if ($field['Field'] != $key) {
"public" => 1 ); $id_workunit = process_sql_insert("tworkunit", $values); $values = array( "id_incident" => $id, "id_workunit" => $id_workunit ); process_sql_insert("tworkunit_incident", $values); // Updating the ticket process_sql_update("tincidencia", array("actualizacion" => $timestamp), array("id_incidencia" => $id)); } else { unlink ($file_tmp); process_sql_delete ('tattachment', array('id_attachment' => $id_attachment)); $result["message"] = __('The file could not be copied'); } } } else { $result["message"] = __('Invalid extension'); } } else { $result["message"] = $upload_result; } echo json_encode($result); return; }
/** * Assign a tag to a lead. * This process will delete the lead tags and assign the new. * * @param mixed Id (int) or ids (array) of the lead. * @param mixed Name (string) or names (array) of the tag. * @param bool Wether html encode the names or not. * * @return mixed The number of assigned tags of false (bool) on error. */ function create_lead_tag_with_names($lead_id, $tag_name, $encode_names = false) { if (empty($lead_id)) { throw new InvalidArgumentException(__('The lead id cannot be empty')); } if (empty($tag_name)) { throw new InvalidArgumentException(__('The tag name cannot be empty')); } if (!is_array($lead_id)) { $lead_id = array($lead_id); } if (!is_array($tag_name)) { $tag_name = array($tag_name); } if ($encode_names) { $tag_name = safe_input($tag_name); } $expected_assingments = count($lead_id) * count($tag_name); $successfull_assingments = 0; // Delete the old tags $delete_res = process_sql_delete(LEADS_TABLE, array(LEADS_TABLE_LEAD_ID_COL => $lead_id)); if ($delete_res !== false) { foreach ($lead_id as $l_id) { if (is_numeric($l_id) && $l_id > 0) { foreach ($tag_name as $t_name) { if (!empty($t_name)) { $tag_id = get_db_value(TAGS_TABLE_ID_COL, TAGS_TABLE, TAGS_TABLE_NAME_COL, $t_name); if (is_numeric($tag_id) && $tag_id > 0) { $values = array(LEADS_TABLE_LEAD_ID_COL => $l_id, LEADS_TABLE_TAG_ID_COL => $tag_id); $result = process_sql_insert(LEADS_TABLE, $values); if ($result !== false) { $successfull_assingments++; } } } } } } } if ($delete_res === false || $expected_assingments > 0 && $successfull_assingments === 0) { $successfull_assingments = false; } return $successfull_assingments; }
} echo "<br>"; print_button(__('OK'), 'OK', false, '', 'class="sub blank"'); } else { if (empty($id)) { echo "<h3 class='error'>" . __('An error ocurred. Event not inserted.') . "</h3>"; } else { echo "<h3 class='error'>" . __('An error ocurred. Event not updated.') . "</h3>"; } echo "<br>"; print_button(__('OK'), 'OK', false, '', 'class="sub blank"'); } } if ($delete_agenda_entry) { if (!empty($id) && !$permission) { // Doesn't have access to this page audit_db($config['id_user'], $config["REMOTE_ADDR"], "ACL Violation", "Trying to delete an agenda entry"); include "general/noaccess.php"; exit; } $result = process_sql_delete('tagenda', array('id' => $id)); if ($result !== false) { echo "<h3 class='suc'>" . __('The event was deleted') . "</h3>"; echo "<br>"; print_button(__('OK'), 'OK', false, '', 'class="sub blank"'); } else { echo "<h3 class='error'>" . __('An error ocurred. Event not deleted') . "</h3>"; echo "<br>"; print_button(__('OK'), 'OK', false, '', 'class="sub blank"'); } }
// Copyright (c) 2008-2011 Artica Soluciones Tecnologicas // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; version 2 // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. global $config; check_login(); require_once 'include/functions_inventories.php'; echo '<h1>' . __('Inventory reports') . '</h1>'; $delete = (bool) get_parameter('delete_report'); if ($delete) { $id = (int) get_parameter('id'); $result = process_sql_delete('tinventory_reports', array('id' => $id)); if ($result !== false) { echo '<h3 class="suc">' . __('Successfully deleted') . '</h3>'; } else { echo '<h3 class="error">' . __('Could not be deleted') . '</h3>'; } } if (dame_admin($config['id_user'])) { $reports = get_db_all_rows_in_table('tinventory_reports'); } else { $all_groups_str = groups_get_user_groups($config['id_user']); $sql = "SELECT * FROM tinventory_reports WHERE id_group IN " . $all_groups_str; $reports = get_db_all_rows_sql($sql); } if ($reports === false) { echo '<h2 class="error">' . __('No reports were found') . '</h2>';
/** * This function creates an inventory object for each agent of pandora with name, address, description * and extra fields if are defined as operating system and url address */ function synchronize_pandora_inventory() { global $config; if (!isset($config["pandora_url"])) { return; } if ($config["pandora_url"] == "") { return; } $separator = ':;:'; $url = $config['pandora_url'] . '/include/api.php?op=get&apipass='******'pandora_api_password'] . '&op2=all_agents&return_type=csv&user='******'pandora_user'] . '&pass='******'pandora_pass']; $return = call_api($url); $agents_csv = explode("\n", $return); foreach ($agents_csv as $agent_csv) { // Avoiding empty csv lines like latest one if ($agent_csv == '') { continue; } $values = array(); $agent = explode(";", $agent_csv); $agent_id = $agent[0]; $agent_name = $agent[1]; $agent_name_safe = safe_input($agent_name); $address = $agent[2]; $description = $agent[3]; $os_name = $agent[4]; $url_address = $agent[5]; // Check if exist to avoid the creation $inventory_id = get_db_value('id', 'tinventory', 'name', $agent_name_safe); if ($inventory_id !== false) { process_sql_delete('tinventory', array('id' => $inventory_id)); process_sql_delete('tobject_field_data', array('id_inventory' => $inventory_id)); } $id_object_type = get_db_value('id', 'tobject_type', 'name', safe_input('Pandora agents')); $values['name'] = $agent_name_safe; $values['description'] = $description; $values['id_object_type'] = $id_object_type; $values['id_contract'] = $config['default_contract']; $id_inventory = process_sql_insert('tinventory', $values); if ($id_inventory) { $id_type_field_os = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('OS'))); $id_type_field_ip = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('IP Address'))); if ($id_type_field_ip == false) { $id_type_field_ip = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => 'IP Address')); } $id_type_field_url = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('URL Address'))); if ($id_type_field_url == false) { $id_type_field_url = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => 'URL Address')); } $id_type_field_id = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => safe_input('ID Agent'))); if ($id_type_field_id == false) { $id_type_field_id = get_db_value_filter('id', 'tobject_type_field', array('id_object_type' => $id_object_type, 'label' => 'ID Agent')); } $value_os = array(); $value_os['id_inventory'] = $id_inventory; $value_os['id_object_type_field'] = $id_type_field_os; $value_os['data'] = $os_name; process_sql_insert('tobject_field_data', $value_os); $value_ip = array(); $value_ip['id_inventory'] = $id_inventory; $value_ip['id_object_type_field'] = $id_type_field_ip; $value_ip['data'] = $address; process_sql_insert('tobject_field_data', $value_ip); $value_url = array(); $value_url['id_inventory'] = $id_inventory; $value_url['id_object_type_field'] = $id_type_field_url; $value_url['data'] = $url_address; process_sql_insert('tobject_field_data', $value_url); $value_id = array(); $value_id['id_inventory'] = $id_inventory; $value_id['id_object_type_field'] = $id_type_field_id; $value_id['data'] = $agent_id; process_sql_insert('tobject_field_data', $value_id); } } }
function um_db_delete_update($id_update) { global $db; $update = um_db_get_update($id_update); $package = um_db_get_package($update->id_update_package); if ($package->status != 'development') { echo '<strong>Error</strong>: ' . 'Only packages in development state can be deleted'; return false; } $result = process_sql_delete(DB_PREFIX . 'tupdate', array('id' => $id_update)); if ($result === false) { echo '<strong>Error deleting update</strong> <br />'; return false; } return true; }
$id_field = get_parameter('id_field'); $global_id = get_db_value("global_id", "tincident_type_field", "id", $id_field); if ($global_id) { //Delete all fields related to global field $fields_sql = sprintf("SELECT id FROM tincident_type_field WHERE global_id = %d", $global_id); $fields = get_db_all_rows_sql($fields_sql); $aux = array(); foreach ($fields as $f) { $aux[] = $f["id"]; } $clause = "(" . implode(",", $aux) . ")"; $sql = sprintf("DELETE FROM tincident_type_field WHERE id IN %s", $clause); $result_delete = process_sql($sql); } else { //Delete only this field $result_delete = process_sql_delete('tincident_type_field', array('id' => $id_field)); } if ($result_delete === false) { echo '<h3 class="error">' . __('Field could not be deleted') . '</h3>'; } else { echo '<h3 class="suc">' . __('Field deleted successfully') . '</h3>'; } } if ($update_field) { //update field to incident type $id_field = (int) get_parameter('id_field'); // The item should be updated to global $new_global = (bool) get_parameter("global"); // The item is global yet $is_global = get_db_value('global_id', 'tincident_type_field', 'id', $id_field); $value_update['label'] = get_parameter('label');
function run_mail_queue() { global $config; // Get pending mails $filter = array('status' => 0); $mails = get_db_all_rows_filter('tpending_mail', $filter); // No pending mails if ($mails === false) { return; } // Init mailer $mailer = null; try { // Use local mailer if host not provided - Attach not supported !! if (empty($config['smtp_host'])) { // Empty snmp conf. System sendmail transport $transport = mail_get_transport(); $mailer = mail_get_mailer($transport); } else { $mailer = mail_get_mailer(); } } catch (Exception $e) { integria_logwrite(sprintf("Mail transport failure: %s", $e->getMessage())); return; } foreach ($mails as $email) { try { //Check if the email was sent at least once if (mail_send($email, $mailer) > 0) { process_sql_delete('tpending_mail', array('id' => (int) $email['id'])); } else { throw new Exception(__('The mail send failed')); } } catch (Exception $e) { $retries = $email['attempts'] + 1; if ($retries > $config['smtp_queue_retries']) { $status = 1; insert_event('MAIL_FAILURE', 0, 0, $email['recipient'] . ' - ' . $e->getMessage()); } else { $status = 0; } $values = array('status' => $status, 'attempts' => $retries); $where = array('id' => (int) $email['id']); process_sql_update('tpending_mail', $values, $where); $to = trim(ascii_output($email['recipient'])); integria_logwrite(sprintf('SMTP error sending to %s (%s)', $to, $e->getMessage())); } } }
function um_db_delete_auth($id_auth) { $result = process_sql_delete(DB_PREFIX . 'tupdate_auth', array('id' => $id_auth)); if ($result === false) { echo '<strong>Error deleting authorization</strong><br />'; return false; } return true; }
} inventory_tracking($id, INVENTORY_OBJECT_TYPE, $id_object_type); } //parent if ($id_parent != 0) { if ($old_parent != false) { //delete fields old parent $old_id_object_type_inherit = get_db_value('id_object_type', 'tinventory', 'id', $old_parent); //parent has object if ($old_id_object_type_inherit !== false) { $old_fields = get_db_all_rows_filter('tobject_type_field', array('id_object_type' => $old_id_object_type_inherit, 'inherit' => 1)); if ($old_fields === false) { $old_fields = array(); } foreach ($old_fields as $key => $old) { process_sql_delete('tobject_field_data', array('id_object_type_field' => $old['id'], 'id_inventory' => $id)); } } $aditional_data = array(); $aditional_data['old'] = $old_parent; $aditional_data['new'] = $id_parent; inventory_tracking($id, INVENTORY_PARENT_UPDATED, $aditional_data); } inventory_tracking($id, INVENTORY_PARENT_CREATED, $id_parent); $id_object_type_inherit = get_db_value('id_object_type', 'tinventory', 'id', $id_parent); //parent has object if ($id_object_type_inherit !== false) { $inherit_fields = get_db_all_rows_filter('tobject_type_field', array('id_object_type' => $id_object_type_inherit, 'inherit' => 1)); if ($inherit_fields === false) { $inherit_fields = array(); }
public function deleteFromDB() { $result = false; if (isset($this->id)) { $where = array('id_attachment' => $this->id); $result = process_sql_delete(self::$dbTable, $where); if ($result) { unset($this->id); } } return $result; }
// as published by the Free Software Foundation; version 2 // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. global $config; check_login(); if (!give_acl($config["id_user"], 0, "VM")) { audit_db($config["id_user"], $config["REMOTE_ADDR"], "ACL Violation", "Trying to access campaign management"); require "general/noaccess.php"; exit; } $delete = get_parameter("del"); $create = get_parameter("create"); if ($delete) { $res = process_sql_delete("tcampaign", array("id" => $delete)); if ($res) { echo "<h3 class='suc'>" . __("Campaign deleted sucessfully") . "</h3>"; } else { echo "<h3 class='error'>" . __("There was a problem deleting campaign") . "</h3>"; } } if ($create) { $title = get_parameter("title"); $description = get_parameter("description"); $start_date = get_parameter("start_date"); $end_date = get_parameter("end_date"); $expenses = get_parameter("expenses"); //$campaign = $values = array("title" => $title, "start_date" => $start_date, "end_date" => $end_date, "description" => $description, "expenses" => $expenses); $id = process_sql_insert("tcampaign", $values);