Exemplo n.º 1
0
function fn_settings_variants_appearance_default_image_previewer()
{
    $previewers_path = Registry::get('config.dir.root') . '/js/tygh/previewers';
    $previewers = fn_get_dir_contents($previewers_path, false, true, 'js');
    $return = array();
    foreach ($previewers as $previewer) {
        $previewer_description = fn_get_file_description($previewers_path . '/' . $previewer, 'previewer-description');
        $return[fn_basename($previewer, '.previewer.js')] = $previewer_description;
    }
    return $return;
}
Exemplo n.º 2
0
function fn_update_attachments($attachment_data, $attachment_id, $object_type, $object_id, $type = 'M', $files = null, $lang_code = DESCR_SL)
{
    $object_id = intval($object_id);
    $directory = $object_type . '/' . $object_id;
    if ($files != null) {
        $uploaded_data = $files;
    } else {
        $uploaded_data = fn_filter_uploaded_data('attachment_files');
    }
    if (!empty($attachment_id)) {
        $rec = array('usergroup_ids' => empty($attachment_data['usergroup_ids']) ? '0' : implode(',', $attachment_data['usergroup_ids']), 'position' => $attachment_data['position']);
        db_query("UPDATE ?:attachment_descriptions SET description = ?s WHERE attachment_id = ?i AND lang_code = ?s", $attachment_data['description'], $attachment_id, $lang_code);
        db_query("UPDATE ?:attachments SET ?u WHERE attachment_id = ?i AND object_type = ?s AND object_id = ?i AND type = ?s", $rec, $attachment_id, $object_type, $object_id, $type);
        fn_set_hook('attachment_update_file', $attachment_data, $attachment_id, $object_type, $object_id, $type, $files, $lang_code, $uploaded_data);
    } elseif (!empty($uploaded_data)) {
        $rec = array('object_type' => $object_type, 'object_id' => $object_id, 'usergroup_ids' => empty($attachment_data['usergroup_ids']) ? '0' : implode(',', $attachment_data['usergroup_ids']), 'position' => $attachment_data['position']);
        if ($type !== null) {
            $rec['type'] = $type;
        } elseif (!empty($attachment_data['type'])) {
            $rec['type'] = $attachment_data['type'];
        }
        $attachment_id = db_query("INSERT INTO ?:attachments ?e", $rec);
        if ($attachment_id) {
            // Add file description
            foreach (fn_get_translation_languages() as $lang_code => $v) {
                $rec = array('attachment_id' => $attachment_id, 'lang_code' => $lang_code, 'description' => is_array($attachment_data['description']) ? $attachment_data['description'][$lang_code] : $attachment_data['description']);
                db_query("INSERT INTO ?:attachment_descriptions ?e", $rec);
            }
            $uploaded_data[$attachment_id] = $uploaded_data[0];
            unset($uploaded_data[0]);
        }
        fn_set_hook('attachment_add_file', $attachment_data, $object_type, $object_id, $type, $files, $attachment_id, $uploaded_data);
    }
    if ($attachment_id && !empty($uploaded_data[$attachment_id]) && $uploaded_data[$attachment_id]['size']) {
        $filename = $uploaded_data[$attachment_id]['name'];
        $old_filename = db_get_field("SELECT filename FROM ?:attachments WHERE attachment_id = ?i", $attachment_id);
        if ($old_filename) {
            Storage::instance('attachments')->delete($directory . '/' . $old_filename);
        }
        list($filesize, $filename) = Storage::instance('attachments')->put($directory . '/' . $filename, array('file' => $uploaded_data[$attachment_id]['path']));
        if ($filesize) {
            $filename = fn_basename($filename);
            db_query("UPDATE ?:attachments SET filename = ?s, filesize = ?i WHERE attachment_id = ?i", $filename, $filesize, $attachment_id);
        }
    }
    return $attachment_id;
}
Exemplo n.º 3
0
function fn_price_list_pdf_url_info()
{
    $return_url = fn_url('addons.manage', 'A', defined('HTTPS') ? 'https' : 'http');
    if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) {
        $text = __('ult_pdf_info') . '<br />';
    } else {
        $text = __('pdf_info') . '<br />';
    }
    $modes = fn_price_list_get_pdf_layouts();
    if (!empty($modes['pdf'])) {
        foreach ($modes['pdf'] as $mode) {
            $mode = fn_basename($mode, '.php');
            $text .= fn_build_link_on_price('price_list.view?display=', $mode, $return_url);
        }
    }
    $text .= '<br />';
    return $text;
}
Exemplo n.º 4
0
 /**
  * Converts URL (http://e.com/a.png) to CSS property ( url("../a.png") )
  * @param  string $style_id   style ID
  * @param  array  $style_data style data (fields)
  * @return array  modified style data
  */
 private function urlToCss($style_id, $style_data)
 {
     $patterns_url = Patterns::instance($this->params)->getUrl($style_id, true);
     if (!empty($this->schema['backgrounds']['fields'])) {
         foreach ($this->schema['backgrounds']['fields'] as $field) {
             if (!empty($field['properties']['pattern'])) {
                 $var_name = $field['properties']['pattern'];
                 if (!empty($style_data[$var_name]) && strpos($style_data[$var_name], '//') !== false) {
                     $url = preg_replace('/url\\([\'"]?(.*?)[\'"]?\\)/', '$1', $style_data[$var_name]);
                     if (strpos($url, '//') === 0) {
                         $url = 'http:' . $url;
                     }
                     $url = fn_normalize_path($url);
                     if (strpos($url, $patterns_url) !== false) {
                         $url = str_replace($patterns_url, '..', $url);
                         if (strpos($url, '?') !== false) {
                             // URL is parsed by Less::parseUrls method, so remove everything after ?
                             list($url) = explode('?', $url);
                         }
                     } elseif ($style_id) {
                         // external url
                         $tmp_file = fn_create_temp_file();
                         fn_put_contents($tmp_file, fn_get_contents($url));
                         $_style = Patterns::instance($this->params)->save($style_id, array('data' => $style_data), array($var_name => array('name' => fn_basename($url), 'path' => $tmp_file)));
                         $style_data = $_style['data'];
                         continue;
                         // assignment done in save method
                     }
                     $style_data[$var_name] = 'url(' . $url . ')';
                 }
             }
         }
     }
     return $style_data;
 }
