scratch – Diff between revs 4 and 12

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 4 Rev 12
Line 1... Line 1...
1 <?php 1 <?php
Line 2... Line 2...
2   2  
3 ########################################################################### 3 ###########################################################################
4 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## 4 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
5 ########################################################################### 5 ###########################################################################
-   6 function atomized_put_contents($file, $data)
6 function atomized_put_contents($file, $data) { 7 {
7 $fp = fopen($file, "w+"); 8 $fp = fopen($file, "w+");
8 if (flock($fp, LOCK_EX)) { 9 if (flock($fp, LOCK_EX)) {
9 fwrite($fp, $data); 10 fwrite($fp, $data);
10 fflush($fp); 11 fflush($fp);
Line 13... Line 14...
13 fclose($fp); 14 fclose($fp);
14 } 15 }
15 ########################################################################### 16 ###########################################################################
16 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## 17 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ##
17 ########################################################################### 18 ###########################################################################
18 function atomized_get_contents($file) { 19 function atomized_get_contents($file)
-   20 {
19 $fp = fopen($file, "r+"); 21 $fp = fopen($file, "r+");
20 $ct = ''; 22 $ct = '';
21 if (flock($fp, LOCK_SH)) { 23 if (flock($fp, LOCK_SH)) {
22 if (filesize($file)) { 24 if (filesize($file)) {
23 $ct = fread($fp, filesize($file)); 25 $ct = fread($fp, filesize($file));
Line 25... Line 27...
25 flock($fp, LOCK_UN); 27 flock($fp, LOCK_UN);
26 } 28 }
27 fclose($fp); 29 fclose($fp);
28 return $ct; 30 return $ct;
29 } 31 }
30   -  
31 ########################################################################### -  
32 ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## -  
33 ########################################################################### -  
34 function wasKeyValueGet($key, $data) { -  
35 return array_reduce( -  
36 explode( -  
37 "&", -  
38 $data -  
39 ), -  
40 function($o, $p) { -  
41 $x = explode("=", $p); -  
42 return array_shift($x) != $o ? $o : array_shift($x); -  
43 }, -  
44 $key -  
45 ); -  
46 } -  
47   -