weblog-content /wp-content/plugins/simple-forum/admin/panel-profiles/support/sfa-profiles-save.php

Language PHP Lines 189
MD5 Hash cac2b0a3bb1ade22e4742625429ed1e1 Estimated Cost $3,480 (why?)
Repository https://bitbucket.org/openfarmtech/weblog-content View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
/*
Simple:Press
Admin Profile Update Support Functions
$LastChangedDate: 2010-03-26 16:38:27 -0700 (Fri, 26 Mar 2010) $
$Rev: 3818 $
*/

if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF']))
{
	die('Access Denied');
}

#= Save Options Data ===============================
function sfa_save_options_data()
{
	check_admin_referer('forum-adminform_options', 'forum-adminform_options');
	$mess = __("Profile Options Updated", "sforum");

	$sfprofile=sf_get_option('sfprofile');

	$sfprofile['nameformat'] = sf_esc_int($_POST['nameformat']);
	$sfprofile['displaymode'] = sf_esc_int($_POST['displaymode']);
	$sfprofile['displaypage'] = sf_filter_save_cleanurl($_POST['displaypage']);
	$sfprofile['displayquery'] = sf_filter_title_save(trim($_POST['displayquery']));
	$sfprofile['formmode'] = sf_esc_int($_POST['formmode']);
	$sfprofile['formpage'] = sf_filter_save_cleanurl($_POST['formpage']);
	$sfprofile['formquery'] = sf_filter_title_save(trim($_POST['formquery']));
	$sfprofile['photosmax'] = sf_esc_int($_POST['photosmax']);
	$sfprofile['photoswidth'] = sf_esc_int($_POST['photoswidth']);

	if($sfprofile['photosmax'] && $sfprofile['photoswidth']==0)
	{
		$sfprofile['photoswidth']=300;
	}

	$sfsigimagesize = array();
	$sfsigimagesize['sfsigwidth'] = sf_esc_int($_POST['sfsigwidth']);
	$sfsigimagesize['sfsigheight'] = sf_esc_int($_POST['sfsigheight']);
	sf_update_option('sfsigimagesize', $sfsigimagesize);

	if (isset($_POST['firstvisit'])) { $sfprofile['firstvisit'] = true; } else { $sfprofile['firstvisit'] = false; }
	if (isset($_POST['forcepw'])) { $sfprofile['forcepw'] = true; } else { $sfprofile['forcepw'] = false; }
	if (isset($_POST['displayinforum'])) { $sfprofile['displayinforum'] = true; } else { $sfprofile['displayinforum'] = false; }
	if (isset($_POST['forminforum'])) { $sfprofile['forminforum'] = true; } else { $sfprofile['forminforum'] = false; }
	if (isset($_POST['profileinstats'])) { $sfprofile['profileinstats'] = true; } else { $sfprofile['profileinstats'] = false; }

	$sfprofile['profilelink'] = sf_esc_int($_POST['profilelink']);
	$sfprofile['weblink'] = sf_esc_int($_POST['weblink']);

	if($_POST['profilelink'] != 3 && ($_POST['profilelink'] == $_POST['weblink']))
	{
		$mess.= '<br />'.__("Profile and Website Links can not be the same", "sforum");
		$sfprofile['weblink']=3;
	}

	$sfprofile['sfprofiletext'] = sf_filter_text_save(trim($_POST['sfprofiletext']));

	sf_update_option('sfprofile', $sfprofile);

	return $mess;
}

#= Save Manage Data ===============================
function sfa_save_data_data()
{
	check_admin_referer('forum-adminform_data', 'forum-adminform_data');
	$mess = __("Profile Data Items Updated", "sforum");

	$sfprofile = sf_get_option('sfprofile');

	foreach($sfprofile['require'] as $field=>$value)
	{
		if(isset($_POST['r-'.$field]) ? $sfprofile['require'][$field]=true : $sfprofile['require'][$field]=false);
	}

	foreach($sfprofile['include'] as $field=>$value)
	{
		if(isset($_POST['i-'.$field]) ? $sfprofile['include'][$field]=true : $sfprofile['include'][$field]=false);
		# if required then this MUST be set true
		if($sfprofile['require'][$field]) $sfprofile['include'][$field]=true;
	}

	foreach($sfprofile['display'] as $field=>$value)
	{
		if(isset($_POST['d-'.$field]) ? $sfprofile['display'][$field]=true : $sfprofile['display'][$field]=false);
	}

	foreach($sfprofile['system'] as $field=>$value)
	{
		if(isset($_POST[$field]) ? $sfprofile['system'][$field]=true : $sfprofile['system'][$field]=false);
	}

	foreach($sfprofile['label'] as $field=>$value)
	{
		if(!empty($_POST['l-'.$field]) ? $label=$_POST['l-'.$field] : $label=$field);
		$sfprofile['label'][$field] = sf_filter_title_save($label);
	}

	sf_update_option('sfprofile', $sfprofile);
	return $mess;
}

