Version 0.1

This commit is contained in:
Root srvweb 2019-11-18 23:36:13 +01:00
parent 51b744909c
commit 005df67e1f
9 changed files with 639 additions and 79 deletions

View file

@ -1,20 +1,27 @@
Options -Indexes
RewriteEngine on
# Sécurité
## Sécurité
RewriteRule ^([0-9]+-[0-9]{1,2})/.key-[0-9]{12}$ /index.php?action=403
RewriteRule ^files/([0-9]+-[0-9]{1,2})/.key-[0-9]{12} /index.php?action=403
RewriteRule ^config.yaml$ index.php?action=403
RewriteRule ^cron.php$ index.php?action=403
# Rewrite
## Rewrite
# direct
RewriteRule ^([0-9]+-[0-9]{1,2})/(.+)$ files/$1/$2 [L]
RewriteRule ^([0-9]+-[0-9]{1,2})/ index.php?action=html&id=$1 [L]
# html page
RewriteRule ^([0-9]+-[0-9]{1,2})/ index.php?action=html&id=$1&%{QUERY_STRING} [L]
# download force
RewriteRule ^dl/([0-9]+-[0-9]{1,2})/(.+)$ index.php?action=dl&id=$1&file=$2 [L]
# delete
RewriteRule ^del/([0-9]+-[0-9]{1,2})/([0-9]{12})/(.+)$ index.php?action=del&id=$1&key=$2&file=$3 [L]
RewriteRule ^del/([0-9]+-[0-9]{1,2})/([0-9]{12})/$ index.php?action=del&id=$1&key=$2 [L]
# zip
RewriteRule ^([0-9]+-[0-9]{1,2})\.zip$ index.php?action=zip&id=$1 [L]
RewriteRule ^My$ index.php?action=myFiles [L]
RewriteRule ^(.+)\.html$ index.php?action=page&name=$1 [L]
# Mes fichiers
RewriteRule ^My$ index.php?action=myFiles&%{QUERY_STRING} [L]
# Pages
RewriteRule ^(.+)\.html$ index.php?action=page&name=$1&%{QUERY_STRING} [L]
# Error
ErrorDocument 404 /index.php?action=404
ErrorDocument 403 /index.php?action=403

107
README.md
View file

