Changeset 13 for branches/download

Show
Ignore:
Timestamp:
02/08/09 17:52:03 (3 years ago)
Author:
daris
Message:

download: some other changes

Location:
branches/download
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • branches/download/admin/download.php

    r12 r13  
    179179        // Fetch page info 
    180180        $query = array( 
    181                         'SELECT'        => 'd.name, d.cat, d.file, d.description, d.version, d.approved', 
     181                        'SELECT'        => 'd.name, d.cat, d.description, d.author, d.version, d.approved', 
    182182                        'FROM'          => 'downloads AS d', 
    183183                        'WHERE'         => 'd.id='.$download_id 
     
    203203                $file = isset($_POST['file']) ? basename($_POST['file']) : null; 
    204204                $version = forum_trim($_POST['version']); 
     205                $author = forum_trim($_POST['author']); 
    205206                $approved = isset($_POST['approved']) ? 1 : 0; 
    206207 
     
    208209                        message($lang_admin_download['Must enter download message']); 
    209210 
    210                 if (isset($_FILES['file_upload']) && is_uploaded_file($_FILES['file_upload']['tmp_name'])) 
     211/*              if (isset($_FILES['file_upload']) && is_uploaded_file($_FILES['file_upload']['tmp_name'])) 
    211212                { 
    212213                        $file_upload = $_FILES['file_upload']['name']; 
    213                         $file_ext = substr($file_upload, strrpos($file_upload, '.')); 
     214                        $file_ext = substr($file_upload, strrpos($file_upload, '.')+1); 
    214215                 
    215216                        if ($file_ext != 'zip') 
     
    231232 
    232233                        move_uploaded_file($_FILES['file_upload']['tmp_name'], DOWNLOAD.'files/'.$file); 
    233                 } 
     234                }*/ 
    234235 
    235236                $query = array( 
    236237                        'UPDATE'        => 'downloads', 
    237                         'SET'           => 'name=\''.$forum_db->escape($name).'\', description=\''.$forum_db->escape($description).'\', cat='.$cat.', file=\''.$forum_db->escape($file).'\', version=\''.$forum_db->escape($version).'\', approved='.$approved, 
     238                        'SET'           => 'name=\''.$forum_db->escape($name).'\', description=\''.$forum_db->escape($description).'\', cat='.$cat.', file=\''.$forum_db->escape($file).'\', version=\''.$forum_db->escape($version).'\', author=\''.$forum_db->escape($author).'\', approved='.$approved, 
    238239                        'WHERE'         => 'id='.$download_id 
    239240                ); 
     
    242243                $forum_db->query_build($query) or error(__FILE__, __LINE__); 
    243244 
     245                move_uploaded_file($_FILES['file_upload']['tmp_name'], DOWNLOAD.'files/'.$forum_db->insert_id().'.zip'); 
     246                 
    244247                ($hook = get_hook('afo_save_forum_pre_redirect')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; 
    245248 
     
    319322                                        </div> 
    320323                                </div> 
    321 <?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?> 
     324<?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null;/* ?> 
    322325                                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>"> 
    323326                                        <div class="sf-box select"> 
     
    340343                                        </div> 
    341344                                </div> 
    342 <?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?> 
     345<?php*/ ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?> 
    343346                                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>"> 
    344347                                        <div class="sf-box text"> 
     
    347350                                        </div> 
    348351                                </div> 
     352<?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?> 
     353                                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>"> 
     354                                        <div class="sf-box text"> 
     355                                                <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Download author'] ?></span></label><br /> 
     356                                                <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="author" size="20" maxlength="80" value="<?php echo forum_htmlencode($cur_download['author']) ?>" /></span> 
     357                                        </div> 
     358                                </div>   
    349359<?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?> 
    350360                                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>"> 
  • branches/download/download.php

    r12 r13  
    2121        // Fetch list of downloads 
    2222        $query = array( 
    23                 'SELECT'        => 'd.name, d.file, d.version', 
     23                'SELECT'        => 'd.name, d.version', 
    2424                'FROM'          => 'downloads AS d', 
    2525                'WHERE'         => 'd.id=\''.$id.'\'', 
     
    3838        $cur_file = $forum_db->fetch_assoc($result); 
    3939 
    40         $file = DOWNLOAD.'files/'.$cur_file['file']; 
    41  
    42         if (!file_exists($file) || trim($cur_file['file']) == '') 
     40        $file = DOWNLOAD.'files/'.$id.'.zip'; 
     41 
     42        if (!file_exists($file)) 
    4343                message($lang_download['File not found']); 
    4444         
     
    126126        // Fetch list of downloads 
    127127        $query = array( 
    128                 'SELECT'        => 'd.id, d.name, d.description, d.version, d.downloads', 
     128                'SELECT'        => 'd.id, d.name, d.description, d.version, d.downloads, d.author, d.user_id, d.added, u.username', 
    129129                'FROM'          => 'downloads AS d', 
     130                'JOINS'         => array( 
     131                        array( 
     132                                'LEFT JOIN'             => 'users AS u', 
     133                                'ON'                    => 'd.user_id=u.id' 
     134                        ), 
     135                ), 
    130136                'WHERE'         => 'd.cat='.$cat.' AND d.approved=1', 
    131137                'LIMIT'         => $forum_page['start_from'].', '.$forum_page['disp_downloads'], 
     
    178184                { 
    179185                        $version_string = (trim($cur_download['version']) == '') ? '' : ' v'.forum_htmlencode($cur_download['version']); 
     186                        $download_url = forum_link($forum_url['download_id'], array($cat, sef_friendly($cur_cat['name']), $cur_download['id'], sef_friendly($cur_download['name']))); 
     187                         
     188                        $forum_page['info'] = array(); 
     189 
     190                        $forum_page['info'][] = '<a href="'.$download_url.'">'.$lang_download['Download'].'</a>'; 
     191                         
     192                        $forum_page['info'][] = sprintf($lang_download['Download count'], $cur_download['downloads']); 
     193 
     194                        if ($cur_download['user_id'] > 0) 
     195                        $forum_page['info'][] = $lang_download['Added by'].' <a href="'.forum_link($forum_url['user'], array($cur_download['user_id'])).'">'.forum_htmlencode($cur_download['username']).'</a>'; 
     196 
     197                        if ($cur_download['author']) 
     198                                $forum_page['info'][] = $lang_download['Author'].' '.forum_htmlencode($cur_download['author']); 
     199 
     200                        if ($cur_download['added']) 
     201                                $forum_page['info'][] = $lang_download['Added time'].' '.format_time($cur_download['added']); 
     202                         
    180203?>               
    181204                        <div class="ct-box data-box download"> 
    182                                 <h2 class="hn"><strong><?php echo forum_htmlencode($cur_download['name']) ?></strong><?php echo $version_string ?></h2> 
     205                                <h2 class="hn"><strong><a href="<?php echo $download_url ?>"><?php echo forum_htmlencode($cur_download['name']) ?></a></strong><?php echo $version_string ?></h2> 
    183206<?php if ($cur_download['description']) : ?>                    <p><?php echo forum_htmlencode($cur_download['description']) ?></p><?php endif; ?> 
    184                                 <p><a href="<?php echo forum_link($forum_url['download_id'], array($cat, sef_friendly($cur_cat['name']), $cur_download['id'], sef_friendly($cur_download['name']))) ?>"><?php echo $lang_download['Download'] ?></a> (<?php printf($lang_download['Download count'], $cur_download['downloads']) ?>)</p> 
     207                                <p><?php echo implode(' | ', $forum_page['info']) ?></p> 
    185208                        </div> 
    186209<?php 
  • branches/download/install.php

    r11 r13  
    7878                                        'default'       => '1.0' 
    7979                                ), 
    80                                 'file'                  => array( 
     80                                'author'                        => array( 
     81                                        'datatype'              => 'VARCHAR(255)', 
     82                                        'allow_null'    => true, 
     83                                ), 
     84/*                              'file'                  => array( 
    8185                                        'datatype'              => 'VARCHAR(255)', 
    8286                                        'allow_null'    => true 
    83                                 ), 
     87                                ),*/ 
    8488                                'downloads'                     => array( 
    8589                                        'datatype'              => 'INT(10) UNSIGNED', 
     
    9296                                        'default'       => 0 
    9397                                ), 
     98                                'user_id'                       => array( 
     99                                        'datatype'              => 'INT(10) UNSIGNED', 
     100                                        'allow_null'    => true, 
     101                                ), 
     102                                'added'                 => array( 
     103                                        'datatype'              => 'INT(10) UNSIGNED', 
     104                                        'allow_null'    => true, 
     105                                ), 
    94106                        ), 
    95107                        'PRIMARY KEY'   => array('id') 
     
    99111                $forum_db->query('INSERT INTO '.$forum_db->prefix.'downloads (name, description, approved) VALUES (\'Geshi highlight\', \'test\', 1)') or error(__FILE__, __LINE__); 
    100112                 
    101                 for ($i = 1; $i < 20; $i++) 
    102                         $forum_db->query('INSERT INTO '.$forum_db->prefix.'downloads (name, description, approved) VALUES (\'Extension '.$i.'\', \'test\', 1)') or error(__FILE__, __LINE__); 
     113/*              for ($i = 1; $i < 20; $i++) 
     114                        $forum_db->query('INSERT INTO '.$forum_db->prefix.'downloads (name, description, approved) VALUES (\'Extension '.$i.'\', \'test\', 1)') or error(__FILE__, __LINE__);*/ 
    103115 
    104116        } 
  • branches/download/lang/English/admin_download.php

    r12 r13  
    4040'Download version'                                      => 'Download version:', 
    4141'Download version help'                         => 'You can leave this field empty', 
     42'Download author'                                       => 'Author:', 
    4243 
    4344'Downloads for approve'                         => 'Downloads for approve', 
     
    5152'Submit download info'                          => 'Your download must be accepted by administrator.', 
    5253'Upload file'                                           => 'Upload file:', 
     54'Download submited redirect'            => 'Download submited. Redirecting�', 
    5355 
    5456'Invalid extension'                                     => 'Invalid extension', 
  • branches/download/lang/English/download.php

    r12 r13  
    1515'Download not found'                    => 'Download not found', 
    1616'File not found'                                => 'File not found', 
     17 
     18'Added by'                                              => 'Added by:', 
     19'Author'                                                => 'Author:', 
     20'Added time'                                    => 'Added:', 
    1721); 
  • branches/download/submit_download.php

    r12 r13  
    3333        $cat = intval($_POST['cat']); 
    3434        $version = forum_trim($_POST['version']); 
     35        $author = forum_trim($_POST['author']); 
    3536 
    3637        if ($name == '') 
     
    4041        { 
    4142                $file_upload = $_FILES['file_upload']['name']; 
    42                 $file_ext = substr($file_upload, strrpos($file_upload, '.')); 
     43                $file_ext = substr($file_upload, strrpos($file_upload, '.')+1); 
    4344                 
    4445                if ($file_ext != 'zip') 
    4546                        message($lang_admin_download['Invalid extension']); 
    4647                 
    47                 if (file_exists(DOWNLOAD.'files/'.$file_upload)) 
     48/*              if (file_exists(DOWNLOAD.'files/'.$file_upload)) 
    4849                { 
    4950                        // Get new name for file 
     
    5657                } 
    5758                else 
    58                         $file = $_FILES['file_upload']['name']; 
    59  
    60                 move_uploaded_file($_FILES['file_upload']['tmp_name'], DOWNLOAD.'files/'.$file); 
     59                        $file = $_FILES['file_upload']['name'];*/ 
    6160        } 
    6261 
    6362        $query = array( 
    64                 'INSERT'        => 'name, description, cat, file, version', 
     63                'INSERT'        => 'name, description, cat, author, version, user_id, added', 
    6564                'INTO'          => 'downloads', 
    66                 'VALUES'        => '\''.$forum_db->escape($name).'\', \''.$forum_db->escape($description).'\', '.$cat.', \''.$forum_db->escape($file).'\', \''.$forum_db->escape($version).'\'', 
     65                'VALUES'        => '\''.$forum_db->escape($name).'\', \''.$forum_db->escape($description).'\', '.$cat.', \''.$forum_db->escape($author).'\', \''.$forum_db->escape($version).'\', \''.$forum_db->escape($forum_user['id']).'\', '.time(), 
    6766        ); 
    6867         
     
    7675        $forum_db->query_build($query) or error(__FILE__, __LINE__); 
    7776 
     77        move_uploaded_file($_FILES['file_upload']['tmp_name'], DOWNLOAD.'files/'.$forum_db->insert_id().'.zip'); 
     78 
    7879        ($hook = get_hook('afo_save_forum_pre_redirect')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; 
    7980 
    80         redirect(forum_link($forum_url['download']), $lang_admin_download['Download submited'].' '.$lang_common['Redirect']); 
     81        redirect(forum_link($forum_url['download']), $lang_admin_download['Download submited redirect']); 
    8182} 
    8283 
     
    160161                                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>"> 
    161162                                        <div class="sf-box text"> 
     163                                                <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Download author'] ?></span></label><br /> 
     164                                                <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="author" size="20" maxlength="80" value="<?php echo forum_htmlencode($forum_user['username']) ?>" /></span> 
     165                                        </div> 
     166                                </div>   
     167<?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?> 
     168 
     169                                <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>"> 
     170                                        <div class="sf-box text"> 
    162171                                                <label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_admin_download['Download version'] ?></span><small><?php echo $lang_admin_download['Download version help'] ?></small></label><br /> 
    163172                                                <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="version" size="20" maxlength="80" /></span> 
    164173                                        </div> 
    165                                 </div>   
     174                                </div> 
    166175<?php ($hook = get_hook('afo_edit_forum_pre_forum_name')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; ?> 
    167176                                <div class="txt-set set<?php echo ++$forum_page['item_count'] ?>">