Exemplo n.º 5
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();
Exemplo n.º 6
0
function fn_ftp_chmod_file($filename, $perm = DEFAULT_FILE_PERMISSIONS, $recursive = false)
{
    $result = false;
    $ftp = Registry::get('ftp_connection');
    if (is_resource($ftp)) {
        $dest = dirname($filename);
        $dest = rtrim($dest, '/') . '/';
        // force adding trailing slash to path
        $rel_path = str_replace(Registry::get('config.dir.root') . '/', '', $dest);
        $cdir = ftp_pwd($ftp);
        if (empty($rel_path)) {
            // if rel_path is empty, assume it's root directory
            $rel_path = $cdir;
        }
        if (@ftp_chdir($ftp, $rel_path)) {
            $result = @ftp_site($ftp, 'CHMOD ' . sprintf('0%o', $perm) . ' ' . fn_basename($filename));
            if ($recursive) {
                $path = fn_normalize_path($cdir . '/' . $rel_path . fn_basename($filename));
                if (is_dir($path)) {
                    $_files = fn_get_dir_contents($path, true, true, '', '', true);
                    if (!empty($_files)) {
                        foreach ($_files as $_file) {
                            fn_ftp_chmod_file($path . '/' . $_file, $perm, false);
                        }
                    }
                }
            }
            ftp_chdir($ftp, $cdir);
        }
    }
    return $result;
}
Exemplo n.º 7
0
    $file_path = fn_te_normalize_path($_REQUEST, $root_dir);
    if (fn_te_check_path($file_path)) {
        $repo_path = str_replace($root_dir, fn_te_get_root('repo'), $file_path);
        if (!file_exists($repo_path) && fn_get_theme_path('[theme]') != Registry::get('config.base_theme') && is_dir(fn_get_theme_path('[repo]/[theme]'))) {
            $repo_path = preg_replace("/\\/themes_repository\\/(\\w+)\\//", "/themes_repository/" . Registry::get('config.base_theme') . "/", $repo_path);
        }
        $object_base = is_file($repo_path) ? 'file' : (is_dir($repo_path) ? 'directory' : '');
        if (!empty($object_base) && fn_copy($repo_path, $file_path)) {
            fn_set_notification('N', __('notice'), __("text_{$object_base}_restored", array("[{$object_base}]" => fn_basename($file_path))));
            Tygh::$app['ajax']->assign('content', fn_get_contents($file_path));
            $copied = true;
        }
    }
    if (!$copied) {
        $object_base = empty($object_base) ? 'file' : $object_base;
        fn_set_notification('E', __('error'), __("text_cannot_restore_{$object_base}", array("[{$object_base}]" => fn_basename($file_path))));
    }
    return array(CONTROLLER_STATUS_REDIRECT, 'templates.init_view?dir=' . $_REQUEST['file_path'] . '/' . $_REQUEST['file']);
}
/**
 * Checks if working path is inside root directory
 * @param string $path working path
 * @return boolean true of success, false - otherwise
 */
function fn_te_check_path($path)
{
    $path = fn_normalize_path($path);
    $base_dir = fn_te_get_root('full');
    return strpos($path, $base_dir) === 0 && !fn_te_filter_path($path);
}
/**
Exemplo n.º 8
0
 /**
  * Gets patterns relative (to css files) path
  * @param  string $style_id style ID
  * @return string patterns relative path
  */
 public static function getRelPath($style_id)
 {
     return '../media/images/patterns/' . fn_basename($style_id);
 }
