Beispiel #1
0
    static function Display()
    {
        global $wpdb, $user_ID;
        wpfb_loadclass('Admin', 'Output');
        $_POST = stripslashes_deep($_POST);
        $_GET = stripslashes_deep($_GET);
        $action = !empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
        $clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync'));
        // keep search keyword
        WPFB_Admin::PrintFlattrHead();
        ?>
<div class="wrap"><?php 
        switch ($action) {
            default:
                ?>
<div id="wpfilebase-donate">
<p><?php 
                _e('If you like WP-Filebase I would appreciate a small donation to support my work. You can additionally add an idea to make WP-Filebase even better. Just click the button below. Thank you!', WPFB);
                ?>
</p>
<?php 
                WPFB_Admin::PrintPayPalButton();
                WPFB_Admin::PrintFlattrButton();
                ?>
</div>
<?php 
                break;
        }
        ?>
</div> <!-- wrap -->
<?php 
    }
 function testCreateTree()
 {
     $this->testSetUser();
     wpfb_loadclass('Admin');
     /** @var WPFB_Category $parent */
     $parent = null;
     /** @var WPFB_Category[] $cats */
     $cats = array();
     for ($d = 0; $d < 4; $d++) {
         $res = WPFB_Admin::InsertCategory(array('cat_name' => "layer {$d}", 'cat_parent' => $parent ? $parent->GetId() : 0));
         $this->assertEmpty($res['error']);
         /** @var WPFB_Category $cat */
         $cat = $res['cat'];
         $this->assertTrue($parent ? $cat->GetParent()->Equals($parent) : is_null($cat->GetParent()));
         $this->assertTrue(is_dir($cat->GetLocalPath()));
         $cats[] = $cat;
         $parent = $cat;
     }
     // print_r(array_map( function($c) { return strval($c);}, $cats));
     $files = new TestFileSet();
     $res = WPFB_Admin::InsertFile(array('file_remote_uri' => 'file://' . $files->getImageBanner(), 'file_category' => $parent));
     $this->assertEmpty($res['error'], $res['error']);
     /** @var WPFB_File $file01 */
     $file01 = $res['file'];
 }
Beispiel #3
0
 public static function Create($form_url, $is_edit = false)
 {
     $uploader_class = version_compare(get_bloginfo('version'), '3.2.1') <= 0 ? 'SWFUpload' : 'PLUpload';
     wpfb_loadclass($uploader_class);
     $uploader_class = "WPFB_" . $uploader_class;
     return new $uploader_class($form_url, $is_edit);
 }
    static function Display()
    {
        wpfb_loadclass('Output', 'File', 'Category', 'TplLib');
        $content = '';
        $file_tpls = WPFB_Core::GetTpls('file');
        $cat_tpls = WPFB_Core::GetTpls('cat');
        if (true || !isset($file_tpls['filebrowser_admin'])) {
            $file_tpls['filebrowser_admin'] = '%file_small_icon% ' . '%file_display_name% (%file_size%) ' . '<!-- IF %file_user_can_edit% --><a href="%file_edit_url%" class="edit" onclick="wpfbFBEditFile(event)">%\'Edit\'%</a><!-- ENDIF -->' . '<!-- IF %file_user_can_edit% --><a href="#" class="delete" onclick="return confirm(\'Sure?\') && wpfbFBDelete(event) && false;">%\'Delete\'%</a><!-- ENDIF -->';
            WPFB_Core::SetFileTpls($file_tpls);
            //WPFB_Admin::ParseTpls();
        }
        if (true || !isset($cat_tpls['filebrowser_admin'])) {
            $cat_tpls['filebrowser_admin'] = '<span class="cat-icon" style="background-image:url(\'%cat_icon_url%\');"><span class="cat-icon-overlay"></span></span>' . '%cat_name% ' . '<!-- IF %cat_user_can_edit% --><a href="%cat_edit_url%" class="edit" onclick="wpfbFBEditCat(event)">%\'Edit\'%</a><!-- ENDIF -->' . '<!-- IF %cat_user_can_edit% --><a href="#" class="delete" onclick="return confirm(\'Sure?\') && wpfbFBDelete(event) && false;">%\'Delete\'%</a><!-- ENDIF -->';
            WPFB_Core::SetCatTpls($cat_tpls);
            WPFB_Admin::ParseTpls();
        }
        WPFB_Output::FileBrowser($content, 0, empty($_GET['wpfb_cat']) ? 0 : intval($_GET['wpfb_cat']));
        WPFB_Core::PrintJS();
        ?>
    <div class="wrap filebrowser-admin"> 
    <h2><?php 
        _e('File Browser', 'wp-filebase');
        ?>
</h2>    
<?php 
        echo '<div>' . __('You can Drag &amp; Drop (multiple) files directly on Categories to upload them. Dragging a category or an existing file to another category is also possible.', 'wp-filebase') . '</div>';
        echo $content;
        ?>
	 </div>
<script>
	function wpfbFBEditCat(e) {
		e.stopPropagation();
	}
	
	function wpfbFBEditFile(e) {
		e.stopPropagation();
	}	
	
	function wpfbFBDelete(e) {
		e.stopPropagation();
		var t = jQuery(e.currentTarget).parents('li').first();		
		var d = {wpfb_action: 'delete'};
		var tid = t.attr('id').split('-');
		d[tid[tid.length-2]+'_id'] = +tid[tid.length-1];
		jQuery.ajax({type: 'POST', url: wpfbConf.ajurl, data: d,
			//async: false,
			success: (function (data) {
				if (data == '1') {
					t.fadeOut(300, function() { t.remove(); });
				}
			})
		});
	
		return false;
	}	
</script>
	
<?php 
    }
Beispiel #5
0
function _manually_load_plugin()
{
    require dirname(dirname(__FILE__)) . '/wp-filebase.php';
    add_action('init', function () {
        require_once dirname(dirname(__FILE__)) . '/classes/Core.php';
        wpfb_loadclass('Setup');
        WPFB_Setup::OnActivateOrVerChange(null);
        WPFB_Core::$settings = (object) get_option(WPFB_OPT_NAME);
        WPFB_Core::InitClass();
    }, 1);
}
Beispiel #6
0
 static function AnalyzeFile($file)
 {
     @ini_set('max_execution_time', '0');
     @set_time_limit(0);
     $filename = is_string($file) ? $file : $file->GetLocalPath();
     $info = WPFB_Core::$settings->disable_id3 ? array() : self::GetEngine()->analyze($filename);
     if (!empty($_GET['debug'])) {
         wpfb_loadclass('Sync');
         WPFB_Sync::PrintDebugTrace("file_analyzed_" . $file->GetLocalPathRel());
     }
     return $info;
 }
 static function Check($tpl)
 {
     $result = array('error' => false, 'msg' => '', 'line' => '');
     wpfb_loadclass('File');
     $f = new WPFB_File();
     $tpl = 'return (' . $tpl . ');';
     if (!@eval($tpl)) {
         $result['error'] = true;
         $err = error_get_last();
         if (!empty($err)) {
             $result['msg'] = $err['message'];
             $result['line'] = $err['line'];
         }
     }
     return $result;
 }
 function test_new_file_remote()
 {
     $usr = wp_create_user('test_admin', 'test_admin');
     $this->assertNotWPError($usr);
     wp_set_current_user($usr);
     wpfb_loadclass('Admin');
     $res = WPFB_Admin::InsertFile(array('file_remote_uri' => 'https://wpfilebase.com/wp-content/blogs.dir/2/files/2015/03/banner_023.png'));
     $this->assertEmpty($res['error'], $res['error']);
     /** @var WPFB_File $file */
     $file = $res['file'];
     $this->assertTrue($file->IsLocal(), 'IsLocal false');
     $this->assertFileExists($file->GetLocalPath());
     $this->assertNotEmpty($file->file_thumbnail);
     $this->assertFileExists($file->GetThumbPath());
     $this->assertTrue($file->Remove());
 }
 function __construct()
 {
     wpfb_loadclass('Download', 'Admin');
     $dir = WPFB_Core::UploadDir() . '/.tmp/';
     WPFB_Admin::Mkdir($dir);
     $test_files = array('banner.png' => 'https://wpfilebase.com/wp-content/blogs.dir/2/files/2015/03/banner_023.png', 'small.txt' => 'https://wpfilebase.com/robots.txt');
     $this->local_files = array();
     foreach ($test_files as $f => $u) {
         $fn = $dir . $f;
         $this->local_files[$f] = $fn;
         if (file_exists($fn)) {
             continue;
         }
         echo "Downloading test file {$u}\n";
         WPFB_Download::SideloadFile($u, $fn);
     }
 }
 /**
  * @depends test_new_cat
  */
 function test_cat_tree()
 {
     wpfb_loadclass('Admin');
     $depth = 4;
     /** @var WPFB_Category $parent */
     $parent = null;
     $cats = array();
     for ($d = 0; $d < $depth; $d++) {
         $res = WPFB_Admin::InsertCategory(array('cat_name' => "layer {$d}", 'cat_parent' => $parent ? $parent->GetId() : 0));
         $this->assertEmpty($res['error']);
         /** @var WPFB_Category $cat */
         $cat = $res['cat'];
         $this->assertTrue($parent ? $cat->GetParent()->Equals($parent) : is_null($cat->GetParent()));
         $cats[] = $cat;
     }
     foreach (array_reverse($cats) as $cat) {
         $res = $cat->Delete();
         $this->assertEmpty($res['error'], $res['error']);
     }
 }
    static function Display()
    {
        wpfb_loadclass('Output', 'File', 'Category', 'TplLib');
        $content = '';
        $file_tpls = WPFB_Core::GetTpls('file');
        $cat_tpls = WPFB_Core::GetTpls('cat');
        if (true || !isset($file_tpls['filebrowser_admin'])) {
            $file_tpls['filebrowser_admin'] = '%file_small_icon% ' . '%file_display_name% (%file_size%) ' . '<!-- IF %file_user_can_edit% --><a href="%file_edit_url%" class="edit" onclick="wpfbFBEditFile(event)">%\'Edit\'%</a><!-- ENDIF -->';
            WPFB_Core::SetFileTpls($file_tpls);
            //WPFB_Admin::ParseTpls();
        }
        if (true || !isset($cat_tpls['filebrowser_admin'])) {
            $cat_tpls['filebrowser_admin'] = '<span class="cat-icon" style="background-image:url(\'%cat_icon_url%\');"><span class="cat-icon-overlay"></span></span>' . '%cat_name% ' . '<!-- IF %cat_user_can_edit% --><a href="%cat_edit_url%" class="edit" onclick="wpfbFBEditCat(event)">%\'Edit\'%</a><!-- ENDIF -->';
            WPFB_Core::SetCatTpls($cat_tpls);
            WPFB_Admin::ParseTpls();
        }
        WPFB_Output::FileBrowser($content, 0, empty($_GET['wpfb_cat']) ? 0 : intval($_GET['wpfb_cat']));
        WPFB_Core::PrintJS();
        ?>
    <div class="wrap filebrowser-admin"> 
    <h2><?php 
        _e('File Browser', WPFB);
        ?>
</h2>    
<?php 
        echo '<div>' . __('You can Drag &amp; Drop (multiple) files directly on Categories to upload them. Dragging a category or an existing file to another category is also possible.', WPFB) . '</div>';
        echo $content;
        ?>
	 </div>
<script>
	function wpfbFBEditCat(e) {
		e.stopPropagation();
	}
	
	function wpfbFBEditFile(e) {
		e.stopPropagation();
	}	
</script>
	
<?php 
    }
