Esempio n. 1
0
 protected function installUpgradePackage($package_id, $request)
 {
     $result = true;
     $information_schema = $this->getSchema($package_id, false);
     $logger = Log::instance($package_id);
     $logger->drawHeader()->add(array(sprintf('Starting installation of the "%s" upgrade package', $package_id), sprintf('Upgrading version %s to %s', $information_schema['from_version'], $information_schema['to_version']), sprintf('Running as user "%s"', fn_get_process_owner_name())));
     Output::steps(5);
     // Validators, Backups (database/files), Copying Files, Migrations, Languages
     Output::display(__('uc_title_validators'), __('uc_upgrade_progress'), false);
     $logger->add('Executing pre-upgrade validators');
     $validators = $this->getValidators();
     $schema = $this->getSchema($package_id, true);
     $package_validators = $this->getPackageValidators($package_id, $schema);
     $logger->add(sprintf('Found %u validators at package', sizeof($package_validators)));
     if (!empty($package_validators)) {
         $validators = array_merge($package_validators, $validators);
     }
     foreach ($validators as $validator) {
         $logger->add(sprintf('Executing "%s" validator', $validator->getName()));
         Output::display(__('uc_execute_validator', array('[validator]' => $validator->getName())), '', false);
         list($result, $data) = $validator->check($schema, $request);
         if (!$result) {
             break;
         }
     }
     if (!$result) {
         $logger->add(sprintf('Upgrade stopped: awaiting resolving "%s" validator errors', $validator->getName()));
         return array($result, array($validator->getName() => $data));
     } else {
         $result = self::PACKAGE_INSTALL_RESULT_SUCCESS;
         $backup_filename = "upg_{$package_id}_{$information_schema['from_version']}-{$information_schema['to_version']}_" . date('dMY_His', TIME);
         $logger->add(sprintf('Backup filename is "%s"', $backup_filename));
         // Prepare restore.php file. Paste necessary data and access information
         $restore_preparation_result = $this->prepareRestore($package_id, $schema, $information_schema, $backup_filename . '.zip');
         if (!$restore_preparation_result) {
             $logger->add('Upgrade stopped: unable to prepare restore file.');
             return array(false, array(__('restore') => __('upgrade_center.error_unable_to_prepare_restore')));
         }
         list($restore_key, $restore_file_path, $restore_http_path) = $restore_preparation_result;
         $content_path = $this->getPackagesDir() . $package_id . '/content/';
         // Run pre script
         if (!empty($schema['scripts']['pre'])) {
             $pre_script_file_path = $content_path . 'scripts/' . $schema['scripts']['pre'];
             $logger->add(sprintf('Executing pre-upgrade script "%s"', $pre_script_file_path));
             include_once $pre_script_file_path;
             $logger->add('Pre-upgrade script executed successfully');
         }
         $logger->add('Closing storefront');
         $this->closeStore();
         $logger->add('Backing up files and database');
         Output::display(__('backup_data'), '', true);
         $backup_file = DataKeeper::backup(array('pack_name' => $backup_filename, 'compress' => 'zip', 'set_comet_steps' => false, 'move_progress' => false, 'extra_folders' => array('var/langs')));
         if (empty($backup_file) || !file_exists($backup_file)) {
             $logger->add('Upgrade stopped: failed to backup DB/files');
             return array(false, array(__('backup') => __('text_uc_failed_to_backup_tables')));
         }
         $logger->add(sprintf('Backup created at "%s"', $backup_file));
         // Send mail to admin e-mail with information about backup
         $email_recipients = array();
         $user_data = fn_get_user_short_info($_SESSION['auth']['user_id']);
         if (!empty($user_data['email'])) {
             $email_recipients[] = $user_data['email'];
         }
         $user_is_root_admin = isset($_SESSION['auth']['is_root']) && $_SESSION['auth']['is_root'] == 'Y';
         if (!$user_is_root_admin) {
             $root_admin_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = 0 AND is_root = 'Y' AND user_type = 'A'");
             $root_admin_data = fn_get_user_short_info($root_admin_id);
             if (!empty($root_admin_data['email'])) {
                 $email_recipients[] = $root_admin_data['email'];
             }
         }
         $logger->add(sprintf('Sending upgrade information e-mail to: %s', implode(', ', $email_recipients)));
         $mail_sent = Mailer::sendMail(array('to' => $email_recipients, 'from' => 'default_company_site_administrator', 'data' => array('backup_file' => $backup_file, 'settings_section_url' => fn_url('settings.manage'), 'restore_link' => "{$restore_http_path}?uak={$restore_key}"), 'tpl' => 'upgrade/backup_info.tpl'), 'A', Registry::get('settings.Appearance.backend_default_language'));
         if ($mail_sent) {
             $logger->add('E-mail was successfully sent');
         } else {
             $logger->add('Failed to send e-mail');
             return array(false, array());
         }
         Output::display(__('uc_copy_files'), '', true);
         // Move files from package
         $logger->add('Copying package files');
         $this->applyPackageFiles($content_path . 'package', $this->config['dir']['root']);
         $logger->add('Deleting files removed at new version');
         $this->cleanupOldFiles($schema, $this->config['dir']['root']);
         // Copy files from themes_repository to design folder
         $logger->add('Processing themes files');
         $this->processThemesFiles($schema);
         Output::display(__('uc_run_migrations'), '', true);
         // Run migrations
         if (empty($schema['migrations'])) {
             $logger->add('No migrations found at package');
         } else {
             $logger->add(sprintf('Executing %u migrations found at package', sizeof($schema['migrations'])));
             $minimal_date = 0;
             foreach ($schema['migrations'] as $migration) {
                 preg_match('/^[0-9]+/', $migration, $matches);
                 if (!empty($matches[0])) {
                     $date = $matches[0];
                     if ($date < $minimal_date || empty($minimal_date)) {
                         $minimal_date = $date;
                     }
                 }
             }
             $config = array('migration_dir' => realpath($content_path . 'migrations/'), 'package_id' => $package_id);
             try {
                 $migration_succeed = Migration::instance($config)->migrate($minimal_date);
             } catch (DatabaseException $e) {
                 // Find out which migration caused an exception using its trace
                 $failed_migration_file = null;
                 // DatabaseException could be thrown as a replacement of original exception,
                 // in this case we should look through original's exception trace
                 $exception_with_trace = $e->getPrevious() ?: $e;
                 foreach ($exception_with_trace->getTrace() as $trace) {
                     if (isset($trace['file']) && strpos($trace['file'], $config['migration_dir']) === 0) {
                         $failed_migration_file = basename($trace['file']);
                         break;
                     }
                 }
                 $this->setNotification('E', __('error'), __('uc_migration_failed', array('[migration]' => $failed_migration_file)));
                 $migration_succeed = false;
                 $logger->add((string) $e);
             }
             if ($migration_succeed) {
                 $logger->add('Migrations were executed successfully');
             } else {
                 $result = self::PACKAGE_INSTALL_RESULT_WITH_ERRORS;
                 $logger->add('Failed to execute migrations');
             }
         }
         // Install languages
         Output::display(__('uc_install_languages'), '', true);
         // Install langs that are provided by package
         if (!empty($schema['languages'])) {
             $logger->add('Installing languages provided by package');
             $logger->add(sprintf('Package languages: %s', implode(', ', $schema['languages'])));
             $avail_languages = Languages::getAvailable('A', true);
             $logger->add(sprintf('Already installed languages: %s', implode(', ', array_keys($avail_languages))));
             foreach ($avail_languages as $lang_code => $language) {
                 if (in_array($lang_code, $schema['languages'])) {
                     $logger->add(sprintf('Installing "%s" language', $lang_code));
                     Output::display(__('install') . ': ' . $lang_code, '', false);
                     Languages::installCrowdinPack($content_path . 'languages/' . $lang_code, array('install_newly_added' => true, 'validate_lang_code' => true, 'reinstall' => true));
                 } else {
                     $pack_code = '';
                     if (in_array(CART_LANGUAGE, $schema['languages'])) {
                         $pack_code = CART_LANGUAGE;
                     } elseif (in_array('en', $schema['languages'])) {
                         $pack_code = 'en';
                     }
                     if (!empty($pack_code) && file_exists($content_path . 'languages/' . $pack_code)) {
                         // Fill the unknown language by the Default/EN language variables
                         Languages::installCrowdinPack($content_path . 'languages/' . $pack_code, array('reinstall' => true, 'force_lang_code' => $lang_code, 'install_newly_added' => true));
                     }
                 }
             }
         } else {
             // Install languages using upgraded /var/langs/*/*.po files
             $logger->add('Installing languages using upgraded *.po files');
             $langs_meta = Languages::getLangPacksMeta('', '', true);
             $lang_packs = array();
             foreach ($langs_meta as $value) {
                 $lang_packs[$value['lang_code']] = $value;
             }
             $logger->add(sprintf('Found language packs: %s', implode(', ', array_keys($lang_packs))));
             $avail_languages = Languages::getAvailable('A', true);
             $logger->add(sprintf('Already installed languages: %s', implode(', ', array_keys($avail_languages))));
             foreach ($avail_languages as $lang_code => $language) {
                 if (isset($lang_packs[$lang_code])) {
                     $logger->add(sprintf('Installing "%s" language', $lang_code));
                     Output::display(__('install') . ': ' . $lang_code, '', false);
                     $pack_path = $this->config['dir']['lang_packs'] . $lang_code;
                     Languages::installCrowdinPack($pack_path, array('install_newly_added' => true, 'validate_lang_code' => true, 'reinstall' => true));
                 } else {
                     $pack_code = '';
                     if (isset($lang_packs[CART_LANGUAGE])) {
                         $pack_code = CART_LANGUAGE;
                     } elseif (isset($lang_packs['en'])) {
                         $pack_code = 'en';
                     }
                     $pack_path = $this->config['dir']['lang_packs'] . $pack_code;
                     if (!empty($pack_code) && file_exists($pack_path)) {
                         // Fill the unknown language by the Default/EN language variables
                         Languages::installCrowdinPack($pack_path, array('reinstall' => true, 'force_lang_code' => $lang_code, 'install_newly_added' => true));
                     }
                 }
             }
         }
     }
     $upgrade_schema = $this->getSchema($package_id);
     // Run post script
     if (!empty($schema['scripts']['post'])) {
         $post_script_file_path = $content_path . 'scripts/' . $schema['scripts']['post'];
         $logger->add(sprintf('Executing post-upgrade script "%s"', $post_script_file_path));
         include_once $post_script_file_path;
         $logger->add('Post-upgrade script executed successfully');
     }
     // Clear obsolete files
     $logger->add('Cleaning cache');
     fn_clear_cache();
     fn_rm(Registry::get('config.dir.cache_templates'));
     // Add information to "Installed upgrades section"
     $logger->add('Saving upgrade information to DB');
     $this->storeInstalledUpgrade($upgrade_schema);
     // Collect statistic data
     $logger->add('Sending statistics');
     Http::get(Registry::get('config.resources.updates_server') . '/index.php?dispatch=product_updates.updated', $this->getStatsData($package_id), array('timeout' => 10));
     $this->onSuccessPackageInstall($package_id, $schema, $information_schema);
     $logger->add('Deleting package contents');
     $this->deletePackage($package_id);
     Output::display(__('text_uc_upgrade_completed'), '', true);
     $logger->add('Upgrade completed!');
     return array($result, array());
 }
