Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2010-11-23 12:08:09

bgiddins
Member
Registered: 2008-08-17
Posts: 54

Uploadile?

Saw this new mod today - but no discussion? Can't read French so the fluxbb.fr links are a bit useless for me - are there screenshots anywhere?

Been using http://www.punres.net/desc.php?pid=362 on a FluxBB 1.2 board, updating to 1.4 and seeing if there's improvements available.

Offline

#2 2010-11-23 13:05:36

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

Here is a translation,

I recently finished adapting plugile Uploadile who can manage file attachments in posts or in their profile.

Changelog 1.2 / 1.3 :

    - Code cleanup to make it compatible XHTML 1.0 strict
    - Added ability to attach images directly when writing a message
    - Fixed a bug preventing the generation of thumbnail images when upload from Internet explorer
    - Fixed percentage display
    - Using the file_size function to manage the display of image sizes
    - Correction of many translation errors (Thanks to the developer team, I had not changed the original translations)
    - Remove all text "raw" in the code
    - And many other changes...

Download : http://fluxbb.org/resources/mods/upload … eases/1.3/

I'll try to make screenshots as soon as possible...

EDIT :
postuploaduploadile.th.pngfilemanageruploadile.th.pngprofileuploadile.th.png

Last edited by bagu (2010-11-23 13:41:53)

Offline

#3 2010-12-08 17:42:46

Plazzmex
Member
Registered: 2008-07-24
Posts: 85

Re: Uploadile?

What is plugile that is required for installation of this one and where am I finding it ?

Offline

#4 2010-12-08 18:10:31

adaur
Developer
From: France
Registered: 2010-01-07
Posts: 843
Website

Re: Uploadile?

Hi

Plugile is available here: http://fluxbb.fr/mods/mods.php?mid=75

There is no 1.4 version, but this one should work (Télécharger = Download)


FeatherBB - A simple and lightweight new generation forum system
Based on FluxBB, written in PHP, using Slim Framework for a proper OOP-MVC architecture.

Offline

#5 2010-12-08 18:49:00

Plazzmex
Member
Registered: 2008-07-24
Posts: 85

Re: Uploadile?

shows an error:

Parse error: parse error in fluxbb\profile.php on line 1755

line 1755:

elseif(!isset($section) AND isset($_GET['plugin']))

Offline

#6 2010-12-08 19:08:12

adaur
Developer
From: France
Registered: 2010-01-07
Posts: 843
Website

Re: Uploadile?

It seems strange.

Could you paste your whole file on http://pastebin.com/ ?


FeatherBB - A simple and lightweight new generation forum system
Based on FluxBB, written in PHP, using Slim Framework for a proper OOP-MVC architecture.

Offline

#7 2010-12-09 23:01:25

Plazzmex
Member
Registered: 2008-07-24
Posts: 85

Re: Uploadile?

Offline

#8 2010-12-10 14:18:38

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

    else
        message($lang_common['Bad request']);

should be after

    elseif(!isset($section) AND isset($_GET['plugin']))
    {
        define('PUN_ACTIVE_PAGE', 'profile');
        // The plugile to load should be supplied via GET
        $plugile = isset($_GET['plugin']) ? $_GET['plugin'] : '';
        if (!preg_match('/^UP?P_(\w*?)\.php$/i', $plugile))
                    message($lang_common['Bad request']);

        $prefix = substr($plugile, 0, strpos($plugile, '_'));
        $suffix = substr($plugile, strlen($plugile) - 4);
        // UP <=> User Plugile (visible par tous) - UPP <=> User Private Plugile (visible par le membre et les administrateurs)
        if ($suffix == '.php' && ($prefix == 'UP' || $prefix == 'UPP'))
            $plugiles[] = array(substr(substr($plugile, strpos($plugile, '_') + 1), 0, -4), $plugile);

        // Make sure the file actually exists
        if (!file_exists(PUN_ROOT.'plugiles/'.$plugile))
                    message('There is no plugile \''.$plugile.'\' in /plugile.');

        // Construct REQUEST_URI if it isn't set
        if (!isset($_SERVER['REQUEST_URI']))
            $_SERVER['REQUEST_URI'] = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '').'?'.(isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');

        $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Profile'], str_replace('_', ' ', $plugiles[0][0]));
        require PUN_ROOT.'header.php';
        
        // Attempt to load the plugile. We don't use @ here to supress error messages,
        // because if we did and a parse error occurred in the plugile, we would only
        // get the "blank page of death".
        include PUN_ROOT.'plugiles/'.$plugile;
        if (!defined('PUN_PLUGIN_LOADED'))
            message('Error while loading \''.$plugile.'\' plugile.');
    }

