public function test_get_space_allowed_filtered()
 {
     update_option('blog_upload_space', 777);
     update_site_option('blog_upload_space', 888);
     add_filter('get_space_allowed', array($this, '_filter_space_allowed'));
     $space_allowed = get_space_allowed();
     remove_filter('get_space_allowed', array($this, '_filter_space_allowed'));
     $this->assertEquals(999, $space_allowed);
 }
 /**
  * Output our custom quota column content.
  *
  * @param string $column_name The registered column name that the list table is currently on.
  * @param int $user_id The blog ID associated with the current blog row.
  */
 public function setup_column($column_name, $blog_id)
 {
     if ($this->column_name !== $column_name) {
         return;
     }
     switch_to_blog($blog_id);
     // You might recognize this from wp_dashboard_quota().
     $quota = get_space_allowed();
     $used = get_space_used();
     if ($used > $quota) {
         $percentused = '100';
     } else {
         $percentused = $used / $quota * 100;
     }
     $text = sprintf(__('%1$s MB / %2$s MB (%3$s%%)'), number_format_i18n(round($used, 2), 2), number_format_i18n($quota, 2), number_format($percentused));
     printf('<a href="%1$s" title="%2$s" class="musublink">%3$s</a>', esc_url(admin_url('upload.php')), __('Manage Uploads'), $text);
     restore_current_blog();
 }
    /**
     * Builder Import Lightbox
     * @return html
     */
    function builder_import_file_ajaxify()
    {
        check_ajax_referer('tfb_load_nonce', 'nonce');
        $output = '<div class="lightbox_inner themify-builder-import-file-inner">';
        $output .= sprintf('<h3>%s</h3>', __('Select a file to import', 'themify'));
        if (is_multisite() && !is_upload_space_available()) {
            $output .= sprintf(__('<p>Sorry, you have filled your %s MB storage quota so uploading has been disabled.</p>', 'themify'), get_space_allowed());
        } else {
            $output .= sprintf('<p><div class="themify-builder-plupload-upload-uic hide-if-no-js tf-upload-btn" id="%sthemify-builder-plupload-upload-ui">
										<input id="%sthemify-builder-plupload-browse-button" type="button" value="%s" class="builder_button" />
										<span class="ajaxnonceplu" id="ajaxnonceplu%s"></span>
								</div></p>', 'themify_builder_import_file', 'themify_builder_import_file', __('Upload', 'themify'), wp_create_nonce('themify_builder_import_filethemify-builder-plupload'));
            $max_upload_size = (int) wp_max_upload_size() / (1024 * 1024);
            $output .= sprintf(__('<p>Maximum upload file size: %d MB.</p>', 'themify'), $max_upload_size);
        }
        $output .= '</div>';
        echo $output;
        die;
    }
Пример #4
0
 function getQuota()
 {
     if (function_exists(get_space_allowed)) {
         $quota = get_space_allowed();
     } else {
         $quota = get_site_option("blog_upload_space");
     }
     return $quota;
 }
Пример #5
0
function display_space_usage() {
	$space = get_space_allowed();
	$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;

	$percentused = ( $used / $space ) * 100;

	if ( $space > 1000 ) {
		$space = number_format( $space / 1024 );
		/* translators: Gigabytes */
		$space .= __( 'GB' );
	} else {
		/* translators: Megabytes */
		$space .= __( 'MB' );
	}
	?>
	<strong><?php printf( __( 'Used: %1s%% of %2s' ), number_format( $percentused ), $space ); ?></strong>
	<?php
}
Пример #6
0
/**
 * Display file upload quota on dashboard.
 *
 * Runs on the activity_box_end hook in wp_dashboard_right_now().
 *
 * @since 3.0.0
 *
 * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled.
*/
function wp_dashboard_quota()
{
    if (!is_multisite() || !current_user_can('upload_files') || get_network_option('upload_space_check_disabled')) {
        return true;
    }
    $quota = get_space_allowed();
    $used = get_space_used();
    if ($used > $quota) {
        $percentused = '100';
    } else {
        $percentused = $used / $quota * 100;
    }
    $used_class = $percentused >= 70 ? ' warning' : '';
    $used = round($used, 2);
    $percentused = number_format($percentused);
    ?>
	<h4 class="mu-storage"><?php 
    _e('Storage Space');
    ?>
</h4>
	<div class="mu-storage">
	<ul>
		<li class="storage-count">
			<?php 
    $text = sprintf(__('%s MB Space Allowed'), number_format_i18n($quota));
    printf('<a href="%1$s" title="%2$s">%3$s</a>', esc_url(admin_url('upload.php')), __('Manage Uploads'), $text);
    ?>
		</li><li class="storage-count <?php 
    echo $used_class;
    ?>
">
			<?php 
    $text = sprintf(__('%1$s MB (%2$s%%) Space Used'), number_format_i18n($used, 2), $percentused);
    printf('<a href="%1$s" title="%2$s" class="musublink">%3$s</a>', esc_url(admin_url('upload.php')), __('Manage Uploads'), $text);
    ?>
		</li>
	</ul>
	</div>
	<?php 
}
Пример #7
0
/**
 * Determines if there is any upload space left in the current blog's quota.
 *
 * @since 3.0.0
 *
 * @return int of upload space available in bytes
 */
function get_upload_space_available()
{
    $allowed = get_space_allowed();
    if ($allowed < 0) {
        $allowed = 0;
    }
    $space_allowed = $allowed * 1024 * 1024;
    if (get_site_option('upload_space_check_disabled')) {
        return $space_allowed;
    }
    $space_used = get_space_used() * 1024 * 1024;
    if ($space_allowed - $space_used <= 0) {
        return 0;
    }
    return $space_allowed - $space_used;
}
Пример #8
0
	/**
	 * @ticket 18119
	 */
	function test_upload_is_user_over_quota() {
		$default_space_allowed = 100;
		$echo = false;

		$this->assertFalse( upload_is_user_over_quota( $echo ) );
		$this->assertTrue( is_upload_space_available() );

		update_site_option('upload_space_check_disabled', true);
		$this->assertFalse( upload_is_user_over_quota( $echo ) );
		$this->assertTrue( is_upload_space_available() );

		update_site_option( 'blog_upload_space', 0 );
		$this->assertFalse( upload_is_user_over_quota( $echo ) );
		$this->assertEquals( $default_space_allowed, get_space_allowed() );
		$this->assertTrue( is_upload_space_available() );

		update_site_option('upload_space_check_disabled', false);
		$this->assertFalse( upload_is_user_over_quota( $echo ) );
		$this->assertTrue( is_upload_space_available() );

		if ( defined( 'BLOGSUPLOADDIR' ) && ! file_exists( BLOGSUPLOADDIR ) )
			$this->markTestSkipped( 'This test is broken when blogs.dir does not exist. ');

		/*
		This is broken when blogs.dir does not exist, as get_upload_space_available()
		simply returns the value of blog_upload_space (converted to bytes), which would
		be negative but still not false. When blogs.dir does exist, < 0 is returned as 0.
		*/

		update_site_option( 'blog_upload_space', -1 );
		$this->assertTrue( upload_is_user_over_quota( $echo ) );
		$this->assertEquals( -1, get_space_allowed() );
		$this->assertFalse( is_upload_space_available() );

		update_option( 'blog_upload_space', 0 );
		$this->assertFalse( upload_is_user_over_quota( $echo ) );
		$this->assertEquals( $default_space_allowed, get_space_allowed() );
		$this->assertTrue( is_upload_space_available() );

		update_option( 'blog_upload_space', -1 );
		$this->assertTrue( upload_is_user_over_quota( $echo ) );
		$this->assertEquals( -1, get_space_allowed() );
		$this->assertFalse( is_upload_space_available() );
	}
Пример #9
0
/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param unknown_type $errors
 */
function media_upload_form($errors = null)
{
    global $type, $tab, $pagenow, $is_IE, $is_opera, $is_iphone;
    if ($is_iphone) {
        return;
    }
    $upload_action_url = admin_url('async-upload.php');
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $_type = isset($type) ? $type : '';
    $_tab = isset($tab) ? $tab : '';
    $upload_size_unit = $max_upload_size = nxt_max_upload_size();
    $sizes = array('KB', 'MB', 'GB');
    for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
        $upload_size_unit /= 1024;
    }
    if ($u < 0) {
        $upload_size_unit = 0;
        $u = 0;
    } else {
        $upload_size_unit = (int) $upload_size_unit;
    }
    ?>

<div id="media-upload-notice"><?php 
    if (isset($errors['upload_notice'])) {
        echo $errors['upload_notice'];
    }
    ?>
</div>
<div id="media-upload-error"><?php 
    if (isset($errors['upload_error']) && is_nxt_error($errors['upload_error'])) {
        echo $errors['upload_error']->get_error_message();
    }
    ?>
</div>
<?php 
    // Check quota for this blog if multisite
    if (is_multisite() && !is_upload_space_available()) {
        echo '<p>' . sprintf(__('Sorry, you have filled your storage quota (%s MB).'), get_space_allowed()) . '</p>';
        return;
    }
    do_action('pre-upload-ui');
    $post_params = array("post_id" => $post_id, "_nxtnonce" => nxt_create_nonce('media-form'), "type" => $_type, "tab" => $_tab, "short" => "1");
    $post_params = apply_filters('upload_post_params', $post_params);
    // hook change! old name: 'swfupload_post_params'
    $plupload_init = array('runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => 'plupload-browse-button', 'container' => 'plupload-upload-ui', 'drop_element' => 'drag-drop-area', 'file_data_name' => 'async-upload', 'multiple_queues' => true, 'max_file_size' => $max_upload_size . 'b', 'url' => $upload_action_url, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => '*')), 'multipart' => true, 'urlstream_upload' => true, 'multipart_params' => $post_params);
    $plupload_init = apply_filters('plupload_init', $plupload_init);
    ?>

<script type="text/javascript">
<?php 
    // Verify size is an int. If not return default value.
    $large_size_h = absint(get_option('large_size_h'));
    if (!$large_size_h) {
        $large_size_h = 1024;
    }
    $large_size_w = absint(get_option('large_size_w'));
    if (!$large_size_w) {
        $large_size_w = 1024;
    }
    ?>
var resize_height = <?php 
    echo $large_size_h;
    ?>
, resize_width = <?php 
    echo $large_size_w;
    ?>
,
nxtUploaderInit = <?php 
    echo json_encode($plupload_init);
    ?>
;
</script>

<div id="plupload-upload-ui" class="hide-if-no-js">
<?php 
    do_action('pre-plupload-upload-ui');
    // hook change, old name: 'pre-flash-upload-ui'
    ?>
<div id="drag-drop-area">
	<div class="drag-drop-inside">
	<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="plupload-browse-button" type="button" value="<?php 
    esc_attr_e('Select Files');
    ?>
" class="button" /></p>
	</div>
</div>
<?php 
    do_action('post-plupload-upload-ui');
    // hook change, old name: 'post-flash-upload-ui'
    ?>
</div>

<div id="html-upload-ui" class="hide-if-js">
<?php 
    do_action('pre-html-upload-ui');
    ?>
	<p id="async-upload-wrap">
		<label class="screen-reader-text" for="async-upload"><?php 
    _e('Upload');
    ?>
</label>
		<input type="file" name="async-upload" id="async-upload" />
		<?php 
    submit_button(__('Upload'), 'button', 'html-upload', false);
    ?>
		<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php 
    _e('Cancel');
    ?>
</a>
	</p>
	<div class="clear"></div>
<?php 
    do_action('post-html-upload-ui');
    ?>
</div>

<span class="max-upload-size"><?php 
    printf(__('Maximum upload file size: %d%s.'), esc_html($upload_size_unit), esc_html($sizes[$u]));
    ?>
</span>
<?php 
    if (($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024) {
        ?>
	<span class="big-file-warning"><?php 
        _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.');
        ?>
</span>
<?php 
    }
    do_action('post-upload-ui');
}
Пример #10
0
	function test_get_space_allowed_negative_site_option() {
		update_option( 'blog_upload_space', false );
		update_site_option( 'blog_upload_space', -1 );
		$this->assertEquals( -1, get_space_allowed() );
	}
/**
 * Modified From media_upload_form in WordPress 3.2.1 Core
 *
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @return unknown
 */
function s2sfu_media_upload_form($errors)
{
    global $type, $tab, $pagenow;
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $upload_size_unit = $max_upload_size = wp_max_upload_size();
    $sizes = array('KB', 'MB', 'GB');
    for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
        $upload_size_unit /= 1024;
    }
    if ($u < 0) {
        $upload_size_unit = 0;
        $u = 0;
    } else {
        $upload_size_unit = (int) $upload_size_unit;
    }
    ?>

<div id="media-upload-notice">
<?php 
    if (isset($errors['upload_notice'])) {
        ?>
	<?php 
        echo $errors['upload_notice'];
    }
    ?>
</div>
<div id="media-upload-error">
<?php 
    if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) {
        ?>
	<?php 
        echo $errors['upload_error']->get_error_message();
    }
    ?>
</div>
<?php 
    // Check quota for this blog if multisite
    if (is_multisite() && !is_upload_space_available()) {
        echo '<p>' . sprintf(__('Sorry, you have filled your storage quota (%s MB).'), get_space_allowed()) . '</p>';
        return;
    }
    do_action('pre-upload-ui');
    ?>

<div id="html-upload-ui" <?php 
    if ($flash) {
        echo 'class="hide-if-js"';
    }
    ?>
>
<?php 
    do_action('pre-html-upload-ui');
    ?>
	<p id="async-upload-wrap">
		<label class="screen-reader-text" for="async-upload"><?php 
    _e('Upload');
    ?>
</label>
		<input type="file" name="async-upload" id="async-upload" />
		<?php 
    submit_button(__('Insert into Post'), 'button', 'html-upload', false);
    ?>
		<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php 
    _e('Cancel');
    ?>
</a>
	</p>
	<div class="clear"></div>
	<p class="media-upload-size"><?php 
    printf(__('Maximum upload file size: %d%s'), $upload_size_unit, $sizes[$u]);
    ?>
</p>
	<?php 
    if (is_lighttpd_before_150()) {
        ?>
	<p><?php 
        _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please update to lighttpd 1.5.');
        ?>
</p>
	<?php 
    }
    do_action('post-html-upload-ui', $flash);
    ?>
</div>
<?php 
    do_action('post-upload-ui');
}
Пример #12
0
function fix_import_form_size($size)
{
    if (upload_is_user_over_quota(false) == true) {
        return 0;
    }
    $spaceAllowed = 1024 * 1024 * get_space_allowed();
    $dirName = constant("ABSPATH") . constant("UPLOADS");
    $dirsize = get_dirsize($dirName);
    if ($size > $spaceAllowed - $dirsize) {
        return $spaceAllowed - $dirsize;
        // remaining space
    } else {
        return $size;
        // default
    }
}
Пример #13
0
function dashboard_quota() {
	if ( get_site_option( 'upload_space_check_disabled' ) )
		return true;

	$quota = get_space_allowed();
	$used = get_dirsize( BLOGUPLOADDIR ) / 1024 / 1024;

	if ( $used > $quota )
		$percentused = '100';
	else
		$percentused = ( $used / $quota ) * 100;
	$used_color = ( $percentused < 70 ) ? ( ( $percentused >= 40 ) ? 'waiting' : 'approved' ) : 'spam';
	$used = round( $used, 2 );
	$percentused = number_format( $percentused );

	?>
	<p class="sub musub"><?php _e( 'Storage Space' ); ?></p>
	<div class="table table_content musubtable">
	<table>
		<tr class="first">
			<td class="first b b-posts"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>' ), esc_url( admin_url( 'upload.php' ) ), $quota ); ?></td>
			<td class="t posts"><?php _e( 'Space Allowed' ); ?></td>
		</tr>
	</table>
	</div>
	<div class="table table_discussion musubtable">
	<table>
		<tr class="first">
			<td class="b b-comments"><?php printf( __( '<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>' ), esc_url( admin_url( 'upload.php' ) ), $used, $percentused ); ?></td>
			<td class="last t comments <?php echo $used_color;?>"><?php _e( 'Space Used' );?></td>
		</tr>
	</table>
	</div>
	<br class="clear" />
	<?php
}
Пример #14
0
/**
 * Determines if there is any upload space left in the current blog's quota.
 *
 * @since 3.0.0
 *
 * @return int of upload space available in bytes
 */
