Example #1
0
 /**
  * Base function
  *
  * This functions receives the request to generate a dump file for the
  * database and does so! Only superadmins are allowed to do this!
  */
 public function index()
 {
     Yii::app()->loadHelper("admin/backupdb");
     $sDbName = _getDbName();
     $sFileName = 'LimeSurvey_' . $sDbName . '_dump_' . dateShift(date('Y-m-d H:i:s'), 'Y-m-d', Yii::app()->getConfig('timeadjust')) . '.sql';
     $this->_outputHeaders($sFileName);
     outputDatabase();
     exit;
 }
Example #2
0
/**
 * Outputs a full dump of the current LimeSurvey database
 * @param string $sDbName Database Name
 */
function outputDatabase($sDbName = '', $bEchoOutput = true, $sFileName = null)
{
    if ($sDbName = '') {
        $sDbName = _getDbName();
    }
    $bAllowExportAllDb = (bool) Yii::app()->getConfig('allowexportalldb');
    $sOutput = _outputDBDescription($sDbName, $bAllowExportAllDb);
    if ($bEchoOutput) {
        echo $sOutput;
    }
    if (!is_null($sFileName)) {
        $oFile = fopen($sFileName, 'w');
        fwrite($oFile, $sOutput);
    }
    _outputDBData($bAllowExportAllDb, $bEchoOutput, $sFileName, $oFile);
    if (!is_null($sFileName)) {
        fclose($oFile);
    }
}