コード例 #1
0
ファイル: wpfb-ajax.php プロジェクト: parsonsc/dofe
     if (($n = count($tags)) > 0) {
         $ks = array_keys($tags);
         for ($i = 0; $i < $n; $i++) {
             if (stripos($ks[$i], $tag) === 0) {
                 while ($i < $n && stripos($ks[$i], $tag) === 0) {
                     $props[] = array('t' => $ks[$i], 'n' => $tags[$ks[$i]]);
                     $i++;
                 }
                 //break;
             }
         }
     }
     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':
コード例 #2
0
ファイル: Output.php プロジェクト: parsonsc/dofe
 static function GetTreeItems($parent_id, $args = array())
 {
     /* $args = array(
      * sort_cats
      * sort_files
      * cats_only
      * exclude_attached
      * priv
      * idp => 
      * onselect
      * );
      */
     $parent_id = is_object($parent_id) ? $parent_id->cat_id : intval($parent_id);
     $args = self::fileBrowserArgs($args);
     $type = $args['type'];
     $browser = $type === 'browser';
     $filesel = $type === 'fileselect';
     $catsel = $type === 'catselect';
     $args['idp'] = wp_strip_all_tags($args['idp']);
     $idp_cat = $args['idp'] . 'cat-';
     $idp_file = $args['idp'] . 'file-';
     $file_tpl = $cat_tpl = !empty($args['tpl']) ? $args['tpl'] : (($is_admin = !empty($args['is_admin'])) ? 'filebrowser_admin' : 'filebrowser');
     if ($parent_id > 0 && (is_null($cat = WPFB_Category::GetCat($parent_id)) || !$cat->CurUserCanAccess())) {
         return array((object) array('id' => 0, 'text' => WPFB_Core::$settings->cat_inaccessible_msg));
     }
     $sql_sort_files = $browser ? WPFB_Core::GetSortSql((WPFB_Core::$settings->file_browser_file_sort_dir ? '>' : '<') . WPFB_Core::$settings->file_browser_file_sort_by) : 'file_display_name';
     $sql_sort_cats = $browser ? WPFB_Core::GetSortSql((WPFB_Core::$settings->file_browser_cat_sort_dir ? '>' : '<') . WPFB_Core::$settings->file_browser_cat_sort_by, false, true) : 'cat_name';
     $files_before_cats = $browser && WPFB_Core::$settings->file_browser_fbc;
     $inline_add_cat = WPFB_Core::CurUserCanCreateCat();
     $where = " cat_parent = {$parent_id} ";
     if ($browser) {
         $where .= " AND cat_exclude_browser <> '1' ";
     }
     $cats = WPFB_Category::GetCats("WHERE {$where} ORDER BY {$sql_sort_cats}");
     $cat_items = array();
     $i = 0;
     $folder_class = $filesel || $catsel ? 'folder' : '';
     foreach ($cats as $c) {
         if ($c->CurUserCanAccess(true)) {
             $cat_items[$i++] = (object) array('id' => $idp_cat . $c->cat_id, 'cat_id' => $c->cat_id, 'text' => self::fileBrowserCatItemText($catsel, $filesel, $c, $args['onselect'], $cat_tpl), 'hasChildren' => $inline_add_cat || $c->HasChildren($catsel), 'classes' => $folder_class);
         }
     }
     if ($inline_add_cat) {
         $is = WPFB_Core::$settings->small_icon_size > 0 ? WPFB_Core::$settings->small_icon_size : 32;
         $cat_items[$i++] = (object) array('id' => $idp_cat . '0', 'cat_id' => 0, 'text' => '<form action="" style="display:none;"><input type="text" placeholder="' . __('Category Name', WPFB) . '" name="cat_name" /></form> ' . '<a href="#" style="text-decoration:none;" onclick=\'return wpfb_newCatInput(this,' . $parent_id . ');\'><span style="' . ($browser ? 'font-size:' . $is . 'px;width:' . $is . 'px' : 'font-size:200%') . ';line-height:0;vertical-align:sub;display:inline-block;text-align:center;">+</span>' . __('Add Category', WPFB) . '</a>' . '<span style="font-size: 200%;vertical-align: sub;line-height: 0;font-weight: lighter;"> / </span>' . '<a href="#" style="text-decoration:none;" class="add-file"><span style="' . ($browser ? 'font-size:' . $is . 'px;width:' . $is . 'px' : 'font-size:200%') . ';line-height:0;vertical-align:sub;display:inline-block;text-align:center;">+</span>' . __('Add File', WPFB) . '</a>', 'hasChildren' => false, 'classes' => 'add-item');
     } elseif ($parent_id == 0 && $catsel && $i == 0) {
         return array((object) array('id' => $idp_cat . '0', 'text' => sprintf(__('You did not create a category. <a href="%s" target="_parent">Click here to create one.</a>', WPFB), admin_url('admin.php?page=wpfilebase_cats#addcat')), 'hasChildren' => false));
     }
     $file_items = array();
     $i = 0;
     if (empty($args['cats_only']) && !$catsel) {
         $where = WPFB_File::GetSqlCatWhereStr($parent_id);
         if (!empty($args['exclude_attached'])) {
             $where .= " AND `file_post_id` = 0";
         }
         //	$files =  WPFB_File::GetFiles2(WPFB_File::GetSqlCatWhereStr($root_id),  WPFB_Core::$settings->hide_inaccessible, $sql_file_order);
         //$files =  WPFB_File::GetFiles2(WPFB_File::GetSqlCatWhereStr($root_id),  WPFB_Core::$settings->hide_inaccessible, $sql_file_order);
         $files = WPFB_File::GetFiles2($where, WPFB_Core::$settings->hide_inaccessible && !($filesel && wpfb_call('Core', 'CurUserCanUpload')), $sql_sort_files);
         foreach ($files as $f) {
             $file_items[$i++] = (object) array('id' => $idp_file . $f->file_id, 'text' => $filesel ? '<a href="javascript:;" onclick="' . sprintf($args['onselect'], $f->file_id) . '">' . esc_html($f->GetTitle(24)) . '</a> <span style="font-size:75%;vertical-align:top;">' . esc_html($f->file_name) . '</span>' : $f->GenTpl2($file_tpl, false), 'classes' => $filesel ? 'file' : null, 'hasChildren' => false);
         }
     }
     return $files_before_cats ? array_merge($file_items, $cat_items) : array_merge($cat_items, $file_items);
 }
