X-Git-Url: https://git.p6c8.net/jirafeau_project.git/blobdiff_plain/ba6f06965a4d9846e23d99a0e9f74b1361c18c40..cbef2b93dfeb51484956c960d58af8c4557c25f5:/lib/functions.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)) {