function sn_mm_points_change($user_id, $change_type, $metamatter, $comment = false, $already_changed = false, &$result) { global $debug, $mm_change_legit, $user, $config; if (!$user_id || !($metamatter = floatval($metamatter))) { return false; } $mm_change_legit = true; $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); if ($already_changed) { $result = -1; } else { $metamatter_total = $metamatter > 0 ? $metamatter : 0; db_user_set_by_id($user_id, "`{$sn_data_metamatter_db_name}` = `{$sn_data_metamatter_db_name}` + '{$metamatter}'" . ($metamatter > 0 ? ", `immortal` = IF(`metamatter_total` + '{$metamatter_total}' >= {$config->player_metamatter_immortal}, NOW(), `immortal`), `metamatter_total` = `metamatter_total` + '{$metamatter_total}'" : '')); $result = db_affected_rows(); } if ($result) { $page_url = db_escape($_SERVER['SCRIPT_NAME']); if (is_array($comment)) { $comment = call_user_func_array('sprintf', $comment); } $comment = db_escape($comment); $row = db_user_by_id($user_id, false, 'username'); $row['username'] = db_escape($row['username']); doquery("INSERT INTO {{log_metamatter}} SET\n `user_id` = {$user_id},\n `username` = '{$row['username']}',\n `reason` = {$change_type},\n `amount` = {$metamatter},\n `comment` = '{$comment}',\n `page` = '{$page_url}'\n ;"); $result = db_insert_id(); if ($user['id'] == $user_id) { $user['metamatter'] += $metamatter; } } else { $debug->warning("Error adjusting Metamatter for player ID {$user_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); } $mm_change_legit = false; return $result; }
/** * Add a news item * * @param integer $p_project_id A project identifier. * @param integer $p_poster_id The user id of poster. * @param integer $p_view_state View state. * @param boolean $p_announcement Whether article is an announcement. * @param string $p_headline News Headline. * @param string $p_body News Body. * @return integer news article id */ function news_create($p_project_id, $p_poster_id, $p_view_state, $p_announcement, $p_headline, $p_body) { if (is_blank($p_headline)) { error_parameters(lang_get('headline')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } if (is_blank($p_body)) { error_parameters(lang_get('body')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } db_param_push(); $t_query = 'INSERT INTO {news} ( project_id, poster_id, date_posted, last_modified, view_state, announcement, headline, body ) VALUES ( ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )'; db_query($t_query, array((int) $p_project_id, (int) $p_poster_id, db_now(), db_now(), (int) $p_view_state, $p_announcement, $p_headline, $p_body)); $t_news_id = db_insert_id(db_get_table('news')); return $t_news_id; }
function email_queue_add($p_email_data) { $t_email_data = email_queue_prepare_db($p_email_data); # email cannot be blank if (is_blank($t_email_data->email)) { error_parameters(lang_get('email')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # subject cannot be blank if (is_blank($t_email_data->subject)) { error_parameters(lang_get('subject')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # body cannot be blank if (is_blank($t_email_data->body)) { error_parameters(lang_get('body')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_email_table = config_get('mantis_email_table'); $c_email = $t_email_data->email; $c_subject = $t_email_data->subject; $c_body = $t_email_data->body; $c_metadata = serialize($t_email_data->metadata); $query = "INSERT INTO {$t_email_table}\r\n\t\t\t\t ( email,\r\n\t\t\t\t subject,\r\n\t\t\t\t\t body,\r\n\t\t\t\t\t submitted,\r\n\t\t\t\t\t metadata)\r\n\t\t\t\t VALUES\r\n\t\t\t\t ( '{$c_email}',\r\n\t\t\t\t '{$c_subject}',\r\n\t\t\t\t '{$c_body}',\r\n\t\t\t\t\t " . db_now() . ",\r\n\t\t\t\t\t '{$c_metadata}'\r\n\t\t\t\t\t)"; db_query($query); return db_insert_id($t_email_table); }
function install($module) { global $db, $messageStack; $error = false; if (!db_field_exists(TABLE_INVENTORY, 'catalog')) { // setup new tab in table inventory $result = $db->Execute("select id FROM " . TABLE_EXTRA_TABS . " WHERE tab_name='ZenCart'"); if ($result->RecordCount() == 0) { $sql_data_array = array('module_id' => 'inventory', 'tab_name' => 'ZenCart', 'description' => 'ZenCart Catalog', 'sort_order' => '49'); db_perform(TABLE_EXTRA_TABS, $sql_data_array); $tab_id = db_insert_id(); } else { $tab_id = $result->fields['id']; } gen_add_audit_log(ZENCART_LOG_TABS . TEXT_ADD, 'zencart'); // setup extra fields for inventory $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'check_box', 'field_name' => 'catalog', 'description' => ZENCART_CATALOG_ADD, 'sort_order' => 10, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'check_box', 'select' => '0', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("alter table " . TABLE_INVENTORY . " add column catalog enum('0','1') default '0'"); $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'category_id', 'description' => ZENCART_CATALOG_CATEGORY_ID, 'sort_order' => 20, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("alter table " . TABLE_INVENTORY . " add column category_id varchar(64) default ''"); $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'manufacturer', 'description' => ZENCART_CATALOG_MANUFACTURER, 'sort_order' => 30, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("alter table " . TABLE_INVENTORY . " add column manufacturer varchar(64) default ''"); $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'ProductModel', 'description' => ZENCART_CATALOG_MODEL, 'sort_order' => 40, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("alter table " . TABLE_INVENTORY . " add column ProductModel varchar(64) default ''"); $sql_data_array = array('module_id' => 'inventory', 'tab_id' => $tab_id, 'entry_type' => 'text', 'field_name' => 'ProductURL', 'description' => ZENCART_CATALOG_URL, 'sort_order' => 50, 'use_in_inventory_filter' => '1', 'params' => serialize(array('type' => 'text', 'length' => '64', 'default' => '', 'inventory_type' => 'ai:ci:ds:sf:ma:ia:lb:mb:ms:mi:ns:sa:sr:sv:si:'))); db_perform(TABLE_EXTRA_FIELDS, $sql_data_array); $db->Execute("alter table " . TABLE_INVENTORY . " add column ProductURL varchar(64) default ''"); gen_add_audit_log(ZENCART_LOG_FIELDS . TEXT_NEW, 'zencart - catalog'); } return $error; }
function write_customer($email, $name, $company, $address, $phone, $fax, $currency) { global $paypal_sales_type_id, $paypal_tax_group_id, $paypal_salesman, $paypal_area, $paypal_location, $paypal_credit_status, $paypal_shipper; global $SysPrefs; log_message("Memory, write_customer start:" . memory_get_usage()); $customer_id = find_customer_by_email($email); if (empty($customer_id)) { $customer_id = find_customer_by_name($company); } if (empty($customer_id)) { //it is a new customer begin_transaction(); add_customer($company, substr($company, 0, 30), $address, '', $currency, 0, 0, $paypal_credit_status, -1, 0, 0, $SysPrefs->default_credit_limit(), $paypal_sales_type_id, 'PayPal'); $customer_id = db_insert_id(); add_branch($customer_id, $company, substr($company, 0, 30), $address, $paypal_salesman, $paypal_area, $paypal_tax_group_id, '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $paypal_location, $address, 0, 0, $paypal_shipper, 'PayPal'); $selected_branch = db_insert_id(); $nameparts = explode(" ", $name); $firstname = ""; for ($i = 0; $i < count($nameparts) - 1; $i++) { if (!empty($firstname)) { $firstname .= " "; } $firstname .= $nameparts[$i]; } $lastname = $nameparts[count($nameparts) - 1]; add_crm_person('paypal', $firstname, $lastname, $address, $phone, '', $fax, $email, '', ''); add_crm_contact('customer', 'general', $selected_branch, db_insert_id()); commit_transaction(); } else { $selected_branch = 0; } log_message("Memory, write_customer end:" . memory_get_usage()); return array($customer_id, $selected_branch); }
/** * Create a new profile for the user, return the ID of the new profile * @param int $p_user_id * @param string $p_platform * @param string $p_os * @param string $p_os_build * @param string $p_description * @return int */ function profile_create($p_user_id, $p_platform, $p_os, $p_os_build, $p_description) { $p_user_id = (int) $p_user_id; if (ALL_USERS != $p_user_id) { user_ensure_unprotected($p_user_id); } # platform cannot be blank if (is_blank($p_platform)) { error_parameters(lang_get('platform')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # os cannot be blank if (is_blank($p_os)) { error_parameters(lang_get('operating_system')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # os_build cannot be blank if (is_blank($p_os_build)) { error_parameters(lang_get('version')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_user_profile_table = db_get_table('user_profile'); # Add profile $query = "INSERT INTO {$t_user_profile_table}\n\t\t\t\t ( user_id, platform, os, os_build, description )\n\t\t\t\t VALUES\n\t\t\t\t ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )'; db_query_bound($query, array($p_user_id, $p_platform, $p_os, $p_os_build, $p_description)); return db_insert_id($t_user_profile_table); }
/** * Add to email queue * @param EmailData $p_email_data * @return int */ function email_queue_add($p_email_data) { $t_email_data = email_queue_prepare_db($p_email_data); # email cannot be blank if (is_blank($t_email_data->email)) { error_parameters(lang_get('email')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # subject cannot be blank if (is_blank($t_email_data->subject)) { error_parameters(lang_get('subject')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # body cannot be blank if (is_blank($t_email_data->body)) { error_parameters(lang_get('body')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_email_table = db_get_table('mantis_email_table'); $c_email = $t_email_data->email; $c_subject = $t_email_data->subject; $c_body = $t_email_data->body; $c_metadata = serialize($t_email_data->metadata); $query = "INSERT INTO {$t_email_table}\n\t\t\t\t ( email,\n\t\t\t\t subject,\n\t\t\t\t\t body,\n\t\t\t\t\t submitted,\n\t\t\t\t\t metadata)\n\t\t\t\t VALUES\n\t\t\t\t ( " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t " . db_param() . ",\n\t\t\t\t\t " . db_param() . ",\n\t\t\t\t\t " . db_param() . "\n\t\t\t\t\t)"; db_query_bound($query, array($c_email, $c_subject, $c_body, db_now(), $c_metadata)); $t_id = db_insert_id($t_email_table, 'email_id'); log_event(LOG_EMAIL, "message #{$t_id} queued"); return $t_id; }
function create_input_timevalue($user, $name, $nodeid, $time, $value) { $time = date("Y-n-j H:i:s", $time); db_query("INSERT INTO input (userid,name,nodeid,time,value) VALUES ('{$user}','{$name}','{$nodeid}','{$time}','{$value}')"); $inputid = db_insert_id(); return $inputid; }
/** * Create a new profile for the user, return the ID of the new profile * @param integer $p_user_id A valid user identifier. * @param string $p_platform Value for profile platform. * @param string $p_os Value for profile operating system. * @param string $p_os_build Value for profile operation system build. * @param string $p_description Description of profile. * @return integer */ function profile_create($p_user_id, $p_platform, $p_os, $p_os_build, $p_description) { $p_user_id = (int) $p_user_id; if (ALL_USERS != $p_user_id) { user_ensure_unprotected($p_user_id); } # platform cannot be blank if (is_blank($p_platform)) { error_parameters(lang_get('platform')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # os cannot be blank if (is_blank($p_os)) { error_parameters(lang_get('os')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # os_build cannot be blank if (is_blank($p_os_build)) { error_parameters(lang_get('version')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # Add profile db_param_push(); $t_query = 'INSERT INTO {user_profile} ( user_id, platform, os, os_build, description ) VALUES ( ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ', ' . db_param() . ' )'; db_query($t_query, array($p_user_id, $p_platform, $p_os, $p_os_build, $p_description)); return db_insert_id(db_get_table('user_profile')); }
function newProductBacklog() { global $agilemantis_au; // Check if team-user name fits into MantisBT regulations if (!(utf8_strlen($this->name) < 22 && user_is_name_valid($this->name) && user_is_name_unique($this->name))) { return null; } $p_username = $this->generateTeamUser($this->name); $p_email = $this->email; $p_email = trim($p_email); $t_seed = $p_email . $p_username; $t_password = auth_generate_random_password($t_seed); if (user_is_name_unique($p_username) === true) { user_create($p_username, $t_password, $p_email, 55, false, true, 'Team-User-' . $_POST['pbl_name']); } else { $t_user_id = $this->getUserIdByName($p_username); user_set_field($t_user_id, 'email', $p_email); } $user_id = $this->getLatestUser(); $agilemantis_au->setAgileMantisUserRights($user_id, 1, 0, 0); if ($this->team == 0) { $this->team = $this->getLatestUser(); } $t_sql = "INSERT INTO gadiv_productbacklogs (name, description, user_id) VALUES ( " . db_param(0) . ", " . db_param(1) . ", " . db_param(2) . ") "; $t_params = array($this->name, $this->description, $user_id); db_query_bound($t_sql, $t_params); $this->id = db_insert_id("gadiv_productbacklogs"); $this->user_id = $user_id; return $this->id; }
function profile_create($p_user_id, $p_platform, $p_os, $p_os_build, $p_description) { $c_user_id = db_prepare_int($p_user_id); $c_platform = db_prepare_string($p_platform); $c_os = db_prepare_string($p_os); $c_os_build = db_prepare_string($p_os_build); $c_description = db_prepare_string($p_description); if (ALL_USERS != $p_user_id) { user_ensure_unprotected($p_user_id); } # platform cannot be blank if (is_blank($c_platform)) { error_parameters(lang_get('platform')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # os cannot be blank if (is_blank($c_os)) { error_parameters(lang_get('operating_system')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } # os_build cannot be blank if (is_blank($c_os_build)) { error_parameters(lang_get('version')); trigger_error(ERROR_EMPTY_FIELD, ERROR); } $t_user_profile_table = config_get('mantis_user_profile_table'); # Add profile $query = "INSERT INTO {$t_user_profile_table}\n\t\t\t\t ( user_id, platform, os, os_build, description )\n\t\t\t\t VALUES\n\t\t\t\t ( '{$c_user_id}', '{$c_platform}', '{$c_os}', '{$c_os_build}', '{$c_description}' )"; db_query($query); return db_insert_id($t_user_profile_table); }
/** * 生成一个新的订单 * * @param $sid 服务(商品)编号 * @param $amount 服务(商品)价格,如果不指定则使用数据库中记录的价格 * @return 成功返回订单信息数组,包含 uid, email, orderid 等信息,失败返回 false */ function order_new($sid, $amount = -1) { $user = user_isonline(); if ($user === false) { vpn_log('User is not online, cant create new order'); return false; } $sid = (int) $sid; $sql = "SELECT * FROM service WHERE id={$sid}"; $res = db_query($sql); if ($res == false || db_num_rows($res) == 0) { vpn_log('No such service id: ' . $sid); return false; } $arr = db_fetch_array($res); $ts = time(NULL); $uid = $user['id']; if ($amount < 0) { $amount = $arr['price']; /// 数据库中的金额单位是(分) } $sql = "INSERT INTO `order` (uid, createtime, amount, serviceid) VALUES ({$uid}, {$ts}, {$amount}, {$sid})"; $res = db_query($sql); if ($res === false) { return false; } $user['orderid'] = db_insert_id(); return $user; }
function sn_ube_report_save(&$combat_data) { // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем if ($combat_data[UBE_REPORT_CYPHER]) { return false; } // Генерируем уникальный секретный ключ и проверяем наличие в базе do { $combat_data[UBE_REPORT_CYPHER] = sys_random_string(32); } while (doquery("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$combat_data[UBE_REPORT_CYPHER]}' LIMIT 1 FOR UPDATE", true)); // Инициализация таблицы для пакетной вставки информации $sql_perform = array('ube_report_player' => array(array('`ube_report_id`', '`ube_report_player_player_id`', '`ube_report_player_name`', '`ube_report_player_attacker`', '`ube_report_player_bonus_attack`', '`ube_report_player_bonus_shield`', '`ube_report_player_bonus_armor`')), 'ube_report_fleet' => array(array('`ube_report_id`', '`ube_report_fleet_player_id`', '`ube_report_fleet_fleet_id`', '`ube_report_fleet_planet_id`', '`ube_report_fleet_planet_name`', '`ube_report_fleet_planet_galaxy`', '`ube_report_fleet_planet_system`', '`ube_report_fleet_planet_planet`', '`ube_report_fleet_planet_planet_type`', '`ube_report_fleet_resource_metal`', '`ube_report_fleet_resource_crystal`', '`ube_report_fleet_resource_deuterium`', '`ube_report_fleet_bonus_attack`', '`ube_report_fleet_bonus_shield`', '`ube_report_fleet_bonus_armor`')), 'ube_report_outcome_fleet' => array(array('`ube_report_id`', '`ube_report_outcome_fleet_fleet_id`', '`ube_report_outcome_fleet_resource_lost_metal`', '`ube_report_outcome_fleet_resource_lost_crystal`', '`ube_report_outcome_fleet_resource_lost_deuterium`', '`ube_report_outcome_fleet_resource_dropped_metal`', '`ube_report_outcome_fleet_resource_dropped_crystal`', '`ube_report_outcome_fleet_resource_dropped_deuterium`', '`ube_report_outcome_fleet_resource_loot_metal`', '`ube_report_outcome_fleet_resource_loot_crystal`', '`ube_report_outcome_fleet_resource_loot_deuterium`', '`ube_report_outcome_fleet_resource_lost_in_metal`')), 'ube_report_outcome_unit' => array(array('`ube_report_id`', '`ube_report_outcome_unit_fleet_id`', '`ube_report_outcome_unit_unit_id`', '`ube_report_outcome_unit_restored`', '`ube_report_outcome_unit_lost`', '`ube_report_outcome_unit_sort_order`')), 'ube_report_unit' => array(array('`ube_report_id`', '`ube_report_unit_player_id`', '`ube_report_unit_fleet_id`', '`ube_report_unit_round`', '`ube_report_unit_unit_id`', '`ube_report_unit_count`', '`ube_report_unit_boom`', '`ube_report_unit_attack`', '`ube_report_unit_shield`', '`ube_report_unit_armor`', '`ube_report_unit_attack_base`', '`ube_report_unit_shield_base`', '`ube_report_unit_armor_base`', '`ube_report_unit_sort_order`'))); // Сохраняем общую информацию о бое $outcome =& $combat_data[UBE_OUTCOME]; doquery("INSERT INTO `{{ube_report}}`\n SET\n `ube_report_cypher` = '{$combat_data[UBE_REPORT_CYPHER]}',\n `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $combat_data[UBE_TIME]) . "',\n `ube_report_time_spent` = {$combat_data[UBE_TIME_SPENT]},\n\n `ube_report_combat_admin` = " . (int) $combat_data[UBE_OPTIONS][UBE_COMBAT_ADMIN] . ",\n `ube_report_mission_type` = {$combat_data[UBE_OPTIONS][UBE_MISSION_TYPE]},\n\n `ube_report_combat_result` = {$outcome[UBE_COMBAT_RESULT]},\n `ube_report_combat_sfr` = " . (int) $outcome[UBE_SFR] . ",\n\n `ube_report_debris_metal` = " . (double) $outcome[UBE_DEBRIS][RES_METAL] . ",\n `ube_report_debris_crystal` = " . (double) $outcome[UBE_DEBRIS][RES_CRYSTAL] . ",\n\n `ube_report_planet_id` = " . (int) $outcome[UBE_PLANET][PLANET_ID] . ",\n `ube_report_planet_name` = '" . db_escape($outcome[UBE_PLANET][PLANET_NAME]) . "',\n `ube_report_planet_size` = " . (int) $outcome[UBE_PLANET][PLANET_SIZE] . ",\n `ube_report_planet_galaxy` = " . (int) $outcome[UBE_PLANET][PLANET_GALAXY] . ",\n `ube_report_planet_system` = " . (int) $outcome[UBE_PLANET][PLANET_SYSTEM] . ",\n `ube_report_planet_planet` = " . (int) $outcome[UBE_PLANET][PLANET_PLANET] . ",\n `ube_report_planet_planet_type` = " . (int) $outcome[UBE_PLANET][PLANET_TYPE] . ",\n\n `ube_report_moon` = " . (int) $outcome[UBE_MOON] . ",\n `ube_report_moon_chance` = " . (int) $outcome[UBE_MOON_CHANCE] . ",\n `ube_report_moon_size` = " . (double) $outcome[UBE_MOON_SIZE] . ",\n\n `ube_report_moon_reapers` = " . (int) $outcome[UBE_MOON_REAPERS] . ",\n `ube_report_moon_destroy_chance` = " . (int) $outcome[UBE_MOON_DESTROY_CHANCE] . ",\n `ube_report_moon_reapers_die_chance` = " . (int) $outcome[UBE_MOON_REAPERS_DIE_CHANCE] . "\n "); $ube_report_id = $combat_data[UBE_REPORT_ID] = db_insert_id(); // Сохраняем общую информацию по игрокам foreach ($combat_data[UBE_PLAYERS] as $player_id => &$player_info) { $sql_perform['ube_report_player'][] = array($ube_report_id, $player_id, "'" . db_escape($player_info[UBE_NAME]) . "'", (int) $player_info[UBE_ATTACKER], (double) $player_info[UBE_BONUSES][UBE_ATTACK], (double) $player_info[UBE_BONUSES][UBE_SHIELD], (double) $player_info[UBE_BONUSES][UBE_ARMOR]); } // Всякая информация по флотам $unit_sort_order = 0; foreach ($combat_data[UBE_FLEETS] as $fleet_id => &$fleet_info) { // Сохраняем общую информацию по флотам $sql_perform['ube_report_fleet'][] = array($ube_report_id, $fleet_info[UBE_OWNER], $fleet_id, (double) $fleet_info[UBE_PLANET][PLANET_ID], "'" . db_escape($fleet_info[UBE_PLANET][PLANET_NAME]) . "'", (int) $fleet_info[UBE_PLANET][PLANET_GALAXY], (int) $fleet_info[UBE_PLANET][PLANET_SYSTEM], (int) $fleet_info[UBE_PLANET][PLANET_PLANET], (int) $fleet_info[UBE_PLANET][PLANET_TYPE], (double) $fleet_info[UBE_RESOURCES][RES_METAL], (double) $fleet_info[UBE_RESOURCES][RES_CRYSTAL], (double) $fleet_info[UBE_RESOURCES][RES_DEUTERIUM], (double) $fleet_info[UBE_BONUSES][UBE_ATTACK], (double) $fleet_info[UBE_BONUSES][UBE_SHIELD], (double) $fleet_info[UBE_BONUSES][UBE_ARMOR]); // Сохраняем итоговую информацию по ресурсам флота - потеряно, выброшено, увезено $fleet_outcome_data =& $outcome[UBE_FLEETS][$fleet_id]; $sql_perform['ube_report_outcome_fleet'][] = array($ube_report_id, $fleet_id, (double) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_METAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_CRYSTAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOST][RES_DEUTERIUM], (double) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_METAL], (double) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_CRYSTAL], (double) $fleet_outcome_data[UBE_CARGO_DROPPED][RES_DEUTERIUM], (double) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_METAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_CRYSTAL], (double) $fleet_outcome_data[UBE_RESOURCES_LOOTED][RES_DEUTERIUM], (double) $fleet_outcome_data[UBE_RESOURCES_LOST_IN_METAL][RES_METAL]); // Сохраняем результаты по юнитам - потеряно и восстановлено foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) { if ($fleet_outcome_data[UBE_UNITS_LOST][$unit_id] || $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id]) { $unit_sort_order++; $sql_perform['ube_report_outcome_unit'][] = array($ube_report_id, $fleet_id, $unit_id, (double) $fleet_outcome_data[UBE_DEFENCE_RESTORE][$unit_id], (double) $fleet_outcome_data[UBE_UNITS_LOST][$unit_id], $unit_sort_order); } } } // Сохраняем информацию о раундах $unit_sort_order = 0; foreach ($combat_data[UBE_ROUNDS] as $round => &$round_data) { foreach ($round_data[UBE_FLEETS] as $fleet_id => &$fleet_data) { foreach ($fleet_data[UBE_COUNT] as $unit_id => $unit_count) { $unit_sort_order++; $sql_perform['ube_report_unit'][] = array($ube_report_id, $fleet_data[UBE_FLEET_INFO][UBE_OWNER], $fleet_id, $round, $unit_id, $unit_count, (int) $fleet_data[UBE_UNITS_BOOM][$unit_id], $fleet_data[UBE_ATTACK][$unit_id], $fleet_data[UBE_SHIELD][$unit_id], $fleet_data[UBE_ARMOR][$unit_id], $fleet_data[UBE_ATTACK_BASE][$unit_id], $fleet_data[UBE_SHIELD_BASE][$unit_id], $fleet_data[UBE_ARMOR_BASE][$unit_id], $unit_sort_order); } } } // Пакетная вставка данных foreach ($sql_perform as $table_name => $table_data) { if (count($table_data) < 2) { continue; } foreach ($table_data as &$record_data) { $record_data = '(' . implode(',', $record_data) . ')'; } $fields = $table_data[0]; unset($table_data[0]); doquery("INSERT INTO {{{$table_name}}} {$fields} VALUES " . implode(',', $table_data)); } return $combat_data[UBE_REPORT_CYPHER]; }
function create_feed($userid, $name, $NoOfDataFields, $datatype) { // Check if feed of given name by the user already exists $feedid = get_feed_id($userid, $name); if ($feedid != 0) { return $feedid; } $result = db_query("INSERT INTO feeds (name,status,datatype) VALUES ('{$name}','0','{$datatype}')"); // Create the feed entry $feedid = db_insert_id(); if ($feedid > 0) { db_query("INSERT INTO feed_relation (userid,feedid) VALUES ('{$userid}','{$feedid}')"); // Create a user->feed relation $feedname = "feed_" . $feedid; // Feed name if ($NoOfDataFields == 1) { // Create a table with one data field $result = db_query("CREATE TABLE {$feedname} (\n\t time INT UNSIGNED, data float,\n INDEX ( `time` ))"); } if ($NoOfDataFields == 2) { // Create a table with two data fields $result = db_query("CREATE TABLE {$feedname} (\n\t time INT UNSIGNED, data float, data2 float,\n INDEX ( `time` ))"); } return $feedid; // Return created feed id } else { return 0; } }
function handle_submit(&$selected_id) { global $path_to_root, $Ajax, $auto_create_branch; if (!can_process()) { return; } if ($selected_id) { update_customer($_POST['customer_id'], $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']); update_record_status($_POST['customer_id'], $_POST['inactive'], 'debtors_master', 'debtor_no'); $Ajax->activate('customer_id'); // in case of status change display_notification(_("Customer has been updated.")); } else { //it is a new customer begin_transaction(); add_customer($_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['tax_id'], $_POST['curr_code'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['credit_status'], $_POST['payment_terms'], input_num('discount') / 100, input_num('pymt_discount') / 100, input_num('credit_limit'), $_POST['sales_type'], $_POST['notes']); $selected_id = $_POST['customer_id'] = db_insert_id(); if (isset($auto_create_branch) && $auto_create_branch == 1) { add_branch($selected_id, $_POST['CustName'], $_POST['cust_ref'], $_POST['address'], $_POST['salesman'], $_POST['area'], $_POST['tax_group_id'], '', get_company_pref('default_sales_discount_act'), get_company_pref('debtors_act'), get_company_pref('default_prompt_payment_act'), $_POST['location'], $_POST['address'], 0, 0, $_POST['ship_via'], $_POST['notes']); $selected_branch = db_insert_id(); add_crm_person($_POST['CustName'], $_POST['cust_ref'], '', $_POST['address'], $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], '', ''); add_crm_contact('cust_branch', 'general', $selected_branch, db_insert_id()); } commit_transaction(); display_notification(_("A new customer has been added.")); if (isset($auto_create_branch) && $auto_create_branch == 1) { display_notification(_("A default Branch has been automatically created, please check default Branch values by using link below.")); } $Ajax->activate('_page_body'); } }
function bannerlist_insert() { global $Translation; // mm: can member insert record? $arrPerm = getTablePermissions('bannerlist'); if (!$arrPerm[1]) { return false; } $data['imgurl'] = makeSafe($_REQUEST['imgurl']); if ($data['imgurl'] == empty_lookup_value) { $data['imgurl'] = ''; } $data['linkurl'] = makeSafe($_REQUEST['linkurl']); if ($data['linkurl'] == empty_lookup_value) { $data['linkurl'] = ''; } $data['listdisp'] = makeSafe($_REQUEST['listdisp']); if ($data['listdisp'] == empty_lookup_value) { $data['listdisp'] = ''; } $data['dldisp'] = makeSafe($_REQUEST['dldisp']); if ($data['dldisp'] == empty_lookup_value) { $data['dldisp'] = ''; } $data['authdisp'] = makeSafe($_REQUEST['authdisp']); if ($data['authdisp'] == empty_lookup_value) { $data['authdisp'] = ''; } // hook: bannerlist_before_insert if (function_exists('bannerlist_before_insert')) { $args = array(); if (!bannerlist_before_insert($data, getMemberInfo(), $args)) { return false; } } $o = array('silentErrors' => true); sql('insert into `bannerlist` set `imgurl`=' . ($data['imgurl'] !== '' && $data['imgurl'] !== NULL ? "'{$data['imgurl']}'" : 'NULL') . ', `linkurl`=' . ($data['linkurl'] !== '' && $data['linkurl'] !== NULL ? "'{$data['linkurl']}'" : 'NULL') . ', `listdisp`=' . ($data['listdisp'] !== '' && $data['listdisp'] !== NULL ? "'{$data['listdisp']}'" : 'NULL') . ', `dldisp`=' . ($data['dldisp'] !== '' && $data['dldisp'] !== NULL ? "'{$data['dldisp']}'" : 'NULL') . ', `authdisp`=' . ($data['authdisp'] !== '' && $data['authdisp'] !== NULL ? "'{$data['authdisp']}'" : 'NULL'), $o); if ($o['error'] != '') { echo $o['error']; echo "<a href=\"bannerlist_view.php?addNew_x=1\">{$Translation['< back']}</a>"; exit; } $recID = db_insert_id(db_link()); // hook: bannerlist_after_insert if (function_exists('bannerlist_after_insert')) { $res = sql("select * from `bannerlist` where `bannerid`='" . makeSafe($recID, false) . "' limit 1", $eo); if ($row = db_fetch_assoc($res)) { $data = array_map('makeSafe', $row); } $data['selectedID'] = makeSafe($recID, false); $args = array(); if (!bannerlist_after_insert($data, getMemberInfo(), $args)) { return get_magic_quotes_gpc() ? stripslashes($recID) : $recID; } } // mm: save ownership data sql("insert ignore into membership_userrecords set tableName='bannerlist', pkValue='{$recID}', memberID='" . getLoggedMemberID() . "', dateAdded='" . time() . "', dateUpdated='" . time() . "', groupID='" . getLoggedGroupID() . "'", $eo); return get_magic_quotes_gpc() ? stripslashes($recID) : $recID; }
function newTeam() { $t_sql = "INSERT INTO gadiv_teams ( name, description, pb_id, daily_scrum )\n\t\t\t\t\tVALUES ( " . db_param(0) . "," . db_param(1) . "," . db_param(2) . "," . db_param(3) . " )"; $t_params = array(htmlspecialchars($this->name), htmlspecialchars($this->description), $this->product_backlog, (int) $this->daily_scrum); db_query_bound($t_sql, $t_params); $this->id = db_insert_id("gadiv_teams"); return $this->id; }
function newsAddNews($add_date, $title, $textToPrePublication, $textToPublication, $textToMail) { $stamp = microtime(); $stamp = explode(" ", $stamp); $stamp = $stamp[1]; db_query("insert into " . NEWS_TABLE . " ( add_date, title, textToPrePublication, textToPublication, textToMail, add_stamp ) " . " values( '" . xEscSQL(dtDateConvert($add_date)) . "', '" . xToText(trim($title)) . "', '" . xEscSQL($textToPrePublication) . "', '" . xEscSQL($textToPublication) . "', '" . xEscSQL($textToMail) . "', " . $stamp . " ) "); return db_insert_id(); }
function insertCompany($company_name) { $q = new DBQuery(); $q->addTable("companies"); $q->addInsert('company_name', $company_name); db_exec($q->prepareInsert()); return db_insert_id(); }
/** * * @param string $event * @param array $t_bug_data */ public function assignCommand($event, $t_bug_data) { #$command_ids = gpc_get_int_array( 'command_id'); $t_bug_id = $t_bug_data->id; // delete all existing bug-command associations if ($event != 'EVENT_REPORT_BUG_FORM') { $delete_query = "DELETE FROM codev_command_bug_table WHERE bug_id=" . db_param(); $delete_result = db_query_bound($delete_query, array($t_bug_id)); } // === create bug-command associations if (isset($_POST['command_id'])) { $command_ids = $_POST['command_id']; $query = "INSERT INTO `codev_command_bug_table` (`command_id`, `bug_id`) VALUES"; $separator = ""; //TODO test if command id is valid !!!! foreach ($command_ids as $command_id) { $query = $query . $separator . " (" . db_param() . ", " . db_param() . ")"; $separator = ","; } $query = $query . ";"; $result = db_query_bound($query, array($command_id, $t_bug_id)); // === add to WBS // 1) get the wbs_id of this command $query2 = "SELECT name, wbs_id FROM codev_command_table WHERE id = " . db_param(); $result2 = db_query_bound($query2, array($command_id)); $row2 = db_fetch_array($result2); $wbs_id = $row2['wbs_id']; $cmd_name = $row2['name']; // 2) if wbs_id is null, the root element must be created // (this happens only once when upgrading from 0.99.24 or below) $order = 1; if (is_null($wbs_id)) { #echo "Create WBS root element for Command $command_id<br>"; // add root element $query3 = "INSERT INTO codev_wbs_table (`order`, `expand`, `title`) " . "VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ")"; $result3 = db_query_bound($query3, array(1, 1, $cmd_name)); $wbs_id = db_insert_id(); $query4 = "UPDATE codev_command_table SET wbs_id = " . db_param() . " WHERE id = " . db_param(); $result4 = db_query_bound($query4, array($wbs_id, $command_id)); // 2.1) add all existing issues to the WBS $query6 = "SELECT bug_id from codev_command_bug_table WHERE command_id = " . db_param() . " ORDER BY bug_id"; $result6 = db_query_bound($query6, array($command_id)); while ($row6 = db_fetch_array($result6)) { #echo "add issue $row6->bug_id to command $command_id<br>"; $query7 = "INSERT INTO codev_wbs_table (`root_id`, `parent_id`, `bug_id`, `order`, `expand`) " . "VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ")"; #echo "SQL query7 = $query7<br>"; $result7 = db_query_bound($query7, array($wbs_id, $wbs_id, $row6['bug_id'], $order, 0)); $order += 1; } } else { // 3) add bug_id to the wbs root element $query5 = "INSERT INTO codev_wbs_table (`root_id`, `parent_id`, `bug_id`, `order`, `expand`) " . "VALUES (" . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ")"; #echo "SQL query5 = $query5<br>"; $result5 = db_query_bound($query5, array($wbs_id, $wbs_id, $t_bug_id, $order, 0)); } } }
/** * @param array $data * @return array|boolean */ public function insert($data) { extract($data); $query = "INSERT INTO {$this->table} (bug_id, description) VALUES (" . db_param() . ', ' . db_param() . ')'; if (!db_query_bound($query, [$bug_id, $description])) { return false; } return ['id' => db_insert_id($this->table), 'bug_id' => $bug_id, 'description' => $description, 'finished' => false]; }
/** * Migrate the legacy category data to the new category_id-based schema. */ function install_category_migrate() { global $g_db_log_queries; $t_bug_table = db_get_table('mantis_bug_table'); $t_category_table = db_get_table('mantis_category_table'); $t_project_category_table = db_get_table('mantis_project_category_table'); // disable query logging (even if it's enabled in config for this) if ($g_db_log_queries !== 0) { $t_log_queries = $g_db_log_queries; $g_db_log_queries = 0; } else { $t_log_queries = null; } $query = "SELECT project_id, category, user_id FROM {$t_project_category_table} ORDER BY project_id, category"; $t_category_result = db_query_bound($query); $query = "SELECT project_id, category FROM {$t_bug_table} ORDER BY project_id, category"; $t_bug_result = db_query_bound($query); $t_data = array(); # Find categories specified by project while ($row = db_fetch_array($t_category_result)) { $t_project_id = $row['project_id']; $t_name = $row['category']; $t_data[$t_project_id][$t_name] = $row['user_id']; } # Find orphaned categories from bugs while ($row = db_fetch_array($t_bug_result)) { $t_project_id = $row['project_id']; $t_name = $row['category']; if (!isset($t_data[$t_project_id][$t_name])) { $t_data[$t_project_id][$t_name] = 0; } } # In every project, go through all the categories found, and create them and update the bug foreach ($t_data as $t_project_id => $t_categories) { $t_inserted = array(); foreach ($t_categories as $t_name => $t_user_id) { $t_lower_name = utf8_strtolower(trim($t_name)); if (!isset($t_inserted[$t_lower_name])) { $query = "INSERT INTO {$t_category_table} ( name, project_id, user_id ) VALUES ( " . db_param() . ', ' . db_param() . ', ' . db_param() . ' )'; db_query_bound($query, array($t_name, $t_project_id, $t_user_id)); $t_category_id = db_insert_id($t_category_table); $t_inserted[$t_lower_name] = $t_category_id; } else { $t_category_id = $t_inserted[$t_lower_name]; } $query = "UPDATE {$t_bug_table} SET category_id=" . db_param() . ' WHERE project_id=' . db_param() . ' AND category=' . db_param(); db_query_bound($query, array($t_category_id, $t_project_id, $t_name)); } } // re-enabled query logging if we disabled it if ($t_log_queries !== null) { $g_db_log_queries = $t_log_queries; } # return 2 because that's what ADOdb/DataDict does when things happen properly return 2; }
protected static function eav_create($name) { $res = db_query("INSERT INTO %ss (name) VALUES ('%s')", static::subGetClass(), $name); if ($res) { return db_insert_id(); } else { Error::generate('notice', static::subGetClass() . 'name already taken.'); return false; } }
function clone_dashboard($userid, $id) { // Get content, name and description from origin dashboard $result = db_query("SELECT content,name,description FROM dashboard WHERE userid = '{$userid}' AND id='{$id}'"); $row = db_fetch_array($result); // Name for cloned dashboard $name = $row['name'] . _(' clone'); db_query("INSERT INTO dashboard (`userid`,`content`,`name`,`description`) VALUES ('{$userid}','{$row['content']}','{$name}','{$row['description']}')"); return db_insert_id(); }
function shippers_insert() { global $Translation; if ($_GET['insert_x'] != '') { $_POST = $_GET; } // mm: can member insert record? $arrPerm = getTablePermissions('shippers'); if (!$arrPerm[1]) { return false; } $data['CompanyName'] = makeSafe($_POST['CompanyName']); if ($data['CompanyName'] == empty_lookup_value) { $data['CompanyName'] = ''; } $data['Phone'] = makeSafe($_POST['Phone']); if ($data['Phone'] == empty_lookup_value) { $data['Phone'] = ''; } if ($data['CompanyName'] == '') { echo StyleSheet() . "\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Company Name': " . $Translation['field not null'] . '<br><br>'; echo '<a href="" onclick="history.go(-1); return false;">' . $Translation['< back'] . '</a></div>'; exit; } // hook: shippers_before_insert if (function_exists('shippers_before_insert')) { $args = array(); if (!shippers_before_insert($data, getMemberInfo(), $args)) { return false; } } $o = array('silentErrors' => true); sql('insert into `shippers` set `CompanyName`=' . ($data['CompanyName'] !== '' && $data['CompanyName'] !== NULL ? "'{$data['CompanyName']}'" : 'NULL') . ', `Phone`=' . ($data['Phone'] !== '' && $data['Phone'] !== NULL ? "'{$data['Phone']}'" : 'NULL'), $o); if ($o['error'] != '') { echo $o['error']; echo "<a href=\"shippers_view.php?addNew_x=1\">{$Translation['< back']}</a>"; exit; } $recID = db_insert_id(db_link()); // hook: shippers_after_insert if (function_exists('shippers_after_insert')) { $res = sql("select * from `shippers` where `ShipperID`='" . makeSafe($recID) . "' limit 1", $eo); if ($row = db_fetch_assoc($res)) { $data = array_map('makeSafe', $row); } $data['selectedID'] = makeSafe($recID); $args = array(); if (!shippers_after_insert($data, getMemberInfo(), $args)) { return get_magic_quotes_gpc() ? stripslashes($recID) : $recID; } } // mm: save ownership data sql("insert into membership_userrecords set tableName='shippers', pkValue='{$recID}', memberID='" . getLoggedMemberID() . "', dateAdded='" . time() . "', dateUpdated='" . time() . "', groupID='" . getLoggedGroupID() . "'", $eo); return get_magic_quotes_gpc() ? stripslashes($recID) : $recID; }
function InsertNewItem($variants, $productID) { $sql = 'INSERT INTO `?#SHOPPING_CART_ITEMS_TABLE` (`productID`) values(?)'; db_phquery($sql, $productID); $itemID = db_insert_id(); foreach ($variants as $var) { $sql = 'INSERT INTO `?#SHOPPING_CART_ITEMS_CONTENT_TABLE` (itemID, variantID) values(?,?)'; db_phquery($sql, $itemID, $var); } return $itemID; }
function acquire($ticketId, $staffId) { global $cfg; if (!$ticketId or !$staffId or !$cfg->getLockTime()) { return 0; } //Cleanup any expired locks on the ticket. db_query('DELETE FROM ' . TICKET_LOCK_TABLE . ' WHERE ticket_id=' . db_input($ticketId) . ' AND expire<NOW()'); //TODO: cleanup any other locks owned by the user? (NOT a good idea.. could be working on 2 tickets at once??) $sql = 'INSERT IGNORE INTO ' . TICKET_LOCK_TABLE . ' SET created=NOW() ' . ',ticket_id=' . db_input($ticketId) . ',staff_id=' . db_input($staffId) . ',expire=DATE_ADD(NOW(),INTERVAL ' . $cfg->getLockTime() . ' MINUTE) '; return db_query($sql) ? db_insert_id() : 0; }
function add_assembly($p_assembly_number, $p_revision, $m_customer_name, $new_customer, $new_assembly) { $p_customer_id = add_customer($m_customer_name, $new_customer); global $g_mantis_serials_assembly; if ($new_assembly == 'true') { $query = "INSERT\n\t\t\t\t\tINTO {$g_mantis_serials_assembly}\n\t\t\t\t\t( assembly_id, customer_id, assembly_number, revision )\n\t\t\t\t\tVALUES\n\t\t\t\t\t( null, '{$p_customer_id}', '{$p_assembly_number}', '{$p_revision}' )"; db_query_bound($query); $t_assembly_id = db_insert_id($g_mantis_serials_assembly); return $t_assembly_id; } else { return $new_assembly; } }
function shipsInFleet($f_iShipId, $f_szFleet, $f_iPlanetId = PLANET_ID) { $iShipsInFleet = db_select_one('fleets f, ships_in_fleets s', 's.amount', 's.fleet_id = f.id AND f.fleetname = \'' . $f_szFleet . '\' AND s.ship_id = ' . (int) $f_iShipId . ' AND f.owner_planet_id = ' . $f_iPlanetId); if (false === $iShipsInFleet) { $iFleetId = db_select_one('fleets', 'id', 'owner_planet_id = ' . $f_iPlanetId . ' AND fleetname = \'' . $f_szFleet . '\''); if (false === $iFleetId) { db_insert('fleets', array('owner_planet_id' => $f_iPlanetId, 'fleetname' => $f_szFleet)); $iFleetId = db_insert_id(); } db_insert('ships_in_fleets', array('fleet_id' => (int) $iFleetId, 'ship_id' => $f_iShipId)); return 0; } return (int) $iShipsInFleet; }
function createUpgradedTicket() { global $cfg; //Create a ticket to make the system warm and happy. $dept_id = $cfg->getDefaultDeptId(); $prio_id = $cfg->getDefaultPriorityId(); $sql = 'INSERT INTO ' . TICKET_TABLE . ' SET created=NOW(), status="open", source="Web" ' . " ,priority_id={$prio_id}, dept_id={$dept_id}, topic_id=0 " . ' ,ticketID=' . db_input(Misc::randNumber(6)) . ' ,email="*****@*****.**" ' . ' ,name="osTicket Support" ' . ' ,subject="osTicket Upgraded!"'; if (db_query($sql, false) && ($tid = db_insert_id())) { if (!($msg = file_get_contents(UPGRADE_DIR . 'msg/upgraded.txt'))) { $msg = 'Congratulations and Thank you for choosing osTicket!'; } $sql = 'INSERT INTO ' . TICKET_THREAD_TABLE . ' SET created=NOW()' . ', source="Web" ' . ', thread_type="M" ' . ', ticket_id=' . db_input($tid) . ', title=' . db_input('osTicket Upgraded') . ', body=' . db_input($msg); db_query($sql, false); } }