/** * Logic for export process */ public function DoExport() { // Test connection $Msg = $this->TestDatabase(); if ($Msg === true) { // Create db object $Ex = new ExportModel(); $Dsn = 'mysql:dbname=' . $this->DbInfo['dbname'] . ';host=' . $this->DbInfo['dbhost']; $Ex->PDO($Dsn, $this->DbInfo['dbuser'], $this->DbInfo['dbpass']); $Ex->Prefix = $this->DbInfo['prefix']; // Test src tables' existence structure $Msg = $Ex->VerifySource($this->_SourceTables); if ($Msg === true) { // Good src tables - Start dump $Ex->UseCompression = TRUE; set_time_limit(60 * 2); $this->ForumExport($Ex); } else { ViewForm($Msg); } // Back to form with error } else { ViewForm($Msg); } // Back to form with error }
/** * Logic for export process */ public function DoExport() { global $Supported; // Test connection $Msg = $this->TestDatabase(); if ($Msg === true) { // Create db object $Ex = new ExportModel(); $Ex->SetConnection($this->DbInfo['dbhost'], $this->DbInfo['dbuser'], $this->DbInfo['dbpass'], $this->DbInfo['dbname']); $Ex->Prefix = $this->DbInfo['prefix']; $Ex->UseStreaming = $this->UseStreaming; // Test src tables' existence structure $Msg = $Ex->VerifySource($this->SourceTables); if ($Msg === true) { // Good src tables - Start dump $Ex->UseCompression(TRUE); $Ex->FilenamePrefix = $this->DbInfo['dbname']; set_time_limit(60 * 60); $this->ForumExport($Ex); // Write the results. if ($Ex->UseStreaming) { exit; } else { ViewExportResult($Ex->Comments, 'Info', $Ex->Path); } } else { ViewForm(array('Supported' => $Supported, 'Msg' => $Msg, 'Info' => $this->DbInfo)); } // Back to form with error } else { ViewForm(array('Supported' => $Supported, 'Msg' => $Msg, 'Info' => $this->DbInfo)); } // Back to form with error }
SetAsComplete($experimentid); ViewForm($experimentid, "view"); break; case 'save': $experimentid = SaveForm($enrollmentid, $formid, $val_strings, $val_numbers, $val_texts, $val_dates, $val_files, $experimentor, $experimentdate, $username, $label, $notes); ViewForm($experimentid, "view"); break; case 'update': UpdateForm($experimentid, $enrollmentid, $formid, $val_strings, $val_numbers, $val_texts, $val_dates, $val_files, $experimentor, $experimentdate, $username, $label, $notes); ViewForm($experimentid, "view"); break; case 'view': ViewForm($experimentid, "print"); break; case 'edit': ViewForm($experimentid, "edit"); break; case 'print': PrintForm($experimentid); break; default: echo "No action specified"; } /* ------------------------------------ functions ------------------------------------ */ /* -------------------------------------------- */ /* ------- SetAsComplete ---------------------- */ /* -------------------------------------------- */ function SetAsComplete($experimentid) {
include 'class.phpbb3.php'; include 'class.bbpress.php'; include 'class.simplepress.php'; // Make sure a default time zone is set if (ini_get('date.timezone') == '') { date_default_timezone_set('America/Montreal'); } // Instantiate the appropriate controller or display the input page. if (isset($_POST['type']) && array_key_exists($_POST['type'], $Supported)) { // Mini-Factory $class = ucwords($_POST['type']); $Controller = new $class(); $Controller->DoExport(); } else { $CanWrite = TestWrite(); ViewForm(array('Supported' => $Supported, 'CanWrite' => $CanWrite)); } /** * Write out a value passed as bytes to its most readable format. */ function FormatMemorySize($Bytes, $Precision = 1) { $Units = array('B', 'K', 'M', 'G', 'T'); $Bytes = max((int) $Bytes, 0); $Pow = floor(($Bytes ? log($Bytes) : 0) / log(1024)); $Pow = min($Pow, count($Units) - 1); $Bytes /= pow(1024, $Pow); $Result = round($Bytes, $Precision) . $Units[$Pow]; return $Result; } /**
{ // Create file $file = 'vanilla2test.txt'; @touch($file); if (is_writable($file)) { @unlink($file); return true; } else { return false; } } // Files include 'class.exportmodel.php'; include 'views.php'; include 'class.exportcontroller.php'; foreach ($supported as $file => $info) { include 'class.' . $file . '.php'; } // Logic if (isset($_POST['type']) && array_key_exists($_POST['type'], $supported)) { // Mini-Factory $class = ucwords($_POST['type']); new $class(); } else { // View form or error if (TestWrite()) { ViewForm($supported); } else { ViewNoPermission("This script has detected that it does not have permission to create files in the current directory. Please rectify this and retry."); } }
/** * Logic for export process. */ public function DoExport() { global $Supported; // Test connection $Msg = $this->TestDatabase(); if ($Msg === true) { // Test src tables' existence structure $Msg = $this->Ex->VerifySource($this->SourceTables); if ($Msg === true) { // Good src tables - Start dump $this->Ex->UseCompression(true); $this->Ex->FilenamePrefix = $this->DbInfo['dbname']; set_time_limit(60 * 60); // ob_start(); $this->ForumExport($this->Ex); // $Errors = ob_get_clean(); $Msg = $this->Ex->Comments; // Write the results. Send no path if we don't know where it went. $RelativePath = $this->Param('destpath', false) ? false : $this->Ex->Path; ViewExportResult($Msg, 'Info', $RelativePath); } else { ViewForm(array('Supported' => $Supported, 'Msg' => $Msg, 'Info' => $this->DbInfo)); } // Back to form with error } else { ViewForm(array('Supported' => $Supported, 'Msg' => $Msg, 'Info' => $this->DbInfo)); } // Back to form with error }