Procházet zdrojové kódy

Lock things down (by IP for now, by user later)

Zachary Kotlarek před 13 roky
rodič
revize
b80b9c3762
1 změnil soubory, kde provedl 14 přidání a 11 odebrání
  1. 14 11
      web/index.php

+ 14 - 11
web/index.php

@@ -16,17 +16,20 @@ if (isset($_REQUEST['show'])) {
 
 # Did the user request an update?
 if ($show !== false && isset($_POST['Save'])) {
-	echo '<h4 style="color: red;">Saving not yet implemented</h4>';
-
-	# Grab the current settings for comparison
-	global $TV_PATH;
-	$series_path = $TV_PATH . '/'. $show;
-	$series_last = readFlags($series_path);
-	$seasons_last = findSeasons($series_path);
-
-	# Save series and season data
-	saveFlags($series_path, $_POST, $series_last, $seasons_last);
-	saveSeasons($series_path, $_POST, $series_last, $seasons_last);
+	# Require auth (or for the time being, specific IP addresses)
+	if (preg_match('/^(?:172\.19\.[17]\.|2602:3f:e50d:76|74\.93\.97\.65)/', $_SERVER['REMOTE_ADDR'])) {
+		# Grab the current settings for comparison
+		global $TV_PATH;
+		$series_path = $TV_PATH . '/'. $show;
+		$series_last = readFlags($series_path);
+		$seasons_last = findSeasons($series_path);
+
+		# Save series and season data
+		saveFlags($series_path, $_POST, $series_last, $seasons_last);
+		saveSeasons($series_path, $_POST, $series_last, $seasons_last);
+	} else {
+		echo '<h4 style="color: red;">Cannot save: User not authenticated</h4>';
+	}
 }
 
 #=========================================================================================