Example #1
0
            // Done, cleanup queue
            $q = fn_se_get_next_queue($q['queue_id']);
        } else {
            $next_started_time = TIME - SE_MAX_PROCESSING_TIME + $q['error_count'] * 60;
            db_query("UPDATE ?:se_queue SET status = 'processing', error_count = error_count + 1, started = ?s WHERE queue_id = ?i", $next_started_time, $q['queue_id']);
            break;
            //try later
        }
        fn_echo('.');
    }
    die('OK');
}
if ($mode == 'info') {
    fn_se_check_import_is_done();
    $company_id = fn_se_get_company_id();
    $engines_data = fn_se_get_engines_data($company_id, NULL, true);
    $options = array();
    if (empty($_REQUEST['parent_private_key']) || fn_se_get_parent_private_key($company_id, DEFAULT_LANGUAGE) !== $_REQUEST['parent_private_key']) {
        foreach ($engines_data as $e) {
            $options[$e['company_id']][$e['lang_code']] = $e['api_key'];
        }
    } else {
        if (isset($_REQUEST['product_id'])) {
            $lang_code = DEFAULT_LANGUAGE;
            if (isset($_REQUEST['lang_code'])) {
                $lang_code = $_REQUEST['lang_code'];
            } elseif (isset($_REQUEST['sl'])) {
                $lang_code = $_REQUEST['sl'];
            }
            $options = fn_se_get_products_xml($_REQUEST['product_id'], $company_id, $lang_code, false);
        } elseif (isset($_REQUEST['resync']) && $_REQUEST['resync'] === 'Y') {
Example #2
0
function fn_se_check_import_is_done($company_id = NULL, $lang_code = NULL)
{
    $skip_time_check = false;
    $engines_data = fn_se_get_engines_data($company_id, $lang_code);
    if ($engines_data) {
        foreach ($engines_data as $engine_data) {
            $c_id = $engine_data['company_id'];
            $l_code = $engine_data['lang_code'];
            if ($engine_data['import_status'] == 'sent') {
                if (TIME - fn_se_get_simple_setting('last_request') > 10 || fn_se_get_simple_setting('last_request') - 10 > TIME || $skip_time_check == true) {
                    $response = fn_se_send_request('/api/state/get/json', fn_se_get_private_key($c_id, $l_code), array('status' => '', 'full_import' => ''));
                    $variables = fn_se_parse_state_response($response);
                    if (!empty($variables) && isset($variables['status'])) {
                        if ($variables['status'] == 'normal' && $variables['full_import'] == 'done') {
                            $skip_time_check = true;
                            fn_se_set_import_status('done', $c_id, $l_code);
                        } elseif ($variables['status'] == 'disabled') {
                            fn_se_set_import_status('none', $c_id, $l_code);
                            //disable status check for disabled engine
                        }
                    }
                }
            }
        }
    }
}