コード例 #3
0
 static function InitClass()
 {
     self::$ajax_url = WPFB_Core::PluginUrl('wpfb-ajax.php');
     if (defined('WPFB_NO_CORE_INIT')) {
         return;
     }
     // used with CSS proxy
     //Load settings
     self::$settings = (object) get_option(WPFB_OPT_NAME);
     // load lang
     $lang_dir = defined('WPFB_LANG_DIR') ? '../../' . WPFB_LANG_DIR : basename(WPFB_PLUGIN_ROOT) . '/languages';
     load_plugin_textdomain(WPFB, 'wp-content/plugins/' . $lang_dir, $lang_dir);
     add_action('parse_query', array(__CLASS__, 'ParseQuery'));
     // search
     add_action('wp_enqueue_scripts', array(__CLASS__, 'EnqueueScripts'));
     add_action('wp_footer', array(__CLASS__, 'Footer'));
     add_action('generate_rewrite_rules', array(__CLASS__, 'GenRewriteRules'));
     add_action(WPFB . '_cron', array(__CLASS__, 'Cron'));
     add_action('wpfilebase_sync', array(__CLASS__, 'Sync'));
     // for Developers: New wp-filebase actions
     add_shortcode('wpfilebase', array(__CLASS__, 'ShortCode'));
     // for attachments and file browser
     add_filter('the_content', array(__CLASS__, 'ContentFilter'), 10);
     // must be lower than 11 (before do_shortcode) and after wpautop (>9)
     add_filter('ext2type', array(__CLASS__, 'Ext2TypeFilter'));
     add_filter('pre_set_site_transient_update_plugins', array(__CLASS__, 'PreSetPluginsTransientFilter'));
     add_filter('plugins_api', array(__CLASS__, 'PluginsApiFilter'), 10, 3);
     // register treeview stuff
     //wp_register_script('jquery-cookie', WPFB_PLUGIN_URI.'extras/jquery/jquery.cookie.js', array('jquery'));
     wp_register_script('jquery-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.js', array('jquery'), WPFB_VERSION);
     wp_register_script('jquery-treeview-edit', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.edit.js', array('jquery-treeview'), WPFB_VERSION);
     wp_register_script('jquery-treeview-async', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.async.js', array('jquery-treeview-edit'), WPFB_VERSION);
     wp_register_style('jquery-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.css', array(), WPFB_VERSION);
     // DataTables
     wp_register_script('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/js/jquery.dataTables.min.js', array('jquery'), WPFB_VERSION);
     wp_register_style('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/css/jquery.dataTables.css', array(), WPFB_VERSION);
     wp_register_script('jquery-dataTables-columnFilter', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/js/jquery.dataTables.columnFilter.js', array('jquery-dataTables'), WPFB_VERSION);
     wp_register_script(WPFB, WPFB_PLUGIN_URI . 'js/common.js', array('jquery'), WPFB_VERSION);
     // cond loading (see Footer)
     if (empty(WPFB_Core::$settings->disable_css)) {
         $wpfb_css = get_option('wpfb_css');
         if ($wpfb_css) {
             // static file?
             wp_enqueue_style(WPFB, strstr($wpfb_css, '//'), array(), WPFB_VERSION, 'all');
         } else {
             $upload_path = path_is_absolute(WPFB_Core::$settings->upload_path) ? '' : WPFB_Core::$settings->upload_path;
             wp_enqueue_style(WPFB, WPFB_Core::PluginUrl("wp-filebase_css.php?rp={$upload_path}"), array(), WPFB_VERSION, 'all');
         }
     }
     $wpfb_admin_page = is_admin() && !empty($_GET['page']) && strpos($_GET['page'], 'wpfilebase_') !== false || defined('WPFB_EDITOR_PLUGIN');
     if ($wpfb_admin_page) {
         wpfb_loadclass('Admin');
     }
     // live admin
     if ($wpfb_admin_page && @$_GET['page'] == 'wpfilebase_filebrowser' || (WPFB_Core::CurUserCanCreateCat() || WPFB_Core::CurUserCanUpload()) && !is_admin()) {
         wp_enqueue_script(WPFB . '-live-admin', WPFB_PLUGIN_URI . 'js/live-admin.js', array('jquery'), WPFB_VERSION);
         if (self::GetOpt('admin_bar')) {
             add_action('admin_bar_menu', array(__CLASS__, 'AdminBar'), 80);
         }
         if (self::GetOpt('file_context_menu')) {
             wp_enqueue_script('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.js', array('jquery'));
             wp_enqueue_style('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.css', array(), WPFB_VERSION);
         }
         wp_enqueue_style('wpfb-live-admin', WPFB_PLUGIN_URI . 'css/live-admin.css', array(), WPFB_VERSION);
     }
     // for admin
     if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
         self::MceAddBtns();
     }
     self::DownloadRedirect();
     if ((WPFB_Core::$settings->frontend_upload || current_user_can('upload_files')) && (!empty($_GET['wpfb_upload_file']) || !empty($_GET['wpfb_add_cat']))) {
         wpfb_call('Admin', empty($_GET['wpfb_upload_file']) ? 'ProcessWidgetAddCat' : 'ProcessWidgetUpload');
     }
 }
コード例 #4
0
    static function Display()
    {
        global $wpdb, $user_ID;
        //register_shutdown_function( create_function('','$error = error_get_last(); if( $error && $error[\'type\'] != E_STRICT ){print_r( $error );}else{return true;}') );
        wpfb_loadclass('File', 'Category', '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', 'doit', 'ids', 'files', 'cats', 'batch_sync'));
        // keep search keyword
        // 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');
        }
        if (!empty($_GET['wpfb-hide-how-start'])) {
            update_user_option($user_ID, WPFB_OPT_NAME . '_hide_how_start', 1);
        }
        $show_how_start = !(bool) get_user_option(WPFB_OPT_NAME . '_hide_how_start');
        WPFB_Admin::PrintFlattrHead();
        ?>
	<script type="text/javascript">	
	/* Liking/Donate Bar */
	if(typeof(jQuery) != 'undefined') {
		jQuery(document).ready(function(){
			if(getUserSetting("wpfilebase_hidesuprow",false) == 1) {
				jQuery('#wpfb-liking').hide();
				jQuery('#wpfb-liking-toggle').addClass('closed');	
			}	
			jQuery('#wpfb-liking-toggle').click(function(){
				jQuery('#wpfb-liking').slideToggle();
				jQuery(this).toggleClass('closed');
				setUserSetting("wpfilebase_hidesuprow", 1-getUserSetting("wpfilebase_hidesuprow",false), 0);
			});	
		});
	}
	</script>
	

	<div class="wrap">
	<div id="icon-wpfilebase" class="icon32"><br /></div>
	<h2><?php 
        echo WPFB_PLUGIN_NAME;
        ?>
</h2>
	
	<?php 
        if ($show_how_start) {
            wpfb_call('AdminHowToStart', 'Display');
        }
        if (!empty($_GET['action'])) {
            echo '<p><a href="' . $clean_uri . '" class="button">' . __('Go back') . '</a></p>';
        }
        switch ($action) {
            default:
                $clean_uri = remove_query_arg('pagenum', $clean_uri);
                $upload_dir = WPFB_Core::UploadDir();
                $upload_dir_rel = str_replace(ABSPATH, '', $upload_dir);
                $chmod_cmd = "CHMOD " . WPFB_PERM_DIR . " " . $upload_dir_rel;
                if (!is_dir($upload_dir)) {
                    $result = WPFB_Admin::Mkdir($upload_dir);
                    if ($result['error']) {
                        $error_msg = sprintf(__('The upload directory <code>%s</code> does not exists. It could not be created automatically because the directory <code>%s</code> is not writable. Please create <code>%s</code> and make it writable for the webserver by executing the following FTP command: <code>%s</code>', WPFB), $upload_dir_rel, str_replace(ABSPATH, '', $result['parent']), $upload_dir_rel, $chmod_cmd);
                    } else {
                        wpfb_call('Setup', 'ProtectUploadPath');
                    }
                } elseif (!is_writable($upload_dir)) {
                    $error_msg = sprintf(__('The upload directory <code>%s</code> is not writable. Please make it writable for PHP by executing the follwing FTP command: <code>%s</code>', WPFB), $upload_dir_rel, $chmod_cmd);
                }
                if (!empty($error_msg)) {
                    echo '<div class="error default-password-nag"><p>' . $error_msg . '</p></div>';
                }
                if (!empty(WPFB_Core::$settings->tag_conv_req)) {
                    echo '<div class="updated"><p><a href="' . add_query_arg('action', 'convert-tags') . '">';
                    _e('WP-Filebase content tags must be converted', WPFB);
                    echo '</a></p></div><div style="clear:both;"></div>';
                }
                if (!get_post(WPFB_Core::$settings->file_browser_post_id)) {
                    echo '<div class="updated"><p>';
                    printf(__('File Browser post or page not set! Some features like search will not work. <a href="%s">Click here to set the File Browser Post ID.</a>', WPFB), esc_attr(admin_url('admin.php?page=wpfilebase_sets#' . sanitize_title(__('File Browser', WPFB)))));
                    echo '</p></div><div style="clear:both;"></div>';
                }
                /*
                wpfb_loadclass('Config');
                if(!WPFB_Config::IsWritable()) {
                	echo '<div class="updated"><p>';
                	printf(__('The config file %s is not writable or could not be created. Please create the file and make it writable for the webserver.',WPFB), WPFB_Config::$file);
                	echo '</p></div><div style="clear:both;"></div>';
                }
                */
                ?>
	<?php 
                if (self::PluginHasBeenUsedAWhile(true)) {
                    self::ProUpgradeNag();
                }
                if (self::PluginHasBeenUsedAWhile()) {
                    ?>
	
<div id="wpfb-support-col">
<div id="wpfb-liking-toggle"></div>
<h3><?php 
                    _e('Like WP-Filebase?', WPFB);
                    ?>
</h3>
<div id="wpfb-liking">
	<!-- <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> -->
	
	<div style="text-align: center;" ><a href="https://twitter.com/wpfilebase" class="twitter-follow-button" data-show-count="false">Follow @wpfilebase</a>
			<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="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
	
	<p>Please <a href="http://wordpress.org/support/view/plugin-reviews/wp-filebase">give it a good rating</a>.</p>
	<p>For Cloud support and lots of other advanced features consider an</p>
	<p style="text-align: center;"><a href="https://wpfilebase.com/?ref=dblike" class="button-primary">Upgrade to Pro</a></p>
	<p style="text-align:right;float:right;font-style:italic;">Thanks, Fabian</p> 
	<!-- <div style="text-align: center;">
	<?php 
                    //WPFB_Admin::PrintPayPalButton()
                    ?>
	<?php 
                    //WPFB_Admin::PrintFlattrButton()
                    ?>
	</div> -->
</div>
</div>
<?php 
                }
                ?>

<div id="wpfb-stats-wrap" style="float:right; border-left: 1px solid #eee; margin-left: 5px;">
<div id="col-container">
	<div id="col-right">
		<div class="col-wrap">
			<h3><?php 
                _e('Traffic', WPFB);
                ?>
</h3>
			<table class="wpfb-stats-table">
			<?php 
                $traffic_stats = wpfb_call('Misc', 'GetTraffic');
                $limit_day = WPFB_Core::$settings->traffic_day * 1048576;
                $limit_month = WPFB_Core::$settings->traffic_month * 1073741824;
                ?>
			<tr>
				<td><?php 
                if ($limit_day > 0) {
                    self::ProgressBar($traffic_stats['today'] / $limit_day, WPFB_Output::FormatFilesize($traffic_stats['today']) . '/' . WPFB_Output::FormatFilesize($limit_day));
                } else {
                    echo WPFB_Output::FormatFilesize($traffic_stats['today']);
                }
                ?>
</td>
				<th scope="row"><?php 
                _e('Today', WPFB);
                ?>
</th>
			</tr>
			<tr>
				<td><?php 
                if ($limit_month > 0) {
                    self::ProgressBar($traffic_stats['month'] / $limit_month, WPFB_Output::FormatFilesize($traffic_stats['month']) . '/' . WPFB_Output::FormatFilesize($limit_month));
                } else {
                    echo WPFB_Output::FormatFilesize($traffic_stats['month']);
                }
                ?>
</td>
				<th scope="row"><?php 
                _e('This Month', WPFB);
                ?>
</th>
			</tr>
			<tr>
				<td><?php 
                echo WPFB_Output::FormatFilesize($wpdb->get_var("SELECT SUM(file_size) FROM {$wpdb->wpfilebase_files}"));
                ?>
</td>
				<th scope="row"><?php 
                _e('Total File Size', WPFB);
                ?>
</th>
			</tr>	
			</table>
</div>
</div><!-- /col-right -->
			
<div id="col-left">
<div class="col-wrap">

			<h3><?php 
                _e('Statistics', WPFB);
                ?>
</h3>
			<table class="wpfb-stats-table">
			<tr>
				<td><?php 
                echo WPFB_File::GetNumFiles();
                ?>
</td>
				<th scope="row"><?php 
                _e('Files', WPFB);
                ?>
</th>				
			</tr>
			<tr>
				<td><?php 
                echo WPFB_Category::GetNumCats();
                ?>
</td>
				<th scope="row"><?php 
                _e('Categories', WPFB);
                ?>
</th>
			</tr>
			<tr>
				<td><?php 
                echo "" . (int) $wpdb->get_var("SELECT SUM(file_hits) FROM {$wpdb->wpfilebase_files}");
                ?>
</td>
				<th scope="row"><?php 
                _e('Downloads', WPFB);
                ?>
</th>
			</tr>
			</table>
</div>
</div><!-- /col-left -->

</div><!-- /col-container -->
</div>


<div>
<!-- <h2><?php 
                _e('Tools');
                ?>
</h2> -->
<?php 
                $cron_sync_desc = '';
                if (WPFB_Core::$settings->cron_sync) {
                    $cron_sync_desc .= __('Automatic sync is enabled. Cronjob scheduled hourly.');
                    $last_sync_time = intval(get_option(WPFB_OPT_NAME . '_cron_sync_time'));
                    $cron_sync_desc .= $last_sync_time > 0 ? " (" . sprintf(__('Last cron sync on %1$s at %2$s.', WPFB), date_i18n(get_option('date_format'), $last_sync_time), date_i18n(get_option('time_format'), $last_sync_time)) . ")" : '';
                } else {
                    $cron_sync_desc .= __('Cron sync is disabled.', WPFB);
                }
                $tools = array(array('url' => add_query_arg(array('action' => 'sync')), 'icon' => 'activity', 'label' => __('Sync Filebase', WPFB), 'desc' => __('Synchronises the database with the file system. Use this to add FTP-uploaded files.', WPFB) . '<br />' . $cron_sync_desc));
                if (current_user_can('install_plugins')) {
                    // is admin?
                    $new_tag = self::NewExtensionsAvailable() ? '<span class="wp-ui-notification new-exts">new</span>' : '';
                    $tools[] = array('url' => add_query_arg(array('action' => 'install-extensions')), 'icon' => 'plug', 'label' => __('Extensions', WPFB) . $new_tag, 'desc' => __('Install Extensions to extend functionality of WP-Filebase', WPFB));
                }
                ?>
<div id="wpfb-tools">
	<h2><?php 
                _e('Tools');
                ?>
</h2>
<ul>
<?php 
                foreach ($tools as $id => $tool) {
                    ?>
	<li id="wpfb-tool-<?php 
                    echo $id;
                    ?>
"><a href="<?php 
                    echo $tool['url'];
                    ?>
" <?php 
                    if (!empty($tool['confirm'])) {
                        ?>
 onclick="return confirm('<?php 
                        echo $tool['confirm'];
                        ?>
')" <?php 
                    }
                    ?>
 class="button"><span style="background-image:url(<?php 
                    echo esc_attr(WPFB_PLUGIN_URI);
                    ?>
images/<?php 
                    echo $tool['icon'];
                    ?>
.png)"></span><?php 
                    echo $tool['label'];
                    ?>
</a></li>
<?php 
                }
                ?>
</ul>
<?php 
                foreach ($tools as $id => $tool) {
                    ?>
	
<div id="wpfb-tool-desc-<?php 
                    echo $id;
                    ?>
" class="tool-desc">
	<?php 
                    echo $tool['desc'];
                    ?>
</div>
<?php 
                }
                ?>
<script>
if(!jQuery(document.body).hasClass('mobile')) {
	jQuery('#wpfb-tools li').mouseenter(function(e) {
		jQuery('#wpfb-tools .tool-desc').hide();
		jQuery('#wpfb-tool-desc-'+this.id.substr(10)).show();
	});
}
</script>
		
<?php 
                if (!empty(WPFB_Core::$settings->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 
                }
                ?>
<!--  <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>
-->
</div>
	
	<div style="clear: both;"></div>

<?php 
                if (WPFB_Core::CurUserCanUpload()) {
                    WPFB_Admin::PrintForm('file', null, array('exform' => $exform));
                }
                ?>
			
		<?php 
                if (!$show_how_start) {
                    // display how start here if its hidden
                    wpfb_call('AdminHowToStart', 'Display');
                }
                ?>
			
			<h2><?php 
                _e('About');
                ?>
</h2>
			<p>
			<?php 
                echo WPFB_PLUGIN_NAME . ' ' . WPFB_VERSION;
                ?>
 by Fabian Schlieper <a href="http://fabi.me/">
			<?php 
                if (strpos($_SERVER['SERVER_PROTOCOL'], 'HTTPS') === false) {
                    ?>
<img src="http://fabi.me/misc/wpfb_icon.gif?lang=<?php 
                    if (defined('WPLANG')) {
                        echo WPLANG;
                    }
                    ?>
" alt="" /><?php 
                }
                ?>
 fabi.me</a><br/>
			Includes the great file analyzer <a href="http://www.getid3.org/">getID3()</a> by James Heinrich.<br />
			Tools Icons by <a href="http://www.icondeposit.com/">Matt Gentile</a>.
			</p>
			<?php 
                if (current_user_can('edit_files')) {
                    ?>
			<p><a href="<?php 
                    echo admin_url('plugins.php?wpfb-uninstall=1');
                    ?>
" class="button"><?php 
                    _e('Completely Uninstall WP-Filebase');
                    ?>
</a></p>
				<?php 
                }
                break;
            case 'convert-tags':
                ?>
<h2><?php 
                _e('Tag Conversion');
                ?>
</h2><?php 
                if (empty($_REQUEST['doit'])) {
                    echo '<div class="updated"><p>';
                    _e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
                    echo '</p></div>';
                    echo '<p><a href="' . add_query_arg('doit', 1) . '" class="button">' . __('Continue') . '</a></p>';
                    break;
                }
                $result = wpfb_call('Setup', 'ConvertOldTags');
                ?>
		<p><?php 
                printf(__('%d Tags in %d Posts has been converted.'), $result['n_tags'], count($result['tags']));
                ?>
</p>
		<ul>
		<?php 
                if (!empty($result['tags'])) {
                    foreach ($result['tags'] as $post_title => $tags) {
                        echo "<li><strong>" . esc_html($post_title) . "</strong><ul>";
                        foreach ($tags as $old => $new) {
                            echo "<li>{$old} =&gt; {$new}</li>";
                        }
                        echo "</ul></li>";
                    }
                }
                ?>
		</ul>
		<?php 
                if (!empty($result['errors'])) {
                    ?>
	
		<h2><?php 
                    _e('Errors');
                    ?>
</h2>
		<ul><?php 
                    foreach ($result['errors'] as $post_title => $err) {
                        echo "<li><strong>" . esc_html($post_title) . ": </strong> " . esc_html($err) . "<ul>";
                    }
                    ?>
</ul>		
		<?php 
                }
                $opts = WPFB_Core::GetOpt();
                unset($opts['tag_conv_req']);
                update_option(WPFB_OPT_NAME, $opts);
                WPFB_Core::$settings = (object) $opts;
                break;
                // convert-tags
            // convert-tags
            case 'del':
                if (!empty($_REQUEST['files']) && WPFB_Core::CurUserCanUpload()) {
                    $ids = explode(',', $_REQUEST['files']);
                    $nd = 0;
                    foreach ($ids as $id) {
                        $id = intval($id);
                        if (($file = WPFB_File::GetFile($id)) != null && $file->CurUserCanEdit()) {
                            $file->Remove(true);
                            $nd++;
                        }
                    }
                    WPFB_File::UpdateTags();
                    echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Files removed'), $nd) . '</p></div>';
                }
                if (!empty($_REQUEST['cats']) && WPFB_Core::CurUserCanCreateCat()) {
                    $ids = explode(',', $_REQUEST['cats']);
                    $nd = 0;
                    foreach ($ids as $id) {
                        $id = intval($id);
                        if (($cat = WPFB_Category::GetCat($id)) != null) {
                            $cat->Delete();
                            $nd++;
                        }
                    }
                    echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Categories removed'), $nd) . '</p></div>';
                }
            case 'sync':
                echo '<h2>' . __('Synchronisation') . '</h2>';
                wpfb_loadclass('Sync');
                $result = WPFB_Sync::Sync(!empty($_GET['hash_sync']), true);
                if (!is_null($result)) {
                    WPFB_Sync::PrintResult($result);
                }
                if (empty($_GET['hash_sync'])) {
                    echo '<p><a href="' . add_query_arg('hash_sync', 1) . '" class="button">' . __('Complete file sync', WPFB) . '</a> ' . __('Checks files for changes, so more reliable but might take much longer. Do this if you uploaded/changed files with FTP.', WPFB) . '</p>';
                }
                break;
                // sync
            // sync
            case 'batch-upload':
                wpfb_loadclass('BatchUploader');
                $batch_uploader = new WPFB_BatchUploader();
                $batch_uploader->Display();
                break;
            case 'reset-hits':
                global $wpdb;
                $n = 0;
                if (current_user_can('manage_options')) {
                    $n = $wpdb->query("UPDATE `{$wpdb->wpfilebase_files}` SET file_hits = 0 WHERE 1=1");
                }
                echo "<p>";
                printf(__('Done. %d Files affected.'), $n);
                echo "</p>";
                break;
            case 'install-extensions':
                wpfb_call('AdmInstallExt', 'Display');
                break;
        }
        // switch
        ?>
</div> <!-- wrap -->
<?php 
    }
