public static function getDirCommerceML() { self::$path_commerceml = fn_get_files_dir_path() . 'exim/1C_' . date('dmY') . '/'; self::$url_commerceml = Registry::get('config.http_location') . '/' . fn_get_rel_dir(self::$path_commerceml); self::$url_images = Storage::instance('images')->getAbsolutePath('from_1c/'); return array(self::$path_commerceml, self::$url_commerceml, self::$url_images); }
public function getFileName() { $parts = explode('\\', get_class($this)); $type = array_pop($parts); $type = strtolower($type); return fn_get_files_dir_path() . 'price_list/price_list_' . CART_LANGUAGE . '.' . $this->price_schema['types'][$type]['extension']; }
function fn_rus_dellin_uninstall() { $service_ids = db_get_fields('SELECT service_id FROM ?:shipping_services WHERE module = ?s', 'dellin'); if (!empty($service_ids)) { db_query('DELETE FROM ?:shipping_services WHERE service_id IN (?a)', $service_ids); db_query('DELETE FROM ?:shipping_service_descriptions WHERE service_id IN (?a)', $service_ids); } db_query('DROP TABLE IF EXISTS ?:rus_dellin_cities'); $file_dir = fn_get_files_dir_path() . "dellin/"; fn_rm($file_dir); }
public function __construct($format = 'csv', $price_id = 0) { $this->format = $format; $this->price_id = $price_id; $this->filename = 'log_tmp_' . $price_id . '.' . $this->format; $this->path = fn_get_files_dir_path() . 'yml/logs/'; fn_mkdir($this->path); $file_is_new = !file_exists($this->path . $this->filename); $this->file = fopen($this->path . $this->filename, 'ab'); if ($file_is_new && $this->format == 'csv') { fwrite($this->file, 'Type; Object ID; Message;' . PHP_EOL); } }
function fn_google_export_add_feed() { $fields = array(array('position' => 0, 'export_field_name' => 'id', 'field' => 'Product id', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'title', 'field' => 'Product name', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'link', 'field' => 'Product URL', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'description', 'field' => 'Google description', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'condition', 'field' => 'Condition', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'price', 'field' => 'Price', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'availability', 'field' => 'Availability', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'image_link', 'field' => 'Image URL', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'gtin', 'field' => 'GTIN', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'brand', 'field' => 'Brand', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'mpn', 'field' => 'MPN', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'google_product_category', 'field' => 'Google product category (US)', 'avail' => 'Y'), array('position' => 0, 'export_field_name' => 'product_type', 'field' => 'Category', 'avail' => 'Y')); $export_options = array('lang_code' => array(DEFAULT_LANGUAGE), 'category_delimiter' => ' > ', 'features_delimiter' => '///', 'price_dec_sign_delimiter' => '.'); $data = array('categories' => '', 'products' => '', 'fields' => serialize($fields), 'export_location' => '', 'export_by_cron' => 'N', 'ftp_url' => '', 'ftp_user' => '', 'ftp_pass' => '', 'file_name' => 'google_base.csv', 'enclosure' => '', 'csv_delimiter' => 'T', 'exclude_disabled_products' => 'N', 'export_options' => serialize($export_options), 'save_dir' => fn_get_files_dir_path(), 'status' => 'A'); $data_feed_id = db_query("INSERT INTO ?:data_feeds ?e", $data); foreach (fn_get_translation_languages() as $language) { db_query("INSERT INTO ?:data_feed_descriptions (datafeed_id, datafeed_name, lang_code) VALUES (?i, 'Google base', ?s);", $data_feed_id, $language['lang_code']); } }
/** * Finds file and return real path to it * * @param string $prefix path to search in * @param string $file Filename, can be URL, absolute or relative path * @return mixed String path to the file or false if file is not found. */ function fn_find_file($prefix, $file) { $file = Bootstrap::stripSlashes($file); // Url if (strpos($file, '://') !== false) { return $file; } $prefix = fn_normalize_path(rtrim($prefix, '/')); $file = fn_normalize_path($file); $files_path = fn_get_files_dir_path(); // Absolute path if (is_file($file) && strpos($file, $files_path) === 0) { return $file; } // Path is relative to files directory if (is_file($files_path . $file)) { return $files_path . $file; } // Path is relative to prefix inside files directory if (is_file($files_path . $prefix . '/' . $file)) { return $files_path . $prefix . '/' . $file; } // Prefix is absolute path if (strpos($prefix, $files_path) === 0 && is_file($prefix . '/' . $file)) { return $prefix . '/' . $file; } return false; }
function fn_data_feeds_export($datafeed_id, $options = array(), $pattern = '') { static $pattern; if (empty($pattern)) { $pattern = fn_get_pattern_definition('products'); } $params['datafeed_id'] = $datafeed_id; $params['single'] = true; $params['available_fields'] = 'Y'; $params = array_merge($params, $options); $datafeed_data = fn_data_feeds_get_data($params, DESCR_SL); if (empty($pattern) || empty($params['datafeed_id'])) { fn_set_notification('E', __('error'), __('error_exim_no_data_exported')); return false; } if ($datafeed_data['exclude_disabled_products'] == 'Y') { $params['status'] = 'A'; } if (empty($datafeed_data['products']) && empty($datafeed_data['categories'])) { $params['cid'] = 0; $params['subcats'] = 'Y'; $params['skip_view'] = 'Y'; $params['extend'] = array('categories'); list($products, $search) = fn_get_products($params); $pids = array_map(create_function('$product', '$pid = $product["product_id"]; return $pid;'), $products); } else { $pids = array(); if (!empty($datafeed_data['products'])) { $pids = explode(',', $datafeed_data['products']); } if (!empty($datafeed_data['categories'])) { $params['cid'] = explode(',', $datafeed_data['categories']); $params['subcats'] = 'Y'; $params['skip_view'] = 'Y'; $params['extend'] = array('categories'); list($products, $search) = fn_get_products($params); $_pids = array_map(create_function('$product', '$pid = $product["product_id"]; return $pid;'), $products); $pids = array_merge($pids, $_pids); unset($_pids); } $pids = array_unique($pids); } if (empty($pids)) { fn_set_notification('E', __('error'), __('error_exim_no_data_exported')); return false; } $pattern['condition']['conditions']['product_id'] = $pids; $fields = array(); if (!empty($datafeed_data['fields'])) { foreach ($datafeed_data['fields'] as $field) { $fields[$field['field']] = $field['export_field_name']; } } $features = db_get_array('SELECT feature_id, description FROM ?:product_features_descriptions WHERE lang_code = ?s', DESCR_SL); $features_fields = array(); if (!empty($features)) { foreach ($features as $feature) { $features_fields[$feature['description']] = array('process_get' => array('fn_data_feeds_get_product_features', '#key', '#field', '#lang_code'), 'linked' => false); } } $pattern['export_fields'] = array_merge($pattern['export_fields'], $features_fields); $options = $datafeed_data['export_options']; $options['delimiter'] = $datafeed_data['csv_delimiter']; $options['filename'] = $datafeed_data['file_name']; $options['fields_names'] = true; $options['force_header'] = true; $pattern['enclosure'] = !empty($datafeed_data['enclosure']) ? $datafeed_data['enclosure'] : ''; if (!empty($fields)) { if (fn_export($pattern, $fields, $options) == true) { $errors = false; $export_location = empty($params['location']) ? $datafeed_data['export_location'] : $params['location']; if ($export_location == 'S') { if (file_exists(fn_get_files_dir_path() . $datafeed_data['file_name']) && is_dir($datafeed_data['save_dir'])) { fn_rename(fn_get_files_dir_path() . $datafeed_data['file_name'], $datafeed_data['save_dir'] . '/' . $datafeed_data['file_name']); } else { $errors = true; fn_set_notification('E', __('error'), __('check_server_export_settings')); } } elseif ($export_location == 'F') { if (empty($datafeed_data['ftp_url'])) { $errors = true; fn_set_notification('E', __('error'), __('ftp_connection_problem')); } else { preg_match("/[^\\/^\\^:]+/", $datafeed_data['ftp_url'], $matches); $host = $matches[0]; preg_match("/.*:([0-9]+)/", $datafeed_data['ftp_url'], $matches); $port = empty($matches[1]) ? 21 : $matches[1]; preg_match("/[^\\/]+(.*)/", $datafeed_data['ftp_url'], $matches); $url = empty($matches[1]) ? '' : $matches[1]; $conn_id = @ftp_connect($host, $port); $result = @ftp_login($conn_id, $datafeed_data['ftp_user'], $datafeed_data['ftp_pass']); if (!empty($url)) { @ftp_chdir($conn_id, $url); } $filename = fn_get_files_dir_path() . $datafeed_data['file_name']; if ($result) { if (@ftp_put($conn_id, $datafeed_data['file_name'], $filename, FTP_ASCII)) { unlink($filename); } else { $errors = true; fn_set_notification('E', __('error'), __('ftp_connection_problem')); } } else { $errors = true; fn_set_notification('E', __('error'), __('ftp_connection_problem')); } @ftp_close($conn_id); } } if (!$errors) { fn_set_notification('N', __('notice'), __('text_exim_data_exported')); return true; } else { unlink(fn_get_files_dir_path() . $datafeed_data['file_name']); return false; } } else { fn_set_notification('E', __('error'), __('error_exim_no_data_exported')); return false; } } else { fn_set_notification('E', __('error'), __('error_exim_fields_not_selected')); return false; } }
$c->SetGridColour($verification_settings['grid_color']); if ($verification_settings['char_shadow'] == 'Y') { $c->DisplayShadow(true); } if ($verification_settings['colour'] == 'Y') { $c->UseColour(true); } if ($verification_settings['string_type'] == 'digits') { $c->SetCharSet(array(2, 3, 4, 5, 6, 8, 9)); } 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)) {
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 . '/'; fn_rm($download_file_dir); fn_mkdir($download_file_dir); $name = $order_id . '.pdf'; $download_file_path = $download_file_dir . $name; if (!fn_is_empty($response)) { fn_put_contents($download_file_path, $response); } }
<?php /*************************************************************************** * * * (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_files_dir_path() . 'google_sitemap/sitemap' . $page . '.xml'; } else { $page = 0; $filename = fn_get_files_dir_path() . 'google_sitemap/sitemap.xml'; } if (file_exists($filename)) { header("Content-Type: text/xml;charset=utf-8"); readfile($filename); exit; } }
public static function writeLog($data, $file = 'sberbank.log') { $path = fn_get_files_dir_path(); fn_mkdir($path); $file = fopen($path . $file, 'a'); if (!empty($file)) { fputs($file, 'TIME: ' . date('Y-m-d H:i:s', TIME) . "\n"); fputs($file, fn_array2code_string($data) . "\n\n"); fclose($file); } }
Registry::get('view')->assign('datafeed_langs', $datafeed_langs); $pattern = fn_get_schema('exim', 'products'); 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; }
function fn_exim_import_file($product_id, $filename, $path, $delete_files = 'N') { $path = fn_get_files_dir_path() . fn_normalize_path($path); // Clean up the directory above if flag is set if ($delete_files == 'Y') { fn_delete_product_file_folders(0, $product_id); fn_delete_product_files(0, $product_id); } // Check if we have several files $files = fn_explode(',', $filename); $folders = array(); // Create folders foreach ($files as $file) { if (strpos($file, '/') !== false) { list($folder) = fn_explode('/', $file); if (!isset($folders[$folder])) { $folder_data = array('product_id' => $product_id, 'folder_name' => $folder); $folders[$folder] = fn_update_product_file_folder($folder_data, 0); } } } // Copy files foreach ($files as $file) { if (strpos($file, '/') !== false) { list($folder_name, $file) = fn_explode('/', $file); } else { $folder_name = ''; } if (strpos($file, '#') !== false) { list($f, $pr) = fn_explode('#', $file); } else { $f = $file; $pr = ''; } $file = fn_find_file($path, $f); if (!empty($file)) { $uploads = array('file_base_file' => array($file), 'type_base_file' => array('server')); if (!empty($pr)) { $preview = fn_find_file($path, $pr); if (!empty($preview)) { $uploads['file_file_preview'] = array($preview); $uploads['type_file_preview'] = array('server'); } } else { $uploads['file_file_preview'] = ""; $uploads['type_file_preview'] = ""; } $_REQUEST = fn_array_merge($_REQUEST, $uploads); // not good to add data to $_REQUEST $file_data = array('product_id' => $product_id); if (!empty($folder_name)) { $file_data['folder_id'] = $folders[$folder_name]; } if (fn_update_product_file($file_data, 0) == false) { return false; } } } return true; }
/** * Gets section root * @param string $type path type: full - full path, rel - relative path from root directory, repo - repository path * @return string path */ function fn_te_get_root($type, $section = 'themes') { if ($section == 'themes') { if (fn_allowed_for('MULTIVENDOR') || Registry::get('runtime.company_id')) { $extra_path = '[theme]/'; } else { $extra_path = ''; } if ($type == 'full') { $path = fn_get_theme_path('[themes]/' . $extra_path, 'C'); } elseif ($type == 'rel') { $path = fn_get_theme_path('/[relative]/' . $extra_path, 'C'); } elseif ($type == 'repo') { $path = fn_get_theme_path('[repo]/' . $extra_path, 'C'); } } elseif ($section == 'files') { if ($type == 'full') { $path = fn_get_files_dir_path(); if (!is_dir($path)) { fn_mkdir($path); } } elseif ($type == 'rel') { $path = '/' . fn_get_rel_dir(fn_get_files_dir_path()); } } elseif ($section == 'images') { if ($type == 'full') { $path = Storage::instance('images')->getAbsolutePath(''); } elseif ($type == 'rel') { $path = '/' . fn_get_rel_dir(Storage::instance('images')->getAbsolutePath('')); } } fn_set_hook('te_get_root', $type, $section, $path); return $path; }
function fn_mailru_write_yml($filename, $mode, &$yml) { $path = fn_get_files_dir_path(); if (!is_dir($path)) { fn_mkdir($path); } $fd = fopen($path . $filename, $mode); if ($fd) { if (!is_array($yml)) { if (Registry::get('addons.rus_tovary_mailru.export_encoding') == 'windows-1251') { $yml = fn_convert_encoding('UTF-8', 'windows-1251', $yml, 'S'); } fwrite($fd, $yml); } else { foreach ($yml as $key => $content) { $content = $content . "\n"; if (Registry::get('addons.rus_tovary_mailru.export_encoding') == 'windows-1251') { $content = fn_convert_encoding('UTF-8', 'windows-1251', $content, 'S'); } fwrite($fd, $content); unset($yml[$key]); } } fclose($fd); @chmod($path . $filename, DEFAULT_FILE_PERMISSIONS); } }
* * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Payments\Processors\YandexMoney\Client; if (defined('PAYMENT_NOTIFICATION')) { if ($mode == 'process' && !empty($_REQUEST['order_id'])) { $order_info = fn_get_order_info($_REQUEST['order_id']); $pp_response = array('order_status' => 'F'); if (!empty($_REQUEST['code']) && fn_check_payment_script('yandex_p2p.php', $_REQUEST['order_id'], $processor_data)) { $client_id = $processor_data['processor_params']['client_id']; $result_url = fn_url("payment_notification.result?payment=yandex_p2p&order_id=" . $order_info['order_id']); $file_log = null; if (!empty($processor_data['processor_params']['logging']) && $processor_data['processor_params']['logging'] == 'Y') { $path = fn_get_files_dir_path(); fn_mkdir($path); $file_log = $path . 'yandex_money_p2p.log'; } $ym = new Client($client_id, $file_log); $receiveTokenResp = $ym->receiveOAuthToken($_REQUEST['code'], $result_url, $processor_data['processor_params']['secret_key']); if ($receiveTokenResp->isSuccess()) { $token = $receiveTokenResp->getAccessToken(); $params = array('to' => $processor_data['processor_params']['payee_id'], 'amount' => $order_info['total'], 'comment' => __("rus_payments.yandex_money_payment_order", array('[order_id]' => $_REQUEST['order_id'])), 'message' => null, 'label' => $_REQUEST['order_id']); if (fn_yandex_money_is_test_mode($processor_data)) { $params['test_payment'] = "true"; $params['test_result'] = $processor_data['processor_params']['test_code']; } $request = $ym->requestPaymentP2P($token, $params); if ($request->isSuccess()) { $requestId = $request->getRequestId();
public function backupYml() { if (file_exists($this->filepath)) { $path = fn_get_files_dir_path() . 'yml/'; $archive_path = $path . 'archives/'; fn_mkdir($archive_path); $archive_name = 'ym_' . date('dmY_His', TIME) . '.tgz'; fn_compress_files($archive_name, $this->filename . '.yml', $path); fn_rename($path . $archive_name, $archive_path . $archive_name); $archives_list = fn_get_dir_contents($archive_path, false, true); if (!empty($archives_list) && count($archives_list) > self::ARCHIVES_LIMIT) { rsort($archives_list); list(, $old_archives) = array_chunk($archives_list, self::ARCHIVES_LIMIT); foreach ($old_archives as $filename) { fn_rm($archive_path . $filename); } } } }
function fn_google_sitemap_check_counter(&$file, &$link_counter, &$file_counter, $links, $header, $footer, $type) { $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_files_dir_path() . 'google_sitemap/sitemap' . $file_counter . '.xml'; $file = fopen($filename, "wb"); $link_counter = count($links); fwrite($file, $header); } else { $link_counter += count($links); fn_set_progress('echo', __($type)); } }
$order_info['text_invoice_payment'] = __("addons.rus_payments.text_invoice_payment", array('[number_account]' => $order_info['order_id'], '[invoice_data]' => $invoice_date)); $view = Tygh::$app['view']; //fn_set_notification('I','view>',print_r($view)); $view->assign('total_print', $total_print); $view->assign('order_info', $order_info); $view->assign('fonts_path', fn_get_theme_path('[relative]/[theme]/media/fonts')); if ($order_info['shipping_cost'] != 0) { $view->assign('shipping_cost', true); } if ($mode == "send_account_payment") { if (!empty($order_info['email'])) { fn_disable_live_editor_mode(); $html = array($view->displayMail('addons/rus_payments/print_invoice_payment.tpl', false, 'C')); Pdf::render($html, fn_get_files_dir_path() . 'account_payment.pdf', 'save'); $data = array('order_info' => $order_info, 'total_print' => $total_print, 'fonts_path' => fn_get_theme_path('[relative]/[theme]/media/fonts')); Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'default_company_orders_department', 'data' => $data, 'attachments' => array(fn_get_files_dir_path() . 'account_payment.pdf'), 'tpl' => 'addons/rus_payments/print_invoice_payment.tpl', 'is_html' => true), 'A'); fn_set_notification('N', __('notice'), __('text_email_sent')); } } else { $view->assign('show_print_button', true); $view->displayMail('addons/rus_payments/print_invoice_payment.tpl', true, 'C'); } exit; } elseif ($mode == 'get_stamp') { Header("Content-Type: image/png"); Header("Content-Type: image/jpg"); Header("Content-Type: image/jpeg"); Header("Content-Type: image/gif"); $path_stamp = fn_get_image_pairs($_REQUEST['payment_id'], 'stamp', 'M', true, true, DESCR_SL); $image = fn_get_contents($path_stamp['icon']['absolute_path']); fn_echo($image);
function fn_yandex_money_log_write($data, $file) { $path = fn_get_files_dir_path(); fn_mkdir($path); $file = fopen($path . $file, 'a'); if (!empty($file)) { fputs($file, 'TIME: ' . date('Y-m-d H:i:s', time()) . "\n"); fputs($file, fn_array2code_string($data) . "\n\n"); fclose($file); } }
use Tygh\Bootstrap; use Tygh\ElFinder\Core; if (!defined('BOOTSTRAP')) { die('Access denied'); } if (Registry::get('config.demo_mode')) { // ElFinder should not work in demo mode $message = json_encode(array('error' => __('error_demo_mode'))); exit($message); } if (AREA == 'C') { if (!Registry::get('runtime.customization_mode.live_editor')) { die('Access denied'); } } $private_files_path = fn_get_files_dir_path(); $public_files_path = fn_get_public_files_path(); fn_mkdir($private_files_path); fn_mkdir($public_files_path); $start_path = ''; if (!empty($_REQUEST['init']) && !empty($_REQUEST['start_path'])) { unset($_GET['target']); $start_path = fn_normalize_path($private_files_path . $_REQUEST['start_path']); if (strpos($start_path, $private_files_path) !== 0) { $start_path = ''; } } $extra_path = str_replace(Storage::instance('images')->getAbsolutePath(''), '', $public_files_path); $opts = array('roots' => array(array('driver' => 'Tygh\\ElFinder\\Volume', 'uploadDeny' => Registry::get('config.forbidden_mime_types'), 'fileMode' => DEFAULT_FILE_PERMISSIONS, 'dirMode' => DEFAULT_DIR_PERMISSIONS, 'uploadMaxSize' => Bootstrap::getIniParam('upload_max_filesize', true), 'alias' => __('private_files'), 'tmbPath' => '', 'path' => $private_files_path, 'startPath' => $start_path, 'mimeDetect' => 'internal', 'archiveMimes' => array('application/zip'), 'icon' => Registry::get('config.current_location') . '/js/lib/elfinder/img/volume_icon_local.png'), array('driver' => 'Tygh\\ElFinder\\Volume', 'uploadDeny' => Registry::get('config.forbidden_mime_types'), 'fileMode' => DEFAULT_FILE_PERMISSIONS, 'dirMode' => DEFAULT_DIR_PERMISSIONS, 'uploadMaxSize' => Bootstrap::getIniParam('upload_max_filesize', true), 'alias' => __('public_files'), 'tmbPath' => '', 'path' => $public_files_path, 'URL' => Storage::instance('images')->getUrl($extra_path), 'mimeDetect' => 'internal', 'archiveMimes' => array('application/zip'), 'icon' => Registry::get('config.current_location') . '/js/lib/elfinder/img/volume_icon_local.png'))); if ($mode == 'images') { unset($opts['roots'][0]);
function fn_rus_exim_1c_get_dir_1c() { $dir_1c = fn_get_files_dir_path() . 'exim/1C_' . date('dmY') . '/'; $dir_1c_url = Registry::get('config.http_location') . '/' . fn_get_rel_dir($dir_1c); $dir_1c_images = Storage::instance('images')->getAbsolutePath('from_1c/'); return array($dir_1c, $dir_1c_url, $dir_1c_images); }
/** * Gets HTTP path user is allowed to put files to * @return string files path */ function fn_get_http_files_dir_path() { $path = fn_get_rel_dir(fn_get_files_dir_path()); $path = Registry::get('config.http_location') . '/' . $path; return $path; }
public function _addDellinCities($url_cities, $post) { $file_dir = fn_get_files_dir_path() . "dellin/"; fn_mkdir($file_dir); @chmod($file_dir, 0777); $file_path = $file_dir . date("Y-m-d", TIME) . '_cities.csv'; if (!file_exists($file_path)) { $response = Http::post($url_cities, json_encode($post), $this->url_params); $result = (array) json_decode($response); file_put_contents($file_path, file_get_contents($result['url'])); if (!empty($result['url'])) { $max_line_size = 65536; // 64 Кб $data_city = array(); $delimiter = ','; $encoding = fn_detect_encoding($result['url'], 'F', CART_LANGUAGE); if (!empty($encoding)) { $result['url'] = fn_convert_encoding($encoding, 'UTF-8', $result['url'], 'F'); } else { fn_set_notification('W', __('warning'), __('text_exim_utf8_file_format')); } $f = false; if ($result['url'] !== false) { $f = fopen($result['url'], 'rb'); } if ($f) { $import_schema = fgetcsv($f, $max_line_size, $delimiter); $schema_size = sizeof($import_schema); $skipped_lines = array(); $line_it = 1; while (($data = fn_fgetcsv($f, $max_line_size, $delimiter)) !== false) { $line_it++; if (fn_is_empty($data)) { continue; } if (sizeof($data) != $schema_size) { $skipped_lines[] = $line_it; continue; } $data = str_replace(array('\\r', '\\n', '\\t', '"'), '', $data); $data_city = array_combine($import_schema, Bootstrap::stripSlashes($data)); if (!empty($data_city)) { $dellin_city = array('number_city' => $data_city['id'], 'code_kladr' => str_replace(' ', '', $data_city['codeKLADR']), 'is_terminal' => $data_city['isTerminal']); $first_pos = strpos($data_city['name'], '('); $end_pos = strpos($data_city['name'], ')') - $first_pos; if (!empty($first_pos)) { $dellin_city['state'] = str_replace(array("(", ")"), "", substr($data_city['name'], $first_pos, $end_pos)); $dellin_city['city'] = str_replace(array('(' . $dellin_city['state'] . ')', '"'), "", $data_city['name']); } else { $dellin_city['state'] = str_replace(array('г.', 'г', 'г. ', 'г '), '', $data_city['name']); $dellin_city['city'] = $data_city['name']; } $dellin_city['city_id'] = db_get_field("SELECT city_id FROM ?:rus_dellin_cities WHERE code_kladr = ?s", $dellin_city['code_kladr']); db_query("REPLACE INTO ?:rus_dellin_cities ?e", $dellin_city); } } } } } }