// FIXME: Bacward preset compatibility if (!empty($_REQUEST['preset_id'])) { $_REQUEST['style_id'] = $_REQUEST['preset_id']; } Styles::factory(fn_get_theme_path('[theme]', 'C'))->delete($_REQUEST['style_id']); return array(CONTROLLER_STATUS_OK, 'theme_editor.view'); } elseif ($mode == 'get_css') { // FIXME: Backward presets compatibility if (!empty($_REQUEST['preset'])) { $_REQUEST['style'] = $_REQUEST['preset']; } $css_filename = !empty($_REQUEST['css_filename']) ? fn_basename($_REQUEST['css_filename']) : ''; $theme_name = fn_get_theme_path('[theme]', 'C'); $content = ''; if (!empty($css_filename)) { $content = fn_get_contents(fn_get_cache_path(false) . 'theme_editor/' . $css_filename); if (strpos($content, '#LESS') !== false) { list($css_content, $less_content) = explode('#LESS#', $content); $css_content = Less::parseUrls($css_content, Registry::get('config.dir.root'), fn_get_theme_path('[themes]/[theme]/media')); } else { $less_content = $content; $css_content = ''; } $data = array(); // FIXME: Bacward preset compatibility if (!empty($_REQUEST['preset_id'])) { $_REQUEST['style_id'] = $_REQUEST['preset_id']; } // If theme ID passed, set default theme if (!empty($_REQUEST['style_id'])) { fn_theme_editor_set_style($_REQUEST['style_id']);
public function getFileName() { $path = sprintf('%syandex_market/%s_yandex_market.yml', fn_get_cache_path(false, 'C', $this->company_id), $this->company_id); return $path; }
function fn_google_sitemap_check_counter(&$file, &$link_counter, &$file_counter, $links, $header, $footer) { $stat = fstat($file); if (count($links) + $link_counter > MAX_URLS_IN_MAP || $stat['size'] >= MAX_SIZE_IN_KBYTES * 1024) { fwrite($file, $footer); fclose($file); $file_counter++; $filename = fn_get_cache_path(false) . 'google_sitemap/sitemap' . $file_counter . '.xml'; $file = fopen($filename, "wb"); $link_counter = count($links); fwrite($file, $header); } else { $link_counter += count($links); } }
/** * Installs new language from ZIP pack * * @param string $path Path to ZIP file * @param array $params * reinstall: Skip adding new language * validate_lang_code:Check meta information (lang_code) with updated language data (lang_code) and forbid to update if does not match * force_lang_code: Skip meta lang code and use this one in all laguage variables * @return int Language ID */ public static function installZipPack($path, $params = array()) { $result = false; // Extract language pack and check the permissions $extract_path = fn_get_cache_path(false) . 'tmp/language_pack/'; // Re-create source folder fn_rm($extract_path); fn_mkdir($extract_path); fn_copy($path, $extract_path . 'pack.zip'); if (fn_decompress_files($extract_path . 'pack.zip', $extract_path)) { fn_rm($extract_path . 'pack.zip'); $result = self::installCrowdinPack($extract_path, $params); } else { fn_set_notification('E', __('error'), __('broken_po_pack')); } return $result; }
/** * Merges css and less files * * @param array $files Array with style files * @param string $styles Style code * @param string $prepend_prefix Prepend prefix * @param array $params additional params */ function fn_merge_styles($files, $styles = '', $prepend_prefix = '', $params = array(), $area = AREA) { $prefix = !empty($prepend_prefix) ? 'embedded' : 'standalone'; $make_rtl = false; if (fn_is_rtl_language()) { $prefix .= '-rtl'; $make_rtl = true; } $output = ''; $less_output = ''; $less_reflection = array(); $compiled_less = ''; $compiled_css = ''; $relative_path = fn_get_theme_path('[relative]/[theme]/css', $area); $hashes = array(); $names = array_map(function ($v) { return !empty($v['relative']) ? $v['relative'] : false; }, $files); // Check file changes if (Development::isEnabled('compile_check') || Debugger::isActive()) { $dir_root = Registry::get('config.dir.root'); foreach ($names as $index => $name) { if (file_exists($dir_root . '/' . $name)) { $hashes[] = $name . filemtime($dir_root . '/' . $name); } } } $hashes[] = md5(implode('|', $names)); $hashes[] = md5($styles); if ($area == 'C') { $hashes[] = Registry::get('runtime.layout.layout_id'); $hashes[] = Registry::get('runtime.layout.style_id'); } arsort($hashes); $hash = md5(implode(',', $hashes) . PRODUCT_VERSION) . fn_get_storage_data('cache_id'); $filename = $prefix . '.' . $hash . '.css'; $theme_manifest = Themes::factory(fn_get_theme_path('[theme]', 'C'))->getManifest(); if (!Storage::instance('assets')->isExist($relative_path . '/' . $filename)) { Debugger::checkpoint('Before styles compilation'); foreach ($files as $src) { $m_prefix = ''; $m_suffix = ''; if (!empty($src['media'])) { $m_prefix = "\n@media " . $src['media'] . " {\n"; $m_suffix = "\n}\n"; } if (strpos($src['file'], '.css') !== false) { $output .= "\n" . $m_prefix . fn_get_contents($src['file']) . $m_suffix; } elseif ($area != 'C' || empty($theme_manifest['converted_to_css'])) { $less_output_chunk = ''; if (file_exists($src['file'])) { if ($area == 'C' && (empty($theme_manifest['parent_theme']) || $theme_manifest['parent_theme'] == 'basic')) { $less_output_chunk = "\n" . $m_prefix . fn_get_contents($src['file']) . $m_suffix; } else { $less_output_chunk = "\n" . $m_prefix . '@import "' . str_replace($relative_path . '/', '', $src['relative']) . '";' . $m_suffix; } } if (!empty($params['reflect_less'])) { if (preg_match('{/addons/([^/]+)/}is', $src['relative'], $m)) { $less_reflection['output']['addons'][$m[1]] .= $less_output_chunk; } else { $less_reflection['output']['main'] .= $less_output_chunk; } } $less_output .= $less_output_chunk; } } $header = str_replace('[files]', implode("\n", $names), Registry::get('config.js_css_cache_msg')); if (!empty($styles)) { $less_output .= $styles; } // Prepend all styles with prefix if (!empty($prepend_prefix)) { $less_output = $output . "\n" . $less_output; $output = ''; } if (!empty($output)) { $compiled_css = Less::parseUrls($output, Storage::instance('assets')->getAbsolutePath($relative_path), fn_get_theme_path('[themes]/[theme]/media', $area)); } if (!empty($theme_manifest['converted_to_css']) && $area == 'C') { $theme_css_path = fn_get_theme_path('[themes]/[theme]', $area) . '/css'; $pcl_filepath = $theme_css_path . '/' . Themes::$compiled_less_filename; if (file_exists($pcl_filepath)) { $compiled_css .= fn_get_contents($pcl_filepath); } list($installed_addons) = fn_get_addons(array('type' => 'active')); foreach ($installed_addons as $addon) { $addon_pcl_filpath = $theme_css_path . "/addons/{$addon['addon']}/" . Themes::$compiled_less_filename; if (file_exists($pcl_filepath)) { $compiled_css .= fn_get_contents($addon_pcl_filpath); } } } if (!empty($less_output)) { $less = new Less(); if (!empty($params['compressed'])) { $less->setFormatter('compressed'); } $less->setImportDir($relative_path); try { $compiled_less = $less->customCompile($less_output, Storage::instance('assets')->getAbsolutePath($relative_path), array(), $prepend_prefix, $area); } catch (Exception $e) { $skip_save = true; $shift = 4; $message = '<div style="border: 2px solid red; padding: 5px;">LESS ' . $e->getMessage(); if (preg_match("/line: (\\d+)/", $message, $m)) { $lo = explode("\n", $less_output); $message .= '<br /><br /><pre>' . implode("\n", array_splice($lo, intval($m[1]) - $shift, $shift * 2)) . '</pre>'; } $message .= '</div>'; fn_set_notification('E', __('error'), $message); } } if (empty($skip_save)) { $compiled_content = $compiled_css . "\n" . $compiled_less; // Move all @import links to the Top of the file. if (preg_match_all('/@import url.*?;/', $compiled_content, $imports)) { $compiled_content = preg_replace('/@import url.*?;/', '', $compiled_content); foreach ($imports[0] as $import_link) { $compiled_content = $import_link . "\n" . $compiled_content; } } if ($make_rtl) { $compiled_content = \CSSJanus::transform($compiled_content); $compiled_content = "body {\ndirection: rtl;\n}\n" . $compiled_content; } Storage::instance('assets')->put($relative_path . '/' . $filename, array('contents' => $header . $compiled_content, 'compress' => false, 'caching' => true)); if (!empty($params['use_scheme'])) { fn_put_contents(fn_get_cache_path(false) . 'theme_editor/' . $filename, $output . '#LESS#' . $less_output); } if (!empty($params['reflect_less'])) { $less_reflection['import_dirs'] = array($relative_path); fn_put_contents(fn_get_cache_path(false) . 'less_reflection.json', json_encode($less_reflection)); } } Debugger::checkpoint('After styles compilation'); } $url = Storage::instance('assets')->getUrl($relative_path . '/' . $filename); return $url; }
/** * Used to sanitize user-inputed HTML from any XSS code. * Use this function when you want to use HTML-code inputed by users safely. * * @param string $raw_html Input HTML code * * @return string Sanitized HTML ready to be safely displayed on page. */ public static function sanitizeHtml($raw_html) { try { $cache_dir = fn_get_cache_path(false) . 'html_purifier/'; if (!is_dir($cache_dir)) { fn_mkdir($cache_dir); } $config_instance = \HTMLPurifier_Config::createDefault(); $config_instance->set('HTML.DefinitionID', PRODUCT_NAME . '_' . PRODUCT_VERSION); $config_instance->set('HTML.DefinitionRev', 1); $config_instance->set('Cache.SerializerPath', $cache_dir); $config_instance->set('Cache.SerializerPermissions', DEFAULT_DIR_PERMISSIONS); $config_instance->autoFinalize = false; /** * Allows to configure HTMLPurifier before it purifies given HTML. * * @param \HTMLPurifier_Config $config_instance Instance of HTMLPurifier_Config * @param string $raw_html HTML to be purified */ fn_set_hook('sanitize_html', $config_instance, $raw_html); /** @var \HTMLPurifier_HTMLDefinition $html_definition */ if ($html_definition = $config_instance->maybeGetRawHTMLDefinition()) { $html_definition->addAttribute('a', 'target', new \HTMLPurifier_AttrDef_Enum(array('_blank', '_self', '_target', '_top'))); } $purifier_instance = \HTMLPurifier::instance($config_instance); $html_purify = $purifier_instance->purify($raw_html); return html_entity_decode($html_purify, ENT_QUOTES, 'UTF-8'); } catch (\Exception $e) { throw new DeveloperException($e->getMessage()); } }
define('FIELDS_HEADER_FONT_SIZE', 11); define('FIELDS_ODD_BG_COLOR', '#EEEEEE'); define('IMAGE_HEIGHT', 50); define('CATEGORY_HEADER_FONT_SIZE', 12); define('CATEGORY_HEADER_FONT_COLOR', '#FFFFFF'); define('CATEGORY_HEADER_BG_COLOR', '#888888'); define('TABLE_CELLPADDING', 4); define('TABLE_CELLSPACING', 0); // Min column width in percent $min_width = array('product' => 50, 'product_code' => 13, 'image' => 10); error_reporting(E_ERROR); ini_set('display_errors', '1'); set_time_limit(0); fn_price_list_timer(); // Start timer; $filename = fn_get_cache_path() . 'price_list/price_list_' . CART_LANGUAGE . '.pdf'; // Must be unique for each pdf mode. if (Storage::instance('assets')->isExist($filename)) { Storage::instance('assets')->get($filename); exit; } else { include_once Registry::get('config.dir.addons') . '/price_list/core/class.counter.php'; $counter = new Counter(100, '.'); $selected_fields = Registry::get('addons.price_list.price_list_fields'); $max_perc = 100; $field_count = count($selected_fields); // First step. Check for the min width. $perc = intval($max_perc / $field_count); foreach ($selected_fields as $field_name => $active) { if (isset($min_width[$field_name])) { if ($min_width[$field_name] > $perc) {
} else { fn_copy($extract_path, $destination); fn_rm($extract_path); if (defined('AJAX_REQUEST')) { Tygh::$app['ajax']->assign('force_redirection', fn_url('themes.manage')); exit; } } } } if (defined('AJAX_REQUEST')) { Tygh::$app['view']->display('views/themes/components/upload_theme.tpl'); exit; } } elseif ($mode == 'recheck') { $source = fn_get_cache_path(false) . 'tmp/theme_pack/'; $destination = Registry::get('config.dir.themes_repository'); if ($action == 'ftp_upload') { $ftp_access = array('hostname' => $_REQUEST['ftp_access']['ftp_hostname'], 'username' => $_REQUEST['ftp_access']['ftp_username'], 'password' => $_REQUEST['ftp_access']['ftp_password'], 'directory' => $_REQUEST['ftp_access']['ftp_directory']); $ftp_copy_result = fn_copy_by_ftp($source, $destination, $ftp_access); if ($ftp_copy_result !== true) { fn_set_notification('E', __('error'), $ftp_copy_result); } if (defined('AJAX_REQUEST')) { Tygh::$app['ajax']->assign('force_redirection', fn_url('themes.manage')); exit; } else { return array(CONTROLLER_STATUS_OK, 'themes.manage'); } } $non_writable_folders = fn_check_copy_ability($source, $destination);
/** * Unpacks and checks the uploaded upgrade pack * * @param string $path Path to the zip/tgz archive with the upgrade * @return true if upgrade pack is ready to use, false otherwise */ public function uploadUpgradePack($pack_info) { // Extract the add-on pack and check the permissions $extract_path = fn_get_cache_path(false) . 'tmp/upgrade_pack/'; $destination = $this->getPackagesDir(); // Re-create source folder fn_rm($extract_path); fn_mkdir($extract_path); fn_copy($pack_info['path'], $extract_path . $pack_info['name']); if (fn_decompress_files($extract_path . $pack_info['name'], $extract_path)) { if (file_exists($extract_path . 'schema.json')) { $schema = json_decode(fn_get_contents($extract_path . 'schema.json'), true); if ($this->validateSchema($schema)) { $package_id = preg_replace('/\\.(zip|tgz|gz)$/i', '', $pack_info['name']); $this->deletePackage($package_id); fn_mkdir($destination . $package_id); fn_copy($extract_path, $destination . $package_id); list($result, $message) = $this->checkPackagePermissions($package_id); if ($result) { $this->setNotification('N', __('notice'), __('uc_downloaded_and_ready')); } else { $this->setNotification('E', __('error'), $message); $this->deletePackage($package_id); } } else { $this->setNotification('E', __('error'), __('uc_broken_upgrade_connector', array('[connector_id]' => $pack_info['name']))); } } else { $this->setNotification('E', __('error'), __('uc_unable_to_read_schema')); } } // Clear obsolete unpacked data fn_rm($extract_path); return false; }
function writeexcel_worksheet($name, $index, &$activesheet, &$firstsheet, &$url_format, &$parser, $tempdir) { $this->writeexcel_biffwriter(); $rowmax = 65536; // 16384 in Excel 5 $colmax = 256; $strmax = 255; $this->_name = $name; $this->_index = $index; $this->_activesheet =& $activesheet; $this->_firstsheet =& $firstsheet; $this->_url_format =& $url_format; $this->_parser =& $parser; $this->_tempdir = fn_get_cache_path(false) . 'xls/'; $this->_ext_sheets = array(); $this->_using_tmpfile = 1; $this->_tmpfilename = false; $this->_filehandle = false; $this->_fileclosed = 0; $this->_offset = 0; $this->_xls_rowmax = $rowmax; $this->_xls_colmax = $colmax; $this->_xls_strmax = $strmax; $this->_dim_rowmin = $rowmax + 1; $this->_dim_rowmax = 0; $this->_dim_colmin = $colmax + 1; $this->_dim_colmax = 0; $this->_colinfo = array(); $this->_selection = array(0, 0); $this->_panes = array(); $this->_active_pane = 3; $this->_frozen = 0; $this->_selected = 0; $this->_paper_size = 0x0; $this->_orientation = 0x1; $this->_header = ''; $this->_footer = ''; $this->_hcenter = 0; $this->_vcenter = 0; $this->_margin_head = 0.5; $this->_margin_foot = 0.5; $this->_margin_left = 0.75; $this->_margin_right = 0.75; $this->_margin_top = 1.0; $this->_margin_bottom = 1.0; $this->_title_rowmin = false; $this->_title_rowmax = false; $this->_title_colmin = false; $this->_title_colmax = false; $this->_print_rowmin = false; $this->_print_rowmax = false; $this->_print_colmin = false; $this->_print_colmax = false; $this->_print_gridlines = 1; $this->_screen_gridlines = 1; $this->_print_headers = 0; $this->_fit_page = 0; $this->_fit_width = 0; $this->_fit_height = 0; $this->_hbreaks = array(); $this->_vbreaks = array(); $this->_protect = 0; $this->_password = false; $this->_col_sizes = array(); $this->_row_sizes = array(); $this->_col_formats = array(); $this->_row_formats = array(); $this->_zoom = 100; $this->_print_scale = 100; $this->_initialize(); }
public function getCacheFileName() { $this->options['price_id'] = isset($this->options['price_id']) ? $this->options['price_id'] : ''; $path = sprintf('%syml/%s_' . $this->filename . '_' . $this->options['price_id'] . '.yml', fn_get_cache_path(false, 'C', $this->company_id), $this->company_id); return $path; }
/** * Get LESS reflection (information necessary to precompile LESS): LESS import dirs and structured output * * @return array LESS reflection */ protected function getLessReflection() { if (empty($this->less_reflection)) { $this->fetchFrontendStyles(array('reflect_less' => true)); $this->less_reflection = json_decode(fn_get_contents(fn_get_cache_path(false) . 'less_reflection.json'), true); } return $this->less_reflection; }
if (defined('AJAX_REQUEST')) { Tygh::$app['ajax']->assign('force_redirection', fn_url('addons.manage')); exit; } } } elseif ($mode == 'upload') { if (defined('RESTRICTED_ADMIN') || Registry::get('runtime.company_id')) { fn_set_notification('E', __('error'), __('access_denied')); return array(CONTROLLER_STATUS_REDIRECT, 'addons.manage'); } $addon_pack = fn_filter_uploaded_data('addon_pack', Registry::get('config.allowed_pack_exts')); if (empty($addon_pack[0])) { fn_set_notification('E', __('error'), __('text_allowed_to_upload_file_extension', array('[ext]' => implode(',', Registry::get('config.allowed_pack_exts'))))); } else { // Extract the add-on pack and check the permissions $extract_path = fn_get_cache_path(false) . 'tmp/addon_pack/'; $addon_pack = $addon_pack[0]; // Re-create source folder fn_rm($extract_path); fn_mkdir($extract_path); fn_copy($addon_pack['path'], $extract_path . $addon_pack['name']); if (fn_decompress_files($extract_path . $addon_pack['name'], $extract_path)) { fn_rm($extract_path . $addon_pack['name']); $struct = fn_get_dir_contents($extract_path, false, true, '', '', true); $addon_name = ''; $relative_addon_path = str_replace(Registry::get('config.dir.root') . '/', '', Registry::get('config.dir.addons')); foreach ($struct as $file) { if (preg_match('#' . $relative_addon_path . '[^a-zA-Z0-9_]*([a-zA-Z0-9_-]+).+?addon.xml$#i', $file, $matches)) { if (!empty($matches[1])) { $addon_name = $matches[1]; }
/** * Create temporary file * * @return temporary file */ function fn_create_temp_file() { $prefix = fn_get_cache_path(false); fn_mkdir($prefix . 'tmp'); $tmpnam = fn_normalize_path(tempnam($prefix . 'tmp/', 'tmp_')); return $tmpnam; }
* * * (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. * ****************************************************************************/ if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($mode == 'view') { if (!empty($_REQUEST['page'])) { $page = intval($_REQUEST['page']); $filename = fn_get_cache_path(false) . 'google_sitemap/sitemap' . $page . '.xml'; } else { $page = 0; $filename = fn_get_cache_path(false) . 'google_sitemap/sitemap.xml'; } if (file_exists($filename)) { header("Content-Type: text/xml;charset=utf-8"); readfile($filename); exit; } else { set_time_limit(3600); fn_google_sitemap_get_content($page); } }