Beispiel #12
0
 /**
  * Intesive analysis of file contents. Does _not_ make changes to the file or store anything in the DB!
  * 
  * @param type $file
  * @return type
  */
 private static function analyzeFile($file)
 {
     @ini_set('max_execution_time', '0');
     @set_time_limit(0);
     $filename = is_string($file) ? $file : $file->GetLocalPath();
     $times = array();
     $times['analyze'] = microtime(true);
     $info = WPFB_Core::$settings->disable_id3 ? array() : self::GetEngine()->analyze($filename);
     if (!WPFB_Core::$settings->disable_id3 && class_exists('getid3_lib')) {
         getid3_lib::CopyTagsToComments($info);
     }
     if (!empty($_GET['debug'])) {
         wpfb_loadclass('Sync');
         WPFB_Sync::PrintDebugTrace("file_analyzed_" . $file->GetLocalPathRel());
     }
     $times['end'] = microtime(true);
     $t_keys = array_keys($times);
     $into['debug'] = array('timestamp' => $times[$t_keys[0]], 'timings' => array());
     for ($i = 1; $i < count($t_keys); $i++) {
         $info['debug']['timings'][$t_keys[$i - 1]] = round(($times[$t_keys[$i]] - $times[$t_keys[$i - 1]]) * 1000);
     }
     return $info;
 }
