Jump to content

lyonsperf

Members
  • Content count

    341
  • Joined

  • Last visited

1 Follower

About lyonsperf

  • Birthday November 2

Profile Information

Recent Profile Visitors

17,342 profile views
  1. lyonsperf

    Google XML Sitemap SEO

    Got the latest version installed on a 2.3.4 shop and was wondering how do I update the xml files on my database manually? The older version for 2.2 had a section in the admin to manually update the various files.
  2. Which addon should i use for osc 2.3.3.4?
  3. lyonsperf

    Stripe Add-On for 2.2

    Heard back from Stripe support and they said it is the integration code that is causing the issues. They offered to work with someone from OSC if they need help re-writing the contribution so that it will work.
  4. lyonsperf

    Stripe Add-On for 2.2

    I tried to install the stripe payment module last night to my 2.2 version store. The add-on offered in the add-on section was written in 2014 and hasn't been updated. I am running into an error on the admin side of the store where I cannot successfully test the API connection to the server. It throws an error Server: https://api.stripe.com/v1/ An error occurred. Please refresh the page, review your settings, and try again. Connection Time: 0.420s I believe it has something to do with the stripe.php file located in includes/modules/payment/ The signature and api version are old. <?php /* $Id: $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ class stripe { var $code, $title, $description, $enabled; function stripe() { global $HTTP_GET_VARS, $PHP_SELF, $order, $payment; $this->signature = 'stripe|stripe|1.1|2.3'; $this->api_version = '2014-05-19'; $this->code = 'stripe'; $this->title = MODULE_PAYMENT_STRIPE_TEXT_TITLE; $this->public_title = MODULE_PAYMENT_STRIPE_TEXT_PUBLIC_TITLE; $this->description = MODULE_PAYMENT_STRIPE_TEXT_DESCRIPTION; $this->sort_order = defined('MODULE_PAYMENT_STRIPE_SORT_ORDER') ? MODULE_PAYMENT_STRIPE_SORT_ORDER : 0; $this->enabled = defined('MODULE_PAYMENT_STRIPE_STATUS') && (MODULE_PAYMENT_STRIPE_STATUS == 'True') ? true : false; $this->order_status = defined('MODULE_PAYMENT_STRIPE_ORDER_STATUS_ID') && ((int)MODULE_PAYMENT_STRIPE_ORDER_STATUS_ID > 0) ? (int)MODULE_PAYMENT_STRIPE_ORDER_STATUS_ID : 0; if ( defined('MODULE_PAYMENT_STRIPE_STATUS') ) { if ( MODULE_PAYMENT_STRIPE_TRANSACTION_SERVER == 'Test' ) { $this->title .= ' [Test]'; $this->public_title .= ' (' . $this->code . '; Test)'; } $this->description .= $this->getTestLinkInfo(); } if ( !function_exists('curl_init') ) { $this->description = '<div class="secWarning">' . MODULE_PAYMENT_STRIPE_ERROR_ADMIN_CURL . '</div>' . $this->description; $this->enabled = false; } if ( $this->enabled === true ) { if ( !tep_not_null(MODULE_PAYMENT_STRIPE_PUBLISHABLE_KEY) || !tep_not_null(MODULE_PAYMENT_STRIPE_SECRET_KEY) ) { $this->description = '<div class="secWarning">' . MODULE_PAYMENT_STRIPE_ERROR_ADMIN_CONFIGURATION . '</div>' . $this->description; $this->enabled = false; } } if ( $this->enabled === true ) { if ( isset($order) && is_object($order) ) { $this->update_status(); } } if ( defined('FILENAME_MODULES') && (basename($PHP_SELF) == FILENAME_MODULES) && isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'install') && isset($HTTP_GET_VARS['subaction']) && ($HTTP_GET_VARS['subaction'] == 'conntest') ) { echo $this->getTestConnectionResult(); exit; } } function update_status() { global $order; if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_STRIPE_ZONE > 0) ) { $check_flag = false; $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_STRIPE_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); while ($check = tep_db_fetch_array($check_query)) { if ($check['zone_id'] < 1) { $check_flag = true; break; } elseif ($check['zone_id'] == $order->delivery['zone_id']) { $check_flag = true; break; } } if ($check_flag == false) { $this->enabled = false; } } } function javascript_validation() { return false; } function selection() { global $customer_id, $payment; if ( (MODULE_PAYMENT_STRIPE_TOKENS == 'True') && !tep_session_is_registered('payment') ) { $tokens_query = tep_db_query("select 1 from customers_stripe_tokens where customers_id = '" . (int)$customer_id . "' limit 1"); if ( tep_db_num_rows($tokens_query) ) { $payment = $this->code; tep_session_register('payment'); } } return array('id' => $this->code, 'module' => $this->public_title); } function pre_confirmation_check() { global $oscTemplate; if ( $this->templateClassExists() ) { $oscTemplate->addBlock($this->getSubmitCardDetailsJavascript(), 'header_tags'); } } function confirmation() { global $customer_id, $order, $currencies, $currency; $months_array = array(); for ($i=1; $i<13; $i++) { $months_array[] = array('id' => tep_output_string(sprintf('%02d', $i)), 'text' => tep_output_string_protected(sprintf('%02d', $i))); } $today = getdate(); $years_array = array(); for ($i=$today['year']; $i < $today['year']+10; $i++) { $years_array[] = array('id' => tep_output_string(strftime('%Y',mktime(0,0,0,1,1,$i))), 'text' => tep_output_string_protected(strftime('%Y',mktime(0,0,0,1,1,$i)))); } $months_string = '<select data-stripe="exp_month">'; foreach ( $months_array as $m ) { $months_string .= '<option value="' . tep_output_string($m['id']) . '">' . tep_output_string($m['text']) . '</option>'; } $months_string .= '</select>'; $years_string = '<select data-stripe="exp_year">'; foreach ( $years_array as $y ) { $years_string .= '<option value="' . tep_output_string($y['id']) . '">' . tep_output_string($y['text']) . '</option>'; } $years_string .= '</select>'; $content = ''; if ( MODULE_PAYMENT_STRIPE_TOKENS == 'True' ) { $tokens_query = tep_db_query("select id, card_type, number_filtered, expiry_date from customers_stripe_tokens where customers_id = '" . (int)$customer_id . "' order by date_added"); if ( tep_db_num_rows($tokens_query) > 0 ) { $content .= '<table id="stripe_table" border="0" width="100%" cellspacing="0" cellpadding="2">'; while ( $tokens = tep_db_fetch_array($tokens_query) ) { $content .= '<tr class="moduleRow" id="stripe_card_' . (int)$tokens['id'] . '">' . ' <td width="40" valign="top"><input type="radio" name="stripe_card" value="' . (int)$tokens['id'] . '" /></td>' . ' <td valign="top"><strong>' . tep_output_string_protected($tokens['card_type']) . '</strong> ****' . tep_output_string_protected($tokens['number_filtered']) . ' ' . tep_output_string_protected(substr($tokens['expiry_date'], 0, 2) . '/' . substr($tokens['expiry_date'], 2)) . '</td>' . '</tr>'; } $content .= '<tr class="moduleRow" id="stripe_card_0">' . ' <td width="40" valign="top"><input type="radio" name="stripe_card" value="0" /></td>' . ' <td valign="top">' . MODULE_PAYMENT_STRIPE_CREDITCARD_NEW . '</td>' . '</tr>' . '</table>'; } } $content .= '<div class="messageStackError payment-errors"></div>' . '<table id="stripe_table_new_card" border="0" width="100%" cellspacing="0" cellpadding="2">' . '<tr>' . ' <td width="30%">' . MODULE_PAYMENT_STRIPE_CREDITCARD_OWNER . '</td>' . ' <td><input type="text" data-stripe="name" value="' . tep_output_string($order->billing['firstname'] . ' ' . $order->billing['lastname']) . '" /></td>' . '</tr>' . '<tr>' . ' <td width="30%">' . MODULE_PAYMENT_STRIPE_CREDITCARD_NUMBER . '</td>' . ' <td><input type="text" maxlength="20" autocomplete="off" data-stripe="number" /></td>' . '</tr>' . '<tr>' . ' <td width="30%">' . MODULE_PAYMENT_STRIPE_CREDITCARD_EXPIRY . '</td>' . ' <td>' . $months_string . ' / ' . $years_string . '</td>' . '</tr>'; if ( MODULE_PAYMENT_STRIPE_VERIFY_WITH_CVC == 'True' ) { $content .= '<tr>' . ' <td width="30%">' . MODULE_PAYMENT_STRIPE_CREDITCARD_CVC . '</td>' . ' <td><input type="text" size="5" maxlength="4" autocomplete="off" data-stripe="cvc" /></td>' . '</tr>'; } if ( MODULE_PAYMENT_STRIPE_TOKENS == 'True' ) { $content .= '<tr>' . ' <td width="30%"> </td>' . ' <td>' . tep_draw_checkbox_field('cc_save', 'true') . ' ' . MODULE_PAYMENT_STRIPE_CREDITCARD_SAVE . '</td>' . '</tr>'; } $content .= '</table>'; $address = array('address_line1' => $order->billing['street_address'], 'address_city' => $order->billing['city'], 'address_zip' => $order->billing['postcode'], 'address_state' => tep_get_zone_name($order->billing['country_id'], $order->billing['zone_id'], $order->billing['state']), 'address_country' => $order->billing['country']['iso_code_2']); foreach ( $address as $k => $v ) { $content .= '<input type="hidden" data-stripe="' . tep_output_string($k) . '" value="' . tep_output_string($v) . '" />'; } if ( !$this->templateClassExists() ) { $content .= $this->getSubmitCardDetailsJavascript(); } $confirmation = array('title' => $content); return $confirmation; } function process_button() { return false; } function before_process() { global $customer_id, $order, $currency, $HTTP_POST_VARS, $stripe_result, $stripe_error; $stripe_result = null; $params = array(); if ( MODULE_PAYMENT_STRIPE_TOKENS == 'True' ) { if ( isset($HTTP_POST_VARS['stripe_card']) && is_numeric($HTTP_POST_VARS['stripe_card']) && ($HTTP_POST_VARS['stripe_card'] > 0) ) { $token_query = tep_db_query("select stripe_token from customers_stripe_tokens where id = '" . (int)$HTTP_POST_VARS['stripe_card'] . "' and customers_id = '" . (int)$customer_id . "'"); if ( tep_db_num_rows($token_query) === 1 ) { $token = tep_db_fetch_array($token_query); $stripe_token_array = explode(':|:', $token['stripe_token'], 2); $params['customer'] = $stripe_token_array[0]; $params['card'] = $stripe_token_array[1]; } else { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=cardstored', 'SSL')); } } } if ( empty($params) && isset($HTTP_POST_VARS['stripeToken']) && !empty($HTTP_POST_VARS['stripeToken']) ) { if ( (MODULE_PAYMENT_STRIPE_TOKENS == 'True') && isset($HTTP_POST_VARS['cc_save']) && ($HTTP_POST_VARS['cc_save'] == 'true') ) { $stripe_customer_id = $this->getCustomerID(); $stripe_card_id = false; if ( $stripe_customer_id === false ) { $stripe_customer_array = $this->createCustomer($HTTP_POST_VARS['stripeToken']); if ( ($stripe_customer_array !== false) && isset($stripe_customer_array['id']) ) { $stripe_customer_id = $stripe_customer_array['id']; $stripe_card_id = $stripe_customer_array['card_id']; } } else { $stripe_card_id = $this->addCard($HTTP_POST_VARS['stripeToken'], $stripe_customer_id); } if ( ($stripe_customer_id !== false) && ($stripe_card_id !== false) ) { $params['customer'] = $stripe_customer_id; $params['card'] = $stripe_card_id; } } else { $params['card'] = $HTTP_POST_VARS['stripeToken']; } } if ( !empty($params) ) { $params['amount'] = $this->format_raw($order->info['total']); $params['currency'] = $currency; $params['capture'] = (MODULE_PAYMENT_STRIPE_TRANSACTION_METHOD == 'Capture') ? 'true' : 'false'; $stripe_result = json_decode($this->sendTransactionToGateway('https://api.stripe.com/v1/charges', $params), true); if ( is_array($stripe_result) && !empty($stripe_result) ) { if ( isset($stripe_result['object']) && ($stripe_result['object'] == 'charge') ) { return true; } } } if ( isset($stripe_result['error']['message']) ) { tep_session_register('stripe_error'); $stripe_error = $stripe_result['error']['message']; } $this->sendDebugEmail($stripe_result); tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL')); } function after_process() { global $insert_id, $customer_id, $stripe_result, $HTTP_POST_VARS; $status_comment = array('Transaction ID: ' . $stripe_result['id'], 'CVC: ' . $stripe_result['card']['cvc_check']); if ( !empty($stripe_result['card']['address_line1_check']) ) { $status_comment[] = 'Address Check: ' . $stripe_result['card']['address_line1_check']; } if ( !empty($stripe_result['card']['address_zip_check']) ) { $status_comment[] = 'ZIP Check: ' . $stripe_result['card']['address_zip_check']; } if ( MODULE_PAYMENT_STRIPE_TOKENS == 'True' ) { if ( isset($HTTP_POST_VARS['cc_save']) && ($HTTP_POST_VARS['cc_save'] == 'true') ) { $status_comment[] = 'Token Saved: Yes'; } elseif ( isset($HTTP_POST_VARS['stripe_card']) && is_numeric($HTTP_POST_VARS['stripe_card']) && ($HTTP_POST_VARS['stripe_card'] > 0) ) { $status_comment[] = 'Token Used: Yes'; } } $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => MODULE_PAYMENT_STRIPE_TRANSACTION_ORDER_STATUS_ID, 'date_added' => 'now()', 'customer_notified' => '0', 'comments' => implode("\n", $status_comment)); tep_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); if ( tep_session_is_registered('stripe_error') ) { tep_session_unregister('stripe_error'); } } function get_error() { global $HTTP_GET_VARS, $stripe_error; $message = MODULE_PAYMENT_STRIPE_ERROR_GENERAL; if ( tep_session_is_registered('stripe_error') ) { $message = $stripe_error . ' ' . $message; tep_session_unregister('stripe_error'); } if ( isset($HTTP_GET_VARS['error']) && !empty($HTTP_GET_VARS['error']) ) { switch ($HTTP_GET_VARS['error']) { case 'cardstored': $message = MODULE_PAYMENT_STRIPE_ERROR_CARDSTORED; break; } } $error = array('title' => MODULE_PAYMENT_STRIPE_ERROR_TITLE, 'error' => $message); return $error; } function check() { if (!isset($this->_check)) { $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_STRIPE_STATUS'"); $this->_check = tep_db_num_rows($check_query); } return $this->_check; } function install($parameter = null) { $params = $this->getParams(); if (isset($parameter)) { if (isset($params[$parameter])) { $params = array($parameter => $params[$parameter]); } else { $params = array(); } } foreach ($params as $key => $data) { $sql_data_array = array('configuration_title' => $data['title'], 'configuration_key' => $key, 'configuration_value' => (isset($data['value']) ? $data['value'] : ''), 'configuration_description' => $data['desc'], 'configuration_group_id' => '6', 'sort_order' => '0', 'date_added' => 'now()'); if (isset($data['set_func'])) { $sql_data_array['set_function'] = $data['set_func']; } if (isset($data['use_func'])) { $sql_data_array['use_function'] = $data['use_func']; } tep_db_perform(TABLE_CONFIGURATION, $sql_data_array); } } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { $keys = array_keys($this->getParams()); if ($this->check()) { foreach ($keys as $key) { if (!defined($key)) { $this->install($key); } } } return $keys; } function getParams() { if ( tep_db_num_rows(tep_db_query("show tables like 'customers_stripe_tokens'")) != 1 ) { $sql = <<<EOD CREATE TABLE customers_stripe_tokens ( id int NOT NULL auto_increment, customers_id int NOT NULL, stripe_token varchar(255) NOT NULL, card_type varchar(32) NOT NULL, number_filtered varchar(20) NOT NULL, expiry_date char(6) NOT NULL, date_added datetime NOT NULL, PRIMARY KEY (id), KEY idx_cstripet_customers_id (customers_id), KEY idx_cstripet_token (stripe_token) ); EOD; tep_db_query($sql); } if (!defined('MODULE_PAYMENT_STRIPE_TRANSACTION_ORDER_STATUS_ID')) { $check_query = tep_db_query("select orders_status_id from " . TABLE_ORDERS_STATUS . " where orders_status_name = 'Stripe [Transactions]' limit 1"); if (tep_db_num_rows($check_query) < 1) { $status_query = tep_db_query("select max(orders_status_id) as status_id from " . TABLE_ORDERS_STATUS); $status = tep_db_fetch_array($status_query); $status_id = $status['status_id']+1; $languages = tep_get_languages(); foreach ($languages as $lang) { tep_db_query("insert into " . TABLE_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . $status_id . "', '" . $lang['id'] . "', 'Stripe [Transactions]')"); } $flags_query = tep_db_query("describe " . TABLE_ORDERS_STATUS . " public_flag"); if (tep_db_num_rows($flags_query) == 1) { tep_db_query("update " . TABLE_ORDERS_STATUS . " set public_flag = 0 and downloads_flag = 0 where orders_status_id = '" . $status_id . "'"); } } else { $check = tep_db_fetch_array($check_query); $status_id = $check['orders_status_id']; } } else { $status_id = MODULE_PAYMENT_STRIPE_TRANSACTION_ORDER_STATUS_ID; } $params = array('MODULE_PAYMENT_STRIPE_STATUS' => array('title' => 'Enable Stripe Module', 'desc' => 'Do you want to accept Stripe payments?', 'value' => 'True', 'set_func' => 'tep_cfg_select_option(array(\'True\', \'False\'), '), 'MODULE_PAYMENT_STRIPE_PUBLISHABLE_KEY' => array('title' => 'Publishable API Key', 'desc' => 'The Stripe account publishable API key to use.', 'value' => ''), 'MODULE_PAYMENT_STRIPE_SECRET_KEY' => array('title' => 'Secret API Key', 'desc' => 'The Stripe account secret API key to use with the publishable key.', 'value' => ''), 'MODULE_PAYMENT_STRIPE_TOKENS' => array('title' => 'Create Tokens', 'desc' => 'Create and store tokens for card payments customers can use on their next purchase?', 'value' => 'False', 'set_func' => 'tep_cfg_select_option(array(\'True\', \'False\'), '), 'MODULE_PAYMENT_STRIPE_VERIFY_WITH_CVC' => array('title' => 'Verify With CVC', 'desc' => 'Verify the credit card billing address with the Card Verification Code (CVC)?', 'value' => 'True', 'set_func' => 'tep_cfg_select_option(array(\'True\', \'False\'), '), 'MODULE_PAYMENT_STRIPE_TRANSACTION_METHOD' => array('title' => 'Transaction Method', 'desc' => 'The processing method to use for each transaction.', 'value' => 'Authorize', 'set_func' => 'tep_cfg_select_option(array(\'Authorize\', \'Capture\'), '), 'MODULE_PAYMENT_STRIPE_ORDER_STATUS_ID' => array('title' => 'Set Order Status', 'desc' => 'Set the status of orders made with this payment module to this value', 'value' => '0', 'use_func' => 'tep_get_order_status_name', 'set_func' => 'tep_cfg_pull_down_order_statuses('), 'MODULE_PAYMENT_STRIPE_TRANSACTION_ORDER_STATUS_ID' => array('title' => 'Transaction Order Status', 'desc' => 'Include transaction information in this order status level', 'value' => $status_id, 'set_func' => 'tep_cfg_pull_down_order_statuses(', 'use_func' => 'tep_get_order_status_name'), 'MODULE_PAYMENT_STRIPE_ZONE' => array('title' => 'Payment Zone', 'desc' => 'If a zone is selected, only enable this payment method for that zone.', 'value' => '0', 'use_func' => 'tep_get_zone_class_title', 'set_func' => 'tep_cfg_pull_down_zone_classes('), 'MODULE_PAYMENT_STRIPE_TRANSACTION_SERVER' => array('title' => 'Transaction Server', 'desc' => 'Perform transactions on the production server or on the testing server.', 'value' => 'Live', 'set_func' => 'tep_cfg_select_option(array(\'Live\', \'Test\'), '), 'MODULE_PAYMENT_STRIPE_VERIFY_SSL' => array('title' => 'Verify SSL Certificate', 'desc' => 'Verify gateway server SSL certificate on connection?', 'value' => 'True', 'set_func' => 'tep_cfg_select_option(array(\'True\', \'False\'), '), 'MODULE_PAYMENT_STRIPE_PROXY' => array('title' => 'Proxy Server', 'desc' => 'Send API requests through this proxy server. (host:port, eg: 123.45.67.89:8080 or proxy.example.com:8080)'), 'MODULE_PAYMENT_STRIPE_DEBUG_EMAIL' => array('title' => 'Debug E-Mail Address', 'desc' => 'All parameters of an invalid transaction will be sent to this email address.'), 'MODULE_PAYMENT_STRIPE_SORT_ORDER' => array('title' => 'Sort order of display.', 'desc' => 'Sort order of display. Lowest is displayed first.', 'value' => '0')); return $params; } function sendTransactionToGateway($url, $parameters = null, $curl_opts = array()) { $server = parse_url($url); if (isset($server['port']) === false) { $server['port'] = ($server['scheme'] == 'https') ? 443 : 80; } if (isset($server['path']) === false) { $server['path'] = '/'; } $header = array('Stripe-Version: ' . $this->api_version, 'User-Agent: OSCOM ' . tep_get_version()); if ( is_array($parameters) && !empty($parameters) ) { $post_string = ''; foreach ($parameters as $key => $value) { $post_string .= $key . '=' . urlencode(utf8_encode(trim($value))) . '&'; } $post_string = substr($post_string, 0, -1); $parameters = $post_string; } $curl = curl_init($server['scheme'] . '://' . $server['host'] . $server['path'] . (isset($server['query']) ? '?' . $server['query'] : '')); curl_setopt($curl, CURLOPT_PORT, $server['port']); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FORBID_REUSE, true); curl_setopt($curl, CURLOPT_FRESH_CONNECT, true); curl_setopt($curl, CURLOPT_USERPWD, MODULE_PAYMENT_STRIPE_SECRET_KEY . ':'); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); if ( !empty($parameters) ) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters); } if ( MODULE_PAYMENT_STRIPE_VERIFY_SSL == 'True' ) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); if ( file_exists(DIR_FS_CATALOG . 'ext/modules/payment/stripe/stripe.com.crt') ) { curl_setopt($curl, CURLOPT_CAINFO, DIR_FS_CATALOG . 'ext/modules/payment/stripe/stripe.com.crt'); } elseif ( file_exists(DIR_FS_CATALOG . 'includes/cacert.pem') ) { curl_setopt($curl, CURLOPT_CAINFO, DIR_FS_CATALOG . 'includes/cacert.pem'); } } else { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); } if ( tep_not_null(MODULE_PAYMENT_STRIPE_PROXY) ) { curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, true); curl_setopt($curl, CURLOPT_PROXY, MODULE_PAYMENT_STRIPE_PROXY); } if ( !empty($curl_opts) ) { foreach ( $curl_opts as $key => $value ) { curl_setopt($curl, $key, $value); } } $result = curl_exec($curl); curl_close($curl); return $result; } function getTestLinkInfo() { $dialog_title = MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_TITLE; $dialog_button_close = MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_BUTTON_CLOSE; $dialog_success = MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_SUCCESS; $dialog_failed = MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_FAILED; $dialog_error = MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_ERROR; $dialog_connection_time = MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_TIME; $test_url = tep_href_link(FILENAME_MODULES, 'set=payment&module=' . $this->code . '&action=install&subaction=conntest'); $js = <<<EOD <script> if ( typeof jQuery == 'undefined' ) { document.write('<scr' + 'ipt src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></scr' + 'ipt>'); document.write('<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/redmond/jquery-ui.css" />'); document.write('<scr' + 'ipt src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></scr' + 'ipt>'); } </script> <script> $(function() { $('#tcdprogressbar').progressbar({ value: false }); }); function openTestConnectionDialog() { var d = $('<div>').html($('#testConnectionDialog').html()).dialog({ modal: true, title: '{$dialog_title}', buttons: { '{$dialog_button_close}': function () { $(this).dialog('destroy'); } } }); var timeStart = new Date().getTime(); $.ajax({ url: '{$test_url}' }).done(function(data) { if ( data == '1' ) { d.find('#testConnectionDialogProgress').html('<p style="font-weight: bold; color: green;">{$dialog_success}</p>'); } else { d.find('#testConnectionDialogProgress').html('<p style="font-weight: bold; color: red;">{$dialog_failed}</p>'); } }).fail(function() { d.find('#testConnectionDialogProgress').html('<p style="font-weight: bold; color: red;">{$dialog_error}</p>'); }).always(function() { var timeEnd = new Date().getTime(); var timeTook = new Date(0, 0, 0, 0, 0, 0, timeEnd-timeStart); d.find('#testConnectionDialogProgress').append('<p>{$dialog_connection_time} ' + timeTook.getSeconds() + '.' + timeTook.getMilliseconds() + 's</p>'); }); } </script> EOD; $info = '<p><img src="images/icons/locked.gif" border="0"> <a href="javascript:openTestConnectionDialog();" style="text-decoration: underline; font-weight: bold;">' . MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_LINK_TITLE . '</a></p>' . '<div id="testConnectionDialog" style="display: none;"><p>Server:<br />https://api.stripe.com/v1/</p><div id="testConnectionDialogProgress"><p>' . MODULE_PAYMENT_STRIPE_DIALOG_CONNECTION_GENERAL_TEXT . '</p><div id="tcdprogressbar"></div></div></div>' . $js; return $info; } function getTestConnectionResult() { $stripe_result = json_decode($this->sendTransactionToGateway('https://api.stripe.com/v1/charges/oscommerce_connection_test'), true); if ( is_array($stripe_result) && !empty($stripe_result) && isset($stripe_result['error']) ) { return 1; } return -1; } function format_raw($number, $currency_code = '', $currency_value = '') { global $currencies, $currency; if (empty($currency_code) || !$currencies->is_set($currency_code)) { $currency_code = $currency; } if (empty($currency_value) || !is_numeric($currency_value)) { $currency_value = $currencies->currencies[$currency_code]['value']; } return number_format(tep_round($number * $currency_value, $currencies->currencies[$currency_code]['decimal_places']), $currencies->currencies[$currency_code]['decimal_places'], '', ''); } function templateClassExists() { return class_exists('oscTemplate') && isset($GLOBALS['oscTemplate']) && is_object($GLOBALS['oscTemplate']) && (get_class($GLOBALS['oscTemplate']) == 'oscTemplate'); } function getSubmitCardDetailsJavascript() { $stripe_publishable_key = MODULE_PAYMENT_STRIPE_PUBLISHABLE_KEY; $js = <<<EOD <script> if ( typeof jQuery == 'undefined' ) { document.write('<scr' + 'ipt src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></scr' + 'ipt>'); } </script> <script src="https://js.stripe.com/v2/"></script> <script> $(function() { Stripe.setPublishableKey('{$stripe_publishable_key}'); $('form[name="checkout_confirmation"]').attr('id', 'payment-form'); $('#payment-form').submit(function(event) { var \$form = $(this); if ( ($('#stripe_table').length < 1) || ($('form[name="checkout_confirmation"] input[name="stripe_card"]:radio:checked').val() == '0') ) { // Disable the submit button to prevent repeated clicks \$form.find('button').prop('disabled', true); try { Stripe.card.createToken(\$form, stripeResponseHandler); } catch ( error ) { \$form.find('.payment-errors').text(error); } // Prevent the form from submitting with the default action return false; } }); var stripeResponseHandler = function(status, response) { var \$form = $('#payment-form'); if (response.error) { // Show the errors on the form \$form.find('.payment-errors').text(response.error.message); \$form.find('button').prop('disabled', false); } else { // token contains id, last4, and card type var token = response.id; // Insert the token into the form so it gets submitted to the server \$form.append($('<input type="hidden" name="stripeToken" />').val(token)); // and submit \$form.get(0).submit(); } }; if ( $('#stripe_table').length > 0 ) { if ( typeof($('#stripe_table').parent().closest('table').attr('width')) == 'undefined' ) { $('#stripe_table').parent().closest('table').attr('width', '100%'); } $('#stripe_table .moduleRowExtra').hide(); $('#stripe_table_new_card').hide(); $('form[name="checkout_confirmation"] input[name="stripe_card"]').change(function() { var selected = $(this).val(); if ( selected == '0' ) { stripeShowNewCardFields(); } else { $('#stripe_table_new_card').hide(); } $('tr[id^="stripe_card_"]').removeClass('moduleRowSelected'); $('#stripe_card_' + selected).addClass('moduleRowSelected'); }); $('form[name="checkout_confirmation"] input[name="stripe_card"]:first').prop('checked', true).trigger('change'); $('#stripe_table .moduleRow').hover(function() { $(this).addClass('moduleRowOver'); }, function() { $(this).removeClass('moduleRowOver'); }).click(function(event) { var target = $(event.target); if ( !target.is('input:radio') ) { $(this).find('input:radio').each(function() { if ( $(this).prop('checked') == false ) { $(this).prop('checked', true).trigger('change'); } }); } }); } else { if ( typeof($('#stripe_table_new_card').parent().closest('table').attr('width')) == 'undefined' ) { $('#stripe_table_new_card').parent().closest('table').attr('width', '100%'); } } }); function stripeShowNewCardFields() { $('#stripe_table_new_card').show(); } </script> EOD; return $js; } function sendDebugEmail($response = array()) { global $HTTP_POST_VARS, $HTTP_GET_VARS; if (tep_not_null(MODULE_PAYMENT_STRIPE_DEBUG_EMAIL)) { $email_body = ''; if (!empty($response)) { $email_body .= 'RESPONSE:' . "\n\n" . print_r($response, true) . "\n\n"; } if (!empty($HTTP_POST_VARS)) { $email_body .= '$HTTP_POST_VARS:' . "\n\n" . print_r($HTTP_POST_VARS, true) . "\n\n"; } if (!empty($HTTP_GET_VARS)) { $email_body .= '$HTTP_GET_VARS:' . "\n\n" . print_r($HTTP_GET_VARS, true) . "\n\n"; } if (!empty($email_body)) { tep_mail('', MODULE_PAYMENT_STRIPE_DEBUG_EMAIL, 'Stripe Debug E-Mail', trim($email_body), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); } } } function getCustomerID() { global $customer_id; $token_check_query = tep_db_query("select stripe_token from customers_stripe_tokens where customers_id = '" . (int)$customer_id . "' limit 1"); if ( tep_db_num_rows($token_check_query) === 1 ) { $token_check = tep_db_fetch_array($token_check_query); $stripe_token_array = explode(':|:', $token_check['stripe_token'], 2); return $stripe_token_array[0]; } return false; } function createCustomer($token) { global $customer_id; $params = array('card' => $token); $result = json_decode($this->sendTransactionToGateway('https://api.stripe.com/v1/customers', $params), true); if ( is_array($result) && !empty($result) && isset($result['object']) && ($result['object'] == 'customer') ) { $token = tep_db_prepare_input($result['id'] . ':|:' . $result['cards']['data'][0]['id']); $type = tep_db_prepare_input($result['cards']['data'][0]['type']); $number = tep_db_prepare_input($result['cards']['data'][0]['last4']); $expiry = tep_db_prepare_input(str_pad($result['cards']['data'][0]['exp_month'], 2, '0', STR_PAD_LEFT) . $result['cards']['data'][0]['exp_year']); $sql_data_array = array('customers_id' => (int)$customer_id, 'stripe_token' => $token, 'card_type' => $type, 'number_filtered' => $number, 'expiry_date' => $expiry, 'date_added' => 'now()'); tep_db_perform('customers_stripe_tokens', $sql_data_array); return array('id' => $result['id'], 'card_id' => $result['cards']['data'][0]['id']); } $this->sendDebugEmail($result); return false; } function addCard($token, $customer) { global $customer_id; $params = array('card' => $token); $result = json_decode($this->sendTransactionToGateway('https://api.stripe.com/v1/customers/' . $customer . '/cards', $params), true); if ( is_array($result) && !empty($result) && isset($result['object']) && ($result['object'] == 'card') ) { $token = tep_db_prepare_input($customer . ':|:' . $result['id']); $type = tep_db_prepare_input($result['type']); $number = tep_db_prepare_input($result['last4']); $expiry = tep_db_prepare_input(str_pad($result['exp_month'], 2, '0', STR_PAD_LEFT) . $result['exp_year']); $sql_data_array = array('customers_id' => (int)$customer_id, 'stripe_token' => $token, 'card_type' => $type, 'number_filtered' => $number, 'expiry_date' => $expiry, 'date_added' => 'now()'); tep_db_perform('customers_stripe_tokens', $sql_data_array); return $result['id']; } $this->sendDebugEmail($result); return false; } function deleteCard($card, $customer, $token_id) { global $customer_id; $result = $this->sendTransactionToGateway('https://api.stripe.com/v1/customers/' . $customer . '/cards/' . $card, null, array(CURLOPT_CUSTOMREQUEST => 'DELETE')); if ( !is_array($result) || !isset($result['object']) || ($result['object'] != 'card') ) { $this->sendDebugEmail($result); } tep_db_query("delete from customers_stripe_tokens where id = '" . (int)$token_id . "' and customers_id = '" . (int)$customer_id . "' and stripe_token = '" . tep_db_prepare_input(tep_db_input($customer . ':|:' . $card)) . "'"); return (tep_db_affected_rows() === 1); } } ?> Has anyone updated this?
  5. OK, I got the MVS to work on m mobile site after some help from Surfalot. My next issue is with the Purchase Without Account Mod. I have got it to show on the account page, then it opens the account information form without password request. When a customer completes the info on the form and clicks the button to continue, the page hangs and does not continue on to checkout_shipping. The customers info is added to the database so I know that part is working. This is on a 2.2ra site Can someone tell me why the page will not forward to the next step, checkout shipping? Here is my Create_account.php code: <?php require_once('includes/application_top.php'); // PWA for IosC BOF if (isset($HTTP_GET_VARS['guest']) && $cart->count_contents() < 1) tep_redirect(tep_mobile_link(FILENAME_SHOPPING_CART)); // PWA for IosC EOF // Country-State Selector if (isset($HTTP_POST_VARS['action']) && $HTTP_POST_VARS['action'] == 'getStates' && isset($HTTP_POST_VARS['country'])) { tep_ajax_get_zones_html(tep_db_prepare_input($HTTP_POST_VARS['country']), '', true); } else { // needs to be included earlier to set the success message in the messageStack require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT); if ( isset($HTTP_POST_VARS['dob_ind']) && isset($HTTP_POST_VARS['dob_inm']) && isset($HTTP_POST_VARS['dob_inY']) ) { $HTTP_POST_VARS['dob'] = $HTTP_POST_VARS['dob_ind'].'/'.$HTTP_POST_VARS['dob_inm'].'/'.$HTTP_POST_VARS['dob_inY']; } $process = false; if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { $process = true; if (ACCOUNT_GENDER == 'true') { if (isset($HTTP_POST_VARS['gender'])) { $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']); } else { $gender = false; } } $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']); $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']); if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']); $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']); $confirm_email_address = tep_db_prepare_input($_POST['confirm_email_address']); if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']); $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']); if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']); $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']); $city = tep_db_prepare_input($HTTP_POST_VARS['city']); if (ACCOUNT_STATE == 'true') { $state = tep_db_prepare_input($HTTP_POST_VARS['state']); if (isset($HTTP_POST_VARS['zone_id'])) { $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']); } else { $zone_id = false; } } $country = tep_db_prepare_input($HTTP_POST_VARS['country']); $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']); $fax = tep_db_prepare_input($HTTP_POST_VARS['fax']); if (isset($HTTP_POST_VARS['newsletter'])) { $newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']); } else { $newsletter = false; } $password = tep_db_prepare_input($HTTP_POST_VARS['password']); $confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']); $error = false; if (ACCOUNT_GENDER == 'true') { if ( ($gender != 'm') && ($gender != 'f') ) { $error = true; $messageStack->add('create_account', ENTRY_GENDER_ERROR); } } if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_FIRST_NAME_ERROR); } if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_LAST_NAME_ERROR); } if (ACCOUNT_DOB == 'true') { if ((is_numeric(tep_date_raw($dob)) == false) || (@checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false)) { $error = true; $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR); } } if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR); } elseif (tep_validate_email($email_address) == false) { $error = true; $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); } else { // PWA for IosC BOF $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "' and guest_account != '1'"); // PWA for IosC EOF $check_email = tep_db_fetch_array($check_email_query); if ($check_email['total'] > 0) { $error = true; $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS); } } if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_STREET_ADDRESS_ERROR); } if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_POST_CODE_ERROR); } if (strlen($city) < ENTRY_CITY_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_CITY_ERROR); } if (is_numeric($country) == false) { $error = true; $messageStack->add('create_account', ENTRY_COUNTRY_ERROR); } if (ACCOUNT_STATE == 'true') { // Country-State Selector if ($zone_id == 0) { if (strlen($state) < ENTRY_STATE_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_STATE_ERROR); } } } if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR); } // PWA for IosC BOF if (!isset($HTTP_GET_VARS['guest']) && !isset($HTTP_POST_VARS['guest'])) { // PWA for IosC EOF if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) { $error = true; $messageStack->add('create_account', ENTRY_PASSWORD_ERROR); } elseif ($password != $confirmation) { $error = true; $messageStack->add('create_account', ENTRY_PASSWORD_ERROR_NOT_MATCHING); } // PWA for IosC BOF } // PWA for IosC EOF if ($error == false) { // PWA for IosC BOF if (!isset($HTTP_GET_VARS['guest']) && !isset($HTTP_POST_VARS['guest'])) { $dbPass = tep_encrypt_password($password); $guestaccount = '0'; }else{ $dbPass = 'null'; $guestaccount = '1'; } // PWA for IosC EOF $sql_data_array = array('customers_firstname' => $firstname, 'customers_lastname' => $lastname, 'customers_email_address' => $email_address, 'customers_telephone' => $telephone, 'customers_fax' => $fax, 'customers_newsletter' => $newsletter, // PWA for IosC BOF 'customers_password' => $dbPass, 'guest_account' => $guestaccount); // PWA for IosC EOF if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender; if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob); tep_db_perform(TABLE_CUSTOMERS, $sql_data_array); $customer_id = tep_db_insert_id(); $sql_data_array = array('customers_id' => $customer_id, 'entry_firstname' => $firstname, 'entry_lastname' => $lastname, 'entry_street_address' => $street_address, 'entry_postcode' => $postcode, 'entry_city' => $city, 'entry_country_id' => $country); if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender; if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company; if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb; if (ACCOUNT_STATE == 'true') { if ($zone_id > 0) { $sql_data_array['entry_zone_id'] = $zone_id; $sql_data_array['entry_state'] = ''; } else { $sql_data_array['entry_zone_id'] = '0'; $sql_data_array['entry_state'] = $state; } } // PWA for IosC BOF if (isset($HTTP_GET_VARS['guest']) or isset($HTTP_POST_VARS['guest'])) tep_session_register('customer_is_guest'); // PWA for IosC EOF tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array); $address_id = tep_db_insert_id(); tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'"); tep_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int)$customer_id . "', '0', now())"); if (SESSION_RECREATE == 'True') { tep_session_recreate(); } $customer_first_name = $firstname; $customer_default_address_id = $address_id; $customer_country_id = $country; $customer_zone_id = $zone_id; tep_session_register('customer_id'); tep_session_register('customer_first_name'); tep_session_register('customer_default_address_id'); tep_session_register('customer_country_id'); tep_session_register('customer_zone_id'); // PWA for IosC BOF if (isset($HTTP_GET_VARS['guest']) or isset($HTTP_POST_VARS['guest'])) tep_redirect(tep_mobile_link(FILENAME_CHECKOUT_SHIPPING)); // PWA for IosC EOF // reset session token $sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand()); // restore cart contents $cart->restore_contents(); // build the message content $name = $firstname . ' ' . $lastname; if (ACCOUNT_GENDER == 'true') { if ($gender == 'm') { $email_text = sprintf(EMAIL_GREET_MR, $lastname); } else { $email_text = sprintf(EMAIL_GREET_MS, $lastname); } } else { $email_text = sprintf(EMAIL_GREET_NONE, $firstname); } $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING; tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); tep_redirect(tep_mobile_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL')); } } // PWA for IosC BOF if (!isset($HTTP_GET_VARS['guest']) && !isset($HTTP_POST_VARS['guest'])){ $breadcrumb->add(HEADING_TITLE, tep_mobile_link(FILENAME_CREATE_ACCOUNT, '', 'SSL')); }else{ $breadcrumb->add(HEADING_TITLE_PWA, tep_mobile_link(FILENAME_CREATE_ACCOUNT, 'guest=guest', 'SSL')); } // PWA for IosC EOF // Country-State Selector if (!isset($country)) $country = STORE_COUNTRY; $breadcrumb->add(NAVBAR_TITLE, tep_mobile_link(FILENAME_CREATE_ACCOUNT, '', 'SSL')); require(DIR_MOBILE_INCLUDES . 'header.php'); $headerTitle->write(); ?> <div id="iphone_content"> <!-- PWA for IosC BOF --> <?php echo tep_draw_form('create_account', tep_mobile_link(FILENAME_CREATE_ACCOUNT, (isset($HTTP_GET_VARS['guest'])? 'guest=guest':''), 'SSL'), 'post', 'onSubmit="return check_form(create_account);"') . tep_draw_hidden_field('action', 'process'); ?> <!-- PWA for IosC EOF --> <?php // PWA BOF if (!isset($HTTP_GET_VARS['guest']) && !isset($HTTP_POST_VARS['guest'])){ ?> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <?php }else{ ?> <td class="pageHeading"><?php echo HEADING_TITLE_PWA; ?></td> <?php } // PWA EOF ?> <!-- Country-State Selector --> <div id="indicator"></div> <div id="messageStack"> <?php if ($messageStack->size('create_account') > 0) { echo $messageStack->output('create_account'); } ?> </div> <div id="inscription"> <h1><?php echo CATEGORY_PERSONAL; ?></h1> <div class="obligatoire"><?php echo FORM_REQUIRED_INFORMATION; ?></div><br /> <?php if (ACCOUNT_GENDER == 'true') { echo tep_radio_select_gender_jquery('gender', ENTRY_GENDER . (tep_not_null(ENTRY_GENDER_TEXT) ? ' ' . ENTRY_GENDER_TEXT : ''), 'a', '', 'data-mini="true"' ); } echo tep_label_input_jquery('firstname','',ENTRY_FIRST_NAME . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_FIRST_NAME_TEXT . '</span>': '')); echo tep_label_input_jquery('lastname', '', ENTRY_LAST_NAME . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_LAST_NAME_TEXT . '</span>': '')); if (ACCOUNT_DOB == 'true') { echo tep_draw_pull_down_date_jquery('dob_in', '0', '0', '1980', ENTRY_DATE_OF_BIRTH, '', 'a', 'data-inline="true" data-mini="true"', false, false, true, 1900, false); } echo tep_label_input_jquery('email_address','', ENTRY_EMAIL_ADDRESS . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''), 'a', '','email'); if (ACCOUNT_COMPANY == 'true') { echo '<h1>' . CATEGORY_COMPANY . '</h1>'; echo tep_label_input_jquery('company', '', ENTRY_COMPANY . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_COMPANY_TEXT . '</span>': '')); } echo '<h1>' . CATEGORY_ADDRESS . '</h1>'; echo tep_label_input_jquery('street_address', '', ENTRY_STREET_ADDRESS . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_STREET_ADDRESS_TEXT . '</span>': '')); if (ACCOUNT_SUBURB == 'true') { echo tep_label_input_jquery('suburb', '', ENTRY_SUBURB . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_SUBURB_TEXT . '</span>': '')); } echo tep_label_input_jquery('postcode', '', ENTRY_POST_CODE . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_POST_CODE_TEXT . '</span>': '')); echo tep_label_input_jquery('city', '', ENTRY_CITY . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_CITY_TEXT . '</span>': '')); echo tep_label_get_country_list_jquery('country', $country, ENTRY_COUNTRY . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_COUNTRY_TEXT . '</span>': ''), '', 'a', 'onChange="getStates(this.value, \'states\');" data-mini="true"'); if (ACCOUNT_STATE == 'true') { // Country-State Selector echo '<div id="states">' . tep_ajax_get_zones_html($country,'',false) . '</div>'; } echo tep_label_input_jquery('telephone', '', ENTRY_TELEPHONE_NUMBER . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''), 'a', '', 'tel'); echo tep_label_input_jquery('fax', '', ENTRY_FAX_NUMBER . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''), 'a', '', 'tel');?> <?php // PWA for IosC BOF if (!isset($HTTP_GET_VARS['guest']) && !isset($HTTP_POST_VARS['guest'])) { // PWA for IosC EOF ?> <?php echo '<h1>' . CATEGORY_PASSWORD . '</h1>'; echo tep_label_password_jquery('password','', ENTRY_PASSWORD . (tep_not_null(ENTRY_PASSWORD_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_PASSWORD_TEXT . '</span>': '')); echo tep_label_password_jquery('confirmation','', ENTRY_PASSWORD_CONFIRMATION . (tep_not_null(ENTRY_PASSWORD_CONFIRMATION_TEXT) ? '<span class="inputRequirement"> ' . ENTRY_PASSWORD_CONFIRMATION_TEXT . '</span>': '')); echo '<h1>' . CATEGORY_OPTIONS . '</h1>'; echo '<fieldset data-role="controlgroup"> ' . tep_checkbox_jquery('newsletter', false, 'a', 1, $option = '' ) . ' <label for="newsletter">' . ENTRY_NEWSLETTER . '</label> </fieldset>'; ?> <div id="bouton"><?php // PWA for IosC BOF } else { echo tep_draw_hidden_field('guest', 'guest'); } // PWA for IosC EOF ?> <?php echo tep_button_jquery( IMAGE_BUTTON_CREATE_ACCOUNT , '', 'b' , 'submit' , 'data-iconpos="right" data-icon="check" data-inline="true"' ); ?> </div> </div> </form> <?php if( JQUERY_MOBILE_VALIDATE == 'True') { require(DIR_MOBILE_INCLUDES. 'form_check.js.php'); } else { require(DIR_WS_INCLUDES . 'form_check.js.php'); } // Country-State Selector require(DIR_MOBILE_INCLUDES . 'country_state_ajax.js.php'); require(DIR_MOBILE_INCLUDES . 'footer.php'); // Country-State Selector } ?>
  6. I understand that the javascript needs to be in jquery form, but I do not know how to do this. When I modify the code for checkout_shipping.php I can view the page on my phone, but it has a bunch of code from the php page at the top. The radio buttons and shipping quote show but it will not allow me to select them or select the continue button. If anyone could help out with a conversion I would appreciate it.
  7. I think I'm close to doing it, but I got stopped with an error in Mobile/checkout_shipping.php. Here is the modified code so far.. <?php require_once('includes/application_top.php'); require(DIR_WS_CLASSES.'http_client.php'); // if the customer is not logged on, redirect them to the login page if (!tep_session_is_registered('customer_id')) { $navigation->set_snapshot(); tep_redirect(tep_mobile_link(FILENAME_LOGIN, '', 'SSL')); } // if there is nothing in the customers cart, redirect them to the shopping cart page if ($cart->count_contents() < 1) { tep_redirect(tep_mobile_link(FILENAME_SHOPPING_CART)); } // if no shipping destination address was selected, use the customers own address as default if (!tep_session_is_registered('sendto')) { tep_session_register('sendto'); $sendto = $customer_default_address_id; } else { // verify the selected shipping address if ( (is_array($sendto) && empty($sendto)) || is_numeric($sendto) ) { $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'"); $check_address = tep_db_fetch_array($check_address_query); if ($check_address['total'] != '1') { $sendto = $customer_default_address_id; if (tep_session_is_registered('shipping')) tep_session_unregister('shipping'); } } } require(DIR_WS_CLASSES . 'order.php'); $order = new order; // register a random ID in the session to check throughout the checkout procedure // against alterations in the shopping cart contents if (!tep_session_is_registered('cartID')) { tep_session_register('cartID'); } elseif (($cartID != $cart->cartID) && tep_session_is_registered('shipping')) { tep_session_unregister('shipping'); } $cartID = $cart->cartID = $cart->generate_cart_id(); // if the order contains only virtual products, forward the customer to the billing page as // a shipping address is not needed if ($order->content_type == 'virtual') { if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); $shipping = false; $sendto = false; tep_redirect(tep_mobile_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } //MVS Start if (SELECT_VENDOR_SHIPPING == 'true') { include(DIR_WS_CLASSES . 'vendor_shipping.php'); $shipping_modules = new shipping; } else { // MVS End $total_weight = $cart->show_weight(); $total_count = $cart->count_contents(); // load all enabled shipping modules require(DIR_WS_CLASSES . 'shipping.php'); $shipping_modules = new shipping; if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) { $pass = false; switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { case 'national': if ($order->delivery['country_id'] == STORE_COUNTRY) { $pass = true; } break; case 'international': if ($order->delivery['country_id'] != STORE_COUNTRY) { $pass = true; } break; case 'both': $pass = true; break; } $free_shipping = false; if ( ($pass == true) && ($order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) { $free_shipping = true; include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php'); } } else { $free_shipping = false; } // process the selected shipping method if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) { if (!tep_session_is_registered('comments')) tep_session_register('comments'); if (tep_not_null($HTTP_POST_VARS['comments'])) { $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']); } if (!tep_session_is_registered('shipping')) tep_session_register('shipping'); // MVS Start if (SELECT_VENDOR_SHIPPING == 'true') { $total_shipping_cost = 0; $shipping_title = MULTIPLE_SHIP_METHODS_TITLE; $vendor_shipping = $cart->vendor_shipping; $shipping = array(); foreach ($vendor_shipping as $vendor_id => $vendor_data) { $products_shipped = $_POST['products_' . $vendor_id]; $products_array = explode ("_", $products_shipped); $shipping_data = $_POST['shipping_' . $vendor_id]; $shipping_array = explode ("_", $shipping_data); $module = $shipping_array[0]; $method = $shipping_array[1]; $ship_tax = $shipping_array[2]; if ( is_object($$module) || ($module == 'free') ) { if ($module == 'free') { $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE; $quote[0]['methods'][0]['cost'] = '0'; } else { $total_weight = $vendor_shipping[$vendor_id]['weight']; $shipping_weight = $total_weight; $cost = $vendor_shipping[$vendor_id]['cost']; $total_count = $vendor_shipping[$vendor_id]['qty']; $quote = $shipping_modules->quote($method, $module, $vendor_id); } if (isset($quote['error'])) { tep_session_unregister('shipping'); } else { if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) { $output[$vendor_id] = array('id' => $module . '_' . $method, 'title' => $quote[0]['methods'][0]['title'], 'ship_tax' => $ship_tax, 'products' => $products_array, 'cost' => $quote[0]['methods'][0]['cost'] ); $total_ship_tax += $ship_tax; $total_shipping_cost += $quote[0]['methods'][0]['cost']; }//if isset }//if isset }//if is_object }//foreach if ($free_shipping == true) { $shipping_title = $quote[0]['module']; } elseif (count($output) <2) { $shipping_title = $quote[0]['methods'][0]['title']; } $shipping = array('id' => $shipping, 'title' => $shipping_title, 'cost' => $total_shipping_cost, 'shipping_tax_total' => $total_ship_tax, 'vendor' => $output ); tep_redirect(tep_mobile_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } else { // MVS End if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) { if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) { $shipping = $HTTP_POST_VARS['shipping']; list($module, $method) = explode('_', $shipping); if ( is_object($$module) || ($shipping == 'free_free') ) { if ($shipping == 'free_free') { $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE; $quote[0]['methods'][0]['cost'] = '0'; } else { $quote = $shipping_modules->quote($method, $module); } if (isset ($quote['error']) ) { tep_session_unregister('shipping'); } else { if ( (isset($quote[0]['methods'][0]['title']) ) && (isset($quote[0]['methods'][0]['cost'])) ) { $shipping = array('id' => $shipping, 'title' => ( ($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'), 'cost' => $quote[0]['methods'][0]['cost']); tep_redirect(tep_mobile_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } } } else { tep_session_unregister ('shipping'); } } } else { $shipping = false; tep_redirect(tep_mobile_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); } // MVS } } // get all available shipping quotes $quotes = $shipping_modules->quote(); // if no shipping method has been selected, automatically select the cheapest method. // if the modules status was changed when none were available, to save on implementing // a javascript force-selection method, also automatically select the cheapest shipping // method if more than one module is now enabled if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest(); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SHIPPING); $breadcrumb->add(NAVBAR_TITLE_1, tep_mobile_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); $breadcrumb->add(NAVBAR_TITLE_2, tep_mobile_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); ?> require(DIR_MOBILE_INCLUDES . 'header.php'); $headerTitle->write(); <script language="javascript"><!-- <?php // MVS Start if (SELECT_VENDOR_SHIPPING == 'true') { ?> function selectRowEffect(object, buttonSelect, vendor) { var test='defaultSelected_' + vendor;//set aside defaultSelected_' . $vendor_id . ' var el=document.getElementsByTagName('tr');//all the tr elements for(var i=0;i<el.length;i++){ var p=el[i].id.replace(test,'').replace(/\d/g,'');//strip the $radio_buttons value if(p=='_'){//the only thing left is an underscore el[i].className = "moduleRow";//make the matching elements normal } } object.className = "moduleRowSelected";//override el[i].className and highlight the clicked row var field = document.getElementById('shipping_radio_' + buttonSelect + '_' + vendor); if (document.getElementById) { var field = document.getElementById('shipping_radio_' + buttonSelect + '_' + vendor); } else { var field = document.all['shipping_radio_' + buttonSelect + '_' + vendor]; } } <?php } else { // MVS End ?> var selected; function selectRowEffect(object, buttonSelect) { if (!selected) { if (document.getElementById) { selected = document.getElementById('defaultSelected'); } else { selected = document.all['defaultSelected']; } } if (selected) selected.className = 'moduleRow'; object.className = 'moduleRowSelected'; selected = object; // one button is not an array if (document.checkout_address.shipping[0]) { document.checkout_address.shipping[buttonSelect].checked=true; } else { document.checkout_address.shipping.checked=true; } } <?php // MVS } ?> function rowOverEffect(object) { if (object.className == 'moduleRow') object.className = 'moduleRowOver'; } function rowOutEffect(object) { if (object.className == 'moduleRowOver') object.className = 'moduleRow'; } //--></script> <div id="iphone_content"> <?php echo tep_draw_form('checkout_address', tep_mobile_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'), 'post', '', true) . tep_draw_hidden_field('action', 'process'); ?> <div id="checkout_shipping"> //MVS if (tep_count_shipping_modules() > 0 || SELECT_VENDOR_SHIPPING == 'true') { ?> <h1><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></h1> <br /> <?php // MVS Start if (SELECT_VENDOR_SHIPPING == 'true') { require(DIR_WS_MODULES . 'vendor_shipping.php'); } else { $quotes = $shipping_modules->quote(); if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') ) { $pass = false; switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { case 'national': if ($order->delivery['country_id'] == STORE_COUNTRY) { $pass = true; } break; case 'international': if ($order->delivery['country_id'] != STORE_COUNTRY) { $pass = true; } break; case 'both': $pass = true; break; } $free_shipping = false; if ( ($pass == true) && ($order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) { $free_shipping = true; include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php'); } } else { $free_shipping = false; } // if no shipping method has been selected, automatically select the cheapest method. // if the modules status was changed when none were available, to save on implementing // a javascript force-selection method, also automatically select the cheapest shipping // method if more than one module is now enabled if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest(); //MVS End ?> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <?php if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) { ?> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td class="main" width="50%" valign="top"><?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?></td> <td class="main" width="50%" valign="top" align="right"><?php echo '<b>' . TITLE_PLEASE_SELECT . '</b><br>' . tep_image(DIR_WS_IMAGES . 'arrow_east_south.gif'); ?></td> <td><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> <div class="ship_add"> <?php echo TEXT_CHOOSE_SHIPPING_METHOD; ?> <?php } elseif ($free_shipping == false) { ?> <div class="ship_add"> <?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?> <?php } echo '<fieldset data-role="controlgroup" data-theme="a" id ="custom-fieldset" >'; if ($free_shipping == true) { ?> <div class="ship_add"> <strong><?php echo FREE_SHIPPING_TITLE; ?></strong></br> <?php echo $quotes[$i]['icon']; echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field('shipping', 'free_free'); ?> </div> <?php } else { ?> <?php $radio_buttons = 0; for ($i=0, $n=sizeof($quotes); $i<$n; $i++) { if (isset($quotes[$i]['error'])) { echo $quotes[$i]['error']; } else { for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) { // set the radio button to be checked if it is the method chosen or only method $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id'] || $n == 1) ? true : false); echo tep_radio_jquery('shipping',$checked,'a',$quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'],'id="'.$quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'].'"') ; ?> <label for="<?php echo $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']?>"><?php echo $quotes[$i]['module'];?> - <?php echo $quotes[$i]['methods'][$j]['title'].' '; ?> <?php if ( ($n > 1) || ($n2 > 1) ) { echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))). '</label>'; ?> <?php } else { ?> <?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))) . '</label>'. tep_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?> <?php } ?> <?php $radio_buttons++; } } } echo '</fieldset>'; } ?> </div> <?php } ?> <hr /> <h1><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></h1> <div class="ship_add"> <?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br />'); echo tep_button_jquery(IMAGE_BUTTON_CHANGE_ADDRESS , tep_mobile_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'), 'b' , 'button' , 'data-icon="check" data-inline="false"' ); ?> </div> <?php ?> <hr /> <div class="bill_add"> <?php echo tep_label_textarea_jquery('comments', TABLE_HEADING_COMMENTS, '', '100px'); ?> </div> <div id="bouton"> <?php echo tep_button_jquery(IMAGE_BUTTON_BACK , tep_mobile_link(FILENAME_SHOPPING_CART, '', 'SSL'), 'b' , 'button' , 'data-icon="back" data-inline="true"' ); echo tep_button_jquery(IMAGE_BUTTON_CONTINUE , '', 'b' , 'submit' , ' data-icon="arrow-r" data-iconpos="right" data-inline="true"' ); ?> </div> </div> </form> <?php require(DIR_MOBILE_INCLUDES . 'footer.php'); ?> Any ideas where I went wrong?
  8. I did a search and came up empty. Has anyone ported this mod for Multi Vendor Shipping (MVS)?
  9. lyonsperf

    Google XML Sitemap SEO

    Here is the code <?php /** * Google XML Sitemap Feed * * The Google sitemap service was announced on 2 June 2005 and represents * a huge development in terms of crawler technology. This contribution is * designed to create the sitemap XML feed per the specification delineated * by Google. * @package Google-XML-Sitemap-Feed * @[member='licensed2kill'] http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.0 * @[member='Link'] http://www.oscommerce-freelancers.com/ osCommerce-Freelancers * @[member='Link'] http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap * @[member='copyright'] Copyright 2005, Bobby Easland * @[member='author'] Bobby Easland * @version 2.0 * @[member='Link'] http://www.eurobigstore.com * @[member='Link'] http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap * @[member='copyright'] Copyright 2006, Davide Duca * @[member='author'] Davide Duca * @filesource */ /** * MySQL_Database Class * * The MySQL_Database class provides abstraction so the databaes can be accessed * without having to use tep API functions. This class has minimal error handling * so make sure your code is tight! * @package Google-XML-Sitemap-Feed * @[member='licensed2kill'] http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.1 * @[member='Link'] http://www.oscommerce-freelancers.com/ osCommerce-Freelancers * @[member='copyright'] Copyright 2005, Bobby Easland * @[member='author'] Bobby Easland */ class MySQL_DataBase{ /** * Database host (localhost, IP based, etc) * @var string */ var $host; /** * Database user * @var string */ var $user; /** * Database name * @var string */ var $db; /** * Database password * @var string */ var $pass; /** * Database link * @var resource */ var $link_id; /** * MySQL_DataBase class constructor * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] string $host * @[member='param'] string $user * @[member='param'] string $db * @[member='param'] string $pass */ function MySQL_DataBase($host, $user, $db, $pass){ $this->host = $host; $this->user = $user; $this->db = $db; $this->pass = $pass; $this->ConnectDB(); $this->SelectDB(); } # end function /** * Function to connect to MySQL * @[member='author'] Bobby Easland * @version 1.0 */ function ConnectDB(){ $this->link_id = mysql_connect($this->host, $this->user, $this->pass); } # end function /** * Function to select the database * @[member='author'] Bobby Easland * @version 1.0 * @[member='Return'] resoource */ function SelectDB(){ return mysql_select_db($this->db); } # end function /** * Function to perform queries * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] string $query SQL statement * @[member='Return'] resource */ function Query($query){ return @mysql_query($query, $this->link_id); } # end function /** * Function to fetch array * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] resource $resource_id * @[member='param'] string $type MYSQL_BOTH or MYSQL_ASSOC * @[member='Return'] array */ function FetchArray($resource_id, $type = MYSQL_BOTH){ return @mysql_fetch_array($resource_id, $type); } # end function /** * Function to fetch the number of rows * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] resource $resource_id * @[member='Return'] mixed */ function NumRows($resource_id){ return @mysql_num_rows($resource_id); } # end function /** * Function to free the resource * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] resource $resource_id * @[member='Return'] boolean */ function Free($resource_id){ return @mysql_free_result($resource_id); } # end function /** * Function to add slashes * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] string $data * @[member='Return'] string */ function Slashes($data){ return addslashes($data); } # end function /** * Function to perform DB inserts and updates - abstracted from osCommerce-MS-2.2 project * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] string $table Database table * @[member='param'] array $data Associative array of columns / values * @[member='param'] string $action insert or update * @[member='param'] string $parameters * @[member='Return'] resource */ function DBPerform($table, $data, $action = 'insert', $parameters = '') { reset($data); if ($action == 'insert') { $query = 'INSERT INTO `' . $table . '` ('; while (list($columns, ) = each($data)) { $query .= '`' . $columns . '`, '; } $query = substr($query, 0, -2) . ') values ('; reset($data); while (list(, $value) = each($data)) { switch ((string)$value) { case 'now()': $query .= 'now(), '; break; case 'null': $query .= 'null, '; break; default: $query .= "'" . $this->Slashes($value) . "', "; break; } } $query = substr($query, 0, -2) . ')'; } elseif ($action == 'update') { $query = 'UPDATE `' . $table . '` SET '; while (list($columns, $value) = each($data)) { switch ((string)$value) { case 'now()': $query .= '`' .$columns . '`=now(), '; break; case 'null': $query .= '`' .$columns .= '`=null, '; break; default: $query .= '`' .$columns . "`='" . $this->Slashes($value) . "', "; break; } } $query = substr($query, 0, -2) . ' WHERE ' . $parameters; } return $this->Query($query); } # end function } # end class /** * Google Sitemap Base Class * * The MySQL_Database class provides abstraction so the databaes can be accessed * @package Google-XML-Sitemap-Feed * @[member='licensed2kill'] http://opensource.org/licenses/gpl-license.php GNU Public License * @version 1.2 * @[member='Link'] http://www.oscommerce-freelancers.com/ osCommerce-Freelancers * @[member='Link'] http://www.google.com/webmasters/sitemaps/docs/en/about.html About Google Sitemap * @[member='copyright'] Copyright 2005, Bobby Easland * @[member='author'] Bobby Easland */ class GoogleSitemap{ /** * $DB is the database object * @var object */ var $DB; /** * $filename is the base name of the feeds (i.e. - 'sitemap') * @var string */ var $filename; /** * $savepath is the path where the feeds will be saved - store root * @var string */ var $savepath; /** * $base_url is the URL for the catalog * @var string */ var $base_url; /** * $debug holds all the debug data * @var array */ var $debug; /** * GoogleSitemap class constructor * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] string $host Database host setting (i.e. - localhost) * @[member='param'] string $user Database user * @[member='param'] string $db Database name * @[member='param'] string $pass Database password */ function GoogleSitemap($host, $user, $db, $pass){ $this->DB = new MySQL_Database($host, $user, $db, $pass); $this->filename = "sitemap"; $this->savepath = DIR_FS_CATALOG; $this->base_url = HTTP_SERVER . DIR_WS_HTTP_CATALOG; $this->debug = array(); } # end class constructor /** * Function to save the sitemap data to file as either XML or XML.GZ format * @[member='author'] Bobby Easland * @version 1.1 * @[member='param'] string $data XML data * @[member='param'] string $type Feed type (index, products, categories) * @[member='Return'] boolean */ function SaveFile($data, $type){ $filename = $this->savepath . '/' . $this->filename . $type; $compress = defined('GOOGLE_SITEMAP_COMPRESS') ? GOOGLE_SITEMAP_COMPRESS : 'false'; if ($type == 'index') $compress = 'false'; switch($compress){ case 'true': $filename .= '.xml.gz'; if ($gz = gzopen($filename,'wb9')){ gzwrite($gz, $data); gzclose($gz); $this->debug['SAVE_FILE_COMPRESS'][] = array('file' => $filename, 'status' => 'success', 'file_exists' => 'true'); return true; } else { $file_check = file_exists($filename) ? 'true' : 'false'; $this->debug['SAVE_FILE_COMPRESS'][] = array('file' => $filename, 'status' => 'failure', 'file_exists' => $file_check); return false; } break; default: $filename .= '.xml'; if ($fp = fopen($filename, 'w+')){ fwrite($fp, $data); fclose($fp); $this->debug['SAVE_FILE_XML'][] = array('file' => $filename, 'status' => 'success', 'file_exists' => 'true'); return true; } else { $file_check = file_exists($filename) ? 'true' : 'false'; $this->debug['SAVE_FILE_XML'][] = array('file' => $filename, 'status' => 'failure', 'file_exists' => $file_check); return false; } break; } # end switch } # end function /** * Function to compress a normal file * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] string $file * @[member='Return'] boolean */ function CompressFile($file){ $source = $this->savepath . $file . '.xml'; $filename = $this->savepath . $file . '.xml.gz'; $error_encountered = false; if( $gz_out = gzopen($filename, 'wb9') ){ if($fp_in = fopen($source,'rb')){ while(!feof($fp_in)) gzwrite($gz_out, fread($fp_in, 1024*512)); fclose($fp_in); } else { $error_encountered = true; } gzclose($gz_out); } else { $error_encountered = true; } if($error_encountered){ return false; } else { return true; } } # end function /** * Function to generate sitemap file from data * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] array $data * @[member='param'] string $file * @[member='Return'] boolean */ function GenerateSitemap($data, $file){ $content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $content = '<?xml-stylesheet type="text/xsl" href="gss.xsl"?>' . "\n"; $content .= '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n"; foreach ($data as $url){ $content .= "\t" . '<url>' . "\n"; $content .= "\t\t" . '<loc>'.$url['loc'].'</loc>' . "\n"; $content .= "\t\t" . '<lastmod>'.$url['lastmod'].'</lastmod>' . "\n"; $content .= "\t\t" . '<changefreq>'.$url['changefreq'].'</changefreq>' . "\n"; $content .= "\t\t" . '<priority>'.$url['priority'].'</priority>' . "\n"; $content .= "\t" . '</url>' . "\n"; } # end foreach $content .= '</urlset>'; return $this->SaveFile($content, $file); } # end function /** * Function to generate sitemap index file * @[member='author'] Bobby Easland * @version 1.1 * @[member='Return'] boolean */ function GenerateSitemapIndex(){ $content = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $content = '<?xml-stylesheet type="text/xsl" href="gss.xsl"?>' . "\n"; $content .= '<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n"; $pattern = defined('GOOGLE_SITEMAP_COMPRESS') ? GOOGLE_SITEMAP_COMPRESS == 'true' ? "sitemap*.xml.gz" : "sitemap*.xml" : "sitemap*.xml"; foreach ( array_merge(glob($this->savepath . $pattern)) as $filename ) { if ( eregi('index', $filename) ) continue; $content .= "\t" . '<sitemap>' . "\n"; $content .= "\t\t" . '<loc>'.$this->base_url . basename($filename).'</loc>' . "\n"; $content .= "\t\t" . '<lastmod>'.date ("Y-m-d", filemtime($filename)).'</lastmod>' . "\n"; $content .= "\t" . '</sitemap>' . "\n"; } # end foreach $content .= '</sitemapindex>'; return $this->SaveFile($content, 'index'); } # end function /** * Function to generate product sitemap data * @[member='author'] Bobby Easland * @version 1.1 * @[member='Return'] boolean */ function GenerateProductSitemap(){ $sql = "SELECT products_id as pID, products_date_added as date_added, products_last_modified as last_mod, products_ordered FROM " . TABLE_PRODUCTS . " WHERE products_status='1' ORDER BY products_ordered DESC"; if ( $products_query = $this->DB->Query($sql) ){ $this->debug['QUERY']['PRODUCTS']['STATUS'] = 'success'; $this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = $this->DB->NumRows($products_query); $container = array(); $number = 0; $top = 0; while( $result = $this->DB->FetchArray($products_query) ){ $top = max($top, $result['products_ordered']); //$location = $this->hrefLink('product' . $result['pID'] . FILENAME_PRODUCT_INFO, 'source=google', 'NONSSL', false); $location = $this->hrefLink(FILENAME_PRODUCT_INFO, 'products_id=' . $result['pID'], 'NONSSL', false); $lastmod = $this->NotNull($result['last_mod']) ? $result['last_mod'] : $result['date_added']; $changefreq = GOOGLE_SITEMAP_PROD_CHANGE_FREQ; $ratio = $top > 0 ? $result['products_ordered']/$top : 0; $priority = $ratio < .1 ? .1 : number_format($ratio, 1, '.', ''); $container[] = array('loc' => htmlspecialchars(utf8_encode($location)), 'lastmod' => date ("Y-m-d", strtotime($lastmod)), 'changefreq' => $changefreq, 'priority' => $priority ); if ( sizeof($container) >= 50000 ){ $type = $number == 0 ? 'products' : 'products' . $number; $this->GenerateSitemap($container, $type); $container = array(); $number++; } } # end while $this->DB->Free($products_query); if ( sizeof($container) > 1 ) { $type = $number == 0 ? 'products' : 'products' . $number; return $this->GenerateSitemap($container, $type); } # end if } else { $this->debug['QUERY']['PRODUCTS']['STATUS'] = 'false'; $this->debug['QUERY']['PRODUCTS']['NUM_ROWS'] = '0'; } } # end function /** * Funciton to generate category sitemap data * @[member='author'] Bobby Easland * @version 1.1 * @[member='Return'] boolean */ function GenerateCategorySitemap(){ $sql = "SELECT categories_id as cID, date_added, last_modified as last_mod FROM " . TABLE_CATEGORIES . " ORDER BY parent_id ASC, sort_order ASC, categories_id ASC"; if ( $categories_query = $this->DB->Query($sql) ){ $this->debug['QUERY']['CATEOGRY']['STATUS'] = 'success'; $this->debug['QUERY']['CATEOGRY']['NUM_ROWS'] = $this->DB->NumRows($categories_query); $container = array(); $number = 0; while( $result = $this->DB->FetchArray($categories_query) ){ //$location = $this->hrefLink('category' . $this->GetFullcPath($result['cID']) . FILENAME_DEFAULT, 'source=google', 'NONSSL', false); $location = $this->hrefLink(FILENAME_DEFAULT, 'cPath=' . $this->GetFullcPath($result['cID']), 'NONSSL', false); $lastmod = $this->NotNull($result['last_mod']) ? $result['last_mod'] : $result['date_added']; $changefreq = GOOGLE_SITEMAP_CAT_CHANGE_FREQ; $priority = .5; $container[] = array('loc' => htmlspecialchars(utf8_encode($location)), 'lastmod' => date ("Y-m-d", strtotime($lastmod)), 'changefreq' => $changefreq, 'priority' => $priority ); if ( sizeof($container) >= 50000 ){ $type = $number == 0 ? 'categories' : 'categories' . $number; $this->GenerateSitemap($container, $type); $container = array(); $number++; } } # end while $this->DB->Free($categories_query); if ( sizeof($container) > 1 ) { $type = $number == 0 ? 'categories' : 'categories' . $number; return $this->GenerateSitemap($container, $type); } # end if } else { $this->debug['QUERY']['CATEOGRY']['STATUS'] = 'false'; $this->debug['QUERY']['CATEOGRY']['NUM_ROWS'] = '0'; } } # end function /** * Function to retrieve full cPath from category ID * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] mixed $cID Could contain cPath or single category_id * @[member='Return'] string Full cPath string */ function GetFullcPath($cID){ if ( ereg('_', $cID) ){ return $cID; } else { $c = array(); $this->GetParentCategories($c, $cID); $c = array_reverse($c); $c[] = $cID; $cID = sizeof($c) > 1 ? implode('_', $c) : $cID; return $cID; } } # end function /** * Recursion function to retrieve parent categories from category ID * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] mixed $categories Passed by reference * @[member='param'] integer $categories_id */ function GetParentCategories(&$categories, $categories_id) { $sql = "SELECT parent_id FROM " . TABLE_CATEGORIES . " WHERE categories_id='" . (int)$categories_id . "'"; $parent_categories_query = $this->DB->Query($sql); while ($parent_categories = $this->DB->FetchArray($parent_categories_query)) { if ($parent_categories['parent_id'] == 0) return true; $categories[sizeof($categories)] = $parent_categories['parent_id']; if ($parent_categories['parent_id'] != $categories_id) { $this->GetParentCategories($categories, $parent_categories['parent_id']); } } } # end function /** * Function to check if a value is NULL * @[member='author'] Bobby Easland as abstracted from osCommerce-MS2.2 * @version 1.0 * @[member='param'] mixed $value * @[member='Return'] boolean */ function NotNull($value) { if (is_array($value)) { if (sizeof($value) > 0) { return true; } else { return false; } } else { if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) { return true; } else { return false; } } } # end function /** * Function to return href_link * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] mixed $value * @[member='Return'] boolean */ function hrefLink($page, $parameters, $connection, $add_session_id) { //if ( defined('SEO_URLS') && SEO_URLS == 'true' || defined('SEO_ENABLED') && SEO_ENABLED == 'true' ) { if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') ) { return tep_href_link($page, $parameters, $connection, $add_session_id); } else { return $this->base_url . $page . '?' . $parameters; } } # end function /** * Utility function to read and return the contents of a GZ formatted file * @[member='author'] Bobby Easland * @version 1.0 * @[member='param'] string $file File to open * @[member='Return'] string */ function ReadGZ( $file ){ $file = $this->savepath . $file; $lines = gzfile($file); return implode('', $lines); } # end function /** * Utility function to generate the submit URL * @[member='author'] Bobby Easland * @version 1.0 * @[member='Return'] string */ function GenerateSubmitURL(){ $url = urlencode($this->base_url . 'sitemapindex.xml'); return htmlspecialchars(utf8_encode('http://www.google.com/webmasters/sitemaps/ping?sitemap=' . $url)); } # end function } # end class ?>
  10. lyonsperf

    Google XML Sitemap SEO

    I changed the lastmod to "Y-m-d" and got the following response: An invalid date was found. Please fix the date or formatting before resubmitting. Parent tag: url Tag: lastmod Value: -0001-11-30 Why is the year appearing like that?
  11. lyonsperf

    Google XML Sitemap SEO

    Got a warning from google that 1,214 urls from my sitemap have: An invalid date was found. Please fix the date or formatting before resubmitting. This is what they are seeing: Parent tag: url Tag: lastmod Value: 2014201420142014-JanJan-SatSatEST0606:0101EST-18000Sat what is the correct format for these values? Where do I change them?
  12. lyonsperf

    USPS Rate V4, Intl Rate V2 (official support thread)

    Can someone please post the entire usps.php file so I can compare and port for mvs?
  13. lyonsperf

    USPS Rate V4, Intl Rate V2 (official support thread)

    yeah this is definitely and issue. I changed the code as posted by Jim, thanks for doing that, and it removed the bold error warnings from my site but it now has bypassed showing usps quotes and defaults to ups which is my secondary choice. At least customers won't be shown an error, just higher shipping. where would I go to submit an code complaint to usps?
  14. BTW, those css files are difficult to modify because they are minified.
×