$backup_prefix_pattern = "-- pmftableprefix:"; $backup_prefix_pattern_len = PMF_String::strlen($backup_prefix_pattern); if (PMF_String::substr($dat, 0, $backup_prefix_pattern_len) == $backup_prefix_pattern) { $table_prefix = trim(PMF_String::substr($dat, $backup_prefix_pattern_len)); } if (PMF_String::substr($dat, 0, 2) != '--' && $dat != '') { $mquery[] = trim(PMF_String::substr($dat, 0, -1)); } } $k = 0; $g = 0; printf("<p>%s</p>\n", $PMF_LANG['ad_csv_process']); $num = count($mquery); $kg = ''; for ($i = 0; $i < $num; $i++) { $mquery[$i] = PMF_DB_Helper::alignTablePrefix($mquery[$i], $table_prefix, PMF_Db::getTablePrefix()); $kg = $faqConfig->getDb()->query($mquery[$i]); if (!$kg) { printf('<div style="alert alert-danger"><strong>Query</strong>: "%s" failed (Reason: %s)</div>%s', PMF_String::htmlspecialchars($mquery[$i], ENT_QUOTES, 'utf-8'), $faqConfig->getDb()->error(), "\n"); $k++; } else { printf('<!-- <div style="alert alert-success"><strong>Query</strong>: "%s" okay</div> -->%s', PMF_String::htmlspecialchars($mquery[$i], ENT_QUOTES, 'utf-8'), "\n"); $g++; } } printf('<p class="alert alert-success">%d %s %d %s</p>', $g, $PMF_LANG['ad_csv_of'], $num, $PMF_LANG['ad_csv_suc']); } } else { switch ($_FILES['userfile']['error']) { case 1: $errorMessage = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
$auth = false; $user = PMF_User_CurrentUser::getFromSession($faqConfig); if ($user) { $auth = true; } else { $user = null; unset($user); } header('Content-Type: application/octet-stream'); header('Pragma: no-cache'); if ($user->perm->checkRight($user->getUserId(), 'backup')) { $tables = $tableNames = $faqConfig->getDb()->getTableNames(PMF_Db::getTablePrefix()); $tablePrefix = PMF_Db::getTablePrefix() !== '' ? PMF_Db::getTablePrefix() . '.phpmyfaq' : 'phpmyfaq'; $tableNames = ''; $majorVersion = substr($faqConfig->get('main.currentVersion'), 0, 3); $dbHelper = new PMF_DB_Helper($faqConfig); switch ($action) { case 'backup_content': foreach ($tables as $table) { if (PMF_Db::getTablePrefix() . 'faqadminlog' == trim($table) || PMF_Db::getTablePrefix() . 'faqsessions' == trim($table)) { continue; } $tableNames .= $table . ' '; } break; case 'backup_logs': foreach ($tables as $table) { if (PMF_Db::getTablePrefix() . 'faqadminlog' == trim($table) || PMF_Db::getTablePrefix() . 'faqsessions' == trim($table)) { $tableNames .= $table . ' '; } }