wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 'bar' ) )
wpdb::insert( 'table', array( 'column' => 'foo', 'field' => 1337 ), array( '%s', '%d' ) )
public insert ( string $table, array $data, array | string $format = null ) : integer | false | ||
$table | string | table name |
$data | array | Data to insert (in column => value pairs). Both $data columns and $data values should be "raw" (neither should be SQL escaped). |
$format | array | string | Optional. An array of formats to be mapped to each of the value in $data. If string, that format will be used for all of the values in $data. A format is one of '%d', '%f', '%s' (integer, float, string). If omitted, all values in $data will be treated as strings unless otherwise specified in wpdb::$field_types. |
return | integer | false | The number of rows inserted, or false on error. |
function __toString() { // if the playlist are saved to db, i load it from db $playlist = $this->wpdb->get_row("SELECT ID, url, playlist FROM " . $this->table_name . " WHERE url = '" . $this->url . "'"); if ($this->wpdb->num_rows > 0) { $playlist = unserialize($playlist->playlist); } else { $playlist = array(); $code = implode("", file($this->url)); if ($code == "") { $this->errors->add('no_content', __('The url $url are not valid!')); } preg_match_all("/section-row-track(.+)/", $code, $results); for ($i = 0; $i < sizeof($results[0]); $i++) { preg_match("/class=\"tracklisttrackname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match); $title = $match[1]; preg_match("/class=\"tracklistartistname mx-link\">(.+)<\\/a>/U", $results[0][$i], $match); $artist = $match[1]; if ($title != "" || $artist != "") { $playlist[] = array("title" => $title, "artist" => $artist); } } $this->wpdb->show_errors(); // save to db the playlist for this url $this->wpdb->insert($this->table_name, array("url" => $this->url, "playlist" => serialize($playlist)), array("%s", "%s")); } $code = "<h3>Playlist</h3><ul class='mixcloud-embed-playlist'>"; for ($i = 0; $i < count($playlist); $i++) { $code .= "<li><span class='mixcloud-embed-position'>" . ($i + 1) . "</span>"; $code .= "<span class='mixcloud-embed-artist'>" . $playlist[$i]["artist"] . "</span>"; $code .= "<span class='mixcloud-embed-title'>" . $playlist[$i]["title"] . "</span></li>"; } $code .= "</ul>"; return $code; }
/** * @param string $email Email address to log * @param string|array $list_ids String or array of list ID's * @param array $data The data that was sent to MailChimp * @param int $success Whether the sign-up succeeded * @param string $method The method that was used (form or checkbox) * @param string $type The type that was used (form, registration, cf7, etc..) * @param int $related_object_id ID of the related object, if any (form, comment, user, etc..) * @param string $url The URl the request originated from * * @return false|int */ public function add($email, $list_ids, $data = array(), $success = 1, $method = 'form', $type = 'form', $related_object_id = 0, $url = '') { if (is_array($list_ids)) { $list_ids = implode(',', $list_ids); } return $this->db->insert($this->table_name, array('email' => $email, 'list_ids' => $list_ids, 'success' => $success ? 1 : 0, 'data' => json_encode($data), 'method' => $method, 'type' => $type, 'related_object_ID' => absint($related_object_id), 'url' => $url)); }
/** * * @param string $email * @param string $name * * @return false|int|void */ public function insertSubscriber($email, $name = '') { if (!is_email($email) || $this->emailExists($email)) { return false; } return $this->wpdb->insert($this->table, ['email' => $email, 'name' => $name]); }
protected function _create() { if (($result = $this->_wpdb->insert($this->_table(), $this->_fields)) === FALSE) { return FALSE; } $this->id = $this->_wpdb->insert_id; return TRUE; }
/** * Saves a ruleset to database. * * @param array $rulesetData The data to save. * @param int $rulesetId Primary key of ruleset if it already exists. * @return bool|int Id of saved rule on success or false on error. */ public function saveRuleset($rulesetData, $rulesetId = 0) { if (empty($rulesetData)) { return false; } if (!empty($rulesetId)) { $updateResult = $this->wpdb->update($this->wpdb->rulesets, $rulesetData, array('id' => $rulesetId), array('%s', '%d', '%s', '%d', '%d', '%s', '%s', '%d', '%s'), array('%d')); return $updateResult === false ? false : $rulesetId; } else { $this->wpdb->insert($this->wpdb->rulesets, $rulesetData, array('%s', '%d', '%s', '%d', '%d', '%s', '%s', '%d', '%s')); $rulesetId = $this->wpdb->insert_id; return empty($rulesetId) ? false : $rulesetId; } }
public function after_save(Table $table, Record $new_record) { // Don't save changes to the changes tables. if (in_array($table->get_name(), self::table_names())) { return false; } // Save a change for each changed column. foreach ($table->get_columns() as $column) { $col_name = $column->is_foreign_key() ? $column->get_name() . Record::FKTITLE : $column->get_name(); $old_val = is_callable(array($this->old_record, $col_name)) ? $this->old_record->{$col_name}() : null; $new_val = $new_record->{$col_name}(); if ($new_val == $old_val) { // Ignore unchanged columns. continue; } $data = array('changeset_id' => self::$current_changeset_id, 'change_type' => 'field', 'table_name' => $table->get_name(), 'column_name' => $column->get_name(), 'record_ident' => $new_record->get_primary_key()); // Daft workaround for https://core.trac.wordpress.org/ticket/15158 if (!is_null($old_val)) { $data['old_value'] = $old_val; } if (!is_null($new_val)) { $data['new_value'] = $new_val; } // Save the change record. $this->wpdb->insert($this->changes_name(), $data); } // Close the changeset if required. if (!self::$keep_changeset_open) { $this->close_changeset(); } }
/** * Records transaction into database. * * @access protected * @param type $user_id * @param type $sub_id * @param type $amount * @param type $currency * @param type $timestamp * @param type $paypal_ID * @param type $status * @param type $note */ protected function _record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $paypal_ID, $status, $note) { $data = array('transaction_subscription_ID' => $sub_id, 'transaction_user_ID' => $user_id, 'transaction_paypal_ID' => $paypal_ID, 'transaction_stamp' => $timestamp, 'transaction_currency' => $currency, 'transaction_status' => $status, 'transaction_total_amount' => (int) round($amount * 100), 'transaction_note' => $note, 'transaction_gateway' => $this->gateway); $existing_id = $this->db->get_var($this->db->prepare("SELECT transaction_ID FROM " . MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION . " WHERE transaction_paypal_ID = %s LIMIT 1", $paypal_ID)); if (!empty($existing_id)) { $this->db->update(MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION, $data, array('transaction_ID' => $existing_id)); } else { $this->db->insert(MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION, $data); } }
function update() { $this->dirty = true; if ($this->id < 0) { $this->add(); } else { $this->db->update(MEMBERSHIP_TABLE_SUBSCRIPTIONS, array('sub_name' => trim(filter_input(INPUT_POST, 'sub_name')), 'sub_description' => trim(filter_input(INPUT_POST, 'sub_description')), 'sub_pricetext' => trim(filter_input(INPUT_POST, 'sub_pricetext')), 'order_num' => filter_input(INPUT_POST, 'sub_order_num', FILTER_VALIDATE_INT)), array('id' => $this->id), array('%s', '%s', '%s', '%d'), array('%d')); // Remove the existing rules for this subscription level $this->db->delete(MEMBERSHIP_TABLE_SUBSCRIPTION_LEVELS, array('sub_id' => $this->id), array('%d')); if (!empty($_POST['level-order'])) { $levels = explode(',', $_POST['level-order']); $count = 1; foreach ((array) $levels as $level) { if (!empty($level)) { // Check if the rule has any information for it. if (isset($_POST['levelmode'][$level])) { $levelmode = esc_attr($_POST['levelmode'][$level]); } else { continue; } if (isset($_POST['levelperiod'][$level])) { $levelperiod = esc_attr($_POST['levelperiod'][$level]); } else { $levelperiod = ''; } if (isset($_POST['levelperiodunit'][$level])) { $levelperiodunit = esc_attr($_POST['levelperiodunit'][$level]); } else { $levelperiodunit = ''; } if (isset($_POST['levelprice'][$level])) { $levelprice = floatval(esc_attr($_POST['levelprice'][$level])); } else { $levelprice = ''; } if (isset($_POST['levelcurrency'][$level])) { $levelcurrency = esc_attr($_POST['levelcurrency'][$level]); } else { $levelcurrency = ''; } // Calculate the level id $lev = explode('-', $level); if ($lev[0] == 'level') { $level_id = (int) $lev[1]; // write it to the database $this->db->insert(MEMBERSHIP_TABLE_SUBSCRIPTION_LEVELS, array("sub_id" => $this->id, "level_period" => $levelperiod, "sub_type" => $levelmode, "level_price" => $levelprice, "level_currency" => $levelcurrency, "level_order" => $count++, "level_id" => $level_id, "level_period_unit" => $levelperiodunit)); } } } } do_action('membership_subscription_update', $this->id); } return true; // for now }
/** * Create a new form. * * @author Jeremy Pry * * @param array $form_data Data to apply to the new form. * * @return int|bool The new form ID, or false on failure. */ public function create_form($form_data) { // Include default form data $form_data = yikes_deep_parse_args($form_data, $this->get_form_defaults()); // If there is an ID set, remove it unset($form_data['id']); // Prepare the data for the database $save_data = $this->prepare_data_for_db($form_data); $formats = $this->get_format_array($save_data); $result = $this->wpdb->insert($this->prefixed_table_name, $save_data, $formats); if (false === $result) { return $result; } return $this->wpdb->insert_id; }
function create_client($subdomain, $client_name, $client_username, $client_email, $client_password) { if ($db = create_db($subdomain) !== false) { try { $con = new wpdb(MYSQL_ROUTING_USER, MYSQL_ROUTING_PASSWORD, MYSQL_ROUTING_DB, MYSQL_ROUTING_HOST); $result = $con->insert('client', array('subdomain' => $subdomain, 'email' => $client_email, 'name' => $client_name, 'admin_username' => $client_username, 'admin_password' => base64_encode($client_password), 'status' => 0, 'db_driver' => 'mysql', 'db_host' => 'localhost', 'db_name' => $db["db_name"], 'db_user' => $db["db_user"], 'db_pass' => $db["db_pass"], 'db_charset' => 'utf8', 'db_collation' => 'utf8_unicode_ci', 'db_prefix' => '', 'created_at' => date("Y-m-d H:i:s")), array('%s', '%s', '%s', '%s', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); if ($result) { return true; } } catch (Exception $e) { return false; } } return false; }
protected function actionLicenseSite($productSlug, $licenseKey) { $this->requireRequestMethod('POST'); $license = $this->validateLicenseRequest($productSlug, $licenseKey); //Is the license still valid? if (!$license->isValid()) { if ($license->getStatus() == 'expired') { $renewalUrl = $license->get('renewal_url'); $this->outputError('expired_license', sprintf('This license key has expired. You can still use the plugin (without activating the key), but you will need to %1$srenew the license%2$s to receive updates.', $renewalUrl ? '<a href="' . esc_attr($renewalUrl) . '" target="_blank">' : '', $renewalUrl ? '</a>' : ''), 400); } else { $this->outputError('invalid_license', 'This license key is invalid or has expired.', 400); } return; } $siteUrl = isset($this->post['site_url']) ? strval($this->post['site_url']) : ''; if (!$this->isValidUrl($siteUrl)) { $this->outputError('site_url_expected', "Missing or invalid site URL.", 400); return; } $siteUrl = $this->sanitizeSiteUrl($siteUrl); //Maybe the site is already licensed? $token = $this->wpdb->get_var($this->wpdb->prepare("SELECT token FROM {$this->tablePrefix}tokens WHERE site_url = %s AND license_id = %d", $siteUrl, $license['license_id'])); if (!empty($token)) { $this->outputResponse(array('site_token' => $token, 'license' => $this->prepareLicenseForOutput($license))); return; } //Check the number of sites already licensed and see if we can add another one. if ($license['max_sites'] !== null) { $licensedSiteCount = $this->wpdb->get_var($this->wpdb->prepare("SELECT COUNT(*) FROM {$this->tablePrefix}tokens WHERE license_id = %d", $license['license_id'])); if (intval($licensedSiteCount) >= intval($license['max_sites'])) { $upgradeUrl = $license->get('upgrade_url'); $this->outputError('max_sites_reached', sprintf('You have reached the maximum number of sites allowed by your license. ' . 'To activate it on another site, you need to either %1$supgrade the license%2$s ' . 'or remove it from one of your existing sites in the <span class="%3$s">"Manage Sites"</span> tab.', $upgradeUrl ? '<a href="' . esc_attr($upgradeUrl) . '" target="_blank">' : '', $upgradeUrl ? '</a>' : '', 'ame-open-tab-manage-sites'), 400, $this->prepareLicenseForOutput($license, false)); return; } } //If the site was already associated with another key, remove that association. Only one key per site. $otherToken = $this->wpdb->get_var($this->wpdb->prepare("SELECT tokens.token\n\t\t\t FROM {$this->tablePrefix}tokens AS tokens\n\t\t\t\tJOIN {$this->tablePrefix}licenses AS licenses\n\t\t\t\tON tokens.license_id = licenses.license_id\n\t\t\t WHERE\n\t\t\t\ttokens.site_url = %s\n\t\t\t\tAND licenses.product_slug = %s\n\t\t\t\tAND licenses.license_id <> %d", $siteUrl, $productSlug, $license['license_id'])); if (!empty($otherToken)) { $this->wpdb->delete($this->tablePrefix . 'tokens', array('token' => $otherToken)); } //Everything checks out, lets create a new token. $token = $this->generateRandomString(32); $this->wpdb->insert($this->tablePrefix . 'tokens', array('license_id' => $license['license_id'], 'token' => $token, 'site_url' => $siteUrl, 'issued_on' => date('Y-m-d H:i:s'))); //Reload the license to ensure it includes the changes we just made. $license = $this->loadLicense($licenseKey); $this->outputResponse(array('site_token' => $token, 'license' => $this->prepareLicenseForOutput($license))); }
protected function actionLicenseSite($productSlug, $licenseKey) { $this->requireRequestMethod('POST'); $license = $this->validateLicenseRequest($productSlug, $licenseKey); //Is the license still valid? if (!$license->isValid()) { if ($license->getStatus() == 'expired') { $this->outputError('expired_license', 'This license key has expired.', 400); } else { $this->outputError('invalid_license', 'This license key is invalid or has expired.', 400); } return; } $siteUrl = isset($this->post['site_url']) ? strval($this->post['site_url']) : ''; if (!$this->isValidUrl($siteUrl)) { $this->outputError('site_url_expected', "Missing or invalid site URL.", 400); return; } $siteUrl = $this->sanitizeSiteUrl($siteUrl); //Maybe the site is already licensed? $token = $this->wpdb->get_var($this->wpdb->prepare("SELECT token FROM {$this->tablePrefix}tokens WHERE site_url = %s AND license_id = %d", $siteUrl, $license['license_id'])); if (!empty($token)) { $this->outputResponse(array('site_token' => $token, 'license' => $this->prepareLicenseForOutput($license))); return; } //Check the number of sites already licensed and see if we can add another one. if ($license['max_sites'] !== null) { $licensedSiteCount = $this->wpdb->get_var($this->wpdb->prepare("SELECT COUNT(*) FROM {$this->tablePrefix}tokens WHERE license_id = %d", $license['license_id'])); if (intval($licensedSiteCount) >= intval($license['max_sites'])) { $this->outputError('max_sites_reached', "You have already reached the maximum number of sites allowed by your license.", 400); return; } } //If the site was already associated with another key, remove that association. Only one key per site. $otherToken = $this->wpdb->get_var($this->wpdb->prepare("SELECT tokens.token\n\t\t\t FROM {$this->tablePrefix}tokens AS tokens\n\t\t\t\tJOIN {$this->tablePrefix}licenses AS licenses\n\t\t\t\tON tokens.license_id = licenses.license_id\n\t\t\t WHERE\n\t\t\t\ttokens.site_url = %s\n\t\t\t\tAND licenses.product_slug = %s\n\t\t\t\tAND licenses.license_id <> %d", $siteUrl, $productSlug, $license['license_id'])); if (!empty($otherToken)) { $this->wpdb->delete($this->tablePrefix . 'tokens', array('token' => $otherToken)); } //Everything checks out, lets create a new token. $token = $this->generateRandomString(32); $this->wpdb->insert($this->tablePrefix . 'tokens', array('license_id' => $license['license_id'], 'token' => $token, 'site_url' => $siteUrl, 'issued_on' => date('Y-m-d H:i:s'))); //Reload the license to ensure it includes the changes we just made. $license = $this->loadLicense($licenseKey); $this->outputResponse(array('site_token' => $token, 'license' => $this->prepareLicenseForOutput($license))); }
public function add_subscription($tosub_id, $tolevel_id = false, $to_order = false, $gateway = 'admin') { if (!apply_filters('pre_membership_add_subscription', true, $tosub_id, $tolevel_id, $to_order, $this->ID) || $this->on_sub($tosub_id)) { return false; } // grab the level information for this position $subscription = Membership_Plugin::factory()->get_subscription($tosub_id); $level = $subscription->get_level_at($tolevel_id, $to_order); if ($level) { $now = current_time('mysql'); $start = strtotime($now); switch ($level->level_period_unit) { case 'd': $period = 'days'; break; case 'w': $period = 'weeks'; break; case 'm': $period = 'months'; break; case 'y': $period = 'years'; break; default: $period = 'days'; break; } //level end date $expires = strtotime('+' . $level->level_period . ' ' . $period, $start); $expires = gmdate('Y-m-d H:i:s', $expires ? $expires : strtotime('+365 days', $start)); //subscription end date $expires_sub = $this->get_subscription_expire_date($subscription, $tolevel_id); $this->_wpdb->insert(MEMBERSHIP_TABLE_RELATIONS, array('user_id' => $this->ID, 'level_id' => $tolevel_id, 'sub_id' => $tosub_id, 'startdate' => $now, 'updateddate' => $now, 'expirydate' => $expires, 'order_instance' => $level->level_order, 'usinggateway' => $gateway)); // Update users start and expiry meta update_user_meta($this->ID, 'start_current_' . $tosub_id, $start); update_user_meta($this->ID, 'expire_current_' . $tosub_id, $expires_sub); update_user_meta($this->ID, 'using_gateway_' . $tosub_id, $gateway); // Update associated role $this->set_role(Membership_Model_Level::get_associated_role($level->level_id)); do_action('membership_add_subscription', $tosub_id, $tolevel_id, $to_order, $this->ID); } return true; }
function add() { switch ($_POST['periodtype']) { case 'd': $time = strtotime('+' . $_POST['periodunit'] . ' days') - time(); break; case 'm': $time = strtotime('+' . $_POST['periodunit'] . ' months') - time(); break; case 'y': $time = strtotime('+' . $_POST['periodunit'] . ' years') - time(); break; } $periodstamp = $_POST['periodprepost'] == 'pre' ? -$time : $time; if ('join' == $_POST['periodprepost'] || 'exp' == $_POST['periodprepost']) { $periodstamp = 0; } return $this->db->insert(MEMBERSHIP_TABLE_COMMUNICATIONS, array("periodunit" => $_POST['periodunit'], "periodtype" => $_POST['periodtype'], "periodprepost" => $_POST['periodprepost'], "subject" => $_POST['subject'], "message" => stripslashes($_POST['message']), "periodstamp" => $periodstamp, "sub_id" => $_POST['subscription_id'])); }
/** * Saves data into the database. * * @since 2.0.0 * * @param array $data The data to insert into database. * * @return bool * @throws Exception */ public function save($data) { $time = current_time('mysql'); // Only save leads if the user has the option checked. $option = get_option('optin_monster'); if (!isset($option['leads']) || isset($option['leads']) && !$option['leads']) { throw new Exception(__('The user has chosen not to store leads locally.', 'optin-monster')); } // Make sure the required fieds exist in the passed data array. foreach ($this->required_fields as $key => $value) { if (!array_key_exists($value, $data)) { throw new Exception(sprintf(__('A value for %s must be passed in the $data array.', 'optin-monster'), $value)); } } // Ensure that the lead does not already exist in the DB. $exists = $this->find_where('lead_email', $data['lead_email']); if (!empty($exists)) { throw new Exception(__('The lead already exists in the database.', 'optin-monster')); } // Add the date modified to the data array $data['date_modified'] = $time; // If an 'id' is passed, we're going to update the record, else insert. if (isset($data['id'])) { $id = $data['id']; unset($data['id']); if (false == $this->db->update($this->table, $data, array('lead_id', $id))) { throw new Exception(__('There was an error updating the lead.', 'optin-monster')); } else { return true; } } else { // This is a new record, so we'll insert the date added. $data['date_added'] = $time; if (false == $this->db->insert($this->table, $data)) { throw new Exception(__('There was an error inserting the lead.', 'optin-monster')); } else { return true; } } }
/** * Load the localization * * @since 0.1 * @uses load_plugin_textdomain, plugin_basename * @param Mlp_Db_Schema_Interface $languages * @return void */ private function import_active_languages(Mlp_Db_Schema_Interface $languages) { // get active languages $mlp_settings = get_site_option('inpsyde_multilingual'); if (empty($mlp_settings)) { return; } $table = $languages->get_table_name(); $sql = 'SELECT ID FROM ' . $table . 'WHERE wp_locale = %s OR iso_639_1 = %s'; foreach ($mlp_settings as $mlp_site) { $text = $mlp_site['text'] != '' ? $mlp_site['text'] : $mlp_site['lang']; $query = $this->wpdb->prepare($sql, $mlp_site['lang'], $mlp_site['lang']); $lang_id = $this->wpdb->get_var($query); // language not found -> insert if (empty($lang_id)) { // @todo add custom name $this->wpdb->insert($table, array('english_name' => $text, 'wp_locale' => $mlp_site['lang'], 'http_name' => str_replace('_', '-', $mlp_site['lang']))); } else { $this->wpdb->update($table, array('priority' => 10), array('ID' => $lang_id)); } } }
} //____data } elseif (get_option('dbf-0-main-function') == 'data') { //______datenbank connect $dbf_db = new wpdb(get_option('dbf-0-db-user'), get_option('dbf-0-db-password'), get_option('dbf-0-db-name'), get_option('dbf-0-db-host')); if ($dbf_db) { //______string vorbereiten $dbf_insert = array(); foreach ($dbf_sec_fields as $field) { $dbf_column = $field['name']; if (isset($_POST[$dbf_column])) { $dbf_insert[$dbf_column] = $_POST[$dbf_column]; } } //______push! if ($dbf_db->insert(get_option('dbf-0-db-table'), $dbf_insert)) { //________confirmation if (get_option('dbf-0-confirmation') == 'true') { //________confirmation bauen //__________recipient if (get_option('dbf-0-confirmation-function') == 'custom') { preg_match_all('/%(.*)%/U', get_option('dbf-0-confirmation-recipient'), $matches); if (count($matches[0]) == 1) { $dbf_confirmation_recipient = $_POST[$matches[1][0]]; } else { $dbf_confirmation_recipient = get_option('dbf-0-confirmation-recipient'); } } else { $dbf_confirmation_recipient = get_option('dbf-0-admin-mail'); } //__________content
/** * Adds a new form to the database table. * * @param string Form name. * @param string Post type that this form is meant to handle. * @param string Form description. * @param array An array consisting of all the form fields and their restrictions. Stored as a serialized string in the database. * @param array An array consisting of form settings. Stored as a serialized string in the database. * @return mixed False in case the row could not be inserted. Otherwize the number of affected rows. **/ public function add($name, $post_type, $description = "", $fields = "", $settings = "", $emails = "") { return $this->db->insert($this->table_name, array('name' => $name, 'post_type' => $post_type, 'description' => $description, 'fields' => $this->serialize($fields), 'settings' => $this->serialize($settings), 'emails' => $this->serialize($emails))); }
protected function _add($term_id, $key, $value) { wp_cache_set($this->_get_cache_key($term_id, $key), $value, 'taxonomy-meta'); return $this->_db->insert($this->_table, ['term_id' => $term_id, 'meta_key' => $key, 'meta_value' => maybe_serialize($value)]); }
//check if email is already registered $email_check = $wpdb->get_var('SELECT SQL_CACHE ID FROM wp_users WHERE user_email = "' . mysql_real_escape_string($_POST['email']) . '" LIMIT 1;'); if (strlen($email_check) > 0) { $msg = '<div class="warning">This email address is already registered !</div>'; } else { $username_check = $wpdb->get_var('SELECT SQL_CACHE ID FROM wp_users WHERE user_login = "******" LIMIT 1;'); if (strlen($username_check) > 0) { //check if username is already registered $msg = '<div class="warning">This username is already registered !</div>'; } else { //make password secure $hash = wp_hash_password(mysql_real_escape_string($_POST['password'])); $display_name = $_POST['first_name'] . " " . $_POST['last_name']; $nickname = $_POST['first_name'] . "." . $_POST['last_name']; //insert wp user into db $insert_user = $wpdb->insert('wp_users', array('user_pass' => $hash, 'user_login' => mysql_real_escape_string($_POST['email']), 'display_name' => $display_name, 'user_nicename' => $display_name, 'user_email' => mysql_real_escape_string($_POST['email']), 'user_registered' => current_time('mysql', 1))); //check if user was inserted if ($insert_user) { //get wp user id $wp_userid = $wpdb->insert_id; //insert user settings in wp_usermeta db table $insert_user_settings = mysql_query('INSERT INTO `wp_usermeta` (`user_id`, `meta_key`, `meta_value`) VALUES ("' . $wp_userid . '", "wp_capabilities", "' . mysql_real_escape_string(serialize(array('subscriber' => '1'))) . '"), ("' . $wp_userid . '", "wp_user_level", "5"),( "' . $wp_userid . '", "first_name", "' . $_POST['first_name'] . '" ),( "' . $wp_userid . '", "last_name", "' . $_POST['last_name'] . '" ); '); if (mysql_affected_rows()) { //send email to new subscriber user $headers = "From: info@europe4you.it\r\n"; $headers .= "Reply-To: info@europe4you.it\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
/** * Process the form and returns the response * * @return string */ function iphorm_process_form() { $ajax = isset($_POST['iphorm_ajax']) && $_POST['iphorm_ajax'] == 1; $swfu = isset($_POST['iphorm_swfu']) && $_POST['iphorm_swfu'] == 1; if (isset($_POST['iphorm_id']) && isset($_POST['iphorm_uid']) && ($form = iphorm_get_form($_POST['iphorm_id'], $_POST['iphorm_uid'])) instanceof iPhorm && $form->getActive()) { // Strip slashes from the submitted data (WP adds them automatically) $_POST = stripslashes_deep($_POST); // Pre-process action hooks do_action('iphorm_pre_process', $form); do_action('iphorm_pre_process_' . $form->getId(), $form); $response = ''; // If we have files uploaded via SWFUpload, merge them into $_FILES if ($swfu && isset($_SESSION['iphorm-' . $form->getUniqId()])) { $_FILES = array_merge($_FILES, $_SESSION['iphorm-' . $form->getUniqId()]); } // Set the form element values $form->setValues($_POST); // Calculate which elements are hidden by conditional logic and which groups are empty $form->calculateElementStatus(); // Pre-validate action hooks do_action('iphorm_pre_validate', $form); do_action('iphorm_pre_validate_' . $form->getId(), $form); if ($form->isValid()) { // Post-validate action hooks do_action('iphorm_post_validate', $form); do_action('iphorm_post_validate_' . $form->getId(), $form); // Process any uploads first $attachments = array(); $elements = $form->getElements(); foreach ($elements as $element) { if ($element instanceof iPhorm_Element_File) { $elementName = $element->getName(); if (array_key_exists($elementName, $_FILES) && is_array($_FILES[$elementName])) { $file = $_FILES[$elementName]; if (is_array($file['error'])) { // Process multiple upload field foreach ($file['error'] as $key => $error) { if ($error === UPLOAD_ERR_OK) { $pathInfo = pathinfo($file['name'][$key]); $extension = isset($pathInfo['extension']) ? $pathInfo['extension'] : ''; $filenameFilter = new iPhorm_Filter_Filename(); $filename = strlen($extension) ? str_replace(".{$extension}", '', $pathInfo['basename']) : $pathInfo['basename']; $filename = $filenameFilter->filter($filename); $filename = apply_filters('iphorm_filename_' . $element->getName(), $filename, $element, $form); if (strlen($extension)) { $filename = strlen($filename) ? "{$filename}.{$extension}" : "upload.{$extension}"; } else { $filename = strlen($filename) ? $filename : 'upload'; } $fullPath = $file['tmp_name'][$key]; $value = array('text' => $filename); if ($element->getSaveToServer()) { $result = iphorm_save_uploaded_file($fullPath, $filename, $element, $form->getId()); if ($result !== false) { $fullPath = $result['fullPath']; $filename = $result['filename']; $value = array('url' => iphorm_get_wp_uploads_url() . '/' . $result['path'] . $filename, 'text' => $filename, 'fullPath' => $fullPath); } } if ($element->getAddAsAttachment()) { $attachments[] = array('fullPath' => $fullPath, 'type' => $file['type'][$key], 'filename' => $filename); } $element->addFile($value); } } } else { // Process single upload field if ($file['error'] === UPLOAD_ERR_OK) { $pathInfo = pathinfo($file['name']); $extension = isset($pathInfo['extension']) ? $pathInfo['extension'] : ''; $filenameFilter = new iPhorm_Filter_Filename(); $filename = strlen($extension) ? str_replace(".{$extension}", '', $pathInfo['basename']) : $pathInfo['basename']; $filename = $filenameFilter->filter($filename); $filename = apply_filters('iphorm_filename_' . $element->getName(), $filename, $element, $form); if (strlen($extension)) { $filename = strlen($filename) ? "{$filename}.{$extension}" : "upload.{$extension}"; } else { $filename = strlen($filename) ? $filename : 'upload'; } $fullPath = $file['tmp_name']; $value = array('text' => $filename); if ($element->getSaveToServer()) { $result = iphorm_save_uploaded_file($fullPath, $filename, $element, $form->getId()); if (is_array($result)) { $fullPath = $result['fullPath']; $filename = $result['filename']; $value = array('url' => iphorm_get_wp_uploads_url() . '/' . $result['path'] . $filename, 'text' => $filename, 'fullPath' => $fullPath); } } if ($element->getAddAsAttachment()) { $attachments[] = array('fullPath' => $fullPath, 'type' => $file['type'], 'filename' => $filename); } $element->addFile($value); } } } // end in $_FILES } // end instanceof file } // end foreach element // Save the entry to the database if ($form->getSaveToDatabase()) { global $wpdb; $currentUser = wp_get_current_user(); $entry = array('form_id' => $form->getId(), 'date_added' => gmdate('Y-m-d H:i:s'), 'ip' => mb_substr(iphorm_get_user_ip(), 0, 32), 'form_url' => isset($_POST['form_url']) ? mb_substr($_POST['form_url'], 0, 512) : '', 'referring_url' => isset($_POST['referring_url']) ? mb_substr($_POST['referring_url'], 0, 512) : '', 'post_id' => isset($_POST['post_id']) ? mb_substr($_POST['post_id'], 0, 32) : '', 'post_title' => isset($_POST['post_title']) ? mb_substr($_POST['post_title'], 0, 128) : '', 'user_display_name' => mb_substr(iphorm_get_current_userinfo('display_name'), 0, 128), 'user_email' => mb_substr(iphorm_get_current_userinfo('user_email'), 0, 128), 'user_login' => mb_substr(iphorm_get_current_userinfo('user_login'), 0, 128)); $wpdb->insert(iphorm_get_form_entries_table_name(), $entry); $entryId = $wpdb->insert_id; $form->setEntryId($entryId); $entryDataTableName = iphorm_get_form_entry_data_table_name(); foreach ($elements as $element) { if ($element->getSaveToDatabase() && !$element->isConditionallyHidden()) { $entryData = array('entry_id' => $entryId, 'element_id' => $element->getId(), 'value' => $element->getValueHtml()); $wpdb->insert($entryDataTableName, $entryData); } } } // Check if we need to send any emails if ($form->getSendNotification() || $form->getSendAutoreply()) { // Get a new PHP mailer instance $mailer = iphorm_new_phpmailer($form); // Create an email address validator, we'll need to use it later $emailValidator = new iPhorm_Validator_Email(); // Check if we should send the notification email if ($form->getSendNotification() && count($form->getRecipients())) { // Set the from address $notificationFromInfo = $form->getNotificationFromInfo(); $mailer->From = $notificationFromInfo['email']; $mailer->FromName = $notificationFromInfo['name']; // Set the BCC if (count($bcc = $form->getBcc())) { foreach ($bcc as $bccEmail) { $mailer->AddBCC($bccEmail); } } // Set the Reply-To header if (($replyToElement = $form->getNotificationReplyToElement()) instanceof iPhorm_Element_Email && $emailValidator->isValid($replyToEmail = $replyToElement->getValue())) { $mailer->AddReplyTo($replyToEmail); } // Set the subject $mailer->Subject = $form->replacePlaceholderValues($form->getSubject()); // Check for conditional recipient rules if (count($form->getConditionalRecipients())) { $recipients = array(); foreach ($form->getConditionalRecipients() as $rule) { if (isset($rule['element'], $rule['value'], $rule['operator'], $rule['recipient']) && ($rElement = $form->getElementById($rule['element'])) instanceof iPhorm_Element_Multi) { if ($rule['operator'] == 'eq') { if ($rElement->getValue() == $rule['value']) { $recipients[] = $rule['recipient']; } } else { if ($rElement->getValue() != $rule['value']) { $recipients[] = $rule['recipient']; } } } } if (count($recipients)) { foreach ($recipients as $recipient) { $mailer->AddAddress($form->replacePlaceholderValues($recipient)); } } else { // No conditional recipient rules were matched, use default recipients foreach ($form->getRecipients() as $recipient) { $mailer->AddAddress($form->replacePlaceholderValues($recipient)); } } } else { // Set the recipients foreach ($form->getRecipients() as $recipient) { $mailer->AddAddress($form->replacePlaceholderValues($recipient)); } } // Set the message content $emailHTML = ''; $emailPlain = ''; if ($form->getCustomiseEmailContent()) { if ($form->getNotificationFormat() == 'html') { $emailHTML = $form->getNotificationEmailContent(); } else { $emailPlain = $form->getNotificationEmailContent(); } // Replace any placeholder values $emailHTML = $form->replacePlaceholderValues($emailHTML, 'html', '<br />'); $emailPlain = $form->replacePlaceholderValues($emailPlain, 'plain', iphorm_get_email_newline()); } else { ob_start(); include IPHORM_INCLUDES_DIR . '/emails/email-html.php'; $emailHTML = ob_get_clean(); ob_start(); include IPHORM_INCLUDES_DIR . '/emails/email-plain.php'; $emailPlain = ob_get_clean(); } if (strlen($emailHTML)) { $mailer->MsgHTML($emailHTML); if (strlen($emailPlain)) { $mailer->AltBody = $emailPlain; } } else { $mailer->Body = $emailPlain; } // Attachments foreach ($attachments as $file) { $mailer->AddAttachment($file['fullPath'], $file['filename'], 'base64', $file['type']); } $mailer = apply_filters('iphorm_pre_send_notification_email', $mailer, $form, $attachments); $mailer = apply_filters('iphorm_pre_send_notification_email_' . $form->getId(), $mailer, $form, $attachments); try { // Send the message $mailer->Send(); } catch (Exception $e) { if (WP_DEBUG) { throw $e; } } } // Check if we should send the autoreply email if ($form->getSendAutoreply() && ($recipientElement = $form->getAutoreplyRecipientElement()) instanceof iPhorm_Element_Email && strlen($recipientEmailAddress = $recipientElement->getValue()) && $emailValidator->isValid($recipientEmailAddress)) { // Get a new PHP mailer instance $mailer = iphorm_new_phpmailer($form); // Set the subject $mailer->Subject = $form->replacePlaceholderValues($form->getAutoreplySubject()); // Set the from name/email $autoreplyFromInfo = $form->getAutoreplyFromInfo(); $mailer->From = $autoreplyFromInfo['email']; $mailer->FromName = $autoreplyFromInfo['name']; // Add the recipient address $mailer->AddAddress($recipientEmailAddress); // Build the email content $emailHTML = ''; $emailPlain = ''; if (strlen($autoreplyEmailContent = $form->getAutoreplyEmailContent())) { if ($form->getAutoreplyFormat() == 'html') { $emailHTML = $form->replacePlaceholderValues($autoreplyEmailContent, 'html', '<br />'); } else { $emailPlain = $form->replacePlaceholderValues($autoreplyEmailContent, 'plain', iphorm_get_email_newline()); } } if (strlen($emailHTML)) { $mailer->MsgHTML($emailHTML); } else { $mailer->Body = $emailPlain; } $mailer = apply_filters('iphorm_pre_send_autoreply_email', $mailer, $form, $attachments); $mailer = apply_filters('iphorm_pre_send_autoreply_email_' . $form->getId(), $mailer, $form, $attachments); try { // Send the autoreply $mailer->Send(); } catch (Exception $e) { if (WP_DEBUG) { throw $e; } } } } // Okay, so now we can save form data to the custom database table if configured if (count($fields = $form->getDbFields())) { foreach ($fields as $key => $value) { $fields[$key] = $form->replacePlaceholderValues($value); } if ($form->getUseWpDb()) { global $wpdb; $wpdb->insert($form->getDbTable(), $fields); } else { $cwpdb = new wpdb($form->getDbUsername(), $form->getDbPassword(), $form->getDbName(), $form->getDbHost()); $cwpdb->insert($form->getDbTable(), $fields); } } // Delete uploaded files and unset file upload info from session if (isset($_SESSION['iphorm-' . $form->getUniqId()])) { if (is_array($_SESSION['iphorm-' . $form->getUniqId()])) { foreach ($_SESSION['iphorm-' . $form->getUniqId()] as $file) { if (isset($file['tmp_name'])) { if (is_array($file['tmp_name'])) { foreach ($file['tmp_name'] as $multiFile) { if (is_string($multiFile) && strlen($multiFile) && file_exists($multiFile)) { unlink($multiFile); } } } else { if (is_string($file['tmp_name']) && strlen($file['tmp_name']) && file_exists($file['tmp_name'])) { unlink($file['tmp_name']); } } } } } unset($_SESSION['iphorm-' . $form->getUniqId()]); } // Unset CAPTCHA info from session if (isset($_SESSION['iphorm-captcha-' . $form->getUniqId()])) { unset($_SESSION['iphorm-captcha-' . $form->getUniqId()]); } // Post-process action hooks do_action('iphorm_post_process', $form); do_action('iphorm_post_process_' . $form->getId(), $form); $result = array('type' => 'success', 'data' => $form->getSuccessMessage()); if ($form->getSuccessType() == 'redirect') { $result['redirect'] = $form->getSuccessRedirectURL(); } if (!$ajax) { // Reset the form for non-JavaScript submit $successMessage = $form->getSuccessMessage(); $form->setSubmitted(true); $form->reset(); } else { // This counteracts the fact that wrapping the JSON response in a textarea decodes HTML entities if (isset($result['redirect'])) { $result['redirect'] = htmlspecialchars($result['redirect'], ENT_NOQUOTES); } $result['data'] = htmlspecialchars($result['data'], ENT_NOQUOTES); } } else { $result = array('type' => 'error', 'data' => $form->getErrors()); } if ($ajax) { $response = '<textarea>' . iphorm_json_encode($result) . '</textarea>'; } else { // Redirect if successful if (isset($result['type'], $result['redirect']) && $result['type'] == 'success') { return '<meta http-equiv="refresh" content="0;URL=\'' . esc_url($result['redirect']) . '\'">'; } // Displays the form again do_action('iphorm_pre_display', $form); do_action('iphorm_pre_display_' . $form->getId(), $form); ob_start(); include IPHORM_INCLUDES_DIR . '/form.php'; $response = ob_get_clean(); } return $response; } }
/** * @param LogEntry $entry */ protected function persist(LogEntry $entry) { $this->wpdb->insert(sprintf("%s%s", $this->wpdb->prefix, $this->logTableName), array('email_address' => $entry->getEmailAddress(), 'reason' => $entry->getFailureReason(), 'submission_date' => (new \DateTime())->format('Y-m-d H:i:s')), array('%s', '%s', '%s')); }
$last_ost_user_email_id = $ost_wpdb->get_var("SELECT id, user_id, address FROM " . $keyost_prefix . "user_email WHERE address = '" . $wp_user_email_id . "'"); } else { $ost_wpdb->query("INSERT INTO " . $keyost_prefix . "user_email (id, user_id, address) VALUES ('','" . $usid . "','" . $wp_user_email_id . "')"); @($last_ost_user_email_id = $ost_wpdb->insert_id); } $result2 = $ost_wpdb->get_results("SELECT default_email_id,name FROM " . $keyost_prefix . "user WHERE default_email_id = '" . @$last_ost_user_email_id . "'"); if (count($result2) > 0) { $last_ost_user_id = $ost_wpdb->get_var("SELECT id FROM " . $keyost_prefix . "user WHERE default_email_id = '" . @$last_ost_user_email_id . "'"); } else { $ost_wpdb->query("INSERT INTO " . $keyost_prefix . "user (id, default_email_id, name, created, updated) VALUES ('','" . $last_ost_user_email_id . "', '" . $fullname . "', '" . $cre . "', '" . $cre . "')"); $last_ost_user_id = $ost_wpdb->insert_id; if ($usid == "") { $ost_wpdb->query("UPDATE " . $keyost_prefix . "user_email SET user_id={$last_ost_user_id} where id={$last_ost_user_email_id}"); } } ////End of new user info user_email_id email_id if ($keyost_version == 194 || $keyost_version == 195 || $keyost_version == 1951) { $ost_wpdb->insert($ticket_table, array('number' => $tic_ID, 'user_id' => $last_ost_user_id, 'user_email_id' => $last_ost_user_email_id, 'dept_id' => $dep_id, 'sla_id' => $sla_id, 'topic_id' => $top_id, 'staff_id' => $staff_id, 'team_id' => $team_id, 'email_id' => $last_ost_user_email_id, 'ip_address' => $ip_add, 'status_id' => $ticketstate, 'source' => $sour, 'isoverdue' => $isoverdue, 'isanswered' => $isans, 'lastmessage' => $las_msg, 'created' => $cre), array('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); } else { $ost_wpdb->insert($ticket_table, array('number' => $tic_ID, 'user_id' => $last_ost_user_id, 'user_email_id' => $last_ost_user_email_id, 'dept_id' => $dep_id, 'sla_id' => $sla_id, 'topic_id' => $top_id, 'staff_id' => $staff_id, 'team_id' => $team_id, 'email_id' => $last_ost_user_email_id, 'ip_address' => $ip_add, 'status' => $ticketstate, 'source' => $sour, 'isoverdue' => $isoverdue, 'isanswered' => $isans, 'lastmessage' => $las_msg, 'created' => $cre), array('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); } $lastid = $ost_wpdb->insert_id; $stat = "created"; $staf = "SYSTEM"; $annulled = 0; $ost_wpdb->insert($ticket_event_table, array('ticket_id' => $lastid, 'staff_id' => $staff_id, 'team_id' => $team_id, 'dept_id' => $dep_id, 'topic_id' => $top_id, 'state' => $stat, 'staff' => $staf, 'annulled' => $annulled, 'timestamp' => $cre), array('%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s')); // File Table Entry Code Start Here By Pratik Maniar on 26/08/2015 if (!empty($_FILES['file']['name'][0])) { if ($keyost_version == 193) { $attachement_status = key4ce_getKeyValue('allow_attachments'); $max_user_file_uploads = key4ce_getKeyValue('max_user_file_uploads');
/** * Insert a row into a table. * * @see wpdb::insert() */ public function insertRow($data, $format = null) { return $this->db->insert($this->schema->table_name, $data, $format); }
<h2>Add a User</h2> <p>Yay. People.</p> <?php require_once SC_USER_DIR . "/library/sc_user_misc.class.php"; $misc = new sc_user_misc(); $scdb = new wpdb(DB_USER, DB_PASSWORD, "uolttorg_sc_data", DB_HOST); if ($misc->get_post("save") == "Add User" && !empty($misc->get_post("ships"))) { $data = array('sc1' => $_POST['sc1'], 'sc2' => $_POST['sc2'], 'forum' => $_POST['forum'], 'rank' => $_POST['rank'], 'role' => $_POST['role'], 'member' => $_POST['member']); $scdb->insert("lttname", $data); $userid = $scdb->insert_id; $ships = $misc->get_ships_by_name(); $data["ships"] = array(); foreach ($_POST['ships'] as $ship) { $scdb->insert("shipsown", array("name" => $userid, "ship" => $ships[$ship])); $data["ships"][] = $ships[$ship]; } $url = "http://insanemaths.com/api/api.php?action=add_user&user_id=" . $userid . "&data=" . str_replace(" ", "+", json_encode($data)); $mail = file_get_contents($url); wp_mail("*****@*****.**", "ruc query data", str_replace("<br>", "\r\n", $mail)); } ?> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <script> $(function() { var availableShips = [ <?php $ship_data = $scdb->get_results("SELECT shipname FROM ships", ARRAY_N);
$returnans = update_user_meta($user_id, 'last_name', $data['middle_name']); } $patient_id = $user_id; } else { $patient_id = explode('=', $origindata[1])[1]; } $table_appoinments = "wp_hmgt_appointment"; $appoinments_data['appointment_date'] = $startDateDate; $appoinments_data['appointment_time'] = $startDateTime; $appoinments_data['appointment_time_string'] = $startDate; $appoinments_data['appointment_end_time_string'] = $endDate; $appoinments_data['doctor_id'] = $doctor_id; $appoinments_data['patient_id'] = $patient_id; $appoinments_data['appoint_create_date'] = date("Y-m-d"); $appoinments_data['appoint_create_by'] = get_current_user_id(); $result = $wordpressdb->insert($table_appoinments, $appoinments_data); echo 1; exit; } } class Hmgtuser { public $usermetadata = array(); public $userdata = array(); public function hmgt_add_user($data) { //-------usersmeta table data-------------- if (isset($data['middle_name'])) { $usermetadata['middle_name'] = $data['middle_name']; } if (isset($data['gender'])) {
$scdb->delete("ships", array("shipUID" => $id)); } unset($_POST['delete_ship']); } if (isset($_POST['add_edit_ship'])) { if ($_POST['add_edit_ship'] == "add") { unset($_POST['add_edit_ship']); $err_c = 0; foreach ($_POST as $k => $v) { if (empty($v)) { echo '<div class="error notice"><p>Please set the "' . $k . '" field!</p></div>'; $err_c++; } } if ($err_c == 0) { $scdb->insert("ships", $_POST); } } elseif ($_POST['add_edit_ship'] != "add" && $_POST['add_edit_ship'] != "") { $data = array(); foreach ($_POST as $k => $v) { if ($v != "" && $k != "add_edit_ship") { $data[$k] = $v; } } $scdb->update("ships", $data, array("shipname" => $_POST['add_edit_ship'])); unset($_POST['add_edit_ship']); } } ?> <form action="" method="POST">
$ost_wpdb->query("INSERT INTO " . $keyost_prefix . "user_email (id, user_id, address) VALUES ('','" . $usid . "','" . $wp_user_email_id . "')"); @($last_ost_user_email_id = $ost_wpdb->insert_id); } $result2 = $ost_wpdb->get_results("SELECT default_email_id,name FROM " . $keyost_prefix . "user WHERE default_email_id = '" . @$last_ost_user_email_id . "'"); if (count($result2) > 0) { $last_ost_user_id = $ost_wpdb->get_var("SELECT id FROM " . $keyost_prefix . "user WHERE default_email_id = '" . @$last_ost_user_email_id . "'"); } else { $ost_wpdb->query("INSERT INTO " . $keyost_prefix . "user (id, default_email_id, name, created, updated) VALUES ('','" . $last_ost_user_email_id . "', '" . $nam . "', '" . $cre . "', '" . $cre . "')\r\n\t"); $last_ost_user_id = $ost_wpdb->insert_id; if ($usid == "") { $ost_wpdb->query("UPDATE " . $keyost_prefix . "user_email SET user_id={$last_ost_user_id} where id={$last_ost_user_email_id}"); } } ////End of new user info user_email_id email_id if ($keyost_version == 194 || $keyost_version == 195 || $keyost_version == 1951) { $ost_wpdb->insert($ticket_table, array('number' => $tic_ID, 'user_id' => $last_ost_user_id, 'user_email_id' => $last_ost_user_email_id, 'dept_id' => $dep_id, 'sla_id' => $sla_id, 'topic_id' => $top_id, 'staff_id' => $staff_id, 'team_id' => $team_id, 'email_id' => $last_ost_user_email_id, 'ip_address' => $ip_add, 'status_id' => $ticketstate, 'source' => $sour, 'isoverdue' => $isoverdue, 'isanswered' => $isans, 'lastmessage' => $las_msg, 'created' => $cre), array('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); } else { $ost_wpdb->insert($ticket_table, array('number' => $tic_ID, 'user_id' => $last_ost_user_id, 'user_email_id' => $last_ost_user_email_id, 'dept_id' => $dep_id, 'sla_id' => $sla_id, 'topic_id' => $top_id, 'staff_id' => $staff_id, 'team_id' => $team_id, 'email_id' => $last_ost_user_email_id, 'ip_address' => $ip_add, 'status' => $ticketstate, 'source' => $sour, 'isoverdue' => $isoverdue, 'isanswered' => $isans, 'lastmessage' => $las_msg, 'created' => $cre), array('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); } $lastid = $ost_wpdb->insert_id; $stat = "created"; $staf = "SYSTEM"; $annulled = 0; $ost_wpdb->insert($ticket_event_table, array('ticket_id' => $lastid, 'staff_id' => $staff_id, 'team_id' => $team_id, 'dept_id' => $dep_id, 'topic_id' => $top_id, 'state' => $stat, 'staff' => $staf, 'annulled' => $annulled, 'timestamp' => $cre), array('%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s')); $pid = 0; $thread_type = "M"; $ost_wpdb->insert($thread_table, array('pid' => $pid, 'ticket_id' => $lastid, 'staff_id' => $staff_id, 'thread_type' => $thread_type, 'poster' => $nam, 'source' => $sour, 'title' => "", 'body' => key4ce_wpetss_forum_text($user_message), 'ip_address' => $ip_add, 'created' => $cre), array('%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')); if ($keyost_version == 194 || $keyost_version == 195 || $keyost_version == 1951) { $ost_wpdb->insert($ticket_cdata, array('ticket_id' => $lastid, 'subject' => $sub, 'priority' => $pri_id), array('%d', '%s', '%d')); } else { $ost_wpdb->insert($ticket_cdata, array('ticket_id' => $lastid, 'subject' => $sub, 'priority' => $priordesc, 'priority_id' => $pri_id), array('%d', '%s', '%s', '%d'));
# Changed (id) -> (like) so we search for text in v1.8+ # ============================================================================================== $id_isonline = $ost_wpdb->get_var("SELECT id FROM {$config_table} WHERE {$config_table}.key like ('%isonline%');"); $isactive = $ost_wpdb->get_row("SELECT id,namespace,{$config_table}.key,{$config_table}.value,updated FROM {$config_table} where id = {$id_isonline}"); $isactive = $isactive->value; $id_helptitle = $ost_wpdb->get_var("SELECT id FROM {$config_table} WHERE {$config_table}.key like ('%helpdesk_title%');"); $title_name = $ost_wpdb->get_row("SELECT id,namespace,{$config_table}.key,{$config_table}.value,updated FROM {$config_table} where id ={$id_helptitle}"); $title_name = $title_name->value; $table_name_config = $keyost_prefix . "config"; // STMP Status Start Here By Pratik Maniar $count_smtp_status = $ost_wpdb->get_var("SELECT count(*) FROM {$config_table} WHERE {$config_table}.key like ('%smtp_status%');"); if ($count_smtp_status == 0) { $id = ''; $namespace = "core"; $key = "smtp_status"; $rows_affected = $ost_wpdb->insert($config_table, array('id' => $id, 'namespace' => $namespace, 'key' => $key, 'value' => 'disable', 'updated' => current_time('mysql'))); } $id_smtp_status = $ost_wpdb->get_var("SELECT id FROM {$config_table} WHERE {$config_table}.key like ('%smtp_status%');"); $smtp_status = $ost_wpdb->get_row("SELECT id,namespace,{$config_table}.key,{$config_table}.value,updated FROM {$config_table} where id = {$id_smtp_status}"); $smtp_status = $smtp_status->value; // STMP Status End Here By Pratik Maniar // STMP Username Start Here By Pratik Maniar $count_smtp_username = $ost_wpdb->get_var("SELECT count(*) FROM {$config_table} WHERE {$config_table}.key like ('%smtp_username%');"); if ($count_smtp_username == 0) { $id = ''; $namespace = "core"; $key = "smtp_username"; $rows_affected = $ost_wpdb->insert($config_table, array('id' => $id, 'namespace' => $namespace, 'key' => $key, 'value' => '', 'updated' => current_time('mysql'))); } $id_smtp_username = $ost_wpdb->get_var("SELECT id FROM {$config_table} WHERE {$config_table}.key like ('%smtp_username%');"); $smtp_username = $ost_wpdb->get_row("SELECT id,namespace,{$config_table}.key,{$config_table}.value,updated FROM {$config_table} where id = {$id_smtp_username}");
/** * Insert a row into the link table. * * @param int $source_site_id Source blog ID. * @param int $target_site_id Target blog ID. * @param int $source_content_id Source post ID or term taxonomy ID. * @param int $target_content_id Target post ID or term taxonomy ID. * @param string $type Content type. * * @return int */ private function insert_row($source_site_id, $target_site_id, $source_content_id, $target_content_id, $type) { $result = (int) $this->wpdb->insert($this->link_table, array('ml_source_blogid' => $source_site_id, 'ml_source_elementid' => $source_content_id, 'ml_blogid' => $target_site_id, 'ml_elementid' => $target_content_id, 'ml_type' => $type)); do_action('mlp_debug', current_filter() . '/' . __METHOD__ . '/' . __LINE__ . " - {$this->wpdb->last_query}"); return $result; }