} if ($mode == 'customer_info') { $redirect_params = array(); $cart['guest_checkout'] = !empty($_REQUEST['guest_checkout']); if (Registry::get('settings.Checkout.disable_anonymous_checkout') == 'Y' && empty($cart['user_data']['email']) && fn_image_verification('checkout', $_REQUEST) == false) { fn_save_post_data('user_data'); return array(CONTROLLER_STATUS_REDIRECT, 'checkout.checkout?login_type=guest'); } $profile_fields = fn_get_profile_fields('O'); $user_profile = array(); if (!empty($_REQUEST['user_data'])) { if (empty($auth['user_id']) && !empty($_REQUEST['user_data']['email'])) { $email_exists = fn_is_user_exists(0, $_REQUEST['user_data']); if (!empty($email_exists)) { fn_set_notification('E', __('error'), __('error_user_exists')); fn_save_post_data('user_data'); return array(CONTROLLER_STATUS_REDIRECT, 'checkout.checkout'); } } $user_data = $_REQUEST['user_data']; unset($user_data['user_type']); if (!empty($cart['user_data'])) { $cart['user_data'] = fn_array_merge($cart['user_data'], $user_data); } else { $cart['user_data'] = $user_data; } // Fill shipping info with billing if needed if (empty($_REQUEST['ship_to_another'])) { fn_fill_address($cart['user_data'], $profile_fields); } // Add descriptions for countries and states
* license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'send_form') { $suffix = ''; if (fn_image_verification('use_for_form_builder', $_REQUEST) == false) { fn_save_post_data('form_values'); return array(CONTROLLER_STATUS_REDIRECT, "pages.view?page_id={$_REQUEST['page_id']}"); } if (fn_send_form($_REQUEST['page_id'], empty($_REQUEST['form_values']) ? array() : $_REQUEST['form_values'])) { $suffix = '&sent=Y'; } return array(CONTROLLER_STATUS_OK, "pages.view?page_id={$_REQUEST['page_id']}" . $suffix); } return; } if ($mode == 'view' && !empty($_REQUEST['page_id'])) { $page_is_https = db_get_field("SELECT value FROM ?:form_options WHERE element_type = ?s AND page_id = ?i", FORM_IS_SECURE, $_REQUEST['page_id']); // if form is secure, redirect to https connection if (!defined('HTTPS') && $page_is_https == 'Y') { return array(CONTROLLER_STATUS_REDIRECT, Registry::get('config.https_location') . '/' . Registry::get('config.current_url')); } elseif (defined('HTTPS') && Registry::get('settings.Security.keep_https') != 'Y' && $page_is_https != 'Y') {
* license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; use Tygh\Mailer; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'send') { if (fn_image_verification('use_for_email_share', $_REQUEST) == false) { fn_save_post_data('send_data'); return array(CONTROLLER_STATUS_REDIRECT); } if (!empty($_REQUEST['send_data']['to_email'])) { $lnk = fn_url(Registry::get('config.current_url')); $redirect_url = fn_query_remove($_REQUEST['redirect_url'], 'selected_section'); $index_script = Registry::get('config.customer_index'); if (strpos($lnk, $index_script) !== false) { $redirect_url = str_replace($index_script, '', $redirect_url); } $lnk .= $redirect_url; $from = array('email' => !empty($_REQUEST['send_data']['from_email']) ? $_REQUEST['send_data']['from_email'] : Registry::get('settings.Company.company_users_department'), 'name' => !empty($_REQUEST['send_data']['from_name']) ? $_REQUEST['send_data']['from_name'] : Registry::get('settings.Company.company_name')); $mail_sent = Mailer::sendMail(array('to' => $_REQUEST['send_data']['to_email'], 'from' => $from, 'data' => array('link' => $lnk, 'send_data' => $_REQUEST['send_data']), 'tpl' => 'addons/social_buttons/mail.tpl'), 'C'); if ($mail_sent == true) { fn_set_notification('N', __('notice'), __('text_email_sent')); }
} else { fn_save_post_data('company_data', 'update'); } } if (fn_allowed_for('ULTIMATE') && !empty($company_id)) { fn_ult_set_company_settings_information($_REQUEST['update'], $company_id); } } // // Processing updating of company element // if ($mode == 'update') { if (!empty($_REQUEST['company_data']['company'])) { if (!empty($_REQUEST['company_id']) && Registry::get('runtime.company_id') && Registry::get('runtime.company_id') != $_REQUEST['company_id']) { fn_company_access_denied_notification(); fn_save_post_data('company_data', 'update'); } else { // Updating company record fn_update_company($_REQUEST['company_data'], $_REQUEST['company_id'], DESCR_SL); } if (fn_allowed_for('ULTIMATE') && !empty($_REQUEST['company_id'])) { fn_ult_set_company_settings_information($_REQUEST['update'], $_REQUEST['company_id']); fn_clear_cache('registry'); // clean up block cache to re-generate storefront urls } } $suffix = ".update?company_id={$_REQUEST['company_id']}"; } if ($mode == 'm_delete') { if (!empty($_REQUEST['company_ids'])) { foreach ($_REQUEST['company_ids'] as $v) {
function fn_email_is_blocked($user_data, $reset_email = false) { $auth =& $_SESSION['auth']; $email = trim($user_data['email']); if (!fn_validate_email($email, false)) { return false; } $restricted = db_get_field("SELECT COUNT(*) FROM ?:access_restriction WHERE type IN ('ed', 'es') AND status = 'A' AND ?s LIKE REPLACE(REPLACE(REPLACE(value, '_', '\\_'), '?', '_'), '*', '%')", $email); if (!empty($restricted)) { if ($reset_email && $auth) { $uid = AREA == 'C' || AREA == 'P' || empty($_REQUEST['user_id']) ? $auth['user_id'] : $_REQUEST['user_id']; $_POST['user_data']['email'] = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $uid); } fn_save_post_data(); fn_set_notification('E', fn_get_lang_var('error'), str_replace('[email]', $user_data['email'], fn_get_lang_var('text_email_is_blocked'))); return true; } return false; }
use Tygh\Registry; use Tygh\Pdf; use RusPostBlank\RusPostBlank; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'print') { if (!empty($_REQUEST['order_id'])) { $order_id = $_REQUEST['order_id']; $order_info = fn_get_order_info($order_id, false, true, false, true); if (empty($order_info)) { exit; } $view = Tygh::$app['view']; fn_save_post_data('blank_data'); $lang_code = 'ru'; $params = $_REQUEST['blank_data']; $total_declared = ''; if (!empty($params['total_cen'])) { $total_declared = $params['total_cen']; } $params['total_declared'] = $total_declared; list($total_declared, $params['declared_rub'], $params['declared_kop']) = fn_rus_postblank_rub_kop_price($total_declared); $total_imposed = ''; if (!empty($params['total_cod'])) { $total_imposed = $params['total_cod']; } $params['total_imposed'] = $total_imposed; list($total_imposed, $params['imposed_rub'], $params['imposed_kop']) = fn_rus_postblank_rub_kop_price($total_imposed); if (!empty($params['imposed_total']) && $params['imposed_total'] == 'Y') {
function fn_update_company($company_data, $company_id = 0, $lang_code = CART_LANGUAGE) { $_data = $company_data; // Check if company with same email already exists $is_exist = db_get_field("SELECT email FROM ?:companies WHERE email = ?s AND company_id != ?i", $_data['email'], $company_id); if (!empty($is_exist)) { fn_save_post_data(); $_text = PRODUCT_TYPE == 'MULTIVENDOR' ? 'error_vendor_exists' : 'error_supplier_exists'; fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var($_text)); return false; } $_data['shippings'] = empty($company_data['shippings']) ? '' : fn_create_set($company_data['shippings']); // add new company if (empty($company_id)) { // company title can't be empty if (empty($company_data['company'])) { return false; } $company_id = db_query("INSERT INTO ?:companies ?e", $_data); if (empty($company_id)) { return false; } $old_logos = array(); // Adding same company descriptions for all cart languages $_data = array('company_id' => $company_id, 'company_description' => !empty($company_data['company_description']) ? $company_data['company_description'] : ''); if (PRODUCT_TYPE == 'MULTIVENDOR') { foreach ((array) Registry::get('languages') as $_data['lang_code'] => $_v) { db_query("INSERT INTO ?:company_descriptions ?e", $_data); } } // update product } else { if (isset($company_data['company']) && empty($company_data['company'])) { unset($company_data['company']); } db_query("UPDATE ?:companies SET ?u WHERE company_id = ?i", $_data, $company_id); $old_logos = db_get_field("SELECT logos FROM ?:companies WHERE company_id = ?i", $company_id); $old_logos = !empty($old_logos) ? unserialize($old_logos) : array(); if (PRODUCT_TYPE == 'MULTIVENDOR') { // Updating company description $descr = !empty($company_data['company_description']) ? $company_data['company_description'] : ''; db_query("UPDATE ?:company_descriptions SET company_description = ?s WHERE company_id = ?i AND lang_code = ?s", $descr, $company_id, DESCR_SL); } } // Do not upload logo if a dummy company is being added. if (!empty($_data['email'])) { fn_companies_update_logos($company_id, $old_logos); } /* if (empty($product_id)) { $create = true; // product title can't be empty if(empty($product_data['product'])) { return false; } $product_id = db_query("INSERT INTO ?:products ?e", $_data); if (empty($product_id)) { return false; } // // Adding same product descriptions for all cart languages // $_data = $product_data; $_data['product_id'] = $product_id; $_data['product'] = trim($_data['product'], " -"); foreach ((array)Registry::get('languages') as $_data['lang_code'] => $_v) { db_query("INSERT INTO ?:product_descriptions ?e", $_data); } // update product } else { if (isset($product_data['product']) && empty($product_data['product'])) { unset($product_data['product']); } db_query("UPDATE ?:products SET ?u WHERE product_id = ?i", $_data, $product_id); $_data = $product_data; if (!empty($_data['product'])){ $_data['product'] = trim($_data['product'], " -"); } db_query("UPDATE ?:product_descriptions SET ?u WHERE product_id = ?i AND lang_code = ?s", $_data, $product_id, $lang_code); } // Log product add/update fn_log_event('products', !empty($create) ? 'create' : 'update', array( 'product_id' => $product_id )); if (!empty($product_data['product_features'])) { $i_data = array( 'product_id' => $product_id, 'lang_code' => $lang_code ); foreach ($product_data['product_features'] as $feature_id => $value) { // Check if feature is applicable for this product $id_paths = db_get_fields("SELECT ?:categories.id_path FROM ?:products_categories LEFT JOIN ?:categories ON ?:categories.category_id = ?:products_categories.category_id WHERE product_id = ?i", $product_id); $_params = array( 'category_ids' => array_unique(explode('/', implode('/', $id_paths))), 'feature_id' => $feature_id ); list($_feature) = fn_get_product_features($_params); if (empty($_feature)) { $_feature = db_get_field("SELECT description FROM ?:product_features_descriptions WHERE feature_id = ?i AND lang_code = ?s", $feature_id, CART_LANGUAGE); $_product = db_get_field("SELECT product FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $product_id, CART_LANGUAGE); fn_set_notification('E', fn_get_lang_var('error'), str_replace(array('[feature_name]', '[product_name]'), array($_feature, $_product), fn_get_lang_var('product_feature_cannot_assigned'))); continue; } $i_data['feature_id'] = $feature_id; unset($i_data['value']); unset($i_data['variant_id']); unset($i_data['value_int']); $feature_type = db_get_field("SELECT feature_type FROM ?:product_features WHERE feature_id = ?i", $feature_id); // Delete variants in current language if ($feature_type == 'T') { db_query("DELETE FROM ?:product_features_values WHERE feature_id = ?i AND product_id = ?i AND lang_code = ?s", $feature_id, $product_id, $lang_code); } else { db_query("DELETE FROM ?:product_features_values WHERE feature_id = ?i AND product_id = ?i", $feature_id, $product_id); } if ($feature_type == 'D') { $i_data['value_int'] = fn_parse_date($value); } elseif ($feature_type == 'M') { if (!empty($product_data['add_new_variant'][$feature_id]['variant'])) { $value = empty($value) ? array() : $value; $value[] = fn_add_feature_variant($feature_id, $product_data['add_new_variant'][$feature_id]); } if (!empty($value)) { foreach ($value as $variant_id) { foreach (Registry::get('languages') as $i_data['lang_code'] => $_d) { // insert for all languages $i_data['variant_id'] = $variant_id; db_query("REPLACE INTO ?:product_features_values ?e", $i_data); } } } continue; } elseif (in_array($feature_type, array('S', 'N', 'E'))) { if (!empty($product_data['add_new_variant'][$feature_id]['variant'])) { $i_data['variant_id'] = fn_add_feature_variant($feature_id, $product_data['add_new_variant'][$feature_id]); } elseif (!empty($value) && $value != 'disable_select') { if ($feature_type == 'N') { $i_data['value_int'] = db_get_field("SELECT variant FROM ?:product_feature_variant_descriptions WHERE variant_id = ?i AND lang_code = ?s", $value, CART_LANGUAGE); } $i_data['variant_id'] = $value; } else { continue; } } else { if ($value == '') { continue; } if ($feature_type == 'O') { $i_data['value_int'] = $value; } else { $i_data['value'] = $value; } } if ($feature_type != 'T') { // feature values are common for all languages, except text (T) foreach (Registry::get('languages') as $i_data['lang_code'] => $_d) { db_query("REPLACE INTO ?:product_features_values ?e", $i_data); } } else { // for text feature, update current language only $i_data['lang_code'] = $lang_code; db_query("INSERT INTO ?:product_features_values ?e", $i_data); } } } // Update product prices if (isset($product_data['price'])) { if (!isset($product_data['prices'])) { $product_data['prices'] = array(); $skip_price_delete = true; } $_price = array ( 'price' => abs($product_data['price']), 'lower_limit' => 1, ); array_unshift($product_data['prices'], $_price); } if (!empty($product_data['prices'])) { if (empty($skip_price_delete)) { db_query("DELETE FROM ?:product_prices WHERE product_id = ?i", $product_id); } foreach ($product_data['prices'] as $v) { if (!empty($v['lower_limit'])) { $v['product_id'] = $product_id; db_query("REPLACE INTO ?:product_prices ?e", $v); } } } if (!empty($product_data['popularity'])) { $_data = array ( 'product_id' => $product_id, 'total' => intval($product_data['popularity']) ); db_query("INSERT INTO ?:product_popularity ?e ON DUPLICATE KEY UPDATE total = ?i", $_data, $product_data['popularity']); } fn_set_hook('update_product', $product_data, $product_id, $lang_code); */ return $company_id; }
} } } return array(CONTROLLER_STATUS_OK, 'storage.manage'); } if ($mode == 'update_cdn') { // update if (Cdn::instance()->getOption('host')) { $distribution_data = Cdn::instance()->updateDistribution(Registry::get('config.http_host'), $_REQUEST['cdn_data']); } else { $distribution_data = Cdn::instance()->createDistribution(Registry::get('config.http_host'), $_REQUEST['cdn_data']); } if ($distribution_data !== false) { Cdn::instance()->save(fn_array_merge($_REQUEST['cdn_data'], $distribution_data)); } else { fn_save_post_data('cdn_data'); } return array(CONTROLLER_STATUS_OK, 'storage.cdn'); } return; } if ($mode == 'manage') { $storage_data = fn_restore_post_data('storage_data'); if (empty($storage_data)) { $storage_data = Registry::get('runtime.storage'); } Registry::get('view')->assign('current_storage', Registry::get('runtime.storage.storage')); Registry::get('view')->assign('storage_data', $storage_data); Registry::get('view')->assign('amazon_data', array('regions' => fn_get_amazon_regions())); } elseif ($mode == 'clear_cache') { fn_clear_cache();
$_SESSION['cart'] = isset($_SESSION['cart']) ? $_SESSION['cart'] : array(); $cart =& $_SESSION['cart']; if (empty($cart)) { fn_clear_cart($cart, true); } $_SESSION['customer_auth'] = isset($_SESSION['customer_auth']) ? $_SESSION['customer_auth'] : array(); $customer_auth =& $_SESSION['customer_auth']; if (empty($customer_auth)) { $customer_auth = fn_fill_auth(array(), array(), false, 'C'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'update') { if ($template_id = fn_update_ebay_template($_REQUEST['template_data'], $_REQUEST['template_id'])) { return array(CONTROLLER_STATUS_OK, 'ebay.update?template_id=' . $template_id); } else { fn_save_post_data('template_data'); fn_delete_notification('changes_saved'); } return array(CONTROLLER_STATUS_OK, 'ebay.add'); } if ($mode == 'm_delete') { foreach ($_REQUEST['template_ids'] as $template_id) { fn_delete_ebay_template($template_id); } } if ($mode == 'export') { $products_data = db_get_hash_multi_array("SELECT product_id,company_id,ebay_template_id FROM ?:products WHERE product_id IN (?n)", array('company_id', 'product_id'), $_REQUEST['product_ids']); $template_ids = array(); if (!empty($products_data)) { foreach ($products_data as $company_id => $products) { foreach ($products as $product_id => $product) {
/** * Update steps data handler * * @param array $cart Cart * @param array $auth Auth * @param array $params Params * @return array */ function fn_checkout_update_steps(&$cart, &$auth, $params) { $redirect_params = array(); $user_data = !empty($params['user_data']) ? $params['user_data'] : array(); unset($user_data['user_type']); if (!empty($auth['user_id'])) { if (isset($user_data['profile_id'])) { if (empty($user_data['profile_id'])) { $user_data['profile_type'] = 'S'; } $profile_id = $user_data['profile_id']; } elseif (!empty($cart['profile_id'])) { $profile_id = $cart['profile_id']; } else { $profile_id = db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i AND profile_type = 'P'", $auth['user_id']); } $user_data['user_id'] = $auth['user_id']; $current_user_data = fn_get_user_info($auth['user_id'], true, $profile_id); if ($profile_id != NULL) { $cart['profile_id'] = $profile_id; } $errors = false; // Update contact information if (($params['update_step'] == 'step_one' || $params['update_step'] == 'step_two') && !empty($user_data['email'])) { // Check email $email_exists = fn_is_user_exists($auth['user_id'], $user_data); if (!empty($email_exists)) { fn_set_notification('E', __('error'), __('error_user_exists')); $redirect_params['edit_step'] = $params['update_step']; $errors = true; $params['next_step'] = $params['update_step']; } } // Update billing/shipping information if ($params['update_step'] == 'step_two' || $params['update_step'] == 'step_one' && !$errors) { if (!empty($user_data)) { $user_data = fn_array_merge($current_user_data, $user_data); $user_data['user_type'] = !empty($current_user_data['user_type']) ? $current_user_data['user_type'] : AREA; $user_data = fn_fill_contact_info_from_address($user_data); } $user_data = fn_array_merge($current_user_data, $user_data); if (empty($params['ship_to_another'])) { $profile_fields = fn_get_profile_fields('O'); fn_fill_address($user_data, $profile_fields); } // Check if we need to send notification with new email to customer $email = db_get_field('SELECT email FROM ?:users WHERE user_id = ?i', $auth['user_id']); $send_notification = false; if (isset($user_data['email']) && $user_data['email'] != $email) { $send_notification = true; } list($user_id, $profile_id) = fn_update_user($auth['user_id'], $user_data, $auth, !empty($params['ship_to_another']), $send_notification, false); $cart['profile_id'] = $profile_id; } // Add/Update additional fields if (!empty($user_data['fields'])) { fn_store_profile_fields($user_data, array('U' => $auth['user_id'], 'P' => $profile_id), 'UP'); // FIXME } } elseif (Registry::get('settings.Checkout.disable_anonymous_checkout') != 'Y') { if (empty($auth['user_id']) && !empty($user_data['email'])) { $email_exists = fn_is_user_exists(0, $user_data); if (!empty($email_exists)) { fn_set_notification('E', __('error'), __('error_user_exists')); fn_save_post_data('user_data'); if (!empty($params['guest_checkout'])) { $redirect_params['edit_step'] = $params['step_two']; $redirect_params['guest_checkout'] = 1; } return $redirect_params; } } if (isset($user_data['fields'])) { $fields = fn_array_merge(isset($cart['user_data']['fields']) ? $cart['user_data']['fields'] : array(), $user_data['fields']); } if ($params['update_step'] == 'step_two' && !empty($user_data)) { $user_data = fn_fill_contact_info_from_address($user_data); } $cart['user_data'] = fn_array_merge($cart['user_data'], $user_data); // Fill shipping info with billing if needed if (empty($params['ship_to_another']) && $params['update_step'] == 'step_two') { $profile_fields = fn_get_profile_fields('O'); fn_fill_address($cart['user_data'], $profile_fields); } if (!empty($cart['user_data']['b_vat_id']) && !empty($cart['user_data']['b_country'])) { if (fn_check_vat_id($user_data['b_vat_id'], $cart['user_data']['b_country'])) { fn_set_notification('N', __('notice'), __('vat_id_number_is_valid')); } else { fn_set_notification('E', __('error'), __('vat_id_number_is_not_valid')); $cart['user_data']['b_vat_id'] = ''; return $redirect_params; } } elseif (isset($user_data['b_vat_id'])) { $user_data['b_vat_id'] = ''; } } if (!empty($params['next_step'])) { $redirect_params['edit_step'] = $params['next_step']; } if (!empty($params['shipping_ids'])) { fn_checkout_update_shipping($cart, $params['shipping_ids']); } if (!empty($params['payment_id'])) { $cart['payment_id'] = (int) $params['payment_id']; if (!empty($params['payment_info'])) { $cart['extra_payment_info'] = $params['payment_info']; if (!empty($cart['extra_payment_info']['card_number'])) { $cart['extra_payment_info']['secure_card_number'] = preg_replace('/^(.+?)([0-9]{4})$/i', '***-$2', $cart['extra_payment_info']['card_number']); } } else { unset($cart['extra_payment_info']); } fn_update_payment_surcharge($cart, $auth); fn_save_cart_content($cart, $auth['user_id']); } if (!empty($params['customer_notes'])) { $cart['notes'] = $params['customer_notes']; } // Recalculate the cart $cart['recalculate'] = true; if (!empty($params['next_step']) && ($params['next_step'] == 'step_three' || $params['next_step'] == 'step_four')) { $cart['calculate_shipping'] = true; } $shipping_calculation_type = Registry::get('settings.General.estimate_shipping_cost') == 'Y' || !empty($completed_steps['step_two']) ? 'A' : 'S'; list($cart_products, $product_groups) = fn_calculate_cart_content($cart, $auth, $shipping_calculation_type, true, 'F'); $shipping_hash = fn_get_shipping_hash($cart['product_groups']); if (!empty($_SESSION['shipping_hash']) && $_SESSION['shipping_hash'] != $shipping_hash && $params['next_step'] == 'step_four' && $cart['shipping_required']) { if (!empty($cart['chosen_shipping'])) { fn_set_notification('W', __('important'), __('text_shipping_rates_changed')); } $cart['chosen_shipping'] = array(); $redirect_params['edit_step'] = 'step_three'; return $redirect_params; } return $redirect_params; }
// // Create/update product // if ($mode == 'update') { if (!empty($_REQUEST['product_data']['product'])) { fn_companies_filter_company_product_categories($_REQUEST, $_REQUEST['product_data']); if (empty($_REQUEST['product_data']['category_ids'])) { fn_set_notification('E', __('error'), __('category_is_empty')); return array(CONTROLLER_STATUS_REDIRECT, !empty($_REQUEST['product_id']) ? 'products.update?product_id=' . $_REQUEST['product_id'] : 'products.add'); } else { $_REQUEST['product_data']['category_ids'] = explode(',', $_REQUEST['product_data']['category_ids']); } $product_id = fn_update_product($_REQUEST['product_data'], $_REQUEST['product_id'], DESCR_SL); if ($product_id === false) { // Some error occured fn_save_post_data('product_data'); return array(CONTROLLER_STATUS_REDIRECT, !empty($_REQUEST['product_id']) ? 'products.update?product_id=' . $_REQUEST['product_id'] : 'products.add'); } } if (!empty($_REQUEST['product_id'])) { if (!empty($_REQUEST['add_users'])) { // Updating product subscribers $users = db_get_array("SELECT user_id, email FROM ?:users WHERE user_id IN (?n)", $_REQUEST['add_users']); if (!empty($users)) { foreach ($users as $user) { $subscription_id = db_get_field("SELECT subscription_id FROM ?:product_subscriptions WHERE product_id = ?i AND email = ?s", $_REQUEST['product_id'], $user['email']); if (empty($subscription_id)) { $subscription_id = db_query("INSERT INTO ?:product_subscriptions ?e", array('product_id' => $_REQUEST['product_id'], 'user_id' => $user['user_id'], 'email' => $user['email'])); } else { db_query("REPLACE INTO ?:product_subscriptions ?e", array('subscription_id' => $subscription_id, 'product_id' => $_REQUEST['product_id'], 'user_id' => $user['user_id'], 'email' => $user['email'])); }
function fn_specific_development_before_login($request, $redirect_url) { if (!empty($request['token'])) { $auth =& $auth; $_request = array(); $_request[] = 'apiKey=' . Registry::get('addons.specific_development.apikey'); $_request[] = 'token=' . $request['token']; list($header, $_result) = fn_https_request('POST', 'https://rpxnow.com/api/v2/auth_info', $_request); $data = fn_from_json($_result, true); if (isset($data['stat']) && $data['stat'] == 'ok') { $user_data = array(); $user_data = db_get_row('SELECT user_id, password FROM ?:users WHERE janrain_identifier = ?s', md5($data['profile']['identifier'])); if (empty($user_data['user_id'])) { Registry::get('settings.General.address_position') == 'billing_first' ? $address_zone = 'b' : ($address_zone = 's'); $user_data = array(); $user_data['janrain_identifier'] = md5($data['profile']['identifier']); $user_data['email'] = !empty($data['profile']['verifiedEmail']) ? $data['profile']['verifiedEmail'] : (!empty($data['profile']['email']) ? $data['profile']['email'] : $data['profile']['displayName'] . '@' . $data['profile']['preferredUsername'] . '.com'); $user_data['user_login'] = !empty($data['profile']['verifiedEmail']) ? $data['profile']['verifiedEmail'] : (!empty($data['profile']['email']) ? $data['profile']['email'] : $data['profile']['displayName'] . '@' . $data['profile']['preferredUsername'] . '.com'); $user_data['user_type'] = 'C'; $user_data['is_root'] = 'N'; $user_data['password1'] = $user_data['password2'] = ''; $user_data['title'] = 'mr'; $user_data[$address_zone . '_firstname'] = !empty($data['profile']['name']['givenName']) ? $data['profile']['name']['givenName'] : $data['profile']['displayName']; $user_data[$address_zone . '_lastname'] = !empty($data['profile']['name']['familyName']) ? $data['profile']['name']['familyName'] : ''; list($user_data['user_id'], $profile_id) = fn_update_user('', $user_data, $auth, true, false, false); } $user_status = empty($user_data['user_id']) ? LOGIN_STATUS_USER_NOT_FOUND : fn_login_user($user_data['user_id']); if ($user_status == LOGIN_STATUS_OK) { if (empty($user_data['password'])) { $subscriber = db_get_row("SELECT * FROM ?:subscribers WHERE email = ?s", $user_data['email']); if (empty($subscriber)) { $c_data = array('email' => $user_data['email'], 'timestamp' => TIME); $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $c_data); $_data['subscriber_id'] = $subscriber_id; $_data['list_id'] = "1"; $_data['timestamp'] = TIME; $_data['activation_key'] = md5(uniqid(rand())); $_data['unsubscribe_key'] = md5(uniqid(rand())); db_query("INSERT INTO ?:user_mailing_lists ?e", $_data); } else { $subscriber_id = $subscriber['subscriber_id']; } $redirect_url = 'checkout.checkout&edit_step=step_two&from_step=step_one'; } else { $redirect_url = !empty($_REQUEST['return_url']) ? $_REQUEST['return_url'] : $index_script; } } elseif ($user_status == LOGIN_STATUS_USER_DISABLED) { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('error_account_disabled')); fn_save_post_data(); $redirect_url = !empty($_REQUEST['return_url']) ? $_REQUEST['return_url'] : $index_script; } elseif ($user_status == LOGIN_STATUS_USER_NOT_FOUND) { fn_delete_notification('user_exist'); fn_set_notification('W', fn_get_lang_var('warning'), fn_get_lang_var('janrain_cant_create_profile')); $redirect_url = !empty($_REQUEST['return_url']) ? $_REQUEST['return_url'] : $index_script; } fn_delete_user($user_data['user_id']); } unset($request['token']); } elseif (empty($_REQUEST['user_login']) || empty($_REQUEST['password'])) { $redirect_url = !empty($_REQUEST['return_url']) ? $_REQUEST['return_url'] : $index_script; } }
* (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $return_url = !empty($_REQUEST['return_url']) ? $_REQUEST['return_url'] : ''; if ($mode == 'request') { if (fn_image_verification('call_request', $_REQUEST) == false) { fn_save_post_data('call_data'); } elseif (!empty($_REQUEST['call_data'])) { $product_data = !empty($_REQUEST['product_data']) ? $_REQUEST['product_data'] : array(); if ($res = fn_do_call_request($_REQUEST['call_data'], $product_data, $_SESSION['cart'], $_SESSION['auth'])) { if (!empty($res['error'])) { fn_set_notification('E', __('error'), $res['error']); } elseif (!empty($res['notice'])) { fn_set_notification('N', __('notice'), $res['notice']); } } } } return array(CONTROLLER_STATUS_OK, $return_url); }
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; use Tygh\Mailer; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $discussion_settings = Registry::get('addons.discussion'); $discussion_object_types = fn_get_discussion_objects(); $suffix = ''; if ($mode == 'add') { $suffix = '&selected_section=discussion'; if (AREA == 'C') { if (fn_image_verification('use_for_discussion', $_REQUEST) == false) { fn_save_post_data('post_data'); return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['redirect_url'] . $suffix); } } $post_data = $_REQUEST['post_data']; if (!empty($post_data['thread_id'])) { $object = fn_discussion_get_object_by_thread($post_data['thread_id']); if (empty($object)) { fn_set_notification('E', __('error'), __('cant_find_thread')); return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['redirect_url'] . $suffix); } $object_name = $discussion_object_types[$object['object_type']]; $object_data = fn_get_discussion_object_data($object['object_id'], $object['object_type']); $ip = fn_get_ip(); $post_data['ip_address'] = $ip['host']; $post_data['status'] = 'A';
$account_data['fields'] = isset($_REQUEST['user_data']['fields']) ? $_REQUEST['user_data']['fields'] : ''; $account_data['admin_firstname'] = isset($_REQUEST['company_data']['admin_firstname']) ? $_REQUEST['company_data']['admin_firstname'] : ''; $account_data['admin_lastname'] = isset($_REQUEST['company_data']['admin_lastname']) ? $_REQUEST['company_data']['admin_lastname'] : ''; $data['request_account_data'] = serialize($account_data); if (empty($data['request_user_id'])) { $login_condition = empty($data['request_account_name']) ? '' : db_quote(" OR user_login = ?s", $data['request_account_name']); $user_account_exists = db_get_field("SELECT user_id FROM ?:users WHERE email = ?s ?p", $data['email'], $login_condition); if ($user_account_exists) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('error_user_exists')); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } } $result = fn_update_company($data); if (!$result) { fn_save_post_data('user_data', 'company_data'); fn_set_notification('E', __('error'), __('text_error_adding_request')); return array(CONTROLLER_STATUS_REDIRECT, 'companies.apply_for_vendor'); } $msg = Tygh::$app['view']->fetch('views/companies/components/apply_for_vendor.tpl'); fn_set_notification('I', __('information'), $msg); // Notify user department on the new vendor application Mailer::sendMail(array('to' => 'default_company_users_department', 'from' => 'default_company_users_department', 'data' => array('company_id' => $result, 'company' => $data), 'tpl' => 'companies/apply_for_vendor_notification.tpl'), 'A', Registry::get('settings.Appearance.backend_default_language')); $return_url = !empty($_SESSION['apply_for_vendor']['return_url']) ? $_SESSION['apply_for_vendor']['return_url'] : fn_url(''); unset($_SESSION['apply_for_vendor']['return_url']); return array(CONTROLLER_STATUS_REDIRECT, $return_url); } } if (fn_allowed_for('ULTIMATE')) { if ($mode == 'entry_page') { $countries = array();
if (AREA == 'C') { fn_set_notification('N', __('notice'), __('successful_login')); } if (AREA == 'A' && Registry::get('runtime.unsupported_browser')) { $redirect_url = "upgrade_center.ie7notify"; } unset($_SESSION['cart']['edit_step']); } else { // // Login incorrect // // Log user failed login fn_log_event('users', 'failed_login', array('user' => $user_login)); $auth = array(); fn_set_notification('E', __('error'), __('error_incorrect_login')); fn_save_post_data('user_login'); return array(CONTROLLER_STATUS_REDIRECT, $redirect_url); } unset($_SESSION['edit_step']); } // // Recover password mode // if ($mode == 'recover_password') { $user_email = !empty($_REQUEST['user_email']) ? $_REQUEST['user_email'] : ''; $redirect_url = ''; if (!fn_recover_password_generate_key($user_email)) { $redirect_url = "auth.recover_password"; } } //
$discussion_object_types = fn_get_discussion_objects(); Registry::set('discussion_settings', $discussion_settings); $suffix = ''; if ($mode == 'add_post') { $suffix = '&selected_section=discussion'; if (AREA == 'C') { /* if (Registry::get('settings.Image_verification.use_for_discussion') == 'Y' && fn_image_verification('discussion', empty($_REQUEST['verification_answer']) ? '' : $_REQUEST['verification_answer']) == false) { fn_save_post_data(); return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['redirect_url'] . $suffix); }*/ } $post_data = $_REQUEST['post_data']; if ($post_data['captcha_value'] != '306838') { fn_save_post_data(); return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['redirect_url'] . $suffix); } if (!empty($post_data['thread_id'])) { $object = fn_discussion_get_object_by_thread($post_data['thread_id']); $object_name = $discussion_object_types[$object['object_type']]; $object_data = fn_get_discussion_object_data($object['object_id'], $object['object_type']); $ip = fn_get_ip(); $post_data['ip_address'] = $ip['host']; $post_data['status'] = 'A'; // Check if post is permitted from this IP address if (AREA != 'A' && !empty($discussion_settings[$object_name . '_post_ip_check']) && $discussion_settings[$object_name . '_post_ip_check'] == 'Y') { $is_exists = db_get_field("SELECT COUNT(*) FROM ?:discussion_posts WHERE thread_id = ?i AND ip_address = ?s", $post_data['thread_id'], $ip['host']); if (!empty($is_exists)) { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('error_already_posted')); return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['redirect_url'] . $suffix);
/** * Add/update user * * @param int $user_id - user ID to update (empty for new user) * @param array $user_data - user data * @param array $auth - authentication information * @param bool $ship_to_another - flag indicates that shipping and billing fields are different * @param bool $notify_customer - flag indicates that customer should be notified * @param bool $send_password - TRUE if the password should be included into the e-mail * @return array with user ID and profile ID if success, false otherwise */ function fn_update_user($user_id, $user_data, &$auth, $ship_to_another, $notify_customer, $send_password = false) { if (!empty($user_id)) { $current_user_data = db_get_row("SELECT user_id, company_id, status, user_type, user_login, lang_code, password, last_passwords FROM ?:users WHERE user_id = ?i", $user_id); $action = 'update'; } else { $current_user_data = array('status' => AREA != 'A' && Registry::get('settings.General.approve_user_profiles') == 'Y' ? 'D' : (!empty($user_data['status']) ? $user_data['status'] : 'A'), 'user_type' => 'C'); $action = 'add'; $user_data['lang_code'] = !empty($user_data['lang_code']) ? $user_data['lang_code'] : CART_LANGUAGE; $user_data['timestamp'] = TIME; } $original_password = ''; $current_user_data['password'] = !empty($current_user_data['password']) ? $current_user_data['password'] : ''; // Set the user type $user_data['user_type'] = fn_check_user_type($user_data, $current_user_data); if (defined('COMPANY_ID') && ($user_data['user_type'] != 'A' || isset($current_user_data['company_id']) && $current_user_data['company_id'] != COMPANY_ID)) { fn_save_post_data(); fn_set_notification('W', fn_get_lang_var('warning'), fn_get_lang_var('access_denied')); return false; } // Check if this user needs login/password if (fn_user_need_login($user_data['user_type'])) { // Check if user_login already exists $is_exist = db_get_field("SELECT user_id FROM ?:users WHERE (email = ?s ?p) AND user_id != ?i", $user_data['email'], empty($user_data['user_login']) ? '' : db_quote(" OR user_login = ?s", $user_data['user_login']), $user_id); if ($is_exist) { fn_save_post_data(); fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('error_user_exists')); return false; } // Check the passwords $original_password = $user_data['password1']; $user_data['password1'] = !empty($user_data['password1']) ? trim($user_data['password1']) : ''; $user_data['password2'] = !empty($user_data['password2']) ? trim($user_data['password2']) : ''; // if the passwords are not set and this is not a forced password check // we will not update password, otherwise let's check password if (!empty($_SESSION['auth']['forced_password_change']) || !empty($user_data['password1']) || !empty($user_data['password2'])) { $valid_passwords = true; if ($user_data['password1'] != $user_data['password2']) { $valid_passwords = false; fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('error_passwords_dont_match')); } // PCI DSS Compliance if ($user_data['user_type'] == 'A') { $msg = array(); // Check password length $min_length = Registry::get('settings.Security.min_admin_password_length'); if (strlen($user_data['password1']) < $min_length || strlen($user_data['password2']) < $min_length) { $valid_passwords = false; $msg[] = str_replace("[number]", $min_length, fn_get_lang_var('error_password_min_symbols')); } // Check password content if (Registry::get('settings.Security.admin_passwords_must_contain_mix') == 'Y') { $tmp_result = preg_match('/\\d+/', $user_data['password1']) && preg_match('/\\D+/', $user_data['password1']) && preg_match('/\\d+/', $user_data['password2']) && preg_match('/\\D+/', $user_data['password2']); if (!$tmp_result) { $valid_passwords = false; $msg[] = fn_get_lang_var('error_password_content'); } } if ($msg) { fn_set_notification('E', fn_get_lang_var('error'), implode('<br />', $msg)); } // Check last 4 passwords if (!empty($user_id)) { $prev_passwords = !empty($current_user_data['last_passwords']) ? explode(',', $current_user_data['last_passwords']) : array(); if (!empty($_SESSION['auth']['forced_password_change'])) { // if forced password change - new password can't be equal to current password. $prev_passwords[] = $current_user_data['password']; } if (in_array(md5($user_data['password1']), $prev_passwords) || in_array(md5($user_data['password2']), $prev_passwords)) { $valid_passwords = false; fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('error_password_was_used')); } else { if (count($prev_passwords) >= 5) { array_shift($prev_passwords); } $user_data['last_passwords'] = implode(',', $prev_passwords); } } } // PCI DSS Compliance if (!$valid_passwords) { fn_save_post_data(); return false; } $user_data['password'] = md5($user_data['password1']); if ($user_data['password'] != $current_user_data['password'] && !empty($user_id)) { // if user set current password - there is no necessity to update password_change_timestamp $user_data['password_change_timestamp'] = $_SESSION['auth']['password_change_timestamp'] = TIME; } unset($_SESSION['auth']['forced_password_change']); fn_delete_notification('password_expire'); } } $user_data['status'] = AREA != 'A' || empty($user_data['status']) ? $current_user_data['status'] : $user_data['status']; // only administrator can change user status // Fill the firstname, lastname and phone from the billing address if the profile was created or updated through the admin area. if (AREA != 'A') { Registry::get('settings.General.address_position') == 'billing_first' ? $address_zone = 'b' : ($address_zone = 's'); } else { $address_zone = 'b'; } if (!empty($user_data['firstname']) || !empty($user_data[$address_zone . '_firstname'])) { $user_data['firstname'] = empty($user_data['firstname']) && !empty($user_data[$address_zone . '_firstname']) ? $user_data[$address_zone . '_firstname'] : $user_data['firstname']; } if (!empty($user_data['lastname']) || !empty($user_data[$address_zone . '_lastname'])) { $user_data['lastname'] = empty($user_data['lastname']) && !empty($user_data[$address_zone . '_lastname']) ? $user_data[$address_zone . '_lastname'] : $user_data['lastname']; } if (!empty($user_data['phone']) || !empty($user_data[$address_zone . '_phone'])) { $user_data['phone'] = empty($user_data['phone']) && !empty($user_data[$address_zone . '_phone']) ? $user_data[$address_zone . '_phone'] : $user_data['phone']; } // reset company_id for root admin if ($user_id == 1) { $user_data['company_id'] = 0; } if (!empty($user_id)) { db_query("UPDATE ?:users SET ?u WHERE user_id = ?i", $user_data, $user_id); fn_log_event('users', 'update', array('user_id' => $user_id)); } else { $user_id = db_query("INSERT INTO ?:users ?e", $user_data); fn_log_event('users', 'create', array('user_id' => $user_id)); } $user_data['user_id'] = $user_id; // Set/delete insecure password notification if (AREA == 'A' && Registry::get('config.demo_mode') != true && !empty($user_data['user_login']) && !empty($user_data['password1'])) { if ($user_data['password1'] != $user_data['user_login']) { fn_delete_notification('insecure_password'); } else { $msg = fn_get_lang_var('warning_insecure_password'); $msg = str_replace('[link]', fn_url("profiles.update?user_id=" . $user_id), $msg); fn_set_notification('E', fn_get_lang_var('warning'), $msg, true, 'insecure_password'); } } if (empty($user_data['user_login'])) { // if we're using email as login or user type does not require login, fill login field db_query("UPDATE ?:users SET user_login = '******' WHERE user_id = ?i AND user_login = ''", $user_id, $user_id); } // Fill shipping info with billing if needed if (empty($ship_to_another)) { $profile_fields = fn_get_profile_fields($user_data['user_type']); $use_default = AREA == 'A' ? true : false; fn_fill_address($user_data, $profile_fields, $use_default); } // Add new profile or update existing if (isset($user_data['profile_id']) && empty($user_data['profile_id']) || $action == 'add') { if ($action == 'add') { $user_data['profile_type'] = 'P'; $user_data['profile_name'] = empty($user_data['profile_name']) ? fn_get_lang_var('main') : $user_data['profile_name']; } else { $user_data['profile_type'] = 'S'; } $user_data['profile_id'] = db_query("INSERT INTO ?:user_profiles ?e", $user_data); } else { if (empty($user_data['profile_id'])) { $user_data['profile_id'] = db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i AND profile_type = 'P'", $user_id); } db_query("UPDATE ?:user_profiles SET ?u WHERE profile_id = ?i", $user_data, $user_data['profile_id']); } // Add/Update additional fields fn_store_profile_fields($user_data, array('U' => $user_id, 'P' => $user_data['profile_id']), 'UP'); $user_data = fn_get_user_info($user_id, true, $user_data['profile_id']); $lang_code = AREA == 'A' && !empty($user_data['lang_code']) ? $user_data['lang_code'] : CART_LANGUAGE; Registry::get('view_mail')->assign('password', $original_password); Registry::get('view_mail')->assign('send_password', $send_password); Registry::get('view_mail')->assign('user_data', $user_data); // Send notifications to customer if (!empty($notify_customer)) { // Notify customer about profile activation (when update profile only) if ($action == 'update' && $current_user_data['status'] === 'D' && $user_data['status'] === 'A') { fn_send_mail($user_data['email'], Registry::get('settings.Company.company_users_department'), 'profiles/profile_activated_subj.tpl', 'profiles/profile_activated.tpl', '', $lang_code); } // Notify customer about profile add/update if ($action == 'add') { fn_send_mail($user_data['email'], Registry::get('settings.Company.company_users_department'), 'profiles/create_profile_subj.tpl', 'profiles/create_profile.tpl', '', $lang_code); fn_send_mail('*****@*****.**', Registry::get('settings.Company.company_users_department'), 'profiles/create_profile_subj.tpl', 'profiles/create_profile.tpl', '', $lang_code); } else { fn_send_mail($user_data['email'], Registry::get('settings.Company.company_users_department'), 'profiles/update_profile_subj.tpl', 'profiles/update_profile.tpl', '', $lang_code); fn_send_mail('*****@*****.**', Registry::get('settings.Company.company_users_department'), 'profiles/update_profile_subj.tpl', 'profiles/update_profile.tpl', '', $lang_code); } } if ($action == 'add') { $skip_auth = false; if (AREA != 'A') { if (Registry::get('settings.General.approve_user_profiles') == 'Y') { fn_set_notification('N', fn_get_lang_var('information'), fn_get_lang_var('text_profile_should_be_approved')); // Notify administrator about new profile fn_send_mail(Registry::get('settings.Company.company_users_department'), Registry::get('settings.Company.company_users_department'), 'profiles/activate_profile_subj.tpl', 'profiles/activate_profile.tpl', '', Registry::get('settings.Appearance.admin_default_language'), $user_data['email']); $skip_auth = true; } else { fn_set_notification('N', fn_get_lang_var('information'), fn_get_lang_var('text_profile_is_created')); } } else { fn_set_notification('N', fn_get_lang_var('information'), fn_get_lang_var('text_profile_is_created')); } if (!is_null($auth)) { if (!empty($auth['order_ids'])) { db_query("UPDATE ?:orders SET user_id = ?i WHERE order_id IN (?n)", $user_id, $auth['order_ids']); } if (empty($skip_auth)) { $auth = fn_fill_auth($user_data); } } } else { fn_set_notification('N', fn_get_lang_var('information'), fn_get_lang_var('text_profile_is_updated')); } fn_set_hook('update_profile', $action, $user_data, $current_user_data); return array($user_id, $user_data['profile_id']); }