Beispiel #13
0
 static function OnActivateOrVerChange($old_ver = null)
 {
     global $wpdb;
     // make sure that either wp-filebase or wp-filebase pro is enabled bot not both!
     if (!function_exists('is_plugin_active')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     if (is_plugin_active('wp-filebase-pro/wp-filebase.php')) {
         deactivate_plugins('wp-filebase/wp-filebase.php');
     }
     wpfb_loadclass('Admin', 'File', 'Category');
     self::SetupDBTables($old_ver);
     $old_options = get_option(WPFB_OPT_NAME);
     self::AddOptions();
     self::AddTpls($old_ver);
     $new_options = get_option(WPFB_OPT_NAME);
     WPFB_Admin::SettingsUpdated($old_options, $new_options);
     self::ProtectUploadPath();
     $sync_data_file = WPFB_Core::UploadDir() . '/._sync.data';
     is_file($sync_data_file) && unlink($sync_data_file);
     WPFB_Admin::WPCacheRejectUri(WPFB_Core::$settings->download_base . '/', $old_options['download_base'] . '/');
     // TODO, do this in background
     if (WPFB_Category::GetNumCats() < self::MANY_CATEGORIES && WPFB_File::GetNumFiles() < self::MANY_FILES) {
         // avoid long activation time
         wpfb_loadclass('Sync');
         WPFB_Sync::SyncCats();
         WPFB_Sync::UpdateItemsPath();
     }
     if (!wp_next_scheduled(WPFB . '_cron')) {
         wp_schedule_event(time() + 20, 'hourly', WPFB . '_cron');
     }
     if (!get_option('wpfb_install_time')) {
         add_option('wpfb_install_time', ($ft = (int) mysql2date('U', $wpdb->get_var("SELECT file_mtime FROM {$wpdb->wpfilebase_files} ORDER BY file_mtime ASC LIMIT 1"))) > 0 ? $ft : time(), null, 'no');
     }
     $wp_upload = wp_upload_dir();
     // move old css
     if (file_exists(WPFB_Core::GetOldCustomCssPath())) {
         $wp_upload_ok = empty($wp_upload['error']) && is_writable($wp_upload['basedir']);
         if ($wp_upload_ok && @rename(WPFB_Core::GetOldCustomCssPath(), $wp_upload['basedir'] . '/wp-filebase.css')) {
             update_option('wpfb_css', $wp_upload['baseurl'] . '/wp-filebase.css?t=' . time());
         }
     }
     // refresh css URL (in case upload_dir changed or upgrade from free to pro)
     update_option('wpfb_css', trailingslashit(file_exists($wp_upload['basedir'] . '/wp-filebase.css') ? $wp_upload['baseurl'] : WPFB_PLUGIN_URI) . 'wp-filebase.css?t=' . time());
     flush_rewrite_rules();
     // change mapping of file browser folder icons (2340897_sdf.svg => svg-.....svg!)
     $image_mappings = array('1449888880_folder.svg' => 'svg-folder.svg', '1449888883_folder.svg' => 'svg-folder-blue.svg', '1449888885_folder-blue.svg' => 'svg-folderblue.svg', '1449888886_folder-green.svg' => 'svg-folder-green.svg');
     $folder_icons_base = '/plugins/wp-filebase/images/folder-icons/';
     $folder_icon = substr(WPFB_Core::$settings->folder_icon, strlen($folder_icons_base));
     if (isset($image_mappings[$folder_icon])) {
         WPFB_Core::UpdateOption('folder_icon', $folder_icons_base . $image_mappings[$folder_icon]);
     }
     //delete_option('wpfilebase_dismiss_support_ending');
     // fixes files that where offline
     if ($old_ver === "3.4.2") {
         $wpdb->query("UPDATE `{$wpdb->wpfilebase_files}` SET file_offline = '0' WHERE 1");
         wpfb_loadclass('Sync');
         WPFB_Sync::list_files(WPFB_Core::UploadDir());
     }
 }
Beispiel #14
0
 static function GetSortSql($sort = null, $attach_order = false, $for_cat = false)
 {
     global $wpdb;
     wpfb_loadclass('Output');
     list($sort, $sortdir) = WPFB_Output::ParseSorting($sort, $for_cat);
     $sort = esc_sql($sort);
     $of = $for_cat ? 'cat_order' : 'file_attach_order';
     return $attach_order ? "`{$of}` ASC, `{$sort}` {$sortdir}" : "`{$sort}` {$sortdir}";
 }
Beispiel #15
0
 function ChangeCategoryOrName($new_cat_id, $new_name = null, $add_existing = false, $overwrite = false)
 {
     // 1. apply new values (inherit permissions if nothing (Everyone) set!)
     // 2. check for name collision and rename
     // 3. move stuff
     // 4. notify parents
     // 5. update child paths
     if (empty($new_name)) {
         $new_name = $this->GetName();
     }
     $this->Lock(true);
     $new_cat_id = intval($new_cat_id);
     $old_cat_id = $this->GetParentId();
     $old_path_rel = $this->GetLocalPathRel(true);
     $old_path = $this->GetLocalPath();
     $old_name = $this->GetName();
     if ($this->is_file) {
         $old_thumb_path = $this->GetThumbPath();
     }
     $old_cat = $this->GetParent();
     $new_cat = WPFB_Category::GetCat($new_cat_id);
     if (!$new_cat) {
         $new_cat_id = 0;
     }
     $cat_changed = $new_cat_id != $old_cat_id;
     if ($cat_changed && $new_cat_id > 0 && $this->IsAncestorOf($new_cat)) {
         return array('error' => __('Cannot move category into a sub-category of itself.', WPFB));
     }
     if ($this->is_file) {
         $this->file_category = $new_cat_id;
         $this->file_name = $new_name;
         $this->file_category_name = $new_cat_id == 0 ? '' : $new_cat->GetTitle();
     } else {
         $this->cat_parent = $new_cat_id;
         $this->cat_folder = $new_name;
     }
     // inherit user roles
     if (count($this->GetReadPermissions()) == 0) {
         $this->SetReadPermissions($new_cat_id != 0 ? $new_cat->GetReadPermissions() : WPFB_Core::$settings->default_roles);
     }
     // flush cache
     $this->last_parent_id = -1;
     $new_path_rel = $this->GetLocalPathRel(true);
     $new_path = $this->GetLocalPath();
     if ($new_path_rel != $old_path_rel) {
         $i = 1;
         if (!$add_existing) {
             $name = $this->GetName();
             if ($overwrite) {
                 if (@file_exists($new_path)) {
                     $ex_file = WPFB_File::GetByPath($new_path_rel);
                     if (!is_null($ex_file)) {
                         $ex_file->Remove();
                     } else {
                         @unlink($new_path);
                     }
                 }
             } else {
                 // rename item if filename collision (ignore if coliding with $this)
                 while (@file_exists($new_path) || !is_null($ex_file = WPFB_File::GetByPath($new_path_rel)) && !$this->Equals($ex_file)) {
                     $i++;
                     if ($this->is_file) {
                         $p = strrpos($name, '.');
                         $this->file_name = $p <= 0 ? "{$name}({$i})" : substr($name, 0, $p) . "({$i})" . substr($name, $p);
                     } else {
                         $this->cat_folder = "{$name}({$i})";
                     }
                     $new_path_rel = $this->GetLocalPathRel(true);
                     $new_path = $this->GetLocalPath();
                 }
             }
         }
         // finally move it!
         if (!empty($old_name) && @file_exists($old_path)) {
             if ($this->is_file && $this->IsLocal()) {
                 if (!@rename($old_path, $new_path)) {
                     return array('error' => sprintf('Unable to move file %s!', $old_path));
                 }
                 @chmod($new_path, octdec(WPFB_PERM_FILE));
             } else {
                 if (!@is_dir($new_path)) {
                     wp_mkdir_p($new_path);
                 }
                 wpfb_loadclass('FileUtils');
                 if (!@WPFB_FileUtils::MoveDir($old_path, $new_path)) {
                     return array('error' => sprintf('Could not move folder %s to %s', $old_path, $new_path));
                 }
             }
         } else {
             if ($this->is_category) {
                 if (!@is_dir($new_path) && !wp_mkdir_p($new_path)) {
                     return array('error' => sprintf(__('Unable to create directory %s. Is it\'s parent directory writable?'), $new_path));
                 }
             }
         }
         // move thumb
         if ($this->is_file && !empty($old_thumb_path) && @is_file($old_thumb_path)) {
             $thumb_path = $this->GetThumbPath();
             if ($i > 1) {
                 $p = strrpos($thumb_path, '-');
                 if ($p <= 0) {
                     $p = strrpos($thumb_path, '.');
                 }
                 $thumb_path = substr($thumb_path, 0, $p) . "({$i})" . substr($thumb_path, $p);
                 $this->file_thumbnail = basename($thumb_path);
             }
             if (!is_dir(dirname($thumb_path))) {
                 WPFB_Admin::Mkdir(dirname($thumb_path));
             }
             if (!@rename($old_thumb_path, $thumb_path)) {
                 return array('error' => 'Unable to move thumbnail! ' . $thumb_path);
             }
             @chmod($thumb_path, octdec(WPFB_PERM_FILE));
         }
         $all_files = $this->is_file || $this->GetId() > 0 ? $this->GetChildFiles(true) : array();
         // all children files (recursively)
         if (!empty($all_files)) {
             foreach ($all_files as $file) {
                 if ($cat_changed) {
                     if ($old_cat) {
                         $old_cat->NotifyFileRemoved($file);
                     }
                     // notify parent cat to remove files
                     if ($new_cat) {
                         $new_cat->NotifyFileAdded($file);
                     }
                 }
                 $file->GetLocalPathRel(true);
                 // update file's path
             }
         }
         unset($all_files);
         if ($this->is_category && $this->GetId() > 0) {
             $cats = $this->GetChildCats(true);
             if (!empty($cats)) {
                 foreach ($cats as $cat) {
                     $cat->GetLocalPathRel(true);
                     // update cats's path
                 }
             }
             unset($cats);
         }
     }
     $this->Lock(false);
     if (!$this->locked) {
         $this->DBSave();
     }
     return array('error' => false);
     /*
     * 		// create the directory if it doesnt exist
     		// move file
     		if($this->IsLocal() && !empty($old_file_path) && @is_file($old_file_path) && $new_file_path != $old_file_path) {
     			if(!@rename($old_file_path, $new_file_path)) return array( 'error' => sprintf('Unable to move file %s!', $this->GetLocalPath()));
     			@chmod($new_file_path, octdec(WPFB_PERM_FILE));
     		}
     */
 }
Beispiel #16
0
 static function FileSearchContent(&$ref_content)
 {
     wpfb_loadclass('ListTpl');
     $tpl = WPFB_ListTpl::Get(WPFB_Core::$settings->search_result_tpl);
     if ($tpl !== null) {
         $ref_content .= $tpl->Generate(null, array('page_limit' => WPFB_Core::$settings->filelist_num));
     } else {
         $files = WPFB_File::GetFiles2(self::SearchWhereSql(WPFB_Core::$settings->search_id3, stripslashes($_GET['wpfb_s'])), WPFB_Core::$settings->hide_inaccessible);
         foreach ($files as $file) {
             $ref_content .= $file->GenTpl2();
         }
     }
 }
Beispiel #17
0
</h2>
	<div id="catselect-filter">
		<p><?php 
    _e('Select the categories containing the files you would like to list.', 'wp-filebase');
    ?>
</p>
		<p><input type="checkbox" id="list-all-files" name="list-all-files" value="1" onchange="incAllCatsChanged(this.checked)"/> <label for="list-all-files"><?php 
    _e('Include all Categories', 'wp-filebase');
    ?>
</label></p>
	
	</div>
	
	<ul id="catbrowser" class="filetree"></ul>
	<?php 
    wpfb_loadclass('TreeviewAdmin');
    WPFB_TreeviewAdmin::RenderHTML("catbrowser");
    ?>
</div>
<form id="listtplselect" class="insert">
	<h2><?php 
    _e('Select Template', 'wp-filebase');
    ?>
</h2>
	<?php 
    $tpls = WPFB_ListTpl::GetAll();
    if (!empty($tpls)) {
        foreach ($tpls as $tpl) {
            echo '<label><input type="radio" name="listtpl" value="' . $tpl->tag . '" />' . $tpl->GetTitle() . '</label><br />';
        }
    }
<?php

wpfb_loadclass('Item');
class WPFB_Category extends WPFB_Item
{
    var $cat_id;
    var $cat_name;
    var $cat_description;
    var $cat_folder;
    var $cat_path;
    var $cat_parent = 0;
    var $cat_num_files = 0;
    var $cat_num_files_total = 0;
    var $cat_user_roles;
    var $cat_owner = 0;
    var $cat_icon;
    var $cat_exclude_browser = 0;
    var $cat_order;
    static $cache = array();
    static $cache_complete = false;
    /**
     * Get category objects
     *
     * @access public
     * 
     * @param $extra_sql Optional
     * @return WPFB_Category[] Categories
     */
    static function GetCats($extra_sql = null)
    {
        global $wpdb;
// ##########################################################
// ##########################################################
// #############    THIS FILE IS DEPRECATED!!    ############
// ##########################################################
// ##########################################################
// ob_start();
define('WPFB_NO_CORE_INIT', true);
define('WP_INSTALLING', true);
// make wp load faster
if (empty($_GET['rp'])) {
    // if rel path not set, need to load whole WP stuff to get to path to custom CSS!
    require_once dirname(__FILE__) . '/../../../cms/wp-load.php';
}
require_once dirname(__FILE__) . '/wp-filebase.php';
// this only loads some wp-filebase stuff, NOT WP!
wpfb_loadclass('Core');
WPFB_Core::InitDirectScriptAccess();
$file = WPFB_Core::GetOldCustomCssPath(stripslashes(@$_GET['rp']));
//echo $file;
//@ob_end_clean();
if (empty($file) || !@file_exists($file) || !@is_writable($file)) {
    // TODO: remove writable check? this is for security!
    $file = WPFB_PLUGIN_ROOT . 'wp-filebase.css';
}
$ftime = filemtime($file);
header("Content-Type: text/css");
header("Cache-Control: max-age=3600");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $ftime) . " GMT");
header("Content-Length: " . filesize($file));
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $ftime) {
    header("HTTP/1.x 304 Not Modified");
 static function SendFile($file_path, $args = array())
 {
     global $wpdb;
     $defaults = array('bandwidth' => 0, 'etag' => null, 'force_download' => WPFB_Core::$settings->force_download, 'cache_max_age' => 0, 'md5_hash' => null, 'filename' => null);
     extract(wp_parse_args($args, $defaults), EXTR_SKIP);
     @ini_set('max_execution_time', '0');
     @set_time_limit(0);
     @error_reporting(0);
     while (@ob_end_clean()) {
     }
     $no_cache = WPFB_Core::$settings->http_nocache && $cache_max_age != 0;
     @ini_set("zlib.output_compression", "Off");
     // remove some headers
     if (function_exists('header_remove')) {
         header_remove();
     } else {
         header("Expires: ");
         header("X-Pingback: ");
     }
     if (!@file_exists($file_path) || !is_file($file_path)) {
         header('HTTP/1.x 404 Not Found');
         wp_die('File ' . basename($file_path) . ' not found!');
     }
     wpfb_loadclass('FileUtils');
     $size = WPFB_FileUtils::GetFileSize($file_path);
     $time = filemtime($file_path);
     $file_type = WPFB_Download::GetFileType($file_path);
     if (empty($etag)) {
         $etag = md5("{$size}|{$time}|{$file_type}");
     } else {
         $etag = trim($etag, '"');
     }
     // set basic headers
     if ($no_cache) {
         header("Cache-Control: no-cache, must-revalidate, max-age=0");
         header("Pragma: no-cache");
         header("Expires: Wed, 11 Jan 1984 05:00:00 GMT");
     } elseif ($cache_max_age > 0) {
         header("Cache-Control: must-revalidate, max-age={$cache_max_age}");
     } elseif ($cache_max_age == -1) {
         header("Cache-Control: public");
     }
     //header("Connection: close");
     //header("Keep-Alive: timeout=5, max=100");
     //header("Connection: Keep-Alive");
     header("Content-Type: " . $file_type . (strpos($file_type, 'text/') !== false ? '; charset=' : ''));
     // charset fix
     header("Last-Modified: " . gmdate("D, d M Y H:i:s", $no_cache ? time() : $time) . " GMT");
     if (!empty($md5_hash) && $md5_hash[0] != '#') {
         // check if fake md5
         $pmd5 = @pack('H32', $md5_hash);
         if (!empty($pmd5)) {
             header("Content-MD5: " . @base64_encode($pmd5));
         }
     }
     if (!$no_cache) {
         header("ETag: \"{$etag}\"");
         $if_mod_since = !empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
         $if_none_match = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? $etag == trim($_SERVER['HTTP_IF_NONE_MATCH'], '"') : false;
         if ($if_mod_since || $if_none_match) {
             $not_modified = true;
             if ($not_modified && $if_mod_since) {
                 $not_modified = @strtotime($if_mod_since) >= $time;
             }
             if ($not_modified && $if_none_match) {
                 $not_modified = $if_none_match == $etag;
             }
             if ($not_modified) {
                 header("Content-Length: " . $size);
                 header("HTTP/1.x 304 Not Modified");
                 exit;
             }
         }
     }
     if (!($fh = @fopen($file_path, 'rb'))) {
         wp_die(__('Could not read file!', 'wp-filebase'));
     }
     list($begin, $end) = self::ParseRangeHeader($size);
     if ($begin > 0 || $end < $size - 1) {
         header('HTTP/1.0 206 Partial Content');
         header("Content-Range: bytes {$begin}-{$end}/{$size}");
     } else {
         header('HTTP/1.0 200 OK');
     }
     $length = $end - $begin + 1;
     WPFB_Download::AddTraffic($length);
     if (self::ShouldSendRangeHeader($file_path, $file_type)) {
         header("Accept-Ranges: bytes");
     }
     $request_file_name = basename(urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)));
     $filename_set = !empty($filename);
     if (!$filename_set) {
         $filename = basename($file_path);
     }
     // content headers
     if ($force_download) {
         header("Content-Disposition: attachment; filename=\"{$filename}\"");
         header("Content-Description: File Transfer");
     } elseif ($filename != $request_file_name) {
         header("Content-Disposition: inline; filename=\"{$filename}\"");
     }
     header("Content-Length: " . $length);
     // clean up things that are not needed for download
     @session_write_close();
     // disable blocking of multiple downloads at the same time
     // close db connection
     if (method_exists($wpdb, 'close')) {
         $wpdb->close();
     } elseif (function_exists('mysql_close')) {
         if (!empty($wpdb->dbh) && is_resource($wpdb->dbh)) {
             @mysql_close($wpdb->dbh);
         } else {
             @mysql_close();
         }
     }
     @ob_flush();
     @flush();
     // ready to send the file!
     if ($begin > 0) {
         fseek($fh, $begin, 0);
     }
     if (WPFB_Core::$settings->use_fpassthru) {
         fpassthru($fh);
     } else {
         $bandwidth = empty($bandwidth) ? 0 : (double) $bandwidth;
         if ($bandwidth <= 0) {
             $bandwidth = 1024 * 1024;
         }
         $buffer_size = (int) (1024 * min($bandwidth, 64));
         // convert kib/s => bytes/ms
         $bandwidth *= 1024 / 1000;
         $cur = $begin;
         while (!@feof($fh) && $cur <= $end && @connection_status() == 0) {
             $nbytes = min($buffer_size, $end - $cur + 1);
             $ts = microtime(true);
             print @fread($fh, $nbytes);
             @ob_flush();
             @flush();
             $dt = (microtime(true) - $ts) * 1000;
             // dt = time delta in ms
             $st = $nbytes / $bandwidth - $dt;
             if ($st > 0) {
                 usleep($st * 1000);
             }
             $cur += $nbytes;
         }
     }
     @fclose($fh);
     return true;
 }
