]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/siteprofile.php
Escape argument to prevent SQL injection attack in
[quix0rs-gnu-social.git] / lib / siteprofile.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * A site profile is a set of default settings for a particular style of
6  * StatusNet site: public, private, community, etc.
7  *
8  * PHP version 5
9  *
10  * LICENCE: This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Installation
24  * @package   StatusNet
25  * @author    Zach Copley <zach@status.net>
26  * @copyright 2011 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 /**
36  * Helper class for getting the settings for a particular site profile
37  */
38 class SiteProfile
39 {
40     /**
41      * Returns the config settings for a site profile by name
42      *
43      * @param  string $name name of a site profile
44      * @return array  config settings
45      */
46     static public function getSettings($name)
47     {
48         $sprofileClass = ucfirst($name) . "Site";
49
50         if (class_exists($sprofileClass)) {
51             return call_user_func(array($sprofileClass, 'getSettings'));
52         } else {
53             common_log(
54                 LOG_ERR,
55                 "Unknown site profile '{$name}' specified in config file.",
56                 __FILE__
57             );
58             return array();
59         }
60     }
61 }
62
63 /**
64  * Site profile settings contain the list of the default settings (and
65  * possibly other information for a particular flavor of StatusNet
66  * installation). These will overwrite base defaults in $config global.
67  *
68  * @category Installation
69  * @package  StatusNet
70  * @author   Zach Copley <zach@status.net>
71  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
72  * @link     http://status.net/
73  */
74 abstract class SiteProfileSettings
75 {
76     abstract static function getSettings();
77 }
78
79 /**
80  * Settings for a 'public' site
81  */
82 class PublicSite extends SiteProfileSettings
83 {
84     /**
85      * Get the settings for this site profile
86      *
87      * @return type array   an array of settings
88      */
89     static function getSettings() {
90         global $config;
91         return array(
92             // We only want to change these values, not replace entire 'site' array
93             'site' => array_merge(
94                 $config['site'], array(
95                     'inviteonly' => false,
96                     'private'    => false,
97                     'closed'     => false
98                 )
99             ),
100             'plugins' => array(
101                 'default' => array(
102                     'Activity'                => null,
103                     'Bookmark'                => null,
104                     'ClientSideShorten'       => null,
105                     'Directory'               => null,
106                     'Event'                   => null,
107                     'ExtendedProfile'         => null,
108                     'Geonames'                => null,
109                     'Gravatar'                => null,
110                     'OpenID'                  => null,
111                     'OStatus'                 => null,
112                     'Poll'                    => null,
113                     'QnA'                     => null,
114                     'SearchSub'               => null,
115                     'StrictTransportSecurity' => null,
116                     'TagSub'                  => null
117                 )
118             ),
119             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
120         );
121     }
122 }
123
124 /**
125  * Settings for a 'private' site
126  *
127  * // XXX Too business oriented?
128  */
129 class PrivateSite extends SiteProfileSettings
130 {
131     /**
132      * Get the settings for this site profile
133      *
134      * @return type array  an array of settings
135      */
136     static function getSettings() {
137         global $config;
138         return array(
139             // We only want to change these values, not replace entire 'site' array
140             'site' => array_merge(
141                 $config['site'], array(
142                     'inviteonly' => true,
143                     'private'    => true,
144                 )
145             ),
146             'plugins' => array(
147                 'default' => array(
148                     'Activity'                => null,
149                     'Bookmark'                => null,
150                     'ClientSideShorten'       => null,
151                     'Directory'               => null,
152                     'Event'                   => null,
153                     'ExtendedProfile'         => null,
154                     'EmailRegistration'       => null,
155                     'Geonames'                => null,
156                     'Gravatar'                => null,
157                     'NewMenu'                 => null,
158                     'MobileProfile'           => null,
159                     'OpenID'                  => null,
160                     'Poll'                    => null,
161                     'QnA'                     => null,
162                     'SearchSub'               => null,
163                     'StrictTransportSecurity' => null,
164                     'TagSub'                  => null
165                 )
166              ),
167             'profile'       => array('delete' => 'true'),
168             'license'       => array('type'   => 'private'),
169             'attachments'   => array(
170                 // Only allow uploads of pictures and MS Office files
171                 'supported' => array(
172                     'image/png',
173                     'image/jpeg',
174                     'image/gif',
175                     'image/svg+xml',
176                     'application/pdf',
177                     'application/msword',
178                     'application/vnd.ms-office',
179                     'application/vnd.ms-excel',
180                     'application/vnd.ms-powerpoint',
181                     'application/ogg'
182                 )
183              ),
184             'discovery' => array('cors'   => false) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
185         );
186     }
187 }
188
189 /**
190  * Settings for a 'community' site
191  */
192 class CommunitySite extends SiteProfileSettings
193 {
194     /**
195      * Get the settings for this site profile
196      *
197      * @return type array  an array of settings
198      */
199     static function getSettings() {
200         global $config;
201         return array(
202             // We only want to change these values, not replace entire 'site' array
203             'site' => array_merge(
204                 $config['site'], array(
205                     'private'    => false,
206                     'closed'     => false
207                 )
208             ),
209             'plugins' => array(
210                 'default' => array(
211                     'Activity'                => null,
212                     'Bookmark'                => null,
213                     'ClientSideShorten'       => null,
214                     'Directory'               => null,
215                     'Event'                   => null,
216                     'Geonames'                => null,
217                     'Gravatar'                => null,
218                     'OpenID'                  => null,
219                     'OStatus'                 => null,
220                     'Poll'                    => null,
221                     'QnA'                     => null,
222                     'SearchSub'               => null,
223                     'StrictTransportSecurity' => null,
224                     'TagSub'                  => null
225                 )
226             ),
227             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
228         );
229     }
230
231 }
232
233 /**
234  * Settings for a 'singleuser' site
235  */
236 class SingleuserSite extends SiteProfileSettings
237 {
238     /**
239      * Get the settings for this site profile
240      *
241      * @return type array  an array of settings
242      */
243     static function getSettings() {
244         global $config;
245         return array(
246             'singleuser' => array('enabled' => true),
247             // We only want to change these values, not replace entire 'site' array
248             'site' => array_merge(
249                 $config['site'], array(
250                     'private'    => false,
251                     'closed'     => true,
252                 )
253             ),
254             'plugins' => array(
255                 'default' => array(
256                     'Activity'                => null,
257                     'Bookmark'                => null,
258                     'ClientSideShorten'       => null,
259                     'Event'                   => null,
260                     'Geonames'                => null,
261                     'NewMenu'                 => null,
262                     'MobileProfile'           => null,
263                     'OpenID'                  => null,
264                     'OStatus'                 => null,
265                     'Poll'                    => null,
266                     'QnA'                     => null,
267                     'SearchSub'               => null,
268                     'StrictTransportSecurity' => null,
269                     'TagSub'                  => null,
270                     'TwitterBridge'           => null,
271                     'FacebookBridge'          => null,
272                 )
273             ),
274             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
275         );
276     }
277
278 }