Oldal: 19 / 24 ElsőElső ... 91718192021 ... UtolsóUtolsó
Eredmény: 181 - 190 (231) összesen

Téma: php segítség kellene

  1. #181
    Rubyist Geri logója
    Csatlakozott
    07-12-15
    Hely
    \x90
    Hozzászólás
    5.749
    Begyűjtött 1.432 köszönetet
    895 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Idézet apacska eredeti hozzászólása Hozzászólás megtekintése
    Regexel megnézed, hogy http-vel vagy https-el kezdődik.
    ^(https)://
    A domain nem kezdodik ezek kozul egyikkel se



  2. #182
    Új tag
    Csatlakozott
    10-05-12
    Hely
    Ajka
    Hozzászólás
    18
    Begyűjtött 0 köszönetet
    0 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Sziasztok!

    Joomla 3 K2 üres blokk megjelenítésében kérném a segítségeteket!

    A K2 kategória nézet megjeleníti az üres blokkokat is, így megnyújtja a sablonnézetet. Én a kategória leírását nem szeretném megjeleníteni, de az üres blokk ott van a lap tetején. (/components/com_k2/templates/default/default.php)

    Az rss blokk kód módosításával ez a blokk eltűnt.
    eredeti:
    HTML kód:
    <!-- RSS feed icon -->
    	<?php if($this->params->get('catFeedIcon')): ?>
    	<div class="k2FeedIcon">
    
    	stb..
    módosítva:
    HTML kód:
    <!-- RSS feed icon -->
    	<?php if($this->params->get('show_catFeedIcon')): ?>
    	<div class="k2FeedIcon">
    
    	stb..
    Viszont ezt a blokkot nem tudom hogyan kellene módosítani, hogy ha üres ne jelenjen meg:
    HTML kód:
    <!-- Category block -->
    	<?php if(isset($this->category) && ( $this->params->get('catImage') || $this->params->get('catTitle') || $this->params->get('catDescription') || $this->category->event->K2CategoryDisplay )): ?>	
    	<div class="itemListCategory">
    
    	stb..
    Tud valaki segíteni? Köszönöm!



  3. #183
    Bölcs Pityu logója
    Csatlakozott
    08-07-04
    Hely
    Budapest
    Hozzászólás
    1.561
    Begyűjtött 448 köszönetet
    328 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Van egy WP pluginom, amivel a felhasználók tölthetnek fel avatarokat maguknak. A plugin a feltöltött képből egy kis bélyegképet készít, ami nagyon jó. Viszont a feltöltött fájl méretét nem vizsgálja, így bárki akár 50 MB-os képet is tölthet fel, amit nem szeretnék. Tudna valaki segíteni, hogy milyen kódot kell még beletennem, hogy a userek max 0.5 megás képfájlokat tudjanak feltölteni?

    Köszönöm előre is, alább a kódrészletem:

    PHP kód:
    public function get_avatar$avatar ''$id_or_email$size 96$default ''$alt false ) {

            
    // Determine if we recive an ID or string
            
    if ( is_numeric$id_or_email ) )
                
    $user_id = (int) $id_or_email;
            elseif ( 
    is_string$id_or_email ) && ( $user get_user_by'email'$id_or_email ) ) )
                
    $user_id $user->ID;
            elseif ( 
    is_object$id_or_email ) && ! empty( $id_or_email->user_id ) )
                
    $user_id = (int) $id_or_email->user_id;

            if ( empty( 
    $user_id ) )
                return 
    $avatar;

            
    $local_avatars get_user_meta$user_id'basic_user_avatar'true );

            if ( empty( 
    $local_avatars ) || empty( $local_avatars['full'] ) )
                return 
    $avatar;

            
    $size = (int) $size;

            if ( empty( 
    $alt ) )
                
    $alt get_the_author_meta'display_name'$user_id );

            
    // Generate a new size
            
    if ( empty( $local_avatars[$size] ) ) {

                
    $upload_path      wp_upload_dir();
                
    $avatar_full_path str_replace$upload_path['baseurl'], $upload_path['basedir'], $local_avatars['full'] );
                
    $image            wp_get_image_editor$avatar_full_path );

                if ( ! 
    is_wp_error$image ) ) {
                    
    $image->resize$size$sizetrue );
                    
    $image_sized $image->save();
                }

                
    // Deal with original being >= to original image (or lack of sizing ability)
                
    $local_avatars[$size] = is_wp_error$image_sized ) ? $local_avatars[$size] = $local_avatars['full'] : str_replace$upload_path['basedir'], $upload_path['baseurl'], $image_sized['path'] );

                
    // Save updated avatar sizes
                
    update_user_meta$user_id'basic_user_avatar'$local_avatars );

            } elseif ( 
    substr$local_avatars[$size], 0) != 'http' ) {
                
    $local_avatars[$size] = home_url$local_avatars[$size] );
            }

            
    $author_class is_author$user_id ) ? ' current-author' '' ;
            
    $avatar       "<img alt='" esc_attr$alt ) . "' src='" $local_avatars[$size] . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";

            return 
    apply_filters'basic_user_avatar'$avatar );
        } 




  4. #184
    Törzsvendég
    Csatlakozott
    14-08-02
    Hozzászólás
    145
    Begyűjtött 2 köszönetet
    2 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Idézet Pityu eredeti hozzászólása Hozzászólás megtekintése
    Van egy WP pluginom, amivel a felhasználók tölthetnek fel avatarokat maguknak. A plugin a feltöltött képből egy kis bélyegképet készít, ami nagyon jó. Viszont a feltöltött fájl méretét nem vizsgálja, így bárki akár 50 MB-os képet is tölthet fel, amit nem szeretnék. Tudna valaki segíteni, hogy milyen kódot kell még beletennem, hogy a userek max 0.5 megás képfájlokat tudjanak feltölteni?
    Én ezt szoktam használni:

    PHP kód:
    <?php
    if($_FILES['photo']['size'] > 512000) { //512000B = 0.5MB
      //Hiba
    } else {
      
    //Feltöltés
    }




  5. #185
    Bölcs Pityu logója
    Csatlakozott
    08-07-04
    Hely
    Budapest
    Hozzászólás
    1.561
    Begyűjtött 448 köszönetet
    328 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Igem, köszi, ezt megtaláltam én is, csak nem sikerül a fenti kódrészletembe beleaplikálni

    Idézet Norbii eredeti hozzászólása Hozzászólás megtekintése
    Én ezt szoktam használni:

    PHP kód:
    <?php
    if($_FILES['photo']['size'] > 512000) { //512000B = 0.5MB
      //Hiba
    } else {
      
    //Feltöltés
    }




  6. #186
    Rubyist Geri logója
    Csatlakozott
    07-12-15
    Hely
    \x90
    Hozzászólás
    5.749
    Begyűjtött 1.432 köszönetet
    895 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Idézet Pityu eredeti hozzászólása Hozzászólás megtekintése
    Igem, köszi, ezt megtaláltam én is, csak nem sikerül a fenti kódrészletembe beleaplikálni
    A fenti kodresz nem tartalmazza a fajlfeltotest.



  7. #187
    Bölcs Pityu logója
    Csatlakozott
    08-07-04
    Hely
    Budapest
    Hozzászólás
    1.561
    Begyűjtött 448 köszönetet
    328 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Bocs, bemásolom az egész fájlt, az lesz a legjobb...

    PHP kód:
    <?php

    class basic_user_avatars {

        
    /**
         * User ID
         *
         * @since 1.0.0
         * @var int
         */
        
    private $user_id_being_edited;

        
    /**
         * Initialize all the things
         *
         * @since 1.0.0
         */
        
    public function __construct() {

            
    // Text domain
            
    $this->load_textdomain();

            
    // Actions
            
    add_action'admin_init',                array( $this'admin_init'               )        );
            
    add_action'show_user_profile',         array( $this'edit_user_profile'        )        );
            
    add_action'edit_user_profile',         array( $this'edit_user_profile'        )        );
            
    add_action'personal_options_update',   array( $this'edit_user_profile_update' )        );
            
    add_action'edit_user_profile_update',  array( $this'edit_user_profile_update' )        );
            
    add_action'bbp_user_edit_after_about', array( $this'bbpress_user_profile'     )        );

            
    // Shortcode
            
    add_shortcode'basic-user-avatars',     array( $this'shortcode'                )        );

            
    // Filters
            
    add_filter'get_avatar',                array( $this'get_avatar'               ), 10);
            
    add_filter'avatar_defaults',           array( $this'avatar_defaults'          )        );
        }

        
    /**
         * Loads the plugin language files.
         *
         * @since 1.0.1
         */
        
    public function load_textdomain() {
            
    $domain 'basic-user-avatars';
            
    $locale apply_filters'plugin_locale'get_locale(), $domain );
            
    load_textdomain$domainWP_LANG_DIR '/' $domain '/' $domain '-' $locale '.mo' );
            
    load_plugin_textdomain$domainfalsedirnameplugin_basename__FILE__ ) ) . '/languages/' );
        }

        
    /**
         * Start the admin engine.
         *
         * @since 1.0.0
         */
        
    public function admin_init() {

            
    // Register/add the Discussion setting to restrict avatar upload capabilites
            
    register_setting'discussion''basic_user_avatars_caps', array( $this'sanitize_options' ) );
            
    add_settings_field'basic-user-avatars-caps'__'Local Avatar Permissions''basic-user-avatars' ), array( $this'avatar_settings_field' ), 'discussion''avatars' );
        }

        
    /**
         * Discussion settings option
         *
         * @since 1.0.0
         * @param array $args [description]
         */
        
    public function avatar_settings_field$args ) {
            
    $options get_option'basic_user_avatars_caps' );
            
    ?>
            <label for="basic_user_avatars_caps">
                <input type="checkbox" name="basic_user_avatars_caps" id="basic_user_avatars_caps" value="1" <?php checked$options['basic_user_avatars_caps'], ); ?>/>
                <?php _e'Only allow users with file upload capabilities to upload local avatars (Authors and above)''basic-user-avatars' ); ?>
            </label>
            <?php
        
    }

        
    /**
         * Sanitize the Discussion settings option
         *
         * @since 1.0.0
         * @param array $input
         * @return array
         */
        
    public function sanitize_options$input ) {
            
    $new_input['basic_user_avatars_caps'] = empty( $input['basic_user_avatars_caps'] ) ? 1;
            return 
    $new_input;
        }

        
    /**
         * Filter the avatar WordPress returns
         *
         * @since 1.0.0
         * @param string $avatar 
         * @param int/string/object $id_or_email
         * @param int $size 
         * @param string $default
         * @param boolean $alt 
         * @return string
         */
        
    public function get_avatar$avatar ''$id_or_email$size 96$default ''$alt false ) {

            
    // Determine if we recive an ID or string
            
    if ( is_numeric$id_or_email ) )
                
    $user_id = (int) $id_or_email;
            elseif ( 
    is_string$id_or_email ) && ( $user get_user_by'email'$id_or_email ) ) )
                
    $user_id $user->ID;
            elseif ( 
    is_object$id_or_email ) && ! empty( $id_or_email->user_id ) )
                
    $user_id = (int) $id_or_email->user_id;

            if ( empty( 
    $user_id ) )
                return 
    $avatar;

            
    $local_avatars get_user_meta$user_id'basic_user_avatar'true );

            if ( empty( 
    $local_avatars ) || empty( $local_avatars['full'] ) )
                return 
    $avatar;

            
    $size = (int) $size;

            if ( empty( 
    $alt ) )
                
    $alt get_the_author_meta'display_name'$user_id );

            
    // Generate a new size
            
    if ( empty( $local_avatars[$size] ) ) {

                
    $upload_path      wp_upload_dir();
                
    $avatar_full_path str_replace$upload_path['baseurl'], $upload_path['basedir'], $local_avatars['full'] );
                
    $image            wp_get_image_editor$avatar_full_path );

                if ( ! 
    is_wp_error$image ) ) {
                    
    $image->resize$size$sizetrue );
                    
    $image_sized $image->save();
                }

                
    // Deal with original being >= to original image (or lack of sizing ability)
                
    $local_avatars[$size] = is_wp_error$image_sized ) ? $local_avatars[$size] = $local_avatars['full'] : str_replace$upload_path['basedir'], $upload_path['baseurl'], $image_sized['path'] );

                
    // Save updated avatar sizes
                
    update_user_meta$user_id'basic_user_avatar'$local_avatars );

            } elseif ( 
    substr$local_avatars[$size], 0) != 'http' ) {
                
    $local_avatars[$size] = home_url$local_avatars[$size] );
            }

            
    $author_class is_author$user_id ) ? ' current-author' '' ;
            
    $avatar       "<img alt='" esc_attr$alt ) . "' src='" $local_avatars[$size] . "' class='avatar avatar-{$size}{$author_class} photo' height='{$size}' width='{$size}' />";

            return 
    apply_filters'basic_user_avatar'$avatar );
        }

        
    /**
         * Form to display on the user profile edit screen
         *
         * @since 1.0.0
         * @param object $profileuser
         * @return
         */
        
    public function edit_user_profile$profileuser ) {

            
    // bbPress will try to auto-add this to user profiles - don't let it.
            // Instead we hook our own proper function that displays cleaner.
            
    if ( function_exists'is_bbpress') && is_bbpress() )
                return;
            
    ?>

            <h3><?php _e'Avatar''basic-user-avatars' ); ?></h3>
            <table class="form-table">
                <tr>
                    <th><label for="basic-user-avatar"><?php _e'Upload Avatar''basic-user-avatars' ); ?></label></th>
                    <td style="width: 50px;" valign="top">
                        <?php echo get_avatar$profileuser->ID ); ?>
                    </td>
                    
                    <td>
                    <?php
                    $options 
    get_option'basic_user_avatars_caps' );
                    if ( empty( 
    $options['basic_user_avatars_caps'] ) || current_user_can'upload_files' ) ) {
                        
    // Nonce security ftw
                        
    wp_nonce_field'basic_user_avatar_nonce''_basic_user_avatar_nonce'false );
                        
                        
    // File upload input
                        
    echo '<input type="file" name="basic-user-avatar" id="basic-local-avatar" /><br />';

                        if ( empty( 
    $profileuser->basic_user_avatar ) ) {
                            echo 
    '<span class="description">' __'No local avatar is set. Use the upload field to add a local avatar.''basic-user-avatars' ) . '</span>';
                        } else {
                            echo 
    '<input type="checkbox" name="basic-user-avatar-erase" value="1" /> ' __'Delete local avatar''basic-user-avatars' ) . '<br />';
                            echo 
    '<span class="description">' __'Replace the local avatar by uploading a new avatar, or erase the local avatar (falling back to a gravatar) by checking the delete option.''basic-user-avatars' ) . '</span>';
                        }

                    } else {
                        if ( empty( 
    $profileuser->basic_user_avatar ) ) {
                            echo 
    '<span class="description">' __'No local avatar is set. Set up your avatar at Gravatar.com.''basic-user-avatars' ) . '</span>';
                        } else {
                            echo 
    '<span class="description">' __'You do not have media management permissions. To change your local avatar, contact the site administrator.''basic-user-avatars' ) . '</span>';
                        }    
                    }
                    
    ?>
                    </td>
                </tr>
            </table>
            <script type="text/javascript">var form = document.getElementById('your-profile');form.encoding = 'multipart/form-data';form.setAttribute('enctype', 'multipart/form-data');</script>
            <?php
        
    }

        
    /**
         * Update the user's avatar setting
         *
         * @since 1.0.0
         * @param int $user_id
         */
        
    public function edit_user_profile_update$user_id ) {

            
    // Check for nonce otherwise bail
            
    if ( ! isset( $_POST['_basic_user_avatar_nonce'] ) || ! wp_verify_nonce$_POST['_basic_user_avatar_nonce'], 'basic_user_avatar_nonce' ) )
                return;

            if ( ! empty( 
    $_FILES['basic-user-avatar']['name'] ) ) {

                
    // Allowed file extensions/types
                
    $mimes = array(
                    
    'jpg|jpeg|jpe' => 'image/jpeg',
                    
    'gif'          => 'image/gif',
                    
    'png'          => 'image/png',
                );

                
    // Front end support - shortcode, bbPress, etc
                
    if ( ! function_exists'wp_handle_upload' ) )
                    require_once 
    ABSPATH 'wp-admin/includes/file.php';

                
    // Delete old images if successful
                
    $this->avatar_delete$user_id );

                
    // Need to be more secure since low privelege users can upload
                
    if ( strstr$_FILES['basic-user-avatar']['name'], '.php' ) )
                    
    wp_die'For security reasons, the extension ".php" cannot be in your file name.' );

                
    // Make user_id known to unique_filename_callback function
                
    $this->user_id_being_edited $user_id
                
    $avatar wp_handle_upload$_FILES['basic-user-avatar'], array( 'mimes' => $mimes'test_form' => false'unique_filename_callback' => array( $this'unique_filename_callback' ) ) );

                
    // Handle failures
                
    if ( empty( $avatar['file'] ) ) {  
                    switch ( 
    $avatar['error'] ) {
                    case 
    'File type does not meet security guidelines. Try another.' :
                        
    add_action'user_profile_update_errors'create_function'$a''$a->add("avatar_error",__("Please upload a valid image file for the avatar.","basic-user-avatars"));' ) );
                        break;
                    default :
                        
    add_action'user_profile_update_errors'create_function'$a''$a->add("avatar_error","<strong>".__("There was an error uploading the avatar:","basic-user-avatars")."</strong> ' esc_attr$avatar['error'] ) . '");' ) );
                    }
                    return;
                }

                
    // Save user information (overwriting previous)
                
    update_user_meta$user_id'basic_user_avatar', array( 'full' => $avatar['url'] ) );

            } elseif ( ! empty( 
    $_POST['basic-user-avatar-erase'] ) ) {
                
    // Nuke the current avatar
                
    $this->avatar_delete$user_id );
            }
        }

        
    /**
         * Enable avatar management on the frontend via this shortocde.
         *
         * @since 1.0.0
         */
        
    function shortcode() {

            
    // Don't bother if the user isn't logged in
            
    if ( ! is_user_logged_in() )
                return;

            
    $user_id     get_current_user_id();
            
    $profileuser get_userdata$user_id );

            if ( isset( 
    $_POST['manage_avatar_submit'] ) ){
                
    $this->edit_user_profile_update$user_id );
            }

            
    ob_start();
            
    ?>
            <form id="basic-user-avatar-form" action="<?php the_permalink(); ?>" method="post" enctype="multipart/form-data">
                <?php
                
    echo get_avatar$profileuser->ID );

                
    $options get_option'basic_user_avatars_caps' );
                if ( empty( 
    $options['basic_user_avatars_caps'] ) || current_user_can'upload_files' ) ) {
                    
    // Nonce security ftw
                    
    wp_nonce_field'basic_user_avatar_nonce''_basic_user_avatar_nonce'false );
                    
                    
    // File upload input
                    
    echo '<p><br><input type="file" name="basic-user-avatar" id="basic-local-avatar" /></p>';
                    

                    if ( empty( 
    $profileuser->basic_user_avatar ) ) {
                        echo 
    '<p class="description">' __'No local avatar is set. Use the upload field to add a local avatar.''basic-user-avatars' ) . '</p>';
                    } else {
                        echo 
    '<input type="checkbox" name="basic-user-avatar-erase" value="1" /> ' __'Delete local avatar''basic-user-avatars' ) . '<br />';
                        echo 
    '<p class="description">' __'Replace the local avatar by uploading a new avatar, or erase the local avatar (falling back to a gravatar) by checking the delete option.''basic-user-avatars' ) . '</p>';
                    }

                } else {
                    if ( empty( 
    $profileuser->basic_user_avatar ) ) {
                        echo 
    '<p class="description">' __'No local avatar is set. Set up your avatar at Gravatar.com.''basic-user-avatars' ) . '</p>';
                    } else {
                        echo 
    '<p class="description">' __'You do not have media management permissions. To change your local avatar, contact the site administrator.''basic-user-avatars' ) . '</p>';
                    }    
                }
                
    ?>
                <input type="submit" name="manage_avatar_submit" value="<?php _e'Update Avatar''basic-user-avatars' ); ?>" />
            </form>
            <?php
            
    return ob_get_clean();
        }

        
    /**
         * Form to display on the bbPress user profile edit screen
         *
         * @since 1.0.0
         */
        
    public function bbpress_user_profile() {

            if ( !
    bbp_is_user_home_edit() )
                return;

            
    $user_id     get_current_user_id();
            
    $profileuser get_userdata$user_id );

            echo 
    '<div>';
                echo 
    '<label for="basic-local-avatar">' __'Avatar''basic-user-avatars' ) . '</label>';
                 echo 
    '<fieldset class="bbp-form avatar">';

                     echo 
    get_avatar$profileuser->ID );
                    
    $options get_option'basic_user_avatars_caps' );
                    if ( empty( 
    $options['basic_user_avatars_caps'] ) || current_user_can'upload_files' ) ) {
                        
    // Nonce security ftw
                        
    wp_nonce_field'basic_user_avatar_nonce''_basic_user_avatar_nonce'false );
                        
                        
    // File upload input
                        
    echo '<br /><input type="file" name="basic-user-avatar" id="basic-local-avatar" /><br />';

                        if ( empty( 
    $profileuser->basic_user_avatar ) ) {
                            echo 
    '<span class="description" style="margin-left:0;">' __'No local avatar is set. Use the upload field to add a local avatar.''basic-user-avatars' ) . '</span>';
                        } else {
                            echo 
    '<input type="checkbox" name="basic-user-avatar-erase" value="1" style="width:auto" /> ' __'Delete local avatar''basic-user-avatars' ) . '<br />';
                            echo 
    '<span class="description" style="margin-left:0;">' __'Replace the local avatar by uploading a new avatar, or erase the local avatar (falling back to a gravatar) by checking the delete option.''basic-user-avatars' ) . '</span>';
                        }

                    } else {
                        if ( empty( 
    $profileuser->basic_user_avatar ) ) {
                            echo 
    '<span class="description" style="margin-left:0;">' __'No local avatar is set. Set up your avatar at Gravatar.com.''basic-user-avatars' ) . '</span>';
                        } else {
                            echo 
    '<span class="description" style="margin-left:0;">' __'You do not have media management permissions. To change your local avatar, contact the site administrator.''basic-user-avatars' ) . '</span>';
                        }    
                    }

                echo 
    '</fieldset>';
            echo 
    '</div>';
            
    ?>
            <script type="text/javascript">var form = document.getElementById('bbp-your-profile');form.encoding = 'multipart/form-data';form.setAttribute('enctype', 'multipart/form-data');</script>
            <?php
        
    }

        
    /**
         * Remove the custom get_avatar hook for the default avatar list output on 
         * the Discussion Settings page.
         *
         * @since 1.0.0
         * @param array $avatar_defaults
         * @return array
         */
        
    public function avatar_defaults$avatar_defaults ) {
            
    remove_action'get_avatar', array( $this'get_avatar' ) );
            return 
    $avatar_defaults;
        }

        
    /**
         * Delete avatars based on user_id
         *
         * @since 1.0.0
         * @param int $user_id
         */
        
    public function avatar_delete$user_id ) {
            
    $old_avatars get_user_meta$user_id'basic_user_avatar'true );
            
    $upload_path wp_upload_dir();

            if ( 
    is_array$old_avatars ) ) {
                foreach ( 
    $old_avatars as $old_avatar ) {
                    
    $old_avatar_path str_replace$upload_path['baseurl'], $upload_path['basedir'], $old_avatar );
                    @
    unlink$old_avatar_path );
                }
            }

            
    delete_user_meta$user_id'basic_user_avatar' );
        }

        
    /**
         * File names are magic
         *
         * @since 1.0.0
         * @param string $dir
         * @param string $name
         * @param string $ext
         * @return string
         */
        
    public function unique_filename_callback$dir$name$ext ) {
            
    $user get_user_by'id', (int) $this->user_id_being_edited );
            
    $name $base_name sanitize_file_name$user->display_name '_avatar' );
            
    $number 1;

            while ( 
    file_exists$dir "/$name$ext) ) {
                
    $name $base_name '_' $number;
                
    $number++;
            }

            return 
    $name $ext;
        }
    }
    $basic_user_avatars = new basic_user_avatars;

    /**
     * During uninstallation, remove the custom field from the users and delete the local avatars
     *
     * @since 1.0.0
     */
    function basic_user_avatars_uninstall() {
        
    $basic_user_avatars = new basic_user_avatars;
        
    $users get_users_of_blog();

        foreach ( 
    $users as $user )
            
    $basic_user_avatars->avatar_delete$user->user_id );

        
    delete_option'basic_user_avatars_caps' );
    }
    register_uninstall_hook__FILE__'basic_user_avatars_uninstall' );




  8. #188
    Bölcs earnnet logója
    Csatlakozott
    12-08-15
    Hely
    Budapest
    Hozzászólás
    1.820
    Begyűjtött 812 köszönetet
    576 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Túl sok a wp magic, amit nem akarok megérteni, inkább felkínálok egy faék megoldást. A feltöltést nem tudod megakadályozni ezzel a kóddal, de ha túl nagy lett, el tudod dobni a szerverről.

    HTML kód:
    if(shell_exec("wc -c ".$image_sized) > 512 ) { exec("rm ".$image_sized); }



    Utoljára módosítva: earnnet által : 2016-07-08 07:59

  9. #189
    Szerkesztő djjean logója
    Csatlakozott
    11-10-15
    Hely
    Baja
    Hozzászólás
    211
    Begyűjtött 48 köszönetet
    44 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Két opció van igazából:
    Norbii által írt kódot kell berakni a következő sor fölé. Bár érdemes valami hibakezelést is berakni.

    PHP kód:
    $avatar wp_handle_upload$_FILES['basic-user-avatar'], array( 'mimes' => $mimes'test_form' => false'unique_filename_callback' => array( $this'unique_filename_callback' ) ) ); 
    vagy pedig ahogy látom lehet rá írni külön filtert:

    PHP kód:
    add_filter('wp_handle_upload_prefilter', function($file) {
        
    $size $file['size'];
        if (
    $size 500 1024) {
           
    $file['error'] = '"Files larger than X bytes are prevented from uploads.';
        }
        return 
    $file;
    }); 
    media library - Give users a maximum upload capacity; limit the number of files a user can upload OR limit the number of files per upload - WordPress Development Stack Exchange



  10. #190
    Bölcs Pityu logója
    Csatlakozott
    08-07-04
    Hely
    Budapest
    Hozzászólás
    1.561
    Begyűjtött 448 köszönetet
    328 hozzászólásával

    Alapbeállítás re: php segítség kellene

    Norbii kódja sajnos nem működik, ugyanúgy akár 10MB-os képet is enged feltölteni.
    A tiéd jó lenne, de sajnos azzal az adminoknak is letiltja az 500 KB feletti feltöltést

    Idézet djjean eredeti hozzászólása Hozzászólás megtekintése
    Két opció van igazából:
    Norbii által írt kódot kell berakni a következő sor fölé. Bár érdemes valami hibakezelést is berakni.

    PHP kód:
    $avatar wp_handle_upload$_FILES['basic-user-avatar'], array( 'mimes' => $mimes'test_form' => false'unique_filename_callback' => array( $this'unique_filename_callback' ) ) ); 
    vagy pedig ahogy látom lehet rá írni külön filtert:

    PHP kód:
    add_filter('wp_handle_upload_prefilter', function($file) {
        
    $size $file['size'];
        if (
    $size 500 1024) {
           
    $file['error'] = '"Files larger than X bytes are prevented from uploads.';
        }
        return 
    $file;
    }); 
    media library - Give users a maximum upload capacity; limit the number of files a user can upload OR limit the number of files per upload - WordPress Development Stack Exchange




Oldal: 19 / 24 ElsőElső ... 91718192021 ... UtolsóUtolsó

A téma címkéi:

Könyvjelzők

Hozzászólás szabályai

  • Új témákat nem hozhatsz létre
  • Válaszokat nem küldhetsz
  • Fájlokat nem csatolhatsz
  • A hozzászólásaidat nem módosíthatod
  •