Beispiel #21
0
 function get_file_where_cond($view = 'all')
 {
     global $wpdb, $current_user;
     wpfb_loadclass('Search');
     $where = WPFB_Search::SearchWhereSql(true);
     if (!empty($_REQUEST['file_category'])) {
         $where = (empty($where) ? '' : "({$where}) AND ") . "file_category = " . intval($_REQUEST['file_category']);
     }
     if (!empty($view) && $view != 'all') {
         $view_cond = "1=1";
         switch ($view) {
             case 'own':
                 $view_cond = "file_added_by = " . (int) $current_user->ID;
                 break;
             case 'offline':
                 $view_cond = "file_offline = '1'";
                 break;
             case 'notattached':
                 $view_cond = "file_post_id = 0";
                 break;
             case 'local':
                 $view_cond = "file_remote_uri = ''";
                 break;
             case 'cloud':
                 $view_cond = "file_remote_uri <> ''";
                 break;
         }
         $where = (empty($where) ? '' : "({$where}) AND ") . $view_cond;
     }
     return $where;
 }
Beispiel #22
0
    public function Display()
    {
        wpfb_call('Output', 'PrintJS');
        wp_print_scripts('utils');
        // setUserSetting
        ?>
		<style type="text/css" media="screen">@import url(<?php 
        echo WPFB_PLUGIN_URI . 'css/batch-uploader.css';
        ?>
);</style>
		
<div id="<?php 
        echo $this->prefix;
        ?>
-uploader-wrap">	
	<div id="<?php 
        echo $this->prefix;
        ?>
-uploader-interface" class="wpfb-batch-uploader-interface">	
		<div class="form-wrap uploader-presets" id="<?php 
        echo $this->prefix;
        ?>
-uploader-presets">	
		<form method="POST" action="" class="validate" name="batch_presets">
			 <h2><?php 
        _e('Upload Presets', 'wp-filebase');
        ?>
</h2> 
			<?php 
        self::DisplayUploadPresets($this->prefix);
        //wp_nonce_field('batch-presets'); // TODO validate this!
        ?>
		</form>
		</div>

		<div id="<?php 
        echo $this->prefix;
        ?>
-drag-drop-uploader" class="drag-drop-uploader">
			 <h2>Drag &amp; Drop</h2> 
			<div id="<?php 
        echo $this->prefix;
        ?>
-drag-drop-area" class="drag-drop-area">
				<div style="margin: 70px auto 0;">
					<p class="drag-drop-info"><?php 
        _e('Drop files here');
        ?>
</p>
					<p><?php 
        _ex('or', 'Uploader: Drop files here - or - Select Files');
        ?>
</p>
					<p class="drag-drop-buttons"><input id="<?php 
        echo $this->prefix;
        ?>
-browse-button" type="button" value="<?php 
        esc_attr_e('Select Files');
        ?>
" class="button" /></p> 			
				</div>
			</div>
			<div id="<?php 
        echo $this->prefix;
        ?>
-uploader-errors"></div>
		</div>

		<div style="clear: both;"></div>
	</div>

	<div id="<?php 
        echo $this->prefix;
        ?>
-uploader-files" style="position:relative;"></div>
</div>

<?php 
        wp_print_scripts('jquery-color');
        wp_print_scripts('jquery-deserialize');
        ?>

<script type="text/javascript">
	
var mouseDragPos = [];
var presetData = '';
var morePresets = 0;

jQuery(document).ready( function() {
	var form = jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-presets').find('form');
		
	jQuery('#<?php 
        echo $this->prefix;
        ?>
-drag-drop-area').bind('dragover', function(e){
		mouseDragPos = [e.originalEvent.pageX, e.originalEvent.pageY];
	});	
	
<?php 
        ?>
	wpfb_setupFormAutoSave(form,'batch_presets');
<?php 
        ?>

	// "more" toggle init
	form.find('tr.more').hide();
	form.find('tr.more-more').hide();
	morePresets = 0;
	jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-presets-more-toggle').click(function() {
		batchUploaderSetPresetsMore(morePresets = ((morePresets+1)%3));
	});	
	batchUploaderSetPresetsMore(typeof(getUserSetting) !== 'function' || getUserSetting('wpfb_batch_presets_more') || 0);
});

