scratch – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | <?php |
2 | |||
3 | ########################################################################### |
||
4 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
||
5 | ########################################################################### |
||
6 | function atomized_put_contents($file, $data) { |
||
7 | $fp = fopen($file, "w+"); |
||
8 | if (flock($fp, LOCK_EX)) { |
||
9 | fwrite($fp, $data); |
||
10 | fflush($fp); |
||
11 | flock($fp, LOCK_UN); |
||
12 | } |
||
13 | fclose($fp); |
||
14 | } |
||
15 | ########################################################################### |
||
16 | ## Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 ## |
||
17 | ########################################################################### |
||
18 | function atomized_get_contents($file) { |
||
19 | $fp = fopen($file, "r+"); |
||
20 | $ct = ''; |
||
21 | if (flock($fp, LOCK_SH)) { |
||
22 | if (filesize($file)) { |
||
23 | $ct = fread($fp, filesize($file)); |
||
24 | } |
||
25 | flock($fp, LOCK_UN); |
||
26 | } |
||
27 | fclose($fp); |
||
28 | return $ct; |
||
29 | } |
||
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 |