.*/s', '', $pingContent); } if ($type === 'image') { $backgroundStyle = "\n\n"; } elseif ($type === 'video') { $backgroundStyle = "\n "; } elseif ($type === 'audio') { $audioElement = " "; } if (strpos($pingContent, '') !== false && strpos($pingContent, '') !== false) { $pingContent = preg_replace('/.*/s', "$backgroundStyle$audioElement", $pingContent); } else { $pingContent .= "\n$backgroundStyle$audioElement\n"; } file_put_contents($pingFile, $pingContent); file_put_contents($currentBgFile, $filename); $backgroundFiles = array_filter(array_map('trim', file($backgroundHistoryFile))); if (($key = array_search($filename, $backgroundFiles)) !== false) { unset($backgroundFiles[$key]); } array_unshift($backgroundFiles, $filename); $backgroundFiles = array_slice($backgroundFiles, 0, 20); file_put_contents($backgroundHistoryFile, implode("\n", $backgroundFiles)); echo "背景已成功设置!"; } elseif ($action === 'remove') { $pingContent = preg_replace('/.*/s', '', $pingContent); file_put_contents($pingFile, $pingContent); file_put_contents($currentBgFile, ''); echo "背景已成功删除!"; } ?>