コード例 #1
0
 case 'show_custom_welcome':
 case 'show_notice_welcome':
 case 'show_notice_visitor':
     $optionfield['style'] = 'tall';
     break;
 case 'custom_register':
 case 'custom_welcome':
 case 'notice_welcome':
 case 'notice_visitor':
     unset($optionfield['label']);
     $optionfield['style'] = 'tall';
     $optionfield['rows'] = 3;
     break;
 case 'avatar_allow_gravatar':
     $optionfield['label'] = strtr($optionfield['label'], array('^1' => '<a href="http://www.gravatar.com/" target="_blank">', '^2' => '</a>'));
     if (!qa_has_gd_image()) {
         $optionfield['style'] = 'tall';
         $optionfield['error'] = qa_lang_html('admin/no_image_gd');
     }
     break;
 case 'avatar_store_size':
 case 'avatar_profile_size':
 case 'avatar_users_size':
 case 'avatar_q_page_q_size':
 case 'avatar_q_page_a_size':
 case 'avatar_q_page_c_size':
 case 'avatar_q_list_size':
 case 'avatar_message_list_size':
     $optionfield['note'] = qa_lang_html('admin/pixels');
     break;
 case 'avatar_default_show':
コード例 #2
0
//	Avatar upload stuff
if (qa_opt('avatar_allow_gravatar') || qa_opt('avatar_allow_upload')) {
    $avataroptions = array();
    if (qa_opt('avatar_default_show') && strlen(qa_opt('avatar_default_blobid'))) {
        $avataroptions[''] = '<span style="margin:2px 0; display:inline-block;">' . qa_get_avatar_blob_html(qa_opt('avatar_default_blobid'), qa_opt('avatar_default_width'), qa_opt('avatar_default_height'), 32) . '</span> ' . qa_lang_html('users/avatar_default');
    } else {
        $avataroptions[''] = qa_lang_html('users/avatar_none');
    }
    $avatarvalue = $avataroptions[''];
    if (qa_opt('avatar_allow_gravatar')) {
        $avataroptions['gravatar'] = '<span style="margin:2px 0; display:inline-block;">' . qa_get_gravatar_html($useraccount['email'], 32) . ' ' . strtr(qa_lang_html('users/avatar_gravatar'), array('^1' => '<a href="http://www.gravatar.com/" target="_blank">', '^2' => '</a>')) . '</span>';
        if ($useraccount['flags'] & QA_USER_FLAGS_SHOW_GRAVATAR) {
            $avatarvalue = $avataroptions['gravatar'];
        }
    }
    if (qa_has_gd_image() && qa_opt('avatar_allow_upload')) {
        $avataroptions['uploaded'] = '<input name="file" type="file">';
        if (isset($useraccount['avatarblobid'])) {
            $avataroptions['uploaded'] = '<span style="margin:2px 0; display:inline-block;">' . qa_get_avatar_blob_html($useraccount['avatarblobid'], $useraccount['avatarwidth'], $useraccount['avatarheight'], 32) . '</span>' . $avataroptions['uploaded'];
        }
        if ($useraccount['flags'] & QA_USER_FLAGS_SHOW_AVATAR) {
            $avatarvalue = $avataroptions['uploaded'];
        }
    }
    $qa_content['form_profile']['fields']['avatar'] = array('type' => 'select-radio', 'label' => qa_lang_html('users/avatar_label'), 'tags' => 'name="avatar"', 'options' => $avataroptions, 'value' => $avatarvalue, 'error' => qa_html(@$errors['avatar']));
} else {
    unset($qa_content['form_profile']['fields']['avatar']);
}
//	Other profile fields
foreach ($userfields as $userfield) {
    $value = @$inprofile[$userfield['fieldid']];
コード例 #3
0
function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    $result = array();
    //	Check per-user upload limits
    require_once QA_INCLUDE_DIR . 'qa-app-users.php';
    require_once QA_INCLUDE_DIR . 'qa-app-limits.php';
    switch (qa_user_permit_error(null, QA_LIMIT_UPLOADS)) {
        case 'limit':
            $result['error'] = qa_lang('main/upload_limit');
            return $result;
        case false:
            qa_limits_increment(qa_get_logged_in_userid(), QA_LIMIT_UPLOADS);
            break;
        default:
            $result['error'] = qa_lang('users/no_permission');
            return $result;
    }
    //	Check the uploaded file is not too large
    $filesize = filesize($localfilename);
    if (isset($maxfilesize)) {
        $maxfilesize = min($maxfilesize, qa_get_max_upload_size());
    } else {
        $maxfilesize = qa_get_max_upload_size();
    }
    if ($filesize <= 0 || $filesize > $maxfilesize) {
        // if file was too big for PHP, $filesize will be zero
        $result['error'] = qa_lang_sub('main/max_upload_size_x', number_format($maxfilesize / 1048576, 1) . 'MB');
        return $result;
    }
    //	Find out what type of source file was uploaded and if appropriate, check it's an image and get preliminary size measure
    $pathinfo = pathinfo($sourcefilename);
    $format = strtolower(@$pathinfo['extension']);
    $isimage = $format == 'png' || $format == 'gif' || $format == 'jpeg' || $format == 'jpg';
    // allowed image extensions
    if ($isimage) {
        $imagesize = @getimagesize($localfilename);
        if (is_array($imagesize)) {
            $result['width'] = $imagesize[0];
            $result['height'] = $imagesize[1];
            switch ($imagesize['2']) {
                // reassign format based on actual content, if we can
                case IMAGETYPE_GIF:
                    $format = 'gif';
                    break;
                case IMAGETYPE_JPEG:
                    $format = 'jpeg';
                    break;
                case IMAGETYPE_PNG:
                    $format = 'png';
                    break;
            }
        }
    }
    $result['format'] = $format;
    if ($onlyimage) {
        if (!$isimage || !is_array($imagesize)) {
            $result['error'] = qa_lang_sub('main/image_not_read', 'GIF, JPG, PNG');
            return $result;
        }
    }
    //	Read in the raw file contents
    $content = file_get_contents($localfilename);
    //	If appropriate, get more accurate image size and apply constraints to it
    require_once QA_INCLUDE_DIR . 'qa-util-image.php';
    if ($isimage && qa_has_gd_image()) {
        $image = @imagecreatefromstring($content);
        if (is_resource($image)) {
            $result['width'] = $width = imagesx($image);
            $result['height'] = $height = imagesy($image);
            if (isset($imagemaxwidth) || isset($imagemaxheight)) {
                if (qa_image_constrain($width, $height, isset($imagemaxwidth) ? $imagemaxwidth : $width, isset($imagemaxheight) ? $imagemaxheight : $height)) {
                    qa_gd_image_resize($image, $width, $height);
                    if (is_resource($image)) {
                        $content = qa_gd_image_jpeg($image);
                        $result['format'] = $format = 'jpeg';
                        $result['width'] = $width;
                        $result['height'] = $height;
                    }
                }
            }
            if (is_resource($image)) {
                // might have been lost
                imagedestroy($image);
            }
        }
    }
    //	Create the blob and return
    require_once QA_INCLUDE_DIR . 'qa-app-blobs.php';
    $userid = qa_get_logged_in_userid();
    $cookieid = isset($userid) ? qa_cookie_get() : qa_cookie_get_create();
    $result['blobid'] = qa_create_blob($content, $format, $sourcefilename, $userid, $cookieid, qa_remote_ip_address());
    if (!isset($result['blobid'])) {
        $result['error'] = qa_lang('main/general_error');
        return $result;
    }
    $result['bloburl'] = qa_get_blob_url($result['blobid'], true);
    return $result;
}