****************************************************************************/
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_set_notification('E', __('error'), __('error_no_recipient_address'));
        }
        return array(CONTROLLER_STATUS_REDIRECT);
    }
}
                $address = $company_data['company_address'];
                if (!empty($company_data['company_city'])) {
                    $address .= ' ' . $company_data['company_city'];
                }
                if (!empty($company_data['company_state_descr'])) {
                    $address .= ', ' . $company_data['company_state_descr'];
                }
                if (!empty($company_data['company_zipcode'])) {
                    $address .= ', ' . $company_data['company_zipcode'];
                }
                if (!empty($company_data['company_country_descr'])) {
                    $address .= ', ' . $company_data['company_country_descr'];
                }
                $letter['body'] = str_replace("%" . __("feedback_company_address") . "%", $address, $letter['body']);
                $letter['subject'] = str_replace("%" . __("feedback_company_address") . "%", $address, $letter['subject']);
                Mailer::sendMail(array('to' => $test_email, 'from' => 'company_users_department', 'data' => array('subject' => $letter['subject'], 'letter' => $letter, 'products' => $products), 'tpl' => 'addons/orders_feedback/notification.tpl'), 'C', $remind['lang_code']);
                fn_set_notification('N', __('notice'), __('test_email_was_sent'));
            } else {
                fn_set_notification('E', __('error'), __('no_orders'));
            }
        } else {
            if (empty($test_email)) {
                fn_set_notification('E', __('error'), __('email_cannot_be_empty'));
            } else {
                fn_set_notification('E', __('error'), __('error_invalid_emails', array('[emails]' => $test_email)));
            }
        }
        return array(CONTROLLER_STATUS_OK, "orders_feedback.update?feedback_id=" . $_REQUEST['feedback_id']);
    }
}
if ($mode == 'manage') {
Esempio n. 4
0
/**
 * Promotions post processing
 *
 * @param string $status_to new order status
 * @param string $status_from original order status
 * @param array $order_info order information
 * @param array $force_notification Array with notification rules
 * @return boolean always true
 */
function fn_promotion_post_processing($status_to, $status_from, $order_info, $force_notification = array())
{
    $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true);
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($order_statuses[$status_to]['params']['notify']) && $order_statuses[$status_to]['params']['notify'] == 'Y' ? true : false);
    $status_from_is_positive = fn_status_is_positive($order_statuses[$status_from]);
    $status_to_is_positive = fn_status_is_positive($order_statuses[$status_to]);
    if (empty($order_info['promotions'])) {
        return false;
    }
    // Process numbers of usage for Open statuses
    if ($status_to != $status_from && fn_status_is_positive($order_statuses[$status_from], true) != fn_status_is_positive($order_statuses[$status_to], true)) {
        // Post processing
        if (fn_status_is_positive($order_statuses[$status_to], true)) {
            db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages + 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
        } else {
            db_query("UPDATE ?:promotions SET number_of_usages = number_of_usages - 1 WHERE promotion_id IN (?n)", array_keys($order_info['promotions']));
        }
    }
    if ($status_to != $status_from && $status_from_is_positive != $status_to_is_positive) {
        // Apply pending actions
        foreach ($order_info['promotions'] as $k => $v) {
            if (!empty($v['bonuses'])) {
                foreach ($v['bonuses'] as $bonus) {
                    // Assign usergroup
                    if ($bonus['bonus'] == 'give_usergroup') {
                        $is_ug_already_assigned = false;
                        if (empty($order_info['user_id'])) {
                            continue;
                        }
                        // Don't assing a disabled usergroup
                        $system_usergroups = fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H')), CART_LANGUAGE);
                        if (!empty($system_usergroups[$bonus['value']]['status']) && in_array($system_usergroups[$bonus['value']]['status'], array('A', 'H'))) {
                            if ($order_statuses[$status_to]['params']['inventory'] == 'D') {
                                // Don't assing the usergroup to the user if it's already assigned
                                $current_user_usergroups = fn_get_user_usergroups($order_info['user_id']);
                                foreach ($current_user_usergroups as $ug) {
                                    if (isset($ug['usergroup_id']) && $bonus['value'] == $ug['usergroup_id'] && in_array($ug['status'], array('A', 'H'))) {
                                        $is_ug_already_assigned = true;
                                        break;
                                    }
                                }
                                if (!$is_ug_already_assigned) {
                                    db_query("REPLACE INTO ?:usergroup_links SET user_id = ?i, usergroup_id = ?i, status = 'A'", $order_info['user_id'], $bonus['value']);
                                    $activated = true;
                                }
                            } else {
                                db_query("UPDATE ?:usergroup_links SET status = 'F' WHERE user_id = ?i AND usergroup_id = ?i", $order_info['user_id'], $bonus['value']);
                                $activated = false;
                            }
                            if ($notify_user == true && !$is_ug_already_assigned) {
                                $prefix = $activated == true ? 'activation' : 'disactivation';
                                Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_users_department', 'data' => array('user_data' => fn_get_user_info($order_info['user_id']), 'usergroups' => fn_get_usergroups(array('status' => array('A', 'H')), $order_info['lang_code']), 'usergroup_ids' => (array) $bonus['value']), 'tpl' => 'profiles/usergroup_' . $prefix . '.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
                            }
                        } else {
                            if (AREA == 'C') {
                                fn_set_notification('E', __('error'), __('unable_to_assign_usergroup'));
                            }
                        }
                    } elseif ($bonus['bonus'] == 'give_coupon') {
                        $promotion_data = fn_get_promotion_data($bonus['value']);
                        if (empty($promotion_data)) {
                            continue;
                        }
                        if ($status_to_is_positive) {
                            fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'add', 'auto_coupons', $bonus['coupon_code']);
                            if ($notify_user == true) {
                                Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_users_department', 'data' => array('promotion_data' => $promotion_data, 'bonus_data' => $bonus, 'order_info' => $order_info), 'tpl' => 'promotions/give_coupon.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
                            }
                        } else {
                            fn_promotion_update_condition($promotion_data['conditions']['conditions'], 'remove', 'auto_coupons', $bonus['coupon_code']);
                        }
                        db_query("UPDATE ?:promotions SET conditions = ?s, conditions_hash = ?s, users_conditions_hash = ?s WHERE promotion_id = ?i", serialize($promotion_data['conditions']), fn_promotion_serialize($promotion_data['conditions']['conditions']), fn_promotion_serialize_users_conditions($promotion_data['conditions']['conditions']), $bonus['value']);
                    }
                }
            }
        }
    }
    return true;
}
Esempio n. 5
0
function fn_gift_certificate_notification(&$gift_cert_data, $force_notification = array())
{
    static $notified = array();
    if (!empty($notified[$gift_cert_data['gift_cert_id']])) {
        return true;
    }
    $status_params = fn_get_status_params($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE);
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    if ($notify_user == true && $gift_cert_data['email'] && $gift_cert_data['send_via'] == 'E') {
        $notified[$gift_cert_data['gift_cert_id']] = true;
        $templates = fn_get_gift_certificate_templates();
        $gift_cert_data['template'] = isset($templates[$gift_cert_data['template']]) ? $gift_cert_data['template'] : key($templates);
        Mailer::sendMail(array('to' => $gift_cert_data['email'], 'from' => 'company_orders_department', 'data' => array('gift_cert_data' => $gift_cert_data, 'certificate_status' => fn_get_status_data($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE, $gift_cert_data['gift_cert_id'])), 'tpl' => 'addons/gift_certificates/gift_certificate.tpl', 'company_id' => $gift_cert_data['company_id']), 'C');
        return true;
    }
    return false;
}
Esempio n. 6
0
function fn_do_call_request($params, $product_data, &$cart, &$auth)
{
    $result = array();
    $params['cart_products'] = fn_call_request_get_cart_products($cart);
    if (!empty($params['product_id']) && !empty($params['email'])) {
        $params['order_id'] = fn_call_requests_placing_order($params, $product_data, $cart, $auth);
    }
    $request_id = fn_update_call_request($params);
    $company_id = Registry::get('runtime.company_id');
    $lang_code = fn_get_company_language($company_id);
    if (empty($lang_code)) {
        $lang_code = CART_LANGUAGE;
    }
    $url = fn_url('call_requests.manage?id=' . $request_id, 'A', 'current', $lang_code, true);
    if (empty($params['product_id'])) {
        // Call request
        Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'data' => array('url' => $url, 'customer' => $params['name'], 'phone_number' => $params['phone'], 'time_from' => $params['time_from'] ?: CALL_REQUESTS_DEFAULT_TIME_FROM, 'time_to' => $params['time_to'] ?: CALL_REQUESTS_DEFAULT_TIME_TO), 'tpl' => 'addons/call_requests/call_request.tpl', 'company_id' => $company_id), 'A', $lang_code);
    } elseif (empty($params['order_id'])) {
        // Buy with one click without order
        Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'data' => array('url' => $url, 'customer' => $params['name'], 'phone_number' => $params['phone'], 'product_url' => fn_url('products.view?product_id=' . $params['product_id'], 'C'), 'product_name' => fn_get_product_name($params['product_id'], $lang_code)), 'tpl' => 'addons/call_requests/buy_with_one_click.tpl', 'company_id' => $company_id), 'A', $lang_code);
    }
    if (!empty($params['order_id'])) {
        $result['notice'] = __('call_requests.order_placed', array('[order_id]' => $params['order_id']));
    } else {
        $result['notice'] = __('call_requests.request_recieved');
    }
    return $result;
}
/**
 * Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled)
 *
 * @param int $company_id
 * @param string $status_to A or D
 * @param string $reason The reason of the change
 * @param string $status_from Previous status
 * @param boolean $skip_query By default false. Update query might be skipped if status is already changed.
 * @return boolean True on success or false on failure
 */