function get_upload_space_available() {
	$space_allowed = get_space_allowed() * 1024 * 1024;
	if ( get_site_option( 'upload_space_check_disabled' ) )
		return $space_allowed;

	$space_used = get_space_used() * 1024 * 1024;

	if ( ( $space_allowed - $space_used ) <= 0 )
		return 0;

	return $space_allowed - $space_used;
}
Пример #15
0
    public function add_quota_to_library()
    {
        global $psts;
        $quota = get_space_allowed();
        $used = get_space_used();
        if ($used > $quota) {
            $percentused = '100';
        } else {
            $percentused = $used / $quota * 100;
        }
        $used_class = $percentused >= 70 ? 'class="warning"' : '';
        $used = round($used, 2);
        $percentused = number_format($percentused);
        $text = sprintf(__('%1$s MB (%2$s%%) of %3$s MB used.', 'psts'), number_format_i18n($used, 2), $percentused, number_format_i18n($quota, 2));
        ?>

		<div id="prosites-media-quota-display" style="display:none;" <?php 
        echo $used_class;
        ?>
><div class="size-text"><?php 
        echo $text;
        ?>
 </div><?php 
        echo $this->message(false, 'media-upload');
        ?>
</div><?php 
        global $psts;
        wp_enqueue_style('psts-quota-style', $psts->plugin_url . 'css/quota.css', $psts->version);
        wp_enqueue_script('psts-quota', $psts->plugin_url . 'js/quota.js', array('jquery'), $psts->version);
    }
