Exemple #1
0
    foreach ($patterns as $p_id => $p) {
        Registry::set('navigation.tabs.' . $p_id, array('title' => $p['name'], 'href' => "exim.import?pattern_id=" . $p_id . '&section=' . $_REQUEST['section'], 'ajax' => true));
    }
    Registry::set('navigation.dynamic.sections', $sections);
    Registry::set('navigation.dynamic.active_section', $_REQUEST['section']);
    unset($patterns[$pattern_id]['options']['lang_code']);
    Tygh::$app['view']->assign('pattern', $patterns[$pattern_id]);
    Tygh::$app['view']->assign('sections', $sections);
} elseif ($mode == 'get_file' && !empty($_REQUEST['filename'])) {
    $file = fn_basename($_REQUEST['filename']);
    if (!empty($_REQUEST['to_screen'])) {
        header("Content-type: text/plain");
        readfile(fn_get_files_dir_path() . $file);
        exit;
    } else {
        fn_get_file(fn_get_files_dir_path() . $file);
    }
} elseif ($mode == 'select_range') {
    $_SESSION['export_ranges'][$_REQUEST['section']] = array('pattern_id' => $_REQUEST['pattern_id'], 'data' => array());
    $pattern = fn_get_pattern_definition($_REQUEST['pattern_id']);
    return array(CONTROLLER_STATUS_REDIRECT, $pattern['range_options']['selector_url']);
}
// --------- ExIm core functions ------------------
//
// Import data using pattern
// Parameters:
// @pattern - import/export pattern
// @import_data - data to import
// @options - import options
function fn_import($pattern, $import_data, $options)
{
Exemple #2
0
 /**
  * Creates PO file for specified Language
  *
  * @param string $lang_code 2-letters language code (Example: "en", "ru")
  * @param string $output    Output destination
  *      screen - Output countent direct to browser page
  *      download - Force file downloading
  *      server - upload file to the config.dir.lang_packs directory
  */
 public static function export($lang_code, $output = 'download')
 {
     $mve_lang_variables = array();
     // Translation packs should not include "Not translated" language data
     $allow_overlap = $lang_code == 'en' ? true : false;
     $default_lang = Registry::get('settings.Appearance.backend_default_language');
     $langs = self::get(array('lang_code' => $lang_code));
     $lang = $langs[$lang_code];
     $pack_path = fn_get_cache_path(false) . 'lang_pack/';
     $core_pack_path = $pack_path . 'core.po';
     $mve_pack_path = $pack_path . 'editions/mve.po';
     fn_rm($pack_path);
     fn_mkdir($pack_path);
     if (fn_allowed_for('MULTIVENDOR') && is_file(Registry::get('config.dir.lang_packs') . $default_lang . '/editions/mve.po')) {
         $mve_lang_variables = Po::getValues(Registry::get('config.dir.lang_packs') . $default_lang . '/editions/mve.po');
         Po::createHeader($mve_pack_path, $lang);
     }
     Po::createHeader($core_pack_path, $lang);
     // Export Language values
     list($values) = LanguageValues::getVariables(array(), 0, $lang_code);
     foreach ($values as $_id => $value) {
         $values[$_id]['msgctxt'] = 'Languages' . \I18n_Pofile::DELIMITER . $value['name'];
     }
     $values = fn_array_value_to_key($values, 'msgctxt');
     $addons_lang_vars = array();
     list($addons) = fn_get_addons(array('type' => 'installed'), 0, $lang_code);
     foreach ($addons as $addon_id => $addon) {
         $addons_lang_vars = array_merge($addons_lang_vars, self::exportAddonsPo($addon_id, $pack_path . 'addons/' . $addon_id . '.po', $lang_code, $values));
     }
     $original_values = self::getOriginalValues('Languages');
     $values = array_diff_key($values, $addons_lang_vars);
     foreach ($values as $_id => $value) {
         $values[$_id]['original_value'] = isset($original_values['Languages::' . $value['name']]) ? $original_values['Languages::' . $value['name']]['msgid'] : '';
     }
     $values = Po::convert($values, array(), $allow_overlap);
     list($values, $excluded) = self::excludeEditionVariables('Languages', $values, $mve_lang_variables);
     Po::putValues('Languages', $values, $core_pack_path);
     if (!empty($excluded)) {
         Po::putValues('Languages', $excluded, $mve_pack_path);
     }
     // Export Settings Sections
     $sections = Settings::instance()->getCoreSections($lang_code);
     $original_values = self::getOriginalValues('SettingsSections');
     foreach ($sections as $_id => $value) {
         $sections[$_id]['original_value'] = isset($original_values['SettingsSections::' . $value['section_id']]) ? $original_values['SettingsSections::' . $value['section_id']]['msgid'] : '';
     }
     $_sections = Po::convert($sections, array('id' => 'section_id', 'value' => 'description'), $allow_overlap);
     list($_sections, $excluded) = self::excludeEditionVariables('SettingsSections', $_sections, $mve_lang_variables);
     Po::putValues('SettingsSections', $_sections, $core_pack_path);
     if (!empty($excluded)) {
         Po::putValues('SettingsSections', $excluded, $mve_pack_path);
     }
     unset($_sections);
     $original_options = self::getOriginalValues('SettingsOptions');
     $original_variants = self::getOriginalValues('SettingsVariants');
     $original_tooltips = self::getOriginalValues('SettingsTooltips');
     foreach ($sections as $section) {
         $options = Settings::instance()->getList($section['object_id'], 0, false, null, $lang_code);
         $_options = array();
         $_tooltips = array();
         foreach ($options['main'] as $option) {
             $_options[] = array('name' => $option['name'], 'value' => $option['description'], 'original_value' => isset($original_options['SettingsOptions' . \I18n_Pofile::DELIMITER . $option['name']]) ? $original_options['SettingsOptions' . \I18n_Pofile::DELIMITER . $option['name']]['msgid'] : '');
             if (!empty($option['variants'])) {
                 $_variants = array();
                 foreach ($option['variants'] as $variant_id => $variant) {
                     $_variants[] = array('name' => $variant_id, 'value' => $variant, 'original_value' => isset($original_variants['SettingsVariants' . \I18n_Pofile::DELIMITER . $option['name'] . \I18n_Pofile::DELIMITER . $variant_id]) ? $original_variants['SettingsVariants' . \I18n_Pofile::DELIMITER . $option['name'] . \I18n_Pofile::DELIMITER . $variant_id]['msgid'] : '');
                 }
                 $_variants = Po::convert($_variants, array(), $allow_overlap);
                 list($_variants, $excluded) = self::excludeEditionVariables('SettingsVariants', $_variants, $mve_lang_variables);
                 Po::putValues('SettingsVariants' . \I18n_Pofile::DELIMITER . $option['name'], $_variants, $core_pack_path);
                 if (!empty($excluded)) {
                     Po::putValues('SettingsVariants', $excluded, $mve_pack_path);
                 }
                 unset($_variants);
             }
             if (!empty($option['tooltip'])) {
                 $_tooltips[] = array('name' => $option['name'], 'value' => $option['tooltip'], 'original_value' => isset($original_tooltips['SettingsTooltips' . \I18n_Pofile::DELIMITER . $option['name']]) ? $original_tooltips['SettingsTooltips' . \I18n_Pofile::DELIMITER . $option['name']]['msgid'] : '');
             }
         }
         $_options = Po::convert($_options, array(), $allow_overlap);
         list($_options, $excluded) = self::excludeEditionVariables('SettingsOptions', $_options, $mve_lang_variables);
         Po::putValues('SettingsOptions', $_options, $core_pack_path);
         if (!empty($excluded)) {
             Po::putValues('SettingsOptions', $excluded, $mve_pack_path);
         }
         $_tooltips = Po::convert($_tooltips, array(), $allow_overlap);
         list($_tooltips, $excluded) = self::excludeEditionVariables('SettingsTooltips', $_tooltips, $mve_lang_variables);
         Po::putValues('SettingsTooltips', $_tooltips, $core_pack_path);
         if (!empty($excluded)) {
             Po::putValues('SettingsTooltips', $excluded, $mve_pack_path);
         }
     }
     // Export Profile fields
     $profile_fields = fn_get_profile_fields('ALL', array(), $lang_code);
     $original_values = self::getOriginalValues('ProfileFields');
     $values = array();
     foreach ($profile_fields as $zone => $fields) {
         foreach ($fields as $field_id => $field) {
             $values[] = array('name' => $field['field_name'], 'value' => $field['description'], 'original_value' => isset($original_values['ProfileFields::' . $field['field_name']]) ? $original_values['ProfileFields::' . $field['field_name']]['msgid'] : '');
         }
     }
     $values = Po::convert($values, array(), $allow_overlap);
     list($values, $excluded) = self::excludeEditionVariables('ProfileFields', $values, $mve_lang_variables);
     Po::putValues('ProfileFields', $values, $core_pack_path);
     if (!empty($excluded)) {
         Po::putValues('ProfileFields', $excluded, $mve_pack_path);
     }
     fn_compress_files($lang_code . '.zip', './', $pack_path);
     $filename = $pack_path . $lang_code . '.zip';
     switch ($output) {
         case 'server':
             fn_copy($filename, Registry::get('config.dir.lang_packs') . $lang_code . '.zip');
             break;
         case 'download':
             fn_get_file($filename, $lang_code . '.zip');
             break;
     }
     return true;
 }
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($mode == 'qwintry_create_shipment') {
    $order_info = fn_get_order_info($_REQUEST['order_id']);
    $result = fn_qwintry_create_shipment($order_info, $_REQUEST['qwintry_data']);
    if ($result === true) {
        fn_set_notification('N', __('notice'), __('done'));
    } else {
        fn_set_notification('E', __('error'), __('error_ajax', $result));
    }
    return array(CONTROLLER_STATUS_REDIRECT, 'orders.details?order_id=' . $_REQUEST['order_id']);
} elseif ($mode == 'qwintry_download_label') {
    fn_get_file(QWINTRY_DIR_LABELS . $_REQUEST['order_id'] . '.pdf');
}
if ($mode == 'details') {
    $order_info = fn_get_order_info($_REQUEST['order_id']);
    foreach ($order_info['shipping'] as $shipping) {
        if ($shipping['module'] == 'qwintry') {
            $qwintry_data = $shipping;
        }
    }
    if (!empty($qwintry_data) && !fn_qwintry_check_label($order_info['order_id'])) {
        $navigation_tabs = Registry::get('navigation.tabs');
        $navigation_tabs['qwintry'] = array('title' => __('qwintry_air'), 'js' => true);
        Registry::set('navigation.tabs', $navigation_tabs);
        Registry::get('view')->assign('qwintry_data', $qwintry_data);
    }
}
Exemple #4
0
                }
            }
            if (!empty($data_shipments)) {
                Registry::set('navigation.tabs.sdek_orders', array('title' => __('shippings.sdek.sdek_orders'), 'js' => true));
                Tygh::$app['view']->assign('data_shipments', $data_shipments);
                Tygh::$app['view']->assign('sdek_pvz', $sdek_pvz);
                Tygh::$app['view']->assign('rec_city_code', $rec_city_code);
                Tygh::$app['view']->assign('order_id', $params['order_id']);
            }
        }
    }
} elseif ($mode == 'sdek_get_ticket') {
    $params = $_REQUEST;
    $file = $params['order_id'] . '.pdf';
    $path = fn_get_files_dir_path() . 'sdek/' . $params['shipment_id'] . '/';
    fn_get_file($path . $file);
    if (defined('AJAX_REQUEST') && !empty($url)) {
        Registry::get('ajax')->assign('force_redirection', $url);
        exit;
    }
    return array(CONTROLLER_STATUS_OK);
}
function fn_sdek_get_ticket_order($data_auth, $order_id, $chek_id)
{
    unset($data_auth['Number']);
    $xml = '            ' . RusSdek::arraySimpleXml('OrdersPrint', $data_auth, 'open');
    $order_sdek = array('Number' => $order_id . '_' . $chek_id, 'Date' => $data_auth['Date']);
    $xml .= '            ' . RusSdek::arraySimpleXml('Order', $order_sdek);
    $xml .= '            ' . '</OrdersPrint>';
    $response = RusSdek::xmlRequest('http://gw.edostavka.ru:11443/orders_print.php', $xml, $data_auth);
    $download_file_dir = fn_get_files_dir_path() . '/sdek' . '/' . $chek_id . '/';
Exemple #5
0
/***************************************************************************
*                                                                          *
*   (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev    *
*                                                                          *
* This  is  commercial  software,  only  users  who have purchased a valid *
* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($mode == 'get') {
    $schema = fn_get_schema('price_list', 'schema');
    if (empty($_REQUEST['display']) || empty($schema['types'][$_REQUEST['display']])) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    $class_name = '\\Tygh\\PriceList\\' . fn_camelize($_REQUEST['display']);
    if (class_exists($class_name)) {
        $generator = new $class_name();
        $filename = $generator->getFileName();
        if (file_exists($filename)) {
            fn_get_file($filename, 'price_list.' . $schema['types'][$_REQUEST['display']]['extension']);
        }
    }
}
Exemple #6
0
    //
    // Update attachments
    //
    if ($mode == 'update') {
        if (!empty($_REQUEST['attachment_data'])) {
            fn_update_attachments($_REQUEST['attachment_data'], $_REQUEST['attachment_id'], $_REQUEST['object_type'], $_REQUEST['object_id']);
        }
    }
    return array(CONTROLLER_STATUS_OK);
    // redirect should be performed via redirect_url always
}
if ($mode == 'getfile') {
    if (!empty($_REQUEST['attachment_id']) && !empty($_REQUEST['object_type']) && !empty($_REQUEST['object_id'])) {
        $data = fn_get_attachment($_REQUEST['attachment_id'], $_REQUEST['object_type'], $_REQUEST['object_id']);
        if (!empty($data['path'])) {
            fn_get_file($data['path']);
        }
    }
    exit;
} elseif ($mode == 'delete') {
    fn_delete_attachments(array($_REQUEST['attachment_id']), $_REQUEST['object_type'], $_REQUEST['object_id']);
    $attachments = fn_get_attachments($_REQUEST['object_type'], $_REQUEST['object_id']);
    if (empty($attachments)) {
        $view->display('addons/attachments/views/attachments/manage.tpl');
    }
    exit;
} elseif ($mode == 'update') {
    // Assign attachments files for products
    $attachments = fn_get_attachments($_REQUEST['object_type'], $_REQUEST['object_id']);
    Registry::set('navigation.tabs.attachments', array('title' => fn_get_lang_var('attachments'), 'js' => true));
    $view->assign('attachments', $attachments);
Exemple #7
0
 /**
  * Push file contents to browser
  *
  * @param  string $file     file to push
  * @param  string $filename file name to be displayed in download dialog
  * @return void
  */
 public function get($file, $filename = '')
 {
     fn_get_file($this->prefix($file), $filename);
 }
Exemple #8
0
        Tygh::$app['view']->assign('extra_id', $_REQUEST['extra_id']);
    }
    $block_types = SchemesManager::getBlockDescriptions($block_types, DESCR_SL);
    Tygh::$app['view']->assign('block_types', $block_types);
    Tygh::$app['view']->assign('unique_blocks', $unique_blocks);
} elseif ($mode == 'get_file' && !empty($_REQUEST['filename'])) {
    $file = fn_basename($_REQUEST['filename']);
    if (Registry::get('runtime.company_id')) {
        $file = Registry::get('runtime.company_id') . '/' . $file;
    }
    if (!empty($_REQUEST['to_screen'])) {
        header("Content-type: text/xml");
        readfile(Registry::get('config.dir.layouts') . $file);
        exit;
    } else {
        fn_get_file(Registry::get('config.dir.layouts') . $file);
    }
} elseif ($mode == 'show_objects') {
    if (!empty($_REQUEST['object_type']) && !empty($_REQUEST['block_id'])) {
        Tygh::$app['view']->assign('object_type', $_REQUEST['object_type']);
        Tygh::$app['view']->assign('block_id', $_REQUEST['block_id']);
        Tygh::$app['view']->assign('object_ids', Block::instance()->getChangedContentsIds($_REQUEST['object_type'], $_REQUEST['block_id']));
        Tygh::$app['view']->assign('params', array('type' => 'links'));
        Tygh::$app['view']->assign('dynamic_object_scheme', SchemesManager::getDynamicObjectByType($_REQUEST['object_type'], $_REQUEST));
    }
}
function fn_get_selected_location($params)
{
    if (isset($params['selected_location']) && !empty($params['selected_location'])) {
        $selected_location = Location::instance()->getById($params['selected_location'], DESCR_SL);
    } else {
Exemple #9
0
    fn_save_cart_content($cart, $auth['user_id']);
    $cart['recalculate'] = true;
    if (defined('AJAX_REQUEST')) {
        fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('text_product_has_been_deleted'));
        if ($action == 'from_status') {
            fn_calculate_cart_content($cart, $auth, 'S', true, 'F', true);
            $view->assign('force_items_deletion', true);
            $view->display('views/checkout/components/cart_status.tpl');
            exit;
        }
    }
    return array(CONTROLLER_STATUS_REDIRECT, "checkout." . $_REQUEST['redirect_mode']);
} elseif ($mode == 'get_custom_file' && isset($_REQUEST['cart_id']) && isset($_REQUEST['option_id']) && isset($_REQUEST['file'])) {
    if (isset($cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']])) {
        $file = $cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']];
        fn_get_file($file['path'], $file['name']);
    }
} elseif ($mode == 'delete_file' && isset($_REQUEST['cart_id'])) {
    if (isset($cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']])) {
        // Delete saved custom file
        $file = $cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']];
        @unlink($file['path']);
        @unlink($file['path'] . '_thumb');
        unset($cart['products'][$_REQUEST['cart_id']]['extra']['custom_files'][$_REQUEST['option_id']][$_REQUEST['file']]);
    }
    fn_save_cart_content($cart, $auth['user_id']);
    $cart['recalculate'] = true;
    if (defined('AJAX_REQUEST')) {
        fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('text_product_file_has_been_deleted'));
        if ($action == 'from_status') {
            fn_calculate_cart_content($cart, $auth, 'S', true, 'F', true);
} elseif ($mode == 'chmod') {
    $file = basename($_REQUEST['file']);
    $fname = fn_normalize_path(DIR_SKINS . $current_path . $file);
    if ($r == 'Y') {
        $res = fn_rchmod($fname, octdec($_REQUEST['perms']));
    } else {
        $res = @chmod($fname, octdec($_REQUEST['perms']));
    }
    fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var($res ? 'text_permissions_changed' : 'error_permissions_not_changed'));
    Registry::get('ajax')->assign('action_type', $res ? '' : 'error');
    exit;
} elseif ($mode == 'get_file') {
    $file = basename($_REQUEST['file']);
    if (!in_array(fn_get_file_ext($file), Registry::get('config.forbidden_file_extensions'))) {
        $pname = fn_normalize_path(DIR_SKINS . $current_path);
        fn_get_file($pname . $file);
    }
    exit;
} elseif ($mode == 'edit') {
    $file = basename($_REQUEST['file']);
    $fname = fn_normalize_path(DIR_SKINS . $current_path . $file);
    if (!in_array(fn_get_file_ext($fname), Registry::get('config.forbidden_file_extensions'))) {
        if (fn_get_image_size($fname)) {
            $ajax->assign('img', Registry::get('config.http_location') . str_replace(DIR_ROOT, '', $fname));
        } else {
            $ajax->assign('content', fn_get_contents($fname));
        }
    }
    exit;
} elseif ($mode == 'restore') {
    $copied = false;
Exemple #11
0
            if (!empty($fields['is_global'])) {
                // Sort table by is_global field
                fn_echo(fn_get_lang_var('sorting_data') . "&nbsp;<b>{$table}</b>...<br />");
                db_query("ALTER TABLE {$table} ORDER BY is_global DESC");
            } elseif (!empty($fields['position'])) {
                // Sort table by position field
                fn_echo(fn_get_lang_var('sorting_data') . "&nbsp;<b>{$table}</b>...<br />");
                db_query("ALTER TABLE {$table} ORDER BY position");
            }
        }
        fn_stop_scroller();
    }
    return array(CONTROLLER_STATUS_OK, "database.manage{$suffix}");
}
if ($mode == 'getfile' && !empty($_REQUEST['file'])) {
    fn_get_file(DIR_DATABASE . 'backup/' . basename($_REQUEST['file']));
} elseif ($mode == 'manage') {
    Registry::set('navigation.tabs', array('backup' => array('title' => fn_get_lang_var('backup'), 'js' => true), 'restore' => array('title' => fn_get_lang_var('restore'), 'js' => true), 'maintenance' => array('title' => fn_get_lang_var('maintenance'), 'js' => true)));
    // Calculate database size and fill tables array
    $status_data = db_get_array("SHOW TABLE STATUS");
    $database_size = 0;
    $all_tables = array();
    foreach ($status_data as $k => $v) {
        $database_size += $v['Data_length'] + $v['Index_length'];
        $all_tables[] = $v['Name'];
    }
    $view->assign('database_size', $database_size);
    $view->assign('all_tables', $all_tables);
    $files = fn_get_dir_contents(DIR_DATABASE . 'backup', false, true, array('.sql', '.tgz'));
    sort($files, SORT_STRING);
    $backup_files = array();
Exemple #12
0
            echo ' .';
            $google_info_new = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = ?s", $_REQUEST['order_id'], GOOGLE_ORDER_DATA);
            if ($google_info_new != $_SESSION['google_info']) {
                unset($_SESSION['google_info']);
                return array(CONTROLLER_STATUS_REDIRECT, "orders.details?order_id={$_REQUEST['order_id']}");
            }
            sleep(1);
        } while (time() - TIME < 59);
        return array(CONTROLLER_STATUS_REDIRECT, "orders.google.wait_response?order_id={$_REQUEST['order_id']}");
    }
} elseif ($mode == 'get_custom_file') {
    if (!empty($_REQUEST['file']) && !empty($_REQUEST['order_id'])) {
        $file_path = DIR_CUSTOM_FILES . 'order_data/' . $_REQUEST['order_id'] . '/' . $_REQUEST['file'];
        if (file_exists($file_path)) {
            $filename = !empty($_REQUEST['filename']) ? $_REQUEST['filename'] : '';
            fn_get_file($file_path, $filename);
        }
    }
}
//
// Calculate gross total and totally paid values for the current set of orders
//
function fn_display_order_totals($orders)
{
    $result = array();
    $result['gross_total'] = 0;
    $result['totally_paid'] = 0;
    if (is_array($orders)) {
        foreach ($orders as $k => $v) {
            $result['gross_total'] += $v['total'];
            if ($v['status'] == 'C' || $v['status'] == 'P') {
Exemple #13
0
    return array(CONTROLLER_STATUS_REDIRECT, "products.manage");
} elseif ($mode == 'getfile') {
    if (!empty($_REQUEST['file_id'])) {
        $revisions = Registry::get('revisions');
        if (!empty($revisions['objects']['product']['tables'])) {
            $revision_subdir = '_rev';
        } else {
            $revision_subdir = '';
        }
        if (empty($_REQUEST['file_type'])) {
            $column = 'file_path';
        } else {
            $column = 'preview_path';
        }
        $file_path = db_get_row("SELECT {$column}, product_id FROM ?:product_files WHERE file_id = ?i", $_REQUEST['file_id']);
        fn_get_file(DIR_DOWNLOADS . $file_path['product_id'] . '/' . $file_path[$column]);
    }
} elseif ($mode == 'clone') {
    if (!empty($_REQUEST['product_id'])) {
        $pid = $_REQUEST['product_id'];
        $pdata = fn_clone_product($pid);
        if (!empty($pdata['product_id'])) {
            $pid = $pdata['product_id'];
            $msg = fn_get_lang_var('text_product_cloned');
            $msg = str_replace('[product]', $pdata['orig_name'], $msg);
            fn_set_notification('N', fn_get_lang_var('notice'), $msg);
        }
        return array(CONTROLLER_STATUS_REDIRECT, "products.update?product_id={$pid}");
    }
} elseif ($mode == 'delete_file') {
    if (!empty($_REQUEST['file_id'])) {
Exemple #14
0
    Registry::get('view')->assign('pattern', $pattern);
    if (empty($datafeed_data['datafeed_id'])) {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
    Registry::get('view')->assign('export_fields', $pattern['export_fields']);
    Registry::get('view')->assign('feature_fields', fn_data_feeds_get_features_fields());
    // [Page sections]
    Registry::set('navigation.tabs', array('detailed' => array('title' => __('general'), 'js' => true), 'exported_items' => array('title' => __('exported_items'), 'js' => true), 'fields' => array('title' => __('map_fields'), 'js' => true)));
    // [/Page sections]
} elseif ($mode == 'download') {
    $params['datafeed_id'] = $_REQUEST['datafeed_id'];
    $params['single'] = true;
    $datafeed_data = fn_data_feeds_get_data($params, DESCR_SL);
    $filename = fn_get_files_dir_path() . $datafeed_data['file_name'];
    if (file_exists($filename)) {
        fn_get_file($filename);
    }
    exit;
}
function fn_data_feeds_update_feed($feed_data, $feed_id = 0, $lang_code = CART_LANGUAGE)
{
    if (!empty($feed_data['fields'])) {
        $_fields = array();
        foreach ($feed_data['fields'] as $key => $field) {
            if (empty($field['export_field_name'])) {
                unset($feed_data['fields'][$key]);
            } else {
                $_fields[intval($field['position'])][] = $field;
            }
        }
    }
Exemple #15
0
        $_REQUEST['section'] = 'products';
    }
    list($sections, $patterns) = fn_get_patterns($_REQUEST['section'], 'import');
    $pattern_id = empty($_REQUEST['pattern_id']) ? key($patterns) : $_REQUEST['pattern_id'];
    $patterns = $parser->enchancePattern($patterns);
    foreach ($patterns as $p_id => $p) {
        Registry::set('navigation.tabs.' . $p_id, array('title' => $p['name'], 'href' => "exim.import?pattern_id=" . $p_id . '&section=' . $_REQUEST['section'], 'ajax' => true));
    }
    Registry::set('navigation.dynamic.sections', $sections);
    Registry::set('navigation.dynamic.active_section', $_REQUEST['section']);
    $patterns['product_images']['analogs_dev'] = 1;
    $view->assign('pattern', $patterns[$pattern_id]);
    $view->assign('sections', $sections);
} elseif ($mode == 'get_file' && !empty($_REQUEST['filename'])) {
    $file = basename($_REQUEST['filename']);
    fn_get_file(DIR_EXIM . $file);
} elseif ($mode == 'delete_file' && !empty($_REQUEST['filename'])) {
    $file = basename($_REQUEST['filename']);
    fn_rm(DIR_EXIM . $file);
    return array(CONTROLLER_STATUS_REDIRECT);
} elseif ($mode == 'delete_range') {
    unset($_SESSION['export_ranges'][$_REQUEST['section']]);
    return array(CONTROLLER_STATUS_REDIRECT, "exim.export?section={$_REQUEST['section']}&pattern_id={$_REQUEST['pattern_id']}");
} elseif ($mode == 'select_range') {
    $_SESSION['export_ranges'][$_REQUEST['section']] = array('pattern_id' => $_REQUEST['pattern_id'], 'data' => array());
    $pattern = fn_get_pattern_definition($_REQUEST['pattern_id']);
    return array(CONTROLLER_STATUS_REDIRECT, $pattern['range_options']['selector_url']);
} elseif ($mode == 'export_simple') {
    $products = db_get_array("SELECT `product_id`, `product_code` FROM `cscart_products`");
    $date = date('d-m-Y');
    $myFile = '' . DIR_EXIM . 'simple_products_' . $date . '.csv';
Exemple #16
0
        fn_set_notification('E', __('error'), __('text_cannot_create_file', array('[file]' => fn_basename($file_path))));
    }
    return array(CONTROLLER_STATUS_REDIRECT, 'templates.init_view?dir=' . $_REQUEST['file_path']);
} elseif ($mode == 'create_folder') {
    $folder_path = fn_te_normalize_path($_REQUEST, $root_dir);
    if (fn_te_check_path($folder_path) && fn_mkdir($folder_path)) {
        fn_set_notification('N', __('notice'), __('text_directory_created', array('[directory]' => fn_basename($folder_path))));
    } else {
        fn_set_notification('E', __('error'), __('text_cannot_create_directory', array('[directory]' => fn_basename($folder_path))));
    }
    return array(CONTROLLER_STATUS_REDIRECT, 'templates.init_view?dir=' . $_REQUEST['file_path']);
} elseif ($mode == 'get_file') {
    $pname = fn_te_normalize_path($_REQUEST, $root_dir);
    if (fn_te_check_path($pname)) {
        if (is_file($pname) && !in_array(fn_strtolower(fn_get_file_ext($pname)), Registry::get('config.forbidden_file_extensions'))) {
            fn_get_file($pname);
        }
    }
    exit;
} elseif ($mode == 'edit') {
    $fname = fn_te_normalize_path($_REQUEST, $root_dir);
    if (fn_te_check_path($fname) && !in_array(fn_strtolower(fn_get_file_ext($fname)), Registry::get('config.forbidden_file_extensions'))) {
        Tygh::$app['ajax']->assign('content', fn_get_contents($fname));
    } else {
        fn_set_notification('E', __('error'), __('you_have_no_permissions'));
    }
    exit;
} elseif ($mode == 'restore') {
    $copied = false;
    $file_path = fn_te_normalize_path($_REQUEST, $root_dir);
    if (fn_te_check_path($file_path)) {
 /**
  * Creates PO file for specified Language
  *
  * @param string $lang_code 2-letters language code (Example: "en", "ru")
  * @param string $output    Output destination
  *      screen - Output countent direct to browser page
  *      download - Force file downloading
  *      server - upload file to the config.dir.lang_packs directory
  * @param string $output_file Default name is $lang_code . '.po'
  */
 public static function createPoFile($lang_code, $output = 'download', $output_file = '')
 {
     // Translation packs should not include "Not translated" language data
     $allow_overlap = $lang_code == 'en' ? true : false;
     $filename = fn_create_temp_file();
     if (empty($output_file)) {
         $output_file = $lang_code . '.po';
     }
     $langs = self::get(array('lang_code' => $lang_code));
     $lang = $langs[$lang_code];
     Po::createHeader($filename, $lang);
     // Export Language values
     list($values) = LanguageValues::getVariables(array(), 0, $lang_code);
     $original_values = self::getOriginalValues('Languages');
     foreach ($values as $_id => $value) {
         $values[$_id]['original_value'] = isset($original_values['Languages::' . $value['name']]) ? $original_values['Languages::' . $value['name']]['msgid'] : '';
     }
     $values = Po::convert($values, array(), $allow_overlap);
     Po::putValues('Languages', $values, $filename);
     // Export "SettingsVariants"
     $values = Settings::instance()->getVariants('', '', '', 'all', $lang_code);
     $original_values = self::getOriginalValues('SettingsVariants');
     foreach ($values as $_id => $value) {
         $values[$_id]['original_value'] = isset($original_values['SettingsVariants::' . $_id]) ? $original_values['SettingsVariants::' . $_id]['msgid'] : '';
     }
     $values = Po::convert($values, array('id' => '%key'), $allow_overlap);
     Po::putValues('SettingsVariants', $values, $filename);
     // Export Settings Sections
     $values = Settings::instance()->getCoreSections($lang_code);
     $original_values = self::getOriginalValues('SettingsSections');
     foreach ($values as $_id => $value) {
         $values[$_id]['original_value'] = isset($original_values['SettingsSections::' . $value['section_id']]) ? $original_values['SettingsSections::' . $value['section_id']]['msgid'] : '';
     }
     $values = Po::convert($values, array('id' => 'section_id', 'value' => 'description'), $allow_overlap);
     Po::putValues('SettingsSections', $values, $filename);
     // Export Settings Options
     $values = Settings::instance()->getList(0, 0, true, null, $lang_code);
     $original_values = self::getOriginalValues('SettingsOptions');
     foreach ($values as $_id => $value) {
         $values[$_id]['original_value'] = isset($original_values['SettingsOptions::' . $value['name']]) ? $original_values['SettingsOptions::' . $value['name']]['msgid'] : '';
     }
     $values = Po::convert($values, array('id' => 'name', 'value' => 'description'), $allow_overlap);
     Po::putValues('SettingsOptions', $values, $filename);
     // Export Addons data (name, description)
     list($addons) = fn_get_addons(array('type' => 'installed'), 0, $lang_code);
     $values = array();
     foreach ($addons as $addon_id => $addon) {
         $values[] = array('name' => $addon_id, 'value' => $addon['name'], 'original_value' => $addon['originals']['name']);
     }
     $values = Po::convert($values, array(), $allow_overlap);
     Po::putValues('Addon', $values, $filename);
     $values = array();
     foreach ($addons as $addon_id => $addon) {
         $values[] = array('name' => $addon_id, 'value' => $addon['description'], 'original_value' => $addon['originals']['description']);
     }
     $values = Po::convert($values, array(), $allow_overlap);
     Po::putValues('AddonDescription', $values, $filename);
     // Export Profile fields
     $profile_fields = fn_get_profile_fields('ALL', array(), $lang_code);
     $original_values = self::getOriginalValues('ProfileFields');
     $values = array();
     foreach ($profile_fields as $zone => $fields) {
         foreach ($fields as $field_id => $field) {
             $values[] = array('name' => $field['field_name'], 'value' => $field['description'], 'original_value' => isset($original_values['ProfileFields::' . $field['field_name']]) ? $original_values['ProfileFields::' . $field['field_name']]['msgid'] : '');
         }
     }
     $values = Po::convert($values, array(), $allow_overlap);
     Po::putValues('ProfileFields', $values, $filename);
     switch ($output) {
         case 'screen':
             header("Content-type: text/plain");
             readfile($filename);
             exit;
             break;
         case 'server':
             fn_copy($filename, Registry::get('config.dir.lang_packs') . $output_file);
             break;
         case 'download':
             fn_get_file($filename, $output_file);
             break;
     }
 }
Exemple #18
0
                // Sort table by position field
                fn_echo('.');
                db_query("ALTER TABLE {$table} ORDER BY position");
            }
        }
        fn_set_notification('N', __('notice'), __('done'));
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['backup_file'])) {
            fn_rm(Registry::get('config.dir.backups') . fn_basename($_REQUEST['backup_file']));
        }
    }
    return array(CONTROLLER_STATUS_OK, 'datakeeper.manage');
}
if ($mode == 'getfile' && !empty($_REQUEST['file'])) {
    fn_get_file(Registry::get('config.dir.backups') . fn_basename($_REQUEST['file']));
} elseif ($mode == 'manage') {
    $view = Tygh::$app['view'];
    // Calculate database size and fill tables array
    $status_data = db_get_array("SHOW TABLE STATUS");
    $database_size = 0;
    $all_tables = array();
    foreach ($status_data as $k => $v) {
        $database_size += $v['Data_length'] + $v['Index_length'];
        $all_tables[] = $v['Name'];
    }
    $view->assign('database_size', $database_size);
    $view->assign('all_tables', $all_tables);
    $files = fn_get_dir_contents(Registry::get('config.dir.backups'), false, true, array('.sql', '.tgz', '.zip'), '', true);
    sort($files, SORT_STRING);
    $backup_files = array();
            if (!empty($fields['is_global'])) {
                // Sort table by is_global field
                fn_echo('.');
                db_query("ALTER TABLE {$table} ORDER BY is_global DESC");
            } elseif (!empty($fields['position'])) {
                // Sort table by position field
                fn_echo('.');
                db_query("ALTER TABLE {$table} ORDER BY position");
            }
        }
        fn_set_notification('N', __('notice'), __('done'));
    }
    return array(CONTROLLER_STATUS_OK, "database.manage");
}
if ($mode == 'getfile' && !empty($_REQUEST['file'])) {
    fn_get_file(Registry::get('config.dir.database') . fn_basename($_REQUEST['file']));
} elseif ($mode == 'manage') {
    Registry::set('navigation.tabs', array('backup' => array('title' => __('backup'), 'js' => true), 'restore' => array('title' => __('restore'), 'js' => true), 'maintenance' => array('title' => __('maintenance'), 'js' => true)));
    // Calculate database size and fill tables array
    $status_data = db_get_array("SHOW TABLE STATUS");
    $database_size = 0;
    $all_tables = array();
    foreach ($status_data as $k => $v) {
        $database_size += $v['Data_length'] + $v['Index_length'];
        $all_tables[] = $v['Name'];
    }
    Registry::get('view')->assign('database_size', $database_size);
    Registry::get('view')->assign('all_tables', $all_tables);
    $files = fn_get_dir_contents(Registry::get('config.dir.database'), false, true, array('.sql', '.tgz'), '', true);
    sort($files, SORT_STRING);
    $backup_files = array();