コード例 #5
0
ファイル: AdminGuiCats.php プロジェクト: TishoTM/WP-Filebase
    static function Display()
    {
        global $wpdb, $user_ID;
        if (!WPFB_Core::CurUserCanCreateCat()) {
            wp_die(__('Cheatin&#8217; uh?'));
        }
        wpfb_loadclass('Category', 'File', '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
        // 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 'editcat':
                $cat_id = (int) $_GET['cat_id'];
                $file_category = WPFB_Category::GetCat($cat_id);
                if (is_null($file_category) || !$file_category->CurUserCanEdit()) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
                WPFB_Admin::PrintForm('cat', $file_category);
                break;
            case 'updatecat':
                $cat_id = (int) $_POST['cat_id'];
                $update = true;
                $file_category = WPFB_Category::GetCat($cat_id);
                if (is_null($file_category) || !$file_category->CurUserCanEdit()) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
            case 'addcat':
                $update = !empty($update);
                if (!$update && !WPFB_Core::CurUserCanCreateCat()) {
                    wp_die(__('Cheatin&#8217; uh?'));
                }
                $result = WPFB_Admin::InsertCategory(array_merge(stripslashes_deep($_POST), $_FILES));
                if (isset($result['error']) && $result['error']) {
                    $message = $result['error'];
                } else {
                    $message = $update ? __('Category updated.') : __('Category added.');
                    /* def */
                }
                //wp_redirect($clean_uri . '&action=manage_cats&message=' . urlencode($message));
            //wp_redirect($clean_uri . '&action=manage_cats&message=' . urlencode($message));
            default:
                if (!empty($_POST['deleteit'])) {
                    foreach ((array) $_POST['delete'] as $cat_id) {
                        if (is_object($cat = WPFB_Category::GetCat($cat_id)) && $cat->CurUserCanEdit()) {
                            $cat->Delete();
                        }
                    }
                }
                if (!empty($_REQUEST['redirect']) && !empty($_REQUEST['redirect_to'])) {
                    WPFB_AdminLite::JsRedirect($_REQUEST['redirect_to']);
                    exit;
                }
                ?>
                    <h2><?php 
                echo str_replace(array('(<', '>)'), array('<', '>'), sprintf(__('Manage Categories (<a href="%s">add new</a>)', 'wp-filebase'), '#addcat" class="add-new-h2'));
                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 
                }
                ?>
 

                    <form class="search-form topmargin" action="" method="get"><p class="search-box">
                            <input type="hidden" value="<?php 
                echo esc_attr($_GET['page']);
                ?>
" name="page" />
                            <label class="hidden" for="category-search-input"><?php 
                _e('Search Categories');
                ?>
:</label>
                            <input type="text" class="search-input" id="category-search-input" name="s" value="<?php 
                echo isset($_GET['s']) ? esc_attr($_GET['s']) : '';
                ?>
" />
                            <input type="submit" value="<?php 
                _e('Search Categories');
                ?>
" class="button" />
                        </p></form>	

                    <br class="clear" />

                    <form id="posts-filter" action="" method="post">
                        <div class="tablenav">
                <?php 
                $pagenum = max(isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 0, 1);
                if (!isset($catsperpage) || $catsperpage < 0) {
                    $catsperpage = 20;
                }
                $pagestart = ($pagenum - 1) * $catsperpage;
                $extra_sql = '';
                if (!empty($_GET['s'])) {
                    $s = esc_sql(trim($_GET['s']));
                    $extra_sql .= "WHERE cat_name LIKE '%{$s}%' OR cat_description LIKE '%{$s}%' OR cat_folder LIKE '%{$s}%' ";
                }
                if (!empty($_GET['order']) && in_array($_GET['order'], array_keys(get_class_vars('WPFB_Category')))) {
                    $extra_sql .= "ORDER BY " . $_GET['order'] . " " . (!empty($_GET['desc']) ? "DESC" : "ASC");
                }
                $cats = WPFB_Category::GetCats($extra_sql . " LIMIT {$pagestart}, {$catsperpage}");
                $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'total' => ceil(count(WPFB_Category::GetCats($extra_sql)) / $catsperpage), 'current' => $pagenum, 'add_args' => array()));
                if ($page_links) {
                    echo "<div class='tablenav-pages'>{$page_links}</div>";
                }
                ?>

                            <div class="alignleft"><input type="submit" value="<?php 
                _e('Delete');
                ?>
