From: Jerome Jutteau Date: Wed, 5 Dec 2012 17:40:32 +0000 (+0000) Subject: Add uploader's ip in link file X-Git-Tag: 1.0~32 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/cbef2b93dfeb51484956c960d58af8c4557c25f5?hp=ba6f06965a4d9846e23d99a0e9f74b1361c18c40 Add uploader's ip in link file --- diff --git a/index.php b/index.php index af1efb4..7ee8ea2 100644 --- a/index.php +++ b/index.php @@ -55,7 +55,7 @@ if($writable && isset($_POST['jirafeau'])) { break; } - $res = jirafeau_upload($_FILES['file'], isset($_POST['one_time_download']), $key, $time, $cfg); + $res = jirafeau_upload($_FILES['file'], isset($_POST['one_time_download']), $key, $time, $cfg, $_SERVER['REMOTE_ADDR']); } require(JIRAFEAU_ROOT . 'lib/template/header.php'); diff --git a/lib/functions.php b/lib/functions.php index cb2226a..48bdefd 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -111,11 +111,12 @@ function jirafeau_upload_errstr($code) { * @param $key if not empty, protect the file with this key * @param $time the time of validity of the file * @param $cfg the current configuration + * @param $ip uploader's ip * @returns an array containing some information * 'error' => information on possible errors * 'link' => the link name of the uploaded file */ -function jirafeau_upload($file, $one_time_download, $key, $time, $cfg) { +function jirafeau_upload($file, $one_time_download, $key, $time, $cfg, $ip) { if(empty($file['tmp_name']) || !is_uploaded_file($file['tmp_name'])) { return(array('error' => array('has_error' => true, 'why' => jirafeau_upload_errstr($file['error'])), 'link' => '')); } @@ -161,7 +162,7 @@ function jirafeau_upload($file, $one_time_download, $key, $time, $cfg) { /* create link file */ $link_tmp_name = VAR_LINKS . $md5 . rand(0, 10000) . '.tmp'; $handle = fopen($link_tmp_name, 'w'); - fwrite($handle, $name . NL . $mime_type . NL . $size . NL . $key . NL . $time . NL . $md5 . NL . ($one_time_download ? 'O' : 'R') . NL . date('U') . NL); + fwrite($handle, $name . NL . $mime_type . NL . $size . NL . $key . NL . $time . NL . $md5 . NL . ($one_time_download ? 'O' : 'R') . NL . date('U') . NL . $ip . NL); fclose($handle); $md5_link = md5_file($link_tmp_name); if(!rename($link_tmp_name, VAR_LINKS . $md5_link)) {