Пример #1
0
function fn_em_subscribe_email($email, $data = array())
{
    $subscriber_id = fn_em_update_subscriber(array('email' => $email, 'name' => !empty($data['name']) ? $data['name'] : '', 'status' => 'P'), 0, false);
    if (!empty($subscriber_id)) {
        if (Registry::get('addons.email_marketing.em_double_opt_in') == 'Y') {
            Tygh::$app['view']->assign('notification_msg', __('email_marketing.text_subscription_pending'));
            $msg = Tygh::$app['view']->fetch('addons/email_marketing/common/notification.tpl');
            fn_set_notification('I', __('email_marketing.subscription_pending'), $msg);
            Mailer::sendMail(array('to' => $email, 'from' => 'default_company_newsletter_email', 'data' => array('url' => fn_url('em_subscribers.confirm?ekey=' . fn_generate_ekey($email, 'E', SECONDS_IN_DAY))), 'tpl' => 'addons/email_marketing/confirmation.tpl'));
        } else {
            if (fn_em_confirm_subscription($email)) {
                Tygh::$app['view']->assign('notification_msg', __('email_marketing.text_subscription_confirmed'));
                $msg = Tygh::$app['view']->fetch('addons/email_marketing/common/notification.tpl');
                fn_set_notification('I', __('email_marketing.subscription_confirmed'), $msg);
            } else {
                fn_em_delete_subscribers_by_email(array($email));
            }
        }
    }
}
Пример #2
0
        }
    } else {
        $email = '';
        if (!empty($_REQUEST['track_data'])) {
            $o_id = 0;
            // If track by email
            if (strpos($_REQUEST['track_data'], '@') !== false) {
                $order_info = db_get_row("SELECT order_id, email, company_id, lang_code FROM ?:orders WHERE email = ?s {$condition} ORDER BY timestamp DESC LIMIT 1", $_REQUEST['track_data']);
                // Assume that this is order number
            } else {
                $order_info = db_get_row("SELECT order_id, email, company_id, lang_code FROM ?:orders WHERE order_id = ?i {$condition}", $_REQUEST['track_data']);
            }
        }
        if (!empty($order_info['email'])) {
            // Create access key
            $ekey = fn_generate_ekey($order_info['email'], 'T', SECONDS_IN_HOUR);
            $company_id = fn_get_company_id('orders', 'order_id', $order_info['order_id']);
            $result = Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('access_key' => $ekey, 'o_id' => $order_info['order_id']), 'tpl' => 'orders/track.tpl', 'company_id' => $company_id), 'C', $order_info['lang_code']);
            if ($result) {
                fn_set_notification('N', __('notice'), __('text_track_instructions_sent'));
            }
        } else {
            fn_set_notification('E', __('error'), __('warning_track_orders_not_found'));
        }
    }
    return array(CONTROLLER_STATUS_OK, $_REQUEST['return_url']);
    //
    // Show order details
    //
} elseif ($mode == 'details') {
    fn_add_breadcrumb(__('order_info'));
Пример #3
0
 function GenerateCode()
 {
     // reset code
     $this->sCode = '';
     // loop through and generate the code letter by letter
     for ($i = 0; $i < $this->iNumChars; $i++) {
         if (count($this->aCharSet) > 0) {
             // select random character and add to code string
             $this->sCode .= $this->aCharSet[array_rand($this->aCharSet)];
         } else {
             // select random character and add to code string
             $this->sCode .= chr(rand(65, 90));
         }
     }
     $cid = md5($this->cId);
     fn_generate_ekey($this->bCaseInsensitive ? strtoupper($this->sCode) : $this->sCode, 'C', CAPTCHA_TTL, $cid);
 }
Пример #4
0
/**
 * Generate ekey.
 *
 * @param string $user_email
 * @return bool
 */
function fn_recover_password_generate_key($user_email, $notify = true)
{
    $result = true;
    if ($user_email) {
        $condition = '';
        if (fn_allowed_for('ULTIMATE')) {
            if (Registry::get('settings.Stores.share_users') == 'N' && AREA != 'A') {
                $condition = fn_get_company_condition('?:users.company_id');
            }
        }
        $uid = db_get_field("SELECT user_id FROM ?:users WHERE email = ?s" . $condition, $user_email);
        $u_data = fn_get_user_info($uid, false);
        if (isset($u_data['status']) && $u_data['status'] == 'D') {
            fn_set_notification('E', __('error'), __('error_account_disabled'));
            return false;
        }
        if (!empty($u_data['email'])) {
            $ekey = fn_generate_ekey($u_data['user_id'], 'U', SECONDS_IN_DAY);
            if ($notify) {
                Mailer::sendMail(array('to' => $u_data['email'], 'from' => 'default_company_users_department', 'data' => array('ekey' => $ekey, 'zone' => $u_data['user_type']), 'tpl' => 'profiles/recover_password.tpl'), fn_check_user_type_admin_area($u_data['user_type']) ? 'A' : 'C', $u_data['lang_code']);
                fn_set_notification('N', __('information'), __('text_password_recovery_instructions_sent'));
            } else {
                $result = array('company_id' => $u_data['company_id'], 'key' => $ekey, 'user_type' => $u_data['user_type']);
            }
        } else {
            fn_set_notification('E', __('error'), __('error_login_not_exists'));
            $result = false;
        }
    } else {
        fn_set_notification('E', __('error'), __('error_login_not_exists'));
        $result = false;
    }
    return $result;
}