Exemplo n.º 9
0
function fn_exim_1c_import_products($catalog, $user_data, $company_id, $lang_code, $cml)
{
    if (isset($catalog->{$cml}['products'])) {
        $images = $products = array();
        list($dir_1c, $dir_1c_url, $dir_1c_images) = fn_rus_exim_1c_get_dir_1c();
        $_categories = Registry::get('rus_exim_1c.categories_1c');
        $settings_1c = Registry::get('addons.rus_exim_1c');
        $only_import_offers = $settings_1c['exim_1c_only_import_offers'];
        $import_product_name = $settings_1c['exim_1c_import_product_name'];
        $import_product_code = $settings_1c['exim_1c_import_product_code'];
        $allow_import_categories = $settings_1c['exim_1c_allow_import_categories'];
        $allow_import_features = $settings_1c['exim_1c_allow_import_features'];
        $import_full_description = $settings_1c['exim_1c_import_full_description'];
        $import_short_description = $settings_1c['exim_1c_import_short_description'];
        $import_page_title = $settings_1c['exim_1c_page_title'];
        $property_for_promo_text = trim($settings_1c['exim_1c_property_product']);
        $category_link_type = $settings_1c['exim_1c_category_link_type'];
        $all_images_is_additional = $settings_1c['exim_1c_all_images_is_additional'];
        $add_tax = $settings_1c['exim_1c_add_tax'];
        $hide_product = $settings_1c['exim_1c_add_out_of_stock'];
        $schema_version = $settings_1c['exim_1c_schema_version'];
        $type_option = $settings_1c['exim_1c_type_option'];
        $standart_option_name = $settings_1c['exim_1c_import_option_name'];
        $features_1c = array();
        if (Registry::isExist('rus_exim_1c.features_1c')) {
            $features_1c = Registry::get('rus_exim_1c.features_1c');
        }
        foreach ($catalog->{$cml}['products']->{$cml}['product'] as $_product) {
            if (empty($_product->{$cml}['name']) || empty($_product->{$cml}['groups']->{$cml}['id'])) {
                continue;
            }
            $ids = fn_explode('#', $_product->{$cml}['id']);
            $guid_product = array_shift($ids);
            $product_id = db_get_field("SELECT product_id FROM ?:products WHERE external_id = ?s", $guid_product);
            $product_id = empty($product_id) ? 0 : $product_id;
            if ($product_id != 0 && $only_import_offers == 'Y') {
                continue;
            }
            $product = array();
            $product['external_id'] = $guid_product;
            $full_name = $product_code = $html_description = '';
            foreach ($_product->{$cml}['value_fields']->{$cml}['value_field'] as $reckvizit) {
                if (strval($reckvizit->{$cml}['name']) == $cml['full_name']) {
                    $full_name = strval($reckvizit->{$cml}['value']);
                }
                if (strval($reckvizit->{$cml}['name']) == $cml['code']) {
                    $product_code = strval($reckvizit->{$cml}['value']);
                }
                if (strval($reckvizit->{$cml}['name']) == $cml['html_description']) {
                    $html_description = strval($reckvizit->{$cml}['value']);
                }
            }
            if ($schema_version == '2.07' && !empty($_product->{$cml}['image'])) {
                foreach ($_product->{$cml}['image'] as $file_description) {
                    $filename = fn_basename(strval($file_description));
                    if (fn_exim_1c_file_is_file($filename)) {
                        $html_description = file_get_contents($dir_1c . $filename);
                    }
                }
            }
            // Import product name
            $product['product'] = strval($_product->{$cml}['name']);
            if ($import_product_name == 'full_name' && !empty($full_name)) {
                $product['product'] = $full_name;
            }
            // Import product code
            $article = strval($_product->{$cml}['article']);
            $product['product_code'] = !empty($article) ? $article : '';
            if ($import_product_code == 'code') {
                $product['product_code'] = $product_code;
            }
            if ($import_product_code == 'bar') {
                $product['product_code'] = strval($_product->{$cml}['bar']);
            }
            // Import product full description
            if ($import_full_description != 'not_import') {
                $product['full_description'] = $_product->{$cml}['description'];
            }
            if ($import_full_description == 'html_description') {
                $product['full_description'] = $html_description;
            } elseif ($import_full_description == 'full_name') {
                $product['full_description'] = $full_name;
            }
            // Import product short description
            if ($import_short_description != 'not_import') {
                $product['short_description'] = $_product->{$cml}['description'];
            }
            if ($import_short_description == 'html_description') {
                $product['short_description'] = $html_description;
            } elseif ($import_short_description == 'full_name') {
                $product['short_description'] = $full_name;
            }
            // Import page title
            if ($import_page_title == 'name') {
                $product['page_title'] = trim($_product->{$cml}['name'], " -");
            } elseif ($import_page_title == 'full_name') {
                $product['page_title'] = trim($full_name, " -");
            }
            // Import promo text
            if (!empty($property_for_promo_text)) {
                $product['promo_text'] = fn_exim_1c_get_promo_text($_product, $property_for_promo_text, $cml);
            }
            $product['company_id'] = $user_data['user_type'] == 'V' ? $user_data['company_id'] : $company_id;
            if ($allow_import_categories == 'Y') {
                $product['category_id'] = !empty($_categories[strval($_product->{$cml}['groups']->{$cml}['id'])]) ? $_categories[strval($_product->{$cml}['groups']->{$cml}['id'])] : array('0');
            }
            if ($product_id == 0) {
                $product['price'] = '0.00';
                $product['list_price'] = '0.00';
                $product['timestamp'] = time();
                $product['lower_limit'] = 1;
                $product['details_layout'] = 'default';
                $product['lang_code'] = $lang_code;
                if ($hide_product == 'Y') {
                    $product['status'] = 'H';
                }
                if ($allow_import_categories != 'Y') {
                    $product['category_id'] = fn_exim_1c_get_default_category($company_id, $settings_1c);
                }
                $product_id = fn_exim_1c_create_product($product);
            } else {
                $product['updated_timestamp'] = time();
                if ($allow_import_categories == 'Y') {
                    $eid = strval($_product->{$cml}['groups']->{$cml}['id']);
                    $product['category_id'] = !empty($_categories[$eid]) ? $_categories[$eid] : 0;
                }
                fn_exim_1c_update_product($product, $product_id, array('allow_import_categories' => $allow_import_categories, 'category_link_type' => $category_link_type), $lang_code, $company_id);
            }
            // Import product features
            if (isset($_product->{$cml}['properties_values']->{$cml}['property_values']) && $allow_import_features == 'Y' && !empty($features_1c)) {
                fn_exim_1c_import_product_features($_product, $product_id, $features_1c, $_categories, $lang_code, $cml);
            }
            // Import taxes
            if (isset($_product->{$cml}['taxes_rates']) && $add_tax == 'Y') {
                fn_exim_1c_add_tax($_product->{$cml}['taxes_rates'], $product_id, $lang_code, $cml);
            }
            // Import images
            $image_main = true;
            foreach ($_product->{$cml}['image'] as $image) {
                $filename = fn_basename(strval($image));
                fn_exim_1c_image_search($filename, $image_main, $all_images_is_additional, $dir_1c_images, $product_id, $lang_code);
                $image_main = false;
            }
            // Import combinations
            if (isset($_product->{$cml}['product_features']) && $schema_version == '2.07') {
                fn_exim_1c_import_product_combinations($_product->{$cml}['product_features'], $product_id, $lang_code, $cml, $standart_option_name, $company_id, $type_option);
            }
            fn_echo(' ');
        }
        $category_ids = array_unique(db_get_fields("SELECT category_id FROM ?:products_categories ORDER BY category_id"));
        foreach ($category_ids as $category_id) {
            $product_count = db_get_field("SELECT COUNT(*) FROM ?:products_categories WHERE category_id = ?i", $category_id);
            db_query("UPDATE ?:categories SET product_count = ?i WHERE category_id = ?i", $product_count, $category_id);
        }
    }
}
Exemplo n.º 10
0
 /**
  * Put directory to storage
  *
  * @param  string  $dir    directory to get files from
  * @param  array   $params additional parameters
  * @return boolean true of success, false on fail
  */
 public function putDir($dir, $params = array())
 {
     $s3 = $this->s3();
     // get object to initialize class and get access to contstants below
     $i = 0;
     $max_batch = 10;
     $files = fn_get_dir_contents($dir, false, true, '', '', true);
     fn_set_progress('step_scale', sizeof($files));
     foreach ($files as $source_file) {
         fn_set_progress('echo', '.');
         $i++;
         $data = array('acl' => \AmazonS3::ACL_PUBLIC, 'headers' => array());
         // File can not be accessible via direct link
         if ($this->getOption('secured')) {
             $data['headers']['Content-disposition'] = 'attachment; filename="' . fn_basename($source_file) . '"';
             $data['acl'] = \AmazonS3::ACL_PRIVATE;
         }
         $data['contentType'] = fn_get_file_type($source_file);
         $data['fileUpload'] = $dir . '/' . $source_file;
         $res = $s3->batch()->create_object($this->getOption('bucket'), $this->prefix($source_file), $data);
         if ($i == $max_batch) {
             $s3->batch()->send();
             $i = 0;
         }
     }
     if (!empty($i)) {
         $s3->batch()->send();
         // send the rest of the batch
     }
     return true;
 }
