Annonces
Livre d'or

Par aircrack

Super CMS, super staff une équipe génial!
Plein de possibilité d'avenir et on attend tous la 4.0

Livre d'or

Mini sondage
Etes-vous satisfait du support PHPBoost ?










Résultats

 
   Le 21/08/09 à 00h52 Citer      

Booster Bazooka

Groupe: Membre

Sexe:
Inscrit le: 27/12/08
Messages: 145
Reprise du message précédent

Merci, ça fonction à merveille, j'ai tout modifié et mis sur mon ftp. :D

Merci encore !! :top

Sujet réglé :d
Visiteurs
   Le 23/08/09 à 02h03 Citer      

Boosteur Inactif

Groupe: Visiteur



Bonjour,

J'ai fait exactement ce que tu a fait mais j'ai des problèmes avec le fichier download.php voici l'erreur

Parse error: syntax error, unexpected ';', expecting ')' in /home/alphapr1/public_html/download/download.php on line 258

download.php
Code PHP :
	'SELECTED_DESC' => $selected_fields['desc']
		));
 
		//On crée une pagination si le nombre de fichiers est trop important.
		import('util/pagination'); 
		$Pagination = new Pagination();
 
		//Notes
		import('content/note');
		import('content/comments');
 
		$Template->assign_vars(array(
			'PAGINATION' => $Pagination->display(url('download.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $category_id . '&p=%d', 'category-' . $category_id . '-%d.php' . $unget), $nbr_files, 'p', $CONFIG_DOWNLOAD['nbr_file_max'], 3),
			'C_FILES' => true,
			'TARGET_ON_CHANGE_ORDER' => $CONFIG['rewrite'] ? 'category-' . $category_id . '.php?' : 'download.php?cat=' . $category_id . '&'
		));
       $Template->assign_block_vars('file', array(			
				'NAME' => $row['title'],
				'IMG_NAME' => str_replace('"', '\"', $row['title']),
				'C_DESCRIPTION' => !empty($row['short_contents']),
				$result = $Sql->query_while("SELECT id, title, timestamp, size, count, note, nbrnote, nbr_com, image, short_contents, version, licence, systeme, langue
		        FROM " . PREFIX . "download
		        WHERE visible = 1 AND approved = 1 AND idcat = '" . $category_id . "'
		        ORDER BY " . $sort . " " . $mode . 
		        $Sql->limit($Pagination->get_first_msg($CONFIG_DOWNLOAD['nbr_file_max'], 'p'), $CONFIG_DOWNLOAD['nbr_file_max']), __LINE__, __FILE__);
		        while ($row = $Sql->fetch_assoc($result))
				'DATE' => sprintf($DOWNLOAD_LANG['add_on_date'], gmdate_format('date_format_short', $row['timestamp'])),
				'COUNT_DL' => sprintf($DOWNLOAD_LANG['downloaded_n_times'], $row['count']),
				'NOTE' => $row['nbrnote'] > 0 ? Note::display_img($row['note'], $CONFIG_DOWNLOAD['note_max'], 5) : '<em>' . $LANG['no_note'] . '</em>',
				'SIZE' => ($row['size'] >= 1) ? number_round($row['size'], 1) . ' ' . $LANG['unit_megabytes'] : (number_round($row['size'], 1) * 1024) . ' ' . $LANG['unit_kilobytes'],
				'C_IMG' => !empty($row['image']),
				'IMG' => $row['image'],
				'U_DOWNLOAD_LINK' => url('download.php?id=' . $row['id'], 'download-' . $row['id'] . '+' . url_encode_rewrite($row['title']) . '.php'),
				'U_ADMIN_EDIT_FILE' => url('management.php?edit=' . $row['id']),
				'U_ADMIN_DELETE_FILE' => url('management.php?del=' . $row['id'] . '&token=' . $Session->get_token()),
				'U_COM_LINK' => Comments::com_display_link($row['nbr_com'], '../download/download' . url('.php?id=' . $row['id'] . '&com=0', '-' . $row['id'] . '+' . url_encode_rewrite($row['title']) . '.php?com=0'), $row['id'], 'download')
		{
			$Template->assign_block_vars('file', array(			
				'NAME' => $row['title'],
				'IMG_NAME' => str_replace('"', '\"', $row['title']),
				'C_DESCRIPTION' => !empty($row['short_contents']),
				'DESCRIPTION' => second_parse($row['short_contents']),
				'DATE' => sprintf($DOWNLOAD_LANG['add_on_date'], gmdate_format('date_format_short', $row['timestamp'])),
				'COUNT_DL' => sprintf($DOWNLOAD_LANG['downloaded_n_times'], $row['count']),
				'NOTE' => $row['nbrnote'] > 0 ? Note::display_img($row['note'], $CONFIG_DOWNLOAD['note_max'], 5) : '<em>' . $LANG['no_note'] . '</em>',
				'SIZE' => ($row['size'] >= 1) ? number_round($row['size'], 1) . ' ' . $LANG['unit_megabytes'] : (number_round($row['size'], 1) * 1024) . ' ' . $LANG['unit_kilobytes'],
				'C_IMG' => !empty($row['image']),
				'IMG' => $row['image'],
				'U_DOWNLOAD_LINK' => url('download.php?id=' . $row['id'], 'download-' . $row['id'] . '+' . url_encode_rewrite($row['title']) . '.php'),
				'U_ADMIN_EDIT_FILE' => url('management.php?edit=' . $row['id']),
				'U_ADMIN_DELETE_FILE' => url('management.php?del=' . $row['id'] . '&token=' . $Session->get_token()),
				'U_COM_LINK' => Comments::com_display_link($row['nbr_com'], '../download/download' . url('.php?id=' . $row['id'] . '&com=0', '-' . $row['id'] . '+' . url_encode_rewrite($row['title']) . '.php?com=0'), $row['id'], 'download')
			));
		}
		$Sql->query_close($result);
	}
	else
	{
		$Template->assign_vars(array(
			'L_NO_FILE_THIS_CATEGORY' => $DOWNLOAD_LANG['none_download'],
			'C_NO_FILE' => true
		));
	}
 
	$Template->pparse('download');
}
 
require_once('../kernel/footer.php'); 
 
?>
 




Edité par Visiteurs Le 23/08/09 à 02h04

   
   Le 23/08/09 à 09h54 Citer      

Administrateur

Equipe historique

Sexe:
Inscrit le: 31/12/07
Messages: 2267
Lieu: Lyon
Là, on pourra pas trop t'aider.

Faudrait que tu nous passe le fichier download en entier entre les balisesCode BBCODE :
[code=php,1]le ",1" après php fait afficher les numéros de lignes[/code]


Cependant, je vois quand même un erreur juste avant le
$Sql->limit
.

Remplaces donc ceci Code PHP :
ORDER BY " . $sort . " " . $mode .
par Code PHP :
ORDER BY " . $sort . " " . $mode
____________________
Soyez polis, pas de langage SMS et soignez votre orthographe, merci.

pm horn@phpboost.com http://www.phpboost.com    
   Le 23/08/09 à 10h08 Citer      

Booster Fusée

Groupe: Membre

Sexe:
Inscrit le: 23/09/08
Messages: 1706
Lieu: Aix en provence
bon alors comme la dit horn il faut que tu ppost avec les nhuméros de ligne mais surtout post tout ton fichier download.php car a ce que je vois tu à collé une requete sql en plein milieu d'un assign_block_vars. il faut bien comprendre que le code donné juste avant par reidlos n'est pas à collé exactement à la ligne donné (il se peu que ton fichier download.php n'est pas les meme num de ligne).



Edité par Crunchfamily Le 23/08/09 à 10h09
____________________

pm    
   Le 23/08/09 à 10h31 Citer      

Administrateur

Equipe historique

Sexe:
Inscrit le: 31/12/07
Messages: 2267
Lieu: Lyon
et en plus, 'javais pas vu le coup de la requête dans le assign vars
____________________
Soyez polis, pas de langage SMS et soignez votre orthographe, merci.

pm horn@phpboost.com http://www.phpboost.com    
Visiteurs
   Le 23/08/09 à 14h16 Citer      

Boosteur Inactif

Groupe: Visiteur



Voici tous mon module download pouvez vous verifier les erreurs :d merci de votre aide.

download.rar

   
   Le 23/08/09 à 14h35 Citer      

Administrateur

Chef de projet
Développement Noyau

Sexe:
Inscrit le: 27/02/09
Messages: 7992
Lieu: Alsace
remplace ton download.php par :

Code :
<?php
/*##################################################
 *                               download.php
 *                            -------------------
 *   begin                : July 27, 2005
 *   copyright            : (C) 2005 Viarre Régis, Sautel Benoit
 *   email                : crowkait@phpboost.com, ben.popeye@phpboost.com
 *
 *
###################################################
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 * 
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
###################################################*/

require_once('../kernel/begin.php');
require_once(
'../download/download_begin.php');
require_once(
'../kernel/header.php');

if (
$file_id 0//Contenu
{
    
$Template->set_filenames(array('download'=> 'download/download.tpl'));
    
    if (
$download_info['size'] > 1)
        
$size_tpl $download_info['size'] . ' ' $LANG['unit_megabytes'];
    elseif (
$download_info['size'] > 0)
        
$size_tpl = ($download_info['size'] * 1024) . ' ' $LANG['unit_kilobytes'];
    else
        
$size_tpl $DOWNLOAD_LANG['unknown_size'];
    
    
import('util/date');
     
$creation_date = new Date(DATE_TIMESTAMPTIMEZONE_SYSTEM$download_info['timestamp']);
     
$release_date = new Date(DATE_TIMESTAMPTIMEZONE_SYSTEM$download_info['release_timestamp']);
    
    
//Affichage notation.
    
import('content/note');
    
$Note = new Note('download'$file_idurl('download.php?id=' $file_id'category-' $category_id '-' $file_id '.php'), $CONFIG_DOWNLOAD['note_max'], ''NOTE_NODISPLAY_NBRNOTES);
    
    
import('content/comments');
    
    
$Template->assign_vars(array(
        
'C_DISPLAY_DOWNLOAD' => true,
        
'C_IMG' => !empty($download_info['image']),
        
'C_EDIT_AUTH' => $auth_write,
        
'MODULE_DATA_PATH' => $Template->get_module_data_path('download'),
        
'ID_FILE' => $file_id,
        
'NAME' => $download_info['title']." ".$download_info['version'], 
        
'CONTENTS' => second_parse($download_info['contents']),
        
'CREATION_DATE' => $creation_date->format(DATE_FORMAT_SHORT),
        
'RELEASE_DATE' => $release_date->get_timestamp() > $release_date->format(DATE_FORMAT_SHORT) : $DOWNLOAD_LANG['unknown_date'],
        
'SIZE' => $size_tpl,
        
'COUNT' => $download_info['count'],
        
'THEME' => get_utheme(),
        
'KERNEL_NOTATION' => $Note->display_form(),
        
'HITS' => sprintf($DOWNLOAD_LANG['n_times'], (int)$download_info['count']),
        
'NUM_NOTES' => sprintf($DOWNLOAD_LANG['num_notes'], (int)$download_info['nbrnote']),
        
'U_IMG' => $download_info['image'],
        
'IMAGE_ALT' => str_replace('"''"'$download_info['title']),
        
'LANG' => get_ulang(),
        
'U_COM' => Comments::com_display_link($download_info['nbr_com'], '../download/download' url('.php?id=' $file_id '&com=0''-' $file_id '+' url_encode_rewrite($download_info['title']) . '.php?com=0'), $file_id'download'),
        
'L_DATE' => $LANG['date'],
        
'L_SIZE' => $LANG['size'],
        
'L_DOWNLOAD' => $DOWNLOAD_LANG['download'],
        
'L_DOWNLOAD_FILE' => $DOWNLOAD_LANG['download_file'],
        
'L_FILE_INFOS' => $DOWNLOAD_LANG['file_infos'],
        
'L_INSERTION_DATE' => $DOWNLOAD_LANG['insertion_date'],
        
'L_RELEASE_DATE' => $DOWNLOAD_LANG['last_update_date'],
        
'L_DOWNLOADED' => $DOWNLOAD_LANG['downloaded'],
        
'L_EDIT_FILE' => str_replace('"''"'$DOWNLOAD_LANG['edit_file']),
        
'L_CONFIRM_DELETE_FILE' => str_replace(''', '''$DOWNLOAD_LANG['confirm_delete_file']),
        
'L_DELETE_FILE' => str_replace('"''"'$DOWNLOAD_LANG['delete_file']),
        
'U_EDIT_FILE' => url('management.php?edit=' $file_id),
        
'U_DELETE_FILE' => url('management.php?del=' $file_id '&token=' $Session->get_token()),
        
'U_DOWNLOAD_FILE' => url('count.php?id=' $file_id'file-' $file_id '+' url_encode_rewrite($download_info['title']) . '.php'),
    
'L_LANGUE'=>$DOWNLOAD_LANG['langue'],
    
'L_VERSION'=>$DOWNLOAD_LANG['version'],
    
'L_LICENCE'=>$DOWNLOAD_LANG['licence'],
    
'L_SYSTEME'=>$DOWNLOAD_LANG['systeme'],
    
'SYSTEME'=>$download_info['systeme'],
    
'LANGUE'=>$download_info['langue'],
    
'VERSION'=>$download_info['version'],
    
'LICENCE'=>$download_info['licence'],



    ));
    
    
//Affichage commentaires.
    
if (isset($_GET['com']))
    {
        
$Template->assign_vars(array(
            
'COMMENTS' => display_comments('download'$file_idurl('download.php?id=' $file_id '&com=%s''download-' $file_id '.php?com=%s'))
        ));
    }
    
    
$Template->pparse('download');
}
else
{
    
$Template->set_filenames(array('download'=> 'download/download.tpl'));
    
    
$Template->assign_vars(array(
        
'C_ADMIN' => $auth_write,
        
'C_DOWNLOAD_CAT' => true,
        
'C_ADD_FILE' => $auth_write || $auth_contribution,
        
'C_DESCRIPTION' => !empty($DOWNLOAD_CATS[$category_id]['contents']) || ($category_id == && !empty($CONFIG_DOWNLOAD['root_contents'])),
        
'IDCAT' => $category_id,
        
'TITLE' => sprintf($DOWNLOAD_LANG['title_download'] . ($category_id ' - ' $DOWNLOAD_CATS[$category_id]['name'] : '')),
        
'DESCRIPTION' => $category_id second_parse($DOWNLOAD_CATS[$category_id]['contents']) : second_parse($CONFIG_DOWNLOAD['root_contents']),
        
'L_ADD_FILE' => $DOWNLOAD_LANG['add_file'],
        
'U_ADMIN_CAT' => $category_id url('admin_download_cat.php?edit=' $category_id) : url('admin_download_cat.php'),
        
'U_ADD_FILE' => url('management.php?new=1&idcat=' $category_id)
    ));
    
    
//let's check if there are some subcategories
    
$num_subcats 0;
    foreach (
$DOWNLOAD_CATS as $id => $value)
    {
        if (
$id != && $value['id_parent'] == $category_id)
            
$num_subcats ++;
    }

    
//listing of subcategories
    
if ($num_subcats 0)
    {
        
$Template->assign_vars(array(
            
'C_SUB_CATS' => true
        
));    
        
        
$i 1;
        
        foreach (
$DOWNLOAD_CATS as $id => $value)
        {
            
//List of children categories
            
if ($id != && $value['visible'] && $value['id_parent'] == $category_id && (empty($value['auth']) || $User->check_auth($value['auth'], DOWNLOAD_READ_CAT_AUTH_BIT)))
            {
                if ( 
$i $CONFIG_DOWNLOAD['nbr_column'] == )
                    
$Template->assign_block_vars('row', array());
                
$Template->assign_block_vars('row.list_cats', array(
                    
'ID' => $id,
                    
'NAME' => $value['name'],
                    
'WIDTH' => floor(100 / (float)$CONFIG_DOWNLOAD['nbr_column']),
                    
'SRC' => $value['icon'],
                    
'IMG_NAME' => addslashes($value['name']),
                    
'NUM_FILES' => sprintf(((int)$value['num_files'] > $DOWNLOAD_LANG['num_files_plural'] : $DOWNLOAD_LANG['num_files_singular']), (int)$value['num_files']),
                    
'U_CAT' => url('download.php?cat=' $id'category-' $id '+' url_encode_rewrite($value['name']) . '.php'),
                    
'U_ADMIN_CAT' => url('admin_download_cat.php?edit=' $id),
                    
'C_CAT_IMG' => !empty($value['icon'])
                ));
                    
                
$i++;
            }
        }
    }
    
    
//Contenu de la catégorie    
    
$nbr_files = (int)$Sql->query("SELECT COUNT(*) FROM " PREFIX "download WHERE visible = 1 AND approved = 1 AND idcat = '" $category_id "'"__LINE____FILE__);
    if (
$nbr_files 0)
    {
        
$get_sort retrieve(GET'sort''');    
        
$get_mode retrieve(GET'mode''');
        
$selected_fields = array(
            
'alpha' => '',
            
'size' => '',
            
'date' => '',
            
'hits' => '',
            
'note' => '',
            
'asc' => '',
            
'desc' => ''
            
);
        
        switch (
$get_sort)
        {
            case 
'alpha' 
            
$sort 'title';
            
$selected_fields['alpha'] = ' selected="selected"';
            break;    
            case 
'size' 
            
$sort 'size';
            
$selected_fields['size'] = ' selected="selected"';
            break;            
            case 
'date' 
            
$sort 'timestamp';
            
$selected_fields['date'] = ' selected="selected"';
            break;        
            case 
'hits' 
            
$sort 'count';
            
$selected_fields['hits'] = ' selected="selected"';
            break;        
            case 
'note' :
            
$sort 'note';
            
$selected_fields['note'] = ' selected="selected"';
            break;
            default :
            
$sort 'timestamp';
            
$selected_fields['date'] = ' selected="selected"';
        }
        
        
$mode = ($get_mode == 'asc') ? 'ASC' 'DESC';
        if (
$mode == 'ASC')
            
$selected_fields['asc'] = ' selected="selected"';
        else
            
$selected_fields['desc'] = ' selected="selected"';
        
        
$unget = (!empty($get_sort) && !empty($mode)) ? '?sort=' $get_sort '&mode=' $get_mode '';
        
        
$Template->assign_vars(array(
            
'L_FILE' => $DOWNLOAD_LANG['file'],
            
'L_ALPHA' => $DOWNLOAD_LANG['sort_alpha'],
            
'L_SIZE' => $LANG['size'],
            
'L_DATE' => $LANG['date'],
            
'L_DOWNLOAD' => $DOWNLOAD_LANG['download'],
            
'L_POPULARITY' => $DOWNLOAD_LANG['popularity'],
            
'L_DESC' => $LANG['desc'],
            
'L_ASC' => $LANG['asc'],
            
'L_NOTE' => $LANG['note'],
            
'L_ORDER_BY' => $DOWNLOAD_LANG['order_by'],
            
'L_CONFIRM_DELETE_FILE' => str_replace(''', '''$DOWNLOAD_LANG['confirm_delete_file']),
            
'SELECTED_ALPHA' => $selected_fields['alpha'],
            
'SELECTED_SIZE' => $selected_fields['size'],
            
'SELECTED_DATE' => $selected_fields['date'],
            
'SELECTED_HITS' => $selected_fields['hits'],
            
'SELECTED_NOTE' => $selected_fields['note'],
            
'SELECTED_ASC' => $selected_fields['asc'],
            
'SELECTED_DESC' => $selected_fields['desc']
        ));
            
        
//On crée une pagination si le nombre de fichiers est trop important.
        
import('util/pagination'); 
        
$Pagination = new Pagination();
        
        
//Notes
        
import('content/note');
        
import('content/comments');
        
        
$Template->assign_vars(array(
            
'PAGINATION' => $Pagination->display(url('download.php' . (!empty($unget) ? $unget '&' '?') . 'cat=' $category_id '&p=%d''category-' $category_id '-%d.php' $unget), $nbr_files'p'$CONFIG_DOWNLOAD['nbr_file_max'], 3),
            
'C_FILES' => true,
            
'TARGET_ON_CHANGE_ORDER' => $CONFIG['rewrite'] ? 'category-' $category_id '.php?' 'download.php?cat=' $category_id '&'
        
));

        
$result $Sql->query_while("SELECT id, title, timestamp, size, count, note, nbrnote, nbr_com, image, short_contents, version, licence, systeme, langue
        FROM " 
PREFIX "download
        WHERE visible = 1 AND approved = 1 AND idcat = '" 
$category_id "'
        ORDER BY " 
$sort " " $mode 
        
$Sql->limit($Pagination->get_first_msg($CONFIG_DOWNLOAD['nbr_file_max'], 'p'), $CONFIG_DOWNLOAD['nbr_file_max']), __LINE____FILE__);
        while (
$row $Sql->fetch_assoc($result))
        {
            
$Template->assign_block_vars('file', array(            
                
'NAME' => $row['title']." ".$row['version'], 
                
'IMG_NAME' => str_replace('"''"'$row['title']),
                
'C_DESCRIPTION' => !empty($row['short_contents']),
                
'DESCRIPTION' => second_parse($row['short_contents']),
                
'DATE' => sprintf($DOWNLOAD_LANG['add_on_date'], gmdate_format('date_format_short'$row['timestamp'])),
                
'COUNT_DL' => sprintf($DOWNLOAD_LANG['downloaded_n_times'], $row['count']),
                
'NOTE' => $row['nbrnote'] > Note::display_img($row['note'], $CONFIG_DOWNLOAD['note_max'], 5) : '<em>' $LANG['no_note'] . '</em>',
                
'SIZE' => ($row['size'] >= 1) ? number_round($row['size'], 1) . ' ' $LANG['unit_megabytes'] : (number_round($row['size'], 1) * 1024) . ' ' $LANG['unit_kilobytes'],
                
'C_IMG' => !empty($row['image']),
                
'IMG' => $row['image'],
                
'U_DOWNLOAD_LINK' => url('download.php?id=' $row['id'], 'download-' $row['id'] . '+' url_encode_rewrite($row['title']) . '.php'),
                
'U_ADMIN_EDIT_FILE' => url('management.php?edit=' $row['id']),
                
'U_ADMIN_DELETE_FILE' => url('management.php?del=' $row['id'] . '&token=' $Session->get_token()),
                
'U_COM_LINK' => Comments::com_display_link($row['nbr_com'], '../download/download' url('.php?id=' $row['id'] . '&com=0''-' $row['id'] . '+' url_encode_rewrite($row['title']) . '.php?com=0'), $row['id'], 'download')
            ));
        }
        
$Sql->query_close($result);
    }
    else
    {
        
$Template->assign_vars(array(
            
'L_NO_FILE_THIS_CATEGORY' => $DOWNLOAD_LANG['none_download'],
            
'C_NO_FILE' => true
        
));
    }
        
    
$Template->pparse('download');
}
    
require_once(
'../kernel/footer.php'); 

?>


et management.php :


Code :
<?php
/*##################################################
 *                               management.php
 *                            -------------------
 *   begin                :  April 14, 2008
 *   copyright            : (C) 2008 Sautel Benoit
 *   email                : ben.popeye@phpboost.com
 *
 *
###################################################
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 * This program 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 General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
###################################################*/

require_once('../kernel/begin.php');

load_module_lang('download'); //Chargement de la langue du module.
$Cache->load('download');

include_once(
'download_auth.php');

import('util/date');
import('util/mini_calendar');

include_once(
'download_cats.class.php');
$download_categories = new DownloadCats();

$edit_file_id retrieve(GET'edit'0);
$add_file retrieve(GET'new'false);
$preview retrieve(POST'preview'false);
$submit retrieve(POST'submit'false);
$selected_cat retrieve(GET'idcat'0);
$delete_file retrieve(GET'del'0);

if (
$delete_file || ($submit && ($add_file || $edit_file_id 0)))
    
$Session->csrf_get_protect();

//Form variables
$file_title retrieve(POST'title''');
$file_image retrieve(POST'image''');
$file_contents retrieve(POST'contents'''TSTRING_AS_RECEIVED);
$file_short_contents retrieve(POST'short_contents'''TSTRING_AS_RECEIVED);
$file_url retrieve(POST'url''');
$file_timestamp retrieve(POST'timestamp'0);
$file_size retrieve(POST'size'0.0TUNSIGNED_FLOAT);
$file_hits retrieve(POST'count'0TUNSIGNED_INT);
$file_cat_id retrieve(REQUEST'idcat'0);
$file_visibility retrieve(POST'visibility'0);
$file_approved retrieve(POST'approved'false);
$ignore_release_date retrieve(POST'ignore_release_date'false);
$file_download_method retrieve(POST'download_method''redirect'TSTRING);
$version retrieve(POST'version'''TSTRING_AS_RECEIVED);
$langueretrieve(POST'langue'''TSTRING_AS_RECEIVED);
$systeme retrieve(POST'systeme'''TSTRING_AS_RECEIVED);
$licence retrieve(POST'licence'''TSTRING_AS_RECEIVED);
//Instanciations of objects required
$file_creation_date MiniCalendar::retrieve_date('creation');

if (!
$ignore_release_date)
    
$file_release_date MiniCalendar::retrieve_date('release_date');
else
    
$file_release_date = new Date(DATE_NOWTIMEZONE_AUTO);

$begining_date MiniCalendar::retrieve_date('begining_date');
$end_date MiniCalendar::retrieve_date('end_date');

//Deleting a file
if ($delete_file 0)
{
    
//Vérification de la valiité du jeton
    
$Session->csrf_get_protect();
    
$file_infos $Sql->query_array(PREFIX 'download''*'"WHERE id = '" $delete_file "'"__LINE____FILE__);
    if (empty(
$file_infos['title']))
        
redirect(HOSTDIR url('/download/download.php'));
    
    if (
$download_categories->check_auth($file_infos['idcat']))
    {
        
$Sql->query_inject("DELETE FROM " PREFIX "download WHERE id = '" $delete_file "'"__LINE____FILE__);
        
//Deleting comments if the file has
        
if ($file_infos['nbr_com'] > 0)
        {
            
import('content/comments');
            
$Comments = new Comments('download'$delete_fileurl('download.php?id=' $delete_file '&com=%s''download-' $delete_file '.php?com=%s'));
            
$Comments->delete_all($delete_file);
        }
        
redirect(HOSTDIR '/download/' . ($file_infos['idcat'] > url('download.php?cat=' $file_infos['idcat'], 'category-' $file_infos['idcat'] . '+' url_encode_rewrite($DOWNLOAD_CATS[$file_infos['idcat']]['name']) . '.php') : url('download.php')));
        
        
// Feeds Regeneration
        
import('content/syndication/feed');
        
Feed::clear_cache('download');
    }
    else
        
$Errorh->handler('e_auth'E_USER_REDIRECT);
}
//Editing a page
elseif ($edit_file_id 0)
{
    
$file_infos $Sql->query_array(PREFIX 'download''*'"WHERE id = '" $edit_file_id "'"__LINE____FILE__);
    
    if (empty(
$file_infos['title']))
        
redirect(HOSTDIR url('/download/download.php'));
    
define('TITLE'$DOWNLOAD_LANG['file_management']);
    
    
//Barre d'arborescence
    
$auth_write $User->check_auth($CONFIG_DOWNLOAD['global_auth'], DOWNLOAD_WRITE_CAT_AUTH_BIT);
    
    
$Bread_crumb->add($DOWNLOAD_LANG['file_management'], url('management.php?edit=' $edit_file_id));
    
    
$Bread_crumb->add($file_infos['title'], url('download.php?id=' $edit_file_id'download-' $edit_file_id '+' url_encode_rewrite($file_infos['title']) . '.php'));
    
    
$id_cat $file_infos['idcat'];

    
//Bread_crumb : we read categories list recursively
    
while ($id_cat 0)
    {
        
$Bread_crumb->add($DOWNLOAD_CATS[$id_cat]['name'], url('download.php?id=' $id_cat'category-' $id_cat '+' url_encode_rewrite($DOWNLOAD_CATS[$id_cat]['name']) . '.php'));
        
        if (!empty(
$DOWNLOAD_CATS[$id_cat]['auth']))
            
$auth_write $User->check_auth($DOWNLOAD_CATS[$id_cat]['auth'], DOWNLOAD_WRITE_CAT_AUTH_BIT);
        
        
$id_cat = (int)$DOWNLOAD_CATS[$id_cat]['id_parent'];
    }
    
    if (!
$auth_write)
        
$Errorh->handler('e_auth'E_USER_REDIRECT);
}
else
{
    
$Bread_crumb->add($DOWNLOAD_LANG['file_addition'], url('management.php?new=1'));
    
define('TITLE'$DOWNLOAD_LANG['file_addition']);
    
    if (!(
$auth_write $User->check_auth($CONFIG_DOWNLOAD['global_auth'], DOWNLOAD_WRITE_CAT_AUTH_BIT)) && !($auth_contribute $User->check_auth($CONFIG_DOWNLOAD['global_auth'], DOWNLOAD_CONTRIBUTION_CAT_AUTH_BIT)))
        
$Errorh->handler('e_auth'E_USER_REDIRECT);
}

$Bread_crumb->add($DOWNLOAD_LANG['download'], url('download.php'));

$Bread_crumb->reverse();

require_once(
'../kernel/header.php');

$Template->set_filenames(array(
    
'file_management'=> 'download/file_management.tpl'
));

$Template->assign_vars(array(
    
'KERNEL_EDITOR' => display_editor(),
    
'KERNEL_EDITOR_SHORT' => display_editor('short_contents'),
    
'C_PREVIEW' => $preview,
    
'L_PAGE_TITLE' => TITLE,
    
'L_EDIT_FILE' => $DOWNLOAD_LANG['edit_file'],
    
'L_YES' => $LANG['yes'],
    
'L_NO' => $LANG['no'],
    
'L_DOWNLOAD_DATE' => $DOWNLOAD_LANG['download_date'],
    
'L_IGNORE_RELEASE_DATE' => $DOWNLOAD_LANG['ignore_release_date'],
    
'L_RELEASE_DATE' => $DOWNLOAD_LANG['release_date'],
    
'L_FILE_VISIBILITY' => $DOWNLOAD_LANG['file_visibility'],
    
'L_APPROVED' => $DOWNLOAD_LANG['approved'],
    
'L_NOW' => $LANG['now'],
    
'L_HIDDEN' => $DOWNLOAD_LANG['hidden'],
    
'L_TO_DATE' => $LANG['to_date'],
    
'L_FROM_DATE' => $LANG['from_date'],
    
'L_DESC' => $LANG['description'],
    
'L_DOWNLOAD' => $DOWNLOAD_LANG['download'],
    
'L_SIZE' => $LANG['size'],
    
'L_URL' => $LANG['url'],
    
'L_FILE_IMAGE' => $DOWNLOAD_LANG['file_image'],
    
'L_TITLE' => $LANG['title'],
    
'L_CATEGORY' => $LANG['category'],
    
'L_REQUIRE' => $LANG['require'],
    
'L_DOWNLOAD_ADD' => $DOWNLOAD_LANG['download_add'],
    
'L_DOWNLOAD_MANAGEMENT' => $DOWNLOAD_LANG['download_management'],
    
'L_DOWNLOAD_CONFIG' => $DOWNLOAD_LANG['download_config'],
    
'L_UPDATE' => $LANG['update'],
    
'L_RESET' => $LANG['reset'],
    
'L_PREVIEW' => $LANG['preview'],
    
'L_UNIT_SIZE' => $LANG['unit_megabytes'],
    
'L_CONTENTS' => $DOWNLOAD_LANG['complete_contents'],
    
'L_SHORT_CONTENTS' => $DOWNLOAD_LANG['short_contents'],
    
'L_SUBMIT' => $edit_file_id $DOWNLOAD_LANG['update_file'] : $DOWNLOAD_LANG['add_file'],
    
'L_WARNING_PREVIEWING' => $DOWNLOAD_LANG['warning_previewing'],
    
'L_REQUIRE_DESCRIPTION' => $DOWNLOAD_LANG['require_description'],
    
'L_REQUIRE_URL' => $DOWNLOAD_LANG['require_url'],
    
'L_REQUIRE_CREATION_DATE' => $DOWNLOAD_LANG['require_creation_date'],
    
'L_REQUIRE_RELEASE_DATE' => $DOWNLOAD_LANG['require_release_date'],
    
'L_REQUIRE_TITLE' => $LANG['require_title'],
    
'L_CONTRIBUTION_LEGEND' => $LANG['contribution'],
    
'L_NUMBER_OF_HITS' => $DOWNLOAD_LANG['number_of_hits'],
    
'L_DOWNLOAD_METHOD' => $DOWNLOAD_LANG['download_method'],
    
'L_DOWNLOAD_METHOD_EXPLAIN' => $DOWNLOAD_LANG['download_method_explain'],
    
'L_FORCE_DOWNLOAD' => $DOWNLOAD_LANG['force_download'],
    
'L_REDIRECTION' => $DOWNLOAD_LANG['redirection_up_to_file'],
    
'L_LANGUE'=>$DOWNLOAD_LANG['langue'],
    
'L_VERSION'=>$DOWNLOAD_LANG['version'],
    
'L_LICENCE'=>$DOWNLOAD_LANG['licence'],
    
'L_SYSTEME'=>$DOWNLOAD_LANG['systeme'],

));

if (
$edit_file_id 0)
{
    if (
$submit)
    {
        
//The form is ok
        
if (!empty($file_title) && $download_categories->check_auth($file_cat_id) && !empty($file_url) && !empty($file_contents))
        {
            
$visible 1;
            
            
$date_now = new Date(DATE_NOW);
            
            switch (
$file_visibility)
            {
                case 
2:
                    if ((
$begining_date->get_timestamp() > $date_now->get_timestamp() || $end_date->get_timestamp() > $date_now->get_timestamp()) && $begining_date->get_timestamp() < $end_date->get_timestamp())
                    {
                        
$start_timestamp $begining_date->get_timestamp();
                        
$end_timestamp $end_date->get_timestamp();
                        
                        if (
$begining_date->get_timestamp() > $date_now->get_timestamp())
                            
$visible 0;
                    }
                    else
                        list(
$start_timestamp$end_timestamp) = array(00);
                    break;
                case 
1:
                    list(
$start_timestamp$end_timestamp) = array(00);
                    break;
                default:
                    list(
$visible$start_timestamp$end_timestamp) = array(000);
            }
            
            
$file_properties $Sql->query_array(PREFIX "download""visible""approved""WHERE id = '" $edit_file_id "'"__LINE____FILE__);
            
            
import('util/url');
            
$file_relative_url = new Url($file_url);
            
            
$Sql->query_inject("UPDATE " PREFIX "download SET title = '" $file_title "', idcat = '" $file_cat_id "', url = '" $file_relative_url->relative() . "', " .
                
"size = '" $file_size "', count = '" $file_hits "', force_download = '" . ($file_download_method == 'force_download' DOWNLOAD_FORCE_DL DOWNLOAD_REDIRECT) . "', contents = '" strparse($file_contents) . "', short_contents = '" strparse($file_short_contents) . "', " .
                
"image = '" $file_image "', timestamp = '" $file_creation_date->get_timestamp() . "', release_timestamp = '" . ($ignore_release_date $file_release_date->get_timestamp()) . "', " .
                
"start = '" $start_timestamp "', end = '" $end_timestamp "',licence='".$licence."',systeme ='".$systeme."',langue = '".$langue."' ,version = '".$version."',visible = '" $visible "', approved = " . (int)$file_approved " " .
                
"WHERE id = '" $edit_file_id "'"__LINE____FILE__);
            
            
//Updating the number of subfiles in each category
            
if ($file_cat_id != $file_infos['idcat'] || (int)$file_properties['visible'] != $visible || (int)$file_properties['approved'] != $file_approved)
            {
                
$download_categories->Recount_sub_files();
            }

            
//If it wasn't approved and now it's, we try to consider the corresponding contribution as processed
            
if ($file_approved && !$file_properties['approved'])
            {
                
import('events/contribution');
                
import('events/contribution_service');
                
                
$corresponding_contributions ContributionService::find_by_criteria('download'$edit_file_id);
                if (
count($corresponding_contributions) > 0)
                {
                    
$file_contribution $corresponding_contributions[0];
                    
//The contribution is now processed
                    
$file_contribution->set_status(EVENT_STATUS_PROCESSED);
                    
                    
//We save the contribution
                    
ContributionService::save_contribution($file_contribution);
                }
            }
            
            
// Feeds Regeneration
            
import('content/syndication/feed');
            
Feed::clear_cache('download');
            
            
//If we cannot see the file, we redirect in its category
            
if (!$visible || !$file_approved)
            {
                if ($
$file_cat_id 0)
                    
redirect(HOST DIR '/download/' url('download.php?cat=' $file_cat_id'category-' $file_cat_id '+' url_encode_rewrite($DOWNLOAD_CATS[$file_cat_id]['name']) . '.php'));
                else
                    
redirect(HOST DIR '/download/' url('download.php'));
            }
            else
                
redirect(HOST DIR '/download/' url('download.php?id=' $edit_file_id'download-' $edit_file_id '+' url_encode_rewrite($file_title) . '.php'));
        }
        
//Error (which souldn't happen because of the javascript checking)
        
else
        {
            
redirect(HOST DIR '/download/' url('download.php'));
        }
    }
    
//Previewing a file
    
elseif ($preview)
    {
        
$begining_calendar = new MiniCalendar('begining_date');
        
$begining_calendar->set_date($begining_date);
        
$end_calendar = new MiniCalendar('end_date');
        
$end_calendar->set_date($end_date);
        
$end_calendar->set_style('margin-left:150px;');

        
$Template->set_filenames(array('download' => 'download/download.tpl'));
        
        if (
$file_size 1)
            
$size_tpl $file_size ' ' $LANG['unit_megabytes'];
        elseif (
$file_size 0)
            
$size_tpl = ($file_size 1024) . ' ' $LANG['unit_kilobytes'];
        else
            
$size_tpl $DOWNLOAD_LANG['unknown_size'];
        
        
//Création des calendriers
        
$creation_calendar = new MiniCalendar('creation');
        
$creation_calendar->set_date($file_creation_date);
        
$release_calendar = new MiniCalendar('release_date');
        
$release_calendar->set_date($file_release_date);
        
        if (
$file_visibility || $file_visibility 2)
            
$file_visibility 0;

        
$Template->assign_vars(array(
            
'C_DISPLAY_DOWNLOAD' => true,
            
'C_IMG' => !empty($file_image),
            
'C_EDIT_AUTH' => false,
            
'MODULE_DATA_PATH' => $Template->get_module_data_path('download'),
            
'NAME' => stripslashes($file_title),
            
'CONTENTS' => second_parse(stripslashes(strparse($file_contents))),
            
'CREATION_DATE' => $file_creation_date->format(DATE_FORMAT_SHORT) ,
            
'RELEASE_DATE' => $file_release_date->get_timestamp() > $file_release_date->format(DATE_FORMAT_SHORT) : $DOWNLOAD_LANG['unknown_date'],
            
'SIZE' => $size_tpl,
            
'COUNT' => $file_hits,
            
'THEME' => get_utheme(),
            
'HITS' => sprintf($DOWNLOAD_LANG['n_times'], (int)$file_hits),
            
'NUM_NOTES' => sprintf($DOWNLOAD_LANG['num_notes'], 0),
            
'U_IMG' => $file_image,
            
'IMAGE_ALT' => str_replace('"''"'$file_title),
            
'LANG' => get_ulang(),
            
'FORCE_DOWNLOAD_SELECTED' => $file_download_method == 'force_download' ' selected="selected"' '',
            
'REDIRECTION_SELECTED' => $file_download_method != 'force_download' ' selected="selected"' '',
            
// Those langs are required by the template inclusion
            
'L_DATE' => $LANG['date'],
            
'L_SIZE' => $LANG['size'],
            
'L_DOWNLOAD' => $DOWNLOAD_LANG['download'],
            
'L_DOWNLOAD_FILE' => $DOWNLOAD_LANG['download_file'],
            
'L_FILE_INFOS' => $DOWNLOAD_LANG['file_infos'],
            
'L_INSERTION_DATE' => $DOWNLOAD_LANG['insertion_date'],
            
'L_RELEASE_DATE' => $DOWNLOAD_LANG['release_date'],
            
'L_DOWNLOADED' => $DOWNLOAD_LANG['downloaded'],
            
'L_NOTE' => $LANG['note'],
            
'U_DOWNLOAD_FILE' => url('count.php?id=' $edit_file_id'file-' $edit_file_id '+' url_encode_rewrite($file_title) . '.php')
        ));

        
$Template->assign_vars(array(
            
'C_CONTRIBUTION' => false,
            
'TITLE' => stripslashes($file_title),
            
'COUNT' => $file_hits,
            
'DESCRIPTION' => stripslashes($file_contents),
            
'SHORT_DESCRIPTION' => stripslashes($file_short_contents),
            
'FILE_IMAGE' => $file_image,
            
'URL' => $file_url,
            
'SIZE_FORM' => $file_size,
            
'DATE' => $file_creation_date->format(DATE_FORMAT_SHORTTIMEZONE_AUTO),
            
'CATEGORIES_TREE' => $download_categories->build_select_form($file_cat_id'idcat''idcat'0DOWNLOAD_WRITE_CAT_AUTH_BIT$CONFIG_DOWNLOAD['global_auth'], IGNORE_AND_CONTINUE_BROWSING_IF_A_CATEGORY_DOES_NOT_MATCH),
            
'SHORT_DESCRIPTION_PREVIEW' => second_parse(stripslashes(strparse($file_short_contents))),
            
'VISIBLE_WAITING' => $file_visibility == ' checked="checked"' '',
            
'VISIBLE_ENABLED' => $file_visibility == ' checked="checked"' '',
            
'VISIBLE_HIDDEN' => $file_visibility == ' checked="checked"' '',
            
'APPROVED' => $file_approved ' checked="checked"' '',
            
'DATE_CALENDAR_CREATION' => $creation_calendar->display(),
            
'DATE_CALENDAR_RELEASE' => $release_calendar->display(),
            
'BOOL_IGNORE_RELEASE_DATE' => $ignore_release_date 'true' 'false',
            
'STYLE_FIELD_RELEASE_DATE' => $ignore_release_date 'none' 'block',
            
'IGNORE_RELEASE_DATE_CHECKED' => $ignore_release_date ' checked="checked"' '',
            
'BEGINING_CALENDAR' => $begining_calendar->display(),
            
'END_CALENDAR' => $end_calendar->display(),
            
'SYSTEME'=>$systeme,
            
'LANGUE'=>$langue,
            
'VERSION'=>$version,
            
'LICENCE'=>$licence,
        ));
    }
    
//Default formulary, with file infos from the database
    
else
    {
        
$file_creation_date = new Date(DATE_TIMESTAMPTIMEZONE_AUTO$file_infos['timestamp']);
        
$file_release_date = new Date(DATE_TIMESTAMPTIMEZONE_AUTO$file_infos['release_timestamp']);
        
        
$creation_calendar = new MiniCalendar('creation');
        
$creation_calendar->set_date($file_creation_date);
        
        
$release_calendar = new MiniCalendar('release_date');
        
$ignore_release_date = ($file_release_date->get_timestamp() == 0);
        if (!
$ignore_release_date)
            
$release_calendar->set_date($file_release_date);
        
        
        
$begining_calendar = new MiniCalendar('begining_date');
        
$end_calendar = new MiniCalendar('end_date');
        
$end_calendar->set_style('margin-left:150px;');
        
        if (!empty(
$file_infos['start']) && !empty($file_infos['end']))
        {
            
$file_visibility 2;
            
$begining_calendar->set_date(new Date(DATE_TIMESTAMPTIMEZONE_AUTO$file_infos['start']));
            
$end_calendar->set_date(new Date(DATE_TIMESTAMPTIMEZONE_AUTO$file_infos['end']));
        }
        elseif (!empty(
$file_infos['visible']))
            
$file_visibility 1;
        else
            
$file_visibility 0;

        
$Template->assign_vars(array(
            
'C_CONTRIBUTION' => false,
            
'TITLE' => $file_infos['title'],
            
'COUNT' => !empty($file_infos['count']) ? $file_infos['count'] : 0,
            
'DESCRIPTION' => unparse($file_infos['contents']),
            
'SHORT_DESCRIPTION' => unparse($file_infos['short_contents']),
            
'FILE_IMAGE' => $file_infos['image'],
            
'URL' => $file_infos['url'],
            
'SIZE_FORM' => $file_infos['size'],
            
'DATE' => $file_creation_date->format(DATE_FORMAT_SHORTTIMEZONE_AUTO),
            
'CATEGORIES_TREE' => $download_categories->build_select_form($file_infos['idcat'], 'idcat''idcat'0DOWNLOAD_WRITE_CAT_AUTH_BIT$CONFIG_DOWNLOAD['global_auth'], IGNORE_AND_CONTINUE_BROWSING_IF_A_CATEGORY_DOES_NOT_MATCH),
            
'DATE_CALENDAR_CREATION' => $creation_calendar->display(),
            
'DATE_CALENDAR_RELEASE' => $release_calendar->display(),
            
'BOOL_IGNORE_RELEASE_DATE' => $ignore_release_date 'true' 'false',
            
'STYLE_FIELD_RELEASE_DATE' => $ignore_release_date 'none' 'block',
            
'IGNORE_RELEASE_DATE_CHECKED' => $ignore_release_date ' checked="checked"' '',
            
'BEGINING_CALENDAR' => $begining_calendar->display(),
            
'END_CALENDAR' => $end_calendar->display(),
            
'VISIBLE_WAITING' => $file_visibility == ' checked="checked"' '',
            
'VISIBLE_ENABLED' => $file_visibility == ' checked="checked"' '',
            
'VISIBLE_HIDDEN' => $file_visibility == ' checked="checked"' '',
            
'APPROVED' => $file_infos['approved'] ? ' checked="checked"' '',
            
'FORCE_DOWNLOAD_SELECTED' => $file_infos['force_download'] == DOWNLOAD_FORCE_DL ' selected="selected"' '',
            
'REDIRECTION_SELECTED' => $file_infos['force_download'] == DOWNLOAD_REDIRECT ' selected="selected"' '',
            
'U_TARGET' => url('management.php?edit=' $edit_file_id '&token=' $Session->get_token()),
            
'SYSTEME'=>$file_infos['systeme'],
            
'LANGUE'=>$file_infos['langue'],
            
'VERSION'=>$file_infos['version'],
            
'LICENCE'=>$file_infos['licence'],
        ));
    }
}
//Adding a file
else
{
    
$contribution_counterpart retrieve(POST'counterpart'''TSTRING_PARSE);
    
    
//If we can't write, the file cannot be approved
    
$file_approved $auth_write;
    
    if (
$submit)
    {
        
//The form is ok
        
if (!empty($file_title) && ($download_categories->check_auth($file_cat_id) || $download_categories->check_contribution_auth($file_cat_id)) && !empty($file_url) && !empty($file_contents))
        {
            
$visible 1;
            
            
$date_now = new Date(DATE_NOW);
            
            switch (
$file_visibility)
            {
                
//If it's a time interval
                
case 2:
                    if (
$begining_date->get_timestamp() < $date_now->get_timestamp() &&  $end_date->get_timestamp() > $date_now->get_timestamp())
                    {
                        
$start_timestamp $begining_date->get_timestamp();
                        
$end_timestamp $end_date->get_timestamp();
                    }
                    else
                        
$visible 0;
                    break;
                
//If it's always visible
                
case 1:
                    list(
$start_timestamp$end_timestamp) = array(00);
                    break;
                default:
                    list(
$visible$start_timestamp$end_timestamp) = array(000);
            }
            
            
import('util/url');
            
$file_relative_url = new Url($file_url);
            
            
$Sql->query_inject("INSERT INTO " PREFIX "download (title, idcat, url, size, count, force_download, contents, short_contents, image, timestamp, release_timestamp, start, end, visible, systeme, langue, licence, version, approved,users_note) " .
                
"VALUES ('" $file_title "', '" $file_cat_id "', '" $file_relative_url->relative() . "', '" $file_size "', '" $file_hits "', '" . ($file_download_method == 'force_download' DOWNLOAD_FORCE_DL DOWNLOAD_REDIRECT) . "', '" strparse($file_contents) . "', '" strparse($file_short_contents) . "', '" $file_image "', '" $file_creation_date->get_timestamp() . "', '" . ($ignore_release_date $file_release_date->get_timestamp()) . "', '" $start_timestamp "', '" $end_timestamp "', '" $visible "','".$systeme."' ,'".$langue."' ,'".$licence."' ,'".$version."' ,'" . (int)$auth_write "', '')"__LINE____FILE__);
            
            
$new_id_file $Sql->insert_id("SELECT MAX(id) FROM " PREFIX "download");
            
            
//If the poster couldn't write, it's a contribution and we put it in the contribution panel, it must be approved
            
if (!$auth_write)
            {
                
//Importing the contribution classes
                
import('events/contribution');
                
import('events/contribution_service');
                
                
$download_contribution = new Contribution();
                
                
//The id of the file in the module. It's useful when the module wants to search a contribution (we will need it in the file edition)
                
$download_contribution->set_id_in_module($new_id_file);
                
//The description of the contribution (the counterpart) to explain why did the contributor contributed
                
$download_contribution->set_description(stripslashes($contribution_counterpart));
                
//The entitled of the contribution
                
$download_contribution->set_entitled(sprintf($DOWNLOAD_LANG['contribution_entitled'], $file_title));
                
//The URL where a validator can treat the contribution (in the file edition panel)
                
$download_contribution->set_fixing_url('/download/management.php?edit=' $new_id_file);
                
//Who is the contributor?
                
$download_contribution->set_poster_id($User->get_attribute('user_id'));
                
//The module
                
$download_contribution->set_module('download');
                
                
                
//Assignation des autorisations d'écriture / Writing authorization assignation
                
$download_contribution->set_auth(
                    
//On déplace le bit sur l'autorisation obtenue pour le mettre sur celui sur lequel travaille les contributions, à savoir CONTRIBUTION_AUTH_BIT
                    //We shift the authorization bit to the one with which the contribution class works, CONTRIBUTION_AUTH_BIT
                    
Authorizations::capture_and_shift_bit_auth(
                        
//On fusionne toutes les autorisations pour obtenir l'autorisation d'écriture dans la catégorie sélectionnée :
                        //C'est la fusion entre l'autorisation de la racine et de l'ensemble de la branche des catégories
                        //We merge the whole authorizations of the branch constituted by the selected category
                        
Authorizations::merge_auth(
                            
$CONFIG_DOWNLOAD['global_auth'],
                            
//Autorisation de l'ensemble de la branche des catégories jusqu'à la catégorie demandée
                            
$download_categories->compute_heritated_auth($file_cat_idDOWNLOAD_WRITE_CAT_AUTH_BITAUTH_CHILD_PRIORITY),
                            
DOWNLOAD_WRITE_CAT_AUTH_BITAUTH_CHILD_PRIORITY
                        
),
                        
DOWNLOAD_WRITE_CAT_AUTH_BITCONTRIBUTION_AUTH_BIT
                    
)
                );

                
//Sending the contribution to the kernel. It will place it in the contribution panel to be approved
                
ContributionService::save_contribution($download_contribution);
                
                
//Redirection to the contribution confirmation page
                
redirect(HOST DIR '/download/contribution.php');
            }
            
            
//Updating the number of subfiles in each category
            
$download_categories->Recount_sub_files();
            
            
// Feeds Regeneration
            
import('content/syndication/feed');
            
Feed::clear_cache('download');
            
            
redirect(HOST DIR '/download/' url('download.php?id=' $new_id_file'download-' $new_id_file '+' url_encode_rewrite($file_title) . '.php'));
        }
        
//Error (which souldn't happen because of the javascript checking)
        
else
        {
            
redirect(HOST DIR '/download/' url('download.php'));
        }
    }
    
//Previewing a file
    
elseif ($preview)
    {
        
$contribution_counterpart_source strprotect(retrieve(POST'counterpart'''TSTRING_AS_RECEIVED), HTML_PROTECTADDSLASHES_NONE);
        
        
$begining_calendar = new MiniCalendar('begining_date');
        
$begining_calendar->set_date($begining_date);
        
$end_calendar = new MiniCalendar('end_date');
        
$end_calendar->set_date($end_date);
        
$end_calendar->set_style('margin-left:150px;');
        
        
$Template->set_filenames(array('download' => 'download/download.tpl'));
        
        if (
$file_size 1)
            
$size_tpl $file_size ' ' $LANG['unit_megabytes'];
        elseif (
$file_size 0)
            
$size_tpl = ($file_size 1024) . ' ' $LANG['unit_kilobytes'];
        else
            
$size_tpl $DOWNLOAD_LANG['unknown_size'];
        
        
//Calendars creation
        
$creation_calendar = new MiniCalendar('creation');
        
$creation_calendar->set_date($file_creation_date);
        
$release_calendar = new MiniCalendar('release_date');
        
$release_calendar->set_date($file_release_date);
        
        if (
$file_visibility || $file_visibility 2)
            
$file_visibility 0;

        
$Template->assign_vars(array(
            
'C_DISPLAY_DOWNLOAD' => true,
            
'C_IMG' => !empty($file_image),
            
'C_EDIT_AUTH' => false,
            
'MODULE_DATA_PATH' => $Template->get_module_data_path('download'),
            
'NAME' => stripslashes($file_title)." ".$version,
            
'CONTENTS' => second_parse(stripslashes(strparse($file_contents))),
            
'CREATION_DATE' => $file_creation_date->format(DATE_FORMAT_SHORT) ,
            
'RELEASE_DATE' => $file_release_date->get_timestamp() > $file_release_date->format(DATE_FORMAT_SHORT) : $DOWNLOAD_LANG['unknown_date'],
            
'SIZE' => $size_tpl,
            
'COUNT' => $file_hits,
            
'THEME' => get_utheme(),
            
'HITS' => sprintf($DOWNLOAD_LANG['n_times'], (int)$file_hits),
            
'NUM_NOTES' => sprintf($DOWNLOAD_LANG['num_notes'], 0),
            
'U_IMG' => $file_image,
            
'IMAGE_ALT' => str_replace('"''"'$file_title),
            
'LANG' => get_ulang(),
            
'CONTRIBUTION_COUNTERPART' => $contribution_counterpart_source,
            
'CONTRIBUTION_COUNTERPART_PREVIEW' => second_parse(stripslashes($contribution_counterpart)),
            
'FORCE_DOWNLOAD_SELECTED' => $file_download_method == 'force_download' ' selected="selected"' '',
            
'REDIRECTION_SELECTED' => $file_download_method != 'force_download' ' selected="selected"' '',
            
// Those langs are required by the template inclusion
            
'L_DATE' => $LANG['date'],
            
'L_SIZE' => $LANG['size'],
            
'L_DOWNLOAD' => $DOWNLOAD_LANG['download'],
            
'L_DOWNLOAD_FILE' => $DOWNLOAD_LANG['download_file'],
            
'L_FILE_INFOS' => $DOWNLOAD_LANG['file_infos'],
            
'L_INSERTION_DATE' => $DOWNLOAD_LANG['insertion_date'],
            
'L_RELEASE_DATE' => $DOWNLOAD_LANG['release_date'],
            
'L_DOWNLOADED' => $DOWNLOAD_LANG['downloaded'],
            
'L_NOTE' => $LANG['note'],
            
'SYSTEME'=>$file_infos['systeme'],
            
'LANGUE'=>$file_infos['langue'],
            
'VERSION'=>$file_infos['version'],
            
'LICENCE'=>$file_infos['licence'],
            
'APPROVED' => ' checked="checked"',
            
'U_DOWNLOAD_FILE' => url('count.php?id=' $edit_file_id'file-' $edit_file_id '+' url_encode_rewrite($file_title) . '.php')
        ));

        
$Template->assign_vars(array(
            
'C_CONTRIBUTION' => !$auth_write,
            
'TITLE' => stripslashes($file_title),
            
'COUNT' => $file_hits,
            
'DESCRIPTION' => stripslashes($file_contents),
            
'SHORT_DESCRIPTION' => stripslashes($file_short_contents),
            
'FILE_IMAGE' => $file_image,
            
'URL' => $file_url,
            
'SIZE_FORM' => $file_size,
            
'DATE' => $file_creation_date->format(DATE_FORMAT_SHORTTIMEZONE_AUTO),
            
'CATEGORIES_TREE' => $auth_write ?
                                    
$download_categories->build_select_form($file_cat_id'idcat''idcat'0DOWNLOAD_WRITE_CAT_AUTH_BIT$CONFIG_DOWNLOAD['global_auth'], IGNORE_AND_CONTINUE_BROWSING_IF_A_CATEGORY_DOES_NOT_MATCH) :
                                    
$download_categories->build_select_form($file_cat_id'idcat''idcat'0DOWNLOAD_CONTRIBUTION_CAT_AUTH_BIT$CONFIG_DOWNLOAD['global_auth'], IGNORE_AND_CONTINUE_BROWSING_IF_A_CATEGORY_DOES_NOT_MATCH),
            
'SHORT_DESCRIPTION_PREVIEW' => second_parse(stripslashes(strparse($file_short_contents))),
            
'VISIBLE_WAITING' => $file_visibility == ' checked="checked"' '',
            
'VISIBLE_ENABLED' => $file_visibility == ' checked="checked"' '',
            
'VISIBLE_HIDDEN' => $file_visibility == ' checked="checked"' '',
            
'APPROVED' => $file_approved ' checked="checked"' '',
            
'DATE_CALENDAR_CREATION' => $creation_calendar->display(),
            
'DATE_CALENDAR_RELEASE' => $release_calendar->display(),
            
'BOOL_IGNORE_RELEASE_DATE' => $ignore_release_date 'true' 'false',
            
'STYLE_FIELD_RELEASE_DATE' => $ignore_release_date 'none' 'block',
            
'IGNORE_RELEASE_DATE_CHECKED' => $ignore_release_date ' checked="checked"' '',
            
'BEGINING_CALENDAR' => $begining_calendar->display(),
            
'END_CALENDAR' => $end_calendar->display(),
        ));
    }
    else
    {
        
$file_creation_date = new Date(DATE_NOWTIMEZONE_AUTO);
        
$file_release_date = new Date(DATE_NOWTIMEZONE_AUTO);
        
        
$creation_calendar = new MiniCalendar('creation');
        
$creation_calendar->set_date($file_creation_date);
        
        
$release_calendar = new MiniCalendar('release_date');
        
$ignore_release_date false;
        if (!
$ignore_release_date)
            
$release_calendar->set_date($file_release_date);
        
        
        
$begining_calendar = new MiniCalendar('begining_date');
        
$end_calendar = new MiniCalendar('end_date');
        
$end_calendar->set_style('margin-left:150px;');
        
        
$begining_calendar->set_date(new Date(DATE_NOWTIMEZONE_AUTO));
        
$end_calendar->set_date(new Date(DATE_NOWTIMEZONE_AUTO));
        
$file_visibility 0;
        
        
$Template->assign_vars(array(
            
'C_CONTRIBUTION' => !$auth_write,
            
'TITLE' => '',
            
'COUNT' => 0,
            
'DESCRIPTION' => '',
            
'SHORT_DESCRIPTION' => '',
            
'FILE_IMAGE' => '',
            
'URL' => '',
            
'SIZE_FORM' => '',
            
'DATE' => $file_creation_date->format(DATE_FORMAT_SHORTTIMEZONE_AUTO),
            
'CATEGORIES_TREE' => $auth_write ?
                                    
$download_categories->build_select_form($file_cat_id'idcat''idcat'0DOWNLOAD_WRITE_CAT_AUTH_BIT$CONFIG_DOWNLOAD['global_auth'], IGNORE_AND_CONTINUE_BROWSING_IF_A_CATEGORY_DOES_NOT_MATCH) :
                                    
$download_categories->build_select_form($file_cat_id'idcat''idcat'0DOWNLOAD_CONTRIBUTION_CAT_AUTH_BIT$CONFIG_DOWNLOAD['global_auth'], IGNORE_AND_CONTINUE_BROWSING_IF_A_CATEGORY_DOES_NOT_MATCH),
            
'DATE_CALENDAR_CREATION' => $creation_calendar->display(),
            
'DATE_CALENDAR_RELEASE' => $release_calendar->display(),
            
'BOOL_IGNORE_RELEASE_DATE' => $ignore_release_date 'true' 'false',
            
'STYLE_FIELD_RELEASE_DATE' => $ignore_release_date 'none' 'block',
            
'IGNORE_RELEASE_DATE_CHECKED' => $ignore_release_date ' checked="checked"' '',
            
'BEGINING_CALENDAR' => $begining_calendar->display(),
            
'END_CALENDAR' => $end_calendar->display(),
            
'VISIBLE_WAITING' => '',
            
'VISIBLE_ENABLED' => ' checked="checked"',
            
'VISIBLE_HIDDEN' => '',
            
'APPROVED' => $file_approved ' checked="checked"' '',
            
'FORCE_DOWNLOAD_SELECTED' => ' selected="selected"',
            
'REDIRECTION_SELECTED' => ' selected="selected"',
            
'U_TARGET' => url('management.php?new=1&token=' $Session->get_token())
        ));
    }
    
$Template->assign_vars(array(
        
'L_NOTICE_CONTRIBUTION' => $DOWNLOAD_LANG['notice_contribution'],
        
'L_CONTRIBUTION_COUNTERPART' => $DOWNLOAD_LANG['contribution_counterpart'],
        
'L_CONTRIBUTION_COUNTERPART_EXPLAIN' => $DOWNLOAD_LANG['contribution_counterpart_explain'],
        
'CONTRIBUTION_COUNTERPART_EDITOR' => display_editor('counterpart')
    ));
}

$Template->pparse('file_management');
require_once(
'../kernel/footer.php');

?>

pm http://www.phpboost.com    
Visiteurs
   Le 23/08/09 à 14h41 Citer      

Boosteur Inactif

Groupe: Visiteur



Je peux pas lire le sujet sur la page n°2

   
   Le 25/08/09 à 20h52 Citer      

Booster Bazooka

Groupe: Membre

Inscrit le: 19/08/09
Messages: 103
Merci. Mais je ne veux pas dire mais ce qu'à donner ReidLos, les "morceaux de code" c'est bourré de faute :s

Mais merci pour tout quand même ;)



Edité par iPremium Le 25/08/09 à 21h45

pm    
   Le 26/08/09 à 12h16 Citer      

Booster Fusée

Groupe: Membre

Sexe:
Inscrit le: 30/12/07
Messages: 3603
Lieu: Tours (37)
iPremium:
Merci. Mais je ne veux pas dire mais ce qu'à donner ReidLos, les "morceaux de code" c'est bourré de faute :s

Dans ce cas, il aurait été plus constructif et plus utile à la communauté de donner les corrections nécessaires, sinon, ton message est parfaitement inutile.
____________________
Shadow
"Quand tu ranges chez toi, ça fout le bordel chez ton voisin". - Règle d'entropie générale adaptée aux usages domestiques.

pm http://lelienlacte.com    
   Le 26/08/09 à 12h43 Citer      

Administrateur

Chef de projet
Développement Noyau

Sexe:
Inscrit le: 27/02/09
Messages: 7992
Lieu: Alsace
les morceaux de code ne sont pas bouré de fautes, mais je vous laisse réfléchir, déjà que je vous donne l'astuce, a vous de voir que la et ici il faut enlever la virgule etc

pm http://www.phpboost.com    
   Le 27/11/09 à 03h19 Citer      

Booster Bazooka

Groupe: Membre

Sexe:
Inscrit le: 11/07/08
Messages: 201
Lieu: Chouzy sur Ciss...
Hello,

J'ai suivi le tuto à la lettre , le nouveau champs s'affiche donc bien, merci ReidLos
Cependant, le nom de l'auteur ne s'affiche pas en face du champs auteur, qu'est ce que j'ai fait de travers :hehe
Avez vous besoin que je vous fournisse le code d'un des fichiers modifié?

Merci bien par avance



Edité par Fisheur Le 27/11/09 à 03h20

pm http://localhost    
   Le 11/11/10 à 20h54 Citer      

Booster Bazooka

Groupe: Membre

Sexe:
Inscrit le: 01/05/10
Messages: 125
bonjour , j'ai un petit problème avec cette astuce . quand je prévisualise une fiche j'ai cette erreur :

Code PHP :
Suggestion : Undefined variable: file_infos dans le fichier /var/www/vhosts/inforumatique.fr/httpdocs/site/download/management.php à la ligne 666
Suggestion : Undefined variable: file_infos dans le fichier /var/www/vhosts/inforumatique.fr/httpdocs/site/download/management.php à la ligne 667
Suggestion : Undefined variable: file_infos dans le fichier /var/www/vhosts/inforumatique.fr/httpdocs/site/download/management.php à la ligne 668
Suggestion : Undefined variable: file_infos dans le fichier /var/www/vhosts/inforumatique.fr/httpdocs/site/download/management.php à la ligne 669 


cette erreur n'apparait pas a la prévisualisation d'une fiche qu'on edit , mais seulement d'une fiche qu'on créer .

vvoici les lignes dans ce fichier :

Code PHP :
			'SYSTEME'=>$file_infos['systeme'],
			'LANGUE'=>$file_infos['langue'],
			'VERSION'=>$file_infos['version'],
			'LICENCE'=>$file_infos['licence'],
____________________
 
 
 

   

pm http://www.inforumatique.fr/    
   Le 12/11/10 à 07h50 Citer      

Booster Mortier

Groupe: Membre

Sexe:
Inscrit le: 11/11/09
Messages: 558
Lieu: Nice (06)
LOOL le déterrage, je pense que cette modification n'est pas pour la 3.0 tout simplement...

pm    
   Le 12/11/10 à 08h51 Citer      

Booster Fusée

Groupe: Membre

Sexe:
Inscrit le: 30/12/07
Messages: 3603
Lieu: Tours (37)
Si, la 3.0 était sortie à l'époque. Tony, évite de t'immiscer dans les sujets des autres membres lorsque tu n'es pas sûr de la pertinence de tes interventions.
____________________
Shadow
"Quand tu ranges chez toi, ça fout le bordel chez ton voisin". - Règle d'entropie générale adaptée aux usages domestiques.

pm http://lelienlacte.com    
   Le 12/11/10 à 18h35 Citer      

Booster Bazooka

Groupe: Membre

Sexe:
Inscrit le: 01/05/10
Messages: 125
désolé pour le deterage de ce sujet , mais cette astuce est encore d'actu , la preuve je l'utilise ;)

ça marche bien a part cette erreure , je crois l'avoir résolu avec un deplacement de ces lignes , qui etait a un mauvais endroit , j'attend le retour de mon equipe la dessus .


EDIT: en fait non l'erreur est toujours présente :(



Edité par Peter Parker Le 13/11/10 à 00h29
____________________
 
 
 

   

pm http://www.inforumatique.fr/    
2 Utilisateurs en ligne :: 0 Administrateur, 0 Modérateur, 0 Membre et 2 Visiteurs
Utilisateurs en ligne: Aucun membre connecté
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie
Annonces