} else { // show some other user's attachments $pagetitle = construct_phrase($vbphrase['attachments_posted_by_x'], $username); $navbits = array('member.php?' . $vbulletin->session->vars['sessionurl'] . "u={$userid}" => $vbphrase['view_profile'], '' => $pagetitle); $shelltemplatename = 'GENERIC_SHELL'; } } // ####################################################################### if ($_REQUEST['do'] == 'customize' or $_POST['do'] == 'docustomize') { if (!($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_profile_styling'])) { print_no_permission(); } require_once DIR . '/includes/class_usercss.php'; $selector_base = array('font_family' => '', 'font_size' => '', 'color' => '', 'background_color' => '', 'background_image' => '', 'border_style' => '', 'border_color' => '', 'border_width' => '', 'linkcolor' => '', 'shadecolor' => '', 'padding' => '', 'background_repeat' => ''); $usercsspermissions = array('caneditfontfamily' => $vbulletin->userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditfontfamily'] ? true : false, 'caneditfontsize' => $vbulletin->userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditfontsize'] ? true : false, 'caneditcolors' => $vbulletin->userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditcolors'] ? true : false, 'caneditbgimage' => ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_albums'] and $vbulletin->userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditbgimage']) ? true : false, 'caneditborders' => $vbulletin->userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditborders'] ? true : false); $usercss = new vB_UserCSS($vbulletin, $vbulletin->userinfo['userid']); $allowedfonts = $usercss->build_select_option($vbulletin->options['usercss_allowed_fonts']); $allowedfontsizes = $usercss->build_select_option($vbulletin->options['usercss_allowed_font_sizes']); $allowedborderwidths = $usercss->build_select_option($vbulletin->options['usercss_allowed_border_widths']); $allowedpaddings = $usercss->build_select_option($vbulletin->options['usercss_allowed_padding']); } // ####################################################################### if ($_POST['do'] == 'docustomize') { $vbulletin->input->clean_array_gpc('p', array('usercss' => TYPE_ARRAY, 'ajax' => TYPE_BOOL)); ($hook = vBulletinHook::fetch_hook('profile_docustomize_start')) ? eval($hook) : false; foreach ($vbulletin->GPC['usercss'] as $selectorname => $selector) { if (!isset($usercss->cssedit["{$selectorname}"]) or !empty($usercss->cssedit["{$selectorname}"]['noinputset'])) { $usercss->error[] = fetch_error('invalid_selector_name_x', htmlspecialchars_uni($selectorname)); continue; } if (!is_array($selector)) {
/** * Removes a Background Image from a customised UserCSS * */ function remove_usercss_background_image() { $this->registry->db->query_write("\n\t\t\tDELETE FROM " . TABLE_PREFIX . "usercss\n\t\t\tWHERE property = 'background_image'\n\t\t\t\tAND value LIKE '" . $this->fetch_field('albumid') . ",%'\n\t\t\t\tAND userid = " . intval($this->fetch_field('userid')) . "\n\t\t"); if ($this->registry->db->affected_rows() and $this->fetch_field('userid')) { require_once DIR . '/includes/class_usercss.php'; $usercss = new vB_UserCSS($this->registry, $this->fetch_field('userid'), false); $usercss->update_css_cache(); } }
$cell[] = '<span class="smallfont">' . vbdate($vbulletin->options['dateformat'] . ', ' . $vbulletin->options['timeformat'], $user['lastvisit']) . '</span>'; print_cells_row($cell); } print_table_footer(); } // ######################################################################## if ($_REQUEST['do'] == 'usercss' or $_POST['do'] == 'updateusercss') { $vbulletin->input->clean_array_gpc('r', array('userid' => vB_Cleaner::TYPE_UINT)); $userinfo = fetch_userinfo($vbulletin->GPC['userid']); if (!$userinfo) { print_stop_message2('invalid_user_specified'); } cache_permissions($userinfo, false); $usercsspermissions = array('caneditfontfamily' => $userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditfontfamily'] ? true : false, 'caneditfontsize' => $userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditfontsize'] ? true : false, 'caneditcolors' => $userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditcolors'] ? true : false, 'caneditbgimage' => $userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditbgimage'] ? true : false, 'caneditborders' => $userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['caneditborders'] ? true : false, 'cancustomize' => $userinfo['permissions']['usercsspermissions'] & $vbulletin->bf_ugp_usercsspermissions['cancustomize'] ? true : false); require_once DIR . '/includes/class_usercss.php'; $usercss = new vB_UserCSS($vbulletin, $userinfo['userid']); } // ######################################################################## if ($_POST['do'] == 'updateusercss') { $vbulletin->input->clean_array_gpc('p', array('usercss' => vB_Cleaner::TYPE_ARRAY)); $allowedfonts = $usercss->build_select_option($vbulletin->options['usercss_allowed_fonts']); $allowedfontsizes = $usercss->build_select_option($vbulletin->options['usercss_allowed_font_sizes']); $allowedborderwidths = $usercss->build_select_option($vbulletin->options['usercss_allowed_border_widths']); $allowedpaddings = $usercss->build_select_option($vbulletin->options['usercss_allowed_padding']); foreach ($vbulletin->GPC['usercss'] as $selectorname => $selector) { if (!isset($usercss->cssedit["{$selectorname}"]) or !empty($usercss->cssedit["{$selectorname}"]['noinputset'])) { $usercss->error[] = fetch_error('invalid_selector_name_x', htmlspecialchars_uni($selectorname)); continue; } if (!is_array($selector)) { continue;
$users["$picture[userid]"] = 1; } } else { //will print errors and die. $attachdm->has_errors(true); } } if (!empty($users)) { require_once(DIR . '/includes/class_usercss.php'); foreach(array_keys($users) AS $userid) { $usercss = new vB_UserCSS($vbulletin, $userid, false); $usercss->update_css_cache(); } } print_next_page(1, $lastid); } else { echo $upgrade_phrases['upgrade_400a1.php']['update_albums_complete']; } } else { echo $upgrade_phrases['upgrade_400a1.php']['update_albums_complete']; }
} } // ####################################################################### if ($_REQUEST['do'] == 'customize') { $cssdisplayinfo = $usercss->build_display_array(); $errors = ''; // if we don't have errors, the displayed values are the existing ones // otherwise, use the form submission if (!defined('HAVE_ERRORS')) { if ($vbulletin->GPC['copyprofilecss'] AND ($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_profile_styling'])) { $profileusercss = new vB_UserCSS($vbulletin, $vbulletin->userinfo['userid']); $selectors_saved = $profileusercss->existing; $usercss_profile_preview = $profileusercss->build_css($profileusercss->fetch_effective()); $usercss_profile_preview = str_replace('/*sessionurl*/', $vbulletin->session->vars['sessionurl_js'], $usercss_profile_preview); $usercss_profile_preview = process_replacement_vars($usercss_profile_preview); unset($profileusercss); define('VBBLOG_NOUSERCSS', true); } else { $selectors_saved = $usercss->existing; } } ($hook = vBulletinHook::fetch_hook('blog_customize_start')) ? eval($hook) : false;
/** * Step #89 - Convert Albums * * @param array contains id to startat processing at * * @return mixed Startat value for next go round */ function step_89($data = null) { $startat = intval($data['startat']); $perpage = 25; $users = array(); // Convert Albums $db_alter = new vB_Database_Alter_MySQL($this->db); if ($db_alter->fetch_table_info('albumpicture')) { $pictures = $this->db->query_read("\n\t\t\t\tSELECT\n\t\t\t\t\talbumpicture.albumid, albumpicture.dateline,\n\t\t\t\t\tpicture.*\n\t\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "picture AS picture ON (albumpicture.pictureid = picture.pictureid)\n\t\t\t\tWHERE\n\t\t\t\t\talbumpicture.pictureid > {$startat}\n\t\t\t\t\t\tAND\n\t\t\t\t\talbumpicture.attachmentid = 0\n\t\t\t\tORDER BY albumpicture.pictureid ASC\n\t\t\t\t" . ($this->limitqueries ? "LIMIT 0, {$perpage}" : "") . "\n\t\t\t"); if ($this->db->num_rows($pictures)) { $lastid = 0; while ($picture = $this->db->fetch_array($pictures)) { $this->show_message(sprintf($this->phrase['version']['400a1']['convert_picture'], $picture['pictureid']), true); $lastid = $picture['pictureid']; if ($this->registry->options['album_dataloc'] == 'db') { $thumbnail =& $picture['thumbnail']; $filedata =& $picture['filedata']; } else { $attachpath = $this->registry->options['album_picpath'] . '/' . floor($picture['pictureid'] / 1000) . "/{$picture['pictureid']}.picture"; if ($this->registry->options['album_dataloc'] == 'fs_directthumb') { $attachthumbpath = $this->registry->options['album_thumbpath'] . '/' . floor($picture['pictureid'] / 1000); } else { $attachthumbpath = $this->registry->options['album_picpath'] . '/' . floor($picture['pictureid'] / 1000); } $attachthumbpath .= "/{$picture['idhash']}_{$picture['pictureid']}.{$picture['extension']}"; $thumbnail = @file_get_contents($attachthumbpath); $filedata = @file_get_contents($attachpath); if ($filedata === false) { $this->show_message(sprintf($this->phrase['version']['400a1']['could_not_find_file'], $attachpath)); continue; } } $attachdm =& datamanager_init('AttachmentFiledata', $this->registry, ERRTYPE_CP, 'attachment'); $attachdm->set('contenttypeid', 8); $attachdm->set('contentid', $picture['albumid']); $attachdm->set('filename', $picture['pictureid'] . '.' . $picture['extension']); $attachdm->set('width', $picture['width']); $attachdm->set('height', $picture['height']); $attachdm->set('state', $picture['state']); $attachdm->set('reportthreadid', $picture['reportthreadid']); $attachdm->set('userid', $picture['userid']); $attachdm->set('caption', $picture['caption']); $attachdm->set('dateline', $picture['dateline']); $attachdm->set('thumbnail_dateline', $picture['thumbnail_dateline']); $attachdm->setr('filedata', $filedata); $attachdm->setr('thumbnail', $thumbnail); if ($attachmentid = $attachdm->save()) { $this->db->query_write("\n\t\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "albumpicture\n\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\tattachmentid = {$attachmentid}\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tpictureid = {$picture['pictureid']}\n\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\talbumid = {$picture['albumid']}\n\t\t\t\t\t\t"); $this->db->query_write("\n\t\t\t\t\t\t\tINSERT IGNORE INTO " . TABLE_PREFIX . "picturelegacy\n\t\t\t\t\t\t\t\t(type, primaryid, pictureid, attachmentid)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t('album', {$picture['albumid']}, {$picture['pictureid']}, {$attachmentid})\n\t\t\t\t\t\t"); $this->db->query_write("\n\t\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "picturecomment\n\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\tfiledataid = " . $attachdm->fetch_field('filedataid') . ",\n\t\t\t\t\t\t\t\tuserid = {$picture['userid']}\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tpictureid = {$picture['pictureid']}\n\t\t\t\t\t\t"); $this->db->query_write("\n\t\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "album\n\t\t\t\t\t\t\tSET coverattachmentid = {$attachmentid}\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tcoverattachmentid = {$picture['pictureid']}\n\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\talbumid = {$picture['albumid']}\n\t\t\t\t\t\t"); $oldvalue = "{$picture['albumid']},{$picture['userid']}"; $newvalue = "{$picture['albumid']},{$attachmentid}]"; $this->db->query_write("\n\t\t\t\t\t\t\tUPDATE " . TABLE_PREFIX . "usercss\n\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\tvalue = '" . $this->db->escape_string($newvalue) . "',\n\t\t\t\t\t\t\t\tconverted = 1\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tproperty = 'background_image'\n\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tvalue = '" . $this->db->escape_string($oldvalue) . "'\n\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tuserid = {$picture['userid']}\n\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tconverted = 0\n\t\t\t\t\t\t"); if ($this->db->affected_rows()) { $users["{$picture['userid']}"] = 1; } } else { //will print errors and die. $attachdm->has_errors(true); } } if (!empty($users)) { require_once DIR . '/includes/class_usercss.php'; foreach (array_keys($users) as $userid) { $usercss = new vB_UserCSS($this->registry, $userid, false); $usercss->update_css_cache(); } } return array('startat' => $lastid); } else { $this->show_message($this->phrase['version']['400a1']['update_albums_complete']); } } else { $this->show_message($this->phrase['version']['400a1']['update_albums_complete']); } }
/** * Returns an array of information about selectors and properties * * @return array */ function build_css_array() { $css = parent::build_css_array(); $css['entryposter'] = array( 'selectors' => array( '.entryposter', ), 'properties' => array( 'background_color', 'background_image', 'background_repeat', 'color', ) ); $css['entryposter_a'] = array( 'selectors' => array( '.entryposter a', ), 'properties' => array( 'linkcolor' ) ); return $css; }
/** * Constructs the User's Custom CSS * * @param array An array of userinfo * @param bool (Return) Whether to show the user css on/off switch to the user * * @return string HTML for the User's CSS */ function construct_usercss(&$userinfo, &$show_usercss_switch) { global $vbulletin; // profile styling globally disabled if (!($vbulletin->options['socnet'] & $vbulletin->bf_misc_socnet['enable_profile_styling'])) { $show_usercss_switch = false; return ''; } // check if permissions have changed and we need to rebuild this user's css if ($userinfo['hascachedcss'] AND $userinfo['cssbuildpermissions'] != $userinfo['permissions']['usercsspermissions']) { require_once(DIR . '/includes/class_usercss.php'); $usercss = new vB_UserCSS($vbulletin, $userinfo['userid'], false); $userinfo['cachedcss'] = $usercss->update_css_cache(); } if (!($vbulletin->userinfo['options'] & $vbulletin->bf_misc_useroptions['showusercss']) AND $vbulletin->userinfo['userid'] != $userinfo['userid']) { // user has disabled viewing css; they can reenable $show_usercss_switch = (trim($userinfo['cachedcss']) != ''); $usercss = ''; } else if (trim($userinfo['cachedcss'])) { $show_usercss_switch = true; $userinfo['cachedcss'] = str_replace('/*sessionurl*/', $vbulletin->session->vars['sessionurl_js'], $userinfo['cachedcss']); $templater = vB_Template::create('memberinfo_usercss'); $templater->register('userinfo', $userinfo); $usercss = $templater->render(); } else { $show_usercss_switch = false; $usercss = ''; } return $usercss; }
$jsblock .= "userTheme['{$varname}'] = '" . $value . "';\n"; } $jsblock .= "var select_color_information = '" . vB_Template_Runtime::escapeJS($vbphrase['select_color_information']) . "';\n"; $jsblock .= "var no_server_response = '" . vB_Template_Runtime::escapeJS($vbphrase['no_server_response']) . "';\n"; $jsblock .= "var not_a_valid_color = '" . vB_Template_Runtime::escapeJS($vbphrase['not_a_valid_color']) . "';\n"; $jsblock .= "var str_OK = '" . vB_Template_Runtime::escapeJS($vbphrase['okay']) . "';\n"; $jsblock .= "var str_exit = '" . vB_Template_Runtime::escapeJS($vbphrase['exit']) . "';\n"; $jsblock .= "var str_dont_exit = '" . vB_Template_Runtime::escapeJS($vbphrase['dont_exit']) . "';\n"; $jsblock .= "var profile_reverted_message = '" . vB_Template_Runtime::escapeJS($vbphrase['profile_reverted_message']) . "';\n"; $jsblock .= "var nothing_to_revert = '" . vB_Template_Runtime::escapeJS($vbphrase['nothing_to_revert']) . "';\n"; $jsblock .= "var confirm_sitedefault_save = '" . vB_Template_Runtime::escapeJS($vbphrase['confirm_sitedefault_msg']) . "';\n"; } //create the user profile customization interface if ($show_customize_profile) { require_once DIR . '/includes/class_usercss.php'; $usercss = new vB_UserCSS($vbulletin, $vbulletin->userinfo['userid']); $allowedfonts = $usercss->build_select_option($vbulletin->options['usercss_allowed_fonts']); $jsblock .= "var default_font = '" . vB_Template_Runtime::escapeJS(vB::$vbulletin->stylevars['font']['family']) . "';\n"; $fontnames = "<option class=\"grey_select_item\" style=\"font-family:" . vB::$vbulletin->stylevars['font']['family'] . "\" value=\"default\">" . $vbphrase['default'] . "</option>\n"; foreach ($allowedfonts as $key => $font) { $selected = $font == $usertheme['font_family'] ? 'selected="selected"' : ''; $fontnames .= "<option style=\"font-family:{$font};\" class=\"grey_select_item\" {$selected} value=\"{$font}\">" . $vbphrase['usercss_font_' . $key] . "</option>\n"; } $fontsizes = ''; $allowedsizes = $usercss->build_select_option($vbulletin->options['usercss_allowed_font_sizes']); $jsblock .= "var fontsizes = new Array();\n"; foreach ($allowedsizes as $key => $fontsize) { $selected = $fontsize == $usertheme['fontsize'] ? 'selected="selected"' : ''; $phrasekey = str_replace('-', '', $fontsize); $fontsizes .= "<option {$selected} class=\"grey_select_item\" value=\"{$fontsize}\">" . $vbphrase[$phrasekey] . "</option>\n"; $jsblock .= "fontsizes['{$fontsize}'] = '" . vB_Template_Runtime::escapeJS($vbphrase[$phrasekey]) . "';\n";
/** * Operations following a save * * @return */ public function post_save($attachdm) { $attachmentid = $attachdm->fetch_field('attachmentid'); if (!$attachdm->condition AND !empty($attachdm->info['albums'])) { $dateline = (!$attachdm->info['dateline'] ? TIMENOW : $$attachdm->info['dateline']); $albumids = array(); foreach ($attachdm->info['albums'] AS $album) { $albumids[] = intval($album['albumid']); } $this->registry->db->query_write(" UPDATE " . TABLE_PREFIX . "album SET " . ($attachdm->fetch_field('state') == 'visible' ? "visible = visible + 1, lastpicturedate = IF($dateline > lastpicturedate, $dateline, lastpicturedate)" : "moderation = moderation + 1") . " WHERE albumid IN (" . implode(',', $albumids) . ") "); } if ( $attachdm->condition AND $attachdm->fetch_field('contentid') != $attachdm->existing('contentid') AND $attachdm->info['albuminfo']['userid'] == $this->registry->userinfo['userid'] ) { if ( $attachdm->info['albuminfo']['state'] == 'private' AND $attachdm->info['destination'] AND $attachdm->info['destination']['state'] != 'private' ) { if ($attachdm->fetch_field('state') != 'private' AND $attachdm->existing['state'] == 'private') { $this->registry->db->query_write(" DELETE FROM " . TABLE_PREFIX . "usercss WHERE property = 'background_image' AND value = '{$attachdm->info['albuminfo']['albumid']},$attachmentid' AND userid = {$attachdm->info['albuminfo']['userid']} "); } else { $oldvalue = "{$attachdm->info['albuminfo']['albumid']},$attachmentid"; $newvalue = "{$attachdm->info['destination']['albumid']},$attachmentid"; $this->registry->db->query_write(" UPDATE " . TABLE_PREFIX . "usercss SET value = '" . $this->registry->db->escape_string($newvalue) . "' WHERE property = 'background_image' AND value = '" . $this->registry->db->escape_string($oldvalue) . "' AND userid = {$attachdm->albuminfo['userid']} "); } } require_once(DIR . '/includes/class_usercss.php'); $usercss = new vB_UserCSS($vbulletin, $this->info['albuminfo']['userid'], false); $usercss->update_css_cache(); } }
unset($albumdata); } } $albumdata =& datamanager_init('Album', $vbulletin, ERRTYPE_SILENT); $albumdata->set_existing($albuminfo); $albumdata->rebuild_counts(); if ($new_coverid or $updatecounter) { if ($new_coverid or $cover_moved) { $albumdata->set('coverattachmentid', $new_coverid); } } $albumdata->save(); unset($albumdata); if ($need_css_rebuild) { require_once DIR . '/includes/class_usercss.php'; $usercss = new vB_UserCSS($vbulletin, $albuminfo['userid'], false); $usercss->update_css_cache(); } // add to updated list if (can_moderate(0, 'canmoderatepictures') or !$vbulletin->options['albums_pictures_moderation'] and $vbulletin->userinfo['permissions']['albumpermissions'] & $vbulletin->bf_ugp_albumpermissions['picturefollowforummoderation']) { exec_album_updated($vbulletin->userinfo, $albuminfo); } if ($vbulletin->GPC['frompicture'] and sizeof($attachmentids) == 1 and !$deleted_picture) { $attachmentid = reset($attachmentids); $vbulletin->url = 'album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid=" . ($picture_moved ? $picture_moved : $albuminfo['albumid']) . "&attachmentid={$attachmentid}"; } else { $vbulletin->url = 'album.php?' . $vbulletin->session->vars['sessionurl'] . "albumid={$albuminfo['albumid']}"; } print_standard_redirect('pictures_updated'); } // #######################################################################