Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1221 lines
42 KiB

  1. <?php
  2. /**
  3. * Friendica admin
  4. */
  5. require_once("include/remoteupdate.php");
  6. /**
  7. * @param App $a
  8. */
  9. function admin_post(&$a){
  10. if(!is_site_admin()) {
  11. return;
  12. }
  13. // do not allow a page manager to access the admin panel at all.
  14. if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
  15. return;
  16. // urls
  17. if ($a->argc > 1){
  18. switch ($a->argv[1]){
  19. case 'site':
  20. admin_page_site_post($a);
  21. break;
  22. case 'users':
  23. admin_page_users_post($a);
  24. break;
  25. case 'plugins':
  26. if ($a->argc > 2 &&
  27. is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")){
  28. @include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
  29. if(function_exists($a->argv[2].'_plugin_admin_post')) {
  30. $func = $a->argv[2].'_plugin_admin_post';
  31. $func($a);
  32. }
  33. }
  34. goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] );
  35. return; // NOTREACHED
  36. break;
  37. case 'themes':
  38. $theme = $a->argv[2];
  39. if (is_file("view/theme/$theme/config.php")){
  40. require_once("view/theme/$theme/config.php");
  41. if (function_exists("theme_admin_post")){
  42. theme_admin_post($a);
  43. }
  44. }
  45. info(t('Theme settings updated.'));
  46. if(is_ajax()) return;
  47. goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
  48. return;
  49. break;
  50. case 'logs':
  51. admin_page_logs_post($a);
  52. break;
  53. case 'dbsync':
  54. admin_page_dbsync_post($a);
  55. break;
  56. case 'update':
  57. admin_page_remoteupdate_post($a);
  58. break;
  59. }
  60. }
  61. goaway($a->get_baseurl(true) . '/admin' );
  62. return; // NOTREACHED
  63. }
  64. /**
  65. * @param App $a
  66. * @return string
  67. */
  68. function admin_content(&$a) {
  69. if(!is_site_admin()) {
  70. return login(false);
  71. }
  72. if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
  73. return "";
  74. /**
  75. * Side bar links
  76. */
  77. // array( url, name, extra css classes )
  78. $aside = Array(
  79. 'site' => Array($a->get_baseurl(true)."/admin/site/", t("Site") , "site"),
  80. 'users' => Array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"),
  81. 'plugins'=> Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"),
  82. 'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"),
  83. 'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"),
  84. //'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update")
  85. );
  86. /* get plugins admin page */
  87. $r = q("SELECT * FROM `addon` WHERE `plugin_admin`=1");
  88. $aside['plugins_admin']=Array();
  89. foreach ($r as $h){
  90. $plugin =$h['name'];
  91. $aside['plugins_admin'][] = Array($a->get_baseurl(true)."/admin/plugins/".$plugin, $plugin, "plugin");
  92. // temp plugins with admin
  93. $a->plugins_admin[] = $plugin;
  94. }
  95. $aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs");
  96. $t = get_markup_template("admin_aside.tpl");
  97. $a->page['aside'] .= replace_macros( $t, array(
  98. '$admin' => $aside,
  99. '$admtxt' => t('Admin'),
  100. '$plugadmtxt' => t('Plugin Features'),
  101. '$logtxt' => t('Logs'),
  102. '$h_pending' => t('User registrations waiting for confirmation'),
  103. '$admurl'=> $a->get_baseurl(true)."/admin/"
  104. ));
  105. /**
  106. * Page content
  107. */
  108. $o = '';
  109. // urls
  110. if ($a->argc > 1){
  111. switch ($a->argv[1]){
  112. case 'site':
  113. $o = admin_page_site($a);
  114. break;
  115. case 'users':
  116. $o = admin_page_users($a);
  117. break;
  118. case 'plugins':
  119. $o = admin_page_plugins($a);
  120. break;
  121. case 'themes':
  122. $o = admin_page_themes($a);
  123. break;
  124. case 'logs':
  125. $o = admin_page_logs($a);
  126. break;
  127. case 'dbsync':
  128. $o = admin_page_dbsync($a);
  129. break;
  130. case 'update':
  131. $o = admin_page_remoteupdate($a);
  132. break;
  133. default:
  134. notice( t("Item not found.") );
  135. }
  136. } else {
  137. $o = admin_page_summary($a);
  138. }
  139. if(is_ajax()) {
  140. echo $o;
  141. killme();
  142. return '';
  143. } else {
  144. return $o;
  145. }
  146. }
  147. /**
  148. * Admin Summary Page
  149. * @param App $a
  150. * @return string
  151. */
  152. function admin_page_summary(&$a) {
  153. $r = q("SELECT `page-flags`, COUNT(uid) as `count` FROM `user` GROUP BY `page-flags`");
  154. $accounts = Array(
  155. Array( t('Normal Account'), 0),
  156. Array( t('Soapbox Account'), 0),
  157. Array( t('Community/Celebrity Account'), 0),
  158. Array( t('Automatic Friend Account'), 0),
  159. Array( t('Blog Account'), 0),
  160. Array( t('Private Forum'), 0)
  161. );
  162. $users=0;
  163. foreach ($r as $u){ $accounts[$u['page-flags']][1] = $u['count']; $users+= $u['count']; }
  164. logger('accounts: ' . print_r($accounts,true),LOGGER_DATA);
  165. $r = q("SELECT COUNT(id) as `count` FROM `register`");
  166. $pending = $r[0]['count'];
  167. $r = q("select count(*) as total from deliverq where 1");
  168. $deliverq = (($r) ? $r[0]['total'] : 0);
  169. $r = q("select count(*) as total from queue where 1");
  170. $queue = (($r) ? $r[0]['total'] : 0);
  171. // We can do better, but this is a quick queue status
  172. $queues = array( 'label' => t('Message queues'), 'deliverq' => $deliverq, 'queue' => $queue );
  173. $t = get_markup_template("admin_summary.tpl");
  174. return replace_macros($t, array(
  175. '$title' => t('Administration'),
  176. '$page' => t('Summary'),
  177. '$queues' => $queues,
  178. '$users' => Array( t('Registered users'), $users),
  179. '$accounts' => $accounts,
  180. '$pending' => Array( t('Pending registrations'), $pending),
  181. '$version' => Array( t('Version'), FRIENDICA_VERSION),
  182. '$build' => get_config('system','build'),
  183. '$plugins' => Array( t('Active plugins'), $a->plugins )
  184. ));
  185. }
  186. /**
  187. * Admin Site Page
  188. * @param App $a
  189. */
  190. function admin_page_site_post(&$a){
  191. if (!x($_POST,"page_site")){
  192. return;
  193. }
  194. check_form_security_token_redirectOnErr('/admin/site', 'admin_site');
  195. $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
  196. $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
  197. $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
  198. $theme = ((x($_POST,'theme')) ? notags(trim($_POST['theme'])) : '');
  199. $theme_mobile = ((x($_POST,'theme_mobile')) ? notags(trim($_POST['theme_mobile'])) : '');
  200. $maximagesize = ((x($_POST,'maximagesize')) ? intval(trim($_POST['maximagesize'])) : 0);
  201. $maximagelength = ((x($_POST,'maximagelength')) ? intval(trim($_POST['maximagelength'])) : MAX_IMAGE_LENGTH);
  202. $jpegimagequality = ((x($_POST,'jpegimagequality')) ? intval(trim($_POST['jpegimagequality'])) : JPEG_QUALITY);
  203. $register_policy = ((x($_POST,'register_policy')) ? intval(trim($_POST['register_policy'])) : 0);
  204. $daily_registrations = ((x($_POST,'max_daily_registrations')) ? intval(trim($_POST['max_daily_registrations'])) :0);
  205. $abandon_days = ((x($_POST,'abandon_days')) ? intval(trim($_POST['abandon_days'])) : 0);
  206. $register_text = ((x($_POST,'register_text')) ? notags(trim($_POST['register_text'])) : '');
  207. $allowed_sites = ((x($_POST,'allowed_sites')) ? notags(trim($_POST['allowed_sites'])) : '');
  208. $allowed_email = ((x($_POST,'allowed_email')) ? notags(trim($_POST['allowed_email'])) : '');
  209. $block_public = ((x($_POST,'block_public')) ? True : False);
  210. $force_publish = ((x($_POST,'publish_all')) ? True : False);
  211. $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
  212. $thread_allow = ((x($_POST,'thread_allow')) ? True : False);
  213. $newuser_private = ((x($_POST,'newuser_private')) ? True : False);
  214. $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
  215. $no_openid = !((x($_POST,'no_openid')) ? True : False);
  216. $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
  217. $no_utf = !((x($_POST,'no_utf')) ? True : False);
  218. $no_community_page = !((x($_POST,'no_community_page')) ? True : False);
  219. $verifyssl = ((x($_POST,'verifyssl')) ? True : False);
  220. $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
  221. $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
  222. $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
  223. $delivery_interval = ((x($_POST,'delivery_interval')) ? intval(trim($_POST['delivery_interval'])) : 0);
  224. $poll_interval = ((x($_POST,'poll_interval')) ? intval(trim($_POST['poll_interval'])) : 0);
  225. $maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
  226. $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
  227. $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
  228. $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
  229. $ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
  230. $new_share = ((x($_POST,'new_share')) ? True : False);
  231. $use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
  232. $itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
  233. $itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
  234. $lockpath = ((x($_POST,'lockpath')) ? notags(trim($_POST['lockpath'])) : '');
  235. $temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
  236. $basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
  237. if($ssl_policy != intval(get_config('system','ssl_policy'))) {
  238. if($ssl_policy == SSL_POLICY_FULL) {
  239. q("update `contact` set
  240. `url` = replace(`url` , 'http:' , 'https:'),
  241. `photo` = replace(`photo` , 'http:' , 'https:'),
  242. `thumb` = replace(`thumb` , 'http:' , 'https:'),
  243. `micro` = replace(`micro` , 'http:' , 'https:'),
  244. `request` = replace(`request`, 'http:' , 'https:'),
  245. `notify` = replace(`notify` , 'http:' , 'https:'),
  246. `poll` = replace(`poll` , 'http:' , 'https:'),
  247. `confirm` = replace(`confirm`, 'http:' , 'https:'),
  248. `poco` = replace(`poco` , 'http:' , 'https:')
  249. where `self` = 1"
  250. );
  251. q("update `profile` set
  252. `photo` = replace(`photo` , 'http:' , 'https:'),
  253. `thumb` = replace(`thumb` , 'http:' , 'https:')
  254. where 1 "
  255. );
  256. }
  257. elseif($ssl_policy == SSL_POLICY_SELFSIGN) {
  258. q("update `contact` set
  259. `url` = replace(`url` , 'https:' , 'http:'),
  260. `photo` = replace(`photo` , 'https:' , 'http:'),
  261. `thumb` = replace(`thumb` , 'https:' , 'http:'),
  262. `micro` = replace(`micro` , 'https:' , 'http:'),
  263. `request` = replace(`request`, 'https:' , 'http:'),
  264. `notify` = replace(`notify` , 'https:' , 'http:'),
  265. `poll` = replace(`poll` , 'https:' , 'http:'),
  266. `confirm` = replace(`confirm`, 'https:' , 'http:'),
  267. `poco` = replace(`poco` , 'https:' , 'http:')
  268. where `self` = 1"
  269. );
  270. q("update `profile` set
  271. `photo` = replace(`photo` , 'https:' , 'http:'),
  272. `thumb` = replace(`thumb` , 'https:' , 'http:')
  273. where 1 "
  274. );
  275. }
  276. }
  277. set_config('system','ssl_policy',$ssl_policy);
  278. set_config('system','delivery_interval',$delivery_interval);
  279. set_config('system','poll_interval',$poll_interval);
  280. set_config('system','maxloadavg',$maxloadavg);
  281. set_config('config','sitename',$sitename);
  282. if ($banner==""){
  283. // don't know why, but del_config doesn't work...
  284. q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
  285. dbesc("system"),
  286. dbesc("banner")
  287. );
  288. } else {
  289. set_config('system','banner', $banner);
  290. }
  291. set_config('system','language', $language);
  292. set_config('system','theme', $theme);
  293. if ( $theme_mobile === '---' ) {
  294. del_config('system','mobile-theme');
  295. } else {
  296. set_config('system','mobile-theme', $theme_mobile);
  297. }
  298. set_config('system','maximagesize', $maximagesize);
  299. set_config('system','max_image_length', $maximagelength);
  300. set_config('system','jpeg_quality', $jpegimagequality);
  301. set_config('config','register_policy', $register_policy);
  302. set_config('system','max_daily_registrations', $daily_registrations);
  303. set_config('system','account_abandon_days', $abandon_days);
  304. set_config('config','register_text', $register_text);
  305. set_config('system','allowed_sites', $allowed_sites);
  306. set_config('system','allowed_email', $allowed_email);
  307. set_config('system','block_public', $block_public);
  308. set_config('system','publish_all', $force_publish);
  309. if ($global_directory==""){
  310. // don't know why, but del_config doesn't work...
  311. q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
  312. dbesc("system"),
  313. dbesc("directory_submit_url")
  314. );
  315. } else {
  316. set_config('system','directory_submit_url', $global_directory);
  317. }
  318. set_config('system','thread_allow', $thread_allow);
  319. set_config('system','newuser_private', $newuser_private);
  320. set_config('system','block_extended_register', $no_multi_reg);
  321. set_config('system','no_openid', $no_openid);
  322. set_config('system','no_regfullname', $no_regfullname);
  323. set_config('system','no_community_page', $no_community_page);
  324. set_config('system','no_utf', $no_utf);
  325. set_config('system','verifyssl', $verifyssl);
  326. set_config('system','proxyuser', $proxyuser);
  327. set_config('system','proxy', $proxy);
  328. set_config('system','curl_timeout', $timeout);
  329. set_config('system','dfrn_only', $dfrn_only);
  330. set_config('system','ostatus_disabled', $ostatus_disabled);
  331. set_config('system','diaspora_enabled', $diaspora_enabled);
  332. set_config('system','new_share', $new_share);
  333. set_config('system','use_fulltext_engine', $use_fulltext_engine);
  334. set_config('system','itemcache', $itemcache);
  335. set_config('system','itemcache_duration', $itemcache_duration);
  336. set_config('system','lockpath', $lockpath);
  337. set_config('system','temppath', $temppath);
  338. set_config('system','basepath', $basepath);
  339. info( t('Site settings updated.') . EOL);
  340. goaway($a->get_baseurl(true) . '/admin/site' );
  341. return; // NOTREACHED
  342. }
  343. /**
  344. * @param App $a
  345. * @return string
  346. */
  347. function admin_page_site(&$a) {
  348. /* Installed langs */
  349. $lang_choices = array();
  350. $langs = glob('view/*/strings.php');
  351. if(is_array($langs) && count($langs)) {
  352. if(! in_array('view/en/strings.php',$langs))
  353. $langs[] = 'view/en/';
  354. asort($langs);
  355. foreach($langs as $l) {
  356. $t = explode("/",$l);
  357. $lang_choices[$t[1]] = $t[1];
  358. }
  359. }
  360. /* Installed themes */
  361. $theme_choices = array();
  362. $theme_choices_mobile = array();
  363. $theme_choices_mobile["---"] = t("No special theme for mobile devices");
  364. $files = glob('view/theme/*');
  365. if($files) {
  366. foreach($files as $file) {
  367. $f = basename($file);
  368. $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
  369. if (file_exists($file . '/mobile')) {
  370. $theme_choices_mobile[$f] = $theme_name;
  371. }
  372. else {
  373. $theme_choices[$f] = $theme_name;
  374. }
  375. }
  376. }
  377. /* Banner */
  378. $banner = get_config('system','banner');
  379. if($banner == false)
  380. $banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
  381. $banner = htmlspecialchars($banner);
  382. //echo "<pre>"; var_dump($lang_choices); die("</pre>");
  383. /* Register policy */
  384. $register_choices = Array(
  385. REGISTER_CLOSED => t("Closed"),
  386. REGISTER_APPROVE => t("Requires approval"),
  387. REGISTER_OPEN => t("Open")
  388. );
  389. $ssl_choices = array(
  390. SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
  391. SSL_POLICY_FULL => t("Force all links to use SSL"),
  392. SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
  393. );
  394. $t = get_markup_template("admin_site.tpl");
  395. return replace_macros($t, array(
  396. '$title' => t('Administration'),
  397. '$page' => t('Site'),
  398. '$submit' => t('Submit'),
  399. '$registration' => t('Registration'),
  400. '$upload' => t('File upload'),
  401. '$corporate' => t('Policies'),
  402. '$advanced' => t('Advanced'),
  403. '$performance' => t('Performance'),
  404. '$baseurl' => $a->get_baseurl(true),
  405. // name, label, value, help string, extra data...
  406. '$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), 'UTF-8'),
  407. '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
  408. '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
  409. '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
  410. '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
  411. '$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
  412. '$new_share' => array('new_share', t("'Share' element"), get_config('system','new_share'), t("Activates the bbcode element 'share' for repeating items.")),
  413. '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
  414. '$maximagelength' => array('maximagelength', t("Maximum image length"), get_config('system','max_image_length'), t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")),
  415. '$jpegimagequality' => array('jpegimagequality', t("JPEG image quality"), get_config('system','jpeg_quality'), t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")),
  416. '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
  417. '$daily_registrations' => array('max_daily_registrations', t("Maximum Daily Registrations"), get_config('system', 'max_daily_registrations'), t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.")),
  418. '$register_text' => array('register_text', t("Register text"), htmlentities($a->config['register_text'], ENT_QUOTES, 'UTF-8'), t("Will be displayed prominently on the registration page.")),
  419. '$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), get_config('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')),
  420. '$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), get_config('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")),
  421. '$allowed_email' => array('allowed_email', t("Allowed email domains"), get_config('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")),
  422. '$block_public' => array('block_public', t("Block public"), get_config('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")),
  423. '$force_publish' => array('publish_all', t("Force publish"), get_config('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")),
  424. '$global_directory' => array('directory_submit_url', t("Global directory update URL"), get_config('system','directory_submit_url'), t("URL to update the global directory. If this is not set, the global directory is completely unavailable to the application.")),
  425. '$thread_allow' => array('thread_allow', t("Allow threaded items"), get_config('system','thread_allow'), t("Allow infinite level threading for items on this site.")),
  426. '$newuser_private' => array('newuser_private', t("Private posts by default for new users"), get_config('system','newuser_private'), t("Set default post permissions for all new members to the default privacy group rather than public.")),
  427. '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")),
  428. '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),
  429. '$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")),
  430. '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")),
  431. '$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), t("Display a Community page showing all recent public postings on this site.")),
  432. '$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disabled'), t("Provide built-in OStatus \x28identi.ca, status.net, etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")),
  433. '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")),
  434. '$dfrn_only' => array('dfrn_only', t('Only allow Friendica contacts'), get_config('system','dfrn_only'), t("All contacts must use Friendica protocols. All other built-in communication protocols disabled.")),
  435. '$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system','verifyssl'), t("If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.")),
  436. '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
  437. '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
  438. '$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
  439. '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")),
  440. '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")),
  441. '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
  442. '$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
  443. '$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), "The item caches buffers generated bbcode and external images."),
  444. '$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), get_config('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day).")),
  445. '$lockpath' => array('lockpath', t("Path for lock file"), get_config('system','lockpath'), "The lock file is used to avoid multiple pollers at one time. Only define a folder here."),
  446. '$temppath' => array('temppath', t("Temp path"), get_config('system','temppath'), "If you have a restricted system where the webserver can't access the system temp path, enter another path here."),
  447. '$basepath' => array('basepath', t("Base path to installation"), get_config('system','basepath'), "If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
  448. '$form_security_token' => get_form_security_token("admin_site"),
  449. ));
  450. }
  451. function admin_page_dbsync(&$a) {
  452. $o = '';
  453. if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') {
  454. set_config('database', 'update_' . intval($a->argv[3]), 'success');
  455. $curr = get_config('system','build');
  456. if(intval($curr) == intval($a->argv[3]))
  457. set_config('system','build',intval($curr) + 1);
  458. info( t('Update has been marked successful') . EOL);
  459. goaway($a->get_baseurl(true) . '/admin/dbsync');
  460. }
  461. if($a->argc > 2 && intval($a->argv[2])) {
  462. require_once('update.php');
  463. $func = 'update_' . intval($a->argv[2]);
  464. if(function_exists($func)) {
  465. $retval = $func();
  466. if($retval === UPDATE_FAILED) {
  467. $o .= sprintf( t('Executing %s failed. Check system logs.'), $func);
  468. }
  469. elseif($retval === UPDATE_SUCCESS) {
  470. $o .= sprintf( t('Update %s was successfully applied.', $func));
  471. set_config('database',$func, 'success');
  472. }
  473. else
  474. $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $func);
  475. }
  476. else
  477. $o .= sprintf( t('Update function %s could not be found.'), $func);
  478. return $o;
  479. }
  480. $failed = array();
  481. $r = q("select * from config where `cat` = 'database' ");
  482. if(count($r)) {
  483. foreach($r as $rr) {
  484. $upd = intval(substr($rr['k'],7));
  485. if($upd < 1139 || $rr['v'] === 'success')
  486. continue;
  487. $failed[] = $upd;
  488. }
  489. }
  490. if(! count($failed))
  491. return '<h3>' . t('No failed updates.') . '</h3>';
  492. $o = replace_macros(get_markup_template('failed_updates.tpl'),array(
  493. '$base' => $a->get_baseurl(true),
  494. '$banner' => t('Failed Updates'),
  495. '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
  496. '$mark' => t('Mark success (if update was manually applied)'),
  497. '$apply' => t('Attempt to execute this update step automatically'),
  498. '$failed' => $failed
  499. ));
  500. return $o;
  501. }
  502. /**
  503. * Users admin page
  504. *
  505. * @param App $a
  506. */
  507. function admin_page_users_post(&$a){
  508. $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() );
  509. $users = ( x($_POST, 'user') ? $_POST['user'] : Array() );
  510. check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
  511. if (x($_POST,'page_users_block')){
  512. foreach($users as $uid){
  513. q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
  514. intval( $uid )
  515. );
  516. }
  517. notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) );
  518. }
  519. if (x($_POST,'page_users_delete')){
  520. require_once("include/Contact.php");
  521. foreach($users as $uid){
  522. user_remove($uid);
  523. }
  524. notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) );
  525. }
  526. if (x($_POST,'page_users_approve')){
  527. require_once("mod/regmod.php");
  528. foreach($pending as $hash){
  529. user_allow($hash);
  530. }
  531. }
  532. if (x($_POST,'page_users_deny')){
  533. require_once("mod/regmod.php");
  534. foreach($pending as $hash){
  535. user_deny($hash);
  536. }
  537. }
  538. goaway($a->get_baseurl(true) . '/admin/users' );
  539. return; // NOTREACHED
  540. }
  541. /**
  542. * @param App $a
  543. * @return string
  544. */
  545. function admin_page_users(&$a){
  546. if ($a->argc>2) {
  547. $uid = $a->argv[3];
  548. $user = q("SELECT * FROM `user` WHERE `uid`=%d", intval($uid));
  549. if (count($user)==0){
  550. notice( 'User not found' . EOL);
  551. goaway($a->get_baseurl(true) . '/admin/users' );
  552. return ''; // NOTREACHED
  553. }
  554. switch($a->argv[2]){
  555. case "delete":{
  556. check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
  557. // delete user
  558. require_once("include/Contact.php");
  559. user_remove($uid);
  560. notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
  561. }; break;
  562. case "block":{
  563. check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
  564. q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
  565. intval( 1-$user[0]['blocked'] ),
  566. intval( $uid )
  567. );
  568. notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
  569. }; break;
  570. }
  571. goaway($a->get_baseurl(true) . '/admin/users' );
  572. return ''; // NOTREACHED
  573. }
  574. /* get pending */
  575. $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
  576. FROM `register`
  577. LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
  578. LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
  579. /* get users */
  580. $total = q("SELECT count(*) as total FROM `user` where 1");
  581. if(count($total)) {
  582. $a->set_pager_total($total[0]['total']);
  583. $a->set_pager_itemspage(100);
  584. }
  585. $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`
  586. FROM
  587. (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
  588. FROM `item`
  589. WHERE `item`.`type` = 'wall'
  590. GROUP BY `item`.`uid`) AS `lastitem`
  591. RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
  592. `contact`
  593. WHERE
  594. `user`.`uid` = `contact`.`uid`
  595. AND `user`.`verified` =1
  596. AND `contact`.`self` =1
  597. ORDER BY `contact`.`name` LIMIT %d, %d
  598. ",
  599. intval($a->pager['start']),
  600. intval($a->pager['itemspage'])
  601. );
  602. function _setup_users($e){
  603. $a = get_app();
  604. $accounts = Array(
  605. t('Normal Account'),
  606. t('Soapbox Account'),
  607. t('Community/Celebrity Account'),
  608. t('Automatic Friend Account')
  609. );
  610. $e['page-flags'] = $accounts[$e['page-flags']];
  611. $e['register_date'] = relative_date($e['register_date']);
  612. $e['login_date'] = relative_date($e['login_date']);
  613. $e['lastitem_date'] = relative_date($e['lastitem_date']);
  614. $e['is_admin'] = ($e['email'] === $a->config['admin_email']);
  615. return $e;
  616. }
  617. $users = array_map("_setup_users", $users);
  618. // Get rid of dashes in key names, Smarty3 can't handle them
  619. foreach($users as $key => $user) {
  620. $new_user = array();
  621. foreach($user as $k => $v) {
  622. $k = str_replace('-','_',$k);
  623. $new_user[$k] = $v;
  624. }
  625. $users[$key] = $new_user;
  626. }
  627. $t = get_markup_template("admin_users.tpl");
  628. $o = replace_macros($t, array(
  629. // strings //
  630. '$title' => t('Administration'),
  631. '$page' => t('Users'),
  632. '$submit' => t('Submit'),
  633. '$select_all' => t('select all'),
  634. '$h_pending' => t('User registrations waiting for confirm'),
  635. '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
  636. '$no_pending' => t('No registrations.'),
  637. '$approve' => t('Approve'),
  638. '$deny' => t('Deny'),
  639. '$delete' => t('Delete'),
  640. '$block' => t('Block'),
  641. '$unblock' => t('Unblock'),
  642. '$siteadmin' => t('Site admin'),
  643. '$h_users' => t('Users'),
  644. '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
  645. '$confirm_delete_multi' => t('Selected users will be deleted!\n\nEverything these users had posted on this site will be permanently deleted!\n\nAre you sure?'),
  646. '$confirm_delete' => t('The user {0} will be deleted!\n\nEverything this user has posted on this site will be permanently deleted!\n\nAre you sure?'),
  647. '$form_security_token' => get_form_security_token("admin_users"),
  648. // values //
  649. '$baseurl' => $a->get_baseurl(true),
  650. '$pending' => $pending,
  651. '$users' => $users,
  652. ));
  653. $o .= paginate($a);
  654. return $o;
  655. }
  656. /**
  657. * Plugins admin page
  658. *
  659. * @param App $a
  660. * @return string
  661. */
  662. function admin_page_plugins(&$a){
  663. /**
  664. * Single plugin
  665. */
  666. if ($a->argc == 3){
  667. $plugin = $a->argv[2];
  668. if (!is_file("addon/$plugin/$plugin.php")){
  669. notice( t("Item not found.") );
  670. return '';
  671. }
  672. if (x($_GET,"a") && $_GET['a']=="t"){
  673. check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
  674. // Toggle plugin status
  675. $idx = array_search($plugin, $a->plugins);
  676. if ($idx !== false){
  677. unset($a->plugins[$idx]);
  678. uninstall_plugin($plugin);
  679. info( sprintf( t("Plugin %s disabled."), $plugin ) );
  680. } else {
  681. $a->plugins[] = $plugin;
  682. install_plugin($plugin);
  683. info( sprintf( t("Plugin %s enabled."), $plugin ) );
  684. }
  685. set_config("system","addon", implode(", ",$a->plugins));
  686. goaway($a->get_baseurl(true) . '/admin/plugins' );
  687. return ''; // NOTREACHED
  688. }
  689. // display plugin details
  690. require_once('library/markdown.php');
  691. if (in_array($plugin, $a->plugins)){
  692. $status="on"; $action= t("Disable");
  693. } else {
  694. $status="off"; $action= t("Enable");
  695. }
  696. $readme=Null;
  697. if (is_file("addon/$plugin/README.md")){
  698. $readme = file_get_contents("addon/$plugin/README.md");
  699. $readme = Markdown($readme);
  700. } else if (is_file("addon/$plugin/README")){
  701. $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
  702. }
  703. $admin_form="";
  704. if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
  705. @require_once("addon/$plugin/$plugin.php");
  706. $func = $plugin.'_plugin_admin';
  707. $func($a, $admin_form);
  708. }
  709. $t = get_markup_template("admin_plugins_details.tpl");
  710. return replace_macros($t, array(
  711. '$title' => t('Administration'),
  712. '$page' => t('Plugins'),
  713. '$toggle' => t('Toggle'),
  714. '$settings' => t('Settings'),
  715. '$baseurl' => $a->get_baseurl(true),
  716. '$plugin' => $plugin,
  717. '$status' => $status,
  718. '$action' => $action,
  719. '$info' => get_plugin_info($plugin),
  720. '$str_author' => t('Author: '),
  721. '$str_maintainer' => t('Maintainer: '),
  722. '$admin_form' => $admin_form,
  723. '$function' => 'plugins',
  724. '$screenshot' => '',
  725. '$readme' => $readme,
  726. '$form_security_token' => get_form_security_token("admin_themes"),
  727. ));
  728. }
  729. /**
  730. * List plugins
  731. */
  732. $plugins = array();
  733. $files = glob("addon/*/");
  734. if($files) {
  735. foreach($files as $file) {
  736. if (is_dir($file)){
  737. list($tmp, $id)=array_map("trim", explode("/",$file));
  738. $info = get_plugin_info($id);
  739. $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
  740. }
  741. }
  742. }
  743. $t = get_markup_template("admin_plugins.tpl");
  744. return replace_macros($t, array(
  745. '$title' => t('Administration'),
  746. '$page' => t('Plugins'),
  747. '$submit' => t('Submit'),
  748. '$baseurl' => $a->get_baseurl(true),
  749. '$function' => 'plugins',
  750. '$plugins' => $plugins,
  751. '$form_security_token' => get_form_security_token("admin_themes"),
  752. ));
  753. }
  754. /**
  755. * @param array $themes
  756. * @param string $th
  757. * @param int $result
  758. */
  759. function toggle_theme(&$themes,$th,&$result) {
  760. for($x = 0; $x < count($themes); $x ++) {
  761. if($themes[$x]['name'] === $th) {
  762. if($themes[$x]['allowed']) {
  763. $themes[$x]['allowed'] = 0;
  764. $result = 0;
  765. }
  766. else {
  767. $themes[$x]['allowed'] = 1;
  768. $result = 1;
  769. }
  770. }
  771. }
  772. }
  773. /**
  774. * @param array $themes
  775. * @param string $th
  776. * @return int
  777. */
  778. function theme_status($themes,$th) {
  779. for($x = 0; $x < count($themes); $x ++) {
  780. if($themes[$x]['name'] === $th) {
  781. if($themes[$x]['allowed']) {
  782. return 1;
  783. }
  784. else {
  785. return 0;
  786. }
  787. }
  788. }
  789. return 0;
  790. }
  791. /**
  792. * @param array $themes
  793. * @return string
  794. */
  795. function rebuild_theme_table($themes) {
  796. $o = '';
  797. if(count($themes)) {
  798. foreach($themes as $th) {
  799. if($th['allowed']) {
  800. if(strlen($o))
  801. $o .= ',';
  802. $o .= $th['name'];
  803. }
  804. }
  805. }
  806. return $o;
  807. }
  808. /**
  809. * Themes admin page
  810. *
  811. * @param App $a
  812. * @return string
  813. */
  814. function admin_page_themes(&$a){
  815. $allowed_themes_str = get_config('system','allowed_themes');
  816. $allowed_themes_raw = explode(',',$allowed_themes_str);
  817. $allowed_themes = array();
  818. if(count($allowed_themes_raw))
  819. foreach($allowed_themes_raw as $x)
  820. if(strlen(trim($x)))
  821. $allowed_themes[] = trim($x);
  822. $themes = array();
  823. $files = glob('view/theme/*');
  824. if($files) {
  825. foreach($files as $file) {
  826. $f = basename($file);
  827. $is_experimental = intval(file_exists($file . '/experimental'));
  828. $is_supported = 1-(intval(file_exists($file . '/unsupported'))); // Is not used yet
  829. $is_allowed = intval(in_array($f,$allowed_themes));
  830. $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
  831. }
  832. }
  833. if(! count($themes)) {
  834. notice( t('No themes found.'));
  835. return '';
  836. }
  837. /**
  838. * Single theme
  839. */
  840. if ($a->argc == 3){
  841. $theme = $a->argv[2];
  842. if(! is_dir("view/theme/$theme")){
  843. notice( t("Item not found.") );
  844. return '';
  845. }
  846. if (x($_GET,"a") && $_GET['a']=="t"){
  847. check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
  848. // Toggle theme status
  849. toggle_theme($themes,$theme,$result);
  850. $s = rebuild_theme_table($themes);
  851. if($result)
  852. info( sprintf('Theme %s enabled.',$theme));
  853. else
  854. info( sprintf('Theme %s disabled.',$theme));
  855. set_config('system','allowed_themes',$s);
  856. goaway($a->get_baseurl(true) . '/admin/themes' );
  857. return ''; // NOTREACHED
  858. }
  859. // display theme details
  860. require_once('library/markdown.php');
  861. if (theme_status($themes,$theme)) {
  862. $status="on"; $action= t("Disable");
  863. } else {
  864. $status="off"; $action= t("Enable");
  865. }
  866. $readme=Null;
  867. if (is_file("view/theme/$theme/README.md")){
  868. $readme = file_get_contents("view/theme/$theme/README.md");
  869. $readme = Markdown($readme);
  870. } else if (is_file("view/theme/$theme/README")){
  871. $readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
  872. }
  873. $admin_form="";
  874. if (is_file("view/theme/$theme/config.php")){
  875. require_once("view/theme/$theme/config.php");
  876. if(function_exists("theme_admin")){
  877. $admin_form = theme_admin($a);
  878. }
  879. }
  880. $screenshot = array( get_theme_screenshot($theme), t('Screenshot'));
  881. if(! stristr($screenshot[0],$theme))
  882. $screenshot = null;
  883. $t = get_markup_template("admin_plugins_details.tpl");
  884. return replace_macros($t, array(
  885. '$title' => t('Administration'),
  886. '$page' => t('Themes'),
  887. '$toggle' => t('Toggle'),
  888. '$settings' => t('Settings'),
  889. '$baseurl' => $a->get_baseurl(true),
  890. '$plugin' => $theme,
  891. '$status' => $status,
  892. '$action' => $action,
  893. '$info' => get_theme_info($theme),
  894. '$function' => 'themes',
  895. '$admin_form' => $admin_form,
  896. '$str_author' => t('Author: '),
  897. '$str_maintainer' => t('Maintainer: '),
  898. '$screenshot' => $screenshot,
  899. '$readme' => $readme,
  900. '$form_security_token' => get_form_security_token("admin_themes"),
  901. ));
  902. }
  903. /**
  904. * List themes
  905. */
  906. $xthemes = array();
  907. if($themes) {
  908. foreach($themes as $th) {
  909. $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
  910. }
  911. }
  912. $t = get_markup_template("admin_plugins.tpl");
  913. return replace_macros($t, array(
  914. '$title' => t('Administration'),
  915. '$page' => t('Themes'),
  916. '$submit' => t('Submit'),
  917. '$baseurl' => $a->get_baseurl(true),
  918. '$function' => 'themes',
  919. '$plugins' => $xthemes,
  920. '$experimental' => t('[Experimental]'),
  921. '$unsupported' => t('[Unsupported]'),
  922. '$form_security_token' => get_form_security_token("admin_themes"),
  923. ));
  924. }
  925. /**
  926. * Logs admin page
  927. *
  928. * @param App $a
  929. */
  930. function admin_page_logs_post(&$a) {
  931. if (x($_POST,"page_logs")) {
  932. check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
  933. $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
  934. $debugging = ((x($_POST,'debugging')) ? true : false);
  935. $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
  936. set_config('system','logfile', $logfile);
  937. set_config('system','debugging', $debugging);
  938. set_config('system','loglevel', $loglevel);
  939. }
  940. info( t("Log settings updated.") );
  941. goaway($a->get_baseurl(true) . '/admin/logs' );
  942. return; // NOTREACHED
  943. }
  944. /**
  945. * @param App $a
  946. * @return string
  947. */
  948. function admin_page_logs(&$a){
  949. $log_choices = Array(
  950. LOGGER_NORMAL => 'Normal',
  951. LOGGER_TRACE => 'Trace',
  952. LOGGER_DEBUG => 'Debug',
  953. LOGGER_DATA => 'Data',
  954. LOGGER_ALL => 'All'
  955. );
  956. $t = get_markup_template("admin_logs.tpl");
  957. $f = get_config('system','logfile');
  958. $data = '';
  959. if(!file_exists($f)) {
  960. $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
  961. readable.");
  962. }
  963. else {
  964. $fp = fopen($f, 'r');
  965. if(!$fp) {
  966. $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
  967. }
  968. else {
  969. $fstat = fstat($fp);
  970. $size = $fstat['size'];
  971. if($size != 0)
  972. {
  973. if($size > 5000000 || $size < 0)
  974. $size = 5000000;
  975. $seek = fseek($fp,0-$size,SEEK_END);
  976. if($seek === 0) {
  977. $data = escape_tags(fread($fp,$size));
  978. while(! feof($fp))
  979. $data .= escape_tags(fread($fp,4096));
  980. }
  981. }
  982. fclose($fp);
  983. }
  984. }
  985. return replace_macros($t, array(
  986. '$title' => t('Administration'),
  987. '$page' => t('Logs'),
  988. '$submit' => t('Submit'),
  989. '$clear' => t('Clear'),
  990. '$data' => $data,
  991. '$baseurl' => $a->get_baseurl(true),
  992. '$logname' => get_config('system','logfile'),
  993. // name, label, value, help string, extra data...
  994. '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
  995. '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
  996. '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
  997. '$form_security_token' => get_form_security_token("admin_logs"),
  998. ));
  999. }
  1000. /**
  1001. * @param App $a
  1002. */
  1003. function admin_page_remoteupdate_post(&$a) {
  1004. // this function should be called via ajax post
  1005. if(!is_site_admin()) {
  1006. return;
  1007. }
  1008. if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
  1009. $remotefile = $_POST['remotefile'];
  1010. $ftpdata = (x($_POST['ftphost'])?$_POST:false);
  1011. doUpdate($remotefile, $ftpdata);
  1012. } else {
  1013. echo "No remote file to download. Abort!";
  1014. }
  1015. killme();
  1016. }
  1017. /**
  1018. * @param App $a
  1019. * @return string
  1020. */
  1021. function admin_page_remoteupdate(&$a) {
  1022. if(!is_site_admin()) {
  1023. return login(false);
  1024. }
  1025. $canwrite = canWeWrite();
  1026. $canftp = function_exists('ftp_connect');
  1027. $needupdate = true;
  1028. $u = checkUpdate();
  1029. if (!is_array($u)){
  1030. $needupdate = false;
  1031. $u = array('','','');
  1032. }
  1033. $tpl = get_markup_template("admin_remoteupdate.tpl");
  1034. return replace_macros($tpl, array(
  1035. '$baseurl' => $a->get_baseurl(true),
  1036. '$submit' => t("Update now"),
  1037. '$close' => t("Close"),
  1038. '$localversion' => FRIENDICA_VERSION,
  1039. '$remoteversion' => $u[1],
  1040. '$needupdate' => $needupdate,
  1041. '$canwrite' => $canwrite,
  1042. '$canftp' => $canftp,
  1043. '$ftphost' => array('ftphost', t("FTP Host"), '',''),
  1044. '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
  1045. '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
  1046. '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
  1047. '$remotefile'=>array('remotefile','', $u['2'],''),
  1048. ));
  1049. }