Пример #16
0
/**
 * Check if user has available space in multisite installations
 * @param String $allowed Content to show if there is space available
 * @param Boolean $echo Flag establishing if content must be echoed or returned
 * @return String
 * @since 1.1.5 
 */
function themify_has_quota($allowed, $echo = false, $custom = '')
{
    if (is_multisite() && !is_upload_space_available()) {
        if ('' != $custom) {
            $message = $custom;
        } else {
            $message = '<small>' . sprintf(__('Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify'), get_space_allowed()) . '</small>';
        }
    } else {
        $message = $allowed;
    }
    if ($echo) {
        echo wp_kses_post($message);
    }
    return $message;
}
Пример #17
0
/**
 * Displays the amount of disk space used by the current site. Not used in core.
 *
 * @since MU
 */
function display_space_usage()
{
    $space_allowed = get_space_allowed();
    $space_used = get_space_used();
    $percent_used = $space_used / $space_allowed * 100;
    if ($space_allowed > 1000) {
        $space = number_format($space_allowed / KB_IN_BYTES);
        /* translators: Gigabytes */
        $space .= __('GB');
    } else {
        $space = number_format($space_allowed);
        /* translators: Megabytes */
        $space .= __('MB');
    }
    ?>
	<strong><?php 
    printf(__('Used: %1$s%% of %2$s'), number_format($percent_used), $space);
    ?>
</strong>
	<?php 
}
Пример #18
0
	
	<?php 
$this->render_catablog_admin_message();
?>
	
	<p>
		<?php 
_e("CataBlog can't make a new entry because your site has run out of storage space.", 'catablog');
?>
	</p>
	<p>
		<?php 
$current_usage = round(get_dirsize(BLOGUPLOADDIR) / 1024 / 1024, 2);
?>
		<?php 
sprintf(_e('You are currently using %sMB of %sMB of storage space.', 'catablog'), $current_usage, get_space_allowed());
?>
	</p>
	<p>
		<?php 
_e('Please talk to your WordPress Administrator to have more space allocated to your site or delete some previous uploaded content.', 'catablog');
?>
	</p>
	<ul>
		<li><strong><?php 
_e('Go To:', 'catablog');
?>
</strong></li>
		<li><a href="index.php"><?php 
