} elseif ($mode == 'connect_social') { $email = !empty($_SESSION['hybrid_auth']['email']) ? $_SESSION['hybrid_auth']['email'] : ''; $identifier = !empty($_SESSION['hybrid_auth']['identifier']) ? $_SESSION['hybrid_auth']['identifier'] : ''; $provider = !empty($_SESSION['hybrid_auth']['provider']) ? $_SESSION['hybrid_auth']['provider'] : ''; $redirect_url = !empty($_SESSION['hybrid_auth']['redirect_url']) ? $_SESSION['hybrid_auth']['redirect_url'] : fn_url(); if (!empty($_SESSION['auth']['user_id'])) { fn_hybrid_auth_link_provider($_SESSION['auth']['user_id'], $identifier, $provider); unset($_SESSION['hybrid_auth']); return array(CONTROLLER_STATUS_REDIRECT, $redirect_url); } if (AREA != 'A') { fn_add_breadcrumb(__('hybrid_auth.connect_social')); } $user_id = fn_is_user_exists(0, array('email' => $email)); if (!empty($user_id)) { $user_data = fn_get_user_short_info($user_id); $user_login = $user_data['email']; } else { $user_login = ''; } Tygh::$app['view']->assign('user_login', $user_login); Tygh::$app['view']->assign('identifier', $identifier); Tygh::$app['view']->assign('view_mode', 'simple'); } elseif ($mode == 'specify_email') { if (!empty($_REQUEST['user_email'])) { fn_hybrid_auth_process('login_provider', $redirect_url); $_REQUEST['redirect_url'] = $redirect_url; return array(CONTROLLER_STATUS_REDIRECT, fn_url($redirect_url)); } $identifier = !empty($_SESSION['hybrid_auth']['identifier']) ? $_SESSION['hybrid_auth']['identifier'] : ''; $provider = !empty($_SESSION['hybrid_auth']['provider']) ? $_SESSION['hybrid_auth']['provider'] : '';
if (!$_REQUEST['token']) { fn_redirect(fn_url()); } $u_user = fn_ulogin_GetUserFromToken($_REQUEST['token']); if (!$u_user) { fn_set_notification('E', __('ulogin_error'), __('ulogin_error_token')); exit; } $u_user = json_decode($u_user, true); $check = fn_ulogin_CheckTokenError($u_user); if (empty($check)) { return false; } $user_id = fn_ulogin_getUserIdByIdentity($u_user['identity']); if (isset($user_id) && !empty($user_id)) { $d = fn_get_user_short_info($user_id); if ($user_id > 0 && $d['user_id'] > 0) { fn_ulogin_CheckUserId($user_id); } else { $user_id = fn_ulogin_registration_user($u_user, 1); } } else { $user_id = fn_ulogin_registration_user($u_user); } if ($user_id > 0) { fn_login_user($user_id); } $redirect_url = fn_url('/profiles-update/'); fn_redirect(isset($_GET['backurl']) ? $_GET['backurl'] : $redirect_url, true); } }
/** * Init user * * @return boolean always true */ function fn_init_user() { if (!empty($_SESSION['auth']['user_id'])) { $user_info = fn_get_user_short_info($_SESSION['auth']['user_id']); if (empty($user_info)) { // user does not exist in the database, but exists in session $_SESSION['auth'] = array(); } else { $_SESSION['auth']['usergroup_ids'] = fn_define_usergroups(array('user_id' => $_SESSION['auth']['user_id'], 'user_type' => $user_info['user_type'])); } } $first_init = false; if (empty($_SESSION['auth'])) { $udata = array(); if (fn_get_cookie(AREA_NAME . '_user_id')) { $udata = db_get_row("SELECT user_id, user_type, tax_exempt, last_login FROM ?:users WHERE user_id = ?i AND password = ?s", fn_get_cookie(AREA_NAME . '_user_id'), fn_get_cookie(AREA_NAME . '_password')); fn_define('LOGGED_VIA_COOKIE', true); } $_SESSION['auth'] = fn_fill_auth($udata, isset($_SESSION['auth']['order_ids']) ? $_SESSION['auth']['order_ids'] : array()); if (!defined('NO_SESSION')) { $_SESSION['cart'] = isset($_SESSION['cart']) ? $_SESSION['cart'] : array(); } if (defined('LOGGED_VIA_COOKIE') && !empty($_SESSION['auth']['user_id']) || ($cu_id = fn_get_cookie('cu_id'))) { $first_init = true; if (!empty($cu_id)) { fn_define('COOKIE_CART', true); } // Cleanup cached shipping rates unset($_SESSION['shipping_rates']); $_utype = empty($_SESSION['auth']['user_id']) ? 'U' : 'R'; $_uid = empty($_SESSION['auth']['user_id']) ? $cu_id : $_SESSION['auth']['user_id']; fn_extract_cart_content($_SESSION['cart'], $_uid, 'C', $_utype); fn_save_cart_content($_SESSION['cart'], $_uid, 'C', $_utype); if (!empty($_SESSION['auth']['user_id'])) { $_SESSION['cart']['user_data'] = fn_get_user_info($_SESSION['auth']['user_id']); } } } if (TIME > Registry::get('settings.cart_products_next_check')) { fn_define('CART_PRODUCTS_CHECK_PERIOD', SECONDS_IN_HOUR * 12); fn_define('CART_PRODUCTS_DELETE_TIME', TIME - SECONDS_IN_DAY * 30); db_query("DELETE FROM ?:user_session_products WHERE user_type = 'U' AND timestamp < ?i", CART_PRODUCTS_DELETE_TIME); db_query("UPDATE ?:settings SET value = ?s WHERE option_name = 'cart_products_next_check'", TIME + CART_PRODUCTS_CHECK_PERIOD); } // If administrative account has usergroup, it means the access restrictions are in action if (AREA == 'A' && !empty($_SESSION['auth']['usergroup_ids'])) { fn_define('RESTRICTED_ADMIN', true); } if (!empty($user_info) && $user_info['user_type'] == 'A') { if (Registry::get('settings.translation_mode') == 'Y') { fn_define('TRANSLATION_MODE', true); } if (Registry::get('settings.customization_mode') == 'Y') { if (AREA != 'A') { fn_define('PARSE_ALL', true); } fn_define('CUSTOMIZATION_MODE', true); } } fn_set_hook('user_init', $_SESSION['auth'], $user_info, $first_init); Registry::set('user_info', $user_info); Registry::get('view')->assign('auth', $_SESSION['auth']); Registry::get('view')->assign('user_info', $user_info); return true; }
function fn_get_order_info($order_id, $native_language = false, $format_info = true, $get_edp_files = false, $skip_static_values = false) { if (!empty($order_id)) { $condition = fn_get_company_condition('?:orders.company_id'); $order = db_get_row("SELECT * FROM ?:orders WHERE ?:orders.order_id = ?i {$condition}", $order_id); if (!empty($order)) { $lang_code = $native_language == true ? $order['lang_code'] : CART_LANGUAGE; if (isset($order['ip_address'])) { $order['ip_address'] = fn_ip_from_db($order['ip_address']); } $order['payment_method'] = fn_get_payment_method_data($order['payment_id'], $lang_code); // Get additional profile fields $additional_fields = db_get_hash_single_array("SELECT field_id, value FROM ?:profile_fields_data " . "WHERE object_id = ?i AND object_type = 'O'", array('field_id', 'value'), $order_id); $order['fields'] = $additional_fields; $order['products'] = db_get_hash_array("SELECT ?:order_details.*, ?:product_descriptions.product, ?:products.status as product_status FROM ?:order_details " . "LEFT JOIN ?:product_descriptions ON ?:order_details.product_id = ?:product_descriptions.product_id AND ?:product_descriptions.lang_code = ?s " . "LEFT JOIN ?:products ON ?:order_details.product_id = ?:products.product_id " . "WHERE ?:order_details.order_id = ?i ORDER BY ?:product_descriptions.product", 'item_id', $lang_code, $order_id); $order['promotions'] = unserialize($order['promotions']); if (!empty($order['promotions'])) { // collect additional data $params = array('promotion_id' => array_keys($order['promotions'])); list($promotions) = fn_get_promotions($params); foreach ($promotions as $pr_id => $p) { $order['promotions'][$pr_id]['name'] = $p['name']; $order['promotions'][$pr_id]['short_description'] = $p['short_description']; } } // Get additional data $additional_data = db_get_hash_single_array("SELECT type, data FROM ?:order_data WHERE order_id = ?i", array('type', 'data'), $order_id); $order['taxes'] = array(); $order['tax_subtotal'] = 0; $order['display_shipping_cost'] = $order['shipping_cost']; // Replace country, state and title values with their descriptions $order_company_id = isset($order['company_id']) ? $order['company_id'] : ''; // company_id will be rewritten by user field, so need to save it. fn_add_user_data_descriptions($order, $lang_code); $order['company_id'] = $order_company_id; $order['need_shipping'] = false; $deps = array(); // Get shipping information if (!empty($additional_data['L'])) { $order['shipping'] = unserialize($additional_data['L']); foreach ($order['shipping'] as $key => $v) { $shipping_id = isset($v['shipping_id']) ? $v['shipping_id'] : 0; $shipping_name = fn_get_shipping_name($shipping_id, $lang_code); if ($shipping_name) { $order['shipping'][$key]['shipping'] = $shipping_name; } } } if (!fn_allowed_for('ULTIMATE:FREE')) { // Get shipments common information $order['shipment_ids'] = db_get_fields("SELECT sh.shipment_id FROM ?:shipments AS sh LEFT JOIN ?:shipment_items AS s_items ON (sh.shipment_id = s_items.shipment_id) " . "WHERE s_items.order_id = ?i GROUP BY s_items.shipment_id", $order_id); $_products = db_get_array("SELECT item_id, SUM(amount) AS amount FROM ?:shipment_items WHERE order_id = ?i GROUP BY item_id", $order_id); $shipped_products = array(); if (!empty($_products)) { foreach ($_products as $_product) { $shipped_products[$_product['item_id']] = $_product['amount']; } } unset($_products); } foreach ($order['products'] as $k => $v) { //Check for product existance if (empty($v['product'])) { $order['products'][$k]['deleted_product'] = true; } else { $order['products'][$k]['deleted_product'] = false; } $order['products'][$k]['discount'] = 0; $v['extra'] = @unserialize($v['extra']); if ($order['products'][$k]['deleted_product'] == true && !empty($v['extra']['product'])) { $order['products'][$k]['product'] = $v['extra']['product']; } else { $order['products'][$k]['product'] = fn_get_product_name($v['product_id'], $lang_code); } $order['products'][$k]['company_id'] = empty($v['extra']['company_id']) ? 0 : $v['extra']['company_id']; if (!empty($v['extra']['discount']) && floatval($v['extra']['discount'])) { $order['products'][$k]['discount'] = $v['extra']['discount']; $order['use_discount'] = true; } if (!empty($v['extra']['promotions'])) { $order['products'][$k]['promotions'] = $v['extra']['promotions']; } if (isset($v['extra']['base_price'])) { $order['products'][$k]['base_price'] = floatval($v['extra']['base_price']); } else { $order['products'][$k]['base_price'] = $v['price']; } $order['products'][$k]['original_price'] = $order['products'][$k]['base_price']; // Form hash key for this product $order['products'][$k]['cart_id'] = $v['item_id']; $deps['P_' . $order['products'][$k]['cart_id']] = $k; // Unserialize and collect product options information if (!empty($v['extra']['product_options'])) { if ($format_info == true) { if (!empty($v['extra']['product_options_value'])) { $order['products'][$k]['product_options'] = $v['extra']['product_options_value']; } else { $order['products'][$k]['product_options'] = fn_get_selected_product_options_info($v['extra']['product_options'], $lang_code); } } $product_options_value = $skip_static_values == false && !empty($v['extra']['product_options_value']) ? $v['extra']['product_options_value'] : array(); if (empty($v['extra']['stored_price']) || !empty($v['extra']['stored_price']) && $v['extra']['stored_price'] != 'Y') { // apply modifiers if this is not the custom price $order['products'][$k]['original_price'] = fn_apply_options_modifiers($v['extra']['product_options'], $order['products'][$k]['base_price'], 'P', $product_options_value, array('product_data' => $v)); } } $order['products'][$k]['extra'] = $v['extra']; $order['products'][$k]['tax_value'] = 0; $order['products'][$k]['display_subtotal'] = $order['products'][$k]['subtotal'] = $v['price'] * $v['amount']; // Get information about edp if ($get_edp_files == true && $order['products'][$k]['extra']['is_edp'] == 'Y') { $order['products'][$k]['files'] = db_get_array("SELECT ?:product_files.file_id, ?:product_files.activation_type, ?:product_files.max_downloads, " . "?:product_file_descriptions.file_name, ?:product_file_ekeys.active, ?:product_file_ekeys.downloads, " . "?:product_file_ekeys.ekey, ?:product_file_ekeys.ttl FROM ?:product_files " . "LEFT JOIN ?:product_file_descriptions ON ?:product_file_descriptions.file_id = ?:product_files.file_id " . "AND ?:product_file_descriptions.lang_code = ?s " . "LEFT JOIN ?:product_file_ekeys ON ?:product_file_ekeys.file_id = ?:product_files.file_id " . "AND ?:product_file_ekeys.order_id = ?i WHERE ?:product_files.product_id = ?i", $lang_code, $order_id, $v['product_id']); } // Get shipments information // If current edition is FREE, we still need to check shipments accessibility (need to display promotion link) if (isset($shipped_products[$k])) { $order['products'][$k]['shipped_amount'] = $shipped_products[$k]; $order['products'][$k]['shipment_amount'] = $v['amount'] - $shipped_products[$k]; } else { $order['products'][$k]['shipped_amount'] = 0; $order['products'][$k]['shipment_amount'] = $v['amount']; } if ($order['products'][$k]['shipped_amount'] < $order['products'][$k]['amount']) { if (!empty($order['shipping'])) { $group_key = empty($v['extra']['group_key']) ? 0 : $v['extra']['group_key']; $order['shipping'][$group_key]['need_shipment'] = true; } else { $order['need_shipment'] = true; } } // Check if the order needs the shipping method if (!($v['extra']['is_edp'] == 'Y' && (!isset($v['extra']['edp_shipping']) || $v['extra']['edp_shipping'] != 'Y'))) { $order['need_shipping'] = true; } // Adds flag that defines if product page is available $order['products'][$k]['is_accessible'] = fn_is_accessible_product($v); fn_set_hook('get_order_items_info_post', $order, $v, $k); } // Unserialize and collect taxes information if (!empty($additional_data['T'])) { $order['taxes'] = unserialize($additional_data['T']); if (is_array($order['taxes'])) { foreach ($order['taxes'] as $tax_id => $tax_data) { if (Registry::get('settings.General.tax_calculation') == 'unit_price') { foreach ($tax_data['applies'] as $_id => $value) { if (strpos($_id, 'P_') !== false && isset($deps[$_id])) { $order['products'][$deps[$_id]]['tax_value'] += $value; if ($tax_data['price_includes_tax'] != 'Y') { $order['products'][$deps[$_id]]['subtotal'] += $value; $order['products'][$deps[$_id]]['display_subtotal'] += Registry::get('settings.Appearance.cart_prices_w_taxes') == 'Y' ? $value : 0; } } if (strpos($_id, 'S_') !== false) { if ($tax_data['price_includes_tax'] != 'Y') { $order['shipping_cost'] += $value; $order['display_shipping_cost'] += Registry::get('settings.Appearance.cart_prices_w_taxes') == 'Y' ? $value : 0; } } } } if ($tax_data['price_includes_tax'] != 'Y') { $order['tax_subtotal'] += $tax_data['tax_subtotal']; } } } else { $order['taxes'] = array(); } } if (!empty($additional_data['C'])) { $order['coupons'] = unserialize($additional_data['C']); } if (!empty($additional_data['R'])) { $order['secondary_currency'] = unserialize($additional_data['R']); } if (!empty($order['issuer_id'])) { $order['issuer_data'] = fn_get_user_short_info($order['issuer_id']); } // Recalculate subtotal $order['subtotal'] = $order['display_subtotal'] = 0; foreach ($order['products'] as $v) { $order['subtotal'] += $v['subtotal']; $order['display_subtotal'] += $v['display_subtotal']; } // Unserialize and collect payment information if (!empty($additional_data['P'])) { $order['payment_info'] = unserialize(fn_decrypt_text($additional_data['P'])); } if (empty($order['payment_info']) || !is_array($order['payment_info'])) { $order['payment_info'] = array(); } // Get shipping information if (!empty($additional_data['G'])) { $order['product_groups'] = unserialize($additional_data['G']); } $order['doc_ids'] = db_get_hash_single_array("SELECT type, doc_id FROM ?:order_docs WHERE order_id = ?i", array('type', 'doc_id'), $order_id); } fn_set_hook('get_order_info', $order, $additional_data); return $order; } return false; }
} elseif ($mode == 'update' || $mode == 'add') { if ($mode == 'update' && empty($cart['order_id'])) { return array(CONTROLLER_STATUS_REDIRECT, "order_management.new"); } // // Prepare order status info // $get_additional_statuses = false; if (!empty($cart['order_id'])) { $order_info = fn_get_order_short_info($cart['order_id']); $cart['order_status'] = $order_info['status']; if ($cart['order_status'] == STATUS_INCOMPLETED_ORDER) { $get_additional_statuses = true; } if (!empty($order_info['issuer_id'])) { $cart['issuer_data'] = fn_get_user_short_info($order_info['issuer_id']); } } $order_statuses = fn_get_simple_statuses(STATUSES_ORDER, $get_additional_statuses, true); Registry::get('view')->assign('order_statuses', $order_statuses); // // Prepare customer info // $profile_fields = fn_get_profile_fields('O', $customer_auth); $cart['profile_id'] = empty($cart['profile_id']) ? 0 : $cart['profile_id']; Registry::get('view')->assign('profile_fields', $profile_fields); //Get user profiles $user_profiles = fn_get_user_profiles($customer_auth['user_id']); Registry::get('view')->assign('user_profiles', $user_profiles); //Get countries and states Registry::get('view')->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE));
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()); }
/** * Init user * * @return boolean always true */ function fn_init_user($area = AREA) { $user_info = array(); if (!empty(Tygh::$app['session']['auth']['user_id'])) { $user_info = fn_get_user_short_info(Tygh::$app['session']['auth']['user_id']); if (empty($user_info)) { // user does not exist in the database, but exists in session Tygh::$app['session']['auth'] = array(); } else { Tygh::$app['session']['auth']['usergroup_ids'] = fn_define_usergroups(array('user_id' => Tygh::$app['session']['auth']['user_id'], 'user_type' => $user_info['user_type'])); } } $first_init = false; if (empty(Tygh::$app['session']['auth'])) { $udata = array(); $user_id = fn_get_session_data($area . '_user_id'); if ($area == 'A' && defined('CONSOLE')) { $user_id = 1; } if ($user_id) { fn_define('LOGGED_VIA_COOKIE', true); } fn_login_user($user_id); if (!defined('NO_SESSION')) { Tygh::$app['session']['cart'] = isset(Tygh::$app['session']['cart']) ? Tygh::$app['session']['cart'] : array(); } if (defined('LOGGED_VIA_COOKIE') && !empty(Tygh::$app['session']['auth']['user_id']) || ($cu_id = fn_get_session_data('cu_id'))) { $first_init = true; if (!empty($cu_id)) { fn_define('COOKIE_CART', true); } // Cleanup cached shipping rates unset(Tygh::$app['session']['shipping_rates']); $_utype = empty(Tygh::$app['session']['auth']['user_id']) ? 'U' : 'R'; $_uid = empty(Tygh::$app['session']['auth']['user_id']) ? $cu_id : Tygh::$app['session']['auth']['user_id']; fn_extract_cart_content(Tygh::$app['session']['cart'], $_uid, 'C', $_utype); fn_save_cart_content(Tygh::$app['session']['cart'], $_uid, 'C', $_utype); if (!empty(Tygh::$app['session']['auth']['user_id'])) { Tygh::$app['session']['cart']['user_data'] = fn_get_user_info(Tygh::$app['session']['auth']['user_id']); $user_info = fn_get_user_short_info(Tygh::$app['session']['auth']['user_id']); } } } if (fn_is_expired_storage_data('cart_products_next_check', SECONDS_IN_HOUR * 12)) { db_query("DELETE FROM ?:user_session_products WHERE user_type = 'U' AND timestamp < ?i", TIME - SECONDS_IN_DAY * 30); } if (!fn_allowed_for('ULTIMATE:FREE')) { // If administrative account has usergroup, it means the access restrictions are in action if ($area == 'A' && !empty(Tygh::$app['session']['auth']['usergroup_ids'])) { fn_define('RESTRICTED_ADMIN', true); } } if (!empty($user_info) && $user_info['user_type'] == 'A' && (empty($user_info['company_id']) || fn_allowed_for('ULTIMATE') && $user_info['company_id'] == Registry::get('runtime.company_id'))) { $customization_mode = fn_array_combine(explode(',', Registry::get('settings.customization_mode')), true); if (!empty($customization_mode)) { Registry::set('runtime.customization_mode', $customization_mode); if ($area == 'A' || Embedded::isEnabled()) { Registry::set('runtime.customization_mode.live_editor', false); } } } fn_set_hook('user_init', Tygh::$app['session']['auth'], $user_info, $first_init); Registry::set('user_info', $user_info); return array(INIT_STATUS_OK); }
function content_55ccecdcad87d6_33701712($_smarty_tpl) { if (!is_callable('smarty_function_math')) { include '/home/coriolan/public_html/lead/app/lib/other/smarty/plugins/function.math.php'; } if (!is_callable('smarty_function_script')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.script.php'; } fn_preload_lang_vars(array('add_users', 'choose', 'select_customer', 'person_name', 'no_items')); echo smarty_function_math(array('equation' => "rand()", 'assign' => "rnd"), $_smarty_tpl); ?> <?php $_smarty_tpl->tpl_vars["data_id"] = new Smarty_variable((string) $_smarty_tpl->tpl_vars['data_id']->value . "_" . (string) $_smarty_tpl->tpl_vars['rnd']->value, null, 0); $_smarty_tpl->tpl_vars["view_mode"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['view_mode']->value) === null || $tmp === '' ? "mixed" : $tmp, null, 0); ?> <?php echo smarty_function_script(array('src' => "js/tygh/picker.js"), $_smarty_tpl); ?> <?php if ($_smarty_tpl->tpl_vars['item_ids']->value && !is_array($_smarty_tpl->tpl_vars['item_ids']->value)) { ?> <?php $_smarty_tpl->tpl_vars["item_ids"] = new Smarty_variable(explode(",", $_smarty_tpl->tpl_vars['item_ids']->value), null, 0); } ?> <?php $_smarty_tpl->tpl_vars["display"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['display']->value) === null || $tmp === '' ? "checkbox" : $tmp, null, 0); ?> <?php if ($_smarty_tpl->tpl_vars['view_mode']->value != "list") { ?> <?php echo $_smarty_tpl->getSubTemplate("views/profiles/components/profiles_scripts.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0); ?> <?php if ($_smarty_tpl->tpl_vars['extra_var']->value) { ?> <?php $_smarty_tpl->tpl_vars["extra_var"] = new Smarty_variable(rawurlencode($_smarty_tpl->tpl_vars['extra_var']->value), null, 0); ?> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['display']->value == "checkbox") { ?> <?php $_smarty_tpl->tpl_vars["_but_text"] = new Smarty_variable($_smarty_tpl->__("add_users"), null, 0); ?> <?php } elseif ($_smarty_tpl->tpl_vars['display']->value == "radio") { ?> <?php $_smarty_tpl->tpl_vars["_but_text"] = new Smarty_variable($_smarty_tpl->__("choose"), null, 0); ?> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['but_text']->value) { ?> <?php $_smarty_tpl->tpl_vars["_but_text"] = new Smarty_variable($_smarty_tpl->__("select_customer"), null, 0); ?> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['placement']->value == 'right') { ?> <div class="clearfix"> <div class="pull-right"> <?php } ?> <?php echo $_smarty_tpl->getSubTemplate("buttons/button.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_id' => "opener_picker_" . (string) $_smarty_tpl->tpl_vars['data_id']->value, 'but_href' => fn_url("profiles.picker?display=" . (string) $_smarty_tpl->tpl_vars['display']->value . "&extra=" . (string) $_smarty_tpl->tpl_vars['extra_var']->value . "&picker_for=" . (string) $_smarty_tpl->tpl_vars['picker_for']->value . "&data_id=" . (string) $_smarty_tpl->tpl_vars['data_id']->value . "&shared_force=" . (string) $_smarty_tpl->tpl_vars['shared_force']->value), 'but_text' => $_smarty_tpl->tpl_vars['_but_text']->value, 'but_role' => "add", 'but_target_id' => "content_" . (string) $_smarty_tpl->tpl_vars['data_id']->value, 'but_meta' => "cm-dialog-opener " . (string) $_smarty_tpl->tpl_vars['but_meta']->value, 'but_icon' => $_smarty_tpl->tpl_vars['but_icon']->value), 0); ?> <?php if ($_smarty_tpl->tpl_vars['placement']->value == 'right') { ?> </div></div> <?php } ?> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['view_mode']->value != "button") { ?> <?php if ($_smarty_tpl->tpl_vars['display']->value != "radio") { ?> <input id="u<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _ids" type="hidden" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> " value="<?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { echo htmlspecialchars(implode(",", $_smarty_tpl->tpl_vars['item_ids']->value), ENT_QUOTES, 'UTF-8'); } ?> " /> <table width="100%" class="table table-middle"> <thead> <tr> <th width="100%"><?php echo $_smarty_tpl->__("person_name"); ?> </th> <th> </th> </tr> </thead> <tbody id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> "<?php if (!$_smarty_tpl->tpl_vars['item_ids']->value) { ?> class="hidden"<?php } ?> > <?php echo $_smarty_tpl->getSubTemplate("pickers/users/js.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('user_id' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "user_id" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'email' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "email" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'user_name' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "user_name" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'holder' => $_smarty_tpl->tpl_vars['data_id']->value, 'clone' => true), 0); ?> <?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { ?> <?php $_smarty_tpl->tpl_vars["user"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["user"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['item_ids']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } $_smarty_tpl->tpl_vars["user"]->index = -1; foreach ($_from as $_smarty_tpl->tpl_vars["user"]->key => $_smarty_tpl->tpl_vars["user"]->value) { $_smarty_tpl->tpl_vars["user"]->_loop = true; $_smarty_tpl->tpl_vars["user"]->index++; $_smarty_tpl->tpl_vars["user"]->first = $_smarty_tpl->tpl_vars["user"]->index === 0; $_smarty_tpl->tpl_vars['smarty']->value['foreach']["items"]['first'] = $_smarty_tpl->tpl_vars["user"]->first; ?> <?php $_smarty_tpl->tpl_vars["user_info"] = new Smarty_variable(fn_get_user_short_info($_smarty_tpl->tpl_vars['user']->value), null, 0); ?> <?php echo $_smarty_tpl->getSubTemplate("pickers/users/js.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('user_id' => $_smarty_tpl->tpl_vars['user']->value, 'email' => $_smarty_tpl->tpl_vars['user_info']->value['email'], 'user_name' => (string) $_smarty_tpl->tpl_vars['user_info']->value['firstname'] . " " . (string) $_smarty_tpl->tpl_vars['user_info']->value['lastname'], 'holder' => $_smarty_tpl->tpl_vars['data_id']->value, 'first_item' => $_smarty_tpl->getVariable('smarty')->value['foreach']['items']['first']), 0); ?> <?php } ?> <?php } ?> </tbody> <tbody id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _no_item"<?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { ?> class="hidden"<?php } ?> > <tr class="no-items"> <td colspan="2"><p><?php echo ($tmp = @$_smarty_tpl->tpl_vars['no_item_text']->value) === null || $tmp === '' ? $_smarty_tpl->__("no_items") : $tmp; ?> </p></td> </tr> </tbody> </table> <?php } } ?> <?php if ($_smarty_tpl->tpl_vars['view_mode']->value != "list") { ?> <div class="hidden" id="content_<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> " title="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['_but_text']->value, ENT_QUOTES, 'UTF-8'); ?> "> </div> <?php } }