Example #1
0
function UpdateStep3()
{
    global $clang, $scriptname, $homedir, $buildnumber, $updatebuild, $debug, $rootdir, $publicdir, $tempdir, $database_exists, $databasetype, $action, $demoModeOnly;

    echo '<div class="header ui-widget-header">'.sprintf($clang->gT('ComfortUpdate step %s'),'3').'</div><div class="updater-background">';
    echo '<h3>'.$clang->gT('Creating DB & file backup').'</h3>';
    if (!isset( $_SESSION['updateinfo']))
    {
        echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').'<br />';

        if ($updateinfo['error']==1)
        {
            setGlobalSetting('updatekey','');
            echo $clang->gT('Your update key is invalid and was removed. ').'<br />';
        }
        else
        echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').'<br />';
    }
    else
    {
        $updateinfo=$_SESSION['updateinfo'];
    }

    // okay, updateinfo now contains all necessary updateinformation
    // Create DB and file backups now

    $basefilename = date("YmdHis-").md5(uniqid(rand(), true));
    //Now create a backup of the files to be delete or modified

    Foreach ($updateinfo['files'] as $file)
    {
        if (is_file($publicdir.$file['file'])===true) // Sort out directories
        {
            $filestozip[]=$publicdir.$file['file'];
        }
    }

    require_once("classes/pclzip/pclzip.lib.php");
    //  require_once('classes/pclzip/pcltrace.lib.php');
    //  require_once('classes/pclzip/pclzip-trace.lib.php');

    //PclTraceOn(1);

    $archive = new PclZip($tempdir.DIRECTORY_SEPARATOR.'files-'.$basefilename.'.zip');


    $v_list = $archive->add($filestozip, PCLZIP_OPT_REMOVE_PATH, $publicdir);

    echo $clang->gT('Creating file backup... ').'<br />';

    if ($v_list == 0) {
        die("Error : ".$archive->errorInfo(true));
    }
    else
    {
        echo "<span class='successtitle'>".$clang->gT('File backup created:').' '.htmlspecialchars($tempdir.DIRECTORY_SEPARATOR.'files-'.$basefilename.'.zip').'</span><br /><br />';

    }

    require_once("dumpdb.php");

    if ($databasetype=='mysql' || $databasetype=='mysqli')
    {
        echo $clang->gT('Creating database backup... ').'<br />';
        $byteswritten=file_put_contents($tempdir.DIRECTORY_SEPARATOR.'db-'.$basefilename.'.sql',completedump());
        if ($byteswritten>5000)
        {
            echo "<span class='successtitle'>".$clang->gT('DB backup created:')." ".htmlspecialchars($tempdir.DIRECTORY_SEPARATOR.'db-'.$basefilename.'.sql').'</span><br /><br />';
        }
    }
    else
    {
        echo "<span class='warningtitle'>".$clang->gT('No DB backup created:').'<br />'.$clang->gT('Database backup functionality is currently not available for your database type. Before proceeding please backup your database using a backup tool!').'</span><br /><br />';
    }

    echo $clang->gT('Please check any problems above and then proceed to the final step.');
    echo "<p><button onclick=\"window.open('$scriptname?action=update&amp;subaction=step4', '_top')\" ";
    echo ">".sprintf($clang->gT('Proceed to step %s'),'4')."</button></p>";
    echo '</div>';
}
 * LimeSurvey
 * Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
 * All rights reserved.
 * License: GNU/GPL License v2 or later, see LICENSE.php
 * LimeSurvey is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 *
 * $Id: dumpdb.php 10475 2011-07-11 16:14:32Z c_schmitz $
 */
include_once "login_check.php";
//Login Check dies also if the script is started directly
if ($database_exists && ($databasetype == 'mysql' || $databasetype == 'mysqli') && $demoModeOnly != true && $action == 'dumpdb') {
    $export = completedump();
    $file_name = "LimeSurvey_{$databasename}_dump_" . date_shift(date("Y-m-d H:i:s"), "Y-m-d", $timeadjust) . ".sql";
    Header("Content-type: application/octet-stream");
    Header("Content-Disposition: attachment; filename={$file_name}");
    Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    Header("Pragma: Public");
    echo $export;
    exit;
    // needs to be inside the condition so the updater still can include this file
}
/**
 * Creates a full dump of the current LimeSurvey database
 *
 * @returns string Contains the dumped data
 */
function completedump()