Subversion Repositories SvarDOS

Compare Revisions

Ignore whitespace Rev 721 → Rev 722

/website/repo/index.php
12,6 → 12,28
*/
 
 
// messages in different languages (and necessary mappings for codepage conversions)
include 'lang.php';
 
 
// convert a utf-8 string into codepage related to lang
function cp_conv($s, $lang) {
global $CP_UTF, $CP_ENC;
$res = str_replace($CP_UTF[$lang], $CP_ENC[$lang], $s);
return($res);
}
 
 
function get_msg($id, $lang) {
global $MSG;
if (!empty($MSG[$id][$lang])) {
return cp_conv($MSG[$id][$lang], $lang);
} else {
echo $MSG[$id]['en'];
}
}
 
 
function nicesize($bytes) {
if ($bytes < 1024) return(round($bytes / 1024, 1) . "K");
if ($bytes < 1024 * 1024) return(round($bytes / 1024) . "K");
63,6 → 85,9
exit(0);
}
 
$lang = 'en';
if (!empty($_GET['lang'])) $lang = strtolower($_GET['lang']);
 
// switch to the packages directory
if (chdir('../../packages') === false) {
http_response_code(404);
126,7 → 151,7
readfile($fname);
} else {
http_response_code(404);
echo "ERROR: package not found on server\r\n";
echo get_msg('PKG_NOT_FOUND', $lang) . "\r\n";
}
exit(0);
}
136,12 → 161,13
 
if ($a === 'search') {
$matches = 0;
header('Content-Type: text/plain');
foreach ($db as $pkg => $meta) {
if ((stristr($pkg, $p)) || (stristr($meta['desc'], $p))) {
// fetch first (preferred) version
$prefver_fname = array_key_first($meta['versions']);
$prefver = array_shift($meta['versions']);
echo str_pad(strtoupper($pkg), 12) . str_pad("ver: {$prefver['ver']} ", 16) . str_pad("size: " . nicesize(filesize($prefver_fname)), 16) . "BSUM: " . sprintf("%04X", $prefver['bsum']) . "\r\n";
echo str_pad(strtoupper($pkg), 12) . str_pad(get_msg('VER', $lang) . " {$prefver['ver']} ", 16) . str_pad(get_msg('SIZE', $lang) . ' ' . nicesize(filesize($prefver_fname)), 16) . "BSUM: " . sprintf("%04X", $prefver['bsum']) . "\r\n";
echo wordwrap($meta['desc'], 79, "\r\n", true);
echo "\r\n";
// do I have any alt versions?
150,13 → 176,13
$altlist[] = $pkg . '-' . $altver['ver'];
}
if (!empty($altlist)) {
echo wordwrap("[alt versions: " . implode(', ', $altlist), 79, "\r\n", true) . "]\r\n";
echo wordwrap('[' . get_msg('ALT_VERS', $lang) . ' ' . implode(', ', $altlist), 79, "\r\n", true) . "]\r\n";
}
echo "\r\n";
$matches++;
}
}
if ($matches == 0) echo "No matching package found.\r\n";
if ($matches == 0) echo get_msg('NO_MATCHING_PKG', $lang) . "\r\n";
}
 
 
177,7 → 203,7
// found version mismatch
if ($found == 0) {
echo str_pad('', 58, '-') . "\r\n";
tabulprint(array('PACKAGE', 'INSTALLED (LOCAL)', 'AVAILABLE (REMOTE)'), array(8, 20, 20));
tabulprint(array(get_msg('PACKAGE', $lang), get_msg('INSTALLED', $lang), get_msg('AVAILABLE', $lang)), array(8, 20, 20));
tabulprint(array('----------', '----------------------', '----------------------'), array(10, 22, 22), false);
}
$found++;
184,10 → 210,10
tabulprint(array('' . $rpkg[0], $rpkg[1], $prefver['ver']), array(8, 20, 20));
}
if ($found == 0) {
echo "no available updates\r\n";
echo get_msg('NO_UPDATES', $lang) . "\r\n";
} else {
echo str_pad('', 58, '-') . "\r\n";
echo "found {$found} differing package(s)\r\n";
echo get_msg('FOUND_DIFFER', $lang) . ' ' . $found . "\r\n";
}
}
 
/website/repo/lang.php
0,0 → 1,55
<?php
 
// translations of repo messages into several languages
// all messages are stored as UTF-8 strings here, and converted to the target
// codepage by index.php using mappings defined in CP_UTF[] and CP_ENC[]
 
$CP_UTF = array();
$CP_ENC = array();
$MSG = array();
 
 
// *** CODEPAGE MAPPINGS ******************************************************
 
// EN (nothing to do, it's ASCII)
$CP_UTF['en'] = array();
$CP_ENC['en'] = array();
 
// PL (mazovia)
$CP_UTF['pl'] = array('Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ż', 'Ź', 'ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ż', 'ź');
$CP_ENC['pl'] = array("\x8f","\x95","\x90","\x9c","\xa5","\xa3","\x98","\xa1","\xa0","\x86","\x8d","\x91","\x92","\xa4","\xa2","\x9e","\xa7","\xa6");
 
 
// *** MESSAGES ***************************************************************
 
$MSG['NO_MATCHING_PKG']['en'] = 'No matching package found';
$MSG['NO_MATCHING_PKG']['pl'] = 'Nie znaleziono żadnego pasującego pakietu';
 
$MSG['PKG_NOT_FOUND']['en'] = 'ERROR: package not found on server';
$MSG['PKG_NOT_FOUND']['pl'] = 'BŁĄD: Nie znaleziono pakietu na serwerze';
 
$MSG['VER']['en'] = 'ver:';
$MSG['VER']['pl'] = 'wer:';
 
$MSG['SIZE']['en'] = 'size:';
$MSG['SIZE']['pl'] = 'rozmiar:';
 
$MSG['ALT_VERS']['en'] = 'alt versions:';
$MSG['ALT_VERS']['pl'] = 'alt. wersje:';
 
$MSG['PACKAGE']['en'] = 'PACKAGE';
$MSG['PACKAGE']['pl'] = 'PAKIET';
 
$MSG['INSTALLED']['en'] = 'INSTALLED (LOCAL)';
$MSG['INSTALLED']['pl'] = 'ZAINSTALOWANY (LOKALNY)';
 
$MSG['AVAILABLE']['en'] = 'AVAILABLE (REMOTE)';
$MSG['AVAILABLE']['pl'] = 'DOSTĘPNY (ZDALNY)';
 
$MSG['NO_UPDATES']['en'] = 'no available updates';
$MSG['NO_UPDATES']['pl'] = 'brak dostępnych aktualizacji';
 
$MSG['FOUND_DIFFER']['en'] = 'found differing packages:';
$MSG['FOUND_DIFFER']['pl'] = 'znalezionych różnic w pakietach:';
 
?>