Ejemplo n.º 1
0
function he_wall_photo_upload($media_desc, $new_action_id)
{
    global $user, $url, $misc, $setting;
    if (!$user->level_info['level_album_allow']) {
        return array('result' => 0, 'error' => SE_Language::get(690706067));
    }
    $album_id = he_wall::get_wall_album($user->user_info['user_id']);
    if (!$album_id) {
        //create new album
        $album_id = he_wall::create_wall_album($user->user_info['user_id']);
    }
    $album_info = he_wall::get_wall_album_info($album_id);
    // SET ALBUM
    $album = new se_album($user->user_info['user_id']);
    // GET TOTAL SPACE USED
    $space_used = $album->album_space();
    if ($user->level_info['level_album_storage']) {
        $space_left = $user->level_info['level_album_storage'] - $space_used;
    } else {
        $space_left = $dfs = disk_free_space("/") ? $dfs : pow(2, 32);
    }
    $new_album_cover = '';
    $file_result = $album->album_media_upload('wall_photo', $album_id, $space_left);
    if (!$file_result['is_error']) {
        $new_album_cover = $file_result['media_id'];
        $media_path = $url->url_base . substr($url->url_userdir($user->user_info['user_id']), 2) . $file_result['media_id'] . "_thumb.jpg";
        $local_media_path = substr($url->url_userdir($user->user_info['user_id']), 2) . $file_result['media_id'] . "_thumb.jpg";
        if (file_exists('./' . $local_media_path)) {
            $thumb_width = (int) $setting['setting_he_wall_photo_thumb_width'];
            $thumb_height = (int) $setting['setting_he_wall_photo_thumb_height'];
            $media_width = $misc->photo_size($local_media_path, $thumb_width, $thumb_height, "w");
            $media_height = $misc->photo_size($local_media_path, $thumb_width, $thumb_height, "h");
            $result = array('result' => 1, 'media_path' => $media_path, 'media_width' => $media_width, 'media_height' => $media_height);
        } else {
            $result = array('result' => 0, 'error' => './' . $local_media_path);
        }
        $new_album_cover = $album_info['album_cover'] ? $album_info['album_cover'] : $new_album_cover;
        he_wall::update_wall_album($album_id, $new_album_cover);
        he_wall::update_wall_album_media($file_result['media_id'], $media_desc);
        he_wall::add_wall_album_media($new_action_id, $file_result['media_id']);
        // UPDATE LAST UPDATE DATE (SAY THAT 10 TIMES FAST)
        $user->user_lastupdate();
    } else {
        $error_msg = sprintf(SE_Language::_get($file_result['is_error']), $file_result['file_name']);
        $result = array('result' => 0, 'error' => $error_msg);
    }
    return $result;
}