Plugin Directory

Changeset 789467


Ignore:
Timestamp:
10/17/2013 07:42:54 PM (12 years ago)
Author:
bastb
Message:

Now checks file access permissions when storing a file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lips/branches/dev-0.8.10/lips.php

    r788909 r789467  
    18831883        $local_picture_copy = "";
    18841884
     1885        // Don't download the profile picture when it is stored to WordPress already.
    18851886        $current_picture = get_user_meta($this->current_user->ID, LIPS_USER_META_PICTURE, true);
    18861887        $download_picture = empty($current_picture);
     
    19161917                    $path = $upload_details['basedir'] . '/lips/' . $dimensions . "_" . str_replace(" ", "-", trim($json['id'])) . "." . substr($mimetype, strpos($mimetype, "/") + 1);
    19171918                    @mkdir(dirname($path), 0, true);
    1918                     file_put_contents($path, file_get_contents($picture_url));
    1919                     $picture_meta = array(
    1920                         "post_title" => sprintf("%s %s", $json["formattedName"], __("profile picture")),
    1921                         "post_content" => "",
    1922                         "post_status" => "private",
    1923                         "post_mime_type" => $mimetype,
    1924                     );
    1925                     $this->current_picture_size = $sizes[$size_index];
    1926                     $picture_id = wp_insert_attachment($picture_meta, $path);
    1927                     wp_update_attachment_metadata($picture_id, $path);
    1928                     $local_picture_copy[$this->current_picture_size] = wp_get_attachment_url($picture_id);
     1919                    $saved = @file_put_contents($path, file_get_contents($picture_url));
     1920                    // The user may not have permission to store the file
     1921                    if (FALSE !== $saved) {
     1922                        $picture_meta = array(
     1923                                "post_title" => sprintf("%s %s", $json["formattedName"], __("profile picture")),
     1924                                "post_content" => "",
     1925                                "post_status" => "private",
     1926                                "post_mime_type" => $mimetype,
     1927                        );
     1928                        $this->current_picture_size = $sizes[$size_index];
     1929                        $picture_id = wp_insert_attachment($picture_meta, $path);
     1930                        wp_update_attachment_metadata($picture_id, $path);
     1931                        $local_picture_copy[$this->current_picture_size] = wp_get_attachment_url($picture_id);
     1932                    }
    19291933                }
    19301934                $size_index++;
Note: See TracChangeset for help on using the changeset viewer.