@ -1,83 +1,54 @@
Req
- http serveur compatible url rewriting (apache2 for exemple)
-
# file2link
PHP file sharing service [free of rights](https://en.wikipedia.org/wiki/Open_source) (license [Beerware](https://en.wikipedia.org/wiki/Beerware)) and free.
Install
**Demonstration : https://dl.zici.fr/**
ReadWrite is ok for "file"
## Requis
Configure
mv config.yaml.exemple config.yaml
- HTTP serveur htaccess compatible (url rewriting enable)
- PHP 5.6 minimum
- PHP GD lib
- No nessecary database
## Installation
Upload source content on you web server
- conf en yaml
- sans bd
- bar de progression pour l'upload
- upload multi file
- upload dans /timestamp de l'expiration/3lettreouchiffre/nomDuFichier.ext
- limit type de fichier
- limite temps + taille
Move config file :
crontab...
mv config.yaml.exemple config.yaml
header-page.php
header.php
footer-page.php
footer.php
file2link_checkupdate
start-home.php
end-home.php
Change paramètre in config.yaml Make sure the consistency between:
- *maxUploadPerFile* is similar to PHP config *upload_max_filesize* and *post_max_size*
- *maxUploadNb* is similar to PHP config *max_file_uploads*
Make sure the "files" directory is writable
php gd
## Changelog
resize for png (no transparent), gif, jpeg
- 0.1 (16/10/2019)
- Configure with YAML file
- Submit a file upload service with temporary link (Direct link, force download link, download multiple after zip)
- Limit in time
- Limit in number is possible
- Limit on type of file (mime) is possible
- Upload with progress bar in HTML5
- Upload multi file
- Multilingual (French / English)
- Images resize possible
- Find these files before uploader (local storage)
- Housekeeping in files expired by cron job or by web traffic on the page
- Personnalize content page with include header-page.php, header.php, footer-page.php, footer.php, start-home.php, end-home.php
# Licence
Beerware : https://en.wikipedia.org/wiki/Beerware
# Crédit
Thank's :
Mime type icone : https://github.com/colorswall/CSS-file-icons
Icone : https://fontawesome.com Creative Commons Attribution 4.0 International license
emailPoubelle.php
=============
# Author
Un script pour un petit service d'email jetable
* [Démo](http://poubelle.zici.fr/)
* [Page du projet](http://forge.zici.fr/p/emailpoubelle-php/)
* [Download](http://forge.zici.fr/p/emailpoubelle-php/source/download/master/)
* [Bug report](http://forge.zici.fr/p/emailpoubelle-php/issues/)
Installation
-----------
Installation des dépendances :
pear install Net_DNS2
Télécharger & décompresser les sources :
mkdir -p /www/emailPoubelle/postfix
cd /tmp
wget -O emailPoubelle.zip https://framagit.org/kepon/emailPoubellePhp/-/archive/master/emailPoubellePhp-master.zip
unzip emailPoubelle.zip
cp -r emailpoubelle-php-master/* /var/www/emailPoubelle
Configure apache virtualhost (ou autres serveur http)
[...]
DocumentRoot /var/www/emailPoubelle/www
[...]
Configurer Postfix :
vi /etc/postfix/main.cf
[...]
virtual_alias_maps = hash:/www/emailPoubelle/var/virtual
touch /www/emailPoubelle/var/virtual
/usr/sbin/postmap /www/emailPoubelle/var/virtual
chown www-data /www/emailPoubelle/var/virtual
chown www-data /www/emailPoubelle/var/virtual.db
Ajouter dans le fichier /etc/aliases le devnull
echo "devnull: /dev/null" >> /etc/aliases
newaliases
David Mercereau [david #arobase# mercereau #point# info](http://david.mercereau.info/contact/)

57
config.yaml.dist Normal file
View file

@ -0,0 +1,57 @@
shortTitle: "File 2 Link"
title: "A file against a temporary link"
backgroundImage: https://picsum.photos/1024/768?random=1
baseUrl: https://yoururl.tdl/
uploadDir: files # Dir in Read/Write accès
expireCron: web # 'web' or 'cli'
expireCronFreq: 86400 # juste for cron web, in second (exemple 86400 = 1j)
expireDay:
- 1
- 7
- 30
- 90
- 180
- 365
expireDayDefault : 7
imageResize: # Propose resize images
- 0 # 0 = no resize
- 300
- 800
- 1024
- 2048
- 4096
imageResizeDefault : 1024
maxUploadPerFile: 30M # Exemple 100K, 30M, 12G
maxUploadTotal: 90M # Exemple 100K, 30M, 12G
maxUploadNb: 100
mimeTypesConduct: allow # allow = Allow this, deny the rest / deny = Deny this, allow the rest
mimeTypes: # pattern for pgrep_match https://www.php.net/manual/function.preg-match.php
- ^text\/
- ^image\/
- ^audio\/
- ^video\/
- ^font\/
- ^application\/x-bzip
- ^application\/x-csh$
- ^application\/msword$
- ^application\/vnd.openxmlformats-officedocument.
- ^application\/epub+zip$
- ^application\/vnd.oasis.opendocument.
- ^application\/ogg
- ^application\/pdf$
- ^application\/x-rar-compressed$
- ^application\/vnd.ms-powerpoint$
- ^application\/x-tar$
- ^application\/vnd.visio$
- ^application\/vnd.ms-excel$
- ^application\/zip$
- ^application\/x-7z-compressed$
similarServicesView: true
similarServicesLink:
- <a href="https://send.firefox.com">Firefox Send</a>
- <a href="https://toffeeshare.com/">ToffeeShare</a>
- <a href="https://envelop.app/">Envelop</a>
- <a href="https://framadrop.org/">Framadrop</a>
htmlPages: # This page is search in dir "htmlPages/$name.html" clear if you wan't disable
cgu: CGU # Print page "htmlPages/cgu.html"
checkUpdate: 86400 # in seconds or "false" for disable

View file

@ -15,6 +15,53 @@ if (isset($_GET['id'])){
$id = null;
}
/* Language */
if (isset($_GET['langueChange'])) {
$locale = lang2locale($_GET['langueChange']);
$localeshort=locale2lang($locale);
setcookie("langue",$localeshort,strtotime( '+1 year' ), '/');
} else {
if (isset($_COOKIE['langue'])) {
$locale = lang2locale($_COOKIE['langue']);
$localeshort=locale2lang($locale);
} else {
$HTTP_ACCEPT_LANGUAGE=$_SERVER['HTTP_ACCEPT_LANGUAGE'];
//echo $HTTP_ACCEPT_LANGUAGE.'<br />';
$lang_from_http_accept = explode(',', $HTTP_ACCEPT_LANGUAGE);
//echo $lang_from_http_accept[0].'<br />';
$locale = lang2locale($lang_from_http_accept[0]);
if (substr($locale,0,2) != substr($lang_from_http_accept[0],0,2)) {
//echo "Non trouvé, 2ème tentative";
$lang_from_http_accept = explode('-', $lang_from_http_accept[0]);
//echo $lang_from_http_accept[0].'<br />';
$locale = lang2locale($lang_from_http_accept[0]);
}
//echo $locale.'<br />';
$localeshort=locale2lang($locale);
}
}
// Définition de la langue :
$results=putenv("LC_ALL=$locale.utf8");
if (!$results) {
exit ('putenv failed');
}
$results=putenv("LC_LANG=$locale.utf8");
if (!$results) {
exit ('putenv failed');
}
$results=putenv("LC_LANGUAGE=$locale.utf8");
if (!$results) {
exit ('putenv failed');
}
$results=setlocale(LC_ALL, "$locale.utf8");
if (!$results) {
exit ('setlocale failed: locale function is not available on this platform, or the given local does not exist in this environment');
}
bindtextdomain("messages", "./lang");
textdomain("messages");
/* / language */
if (convertHumain2octect($config['maxUploadPerFile']) > convertHumain2octect(ini_get('upload_max_filesize'))) {
exit(printf(_('In coherence with your configuration (config.yaml) you must increase the PHP configuration upload_max_filesize to %s'), $config['maxUploadPerFile']));
}
@ -109,7 +156,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'del') {
<html>
<head>
<meta charset="UTF-8" />
<title>Upload</title>
<title><?= $config['shortTitle'] ?> : <?= $config['title'] ?></title>
<script src="<?= $config['baseUrl'] ?>lib/jquery-3.1.0.min.js"></script>
<script>
var Config_baseUrl = '<?= $config['baseUrl'] ?>'
@ -134,7 +181,17 @@ if (isset($_GET['action']) && $_GET['action'] == 'del') {
</head>
<body>
<div id="langues">
<a href="https://crwd.in/calcpvautonome"><img class="drapeau" src="./lib/trad.png" alt="Help to translate" /></a>
<?php
ksort($lang_ini);
foreach($langueEtLocalDispo as $langShort=>$lang) {
$flag='';
if ($localeshort == $langShort) {
$flag=' drapeauActif';
}
echo '<a id="href'.$langShort.'" href="?langueChange='.$langShort.'"><img class="drapeau'.$flag.'" src="'.$config['baseUrl'].'lib/'.$langShort.'.png" alt="'.$langShort.'" width="23" height="15" /></a>';
}
?>
</div>
<div id="languesLegende" style="display: none"></div>
<div id="page-wrap">
@ -395,7 +452,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'del') {
}
?>
<div id="footer">
<p class="footer_right"><?= _('By') ?> <a href="http://david.mercereau.info/">David Mercereau</a> (<a href="https://framagit.org/kepon/CalcPvAutonome"><?= _('Git repository') ?></a>)</p>
<p class="footer_right"><?= _('By') ?> <a href="http://david.mercereau.info/">David Mercereau</a> (<a href="https://framagit.org/kepon/file2link"><?= _('Git repository') ?></a>)</p>
<p class="footer_left">file2link <?= _('version') ?> <?= VERSION ?> <?= _('is an open software licensed <a href="https://en.wikipedia.org/wiki/Beerware">Beerware</a>') ?></p>
<?php
if ($config['htmlPages']) {

1
lang/fr Symbolic link
View file

@ -0,0 +1 @@
fr_FR/

Binary file not shown.

View file

@ -0,0 +1,226 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-18 18:12+0100\n"
"PO-Revision-Date: 2019-11-18 23:01+0100\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.6\n"
"Last-Translator: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr_FR\n"
#: cron.php:7
msgid "Start the command in the file2link directory"
msgstr "Lancer la commande dans le répertoire de travail file2link"
#: cron.php:10
msgid "Completed"
msgstr "Terminé"
#: cron.php:12
msgid "expireCron is not at \"cli\" mod (in config.yaml)"
msgstr "expireCron n'est pas à la valeur \"cli\" (dans le config.yaml)"
#: index.php:19
#, php-format
msgid ""
"In coherence with your configuration (config.yaml) you must increase the PHP "
"configuration upload_max_filesize to %s"
msgstr ""
"En cohérence avec votre configuration (config.yaml), vous devez modifier la "
"configuration PHP upload_max_filesize à%s"
#: index.php:22
#, php-format
msgid ""
"In coherence with your configuration (config.yaml) you must increase the PHP "
"configuration post_max_size to %s"
msgstr ""
"En cohérence avec votre configuration (config.yaml), vous devez modifier la "
"configuration PHP post_max_size à%s"
#: index.php:25
#, php-format
msgid ""
"In coherence with your configuration (config.yaml) you must increase the PHP "
"configuration max_file_uploads to %s"
msgstr ""
"En cohérence avec votre configuration (config.yaml), vous devez modifier la "
"configuration PHP max_file_uploads à%s"
#: index.php:121 upload.php:43
#, php-format
msgid "this file exceeds the allowed size %s"
msgstr "ce fichier dépasse la taille autorisée %s"
#: index.php:122
#, php-format
msgid "The total size of the files exceeds the allowed size : %s"
msgstr "La taille totale des fichiers dépasse la taille autorisée: %s"
#: index.php:123
#, php-format
msgid "You can not send more than %d files at a time"
msgstr "Vous ne pouvez pas envoyer plus de %d fichiers à la fois"
#: index.php:124
#, php-format
msgid "this type of file isn\\'t allow"
msgstr "ce type de fichier nautorise pas"
#: index.php:146
msgid "Similar services"
msgstr "Services similaires"
#: index.php:179
#, php-format
msgid ""
"Error: The directory (%s) is not writable, please contact the service "
"administrator"
msgstr ""
"Erreur: le répertoire (%s) n'est pas accessible en écriture, veuillez "
"contacter l'administrateur du service"
#: index.php:190 index.php:192
msgid "The requested page does not exist"
msgstr "La page demandée n'existe pas"
#: index.php:212
#, php-format
msgid "These files will be automatically deleted on %s, ie in %d days"
msgstr ""
"Ces fichiers seront automatiquement supprimés le %s, c'est-à-dire dans %d "
"jours"
#: index.php:224
msgid "Error: Nothing to display"
msgstr "Erreur: rien à afficher"
#: index.php:228
msgid "This page"
msgstr "Cette page"
#: index.php:235
msgid "All"
msgstr "Tout"
#: index.php:235
msgid "Delete all (permanently)"
msgstr "Supprimer tout (définitivement)"
#: index.php:262
msgid "Size"
msgstr "Taille"
#: index.php:263
msgid "Type"
msgstr "Type"
#: index.php:294
msgid "My files"
msgstr "Mes fichiers"
#: index.php:295 index.php:348
msgid ""
"Online file sharing service <a href=\"https://en.wikipedia.org/wiki/"
"Open_source\">free of rights</a> (license <a href=\"https://en.wikipedia.org/"
"wiki/Beerware\">Beerware</a>) and free."
msgstr ""
"Service de partage de fichiers en ligne <a href=\"https://en.wikipedia.org/"
"wiki/Open_source\"> libre de droits </a> (licence <a href = \"https://en."
"wikipedia.org/wiki/Beerware \"> Bière </a>) et gratuite."
#: index.php:300 index.php:362
msgid "Expire"
msgstr "Expiration"
#: index.php:300
msgid "Link"
msgstr "Lien"
#: index.php:323
msgid "No files, maybe all of them have expired."
msgstr "Aucun fichier, peut-être que tous ont expiré."
#: index.php:326
msgid "All your files have expired."
msgstr "Tous vos fichiers ont expiré."
#: index.php:333 index.php:334
msgid "Unauthorized access"
msgstr "Accès non autorisé"
#: index.php:338
msgid "Not Found"
msgstr "Introuvable"
#: index.php:339
msgid "This sharing does not exist, it has probably expired"
msgstr "Ce partage n'existe pas, il a probablement expiré"
#: index.php:366 index.php:368
msgid "day"
msgstr "jour"
#: index.php:373
msgid "Images resize"
msgstr "Redimensionner les images"
#: index.php:378
msgid "No resizing"
msgstr "Pas de redimensionnement"
#: index.php:388
#, php-format
msgid "The limit per file is %dM, and the total limit per upload is %dM"
msgstr ""
"La limite par fichier est de %dM et la limite totale par téléchargement est "
"de %dM"
#: index.php:398
msgid "By"
msgstr "Par"
#: index.php:398
msgid "Git repository"
msgstr "Source git"
#: index.php:399
msgid "version"
msgstr "version"
#: index.php:399
msgid ""
"is an open software licensed <a href=\"https://en.wikipedia.org/wiki/Beerware"
"\">Beerware</a>"
msgstr ""
"est un logiciel libre sous licence <a href=\"https://en.wikipedia.org/wiki/"
"Beerware\"> Beerware </a>"
#: upload.php:37
#, php-format
msgid "this type of file isn't allow"
msgstr "ce type de fichier n'est pas autorisé"
#: upload.php:49
#, php-format
msgid "The total size of the files exceeds the allowed size %s"
msgstr "La taille totale des fichiers dépasse la taille autorisée %s"
#: upload.php:71
#, php-format
msgid "Unknown error"
msgstr "Erreur inconnue"
#: lib/functions.php:104
msgid "Expired"
msgstr "Expiré"

209
lang/messages.pot Normal file
View file

@ -0,0 +1,209 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-11-18 18:12+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: cron.php:7
msgid "Start the command in the file2link directory"
msgstr ""
#: cron.php:10
msgid "Completed"
msgstr ""
#: cron.php:12
msgid "expireCron is not at \"cli\" mod (in config.yaml)"
msgstr ""
#: index.php:19
#, php-format
msgid ""
"In coherence with your configuration (config.yaml) you must increase the PHP "
"configuration upload_max_filesize to %s"
msgstr ""
#: index.php:22
#, php-format
msgid ""
"In coherence with your configuration (config.yaml) you must increase the PHP "
"configuration post_max_size to %s"
msgstr ""
#: index.php:25
#, php-format
msgid ""
"In coherence with your configuration (config.yaml) you must increase the PHP "
"configuration max_file_uploads to %s"
msgstr ""
#: index.php:121 upload.php:43
#, php-format
msgid "this file exceeds the allowed size %s"
msgstr ""
#: index.php:122
#, php-format
msgid "The total size of the files exceeds the allowed size : %s"
msgstr ""
#: index.php:123
#, php-format
msgid "You can not send more than %d files at a time"
msgstr ""
#: index.php:124
#, php-format
msgid "this type of file isn\\'t allow"
msgstr ""
#: index.php:146
msgid "Similar services"
msgstr ""
#: index.php:179
#, php-format
msgid ""
"Error: The directory (%s) is not writable, please contact the service "
"administrator"
msgstr ""
#: index.php:190 index.php:192
msgid "The requested page does not exist"
msgstr ""
#: index.php:212
#, php-format
msgid "These files will be automatically deleted on %s, ie in %d days"
msgstr ""
#: index.php:224
msgid "Error: Nothing to display"
msgstr ""
#: index.php:228
msgid "This page"
msgstr ""
#: index.php:235
msgid "All"
msgstr ""
#: index.php:235
msgid "Delete all (permanently)"
msgstr ""
#: index.php:262
msgid "Size"
msgstr ""
#: index.php:263
msgid "Type"
msgstr ""
#: index.php:294
msgid "My files"
msgstr ""
#: index.php:295 index.php:348
msgid ""
"Online file sharing service <a href=\"https://en.wikipedia.org/wiki/"
"Open_source\">free of rights</a> (license <a href=\"https://en.wikipedia.org/"
"wiki/Beerware\">Beerware</a>) and free."
msgstr ""
#: index.php:300 index.php:362
msgid "Expire"
msgstr ""
#: index.php:300
msgid "Link"
msgstr ""
#: index.php:323
msgid "No files, maybe all of them have expired."
msgstr ""
#: index.php:326
msgid "All your files have expired."
msgstr ""
#: index.php:333 index.php:334
msgid "Unauthorized access"
msgstr ""
#: index.php:338
msgid "Not Found"
msgstr ""
#: index.php:339
msgid "This sharing does not exist, it has probably expired"
msgstr ""
#: index.php:366 index.php:368
msgid "day"
msgstr ""
#: index.php:373
msgid "Images resize"
msgstr ""
#: index.php:378
msgid "No resizing"
msgstr ""
#: index.php:388
#, php-format
msgid "The limit per file is %dM, and the total limit per upload is %dM"
msgstr ""
#: index.php:398
msgid "By"
msgstr ""
#: index.php:398
msgid "Git repository"
msgstr ""
#: index.php:399
msgid "version"
msgstr ""
#: index.php:399
msgid ""
"is an open software licensed <a href=\"https://en.wikipedia.org/wiki/Beerware"
"\">Beerware</a>"
msgstr ""
#: upload.php:37
#, php-format
msgid "this type of file isn't allow"
msgstr ""
#: upload.php:49
#, php-format
msgid "The total size of the files exceeds the allowed size %s"
msgstr ""
#: upload.php:71
#, php-format
msgid "Unknown error"
msgstr ""
#: lib/functions.php:104
msgid "Expired"
msgstr ""

View file

@ -1,5 +1,10 @@
<?php
// CODE LOCALE (locale -a)
$langueEtLocalDispo=array( 'fr' => 'fr_FR',
'en' => 'en_US'
);
function CheckUpdate() {
global $config;
if ($config['checkUpdate']) {
@ -65,14 +70,16 @@ function genZip($id) {
global $config;
$uploadDirId=$config['uploadDir'].'/'.$id;
$zipFile = $uploadDirId.'/'.$id.'.zip';
if (!is_file($zipFile)) {
if (!is_file($zipFile)) {
$zip = new ZipArchive();
if ($zip->open($zipFile, ZipArchive::CREATE)!==TRUE) {
exit('Error in open <$zipFile>\n');
}
foreach (scandir($uploadDirId) as $file) {
if (is_file($uploadDirId.'/'.$file)) {
$zip->addFile($uploadDirId.'/'.$file,$file);
if (is_file($uploadDirId.'/'.$file)
&& !preg_match('/^.key-[0-9]{12}$/', $file)
&& !preg_match('/^\.(.+)\.small$/', $file)) {
$zip->addFile($uploadDirId.'/'.$file,$file);
}
}
$zip->close();
@ -179,4 +186,29 @@ function truncate($string, $max_length = 30, $replacement = '', $trunc_at_space
return substr_replace($string, $replacement, $max_length);
}
function lang2locale($langue) {
global $langueEtLocalDispo;
if ($langueEtLocalDispo[$langue] != '') {
return $langueEtLocalDispo[$langue];
} else {
// par défaut
return 'en_US';
}
}
function locale2lang($localeRecherche) {
global $langueEtLocalDispo;
foreach($langueEtLocalDispo as $code=>$locale) {
if ($locale == $localeRecherche) {
return $code;
break;
}
}
// par défaut
return 'en';
}
?>