[www] r704 - trunk/packs.matroska.org/data

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: toff
Date: 2004-09-18 13:22:22 +0400 (Sat, 18 Sep 2004)
New Revision: 704

Modified:
   trunk/packs.matroska.org/data/index.php.fr
   trunk/packs.matroska.org/data/links.txt
Log:
Add some locking capability

Modified: trunk/packs.matroska.org/data/index.php.fr
===================================================================
--- trunk/packs.matroska.org/data/index.php.fr	2004-09-18 09:12:24 UTC (rev 703)
+++ trunk/packs.matroska.org/data/index.php.fr	2004-09-18 09:22:22 UTC (rev 704)
@@ -1,6 +1,6 @@
 <?php
-	$download = unserialize(implode('', file('logs.txt'))); 
 	include("links.txt");
+	$download = unserialize(safe_read_file('logs.txt'));
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html>

Modified: trunk/packs.matroska.org/data/links.txt
===================================================================
--- trunk/packs.matroska.org/data/links.txt	2004-09-18 09:12:24 UTC (rev 703)
+++ trunk/packs.matroska.org/data/links.txt	2004-09-18 09:22:22 UTC (rev 704)
@@ -64,4 +64,28 @@
 		echo number_format($filesize[$packversion][$packname], 0, '.', '\'') . " Bytes";
 	}
 	
+	
+	function safe_read_file($file)
+	{
+    $fp = fopen($file,"r");
+    if (flock($fp, LOCK_EX)) { // exclusive lock
+    	$return = fread($fp, filesize($file));
+    	flock($fp, LOCK_UN);
+    } else {
+    	$return = "";
+    }
+    fclose($fp);
+    return $return;
+  }
+  
+	function safe_write_file($file,$data)
+	{
+		$fp = fopen($file, "w");
+		if (flock($fp, LOCK_EX)) { // exclusive lock
+   		fwrite($fp, $data);
+   		flock($fp, LOCK_UN);
+		}
+		fclose($fp);
+  }
+  	
 ?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.