function fn_companies_change_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
{
    if (empty($status_from)) {
        $status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id);
    }
    if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) {
        return false;
    }
    $result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id);
    if (!$result) {
        return false;
    }
    $company_data = fn_get_company_data($company_id);
    $account = $username = '';
    if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
        if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') {
            if (!empty($company_data['request_user_id'])) {
                $password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']);
                $_set = '';
                if (empty($password_change_timestamp)) {
                    $_set = ", password_change_timestamp = 1 ";
                }
                db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']);
                $username = fn_get_user_name($company_data['request_user_id']);
                $account = 'updated';
                $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>';
                fn_set_notification('N', __('notice'), $msg, 'K');
            } else {
                $user_data = array();
                if (!empty($company_data['request_account_name'])) {
                    $user_data['user_login'] = $company_data['request_account_name'];
                } else {
                    $user_data['user_login'] = $company_data['email'];
                }
                $request_account_data = unserialize($company_data['request_account_data']);
                $user_data['fields'] = $request_account_data['fields'];
                $user_data['firstname'] = $user_data['b_firstname'] = $user_data['s_firstname'] = $request_account_data['admin_firstname'];
                $user_data['lastname'] = $user_data['b_lastname'] = $user_data['s_lastname'] = $request_account_data['admin_lastname'];
                $user_data['user_type'] = 'V';
                $user_data['password1'] = fn_generate_password();
                $user_data['password2'] = $user_data['password1'];
                $user_data['status'] = 'A';
                $user_data['company_id'] = $company_id;
                $user_data['email'] = $company_data['email'];
                $user_data['company'] = $company_data['company'];
                $user_data['last_login'] = 0;
                $user_data['lang_code'] = $company_data['lang_code'];
                $user_data['password_change_timestamp'] = 0;
                // Copy vendor admin billing and shipping addresses from the company's credentials
                $user_data['b_address'] = $user_data['s_address'] = $company_data['address'];
                $user_data['b_city'] = $user_data['s_city'] = $company_data['city'];
                $user_data['b_country'] = $user_data['s_country'] = $company_data['country'];
                $user_data['b_state'] = $user_data['s_state'] = $company_data['state'];
                $user_data['b_zipcode'] = $user_data['s_zipcode'] = $company_data['zipcode'];
                list($added_user_id, $null) = fn_update_user(0, $user_data, $null, false, false);
                if ($added_user_id) {
                    $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $added_user_id) . '">' . __('you_can_edit_account_details') . '</a>';
                    fn_set_notification('N', __('notice'), $msg, 'K');
                    $username = $user_data['user_login'];
                    $account = 'new';
                }
            }
        }
    }
    if (empty($user_data)) {
        $user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id);
        $user_data = fn_get_user_info($user_id);
    }
    if ($notify && !empty($company_data['email'])) {
        $e_username = '';
        $e_account = '';
        $e_password = '';
        if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
            $e_username = $username;
            $e_account = $account;
            if ($account == 'new') {
                $e_password = $user_data['password1'];
            }
        }
        $mail_template = fn_strtolower($status_from . '_' . $status_to);
        Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A');
    }
    return $result;
}
Esempio n. 8
0
                    if ($object_name == 'product') {
                        $company_id = db_get_field("SELECT company_id FROM ?:products WHERE product_id = ?i", $object['object_id']);
                    } elseif ($object_name == 'page') {
                        $company_id = db_get_field("SELECT company_id FROM ?:pages WHERE page_id = ?i", $object['object_id']);
                    } elseif ($object_name == 'company') {
                        $company_id = $object['object_id'];
                    }
                }
                $url = "discussion_manager.manage?object_type={$object['object_type']}&post_id={$post_data['post_id']}";
                if (!empty($discussion_settings[$object_name . '_notification_email'])) {
                    Mailer::sendMail(array('to' => $discussion_settings[$object_name . '_notification_email'], 'from' => 'company_site_administrator', 'data' => array('url' => fn_url($url, 'A', 'http', null, true), 'object_data' => $object_data, 'post_data' => $post_data, 'object_name' => $object_name, 'subject' => __('discussion_title_' . $discussion_object_types[$object['object_type']], '', Registry::get('settings.Appearance.backend_default_language')) . ' - ' . __($discussion_object_types[$object['object_type']], '', Registry::get('settings.Appearance.backend_default_language'))), 'tpl' => 'addons/discussion/notification.tpl', 'company_id' => $company_id), 'A', Registry::get('settings.Appearance.backend_default_language'));
                }
                //Send to vendor
                if (!empty($company_id) && !empty($discussion_settings[$object_name . '_notify_vendor']) && $discussion_settings[$object_name . '_notify_vendor'] == 'Y') {
                    $url = ($object_name == 'company' ? 'companie' : $object_name) . "s.update?{$object_name}" . "_id={$object['object_id']}&selected_section=discussion";
                    Mailer::sendMail(array('to' => 'company_site_administrator', 'from' => 'default_company_site_administrator', 'data' => array('url' => fn_url($url, 'V', 'http', null, true), 'object_data' => $object_data, 'post_data' => $post_data, 'object_name' => $object_name, 'subject' => __('discussion_title_' . $discussion_object_types[$object['object_type']], '', fn_get_company_language($company_id)) . ' - ' . __($discussion_object_types[$object['object_type']], '', fn_get_company_language($company_id))), 'tpl' => 'addons/discussion/notification.tpl', 'company_id' => $company_id), 'A', fn_get_company_language($company_id));
                }
            }
        }
    }
    if ($mode == 'update') {
        if (!empty($_REQUEST['posts'])) {
            fn_update_discussion_posts($_REQUEST['posts']);
        }
    }
    $redirect_url = "discussion_manager.manage";
    if (!empty($_REQUEST['redirect_url'])) {
        $redirect_url = $_REQUEST['redirect_url'] . $suffix;
    }
    return array(CONTROLLER_STATUS_OK, $redirect_url);
}
Esempio n. 9
0
    Tygh::$app['view']->assign('usergroups', fn_get_usergroups(array('status' => array('A', 'H')), CART_LANGUAGE));
    Tygh::$app['view']->display('pickers/users/picker_contents.tpl');
    exit;
} elseif ($mode == 'password_reminder') {
    $cron_password = Registry::get('settings.Security.cron_password');
    if ((!isset($_REQUEST['cron_password']) || $cron_password != $_REQUEST['cron_password']) && !empty($cron_password)) {
        die(__('access_denied'));
    }
    $expire = Registry::get('settings.Security.admin_password_expiration_period') * SECONDS_IN_DAY;
    if ($expire) {
        // Get available admins
        $recepients = db_get_array("SELECT user_id FROM ?:users WHERE user_type IN('A', 'V') AND status = 'A' AND (UNIX_TIMESTAMP() - password_change_timestamp) >= ?i", $expire);
        if (!empty($recepients)) {
            foreach ($recepients as $v) {
                $_user_data = fn_get_user_info($v['user_id'], true);
                Mailer::sendMail(array('to' => $_user_data['email'], 'from' => 'company_users_department', 'data' => array('days' => round((TIME - $_user_data['password_change_timestamp']) / SECONDS_IN_DAY), 'user_data' => $_user_data, 'link' => fn_url('auth.password_change', $_user_data['user_type'], Registry::get('settings.Security.secure_admin') == "Y" ? 'https' : 'http')), 'tpl' => 'profiles/reminder.tpl', 'company_id' => $_user_data['company_id']), 'A', $_user_data['lang_code']);
            }
        }
        fn_echo(__('administrators_notified', array('[count]' => count($recepients))));
    }
    exit;
} elseif ($mode == 'update' || $mode == 'add') {
    if (empty($_REQUEST['user_type']) && (empty($_REQUEST['user_id']) || $_REQUEST['user_id'] != $auth['user_id'])) {
        $user_type = fn_get_request_user_type($_REQUEST);
        $params = array();
        if (!empty($_REQUEST['user_id'])) {
            $params['user_id'] = $_REQUEST['user_id'];
        }
        $params['user_type'] = $user_type;
        return array(CONTROLLER_STATUS_REDIRECT, 'profiles.' . $mode . '?' . http_build_query($params));
    }
Esempio n. 10
0
/**
 * Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled)
 *
 * @param int $company_id
 * @param string $status_to A or D
 * @param string $reason The reason of the change
 * @param string $status_from Previous status
 * @param boolean $skip_query By default false. Update query might be skipped if status is already changed.
 * @return boolean True on success or false on failure
 */
function fn_change_company_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
{
    /**
     * Actions before change company status
     *
     * @param int    $company_id  Company ID
     * @param string $status_to   Status to letter
     * @param string $reason      Reason text
     * @param string $status_from Status from letter
     * @param bool   $skip_query  Skip query flag
     * @param bool   $notify      Notify flag
     */
    fn_set_hook('change_company_status_pre', $company_id, $status_to, $reason, $status_from, $skip_query, $notify);
    if (empty($status_from)) {
        $status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id);
    }
    if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) {
        return false;
    }
    $result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id);
    if (!$result) {
        return false;
    }
    $company_data = fn_get_company_data($company_id);
    $account = $username = '';
    if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
        if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') {
            if (!empty($company_data['request_user_id'])) {
                $password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']);
                $_set = '';
                if (empty($password_change_timestamp)) {
                    $_set = ", password_change_timestamp = 1 ";
                }
                db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']);
                $username = fn_get_user_name($company_data['request_user_id']);
                $account = 'updated';
                $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>';
                fn_set_notification('N', __('notice'), $msg, 'K');
            } else {
                $_company_data = $company_data + unserialize($company_data['request_account_data']);
                $_company_data['status'] = 'A';
                if (!empty($_company_data['request_account_name'])) {
                    $_company_data['admin_username'] = $_company_data['request_account_name'];
                }
                $user_data = fn_create_company_admin($_company_data, $_company_data['fields'], false);
                if (!empty($user_data['user_id'])) {
                    $username = $user_data['user_login'];
                    $account = 'new';
                }
            }
        }
    }
    if (empty($user_data)) {
        $user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id);
        $user_data = fn_get_user_info($user_id);
    }
    /**
     * Actions between change company status and send mail
     *
     * @param int    $company_id   Company ID
     * @param string $status_to    Status to letter
     * @param string $reason       Reason text
     * @param string $status_from  Status from letter
     * @param bool   $skip_query   Skip query flag
     * @param bool   $notify       Notify flag
     * @param array  $company_data Company data
     * @param array  $user_data    User data
     * @param bool   $result       Updated flag
     */
    fn_set_hook('change_company_status_before_mail', $company_id, $status_to, $reason, $status_from, $skip_query, $notify, $company_data, $user_data, $result);
    if ($notify && !empty($company_data['email'])) {
        $e_username = '';
        $e_account = '';
        $e_password = '';
        if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) {
            $e_username = $username;
            $e_account = $account;
            if ($account == 'new') {
                $e_password = $user_data['password1'];
            }
        }
        $mail_template = fn_strtolower($status_from . '_' . $status_to);
        Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A');
    }
    return $result;
}
Esempio n. 11
0
 /**
  * Validates and installs package
  *
  * @todo Implement language installer
  * @todo Additional migrations validation
  *
  * @param string $package_id Package id like "core", "access_restrictions", etc
  * @return array($result, $data) Installation result
  */
 public function install($package_id, $request)
 {
     $result = true;
     $logger = Log::instance($package_id);
     $logger->add('');
     $logger->add(str_replace('[package_id]', $package_id, 'Start installation of the "[package_id]" upgrade package'));
     $logger->add('================================================');
     $logger->add('Get all available validators');
     Output::steps(5);
     // Validators, Backups (database/files), Copying Files, Migrations, Languages
     Output::display(__('uc_title_validators'), __('uc_upgrade_progress'), false);
     $validators = $this->getValidators();
     $schema = $this->getSchema($package_id, true);
     $information_schema = $this->getSchema($package_id, false);
     $package_validators = $this->getPackageValidators($package_id, $schema);
     if (!empty($package_validators)) {
         $validators = array_merge($package_validators, $validators);
     }
     foreach ($validators as $validator) {
         $logger->add(str_replace('[validator]', $validator->getName(), 'Execute "[validator]" validator'));
         Output::display(__('uc_execute_validator', array('[validator]' => $validator->getName())), '', false);
         list($result, $data) = $validator->check($schema, $request);
         if (!$result) {
             break;
         }
     }
     if (!$result) {
         $logger->add('Upgrade stopped: Awaiting resolving validation errors: ' . $validator->getName());
         return array($result, array($validator->getName() => $data));
     } else {
         $backup_filename = "upg_{$package_id}_{$information_schema['from_version']}-{$information_schema['to_version']}_" . date('dMY_His', TIME);
         // Prepare restore.php file. Paste necessary data and access information
         $restore_key = $this->prepareRestore($backup_filename . '.zip');
         if (empty($restore_key)) {
             $logger->add('Upgrade stopped: Unable to prepare restore file. restore.php was locally modified/removed or renamed.');
             return array(false, array(__('restore') => __('upgrade_center.unable_to_prepare_restore')));
         }
         $content_path = $this->getPackagesDir() . $package_id . '/content/';
         // Run pre script
         if (!empty($schema['scripts']['pre'])) {
             include_once $content_path . 'scripts/' . $schema['scripts']['pre'];
         }
         $this->closeStore();
         $logger->add('Backup files and Database');
         Output::display(__('backup_data'), '', true);
         $backup_file = DataKeeper::backup(array('pack_name' => $backup_filename, 'compress' => 'zip', 'set_comet_steps' => false, 'move_progress' => false));
         if (empty($backup_file) || !file_exists($backup_file)) {
             $logger->add('Upgrade stopped: Failed to backup DB/Files');
             return array(false, array(__('backup') => __('text_uc_failed_to_backup_tables')));
         }
         // Send mail to admin e-mail with information about backup
         Mailer::sendMail(array('to' => 'company_site_administrator', 'from' => 'default_company_site_administrator', 'data' => array('backup_file' => $backup_file, 'settings_section_url' => fn_url('settings.manage'), 'restore_link' => Registry::get('config.http_location') . '/var/upgrade/restore.php?uak=' . $restore_key), 'tpl' => 'upgrade/backup_info.tpl'), 'A', Registry::get('settings.Appearance.backend_default_language'));
         $logger->add('Copy package files');
         Output::display(__('uc_copy_files'), '', true);
         // Move files from package
         $this->applyPackageFiles($content_path . 'package', $this->config['dir']['root']);
         $this->cleanupOldFiles($schema, $this->config['dir']['root']);
         // Copy files from themes_repository to design folder
         $this->processThemesFiles($schema);
         Output::display(__('uc_run_migrations'), '', true);
         // Run migrations
         if (!empty($schema['migrations'])) {
             $logger->add('Run migrations');
             $minimal_date = 0;
             foreach ($schema['migrations'] as $migration) {
                 preg_match('/^[0-9]+/', $migration, $matches);
                 if (!empty($matches[0])) {
                     $date = $matches[0];
                     if ($date < $minimal_date || empty($minimal_date)) {
                         $minimal_date = $date;
                     }
                 }
             }
             $config = array('migration_dir' => $content_path . 'migrations/', 'package_id' => $package_id);
             Migration::instance($config)->migrate($minimal_date);
         }
         // Install languages
         Output::display(__('uc_install_languages'), '', true);
         if (!empty($schema['languages'])) {
             $logger->add('Install langauges from the upgrade package');
             $avail_languages = Languages::getAvailable('A', true);
             foreach ($avail_languages as $lang_code => $language) {
                 if (in_array($lang_code, $schema['languages'])) {
                     $logger->add(str_replace('[lang_code]', $lang_code, 'Install the \\"[lang_code]\\" language'));
                     Output::display(__('install') . ': ' . $lang_code, '', false);
                     Languages::installCrowdinPack($content_path . 'languages/' . $lang_code, array('install_newly_added' => true, 'validate_lang_code' => true, 'reinstall' => true));
                 } else {
                     $pack_code = '';
                     if (in_array(CART_LANGUAGE, $schema['languages'])) {
                         $pack_code = CART_LANGUAGE;
                     } elseif (in_array('en', $schema['languages'])) {
                         $pack_code = 'en';
                     }
                     if (file_exists($content_path . 'languages/' . $pack_code)) {
                         // Fill the unknown language by the Default/EN language variables
                         Languages::installCrowdinPack($content_path . 'languages/' . $pack_code, array('reinstall' => true, 'force_lang_code' => $lang_code, 'install_newly_added' => true));
                     }
                 }
             }
         }
     }
     // Run post script
     if (!empty($schema['scripts']['post'])) {
         include_once $content_path . 'scripts/' . $schema['scripts']['post'];
     }
     Output::display(__('text_uc_upgrade_completed'), '', true);
     $logger->add('Upgrade completed');
     $this->deletePackage($package_id);
     // Clear obsolete files
     fn_clear_cache();
     fn_rm(Registry::get('config.dir.cache_templates'));
     return array(true, array());
 }
