return $code;
}
+function is_ssl() {
+ if ( isset($_SERVER['HTTPS']) ) {
+ if ( 'on' == strtolower($_SERVER['HTTPS']) )
+ return true;
+ if ( '1' == $_SERVER['HTTPS'] )
+ return true;
+ } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
+ return true;
+ }
+ return false;
+}
+
function
jirafeau_human_size ($octets)
{
function
jirafeau_upload ($file, $one_time_download, $key, $time, $ip, $crypt, $link_name_length)
{
- if (!is_int ($link_name_length))
- $link_name_length = 8;
if (empty ($file['tmp_name']) || !is_uploaded_file ($file['tmp_name']))
{
return (array(
'link' =>'',
'delete_link' => ''));
}
- return (array ('error' => $noerr,
- 'link' => $md5_link,
- 'delete_link' => $delete_link_code,
- 'crypt_key' => $crypt_key));
+ return (array ('error' => $noerr,
+ 'link' => $md5_link,
+ 'delete_link' => $delete_link_code,
+ 'crypt_key' => $crypt_key));
}
/**
}
}
-function check_errors ()
+function check_errors ($cfg)
{
if (file_exists (JIRAFEAU_ROOT . 'install.php')
- && !file_exists (JIRAFEAU_ROOT . 'lib/config.local.php'))
+ && !($cfg['installation_done'] === true))
{
header('Location: install.php');
exit;
if (!is_writable (VAR_BLOCK))
add_error (t('The block directory is not writable!'), VAR_BLOCK);
-
- /* Check if the install.php script is still in the directory. */
- if (file_exists (JIRAFEAU_ROOT . 'install.php'))
- add_error (t('Installer script still present'),
- t('Please make sure to delete the installer script ' .
- '"install.php" before continuing.'));
}
/**
$out['link_code'] = trim ($c[9]);
if (trim ($c[10]) == 'C')
$out['crypted'] = true;
+ else
+ $out['crypted'] = false;
return $out;
}
function
jirafeau_async_end ($ref, $code, $crypt, $link_name_length)
{
- if (!is_int ($link_name_length))
- $link_name_length = 8;
/* Get async infos. */
$a = jirafeau_get_async_ref ($ref);
if (count ($a) == 0
$crypt_key = '';
if ($crypt == true && extension_loaded('mcrypt'))
{
- $cypt_key = jirafeau_encrypt_file ($p, $p);
+ $crypt_key = jirafeau_encrypt_file ($p, $p);
if (strlen($crypt_key) > 0)
$crypted = true;
}
return true;
}
-?>
+/**
+ * Check if Jirafeau is password protected for visitors.
+ * @return true if Jirafeau is password protected, false otherwise.
+ */
+function jirafeau_has_upload_password ($cfg)
+{
+ return count ($cfg['upload_password']) > 0;
+}
+
+/**
+ * Challenge password for a visitor.
+ * @param $password password to be challenged
+ * @return true if password is valid, false otherwise.
+ */
+function jirafeau_challenge_upload_password ($cfg, $password)
+{
+ if (!jirafeau_has_upload_password($cfg))
+ return false;
+ forEach ($cfg['upload_password'] as $p)
+ if ($password == $p)
+ return true;
+ error_log("password not found $password");
+ return false;
+}
+