* @version $id SVN
* @access public
* @license http://opensource.org/licenses/gpl-3.0.html
*/
ob_start();
@set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors',1);
ini_set("track_errors", 1);
// defines
define('SITE_LINEA_URL', 'https://www.linea21.com');
define('USER_AGENT', 'Linea21 - Loader/0.4 (https://www.linea21.com)');
define('REFERER', $_SERVER["HTTP_HOST"].' Linea21 - Loader/0.4');
define('ZIP_FILE', '_tmp.zip');
define('BASE_PATH', dirname(__FILE__).'/');
define('END_LINE', "
");
define('PERFORM_TEST', true);
// TARGET_URL is set later - do not uncomment the following line
// U_L is defined later
# localized input
$lang = array(
'en' => array(
'already_installed' => 'Linea21 seems to be already installed.',
'pre-requisites' => 'pre-requisites',
'connection_failed' => 'Unable to connect to %s.',
'OK' => 'OK',
'not_OK' => 'not OK',
'php_version' => 'PHP version >= 7.3',
'is_writable' => 'Folder is writable',
'simplexml_ext' => 'SimpleXML extension',
'gd_ext' => 'GD extension',
'xml_ext' => 'XML extension',
'libxml_ext' => 'LibXML extension',
'mbstring_ext' => 'mbstring extension',
'mysqli_ext' => 'MySQLi extension',
'zip_ext' => 'ZIP extension',
'curl_ext' => 'cURL extension',
'check_not_ok' => 'Sorry, settings do not allow the Loader to run correctly.',
'dl_latest' => 'Downloading latest stable version',
'dl_from' => 'Downloading from',
'curl_error_no' => 'cURL error number',
'curl_error_msg' => 'cURL error message',
'zip_extract' => 'Extracting %s to %s',
'del_msg' => 'Deleting %s',
'succeed' => 'succeed',
'failed' => 'failed',
'end_up' => ' The automatic installation ended up. Please, change current settings or download Linea21 manually.',
'delete_loader' => 'Do not forget to delete loader.php file.',
'go_on' => 'Téléchargement terminé, poursuivre l\'installation !',
'errors' => 'error(s)'
),
'fr' => array(
'already_installed' => 'Linea21 semble déjà installé.',
'pre-requisites' => 'Pré-requis',
'connection_failed' => 'Connexion à %s impossible.',
'OK' => 'OK',
'not_OK' => 'non OK',
'php_version' => 'PHP version >= 7.3',
'is_writable' => 'Permissions en écriture sur le dossier',
'simplexml_ext' => 'extension SimpleXML',
'gd_ext' => 'extension GD',
'xml_ext' => 'extension XML',
'libxml_ext' => 'extension LibXML',
'mbstring_ext' => 'extension MBstring',
'mysqli_ext' => 'extension MySQLi',
'zip_ext' => 'extension ZIP',
'curl_ext' => 'extension cURL',
'check_not_ok' => 'Desolé, la configuration actuelle ne permet pas de lancer le Loader.',
'dl_latest' => 'Téléchargement de la dernière version stable',
'dl_from' => 'Téléchargement depuis',
'curl_error_no' => 'erreur cURL numéro',
'curl_error_msg' => 'message d\'erreur cURL',
'zip_extract' => 'Extraction de %s vers %s',
'del_msg' => 'Suppression de %s',
'succeed' => 'succès',
'failed' => 'échec',
'end_up' => ' L\'installation automatique a été stoppée. Veuillez modifier vos paramètres ou installer Linea21 manuellement.',
'delete_loader' => 'N\'oubliez pas de supprimer le fichier loader.php.',
'go_on' => 'Téléchargement terminé, poursuivre l\'installation !',
'errors' => 'erreur(s)'
)
);
$language = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2));
if(!in_array($language, array_keys($lang))) $language = 'en';
define('U_L', $language);
$check = true;
// display localized message
function _t($var) {
global $lang;
return $lang[U_L][$var];
}
function rmLoader() {
$js = "";
echo $js;
}
// buffer flush
function fl() {
@ob_end_flush();
@ob_flush();
@flush();
@ob_start();
}
// check if given extension is loaded
function check_ext($ext) {
global $check;
if (!extension_loaded($ext)) {
$check = false;
return _t('not_OK');
} else {
return _t('OK');
}
}
// check PHP version
function check_php() {
global $check;
if (version_compare(PHP_VERSION, '7.3.0', '>=')) {
return _t('OK'). ' ('.PHP_VERSION.')';
} else {
$check = false;
return _t('not_OK'). ' ('.PHP_VERSION.')';
}
}
// check writable file/folder
function check_writable() {
global $check;
if (!is_writable(__DIR__)) {
$check = false;
return _t('not_OK');
} else {
return _t('OK');
}
}
# from https://www.php.net/manual/en/ziparchive.extractto.php#116353
# permet de supprimer des dossiers de l'arborescence. Ici : 'linea21'
class my_ZipArchive extends ZipArchive
{
public function extractSubdirTo($destination, $subdir)
{
$errors = array();
// Prepare dirs
$destination = str_replace(array("/", "\\"), DIRECTORY_SEPARATOR, $destination);
$subdir = str_replace(array("/", "\\"), "/", $subdir);
if (substr($destination, mb_strlen(DIRECTORY_SEPARATOR, "UTF-8") * -1) != DIRECTORY_SEPARATOR)
$destination .= DIRECTORY_SEPARATOR;
if (substr($subdir, -1) != "/")
$subdir .= "/";
// Extract files
for ($i = 0; $i < $this->numFiles; $i++)
{
$filename = $this->getNameIndex($i);
if (substr($filename, 0, mb_strlen($subdir, "UTF-8")) == $subdir)
{
$relativePath = substr($filename, mb_strlen($subdir, "UTF-8"));
$relativePath = str_replace(array("/", "\\"), DIRECTORY_SEPARATOR, $relativePath);
if (mb_strlen($relativePath, "UTF-8") > 0)
{
if (substr($filename, -1) == "/") // Directory
{
// New dir
if (!is_dir($destination . $relativePath))
if (!@mkdir($destination . $relativePath, 0755, true))
$errors[$i] = $filename;
}
else
{
if (dirname($relativePath) != ".")
{
if (!is_dir($destination . dirname($relativePath)))
{
// New dir (for file)
@mkdir($destination . dirname($relativePath), 0755, true);
}
}
// New file
if (@file_put_contents($destination . $relativePath, $this->getFromIndex($i)) === false)
$errors[$i] = $filename;
}
}
}
}
return $errors;
}
}
?>
'; echo _t('curl_error_no'). ' : ' .curl_errno($h).END_LINE; echo _t('curl_error_msg'). ' : ' . curl_error($h); echo '
'; rmLoader(); die(_t('end_up')); } else { echo ' : '. _t('succeed').END_LINE; } curl_close($h); fclose($fp); fl(); ### Step 3 ### Extracting zip file and cleaning echo ''.ZIP_FILE . ' : chmod '; echo @chmod(ZIP_FILE, 0777) == true ? _t('succeed').END_LINE : _t('failed').END_LINE; echo sprintf(_t('zip_extract'), ZIP_FILE, BASE_PATH). ' '; fl(); $zip = new my_ZipArchive(); if ($zip->open(ZIP_FILE) === TRUE) { $errors = $zip->extractSubdirTo("./", "linea21/"); $zip->close(); echo _t('succeed').END_LINE; echo ' [' . _t('errors') . ' : ' . count($errors) . '] : '; } else { echo _t('failed').END_LINE; } fl(); // deleting old files and ZIP archive) // echo sprintf(_t('del_msg').' : ', BASE_PATH.'linea21'); // if(@rmdir(BASE_PATH.'linea21')) echo _t('succeed').END_LINE; else echo _t('failed').END_LINE; echo sprintf(_t('del_msg').' : ', ZIP_FILE); if(@unlink(ZIP_FILE)) echo _t('succeed').END_LINE; else echo _t('failed').END_LINE; exec ("chmod -R 0755 " . dirname($_SERVER['SCRIPT_FILENAME'])); ### Step 4 ### Follow up on DB Install and set-up ?>