" name="deleteit" class="button delete" /><?php 
                wp_nonce_field('bulk-categories');
                ?>
</div>
                        </div>

                        <br class="clear" />

                        <table class="widefat">
                            <thead>
                                <tr>
                                    <th scope="col" class="check-column"><input type="checkbox" /></th>
                                    <th scope="col"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_name');
                ?>
"><?php 
                _e('Name');
                ?>
</a></th>
                                    <th scope="col"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_description');
                ?>
"><?php 
                _e('Description');
                ?>
</a></th>
                                    <th scope="col" class="num"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_num_files');
                ?>
"><?php 
                _e('Files', 'wp-filebase');
                ?>
</a></th>
                                    <th scope="col"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_parent');
                ?>
"><?php 
                _e('Parent Category');
                ?>
</a></th>
                                    <th scope="col"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_path');
                ?>
"><?php 
                _e('Path');
                ?>
</a></th>
                                    <th scope="col"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_user_roles');
                ?>
"><?php 
                _e('Access Permission', 'wp-filebase');
                ?>
</a></th>
                
                                    <th scope="col"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_owner');
                ?>
"><?php 
                _e('Owner', 'wp-filebase');
                ?>
</a></th>
                                    <th scope="col"><a href="<?php 
                echo WPFB_Admin::AdminTableSortLink('cat_order');
                ?>