function batchUploaderSetPresetsMore(m)
{
	if(isNaN(m)) m = 0;
	var form = jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-presets').find('form');
	
	form.find('tr.more')[m == 0 ? 'hide' : 'show'](400);
	form.find('tr.more-more')[m != 2 ? 'hide' : 'show'](400);
	
	// TODO show any field with non-default value!!
	
	//form.find('tr.more').toggle(morePresets > 0);
	//form.find('tr.more-more').toggle(morePresets > 1);
	
	if(typeof(setUserSetting) !== 'undefined') setUserSetting('wpfb_batch_presets_more',''+morePresets);
	jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-presets-more-toggle td span').html(m==2?'<?php 
        _e('less');
        ?>
':'<?php 
        _e('more');
        ?>
');
}

function batchUploaderFilesQueued(up, files)
{
	var form = jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-presets').find('form');
	up.settings.multipart_params["presets"] = form.serialize();
	
	var hidden_params = form.find('input[type=hidden]').serializeArray();
	for (var i = 0; i < hidden_params.length; ++i) {
		up.settings.multipart_params[hidden_params[i].name] = hidden_params[i].value;
	}
	
	form
		.css({ background:			 "rgba(255,255,0,0.0)" })
		.animate({ backgroundColor: "rgba(255,255,0,0.5)"}, 100)
		.animate({ backgroundColor: "rgba(255,255,0,0.0)"}, 400);
		
	form.find('input,textarea,select')
		.animate({ opacity: 0.2}, 100)
		.animate({ opacity: 1.0}, 400);
		
	form.find("input[name='file_display_name']").val('');
}