Exemplo n.º 11
0
                 }
             }
             // Update manifest
             if (file_exists($theme_path . '/' . THEME_MANIFEST)) {
                 $manifest_content = fn_get_contents($theme_path . '/' . THEME_MANIFEST);
                 $manifest = json_decode($manifest_content, true);
             } else {
                 $manifest = parse_ini_file($theme_path . '/' . THEME_MANIFEST_INI);
             }
             $manifest['title'] = $_REQUEST['theme_data']['title'];
             $manifest['description'] = $_REQUEST['theme_data']['description'];
             // Put logos of current layout to manifest
             $logos = fn_get_logos(Registry::get('runtime.company_id'));
             foreach ($logos as $type => $logo) {
                 if (!empty($logo['image'])) {
                     $filename = fn_basename($logo['image']['relative_path']);
                     Storage::instance('images')->export($logo['image']['relative_path'], $theme_path . '/media/images/' . $filename);
                     $manifest[$type] = 'media/images/' . $filename;
                 }
             }
             fn_put_contents($theme_path . '/' . THEME_MANIFEST, json_encode($manifest));
             fn_install_theme($theme_dest, Registry::get('runtime.company_id'), false);
         }
     } else {
         fn_set_notification('W', __('warning'), __('warning_theme_clone_dir_exists'));
     }
 } elseif ($mode == 'upload') {
     $theme_pack = fn_filter_uploaded_data('theme_pack', Registry::get('config.allowed_pack_exts'));
     if (empty($theme_pack[0])) {
         fn_set_notification('E', __('error'), __('text_allowed_to_upload_file_extension', array('[ext]' => implode(',', Registry::get('config.allowed_pack_exts')))));
     } else {
Exemplo n.º 12
0
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
//
// Delete image
//
if ($mode == 'create') {
    $result_image = '';
    if (!empty($_SERVER['REQUEST_URI'])) {
        $path = defined('HTTPS') ? Registry::get('config.https_path') : Registry::get('config.http_path');
        $image_file = str_replace($path . '/images/', '', $_SERVER['REQUEST_URI']);
        $watermarked_file = WATERMARKS_DIR_NAME . $image_file;
        if (Storage::instance('images')->isExist($watermarked_file)) {
            $result_image = Storage::instance('images')->getUrl($watermarked_file);
        } elseif (Storage::instance('images')->isExist($image_file)) {
            $image_name = fn_basename($image_file);
            $image_id = db_get_field("SELECT image_id FROM ?:images WHERE image_path LIKE ?l", "%{$image_name}%");
            $image_link = db_get_row("SELECT * FROM ?:images_links WHERE image_id = ?i OR detailed_id = ?i", $image_id, $image_id);
            if (!empty($image_link)) {
                $is_detailed = $image_link['detailed_id'] == $image_id;
                $image_type = $is_detailed ? 'detailed' : 'icons';
                $generate_watermark = fn_is_need_watermark($image_link['object_type'], $is_detailed, Registry::get('runtime.company_id'));
                if (fn_watermark_create($image_file, $watermarked_file, $is_detailed, Registry::get('runtime.company_id'), $generate_watermark)) {
                    $result_image = Storage::instance('images')->getUrl($watermarked_file);
                }
            }
        }
    }
    if (!empty($result_image)) {
        header('Location: ' . $result_image);
    }
Exemplo n.º 13
0
 private function _copyImages()
 {
     $images_dirs = fn_get_dir_contents($this->store_data['path'] . '/images', true, false, '', $this->store_data['path'] . '/images/');
     $img_path_info = Registry::get('config.storage.images');
     foreach ($images_dirs as $dir) {
         fn_copy($dir, $img_path_info['dir'] . fn_basename($dir), true);
     }
     return true;
 }
Exemplo n.º 14
0
             $base_price_1c .= $price['price_1c'] . ',';
         } elseif ($price['type'] == 'list') {
             $list_price_1c .= $price['price_1c'] . ',';
         } else {
             $prices[] = $price;
         }
     }
     Tygh::$app['view']->assign('list_price_1c', trim($list_price_1c, ','));
     Tygh::$app['view']->assign('base_price_1c', trim($base_price_1c, ','));
     Tygh::$app['view']->assign('prices_data', $prices);
     if ($s_commerceml['exim_1c_check_prices'] == 'Y') {
         list($path_commerceml, $url_commerceml, $url_images) = RusEximCommerceml::getDirCommerceML();
         $result = array();
         $file_offers = glob($path_commerceml . "offers*");
         if (!empty($file_offers)) {
             $filename = fn_basename(reset($file_offers));
             $xml = RusEximCommerceml::getFileCommerceml($filename);
             if (isset($xml->{$cml}['packages']->{$cml}['offers']->{$cml}['offer'])) {
                 $result = RusEximCommerceml::checkPricesOffers($xml->{$cml}['packages']);
             }
         } else {
             fn_set_notification('W', __('warning'), __('offers_not_found'));
         }
         Tygh::$app['view']->assign('resul_test', $result);
     }
 }
 if ($s_commerceml['exim_1c_add_tax'] == 'Y') {
     $taxes = fn_get_taxes();
     $taxes_data = db_get_array("SELECT * FROM ?:rus_exim_1c_taxes");
     Tygh::$app['view']->assign('taxes_data', $taxes_data);
     Tygh::$app['view']->assign('taxes', $taxes);
Exemplo n.º 15
0
function fn_copy_product_files($file_id, $file, $product_id, $var_prefix = 'file')
{
    /**
     * Changes params before copying product files
     *
     * @param int    $file_id    File identifier
     * @param array  $file       File data
     * @param int    $product_id Product identifier
     * @param string $var_prefix Prefix of file variables
     */
    fn_set_hook('copy_product_files_pre', $file_id, $file, $product_id, $var_prefix);
    $filename = $product_id . '/' . $file['name'];
    $_data = array();
    list($_data[$var_prefix . '_size'], $_data[$var_prefix . '_path']) = Storage::instance('downloads')->put($filename, array('file' => $file['path'], 'overwrite' => true));
    $_data[$var_prefix . '_path'] = fn_basename($_data[$var_prefix . '_path']);
    db_query('UPDATE ?:product_files SET ?u WHERE file_id = ?i', $_data, $file_id);
    /**
     * Adds additional actions after product files were copied
     *
     * @param int    $file_id    File identifier
     * @param array  $file       File data
     * @param int    $product_id Product identifier
     * @param string $var_prefix Prefix of file variables
     */
    fn_set_hook('copy_product_files_post', $file_id, $file, $product_id, $var_prefix);
    return true;
}
Exemplo n.º 16
0
        }
        return array(CONTROLLER_STATUS_REDIRECT, $_REQUEST['current_url']);
    }
    if ($mode == 'restore_template') {
        $copied = false;
        $full_path = fn_get_theme_path('[themes]/[theme]', 'C') . '/templates/' . $_REQUEST['file'];
        if (fn_check_path($full_path)) {
            $c_name = fn_normalize_path($full_path);
            $r_name = fn_normalize_path(Registry::get('config.dir.themes_repository') . Registry::get('config.base_theme') . '/templates/' . $_REQUEST['file']);
            if (is_file($r_name)) {
                $copied = fn_copy($r_name, $c_name);
            }
            if ($copied) {
                fn_set_notification('N', __('notice'), __('text_file_restored', array('[file]' => fn_basename($_REQUEST['file']))));
            } else {
                fn_set_notification('E', __('error'), __('text_cannot_restore_file', array('[file]' => fn_basename($_REQUEST['file']))));
            }
            if ($copied) {
                if (defined('AJAX_REQUEST')) {
                    Registry::get('ajax')->assign('force_redirection', fn_url($_REQUEST['current_url']));
                    Registry::get('ajax')->assign('non_ajax_notifications', true);
                }
                return array(CONTROLLER_STATUS_OK, $_REQUEST['current_url']);
            }
        }
        exit;
    }
}
if ($mode == 'get_content') {
    $ext = fn_strtolower(fn_get_file_ext($_REQUEST['file']));
    if ($ext == 'tpl') {
Exemplo n.º 17
0
/**
 * Uninstalles addon
 *
 * @param string $addon_name Addon name to be uninstalled
 * @param bool $show_message If defined as true, additionally show notification
 * @return bool True if addons uninstalled successfully, false otherwise
 */
function fn_uninstall_addon($addon_name, $show_message = true)
{
    $addon_scheme = SchemesManager::getScheme($addon_name);
    if ($addon_scheme != false) {
        // Unmanaged addons can be uninstalled via console only
        if ($addon_scheme->getUnmanaged() && !defined('CONSOLE')) {
            return false;
        }
        // Check dependencies
        $dependencies = SchemesManager::getUninstallDependencies($addon_name);
        if (!empty($dependencies)) {
            fn_set_notification('W', __('warning'), __('text_addon_uninstall_dependencies', array('[addons]' => implode(',', $dependencies))));
            return false;
        }
        // Execute custom functions for uninstall
        $addon_scheme->callCustomFunctions('uninstall');
        $addon_description = db_get_field("SELECT name FROM ?:addon_descriptions WHERE addon = ?s and lang_code = ?s", $addon_name, CART_LANGUAGE);
        // Delete options
        db_query("DELETE FROM ?:addons WHERE addon = ?s", $addon_name);
        db_query("DELETE FROM ?:addon_descriptions WHERE addon = ?s", $addon_name);
        // Delete settings
        $section = Settings::instance()->getSectionByName($addon_name, Settings::ADDON_SECTION);
        if (isset($section['section_id'])) {
            Settings::instance()->removeSection($section['section_id']);
        }
        // Delete language variables
        $addon_scheme->uninstallLanguageValues();
        // Revert database structure
        $addon_scheme->processQueries('uninstall', Registry::get('config.dir.addons') . $addon_name);
        // Remove product tabs
        ProductTabs::instance()->deleteAddonTabs($addon_name);
        fn_uninstall_addon_templates(fn_basename($addon_name));
        if (file_exists(Registry::get('config.dir.addons') . $addon_name . '/layouts.xml')) {
            $xml = simplexml_load_file(Registry::get('config.dir.addons') . $addon_name . '/layouts.xml', '\\Tygh\\ExSimpleXmlElement', LIBXML_NOCDATA);
            foreach ($xml->location as $location) {
                if (fn_allowed_for('ULTIMATE')) {
                    foreach (fn_get_all_companies_ids() as $company) {
                        $layouts = Layout::instance($company)->getList();
                        foreach ($layouts as $layout_id => $layout) {
                            Location::instance($layout_id)->removeByDispatch((string) $location['dispatch']);
                        }
                    }
                } else {
                    $layouts = Layout::instance()->getList();
                    foreach ($layouts as $layout_id => $layout) {
                        Location::instance($layout_id)->removeByDispatch((string) $location['dispatch']);
                    }
                }
            }
        }
        if ($show_message) {
            fn_set_notification('N', __('notice'), __('text_addon_uninstalled', array('[addon]' => $addon_scheme->getName())));
        }
        //Clean Registry
        Registry::del('addons.' . $addon_name);
        $hooks = Registry::get('hooks');
        Registry::del('hooks');
        if (!empty($hooks)) {
            foreach ($hooks as $hook_name => $hooks_data) {
                foreach ($hooks_data as $key => $hook_data) {
                    if ($hook_data['addon'] === $addon_name) {
                        unset($hooks[$hook_name][$key]);
                    }
                }
            }
        }
        Registry::set('hooks', $hooks);
        // Clean cache
        fn_clear_cache();
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 18
0
 public static function copyPresetImages()
 {
     $theme_name = Registry::get('config.base_theme');
     $presets_path = fn_get_theme_path('[themes]/' . $theme_name . '/presets/data', 'C');
     $preset_images_path = fn_get_theme_path('[themes]/' . $theme_name . '/media/images/patterns', 'C');
     $files = fn_get_dir_contents($presets_path, false, true);
     foreach ($files as $file) {
         $content = fn_get_contents($presets_path . '/' . $file);
         if (preg_match('/@general_bg_image\\: url\\(["]?(.*?)["]?\\)/', $content, $m)) {
             $image_name = fn_basename($m[1]);
             if (strpos($image_name, '?') !== false) {
                 list($image_name) = explode('?', $image_name);
             }
             if (file_exists($preset_images_path . '/' . $image_name)) {
                 $preset_dir = str_replace('.less', '', $file);
                 $new_path = $preset_images_path . '/' . $preset_dir;
                 fn_mkdir($new_path);
                 fn_copy($preset_images_path . '/' . $image_name, $new_path);
                 $content = str_replace($image_name, $preset_dir . '/' . $image_name, $content);
                 fn_put_contents($presets_path . '/' . $file, $content);
             }
         }
     }
     return true;
 }
Exemplo n.º 19
0
function fn_theme_editor_set_style($style_id)
{
    $style_id = fn_basename($style_id);
    $theme_name = Registry::get('runtime.layout.theme_name');
    $layout_id = Registry::get('runtime.layout.layout_id');
    Styles::factory($theme_name)->setStyle($layout_id, $style_id);
    Registry::set('runtime.layout.style_id', $style_id);
    fn_clear_cache('assets', 'design/');
    return true;
}
Exemplo n.º 20
0
 if ($mode == 'install_from_po') {
     $uploaded_data = fn_filter_uploaded_data('language_data', array('po', 'zip'));
     if (!empty($uploaded_data['po_file']['path'])) {
         $ext = fn_get_file_ext($uploaded_data['po_file']['name']);
         if ($ext == 'po') {
             $result = Languages::installLanguagePack($uploaded_data['po_file']['path']);
         } else {
             $result = Languages::installZipPack($uploaded_data['po_file']['path']);
         }
         if (!$result) {
             fn_delete_notification('changes_saved');
         }
     }
 }
 if ($mode == 'install' && !empty($_REQUEST['pack'])) {
     $pack_path = Registry::get('config.dir.lang_packs') . fn_basename($_REQUEST['pack']);
     if (Languages::installCrowdinPack($pack_path, array())) {
         return array(CONTROLLER_STATUS_OK, 'languages.manage');
     } else {
         return array(CONTROLLER_STATUS_OK, 'languages.manage?selected_section=available_languages');
     }
 }
 if ($mode == 'delete_variable') {
     LanguageValues::deleteVariables($_REQUEST['name']);
     return array(CONTROLLER_STATUS_REDIRECT);
 }
 if ($mode == 'update_status') {
     if (fn_allowed_for('ULTIMATE:FREE')) {
         if ($_REQUEST['status'] == 'H') {
             fn_set_notification('E', __('error'), __('language_hidden_status_free'));
             return array(CONTROLLER_STATUS_REDIRECT, 'languages.manage');
Exemplo n.º 21
0
 /**
  * Makes DB backup
  *  db_filename - string name of result pack. Will be stored in Registry::get('config.dir.database') . $db_filename;
  *  db_tables - array List of tables to be backuped
  *  db_schema - bool Backup tables schema
  *  db_data - bool Backup data from tables
  * @param array $params
  *
  * @return string Path to backuped DB sql/tgz file
  */
 public static function backupDatabase($params = array())
 {
     $default_params = array('db_tables' => array(), 'db_schema' => false, 'db_data' => false, 'db_compress' => false, 'move_progress' => true);
     $params = array_merge($default_params, $params);
     $db_filename = empty($params['db_filename']) ? 'dump_' . date('mdY') . '.sql' : fn_basename($params['db_filename']);
     if (!fn_mkdir(Registry::get('config.dir.backups'))) {
         fn_set_notification('E', __('error'), __('text_cannot_create_directory', array('[directory]' => fn_get_rel_dir(Registry::get('config.dir.backups')))));
         return false;
     }
     $dump_file = Registry::get('config.dir.backups') . $db_filename;
     if (is_file($dump_file)) {
         if (!is_writable($dump_file)) {
             fn_set_notification('E', __('error'), __('dump_file_not_writable'));
             return false;
         }
     }
     $result = db_export_to_file($dump_file, $params['db_tables'], $params['db_schema'], $params['db_data'], true, true, $params['move_progress']);
     if (!empty($params['db_compress'])) {
         fn_set_progress('echo', __('compress_dump'), false);
         $ext = $params['db_compress'] == 'tgz' ? '.tgz' : '.zip';
         $result = fn_compress_files($db_filename . $ext, $db_filename, dirname($dump_file));
         unlink($dump_file);
         $dump_file .= $ext;
     }
     if ($result) {
         return $dump_file;
     }
     return false;
 }
Exemplo n.º 22
0
    } elseif ($verification_settings['string_type'] == 'letters') {
        $c->SetCharSet(range('A', 'F'));
    } else {
        $c->SetCharSet(fn_array_merge(range('A', 'F'), array(2, 3, 4, 5, 6, 8, 9), false));
    }
    if (!empty($verification_settings['background_image'])) {
        $c->SetBackgroundImages(fn_get_files_dir_path() . $verification_settings['background_image']);
    }
    $c->Create();
    exit;
} elseif ($mode == 'custom_image') {
    if (empty($_REQUEST['image'])) {
        exit;
    }
    $type = empty($_REQUEST['type']) ? 'T' : $_REQUEST['type'];
    $image_path = 'sess_data/' . fn_basename($_REQUEST['image']);
    if (Storage::instance('custom_files')->isExist($image_path)) {
        $real_path = Storage::instance('custom_files')->getAbsolutePath($image_path);
        list(, , $image_type, $tmp_path) = fn_get_image_size($real_path);
        if ($type == 'T') {
            $thumb_path = $image_path . '_thumb';
            if (!Storage::instance('custom_files')->isExist($thumb_path)) {
                // Output a thumbnail image
                list($cont, $format) = fn_resize_image($tmp_path, Registry::get('settings.Thumbnails.product_lists_thumbnail_width'), Registry::get('settings.Thumbnails.product_lists_thumbnail_height'), Registry::get('settings.Thumbnails.thumbnail_background_color'));
                if (!empty($cont)) {
                    Storage::instance('custom_files')->put($thumb_path, array('contents' => $cont));
                }
            }
            $real_path = Storage::instance('custom_files')->getAbsolutePath($thumb_path);
        }
        header('Content-type: ' . $image_type);
Exemplo n.º 23
0
    if (!empty($_REQUEST['on_product_tabs'])) {
        $selected_location['dispatch'] = 'product_tabs';
    }
    $unique_blocks = SchemesManager::filterByLocation(Block::instance()->getAllUnique(DESCR_SL), $selected_location);
    $block_types = SchemesManager::filterByLocation(SchemesManager::getBlockTypes(DESCR_SL), $selected_location);
    if (!empty($_REQUEST['grid_id'])) {
        Tygh::$app['view']->assign('grid_id', $_REQUEST['grid_id']);
    }
    if (!empty($_REQUEST['extra_id'])) {
        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']));
Exemplo n.º 24
0
    RusEximCommerceml::showMessageError("Privileges for user not setted");
    exit;
}
RusEximCommerceml::getCompanyStore($user_data);
$type = $mode = '';
$service_exchange = '';
if (isset($_REQUEST['type'])) {
    $type = $_REQUEST['type'];
}
if (isset($_REQUEST['mode'])) {
    $mode = $_REQUEST['mode'];
}
if (isset($_REQUEST['service_exchange'])) {
    $service_exchange = $_REQUEST['service_exchange'];
}
$filename = !empty($_REQUEST['filename']) ? fn_basename($_REQUEST['filename']) : '';
$lang_code = !empty($s_commerceml['exim_1c_lang']) ? $s_commerceml['exim_1c_lang'] : CART_LANGUAGE;
if ($type == 'catalog') {
    if ($mode == 'checkauth') {
        RusEximCommerceml::exportDataCheckauth();
    } elseif ($mode == 'init') {
        RusEximCommerceml::exportDataInit();
    } elseif ($mode == 'file') {
        if (RusEximCommerceml::createImportFile($filename) === false) {
            fn_echo("failure");
            exit;
        }
        fn_echo("success\n");
    } elseif ($mode == 'import') {
        $fileinfo = pathinfo($filename);
        $xml = RusEximCommerceml::getFileCommerceml($filename);
Exemplo n.º 25
0
}
if ($mode == 'view') {
    fn_disable_translation_mode();
    if (empty($_REQUEST['display'])) {
        die('Access denied');
    }
    $types = array('pdf', 'xls');
    $price_schema = fn_get_schema('price_list', 'schema');
    $selected_fields = Registry::get('addons.price_list.price_list_fields');
    $modes = fn_price_list_get_pdf_layouts();
    // Check the available libs
    foreach ($types as $type) {
        if (!empty($modes[$type])) {
            foreach ($modes[$type] as $f_mode) {
                if ($_REQUEST['display'] == fn_basename($f_mode, '.php')) {
                    include_once Registry::get('config.dir.addons') . '/price_list/templates/' . $type . '/' . $f_mode;
                    $meta_redirect_url = urlencode(fn_url('price_list.view?display=' . fn_basename($f_mode, '.php'), 'C', 'http'));
                    if (!empty($_REQUEST['return_url'])) {
                        $base_url = $_REQUEST['return_url'];
                    } else {
                        $base_url = empty($_SERVER['HTTP_REFERER']) ? fn_url() . '?' : $_SERVER['HTTP_REFERER'];
                        if (strpos('?', $base_url) === false) {
                            $base_url .= '?';
                        }
                    }
                    return array(CONTROLLER_STATUS_REDIRECT, $base_url . '&meta_redirect_url=' . $meta_redirect_url, true);
                }
            }
        }
    }
}
Exemplo n.º 26
0
 if (!empty($product['page_title'])) {
     Registry::get('view')->assign('page_title', $product['page_title']);
 }
 $params = array('product_id' => $_REQUEST['product_id'], 'preview_check' => true);
 list($files) = fn_get_product_files($params);
 if (!empty($files)) {
     Registry::get('view')->assign('files', $files);
 }
 /* [Product tabs] */
 $tabs = ProductTabs::instance()->getList('', $product['product_id'], DESCR_SL);
 foreach ($tabs as $tab_id => $tab) {
     if ($tab['status'] == 'D') {
         continue;
     }
     if (!empty($tab['template'])) {
         $tabs[$tab_id]['html_id'] = fn_basename($tab['template'], ".tpl");
     } else {
         $tabs[$tab_id]['html_id'] = 'product_tab_' . $tab_id;
     }
     if ($tab['show_in_popup'] != "Y") {
         Registry::set('navigation.tabs.' . $tabs[$tab_id]['html_id'], array('title' => $tab['name'], 'js' => true));
     }
 }
 Registry::get('view')->assign('tabs', $tabs);
 /* [/Product tabs] */
 // Set recently viewed products history
 fn_add_product_to_recently_viewed($_REQUEST['product_id']);
 // Increase product popularity
 fn_set_product_popularity($_REQUEST['product_id']);
 $product_notification_enabled = isset($_SESSION['product_notifications']) ? isset($_SESSION['product_notifications']['product_ids']) && in_array($_REQUEST['product_id'], $_SESSION['product_notifications']['product_ids']) ? 'Y' : 'N' : 'N';
 if ($product_notification_enabled) {
Exemplo n.º 27
0
/**
 * Fuctnions parses SQL file and import data from it
 *
 * @param string $file File for import
 * @param integer $buffer Buffer size for fread function
 * @param bool $show_status Show or do not show process by printing ' .'
 * @param integer $show_create_table 0 - Do not print the name of created table, 1 - Print name and get lang_var('create_table'), 2 - Print name without getting lang_var
 * @param bool $check_prefix Check table prefix and replace it with the installed in config.php
 * @param bool $track Use queries cache. Do not execute queries that already are executed.
 * @param bool $skip_errors Skip errors or not
 * @param bool $move_progress_bar Move COMET progress bar or not on show progress
 * @return bool false, if file is not accessible
 */
function db_import_sql_file($file, $buffer = 16384, $show_status = true, $show_create_table = 1, $check_prefix = false, $track = false, $skip_errors = false, $move_progress_bar = true)
{
    if (file_exists($file)) {
        $path = dirname($file);
        $file_name = fn_basename($file);
        $tmp_file = $path . "/{$file_name}.tmp";
        $executed_queries = array();
        if ($track && file_exists($tmp_file)) {
            $executed_queries = unserialize(fn_get_contents($tmp_file));
        }
        if ($skip_errors) {
            $_skip_errors = Registry::get('runtime.database.skip_errors');
            Registry::set('runtime.database.skip_errors', true);
        }
        $fd = fopen($file, 'r');
        if ($fd) {
            $ret = array();
            $rest = '';
            $fs = filesize($file);
            if ($show_status && $move_progress_bar) {
                fn_set_progress('step_scale', ceil($fs / $buffer));
            }
            while (!feof($fd)) {
                $str = $rest . fread($fd, $buffer);
                $rest = fn_parse_queries($ret, $str);
                if ($show_status) {
                    fn_set_progress('echo', '<br />' . __('importing_data'), $move_progress_bar);
                }
                if (!empty($ret)) {
                    foreach ($ret as $query) {
                        if (!in_array($query, $executed_queries)) {
                            if ($show_create_table && preg_match('/CREATE\\s+TABLE\\s+`?(\\w+)`?/i', $query, $matches)) {
                                if ($show_create_table == 1) {
                                    $_text = __('creating_table');
                                } elseif ($show_create_table == 2) {
                                    $_text = 'Creating table';
                                }
                                $table_name = $check_prefix ? fn_check_db_prefix($matches[1], Registry::get('config.table_prefix')) : $matches[1];
                                if ($show_status) {
                                    fn_set_progress('echo', '<br />' . $_text . ': <b>' . $table_name . '</b>', $move_progress_bar);
                                }
                            }
                            if ($check_prefix) {
                                $query = fn_check_db_prefix($query);
                            }
                            Database::query($query);
                            if ($track) {
                                $executed_queries[] = $query;
                                fn_put_contents($tmp_file, serialize($executed_queries));
                            }
                            if ($show_status) {
                                fn_echo(' .');
                            }
                        }
                    }
                    $ret = array();
                }
            }
            fclose($fd);
            return true;
        }
        if ($skip_errors) {
            Registry::set('runtime.database.skip_errors', $_skip_errors);
        }
    }
    return false;
}
Exemplo n.º 28
0
/**
 * Export image (moves to selected directory on filesystem)
 *
 * @param int $image_id ID of the image
 * @param string $object object to export image for (product, category, etc...)
 * @param string $backup_path path to export image
 * @return string path to the exported image
 */
function fn_export_image($image_id, $object, $backup_path = '', $include_alt = true)
{
    if (empty($backup_path)) {
        $backup_path = 'exim/backup/images/' . $object . '/';
    }
    $backup_path = rtrim(fn_normalize_path($backup_path), '/');
    $images_path = fn_get_files_dir_path() . $backup_path;
    // if backup dir does not exist then try to create it
    fn_mkdir($images_path);
    $image_data = db_get_row("SELECT image_id, image_path FROM ?:images WHERE image_id = ?i", $image_id);
    if (empty($image_data)) {
        return '';
    }
    if ($include_alt) {
        $alt_data = db_get_hash_single_array("SELECT lang_code, description FROM ?:common_descriptions WHERE ?:common_descriptions.object_id = ?i AND ?:common_descriptions.object_holder = 'images'", array('lang_code', 'description'), $image_id);
        $alt_text = '#{';
        if (!empty($alt_data)) {
            foreach ($alt_data as $lang_code => $text) {
                $alt_text .= '[' . $lang_code . ']:' . $text . ';';
            }
        }
        $alt_text .= '}';
    }
    $path = $images_path . '/' . fn_basename($image_data['image_path']);
    Storage::instance('images')->export($object . '/' . floor($image_id / MAX_FILES_IN_DIR) . '/' . $image_data['image_path'], $path);
    return $backup_path . '/' . fn_basename($image_data['image_path']) . (!empty($alt_data) && $include_alt ? $alt_text : '');
}
Exemplo n.º 29
0
function fn_clone_image_pairs($target_object_id, $object_id, $object_type, $lang_code = CART_LANGUAGE)
{
    // Get all pairs
    $pair_data = db_get_hash_array("SELECT pair_id, image_id, detailed_id, type FROM ?:images_links WHERE object_id = ?i AND object_type = ?s", 'pair_id', $object_id, $object_type);
    if (empty($pair_data)) {
        return false;
    }
    $icons = $detailed = $pairs_data = array();
    foreach ($pair_data as $pair_id => $p_data) {
        if (!empty($p_data['image_id'])) {
            $icons[$pair_id] = fn_get_image($p_data['image_id'], $object_type, $lang_code, true);
            if (!empty($icons[$pair_id])) {
                $p_data['image_alt'] = empty($icons[$pair_id]['alt']) ? '' : $icons[$pair_id]['alt'];
                $tmp_name = fn_create_temp_file();
                Storage::instance('images')->export($icons[$pair_id]['relative_path'], $tmp_name);
                $name = fn_basename($icons[$pair_id]['image_path']);
                $icons[$pair_id] = array('path' => $tmp_name, 'size' => filesize($tmp_name), 'error' => 0, 'name' => $name);
            }
        }
        if (!empty($p_data['detailed_id'])) {
            $detailed[$pair_id] = fn_get_image($p_data['detailed_id'], 'detailed', $lang_code, true);
            if (!empty($detailed[$pair_id])) {
                $p_data['detailed_alt'] = empty($detailed[$pair_id]['alt']) ? '' : $detailed[$pair_id]['alt'];
                $tmp_name = fn_create_temp_file();
                Storage::instance('images')->export($detailed[$pair_id]['relative_path'], $tmp_name);
                $name = fn_basename($detailed[$pair_id]['image_path']);
                $detailed[$pair_id] = array('path' => $tmp_name, 'size' => filesize($tmp_name), 'error' => 0, 'name' => $name);
            }
        }
        $pairs_data = array($pair_id => array('type' => $p_data['type'], 'image_alt' => !empty($p_data['image_alt']) ? $p_data['image_alt'] : '', 'detailed_alt' => !empty($p_data['detailed_alt']) ? $p_data['detailed_alt'] : ''));
        fn_update_image_pairs($icons, $detailed, $pairs_data, $target_object_id, $object_type, array(), true, $lang_code);
    }
}
Exemplo n.º 30
0
    }
    $cart['recalculate'] = true;
    fn_calculate_cart_content($cart, $auth, 'A', true, 'F', true);
    if (defined('AJAX_REQUEST')) {
        fn_set_notification('N', __('notice'), __('text_product_has_been_deleted'));
    }
    $redirect_mode = empty($_REQUEST['redirect_mode']) ? 'cart' : $_REQUEST['redirect_mode'];
    return array(CONTROLLER_STATUS_REDIRECT, "checkout." . $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']];
        Storage::instance('custom_files')->get($file['path'], $file['name']);
    }
} elseif ($mode == 'ls_get_custom_file') {
    if (!empty($_REQUEST['file'])) {
        $file_path = 'sess_data/' . $_REQUEST['order_id'] . '/' . fn_basename($_REQUEST['file']);
        if (Storage::instance('custom_files')->isExist($file_path)) {
            $filename = !empty($_REQUEST['filename']) ? $_REQUEST['filename'] : '';
            Storage::instance('custom_files')->get($file_path, $filename);
        }
    }
} 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
        $product = $cart['products'][$_REQUEST['cart_id']];
        $option_id = $_REQUEST['option_id'];
        $file_id = $_REQUEST['file'];
        $file = $product['extra']['custom_files'][$option_id][$file_id];
        Storage::instance('custom_files')->delete($file['path']);
        Storage::instance('custom_files')->delete($file['path'] . '_thumb');
        unset($product['extra']['custom_files'][$option_id][$file_id]);