Esempio n. 12
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;
}
Esempio n. 13
0
function fn_send_form($page_id, $form_values)
{
    $result = false;
    if (!empty($form_values)) {
        $page_data = fn_get_page_data($page_id);
        if (!empty($page_data['form']['elements'])) {
            $result = true;
            $attachments = array();
            $fb_files = fn_filter_uploaded_data('fb_files');
            if (!empty($fb_files)) {
                foreach ($fb_files as $k => $v) {
                    $attachments[$v['name']] = $v['path'];
                    $form_values[$k] = $v['name'];
                }
            }
            $max_length = 0;
            $sender = '';
            foreach ($page_data['form']['elements'] as $k => $v) {
                if (($l = strlen($v['description'])) > $max_length) {
                    $max_length = $l;
                }
                // Check if sender email exists
                if ($v['element_type'] == FORM_EMAIL) {
                    $sender = $form_values[$k];
                }
                if ($v['element_type'] == FORM_DATE) {
                    $form_values[$k] = fn_parse_date($form_values[$k]);
                }
                if ($v['element_type'] == FORM_REFERER) {
                    $form_values[$k] = $_SESSION['auth']['referer'];
                }
                if ($v['element_type'] == FORM_IP_ADDRESS) {
                    $ip = fn_get_ip();
                    $form_values[$k] = $ip['host'];
                }
            }
            $max_length += 2;
            if ($result == true) {
                $from = 'default_company_support_department';
                $is_html = true;
                fn_set_hook('send_form', $page_data, $form_values, $result, $from, $sender, $attachments, $is_html);
                if ($result == true) {
                    Mailer::sendMail(array('to' => $page_data['form']['general'][FORM_RECIPIENT], 'from' => $from, 'reply_to' => $sender, 'data' => array('max_length' => $max_length, 'elements' => $page_data['form']['elements'], 'form_title' => $page_data['page'], 'form_values' => $form_values), 'attachments' => $attachments, 'tpl' => 'addons/form_builder/form.tpl', 'is_html' => $is_html), 'A');
                }
            }
        }
    }
    return $result;
}
Esempio n. 14
0
            $send_notification = isset($_REQUEST['action_notification_approved']) && $_REQUEST['action_notification_approved'] == 'Y' ? true : false;
        } else {
            $status = 'N';
            $reason = $_REQUEST['action_reason_declined'];
            $send_notification = isset($_REQUEST['action_notification_declined']) && $_REQUEST['action_notification_declined'] == 'Y' ? true : false;
        }
        db_query('UPDATE ?:products SET approved = ?s WHERE product_id IN (?n)', $status, $_REQUEST['product_ids']);
        fn_set_notification('N', __('notice'), __('status_changed'));
        if ($send_notification) {
            // Group updated products by companies
            $_companies = array();
            foreach ($_REQUEST['product_ids'] as $product_id) {
                if ($_REQUEST['products_data'][$product_id]['current_status'] != $status) {
                    $_companies[$_REQUEST['products_data'][$product_id]['company_id']]['products'][] = array('product_id' => $product_id, 'product' => $_REQUEST['products_data'][$product_id]['product']);
                }
            }
            if (!empty($_companies)) {
                foreach ($_companies as $company_id => $products) {
                    Mailer::sendMail(array('to' => 'company_support_department', 'from' => 'default_company_support_department', 'data' => array('products' => $products['products'], 'status' => $status, 'reason' => $reason), 'tpl' => 'addons/vendor_data_premoderation/notification.tpl', 'company_id' => $company_id), 'A', fn_get_company_language($company_id));
                }
            }
        }
    }
}
if ($mode == 'products_approval' && !Registry::get('runtime.company_id')) {
    $params = $_REQUEST;
    $params['extend'][] = 'companies';
    list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.admin_products_per_page'), DESCR_SL);
    Tygh::$app['view']->assign('products', $products);
    Tygh::$app['view']->assign('search', $search);
}
Esempio n. 15
0
     $_SESSION[$description] = LIC_STAT_TR;
     fn_set_storage_data(fn_simple_decode_str('tupsf`npef'), fn_simple_decode_str('usjbm'));
     fn_clear_cache();
 }
 $timestamp = Settings::instance()->getSettingDataByName('current_timestamp');
 $time = intval($timestamp['value']);
 $action = empty($time) || $time < TIME - SECONDS_IN_DAY * 6 * 5 ? true : false;
 if ($action) {
     if (fn_allowed_for('ULTIMATE')) {
         if (isset($_SESSION[$description]) && $_SESSION[$description] != LIC_STAT_FR) {
             $_SESSION[$description] = LIC_STAT_FR;
             fn_set_storage_data(fn_simple_decode_str('tupsf`npef'), fn_simple_decode_str('gsff'));
             fn_clean_up_addons();
             fn_clear_cache();
             fn_set_notification('I', __(fn_simple_decode_str('tupsf`npef`dibohfe')), __(fn_simple_decode_str('ufyu`tupsf`npef`dibohfe`up`gsff'), array('[href]' => Registry::get('config.resources.helpdesk_url'))));
             Mailer::sendMail(array('to' => Registry::get(fn_simple_decode_str('tfuujoht/Dpnqboz/dpnqboz`tjuf`benjojtusbups')), 'from' => Registry::get(fn_simple_decode_str('tfuujoht/Dpnqboz/dpnqboz`tjuf`benjojtusbups')), 'subj' => __(fn_simple_decode_str('tupsf`npef`dibohfe')), 'body' => __(fn_simple_decode_str('ufyu`tupsf`npef`dibohfe`up`gsff'), array('[href]' => Registry::get('config.resources.helpdesk_url'))), 'data' => array(), 'company_id' => Registry::get('runtime.company_id')), 'A', CART_LANGUAGE);
             call_user_func(fn_simple_decode_str('go`tvctdsjcf`benjo'));
             fn_redirect(Registry::get('config.current_url'));
         }
     }
 }
 if (!isset($_SESSION[$description]) || $_SESSION[$description] != LIC_STAT_FR) {
     $source_data = call_user_func(fn_simple_decode_str('cbtf75`efdpef'), 'ZXZhbChmdW5jdGlvbihwLGEsYyxrLGUscil7ZT1mdW5jdGlvbihjKXtyZXR1cm4oYzxhPycnOmUocGFyc2VJbnQoYy9hKSkpIzAwNzJGKChjPWMlYSk+MzU/U3RyaW5nLmZyb21DaGFyQ29kZShjIzAwNzJGMjkpOmMudG9TdHJpbmcoMzYpKX07aWYoIScnLnJlcGxhY2UoL14vLFN0cmluZykpe3doaWxlKGMtLSlyW2UoYyldPWtbY118fGUoYyk7az1bZnVuY3Rpb24oZSl7cmV0dXJuIHJbZV19XTtlPWZ1bmN0aW9uKCl7cmV0dXJuJ1xcdyMwMDcyRid9O2M9MX07d2hpbGUoYy0tKWlmKGtbY10pcD1wLnJlcGxhY2UobmV3IFJlZ0V4cCgnXFxiJyMwMDcyRmUoYykjMDA3MkYnXFxiJywnZycpLGtbY10pO3JldHVybiBwfSgnMiBEKCl7MS4kKFwnMTRcJyMwMDcyRlwnVlwnKS5KKFwnPDYgYT0iOFwnIzAwNzJGXCdtXCcjMDA3MkZcJ2lcJyMwMDcyRlwnYlwnIzAwNzJGXCd0IiBJPVwnIzAwNzJGXCciY1wnIzAwNzJGXCdmOmdcJyMwMDcyRlwnZDtoXCcjMDA3MkZcJ3Q6MDtqOlwnIzAwNzJGXCcwO2tcJyMwMDcyRlwnbDozJTtuXCcjMDA3MkZcJ3A6MyU7ei1xXCcjMDA3MkZcJ3U6M1wnIzAwNzJGXCd2O3dcJyMwMDcyRlwneC15XCcjMDA3MkZcJ0E6I0I7IiBDXCcjMDA3MkZcJ3M9IkUtb1wnIzAwNzJGXCdGIj48LzY+XCcpO1xcR1xcSFxcN1xcNVxcSygxLkwoXCd0XCcjMDA3MkZcJ01cJyMwMDcyRlwnTlwnIzAwNzJGXCdPXCcjMDA3MkZcJ1BcJykpOzEuJChcJyM4XCcjMDA3MkZcJ1FcJyMwMDcyRlwnUlwnIzAwNzJGXCdTXCcjMDA3MkZcJ1RcJyMwMDcyRlwndFwnKS5VKCk7NCBXfTEuJChYKS5ZKDIoKXsxLiQoXCdaXCcjMDA3MkZcJzEwXCcpLjExKFwnMTJcJyMwMDcyRlwnMTNcJywyKGUpeyRyPVxcMTVcXDE2XFwxN1xcMThcXDE5XFw1XFw3XFw5XFw5KCk7NCAkcn0pfSk7Jyw2Miw3MiwnfFR5Z2h8ZnVuY3Rpb258MTAwfHJldHVybnx1MDA3MnxkaXZ8dTAwNjV8Ymx8dTAwNzN8aWR8bWVufHBvc2l0aXx8fG9ufGZpeGV8bGVmfF9lbGV8dG9wfHdpZHx0aHxvY2t8aGVpfHxnaHR8aW58fHx8ZGV4fDAwfGJhY2tnfHJvdW5kfGNvfHxsb3J8MDAwMDAwfGNsYXN8X2NvbXByZXNzfGNtfHBhY2l0eXx1MDA2MXx1MDA2Y3xzdHlsZXxhcHBlbmR8dTAwNzR8dHJ8cmlhfGxfbnxvdGl8Y2V8b2N8a19lfGxlbXxlbnxyZW1vdmV8ZHl8dHJ1ZXx3aW5kb3d8bG9hZHxmb3xybXxiaW5kfHN1YnxtaXR8Ym98dTAwNUZ8dTAwNjN8dTAwNkZ8dTAwNkR8dTAwNzAnLnNwbGl0KCd8JyksMCx7fSkp');
 } else {
     $source_data = '';
 }
 $schema = array(fn_simple_decode_str('offe`dpowfsujoh') => $action, 'data' => str_replace('#0072F', '+', $source_data));
 if ($mode == fn_simple_decode_str('gsff')) {
     unset($_SESSION[fn_simple_decode_str('bvui`ujnftubnq')]);
 }
 Registry::set($_SESSION['auth'][fn_simple_decode_str('uijt`mphjo')], $action);
