<commit_before><?php
/********************************************************************************
*                                                                               *
*   Copyright 2012 <NAME> (<EMAIL>)                      *
*   http://www.elabftw.net/                                                     *
*                                                                               *
********************************************************************************/

/********************************************************************************
*  This file is part of eLabFTW.                                                *
*                                                                               *
*    eLabFTW is free software: you can redistribute it and/or modify            *
*    it under the terms of the GNU Affero General Public License as             *
*    published by the Free Software Foundation, either version 3 of             *
*    the License, or (at your option) any later version.                        *
*                                                                               *
*    eLabFTW is distributed in the hope that it will be useful,                 *
*    but WITHOUT ANY WARRANTY; without even the implied                         *
*    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                    *
*    PURPOSE.  See the GNU Affero General Public License for more details.      *
*                                                                               *
*    You should have received a copy of the GNU Affero General Public           *
*    License along with eLabFTW.  If not, see <http://www.gnu.org/licenses/>.   *
*                                                                               *
********************************************************************************/
// where are we, on experiments or items (database) page ?
if (strpos($_SERVER['SCRIPT_FILENAME'], 'experiments')) {
    $type = 'experiments';
} else {
    $type = 'items';
}
?>
<section class='box'>
    <!-- FILE UPLOAD BLOCK -->
    <script src="js/dropzone/dist/min/dropzone.min.js"></script>
    <link rel="stylesheet" media="all" href="js/dropzone/dist/dropzone.css" />
    <!-- fix some css here -->
    <style>
    .dropzone {
        border: 1px solid #fff;
    }
    .dropzone:hover {
        border: 1px solid #29AEB9;
        border-radius: 5px;
    }
    </style>
    <img src='img/attached.png' class='bot5px'> <h3 style='display:inline'><?php echo _('Attach a file'); ?></h3>
    <!-- additionnal parameters are added as GET params -->
    <form action="app/upload.php?item_id=<?php echo $id; ?>&type=<?php echo $type; ?>"
        method="post"
        enctype="multipart/form-data"
        class="dropzone"
        id='elabftw-dropzone'>
    </form>
</section>
<script>
// we need this to reload the #filesdiv (div displaying uploaded files)
var type = '<?php echo $type; ?>';
if (type == 'items') {
    type = 'database';
}
var item_id = '<?php echo $id; ?>';

// config for dropzone, id is camelCased.
Dropzone.options.elabftwDropzone = {
    // i18n message to user
    dictDefaultMessage: '<?php echo _('Drop files here to upload'); ?>',
    maxFilesize: 2, // MB
    init: function() {
        this.on("complete", function() {
            // reload the #filesdiv once the file is uploaded
            if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
                $("#filesdiv").load(type + '.php?mode=edit&id=' + item_id + ' #filesdiv', function() {
                    // make the comment zone editable (fix issue #54)
                    $('.thumbnail p.editable').editable('app/editinplace.php', {
                     tooltip : 'Click to edit',
                     indicator : 'Saving...',
                     id   : 'id',
                     name : 'filecomment',
                     submit : 'Save',
                     cancel : 'Cancel',
                     style : 'display:inline'
                    });
                });
            }
        });
    }
};
</script><commit_msg>Resolved issue where the file upload was forced to 2mb instead of pulling from the php ini settings<commit_after><?php
/********************************************************************************
*                                                                               *
*   Copyright 2012 <NAME> (<EMAIL>)                      *
*   http://www.elabftw.net/                                                     *
*                                                                               *
********************************************************************************/

/********************************************************************************
*  This file is part of eLabFTW.                                                *
*                                                                               *
*    eLabFTW is free software: you can redistribute it and/or modify            *
*    it under the terms of the GNU Affero General Public License as             *
*    published by the Free Software Foundation, either version 3 of             *
*    the License, or (at your option) any later version.                        *
*                                                                               *
*    eLabFTW is distributed in the hope that it will be useful,                 *
*    but WITHOUT ANY WARRANTY; without even the implied                         *
*    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                    *
*    PURPOSE.  See the GNU Affero General Public License for more details.      *
*                                                                               *
*    You should have received a copy of the GNU Affero General Public           *
*    License along with eLabFTW.  If not, see <http://www.gnu.org/licenses/>.   *
*                                                                               *
********************************************************************************/
// where are we, on experiments or items (database) page ?
if (strpos($_SERVER['SCRIPT_FILENAME'], 'experiments')) {
    $type = 'experiments';
} else {
    $type = 'items';
}

// Converts the php.ini upload size setting to a numeric value in MB
// Returns 2 if no value is found (utilizing the default setting that was in there previously)
function returnMaxUploadSize() {    
    $val = trim($ini_get('upload_max_filesize'));
    
    if (!isset($val)) {
      return 2;
    }
    
    $last = strtolower($val[strlen($val)-1]);
    
    switch($last) {
        case 'g':
            $val *= 1000;
        case 'k':
            $val /= 1024;
    }

    return $val;
}

?>
<section class='box'>
    <!-- FILE UPLOAD BLOCK -->
    <script src="js/dropzone/dist/min/dropzone.min.js"></script>
    <link rel="stylesheet" media="all" href="js/dropzone/dist/dropzone.css" />
    <!-- fix some css here -->
    <style>
    .dropzone {
        border: 1px solid #fff;
    }
    .dropzone:hover {
        border: 1px solid #29AEB9;
        border-radius: 5px;
    }
    </style>
    <img src='img/attached.png' class='bot5px'> <h3 style='display:inline'><?php echo _('Attach a file'); ?></h3>
    <!-- additionnal parameters are added as GET params -->
    <form action="app/upload.php?item_id=<?php echo $id; ?>&type=<?php echo $type; ?>"
        method="post"
        enctype="multipart/form-data"
        class="dropzone"
        id='elabftw-dropzone'>
    </form>
</section>
<script>
// we need this to reload the #filesdiv (div displaying uploaded files)
var type = '<?php echo $type; ?>';
if (type == 'items') {
    type = 'database';
}
var item_id = '<?php echo $id; ?>';

// config for dropzone, id is camelCased.
Dropzone.options.elabftwDropzone = {
    // i18n message to user
    dictDefaultMessage: '<?php echo _('Drop files here to upload'); ?>',
    maxFilesize: '<?php returnMaxUploadSize(); ?>', // MB
    init: function() {
        this.on("complete", function() {
            // reload the #filesdiv once the file is uploaded
            if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
                $("#filesdiv").load(type + '.php?mode=edit&id=' + item_id + ' #filesdiv', function() {
                    // make the comment zone editable (fix issue #54)
                    $('.thumbnail p.editable').editable('app/editinplace.php', {
                     tooltip : 'Click to edit',
                     indicator : 'Saving...',
                     id   : 'id',
                     name : 'filecomment',
                     submit : 'Save',
                     cancel : 'Cancel',
                     style : 'display:inline'
                    });
                });
            }
        });
    }
};
</script>
{'fraction_non_alphanumeric': 0.18312710911136107, 'fraction_numerical': 0.005961754780652418, 'mean_word_length': 1.5087471783295712, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7616842', 'n_tokens_mistral': 2200, 'n_tokens_neox': 2089, 'n_words': 636}