"><?php 
                _e('Custom Sort Order', 'wp-filebase');
                ?>
</a></th>
                                </tr>
                            </thead>
                            <tbody id="the-list" class="list:cat">

                <?php 
                foreach ($cats as $cat_id => &$cat) {
                    if ($cat->CurUserCanEdit()) {
                        self::CatRow($cat);
                    }
                }
                ?>

                            </tbody>
                        </table>
                        <div class="tablenav"><?php 
                if ($page_links) {
                    echo "<div class='tablenav-pages'>{$page_links}</div>";
                }
                ?>
</div>
                    </form>
                    <br class="clear" />

                <?php 
                if (WPFB_Core::CurUserCanCreateCat()) {
                    ?>
                        <p><?php 
                    _e('<strong>Note:</strong><br />Deleting a category does not delete the files in that category. Instead, files that were assigned to the deleted category are set to the parent category.', 'wp-filebase');
                    ?>
</p><?php 
                    WPFB_Admin::PrintForm('cat');
                }
                break;
        }
        ?>
        </div> <!-- wrap -->
            <?php 
    }
コード例 #6
0
ファイル: AdminGuiManage.php プロジェクト: noxian/WP-Filebase
    static function Display()
    {
        global $wpdb, $user_ID;
        require_once ABSPATH . 'wp-admin/includes/dashboard.php';
        wpfb_loadclass('AdminDashboard');
        add_thickbox();
        wp_enqueue_script('dashboard');
        if (wp_is_mobile()) {
            wp_enqueue_script('jquery-touch-punch');
        }
        //register_shutdown_function( create_function('','$error = error_get_last(); if( $error && $error[\'type\'] != E_STRICT ){print_r( $error );}else{return true;}') );
        wpfb_loadclass('File', 'Category', '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', 'doit', 'ids', 'files', 'cats', 'batch_sync'));
        // keep search keyword
        WPFB_Admin::PrintFlattrHead();
        ?>
	<script type="text/javascript">	
	/* Liking/Donate Bar */
	if(typeof(jQuery) != 'undefined') {
		jQuery(document).ready(function(){
			if(getUserSetting("wpfilebase_hidesuprow",false) == 1) {
				jQuery('#wpfb-liking').hide();
				jQuery('#wpfb-liking-toggle').addClass('closed');	
			}	
			jQuery('#wpfb-liking-toggle').click(function(){
				jQuery('#wpfb-liking').slideToggle();
				jQuery(this).toggleClass('closed');
				setUserSetting("wpfilebase_hidesuprow", 1-getUserSetting("wpfilebase_hidesuprow",false), 0);
			});	
		});
	}
	</script>
	

	<div class="wrap">
	<div id="icon-wpfilebase" class="icon32"><br /></div>
	<h2><?php 
        echo WPFB_PLUGIN_NAME;
        ?>
