corrade-http-templates – Blame information for rev 24

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