get_row() public method

Executes a SQL query and returns the row from the SQL result.
Since: 0.71
public get_row ( string | null $query = null, string $output = OBJECT, integer $y ) : mixed
$query string | null SQL query.
$output string Optional. one of ARRAY_A | ARRAY_N | OBJECT constants. Return an associative array (column => value, ...), a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively.
$y integer Optional. Row to return. Indexed from 0.
return mixed Database query result in format specified by $output or null on failure
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function fetchArray($sql)
 {
     $sql = $this->_prepareSql($sql);
     $result = $this->_db->get_row($sql, ARRAY_N);
     $this->_checkError();
     return $result;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 protected function createChangeInfo($oldEntity, $newEntity, $action = null)
 {
     if ($action === 'edit') {
         $diff = EntityUtils::getDiff($oldEntity, $newEntity);
     }
     if (isset($diff['comment_approved'])) {
         // determine more specific edit action
         if ($oldEntity['comment_approved'] === 'trash' && $newEntity['comment_approved'] === 'post-trashed' || $oldEntity['comment_approved'] === 'post-trashed' && $newEntity['comment_approved'] === 'trash') {
             $action = 'edit';
             // trash -> post-trashed and post-trashed -> trash are not interesting action for us
         } elseif ($diff['comment_approved'] === 'trash') {
             $action = 'trash';
         } elseif ($oldEntity['comment_approved'] === 'trash') {
             $action = 'untrash';
         } elseif ($diff['comment_approved'] === 'spam') {
             $action = 'spam';
         } elseif ($oldEntity['comment_approved'] === 'spam') {
             $action = 'unspam';
         } elseif ($oldEntity['comment_approved'] == 0 && $newEntity['comment_approved'] == 1) {
             $action = 'approve';
         } elseif ($oldEntity['comment_approved'] == 1 && $newEntity['comment_approved'] == 0) {
             $action = 'unapprove';
         }
     }
     if ($action === 'create' && $newEntity['comment_approved'] == 0) {
         $action = 'create-pending';
     }
     $author = $newEntity["comment_author"];
     $postTable = $this->database->prefix . 'posts';
     $vpIdTable = $this->database->prefix . 'vp_id';
     $result = $this->database->get_row("SELECT post_title FROM {$postTable} JOIN {$vpIdTable} ON {$postTable}.ID = {$vpIdTable}.id WHERE vp_id = UNHEX('{$newEntity['vp_comment_post_ID']}')");
     $postTitle = $result->post_title;
     return new CommentChangeInfo($action, $newEntity["vp_id"], $author, $postTitle);
 }
Ejemplo n.º 4
0
 /**
  * Fetches ruleset data from database.
  *
  * @param int $rulesetId Primary key of ruleset.
  * @return bool|mixed Array containing ruleset data or false on error.
  */
 public function getRulesetData($rulesetId)
 {
     if (empty($rulesetId)) {
         return false;
     }
     $row = $this->wpdb->get_row("SELECT *\n\t\t\tFROM " . $this->wpdb->rulesets . " rs\n\t\t\tWHERE rs.id = " . (int) $rulesetId, ARRAY_A);
     return $row;
 }
Ejemplo n.º 5
0
 public function findByAttributes(array $attributes = array())
 {
     $query = 'SELECT * FROM ' . $this->_table();
     $where = '';
     foreach ($attributes as $key => $value) {
         $where .= ($where ? ' AND ' : ' WHERE ') . $key . " = '" . $this->_wpdb->escape($value) . "'";
     }
     $this->_fields = $this->_wpdb->get_row($query . $where . ' LIMIT 1', 'ARRAY_A');
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * @param $criteria
  * @param $cast
  * @return array|null|object
  */
 public function findOneBy($criteria, $cast = false)
 {
     $returnType = $cast ? OBJECT : ARRAY_A;
     $criteria = $this->parseCriteria($criteria);
     if (class_exists($this->modelClass)) {
         $model = new $this->modelClass();
         $tableName = $this->wpdb->prefix . $model::TABLE_NAME;
         $res = $this->wpdb->get_row($this->wpdb->prepare("\n                SELECT *\n                FROM {$tableName}\n                WHERE {$criteria["where"]}\n            ", $criteria["values"]), $returnType);
         return $cast ? $this->cast($this->modelClass, $res) : $res;
     }
     return null;
 }
 /**
  * @param string   $cms_id
  * @param bool|TranslationProxy_Service $translation_service
  *
  * @return int|null translation id for the given cms_id's target
  */
 public function get_translation_id($cms_id, $translation_service = false)
 {
     list($post_type, $element_id, , $target_lang) = $this->parse_cms_id($cms_id);
     $translation = $this->wpdb->get_row($this->wpdb->prepare("\n\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT t.translation_id, j.job_id, t.element_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_translations t\n\t\t\t\t\t\t\t\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_translations o\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON o.trid = t.trid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND o.element_type = t.element_type\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$this->wpdb->prefix}icl_translation_status st\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON st.translation_id = t.translation_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN {$this->wpdb->prefix}icl_translate_job j\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tON j.rid = st.rid\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE o.element_id=%d\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND t.language_code=%s\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND o.element_type LIKE %s\n\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1", $element_id, $target_lang, '%_' . $post_type));
     $translation_id = $this->maybe_cleanup_broken_row($translation, $translation_service);
     if ($translation_service && !isset($translation_id) && $translation_service) {
         $job_id = $this->job_factory->create_local_post_job($element_id, $target_lang);
         $job = $this->job_factory->get_translation_job($job_id, false, false, true);
         $translation_id = $job ? $job->get_translation_id() : 0;
         if ($translation_id) {
             $this->tm_records->icl_translation_status_by_translation_id($translation_id)->update(array('status' => ICL_TM_IN_PROGRESS, 'translation_service' => $translation_service->id));
         }
     }
     return $translation_id;
 }
Ejemplo n.º 8
0
 public function record_active_payment($sub_id, $level_order, $stamp)
 {
     $rel = $this->_wpdb->get_row(sprintf("SELECT * FROM %s WHERE user_id = %d AND sub_id = %d", MEMBERSHIP_TABLE_RELATIONS, $this->ID, $sub_id));
     if (!$rel) {
         return;
     }
     $subscription = Membership_Plugin::factory()->get_subscription($sub_id);
     $level = $subscription->get_level_at_position($level_order);
     if (!$level) {
         return;
     }
     $payment = array('member_id' => $this->ID, 'sub_id' => $sub_id, 'level_id' => $level->id, 'level_order' => $level_order, 'paymentmade' => gmdate('Y-m-d H:i:s', $stamp));
     $expires = mysql2date("U", $rel->expirydate);
     switch ($level->level_period_unit) {
         case 'd':
             $paymentexpires = strtotime('+' . $level->level_period . ' days', $expires);
             break;
         case 'w':
             $paymentexpires = strtotime('+' . $level->level_period . ' weeks', $expires);
             break;
         case 'm':
             $paymentexpires = strtotime('+' . $level->level_period . ' months', $expires);
             break;
         case 'y':
             $paymentexpires = strtotime('+' . $level->level_period . ' years', $expires);
             break;
     }
     $payment['paymentexpires'] = gmdate('Y-m-d H:i:s', $paymentexpires);
     $this->_wpdb->insert(MEMBERSHIP_TABLE_MEMBER_PAYMENTS, $payment);
 }
 /**
  * Build login cookie.
  */
 function build_blog_cookie($action = 'login', $userblog_id = '')
 {
     global $blog_id;
     if ($action == '') {
         $action = 'login';
     }
     $url = false;
     if (class_exists('domain_map') && defined('DOMAIN_MAPPING')) {
         $domain = $this->db->get_var("SELECT domain FROM {$this->db->dmtable} WHERE blog_id = '{$userblog_id}' ORDER BY id LIMIT 1");
         if ($domain) {
             $dom = str_replace('.', '', $domain);
             $url = 'http://' . $domain . '/';
         }
     } else {
         $domains = $this->db->get_row("SELECT domain, path FROM {$this->db->blogs} WHERE blog_id = '{$userblog_id}' LIMIT 1");
         $dom = str_replace('.', '', $domains->domain);
         $url = 'http://' . $domains->domain . $domains->path;
     }
     if ($url) {
         $key = get_site_option("multi_domains_cross_domain_{$dom}", array());
         $user_id = get_current_user_id();
         if (!isset($key[$user_id]['action']) || isset($key[$user_id]['action']) && $key[$user_id]['action'] !== $action) {
             $key[$user_id] = array('domain' => $url, 'action' => $action);
             update_site_option("multi_domains_cross_domain_{$dom}", $key);
         }
         $hash = md5(AUTH_KEY . 'multi_domains');
         if ($blog_id !== $userblog_id && 'login' == $action) {
             // Removing transient check
             echo '<link rel="stylesheet" href="' . $url . $hash . '.css?build=' . date("Ymd", strtotime('-24 days')) . '&id=' . $user_id . '" type="text/css" media="screen" />';
             set_transient("multi_domains_{$dom}_{$user_id}", 'add', 60 * 15);
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Get a term by its term_taxonomy_id.
  *
  * @param  int $tt_id term_taxonomy_id
  * @return array
  */
 private function get_term_by_tt_id($tt_id)
 {
     $sql = "\nSELECT terms.`term_id`, terms.`name`, terms.`slug`, tax.`taxonomy`\nFROM {$this->wpdb->terms} terms\n  INNER JOIN {$this->wpdb->term_taxonomy} tax\n    ON tax.`term_taxonomy_id` = %d\nWHERE tax.`term_id` = terms.`term_id`\nLIMIT 1";
     $query = $this->wpdb->prepare($sql, $tt_id);
     $result = $this->wpdb->get_row($query, ARRAY_A);
     // $result might be NULL, but we need a predictable return type.
     return empty($result) ? array() : $result;
 }
 /**
  * Get a term by its term taxonomy ID.
  *
  * @param int $term_taxonomy_id Term taxonomy ID.
  *
  * @return array
  */
 private function get_term_by_term_taxonomy_id($term_taxonomy_id)
 {
     $sql = "\nSELECT t.term_id, t.name, tt.taxonomy\nFROM {$this->wpdb->terms} t, {$this->wpdb->term_taxonomy} tt\nWHERE tt.term_id = t.term_id AND tt.term_taxonomy_id = %d\nLIMIT 1";
     $query = $this->wpdb->prepare($sql, $term_taxonomy_id);
     $result = $this->wpdb->get_row($query, ARRAY_A);
     // $result might be NULL, but we need a predictable return type.
     return empty($result) ? array() : $result;
 }
Ejemplo n.º 12
0
 /**
  * Fetches and returns a row from the database.
  *
  * @param int $id Database id of the row.
  * @return array An associative array with column names as keys.
  **/
 public function get($id)
 {
     $form = $this->db->get_row("SELECT * FROM {$this->table_name} WHERE id={$id}", ARRAY_A);
     if ($form) {
         $form["fields"] = $this->unserialize($form["fields"]);
         $form["settings"] = $this->unserialize($form["settings"]);
         $form["emails"] = $this->unserialize($form["emails"]);
     }
     return $form;
 }
Ejemplo n.º 13
0
 /**
  * Load entity from database.
  *
  * @param integer $id
  * @return boolean
  */
 public function load($id)
 {
     $row = $this->wpdb->get_row(sprintf('SELECT * FROM %s WHERE id = %d', $this->table_name, $id));
     if ($row) {
         $this->setData($row);
         $this->loaded = true;
     } else {
         $this->loaded = false;
     }
     return $this->loaded;
 }
 /**
  * Get the data for a particular form.
  *
  * @author Jeremy Pry
  *
  * @param int $form_id The ID of the form to retrieve.
  *
  * @return array The array of form data.
  */
 public function get_form($form_id)
 {
     // Retrieve the raw data from the DB.
     $form_results = $this->wpdb->get_row($this->wpdb->prepare("SELECT * FROM {$this->prefixed_table_name} WHERE id = %d", $form_id), ARRAY_A);
     // If there were no results, then return an empty array.
     if (null === $form_results) {
         /**
          * Filter the form data that is retrieved from the Database.
          *
          * @param array $form_settings The array of processed form data.
          * @param int   $form_id       The form ID.
          * @param array $form_results  The raw data from the database.
          */
         return apply_filters('yikes-easy-mailchimp-extender-form-data', array(), $form_id, $form_results);
     }
     // Populate array with new settings.
     $form_settings = $this->prepare_data_for_display($form_results);
     /** This filter is documented in this function above. */
     return apply_filters('yikes-easy-mailchimp-extender-form-data', $form_settings, $form_id, $form_results);
 }
Ejemplo n.º 15
0
 /**
  * @param string $slug
  * @param string $post_type
  * @param string|bool $language
  *
  * @return string
  */
 function get_translated_slug($slug, $post_type, $language = false)
 {
     if ($post_type) {
         $language = $language ? $language : $this->sitepress->get_current_language();
         if (!isset($this->translated_slugs[$post_type][$language])) {
             $slug_original = $this->wpdb->get_row($this->wpdb->prepare("SELECT s.value, s.language\r\r\n\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\r\n\t\t\t\t\t\t\t\t\t\tWHERE s.name = %s\r\r\n\t\t\t\t\t\t\t\t\t\t    AND (s.context = %s OR s.context = %s)", 'URL slug: ' . $post_type, 'default', 'WordPress'));
             if ((bool) $slug_original === true) {
                 $this->translated_slugs[$post_type][$slug_original->language] = $slug_original->value;
                 $slugs_translations = $this->wpdb->get_results($this->wpdb->prepare("SELECT t.value, t.language\r\r\n\t\t\t\t\t\t\t\t\t\tFROM {$this->wpdb->prefix}icl_strings s\r\r\n\t\t\t\t\t\t\t\t\t\tJOIN {$this->wpdb->prefix}icl_string_translations t ON t.string_id = s.id\r\r\n\t\t\t\t\t\t\t\t\t\tWHERE s.name = %s\r\r\n\t\t\t\t\t\t\t\t\t\t    AND (s.context = %s OR s.context = %s)\r\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.status = %d\r\r\n\t\t\t\t\t\t\t\t\t\t\tAND t.value <> ''", 'URL slug: ' . $post_type, 'default', 'WordPress', ICL_TM_COMPLETE));
                 foreach ($slugs_translations as $translation) {
                     $this->translated_slugs[$post_type][$translation->language] = $translation->value;
                 }
                 foreach ($this->sitepress->get_active_languages() as $lang) {
                     if (!isset($this->translated_slugs[$post_type][$lang['code']])) {
                         $this->translated_slugs[$post_type][$lang['code']] = $slug;
                     }
                 }
             }
         }
         $slug = !empty($this->translated_slugs[$post_type][$language]) ? $this->translated_slugs[$post_type][$language] : $slug;
     }
     return $slug;
 }
Ejemplo n.º 16
0
 /**
  * Get taxonomy meta
  *
  * @param int $term_id
  * @param string $key
  * @return mixed
  */
 public function get($term_id, $key)
 {
     if ($value = wp_cache_get($this->_get_cache_key($term_id, $key), 'taxonomy-meta')) {
         return $value;
     }
     $row = $this->_db->get_row($this->_db->prepare("SELECT meta_value FROM {$this->_table} WHERE term_id = %d AND meta_key = %s LIMIT 1", $term_id, $key));
     if (is_object($row)) {
         $value = maybe_unserialize($row->meta_value);
     } else {
         $value = false;
     }
     wp_cache_set($this->_get_cache_key($term_id, $key), $value, 'taxonomy-meta');
     return $value;
 }
Ejemplo n.º 17
0
 /**
  * @param $ids string|array
  *
  * @return mixed
  */
 public function find_by_id($ids)
 {
     if (is_array($ids)) {
         // create comma-separated string
         $ids = implode(',', $ids);
     }
     // escape string for usage in IN clause
     $ids = esc_sql($ids);
     $sql = sprintf("SELECT * FROM `%s` WHERE ID IN (%s)", $this->table_name, $ids);
     // return single row if only one id is given
     if (substr_count($ids, ',') === 0) {
         return $this->db->get_row($sql);
     }
     return $this->db->get_results($sql);
 }
 /**
  * Get a term by its term taxonomy ID.
  *
  * @param int $term_taxonomy_id Term taxonomy ID.
  *
  * @return array
  */
 private function get_term_by_term_taxonomy_id($term_taxonomy_id)
 {
     $cache_key = $this->get_term_by_term_taxonomy_id_cache_key($term_taxonomy_id);
     $term = wp_cache_get($cache_key, 'mlp');
     if (is_array($term)) {
         return $term;
     }
     $query = "\nSELECT t.term_id, t.name, tt.taxonomy\nFROM {$this->wpdb->terms} t, {$this->wpdb->term_taxonomy} tt\nWHERE tt.term_id = t.term_id AND tt.term_taxonomy_id = %d\nLIMIT 1";
     $query = $this->wpdb->prepare($query, $term_taxonomy_id);
     $term = $this->wpdb->get_row($query, ARRAY_A);
     if (!$term) {
         $term = [];
     }
     wp_cache_set($cache_key, $term, 'mlp');
     return $term;
 }
Ejemplo n.º 19
0
 /**
  * Return a record as an array based on a given SQL select statement keys and params list.
  *
  * Executes wpdb get_row using the specified SQL statement.
  * If more than one row is returned by the query, only the specified row is returned by the function, but all rows are cached for later use.
  * Returns NULL if no result is found
  *
  * @link https://codex.wordpress.org/Class_Reference/wpdb WordPress WPDB Class
  *
  * @param string[] $commandList
  * @param mixed[] $params
  * @param int $offset
  * @param mixed $type the type of object/array/etc. to return see wpdb get_row.
  * @param string $mode = get_row or get_col to fetch a single row or multiple rows of a single column
  * @return mixed the database array_a or object.
  */
 function get_Record($commandList, $params = array(), $offset = 0, $type = ARRAY_A, $mode = 'get_row')
 {
     $this->is_Extended();
     $query = $this->get_SQL($commandList);
     // No placeholders, just call direct with no prepare
     //
     if (strpos($query, '%') !== false) {
         $query = $this->db->prepare($query, $params);
     }
     // get_row (default) or get_col based on the mode
     if ($mode === 'get_col') {
         $results = $this->db->get_col($query, $offset);
     } else {
         $results = $this->db->get_row($query, $type, $offset);
     }
     return $results;
 }
Ejemplo n.º 20
0
 /**
  * Retrieve a license by license key or token.
  *
  * If you specify a token, this method will ignore $licenseKey and just
  * look for the token. The returned license object will also include
  * the URL of the site associated with that token in a 'site_url' field.
  *
  * @param string|null $licenseKey
  * @param string|null $token
  * @throws InvalidArgumentException
  * @return Wslm_ProductLicense|null A license object, or null if the license doesn't exist.
  */
 public function loadLicense($licenseKey, $token = null)
 {
     if (!empty($token)) {
         $query = $this->wpdb->prepare("SELECT licenses.*, tokens.site_url\n\t\t\t\t FROM\n\t\t\t\t \t`{$this->tablePrefix}licenses` AS licenses\n\t\t\t\t \tJOIN `{$this->tablePrefix}tokens` AS tokens\n\t\t\t\t \tON licenses.license_id = tokens.license_id\n\t\t\t\t WHERE tokens.token = %s", $token);
     } else {
         if (!empty($licenseKey)) {
             $query = $this->wpdb->prepare("SELECT licenses.* FROM `{$this->tablePrefix}licenses` AS licenses\n\t\t\t\t WHERE license_key = %s", $licenseKey);
         } else {
             throw new InvalidArgumentException('You must specify a license key or a site token.');
         }
     }
     $license = $this->wpdb->get_row($query, ARRAY_A);
     if (!empty($license)) {
         //Also include the list of sites associated with this license.
         $license['sites'] = $this->loadLicenseSites($license['license_id']);
         $license = new Wslm_ProductLicense($license);
     } else {
         $license = null;
     }
     return $license;
 }
Ejemplo n.º 21
0
 /**
  * Load entity from database by field values.
  *
  * @param array $fields
  * @return bool
  */
 public function loadBy(array $fields)
 {
     // Prepare WHERE clause.
     $where = array();
     $values = array();
     foreach ($fields as $field => $value) {
         if ($value === null) {
             $where[] = sprintf('`%s` IS NULL', $field);
         } else {
             $where[] = sprintf('`%s` = %s', $field, static::$schema[$field]['format']);
             $values[] = $value;
         }
     }
     $query = sprintf('SELECT * FROM `%s` WHERE %s LIMIT 1', $this->table_name, implode(' AND ', $where));
     $row = $this->wpdb->get_row(empty($values) ? $query : $this->wpdb->prepare($query, $values));
     if ($row) {
         $this->setFields($row);
         $this->loaded_values = $this->fields;
     } else {
         $this->loaded_values = null;
     }
     return $this->isLoaded();
 }
Ejemplo n.º 22
0
$staff_table = $keyost_prefix . "staff";
$ost_user = $keyost_prefix . "user";
$ost_useremail = $keyost_prefix . "user_email";
$ost_ticket_attachment = $keyost_prefix . "ticket_attachment";
$ost_ticket_status = $keyost_prefix . "ticket_status";
$ost_file = $keyost_prefix . "file";
$directory = $config['supportpage'];
$dirname = strtolower($directory);
$category = @$_GET['cat'];
$status_opt = @$_GET['status'];
$ticket = @$_GET['ticket'];
# ==============================================================================================
# 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}");
Ejemplo n.º 23
0
 /**
  * @see wpdb::get_row()
  */
 function get_row($query = null, $output = OBJECT, $y = 0)
 {
     if ($this->ignore_query($query)) {
         return parent::get_row($query, $output, $y);
     }
     $this->init_cache();
     $key = md5('get_row(' . $query . ',' . $output . ',' . $y . ')');
     $result = null;
     $cache = $this->get_cache_item($key);
     if ($cache) {
         $result = $cache['result'];
         $this->last_result = $cache['last_result'];
         $this->num_rows = $cache['num_rows'];
     } else {
         $result = parent::get_row($query, $output, $y);
         $cache = array('result' => $result, 'last_result' => $this->last_result, 'num_rows' => $this->num_rows);
         $this->set_cache_item($key, $cache);
     }
     return $result;
 }
Ejemplo n.º 24
0
 /**
  * Return a record as an array based on a given SQL select statement keys and params list.
  *
  * Executes wpdb get_row using the specified SQL statement.
  * If more than one row is returned by the query, only the specified row is returned by the function, but all rows are cached for later use.
  * Returns NULL if no result is found
  *
  * @link https://codex.wordpress.org/Class_Reference/wpdb WordPress WPDB Class
  *
  * @param string[] $commandList
  * @param mixed[] $params
  * @param int $offset
  */
 function get_Record($commandList, $params = array(), $offset = 0)
 {
     return $this->db->get_row($this->db->prepare($this->get_SQL($commandList), $params), ARRAY_A, $offset);
 }
Ejemplo n.º 25
0
 $ost_staff = $keyost_prefix . "staff";
 $ost_useremail = $keyost_prefix . "user_email";
 $ost_ticket_attachment = $keyost_prefix . "ticket_attachment";
 $ost_ticket_status = $keyost_prefix . "ticket_status";
 $ost_file = $keyost_prefix . "file";
 $directory = $config['supportpage'];
 $dirname = strtolower($directory);
 $category = @$_GET['cat'];
 $status_opt = @$_GET['status'];
 $ticket = @$_GET['ticket'];
 $parurl = $_SERVER['QUERY_STRING'];
 $page_id_chk = @$_REQUEST['page_id'];
 get_currentuserinfo();
 $user_email = $current_user->user_email;
 $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;
 //Added By Pratik Maniar on 01-05-2014 Start Here
 $default_email_id = $ost_wpdb->get_var("SELECT value FROM " . $keyost_prefix . "config WHERE `key` LIKE 'default_email_id'");
 $default_email_id_data = $ost_wpdb->get_row("SELECT * FROM " . $keyost_prefix . "email WHERE `email_id` ={$default_email_id}");
 //Added By Pratik Maniar on 01-05-2014 End Here
 $title_name = $default_email_id_data->name;
 $id_maxopen = $ost_wpdb->get_var("SELECT id FROM {$config_table} WHERE {$config_table}.key like ('%max_open_tickets%');");
 $max_open_tickets = $ost_wpdb->get_row("SELECT id,namespace,{$config_table}.key,{$config_table}.value,updated FROM {$config_table} where id = {$id_maxopen}");
 $max_open_tickets = $max_open_tickets->value;
 $os_admin_email = $default_email_id_data->email;
 $id_hidename = $ost_wpdb->get_var("SELECT id FROM {$config_table} WHERE {$config_table}.key like ('%hide_staff_name%');");
 $hidename = $ost_wpdb->get_row("SELECT id,namespace,{$config_table}.key,{$config_table}.value,updated FROM {$config_table} where id = {$id_hidename}");
 $hidename = $hidename->value;
 if ($isactive != 1) {
     include WP_PLUGIN_DIR . '/key4ce-osticket-bridge/templates/message.php';
Ejemplo n.º 26
0
function bbld_widget($args)
{
    global $table_prefix, $wpdb;
    $forum_slimit = get_option('wpbb_limit');
    if (get_option('wpbb_exdb')) {
        $exbbdb = new wpdb(get_option('wpbb_dbuser'), get_option('wpbb_dbpass'), get_option('wpbb_dbname'), get_option('wpbb_dbhost'));
        $bbtopic = $exbbdb->get_results("SELECT * FROM " . get_option('wpbb_bbprefix') . "topics WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT {$forum_slimit}");
    } else {
        $bbtopic = $wpdb->get_results("SELECT * FROM " . get_option('wpbb_bbprefix') . "topics WHERE topic_status = 0 ORDER BY topic_time DESC LIMIT {$forum_slimit}");
    }
    if ($bbtopic) {
        extract($args);
        echo $before_widget;
        echo $before_title . sprintf(__("Forum Last %d Discussions", 'bbpress'), $forum_slimit) . $after_title;
        echo '<ul>';
        foreach ($bbtopic as $bbtopic) {
            $title_text = wpbb_trim($bbtopic->topic_title, get_option('wpbb_slimit'));
            if (get_option('wpbb_exdb')) {
                $bbforum = $exbbdb->get_row("SELECT * FROM " . get_option('wpbb_bbprefix') . "forums WHERE forum_id = '{$bbtopic->forum_id}'");
            } else {
                $bbforum = $wpdb->get_row("SELECT * FROM " . get_option('wpbb_bbprefix') . "forums WHERE forum_id = '{$bbtopic->forum_id}'");
            }
            if (get_option('wpbb_permalink')) {
                echo '<li><a href="' . get_option('wpbb_path') . '/topic/' . $bbtopic->topic_id . '">' . __("{$title_text}", 'bbpress') . '</a><br />';
                $forum_url = get_option('wpbb_path') . '/forum/' . $bbtopic->forum_id;
            } else {
                echo '<li><a href="' . get_option('wpbb_path') . '/topic.php?id=' . $bbtopic->topic_id . '">' . __("{$title_text}", 'bbpress') . '</a><br />';
                $forum_url = get_option('wpbb_path') . '/forum.php?id=' . $bbtopic->forum_id;
            }
            if (get_option('wpbb_intergrated')) {
                $wpuid = $wpdb->get_row("SELECT * FROM " . $table_prefix . "users WHERE user_login = '******'");
                if ($wpuid) {
                    $user_forum_data = "{$bbtopic->topic_last_poster_name}";
                    $user_forum_data = get_userdata($wpuid->ID);
                    bbld_extra_info($user_forum_data->display_name, $bbforum->forum_name, $forum_url);
                    echo "</li>";
                } else {
                    bbld_extra_info($bbtopic->topic_last_poster_name, $bbforum->forum_name, $forum_url);
                    echo "</li>";
                }
            } else {
                bbld_extra_info($bbtopic->topic_last_poster_name, $bbforum->forum_name, $forum_url);
                echo "</li>";
            }
        }
        echo "</ul>";
        echo $after_widget;
    }
}
    function woocommerce_etsyi_submenu_page_callback()
    {
        global $wpdb, $oscdb, $import_cat_counter, $import_prod_counter;
        if (!empty($_POST)) {
            $oscdb = new wpdb(trim($_POST['store_user']), trim($_POST['store_pass']), trim($_POST['store_dbname']), trim($_POST['store_host']));
            if ($oscdb->ready) {
                echo '<p>Starting...<em>(If the page stops loading or shows a timeout error, then just refresh the page and the importer will continue where it left off.  If you are using a shared server and are importing a lot of products you may need to refresh several times)</p>';
                // Do customer import
                if ($_POST['dtype']['customers'] == 1) {
                    $country_data = $oscdb->get_results("SELECT * FROM countries", ARRAY_A);
                    $countries_id = array();
                    foreach ($country_data as $cdata) {
                        $countries_id[$cdata['countries_id']] = $cdata;
                    }
                    $zones = array();
                    $zone_data = $oscdb->get_results("SELECT zone_id, zone_code FROM zones", ARRAY_A);
                    foreach ($zone_data as $z) {
                        $zones[$z['zone_id']] = $z['zone_code'];
                    }
                    if ($customers = $oscdb->get_results("SELECT c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_country_id, ab.entry_lastname, ab.entry_firstname, ab.entry_street_address, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_state, ab.entry_zone_id FROM customers c, address_book ab WHERE c.customers_id=ab.customers_id AND c.customers_default_address_id=ab.address_book_id", ARRAY_A)) {
                        foreach ($customers as $customer) {
                            if (!email_exists($customer['customers_email_address'])) {
                                $original = strtolower(preg_replace("/[^A-Za-z0-9]/", '', $customer['customers_firstname'] . $customer['customers_lastname']));
                                $user_name = $original;
                                $i = 1;
                                while ($user_id = username_exists($user_name)) {
                                    $user_name = $original . $i;
                                    $i++;
                                }
                                $random_password = wp_generate_password();
                                $user_id = wp_create_user($user_name, $random_password, $customer['customers_email_address']);
                                $data = array('first_name' => $customer['customers_firstname'], 'last_name' => $customer['customers_lastname'], 'billing_country' => $countries_id[$customer['entry_country_id']]['countries_iso_code_2'], 'billing_first_name' => $customer['entry_firstname'], 'billing_last_name' => $customer['entry_lastname'], 'billing_address_1' => $customer['entry_street_address'], 'billing_address_2' => $customer['entry_suburb'], 'billing_city' => $customer['entry_city'], 'billing_state' => $customer['entry_state'] != '' ? $customer['entry_state'] : $zones[$customer['entry_zone_id']], 'billing_postcode' => $customer['entry_postcode'], 'billing_email' => $customer['customers_email_address'], 'billing_phone' => $customer['customers_telephone'], 'shipping_country' => $countries_id[$customer['entry_country_id']]['countries_iso_code_2'], 'shipping_first_name' => $customer['entry_firstname'], 'shipping_last_name' => $customer['entry_lastname'], 'shipping_address_1' => $customer['entry_street_address'], 'shipping_address_2' => $customer['entry_suburb'], 'shipping_city' => $customer['entry_city'], 'shipping_state' => $customer['entry_state'] != '' ? $customer['entry_state'] : $zones[$customer['entry_zone_id']], 'shipping_postcode' => $customer['entry_postcode'], 'osc_id' => $customer['customers_id']);
                                foreach ($data as $k => $v) {
                                    update_user_meta($user_id, $k, $v);
                                }
                                if ($user_id > 1) {
                                    wp_update_user(array('ID' => $user_id, 'role' => 'customer'));
                                }
                                $import_customer_counter++;
                            }
                        }
                    }
                }
                if ($_POST['dtype']['products'] == 1) {
                    woocommerce_osc_run_cats();
                    // Get all categories by OSC cat ID
                    $categories = array();
                    $terms = get_terms('product_cat', array('hide_empty' => 0));
                    foreach ($terms as $term) {
                        $o = get_woocommerce_term_meta($term->term_id, 'osc_id', true);
                        $categories[$o] = (int) $term->term_id;
                    }
                    // Import the products
                    if ($products = $oscdb->get_results("SELECT p.*, pd.*, p2c.categories_id FROM products p, products_description pd, products_to_categories p2c WHERE p.products_id=pd.products_id AND pd.language_id=1 AND p.products_id=p2c.products_id GROUP BY p.products_id", ARRAY_A)) {
                        foreach ($products as $product) {
                            $existing_product = get_posts(array('post_type' => 'product', 'posts_per_page' => 1, 'post_status' => 'any', 'meta_query' => array(array('key' => 'osc_id', 'value' => $product['products_id']))));
                            if (empty($existing_product)) {
                                $product_id = wp_insert_post(array('post_title' => $product['products_name'], 'post_content' => $product['products_description'], 'post_status' => 'publish', 'post_type' => 'product', 'post_author' => 1));
                                update_post_meta($product_id, 'osc_id', $product['products_id']);
                                wp_set_object_terms($product_id, 'simple', 'product_type');
                                wp_set_object_terms($product_id, (int) $categories[$product['categories_id']], 'product_cat');
                                update_post_meta($product_id, '_sku', $product['products_model']);
                                update_post_meta($product_id, '_regular_price', $product['products_price']);
                                update_post_meta($product_id, '_price', $product['products_price']);
                                update_post_meta($product_id, '_visibility', 'visible');
                                update_post_meta($product_id, '_stock_status', $product['products_status'] ? 'instock' : 'outofstock');
                                update_post_meta($product_id, '_manage_stock', '1');
                                update_post_meta($product_id, '_stock', $product['products_quantity']);
                                $import_prod_counter++;
                                if ($special = $oscdb->get_row("SELECT specials_new_products_price, expires_date FROM specials WHERE status=1 AND products_id='" . $product_id . "' LIMIT 1", ARRAY_A)) {
                                    update_post_meta($product_id, '_sale_price', $special['specials_new_products_price']);
                                    $special['expires_date'] = strtotime($special['expires_date']);
                                    if ($special['expires_date'] > time()) {
                                        update_post_meta($product_id, '_sale_price_dates_to', date("Y-m-d", $special['expires_date']));
                                        update_post_meta($product_id, '_sale_price_dates_from', date("Y-m-d"));
                                    }
                                }
                                $attach_id = 0;
                                if ($product['products_image'] != '') {
                                    $url = rtrim($_POST['store_url'], '/') . '/images/' . urlencode($product['products_image']);
                                    $attach_id = woocommerce_osc_import_image($url);
                                }
                                if ($attach_id > 0) {
                                    set_post_thumbnail($product_id, $attach_id);
                                }
                                // Handle attributes
                                if ($attributes = $oscdb->get_results("SELECT po.products_options_name, pov.products_options_values_name FROM products_attributes pa, products_options po, products_options_values pov WHERE pa.products_id='" . $product['products_id'] . "' AND  pov.products_options_values_id = pa.options_values_id AND pov.language_id=po.language_id AND po.language_id=1 AND pa.options_id=products_options_id", ARRAY_A)) {
                                    wp_set_object_terms($product_id, 'variable', 'product_type');
                                    $attrib_array = array();
                                    $attrib_combo = array();
                                    $max_price = $product['products_price'];
                                    $min_price = $product['products_price'];
                                    foreach ($attributes as $attribute) {
                                        $slug = sanitize_title($attribute['products_options_name']);
                                        $attrib_array[$slug] = array('name' => $attribute['products_options_name'], 'value' => ltrim($attrib_array[$slug]['value'] . ' | ' . $attribute['products_options_values_name'], ' | '), 'position' => 0, 'is_visible' => 1, 'is_variation' => 1, 'is_taxonomy' => 0);
                                        $attrib_combo[$slug][] = array($attribute['products_options_values_name'], ($attribute['price_prefix'] == '-' ? '-' : '') . $attribute['options_values_price']);
                                    }
                                    // Now it gets tricky...
                                    $combos = woocommerce_osc_cartesian_product($attrib_combo);
                                    foreach ($combos as $combo) {
                                        $variation_id = wp_insert_post(array('post_title' => 'Product ' . $product_id . ' Variation', 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'product_variation', 'post_author' => 1, 'post_parent' => $product_id));
                                        $opt_price = $product['products_price'];
                                        $special_price = $special['specials_new_products_price'];
                                        foreach ($combo as $k => $v) {
                                            update_post_meta($variation_id, 'attribute_' . $k, $v[0]);
                                            $opt_price += $v[1];
                                            $special_price += $v[1];
                                        }
                                        update_post_meta($variation_id, '_sku', $product['products_model']);
                                        update_post_meta($variation_id, '_regular_price', $opt_price);
                                        update_post_meta($variation_id, '_price', $opt_price);
                                        update_post_meta($variation_id, '_thumbnail_id', 0);
                                        update_post_meta($variation_id, '_stock', $product['products_quantity']);
                                        if ($special) {
                                            update_post_meta($variation_id, '_sale_price', $special_price);
                                            if ($special['expires_date'] > time()) {
                                                update_post_meta($variation_id, '_sale_price_dates_to', date("Y-m-d", $special['expires_date']));
                                                update_post_meta($variation_id, '_sale_price_dates_from', date("Y-m-d"));
                                            }
                                        }
                                        if ($opt_price > $max_price) {
                                            $max_price = $opt_price;
                                        }
                                        if ($opt_price < $min_price) {
                                            $min_price = $opt_price;
                                        }
                                    }
                                    update_post_meta($product_id, '_product_attributes', $attrib_array);
                                    update_post_meta($product_id, '_max_variation_regular_price', $max_price);
                                    update_post_meta($product_id, '_min_variation_regular_price', $min_price);
                                    update_post_meta($product_id, '_max_variation_price', $max_price);
                                    update_post_meta($product_id, '_min_variation_price', $min_price);
                                }
                            }
                        }
                    }
                }
                if ($_POST['dtype']['orders'] == 1) {
                    $customers = $wpdb->get_results("SELECT ID FROM {$wpdb->users}", ARRAY_A);
                    $customer_id = array();
                    foreach ($customers as $c) {
                        $osc_id = get_user_meta($c['ID'], 'osc_id', true);
                        $customer_id[$osc_id] = $c['ID'];
                    }
                    $product_id = array();
                    $products_query = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type='product'", ARRAY_A);
                    foreach ($products_query as $p) {
                        $osc_id = get_post_meta($p['ID'], 'osc_id', true);
                        $product_id[$osc_id] = $p['ID'];
                    }
                    $country_data = $oscdb->get_results("SELECT * FROM countries", ARRAY_A);
                    $countries_name = array();
                    foreach ($country_data as $cdata) {
                        $countries_name[$cdata['countries_name']] = $cdata;
                    }
                    if ($orders = $oscdb->get_results("SELECT * FROM orders ORDER BY orders_id", ARRAY_A)) {
                        foreach ($orders as $order) {
                            $existing_order = get_posts(array('post_type' => 'shop_order', 'posts_per_page' => 1, 'post_status' => 'any', 'meta_query' => array(array('key' => 'osc_id', 'value' => $order['orders_id']))));
                            if (empty($existing_order)) {
                                $totals = array();
                                if ($total_query = $oscdb->get_results("SELECT * FROM orders_total WHERE orders_id='" . $order['orders_id'] . "'", ARRAY_A)) {
                                    foreach ($total_query as $t) {
                                        $totals[$t['class']] = $t;
                                    }
                                }
                                $order_key = 'order_' . wp_generate_password(13);
                                $data = array('post_type' => 'shop_order', 'post_date' => $order['date_purchased'], 'post_author' => $customer_id[$order['customers_id']], 'post_password' => $order_key, 'post_title' => 'Order &ndash; ' . date("M d, Y @ h:i A", strtotime($order['date_purchased'])), 'post_status' => 'publish');
                                $order_id = wp_insert_post($data);
                                $billing_namebits = explode(' ', $order['billing_name']);
                                $billing_firstname = $billing_namebits[0];
                                $billing_lastname = trim(str_replace($billing_namebits[0], '', $order['billing_name']));
                                $shipping_namebits = explode(' ', $order['delivery_name']);
                                $shipping_firstname = $shipping_namebits[0];
                                $shipping_lastname = trim(str_replace($shipping_namebits[0], '', $order['delivery_name']));
                                $meta_data = array('_billing_address_1' => $order['billing_street_address'], '_billing_address_2' => $order['billing_suburb'], '_wpas_done_all' => 1, '_billing_country' => $countries_name[$order['billing_country']]['countries_iso_code_2'], '_billing_first_name' => $billing_firstname, '_billing_last_name' => $billing_lastname, '_billing_company' => $order['billing_company'], '_billing_city' => $order['billing_city'], '_billing_state' => $order['billing_state'], '_billing_postcode' => $order['billing_postcode'], '_billing_phone' => $order['customers_telephone'], '_billing_email' => $order['customers_email_address'], '_shipping_country' => $countries_name[$order['delivery_country']]['countries_iso_code_2'], '_shipping_first_name' => $shipping_firstname, '_shipping_last_name' => $shipping_lastname, '_shipping_company' => $order['delivery_company'], '_shipping_address_1' => $order['delivery_street_address'], '_shipping_address_2' => $order['delivery_suburb'], '_shipping_city' => $order['delivery_city'], '_shipping_state' => $order['delivery_state'], '_shipping_postcode' => $order['delivery_postcode'], '_shipping_method_title' => $totals['ot_shipping']['title'], '_payment_method_title' => $order['payment_method'], '_order_shipping' => $totals['ot_shipping']['value'], '_order_discount' => $totals['ot_coupon']['value'] + $totals['ot_discount']['value'], '_order_tax' => $totals['ot_tax']['value'], '_order_shipping_tax' => 0, '_order_total' => $totals['ot_total']['value'], '_order_key' => $order_key, '_customer_user' => $customer_id[$order['customers_id']], '_order_currency' => $order['currency'], '_prices_include_tax' => 'no', 'osc_id' => $order['orders_id']);
                                foreach ($meta_data as $k => $v) {
                                    update_post_meta($order_id, $k, $v);
                                }
                                $order_import_counter++;
                                if ($order_products = $oscdb->get_results("SELECT * FROM orders_products WHERE orders_id='" . $order['orders_id'] . "'", ARRAY_A)) {
                                    foreach ($order_products as $product) {
                                        $item_id = woocommerce_add_order_item($order_id, array('order_item_name' => $product['products_name'], 'order_item_type' => 'line_item'));
                                        if ($item_id) {
                                            $item_meta = array('_qty' => $product['products_quantity'], '_product_id' => $product_id[$product['products_id']], '_line_subtotal' => $product['final_price'] * $product['products_quantity'], '_line_total' => $product['final_price'] * $product['products_quantity']);
                                            foreach ($item_meta as $k => $v) {
                                                woocommerce_add_order_item_meta($item_id, $k, $v);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if ($_POST['dtype']['pages'] == 1) {
                    $page_import_counter = 0;
                    if ($information_table = $oscdb->get_results("SHOW TABLES LIKE 'information'", ARRAY_A)) {
                        if ($information_pages = $oscdb->get_results("SELECT * FROM information WHERE language_id=1", ARRAY_A)) {
                            foreach ($information_pages as $information) {
                                $existing_page = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} WHERE post_type='page' AND LOWER(post_title)='" . strtolower(esc_sql($information['information_title'])) . "'", ARRAY_A);
                                if (!$existing_page) {
                                    $existing_page = get_posts(array('post_type' => 'page', 'posts_per_page' => 1, 'post_status' => 'any', 'meta_query' => array(array('key' => 'osc_id', 'value' => $information['information_id']))));
                                    if (!$existing_page) {
                                        $data = array('post_type' => 'page', 'post_title' => $information['information_title'], 'post_content' => $information['information_description'], 'post_status' => 'publish');
                                        $page_id = wp_insert_post($data);
                                        update_post_meta($page_id, 'osc_id', $information['information_id']);
                                        $page_import_counter++;
                                    }
                                }
                            }
                        }
                    } else {
                        echo '<p class="notice">The information (pages) table does not exist in this osCommerce installation.</p>';
                    }
                }
                $success = true;
            } else {
                echo '<p class="notice">Could not connect to the osCommerce database</p>';
            }
        }
        if ($success) {
            echo '<h3>The oscommerce data was successfully imported</h3>';
            if ($_POST['dtype']['customers'] == 1) {
                echo '<p><strong>Customers Imported: ' . $import_customer_counter . '</p>';
            }
            if ($_POST['dtype']['orders'] == 1) {
                echo '<p><strong>Orders Imported: ' . $order_import_counter . '</p>';
            }
            if ($_POST['dtype']['products'] == 1) {
                echo '<p><strong>Categories Imported: ' . $import_cat_counter . '</p>';
                echo '<p><strong>Products Imported: ' . $import_prod_counter . '</p>';
            }
            if ($_POST['dtype']['pages'] == 1) {
                echo '<p><strong>Pages Imported: ' . $page_import_counter . '</p>';
            }
        } else {
            ?>
            <form action="<?php 
            echo $_SERVER['REQUEST_URI'];
            ?>
" method="post">
                <h3>Import data from osCommerce</h3>

                <p>
                    Enter your oscommerce database information (you will need remote access to your oscommerce database)
                </p>

                <p>
                    <label>osCommerce store URL: <input type="text" name="store_url"
                                                        value="<?php 
            echo $_POST['store_url'];
            ?>
"></label>
                </p>

                <p>
                    <label>osCommerce Database Host: <input type="text" name="store_host" value="localhost"></label></p>

                <p>
                    <label>osCommerce Database User: <input type="text" name="store_user"
                                                            value="<?php 
            echo $_POST['store_user'];
            ?>
"></label>
                </p>

                <p>
                    <label>osCommerce Database Password: <input type="text" name="store_pass"
                                                                value="<?php 
            echo $_POST['store_pass'];
            ?>
"></label>
                </p>

                <p>
                    <label>osCommerce Database Name: <input type="text" name="store_dbname"
                                                            value="<?php 
            echo $_POST['store_dbname'];
            ?>
"></label>
                </p>

                <p>
                    Data to Import:<br>
                    <label><input type="checkbox" name="dtype[customers]" value="1"> Customers (passwords will not be
                        transferred)</label>
                    <br>
                    <label><input type="checkbox" name="dtype[orders]" value="1"> Orders</label>
                    <br>
                    <label><input type="checkbox" name="dtype[products]" value="1"> Categories/Products</label>
                    <br>
                    <label><input type="checkbox" name="dtype[pages]" value="1"> Information Pages</label>
                </p>

                <p>
                    <input type="submit" value="Import Data" class="button button-primary button-large">
                </p>
            </form>
            <?php 
        }
    }
 /**
  * Get a single row form related table
  *
  * @param int $pid1
  * @param int $pid2
  * @return array Result array
  * @since 1.0.0
  * @author Panagiotis Vagenas <*****@*****.**>
  */
 public function getRowFromRel($pid1, $pid2)
 {
     $where = ' (pid1="' . $pid1 . '" AND pid2="' . $pid2 . '") OR (pid1="' . $pid2 . '" AND pid2="' . $pid1 . '") ';
     return $this->db->get_row('SELECT * FROM ' . $this->tableName . ' WHERE ' . $where, ARRAY_A);
 }
Ejemplo n.º 29
0
 public function get_companies_indexex()
 {
     global $wpdb;
     //$alldb = new wpdb( 'root', 'root', 'allmoldova_old', 'localhost');
     $alldb = new wpdb('allmoldova', '398DU5Yv', 'allmoldova_old', 'localhost');
     $posts = $wpdb->get_results("SELECT * FROM allmoldova_posts WHERE post_type = 'company' ");
     foreach ($posts as $post) {
         $old_id = get_post_meta($post->ID, 'company_old_id', true);
         $old_post = $alldb->get_row("SELECT * FROM firms WHERE id = " . $old_id, ARRAY_A);
         if (!empty($old_post['index_'])) {
             add_post_meta($post->ID, 'index', $old_post['index_']);
         }
         add_post_meta($post->ID, 'country', 394);
     }
 }
            $session_id = $_REQUEST['session_id'];
            $table_sessions = $wordpressdb->prefix . 'wp_hmgt_sessions';
            $table_durations = $wordpressdb->prefix . 'wp_hmgt_sessions_durations';
            $durations = $wordpressdb->get_results("SELECT * FROM {$table_durations} INNER JOIN {$table_sessions} ON ({$table_sessions}.session_id = {$table_durations}.session_id ) where {$table_durations}.session_id= " . $session_id);
            foreach ($durations as $duration) {
                $duration = (array) $duration;
                $durationhtml .= "<option value='" . $duration['duration_id'] . "'>" . $duration['duration_time'] . "</option>";
            }
            print_r($durationhtml);
            exit;
        case 'is_over_lapping':
            $doctor_id = $_REQUEST['doctor_id'];
            $from_time = $_REQUEST['from_time'];
            $to_time = $_REQUEST['to_time'];
            $table_packages = $wordpressdb->prefix . 'wp_hmgt_packages';
            $overlapping = $wordpressdb->get_row("SELECT * FROM {$table_packages} WHERE ((`to_date` BETWEEN {$from_time} AND {$to_time}) OR (`from_date` BETWEEN {$from_time} AND {$to_time}) AND doctor_id={$doctor_id})");
            if ($overlapping) {
                echo 1;
            } else {
                echo 0;
            }
        case 'delete_session':
            $package_id = $_REQUEST['package_id'];
            $session_id = $_REQUEST['session_id'];
            $duration_id = $_REQUEST['duration_id'];
            $table_packages = $wordpressdb->prefix . 'wp_hmgt_packages';
            $overlapping = $wordpressdb->query("DELETE FROM {$table_packages} WHERE (`session_id` = {$session_id} AND `package_id`={$package_id} AND `duration_id`={$duration_id})");
            return 1;
    }
}
class Hmgt_session_duration