-
Notifications
You must be signed in to change notification settings - Fork 1
/
compat.php
45 lines (37 loc) · 1.45 KB
/
compat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* Depending on the PHP version, define the parse_ini_string function.
* Source: a comment in the PHP manual, http://php.net/manual/en/function.parse-ini-string.php#97621
* (Allow white-space?)
*/
# Define parse_ini_string if it doesn't exist.
# Does accept lines starting with ; as comments
# Does not accept comments after values
if( !function_exists('parse_ini_string') ){
function parse_ini_string( $string ) {
$array = Array();
$lines = explode("\n", $string );
foreach( $lines as $line ) {
$statement = preg_match(
#"/^(?!;)(?P<key>[\w+\.\-]+?)\s*=\s*(?P<value>.+?)\s*$/" //WAS.
"/^(?!;)\s*?(?P<key>[\w+\.\-]+?)\s*=\s*(?P<value>.+?)\s*$/", $line, $match );
if( $statement ) {
$key = $match[ 'key' ];
$value = $match[ 'value' ];
# Remove quote
if( preg_match( "/^\".*\"$/", $value ) || preg_match( "/^'.*'$/", $value ) ) {
$value = mb_substr( $value, 1, mb_strlen( $value ) - 2 );
}
$array[ $key ] = $value;
}
}
return $array;
}
}
function copyemz($file1, $file2){
$contentx = file_get_contents($file1);
$openedfile = fopen($file2, "w");
fwrite($openedfile, $contentx);
fclose($openedfile);
return $contentx!==FALSE; //$status;
}