/**
  * Email validator
  *
  * @param  array $email
  * @return bool  true if email is valid
  */
 public function isEmailValid($email)
 {
     if (!fn_validate_email($email)) {
         return false;
     }
     return true;
 }
Example #2
0
function fn_em_update_subscriber($subscriber_data, $subscriber_id = 0, $sync = true, $lang_code = CART_LANGUAGE)
{
    $invalid_emails = array();
    if (empty($subscriber_id)) {
        if (!empty($subscriber_data['email'])) {
            $company_condition = fn_em_get_company_condition();
            if (db_get_field("SELECT email FROM ?:em_subscribers WHERE email = ?s ?p", $subscriber_data['email'], $company_condition) == '') {
                if (fn_validate_email($subscriber_data['email']) == false) {
                    $invalid_emails[] = $subscriber_data['email'];
                } else {
                    if (empty($subscriber_data['name'])) {
                        $subscriber_data['name'] = '';
                    }
                    if (empty($subscriber_data['timestamp'])) {
                        $subscriber_data['timestamp'] = time();
                    }
                    if (empty($subscriber_data['ip_address'])) {
                        $ip = fn_get_ip();
                        $subscriber_data['ip_address'] = fn_ip_to_db($ip['host']);
                    }
                    if (empty($subscriber_data['unsubscribe_key'])) {
                        $subscriber_data['unsubscribe_key'] = md5(uniqid());
                    }
                    $subscriber_data['company_id'] = Registry::get('runtime.company_id');
                    $subscriber_data['lang_code'] = $lang_code;
                    $subscriber_id = db_query("INSERT INTO ?:em_subscribers ?e", $subscriber_data);
                }
            } else {
                fn_set_notification('W', __('warning'), __('email_marketing.warning_email_exists', array('[email]' => $subscriber_data['email'])));
            }
        }
    } else {
        db_query("UPDATE ?:em_subscribers SET ?u WHERE subscriber_id = ?i", $subscriber_data, $subscriber_id);
    }
    if (!empty($invalid_emails)) {
        fn_set_notification('E', __('error'), __('error_invalid_emails', array('[emails]' => implode(', ', $invalid_emails))));
    } elseif ($sync) {
        $subscriber_data = fn_em_get_subscriber_data('', $subscriber_id);
        $subscribed = EmailSync::instance()->subscribe(array('email' => $subscriber_data['email'], 'timestamp' => $subscriber_data['timestamp'], 'lang_code' => $subscriber_data['lang_code'], 'ip_address' => fn_ip_from_db($subscriber_data['ip_address']), 'name' => $subscriber_data['name']));
        if ($subscribed == false) {
            fn_em_delete_subscribers(array($subscriber_id), false);
            $subscriber_id = false;
        }
    }
    return $subscriber_id;
}
Example #3
0
function fn_email_is_blocked($user_data, $reset_email = false)
{
    $auth =& $_SESSION['auth'];
    $user_data['email'] = isset($user_data['email']) ? $user_data['email'] : '';
    $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' || 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_set_notification('E', __('error'), __('text_email_is_blocked', array('[email]' => $user_data['email'])));
        return true;
    }
    return false;
}
Example #4
0
function fn_email_is_blocked($user_data, $reset_email = false)
{
    $auth =& Tygh::$app['session']['auth'];
    // FIXME: unassigned $user_data['email'] when trying to change admin pass. login by e-mail == on, admin must change pass on first login == on
    $user_data['email'] = isset($user_data['email']) ? $user_data['email'] : '';
    $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' || 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_set_notification('E', __('error'), __('text_email_is_blocked', array('[email]' => $user_data['email'])));
        return true;
    }
    return false;
}
Example #5
0
*                                                                          *
* 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') {
    // Add email to maillist
    if ($mode == 'add_subscriber') {
        if (empty($_REQUEST['subscribe_email']) || fn_validate_email($_REQUEST['subscribe_email']) == false) {
            fn_set_notification('E', __('error'), __('error_invalid_emails', array('[emails]' => $_REQUEST['subscribe_email'])));
        } else {
            // First check if subscriber's email already in the list
            $subscriber = db_get_row("SELECT * FROM ?:subscribers WHERE email = ?s", $_REQUEST['subscribe_email']);
            if (empty($subscriber)) {
                $_data = array('email' => $_REQUEST['subscribe_email'], 'timestamp' => TIME);
                $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $_data);
                $subscriber = db_get_row("SELECT * FROM ?:subscribers WHERE subscriber_id = ?i", $subscriber_id);
            } else {
                $subscriber_id = $subscriber['subscriber_id'];
            }
            // update subscription data. If there is no any registration autoresponders, we set confirmed=1
            // so user doesn't need to activate subscription
            list($lists) = fn_get_mailing_lists();
            fn_update_subscriptions($subscriber_id, array_keys($lists), NULL, fn_get_notification_rules(true));
         if (!empty($check)) {
             db_query("UPDATE ?:orders_feedback SET ?u WHERE feedback_id = ?i AND lang_code=?s", $_REQUEST['settings_data'], $_REQUEST['feedback_id'], DESCR_SL);
         } else {
             foreach (fn_get_translation_languages() as $_REQUEST['settings_data']['lang_code'] => $v) {
                 $_REQUEST['settings_data']['feedback_id'] = db_query("INSERT INTO ?:orders_feedback ?e", $_REQUEST['settings_data']);
             }
             return array(CONTROLLER_STATUS_OK, "orders_feedback.update?feedback_id=" . $_REQUEST['settings_data']['feedback_id']);
         }
     }
     return array(CONTROLLER_STATUS_OK, "orders_feedback.update?feedback_id=" . $_REQUEST['feedback_id']);
 }
 if ($mode == "test_send") {
     $test_email = $_REQUEST['test_email'];
     $remind = $_REQUEST['settings_data'];
     $remind['lang_code'] = DESCR_SL;
     if (fn_validate_email($test_email)) {
         $statuses = $remind['statuses'];
         $remind_orders = db_get_array("SELECT * FROM ?:orders WHERE status in (?a) AND lang_code=?s", $statuses, $remind['lang_code']);
         if (!empty($remind_orders)) {
             $remind_order = array_pop($remind_orders);
             $order_info = fn_get_order_info($remind_order['order_id']);
             $letter['body'] = $remind['body'];
             $letter['subject'] = $remind['subject'];
             $customer_name = $order_info['firstname'] . ' ' . $remind_order['lastname'];
             $company = db_get_field("SELECT company FROM ?:companies WHERE company_id=?i", $remind_order['company_id']);
             $products = array();
             foreach ($order_info['products'] as $key => $product) {
                 $product_data = fn_get_product_data($product['product_id'], $_SESSION['auth']);
                 if (!empty($product_data['discussion_type']) && $product_data['discussion_type'] != 'D') {
                     $products[$product['product_id']] = $product_data;
                 }
Example #7
0
 if ($mode == 'add') {
     if (fn_allowed_for('MULTIVENDOR') && empty($_SESSION['cart']['gift_certificates']) && !empty($_SESSION['cart']['products'])) {
         fn_set_notification('W', 'Warning', __('gift_cert_with_products'));
         return array(CONTROLLER_STATUS_OK, 'gift_certificates.add');
     }
     if (!empty($_REQUEST['gift_cert_data']) && is_array($_REQUEST['gift_cert_data'])) {
         $gift_cert_data = $_REQUEST['gift_cert_data'];
         if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
             $gift_cert_data['company_id'] = Registry::get('runtime.company_id');
         }
         // Cart is empty, create it
         if (empty($_SESSION['cart'])) {
             fn_clear_cart($_SESSION['cart']);
         }
         unset($_SESSION['cart']['product_groups']);
         if (!empty($_REQUEST['gift_cert_data']['email']) && !fn_validate_email($_REQUEST['gift_cert_data']['email'], true)) {
             if (defined('AJAX_REQUEST')) {
                 exit;
             } else {
                 return array(CONTROLLER_STATUS_OK, 'gift_certificates.add');
             }
         }
         // Gift certificates is empty, create it
         if (empty($_SESSION['cart']['gift_certificates'])) {
             $_SESSION['cart']['gift_certificates'] = array();
         }
         $previous_cart_total = isset($_SESSION['cart']['total']) ? floatval($_SESSION['cart']['total']) : 0;
         list($gift_cert_id, $gift_cert) = fn_add_gift_certificate_to_cart($gift_cert_data, $auth);
         if (!empty($gift_cert_id)) {
             $_SESSION['cart']['gift_certificates'][$gift_cert_id] = $gift_cert;
             $gift_cert['gift_cert_id'] = $gift_cert_id;
Example #8
0
function fn_update_product_notifications($data)
{
    if (!empty($data['email']) && fn_validate_email($data['email'])) {
        $_SESSION['product_notifications']['email'] = $data['email'];
        if ($data['enable'] == 'Y') {
            db_query("REPLACE INTO ?:product_subscriptions ?e", $data);
            if (!isset($_SESSION['product_notifications']['product_ids']) || is_array($_SESSION['product_notifications']['product_ids']) && !in_array($data['product_id'], $_SESSION['product_notifications']['product_ids'])) {
                $_SESSION['product_notifications']['product_ids'][] = $data['product_id'];
            }
            fn_set_notification('N', __('notice'), __('product_notification_subscribed'));
        } else {
            $deleted = db_query("DELETE FROM ?:product_subscriptions WHERE product_id = ?i AND user_id = ?i AND email = ?s", $data['product_id'], $data['user_id'], $data['email']);
            if (isset($_SESSION['product_notifications']) && isset($_SESSION['product_notifications']['product_ids']) && in_array($data['product_id'], $_SESSION['product_notifications']['product_ids'])) {
                $_SESSION['product_notifications']['product_ids'] = array_diff($_SESSION['product_notifications']['product_ids'], array($data['product_id']));
            }
            if (!empty($deleted)) {
                fn_set_notification('N', __('notice'), __('product_notification_unsubscribed'));
            }
        }
    }
}
Example #9
0
function fn_update_subscriber($subscriber_data, $subscriber_id = 0)
{
    $invalid_emails = array();
    if (empty($subscriber_data['list_ids'])) {
        $subscriber_data['list_ids'] = array();
    }
    if (empty($subscriber_data['mailing_lists'])) {
        $subscriber_data['mailing_lists'] = array();
    }
    $subscriber_data['list_ids'] = array_filter($subscriber_data['list_ids']);
    $subscriber_data['mailing_lists'] = array_filter($subscriber_data['mailing_lists']);
    if (empty($subscriber_id)) {
        if (!empty($subscriber_data['email'])) {
            if (db_get_field("SELECT email FROM ?:subscribers WHERE email = ?s", $subscriber_data['email']) == '') {
                if (fn_validate_email($subscriber_data['email']) == false) {
                    $invalid_emails[] = $subscriber_data['email'];
                } else {
                    $subscriber_data['timestamp'] = TIME;
                    $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $subscriber_data);
                }
            } else {
                fn_set_notification('W', __('warning'), __('ne_warning_subscr_email_exists', array('[email]' => $subscriber_data['email'])));
            }
        }
    } else {
        db_query("UPDATE ?:subscribers SET ?u WHERE subscriber_id = ?i", $subscriber_data, $subscriber_id);
    }
    fn_update_subscriptions($subscriber_id, $subscriber_data['list_ids'], isset($subscriber_data['confirmed']) ? $subscriber_data['confirmed'] : $subscriber_data['mailing_lists'], fn_get_notification_rules($subscriber_data), $subscriber_data['lang_code']);
    if (!empty($invalid_emails)) {
        fn_set_notification('E', __('error'), __('error_invalid_emails', array('[emails]' => implode(', ', $invalid_emails))));
    }
    return $subscriber_id;
}
Example #10
0
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
define('MAX_PAYPAL_PRODUCTS', 100);
// Return from paypal website
if (defined('PAYMENT_NOTIFICATION')) {
    if ($mode == 'notify' && !empty($_REQUEST['order_id'])) {
        if (fn_check_payment_script('paypal.php', $_REQUEST['order_id'], $processor_data)) {
            $pp_response = array();
            $order_info = fn_get_order_info($_REQUEST['order_id']);
            if (empty($processor_data)) {
                $processor_data = fn_get_processor_data($order_info['payment_id']);
            }
            $paypal_statuses = $processor_data['processor_params']['statuses'];
            $account_type = fn_validate_email($processor_data['processor_params']['account']) ? 'receiver_email' : 'receiver_id';
            if ($_REQUEST[$account_type] != $processor_data['processor_params']['account']) {
                $pp_response['order_status'] = $paypal_statuses['denied'];
                $pp_response['reason_text'] = __('paypal_security_error');
                fn_finish_payment($_REQUEST['order_id'], $pp_response);
                exit;
            }
            $pp_mc_gross = !empty($_REQUEST['mc_gross']) ? $_REQUEST['mc_gross'] : 0;
            if (stristr($_REQUEST['payment_status'], 'Refunded')) {
                $_order = db_get_row("SELECT status, total FROM ?:orders WHERE order_id = ?i", $_REQUEST['order_id']);
                $pp_response['order_status'] = floatval($_order['total']) - abs(floatval($_REQUEST['payment_gross'])) == 0 ? $paypal_statuses['refunded'] : $_order['status'];
                if ($pp_response['order_status'] != $_order['status']) {
                    fn_change_order_status($_REQUEST['order_id'], $pp_response['order_status']);
                }
                exit;
            }
Example #11
0
     } else {
         //             echo "Sorry, there was an error uploading your file.";
         //       echo 'file not uploaded,tmp name='.$_FILES["p1"]["tmp_name"].";target file=$target_file";
     }
 }
 if (fn_image_verification('use_for_register', $_REQUEST) == false) {
     fn_save_post_data('user_data');
     return array(CONTROLLER_STATUS_REDIRECT, 'profiles.add');
 }
 $is_update = !empty($auth['user_id']);
 if (!$is_update) {
     $is_valid_user_data = true;
     if (empty($_REQUEST['user_data']['email'])) {
         fn_set_notification('W', __('warning'), __('error_validator_required', array('[field]' => __('email'))));
         $is_valid_user_data = false;
     } elseif (!fn_validate_email($_REQUEST['user_data']['email'])) {
         fn_set_notification('W', __('error'), __('text_not_valid_email', array('[email]' => $_REQUEST['user_data']['email'])));
         $is_valid_user_data = false;
     }
     if (empty($_REQUEST['user_data']['password1']) || empty($_REQUEST['user_data']['password2'])) {
         if (empty($_REQUEST['user_data']['password1'])) {
             fn_set_notification('W', __('warning'), __('error_validator_required', array('[field]' => __('password'))));
         }
         if (empty($_REQUEST['user_data']['password2'])) {
             fn_set_notification('W', __('warning'), __('error_validator_required', array('[field]' => __('confirm_password'))));
         }
         $is_valid_user_data = false;
     } elseif ($_REQUEST['user_data']['password1'] !== $_REQUEST['user_data']['password2']) {
         fn_set_notification('W', __('warning'), __('error_validator_password', array('[field2]' => __('password'), '[field]' => __('confirm_password'))));
         $is_valid_user_data = false;
     }
Example #12
0
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: subscribers.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'add') {
        $invalid_emails = array();
        foreach ((array) $_REQUEST['add_subscribers'] as $k => $subscriber) {
            if (!empty($subscriber['email'])) {
                if (db_get_field("SELECT email FROM ?:subscribers WHERE email = ?s", $subscriber['email']) == '') {
                    if (fn_validate_email($subscriber['email']) == false) {
                        $invalid_emails[] = $subscriber['email'];
                        continue;
                    }
                    $subscriber['timestamp'] = TIME;
                    $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $subscriber);
                    // we launch update_subscriptions for each msqiling list to allow different format and lang for each item
                    if (!empty($subscriber['list_ids'])) {
                        fn_update_subscriptions($subscriber_id, $subscriber['list_ids'], $subscriber['format'], NEWSLETTER_ONLY_CHECKED, $subscriber['confirmed'], fn_get_notification_rules($subscriber), $subscriber['lang_code']);
                    }
                } else {
                    $msg = fn_get_lang_var('warning_subscr_email_exists');
                    $msg = str_replace('[email]', $subscriber['email'], $msg);
                    fn_set_notification('W', fn_get_lang_var('warning'), $msg);
                }
            }
Example #13
0
 public static function ValidateAddress($email, $method = 'auto')
 {
     return fn_validate_email($email, false);
 }
Example #14
0
function fn_update_event_subscribers($event_data, $event_id)
{
    $subscribers = array();
    if (!empty($event_data['subscribers'])) {
        $subscribers = $event_data['subscribers'];
    }
    if (!empty($event_data['add_subscribers'])) {
        $subscribers = fn_array_merge($subscribers, $event_data['add_subscribers'], false);
    }
    if (!empty($subscribers)) {
        $invalid_emails = array();
        db_query("DELETE FROM ?:giftreg_event_subscribers WHERE event_id = ?i", $event_id);
        foreach ($subscribers as $v) {
            if (empty($v['email']) || empty($v['name'])) {
                continue;
            }
            if (fn_validate_email($v['email']) == false) {
                $invalid_emails[] = $v['email'];
            }
            $v['event_id'] = $event_id;
            db_query("REPLACE INTO ?:giftreg_event_subscribers ?e", $v);
        }
        if (!empty($invalid_emails)) {
            $msg = fn_get_lang_var('error_invalid_emails');
            $msg = str_replace('[emails]', implode(", ", $invalid_emails), $msg);
            fn_set_notification('W', fn_get_lang_var('warning'), $msg);
        }
    }
    return true;
}
Example #15
0
function fn_update_access_restriction_rule($rule_data, $rule_id = 0, $lang_code = DESCR_SL)
{
    if ($rule_data['section'] == 'ip' || $rule_data['section'] == 'admin_panel') {
        $visitor_ip = fn_get_ip(true);
        if (!empty($rule_data['range_from']) || !empty($rule_data['range_to'])) {
            $range_from = empty($rule_data['range_from']) ? $rule_data['range_to'] : $rule_data['range_from'];
            $range_to = empty($rule_data['range_to']) ? $rule_data['range_from'] : $rule_data['range_to'];
            if (fn_validate_ip($range_from, true) && fn_validate_ip($range_to, true)) {
                $type_s = $rule_data['section'] == 'ip' ? 'ip' : 'aa';
                $_data = array('ip_from' => sprintf("%u", ip2long($range_from)), 'ip_to' => sprintf("%u", ip2long($range_to)), 'timestamp' => TIME, 'status' => $rule_data['status'], 'type' => $range_from == $range_to ? $type_s . 's' : $type_s . 'r');
                if ($rule_data['section'] == 'admin_panel' && Registry::get('addons.access_restrictions.admin_reverse_ip_access') != 'Y' && $_data['ip_from'] <= $visitor_ip['host'] && $_data['ip_to'] >= $visitor_ip['host']) {
                    fn_set_notification('W', __('warning', '', $lang_code), __('warning_of_ip_adding', array('[entered_ip]' => long2ip($_data['ip_from']) . ($_data['ip_from'] == $_data['ip_to'] ? '' : '-' . long2ip($_data['ip_to'])), '[your_ip]' => long2ip($visitor_ip['host'])), $lang_code));
                } else {
                    $rule_id = $_data['item_id'] = db_query("INSERT INTO ?:access_restriction ?e", $_data);
                    $_data['reason'] = $rule_data['reason'];
                    foreach (fn_get_translation_languages() as $_data['lang_code'] => $v) {
                        db_query("INSERT INTO ?:access_restriction_reason_descriptions ?e", $_data);
                    }
                }
            }
        }
        // Add domains
    } elseif ($rule_data['section'] == 'domain') {
        if (fn_validate_domain_name($rule_data['value'], true)) {
            $rule_data['type'] = 'd';
            // Domain
            $rule_data['timestamp'] = TIME;
            $rule_id = $rule_data['item_id'] = db_query("INSERT INTO ?:access_restriction ?e", $rule_data);
            foreach (fn_get_translation_languages() as $rule_data['lang_code'] => $v) {
                db_query("INSERT INTO ?:access_restriction_reason_descriptions ?e", $rule_data);
            }
        }
        // Add emails
    } elseif ($rule_data['section'] == 'email') {
        if (strstr($rule_data['value'], '@') && strpos($rule_data['value'], '*@') !== 0) {
            if (fn_validate_email($rule_data['value'], true) && fn_validate_domain_name(substr($rule_data['value'], strpos($rule_data['value'], '@')), true)) {
                $rule_data['type'] = 'es';
                // specific E-Mail
                $rule_data['timestamp'] = TIME;
                $rule_id = $rule_data['item_id'] = db_query("INSERT INTO ?:access_restriction ?e", $rule_data);
                foreach (fn_get_translation_languages() as $rule_data['lang_code'] => $v) {
                    db_query("INSERT INTO ?:access_restriction_reason_descriptions ?e", $rule_data);
                }
            }
        } else {
            $_domain = strpos($rule_data['value'], '*@') === 0 ? substr($rule_data['value'], 2) : $rule_data['value'];
            if (fn_validate_domain_name($_domain, true)) {
                $rule_data['type'] = 'ed';
                // E-Mail domain
                $rule_data['timestamp'] = TIME;
                $rule_id = $rule_data['item_id'] = db_query("INSERT INTO ?:access_restriction ?e", $rule_data);
                foreach (fn_get_translation_languages() as $rule_data['lang_code'] => $v) {
                    db_query("INSERT INTO ?:access_restriction_reason_descriptions ?e", $rule_data);
                }
            }
        }
        // Add credit cards
    } elseif ($rule_data['section'] == 'credit_card') {
        if (fn_validate_cc_number($rule_data['value'], true)) {
            $rule_data['type'] = 'cc';
            // specific Credit Card Number
            $rule_data['timestamp'] = TIME;
            $rule_id = $rule_data['item_id'] = db_query("INSERT INTO ?:access_restriction ?e", $rule_data);
            foreach (fn_get_translation_languages() as $rule_data['lang_code'] => $v) {
                db_query("INSERT INTO ?:access_restriction_reason_descriptions ?e", $rule_data);
            }
        }
    }
    return $rule_id;
}
Example #16
0
if (!empty($_REQUEST['language'])) {
    if (in_array($_REQUEST['language'], array_keys(Registry::get('languages')))) {
        $lang_code = $_REQUEST['language'];
    }
}
$mode = Registry::get('runtime.mode');
$meta = fn_twg_init_api_meta($response);
$is_cache_request = isset($_GET['get_cache_js']) && in_array($meta['action'], array('get', 'details'));
if (($_SERVER['REQUEST_METHOD'] == 'POST' || $is_cache_request) && $mode == 'post') {
    if ($meta['action'] == 'login') {
        $login = !empty($_REQUEST['login']) ? $_REQUEST['login'] : '';
        $password = !empty($_REQUEST['password']) ? $_REQUEST['password'] : '';
        // Support login by email even if it is disabled
        // replace email in login name with the login corresponding to entered email
        // REMOVE AFTER adding login settings to the application
        if (Registry::get('settings.General.use_email_as_login') != 'Y' && fn_validate_email($login)) {
            $login = db_get_field('SELECT user_login FROM ?:users WHERE email = ?s', $login);
        }
        if (!($user_data = fn_twg_api_customer_login($login, $password))) {
            $response->addError('ERROR_CUSTOMER_LOGIN_FAIL', __('error_incorrect_login'));
        }
        $user_info_params = array('mode' => $mode, 'user_id' => $user_data['user_id']);
        $profile = fn_twg_get_user_info($user_info_params);
        if (fn_allowed_for('MULTIVENDOR')) {
            $profile['company_data'] = !empty($_SESSION['auth']['company_id']) ? fn_get_company_data($_SESSION['auth']['company_id']) : array();
        } else {
            $profile['company_data'] = array();
        }
        $_profile = array_merge($profile, array('cart' => fn_twg_api_get_session_cart($_SESSION['cart'], $lang_code)));
        $response->setData($_profile);
    } elseif ($meta['action'] == 'add_to_cart') {