_e('Dashboard', 'catablog');
?>
 /**
  * File upload psace left per site in MB.
  *  -1 means NO LIMIT.
  * @return number
  */
 static function network_site_upload_space($option = null)
 {
     // value in MB
     return get_site_option('upload_space_check_disabled') ? -1 : get_space_allowed();
 }
    /**
     * Module Styling Fields
     * @param array $styling 
     * @return string
     */
    function themify_builder_styling_field($styling)
    {
        switch ($styling['type']) {
            case 'text':
                ?>
				<input id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" type="text" value="" class="<?php 
                echo esc_attr($styling['class']);
                ?>
 tfb_lb_option">
				<?php 
                if (isset($styling['description'])) {
                    echo '<small>' . wp_kses_post($styling['description']) . '</small>';
                }
                ?>
				<?php 
                break;
            case 'textarea':
                ?>
				<textarea id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" class="<?php 
                echo esc_attr($styling['class']);
                ?>
 tfb_lb_option"><?php 
                if (isset($styling['value'])) {
                    echo esc_textarea($styling['value']);
                }
                ?>
</textarea>
				<?php 
                if (isset($styling['description'])) {
                    echo '<small>' . wp_kses_post($styling['description']) . '</small>';
                }
                ?>
				<?php 
                break;
            case 'separator':
                echo isset($styling['meta']['html']) && '' != $styling['meta']['html'] ? $styling['meta']['html'] : '<hr class="meta_fields_separator" />';
                break;
            case 'image':
                ?>
				<input id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" placeholder="<?php 
                if (isset($styling['value'])) {
                    echo esc_attr($styling['value']);
                }
                ?>
" class="<?php 
                echo esc_attr($styling['class']);
                ?>
 themify-builder-uploader-input tfb_lb_option" type="text" /><br />
								
				<div class="small">

					<?php 
                if (is_multisite() && !is_upload_space_available()) {
                    ?>
						<?php 
                    echo sprintf(__('Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify'), get_space_allowed());
                    ?>
					<?php 
                } else {
                    ?>
					<div class="themify-builder-plupload-upload-uic hide-if-no-js tf-upload-btn" id="<?php 
                    echo esc_attr($styling['id']);
                    ?>
themify-builder-plupload-upload-ui">
							<input id="<?php 
                    echo esc_attr($styling['id']);
                    ?>
themify-builder-plupload-browse-button" type="button" value="<?php 
                    esc_attr_e(__('Upload', 'themify'));
                    ?>
" class="builder_button" />
							<span class="ajaxnonceplu" id="ajaxnonceplu<?php 
                    echo wp_create_nonce($styling['id'] . 'themify-builder-plupload');
                    ?>
"></span>
					</div> <?php 
                    _e('or', 'themify');
                    ?>
 <a href="#" class="themify-builder-media-uploader tf-upload-btn" data-uploader-title="<?php 
                    esc_attr_e('Upload an Image', 'themify');
                    ?>
" data-uploader-button-text="<?php 
                    esc_attr_e('Insert file URL', 'themify');
                    ?>
"><?php 
                    _e('Browse Library', 'themify');
                    ?>
</a>

					<?php 
                }
                ?>

				</div>
				
				<p class="thumb_preview">
					<span class="img-placeholder"></span>
					<a href="#" class="themify_builder_icon small delete themify-builder-delete-thumb"></a>
				</p>


				<?php 
                break;
            case 'video':
                ?>
				<input id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" placeholder="<?php 
                if (isset($styling['value'])) {
                    echo esc_attr($styling['value']);
                }
                ?>
" class="<?php 
                echo esc_attr($styling['class']);
                ?>
 themify-builder-uploader-input tfb_lb_option" type="text" /><br />

				<div class="small">

					<?php 
                if (is_multisite() && !is_upload_space_available()) {
                    ?>
						<?php 
                    echo sprintf(__('Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify'), get_space_allowed());
                    ?>
					<?php 
                } else {
                    ?>
					<div class="themify-builder-plupload-upload-uic hide-if-no-js tf-upload-btn" id="<?php 
                    echo esc_attr($styling['id']);
                    ?>
themify-builder-plupload-upload-ui" data-extensions="<?php 
                    echo esc_attr(implode(',', wp_get_video_extensions()));
                    ?>
">
						<input id="<?php 
                    echo esc_attr($styling['id']);
                    ?>
themify-builder-plupload-browse-button" type="button" value="<?php 
                    esc_attr_e(__('Upload', 'themify'));
                    ?>
" class="builder_button" />
						<span class="ajaxnonceplu" id="ajaxnonceplu<?php 
                    echo wp_create_nonce($styling['id'] . 'themify-builder-plupload');
                    ?>
"></span>
					</div> <?php 
                    _e('or', 'themify');
                    ?>
 <a href="#" class="themify-builder-media-uploader tf-upload-btn" data-uploader-title="<?php 
                    _e('Upload a Video', 'themify');
                    ?>
" data-uploader-button-text="<?php 
                    esc_attr_e('Insert file URL', 'themify');
                    ?>
" data-library-type="video"><?php 
                    _e('Browse Library', 'themify');
                    ?>
</a>

					<?php 
                }
                ?>

				</div>

				<?php 
                if (isset($styling['description'])) {
                    echo '<small>' . wp_kses_post($styling['description']) . '</small>';
                }
                ?>

				<?php 
                break;
            case 'select':
                ?>
				
				<select id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" class="tfb_lb_option <?php 
                echo isset($styling['class']) ? esc_attr($styling['class']) : '';
                ?>
">
					<?php 
                if (isset($styling['default'])) {
                    ?>
					<option value="<?php 
                    echo esc_attr($styling['default']);
                    ?>
"><?php 
                    echo esc_html($styling['default']);
                    ?>
</option>
					<?php 
                }
                foreach ($styling['meta'] as $option) {
                    ?>
					<option value="<?php 
                    echo esc_attr($option['value']);
                    ?>
"><?php 
                    echo esc_html($option['name']);
                    ?>
</option>
					<?php 
                }
                ?>

				</select>

				<?php 
                if (isset($styling['description'])) {
                    echo wp_kses_post($styling['description']);
                }
                ?>

			<?php 
                break;
            case 'animation_select':
                ?>
				<?php 
                $class = isset($styling['class']) ? $styling['class'] : '';
                ?>
				<select id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" class="tfb_lb_option <?php 
                echo esc_attr($class);
                ?>
">
					<option value=""></option>
					
					<?php 
                $animation = Themify_Builder_model::get_preset_animation();
                foreach ($animation as $group) {
                    ?>

						<optgroup label="<?php 
                    echo esc_attr($group['group_label']);
                    ?>
">
							<?php 
                    foreach ($group['options'] as $opt) {
                        ?>
								<option value="<?php 
                        echo esc_attr($opt['value']);
                        ?>
"><?php 
                        echo esc_html($opt['name']);
                        ?>
</option>
							<?php 
                    }
                    ?>
						</optgroup>

					<?php 
                }
                ?>

				</select>

				<?php 
                if (isset($styling['description'])) {
                    echo wp_kses_post($styling['description']);
                }
                ?>

			<?php 
                break;
            case 'font_select':
                $fonts = array_merge(themify_get_web_safe_font_list(), themify_get_google_web_fonts_list());
                ?>
				
				<select id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" class="tfb_lb_option <?php 
                echo esc_attr($styling['class']);
                ?>
">
					<?php 
                if (isset($styling['default'])) {
                    ?>
					<option value="<?php 
                    echo esc_attr($styling['default']);
                    ?>
"><?php 
                    echo esc_html($styling['default']);
                    ?>
</option>
					<?php 
                }
                foreach ($fonts as $option) {
                    ?>
					<option value="<?php 
                    echo esc_attr($option['value']);
                    ?>
"><?php 
                    echo esc_html($option['name']);
                    ?>
</option>
					<?php 
                }
                ?>

				</select>

				<?php 
                if (isset($styling['description'])) {
                    echo wp_kses_post($styling['description']);
                }
                ?>

			<?php 
                break;
            case 'color':
                ?>
				<span class="builderColorSelect"><span></span></span>
				<input type="text" class="<?php 
                echo esc_attr($styling['class']);
                ?>
 colordisplay"/>
				<input id="<?php 
                echo esc_attr($styling['id']);
                ?>
" name="<?php 
                echo esc_attr($styling['id']);
                ?>
" value="" class="builderColorSelectInput tfb_lb_option" type="hidden" />
			<?php 
                break;
            case 'checkbox':
                if (isset($styling['before'])) {
                    echo wp_kses_post($styling['before']);
                }
                ?>
				<div id="<?php 
                echo esc_attr($styling['id']);
                ?>
" class="tfb_lb_option themify-checkbox">
				<?php 
                foreach ($styling['options'] as $opt) {
                    ?>
					<?php 
                    $checkbox_checked = '';
                    if (isset($styling['default']) && is_array($styling['default'])) {
                        $checkbox_checked = in_array($opt['name'], $styling['default']) ? 'checked="checked"' : '';
                    } elseif (isset($styling['default'])) {
                        $checkbox_checked = checked($styling['default'], $opt['name'], false);
                    }
                    ?>
					<input id="<?php 
                    echo esc_attr($styling['id'] . '_' . $opt['name']);
                    ?>
" name="<?php 
                    echo esc_attr($styling['id']);
                    ?>
" type="checkbox" class="tfb_lb_option tf-checkbox" value="<?php 
                    echo esc_attr($opt['name']);
                    ?>
" <?php 
                    echo $checkbox_checked;
                    ?>
 />
					<label for="<?php 
                    echo esc_attr($styling['id'] . '_' . $opt['name']);
                    ?>
" class="pad-right"><?php 
                    echo wp_kses_post($opt['value']);
                    ?>
</label>
					
					<?php 
                    if (isset($opt['help'])) {
                        ?>
					<small><?php 
                        echo wp_kses_post($opt['help']);
                        ?>
</small>
					<?php 
                    }
                    ?>
					
					<?php 
                    if (!isset($styling['new_line']) || $styling['new_line'] == true) {
                        ?>
					<br />
					<?php 
                    }
                    ?>

				<?php 
                }
                ?>
				</div>
				<?php 
                if (isset($styling['after'])) {
                    echo wp_kses_post($styling['after']);
                }
                break;
            case 'radio':
                $option_js = isset($styling['option_js']) && $styling['option_js'] == true ? 'tf-option-checkbox-js' : '';
                $option_js_wrap = isset($styling['option_js']) && $styling['option_js'] == true ? 'tf-option-checkbox-enable' : '';
                ?>
				<div id="<?php 
                echo esc_attr($styling['id']);
                ?>
" class="tfb_lb_option tf-radio-input-container <?php 
                echo esc_attr($option_js_wrap);
                ?>
">
				<?php 
                foreach ($styling['meta'] as $option) {
                    $checked = isset($option['selected']) && $option['selected'] == true ? 'checked="checked"' : '';
                    $data_el = isset($styling['option_js']) && $styling['option_js'] == true ? 'data-selected="tf-group-element-' . $option['value'] . '"' : '';
                    ?>
					<input type="radio" id="<?php 
                    echo esc_attr($styling['id'] . '_' . $option['value']);
                    ?>
" name="<?php 
                    echo esc_attr($styling['id']);
                    ?>
" value="<?php 
                    echo esc_attr($option['value']);
                    ?>
" class="tfb_lb_option <?php 
                    echo esc_attr($option_js);
                    ?>
" <?php 
                    echo $checked . ' ' . $data_el;
                    ?>
> <label for="<?php 
                    echo esc_attr($styling['id'] . '_' . $option['value']);
                    ?>
"><?php 
                    echo esc_html($option['name']);
                    ?>
</label>
				<?php 
                }
                ?>
					<?php 
                if (isset($styling['description'])) {
                    echo '<br/><small>' . wp_kses_post($styling['description']) . '</small>';
                }
                ?>
				</div>
				<?php 
                break;
        }
    }
    /**
     * Print the field based on field type
     * @param array $field 
     */
    public static function print_field($field)
    {
        $field = wp_parse_args($field, array('id' => '', 'name' => '', 'class' => ''));
        switch ($field['type']) {
            case 'text':
                ?>
				<input id="<?php 
                echo esc_attr($field['id']);
                ?>
" name="<?php 
                echo esc_attr($field['id']);
                ?>
" type="text" value="" class="<?php 
                echo esc_attr($field['class']);
                ?>
 tfb_lb_option">
				<?php 
                if (isset($field['description'])) {
                    echo wp_kses_post($field['description']);
                }
                break;
            case 'separator':
                if (isset($field['meta']['html']) && '' != $field['meta']['html']) {
                    echo wp_kses_post($field['meta']['html']);
                } else {
                    ?>
					<hr class="meta_fields_separator" />
					<?php 
                }
                break;
            case 'image':
                ?>
				<input id="<?php 
                echo esc_attr($field['id']);
                ?>
" name="<?php 
                echo esc_attr($field['id']);
                ?>
" placeholder="<?php 
                if (isset($field['value'])) {
                    echo esc_attr($field['value']);
                }
                ?>
" class="<?php 
                echo esc_attr($field['class']);
                ?>
 themify-builder-uploader-input tfb_lb_option" type="text" /><br />
				<input type="hidden" name="<?php 
                echo esc_attr($field['id'] . '_attach_id');
                ?>
" class="themify-builder-uploader-input-attach-id" value="">
				<div class="small">

					<?php 
                if (is_multisite() && !is_upload_space_available()) {
                    ?>
						<?php 
                    echo sprintf(__('Sorry, you have filled your %s MB storage quota so uploading has been disabled.', 'themify'), get_space_allowed());
                    ?>
					<?php 
                } else {
                    ?>
					<div class="themify-builder-plupload-upload-uic hide-if-no-js tf-upload-btn" id="<?php 
                    echo esc_attr($field['id']);
                    ?>
themify-builder-plupload-upload-ui">
							<input id="<?php 
                    echo esc_attr($field['id']);
                    ?>
themify-builder-plupload-browse-button" type="button" value="<?php 
                    esc_attr_e(__('Upload', 'themify'));
                    ?>
" class="builder_button" />
							<span class="ajaxnonceplu" id="ajaxnonceplu<?php 
                    echo wp_create_nonce($field['id'] . 'themify-builder-plupload');
                    ?>
"></span>
					</div> <?php 
                    _e('or', 'themify');
                    ?>
 <a href="#" class="themify-builder-media-uploader tf-upload-btn" data-uploader-title="<?php 
                    esc_attr_e('Upload an Image', 'themify');
                    ?>
" data-uploader-button-text="<?php 
                    esc_attr_e('Insert file URL', 'themify');
                    ?>
"><?php 
                    _e('Browse Library', 'themify');
                    ?>
</a>

					<?php 
                }
                ?>

				</div>
				
				<p class="thumb_preview">
					<span class="img-placeholder"></span>
					<a href="#" class="themify_builder_icon small delete themify-builder-delete-thumb"></a>
				</p>

				<?php 
                break;
            case 'select':
                ?>
				
				<select id="<?php 
                echo esc_attr($field['id']);
                ?>
" name="<?php 
                echo esc_attr($field['id']);
                ?>
" class="tfb_lb_option <?php 
                echo esc_attr($field['class']);
                ?>
">
					<?php 
                if (isset($field['default'])) {
                    ?>
					<option value="<?php 
                    echo esc_attr($field['default']);
                    ?>
"><?php 
                    echo esc_html($field['default']);
                    ?>
</option>
					<?php 
                }
                foreach ($field['meta'] as $option) {
                    ?>
					<option value="<?php 
                    echo esc_attr($option['value']);
                    ?>
"><?php 
                    echo esc_html($option['name']);
                    ?>
</option>
					<?php 
                }
                ?>

				</select>

				<?php 
                if (isset($field['description'])) {
                    echo wp_kses_post($field['description']);
                }
                ?>

			<?php 
                break;
            case 'font_select':
                $fonts = array_merge(themify_get_web_safe_font_list(), themify_get_google_web_fonts_list());
                ?>
				
				<select id="<?php 
                echo esc_attr($field['id']);
                ?>
" name="<?php 
                echo esc_attr($field['id']);
                ?>
" class="tfb_lb_option <?php 
                echo esc_attr($field['class']);
                ?>
">
					<?php 
                if (isset($field['default'])) {
                    ?>
					<option value="<?php 
                    echo esc_attr($field['default']);
                    ?>
"><?php 
                    echo esc_html($field['default']);
                    ?>
</option>
					<?php 
                }
                foreach ($fonts as $option) {
                    ?>
					<option value="<?php 
                    echo esc_attr($option['value']);
                    ?>
"><?php 
                    echo esc_html($option['name']);
                    ?>
</option>
					<?php 
                }
                ?>

				</select>

				<?php 
                if (isset($field['description'])) {
                    echo wp_kses_post($field['description']);
                }
                ?>

			<?php 
                break;
            case 'color':
                ?>
				<span class="builderColorSelect"><span></span></span>
				<input type="text" class="<?php 
                echo esc_attr($field['class']);
                ?>
 colordisplay"/>
				<input id="<?php 
                echo esc_attr($field['id']);
                ?>
" name="<?php 
                echo esc_attr($field['id']);
                ?>
" value="" class="builderColorSelectInput tfb_lb_option" type="text" />
			<?php 
                break;
            case 'radio':
                foreach ($field['meta'] as $option) {
                    ?>
					<input type="radio" id="<?php 
                    echo esc_attr($field['id'] . '_' . $option['value']);
                    ?>
" name="<?php 
                    echo esc_attr($field['id']);
                    ?>
" value="<?php 
                    echo esc_attr($option['value']);
                    ?>
" class="tfb_lb_option" <?php 
                    checked(isset($option['selected']) ? $option['selected'] : false, true);
                    ?>
> <label for="<?php 
                    echo esc_attr($field['id'] . '_' . $option['value']);
                    ?>
"><?php 
                    echo esc_html($option['name']);
                    ?>
</label>
				<?php 
                }
                break;
            case 'textarea':
                if (!array_key_exists('rows', $field) || empty($field['rows'])) {
                    $field['rows'] = '3';
                }
                ?>
				<textarea id="<?php 
                echo esc_attr($field['id']);
                ?>
" name="<?php 
                echo esc_attr($field['id']);
                ?>
" class="<?php 
                echo esc_attr($field['class']);
                ?>
 tfb_lb_option" rows="<?php 
                echo esc_attr($field['rows']);
                ?>
"></textarea>
				<?php 
                if (isset($field['description'])) {
                    ?>
				<small>
					<br>
					<small>
						<?php 
                    echo wp_kses_post($field['description']);
                    ?>
					</small>
				</small>
				<?php 
                }
                break;
        }
    }
