From: Dan Untenzu Date: Tue, 24 Jan 2017 12:08:59 +0000 (+0100) Subject: [FEATURE] Switch to PSR-2 X-Git-Tag: 3.0.0~17 X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/commitdiff_plain/96707e02b8b24054e0827eaf169cc88504a1e78c?ds=inline [FEATURE] Switch to PSR-2 Convert all PHP files to PSR-2, which defined a basic Coding Style Guide for PHP projects. Using the awesome friendsofphp/php-cs-fixer tool, running with the @PSR2 ruleset. 1) script.php (no_spaces_after_function_name, braces) 2) f.php (indentation_type, no_spaces_after_function_name, braces) 3) install.php (indentation_type, function_declaration, elseif, no_spaces_after_function_name, braces) 4) lib/functions.php (no_spaces_inside_parenthesis, method_argument_space, function_declaration, elseif, no_spaces_after_function_name, lowercase_constants, lowercase_keywords, braces, single_blank_line_at_eof) 5) lib/functions.js.php (no_spaces_after_function_name) 6) lib/lang.php (function_declaration, no_spaces_after_function_name, lowercase_constants, no_closing_tag, braces, single_blank_line_at_eof) 7) lib/template/footer.php (braces) 8) lib/config.local.bak.php (method_argument_space, no_spaces_after_function_name, no_closing_tag, single_blank_line_at_eof) 9) lib/config.original.php (no_spaces_after_function_name, no_closing_tag, single_blank_line_at_eof) 0) lib/settings.php (indentation_type, no_spaces_after_function_name, braces) 1) lib/config.local.php (no_spaces_after_function_name, single_blank_line_at_eof) 2) index.php (indentation_type, no_spaces_after_function_name, braces) 3) admin.php (no_spaces_after_function_name, braces) 4) tos.php (no_spaces_after_function_name, no_closing_tag, single_blank_line_at_eof) Refs #103 --- diff --git a/admin.php b/admin.php index d602dcd..e4321db 100644 --- a/admin.php +++ b/admin.php @@ -17,45 +17,38 @@ * along with this program. If not, see . */ -define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); +define('JIRAFEAU_ROOT', dirname(__FILE__) . '/'); -require (JIRAFEAU_ROOT . 'lib/settings.php'); -require (JIRAFEAU_ROOT . 'lib/functions.php'); -require (JIRAFEAU_ROOT . 'lib/lang.php'); +require(JIRAFEAU_ROOT . 'lib/settings.php'); +require(JIRAFEAU_ROOT . 'lib/functions.php'); +require(JIRAFEAU_ROOT . 'lib/lang.php'); /* Check if installation is OK. */ -if (file_exists (JIRAFEAU_ROOT . 'install.php') - && !file_exists (JIRAFEAU_ROOT . 'lib/config.local.php')) -{ +if (file_exists(JIRAFEAU_ROOT . 'install.php') + && !file_exists(JIRAFEAU_ROOT . 'lib/config.local.php')) { header('Location: install.php'); exit; } /* If called from CLI, no password or graphical interface */ if (php_sapi_name() == "cli") { - if ((count($argv)>1) && $argv[1]=="clean_expired") { - $total = jirafeau_admin_clean (); - echo "$total expired files deleted."; - } - elseif ((count($argv)>1) && $argv[1]=="clean_async") { - $total = jirafeau_admin_clean_async (); - echo "$total old unfinished transfers deleted."; - } - else - { - die("No command found. Should be admin.php ."); - } -} -else -{ - /* Disable admin interface if we have a empty admin password. */ - if (empty($cfg['admin_password']) && empty($cfg['admin_http_auth_user'])) - { - require (JIRAFEAU_ROOT . 'lib/template/header.php'); + if ((count($argv)>1) && $argv[1]=="clean_expired") { + $total = jirafeau_admin_clean(); + echo "$total expired files deleted."; + } elseif ((count($argv)>1) && $argv[1]=="clean_async") { + $total = jirafeau_admin_clean_async(); + echo "$total old unfinished transfers deleted."; + } else { + die("No command found. Should be admin.php ."); + } +} else { + /* Disable admin interface if we have a empty admin password. */ + if (empty($cfg['admin_password']) && empty($cfg['admin_http_auth_user'])) { + require(JIRAFEAU_ROOT . 'lib/template/header.php'); echo '

