aboutsummaryrefslogtreecommitdiffstats
path: root/en/about/license/license.php
blob: eebf1163e6ef0bdbbdf1e2cb5af3dfd995a4c192 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
function read_license_from_vcs($locale) {
    $license_strings = array(
        array('_: You can warn about unofficial translation here'),
        array('Introduction', 'h3'),
        array('The operating system and the different components available in the Mageia distribution \nshall be called the \"Software Products\" hereafter. The Software Products include, but are not \nrestricted to, the set of programs, methods, rules and documentation related to the operating \nsystem and the different components of the Mageia distribution, and any applications \ndistributed with these products provided by Mageia\'s licensors or suppliers.'),
        array('1. License Agreement', 'h3'),
        array('Please read this document carefully. This document is a license agreement between you and  \nMageia which applies to the Software Products.\nBy installing, duplicating or using any of the Software Products in any manner, you explicitly \naccept and fully agree to conform to the terms and conditions of this License. \nIf you disagree with any portion of the License, you are not allowed to install, duplicate or use \nthe Software Products. \nAny attempt to install, duplicate or use the Software Products in a manner which does not comply \nwith the terms and conditions of this License is void and will terminate your rights under this \nLicense. Upon termination of the License,  you must immediately destroy all copies of the \nSoftware Products.'),
        array('2. Limited Warranty', 'h3'),
        array('The Software Products and attached documentation are provided \"as is\", with no warranty, to the \nextent permitted by law.\nNeither Mageia nor its licensors or suppliers will, in any circumstances and to the extent \npermitted by law, be liable for any special, incidental, direct or indirect damages whatsoever \n(including without limitation damages for loss of business, interruption of business, financial \nloss, legal fees and penalties resulting from a court judgment, or any other consequential loss) \narising out of  the use or inability to use the Software Products, even if Mageia or its \nlicensors or suppliers have been advised of the possibility or occurrence of such damages.\n\nLIMITED LIABILITY LINKED TO POSSESSING OR USING PROHIBITED SOFTWARE IN SOME COUNTRIES\n\nTo the extent permitted by law, neither Mageia nor its licensors, suppliers or\ndistributors will, in any circumstances, be liable for any special, incidental, direct or indirect \ndamages whatsoever (including without limitation damages for loss of business, interruption of \nbusiness, financial loss, legal fees and penalties resulting from a court judgment, or any \nother consequential loss) arising out of the possession and use of software components or \narising out of  downloading software components from one of Mageia sites which are \nprohibited or restricted in some countries by local laws.\nThis limited liability applies to, but is not restricted to, the strong cryptography components \nincluded in the Software Products.\nHowever, because some jurisdictions do not allow the exclusion or limitation of liability for \nconsequential or incidental damages, the above limitation may not apply to you.'),
        array('3. The GPL License and Related Licenses', 'h3'),
        array('The Software Products consist of components created by different persons or entities.\nMost of these licenses allow you to use, duplicate, adapt or redistribute the components which \nthey cover. Please read carefully the terms and conditions of the license agreement for each component \nbefore using any component. Any question on a component license should be addressed to the component \nlicensor or supplier and not to Mageia.\nThe programs developed by Mageia are governed by the GPL License. Documentation written \nby Mageia is governed by \"%s\" License.', null, 'CC-By-SA'), // "CC-By-SA" https://svnweb.mageia.org/soft/drakx/trunk/perl-install/messages.pm?revision=5942&view=markup
        array('4. Intellectual Property Rights', 'h3'),
        array('All rights to the components of the Software Products belong to their respective authors and are \nprotected by intellectual property and copyright laws applicable to software programs.\nMageia and its suppliers and licensors reserves their rights to modify or adapt the Software \nProducts, as a whole or in parts, by all means and for all purposes.\n\"Mageia\" and associated logos are trademarks of %s', null, 'Mageia.Org'), // "Mageia.Org" https://svnweb.mageia.org/soft/drakx/trunk/perl-install/messages.pm?revision=5942&view=markup
        array('5. Governing Laws', 'h3'),
        array('If any portion of this agreement is held void, illegal or inapplicable by a court judgment, this \nportion is excluded from this contract. You remain bound by the other applicable sections of the \nagreement.\nThe terms and conditions of this License are governed by the Laws of France.\nAll disputes on the terms of this license will preferably be settled out of court. As a last \nresort, the dispute will be referred to the appropriate Courts of Law of Paris - France.\nFor any question on this document, please contact Mageia.'),
        array('Warning: Free Software may not necessarily be patent free, and some Free\nSoftware included may be covered by patents in your country. For example, the\nMP3 decoders included may require a license for further usage (see\nhttp://www.mp3licensing.com for more details). If you are unsure if a patent\nmay be applicable to you, check your local laws.'),
    );

    if($locale == 'en') {
        $po_locale = 'libDrakX.pot';
    } else {
        $po_locale = locale_hyphen_underscore($locale, true) . '.po'; // create pt_BR.po from pt-br and alike
    }
//  $po_files_path = "http://svnweb.mageia.org/soft/drakx/trunk/perl-install/share/po/";
//  $po_files_end  = "?view=co";
    $po_files_path = "http://gitweb.mageia.org/software/drakx/plain/perl-install/share/po/"; // git doesn't work yet on https
    $po_files_end  = "";

    $po_file = phpmo_parse_po_file($po_files_path . $po_locale . $po_files_end);
    if($po_file === false) {
        $po_file = phpmo_parse_po_file($po_files_path . "libDrakX.pot" . $po_files_end);
    }

    $num_of_untranslated_sentences    = 0;
    $num_of_sentences_for_translation = 0;
    $untranslated_sentences = array();
    $search  = array('\\"', '\n', '  ');
    $replace = array('"','<br>', ' ');
    foreach($license_strings as $value) {
        str_replace(array(".", "_"), array(".", "_"), $value[0], $count);
        $num_of_sentences_for_translation += $count;
        if(!empty($po_file[$value[0]][0][0]) && trim($po_file[$value[0]][0][0]) != "" && $po_file[$value[0]][0][0] != $value[0]) {
            $license_string = $po_file[$value[0]][0][0];
        } else {
            $num_of_untranslated_sentences += $count;
            $untranslated_sentences[] = $value[0];
            $license_string = $value[0];
        }
        $license_string = str_replace('%s', (isset($value[2]) ? $value[2] : ''), $license_string);
        $prepared_license_strings[] = array(str_replace($search, $replace, $license_string), (isset($value[1]) ? $value[1] : 'p'), 'untran' => $num_of_untranslated_sentences, 'all' => $num_of_sentences_for_translation, 'untranslated_sentences' => $untranslated_sentences);
    }

    return $prepared_license_strings;
}

