Example #1
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     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::restoreSettings();
     db_query("\n            DELETE FROM ?:settings_objects\n            WHERE name IN (\n                'product_notify_vendor',\n                'order_notify_vendor',\n                'page_notify_vendor',\n                'company_discussion_type',\n                'company_only_buyers',\n                'company_posts_per_page',\n                'company_post_approval',\n                'company_post_ip_check',\n                'company_notification_email',\n                'company_notify_vendor',\n                'companies_setting',\n                'include_companies',\n                'companies_change',\n                'companies_priority',\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 IN (\n                    'discussion',\n                    'google_sitemap'\n                )\n            )\n        ");
     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');
     db_query('DROP TABLE IF EXISTS ?:se_queue');
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     return true;
 }
Example #2
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     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::getUnavailableLangVar('updating_languages'));
     General::updateAltLanguages('language_values', 'name');
     General::updateAltLanguages('shipping_service_descriptions', 'service_id');
     General::setEmptyProgressBar();
     General::setEmptyProgressBar();
     return true;
 }
Example #3
0
function smarty_helper_inline_scripts($params, $content, &$smarty, &$repeat)
{
    Registry::del('runtime.inside_scripts');
    // Get inline scripts
    $repeat = false;
    $smarty->loadPlugin('smarty_block_inline_script');
    $inline_scripts = "\n\n<!-- Inline scripts -->\n" . smarty_block_inline_script(array('output' => true), '', $smarty, $repeat);
    // FIXME: Backward compatibility. If {scripts} included at the TOP of the page, do not grab inline scripts.
    Registry::set('runtime.inside_scripts', 1);
    return $inline_scripts;
}
 /**
  * @param string $path Path to settings in the 'runtime.twigmo'
  * @return mixed
  */
 public static function get($path = '')
 {
     if ($path) {
         $path = '.' . ltrim($path, '.');
     }
     $path = self::REGISTRY_PATH . $path;
     $value = Registry::get($path);
     if (is_null($value)) {
         // To avoid empty value appearing in the registry we have to delete it
         Registry::del($path);
     }
     return $value;
 }
Example #5
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     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::connectToImportedDB($this->store_data);
     $supplier_settings = $this->getSupplierSettings();
     General::setSupplierSettings($supplier_settings);
     $default_language = db_get_field("SELECT value FROM ?:settings WHERE option_name = 'customer_default_language' AND section_id = 'Appearance'");
     $settings_to_be_saved = array('use_email_as_login', 'admin_default_language', 'customer_default_language', 'disable_shipping', 'fedex_enabled', 'ups_enabled', 'usps_enabled', 'dhl_enabled', 'aup_enabled', 'can_enabled', 'swisspost_enabled', 'seo_product_type', 'seo_category_type', 'single_url', 'seo_language');
     $settings_to_be_saved_values = General::get22xSettings($settings_to_be_saved);
     $addons = General::get22xAddons();
     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::processAddons($this->store_data, __CLASS__, array_keys($addons));
     if (!empty($addons)) {
         General::processAddonsSettings($addons);
     }
     General::enableInstalledAddons($addons);
     General::setEmptyProgressBar();
     $this->_importMenu();
     $this->_copyImages();
     $this->_copyFiles();
     $this->_patchProfileFields();
     $this->_normalizeProductViews();
     $this->_normalizeUserGroupIds();
     $this->_fixLanguagesMissedInImported($default_language);
     General::addStatusColors();
     General::copyProductsBlocks($this->store_data);
     General::restore22xSavedSetting($settings_to_be_saved_values);
     General::setEmptyProgressBar();
     return true;
 }
Example #6
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     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()));
     $default_company = General::getDefaultCompany();
     $supplier_settings = $this->getSupplierSettings();
     General::setSupplierSettings($supplier_settings);
     $enabledSuppliers = General::supplierSettings('enabled') ? true : false;
     $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;
         }
     }
     if ($enabledSuppliers) {
         $this->_importSuppliers();
     }
     General::processAddons($this->store_data, __CLASS__);
     General::setEmptyProgressBar();
     $this->_deleteAllCompanies();
     $default_company_id = (int) General::createDefaultCompany($default_company);
     $this->_fillSharingTable($default_company_id);
     $this->_updateCompanyId($default_company_id);
     $this->_setStorefromUrl($default_company_id, $this->store_data);
     General::setEmptyProgressBar();
     return true;
 }
