aboutsummaryrefslogtreecommitdiffstats
path: root/test/lang.php
blob: 4c0c554c300bcfe21f5f65bc2db6a252c33ee5b9 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<pre><?php
/**
*/

function get($s){
    return (boolean) filter_input(INPUT_GET, $s, FILTER_SANITIZE_STRING);
}

/*
 * Option for deleting feed cache if blog posts are not parsed properly:
 * https://www.mageia.org/test/lang.php?delete_feed_cache=1
 */
$delete_feed_cache = get('delete_feed_cache');
if ($delete_feed_cache) {
    $feed_cache_patern = "../_nav/var/tmp/cache/*.spc";
    echo "Deleting feed cache!\n\n";
    array_map('unlink', glob($feed_cache_patern));

    foreach (glob($feed_cache_patern) as $filename) {
        echo "It seems that deleting feed cache didn't work as some files listed below are still there!\n\n";
        echo "$filename, uid: " . fileowner($filename) . "\n";
    }
}

/*
 * Option for deleting navigation cache if pages in one language are blank or not parsed properly:
 * https://www.mageia.org/test/lang.php?delete_nav_cache=1
 */
$delete_nav_cache = get('delete_nav_cache');
if ($delete_nav_cache) {
    $nav_cache_patern = "../_nav/var/tmp/cache/nav_lang_*.php";
    echo "Deleting navigation cache!\n\n";
    array_map('unlink', glob($nav_cache_patern));

    foreach (glob($nav_cache_patern) as $filename) {
        echo "It seems that deleting navigation cache didn't work as some files listed below are still there!\n\n";
        echo "$filename, uid: " . fileowner($filename) . "\n";
    }
}

include_once '../localeDetection.class.php';
include_once '../langs.inc.php';

echo 'Accept-Language: ', $_SERVER['HTTP_ACCEPT_LANGUAGE'], "\n\n";
echo "Relocate `community` with `en` as a default: ", relocate($langs, 'community', 'en', null, false), "\n";

echo "\nTests:\n";

$test_dir = '../sv/map/index.php';
$lstat = '';

if (file_exists($test_dir)) {
    echo "The file $test_dir exists\n";
    $lstat = lstat($test_dir);
//     $linkinfo = linkinfo($test_dir);
//     $readlink = readlink($test_dir);
} else {
    echo "The file $test_dir does not exist\n";
}

if (is_dir($test_dir)) {
    echo "The $test_dir is a dir\n";
} else {
    echo "The $test_dir is not a dir.\n";
}

if (is_file($test_dir)) {
    echo "The $test_dir is a file\n";
} else {
    echo "The $test_dir is not a file.\n";
}

if (is_readable($test_dir)) {
    echo "The file $test_dir is readable\n";
} else {
    echo "The file $test_dir is not readable\n";
}

var_dump($lstat);
// var_dump($readlink);


$test_dir = '../sl/map/index.php';
$lstat2 = '';

if (file_exists($test_dir)) {
    echo "The file $test_dir exists\n";
    $lstat2 = lstat($test_dir);
//     $linkinfo = linkinfo($test_dir);
//     $readlink = readlink($test_dir);
} else {
    echo "The file $test_dir does not exist\n";
}

if (is_dir($test_dir)) {
    echo "The $test_dir is a dir\n";
} else {
    echo "The $test_dir is not a dir.\n";
}

if (is_file($test_dir)) {
    echo "The $test_dir is a file\n";
} else {
    echo "The $test_dir is not a file.\n";
}

if (is_readable($test_dir)) {
    echo "The file $test_dir is readable\n";
} else {
    echo "The file $test_dir is not readable\n";
}

var_dump($lstat2);
// var_dump($readlink);

$diff = array_diff($lstat, $lstat2);
var_dump($diff);