Пример #22
0
function et_handle_upload_prefilter($file)
{
    if (!is_multisite()) {
        return $file;
    }
    if (get_site_option('upload_space_check_disabled')) {
        return $file;
    }
    if ($file['error'] != '0') {
        // there's already an error
        return $file;
    }
    if (defined('WP_IMPORTING')) {
        return $file;
    }
    $space_allowed = 1048576 * get_space_allowed();
    $space_used = get_dirsize(BLOGUPLOADDIR);
    $space_left = $space_allowed - $space_used;
    $file_size = filesize($file['tmp_name']);
    if ($space_left < $file_size) {
        $file['error'] = sprintf(__('Not enough space to upload. %1$s KB needed.', ET_DOMAIN), number_format(($file_size - $space_left) / 1024));
    }
    if ($file_size > 1024 * get_site_option('fileupload_maxk', 1500)) {
        $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.', ET_DOMAIN), get_site_option('fileupload_maxk', 1500));
    }
    if (function_exists('upload_is_user_over_quota') && upload_is_user_over_quota(false)) {
        $file['error'] = __('You have used your space quota. Please delete files before uploading.', ET_DOMAIN);
    }
    // if ( $file['error'] != '0' && !isset($_POST['html-upload']) )
    // 	wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' );
    return $file;
}
Пример #23
0
function wp_dashboard_quota()
{
    if (!is_multisite() || !current_user_can('upload_files') || get_site_option('upload_space_check_disabled')) {
        return true;
    }
    $quota = get_space_allowed();
    $used = get_dirsize(BLOGUPLOADDIR) / 1024 / 1024;
    if ($used > $quota) {
        $percentused = '100';
    } else {
        $percentused = $used / $quota * 100;
    }
    $used_color = $percentused >= 70 ? ' spam' : '';
    $used = round($used, 2);
    $percentused = number_format($percentused);
    ?>
	<p class="sub musub"><?php 
    _e('Storage Space');
    ?>
</p>
	<div class="table table_content musubtable">
	<table>
		<tr class="first">
			<td class="first b b-posts"><?php 
    printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>'), esc_url(admin_url('upload.php')), $quota);
    ?>
</td>
			<td class="t posts"><?php 
    _e('Space Allowed');
    ?>
</td>
		</tr>
	</table>
	</div>
	<div class="table table_discussion musubtable">
	<table>
		<tr class="first">
			<td class="b b-comments"><?php 
    printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>'), esc_url(admin_url('upload.php')), $used, $percentused);
    ?>
</td>
			<td class="last t comments<?php 
    echo $used_color;
    ?>
"><?php 
    _e('Space Used');
    ?>
</td>
		</tr>
	</table>
	</div>
	<br class="clear" />
	<?php 
}
function anno_media_upload_form()
{
    if (!anno_current_user_can_edit()) {
        echo '<div style="text-align:center;">' . _x('You do not have proper permissions to upload a new image', 'Permissions warning for image uplaod', 'anno') . '</div>';
        return;
    }
    global $type, $tab, $pagenow;
    $flash_action_url = admin_url('async-upload.php');
    // If Mac and mod_security, no Flash. :(
    $flash = true;
    if (false !== stripos($_SERVER['HTTP_USER_AGENT'], 'mac') && apache_mod_loaded('mod_security')) {
        $flash = false;
    }
    $flash = apply_filters('flash_uploader', $flash);
    $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;
    $upload_size_unit = $max_upload_size = wp_max_upload_size();
    $sizes = array('KB', 'MB', 'GB');
    for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
        $upload_size_unit /= 1024;
    }
    if ($u < 0) {
        $upload_size_unit = 0;
        $u = 0;
    } else {
        $upload_size_unit = (int) $upload_size_unit;
    }
    ?>
	<script type="text/javascript">
	//<![CDATA[
	var uploaderMode = 0;
	jQuery(document).ready(function($){
		uploaderMode = getUserSetting('uploader');
		$('.upload-html-bypass a').click(function(){deleteUserSetting('uploader');uploaderMode=0;swfuploadPreLoad();return false;});
		$('.upload-flash-bypass a').click(function(){setUserSetting('uploader', '1');uploaderMode=1;swfuploadPreLoad();return false;});
	});
	//]]>
	</script>
	<div id="media-upload-notice">
	<?php 
    if (isset($errors['upload_notice'])) {
        ?>
		<?php 
        echo $errors['upload_notice'];
        ?>
	<?php 
    }
    ?>
	</div>
	<div id="media-upload-error">
	<?php 
    if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) {
        ?>
		<?php 
        echo $errors['upload_error']->get_error_message();
        ?>
	<?php 
    }
    ?>
	</div>
	<?php 
    // Check quota for this blog if multisite
    if (is_multisite() && !is_upload_space_available()) {
        echo '<p>' . sprintf(_x('Sorry, you have filled your storage quota (%s MB).', 'Media upload error text', 'anno'), get_space_allowed()) . '</p>';
        return;
    }
    do_action('pre-upload-ui');
    if ($flash) {
        // Set the post params, which SWFUpload will post back with the file, and pass
        // them through a filter.
        $post_params = array('post_id' => anno_get_post_id(), 'auth_cookie' => is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE], 'logged_in_cookie' => $_COOKIE[LOGGED_IN_COOKIE], '_wpnonce' => wp_create_nonce('media-form'), 'type' => $type, 'tab' => $tab, 'short' => '1', 'action' => 'tinymce_upload');
        $post_params = apply_filters('swfupload_post_params', $post_params);
        $p = array();
        foreach ($post_params as $param => $val) {
            $p[] = "\t\t'{$param}' : '{$val}'";
        }
        $post_params_str = implode(", \n", $p);
        // #8545. wmode=transparent cannot be used with SWFUpload
        if ('media-new.php' == $pagenow) {
            $upload_image_path = get_user_option('admin_color');
            if ('classic' != $upload_image_path) {
                $upload_image_path = 'fresh';
            }
            $upload_image_path = admin_url('images/upload-' . $upload_image_path . '.png?ver=20101205');
        } else {
            $upload_image_path = includes_url('images/upload.png?ver=20100531');
        }
        ?>
	<script type="text/javascript">
	//<![CDATA[
	var swfu;
	SWFUpload.onload = function() {
		var settings = {
				button_text: '<span class="button"><?php 
        _ex('Select Files', 'Media upload text', 'anno');
        ?>
<\/span>',
				button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 11px; text-shadow: 0 1px 0 #FFFFFF; color:#464646;}',
				button_height: "23",
				button_width: "132",
				button_text_top_padding: 3,
				button_image_url: '<?php 
        echo $upload_image_path;
        ?>
',
				button_placeholder_id: "flash-browse-button",
				upload_url : "<?php 
        echo esc_attr($flash_action_url);
        ?>
",
				flash_url : "<?php 
        echo includes_url('js/swfupload/swfupload.swf');
        ?>
",
				file_post_name: "async-upload",
				post_params : {
					<?php 
        echo $post_params_str;
        ?>
				},
				file_size_limit : "<?php 
        echo $max_upload_size;
        ?>
b",
				file_dialog_start_handler : fileDialogStart,
				file_queued_handler : annoFileQueued,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : <?php 
        echo apply_filters('swfupload_success_handler', 'uploadSuccess');
        ?>
,
				upload_complete_handler : uploadComplete,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				swfupload_pre_load_handler: swfuploadPreLoad,
				swfupload_load_failed_handler: swfuploadLoadFailed,
				custom_settings : {
					degraded_element_id : "html-upload-ui", // id of the element displayed when swfupload is unavailable
					swfupload_element_id : "flash-upload-ui" // id of the element displayed when swfupload is available
				},
				file_types : "*.jpg;*.gif;*.png;*.jpeg;*.bmp;",
				debug: false
			};
			swfu = new SWFUpload(settings);
	};
	//]]>
	</script>

	<div id="flash-upload-ui" class="tinymce-uploader hide-if-no-js">
	<?php 
        do_action('pre-flash-upload-ui');
        ?>
		<div>
		<?php 
        _ex('Choose files to upload', 'Media upload dialog', 'anno');
        ?>
		<div id="flash-browse-button"></div>
		<span><input id="cancel-upload" disabled="disabled" onclick="cancelUpload()" type="button" value="<?php 
        _ex('Cancel Upload', 'Media cancel button text', 'anno');
        ?>
