Plugin Directory

Changeset 639699


Ignore:
Timestamp:
12/15/2012 02:59:36 PM (13 years ago)
Author:
fabifott
Message:

WP-Filebase 0.2.9.28

  • Made code adjustments for WordPress 3.5 compatibility
  • New Option Small Icon Size in File Browser settings to adjust the size of icons and thumbnails
  • Improved compatibility with custom Role Plugins
  • Some GUI changes
  • Fixed 'Cheating uh?' bug when using the category seaech form after editing (thanks to David Bell)
  • Fixed secondary category query causing files to appear in root folder
  • Removed call wp_create_thumbnail which is deprecated since WP 3.5
  • Widget File Search Form now looks like the default search form
  • Added length limit for template variables: %file_display_name:20% limits the name to 20 characters
  • Fixed pagenav shortcode parameter, thanks to yuanl
  • Fixed file size limit in Drag&Drop uploader causing trouble
  • Fixed CSS Editor Bug
  • Fixed bug in list sorting
Location:
wp-filebase
Files:
276 added
1 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • wp-filebase/trunk/classes/Admin.php

    r631304 r639699  
    66static function InitClass()
    77{   
    8     wpfb_loadclass('AdminLite', 'Item', 'File', 'Category');
     8    wpfb_loadclass('AdminLite', 'Item', 'File', 'Category','FileUtils');
    99   
    1010    wp_enqueue_script('jquery');
     
    8787    'file_browser_fbc'      => array('default' => false, 'title' => __('Files before Categories', WPFB), 'type' => 'checkbox', 'desc' => __('Files will appear above categories in the file browser.', WPFB)),
    8888   
     89    'small_icon_size'       => array('default' => 32, 'title' => __('Small Icon Size'), 'desc' => __('Icon size for categories and files', WPFB), 'type' => 'number', 'class' => 'num', 'size' => 8),
     90           
    8991   
    9092    'cat_drop_down'         => array('default' => false, 'title' => __('Category drop down list', WPFB), 'type' => 'checkbox', 'desc' => __('Use category drop down list in the file browser instead of listing like files.', WPFB)),
     
    530532        $file_flash_upload = json_decode($data->file_flash_upload, true);
    531533        $file_flash_upload['tmp_name'] = WPFB_Core::UploadDir().'/'.str_replace('../','',$file_flash_upload['tmp_name']);
    532         if(is_file($file_flash_upload['tmp_name']) && $file_flash_upload['size'] == filesize($file_flash_upload['tmp_name']))
     534        if(is_file($file_flash_upload['tmp_name']) && $file_flash_upload['size'] == WPFB_FileUtils::GetFileSize($file_flash_upload['tmp_name']))
    533535            $data->file_upload = $file_flash_upload;
    534536    }
     
    540542   
    541543    // are we uploading a thumbnail?
    542     $upload_thumb = (!$add_existing && @is_uploaded_file($data->file_upload_thumb['tmp_name']) && self::IsValidImage($data->file_upload_thumb['tmp_name']) !== false);
     544    $upload_thumb = (!$add_existing && @is_uploaded_file($data->file_upload_thumb['tmp_name']) && WPFB_FileUtils::FileHasImageExt($data->file_upload['name']) && WPFB_FileUtils::IsValidImage($data->file_upload_thumb['tmp_name']));
    543545   
    544546    if($remote_upload) {
     
    591593   
    592594   
    593     // this sets permissions as well:
     595    // this inherits permissions as well:
    594596    $result = $file->ChangeCategoryOrName($file_category, empty($data->file_rename) ? $file_name : $data->file_rename, $add_existing, !empty($data->overwrite));
    595597    if(!empty($result['error'])) return $result;
     
    632634    if(!($update && $remote_redirect) && is_file($file->GetLocalPath()))
    633635    {
    634         $file->file_size = filesize($file->GetLocalPath());
     636        $file->file_size = WPFB_FileUtils::GetFileSize($file->GetLocalPath());
    635637        $file->file_mtime = filemtime($file->GetLocalPath());
    636638        $old_hash = $file->file_hash;
     
    732734}
    733735
    734 static function IsValidImage($img) {
    735     return @getimagesize($img) !== false;
    736 }
     736
     737
    737738
    738739static function ParseFileNameVersion($file_name, $file_version) {
     
    801802   
    802803    if( $size_for_progress >= self::$MIN_SIZE_FOR_PROGRESSBAR) {
    803         include_once(WPFB_PLUGIN_ROOT.'extras/progressbar.class.php');
     804        if(!class_exists('progressbar')) include_once(WPFB_PLUGIN_ROOT.'extras/progressbar.class.php');
    804805        $progress_bar = new progressbar(0, $size_for_progress, 300, 30, '#aaa');
    805806        echo "<p><code>".esc_html($url)."</code> ...</p>";
     
    11201121        $content .= $file->GenTpl2();
    11211122        $title = trim(__('File added.', WPFB),'.');
     1123       
    11221124    }
    11231125   
  • wp-filebase/trunk/classes/AdminGuiCats.php

    r630203 r639699  
    104104    <form class="search-form topmargin" action="" method="get"><p class="search-box">
    105105        <input type="hidden" value="<?php echo esc_attr($_GET['page']); ?>" name="page" />
    106         <input type="hidden" value="<?php echo esc_attr($action); ?>" name="action" />
    107106        <label class="hidden" for="category-search-input"><?php _e('Search Categories'/*def*/); ?>:</label>
    108107        <input type="text" class="search-input" id="category-search-input" name="s" value="<?php echo(isset($_GET['s']) ? esc_attr($_GET['s']) : ''); ?>" />
  • wp-filebase/trunk/classes/AdminGuiCss.php

    r487234 r639699  
    4646                // write
    4747                $newcontent = stripslashes($_POST['newcontent']);
    48                 $f = fopen($css_path_edit, 'w+');
    49                 if ($f !== false) {
    50                     fwrite($f, $newcontent);
    51                     fclose($f);
    52                     $exists = true;
    53                 }
     48                $exists = (file_put_contents($css_path_edit, $newcontent) !== false);
    5449            }
    5550
    5651            $fpath = $exists ? $css_path_edit : $css_path_default;
    57             $f = fopen($fpath , 'r');
    58             $content = fread($f, filesize($fpath));
    59             fclose($f);
    60             $content = htmlspecialchars($content);
     52            $content = esc_html(file_get_contents($fpath));
    6153            ?>
    6254<form name="csseditor" id="csseditor" action="<?php echo $clean_uri ?>&amp;action=edit_css" method="post">
  • wp-filebase/trunk/classes/AdminGuiManage.php

    r630203 r639699  
    4040        });
    4141    }
    42     </script>   
     42    </script>
     43   
     44
    4345    <div class="wrap">
    4446    <div id="icon-wpfilebase" class="icon32"><br /></div>
     
    102104<div id="wpfb-liking">
    103105    <div style="text-align: center;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fwp-filebase%2F&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:140px; height:21px; display:inline-block; text-align:center;" <?php echo ' allowTransparency="true"'; ?>></iframe></div>
     106   
     107    <div style="text-align: center;" ><a href="https://twitter.com/wpfilebase" class="twitter-follow-button" data-show-count="false">Follow @wpfilebase</a>
     108            <script type="text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://plugins.trac.wordpress.org//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
     109   
    104110    <p>Please <a href="http://wordpress.org/extend/plugins/wp-filebase/">give it a good rating</a>, or even consider a donation using PayPal or Flattr to support the developer of WP-Filebase:</p>
    105111    <div style="text-align: center;">   
     
    113119?>
    114120
     121<div id="wpfb-stats-wrap" style="float:right; border-left: 1px solid #eee; margin-left: 5px;">
    115122<div id="col-container">
    116123    <div id="col-right">
    117124        <div class="col-wrap">
    118125            <h3><?php _e('Traffic', WPFB); ?></h3>
    119             <table class="form-table">
     126            <table class="wpfb-stats-table">
    120127            <?php
    121128                $traffic_stats = WPFB_Core::GetTraffic();                   
     
    124131            ?>
    125132            <tr>
    126                 <th scope="row"><?php _e('Today', WPFB); ?></th>
    127133                <td><?php
    128134                    if($limit_day > 0)
     
    131137                        echo WPFB_Output::FormatFilesize($traffic_stats['today']);
    132138                ?></td>
    133             </tr>
    134             <tr>
    135                 <th scope="row"><?php _e('This Month', WPFB); ?></th>
     139                <th scope="row"><?php _e('Today', WPFB); ?></th>
     140            </tr>
     141            <tr>
    136142                <td><?php
    137143                    if($limit_month > 0)
     
    140146                        echo WPFB_Output::FormatFilesize($traffic_stats['month']);
    141147                ?></td>
    142             </tr>
    143             <tr>
     148                <th scope="row"><?php _e('This Month', WPFB); ?></th>
     149            </tr>
     150            <tr>
     151                <td><?php echo WPFB_Output::FormatFilesize($wpdb->get_var("SELECT SUM(file_size) FROM $wpdb->wpfilebase_files")) ?></td>
    144152                <th scope="row"><?php _e('Total File Size', WPFB); ?></th>
    145                 <td><?php echo WPFB_Output::FormatFilesize($wpdb->get_var("SELECT SUM(file_size) FROM $wpdb->wpfilebase_files")) ?></td>
    146153            </tr>   
    147154            </table>
     
    153160
    154161            <h3><?php _e('Statistics', WPFB); ?></h3>
    155             <table class="form-table">
    156             <tr>
    157                 <th scope="row"><?php _e('Number of Files', WPFB); ?></th>
     162            <table class="wpfb-stats-table">
     163            <tr>
    158164                <td><?php echo WPFB_File::GetNumFiles() ?></td>
    159             </tr>
    160             <tr>
    161                 <th scope="row"><?php _e('Number of Categories', WPFB); ?></th>
     165                <th scope="row"><?php _e('Files', WPFB); ?></th>               
     166            </tr>
     167            <tr>
    162168                <td><?php echo WPFB_Category::GetNumCats() ?></td>
    163             </tr>
    164             <tr>
    165                 <th scope="row"><?php _e('Total Downloads', WPFB); ?></th>
     169                <th scope="row"><?php _e('Categories', WPFB); ?></th>
     170            </tr>
     171            <tr>
    166172                <td><?php echo $wpdb->get_var("SELECT SUM(file_hits) FROM $wpdb->wpfilebase_files") ?></td>
     173                <th scope="row"><?php _e('Downloads', WPFB); ?></th>
    167174            </tr>
    168175            </table>
     
    171178
    172179</div><!-- /col-container -->
    173 
     180</div>
     181
     182
     183<div>
    174184<h2><?php _e('Tools'); ?></h2>
    175 <p><a href="<?php echo add_query_arg(
     185<table class="wpfb-tools">
     186<tr><th><a href="<?php echo add_query_arg(
    176187                array('action' => 'sync',
    177                 )); ?>" class="button"><?php _e('Sync Filebase',WPFB)?></a> &nbsp; <?php _e('Synchronises the database with the file system. Use this to add FTP-uploaded files.',WPFB) ?></p>
    178    
    179 <p>
     188                )); ?>" class="button"><?php _e('Sync Filebase',WPFB)?></a></th><td><?php _e('Synchronises the database with the file system. Use this to add FTP-uploaded files.',WPFB) ?><br />
     189               
    180190<?php       
    181191if(WPFB_Core::GetOpt('cron_sync')) {
     
    187197}
    188198?>
    189 </p>
    190 
    191            
     199                </td>
     200</tr>
     201
     202       
     203
     204
     205
     206</table>
     207   
    192208               
    193209<?php if(WPFB_Core::GetOpt('tag_conv_req')) { ?><p><a href="<?php echo add_query_arg('action', 'convert-tags') ?>" class="button"><?php _e('Convert old Tags',WPFB)?></a> &nbsp; <?php printf(__('Convert tags from versions earlier than %s.',WPFB), '0.2.0') ?></p> <?php } ?>
    194210<!--  <p><a href="<?php echo add_query_arg('action', 'add-urls') ?>" class="button"><?php _e('Add multiple URLs',WPFB)?></a> &nbsp; <?php _e('Add multiple remote files at once.', WPFB); ?></p>
    195211-->
     212</div>
    196213
    197214<?php
  • wp-filebase/trunk/classes/AdminGuiSettings.php

    r630203 r639699  
    206206        __('Common', WPFB)                  => array('upload_path','search_integration' /*'cat_drop_down'*/),
    207207        __('Display', WPFB)                 => array('file_date_format','thumbnail_size','auto_attach_files', 'attach_loop','attach_pos', 'filelist_sorting', 'filelist_sorting_dir', 'filelist_num', /* TODO: remove? 'parse_tags_rss',*/ 'decimal_size_format'),
    208         __('File Browser',WPFB)             => array('file_browser_post_id','file_browser_cat_sort_by','file_browser_cat_sort_dir','file_browser_file_sort_by','file_browser_file_sort_dir','file_browser_fbc', 'late_script_loading',
     208        __('File Browser',WPFB)             => array('file_browser_post_id','file_browser_cat_sort_by','file_browser_cat_sort_dir','file_browser_file_sort_by','file_browser_file_sort_dir','file_browser_fbc', 'late_script_loading','small_icon_size',
    209209        'disable_footer_credits','footer_credits_style',
    210210        ),
  • wp-filebase/trunk/classes/Category.php

    r631304 r639699  
    177177            case 'cat_parent_name': return is_object($parent =& $this->GetParent()) ? $parent->cat_name : '';
    178178            case 'cat_icon_url':    return $this->GetIconUrl();
    179             case 'cat_small_icon':  $esc=false; return '<img src="'.$this->GetIconUrl('small').'" style="height:32px;vertical-align:middle;" />';
     179            case 'cat_small_icon':  $esc=false; return '<img src="'.$this->GetIconUrl('small').'" style="height:'.WPFB_Core::GetOpt('small_icon_size').'px;vertical-align:middle;" />';
    180180            case 'cat_num_files':       return $this->cat_num_files;
    181181            case 'cat_num_files_total': return $this->cat_num_files_total;
  • wp-filebase/trunk/classes/Core.php

    r630203 r639699  
    44static $file_browser_search = false;
    55static $file_browser_item = null;
    6 //static $options = null;
     6static $current_user = null;
    77
    88static function InitClass()
     
    305305    if(!empty($wpfb_fb) && !WPFB_Core::GetOpt('disable_footer_credits')) {
    306306        echo '<div id="wpfb-credits" name="wpfb-credits" style="'.esc_attr(WPFB_Core::GetOpt('footer_credits_style')).'">';
    307         printf(__('<a href="%s" title="Wordpress Download Manager Plugin" style="color:inherit;font-size:inherit;">Downloads served by WP-Filebase</a>',WPFB),'http://wpfilebase.fabi.me/');
     307        printf(__('<a href="%s" title="Wordpress Download Manager Plugin" style="color:inherit;font-size:inherit;">Downloads served by WP-Filebase</a>',WPFB),'http://wpfilebase.com/');
    308308        echo '</div>';
    309309    }
     
    657657}
    658658
    659 }
     659
     660}
  • wp-filebase/trunk/classes/Download.php

    r615301 r639699  
    359359    }
    360360   
    361     $size = filesize($file_path);
     361    wpfb_loadclass('FileUtils');
     362    $size = WPFB_FileUtils::GetFileSize($file_path);
    362363    $time = filemtime($file_path);
    363364    $file_type = WPFB_Download::GetFileType($file_path);
  • wp-filebase/trunk/classes/File.php

    r630203 r639699  
    161161    {
    162162        global $wpdb;
    163         return (int)$wpdb->get_var("SELECT COUNT($wpdb->wpfilebase_files.file_id) FROM ".self::genSelectSql($where, $check_permissions));
     163        return (int)$wpdb->get_var("SELECT COUNT(`{$wpdb->wpfilebase_files}`.`file_id`) FROM ".self::genSelectSql($where, $check_permissions));
    164164    }
    165165   
     
    178178    { // validate some values before saving (fixes for mysql strict mode)
    179179        if($this->locked > 0) return $this->TriggerLockedError();   
    180         $ints = array('file_size','file_category','file_post_id','file_attach_order','file_wpattach_id','file_added_by','file_update_of','file_hits','file_ratings','file_rating_sum');
     180        $ints = array('file_category','file_post_id','file_attach_order','file_wpattach_id','file_added_by','file_update_of','file_hits','file_ratings','file_rating_sum');
    181181        foreach($ints as $i) $this->$i = intval($this->$i);
    182182        $this->file_offline = (int)!empty($this->file_offline);
     
    199199   
    200200    function CreateThumbnail($src_image='', $del_src=false)
    201     {       
     201    {
     202        wpfb_loadclass('FileUtils');
     203       
    202204        $src_set = !empty($src_image) && file_exists($src_image);
    203205        $tmp_src = $del_src;
     
    220222       
    221223        $ext = trim($this->GetExtension(), '.');
    222    
    223         if($ext != 'bmp' &&
    224         ($src_size = @getimagesize($src_image)) === false) { // check if valid image
     224        $src_size = array();
     225       
     226        if(!WPFB_FileUtils::FileHasImageExt($this->file_name) &&
     227        !($src_set && WPFB_FileUtils::IsValidImage($src_image, $src_size))) { // check if valid image
    225228            if($tmp_src) @unlink($src_image);
    226229            return;
     
    231234        $thumb_size = (int)WPFB_Core::GetOpt('thumbnail_size');
    232235       
    233         if(!function_exists('wp_create_thumbnail')) {
    234             require_once(ABSPATH . 'wp-admin/includes/image.php');
    235             if(!function_exists('wp_create_thumbnail'))
    236             {
    237                 if($tmp_src) @unlink($src_image);
    238                 wp_die('Function wp_create_thumbnail does not exist!');
    239                 return;
    240             }
    241         }
     236
    242237           
    243238        $extras_dir = WPFB_PLUGIN_ROOT . 'extras/';
     
    259254                        if(@file_exists($jpg_file) && @filesize($jpg_file) > 0)
    260255                        {
    261                             $thumb = @wp_create_thumbnail($jpg_file, $thumb_size);
     256                            $thumb = WPFB_FileUtils::CreateThumbnail($jpg_file, $thumb_size);
    262257                        }
    263258                        @unlink($jpg_file);
     
    266261            }
    267262        } else {
    268             $thumb = @wp_create_thumbnail($src_image, $thumb_size);
     263            $thumb = WPFB_FileUtils::CreateThumbnail($src_image, $thumb_size);
    269264            if(is_wp_error($thumb) && max($src_size) <= $thumb_size) { // error occurs when image is smaller than thumb_size. in this case, just copy original
    270265                $name = wp_basename($src_image, ".$ext");
     
    387382            case 'file_post_url':       return htmlspecialchars(!($url = $this->GetPostUrl()) ? $this->GetUrl() : $url);           
    388383            case 'file_icon_url':       return htmlspecialchars($this->GetIconUrl());
    389             case 'file_small_icon':     return '<img src="'.esc_attr($this->GetIconUrl('small')).'" style="vertical-align:middle;height:32px;" />';
     384            case 'file_small_icon':     return '<img src="'.esc_attr($this->GetIconUrl('small')).'" style="vertical-align:middle;height:'.WPFB_Core::GetOpt('small_icon_size').'px;" />';
    390385            case 'file_size':           return $this->GetFormattedSize();
    391386            case 'file_path':           return htmlspecialchars($this->GetLocalPathRel());
    392387           
    393388            case 'file_category':       return htmlspecialchars(is_object($cat = $this->GetParent()) ? $cat->cat_name : '');
    394             case 'cat_small_icon':      return is_null($cat = $this->GetParent()) ? '' : ('<img align="" src="'.htmlspecialchars($cat->GetIconUrl('small')).'" style="height:32px;vertical-align:middle;" />');
     389            case 'cat_small_icon':      return is_null($cat = $this->GetParent()) ? '' : ('<img align="" src="'.htmlspecialchars($cat->GetIconUrl('small')).'" style="height:'.WPFB_Core::GetOpt('small_icon_size').'px;vertical-align:middle;" />');
    395390            case 'cat_icon_url':        return is_null($cat = $this->GetParent()) ? '' : htmlspecialchars($cat->GetIconUrl());
    396391            case 'cat_url':             return is_null($cat = $this->GetParent()) ? '' : htmlspecialchars($cat->GetUrl());
     
    428423            return htmlspecialchars($this->getInfoValue($path));
    429424        } elseif(strpos($name, 'file_custom') === 0) // dont esc custom
    430             return isset($this->$name) ? $this->$name : '';     
     425            return isset($this->$name) ? $this->$name : '';
     426       
     427        // string length limit:
     428        if(!isset($this->$name) && ($p=strpos($name, ':')) > 0) {
     429            $maxlen = (int)substr($name, $p+1);
     430            $name = substr($name, 0, $p);
     431            $str = $this->get_tpl_var($name);           
     432            if($maxlen > 3 && strlen($str) > $maxlen) $str = (function_exists('mb_substr') ? mb_substr($str, 0, $maxlen-3,'utf8') : mb_substr($str, 0, $maxlen-3)).'...';
     433            return $str;
     434        }
     435       
    431436        return isset($this->$name) ? htmlspecialchars($this->$name) : '';
    432437    }
  • wp-filebase/trunk/classes/Item.php

    r631304 r639699  
    3131    function GetTitle($maxlen=0){
    3232        $t = $this->is_file?$this->file_display_name:$this->cat_name;
    33         if($maxlen > 3 && strlen($t) > $maxlen) $t = mb_substr($t, 0, $maxlen-3,'utf8').'...';
     33        if($maxlen > 3 && strlen($t) > $maxlen) $t = (function_exists('mb_substr') ? mb_substr($t, 0, $maxlen-3,'utf8') : substr($t, 0, $maxlen-3)).'...';
    3434        return $t;
    3535    }   
     
    9595    static function Sort(&$items, $order_sql) {
    9696        $order_sql = str_replace(array('&gt;','&lt;'), array('>','<'), $order_sql);
    97         if(($desc = ($order_sql{0} == '>')) || $order_sql{0} = '<')
     97        if(($desc = ($order_sql{0} == '>')) || $order_sql{0} == '<')
    9898            $on = substr($order_sql,1);
    9999        else {
     
    198198    function CurUserCanAccess($for_tpl=false)
    199199    {
    200         global $current_user;
    201         if($current_user->ID > 0 && empty($current_user->roles[0]))
    202             $current_user = new WP_User($current_user->ID);// load the roles!
    203        
    204         if( ($for_tpl && !WPFB_Core::GetOpt('hide_inaccessible')) || in_array('administrator',$current_user->roles) || ($this->is_file && $this->CurUserIsOwner()) )
     200        global $user_ID; // is 0 when not logged in                     
     201        if(is_null(WPFB_Core::$current_user))
     202            WPFB_Core::$current_user = new WP_User($user_ID); //load all roles
     203       
     204        if( ($for_tpl && !WPFB_Core::GetOpt('hide_inaccessible')) || in_array('administrator',WPFB_Core::$current_user->roles) || ($this->is_file && $this->CurUserIsOwner()) )
    205205            return true;
    206206        if(WPFB_Core::GetOpt('private_files') && $this->GetOwnerId() != 0 && !$this->CurUserIsOwner()) // check private files
     
    208208        $frs = $this->GetReadPermissions();
    209209        if(empty($frs)) return true; // item is for everyone!       
    210         foreach($current_user->roles as $ur) { // check user roles against item roles
     210        foreach(WPFB_Core::$current_user->roles as $ur) { // check user roles against item roles
    211211            if(in_array($ur, $frs))
    212212                return true;
     
    310310        {
    311311            // add mtime for cache updates
    312             return WPFB_PLUGIN_URI . (empty($this->cat_icon) ? ('images/'.(($size=='small')?'folder48':'crystal_cat').'.png') : "wp-filebase_thumb.php?cid=$this->cat_id&t=".filemtime($this->GetThumbPath()));
     312            return WPFB_PLUGIN_URI . (empty($this->cat_icon) ? ('images/'.(($size=='small')?'folder48':'crystal_cat').'.png') : "wp-filebase_thumb.php?cid=$this->cat_id&t=".@filemtime($this->GetThumbPath()));
    313313        }
    314314
     
    526526   
    527527    protected static function GetPermissionWhere($owner_field, $permissions_field) {
    528         global $wpdb, $current_user;
     528        global $wpdb, $user_ID;
     529       
     530        if(is_null(WPFB_Core::$current_user))
     531            WPFB_Core::$current_user = new WP_User($user_ID); //load all roles
     532        $current_user = WPFB_Core::$current_user;
     533       
    529534        static $permission_sql = '';
    530535        if(empty($permission_sql)) { // only generate once per request
    531             if($current_user->ID > 0 && empty($current_user->roles[0]))
    532                 $current_user = new WP_User($current_user->ID);// load the roles
    533 
    534536            if(in_array('administrator',$current_user->roles)) $permission_sql = '1=1'; // administrator can access everything!
    535537            elseif(WPFB_Core::GetOpt('private_files')) {
  • wp-filebase/trunk/classes/ListTpl.php

    r598768 r639699  
    4343   
    4444    static function ParseHeaderFooter($str, $uid=null) {
    45         global $wp_query;   
    4645        $str = preg_replace('/%sort_?link:([a-z0-9_]+)%/ie', __CLASS__.'::GenSortlink(\'$1\')', $str);
    47         if(strpos($str, '%search_form%') !== false) {
    48             $searching = !empty($_GET['wpfb_s']);
    49             if($searching) {
    50                 $sb = empty($wp_query->query_vars['s'])?null:$wp_query->query_vars['s'];
    51                 $wp_query->query_vars['s'] = $_GET['wpfb_s'];
    52             }
    53            
    54             ob_start();
    55             get_search_form();
    56             $form = ob_get_clean();
    57             if(empty($form)) echo "Searchform empty!";
    58            
    59             if($searching) $wp_query->query_vars['s'] = $sb; // restore query var s
    60 
    61             $form = preg_replace('/action=["\'].+?["\']/', 'action=""', $form);
    62             $form = str_replace('="s"', '="wpfb_s"', $form);
    63             $form = str_replace("='s'", "='wpfb_s'", $form);
    64             $gets = '';
    65             foreach($_GET as $name => $value) if($name != 'wpfb_s' && $name != 'wpfb_list_page') $gets.='<input type="hidden" name="'.esc_attr(stripslashes($name)).'" value="'.esc_attr(stripslashes($value)).'" />';
    66             $form = str_ireplace('</form>', "$gets</form>", $form);
    67             $str = str_replace('%search_form%', $form, $str);
    68         }
     46       
     47        if(strpos($str, '%search_form%') !== false)
     48            $str = str_replace('%search_form%', WPFB_Output::GetSearchForm("", $_GET), $str);
    6949       
    7050        $str = preg_replace('/%print_?script:([a-z0-9_-]+)%/ie', __CLASS__.'::PrintScriptOrStyle(\'$1\', false)', $str);
     
    9575    }
    9676   
    97     function Generate($categories, $show_cats, $file_order, $page_limit, $cat_order=null)
     77    function Generate($categories, $show_cats, $file_order, $page_limit, $cat_order=null, $hide_pagenav = false)
    9878    {
    9979        $uid = uniqid();
     
    152132                        if($nf > 0) {
    153133                            $files = WPFB_File::GetFiles2("($where) AND ".WPFB_File::GetSqlCatWhereStr($cat->cat_id), $hia, $sort, $page_limit, $start);
    154                             if($show_cats && count($files) > 0)
     134                            if(count($files) > 0)
    155135                                $content .= $cat->GenTpl2($this->cat_tpl_tag); // check for file count again, due to pagination!
    156136                               
     
    175155                    $keys = array_keys($all_files);
    176156                    if($start == -1) $start = 0;
    177                     $last = min($start + $page_limit, $num_total_files);
     157                    $last = ($page_limit > 0) ? min($start + $page_limit, $num_total_files) : $num_total_files;
    178158                    for($i = $start; $i < $last; $i++)
    179159                        $content .= $all_files[$keys[$i]]->GenTpl2($this->file_tpl_tag);
     
    184164        $footer = self::ParseHeaderFooter($this->footer, $uid);
    185165       
    186         if($page_limit > 0 && $num_total_files > $page_limit) {
     166        if($page_limit > 0 && $num_total_files > $page_limit && !$hide_pagenav) {
    187167            $pagenav = paginate_links( array(
    188168                'base' => add_query_arg( 'wpfb_list_page', '%#%' ),
     
    191171                'current' => empty($_GET['wpfb_list_page']) ? 1 : absint($_GET['wpfb_list_page'])
    192172            ));
    193             /*
    194             'show_all' => false,
    195             'prev_next' => true,
    196             'prev_text' => __('&laquo; Previous'),
    197             'next_text' => __('Next &raquo;'),
    198             'end_size' => 1,
    199             'mid_size' => 2,
    200             'type' => 'plain',
    201             'add_args' => false, // array of query args to add
    202             'add_fragment' => ''*/     
    203173
    204174            if(strpos($footer, '%page_nav%') === false)
  • wp-filebase/trunk/classes/Output.php

    r630203 r639699  
    7474            return '';
    7575        }
    76     }
    77    
    78     if(empty($args['id']) || $args['id'] == -1) {
    79         $cats = $args['showcats'] ? WPFB_Category::GetCats() : null;
    80     } else {
    81         $cats = array();   
    82         $cat_ids = explode(',', $args['id']);   
    83         foreach($cat_ids as $cat_id) {
    84             if(!is_null($cat = WPFB_Category::GetCat($cat_id))) $cats[] = $cat;
    85         }
    86     }
    87    
    88     return $tpl->Generate($cats, $args['showcats'], $args['sort'], $args['num'], $args['sortcats']);
     76    }   
     77
     78    $cats = (empty($args['id']) || $args['id'] == -1) ? ($args['showcats'] ? WPFB_Category::GetCats() : null) : array_filter(array_map(array('WPFB_Category','GetCat'), explode(',', $args['id'])));
     79   
     80    return $tpl->Generate($cats, $args['showcats'], $args['sort'], $args['num'], $args['sortcats'], isset($args['pagenav']) && !((int)$args['pagenav']));
    8981}
    9082
     
    460452                <small><?php printf(str_replace('%d%s','%s',__('Maximum upload file size: %d%s'/*def*/)), WPFB_Output::FormatFilesize(WPFB_Core::GetMaxUlSize())) ?></small>
    461453               
    462                 <div style="float: right; text-align:right;"><input type="submit" class="button-primary" name="submit-btn" value="<?php _ex('Add New', 'file'); ?>" /></div>
     454                <?php if(empty($auto_submit)) { ?><div style="float: right; text-align:right;"><input type="submit" class="button-primary" name="submit-btn" value="<?php _ex('Add New', 'file'); ?>" /></div>
     455                <?php } ?>
    463456            </div> 
    464457        </form>
    465458    <?php
    466459}
    467 }
     460
     461static function GetSearchForm($action, $hidden_vars = array(), $prefix=null)
     462{
     463    global $wp_query;
     464   
     465    $searching = !empty($_GET['wpfb_s']);
     466    if($searching) { // set preset value for search form
     467        $sb = empty($wp_query->query_vars['s'])?null:$wp_query->query_vars['s'];
     468        $wp_query->query_vars['s'] = stripslashes($_GET['wpfb_s']);
     469    }   
     470   
     471    ob_start();
     472    get_search_form();
     473    $form = ob_get_clean();
     474   
     475    if($searching) $wp_query->query_vars['s'] = $sb; // restore query var s
     476   
     477    $form = preg_replace('/action=["\'].+?["\']/', 'action="'.esc_attr($action).'"', $form);
     478    $form = str_replace('name="s"', 'name="wpfb_s"', $form);
     479    $form = str_replace("name='s'", "name='wpfb_s'", $form);
     480   
     481    if(!empty($hidden_vars)) {
     482        $gets = '';
     483        foreach($hidden_vars as $name => $value) if($name != 'wpfb_s' && $name != 'wpfb_list_page') $gets.='<input type="hidden" name="'.esc_attr(stripslashes($name)).'" value="'.esc_attr(stripslashes($value)).'" />';
     484        $form = str_ireplace('</form>', "$gets</form>", $form);
     485    }
     486   
     487    if(!empty($prefix)) {
     488        $form = str_replace('id="', 'id="'.$prefix, $form);
     489        $form = str_replace("id='", "id='".$prefix, $form);
     490    }
     491    return $form;
     492}
     493}
  • wp-filebase/trunk/classes/PLUpload.php

    r630203 r639699  
    4141$id = $this->id;
    4242
    43 require_once(ABSPATH . 'wp-admin/includes/template.php'); // wp_max_upload_size
    44 $upload_size_unit = $max_upload_size = wp_max_upload_size();
     43$upload_size_unit = $max_upload_size = WPFB_Core::GetMaxUlSize();
    4544$sizes = array( 'KB', 'MB', 'GB' );
    4645
  • wp-filebase/trunk/classes/ProgressReporter.php

    r615301 r639699  
    2929        if(!$this->quiet) {
    3030            if(is_null($this->progress_bar)) {
    31                 include_once(WPFB_PLUGIN_ROOT.'extras/progressbar.class.php');
     31                if(!class_exists('progressbar')) include_once(WPFB_PLUGIN_ROOT.'extras/progressbar.class.php');
    3232                $this->progress_bar = new progressbar(0, 100);
    3333                $this->progress_bar->print_code();
  • wp-filebase/trunk/classes/Sync.php

    r630203 r639699  
    55static function InitClass()
    66{
    7     wpfb_loadclass("Admin", "GetID3");
     7    wpfb_loadclass("Admin", "GetID3", "FileUtils");
    88    require_once(ABSPATH . 'wp-admin/includes/file.php');
    99   
     
    111111        echo "</p>";
    112112       
    113         include_once(WPFB_PLUGIN_ROOT.'extras/progressbar.class.php');
     113        if(!class_exists('progressbar')) include_once(WPFB_PLUGIN_ROOT.'extras/progressbar.class.php');
    114114        $progress_bar = new progressbar(0, $sync_data->num_files_to_add);
    115115        $progress_bar->print_code();
     
    193193       
    194194        if($sync_data->hash_sync) $file_hash = WPFB_Admin::GetFileHash($file_path);
    195         $file_size = (int)@filesize($file_path);
     195        $file_size = WPFB_FileUtils::GetFileSize($file_path);
    196196        $file_mtime = filemtime($file_path);
    197197        $file_analyzetime = !$sync_id3 ? $file_mtime : WPFB_GetID3::GetFileAnalyzeTime($file);
  • wp-filebase/trunk/classes/TplLib.php

    r599590 r639699  
    3939   
    4040    // parse variables
    41     $tpl = preg_replace('/%([a-z0-9_\/]+?)%/i', '\'.$f->get_tpl_var(\'$1\').\'', $tpl);
     41    $tpl = preg_replace('/%([a-z0-9_\/:]+?)%/i', '\'.$f->get_tpl_var(\'$1\').\'', $tpl);
    4242   
    4343    // remove html comments
  • wp-filebase/trunk/classes/Widget.php

    r615301 r639699  
    270270       
    271271        $prefix = "wpfb-search-widget-".$this->id_base;
    272         $form_url = add_query_arg('wpfb_add_cat', 1);
    273         $nonce_action = $prefix;
    274         ?>
    275         <form name="<?php echo $prefix ?>form" method="get" action="<?php echo remove_query_arg(array('p','post_id','page_id','wpfb_s')); ?>" class="searchform" id="searchform">
    276         <input name="p" type="hidden" value="<?php echo WPFB_Core::GetOpt('file_browser_post_id') ?>" />
    277         <fieldset>
    278             <input name="wpfb_s" id="<?php echo $prefix ?>search" type="text" value="<?php echo empty($_GET['wpfb_s']) ? '' : esc_attr(stripslashes($_GET['wpfb_s'])) ?>" />
    279             <!-- <button type="submit" name="searchsubmit" value="Search"></button> -->
    280             <input type="submit" class="button-primary" name="searchsubmit" value="<?php _e('Search'/*def*/) ?>" />
    281         </fieldset>
    282         </form>
    283     <?php
     272       
     273        $fbp_id = WPFB_Core::GetOpt('file_browser_post_id');
     274        $action = WPFB_Core::GetPostUrl($fbp_id);
     275        $p_in_query = (strpos($action,'?') !== false); // no permalinks?
     276        $action = $p_in_query ? remove_query_arg(array('p','post_id','page_id','wpfb_s')) : $action;
     277       
     278        echo WPFB_Output::GetSearchForm($action, $p_in_query ? array('p' => $fbp_id) : null, "");
     279
    284280        echo $after_widget;
    285281    }
     
    407403        parent::WP_Widget( false, WPFB_PLUGIN_NAME .' '.__('File list', WPFB), array('description' => __('Listing of files with custom sorting', WPFB)) );
    408404    }
     405   
     406    static function limitStrLen($str, $maxlen)
     407    {
     408        if($maxlen > 3 && strlen($str) > $maxlen) $str = (function_exists('mb_substr') ? mb_substr($str, 0, $maxlen-3,'utf8') : mb_substr($str, 0, $maxlen-3)).'...';
     409        return $str;
     410    }
    409411
    410412    function widget( $args, $instance ) {
     
    425427            (int)$instance['limit']
    426428        );
     429       
     430        //$instance['tpl_parsed']
     431        //WPFB_FileListWidget
    427432       
    428433        $tpl_func = WPFB_Core::CreateTplFunc($instance['tpl_parsed']);
  • wp-filebase/trunk/extras/getid3/getid3.php

    r559064 r639699  
    17371737
    17381738
    1739 class getid3_exception extends Exception
    1740 {
    1741     public $message;
     1739if(!class_exists('getid3_exception')) {
     1740    class getid3_exception extends Exception
     1741    {
     1742        public $message;
     1743    }
    17421744}
    17431745
  • wp-filebase/trunk/readme.txt

    r631304 r639699  
    44Tags: filebase, filemanager, file, files, manager, upload, download, downloads, downloadmanager, images, pdf, widget, filelist, list, thumbnails, thumbnail, attachment, attachments, category, categories, media, template, ftp, http, mp3, id3
    55Requires at least: 3.1
    6 Tested up to: 3.4.2
    7 Stable tag: 0.2.9.27
     6Tested up to: 3.5
     7Stable tag: 0.2.9.28
    88
    99Adds a powerful download manager including file categories, downloads counter, widgets, sorted file lists and more to your WordPress blog.
     
    4949*   Automatic synchronization of file system and database
    5050
    51 You can see a [live demo on my Website](http://fabi.me/downloads/ "WP-Filebase demo"), [documentation can be found here](http://wpfilebase.fabi.me/documentation/ "WP-Filebase documentation").
     51You can see a [live demo on my Website](http://fabi.me/downloads/ "WP-Filebase demo"), [documentation can be found here](http://wpfilebase.com/documentation/ "WP-Filebase documentation").
    5252For support, please [leave a message on my blog](http://fabi.me/wordpress-plugins/wp-filebase-file-download-manager/#postcomment "Post comment"). When having trouble don't forget to post PHP and Wordpress version! Any ideas/feature requests are welcome.
    5353
    5454= WP-Filebase Pro =
    55 [WP-Filebase Pro](http://wpfilebase.fabi.me/) includes even more advanced features:
     55[WP-Filebase Pro](http://wpfilebase.com/) includes even more advanced features:
    5656
    5757*   PDF indexing and thumbnails
     
    69693. Activate the Plugin and customize the settings under *Settings->WP-Filebase*
    7070
    71 Read more in [WP-Filebase documentation](http://wpfilebase.fabi.me/documentation/setup/).
     71Read more in [WP-Filebase documentation](http://wpfilebase.com/documentation/setup/).
    7272
    7373== Frequently Asked Questions ==
     
    114114== Changelog ==
    115115
     116= 0.2.9.28 =
     117* Made code adjustments for WordPress 3.5 compatibility
     118* New Option `Small Icon Size` in File Browser settings to adjust the size of icons and thumbnails
     119* Improved compatibility with custom Role Plugins
     120* Some GUI changes
     121* Fixed 'Cheating uh?' bug when using the category seaech form after editing (thanks to David Bell)
     122* Fixed secondary category query causing files to appear in root folder
     123* Removed call wp_create_thumbnail which is deprecated since WP 3.5
     124* Widget File Search Form now looks like the default search form
     125* Added length limit for template variables: `%file_display_name:20%` limits the name to 20 characters
     126* Fixed pagenav shortcode parameter, thanks to yuanl
     127* Fixed file size limit in Drag&Drop uploader causing trouble
     128* Fixed CSS Editor Bug
     129* Fixed bug in list sorting
     130
    116131= 0.2.9.27 =
    117132* Fixed AJAX tree not showing
     
    126141
    127142= 0.2.9.25 =
    128 * [WP-Filebase Documentation](http://wpfilebase.fabi.me/documentation/) and [WP-Filebase Pro](http://wpfilebase.fabi.me/) released
     143* [WP-Filebase Documentation](http://wpfilebase.com/documentation/) and [WP-Filebase Pro](http://wpfilebase.com/) released
    129144* Added Category Owners
    130145* Raised limits of file name length: file name 300, category folder name: 300, total path length: 2000
     
    569584
    570585== Documentation ==
    571 [WP-Filebase Documentation](http://wpfilebase.fabi.me/documentation/)
     586[WP-Filebase Documentation](http://wpfilebase.com/documentation/)
    572587
    573588== Translation ==
     
    578593
    579594== WP-Filebase Pro ==
    580 [WP-Filebase Pro](http://wpfilebase.fabi.me/) is the commercial version of WP-Filebase with an extended range of functions. It supports secondary categories, extended permissions, embedded upload forms. Furthermore it can generate PDF thumbnails, sync with Dropbox or FTP and includes an improved file sync algorithm.
     595[WP-Filebase Pro](http://wpfilebase.com/) is the commercial version of WP-Filebase with an extended range of functions. It supports secondary categories, extended permissions, embedded upload forms. Furthermore it can generate PDF thumbnails, sync with Dropbox or FTP and includes an improved file sync algorithm.
    581596
    582597== Traffic Limiter ==
  • wp-filebase/trunk/wp-filebase-admin.css

    r630203 r639699  
    264264    position:absolute;
    265265    right: 0px;
     266    top: 40px;
    266267   
    267268    border-width:1px;
     
    352353   
    353354}
     355
     356
     357.wpfb-tools td {
     358    padding: 10px;
     359    cursor: default;
     360}
     361
     362.wpfb-tools th {
     363    text-align:center;
     364    padding: 10px
     365}
     366
     367.wpfb-tools tr {
     368    border-bottom: 1px solid #aaa;
     369}
     370
     371.wpfb-tools tr:hover {
     372    background-color: #eee;
     373}
     374
     375.wpfb-stats-table {
     376
     377}
     378
     379.wpfb-stats-table th  {
     380    text-align: left;
     381    padding: 5px;
     382    font-weight: normal;
     383}
     384
     385.wpfb-stats-table td  {
     386    text-align: right;
     387    padding: 2px;
     388    font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
     389    font-size: 18px;
     390}
  • wp-filebase/trunk/wp-filebase.php

    r631304 r639699  
    55Description: Adds a powerful downloads manager supporting file categories, download counter, widgets, sorted file lists and more to your WordPress blog.
    66Author: Fabian Schlieper
    7 Version: 0.2.9.27
     7Version: 0.2.9.28
    88Author URI: http://fabi.me/
    99*/
     
    1212{
    1313    define('WPFB', 'wpfb');
    14     define('WPFB_VERSION', '0.2.9.27');
     14    define('WPFB_VERSION', '0.2.9.28');
    1515    define('WPFB_PLUGIN_ROOT', str_replace('\\','/',dirname(__FILE__)).'/');
    1616    if(!defined('ABSPATH')) {
Note: See TracChangeset for help on using the changeset viewer.