Changeset 15 for branches/download

Show
Ignore:
Timestamp:
02/09/09 17:07:27 (3 years ago)
Author:
daris
Message:

download: some changes

Location:
branches/download
Files:
1 added
7 modified

Legend:

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

    r13 r15  
    2929        require DOWNLOAD.'lang/English/admin_download.php'; 
    3030 
     31if (file_exists(DOWNLOAD.'lang/'.$forum_user['language'].'/download.php')) 
     32        require DOWNLOAD.'lang/'.$forum_user['language'].'/download.php'; 
     33else 
     34        require DOWNLOAD.'lang/English/download.php'; 
    3135 
    3236// Add a "default" forum 
     
    201205                $description = forum_linebreaks(forum_trim($_POST['description'])); 
    202206                $cat = intval($_POST['cat']); 
    203                 $file = isset($_POST['file']) ? basename($_POST['file']) : null; 
     207//              $file = isset($_POST['file']) ? basename($_POST['file']) : null; 
    204208                $version = forum_trim($_POST['version']); 
    205209                $author = forum_trim($_POST['author']); 
     
    236240                $query = array( 
    237241                        'UPDATE'        => 'downloads', 
    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, 
     242                        'SET'           => 'name=\''.$forum_db->escape($name).'\', description=\''.$forum_db->escape($description).'\', cat='.$cat.', version=\''.$forum_db->escape($version).'\', author=\''.$forum_db->escape($author).'\', approved='.$approved, 
    239243                        'WHERE'         => 'id='.$download_id 
    240244                ); 
     
    243247                $forum_db->query_build($query) or error(__FILE__, __LINE__); 
    244248 
    245                 move_uploaded_file($_FILES['file_upload']['tmp_name'], DOWNLOAD.'files/'.$forum_db->insert_id().'.zip'); 
     249                move_uploaded_file($_FILES['file_upload']['tmp_name'], DOWNLOAD.'files/'.$download_id.'.zip'); 
    246250                 
    247251                ($hook = get_hook('afo_save_forum_pre_redirect')) ? (defined('FORUM_USE_INCLUDE') ? include $hook : eval($hook)) : null; 
  • branches/download/download.php

    r13 r15  
    1414        require_once DOWNLOAD.'lang/English/download.php'; 
    1515 
     16require_once FORUM_ROOT.'include/parser.php'; 
     17 
    1618$id = isset($_GET['id']) ? intval($_GET['id']) : null; 
    1719$cat = isset($_GET['cat']) ? intval($_GET['cat']) : null; 
    18  
    19 if (isset($id)) 
     20$get = isset($_GET['get']) ? 1 : 0; 
     21 
     22if (isset($id) && $get) 
    2023{ 
    2124        // Fetch list of downloads 
     
    5962         
    6063        //@ob_end_clean(); //turn off output buffering to decrease cpu usage 
    61          
    6264        header('Content-Type: application/zip'); 
    6365        header('Content-Disposition: attachment; filename="'.rawurldecode($url).'"'); 
    64         header("Content-Transfer-Encoding: binary"); 
    65         header('Accept-Ranges: bytes'); 
     66/*      header("Content-Transfer-Encoding: binary"); 
     67        header('Accept-Ranges: bytes');*/ 
    6668        header("Content-Length: ".filesize($file)); 
    6769         
     
    136138                'WHERE'         => 'd.cat='.$cat.' AND d.approved=1', 
    137139                'LIMIT'         => $forum_page['start_from'].', '.$forum_page['disp_downloads'], 
    138                 'ORDER BY'      => 'd.name' 
     140                'ORDER BY'      => 'd.name AND d.version' 
    139141        ); 
    140142 
     
    161163        $form_action = DOWNLOAD.'download.php'; 
    162164 
     165        ob_start(); 
    163166 
    164167?> 
     
    167170                <h2 class="hn"><span><?php echo $forum_page['items_info'] ?></span></h2> 
    168171        </div> 
    169  
    170 <?php if (isset($cur_cat['description'])) : ?> 
     172<!-- 
    171173        <div class="main-subhead"> 
    172                 <h2 class="hn"><span><?php echo forum_htmlencode($cur_cat['description']) ?></span></h2> 
    173         </div> 
     174                <h2 class="hn"><?php echo forum_htmlencode($cur_cat['description']) ?></h2> 
     175        </div> 
     176--> 
     177        <div class="main-content main-frm"> 
     178 
     179<?php if (isset($cur_cat['description'])) : ?>   
     180                        <div class="ct-box info-box"> 
     181                                <h2 class="hn"><?php echo forum_htmlencode($cur_cat['description']) ?></h2> 
     182                        </div> 
    174183<?php endif; ?> 
    175  
    176         <div class="main-content main-frm"> 
    177184 
    178185<?php 
     
    184191                { 
    185192                        $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                        $download_info_array = array($cat, sef_friendly($cur_cat['name']), $cur_download['id'], sef_friendly($cur_download['name'])); 
     195                         
     196                        $download_get_url = forum_link($forum_url['download_get'], $download_info_array); 
     197                        $download_url = forum_link($forum_url['download_id'], $download_info_array); 
     198                         
     199                        $forum_page['download'] = array(); 
     200                        $forum_page['download']['info'] = array(); 
     201 
     202                        $forum_page['download']['info'][] = '<a href="'.$download_get_url.'">'.$lang_download['Download'].'</a>'; 
     203                         
     204                        $forum_page['download']['info'][] = sprintf($lang_download['Download count'], $cur_download['downloads']); 
     205 
     206                        if ($cur_download['author']) 
     207                                $forum_page['download']['info'][] = $lang_download['Author'].' '.forum_htmlencode($cur_download['author']); 
    193208 
    194209                        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']); 
     210                        $forum_page['download']['info'][] = $lang_download['Added by'].' <a href="'.forum_link($forum_url['user'], array($cur_download['user_id'])).'">'.forum_htmlencode($cur_download['username']).'</a>'; 
    199211 
    200212                        if ($cur_download['added']) 
    201                                 $forum_page['info'][] = $lang_download['Added time'].' '.format_time($cur_download['added']); 
     213                                $forum_page['download']['info'][] = $lang_download['Added time'].' '.format_time($cur_download['added']); 
     214                         
     215                        $forum_page['download']['description'] = parse_message($cur_download['description'], true); 
     216 
    202217                         
    203218?>               
    204                         <div class="ct-box data-box download"> 
     219                        <div class="ct-box data-box download entry-content"> 
    205220                                <h2 class="hn"><strong><a href="<?php echo $download_url ?>"><?php echo forum_htmlencode($cur_download['name']) ?></a></strong><?php echo $version_string ?></h2> 
    206 <?php if ($cur_download['description']) : ?>                    <p><?php echo forum_htmlencode($cur_download['description']) ?></p><?php endif; ?> 
    207                                 <p><?php echo implode(' | ', $forum_page['info']) ?></p> 
     221                                <?php echo $forum_page['download']['description'] ?> 
     222                                <p><?php echo implode(' | ', $forum_page['download']['info']) ?></p> 
    208223                        </div> 
    209224<?php 
     
    231246        require FORUM_ROOT.'footer.php'; 
    232247} 
     248elseif (isset($id)) 
     249{ 
     250 
     251        // Fetch list of downloads 
     252        $query = array( 
     253                'SELECT'        => 'd.id, d.name, d.cat, d.description, d.version, d.downloads, d.author, d.user_id, d.added, u.username, c.name as catname', 
     254                'FROM'          => 'downloads AS d', 
     255                'JOINS'         => array( 
     256                        array( 
     257                                'LEFT JOIN'             => 'users AS u', 
     258                                'ON'                    => 'd.user_id=u.id' 
     259                        ), 
     260                        array( 
     261                                'LEFT JOIN'             => 'downloads_cats AS c', 
     262                                'ON'                    => 'd.cat=c.id' 
     263                        ), 
     264                ), 
     265                'WHERE'         => 'd.id='.$id.' AND d.approved=1', 
     266        ); 
     267 
     268        ($hook = get_hook('xn_portal_by_daris_nw_qr_get_news')) ? eval($hook) : null; 
     269        $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); 
     270 
     271        // If there are news in selected forums 
     272        if ($forum_db->num_rows($result) == 0) 
     273                message('Download not exists'); 
     274 
     275        $cur_download = $forum_db->fetch_assoc($result); 
     276         
     277        // Setup breadcrumbs 
     278        $forum_page['crumbs'] = array( 
     279                array($forum_config['o_board_title'], forum_link($forum_url['index'])), 
     280                array($lang_download['Downloads'], forum_link($forum_url['download'])), 
     281                array(forum_htmlencode($cur_download['catname']), forum_link($forum_url['download_cat'], array($cur_download['cat'], sef_friendly($cur_download['catname'])))), 
     282                array(forum_htmlencode($cur_download['name']), forum_link($forum_url['download_id'], array($cur_download['cat'], sef_friendly($cur_download['catname'], $id, sef_friendly($cur_download['name']))))) 
     283        ); 
     284 
     285 
     286//      define('FORUM_PAGE_SECTION', 'management'); 
     287        define('FORUM_PAGE', 'download'); 
     288        define('FORUM_PAGE_TYPE', 'sectioned'); 
     289        require FORUM_ROOT.'header.php'; 
     290 
     291        ob_start(); 
     292 
     293?> 
     294        <div class="main-head"> 
     295                <h2 class="hn"><span><?php echo forum_htmlencode($cur_download['name']) ?></span></h2> 
     296        </div> 
     297 
     298        <div class="main-content main-frm"> 
     299 
     300<?php 
     301 
     302 
     303                $version_string = (trim($cur_download['version']) == '') ? '' : ' v'.forum_htmlencode($cur_download['version']); 
     304                 
     305                $download_info_array = array($cur_download['cat'], sef_friendly($cur_download['catname']), $cur_download['id'], sef_friendly($cur_download['name'])); 
     306                 
     307                $download_get_url = forum_link($forum_url['download_get'], $download_info_array); 
     308                $download_url = forum_link($forum_url['download_id'], $download_info_array); 
     309                 
     310                $forum_page['download'] = array(); 
     311                $forum_page['download']['info'] = array(); 
     312 
     313                $forum_page['download']['info'][] = '<a href="'.$download_get_url.'">'.$lang_download['Download'].'</a>'; 
     314                 
     315                $forum_page['download']['info'][] = sprintf($lang_download['Download count'], $cur_download['downloads']); 
     316 
     317                if ($cur_download['author']) 
     318                        $forum_page['download']['info'][] = $lang_download['Author'].' '.forum_htmlencode($cur_download['author']); 
     319 
     320                if ($cur_download['user_id'] > 0) 
     321                $forum_page['download']['info'][] = $lang_download['Added by'].' <a href="'.forum_link($forum_url['user'], array($cur_download['user_id'])).'">'.forum_htmlencode($cur_download['username']).'</a>'; 
     322 
     323                if ($cur_download['added']) 
     324                        $forum_page['download']['info'][] = $lang_download['Added time'].' '.format_time($cur_download['added']); 
     325                 
     326                $forum_page['download']['description'] = parse_message($cur_download['description'], true); 
     327 
     328                 
     329?>               
     330                        <div class="ct-box data-box download entry-content"> 
     331                                <h2 class="hn"><strong><a href="<?php echo $download_url ?>"><?php echo forum_htmlencode($cur_download['name']) ?></a></strong><?php echo $version_string ?></h2> 
     332                                <?php echo $forum_page['download']['description'] ?> 
     333                                <p><?php echo implode(' | ', $forum_page['download']['info']) ?></p> 
     334                        </div> 
     335        </div> 
     336        <div class="main-foot"> 
     337                <h2 class="hn"><span><?php echo forum_htmlencode($cur_download['name']) ?></span></h2> 
     338        </div> 
     339<?php 
     340        $tpl_temp = trim(ob_get_contents()); 
     341        $tpl_main = str_replace('<!-- forum_main -->', $tpl_temp, $tpl_main); 
     342        ob_end_clean(); 
     343        // END SUBST - <!-- forum_main --> 
     344 
     345        require FORUM_ROOT.'footer.php'; 
     346} 
    233347else 
    234348{ 
     
    279393        require FORUM_ROOT.'header.php'; 
    280394 
     395        ob_start(); 
    281396 
    282397?> 
     
    299414                while ($cur_cat = $forum_db->fetch_assoc($result)) 
    300415                { 
     416                        $forum_page['cat'] = array(); 
     417                        $forum_page['cat']['info'] =  array(); 
    301418                         
    302419                        // Fetch list of downloads 
     
    311428                         
    312429                        $files_count = $forum_db->result($result_downloads); 
     430         
     431                        // Fetch list of downloads 
     432                        $query_last_added = array( 
     433                                'SELECT'        => 'd.id, d.name, d.version', 
     434                                'FROM'          => 'downloads AS d', 
     435                                'WHERE'         => 'd.cat='.$cur_cat['id'].' AND d.approved=1', 
     436                                'ORDER BY'      => 'd.added DESC', 
     437                                'LIMIT'         => 5 
     438                        ); 
     439 
     440                        ($hook = get_hook('xn_portal_by_daris_nw_qr_get_news')) ? eval($hook) : null; 
     441                        $result_last_added = $forum_db->query_build($query_last_added) or error(__FILE__, __LINE__); 
     442 
     443                        $last_added = array(); 
     444                        while ($cur_download = $forum_db->fetch_assoc($result_last_added)) 
     445                                $last_added[] = '<a href="'.forum_link($forum_url['download_id'], array($cur_cat['id'], sef_friendly($cur_cat['name']), $cur_download['id'], sef_friendly($cur_download['name']))).'">'.forum_htmlencode($cur_download['name']).($cur_download['version'] != '' ? ' ('.forum_htmlencode($cur_download['version']).')' : '').'</a>'; 
     446                         
     447                        $forum_page['cat']['description'] = parse_message($cur_cat['description'], true); 
     448                         
     449                        if (count($last_added)) 
     450                                $forum_page['cat']['info'][] = $lang_download['Last added'].' '.implode(', ', $last_added); 
     451 
    313452?>               
    314453                        <div class="ct-box data-box download"> 
    315454                                <h2 class="hn"><a href="<?php echo forum_link($forum_url['download_cat'], array($cur_cat['id'], sef_friendly($cur_cat['name']))) ?>"><strong><?php echo forum_htmlencode($cur_cat['name']) ?></strong></a> (<?php printf($lang_download['Files count'], $files_count) ?>)</h2> 
    316 <?php if ($cur_cat['description']) : ?>                 <p><?php echo forum_htmlencode($cur_cat['description']) ?></p><?php endif; ?> 
     455                                <?php echo $forum_page['cat']['description'] ?> 
     456<?php if (count($forum_page['cat']['info'])) : ?>                               <p><?php echo implode(' | ', $forum_page['cat']['info']) ?></p><?php endif; ?> 
    317457                        </div> 
    318458<?php 
  • branches/download/include/url/Folder_based_(fancy)/forum_urls.php

    r10 r15  
    1616 
    1717$forum_url_portal = array( 
    18         'download'              => 'download/', 
    19         'download_cat'          => 'download/$1/$2/', 
    20         'download_id'           => 'download/$1/$2/$3/$4/', 
    21         'submit_download'       => 'download/submit/', 
    22         'submit_download_cat'=> 'download/submit/$1/$2/', 
    23         'admin_download'        => $portal_dir.'admin/download.php', 
     18        'download'                              => 'download/', 
     19        'download_cat'                  => 'download/$1/$2/', 
     20        'download_id'                   => 'download/$1/$2/$3/$4/', 
     21        'download_get'                  => 'download/$1/$2/$3/$4/get/', 
     22        'submit_download'               => 'download/submit/', 
     23        'submit_download_cat'   => 'download/submit/$1/$2/', 
     24        'admin_download'                => $portal_dir.'admin/download.php', 
     25        'admin_download_cats'   => $portal_dir.'admin/download_cats.php', 
    2426 
    2527); 
  • branches/download/include/url/Folder_based_(fancy)/rewrite_rules.php

    r10 r15  
    1818        '/^download\/submit(\.html?|\/)?$/i'                                            =>      $ext_info['path'].'/submit_download.php', 
    1919        '/^download\/([0-9]+)?\/.*?\/p(age)?\/?([0-9]+)\/$/i'           =>      'index.php?download&cat=$1&p=$3', 
     20        '/^download\/([0-9]+)\/.*?\/([0-9]+)\/.*?\/get\/$/i'            =>      'index.php?download&id=$2&get', 
    2021        '/^download\/([0-9]+)\/.*?\/([0-9]+)\/.*?\/$/i'                         =>      'index.php?download&id=$2', 
    2122        '/^download\/([0-9]+)\/.*?\/$/i'                                                        =>      'index.php?download&cat=$1', 
    2223        '/^download\/p(age)?\/?([0-9]+)\/$/i'                                           =>      'index.php?download&p=$2', 
    2324        '/^download(\.html?|\/)?$/i'                                                            =>      'index.php?download', 
    24         '/^download\/extensions[\/_-]?(.*?)(\.html?|\/)?$/i'            =>      'index.php?download&extension=$1', 
    2525); 
    2626 
  • branches/download/lang/English/admin_download.php

    r13 r15  
    5555 
    5656'Invalid extension'                                     => 'Invalid extension', 
     57 
     58// Categories 
     59'Download cats'                                         => 'Download cats', // menu 
     60 
     61'Edit category head'                            =>      'Edit category: %s', 
     62'Edit or delete'                                =>      '%s or %s', 
     63'Edit'                                                  =>      'Edit', 
     64'Delete'                                                =>      'Delete', 
     65'Category name'                                         =>      'Category name:', 
     66'Delete category'                                       =>      'Delete category', 
     67'Delete category warning'                       =>      'After deleting category you have to assign new category for each download in this category.', 
     68'Edit category'                                         =>      'Edit category', 
     69'Edit category details legend'          =>      'Category details:', 
     70'Add to category label'                 =>      'Add to category:', 
     71'Category description'                          =>      'Category description:', 
     72'Category description help'                             =>      'You may use BBCode in your description.', 
     73'Edit categorys head'                           =>      'Edit or delete category', 
     74'Edit category details head'            =>      'Edit category details', 
     75'Edit categories head'                          =>      'Edit categories', 
     76'Confirm delete category'                       =>      'You are deleting the category "%s"', 
     77'Add category'                                          =>      'Add category', 
     78'Add category head'                                     =>      'Add a new category', 
     79'Add category legend'                           =>      'Add category:', 
     80'Category added'                                        =>      'Category added.', 
     81'Category deleted'                                      =>      'Category deleted.', 
     82'Category updated'                                      =>      'Category updated.', 
     83'Must enter category message'           =>      'You must enter a category name.', 
     84 
     85'Categories'                                            =>      'Categories', 
     86 
    5787); 
  • branches/download/lang/English/download.php

    r13 r15  
    99'No categories'                                 => 'There are no categories.', 
    1010'Category list'                                 => 'Category list', 
    11 'Files count'                                   => 'Files count: %s', 
     11'Files count'                                   => 'Files: %s', 
    1212 
    1313'New downloads'                                 => 'New downloads [%s]', 
     14'Submit download'                               => 'Submit download', 
    1415 
    1516'Download not found'                    => 'Download not found', 
     
    1920'Author'                                                => 'Author:', 
    2021'Added time'                                    => 'Added:', 
     22 
     23'Last added'                                    => 'Last added:', 
    2124); 
  • branches/download/submit_download.php

    r13 r15  
    9595require FORUM_ROOT.'header.php'; 
    9696 
    97  
     97ob_start(); 
    9898?> 
    9999        <div class="main-head">