Example #7
0
 public function import($db_already_cloned)
 {
     Registry::set('runtime.simple_ultimate', true);
     Registry::del('runtime.forced_company_id');
     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::getUnavailableLangVar('updating_languages'));
     General::updateAltLanguages('language_values', 'name');
     General::updateAltLanguages('settings_descriptions', array('object_id', 'object_type'));
     General::updateAltLanguages('state_descriptions', 'state_id');
     General::updateAltLanguages('shipping_service_descriptions', 'service_id');
     General::updateAltLanguages('privilege_descriptions', 'privilege');
     General::updateAltLanguages('privilege_section_descriptions', 'section_id');
     General::updateAltLanguages('country_descriptions', 'code');
     db_query('DROP TABLE IF EXISTS ?:se_queue');
     General::setEmptyProgressBar();
     General::processBlocks();
     if (db_get_field("SHOW TABLES LIKE '?:mailing_lists'")) {
         db_query("ALTER TABLE ?:mailing_lists DROP `show_on_sidebar`");
     }
     General::setEmptyProgressBar();
     return true;
 }
Example #8
0
/**
 * Puts data to storage
 * @param string $key key
 * @param string $data data
 * @return integer data ID
 */
function fn_set_storage_data($key, $data = '')
{
    $data_id = 0;
    if (!empty($data)) {
        $data_id = db_query('REPLACE ?:storage_data (`data_key`, `data`) VALUES(?s, ?s)', $key, $data);
        Registry::set('storage_data.' . $key, $data);
    } else {
        db_query('DELETE FROM ?:storage_data WHERE `data_key` = ?s', $key);
        Registry::del('storage_data.' . $key);
    }
    return $data_id;
}
Example #9
0
 /**
  * Registers block cache
  *
  * @param string $cache_name   Cache name
  * @param array  $block_schema Block schema data
  * @param array  $block_data   Block data from DB
  *
  * @return bool Whether cache have been registered or not
  */
 public static function registerBlockCacheIfNeeded($cache_name, $block_schema, $block_data)
 {
     // @TODO: remove Registry calls and use RenderManager::$_location instead. This method should be non-static.
     $dispatch = Registry::get('runtime.controller') . '.' . Registry::get('runtime.mode');
     // Use parameters for current dispatch with fallback to common params
     if (!empty($block_schema['cache_overrides_by_dispatch'][$dispatch])) {
         $cache_params = $block_schema['cache_overrides_by_dispatch'][$dispatch];
     } elseif (!empty($block_schema['cache'])) {
         $cache_params = $block_schema['cache'];
     } else {
         return false;
     }
     $cookie_data = fn_get_session_data();
     $cookie_data['all'] = $cookie_data;
     $callable_handlers_variables = compact('block_schema', 'block_data');
     $disable_cache = false;
     // Check conditions that disable block caching
     if (!empty($cache_params['disable_cache_when'])) {
         $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'request_handlers', $_REQUEST);
         $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'session_handlers', $_SESSION);
         $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'cookie_handlers', $cookie_data);
         $disable_cache |= self::findHandlerParamsAtData($cache_params['disable_cache_when'], 'auth_handlers', $_SESSION['auth']);
         // Disable cache if any of callable handlers returns true
         if (!empty($cache_params['disable_cache_when']['callable_handlers'])) {
             self::execCallableHandlers(function ($handler_name, $handler_result) use(&$disable_cache) {
                 $disable_cache |= $handler_result;
             }, (array) $cache_params['disable_cache_when']['callable_handlers'], $callable_handlers_variables);
         }
     }
     if ($disable_cache) {
         return false;
     }
     // Generate suffix to cache key using dependencies specified at schema
     $cache_key_suffix = '';
     $generate_additional_level = function ($param_name, $param_value) use(&$cache_key_suffix) {
         $cache_key_suffix .= '|' . $param_name . '=' . md5(serialize($param_value));
     };
     self::findHandlerParamsAtData($cache_params, 'request_handlers', $_REQUEST, $generate_additional_level);
     self::findHandlerParamsAtData($cache_params, 'session_handlers', $_SESSION, $generate_additional_level);
     self::findHandlerParamsAtData($cache_params, 'cookie_handlers', $cookie_data, $generate_additional_level);
     self::findHandlerParamsAtData($cache_params, 'auth_handlers', $_SESSION['auth'], $generate_additional_level);
     if (!empty($cache_params['callable_handlers'])) {
         self::execCallableHandlers($generate_additional_level, (array) $cache_params['callable_handlers'], $callable_handlers_variables);
     }
     $cache_key_suffix .= '|path=' . Registry::get('config.current_path');
     $cache_key_suffix .= Embedded::isEnabled() ? '|embedded' : '';
     $cache_key_suffix = empty($cache_key_suffix) ? '' : md5($cache_key_suffix);
     $default_update_handlers = fn_get_schema('block_manager', 'block_cache_properties');
     if (isset($cache_params['update_handlers']) && is_array($cache_params['update_handlers'])) {
         $handlers = array_merge($cache_params['update_handlers'], $default_update_handlers['update_handlers']);
     } else {
         $handlers = $default_update_handlers['update_handlers'];
     }
     $cache_level = isset($cache_params['cache_level']) ? $cache_params['cache_level'] : Registry::cacheLevel('html_blocks');
     Registry::registerCache($cache_name, $handlers, $cache_level . '__' . $cache_key_suffix);
     // Check conditions that trigger block cache regeneration
     $regenerate_cache = false;
     if (!empty($cache_params['regenerate_cache_when'])) {
         $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'request_handlers', $_REQUEST);
         $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'session_handlers', $_SESSION);
         $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'cookie_handlers', $cookie_data);
         $regenerate_cache |= self::findHandlerParamsAtData($cache_params['regenerate_cache_when'], 'auth_handlers', $_SESSION['auth']);
         // Regenerate cache if any of callable handlers returns true
         if (!empty($cache_params['regenerate_cache_when']['callable_handlers'])) {
             self::execCallableHandlers(function ($handler_name, $handler_result) use(&$regenerate_cache) {
                 $regenerate_cache |= $handler_result;
             }, (array) $cache_params['regenerate_cache_when']['callable_handlers'], $callable_handlers_variables);
         }
     }
     if ($regenerate_cache) {
         Registry::del($cache_name);
     }
     return true;
 }