function load_license_numbers($lang, $skip_rebuilding_cache = false)
{
    $pot_filename  = 'libDrakX.pot';
    $po_files_path = "http://gitweb.mageia.org/software/drakx/plain/perl-install/share/po/";
    $cache_file    = __DIR__ . '/../../../_nav/var/tmp/cache/license_numbers_' . $lang . '.php';
    $rebuild_cache = false;
    date_default_timezone_set(@date_default_timezone_get());
    if($lang == 'en') {
        $filename = $pot_filename;
        $start_text = '"POT-Creation-Date:';
    } else {
        $filename   = locale_hyphen_underscore($lang, true) . '.po'; // create pt_BR.po from pt-br and alike
        $start_text = '"PO-Revision-Date:';
    }
    if(!$skip_rebuilding_cache) {
        $po_file    = $po_files_path . $filename;
        $po_time    = 0;
        $filehandle = @fopen($po_file, 'r'); // read $po_file
        if($filehandle !== false) { // could open $po_fil
            fclose($filehandle);
            $po_time = get_po_time($po_file, $start_text);
        } else {
            $po_time = get_po_time($po_files_path . $pot_filename, $start_text);
            if(!$po_time) { $po_time = 0; } // fallback
        }
        if(file_exists($cache_file)) {
            $cached_time = -1;
            include $cache_file;
            $cached_time = intval($cached_time);
            $po_time     = intval($po_time);
            if($cached_time < $po_time) {
                $rebuild_cache = true;
            }
        } else {
            $rebuild_cache = true;
        }
        if($rebuild_cache) {
            $po_time         = intval($po_time);
            $license_array   = read_license_from_vcs($lang);
            $license_numbers = array_pop($license_array);
            $license_num_all = $license_numbers["all"];
            $license_num_unt = $license_numbers["untran"];
            $cache_content   = <<<P
<?php
/**! Generated. Do not edit. */

// Date in $po_file
\$cached_time = $po_time;

// $lang license numbers
\$license_num_all = $license_num_all;
\$license_num_unt = $license_num_unt;

P;
            file_put_contents($cache_file, $cache_content);
        }
    } else {
        if(file_exists($cache_file)) {
            include $cache_file;
        } else { // fallback (defaults to half translated license)
            $license_num_all = 38;
            $license_num_unt = 19;
        }
    }

    $return_license_numbers["all"]    = $license_num_all;
    $return_license_numbers["untran"] = $license_num_unt;
    return $return_license_numbers;
}

function get_po_time($po_file, $start_text)
{
    $filehandle = @fopen($po_file, 'r'); // read $po_file
    if($filehandle === false) { // still could not open $po_file
        return 0; // fallback
    }

    while(($line = fgets($filehandle, 50)) !== false) { // check first 50 characters
        $line = trim($line);
        if(substr_count($line, $start_text) == 1) { // if $start_text is present
            $line = trim(str_replace(array($start_text, '\n"'), '', $line));
            $po_time = strtotime($line);
            fclose($filehandle);
            return $po_time;
        }
    }
    fclose($filehandle);
    return 0; // fallback
}