And not before.

note : i have done a small correction in $page_title definition to make it compatible with v1.4.x

I think i will try to make a compatible version of plugile and submit it here...It should be easier.

Last edited by bagu (2010-12-10 14:22:50)

Offline

#9 2010-12-10 16:29:41

Plazzmex
Member
Registered: 2008-07-24
Posts: 85

Re: Uploadile?

No.. After all I decided not to use this mod.
Because I just need a simple attachments mod and not something monster like this.

Offline

#10 2010-12-11 12:24:01

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

Monster ?
I think an attachement mod is more intrusive than this....But, if you find something better for you, it's good wink

Offline

#11 2010-12-12 00:12:04

Plazzmex
Member
Registered: 2008-07-24
Posts: 85

Re: Uploadile?

No, Actually there isn't available real attachment mod.
So I'll have wait till someone will create a simple one, or will fully adapt plugile and uploadile to work with the latest ENGLISH fluxbb..

Offline

#12 2010-12-12 01:15:38

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

Uploadile is fully compatible with the latest fluxbb. (English and french)

For plugile, as i said, i will try to adapt and translate it as soon as possible.

Last edited by bagu (2010-12-12 01:18:54)

Offline

#13 2011-01-27 09:15:12

fabek
Member
Registered: 2011-01-26
Posts: 17

Re: Uploadile?

bagu wrote:

Uploadile is fully compatible with the latest fluxbb. (English and french)

For plugile, as i said, i will try to adapt and translate it as soon as possible.

hey mate,

how goes the work on plugile and uploadile?

is there way to install uploadile without plugile? because it doesn't work for me with new fluxbb.

can't find that in profile.php (fluxbb 1.4.3) to install plugile!

#
#---------[ 7. FIND ]-----------------------------------
#

            <div class="inform">
                <fieldset>
                <legend><?php echo $lang_profile['User activity'] ?></legend>
                    <div class="infldset">
                        <dl>
<?php if ($posts_field != ''): ?>                            <dt><?php echo $lang_common['Posts'] ?>: </dt>
                            <dd><?php echo $posts_field ?></dd>
<?php endif; ?>                            <dt><?php echo $lang_common['Last post'] ?>: </dt>
                            <dd><?php echo $last_post ?></dd>
                            <dt><?php echo $lang_common['Registered'] ?>: </dt>
                            <dd><?php echo format_time($user['registered'], true) ?></dd>
                        </dl>
                        <div class="clearer"></div>
                    </div>
                </fieldset>
            </div>

Last edited by fabek (2011-01-27 09:39:13)


coder/reverser/programmer (asm, c++, php, etc.)

Offline

#14 2011-01-27 12:30:19

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

I'm on the work to adapt plugile...
I have made a git space here to work on it : https://github.com/Bagu/Plugile

Any help will be welcome.

(Actually, it work, but i think there must have some rewrite to get translated error messages)

Offline

#15 2011-01-30 18:39:02

fabek
Member
Registered: 2011-01-26
Posts: 17

Re: Uploadile?

Ok, Plugile works without last modification in a profile.php :-)

bagu, maybe do you want polish translation for Uploadile?

I have also an idea. After file is uploaded, I click "Insert" then Uploadile generates link to a file. How to get filename by default inside [ url ] tags instead "Your text here"?


coder/reverser/programmer (asm, c++, php, etc.)

Offline

#16 2011-01-30 20:42:29

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

Ok, Plugile works without last modification in a profile.php :-)

Witch ?

bagu, maybe do you want polish translation for Uploadile?

Yes, of course.

I have also an idea. After file is uploaded, I click "Insert" then Uploadile generates link to a file. How to get filename by default inside [ url ] tags instead "Your text here"?