'. t('Sorry, the admin interface is not enabled.') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } @@ -63,36 +56,34 @@ else session_start(); /* Unlog if asked. */ - if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0)) + if (isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { $_SESSION['admin_auth'] = false; + } /* Check classic admin password authentification. */ - if (isset ($_POST['admin_password']) && empty($cfg['admin_http_auth_user'])) - { + if (isset($_POST['admin_password']) && empty($cfg['admin_http_auth_user'])) { if ($cfg['admin_password'] === $_POST['admin_password'] || - $cfg['admin_password'] === hash('sha256', $_POST['admin_password'])) + $cfg['admin_password'] === hash('sha256', $_POST['admin_password'])) { $_SESSION['admin_auth'] = true; - else - { + } else { $_SESSION['admin_auth'] = false; - require (JIRAFEAU_ROOT . 'lib/template/header.php'); + require(JIRAFEAU_ROOT . 'lib/template/header.php'); echo '

'. t('Wrong password.') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } } /* Ask for classic admin password authentification. */ - elseif ((!isset ($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true) - && empty($cfg['admin_http_auth_user'])) - { - require (JIRAFEAU_ROOT . 'lib/template/header.php'); ?> + elseif ((!isset($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true) + && empty($cfg['admin_http_auth_user'])) { + require(JIRAFEAU_ROOT . 'lib/template/header.php'); ?>
'; + echo '
+

'. + if (!isset($_SESSION['admin_auth']) || $_SESSION['admin_auth'] != true) { + $_SESSION['admin_auth'] = false; + require(JIRAFEAU_ROOT . 'lib/template/header.php'); + echo '

'. t('Sorry, you are not authenticated on admin interface.') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); - exit; + require(JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; } /* Operations may take a long time. @@ -141,14 +131,12 @@ else @error_reporting(0); /* Show admin interface if not downloading a file. */ - if (!(isset ($_POST['action']) && strcmp ($_POST['action'], 'download') == 0)) - { - require (JIRAFEAU_ROOT . 'lib/template/header.php'); - ?>

(version )

-
+
@@ -234,71 +222,56 @@ else ' . NL; echo '

'; echo t('Number of cleaned files') . ' : ' . $total; echo '

'; - } - elseif (strcmp ($_POST['action'], 'clean_async') == 0) - { - $total = jirafeau_admin_clean_async (); + } elseif (strcmp($_POST['action'], 'clean_async') == 0) { + $total = jirafeau_admin_clean_async(); echo '
' . NL; echo '

'; echo t('Number of cleaned files') . ' : ' . $total; echo '

'; - } - elseif (strcmp ($_POST['action'], 'list') == 0) - { - jirafeau_admin_list ("", "", ""); - } - elseif (strcmp ($_POST['action'], 'search_by_name') == 0) - { - jirafeau_admin_list ($_POST['name'], "", ""); - } - elseif (strcmp ($_POST['action'], 'search_by_file_hash') == 0) - { - jirafeau_admin_list ("", $_POST['hash'], ""); - } - elseif (strcmp ($_POST['action'], 'search_link') == 0) - { - jirafeau_admin_list ("", "", $_POST['link']); - } - elseif (strcmp ($_POST['action'], 'delete_link') == 0) - { - jirafeau_delete_link ($_POST['link']); + } elseif (strcmp($_POST['action'], 'list') == 0) { + jirafeau_admin_list("", "", ""); + } elseif (strcmp($_POST['action'], 'search_by_name') == 0) { + jirafeau_admin_list($_POST['name'], "", ""); + } elseif (strcmp($_POST['action'], 'search_by_file_hash') == 0) { + jirafeau_admin_list("", $_POST['hash'], ""); + } elseif (strcmp($_POST['action'], 'search_link') == 0) { + jirafeau_admin_list("", "", $_POST['link']); + } elseif (strcmp($_POST['action'], 'delete_link') == 0) { + jirafeau_delete_link($_POST['link']); echo '
' . NL; echo '

' . t('Link deleted') . '