#= Save Custom Fields ===============================
function sfa_save_fields_data()
{
	check_admin_referer('forum-adminform_fields', 'forum-adminform_fields');

	$mess = '';

	$fields = array();
	$sfprofile = sf_get_option('sfprofile');

	for($x=0; $x<count(array_unique($_POST['cfieldname'])); $x++)
	{
		if (!empty($_POST['cfieldname'][$x]))
		{
			$fields = array();
			$fields['type'] = sf_esc_str($_POST['cfieldtype'][$x]);
			$fields['selectvalues'] = sf_filter_title_save(trim($_POST['cfieldvalues'][$x]));

			# ensure type selected
			if ($fields['type'] != 'none')
			{
				if (($fields['type'] == 'select' || $fields['type'] == 'radio') && empty($fields['selectvalues']))
				{
					$mess .= __('One Select/Radio Custom Field Missing Values - Not Updated!', 'sforum').'<br />';
					continue;
				}
				$fname = sf_create_slug(sf_filter_title_save(trim($_POST['cfieldname'][$x])),'');
				$fname = preg_replace('|[^a-z0-9_]|i', '', $fname);

				sf_add_sfmeta('custom_field', $fname, serialize($fields));

				# add to admins list
				$sfprofile['require'][$fname] = true;
				$sfprofile['include'][$fname] = true;
				$sfprofile['display'][$fname] = true;
				$sfprofile['label'][$fname] = sf_filter_title_save($fname);
			} else {
				$mess .= __('One Custom Field Missing Type - Not Updated!', 'sforum').'<br />';
			}
		}
	}
	sf_update_option('sfprofile', $sfprofile);

	$mess .= __('Custom Fields Updated!', 'sforum');
	return $mess;
}

function sfa_save_avatars_data()
{
	check_admin_referer('forum-adminform_avatars', 'forum-adminform_avatars');

	$mess = '';

	$sfavatars = array();
	if (isset($_POST['sfshowavatars'])) { $sfavatars['sfshowavatars'] = true; } else { $sfavatars['sfshowavatars'] = false; }
	if (isset($_POST['sfavataruploads'])) { $sfavatars['sfavataruploads'] = true; } else { $sfavatars['sfavataruploads'] = false; }
	if (isset($_POST['sfavatarpool'])) { $sfavatars['sfavatarpool'] = true; } else { $sfavatars['sfavatarpool'] = false; }
	if (isset($_POST['sfavatarremote'])) { $sfavatars['sfavatarremote'] = true; } else { $sfavatars['sfavatarremote'] = false; }
	if (isset($_POST['sfavatarreplace'])) { $sfavatars['sfavatarreplace'] = true; } else { $sfavatars['sfavatarreplace'] = false; }
	$sfavatars['sfavatarsize'] = sf_esc_int($_POST['sfavatarsize']);
	$sfavatars['sfavatarfilesize'] = sf_esc_int($_POST['sfavatarfilesize']);
	if(empty($sfavatars['sfavatarsize']) || $sfavatars['sfavatarsize'] == 0) $sfavatars['sfavatarsize'] = 50;
	if(empty($sfavatars['sfavatarfilesize']) || $sfavatars['sfavatarfilesize'] == 0) $sfavatars['sfavatarfilesize'] = 10240;
	$sfavatars['sfgmaxrating'] = sf_esc_int($_POST['sfgmaxrating']);
	$current = array();
	$current = sf_get_option('sfavatars');
	if ($_POST['sfavataropts'])
	{
		$list = explode("&", $_POST['sfavataropts']);
		$newarray = array();
		foreach($list as $item)
		{
			$thisone = explode("=", $item);
			$newarray[] = $thisone[1];
		}
		$sfavatars['sfavatarpriority'] = $newarray;
	} else {
		$sfavatars['sfavatarpriority'] = $current['sfavatarpriority'];
	}
	sf_update_option('sfavatars', $sfavatars);

	$mess .= __('Avatars Updated!', 'sforum');
	return $mess;
}

?>
Back to Top