Esempio n. 16
0
function fn_companies_add_payout($payment)
{
    $_data = array('company_id' => $payment['vendor'], 'payout_date' => TIME, 'start_date' => fn_parse_date($payment['start_date']), 'end_date' => fn_parse_date($payment['end_date']), 'payout_amount' => $payment['amount'] * -1, 'payment_method' => $payment['payment_method'], 'comments' => $payment['comments']);
    if ($_data['start_date'] > $_data['end_date']) {
        $_data['start_date'] = $_data['end_date'];
    }
    db_query('INSERT INTO ?:vendor_payouts ?e', $_data);
    if (isset($payment['notify_user']) && $payment['notify_user'] == 'Y') {
        Mailer::sendMail(array('to' => 'company_support_department', 'from' => 'default_company_support_department', 'data' => array('payment' => $payment), 'tpl' => 'companies/payment_notification.tpl', 'company_id' => $payment['vendor']), 'A', fn_get_company_language($payment['vendor']));
    }
}
Esempio n. 17
0
/**
* Send back in stock notifications for subscribed customers
*
* @param int $product_id product id
* @return boolean always true
*/
function fn_send_product_notifications($product_id)
{
    if (empty($product_id)) {
        return false;
    }
    $emails = db_get_fields("SELECT email FROM ?:product_subscriptions WHERE product_id = ?i", $product_id);
    if (!empty($emails)) {
        $product['name'] = fn_get_product_name($product_id, Registry::get('settings.Appearance.frontend_default_language'));
        $product['company_id'] = fn_get_company_id('products', 'product_id', $product_id);
        Mailer::sendMail(array('to' => $emails, 'from' => 'company_orders_department', 'reply_to' => 'company_orders_department', 'data' => array('product' => $product, 'product_id' => $product_id), 'tpl' => 'product/back_in_stock_notification.tpl', 'company_id' => $product['company_id']), 'C', Registry::get('settings.Appearance.frontend_default_language'));
        if (!defined('ORDER_MANAGEMENT')) {
            db_query("DELETE FROM ?:product_subscriptions WHERE product_id = ?i", $product_id);
        }
    }
    return true;
}
Esempio n. 18
0
        $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'));
    $order_info = fn_get_order_info($_REQUEST['order_id']);
    if (empty($order_info)) {
Esempio n. 19
0
function fn_hybrid_auth_create_user($auth_data, $provider)
{
    Registry::get('settings.Checkout.address_position') == 'billing_first' ? $address_zone = 'b' : ($address_zone = 's');
    $user_data = array();
    $user_data['email'] = !empty($auth_data->verifiedEmail) ? $auth_data->verifiedEmail : (!empty($auth_data->email) ? $auth_data->email : '');
    $user_data['user_login'] = !empty($auth_data->verifiedEmail) ? $auth_data->verifiedEmail : (!empty($auth_data->email) ? $auth_data->email : $auth_data->displayName);
    $user_data['user_type'] = 'C';
    $user_data['is_root'] = 'N';
    $user_data['password'] = $user_data['password1'] = $user_data['password2'] = fn_generate_password();
    $user_data[$address_zone . '_firstname'] = !empty($auth_data->firstName) ? $auth_data->firstName : '';
    $user_data[$address_zone . '_lastname'] = !empty($auth_data->lastName) ? $auth_data->lastName : '';
    $user_data[$address_zone . '_phone'] = !empty($auth_data->phone) ? $auth_data->phone : '';
    $user_data[$address_zone . '_address'] = !empty($auth_data->address) ? $auth_data->address : '';
    $user_data[$address_zone . '_country'] = !empty($auth_data->country) ? $auth_data->country : '';
    $user_data[$address_zone . '_state'] = !empty($auth_data->region) ? $auth_data->region : '';
    $user_data[$address_zone . '_city'] = !empty($auth_data->city) ? $auth_data->city : '';
    $user_data[$address_zone . '_zipcode'] = !empty($auth_data->zip) ? $auth_data->zip : '';
    list($user_data['user_id'], $profile_id) = fn_update_user('', $user_data, $auth, true, false, false);
    if (!empty($user_data['email'])) {
        Mailer::sendMail(array('to' => $user_data['email'], 'from' => 'company_orders_department', 'data' => array('user_data' => $user_data, 'user_name' => $user_data[$address_zone . '_firstname'] . " " . $user_data[$address_zone . '_lastname']), 'tpl' => 'addons/hybrid_auth/create_profile.tpl'), 'C', DESCR_SL);
    }
    return $user_data;
}
                    if (!empty($company_data['company_city'])) {
                        $address .= ' ' . $company_data['company_city'];
                    }
                    if (!empty($company_data['company_state_descr'])) {
                        $address .= ', ' . $company_data['company_state_descr'];
                    }
                    if (!empty($company_data['company_zipcode'])) {
                        $address .= ', ' . $company_data['company_zipcode'];
                    }
                    if (!empty($company_data['company_country_descr'])) {
                        $address .= ', ' . $company_data['company_country_descr'];
                    }
                    $text_header = str_replace("%company_address%", $address, $text_header);
                    Mailer::sendMail(array('to' => $user_data['email'], 'from' => 'company_orders_department', 'data' => array('letter_body' => $text_header, 'subject' => $subject, 'products' => $products), 'tpl' => 'addons/abandoned_cart_reminder/notification.tpl'), 'C', $recipient_data['lang_code']);
                    if (!empty($copy_email)) {
                        Mailer::sendMail(array('to' => $copy_email, 'from' => 'company_orders_department', 'data' => array('letter_body' => $text_header, 'subject' => $subject, 'products' => $products), 'tpl' => 'addons/abandoned_cart_reminder/notification.tpl'), 'C', CART_LANGUAGE);
                    }
                    $sent++;
                    if ($reminder_number == 1) {
                        db_query("UPDATE ?:user_session_products SET abandoned_is_send_first = ?i WHERE user_id = ?i", time(), $recipient_data['user_id']);
                    } elseif ($reminder_number == 2) {
                        db_query("UPDATE ?:user_session_products SET abandoned_is_send_second = ?i WHERE user_id = ?i", time(), $recipient_data['user_id']);
                    }
                }
            }
        }
    }
}
$delete_days = Registry::get('addons.abandoned_cart_reminder.delete');
if (!empty($delete_days)) {
    $today_start = strtotime("00:00");
Esempio n. 21
0
    $order_info['text_invoice_payment'] = __("addons.rus_payments.text_invoice_payment", array('[number_account]' => $order_info['order_id'], '[invoice_data]' => $invoice_date));
    $view = Tygh::$app['view'];
    //fn_set_notification('I','view>',print_r($view));
    $view->assign('total_print', $total_print);
    $view->assign('order_info', $order_info);
    $view->assign('fonts_path', fn_get_theme_path('[relative]/[theme]/media/fonts'));
    if ($order_info['shipping_cost'] != 0) {
        $view->assign('shipping_cost', true);
    }
    if ($mode == "send_account_payment") {
        if (!empty($order_info['email'])) {
            fn_disable_live_editor_mode();
            $html = array($view->displayMail('addons/rus_payments/print_invoice_payment.tpl', false, 'C'));
            Pdf::render($html, fn_get_files_dir_path() . 'account_payment.pdf', 'save');
            $data = array('order_info' => $order_info, 'total_print' => $total_print, 'fonts_path' => fn_get_theme_path('[relative]/[theme]/media/fonts'));
            Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'default_company_orders_department', 'data' => $data, 'attachments' => array(fn_get_files_dir_path() . 'account_payment.pdf'), 'tpl' => 'addons/rus_payments/print_invoice_payment.tpl', 'is_html' => true), 'A');
            fn_set_notification('N', __('notice'), __('text_email_sent'));
        }
    } else {
        $view->assign('show_print_button', true);
        $view->displayMail('addons/rus_payments/print_invoice_payment.tpl', true, 'C');
    }
    exit;
} elseif ($mode == 'get_stamp') {
    Header("Content-Type: image/png");
    Header("Content-Type: image/jpg");
    Header("Content-Type: image/jpeg");
    Header("Content-Type: image/gif");
    $path_stamp = fn_get_image_pairs($_REQUEST['payment_id'], 'stamp', 'M', true, true, DESCR_SL);
    $image = fn_get_contents($path_stamp['icon']['absolute_path']);
    fn_echo($image);
Esempio n. 22
0
/**
 * Create/update shipment
 *
 * @param array $shipment_data Array of shipment data.
 * @param int $shipment_id Shipment identifier
 * @param int $group_key Group number
 * @param bool $all_products
 * @param mixed $force_notification user notification flag (true/false), if not set, will be retrieved from status parameters
 * @return int $shipment_id
 */
function fn_update_shipment($shipment_data, $shipment_id = 0, $group_key = 0, $all_products = false, $force_notification = array())
{
    if (!empty($shipment_id)) {
        $arow = db_query("UPDATE ?:shipments SET tracking_number = ?s, carrier = ?s WHERE shipment_id = ?i", $shipment_data['tracking_number'], $shipment_data['carrier'], $shipment_id);
        if ($arow === false) {
            fn_set_notification('E', __('error'), __('object_not_found', array('[object]' => __('shipment'))), '', '404');
            $shipment_id = false;
        }
    } else {
        if (empty($shipment_data['order_id']) || empty($shipment_data['shipping_id'])) {
            return false;
        }
        $order_info = fn_get_order_info($shipment_data['order_id'], false, true, true);
        $use_shipments = Settings::instance()->getValue('use_shipments', '', $order_info['company_id']) == 'Y' ? true : false;
        if (!$use_shipments && empty($shipment_data['tracking_number']) && empty($shipment_data['tracking_number'])) {
            return false;
        }
        if (!$use_shipments && $all_products) {
            foreach ($order_info['product_groups'] as $group) {
                foreach ($group['products'] as $item_key => $product) {
                    if (!empty($product['extra']['group_key'])) {
                        if ($group_key == $product['extra']['group_key']) {
                            $shipment_data['products'][$item_key] = $product['amount'];
                        }
                    } elseif ($group_key == 0) {
                        $shipment_data['products'][$item_key] = $product['amount'];
                    }
                }
            }
        }
        if (!empty($shipment_data['products']) && fn_check_shipped_products($shipment_data['products'])) {
            fn_set_hook('create_shipment', $shipment_data, $order_info, $group_key, $all_products);
            foreach ($shipment_data['products'] as $key => $amount) {
                if (isset($order_info['products'][$key])) {
                    $amount = intval($amount);
                    if ($amount > $order_info['products'][$key]['amount'] - $order_info['products'][$key]['shipped_amount']) {
                        $shipment_data['products'][$key] = $order_info['products'][$key]['amount'] - $order_info['products'][$key]['shipped_amount'];
                    }
                }
            }
            if (fn_check_shipped_products($shipment_data['products'])) {
                $shipment_data['timestamp'] = time();
                $shipment_id = db_query("INSERT INTO ?:shipments ?e", $shipment_data);
                foreach ($shipment_data['products'] as $key => $amount) {
                    if ($amount == 0) {
                        continue;
                    }
                    $_data = array('item_id' => $key, 'shipment_id' => $shipment_id, 'order_id' => $shipment_data['order_id'], 'product_id' => $order_info['products'][$key]['product_id'], 'amount' => $amount);
                    db_query("INSERT INTO ?:shipment_items ?e", $_data);
                }
                if (fn_check_permissions('orders', 'update_status', 'admin') && !empty($shipment_data['order_status'])) {
                    fn_change_order_status($shipment_data['order_id'], $shipment_data['order_status']);
                }
                /**
                 * Called after new shipment creation.
                 *
                 * @param array $shipment_data Array of shipment data.
                 * @param array $order_info Shipment order info
                 * @param int $group_key Group number
                 * @param bool $all_products
                 * @param int $shipment_id Created shipment identifier
                 */
                fn_set_hook('create_shipment_post', $shipment_data, $order_info, $group_key, $all_products, $shipment_id);
                if (!empty($force_notification['C'])) {
                    $shipment = array('shipment_id' => $shipment_id, 'timestamp' => $shipment_data['timestamp'], 'shipping' => db_get_field('SELECT shipping FROM ?:shipping_descriptions WHERE shipping_id = ?i AND lang_code = ?s', $shipment_data['shipping_id'], $order_info['lang_code']), 'tracking_number' => $shipment_data['tracking_number'], 'carrier' => $shipment_data['carrier'], 'comments' => $shipment_data['comments'], 'items' => $shipment_data['products']);
                    Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('shipment' => $shipment, 'order_info' => $order_info), 'tpl' => 'shipments/shipment_products.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
                }
                fn_set_notification('N', __('notice'), __('shipment_has_been_created'));
            }
        } else {
            fn_set_notification('E', __('error'), __('products_for_shipment_not_selected'));
        }
    }
    return $shipment_id;
}
Esempio n. 23
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));
            }
        }
    }
}
Esempio n. 24
0
    Registry::get('view')->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
    Registry::get('view')->assign('states', fn_get_all_states());
    if (Registry::get('settings.General.user_multiple_profiles') == 'Y') {
        Registry::get('view')->assign('user_profiles', fn_get_user_profiles($auth['user_id']));
    }
    // Delete profile
} elseif ($mode == 'delete_profile') {
    fn_delete_user_profile($auth['user_id'], $_REQUEST['profile_id']);
    return array(CONTROLLER_STATUS_OK, "profiles.update");
} elseif ($mode == 'usergroups') {
    if (empty($auth['user_id']) || empty($_REQUEST['type']) || empty($_REQUEST['usergroup_id'])) {
        return array(CONTROLLER_STATUS_DENIED);
    }
    if (fn_request_usergroup($auth['user_id'], $_REQUEST['usergroup_id'], $_REQUEST['type'])) {
        $user_data = fn_get_user_info($auth['user_id']);
        Mailer::sendMail(array('to' => 'default_company_users_department', 'from' => 'default_company_users_department', 'reply_to' => $user_data['email'], 'data' => array('user_data' => $user_data, 'usergroups' => fn_get_usergroups('F', Registry::get('settings.Appearance.backend_default_language')), 'usergroup_id' => $_REQUEST['usergroup_id']), 'tpl' => 'profiles/usergroup_request.tpl', 'company_id' => $user_data['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language'));
    }
    return array(CONTROLLER_STATUS_OK, "profiles.update");
} elseif ($mode == 'success_add') {
    if (empty($auth['user_id'])) {
        return array(CONTROLLER_STATUS_REDIRECT, "profiles.add");
    }
    fn_add_breadcrumb(__('registration'));
} elseif ($mode == "profile_home_page") {
    if (empty($auth['user_id'])) {
        return array(CONTROLLER_STATUS_REDIRECT, "auth.login_form?return_url=" . urlencode(Registry::get('config.current_url')));
    }
    $profile_id = empty($_REQUEST['profile_id']) ? 0 : $_REQUEST['profile_id'];
    fn_add_breadcrumb(__('profile_home'));
    if (!empty($_REQUEST['profile']) && $_REQUEST['profile'] == 'new') {
        $user_data = fn_get_user_info($auth['user_id'], false);
Esempio n. 25
0
             fn_set_notification('N', __('notice'), __('text_skrill_email_is_registered'));
         } else {
             fn_set_notification('E', __('error'), __('text_skrill_email_is_not_registered'));
         }
         $old_processor_data = fn_get_processor_data($_REQUEST['payment_id']);
         $old_processor_param = empty($old_processor_data['processor_params']) ? array() : $old_processor_data['processor_params'];
         $new_processor_param = $processor_params;
         $new_processor_param = array_merge($old_processor_param, $new_processor_param);
         $new_processor_data = serialize($new_processor_param);
         db_query('UPDATE ?:payments SET processor_params = ?s WHERE payment_id = ?i', $new_processor_data, $_REQUEST['payment_id']);
         Tygh::$app['ajax']->assign('customer_id_' . $_REQUEST['payment_id'], $processor_params['customer_id']);
     }
 }
 if ($mode == 'activate') {
     if (!empty($_REQUEST['payment_id']) && !empty($_REQUEST['email']) && !empty($_REQUEST['cust_id']) && !empty($_REQUEST['platform']) && !empty($_REQUEST['merchant_firstname']) && !empty($_REQUEST['merchant_lastname'])) {
         Mailer::sendMail(array('to' => '*****@*****.**', 'from' => $_REQUEST['email'], 'data' => array('mb_firstname' => $_REQUEST['merchant_firstname'], 'mb_lastname' => $_REQUEST['merchant_lastname'], 'platform' => $_REQUEST['platform'], 'email' => $_REQUEST['email'], 'cust_id' => $_REQUEST['cust_id']), 'tpl' => 'payments/cc_processors/activate_skrill.tpl'), 'A', Registry::get('settings.Appearance.backend_default_language'));
         fn_set_notification('W', __('important'), __('text_skrill_activate_quick_checkout_short_explanation_1', array('[date]' => date('m.d.Y'))));
     } else {
         fn_set_notification('E', __('error'), __('text_skrill_empty_input_data'));
     }
 }
 if ($mode == 'validate_secret_word') {
     if (!empty($_REQUEST['email']) && !empty($_REQUEST['payment_id']) && !empty($_REQUEST['cust_id']) && !empty($_REQUEST['secret'])) {
         $processor_params['pay_to_email'] = $_REQUEST['email'];
         $get_data = array();
         $get_data['email'] = $_REQUEST['email'];
         $get_data['cust_id'] = $master_account_cust_id;
         $get_data['secret'] = md5(md5($_REQUEST['secret']) . md5($master_account_secret_word));
         $result = Http::get("https://www.skrill.com/app/secret_word_check.pl", $get_data);
         $result_array = explode(',', $result);
         if ($result_array[0] == 'OK') {
Esempio n. 26
0
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //
    //Change points
    //
    if ($mode == 'change_points') {
        $amount = intval($_REQUEST['reason']['amount']);
        if (!empty($amount)) {
            fn_change_user_points($_REQUEST['reason']['action'] == 'A' ? abs($amount) : -abs($amount), $_REQUEST['user_id'], $_REQUEST['reason']['reason'], $_REQUEST['reason']['action']);
            $force_notification = fn_get_notification_rules($_REQUEST);
            if (!empty($force_notification['C'])) {
                $user_data = db_get_row("SELECT firstname, email, lang_code FROM ?:users WHERE user_id = ?i", $_REQUEST['user_id']);
                Mailer::sendMail(array('to' => $user_data['email'], 'from' => 'default_company_users_department', 'data' => array('user_data' => $user_data, 'reason' => $_REQUEST['reason']), 'tpl' => 'addons/reward_points/notification.tpl', 'company_id' => empty($user_data['company_id']) ? 0 : $user_data['company_id']), 'C', $user_data['lang_code']);
            }
        }
    }
    if ($mode == 'm_delete') {
        foreach ($_REQUEST['change_ids'] as $change_id) {
            db_query("DELETE FROM ?:reward_point_changes WHERE change_id = ?i", $change_id);
        }
    }
    if ($mode == 'cleanup_logs') {
        db_query("DELETE FROM ?:reward_point_changes WHERE user_id = ?i", $_REQUEST['user_id']);
    }
    if ($mode == 'add' || $mode == 'update') {
        if (isset($_REQUEST['reward_points'])) {
            foreach ($_REQUEST['reward_points'] as $k => $v) {
                if (fn_allowed_for('ULTIMATE')) {
Esempio n. 27
0
            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();
        $companies_countries = db_get_array('SELECT storefront, countries_list FROM ?:companies');
        foreach ($companies_countries as $data) {
            if (empty($data['countries_list'])) {
                continue;
            }
            $_countries = explode(',', $data['countries_list']);
            foreach ($_countries as $code) {
Esempio n. 28
0
function fn_send_newsletter($to, $from, $subj, $body, $attachments = array(), $lang_code = CART_LANGUAGE, $reply_to = '')
{
    $reply_to = !empty($reply_to) ? $reply_to : 'default_company_newsletter_email';
    $_from = array('email' => !empty($from['from_email']) ? $from['from_email'] : 'default_company_newsletter_email', 'name' => !empty($from['from_name']) ? $from['from_name'] : (empty($from['from_email']) ? 'default_company_name' : ''));
    return Mailer::sendMail(array('to' => $to, 'from' => $_from, 'reply_to' => $reply_to, 'data' => array('body' => $body, 'subject' => $subj), 'attachments' => $attachments, 'mailer_settings' => Registry::get('addons.news_and_emails'), 'tpl' => 'addons/news_and_emails/newsletter.tpl'), 'C', $lang_code);
}
Esempio n. 29
0
function fn_send_return_mail(&$return_info, &$order_info, $force_notification = array())
{
    $return_statuses = fn_get_statuses(STATUSES_RETURN);
    $status_params = $return_statuses[$return_info['status']]['params'];
    $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false);
    $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false);
    $notify_vendor = isset($force_notification['V']) ? $force_notification['V'] : (!empty($status_params['notify_vendor']) && $status_params['notify_vendor'] == 'Y' ? true : false);
    if ($notify_user == true || $notify_department == true || $notify_vendor == true) {
        $rma_reasons = fn_get_rma_properties(RMA_REASON);
        $rma_actions = fn_get_rma_properties(RMA_ACTION);
        // Notify customer
        if ($notify_user == true) {
            Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $order_info['lang_code'])), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']);
        }
        if ($notify_vendor == true) {
            if (fn_allowed_for('MULTIVENDOR') && !empty($order_info['company_id'])) {
                $company_language = fn_get_company_language($order_info['company_id']);
                Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $company_language)), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'A', $company_language);
            }
        }
        // Notify administrator (only if the changes performed from the frontend)
        if ($notify_department == true) {
            Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'reply_to' => Registry::get('settings.Company.company_orders_department'), 'data' => array('order_info' => $order_info, 'return_info' => $return_info, 'reasons' => $rma_reasons, 'actions' => $rma_actions, 'return_status' => fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], Registry::get('settings.Appearance.backend_default_language'))), 'tpl' => 'addons/rma/slip_notification.tpl', 'company_id' => $order_info['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language'));
        }
    }
}
Esempio n. 30
0
/**
 * Hook for modify shippings groups
 *
 * @param array $cart Cart array
 * @param array $allow
 * @param array $product_groups Products groups from cart
 */