I don't understand what you want...Maybe a screenshot ?

Offline

#17 2011-01-30 22:22:14

fabek
Member
Registered: 2011-01-26
Posts: 17

Re: Uploadile?

I don't understand what you want...Maybe a screenshot ?

screennt.jpg

Now do you understand bro?


coder/reverser/programmer (asm, c++, php, etc.)

Offline

#18 2011-01-31 10:05:04

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

ok, it's done by javascript and i don't know how to do this in javascript...
So i need some help.

Ok, Plugile works without last modification in a profile.php :-)

Witch ?

Last edited by bagu (2011-01-31 10:05:27)

Offline

#19 2011-01-31 10:17:18

fabek
Member
Registered: 2011-01-26
Posts: 17

Re: Uploadile?

bagu wrote:

ok, it's done by javascript and i don't know how to do this in javascript...
So i need some help.

function image(url, mini_url)
...
...
...
input.value += insText + '[url=' + url + ']<?php echo $lang_uploadile['texte']; ?>[/url]';

what mini_url and url contains?

Witch ?

thiz one.

#
#---------[ 7. FIND ]-----------------------------------
#

            <div class="inform">
                <fieldset>
                <legend><?php echo $lang_profile['User activity'] ?></legend>
                    <div class="infldset">
                        <dl>
<?php if ($posts_field != ''): ?>                            <dt><?php echo $lang_common['Posts'] ?>: </dt>
                            <dd><?php echo $posts_field ?></dd>
<?php endif; ?>                            <dt><?php echo $lang_common['Last post'] ?>: </dt>
                            <dd><?php echo $last_post ?></dd>
                            <dt><?php echo $lang_common['Registered'] ?>: </dt>
                            <dd><?php echo format_time($user['registered'], true) ?></dd>
                        </dl>
                        <div class="clearer"></div>
                    </div>
                </fieldset>
            </div>

coder/reverser/programmer (asm, c++, php, etc.)

Offline

#20 2011-02-01 11:58:23

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

url contain the relative url of the file, mini url is for image preview.

For the profile modification, try this : https://github.com/Bagu/Plugile/blob/master/read_me.txt