Example #10
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;
    }
}
Example #11
0
function fn_log_event($type, $action, $data = array())
{
    $object_primary_keys = array('users' => 'user_id', 'orders' => 'order_id', 'products' => 'product_id', 'categories' => 'category_id');
    $update = false;
    $content = array();
    $actions = Registry::get('settings.Logging.log_type_' . $type);
    $cut_log = Registry::ifGet('log_cut', false);
    Registry::del('log_cut');
    $cut_data = Registry::ifGet('log_cut_data', false);
    Registry::del('log_cut_data');
    if (empty($actions) || $action && !empty($actions) && empty($actions[$action]) || !empty($cut_log)) {
        return false;
    }
    if (!empty($_SESSION['auth']['user_id'])) {
        $user_id = $_SESSION['auth']['user_id'];
    } else {
        $user_id = 0;
    }
    if ($type == 'users' && $action == 'logout' && !empty($data['user_id'])) {
        $user_id = $data['user_id'];
    }
    if ($user_id) {
        $udata = db_get_row("SELECT firstname, lastname, email FROM ?:users WHERE user_id = ?i", $user_id);
    }
    $event_type = 'N';
    // notice
    if (!empty($data['backtrace'])) {
        $_btrace = array();
        $func = '';
        foreach (array_reverse($data['backtrace']) as $v) {
            if (!empty($v['file'])) {
                $v['file'] = fn_get_rel_dir($v['file']);
            }
            if (empty($v['file'])) {
                $func = $v['function'];
                continue;
            } elseif (!empty($func)) {
                $v['function'] = $func;
                $func = '';
            }
            $_btrace[] = array('file' => !empty($v['file']) ? $v['file'] : '', 'line' => !empty($v['line']) ? $v['line'] : '', 'function' => $v['function']);
        }
        $data['backtrace'] = serialize($_btrace);
    } else {
        $data['backtrace'] = '';
    }
    if ($type == 'general') {
        if ($action == 'deprecated') {
            $content['deprecated_function'] = $data['function'];
        }
        $content['message'] = $data['message'];
    } elseif ($type == 'orders') {
        $order_status_descr = fn_get_simple_statuses(STATUSES_ORDER, true, true);
        $content = array('order' => '# ' . $data['order_id'], 'id' => $data['order_id']);
        if ($action == 'status') {
            $content['status'] = $order_status_descr[$data['status_from']] . ' -> ' . $order_status_descr[$data['status_to']];
        }
    } elseif ($type == 'products') {
        $product = db_get_field("SELECT product FROM ?:product_descriptions WHERE product_id = ?i AND lang_code = ?s", $data['product_id'], Registry::get('settings.Appearance.backend_default_language'));
        $content = array('product' => $product . ' (#' . $data['product_id'] . ')', 'id' => $data['product_id']);
        if ($action == 'low_stock') {
            // log stock - warning
            $event_type = 'W';
        }
    } elseif ($type == 'categories') {
        $category = db_get_field("SELECT category FROM ?:category_descriptions WHERE category_id = ?i AND lang_code = ?s", $data['category_id'], Registry::get('settings.Appearance.backend_default_language'));
        $content = array('category' => $category . ' (#' . $data['category_id'] . ')', 'id' => $data['category_id']);
    } elseif ($type == 'database') {
        if ($action == 'error') {
            $content = array('error' => $data['error']['message'], 'query' => $data['error']['query']);
            $event_type = 'E';
        }
    } elseif ($type == 'requests') {
        if (!empty($cut_data)) {
            $data['data'] = preg_replace("/\\<(" . implode('|', $cut_data) . ")\\>(.*?)\\<\\/(" . implode('|', $cut_data) . ")\\>/s", '<${1}>******</${1}>', $data['data']);
            $data['data'] = preg_replace("/%3C(" . implode('|', $cut_data) . ")%3E(.*?)%3C%2F(" . implode('|', $cut_data) . ")%3E/s", '%3C${1}%3E******%3C%2F${1}%3E', $data['data']);
            $data['data'] = preg_replace("/(" . implode('|', $cut_data) . ")=(.*?)(&)/s", '${1}=******${3}', $data['data']);
        }
        $content = array('url' => $data['url'], 'request' => fn_strlen($data['data']) < LOG_MAX_DATA_LENGTH && preg_match('//u', $data['data']) ? $data['data'] : '', 'response' => fn_strlen($data['response']) < LOG_MAX_DATA_LENGTH && preg_match('//u', $data['response']) ? $data['response'] : '');
    } elseif ($type == 'users') {
        if (!empty($data['time'])) {
            if (empty($_SESSION['log']['login_log_id'])) {
                return false;
            }
            $content = db_get_field('SELECT content FROM ?:logs WHERE log_id = ?i', $_SESSION['log']['login_log_id']);
            $content = unserialize($content);
            $minutes = ceil($data['time'] / 60);
            $hours = floor($minutes / 60);
            if ($hours) {
                $minutes -= $hours * 60;
            }
            if ($hours || $minutes) {
                $content['loggedin_time'] = ($hours ? $hours . ' |hours| ' : '') . ($minutes ? $minutes . ' |minutes|' : '');
            }
            if (!empty($data['timeout']) && $data['timeout']) {
                $content['timeout'] = true;
            }
            $update = $_SESSION['log']['login_log_id'];
        } else {
            if (!empty($data['user_id'])) {
                $info = db_get_row("SELECT firstname, lastname, email FROM ?:users WHERE user_id = ?i", $data['user_id']);
                $content = array('user' => $info['firstname'] . ($info['firstname'] && $info['lastname'] ? ' ' : '') . $info['lastname'] . ($info['firstname'] || $info['lastname'] ? '; ' : '') . $info['email'] . ' (#' . $data['user_id'] . ')');
                $content['id'] = $data['user_id'];
            } elseif (!empty($data['user'])) {
                $content = array('user' => $data['user']);
            }
            if (in_array($action, array('session', 'failed_login'))) {
                $ip = fn_get_ip();
                $content['ip_address'] = empty($data['ip']) ? $ip['host'] : $data['ip'];
            }
        }
        if ($action == 'failed_login') {
            // failed login - warning
            $event_type = 'W';
        }
    }
    fn_set_hook('save_log', $type, $action, $data, $user_id, $content, $event_type, $object_primary_keys);
    $content = serialize($content);
    if ($update) {
        db_query('UPDATE ?:logs SET content = ?s WHERE log_id = ?i', $content, $update);
    } else {
        if (Registry::get('runtime.company_id')) {
            $company_id = Registry::get('runtime.company_id');
        } elseif (!empty($object_primary_keys[$type]) && !empty($data[$object_primary_keys[$type]])) {
            $company_id = fn_get_company_id($type, $object_primary_keys[$type], $data[$object_primary_keys[$type]]);
        } else {
            $company_id = 0;
        }
        $row = array('user_id' => $user_id, 'timestamp' => TIME, 'type' => $type, 'action' => $action, 'event_type' => $event_type, 'content' => $content, 'backtrace' => $data['backtrace'], 'company_id' => $company_id);
        $log_id = db_query("INSERT INTO ?:logs ?e", $row);
        if ($type == 'users' && $action == 'session') {
            $_SESSION['log']['login_log_id'] = $log_id;
        }
    }
    return true;
}
Example #12
0
 /**
  * Deletes file
  *
  * @param  string  $file file to delete
  * @return boolean true if deleted successfully, false - otherwise
  */
 public function delete($file)
 {
     $file = $this->prefix($file);
     if ($this->s3()->delete_object($this->getOption('bucket'), $file)) {
         $cache_name = 's3_' . $this->getOption('bucket');
         Registry::registerCache($cache_name, array(), Registry::cacheLevel('static'), true);
         Registry::del($cache_name . '.' . md5($file));
         return true;
     }
     return false;
 }