</h2>
		
	<?php 
        switch ($action) {
            default:
                $clean_uri = remove_query_arg('pagenum', $clean_uri);
                $upload_dir = WPFB_Core::UploadDir();
                $upload_dir_rel = str_replace(ABSPATH, '', $upload_dir);
                $chmod_cmd = "CHMOD " . WPFB_PERM_DIR . " " . $upload_dir_rel;
                if (!is_dir($upload_dir)) {
                    $result = WPFB_Admin::Mkdir($upload_dir);
                    if ($result['error']) {
                        $error_msg = sprintf(__('The upload directory <code>%s</code> does not exists. It could not be created automatically because the directory <code>%s</code> is not writable. Please create <code>%s</code> and make it writable for the webserver by executing the following FTP command: <code>%s</code>', 'wp-filebase'), $upload_dir_rel, str_replace(ABSPATH, '', $result['parent']), $upload_dir_rel, $chmod_cmd);
                    } else {
                        wpfb_call('Setup', 'ProtectUploadPath');
                    }
                } elseif (!is_writable($upload_dir)) {
                    $error_msg = sprintf(__('The upload directory <code>%s</code> is not writable. Please make it writable for PHP by executing the follwing FTP command: <code>%s</code>', 'wp-filebase'), $upload_dir_rel, $chmod_cmd);
                }
                if (!empty($error_msg)) {
                    echo '<div class="error default-password-nag"><p>' . $error_msg . '</p></div>';
                }
                if (!empty(WPFB_Core::$settings->tag_conv_req)) {
                    echo '<div class="updated"><p><a href="' . add_query_arg('action', 'convert-tags') . '">';
                    _e('WP-Filebase content tags must be converted', 'wp-filebase');
                    echo '</a></p></div><div style="clear:both;"></div>';
                }
                ?>
	<?php 
                if (self::PluginHasBeenUsedAWhile(true)) {
                    self::ProUpgradeNag();
                }
                if (self::PluginHasBeenUsedAWhile()) {
                    ?>
	
<div id="wpfb-support-col">
<div id="wpfb-liking-toggle"></div>
<h3><?php 
                    _e('Like WP-Filebase?', 'wp-filebase');
                    ?>
</h3>
<div id="wpfb-liking">
	<!-- <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> -->
	
	<div style="text-align: center;" ><a href="https://twitter.com/wpfilebase" class="twitter-follow-button" data-show-count="false">Follow @wpfilebase</a>
			<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="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
	
	<p>Please <a href="http://wordpress.org/support/view/plugin-reviews/wp-filebase">give it a good rating</a>.</p>
	<p>For Cloud support and lots of other advanced features consider an</p>
	<p style="text-align: center;"><a href="https://wpfilebase.com/?ref=dblike" class="button-primary">Upgrade to Pro</a></p>
	<p style="text-align: center;"><a href="http://demo.wpfilebase.com/?ref=dblike" class="button">Live Pro Demo</a></p>
	<p style="text-align:right;float:right;font-style:italic;">Thanks, Fabian</p> 
	<!-- <div style="text-align: center;">
	<?php 
                    //WPFB_Admin::PrintPayPalButton()
                    ?>
	<?php 
                    //WPFB_Admin::PrintFlattrButton()
                    ?>
	</div> -->
</div>
</div>
<?php 
                }
                ?>

	
	<div id="dashboard-widgets-wrap">
	<?php 
                wp_dashboard();
                ?>
	</div><!-- dashboard-widgets-wrap -->
	
	<?php 
                break;
            case 'convert-tags':
                ?>
<h2><?php 
                _e('Tag Conversion');
                ?>
</h2><?php 
                if (empty($_REQUEST['doit'])) {
                    echo '<div class="updated"><p>';
                    _e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
                    echo '</p></div>';
                    echo '<p><a href="' . add_query_arg('doit', 1) . '" class="button">' . __('Continue') . '</a></p>';
                    break;
                }
                $result = wpfb_call('Setup', 'ConvertOldTags');
                ?>
		<p><?php 
                printf(__('%d Tags in %d Posts has been converted.'), $result['n_tags'], count($result['tags']));
                ?>
</p>
		<ul>
		<?php 
                if (!empty($result['tags'])) {
                    foreach ($result['tags'] as $post_title => $tags) {
                        echo "<li><strong>" . esc_html($post_title) . "</strong><ul>";
                        foreach ($tags as $old => $new) {
                            echo "<li>{$old} =&gt; {$new}</li>";
                        }
                        echo "</ul></li>";
                    }
                }
                ?>
		</ul>
		<?php 
                if (!empty($result['errors'])) {
                    ?>
	
		<h2><?php 
                    _e('Errors');
                    ?>
</h2>
		<ul><?php 
                    foreach ($result['errors'] as $post_title => $err) {
                        echo "<li><strong>" . esc_html($post_title) . ": </strong> " . esc_html($err) . "<ul>";
                    }
                    ?>
</ul>		
		<?php 
                }
                $opts = WPFB_Core::GetOpt();
                unset($opts['tag_conv_req']);
                update_option(WPFB_OPT_NAME, $opts);
                WPFB_Core::$settings = (object) $opts;
                break;
                // convert-tags
            // convert-tags
            case 'del':
                if (!empty($_REQUEST['files']) && WPFB_Core::CurUserCanUpload()) {
                    $ids = explode(',', $_REQUEST['files']);
                    $nd = 0;
                    foreach ($ids as $id) {
                        $id = intval($id);
                        if (($file = WPFB_File::GetFile($id)) != null && $file->CurUserCanDelete()) {
                            $file->Remove(true);
                            $nd++;
                        }
                    }
                    WPFB_File::UpdateTags();
                    echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Files removed'), $nd) . '</p></div>';
                }
                if (!empty($_REQUEST['cats']) && WPFB_Core::CurUserCanCreateCat()) {
                    $ids = explode(',', $_REQUEST['cats']);
                    $nd = 0;
                    foreach ($ids as $id) {
                        $id = intval($id);
                        if (($cat = WPFB_Category::GetCat($id)) != null) {
                            $cat->Delete();
                            $nd++;
                        }
                    }
                    echo '<div id="message" class="updated fade"><p>' . sprintf(__('%d Categories removed'), $nd) . '</p></div>';
                }
            case 'sync':
                echo '<h2>' . __('Synchronisation') . '</h2>';
                wpfb_loadclass('Sync');
                $result = WPFB_Sync::Sync(!empty($_GET['hash_sync']), true);
                if (!is_null($result)) {
                    WPFB_Sync::PrintResult($result);
                }
                if (empty($_GET['hash_sync'])) {
                    echo '<p><a href="' . add_query_arg('hash_sync', 1) . '" class="button">' . __('Complete file sync', 'wp-filebase') . '</a> ' . __('Checks files for changes, so more reliable but might take much longer. Do this if you uploaded/changed files with FTP.', 'wp-filebase') . '</p>';
                }
                if (empty($_GET['debug'])) {
                    echo '<p><a href="' . add_query_arg('debug', 1) . '" class="button">' . __('Debug Sync', 'wp-filebase') . '</a> ' . __('Run to get more Debug Info in case Sync crashes', 'wp-filebase') . '</p>';
                }
                break;
                // sync
            // sync
            case 'batch-upload':
                wpfb_loadclass('BatchUploader');
                $batch_uploader = new WPFB_BatchUploader();
                $batch_uploader->Display();
                break;
            case 'reset-hits':
                global $wpdb;
                $n = 0;
                if (current_user_can('manage_options')) {
                    $n = $wpdb->query("UPDATE `{$wpdb->wpfilebase_files}` SET file_hits = 0 WHERE 1=1");
                }
                echo "<p>";
                printf(__('Done. %d Files affected.'), $n);
                echo "</p>";
                break;
            case 'install-extensions':
                wpfb_call('AdmInstallExt', 'Display');
                break;
        }
        // switch
        if (!empty($_GET['action'])) {
            echo '<p><a href="' . $clean_uri . '" class="button">' . __('Go back') . '</a></p>';
        }
        ?>
