作者:heg-arc-n
项目:cscar
public function import($db_already_cloned)
{
General::setProgressTitle(__CLASS__);
if (!$db_already_cloned) {
if (!General::cloneImportedDB($this->store_data)) {
return false;
}
} else {
General::setEmptyProgressBar(__('importing_data'));
General::setEmptyProgressBar(__('importing_data'));
}
$main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
General::backupSettings();
if (is_file($main_sql)) {
//Process main sql
if (!db_import_sql_file($main_sql)) {
return false;
}
}
//Find all quick menu linked to the template_editor and change it to file_editor
$quick_menus = db_get_array("SELECT * FROM ?:quick_menu WHERE url LIKE '%template_editor%'");
foreach ($quick_menus as $quick_menu) {
$quick_menu['url'] = str_replace('template_editor', 'file_editor', $quick_menu['url']);
db_query("REPLACE INTO ?:quick_menu ?e", $quick_menu);
}
General::setEmptyProgressBar();
General::setEmptyProgressBar();
General::setEmptyProgressBar();
General::setEmptyProgressBar();
return true;
}
作者:askza
项目:ultimat
function fn_ebay_check_license($silent = false, $skip_messages = false)
{
// addons.ebay.ebay_license_number
$license_number = Registry::get(str_rot13('nqqbaf.ronl.ronl_yvprafr_ahzore'));
$_SESSION['eauth'] = time();
if (empty($license_number)) {
if (!$silent) {
// ebay_empty_license_number
fn_set_notification('E', __('error'), __(str_rot13('ronl_rzcgl_yvprafr_ahzore')));
}
return false;
} else {
// Some HD checking code
$data = Helpdesk::getLicenseInformation($license_number, array('edition' => 'EBAY'));
list($license_status, , $messages) = Helpdesk::parseLicenseInformation($data, array(), false);
if (!empty($messages) && !$skip_messages) {
foreach ($messages as $message) {
fn_set_notification($message['type'], $message['title'], $message['text']);
}
}
if ($license_status == 'ACTIVE') {
return 'A';
} elseif ($license_status == '') {
// Timeout
fn_set_notification('E', __('error'), __('unable_to_check_license'));
return 'T';
} else {
return 'I';
}
}
}
作者:OneataBogda
项目:lead_coriola
/**
* Gets theme patterns
* @param string $style_id style ID
* @return array theme patterns
*/
public static function get($style_id)
{
$style_id = fn_basename($style_id);
$url = Registry::get('config.current_location') . '/' . fn_get_theme_path('[relative]/[theme]/media/images/patterns/' . $style_id . '/');
$patterns = self::getPath($style_id);
return fn_get_dir_contents($patterns, false, true, '', $url);
}
作者:askza
项目:ultimat
public function index($id = 0, $params = array())
{
$lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
if ($this->getParentName() == 'categories') {
$parent_category = $this->getParentData();
$params['cid'] = $parent_category['category_id'];
}
if (!empty($id)) {
$data = fn_get_product_data($id, $this->auth, $lang_code, '', true, true, true, false, false, false, false);
if (empty($data)) {
$status = Response::STATUS_NOT_FOUND;
} else {
$status = Response::STATUS_OK;
}
} else {
$items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_products_per_page'));
$params['extend'][] = 'categories';
list($products, $search) = fn_get_products($params, $items_per_page, $lang_code);
$params['get_options'] = $this->safeGet($params, 'get_options', false);
$params['get_features'] = $this->safeGet($params, 'get_features', true);
$params['get_detailed'] = $this->safeGet($params, 'get_detailed', true);
$params['get_icon'] = $this->safeGet($params, 'get_icon', true);
$params['get_additional'] = $this->safeGet($params, 'get_additional', true);
$params['detailed_params'] = $this->safeGet($params, 'detailed_params', false);
$params['features_display_on'] = 'A';
fn_gather_additional_products_data($products, $params);
$data = array('products' => array_values($products), 'params' => $search);
$status = Response::STATUS_OK;
}
return array('status' => $status, 'data' => $data);
}
作者:ambient-loung
项目:sit
/**
* Gets settings list
*
* @param int $id Settings identifier
* @param array $params Filter params
* @return array
*/
public function index($id = 0, $params = array())
{
$company_id = $this->safeGet($params, 'company_id', null);
$lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
if (!empty($id)) {
$data = CartSettings::instance()->getData($id, $company_id);
if (empty($data)) {
$status = Response::STATUS_NOT_FOUND;
} else {
$status = Response::STATUS_OK;
}
} else {
$section_id = $this->safeGet($params, 'section_id', 0);
$section_tab_id = $this->safeGet($params, 'section_tab_id', 0);
$items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_elements_per_page'));
$page = $this->safeGet($params, 'page', 1);
$data = CartSettings::instance()->getList($section_id, $section_tab_id, true, $company_id, $lang_code);
if ($items_per_page) {
$data = array_slice($data, ($page - 1) * $items_per_page, $items_per_page);
}
$data = array('settings' => $data, 'params' => array('section_id' => $section_id, 'section_tab_id' => $section_tab_id, 'items_per_page' => $items_per_page, 'page' => $page, 'total_items' => count($data)));
$status = Response::STATUS_OK;
}
return array('status' => $status, 'data' => $data);
}
作者:heg-arc-n
项目:cscar
function fn_bestsellers_get_products_pre(&$params, &$items_per_page, &$lang_code)
{
if (!empty($params['bestsellers'])) {
$params['extend'][] = 'categories';
} elseif (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) {
$default_sorting_params = fn_get_default_products_sorting();
if (!empty($params['sort_by']) && $params['sort_by'] == 'bestsellers' || $default_sorting_params['sort_by'] == 'bestsellers' || isset($params['sales_amount_from']) || isset($params['sales_amount_to'])) {
$params['extend'][] = 'categories';
$params['extend'][] = 'sales';
} elseif (!empty($params['sort_by']) && $params['sort_by'] == 'on_sale' || $default_sorting_params['sort_by'] == 'on_sale') {
$params['extend'][] = 'on_sale';
}
}
if (!empty($params['similar'])) {
$product = Registry::get('view')->getTemplateVars('product');
if (!empty($params['main_product_id'])) {
$params['exclude_pid'] = $params['main_product_id'];
}
if (!empty($params['similar_category']) && $params['similar_category'] == 'Y') {
$params['cid'] = $product['main_category'];
if (!empty($params['similar_subcats']) && $params['similar_subcats'] == 'Y') {
$params['subcats'] = 'Y';
}
}
if (!empty($product['price'])) {
if (!empty($params['percent_range'])) {
$range = $product['price'] / 100 * $params['percent_range'];
$params['price_from'] = $product['price'] - $range;
$params['price_to'] = $product['price'] + $range;
}
}
}
}
作者:heg-arc-n
项目:cscar
public function import($db_already_cloned)
{
General::setProgressTitle(__CLASS__);
if (!$db_already_cloned) {
if (!General::cloneImportedDB($this->store_data)) {
return false;
}
} else {
General::setEmptyProgressBar(__('importing_data'));
General::setEmptyProgressBar(__('importing_data'));
}
$main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
General::backupSettings();
if (is_file($main_sql)) {
//Process main sql
if (!db_import_sql_file($main_sql)) {
return false;
}
}
$payflow_enabled = db_get_field("SELECT processor_params FROM ?:payments WHERE processor_id = (SELECT processor_id FROM ?:payment_processors WHERE processor_script = 'payflow_pro.php')");
if (!empty($payflow_enabled)) {
$payflow_params = unserialize($payflow_enabled);
unset($payflow_params['country']);
$payflow_params['currency'] = 840;
db_query("UPDATE ?:payments SET processor_params = ?s WHERE processor_id = (SELECT processor_id FROM ?:payment_processors WHERE processor_script = 'payflow_pro.php')", serialize($payflow_params));
}
General::setEmptyProgressBar();
General::setEmptyProgressBar();
General::setEmptyProgressBar();
General::setEmptyProgressBar();
return true;
}
作者:OneataBogda
项目:lead_coriola
public function import($db_already_cloned)
{
General::setProgressTitle(__CLASS__);
if (!$db_already_cloned) {
if (!General::cloneImportedDB($this->store_data)) {
return false;
}
} else {
General::setEmptyProgressBar(__('importing_data'));
General::setEmptyProgressBar(__('importing_data'));
}
General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
General::processAddons($this->store_data, __CLASS__);
$main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
if (is_file($main_sql)) {
//Process main sql
if (!db_import_sql_file($main_sql)) {
return false;
}
}
General::setEmptyProgressBar(General::getUnavailableLangVar('updating_languages'));
General::updateAltLanguages('language_values', 'name');
General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
General::convertPresets403To411();
General::convertScrollerBlocks();
db_query("UPDATE ?:sales_reports_tables SET type = 'P' WHERE type = 'C'");
General::setEmptyProgressBar();
return true;
}
作者:OneataBogda
项目:lead_coriola
public function import($db_already_cloned)
{
General::setProgressTitle(__CLASS__);
if (!$db_already_cloned) {
if (!General::cloneImportedDB($this->store_data)) {
return false;
}
} else {
General::setEmptyProgressBar(__('importing_data'));
General::setEmptyProgressBar(__('importing_data'));
}
General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
General::processAddons($this->store_data, __CLASS__);
$main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
if (is_file($main_sql)) {
//Process main sql
if (!db_import_sql_file($main_sql)) {
return false;
}
}
// General::restoreSettings();
if (db_get_field("SELECT status FROM ?:addons WHERE addon = 'searchanise'") != 'D') {
db_query("UPDATE ?:addons SET status = 'D' WHERE addon = 'searchanise'");
fn_set_notification('W', __('warning'), General::getUnavailableLangVar('uc_searchanise_disabled'));
}
General::setActualLangValues();
General::updateAltLanguages('language_values', 'name');
General::updateAltLanguages('ult_language_values', array('name', 'company_id'));
General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
General::setEmptyProgressBar();
General::setEmptyProgressBar();
General::setEmptyProgressBar();
General::setEmptyProgressBar();
return true;
}
作者:ambient-loung
项目:sit
public function generate($force = false)
{
$filename = $this->getFileName();
if (!is_dir(dirname($filename))) {
fn_mkdir(dirname($filename));
}
if ($force) {
fn_rm($filename);
}
if (!file_exists($filename)) {
fn_set_progress('echo', __('generating_xls'), false);
$header = $data = array();
$currencies = Registry::get('currencies');
$currency = $currencies[CART_SECONDARY_CURRENCY];
$currency_format = '#' . $currency['thousands_separator'] . '##0.' . str_repeat('0', $currency['decimals']);
$currency_format = $currency['after'] == 'Y' ? $currency_format . $currency['symbol'] : $currency['symbol'] . $currency_format;
foreach ($this->selected_fields as $field_id => $field_value) {
$header[$this->price_schema['fields'][$field_id]['title']] = $field_id == 'price' ? $currency_format : 'string';
}
$this->writer->writeSheetHeader($this->sheet, $header);
$this->render();
$this->writer->writeToFile($filename);
}
return $filename;
}
作者:askza
项目:ultimat
/**
* Gets current company ID
* @param integer $company_id company ID
* @return integer company ID
*/
private static function getCompany($company_id = 0)
{
if (empty($company_id) && Registry::get('runtime.company_id')) {
$company_id = Registry::get('runtime.company_id');
}
return intval($company_id);
}
作者:askza
项目:ultimat
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
function smarty_function_script($params, &$smarty)
{
static $scripts = array();
if (!isset($scripts[$params['src']])) {
if (strpos($params['src'], '//') === false) {
$src = Registry::get('config.current_location') . '/' . fn_link_attach($params['src'], 'ver=' . PRODUCT_VERSION);
} else {
$src = $params['src'];
}
$scripts[$params['src']] = '<script type="text/javascript"' . (!empty($params['class']) ? ' class="' . $params['class'] . '" ' : '') . ' src="' . $src . '" ' . (isset($params['charset']) ? 'charset="' . $params['charset'] . '"' : '') . (isset($params['escape']) ? '><\\/script>' : '></script>');
if (defined('AJAX_REQUEST') || Registry::get('runtime.inside_scripts')) {
return $scripts[$params['src']];
} else {
if (isset($params['no-defer']) && $params['no-defer']) {
return $scripts[$params['src']];
} else {
$cache_name = $smarty->getTemplateVars('block_cache_name');
if (!empty($cache_name)) {
$cached_content = Registry::get($cache_name);
if (!isset($cached_content['javascript'])) {
$cached_content['javascript'] = '';
}
$cached_content['javascript'] .= $scripts[$params['src']];
Registry::set($cache_name, $cached_content, true);
}
$repeat = false;
$smarty->loadPlugin('smarty_block_inline_script');
smarty_block_inline_script(array(), $scripts[$params['src']], $smarty, $repeat);
return '<!-- Inline script moved to the bottom of the page -->';
}
}
}
}
作者:heg-arc-n
项目:cscar
public function import($db_already_cloned)
{
General::setProgressTitle(__CLASS__);
if (!$db_already_cloned) {
if (!General::cloneImportedDB($this->store_data)) {
return false;
}
} else {
General::setEmptyProgressBar(__('importing_data'));
General::setEmptyProgressBar(__('importing_data'));
}
General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
$main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
if (is_file($main_sql)) {
//Process main sql
if (!db_import_sql_file($main_sql)) {
return false;
}
}
General::setEmptyProgressBar();
General::restoreSettings();
db_query("\n DELETE FROM ?:settings_objects\n WHERE name IN (\n 'product_share_discussion',\n 'news_share_discussion',\n 'page_share_discussion',\n 'testimonials_from_all_stores'\n )\n AND section_id IN (\n SELECT section_id FROM ?:settings_sections\n WHERE name = 'discussion'\n )\n ");
General::setEmptyProgressBar(General::getUnavailableLangVar('updating_languages'));
General::updateAltLanguages('language_values', 'name');
General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
General::updateAltLanguages('shipping_service_descriptions', 'service_id');
General::updateAltLanguages('state_descriptions', 'state_id');
General::setEmptyProgressBar();
return true;
}
作者:OneataBogda
项目:lead_coriola
public function index($id = 0, $params = array())
{
$lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
if (!empty($id)) {
$data = fn_get_category_data($id, $lang_code);
if (empty($data)) {
$status = Response::STATUS_NOT_FOUND;
} else {
$status = Response::STATUS_OK;
}
} else {
if (!empty($params['category_ids']) && is_array($params['category_ids'])) {
$params['item_ids'] = $params['category_ids'];
}
$params['plain'] = $this->safeGet($params, 'plain', true);
$params['simple'] = $this->safeGet($params, 'simple', false);
$params['group_by_level'] = $this->safeGet($params, 'group_by_level', false);
$items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_products_per_page'));
$page = $this->safeGet($params, 'page', 1);
list($data, $params) = fn_get_categories($params, $lang_code);
$params['items_per_page'] = $items_per_page;
$params['page'] = $page;
$params['total_items'] = count($data);
if ($items_per_page) {
$data = array_slice($data, ($page - 1) * $items_per_page, $items_per_page);
}
$data = array('categories' => $data, 'params' => $params);
$status = Response::STATUS_OK;
}
return array('status' => $status, 'data' => $data);
}
作者:ambient-loung
项目:sit
public function index($id = 0, $params = array())
{
if (fn_allowed_for('MULTIVENDOR') && $this->auth['user_type'] == 'V' && $this->getParentName() != 'products') {
return array('status' => Response::STATUS_FORBIDDEN);
}
$data = array();
if ($this->getParentName() == 'products') {
$parent_product = $this->getParentData();
$params['object_id'] = $parent_product['product_id'];
$params['object_type'] = 'P';
unset($params['thread_id']);
}
if (!empty($id)) {
$data = $this->getPost($id, $params);
if ($data) {
$status = Response::STATUS_OK;
} else {
$status = Response::STATUS_NOT_FOUND;
}
} else {
$items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_elements_per_page'));
list($discussions, $search) = fn_get_discussions($params, $items_per_page);
$data = array('discussions' => array_values($discussions), 'params' => $search);
$status = Response::STATUS_OK;
}
return array('status' => $status, 'data' => $data);
}
作者:heg-arc-n
项目:cscar
public function create($params)
{
$status = Response::STATUS_BAD_REQUEST;
$data = array();
$valid_params = true;
unset($params['category_id']);
if (empty($params['feature_type'])) {
$data['message'] = __('api_required_field', array('[field]' => 'feature_type'));
$valid_params = false;
}
if (empty($params['description'])) {
$data['message'] = __('api_required_field', array('[field]' => 'description'));
$valid_params = false;
}
if (fn_allowed_for('ULTIMATE')) {
if (empty($params['company_id']) && Registry::get('runtime.company_id') == 0) {
$data['message'] = __('api_need_store');
$valid_params = false;
}
}
if ($valid_params) {
$feature_id = fn_update_product_feature($params, 0);
if ($feature_id) {
$status = Response::STATUS_CREATED;
$data = array('feature_id' => $feature_id);
}
}
return array('status' => $status, 'data' => $data);
}
作者:ambient-loung
项目:sit
/**
* Gets products for printing and print them
* @param array $params product search params
*/
protected function processProducts($params)
{
$total = static::ITEMS_PER_PAGE;
while (static::ITEMS_PER_PAGE * ($params['page'] - 1) <= $total) {
list($products, $search) = fn_get_products($params, static::ITEMS_PER_PAGE);
$total = $search['total_items'];
if ($params['page'] == 1) {
fn_set_progress('parts', $total);
}
$get_images = !empty($this->selected_fields['image']);
$_params = array('get_icon' => $get_images, 'get_detailed' => $get_images, 'get_options' => Registry::get('addons.price_list.include_options') == 'Y' ? true : false, 'get_discounts' => false);
fn_gather_additional_products_data($products, $_params);
$params['page']++;
$this->printProductsBatch(true);
foreach ($products as $product) {
fn_set_progress('echo');
if (Registry::get('addons.price_list.include_options') == 'Y' && $product['has_options']) {
$product = fn_price_list_get_combination($product);
foreach ($product['combinations'] as $c_id => $c_value) {
$product['price'] = $product['combination_prices'][$c_id];
$product['weight'] = $product['combination_weight'][$c_id];
$product['amount'] = $product['combination_amount'][$c_id];
$product['product_code'] = $product['combination_code'][$c_id];
$this->printProductRow($product, $c_value);
}
} else {
$this->printProductRow($product);
}
}
$this->printProductsBatch();
}
}
作者:askza
项目:ultimat
/**
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier<br>
* Name: price<br>
* Purpose: getting formatted price with grouped thousands and
* decimal separators
* Example: {$price|price:"2":".":","}
* -------------------------------------------------------------
*/
function smarty_modifier_format_price($price, $currency, $span_id = '', $class = '', $is_secondary = false, $live_editor_name = '', $live_editor_phrase = '')
{
$value = fn_format_rate_value($price, $number_type, $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
if (!empty($span_id) && $is_secondary) {
$span_id = 'sec_' . $span_id;
}
$span_id = !empty($span_id) ? ' id="' . $span_id . '"' : '';
$class = !empty($class) ? ' class="' . $class . '"' : '';
$live_editor_attrs = '';
if (Registry::get('runtime.customization_mode.live_editor') && !empty($live_editor_name)) {
$live_editor_attrs = ' data-ca-live-editor-obj="' . $live_editor_name . '"';
if (!empty($live_editor_phrase)) {
$live_editor_attrs .= ' data-ca-live-editor-phrase="' . $live_editor_phrase . '"';
}
}
if ($class) {
$currency['symbol'] = '<span' . $class . '>' . $currency['symbol'] . '</span>';
}
$data = array('<span' . $span_id . $class . $live_editor_attrs . '>', $value, '</span>');
if ($currency['after'] == 'Y') {
array_push($data, ' ' . $currency['symbol']);
} else {
array_unshift($data, $currency['symbol']);
}
return implode('', $data);
}
作者:OneataBogda
项目:lead_coriola
public function import($db_already_cloned)
{
General::setProgressTitle(__CLASS__);
if (!$db_already_cloned) {
if (!General::cloneImportedDB($this->store_data)) {
return false;
}
} else {
General::setEmptyProgressBar(__('importing_data'));
General::setEmptyProgressBar(__('importing_data'));
}
General::connectToOriginalDB(array('table_prefix' => General::formatPrefix()));
$main_sql = Registry::get('config.dir.addons') . 'store_import/database/' . $this->main_sql_filename;
if (is_file($main_sql)) {
//Process main sql
if (!db_import_sql_file($main_sql)) {
return false;
}
}
General::addEsStates();
General::restoreSettings();
General::setEmptyProgressBar(General::getUnavailableLangVar('updating_languages'));
General::updateAltLanguages('language_values', 'name');
General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
General::updateAltLanguages('state_descriptions', 'state_id');
General::setEmptyProgressBar();
General::setEmptyProgressBar();
return true;
}
作者:drahosistva
项目:cscart-api-aut
function fn_api_auth_routines($request, $auth)
{
$status = true;
$user_login = !empty($request['user_login']) ? trim($request['user_login']) : '';
$password = !empty($request['password']) ? $request['password'] : '';
$field = 'email';
$condition = '';
if (fn_allowed_for('ULTIMATE')) {
if (Registry::get('settings.Stores.share_users') == 'N' && AREA != 'A') {
$condition = fn_get_company_condition('?:users.company_id');
}
}
$user_data = db_get_row("SELECT * FROM ?:users WHERE {$field} = ?s" . $condition, $user_login);
if (empty($user_data)) {
$user_data = db_get_row("SELECT * FROM ?:users WHERE {$field} = ?s AND user_type IN ('A', 'V', 'P')", $user_login);
}
if (!empty($user_data)) {
$user_data['usergroups'] = fn_get_user_usergroups($user_data['user_id']);
}
if (!empty($user_data['status']) && $user_data['status'] == 'D') {
fn_set_notification('E', __('error'), __('error_account_disabled'));
$status = false;
}
$salt = isset($user_data['salt']) ? $user_data['salt'] : '';
return array($status, $user_data, $user_login, $password, $salt);
}