function batchUploaderFileQueued(up, file)
{
	//file.name, file.size

	jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-files').prepend('<div id="<?php 
        echo $this->prefix;
        ?>
-uploader-file-'+file.id+'-spacer" class="batch-uploader-file-spacer"></div>');

	jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-files').prepend('<div id="'+file.dom_id+'" class="media-item batch-uploader-file">'+
	'<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>'+
	'<img src="<?php 
        echo site_url(WPINC . '/images/crystal/default.png');
        ?>
" alt="Loading..." /><span class="filename">'+file.name+'</span><span class="error"></span></div>');
	
	
	var fileEl = jQuery('#'+file.dom_id);
	var spacerEl = jQuery('#<?php 
        echo $this->prefix;
        ?>
-uploader-file-'+file.id+'-spacer');
	var dest = fileEl.offset();
	var ppos = fileEl.parent().offset();
	var destWidth = fileEl.width();
	
	fileEl.css({position:'absolute', zIndex:100, top:mouseDragPos[1]-ppos.top, left:mouseDragPos[0]-ppos.left-15});
	
	fileEl.animate({
		 //opacity: 0.25,
		 left: dest.left-ppos.left,
		 top: dest.top-ppos.top
	  }, 400, function() {
		 spacerEl.remove();
		 var startWidth = jQuery(this).width();
		 jQuery(this)
			.css({position:'',top:0,left:0,width:startWidth})
			.animate({width: destWidth}, 200);
	  });
	  
	spacerEl.animate({height: fileEl.outerHeight(true)}, 400);
	  
	jQuery('.error', fileEl).hide();
}

function batchUploaderSuccess(file, serverData)
{
	var item = jQuery('#'+file.dom_id);	
        
        if(!serverData || serverData == -1 || 'object' != typeof(serverData)) {
            jQuery('.error', item).show().html('Server response error! '+serverData);
            console.log(serverData);
            return;
        }
        
	var url = serverData.file_cur_user_can_edit ? serverData.file_edit_url : serverData.file_download_url;
	jQuery('.filename', item).html('<a href="'+url+'" target="_blank">'+serverData.file_display_name+'</a> <span class="ok"><?php 
        _e('Upload OK!', 'wp-filebase');
        ?>
</span>');
	jQuery('img', item).attr('src', serverData.file_thumbnail_url);
}
</script>
<?php 
        wpfb_loadclass('PLUploader');
        $uploader = new WPFB_PLUploader();
        $uploader->js_file_queued = 'batchUploaderFileQueued';
        $uploader->js_files_queued = 'batchUploaderFilesQueued';
        $uploader->js_upload_success = 'batchUploaderSuccess';
        $uploader->post_params['file_add_now'] = true;
        if (!empty($this->hidden_vars)) {
            $uploader->post_params = array_merge($uploader->post_params, $this->hidden_vars);
        }
        $uploader->Init($this->prefix . '-drag-drop-area', $this->prefix . '-browse-button', $this->prefix . '-uploader-errors');
    }
Beispiel #23
0
 function GenerateList(&$content, $categories, $list_args = null)
 {
     if (!empty($list_args)) {
         $this->current_list = (object) $list_args;
         unset($list_args);
     }
     $hia = WPFB_Core::$settings->hide_inaccessible;
     $sort = WPFB_Core::GetSortSql($this->current_list->file_order);
     if ($this->current_list->page_limit > 0) {
         // pagination
         $page = empty($_REQUEST['wpfb_list_page']) || $_REQUEST['wpfb_list_page'] < 1 ? 1 : intval($_REQUEST['wpfb_list_page']);
         $start = $this->current_list->page_limit * ($page - 1);
     } else {
         $start = -1;
     }
     $search_term = empty($_GET['wpfb_s']) ? null : stripslashes($_GET['wpfb_s']);
     if ($search_term || WPFB_Core::$file_browser_search) {
         // search
         wpfb_loadclass('Search');
         $where = WPFB_Search::SearchWhereSql(WPFB_Core::$settings->search_id3, $search_term);
     } else {
         $where = '1=1';
     }
     $num_total_files = 0;
     if (is_null($categories)) {
         // if null, just list all files!
         $files = WPFB_File::GetFiles2($where, $hia, $sort, $this->current_list->page_limit, $start);
         $num_total_files = WPFB_File::GetNumFiles2($where, $hia);
         foreach ($files as $file) {
             $content .= $file->GenTpl2($this->file_tpl_tag);
         }
     } else {
         if (!empty($this->current_list->cat_order)) {
             WPFB_Item::Sort($categories, $this->current_list->cat_order);
         }
         $cat = reset($categories);
         // get first category
         // here we check if single category and cat has at least one file (also secondary cat files!)
         if (count($categories) == 1 && $cat->cat_num_files > 0) {
             // single cat
             if (!$cat->CurUserCanAccess()) {
                 return '';
             }
             $where = "({$where}) AND " . WPFB_File::GetSqlCatWhereStr($cat->cat_id);
             $files = WPFB_File::GetFiles2($where, $hia, $sort, $this->current_list->page_limit, $start);
             $num_total_files = WPFB_File::GetNumFiles2($where, $hia);
             if ($this->current_list->cat_grouping && $num_total_files > 0) {
                 $content .= $cat->GenTpl2($this->cat_tpl_tag);
             }
             foreach ($files as $file) {
                 $content .= $file->GenTpl2($this->file_tpl_tag);
             }
         } else {
             // multi-cat
             // TODO: multi-cat list pagination does not work properly yet
             // special handling of categories that do not have files directly: list child cats!
             if (count($categories) == 1 && $cat->cat_num_files == 0) {
                 $categories = $cat->GetChildCats(true, true);
                 if (!empty($this->current_list->cat_order)) {
                     WPFB_Item::Sort($categories, $this->current_list->cat_order);
                 }
             }
             if ($this->current_list->cat_grouping) {
                 // group by categories
                 $n = 0;
                 foreach ($categories as $cat) {
                     if (!$cat->CurUserCanAccess()) {
                         continue;
                     }
                     $num_total_files = max($nf = WPFB_File::GetNumFiles2("({$where}) AND " . WPFB_File::GetSqlCatWhereStr($cat->cat_id), $hia), $num_total_files);
                     // TODO
                     //if($n > $this->current_list->page_limit) break; // TODO!!
                     if ($nf > 0) {
                         $files = WPFB_File::GetFiles2("({$where}) AND " . WPFB_File::GetSqlCatWhereStr($cat->cat_id), $hia, $sort, $this->current_list->page_limit, $start);
                         if (count($files) > 0) {
                             $content .= $cat->GenTpl2($this->cat_tpl_tag);
                             // check for file count again, due to pagination!
                             foreach ($files as $file) {
                                 $content .= $file->GenTpl2($this->file_tpl_tag);
                             }
                         }
                     }
                 }
             } else {
                 // this is not very efficient, because all files are loaded, no pagination!
                 $all_files = array();
                 foreach ($categories as $cat) {
                     if (!$cat->CurUserCanAccess()) {
                         continue;
                     }
                     $all_files += WPFB_File::GetFiles2("({$where}) AND " . WPFB_File::GetSqlCatWhereStr($cat->cat_id), $hia, $sort);
                 }
                 $num_total_files = count($all_files);
                 WPFB_Item::Sort($all_files, $sort);
                 $keys = array_keys($all_files);
                 if ($start == -1) {
                     $start = 0;
                 }
                 $last = $this->current_list->page_limit > 0 ? min($start + $this->current_list->page_limit, $num_total_files) : $num_total_files;
                 for ($i = $start; $i < $last; $i++) {
                     $content .= $all_files[$keys[$i]]->GenTpl2($this->file_tpl_tag);
                 }
             }
         }
     }
     return $num_total_files;
 }
    static function Display()
    {
        global $wpdb;
        wpfb_loadclass('Admin', 'Output');
        WPFB_Core::PrintJS();
        // prints wpfbConf.ajurl
        wp_register_script('jquery-imagepicker', WPFB_PLUGIN_URI . 'extras/jquery/image-picker/image-picker.min.js', array('jquery'), WPFB_VERSION);
        wp_register_style('jquery-imagepicker', WPFB_PLUGIN_URI . 'extras/jquery/image-picker/image-picker.css', array(), WPFB_VERSION);
        if (!current_user_can('manage_options')) {
            wp_die(__('Cheatin&#8217; uh?') . '<!-- manage_options -->');
        }
        // nonce and referer check (security)
        if ((!empty($_POST['reset']) || !empty($_POST['submit'])) && !check_admin_referer('wpfb-update-settings', 'wpfb-nonce')) {
            wp_die(__('Cheatin&#8217; uh?'));
        }
        $post = stripslashes_deep($_POST);
        $action = !empty($post['action']) ? $post['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
        $messages = array();
        $errors = array();
        $options = get_option(WPFB_OPT_NAME);
        $option_fields = WPFB_Admin::SettingsSchema();
        if (isset($post['reset'])) {
            // keep templates
            $file_tpl = WPFB_Core::$settings->template_file;
            $cat_tpl = WPFB_Core::$settings->template_cat;
            wpfb_loadclass('Setup');
            WPFB_Setup::ResetOptions();
            WPFB_Core::UpdateOption('template_file', $file_tpl);
            WPFB_Core::UpdateOption('template_cat', $cat_tpl);
            $new_options = get_option(WPFB_OPT_NAME);
            $messages = array_merge($messages, WPFB_Admin::SettingsUpdated($options, $new_options));
            unset($new_options);
            $messages[] = __('Settings reseted.', WPFB);
            $options = get_option(WPFB_OPT_NAME);
        } elseif (isset($post['submit'])) {
            // cleanup
            foreach ($option_fields as $opt_tag => $opt_data) {
                if (isset($post[$opt_tag])) {
                    if (!is_array($post[$opt_tag])) {
                        $post[$opt_tag] = trim($post[$opt_tag]);
                    }
                    switch ($opt_data['type']) {
                        case 'number':
                            $post[$opt_tag] = intval($post[$opt_tag]);
                            break;
                        case 'select':
                            // check if value is in options array, if not set to default
                            if (!in_array($post[$opt_tag], array_keys($opt_data['options']))) {
                                $post[$opt_tag] = $opt_data['default'];
                            }
                            break;
                        case 'roles':
                            $post[$opt_tag] = array_values(array_filter($post[$opt_tag]));
                            // the following must not be removed! if the roles array is empty, permissions are assumed to be set for everyone!
                            // so make sure that the admin is explicitly set!
                            if (!empty($opt_data['not_everyone']) && !in_array('administrator', $post[$opt_tag])) {
                                if (!is_array($post[$opt_tag])) {
                                    $post[$opt_tag] = array();
                                }
                                array_unshift($post[$opt_tag], 'administrator');
                            }
                            break;
                        case 'cat':
                            $post[$opt_tag] = empty($post[$opt_tag]) || is_null($cat = WPFB_Category::GetCat($post[$opt_tag])) ? 0 : intval($post[$opt_tag]);
                            break;
                    }
                }
            }
            $post['upload_path'] = str_replace(ABSPATH, '', $post['upload_path']);
            $options['upload_path'] = str_replace(ABSPATH, '', $options['upload_path']);
            $post['download_base'] = trim($post['download_base'], '/');
            if (WPFB_Admin::WPCacheRejectUri($post['download_base'] . '/', $options['download_base'] . '/')) {
                $messages[] = sprintf(__('/%s/ added to rejected URIs list of WP Super Cache.', WPFB), $post['download_base']);
            }
            $tpl_file = $post['template_file'];
            $tpl_cat = $post['template_cat'];
            if (!empty($tpl_file) && (empty($options['template_file_parsed']) || $tpl_file != $options['template_file'])) {
                wpfb_loadclass('TplLib');
                $tpl_file = WPFB_TplLib::Parse($tpl_file);
                $result = WPFB_TplLib::Check($tpl_file);
                if (!$result['error']) {
                    $options['template_file_parsed'] = $tpl_file;
                    $messages[] = __('File template successfully parsed.', WPFB);
                } else {
                    $errors[] = sprintf(__('Could not parse template: error (%s) in line %s.', WPFB), $result['msg'], $result['line']);
                }
            }
            if (!empty($tpl_cat) && (empty($options['template_cat_parsed']) || $tpl_cat != $options['template_cat'])) {
                wpfb_loadclass('TplLib');
                $tpl_cat = WPFB_TplLib::Parse($tpl_cat);
                $result = WPFB_TplLib::Check($tpl_cat);
                if (!$result['error']) {
                    $options['template_cat_parsed'] = $tpl_cat;
                    $messages[] = __('Category template successfully parsed.', WPFB);
                } else {
                    $errors[] = sprintf(__('Could not parse template: error (%s) in line %s.', WPFB), $result['msg'], $result['line']);
                }
            }
            $fb_sub_pages = get_pages(array('child_of' => $options['file_browser_post_id']));
            if ($options['file_browser_post_id'] > 0 && count($fb_sub_pages)) {
                $messages[] = sprintf(__('Warning: The Filebrowser page <b>%s</b> has at least one subpage <b>%s</b>. This will cause unexpected behavior, since all requests to the subpages are redirected to the File Browser Page. Please choose a Page that does not have any subpages for File Browser.', WPFB), get_the_title($post['file_browser_post_id']), get_the_title($fb_sub_pages[0]->ID));
            }
            // save options
            foreach ($option_fields as $opt_tag => $opt_data) {
                $val = isset($post[$opt_tag]) ? $post[$opt_tag] : '';
                $options[$opt_tag] = $val;
            }
            // make sure a short tag exists, if not append one
            $select_opts = array('languages', 'platforms', 'licenses', 'requirements', 'custom_fields');
            foreach ($select_opts as $opt_tag) {
                if (empty($options[$opt_tag])) {
                    $options[$opt_tag] = '';
                    continue;
                }
                $lines = explode("\n", $options[$opt_tag]);
                $lines2 = array();
                for ($i = 0; $i < count($lines); $i++) {
                    $lines[$i] = str_replace('||', '|', trim($lines[$i], "|\r"));
                    if (empty($lines[$i]) || $lines[$i] == '|') {
                        continue;
                    }
                    $pos = strpos($lines[$i], '|');
                    if ($pos <= 0) {
                        $lines[$i] .= '|' . sanitize_key(substr($lines[$i], 0, min(8, strlen($lines[$i]))));
                    }
                    $lines2[] = $lines[$i];
                }
                $options[$opt_tag] = implode("\n", $lines2);
            }
            $old_options = get_option(WPFB_OPT_NAME);
            update_option(WPFB_OPT_NAME, $options);
            WPFB_Core::$settings = (object) $options;
            $messages = array_merge($messages, WPFB_Admin::SettingsUpdated($old_options, $options));
            if (count($errors) == 0) {
                $messages[] = __('Settings updated.', WPFB);
            }
            //refresh any description which can contain opt values
            $option_fields = WPFB_Admin::SettingsSchema();
        }
        if (WPFB_Core::$settings->allow_srv_script_upload) {
            $messages[] = __('WARNING: Script upload enabled!', WPFB);
        }
        $upload_path = WPFB_Core::$settings->upload_path;
        if (!empty($old_options) && path_is_absolute($upload_path) && !path_is_absolute($old_options['upload_path'])) {
            $rel_path = str_replace('\\', '/', $upload_path);
            $rel_path = substr($rel_path, strpos($rel_path, '/') + 1);
            $messages[] = __(sprintf('NOTICE: The upload path <code>%s</code> is rooted to the filesystem. You should remove the leading slash if you want to use a folder inside your Wordpress directory (i.e: <code>%s</code>)', $upload_path, $rel_path), WPFB);
        }
        $action_uri = admin_url('admin.php') . '?page=' . $_GET['page'] . '&amp;updated=true';
        if (!empty($messages)) {
            $message = '';
            foreach ($messages as $msg) {
                $message .= '<p>' . $msg . '</p>';
            }
            ?>
<div id="message" class="updated fade"><?php 
            echo $message;
            ?>
</div>
<?php 
        }
        if (!empty($errors)) {
            $error = '';
            foreach ($errors as $err) {
                $error .= '<p>' . $err . '</p>';
            }
            ?>
<div id="message" class="error fade"><?php 
            echo $error;
            ?>
</div>
<?php 
        }
        ?>
<script type="text/javascript">
/* Option tabs */
jQuery(document).ready( function() {
	try { jQuery('#wpfb-tabs').tabs(); }
	catch(ex) {}
	/*if(typeof(CKEDITOR) != 'undefined') {
		CKEDITOR.plugins.addExternal('wpfilebase', ajaxurl+'/../../wp-content/plugins/wp-filebase/extras/ckeditor/');
		alert( ajaxurl+'/../../wp-content/plugins/wp-filebase/extras/ckeditor/');
	}*/
});
</script>

<div class="wrap">
<div id="icon-options-general" class="icon32"><br /></div>
<h2><?php 
        echo WPFB_PLUGIN_NAME;
        echo ' ';
        _e("Settings");
        ?>
</h2>

<form method="post" action="<?php 
        echo $action_uri;
        ?>
" name="wpfilebase-options">
	<?php 
        wp_nonce_field('wpfb-update-settings', 'wpfb-nonce');
        ?>
	<p class="submit">
	<input type="submit" name="submit" value="<?php 
        _e('Save Changes');
        ?>
" class="button-primary" />
	</p>
	<?php 
        $misc_tags = array('disable_id3', 'search_id3', 'thumbnail_path', 'use_path_tags', 'no_name_formatting');
        if (function_exists('wp_admin_bar_render')) {
            $misc_tags[] = 'admin_bar';
        }
        $limits = array('bitrate_unregistered', 'bitrate_registered', 'traffic_day', 'traffic_month', 'traffic_exceeded_msg', 'file_offline_msg', 'daily_user_limits', 'daily_limit_subscriber', 'daily_limit_contributor', 'daily_limit_author', 'daily_limit_editor', 'daily_limit_exceeded_msg');
        $option_categories = array(__('Common', WPFB) => array('upload_path', 'search_integration'), __('Display', WPFB) => array('file_date_format', 'thumbnail_size', 'auto_attach_files', 'attach_loop', 'attach_pos', 'filelist_sorting', 'filelist_sorting_dir', 'filelist_num', 'decimal_size_format', 'search_result_tpl', 'disable_css'), __('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', 'folder_icon', 'small_icon_size', 'disable_footer_credits', 'footer_credits_style'), __('Download', WPFB) => array('hide_links', 'disable_permalinks', 'download_base', 'force_download', 'range_download', 'http_nocache', 'ignore_admin_dls', 'accept_empty_referers', 'allowed_referers', 'use_fpassthru'), __('Form Presets', WPFB) => array('default_author', 'default_roles', 'default_cat', 'default_direct_linking', 'languages', 'platforms', 'licenses', 'requirements', 'custom_fields'), __('Limits', WPFB) => $limits, __('Security', WPFB) => array('allow_srv_script_upload', 'fext_blacklist', 'frontend_upload', 'hide_inaccessible', 'inaccessible_msg', 'inaccessible_redirect', 'cat_inaccessible_msg', 'login_redirect_src', 'protect_upload_path', 'private_files'), __('Templates and Scripts', WPFB) => array('template_file', 'template_cat', 'dlclick_js'), __('Sync', WPFB) => array('cron_sync', 'base_auto_thumb', 'remove_missing_files', 'fake_md5'), __('Misc') => $misc_tags);
        ?>
	<div id="wpfb-tabs">
		<ul class="wpfb-tab-menu">
			<?php 
        foreach ($option_categories as $key => $val) {
            echo '<li><a href="#' . sanitize_title($key) . '">' . esc_html($key) . '</a></li>';
        }
        ?>
		</ul>
	<?php 
        $page_option_list = '';
        $n = 0;
        foreach ($option_categories as $opt_cat => $opt_cat_fields) {
            //echo "\n".'<h3>'.$opt_cat.'</h3>';
            echo "\n\n" . '<div id="' . sanitize_title($opt_cat) . '" class="wpfilebase-opttab"><h3>' . $opt_cat . '</h3><table class="form-table">';
            foreach ($opt_cat_fields as $opt_tag) {
                $field_data = $option_fields[$opt_tag];
                $opt_val = $options[$opt_tag];
                echo "\n" . '<tr valign="top">' . "\n" . '<th scope="row">' . $field_data['title'] . '</th>' . "\n" . '<td>';
                $style_class = '';
                if (!empty($field_data['class'])) {
                    $style_class .= ' class="' . $field_data['class'] . '"';
                }
                if (!empty($field_data['style'])) {
                    $style_class .= ' style="' . $field_data['style'] . '"';
                }
                switch ($field_data['type']) {
                    case 'text':
                    case 'number':
                    case 'checkbox':
                        echo '<input name="' . $opt_tag . '" type="' . $field_data['type'] . '" id="' . $opt_tag . '"';
                        echo !empty($field_data['class']) ? ' class="' . $field_data['class'] . '"' : '';
                        if ($field_data['type'] == 'checkbox') {
                            echo ' value="1" ';
                            checked('1', $opt_val);
                        } elseif ($field_data['type'] == 'number') {
                            echo ' value="' . intval($opt_val) . '" size="5" style="text-align: right"';
                        } else {
                            echo ' value="' . esc_attr($opt_val) . '"';
                            if (isset($field_data['size'])) {
                                echo ' size="' . (int) $field_data['size'] . '"';
                            }
                        }
                        echo $style_class . ' />';
                        break;
                    case 'textarea':
                        $code_edit = strpos($opt_tag, 'template_') !== false || isset($field_data['class']) && strpos($field_data['class'], 'code') !== false;
                        $nowrap = !empty($field_data['nowrap']);
                        echo '<textarea name="' . $opt_tag . '" id="' . $opt_tag . '"';
                        if ($nowrap || $code_edit) {
                            echo ' cols="100" wrap="off" style="width: 100%;' . ($code_edit ? 'font-size: 9px;' : '') . '"';
                        } else {
                            echo ' cols="50"';
                        }
                        echo ' rows="' . ($code_edit ? 20 : 5) . '"';
                        echo $style_class;
                        echo '>';
                        echo esc_html($opt_val);
                        echo '</textarea>';
                        break;
                    case 'select':
                        echo '<select name="' . $opt_tag . '" id="' . $opt_tag . '">';
                        foreach ($field_data['options'] as $opt_v => $opt_n) {
                            echo '<option value="' . esc_attr($opt_v) . '"' . ($opt_v == $opt_val ? ' selected="selected" ' : '') . $style_class . '>' . (!is_numeric($opt_v) && $opt_v !== $opt_n ? esc_html($opt_v) . ': ' : '') . esc_html($opt_n) . '</option>';
                        }
                        echo '</select>';
                        break;
                    case 'roles':
                        WPFB_Admin::RolesCheckList($opt_tag, $opt_val, empty($field_data['not_everyone']));
                        break;
                    case 'icon':
                        wp_print_scripts('jquery-imagepicker');
                        wp_print_styles('jquery-imagepicker');
                        echo '<select class="image-picker show-html" name="' . $opt_tag . '" id="' . $opt_tag . '">';
                        ?>
						<?php 
                        foreach ($field_data['icons'] as $icon) {
                            echo '<option data-img-src="' . $icon['url'] . '" value="' . $icon['path'] . '" ' . ($icon['path'] === $opt_val ? ' selected="selected" ' : '') . '>' . basename($icon['path']) . '</option>';
                        }
                        ?>
					</select>
					<script type="text/javascript">
					jQuery(document).ready( function() { jQuery("#<?php 
                        echo $opt_tag;
                        ?>
").imagepicker(); });
					</script>
					<?php 
                        break;
                    case 'cat':
                        echo "<select name='{$opt_tag}' id='{$opt_tag}'>";
                        echo WPFB_Output::CatSelTree(array('selected' => $opt_val));
                        echo "</select>";
                        break;
                }
                if (!empty($field_data['unit'])) {
                    echo ' ' . $field_data['unit'];
                }
                if (!empty($field_data['desc'])) {
                    echo "\n" . '<br />' . str_replace('%value%', is_array($opt_val) ? join(', ', $opt_val) : $opt_val, $field_data['desc']);
                }
                echo "\n</td>\n</tr>";
                $page_option_list .= $opt_tag . ',';
            }
            echo '</table></div>' . "\n";
        }
        ?>
</div> <!--wpfilebase-opttabs-->
	<input type="hidden" name="action" value="update" />
	<input type="hidden" name="page_options" value="<?php 
        echo $page_option_list;
        ?>
" />
	<p class="submit">
	<input type="submit" name="submit" value="<?php 
        _e('Save Changes');
        ?>
" class="button-primary" />
	<input type="submit" name="reset" value="<?php 
        _e('Restore Default Settings', WPFB);
        ?>
" onclick="return confirm('<?php 
        _e('All settings (except default file and category template) will be set to default values. Continue?', WPFB);
        ?>
')" class="button delete" style="float: right;" />
	</p>
</form>
</div>	<!-- wrap -->	
<?php 
    }
 private static function CheckChangedVer()
 {
     $ver = wpfb_call('Core', 'GetOpt', 'version');
     if ($ver != WPFB_VERSION) {
         wpfb_loadclass('Setup');
         WPFB_Setup::OnActivateOrVerChange($ver);
     }
 }
Beispiel #26
0
 static function PrintDebugTrace($tag = "")
 {
     if (!empty($_GET['debug'])) {
         wpfb_loadclass('Output');
         $ms = self::GetMemStats();
         echo "<!-- [{$tag}] (MEM: " . WPFB_Output::FormatFilesize($ms['used']) . " / {$ms['limit']}) BACKTRACE:\n";
         echo esc_html(print_r(wp_debug_backtrace_summary(), true));
         echo "\nEND -->";
         self::UpdateMemBar();
     }
 }
Beispiel #27
0
 static function AdminDashboardSetup()
 {
     wpfb_loadclass('AdminDashboard');
     WPFB_AdminDashboard::Setup(false);
 }
Beispiel #28
0
<?php

// dont allow direct access and access from outside wp-admin context
if (!defined('ABSPATH') || !is_admin()) {
    exit;
}
if (empty($_REQUEST['type']) || empty($_REQUEST['tag'])) {
    exit;
}
$type = $_REQUEST['type'];
$tag = $_REQUEST['tag'];
$list = $type == 'list';
wpfb_loadclass('Output', 'TplLib', 'ListTpl', 'AdminGuiTpls');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php 
do_action('admin_xml_ns');
?>
 <?php 
language_attributes();
?>
>
<head>
<title><?php 
_e('Posts');
?>
</title>
<meta http-equiv="Content-Type" content="<?php 
bloginfo('html_type');
?>
; charset=<?php 
Beispiel #29
0
    static function Display()
    {
        global $wpdb, $user_ID;
        wpfb_loadclass('File', 'Category', 'Admin', 'Output');
        $_POST = stripslashes_deep($_POST);
        $_GET = stripslashes_deep($_GET);
        $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
        $clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync'));
        // keep search keyword
        // nonce/referer check (security)
        if ($action == 'updatefile' || $action == 'addfile') {
            $nonce_action = WPFB . "-" . $action;
            if ($action == 'updatefile') {
                $nonce_action .= $_POST['file_id'];
            }
            if (!check_admin_referer($nonce_action, 'wpfb-file-nonce')) {
                wp_die(__('Cheatin&#8217; uh?'));
            }
        }
        // switch simple/extended form
        if (isset($_GET['exform'])) {
            $exform = !empty($_GET['exform']) && $_GET['exform'] == 1;
            update_user_option($user_ID, WPFB_OPT_NAME . '_exform', $exform, true);
        } else {
            $exform = (bool) get_user_option(WPFB_OPT_NAME . '_exform');
        }
        ?>
	<div class="wrap">
	<?php 
        switch ($action) {
            case 'editfile':
                if (!current_user_can('upload_files')) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
                if (!empty($_POST['files'])) {
                    if (!is_array($_POST['files'])) {
                        $_POST['files'] = explode(',', $_POST['files']);
                    }
                    $files = array();
                    foreach ($_POST['files'] as $file_id) {
                        $file = WPFB_File::GetFile($file_id);
                        if (!is_null($file) && $file->CurUserCanEdit()) {
                            $files[] = $file;
                        }
                    }
                    if (count($files) > 0) {
                        WPFB_Admin::PrintForm('file', $files, array('multi_edit' => true));
                    } else {
                        wp_die('No files to edit.');
                    }
                } else {
                    $file = WPFB_File::GetFile($_GET['file_id']);
                    if (is_null($file) || !$file->CurUserCanEdit()) {
                        wp_die(__('You do not have the permission to edit this file!', 'wp-filebase'));
                    }
                    WPFB_Admin::PrintForm('file', $file);
                }
                break;
            case 'updatefile':
                $file_id = (int) $_POST['file_id'];
                $update = true;
                $file = WPFB_File::GetFile($file_id);
                if (is_null($file) || !$file->CurUserCanEdit()) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
            case 'addfile':
                $update = !empty($update);
                if (!WPFB_Core::CurUserCanUpload()) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
                extract($_POST);
                if (isset($jj) && isset($ss)) {
                    $jj = $jj > 31 ? 31 : $jj;
                    $hh = $hh > 23 ? $hh - 24 : $hh;
                    $mn = $mn > 59 ? $mn - 60 : $mn;
                    $ss = $ss > 59 ? $ss - 60 : $ss;
                    $_POST['file_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
                }
                $result = WPFB_Admin::InsertFile(stripslashes_deep(array_merge($_POST, $_FILES)), true);
                if (isset($result['error']) && $result['error']) {
                    $message = $result['error'] . '<br /><a href="javascript:history.back()">' . __("Go back") . '</a>';
                } else {
                    $message = $update ? __('File updated.', 'wp-filebase') : __('File added.', 'wp-filebase');
                }
            default:
                if (!current_user_can('upload_files')) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
                if (!empty($_REQUEST['redirect']) && !empty($_REQUEST['redirect_to'])) {
                    WPFB_AdminLite::JsRedirect($_REQUEST['redirect_to']);
                    exit;
                }
                if (!empty($_POST['deleteit'])) {
                    foreach ((array) $_POST['delete'] as $file_id) {
                        if (is_object($file = WPFB_File::GetFile($file_id)) && $file->CurUserCanDelete()) {
                            $file->Remove(true);
                        }
                    }
                    WPFB_File::UpdateTags();
                }
                ?>
	<h2><?php 
                echo str_replace(array('(<', '>)'), array('<', '>'), sprintf(__('Manage Files (<a href="%s">add new</a>)', 'wp-filebase'), '#addfile" class="add-new-h2'));
                echo '<a href="' . admin_url('admin.php?page=wpfilebase_manage&amp;action=batch-upload') . '" class="add-new-h2">' . __('Batch Upload', 'wp-filebase') . '</a>';
                if (isset($_GET['s']) && $_GET['s']) {
                    printf('<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html(stripslashes($_GET['s'])));
                }
                ?>
</h2>
	<?php 
                if (!empty($message)) {
                    ?>
<div id="message" class="updated fade"><p><?php 
                    echo $message;
                    ?>
</p></div><?php 
                }
                if (WPFB_Core::CurUserCanUpload() && ($action == 'addfile' || $action == 'updatefile')) {
                    unset($file);
                    WPFB_Admin::PrintForm('file', null, array('exform' => $exform, 'item' => new WPFB_File(isset($result['error']) && $result['error'] ? $_POST : null)));
                }
                wpfb_loadclass('FileListTable');
                $file_table = new WPFB_FileListTable();
                $file_table->prepare_items();
                ?>
	
<form class="search-form topmargin" action="" method="get">
	<input type="hidden" value="<?php 
                echo esc_attr($_GET['page']);
                ?>
" name="page" />
	<input type="hidden" value="<?php 
                echo empty($_GET['view']) ? '' : esc_attr(@$_GET['view']);
                ?>
" name="view" />
<?php 
                $file_table->search_box(__('Search Files', 'wp-filebase'), 's');
                ?>
</form>	
 
<?php 
                $file_table->views();
                ?>
 <form id="posts-filter" action="" method="post">
 <input type="hidden" name="page" value="<?php 
                echo $_REQUEST['page'];
                ?>
" />
 <?php 
                $file_table->display();
                ?>
 </form>
 <br class="clear" />

<?php 
                if ($action != 'addfile' && $action != 'updatefile' && WPFB_Core::CurUserCanUpload()) {
                    unset($file);
                    WPFB_Admin::PrintForm('file', null, array('exform' => $exform));
                }
                break;
                // default
        }
        /*
        $file_list_table = new WPFB_File_List_Table();
        	$pagenum = $file_list_table->get_pagenum();
        	$doaction = $file_list_table->current_action();
        $file_list_table->prepare_items();
        $file_list_table->views();
        	$file_list_table->search_box( "asdf", 'post' );
        $file_list_table->display();
        */
        ?>
	
	
	
	
</div> <!-- wrap -->
<?php 
    }
Beispiel #30
0
            }
        }
        wpfb_print_json($props);
        exit;
    case 'new-cat':
        if (!WPFB_Core::CurUserCanCreateCat()) {
            die('-1');
        }
        wpfb_loadclass('Admin');
        $result = WPFB_Admin::InsertCategory($_POST);
        if (isset($result['error']) && $result['error']) {
            wpfb_print_json(array('error' => $result['error']));
            exit;
        }
        $cat = $result['cat'];
        $args = WPFB_Output::fileBrowserArgs($_POST['args']);
        $filesel = $args['type'] === 'fileselect';
        $catsel = $args['type'] === 'catselect';
        wpfb_print_json(array('error' => 0, 'id' => $cat->GetId(), 'name' => $cat->GetTitle(), 'id_str' => $args['idp'] . 'cat-' . $cat->cat_id, 'url' => $cat->GetUrl(), 'text' => WPFB_Output::fileBrowserCatItemText($catsel, $filesel, $cat, $args['onselect'], empty($_REQUEST['is_admin']) ? 'filebrowser' : 'filebrowser_admin'), 'classes' => $filesel || $catsel ? 'folder' : null));
        exit;
    case 'change-category':
        wpfb_loadclass('File', 'Admin');
        $item = WPFB_Item::GetById($_POST['id'], $_POST['type']);
        if ($item && $item->CurUserCanEdit()) {
            $res = $item->ChangeCategoryOrName($_POST['new_cat_id']);
            wpfb_print_json($res);
        } else {
            die('-1');
        }
        exit;
}