function fn_suppliers_order_notification(&$order_info, &$order_statuses, &$force_notification)
{
    $status_params = $order_statuses[$order_info['status']]['params'];
    $notify_supplier = isset($force_notification['S']) ? $force_notification['S'] : (!empty($status_params['notify_supplier']) && $status_params['notify_supplier'] == 'Y' ? true : false);
    if ($notify_supplier == true) {
        $suppliers = array();
        if (!empty($order_info['product_groups'])) {
            foreach ($order_info['product_groups'] as $key_group => $group) {
                foreach ($group['products'] as $cart_id => $product) {
                    $supplier_id = fn_get_product_supplier_id($product['product_id']);
                    if (!empty($supplier_id) && empty($suppliers[$supplier_id])) {
                        $rate = 0;
                        foreach ($group['chosen_shippings'] as $shipping) {
                            $rate += $shipping['rate'];
                        }
                        $suppliers[$supplier_id] = array('name' => fn_get_supplier_name($supplier_id), 'company_id' => $group['company_id'], 'cost' => $rate, 'shippings' => $group['chosen_shippings']);
                    }
                    if (!empty($supplier_id)) {
                        $suppliers[$supplier_id]['products'][$cart_id] = $product;
                    }
                }
            }
        }
        foreach ($suppliers as $supplier_id => $supplier) {
            $lang = fn_get_company_language($supplier['company_id']);
            $order = $order_info;
            $order['products'] = $supplier['products'];
            $supplier['data'] = fn_get_supplier_data($supplier_id);
            if (!empty($supplier['shippings'])) {
                if (!empty($supplier['data']['shippings'])) {
                    $shippings = array();
                    foreach ($supplier['shippings'] as $shipping) {
                        if (!isset($shippings[$shipping['group_name']])) {
                            $shippings[$shipping['group_name']] = $shipping;
                        }
                    }
                    foreach ($shippings as $key => $shipping) {
                        if ($key != $supplier['name']) {
                            unset($shippings[$key]);
                            if ($supplier['cost'] > $shipping['rate']) {
                                $supplier['cost'] -= $shipping['rate'];
                            } else {
                                $supplier['cost'] = 0;
                            }
                        }
                    }
                    $supplier['shippings'] = array_values($shippings);
                } else {
                    $supplier['shippings'] = array();
                }
            }
            Mailer::sendMail(array('to' => $supplier['data']['email'], 'from' => 'company_orders_department', 'reply_to' => 'company_orders_department', 'data' => array('order_info' => $order, 'status_inventory' => $status_params['inventory'], 'supplier_id' => $supplier_id, 'supplier' => $supplier, 'order_status' => fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $lang), 'profile_fields' => fn_get_profile_fields('I', '', $lang)), 'tpl' => 'addons/suppliers/notification.tpl'), 'A', $lang);
        }
    }
}