'; - } - elseif (strcmp ($_POST['action'], 'delete_file') == 0) - { - $count = jirafeau_delete_file ($_POST['md5']); + } elseif (strcmp($_POST['action'], 'delete_file') == 0) { + $count = jirafeau_delete_file($_POST['md5']); echo '
' . NL; echo '

' . t('Deleted links') . ' : ' . $count . '

'; - } - elseif (strcmp ($_POST['action'], 'download') == 0) - { - $l = jirafeau_get_link ($_POST['link']); - if (!count ($l)) + } elseif (strcmp($_POST['action'], 'download') == 0) { + $l = jirafeau_get_link($_POST['link']); + if (!count($l)) { return; - $p = s2p ($l['md5']); - header ('Content-Length: ' . $l['file_size']); - header ('Content-Type: ' . $l['mime_type']); - header ('Content-Disposition: attachment; filename="' . + } + $p = s2p($l['md5']); + header('Content-Length: ' . $l['file_size']); + header('Content-Type: ' . $l['mime_type']); + header('Content-Disposition: attachment; filename="' . $l['file_name'] . '"'); - if (file_exists(VAR_FILES . $p . $l['md5'])) - readfile (VAR_FILES . $p . $l['md5']); + if (file_exists(VAR_FILES . $p . $l['md5'])) { + readfile(VAR_FILES . $p . $l['md5']); + } exit; } } - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); } ?> diff --git a/f.php b/f.php index 109ac53..d94b55b 100644 --- a/f.php +++ b/f.php @@ -17,15 +17,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); +define('JIRAFEAU_ROOT', dirname(__FILE__) . '/'); -require (JIRAFEAU_ROOT . 'lib/settings.php'); -require (JIRAFEAU_ROOT . 'lib/functions.php'); -require (JIRAFEAU_ROOT . 'lib/lang.php'); +require(JIRAFEAU_ROOT . 'lib/settings.php'); +require(JIRAFEAU_ROOT . 'lib/functions.php'); +require(JIRAFEAU_ROOT . 'lib/lang.php'); -if (!isset ($_GET['h']) || empty ($_GET['h'])) -{ - header ('Location: ' . $cfg['web_root']); +if (!isset($_GET['h']) || empty($_GET['h'])) { + header('Location: ' . $cfg['web_root']); exit; } @@ -38,95 +37,91 @@ if (!isset ($_GET['h']) || empty ($_GET['h'])) $link_name = $_GET['h']; -if (!preg_match ('/[0-9a-zA-Z_-]+$/', $link_name)) -{ - require (JIRAFEAU_ROOT.'lib/template/header.php'); +if (!preg_match('/[0-9a-zA-Z_-]+$/', $link_name)) { + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '

' . t('Sorry, the requested file is not found') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } -$link = jirafeau_get_link ($link_name); -if (count ($link) == 0) -{ +$link = jirafeau_get_link($link_name); +if (count($link) == 0) { /* Try alias. */ - $alias = jirafeau_get_alias (md5 ($link_name)); - if (count ($alias) > 0) - $link = jirafeau_get_link ($alias["destination"]); + $alias = jirafeau_get_alias(md5($link_name)); + if (count($alias) > 0) { + $link = jirafeau_get_link($alias["destination"]); + } } -if (count ($link) == 0) -{ - require (JIRAFEAU_ROOT.'lib/template/header.php'); +if (count($link) == 0) { + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '

' . t('Sorry, the requested file is not found') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } $delete_code = ''; -if (isset ($_GET['d']) && !empty ($_GET['d']) && $_GET['d'] != '1') +if (isset($_GET['d']) && !empty($_GET['d']) && $_GET['d'] != '1') { $delete_code = $_GET['d']; +} $crypt_key = ''; -if (isset ($_GET['k']) && !empty ($_GET['k'])) +if (isset($_GET['k']) && !empty($_GET['k'])) { $crypt_key = $_GET['k']; +} $do_download = false; -if (isset ($_GET['d']) && $_GET['d'] == '1') +if (isset($_GET['d']) && $_GET['d'] == '1') { $do_download = true; +} $do_preview = false; -if (isset ($_GET['p']) && !empty ($_GET['p'])) +if (isset($_GET['p']) && !empty($_GET['p'])) { $do_preview = true; +} -$p = s2p ($link['md5']); -if (!file_exists (VAR_FILES . $p . $link['md5'])) -{ - jirafeau_delete_link ($link_name); - require (JIRAFEAU_ROOT.'lib/template/header.php'); +$p = s2p($link['md5']); +if (!file_exists(VAR_FILES . $p . $link['md5'])) { + jirafeau_delete_link($link_name); + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '

'.t('File not available.'). '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } -if (!empty ($delete_code) && $delete_code == $link['link_code']) -{ - jirafeau_delete_link ($link_name); - require (JIRAFEAU_ROOT.'lib/template/header.php'); +if (!empty($delete_code) && $delete_code == $link['link_code']) { + jirafeau_delete_link($link_name); + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '

'.t('File has been deleted.'). '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } -if ($link['time'] != JIRAFEAU_INFINITY && time () > $link['time']) -{ - jirafeau_delete_link ($link_name); - require (JIRAFEAU_ROOT.'lib/template/header.php'); +if ($link['time'] != JIRAFEAU_INFINITY && time() > $link['time']) { + jirafeau_delete_link($link_name); + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '

'. t('The time limit of this file has expired.') . ' ' . t('File has been deleted.') . '

'; - require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + require(JIRAFEAU_ROOT . 'lib/template/footer.php'); exit; } -if (empty ($crypt_key) && $link['crypted']) -{ - require (JIRAFEAU_ROOT.'lib/template/header.php'); +if (empty($crypt_key) && $link['crypted']) { + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '

' . t('Sorry, the requested file is not found') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } $password_challenged = false; -if (!empty ($link['key'])) -{ - if (!isset ($_POST['key'])) - { - require (JIRAFEAU_ROOT.'lib/template/header.php'); +if (!empty($link['key'])) { + if (!isset($_POST['key'])) { + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '
' . '
' . t('Terms of Service') . '.' . '
'; - if ($link['onetime'] == 'O') - { + if ($link['onetime'] == 'O') { echo ''; - } - - ?>
' . t('Warning, this file will self-destruct after being read') . '
'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; - } - else - { - if ($link['key'] == md5 ($_POST['key'])) + } else { + if ($link['key'] == md5($_POST['key'])) { $password_challenged = true; - else - { - sleep (2); - require (JIRAFEAU_ROOT.'lib/template/header.php'); + } else { + sleep(2); + require(JIRAFEAU_ROOT.'lib/template/header.php'); echo '

' . t('Access denied') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } } } -if (!$password_challenged && !$do_download && !$do_preview) -{ - require (JIRAFEAU_ROOT.'lib/template/header.php'); - echo '
' . +if (!$password_challenged && !$do_download && !$do_preview) { + require(JIRAFEAU_ROOT.'lib/template/header.php'); + echo '
' . '
'; ?> ' . htmlspecialchars($link['file_name']) . '' . @@ -204,84 +192,79 @@ if (!$password_challenged && !$do_download && !$do_preview) t('By using our services, you accept our'). ' ' . t('Terms of Service') . '.' . ''; - if ($link['onetime'] == 'O') - { - echo ''; - } - - ?> + } ?> '; - echo '
' . + if ($link['onetime'] == 'O') { + echo '
' . t('Warning, this file will self-destruct after being read') . '
'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); - exit; + echo '
'; + require(JIRAFEAU_ROOT.'lib/template/footer.php'); + exit; } -header ('HTTP/1.0 200 OK'); -header ('Content-Length: ' . $link['file_size']); -if (!jirafeau_is_viewable ($link['mime_type']) || !$cfg['preview'] || $do_download) - header ('Content-Disposition: attachment; filename="' . $link['file_name'] . '"'); -else - header ('Content-Disposition: filename="' . $link['file_name'] . '"'); -header ('Content-Type: ' . $link['mime_type']); -header ('Content-MD5: ' . hex_to_base64($link['md5'])); +header('HTTP/1.0 200 OK'); +header('Content-Length: ' . $link['file_size']); +if (!jirafeau_is_viewable($link['mime_type']) || !$cfg['preview'] || $do_download) { + header('Content-Disposition: attachment; filename="' . $link['file_name'] . '"'); +} else { + header('Content-Disposition: filename="' . $link['file_name'] . '"'); +} +header('Content-Type: ' . $link['mime_type']); +header('Content-MD5: ' . hex_to_base64($link['md5'])); /* Read encrypted file. */ -if ($link['crypted']) -{ +if ($link['crypted']) { /* Init module */ $m = mcrypt_module_open('rijndael-256', '', 'ofb', ''); /* Extract key and iv. */ - $md5_key = md5 ($crypt_key); - $iv = jirafeau_crypt_create_iv ($md5_key, mcrypt_enc_get_iv_size($m)); + $md5_key = md5($crypt_key); + $iv = jirafeau_crypt_create_iv($md5_key, mcrypt_enc_get_iv_size($m)); /* Init module. */ - mcrypt_generic_init ($m, $md5_key, $iv); + mcrypt_generic_init($m, $md5_key, $iv); /* Decrypt file. */ - $r = fopen (VAR_FILES . $p . $link['md5'], 'r'); - while (!feof ($r)) - { - $dec = mdecrypt_generic($m, fread ($r, 1024)); + $r = fopen(VAR_FILES . $p . $link['md5'], 'r'); + while (!feof($r)) { + $dec = mdecrypt_generic($m, fread($r, 1024)); print $dec; ob_flush(); } - fclose ($r); + fclose($r); /* Cleanup. */ mcrypt_generic_deinit($m); mcrypt_module_close($m); } /* Read file. */ -else -{ - $r = fopen (VAR_FILES . $p . $link['md5'], 'r'); - while (!feof ($r)) - { - print fread ($r, 1024); +else { + $r = fopen(VAR_FILES . $p . $link['md5'], 'r'); + while (!feof($r)) { + print fread($r, 1024); ob_flush(); } - fclose ($r); + fclose($r); } -if ($link['onetime'] == 'O') - jirafeau_delete_link ($link_name); +if ($link['onetime'] == 'O') { + jirafeau_delete_link($link_name); +} exit; ?> diff --git a/index.php b/index.php index 2002ad7..b8feabd 100644 --- a/index.php +++ b/index.php @@ -18,66 +18,59 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); +define('JIRAFEAU_ROOT', dirname(__FILE__) . '/'); -require (JIRAFEAU_ROOT . 'lib/settings.php'); -require (JIRAFEAU_ROOT . 'lib/functions.php'); -require (JIRAFEAU_ROOT . 'lib/lang.php'); +require(JIRAFEAU_ROOT . 'lib/settings.php'); +require(JIRAFEAU_ROOT . 'lib/functions.php'); +require(JIRAFEAU_ROOT . 'lib/lang.php'); -check_errors ($cfg); -if (has_error ()) -{ - show_errors (); - require (JIRAFEAU_ROOT . 'lib/template/footer.php'); +check_errors($cfg); +if (has_error()) { + show_errors(); + require(JIRAFEAU_ROOT . 'lib/template/footer.php'); exit; } -require (JIRAFEAU_ROOT . 'lib/template/header.php'); +require(JIRAFEAU_ROOT . 'lib/template/header.php'); /* Check if user is allowed to upload. */ -if (!jirafeau_challenge_upload_ip ($cfg, get_ip_address($cfg))) -{ +if (!jirafeau_challenge_upload_ip($cfg, get_ip_address($cfg))) { echo '

' . t('Access denied') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } /* Ask password if upload password is set. */ -if (jirafeau_has_upload_password ($cfg)) -{ +if (jirafeau_has_upload_password($cfg)) { session_start(); /* Unlog if asked. */ - if (isset ($_POST['action']) && (strcmp ($_POST['action'], 'logout') == 0)) - session_unset (); + if (isset($_POST['action']) && (strcmp($_POST['action'], 'logout') == 0)) { + session_unset(); + } /* Auth. */ - if (isset ($_POST['upload_password'])) - { - if (jirafeau_challenge_upload_password ($cfg, $_POST['upload_password'])) - { + if (isset($_POST['upload_password'])) { + if (jirafeau_challenge_upload_password($cfg, $_POST['upload_password'])) { $_SESSION['upload_auth'] = true; $_SESSION['user_upload_password'] = $_POST['upload_password']; - } - else - { + } else { $_SESSION['admin_auth'] = false; echo '

' . t('Wrong password.') . '

'; - require (JIRAFEAU_ROOT.'lib/template/footer.php'); + require(JIRAFEAU_ROOT.'lib/template/footer.php'); exit; } } /* Show auth page. */ - if (!isset ($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true) - { - ?> + if (!isset($_SESSION['upload_auth']) || $_SESSION['upload_auth'] != true) { + ?>
0) - { - echo '

' . t ('File size is limited to'); - echo " " . $cfg['maximal_upload_size'] . " MB

"; + if ($cfg['maximal_upload_size'] > 0) { + echo '

' . t('File size is limited to'); + echo " " . $cfg['maximal_upload_size'] . " MB

"; } ?>

+ if (jirafeau_has_upload_password($cfg) && $_SESSION['upload_auth']) { + ?> + + } else { + ?>

+

- +

:

- +

:

@@ -137,7 +132,7 @@ if (jirafeau_has_upload_password ($cfg))

- +

@@ -154,7 +149,7 @@ if (jirafeau_has_upload_password ($cfg))

')"/> + onchange="control_selected_file_size(, '')"/>

@@ -206,59 +201,57 @@ if (jirafeau_has_upload_password ($cfg)) ) ); foreach ($expirationTimeOptions as $expirationTimeOption) { - $selected = ($expirationTimeOption['value'] === $cfg['availability_default'])? 'selected="selected"' : ''; - if(true === $cfg['availabilities'][$expirationTimeOption['value']]) { - echo ''; - } + } } ?>
+ if (jirafeau_has_upload_password($cfg)) { + ?>
@@ -272,7 +265,7 @@ if (jirafeau_has_upload_password ($cfg)) document.getElementById('send').style.display = 'none'; if (!check_html5_file_api ()) document.getElementById('max_file_size').innerHTML = ''; - + diff --git a/install.php b/install.php index fbd3667..9e05b8c 100644 --- a/install.php +++ b/install.php @@ -17,30 +17,28 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/'); +define('JIRAFEAU_ROOT', dirname(__FILE__) . '/'); -define ('JIRAFEAU_CFG', JIRAFEAU_ROOT . 'lib/config.local.php'); -define ('JIRAFEAU_VAR_RAND_LENGTH', 15); +define('JIRAFEAU_CFG', JIRAFEAU_ROOT . 'lib/config.local.php'); +define('JIRAFEAU_VAR_RAND_LENGTH', 15); -require (JIRAFEAU_ROOT . 'lib/settings.php'); -require (JIRAFEAU_ROOT . 'lib/functions.php'); -require (JIRAFEAU_ROOT . 'lib/lang.php'); +require(JIRAFEAU_ROOT . 'lib/settings.php'); +require(JIRAFEAU_ROOT . 'lib/functions.php'); +require(JIRAFEAU_ROOT . 'lib/lang.php'); /** * Prepend used functions **/ -function -jirafeau_quoted ($str) +function jirafeau_quoted($str) { - return QUOTE . str_replace (QUOTE, "\'", $str) . QUOTE; + return QUOTE . str_replace(QUOTE, "\'", $str) . QUOTE; } -function -jirafeau_export_cfg ($cfg) +function jirafeau_export_cfg($cfg) { $content = ' true, + if (!jirafeau_mkdir($path) || !jirafeau_is_writable($path)) { + return array('has_error' => true, 'why' => $mkdir_str1 . '
' . $path . '
' . $solution_str . '
' . $mkdir_str2); + } - foreach (array ('files', 'links', 'async', 'alias') as $subdir) - { + foreach (array('files', 'links', 'async', 'alias') as $subdir) { $subpath = $path.$subdir; - if (!jirafeau_mkdir ($subpath) || !jirafeau_is_writable ($subpath)) - return array ('has_error' => true, + if (!jirafeau_mkdir($subpath) || !jirafeau_is_writable($subpath)) { + return array('has_error' => true, 'why' => $mkdir_str1 . '
' . $subpath . '
' . $solution_str . '
' . $mkdir_str2); + } } - return array ('has_error' => false, 'why' => ''); + return array('has_error' => false, 'why' => ''); } -function -jirafeau_add_ending_slash ($path) +function jirafeau_add_ending_slash($path) { - return $path . ((substr ($path, -1) == '/') ? '' : '/'); + return $path . ((substr($path, -1) == '/') ? '' : '/'); } -function -jirafeau_fatal_error($errorText) +function jirafeau_fatal_error($errorText) { echo '

Error

' . $errorText . '

'; - require (JIRAFEAU_ROOT . 'lib/template/footer.php'); + require(JIRAFEAU_ROOT . 'lib/template/footer.php'); exit; } @@ -121,24 +115,21 @@ jirafeau_fatal_error($errorText) // Is the installation process done already? // Then there is nothing to do here → redirect to the main page. -if ($cfg['installation_done'] === true) -{ - header('Location: index.php'); - exit; +if ($cfg['installation_done'] === true) { + header('Location: index.php'); + exit; } /** * Prepare installation process **/ -require (JIRAFEAU_ROOT . 'lib/template/header.php'); +require(JIRAFEAU_ROOT . 'lib/template/header.php'); // does the local configuration file exist? -if (!file_exists (JIRAFEAU_CFG)) -{ +if (!file_exists(JIRAFEAU_CFG)) { // show an error if it is not possible to create the file - if (!@touch (JIRAFEAU_CFG)) - { + if (!@touch(JIRAFEAU_CFG)) { jirafeau_fatal_error( t('The local configuration file could not be created. Create a ' . 'lib/config.local.php file and give the write ' . @@ -150,8 +141,7 @@ if (!file_exists (JIRAFEAU_CFG)) } // is the local configuration writable? -if (!is_writable (JIRAFEAU_CFG) && !@chmod (JIRAFEAU_CFG, '0666')) -{ +if (!is_writable(JIRAFEAU_CFG) && !@chmod(JIRAFEAU_CFG, '0666')) { jirafeau_fatal_error( t('The local configuration is not writable by the web server. ' . 'Give the write permission to the web server on the ' . @@ -163,48 +153,45 @@ if (!is_writable (JIRAFEAU_CFG) && !@chmod (JIRAFEAU_CFG, '0666')) * Run trough each installation step **/ -if (isset ($_POST['step']) && isset ($_POST['next'])) -{ - switch ($_POST['step']) - { +if (isset($_POST['step']) && isset($_POST['next'])) { + switch ($_POST['step']) { case 1: $cfg['lang'] = $_POST['lang']; - jirafeau_export_cfg ($cfg); + jirafeau_export_cfg($cfg); break; case 2: $cfg['admin_password'] = hash('sha256', $_POST['admin_password']); - jirafeau_export_cfg ($cfg); + jirafeau_export_cfg($cfg); break; case 3: - $cfg['web_root'] = jirafeau_add_ending_slash ($_POST['web_root']); - $cfg['var_root'] = jirafeau_add_ending_slash ($_POST['var_root']); - jirafeau_export_cfg ($cfg); + $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']); + $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']); + jirafeau_export_cfg($cfg); break; case 4: - $cfg['web_root'] = jirafeau_add_ending_slash ($_POST['web_root']); - $cfg['var_root'] = jirafeau_add_ending_slash ($_POST['var_root']); - jirafeau_export_cfg ($cfg); + $cfg['web_root'] = jirafeau_add_ending_slash($_POST['web_root']); + $cfg['var_root'] = jirafeau_add_ending_slash($_POST['var_root']); + jirafeau_export_cfg($cfg); break; } - } $current = 1; -if (isset ($_POST['next'])) +if (isset($_POST['next'])) { $current = $_POST['step'] + 1; -else if (isset ($_POST['previous'])) +} elseif (isset($_POST['previous'])) { $current = $_POST['step'] - 1; -else if (isset ($_POST['retry'])) +} elseif (isset($_POST['retry'])) { $current = $_POST['step']; +} -switch ($current) -{ +switch ($current) { case 1: default: - ?>