Example #13
0
 public static function quit()
 {
     if (!(defined('DEBUG_MODE') && DEBUG_MODE == true)) {
         fn_set_cookie('debugger', '', 0);
         unset(self::$actives[self::$debugger_cookie]);
         fn_set_storage_data('debugger_active', serialize(self::$actives));
         Registry::del('debugger.data.' . self::$debugger_cookie);
     }
 }
Example #14
0
 /**
  * Sync ebay objects
  * @param int $site_id
  * @param int $category_id
  * @return bool
  */
 public static function synchronizationObjects($site_id, $category_id)
 {
     @set_time_limit(600);
     $start_time = fn_get_storage_data('ebay_synchronization_start_time');
     if (!empty($start_time) && $start_time > strtotime('-10 minutes')) {
         $time = time();
         $current_step = fn_get_storage_data('ebay_synchronization_step');
         $count_steps = fn_get_storage_data('ebay_synchronization_step_count');
         fn_set_progress('title', __('ebay_synchronization_title'));
         fn_set_progress('parts', $count_steps);
         for ($i = 1; $i < $current_step; $i++) {
             fn_set_progress('echo', '.');
         }
         fn_set_progress('echo', fn_get_storage_data('ebay_synchronization_step_title'), false);
         while (true) {
             //TODO move logic to same function fn_get_storage_data
             Registry::del('storage_data.ebay_synchronization_step');
             Registry::del('storage_data.ebay_synchronization_step_title');
             $step = fn_get_storage_data('ebay_synchronization_step');
             if (empty($step)) {
                 return true;
             }
             if ($step != $current_step) {
                 fn_set_progress('echo', '.');
                 fn_set_progress('echo', fn_get_storage_data('ebay_synchronization_step_title'), false);
                 $current_step = $step;
             }
             if ($time < strtotime('-10 minutes')) {
                 return true;
             }
             sleep(1);
         }
         return true;
     }
     $objects = fn_ebay_get_objects_needed_synchronization($site_id, $category_id);
     if (!empty($objects)) {
         $current_step = 1;
         register_shutdown_function(function () {
             fn_set_storage_data('ebay_synchronization_start_time', null);
             fn_set_storage_data('ebay_synchronization_step_title', null);
             fn_set_storage_data('ebay_synchronization_step', null);
             fn_set_storage_data('ebay_synchronization_step_count', null);
         });
         fn_set_storage_data('ebay_synchronization_start_time', time());
         fn_set_storage_data('ebay_synchronization_step_count', count($objects));
         fn_set_storage_data('ebay_synchronization_step', $current_step);
         fn_set_progress('title', __('ebay_synchronization_title'));
         fn_set_progress('parts', count($objects));
         if (in_array('Site', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_regions'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_regions'));
             Site::synchronization();
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
         if (in_array('Category', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_categories'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_categories'));
             Category::synchronization($site_id);
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
         if (in_array('Shipping', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_shipping_services'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_shipping_services'));
             Shipping::synchronization($site_id);
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
         if (in_array('CategoryFeature', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_category_features'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_category_features'));
             CategoryFeature::synchronization($site_id, $category_id);
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
     }
     return true;
 }