</div> <!-- wrap -->
<?php 
    }
コード例 #7
0
ファイル: Ajax.php プロジェクト: noxian/WP-Filebase
 private static function actionNewCat($args)
 {
     wpfb_loadclass('Category');
     $parent_cat = empty($args['cat_parent']) ? null : WPFB_Category::GetCat($args['cat_parent']);
     if (!WPFB_Core::CurUserCanCreateCat() && !$parent_cat && !$parent_cat->CurUserCanAddFiles()) {
         die('-1');
     }
     wpfb_loadclass('Admin');
     $result = WPFB_Admin::InsertCategory($args);
     if (isset($result['error']) && $result['error']) {
         wp_send_json(array('error' => $result['error']));
         exit;
     }
     $cat = $result['cat'];
     $fb_args = WPFB_Output::fileBrowserArgs(empty($args['args']) ? array() : $args['args']);
     $filesel = $fb_args['type'] === 'fileselect';
     $catsel = $fb_args['type'] === 'catselect';
     $tpl = empty($args['tpl']) ? empty($args['is_admin']) ? 'filebrowser' : 'filebrowser_admin' : $args['tpl'];
     wp_send_json(array('error' => 0, 'id' => $cat->GetId(), 'name' => $cat->GetTitle(), 'id_str' => $fb_args['idp'] . 'cat-' . $cat->cat_id, 'url' => $cat->GetUrl(), 'text' => WPFB_Output::fileBrowserCatItemText($catsel, $filesel, $cat, $fb_args['onselect'], $tpl), 'classes' => $filesel || $catsel ? 'folder' : null));
 }