" class="button" /></span>
		</div>
	<?php 
        do_action('post-plupload-upload-ui');
        ?>
	</div>
	<?php 
    }
    // $flash
    ?>

	<div id="html-upload-ui" class="tinymce-uploader<?php 
    if ($flash) {
        echo ' hide-if-js';
    }
    ?>
">
	<?php 
    do_action('pre-html-upload-ui');
    ?>
		<p id="async-upload-wrap">
			<label class="screen-reader-text" for="async-upload"><?php 
    _ex('Upload', 'Media upload text', 'anno');
    ?>
</label>
			<input type="file" name="async-upload" id="async-upload" accept="image/gif, image/jpeg, image/jpg, image/png" />
			<?php 
    submit_button(_x('Upload', 'Media upload text', 'anno'), 'button', 'html-upload', false);
    ?>
		</p>
		<div class="clear"></div>
		<?php 
    if (is_lighttpd_before_150()) {
        ?>
		<p><?php 
        _ex('If you want to use all capabilities of the uploader, like uploading multiple files at once, please update to lighttpd 1.5.', 'Media upload error text', 'anno');
        ?>
</p>
		<?php 
    }
    ?>
	<?php 
    do_action('post-html-upload-ui', $flash);
    ?>
	</div>
	<?php 
    do_action('post-upload-ui');
    ?>
	<?php 
}
Пример #25
0
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $errors
 */