But there is some work to do to pass fluxbb.org validation (hard because it's not my code in origin)

Offline

#21 2011-02-01 18:10:00

fabek
Member
Registered: 2011-01-26
Posts: 17

Re: Uploadile?

bagu wrote:

For the profile modification, try this : https://github.com/Bagu/Plugile/blob/master/read_me.txt

thanks! works now.


coder/reverser/programmer (asm, c++, php, etc.)

Offline

#22 2011-02-06 00:39:58

fabek
Member
Registered: 2011-01-26
Posts: 17

Re: Uploadile?

hello bagu, how your work is going?


coder/reverser/programmer (asm, c++, php, etc.)

Offline

#23 2011-02-06 17:30:30

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 1,518
Website

Re: Uploadile?

I change this updating for myself tongue
Current variant of file gestionnaire.php:

<?php

/**
 * Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
 * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 */

define('PUN_HELP', 1);

define('PUN_ROOT', dirname(__FILE__).'/');
require PUN_ROOT.'include/common.php';

if ($pun_user['g_read_board'] == '0' || $pun_user['is_guest'])
    message($lang_common['No view']);

// Load language file
if (file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/uploadile.php'))
    require PUN_ROOT.'lang/'.$pun_user['language'].'/uploadile.php';
else
    require PUN_ROOT.'lang/English/uploadile.php';

$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']),$lang_uploadile['popup_title']);
define('PUN_ACTIVE_PAGE', 'upfiles');
require PUN_ROOT.'header.php';

define('PLUGIN_URL', 'gestionnaire.php');
$boucle_id = 1;
$tabindex = 0;

?>
<script type="text/javascript">
/* <![CDATA[ */
function image(url, mini_url)
{
    url = '<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>' + url;
    if ( (new String(mini_url)).length > 0)
        mini_url = '<?php echo pun_htmlspecialchars(get_base_url(true).'/') ?>' + mini_url;
    var input = window.opener.document.getElementsByName("req_message").item(0);
    input.focus();

    if(typeof document.selection != 'undefined')/* --- Pour IE --- */
    {
        var range = document.selection.createRange();
        var insText = range.text;
        if(mini_url == url)
        {
            input.value += insText + '[img]' + url + '[/img]';
            if (url.length == 0)
            {
                range.move('character', -6);
            }
        }
        else if(mini_url != '' && mini_url != url)
        {
            input.value += insText + '[url=' + url + '][img]' + mini_url + '[/img][/url]';
            if (mini_url.length == 0 && url.length == 0)
            {
                range.move('character', -18);
            }
            else if (mini_url.length == 0 && url.length != 0)
            {
                range.move('character', -18  + url.length);
            }
            else if (mini_url.length != 0 && url.length == 0)
            {
                range.move('character', -17);
            }
        }
        else
        {
            input.value += insText + '[url=' + url + ']<?php echo $lang_uploadile['texte']; ?>[/url]';
            if (url.length == 0)
            {
                range.movestart('character', 5);
            }
            else
            {
                range.movestart('character', 5 + url.length + 1);
            }
        }
        range.select();
    }            
    else if(typeof input.selectionStart != 'undefined') /* --- Navigateurs récents (FF) --- */
    {
        var start = input.selectionStart;
        var end = input.selectionEnd;
        var selText = input.value.substring(start, end);
        var pos;
        
        if(mini_url == url)
        {        
            input.value = input.value.substr(0, start) + selText + '[img]' + url + '[/img]' + input.value.substr(end);
            if (url.length == 0)
            {
                pos = start + 5;
            }
            else
            {
                pos = start + 5 + url.length + 6;
            }
        }
        else if(mini_url != '' && mini_url != url)
        {
            input.value = input.value.substr(0, start) + selText + '[url=' + url + '][img]' + mini_url + '[/img][/url]' + input.value.substr(end);
            if (mini_url.length == 0 && url.length == 0)
            {
                pos = start + 5;
            }
            else if (mini_url.length == 0 && url.length != 0)
            {
                pos = start + 5;
            }
            else if (mini_url.length != 0 && url.length == 0)
            {
                pos = start + 5 + mini_url.length + 6;
            }
            else
            {
                pos = start + 5 + mini_url.length + 6 + url.length + 12;
            }
        }
        else
        {
            input.value = input.value.substr(0, start) + selText + '[url=' + url + ']<?php echo $lang_uploadile['texte']; ?>[/url]' + input.value.substr(end);
            if (url.length == 0)
            {
                pos = start + 5;
            }
            else
            {
                pos = start + 5 + url.length + 1;
            }
        }

        input.selectionStart = pos;
        input.selectionEnd = pos;
    }
    else /* --- Autres navigateurs --- */
    {
        var pos;
        var re = new RegExp('^[0-9]{0,3}$');
        while(!re.test(pos))
        {
            pos = prompt("insertion (0.." + input.value.length + "):", "0");
        }
        if(pos > input.value.length)
        {
            pos = input.value.length;
        }
        var insText = prompt("<?php echo $lang_uploadile['texte']; ?>");
        input.value = input.value.substr(0, pos) + insText + '[img]' + url + '[/img]' + input.value.substr(pos);
    }
}
/* ]]> */
</script>
<?php

require PUN_ROOT.'include/parser.php';

// #######################################################################################################
// This function doesn't work in UTF-8 :P
function parse_file($file_name) 
{
    $file_name = preg_replace('![_@=\' ]!i', '-', $file_name);
    $file_name = preg_replace('![&\$ \?\!\.,;:\*\+\/\\\^\(\)%"~\[\]\{\}]!i', '', $file_name);
    $file_name = preg_replace('!([àâä])!i', 'a', $file_name);
    $file_name = preg_replace('!([éèêë])!i', 'e', $file_name);
    $file_name = preg_replace('!([îï])!i', 'i', $file_name);
    $file_name = preg_replace('!([ôö])!i', 'o', $file_name);
    $file_name = preg_replace('!([ùüû])!i', 'u', $file_name);
    $file_name = preg_replace('!ÿ!i', 'y', $file_name);
    $file_name = preg_replace('!ç!i', 'c', $file_name);
    return $file_name;
}

if($pun_user['g_id'] == PUN_ADMIN)
{
    $limit = '100000000000';
    $maxsize = '100000000000';
}
elseif($pun_user['g_moderator'] == 1)
{
    $limit = $pun_config['o_uploadile_limit_modo'];
    $maxsize = $pun_config['o_uploadile_maxsize_modo'];
}
else
{
    $limit = $pun_config['o_uploadile_limit_member'];
    $maxsize = $pun_config['o_uploadile_maxsize_member'];
}
$pourcentage_utilise = ceil(($pun_user['upload']*100)/$limit);

// Suppression des fichiers
if(isset($_POST['supprimer']) AND $_POST['supprimer'] != NULL)
{
    $dir = 'img/members/'.$pun_user['id'].'/';
    $erreur = 0;
    $upload = 0;
    if(is_dir($dir)) // On vérifie que la valeur est un fichier (pour écarter les sous dossiers)
    {
        // On supprime les images
        for($u = 1 ; $u <= $_POST['boucle_id'] ; $u++)
        {
            if(isset($_POST['supprimer_'.$u]) AND is_file($dir.$_POST['supprimer_'.$u]))
            {
                $delete = unlink($dir.$_POST['supprimer_'.$u]);
                if($pun_config['o_uploadile_thumb'] == '1')
                    @unlink($dir.'mini_'.$_POST['supprimer_'.$u]);
                if($delete == false)
                    $erreur++;
            }
        }

        // On cherche la taille du dossier du membre 
        $open = opendir($dir); // On ouvre le répertoire
        while(false !== ($file = readdir($open))) // Tant qu'il y a des fichiers à lire
        {
            if(is_file($dir.$file)) // On vérifie que la valeur est un fichier (pour écarter les sous dossiers)
            {
                $extension = strtolower(substr(strrchr($file,  "." ), 1)); // On prend l'extension du fichier dans la variable $extension avec une sous-chaine
                $extsupport = explode(',', $pun_config['o_uploadile_laws'].','.strtoupper($pun_config['o_uploadile_laws'])); // La liste des extensions possibles pour une image
                if(in_array($extension, $extsupport) and ($file[0] != "#")) // Si l'extension ne figure pas dans la liste on passe le fichier (A noter: Pour cacher une image placez un "#" devant son nom)
                    $files[] = $dir.$file; // Si elle y figure on ajoute le fichier à l'array $files
            }
        }
        closedir($open); // Et enfin on ferme le dossier
        if(isset($files))
        {
            foreach($files as $image)
                $upload = $upload + filesize($image);
        }
        $db->query('UPDATE '.$db->prefix.'users SET upload=\''.$upload.'\' WHERE id='.$pun_user['id']) or error(sprintf($lang_uploadile['err_insert'],$conf_name), __FILE__, __LINE__, $db->error());
    }

    if($erreur == 0)
        redirect(PLUGIN_URL, $lang_uploadile['delete_success']);
    else
        redirect(PLUGIN_URL, $lang_uploadile['err_delete']);
}

elseif(isset($_FILES['fichier']) AND $_FILES['fichier'] != NULL AND $_FILES['fichier']['error'] == 0)
{
    // On vérifie les extensions
    $extension_multiple = explode('.', $_FILES['fichier']['name']); 
    if(count($extension_multiple) == '2') // Pour empêcher les extensions du type exemple.php.jpg
    {
        $extensions_valides = explode(',', $pun_config['o_uploadile_laws'].','.strtoupper($pun_config['o_uploadile_laws']));
        $extension_upload = substr(strrchr($_FILES['fichier']['name'], '.'), 1);
        if(in_array($extension_upload,$extensions_valides))
        {
            // On vérifie la taille maximale
            if($_FILES['fichier']['size'] <= $maxsize)
            {
                // On vérifie l'espace alloué
                if($_FILES['fichier']['size']+$pun_user['upload'] <= $limit)
                {
                    $upload = $pun_user['upload']+$_FILES['fichier']['size'];
                    $fichier = explode('.', $_FILES['fichier']['name']);
                    $fichier = parse_file($fichier[0]).'.'.$fichier[1];
                    $fichier_name_temp = $_FILES['fichier']['tmp_name'];
                    $dir = 'img/members/'.$pun_user['id'].'/';
                    if(is_file($dir.$fichier))
                        $fichier = date('dmY\-Hi', time()).'_'.$fichier;

                    if(!is_dir('img/members/'))
                        mkdir('img/members', 0755);
                    if(!is_dir($dir))
                        mkdir('img/members/'.$pun_user['id'], 0755);
                    move_uploaded_file($fichier_name_temp,$dir.$fichier);

                    // Miniaturisation des images si demandées
                    if($pun_config['o_uploadile_thumb'] == '1') //  On vérifie que la miniaturisation est activée.
                    {
                        $hauteur_destination = $pun_config['o_uploadile_thumb_size'];
                        $type = $_FILES['fichier']['type'];
                        switch ($type)
                        {
                            case 'image/pjpeg':
                            case 'image/jpeg':
                                $image = imagecreatefromjpeg($dir.$fichier);
                                $type = 'image/jpeg';
                                break;
                            case 'image/x-png':
                            case 'image/png':
                                $image = imagecreatefrompng($dir.$fichier);
                                $type = 'image/png';
                                break;
                            case 'image/gif':
                                $image = imagecreatefromgif($dir.$fichier);
                                break;
                        }
                        if($type == 'image/png' OR $type == 'image/jpeg' OR $type == 'image/gif')
                        {
                            $largeur = imagesx($image);
                            $hauteur = imagesy($image);
                            if($hauteur >= $hauteur_destination)
                            {
                                $pourcentage = $hauteur_destination/$hauteur;
                                $largeur_destination = $largeur*$pourcentage;
                                $destination = imagecreatetruecolor($largeur_destination, $hauteur_destination);
                                imagecopyresampled($destination, $image, 0, 0, 0, 0, $largeur_destination, $hauteur_destination, $largeur, $hauteur);
                                imagepng($destination, $dir.'mini_'.$fichier);
                            }
                            else
                                imagepng($image, $dir.'mini_'.$fichier);
                            if(isset($image))
                                imagedestroy($image);
                            if(isset($destination))
                                imagedestroy($destination);
                        }
                    }
                    $db->query('UPDATE '.$db->prefix.'users SET upload=\''.$upload.'\' WHERE id='.$pun_user['id']) or error(sprintf($lang_uploadile['err_insert'],$conf_name), __FILE__, __LINE__, $db->error());
                    redirect(PLUGIN_URL, $lang_uploadile['modif_success']);
                }
                else
                    redirect(PLUGIN_URL, $lang_uploadile['err_espace']);
            }
            else
                redirect(PLUGIN_URL, $lang_uploadile['err_size']);
        }
        else
            redirect(PLUGIN_URL, $lang_uploadile['err_extension']);
    }
    else
    {
        if(count($extension_multiple) == '0')
            redirect(PLUGIN_URL, $lang_uploadile['err_noExtension']);
        else
            redirect(PLUGIN_URL, $lang_uploadile['err_extension_multiple']);
    }
}

// S'il y a une erreur
elseif(isset($_FILES['fichier']) AND $_FILES['fichier'] != NULL AND !isset($_POST['formerFichierName']) AND $_FILES['fichier']['error'] != 0)
{
    if($_FILES['fichier']['error'] == '1')
        $s_erreur = $_FILES['fichier']['name'].': '.$lang_uploadile['err_size'].' ( '.get_cfg_var('upload_max_filesize').' )';
    if($_FILES['fichier']['error'] == '2')
        $s_erreur = $lang_uploadile['err_size'];
    if($_FILES['fichier']['error'] == '3')
        $s_erreur = $lang_uploadile['err_4'];
    if($_FILES['fichier']['error'] == '4')
        $s_erreur = $lang_uploadile['err_1'];
    else
        $s_erreur = $lang_uploadile['err_4'];
    redirect(PLUGIN_URL, $s_erreur);
}

// #######################################################################################################

?>
    <div id="uploadile" class="blockform">
        <h2 class="block2"><span><?php echo $lang_uploadile['titre_2']; ?></span></h2>
        <div class="box">
            <form method="post" action="<?php echo PLUGIN_URL ?>" enctype="multipart/form-data">
                <div class="inform">
                    <fieldset>
                        <legend><?php echo $lang_uploadile['legend']; ?></legend>
                        <div class="infldset">
                            <label for="fichier"><?php echo $lang_uploadile['fichier']; ?></label> <input type="file" id="fichier" name="fichier" tabindex="<?php echo $tabindex++; ?>" />
                            <p>
                                <?php
                                if($pun_user['g_id'] == '1')
                                    printf($lang_uploadile['info_2_admi'],str_replace(',', ', ', $pun_config['o_uploadile_laws']));
                                else
                                    printf($lang_uploadile['info_2'],file_size($maxsize),str_replace(',', ', ', $pun_config['o_uploadile_laws']));
                                ?>
                            </p>
                            <p><input type="submit" name="submit" value="<?php echo $lang_uploadile['submit']; ?>" tabindex="<?php echo $tabindex++; ?>" /></p>
                        </div>
                    </fieldset>
                </div>
            </form>
        </div>
        <h2 class="block2"><span><?php echo $lang_uploadile['titre_4']; ?></span></h2>
        <div class="box">
            <form method="post" action="<?php echo PLUGIN_URL ?>" enctype="multipart/form-data">
                <div class="inform">
                    <?php 
                    if($pun_user['g_id'] != '1')
                        printf($lang_uploadile['info_4'], $pourcentage_utilise, '%', $pourcentage_utilise, '%', file_size($pun_user['upload']),file_size($limit), $pun_user['id']);
                    ?>
                    <div class="infldset" style="height:385px; overflow: auto; padding: 0;">
                        <table>
                            <thead>
                                <tr>
                                    <th scope="row"><?php echo $lang_uploadile['th']; ?></th>
                                    <th scope="row"><?php echo $lang_uploadile['th2']; ?></th>
                                    <th><input type="submit" value="<?php echo $lang_uploadile['delete']; ?>" name="supprimer" tabindex="<?php echo $tabindex++; ?>" /></th>
                                </tr>
                            </thead>
                            <tfoot>
                                <tr>
                                    <th class="tc1" scope="row"><?php echo $lang_uploadile['th']; ?></th>
                                    <th class="tc1" scope="row"><?php echo $lang_uploadile['th2']; ?></th>
                                    <th><input type="submit" value="<?php echo $lang_uploadile['delete']; ?>" name="supprimer" tabindex="<?php echo $tabindex++; ?>" /></th>
                                </tr>
                            </tfoot>
                            <tbody>
                            <?php
                            $dir = 'img/members/'.$pun_user['id'].'/';
                            if(is_dir($dir)) // On vérifie que la valeur est un fichier (pour écarter les sous dossiers)
                            {
                                $open = opendir($dir); // On ouvre le répertoire
                                while(false !== ($file = readdir($open))) // Tant qu'il y a des fichiers à lire
                                {
                                    if(is_file($dir.$file)) // On vérifie que la valeur est un fichier (pour écarter les sous dossiers)
                                    {
                                            $extension = strtolower(substr(strrchr($file,  "." ), 1)); // On prend l'extension du fichier dans la variable $extension avec une sous-chaine
                                            $extsupport = explode(',', $pun_config['o_uploadile_laws'].','.strtoupper($pun_config['o_uploadile_laws'])); // La liste des extensions possibles pour une image
                                            if(in_array($extension, $extsupport) and ($file[0] != "#")) // Si l'extension ne figure pas dans la liste on passe le fichier (A noter: Pour cacher une image placez un "#" devant son nom)
                                            {
                                                $time = filemtime($dir.$file).$file;
                                                $filesvar[$time] = $dir.$file; // Si elle y figure on ajoute le fichier à l'array $files
                                            }
                                    }
                                }
                                closedir($open); // Et enfin on ferme le dossier
                                if(isset($filesvar))
                                {
                                    krsort($filesvar);
                                    foreach($filesvar as $time => $file)
                                    {
                                        $files[] = $file;
                                    }
                                }
                                if(isset($files))
                                {
                                    
                                    foreach($files as $fichier)
                                    {
                                        $nom_fichier_brut = preg_replace('`img/members/'.$pun_user['id'].'/(.+)`','$1',$fichier); // Nom du fichier avec extension
                                        $nom_fichier = preg_replace('`(.+)\..*`', '$1', $nom_fichier_brut); // Nom du fichier sans extension
                                        $type_fichier = preg_replace('`.*\.(.+)`', '$1', $nom_fichier_brut); // Extension du fichier
                                        $size_fichier = file_size(filesize($fichier)); // Taille du fichier
                                        $miniature = $dir.'mini_'.$nom_fichier.'.'.$type_fichier; // Adresse de la miniature potentiellement existente
                                        $mini = explode('_', $nom_fichier); // On vérifie que ce n'est pas une miniature
                                        if($mini[0] != 'mini')
                                        {
                                            ?>
                                            <tr>
                                                <td class="tc1">
                                                    <input type="text" size="20" tabindex="<?php echo $tabindex++; ?>" value="<?php echo pun_htmlspecialchars(get_base_url(true).'/'.$fichier); ?>" />
                                                    <input type="button" value="<?php echo $lang_uploadile['insert']; ?>" onclick="javascript:image(<?php echo '\''.$fichier.'\', \''.(is_file($miniature) ? $fichier : '').'\''; ?>);return(false)" />
                                                    <?php 
                                                    if(is_file($miniature))
                                                    {
                                                    ?>
                                                        <br />
                                                        <input type="text" size="20" tabindex="<?php echo $tabindex++; ?>" value="<?php echo pun_htmlspecialchars(get_base_url(true).'/'.$miniature); ?>" />
                                                        <input type="button" value="<?php echo $lang_uploadile['insert_thumbnail']; ?>" onclick="javascript:image('<?php echo $fichier; ?>','<?php echo $miniature; ?>');return(false)" />
                                                    <?php 
                                                    }
                                                    ?>
                                                </td>
                                                <?php
                                                // Affichage de la miniature
                                                if($pun_config['o_uploadile_thumb'] == '1' AND is_file($miniature))
                                                    echo '<td class="tc2"><a href="'.$dir.$nom_fichier.'.'.$type_fichier.'" onclick="javascript:image(\''.$fichier.'\', \''.(is_file($miniature) ? $fichier : '').'\');return(false)" title="'.$nom_fichier.' - '.$size_fichier.'"><img src="'.$dir.'mini_'.$nom_fichier.'.'.$type_fichier.'" alt="'.$nom_fichier.'" /></a></td>';
                                                else
                                                    echo '<td class="tc2">'.$lang_uploadile['no_preview'].'</td>';
                                                ?>
                                                <td style="text-align:center;"><input type="checkbox" name="supprimer_<?php echo $boucle_id++; ?>" value="<?php echo $nom_fichier_brut; ?>" tabindex="<?php echo $tabindex++; ?>" /></td>
                                            </tr>
                                            <?php
                                        }
                                    }
                                }
                                else
                                    echo '<tr><td colspan="2">'.$lang_uploadile['err_1'].'</td></tr>';
                            }
                            else
                                echo '<tr><td colspan="2">'.$lang_uploadile['err_2'].'</td></tr>';
                            ?>
                            </tbody>
                        </table>
                        <input type="hidden" name="boucle_id" value="<?php echo $boucle_id; ?>" />
                    </div>
                </div>
            </form>
        </div>
    </div>
<?php

require PUN_ROOT.'footer.php';

Is necessary function of transliteration of any file's name to English .

Last edited by Visman (2011-02-06 17:34:53)

Offline

#24 2011-02-08 14:47:06

Visman
Member
From: Siberia
Registered: 2010-07-10
Posts: 1,518
Website

Re: Uploadile?

v 1.3.1
It is a lot of errors.
Hole in plugin AP_Uploadile.php.
Incorrectly works with UTF-8.

Offline

#25 2011-02-15 11:27:27

bagu
Member
Registered: 2010-10-18
Posts: 36

Re: Uploadile?

Hello,

I don't have time to work on it for the moment.
@visman : work perfectly here...Can you give me an example ?

If you want to submit change : https://github.com/Bagu/Uploadile is open for everyone.

Offline

Board footer

Powered by FluxBB