コード例 #8
0
ファイル: Core.php プロジェクト: noxian/WP-Filebase
 static function InitClass()
 {
     self::$ajax_url = admin_url('admin-ajax.php?action=wpfilebase');
     self::$ajax_url_public = strstr(home_url('/?wpfilebase_ajax=1'), '//');
     // remove protocol qualifier
     self::$settings = (object) get_option(WPFB_OPT_NAME, array());
     if (defined('WPFB_NO_CORE_INIT')) {
         return;
     }
     // on activation
     $lang_dir = defined('WPFB_LANG_DIR') ? '../../' . WPFB_LANG_DIR : basename(WPFB_PLUGIN_ROOT) . '/languages';
     load_plugin_textdomain('wp-filebase', false, $lang_dir);
     add_action('parse_query', array(__CLASS__, 'ParseQuery'));
     // search
     add_action('wp_enqueue_scripts', array(__CLASS__, 'EnqueueScripts'));
     add_action('wp_footer', array(__CLASS__, 'Footer'));
     add_action('generate_rewrite_rules', array(__CLASS__, 'GenRewriteRules'));
     add_action('wp_ajax_nopriv_wpfilebase', wpfb_callback('Ajax', 'PublicRequest'));
     add_action('wp_ajax_wpfilebase', wpfb_callback('Ajax', 'AdminRequest'));
     add_action('wpfb_cron', array(__CLASS__, 'Cron'));
     add_action('wpfilebase_sync', array(__CLASS__, 'Sync'));
     // for Developers: New wp-filebase actions
     add_action('wpfilebase_bgscan', array(__CLASS__, 'BgScanWork'));
     // for Developers: New wp-filebase actions
     // for attachments and file browser
     add_filter('the_content', array(__CLASS__, 'ContentFilter'), 10);
     // must be lower than 11 (before do_shortcode) and after wpautop (>9)
     add_filter('pre_set_site_transient_update_plugins', array(__CLASS__, 'PreSetPluginsTransientFilter'));
     add_filter('plugins_api', array(__CLASS__, 'PluginsApiFilter'), 10, 3);
     add_filter('ext2type', array(__CLASS__, 'Ext2TypeFilter'));
     add_shortcode('wpfilebase', array(__CLASS__, 'ShortCode'));
     self::DownloadRedirect();
     if (isset($_GET['wpfilebase_ajax'])) {
         define('DOING_AJAX', true);
         wpfb_loadclass('Ajax');
         WPFB_Ajax::PublicRequest();
     }
     // register treeview stuff
     wp_register_script('wpfb-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview-async-edit.min.js', array('jquery'), WPFB_VERSION);
     wp_register_style('wpfb-treeview', WPFB_PLUGIN_URI . 'extras/jquery/treeview/jquery.treeview.css', array(), WPFB_VERSION);
     // DataTables
     wp_register_script('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/datatables.min.js', array('jquery'), WPFB_VERSION);
     wp_register_style('jquery-dataTables', WPFB_PLUGIN_URI . 'extras/jquery/dataTables/datatables.min.css', array(), WPFB_VERSION);
     wp_register_script(WPFB, WPFB_PLUGIN_URI . 'js/common.js', array('jquery'), WPFB_VERSION);
     // cond loading (see Footer)
     wp_register_script('wpfb-live-admin', WPFB_PLUGIN_URI . 'js/live-admin.js', array('jquery'), WPFB_VERSION);
     if (empty(WPFB_Core::$settings->disable_css)) {
         $wpfb_css = get_option('wpfb_css');
         wp_enqueue_style(WPFB, strstr($wpfb_css ? $wpfb_css : WPFB_PLUGIN_URI . 'wp-filebase.css', '//'), array(), WPFB_VERSION, 'all');
     }
     // live admin normaly for front-end, but also on filebrowser backend
     if (is_admin() ? isset($_GET['page']) && $_GET['page'] == 'wpfilebase_filebrowser' : WPFB_Core::CurUserCanCreateCat() || WPFB_Core::CurUserCanUpload()) {
         wp_enqueue_script('wpfb-live-admin');
         wp_enqueue_style('wpfb-live-admin', WPFB_PLUGIN_URI . 'css/live-admin.css', array(), WPFB_VERSION);
         self::$settings->admin_bar && add_action('admin_bar_menu', array(__CLASS__, 'AdminBar'), 80);
         if (!empty(self::$settings->file_context_menu)) {
             wp_enqueue_script('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.js', array('jquery'));
             wp_enqueue_style('jquery-contextmenu', WPFB_PLUGIN_URI . 'extras/jquery/contextmenu/jquery.contextmenu.css', array(), WPFB_VERSION);
         }
     }
     if (WPFB_Core::$settings->frontend_upload && (!empty($_GET['wpfb_upload_file']) || !empty($_GET['wpfb_add_cat'])) && (WPFB_Core::CurUserCanUpload() || WPFB_Core::CurUserCanCreateCat())) {
         wpfb_call('Admin', empty($_GET['wpfb_upload_file']) ? 'ProcessWidgetAddCat' : 'ProcessWidgetUpload');
     }
 }