Exemple #1
0
/**
 * Building cache and installing database
 *
 * @param array   $params
 * @param boolean $silentMode Silent mode
 *
 * @return bool
 */
function module_install_cache(&$params, $silentMode = false)
{
    global $error;
    $result = false;
    if (!empty($params['new_installation']) && 'Y' == $params['demo']) {
        $dump_file = LC_DIR_ROOT . 'dump.sql';
        if (file_exists($dump_file) && is_readable($dump_file)) {
            echo xtr('Uploading dump.sql into database...');
            $sql = file_get_contents($dump_file);
            $sql = str_replace('`xlite_', '`' . $params['mysqlprefix'], $sql);
            $randPrefix = rand(0, 99);
            $sql = str_replace('`FK_', '`FK_' . $randPrefix, $sql);
            $sql = str_replace('`IDX_', '`IDX_' . $randPrefix, $sql);
            // Drop existing X-Cart tables
            if (doDropDatabaseTables($params)) {
                // Load SQL dump to the database
                $pdoErrorMsg = '';
                dbExecute($sql, $pdoErrorMsg);
                if (empty($pdoErrorMsg)) {
                    $result = true;
                }
            }
            @unlink($dump_file);
            if ($result) {
                echo '<span class="status-ok">OK</span>';
                echo '<br /><p>' . xtr('Redirecting to the next step...') . '</p>';
                ?>

<script type="text/javascript">

function isProcessComplete() {

    if (document.getElementById('next-button')) {
        setNextButtonDisabled(false, true);
        setNextButtonDisabled(true);
        document.getElementById('back-button').disabled = 'disabled';

    } else {
        setTimeout('isProcessComplete()', 1000);
    }
}

window.onload = function () {
    setNextButtonDisabled(true);
}

setTimeout('isProcessComplete()', 1000);

</script>

<?php 
            }
        }
    }
    if (!$result) {
        $result = doPrepareFixtures($params, $silentMode);
        if ($result) {
            doRemoveCache(null);
            ?>

<div id="cache-rebuild-failed" class="cache-error" style="display: none;"><span><?php 
            echo xtr('Oops! Cache rebuild failed.');
            ?>
</span> <?php 
            echo xtr('Check for possible reasons <a href="http://kb.x-cart.com/pages/viewpage.action?pageId=7504578">here</a>.');
            ?>
</div>

<iframe id="process_iframe" style="padding-top: 15px;" src="admin.php?doNotRedirectAfterCacheIsBuilt&<?php 
            echo time();
            ?>
" width="100%" height="300" frameborder="0" marginheight="10" marginwidth="10"></iframe>

<br />
<br />
<br />

<?php 
            echo xtr('Building cache notice');
            ?>

<script type="text/javascript">

    var errCount = 0;
    var isStopped = false;

    function isProcessComplete() {

        var iframe = document.getElementById('process_iframe').contentWindow.document;

        if (iframe.getElementById('finish')) {
            resetCacheWindowContent();

        } else {

            if (iframe.readyState == 'complete') {

                if (errCount > 60) {
                    var pattern = /^.*Deploying store \[step (\d+) of (\d+)\].*$/m;
                    var matches = iframe.body.innerHTML.match(pattern);

                    processCacheRebuildFailure(matches);
                    isStopped = true;

                } else {
                    errCount = errCount + 1;
                }

            } else {
                errCount = 0;
            }

            setTimeout('isProcessComplete()', 1000);
        }
    }

    setTimeout('isProcessComplete()', 1000);

</script>

<?php 
        } else {
            fatal_error(xtr('Error has encountered while creating fixtures or modules list.'), 'file', 'fixtures');
        }
        $error = true;
    }
    return false;
}
Exemple #2
0
/**
 * Building cache and installing database
 *
 * @param array $params
 *
 * @return bool
 */
function module_install_cache(&$params)
{
    global $error;
    $result = doPrepareFixtures($params);
    if ($result) {
        doRemoveCache(null);
        ?>

<iframe id="process_iframe" style="padding-top: 15px;" src="cart.php?doNotRedirectAfterCacheIsBuilt&<?php 
        echo time();
        ?>
" width="100%" height="300" frameborder="0" marginheight="10" marginwidth="10"></iframe>

<br />
<br />
<br />

<?php 
        echo xtr('Building cache notice');
        ?>

<script type="text/javascript">

    function isProcessComplete() {

        if (document.getElementById('process_iframe').contentWindow.document.getElementById('finish')) {
            setNextButtonDisabled(false);

        } else {
            setTimeout('isProcessComplete()', 1000);
        }
    }

    setTimeout('isProcessComplete()', 1000);

</script>

<?php 
    } else {
        fatal_error(xtr('Error has encountered while creating fixtures or modules list.'));
    }
    $error = true;
    return false;
}