7 function admin_init(&$a) {
9 notice( t('Permission denied.') . EOL);
14 function admin_post(&$a){
15 if(!is_site_admin()) {
23 admin_page_site_post($a);
26 admin_page_logs_post($a);
31 goaway($a->get_baseurl() . '/admin' );
35 function admin_content(&$a) {
37 if(!is_site_admin()) {
45 // array( url, name, extra css classes )
47 'site' => Array($a->get_baseurl()."/admin/site/", t("Site") , "site"),
48 'users' => Array($a->get_baseurl()."/admin/users/", t("Users") , "users"),
49 'plugins'=> Array($a->get_baseurl()."/admin/plugins/", t("Plugins") , "plugins")
52 /* get plugins admin page */
54 $r = q("SELECT * FROM `hook` WHERE `hook`='plugin_admin'");
55 $aside['plugins_admin']=Array();
57 $plugin = explode("/",$h['file']); $plugin = $plugin[1];
58 $aside['plugins_admin'][] = Array($a->get_baseurl()."/admin/plugins/".$plugin, $plugin, "plugin");
61 $aside['logs'] = Array($a->get_baseurl()."/admin/logs/", t("Logs"), "logs");
63 $t = get_markup_template("admin_aside.tpl");
64 $a->page['aside'] = replace_macros( $t, array(
66 '$admurl'=> $a->get_baseurl()."/admin/"
80 $o = admin_page_site($a);
83 $o = admin_page_users($a);
86 $o = admin_page_plugins($a);
89 $o = admin_page_logs($a);
92 notice( t("Item not found.") );
95 $o = admin_page_summary($a);
104 function admin_page_summary(&$a) {
105 $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`");
107 Array( t('Normal Account'), 0),
108 Array( t('Soapbox Account'), 0),
109 Array( t('Community/Celebrity Account'), 0),
110 Array( t('Automatic Friend Account'), 0)
113 foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+=$u['count']; }
116 $r = q("SELECT COUNT(id) as `count` FROM `register`");
117 $pending = $r[0]['count'];
123 $t = get_markup_template("admin_summary.tpl");
124 return replace_macros($t, array(
125 '$title' => t('Administration'),
126 '$page' => t('Summary'),
127 '$users' => Array( t('Registered users'), $users),
128 '$accounts' => $accounts,
129 '$pending' => Array( t('Pending registrations'), $pending),
130 '$version' => Array( t('Version'), FRIENDIKA_VERSION),
131 '$build' => get_config('system','build'),
132 '$plugins' => Array( t('Active plugins'), $a->plugins )
140 function admin_page_site_post(&$a){
141 if (!x($_POST,"page_site")){
146 $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
147 $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
148 $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
149 $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
150 $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
151 $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
152 $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
153 $block_public = ((x($_POST,'block_public')) ? True : False);
154 $force_publish = ((x($_POST,'publish_all')) ? True : False);
155 $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
156 $global_search_url = ((x($_POST,'directory_search_url'))? notags(trim($_POST['directory_search_url'])) : '');
157 $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
158 $no_openid = ((x($_POST,'no_openid')) ? True : False);
159 $no_gravatar = ((x($_POST,'no_gravatar')) ? True : False);
160 $no_regfullname = ((x($_POST,'no_regfullname')) ? True : False);
161 $no_utf = ((x($_POST,'no_utf')) ? True : False);
162 $rino_enc = ((x($_POST,'rino_enc')) ? True : False);
163 $verifyssl = ((x($_POST,'verifyssl')) ? True : False);
164 $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['global_search_url'])) : '');
165 $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['global_search_url'])) : '');
166 $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
169 $a->config['sitename'] = $sitename;
171 // don't know why, but del_config doesn't work...
172 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
177 set_config('system','banner', $banner);
179 set_config('system','language', $language);
180 set_config('system','theme', $theme);
181 set_config('system','maximagesize', $maximagesize);
182 set_config('system','allowed_sites', $allowed_sites);
183 set_config('system','allowed_email', $allowed_email);
184 set_config('system','block_public', $block_public);
185 set_config('system','publish_all', $force_publish);
186 if ($global_directory==""){
187 // don't know why, but del_config doesn't work...
188 q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
190 dbesc("directory_submit_url")
193 set_config('system','directory_submit_url', $global_directory);
195 set_config('system','directory_search_url', $global_search_url);
196 set_config('system','block_extended_register', $no_multi_reg);
197 set_config('system','no_openid', $no_openid);
198 set_config('system','no_gravatar', $no_gravatar);
199 set_config('system','no_regfullname', $no_regfullname);
200 set_config('system','proxy', $no_utf);
201 set_config('system','rino_encrypt', $rino_enc);
202 set_config('system','verifyssl', $verifyssl);
203 set_config('system','proxyuser', $proxyuser);
204 set_config('system','proxy', $proxy);
205 set_config('system','curl_timeout', $timeout);
207 $r = q("SELECT * FROM `config` WHERE `cat`='config' AND `k`='sitename'");
209 q("UPDATE `config` SET `v`='%s' WHERE `cat`='config' AND `k`='sitename'",
210 dbesc($a->config['sitename'])
213 q("INSERT INTO `config` ( `cat`, `k`, `v` ) VALUES ( 'config', 'sitename', '%s' )",
214 dbesc($a->config['sitename'])
220 goaway($a->get_baseurl() . '/admin/site' );
221 return; // NOTREACHED
225 function admin_page_site(&$a) {
227 /* Installed langs */
228 $lang_choices = array();
229 $langs = glob('view/*/strings.php');
231 if(is_array($langs) && count($langs)) {
232 if(! in_array('view/en/strings.php',$langs))
233 $langs[] = 'view/en/';
235 foreach($langs as $l) {
236 $t = explode("/",$l);
237 $lang_choices[$t[1]] = $t[1];
241 /* Installed themes */
242 $theme_choices = array();
243 $files = glob('view/theme/*');
245 foreach($files as $file) {
246 $f = basename($file);
247 $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
248 $theme_choices[$f] = $theme_name;
254 $banner = get_config('system','banner');
256 $banner = htmlspecialchars('<a href="http://project.friendika.com"><img id="logo-img" src="images/friendika-32.png" alt="logo" /></a><span id="logo-text"><a href="http://project.friendika.com">Friendika</a></span>');
258 //echo "<pre>"; var_dump($lang_choices); die("</pre>");
262 $t = get_markup_template("admin_site.tpl");
263 return replace_macros($t, array(
264 '$title' => t('Administration'),
265 '$page' => t('Site'),
266 '$submit' => t('Submit'),
267 '$baseurl' => $a->get_baseurl(),
269 // name, label, value, help string, extra data...
270 '$sitename' => array('sitename', t("Site name"), $a->config['sitename'], ""),
271 '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
272 '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
273 '$theme' => array('theme', t("System theme"), get_config('system','theme'), "Default system theme (which may be over-ridden by user profiles)", $theme_choices),
275 '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), "Maximum size in bytes of uploaded images. Default is 0, which means no limits."),
277 '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), "Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains"),
278 '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), "Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains"),
279 '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), "Check to block public access to all otherwise public personal pages on this site unless you are currently logged in."),
280 '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), "Check to force all profiles on this site to be listed in the site directory."),
281 '$global_directory' => array('directory_submit_url', t("Global directory update URL"), get_config('system','directory_submit_url'), "URL to update the global directory. If this is not set, the global directory is completely unavailable to the application."),
282 '$global_search_url'=> array('directory_search_url', t("Global directory search URL"), get_config('system','directory_search_url'), ""),
285 '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), "Disallow users to register additional accounts for use as pages."),
286 '$no_openid' => array('no_openid', t("No OpenID support"), get_config('system','no_openid'), "Disable OpenID support for registration and logins."),
287 '$no_gravatar' => array('no_gravatar', t("No Gravatar support"), get_config('system','no_gravatar'), ""),
288 '$no_regfullname' => array('no_regfullname', t("No fullname check"), get_config('system','no_regfullname'), "If unchecked, force users to registrate with a space between his firsname and lastname in Full name, as an antispam measure"),
289 '$no_utf' => array('no_utf', t("No UTF-8 Regular expressions"), get_config('system','proxy'), "Default is false (meaning UTF8 regular expressions are supported and working)"),
291 '$rino_enc' => array('rino_enc', t("Enable Rino encrypt"), get_config('system','rino_encrypt'),""),
292 '$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system','verifyssl'), "If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites."),
293 '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
294 '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
295 '$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), "Value is in seconds. Set to 0 for unlimited (not recommended)."),
307 function admin_page_users(&$a){
316 function admin_page_plugins(&$a){
322 $plugin = $a->argv[2];
323 if (!is_file("addon/$plugin/$plugin.php")){
324 notice( t("Item not found.") );
328 if (x($_GET,"a") && $_GET['a']=="t"){
329 // Toggle plugin status
330 $idx = array_search($plugin, $a->plugins);
332 unset($a->plugins[$idx]);
333 uninstall_plugin($plugin);
335 $a->plugins[] = $plugin;
336 install_plugin($plugin);
338 set_config("system","addon", implode(", ",$a->plugins));
339 goaway($a->get_baseurl() . '/admin/plugins' );
340 return; // NOTREACHED
342 // display plugin details
345 if (in_array($plugin, $a->plugins)){
346 $status="on"; $action= t("Disable");
348 $status="off"; $action= t("Enable");
351 $t = get_markup_template("admin_plugins_details.tpl");
352 return replace_macros($t, array(
353 '$title' => t('Administration'),
354 '$page' => t('Plugins'),
355 '$toggle' => t('Toggle'),
356 '$baseurl' => $a->get_baseurl(),
358 '$plugin' => $plugin,
359 '$status' => $status,
371 $files = glob("addon/*/");
373 foreach($files as $file) {
375 list($tmp, $id)=array_map("trim", explode("/",$file));
376 // TODO: plugins info
377 $name=$author=$description=$homepage="";
378 $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $name, $author, $description, $homepage);
383 $t = get_markup_template("admin_plugins.tpl");
384 return replace_macros($t, array(
385 '$title' => t('Administration'),
386 '$page' => t('Plugins'),
387 '$submit' => t('Submit'),
388 '$baseurl' => $a->get_baseurl(),
390 '$plugins' => $plugins
399 function admin_page_logs_post(&$a) {
400 if (x($_POST,"page_logs")) {
402 $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
403 $debugging = ((x($_POST,'debugging')) ? true : false);
404 $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
406 set_config('system','logfile', $logfile);
407 set_config('system','debugging', $debugging);
408 set_config('system','loglevel', $loglevel);
413 goaway($a->get_baseurl() . '/admin/logs' );
414 return; // NOTREACHED
417 function admin_page_logs(&$a){
419 $log_choices = Array(
420 LOGGER_NORMAL => 'Normal',
421 LOGGER_TRACE => 'Trace',
422 LOGGER_DEBUG => 'Debug',
423 LOGGER_DATA => 'Data',
427 $t = get_markup_template("admin_logs.tpl");
428 return replace_macros($t, array(
429 '$title' => t('Administration'),
430 '$page' => t('Logs'),
431 '$submit' => t('Submit'),
432 '$clear' => t('Clear'),
433 '$baseurl' => $a->get_baseurl(),
434 '$logname' => get_config('system','logfile'),
436 // name, label, value, help string, extra data...
437 '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
438 '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), "Must be writable by web server. Relative to your Friendika index.php."),
439 '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),