function media_upload_form( $errors = null ) {
	global $type, $tab;

	$flash_action_url = admin_url('async-upload.php');

	// If Mac and mod_security, no Flash. :(
	$flash = true;
	if ( false !== stripos($_SERVER['HTTP_USER_AGENT'], 'mac') && apache_mod_loaded('mod_security') )
		$flash = false;

	$flash = apply_filters('flash_uploader', $flash);
	$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0;

	$upload_size_unit = $max_upload_size =  wp_max_upload_size();
	$sizes = array( 'KB', 'MB', 'GB' );
	for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ )
		$upload_size_unit /= 1024;
	if ( $u < 0 ) {
		$upload_size_unit = 0;
		$u = 0;
	} else {
		$upload_size_unit = (int) $upload_size_unit;
	}
?>
<script type="text/javascript">
//<![CDATA[
var uploaderMode = 0;
jQuery(document).ready(function($){
	uploaderMode = getUserSetting('uploader');
	$('.upload-html-bypass a').click(function(){deleteUserSetting('uploader');uploaderMode=0;swfuploadPreLoad();return false;});
	$('.upload-flash-bypass a').click(function(){setUserSetting('uploader', '1');uploaderMode=1;swfuploadPreLoad();return false;});
});
//]]>
</script>
<div id="media-upload-notice">
<?php if (isset($errors['upload_notice']) ) { ?>
	<?php echo $errors['upload_notice']; ?>
<?php } ?>
</div>
<div id="media-upload-error">
<?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?>
	<?php echo $errors['upload_error']->get_error_message(); ?>
<?php } ?>
</div>
<?php
// Check quota for this blog if multisite
if ( is_multisite() && !is_upload_space_available() ) {
	echo '<p>' . sprintf( __( 'Sorry, you have filled your storage quota (%s MB).' ), get_space_allowed() ) . '</p>';
	return;
}

do_action('pre-upload-ui');

if ( $flash ) : ?>
<script type="text/javascript">
//<![CDATA[
var swfu;
SWFUpload.onload = function() {
	var settings = {
			button_text: '<span class="button"><?php _e('Select Files'); ?><\/span>',
			button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size: 11px; text-shadow: 0 1px 0 #FFFFFF; color:#464646; }',
			button_height: "23",
			button_width: "132",
			button_text_top_padding: 3,
			button_image_url: '<?php echo includes_url('images/upload.png?ver=20100531'); ?>',
			button_placeholder_id: "flash-browse-button",
			upload_url : "<?php echo esc_attr( $flash_action_url ); ?>",
			flash_url : "<?php echo includes_url('js/swfupload/swfupload.swf'); ?>",
			file_post_name: "async-upload",
			file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",
			post_params : {
				"post_id" : "<?php echo $post_id; ?>",
				"auth_cookie" : "<?php echo (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]); ?>",
				"logged_in_cookie": "<?php echo $_COOKIE[LOGGED_IN_COOKIE]; ?>",
				"_wpnonce" : "<?php echo wp_create_nonce('media-form'); ?>",
				"type" : "<?php echo $type; ?>",
				"tab" : "<?php echo $tab; ?>",
				"short" : "1"
			},
			file_size_limit : "<?php echo $max_upload_size; ?>b",
			file_dialog_start_handler : fileDialogStart,
			file_queued_handler : fileQueued,
			upload_start_handler : uploadStart,
			upload_progress_handler : uploadProgress,
			upload_error_handler : uploadError,
			upload_success_handler : uploadSuccess,
			upload_complete_handler : uploadComplete,
			file_queue_error_handler : fileQueueError,
			file_dialog_complete_handler : fileDialogComplete,
			swfupload_pre_load_handler: swfuploadPreLoad,
			swfupload_load_failed_handler: swfuploadLoadFailed,
			custom_settings : {
				degraded_element_id : "html-upload-ui", // id of the element displayed when swfupload is unavailable
				swfupload_element_id : "flash-upload-ui" // id of the element displayed when swfupload is available
			},
			debug: false
		};
		swfu = new SWFUpload(settings);
};
//]]>
</script>

