function pre_save($doquery = true) { if ($this->presave_called !== null) { return $this->presave_called; } if ($file =& $this->fetch_field('filedata')) { $this->setr_info('filedata', $file); $this->do_unset('filedata'); $this->set('filesize', strlen($this->info['filedata'])); if (!is_writable($this->filepath)) { $this->error('upload_invalid_imagepath'); return false; } if ($thumb =& $this->fetch_field('filedata_thumb')) { $this->setr_info('filedata_thumb', $thumb); $this->do_unset('filedata_thumb'); } require_once DIR . '/includes/class_image.php'; $image =& vB_Image::fetch_library($this->registry); } return parent::pre_save($doquery); }
if (!$vbulletin->options['profilepicenabled']) { print_no_permission(); } $vbulletin->input->clean_array_gpc('p', array('deleteprofilepic' => TYPE_BOOL, 'avatarurl' => TYPE_STR)); ($hook = vBulletinHook::fetch_hook('profile_updateprofilepic_start')) ? eval($hook) : false; if ($vbulletin->GPC['deleteprofilepic']) { $userpic =& datamanager_init('Userpic_Profilepic', $vbulletin, ERRTYPE_STANDARD, 'userpic'); $userpic->condition = "userid = " . $vbulletin->userinfo['userid']; $userpic->delete(); } else { $vbulletin->input->clean_gpc('f', 'upload', TYPE_FILE); require_once DIR . '/includes/class_upload.php'; require_once DIR . '/includes/class_image.php'; $upload = new vB_Upload_Userpic($vbulletin); $upload->data =& datamanager_init('Userpic_Profilepic', $vbulletin, ERRTYPE_STANDARD, 'userpic'); $upload->image =& vB_Image::fetch_library($vbulletin); $upload->maxwidth = $vbulletin->userinfo['permissions']['profilepicmaxwidth']; $upload->maxheight = $vbulletin->userinfo['permissions']['profilepicmaxheight']; $upload->maxuploadsize = $vbulletin->userinfo['permissions']['profilepicmaxsize']; $upload->allowanimation = $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cananimateprofilepic'] ? true : false; if (!$upload->process_upload($vbulletin->GPC['avatarurl'])) { eval(standard_error($upload->fetch_error())); } } ($hook = vBulletinHook::fetch_hook('profile_updateprofilepic_complete')) ? eval($hook) : false; $vbulletin->url = 'profile.php?' . $vbulletin->session->vars['sessionurl'] . 'do=editprofilepic'; eval(print_standard_redirect('redirect_updatethanks')); } // ############################### start choose displayed usergroup ############################### if ($_POST['do'] == 'updatedisplaygroup') { $vbulletin->input->clean_array_gpc('p', array('usergroupid' => TYPE_UINT));
public function UpdatevBAvatar(array $info) { if (empty($info['username'])) { return false; } $username = $info['username']; if (DLE_CHARSET && DLE_CHARSET != $this->vbulletin->userinfo['lang_charset']) { $username = iconv($this->vbulletin->userinfo['lang_charset'], DLE_CHARSET, $username); } if ($this->vbulletin->userinfo['username'] != $username) { $this->vbulletin->userinfo = $this->vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE username='******'"); } if ($this->vbulletin->userinfo['userid']) { $this->vbulletin->userinfo = fetch_userinfo($this->vbulletin->userinfo['userid'], (defined('IN_CONTROL_PANEL') ? 16 : 0) + (defined('AVATAR_ON_NAVBAR') ? 2 : 0)); cache_permissions($this->vbulletin->userinfo); if (!empty($info['delete'])) { if ($this->vbulletin->userinfo['avatarid']) { $userdata =& datamanager_init('User', $this->vbulletin, ERRTYPE_STANDARD); $userdata->set_existing($this->vbulletin->userinfo); $userdata->set('avatarid', 0); $userdata->save(); } else { $userpic =& datamanager_init('Userpic_Avatar', $this->vbulletin, ERRTYPE_STANDARD, 'userpic'); $userpic->condition = 'userid = ' . $this->vbulletin->userinfo['userid']; $userpic->delete(); } } elseif (!empty($info['avatarurl'])) { require_once DIR . '/includes/class_upload.php'; require_once DIR . '/includes/class_image.php'; $upload = new vB_Upload_Userpic($this->vbulletin); $upload->data =& datamanager_init('Userpic_Avatar', $this->vbulletin, ERRTYPE_STANDARD, 'userpic'); $upload->image =& vB_Image::fetch_library($this->vbulletin); $upload->maxwidth = $this->vbulletin->userinfo['permissions']['avatarmaxwidth']; $upload->maxheight = $this->vbulletin->userinfo['permissions']['avatarmaxheight']; $upload->maxuploadsize = $this->vbulletin->userinfo['permissions']['avatarmaxsize']; $upload->allowanimation = $this->vbulletin->userinfo['permissions']['genericpermissions'] & $this->vbulletin->bf_ugp_genericpermissions['cananimateavatar'] ? true : false; $upload->process_upload($info['avatarurl']); $userdata =& datamanager_init('User', $this->vbulletin, ERRTYPE_STANDARD); $userdata->set_existing($this->vbulletin->userinfo); $userdata->set('avatarid', 0); $userdata->save(); } } }
public function upload($files, $urls, $filedata, $imageonly = false) { $errors = array(); require_once DIR . '/includes/class_upload.php'; require_once DIR . '/includes/class_image.php'; // check for any funny business $filecount = 1; if (!empty($files['tmp_name'])) { foreach ($files['tmp_name'] as $filename) { if (!empty($filename)) { if ($filecount > $this->registry->options['attachboxcount']) { @unlink($filename); } $filecount++; } } } // Move any urls into the attachment array if we allow url upload if ($this->registry->options['attachurlcount']) { $urlcount = 1; foreach ($urls as $url) { if (!empty($url) and $urlcount <= $this->registry->options['attachurlcount']) { $index = count($files['name']); $files['name']["{$index}"] = $url; $files['url']["{$index}"] = true; $urlcount++; } } } if (!empty($filedata)) { foreach ($filedata as $filedataid) { $index = count($files['name']); $files['name']["{$index}"] = 'filedata'; $files['filedataid']["{$index}"] = $filedataid; } } //$this->attachcount = 0; $ids = array(); $uploadsum = count($files['name']); for ($x = 0; $x < $uploadsum; $x++) { if (!$files['name']["{$x}"]) { if ($files['tmp_name']["{$x}"]) { @unlink($files['tmp_name']["{$x}"]); } continue; } $attachdata =& $this->fetch_attachdm(); $upload = new vB_Upload_Attachment($this->registry); $upload->contenttypeid = $this->contenttypeid; $image =& vB_Image::fetch_library($this->registry); $upload->userinfo = $this->userinfo; $upload->data =& $attachdata; $upload->image =& $image; if ($uploadsum > 1) { $upload->emptyfile = false; } if ($files['filedataid']["{$x}"]) { if (!($filedatainfo = $this->registry->db->query_first_slave("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tacu.filedataid, acu.filename, fd.filehash, fd.filesize, fd.extension\n\t\t\t\t\tFROM " . TABLE_PREFIX . "attachmentcategoryuser AS acu\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "filedata AS fd ON (acu.filedataid = fd.filedataid)\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tacu.filedataid = " . intval($files['filedataid']["{$x}"]) . "\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\tacu.userid = " . $this->registry->userinfo['userid'] . "\n\t\t\t\t"))) { $this->errors[] = array('filename' => "", 'error' => fetch_error('invalid_filedataid_x', $files['filedataid']["{$x}"])); continue; } $attachment = array('filedataid' => $files['filedataid']["{$x}"], 'name' => $filedatainfo['filename'], 'filehash' => $filedatainfo['filehash'], 'filesize' => $filedatainfo['filesize'], 'extension' => $filedatainfo['extension'], 'filename' => $filedatainfo['filename']); } else { if ($files['url']["{$x}"]) { $attachment = $files['name']["{$x}"]; } else { $attachment = array('name' => $files['name']["{$x}"], 'tmp_name' => $files['tmp_name']["{$x}"], 'error' => $files['error']["{$x}"], 'size' => $files['size']["{$x}"], 'utf8_name' => $files['utf8_names']); } } $this->attachcount++; $ids[] = $this->process_upload($upload, $attachment, $imageonly); } return implode(',', $ids); }
$db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "humanverify\n\t\t\tSET viewed = 1\n\t\t\tWHERE hash = '" . $db->escape_string($vbulletin->GPC['hash']) . "' AND\n\t\t\t\tviewed = 0\n\t\t"); if ($db->affected_rows() == 0) { // image managed to get viewed by someone else between the $imageinfo query above and now header('Content-type: image/gif'); readfile(DIR . '/' . $vbulletin->options['cleargifurl']); exit; } } } if ($vbulletin->GPC['i'] == 'gd') { $image = new vB_Image_GD($vbulletin); } else { if ($vbulletin->GPC['i'] == 'im') { $image = new vB_Image_Magick($vbulletin); } else { $image =& vB_Image::fetch_library($vbulletin, 'regimage'); } } $db->close(); $image->print_image_from_string($imageinfo['answer'], $moveabout); } else { if ($vbulletin->GPC['userid']) { $vbulletin->input->clean_array_gpc('r', array('dateline' => TYPE_UINT)); $filedata = 'filedata'; if ($vbulletin->GPC['type'] == 'profile') { $table = 'customprofilepic'; $can_view_profile_pic = ($vbulletin->options['profilepicenabled'] and ($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseeprofilepic'] or $vbulletin->userinfo['userid'] == $vbulletin->GPC['userid'])); if ($can_view_profile_pic) { require_once DIR . '/includes/functions_user.php'; if (!can_view_profile_section($vbulletin->GPC['userid'], 'profile_picture')) { $can_view_profile_pic = false;
'perpage' => TYPE_UINT, 'startat' => TYPE_UINT )); // Increase memlimit if (($memory_limit = ini_size_to_bytes(@ini_get('memory_limit'))) < 128 * 1024 * 1024 AND $memory_limit > 0) { @ini_set('memory_limit', 128 * 1024 * 1024); } // Get dimension constants require_once(DIR . '/includes/functions_socialgroup.php'); // Get image handler require_once(DIR . '/includes/class_image.php'); $image = vB_Image::fetch_library($vbulletin); // Check if image manip is supported if ($vbulletin->options['imagetype'] != 'Magick' AND !function_exists('imagetypes')) { print_stop_message('your_version_no_image_support'); } $vbulletin->GPC['perpage'] = max($vbulletin->GPC['perpage'], 20); echo '<p>' . construct_phrase($vbphrase['building_sgicon_thumbnails'], "misc.php?" . $vbulletin->session->vars['sessionurl'] . "do=rebuildsgicons&startat=" . $vbulletin->GPC['startat'] . "&pp=" . $vbulletin->GPC['perpage'] . "&autoredirect=" . $vbulletin->GPC['autoredirect'] . "&quality=" . $vbulletin->GPC['quality']) . '</p>'; // Get group info $result = $vbulletin->db->query_read(" SELECT socialgroupicon.dateline, socialgroupicon.userid, socialgroupicon.filedata, socialgroupicon.extension, socialgroupicon.width, socialgroupicon.height, socialgroupicon.groupid
/** * Any checks to run immediately before saving. If returning false, the save will not take place. * * @access protected * * @param boolean $doquery Do the query? * @return boolean True on success; false if an error occurred */ function pre_save($doquery = true) { if ($this->presave_called !== null) { return $this->presave_called; } if ($file =& $this->fetch_field('filedata')) { $this->setr_info('filedata', $file); $this->do_unset('filedata'); if (!is_writable($this->fetch_path($this->fetch_field('groupid'), $this->info['group']['icondateline'], false, true))) { $this->error('upload_invalid_imagepath'); return false; } if ($thumb =& $this->fetch_field('thumbnail_filedata')) { $this->setr_info('thumbnail_filedata', $thumb); $this->do_unset('thumbnail_filedata'); } require_once(DIR . '/includes/class_image.php'); $image =& vB_Image::fetch_library($this->registry); } return parent::pre_save($doquery); }
function doAction($action) { global $vbulletin, $vbphrase, $KBANK_HOOK_NAME; if ($action == 'use') { if ($this->ready2Enable()) { $item_new = array('status' => KBANK_ITEM_USED_WAITING, 'expire_time' => iif($this->data['options']['duration'] > 0, TIMENOW + $this->data['options']['duration'] * 24 * 60 * 60, -1)); $vbulletin->db->query_write(fetch_query_sql($item_new, 'kbank_items', "WHERE itemid = {$this->data[itemid]}")); if ($this->isAvatarItem and !$this->isSigPicItem) { $vbulletin->url = "profile.php?" . $vbulletin->session->vars['sessionurl'] . "do=editavatar"; } else { if (!$this->isAvatarItem and $this->isSigPicItem) { $vbulletin->url = "profile.php?" . $vbulletin->session->vars['sessionurl'] . "do=editsignature"; } else { $vbulletin->url = "profile.php?" . $vbulletin->session->vars['sessionurl']; } } eval(print_standard_redirect('kbank_use_successful')); } } if ($action == 'work' && $KBANK_HOOK_NAME == KBANK_GLOBAL_START && THIS_SCRIPT == 'profile') { global $permissions; $this->do_permissions($permissions, $this->itemtypedata['options']); //Update for later use (?) $vbulletin->userinfo['permissions'] = $permissions; } if ($action == 'work_expired') { global $vbphrase, $kbank_profile_images; $donow = true; $actionStatus = true; echo "Processing item ID#{$this->data[itemid]}<br/>"; //Search for activating item if (!isset($kbank_profile_images[$this->data['userid']])) { $kbank_profile_images[$this->data['userid']] = array(); $itemtypes = $vbulletin->db->query_read("\n\t\t\t\t\t\tSELECT \n\t\t\t\t\t\t\titems.itemid AS itemid\n\t\t\t\t\t\t\t, itemtypes.options AS itemtypeoptions\n\t\t\t\t\t\tFROM `" . TABLE_PREFIX . "kbank_items` AS items\n\t\t\t\t\t\tINNER JOIN `" . TABLE_PREFIX . "kbank_itemtypes` AS itemtypes ON (itemtypes.itemtypeid = items.type)\n\t\t\t\t\t\tWHERE itemtypes.filename = 'profile_images.kbank.php'\n\t\t\t\t\t\t\tAND items.status = " . KBANK_ITEM_USED_WAITING . "\n\t\t\t\t\t\t\tAND (items.expire_time > " . TIMENOW . "\n\t\t\t\t\t\t\t\tOR items.expire_time < 0)\n\t\t\t\t\t\t\tAND items.userid = {$this->data['userid']}\n\t\t\t\t\t"); while ($itemtype = $vbulletin->db->fetch_array($itemtypes)) { $tmp = unserialize($itemtype['itemtypeoptions']); foreach ($this->vars as $var) { $kbank_profile_images[$this->data['userid']][$var] = max($kbank_profile_images[$this->data['userid']][$var], $tmp[$var]); } } } //Check for activating item $donow = false; foreach ($this->vars as $var) { if ($kbank_profile_images[$this->data['userid']][$var] < $this->itemtypedata['options'][$var]) { $donow = true; } } if (!$donow) { //Found other stuff can handle everything echo 'User have other item(s), nothing to do now!<br/>'; } $status = array(); $message = array(); if ($donow) { $owner = fetch_userinfo($this->data['userid']); cache_permissions($owner, false); //Apply activating options to owner permissions; $this->do_permissions($owner['permissions'], $kbank_profile_images[$this->data['userid']]); foreach (array('Avatar', 'SigPic') as $type) { //If this item is this type eval('$work = iif($this->is' . $type . 'Item,true,false);'); switch ($type) { case 'Avatar': $table = 'customavatar'; $fullname = 'avatar'; $bits = $vbulletin->bf_ugp_genericpermissions; $permkey = 'genericpermissions'; $canuse = 'canuseavatar'; $dm = 'Userpic_Avatar'; break; case 'SigPic': $table = 'sigpic'; $fullname = 'sigpic'; $bits = $vbulletin->bf_ugp_signaturepermissions; $permkey = 'signaturepermissions'; $canuse = 'cansigpic'; $dm = 'Userpic_Sigpic'; break; } if ($work) { $removenow = false; $updatedone = false; $message[$type] = ''; $status[$type] = 'none'; //Check if user using system avatar if ($type == 'Avatar' and $owner['avatarid'] != 0) { //Check for System Avatar (only check with type = avatar) echo 'User using System Avatar, do nothing!<br/>'; } else { //Check for custom image if ($customimg = $vbulletin->db->query_first("\n\t\t\t\t\t\t\t\t\tSELECT filedata, dateline, filename, filesize\n\t\t\t\t\t\t\t\t\tFROM `" . TABLE_PREFIX . $table . "`\n\t\t\t\t\t\t\t\t\tWHERE userid = " . intval($owner['userid']) . "\n\t\t\t\t\t\t\t\t\tORDER BY dateline DESC\n\t\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t\t")) { $extension = trim(substr(strrchr(strtolower($customimg['filename']), '.'), 1)); $tmp_filename = DIR . "/includes/tmp_profile_images_{$customimg['dateline']}.{$extension}"; $tmp_file = fopen($tmp_filename, 'w'); fwrite($tmp_file, $customimg['filedata']); fclose($tmp_file); require_once DIR . '/includes/class_image.php'; $image =& vB_Image::fetch_library($vbulletin); $imginfo = $image->fetch_image_info($tmp_filename); if (!($owner['permissions'][$permkey] & $bits[$canuse])) { //Check if user can use Avatar/SigPic echo "User doesn't have permission to use {$type}<br/>"; $removenow = true; } else { if (!($owner['permissions'][$permkey] & $bits['cananimate' . $fullname]) and $imginfo['scenes'] > 1) { //gif, we will not process this one! remove now echo "GIF image found! Remove now!<br/>"; $removenow = true; } else { if ($owner['permissions'][$fullname . 'maxwidth'] < $imginfo[0] or $owner['permissions'][$fullname . 'maxheight'] < $imginfo[1] or $owner['permissions'][$fullname . 'maxsize'] < $customimg['filesize']) { //Check if current custom image exceed user permission options echo "{$type} need to be updated/removed!<br/>"; if ($newimg = $image->fetch_thumbnail(basename($tmp_filename), $tmp_filename, $owner['permissions'][$fullname . 'maxwidth'], $owner['permissions'][$fullname . 'maxheight'], $vbulletin->options['thumbquality'])) { //Trying to update with smaller size echo 'Updating with smaller size! ' . $owner['permissions'][$fullname . 'maxwidth'] . 'x' . $owner['permissions'][$fullname . 'maxheight'] . '<br/>'; $status[$type] = 'update'; $data =& datamanager_init($dm, $vbulletin, ERRTYPE_STANDARD, 'userpic'); $data->set('userid', $owner['userid']); $data->set('dateline', TIMENOW); $data->set('filename', $customimg['filename']); $data->set('width', $newimg['width']); $data->set('height', $newimg['height']); $data->setr('filedata', $newimg['filedata']); if ($newimg['width'] <= $owner['permissions'][$fullname . 'maxwidth'] and $newimg['height'] <= $owner['permissions'][$fullname . 'maxheight'] and $newimg['filesize'] <= $owner['permissions'][$fullname . 'maxsize'] and $data->save()) { $updatedone = true; } else { $removenow = true; } } else { $removenow = true; } } else { echo "{$type} Size Is Okie, do nothing!<br/>"; } } } //Send PM if ($updatedone) { $message[$type] = construct_phrase($vbphrase['kbank_pm_profile_images_message_update'], $newimg['width'], $newimg['height'], $type); } if ($removenow) { //Just remove record echo 'Just remove!<br/>'; $status[$type] = 'remove'; $vbulletin->db->query_write("\n\t\t\t\t\t\t\t\t\t\t\tDELETE FROM `" . TABLE_PREFIX . $table . "`\n\t\t\t\t\t\t\t\t\t\t\tWHERE userid = " . intval($owner['userid']) . "\n\t\t\t\t\t\t\t\t\t\t"); $message[$type] = construct_phrase($vbphrase['kbank_pm_profile_images_message_remove'], $type); } @unlink($tmp_filename); } else { echo "No Custom {$type} found, do nothing!<br/>"; } } } } if (isset($message['Avatar']) or isset($message['SigPic'])) { //Send PM $from = array('userid' => 1, 'username' => $vbphrase['kbank'], 'permissions' => array('pmsendmax' => 5)); $to =& $owner; $subject = $vbphrase['kbank_pm_profile_images_subject']; $message = construct_phrase($vbphrase['kbank_pm_profile_images_message'], $this->data['name'], vbdate($vbulletin->options['dateformat'] . ' ' . $vbulletin->options['timeformat'], $this->data['expire_time']), implode(', ', $message), $vbulletin->options['bburl'] . '/' . $vbulletin->kbank['phpfile'] . '?do=myitems', $vbulletin->options['bburl'] . '/usercp.php'); $result = kbank_sendPM($from, $to, $subject, $message, false); } } $vbulletin->db->query_write("\n\t\t\t\t\tUPDATE `" . TABLE_PREFIX . "kbank_items`\n\t\t\t\t\tSET status = " . KBANK_ITEM_USED . "\n\t\t\t\t\tWHERE itemid = {$this->data['itemid']}\n\t\t\t\t"); if (count($status) == 2) { //Really? Item with both options for Avatar & SigPic. Nothing's impossible! return "Avatar: {$status['Avatar']}; SigPic: {$status['SigPic']}"; } else { foreach ($status as $tmp) { return $tmp; } } } return parent::doAction($action); }
/** * Saves the facebook avatar specified from facebook url * * @param vB_DataManager_User, the datamanager to put any upload errors into * @param string, the url to retrieve the avatar from * @param bool, flag denoting if we want to try a different URL if this one fails * @param string, the url to retrieve the avatar from if the first one fails * * @return bool true if saved worked, false otherwise */ function save_fbavatar($userdata, $avatarurl = '', $do_fallback = true, $fallback_avatarurl = '') { global $vbulletin; // if we are not passed an avatar url, grab it from fb api if (empty($avatarurl)) { $pf = get_vbprofileinfo(); $avatarurl = $pf['avatarurl']; } // begin custom avatar code require_once DIR . '/includes/class_upload.php'; require_once DIR . '/includes/class_image.php'; // grab permissions info from logged in user, if user not logged in, use permissions from registered usergroup $usergroup_info = !empty($vbulletin->userinfo['userid']) ? $vbulletin->userinfo['permissions'] : $vbulletin->usergroupcache[2]; // if user does not have permission to user custom avatar, skip this step if (!($usergroup_info['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar'])) { return; } // initialize the uploader and populate with the avatar permissions $upload = new vB_Upload_Userpic($vbulletin); $upload->data =& datamanager_init('Userpic_Avatar', $vbulletin, ERRTYPE_STANDARD, 'userpic'); $upload->image =& vB_Image::fetch_library($vbulletin); $upload->maxwidth = $usergroup_info['avatarmaxwidth']; $upload->maxheight = $usergroup_info['avatarmaxheight']; $upload->maxuploadsize = $usergroup_info['avatarmaxsize']; $upload->allowanimation = $usergroup_info['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cananimateavatar'] ? true : false; // upload and validate if (!$upload->process_upload($avatarurl)) { // check if we want to try a fallback url if ($do_fallback) { // if we are not passed a fallback url, grab smaller pic from FB api if (empty($fallback_avatarurl)) { $pf = get_vbprofileinfo(); $fallback_avatarurl = $pf['fallback_avatarurl']; } // do this again, but don't use a fallback if that one fails return save_fbavatar($userdata, $fallback_avatarurl, false); } else { $userdata->error($upload->fetch_error()); return false; } } // if we get here, there were no errors, so return true return true; }
function do_upload_avatar() { global $vbulletin, $db, $show, $vbphrase, $permissions; if (!($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canmodifyprofile'])) { print_no_permission(); } if (!$vbulletin->options['avatarenabled']) { standard_error(fetch_error('avatardisabled')); } if ($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canuseavatar']) { $vbulletin->input->clean_gpc('f', 'upload', TYPE_FILE); // begin custom avatar code require_once DIR . '/includes/class_upload.php'; require_once DIR . '/includes/class_image.php'; $upload = new vB_Upload_Userpic($vbulletin); $upload->data =& datamanager_init('Userpic_Avatar', $vbulletin, ERRTYPE_STANDARD, 'userpic'); $upload->image =& vB_Image::fetch_library($vbulletin); $upload->maxwidth = $vbulletin->userinfo['permissions']['avatarmaxwidth']; $upload->maxheight = $vbulletin->userinfo['permissions']['avatarmaxheight']; $upload->maxuploadsize = $vbulletin->userinfo['permissions']['avatarmaxsize']; $upload->allowanimation = $vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cananimateavatar'] ? true : false; if (!$upload->process_upload($vbulletin->GPC['avatarurl'])) { standard_error($upload->fetch_error()); } } // init user data manager $userdata =& datamanager_init('User', $vbulletin, ERRTYPE_STANDARD); $userdata->set_existing($vbulletin->userinfo); $userdata->set('avatarid', 0); ($hook = vBulletinHook::fetch_hook('profile_updateavatar_complete')) ? eval($hook) : false; $userdata->save(); return array('success' => true); }
function attach_image ($file_name, $filedirectory, $nodeid) { global $vbulletin; //make a copy of the file, the attachment code assumes its a temp file and deletes it. $file_location = "$filedirectory/$file_name"; if (!$file_name OR !file_exists($file_location)) { echo "<p>Could not find file $file_location\n"; exit; } if ($vbulletin->options['safeupload']) { $temp_name = $vbulletin->options['tmppath'] . '/vbupload-install-' . substr(TIMENOW, -4); } else { $temp_name = @tempnam(ini_get('upload_tmp_dir'), 'vbupload'); } if (!copy($file_location, $temp_name)) { echo "<p>Could not make temporary copy of image in $temp_name</p>"; exit; } //need to clear the cache so that the filesize operation works below. clearstatcache(); $attachment = array( 'name' => $file_name, 'tmp_name' => $temp_name, 'error' => array(), 'size' => filesize($temp_name) ); $poststarttime = time(); $posthash = md5($vbulletin->GPC['poststarttime'] . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']); $contenttypeid = vB_Types::instance()->getContentTypeId("vBCms_Article"); // here we call the attach/file data combined dm $attachdata =& datamanager_init('AttachmentFiledata', $vbulletin, ERRTYPE_ARRAY, 'attachment'); $attachdata->set('contenttypeid', $contenttypeid); $attachdata->set('posthash', $posthash); $attachdata->set('contentid', $nodeid); $attachdata->set_info('categoryid', 0); $attachdata->set('state', 'visible'); $upload = new vB_Upload_Attachment_Backend($vbulletin); $upload->contenttypeid = $contenttypeid; $upload->userinfo = $vbulletin->userinfo; $upload->data =& $attachdata; $upload->image =& vB_Image::fetch_library($vbulletin); $attachmentid = $upload->process_upload($attachment); if(!$attachmentid) { echo "<p>Error loading image '$file_name':" . $upload->error . "</p>"; } return $attachmentid; }