<div id="flash-upload-ui" class="hide-if-no-js">
<?php do_action('pre-flash-upload-ui'); ?>

	<div>
	<?php _e( 'Choose files to upload' ); ?>
	<div id="flash-browse-button"></div>
	<span><input id="cancel-upload" disabled="disabled" onclick="cancelUpload()" type="button" value="<?php esc_attr_e('Cancel Upload'); ?>" class="button" /></span>
	</div>
	<p class="media-upload-size"><?php printf( __( 'Maximum upload file size: %d%s' ), $upload_size_unit, $sizes[$u] ); ?></p>
<?php do_action('post-flash-upload-ui'); ?>
	<p class="howto"><?php _e('After a file has been uploaded, you can add titles and descriptions.'); ?></p>
</div>
<?php endif; // $flash ?>

<div id="html-upload-ui">
<?php do_action('pre-html-upload-ui'); ?>
	<p id="async-upload-wrap">
	<label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label>
	<input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php esc_attr_e('Upload'); ?>" /> <a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?></a>
	</p>
	<div class="clear"></div>
	<p class="media-upload-size"><?php printf( __( 'Maximum upload file size: %d%s' ), $upload_size_unit, $sizes[$u] ); ?></p>
	<?php if ( is_lighttpd_before_150() ): ?>
	<p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p>
	<?php endif;?>
<?php do_action('post-html-upload-ui', $flash); ?>
</div>
<?php do_action('post-upload-ui'); ?>
<?php
}
Пример #26
0
function wpmu_checkAvailableSpace()
{
    $spaceAllowed = get_space_allowed();
    $dirName = trailingslashit(BLOGUPLOADDIR);
    if (!(is_dir($dirName) && is_readable($dirName))) {
        return;
    }
    $dir = dir($dirName);
    $size = 0;
    while ($file = $dir->read()) {
        if ($file != '.' && $file != '..') {
            if (is_dir($dirName . $file)) {
                $size += get_dirsize($dirName . $file);
            } else {
                $size += filesize($dirName . $file);
            }
        }
    }
    $dir->close();
    $size = $size / 1024 / 1024;
    if ($spaceAllowed - $size <= 0) {
        define('DISABLE_UPLOADS', true);
        define('DISABLE_UPLOADS_MESSAGE', __('Sorry, you must delete files before you can upload any more.'));
    }
}
Пример #27
0
/**
 * Displays the out of storage quota message in Multisite.
 *
 * @since 3.5.0
 */
function multisite_over_quota_message()
{
    echo '<p>' . sprintf(__('Sorry, you have used all of your storage quota of %s MB.'), get_space_allowed()) . '</p>';
}
Пример #28
0
 function evc_fetch_remote_file($args)
 {
     if (!empty($args)) {
         extract($args);
     }
     //$post_date = date('Y-m-d H:i:s');
     $upload = wp_upload_dir();
     $upload = wp_upload_bits($file_name, 0, '');
     if ($upload['error']) {
         return new WP_Error('upload_dir_error', $upload['error']);
     }
     $headers = wp_get_http($url, $upload['file']);
     if (!$headers) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', __('Remote server did not respond', 'evc'));
     }
     if ($headers['response'] != '200') {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', sprintf(__('Remote server says: %1$d %2$s', 'evc'), $headers['response'], get_status_header_desc($headers['response'])));
     } elseif (isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length']) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', __('Remote file is incorrect size', 'evc'));
     }
     $max_size = (int) get_site_option('fileupload_maxk') * 1024;
     // fileupload_maxk for wpmu compatibility
     $file_size = filesize($upload['file']);
     if (!empty($max_size) && $file_size > $max_size) {
         @unlink($upload['file']);
         return new WP_Error('import_file_error', sprintf(__('Remote file is %1$d KB but limit is %2$d', 'evc'), $file_size / 1024, $max_size / 1024));
     }
     // This check is for wpmu compatibility
     if (function_exists('get_space_allowed')) {
         $space_allowed = 1048576 * get_space_allowed();
         $space_used = get_dirsize(BLOGUPLOADDIR);
         $space_left = $space_allowed - $space_used;
         if ($space_left < 0) {
             @unlink($upload['file']);
             return new WP_Error('not_enough_diskspace', sprintf(__('You have %1$d KB diskspace used but %2$d allowed.', 'evc'), $space_used / 1024, $space_allowed / 1024));
         }
     }
     $upload['content-type'] = $headers['content-type'];
     return $upload;
 }
Пример #29
0
/**
 * Get the remaining upload space for this blog.
 *
 * @since MU
 * @uses upload_is_user_over_quota()
 * @uses get_space_allowed()
 * @uses get_dirsize()
 *
 * @param int $size
 * @return int
 */
function fix_import_form_size($size)
{
    if (upload_is_user_over_quota(false) == true) {
        return 0;
    }
    $spaceAllowed = 1024 * 1024 * get_space_allowed();
    $dirName = BLOGUPLOADDIR;
    $dirsize = get_dirsize($dirName);
    if ($size > $spaceAllowed - $dirsize) {
        return $spaceAllowed - $dirsize;
    } else {
        return $size;
    }
    // default
}
Пример #30
0
function ngg_dashboard_quota()
{
    if (get_site_option('upload_space_check_disabled')) {
        return;
    }
    if (!wpmu_enable_function('wpmuQuotaCheck')) {
        return;
    }
    $quota = get_space_allowed();
    $used = get_dirsize(BLOGUPLOADDIR) / 1024 / 1024;
    if ($used > $quota) {
        $percentused = '100';
    } else {
        $percentused = $used / $quota * 100;
    }
    $used_color = $percentused < 70 ? $percentused >= 40 ? 'waiting' : 'approved' : 'spam';
    $used = round($used, 2);
    $percentused = number_format($percentused);
    ?>
	<p class="sub musub" style="position:static" ><?php 
    _e('Storage Space');
    ?>
</p>
	<div class="table table_content musubtable">
	<table>
		<tr class="first">
			<td class="first b b-posts"><?php 
    printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB</a>'), esc_url(admin_url('admin.php?page=nggallery-manage-gallery')), $quota);
    ?>
</td>
			<td class="t posts"><?php 
    _e('Space Allowed');
    ?>
</td>
		</tr>
	</table>
	</div>
	<div class="table table_discussion musubtable">
	<table>
		<tr class="first">
			<td class="b b-comments"><?php 
    printf(__('<a href="%1$s" title="Manage Uploads" class="musublink">%2$sMB (%3$s%%)</a>'), esc_url(admin_url('admin.php?page=nggallery-manage-gallery')), $used, $percentused);
    ?>
</td>
			<td class="last t comments <?php 
    echo $used_color;
    ?>
"><?php 
    _e('Space Used');
    ?>
</td>
		</tr>
	</table>
	</div>
	<br class="clear" />
	<?php 
}