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.
 
 
 
 
 
 

1231 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. $hide_help = ((x($_POST,'hide_help')) ? True : False);
  232. $use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
  233. $itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
  234. $itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
  235. $lockpath = ((x($_POST,'lockpath')) ? notags(trim($_POST['lockpath'])) : '');
  236. $temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
  237. $basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
  238. if($ssl_policy != intval(get_config('system','ssl_policy'))) {
  239. if($ssl_policy == SSL_POLICY_FULL) {
  240. q("update `contact` set
  241. `url` = replace(`url` , 'http:' , 'https:'),
  242. `photo` = replace(`photo` , 'http:' , 'https:'),
  243. `thumb` = replace(`thumb` , 'http:' , 'https:'),
  244. `micro` = replace(`micro` , 'http:' , 'https:'),
  245. `request` = replace(`request`, 'http:' , 'https:'),
  246. `notify` = replace(`notify` , 'http:' , 'https:'),
  247. `poll` = replace(`poll` , 'http:' , 'https:'),
  248. `confirm` = replace(`confirm`, 'http:' , 'https:'),
  249. `poco` = replace(`poco` , 'http:' , 'https:')
  250. where `self` = 1"
  251. );
  252. q("update `profile` set
  253. `photo` = replace(`photo` , 'http:' , 'https:'),
  254. `thumb` = replace(`thumb` , 'http:' , 'https:')
  255. where 1 "
  256. );
  257. }
  258. elseif($ssl_policy == SSL_POLICY_SELFSIGN) {
  259. q("update `contact` set
  260. `url` = replace(`url` , 'https:' , 'http:'),
  261. `photo` = replace(`photo` , 'https:' , 'http:'),
  262. `thumb` = replace(`thumb` , 'https:' , 'http:'),
  263. `micro` = replace(`micro` , 'https:' , 'http:'),
  264. `request` = replace(`request`, 'https:' , 'http:'),
  265. `notify` = replace(`notify` , 'https:' , 'http:'),
  266. `poll` = replace(`poll` , 'https:' , 'http:'),
  267. `confirm` = replace(`confirm`, 'https:' , 'http:'),
  268. `poco` = replace(`poco` , 'https:' , 'http:')
  269. where `self` = 1"
  270. );
  271. q("update `profile` set
  272. `photo` = replace(`photo` , 'https:' , 'http:'),
  273. `thumb` = replace(`thumb` , 'https:' , 'http:')
  274. where 1 "
  275. );
  276. }
  277. }
  278. set_config('system','ssl_policy',$ssl_policy);
  279. set_config('system','delivery_interval',$delivery_interval);
  280. set_config('system','poll_interval',$poll_interval);
  281. set_config('system','maxloadavg',$maxloadavg);
  282. set_config('config','sitename',$sitename);
  283. if ($banner==""){
  284. // don't know why, but del_config doesn't work...
  285. q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
  286. dbesc("system"),
  287. dbesc("banner")
  288. );
  289. } else {
  290. set_config('system','banner', $banner);
  291. }
  292. set_config('system','language', $language);
  293. set_config('system','theme', $theme);
  294. if ( $theme_mobile === '---' ) {
  295. del_config('system','mobile-theme');
  296. } else {
  297. set_config('system','mobile-theme', $theme_mobile);
  298. }
  299. set_config('system','maximagesize', $maximagesize);
  300. set_config('system','max_image_length', $maximagelength);
  301. set_config('system','jpeg_quality', $jpegimagequality);
  302. set_config('config','register_policy', $register_policy);
  303. set_config('system','max_daily_registrations', $daily_registrations);
  304. set_config('system','account_abandon_days', $abandon_days);
  305. set_config('config','register_text', $register_text);
  306. set_config('system','allowed_sites', $allowed_sites);
  307. set_config('system','allowed_email', $allowed_email);
  308. set_config('system','block_public', $block_public);
  309. set_config('system','publish_all', $force_publish);
  310. if ($global_directory==""){
  311. // don't know why, but del_config doesn't work...
  312. q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
  313. dbesc("system"),
  314. dbesc("directory_submit_url")
  315. );
  316. } else {
  317. set_config('system','directory_submit_url', $global_directory);
  318. }
  319. set_config('system','thread_allow', $thread_allow);
  320. set_config('system','newuser_private', $newuser_private);
  321. set_config('system','block_extended_register', $no_multi_reg);
  322. set_config('system','no_openid', $no_openid);
  323. set_config('system','no_regfullname', $no_regfullname);
  324. set_config('system','no_community_page', $no_community_page);
  325. set_config('system','no_utf', $no_utf);
  326. set_config('system','verifyssl', $verifyssl);
  327. set_config('system','proxyuser', $proxyuser);
  328. set_config('system','proxy', $proxy);
  329. set_config('system','curl_timeout', $timeout);
  330. set_config('system','dfrn_only', $dfrn_only);
  331. set_config('system','ostatus_disabled', $ostatus_disabled);
  332. set_config('system','diaspora_enabled', $diaspora_enabled);
  333. set_config('system','new_share', $new_share);
  334. set_config('system','hide_help', $hide_help);
  335. set_config('system','use_fulltext_engine', $use_fulltext_engine);
  336. set_config('system','itemcache', $itemcache);
  337. set_config('system','itemcache_duration', $itemcache_duration);
  338. set_config('system','lockpath', $lockpath);
  339. set_config('system','temppath', $temppath);
  340. set_config('system','basepath', $basepath);
  341. info( t('Site settings updated.') . EOL);
  342. goaway($a->get_baseurl(true) . '/admin/site' );
  343. return; // NOTREACHED
  344. }
  345. /**
  346. * @param App $a
  347. * @return string
  348. */
  349. function admin_page_site(&$a) {
  350. /* Installed langs */
  351. $lang_choices = array();
  352. $langs = glob('view/*/strings.php');
  353. if(is_array($langs) && count($langs)) {
  354. if(! in_array('view/en/strings.php',$langs))
  355. $langs[] = 'view/en/';
  356. asort($langs);
  357. foreach($langs as $l) {
  358. $t = explode("/",$l);
  359. $lang_choices[$t[1]] = $t[1];
  360. }
  361. }
  362. /* Installed themes */
  363. $theme_choices = array();
  364. $theme_choices_mobile = array();
  365. $theme_choices_mobile["---"] = t("No special theme for mobile devices");
  366. $files = glob('view/theme/*');
  367. if($files) {
  368. foreach($files as $file) {
  369. $f = basename($file);
  370. $theme_name = ((file_exists($file . '/experimental')) ? sprintf("%s - \x28Experimental\x29", $f) : $f);
  371. if (file_exists($file . '/mobile')) {
  372. $theme_choices_mobile[$f] = $theme_name;
  373. }
  374. else {
  375. $theme_choices[$f] = $theme_name;
  376. }
  377. }
  378. }
  379. /* Banner */
  380. $banner = get_config('system','banner');
  381. if($banner == false)
  382. $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>';
  383. $banner = htmlspecialchars($banner);
  384. //echo "<pre>"; var_dump($lang_choices); die("</pre>");
  385. /* Register policy */
  386. $register_choices = Array(
  387. REGISTER_CLOSED => t("Closed"),
  388. REGISTER_APPROVE => t("Requires approval"),
  389. REGISTER_OPEN => t("Open")
  390. );
  391. $ssl_choices = array(
  392. SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
  393. SSL_POLICY_FULL => t("Force all links to use SSL"),
  394. SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
  395. );
  396. $t = get_markup_template("admin_site.tpl");
  397. return replace_macros($t, array(
  398. '$title' => t('Administration'),
  399. '$page' => t('Site'),
  400. '$submit' => t('Submit'),
  401. '$registration' => t('Registration'),
  402. '$upload' => t('File upload'),
  403. '$corporate' => t('Policies'),
  404. '$advanced' => t('Advanced'),
  405. '$performance' => t('Performance'),
  406. '$baseurl' => $a->get_baseurl(true),
  407. // name, label, value, help string, extra data...
  408. '$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), 'UTF-8'),
  409. '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
  410. '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
  411. '$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),
  412. '$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
  413. '$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),
  414. '$new_share' => array('new_share', t("'Share' element"), get_config('system','new_share'), t("Activates the bbcode element 'share' for repeating items.")),
  415. '$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
  416. '$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.")),
  417. '$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.")),
  418. '$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.")),
  419. '$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices),
  420. '$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.")),
  421. '$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.")),
  422. '$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.')),
  423. '$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")),
  424. '$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")),
  425. '$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.")),
  426. '$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.")),
  427. '$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.")),
  428. '$thread_allow' => array('thread_allow', t("Allow threaded items"), get_config('system','thread_allow'), t("Allow infinite level threading for items on this site.")),
  429. '$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.")),
  430. '$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.")),
  431. '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),
  432. '$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")),
  433. '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")),
  434. '$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.")),
  435. '$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.")),
  436. '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")),
  437. '$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.")),
  438. '$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.")),
  439. '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
  440. '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
  441. '$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).")),
  442. '$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.")),
  443. '$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.")),
  444. '$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.")),
  445. '$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.")),
  446. '$itemcache' => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), "The item caches buffers generated bbcode and external images."),
  447. '$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).")),
  448. '$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."),
  449. '$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."),
  450. '$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."),
  451. '$form_security_token' => get_form_security_token("admin_site"),
  452. ));
  453. }
  454. function admin_page_dbsync(&$a) {
  455. $o = '';
  456. if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') {
  457. set_config('database', 'update_' . intval($a->argv[3]), 'success');
  458. $curr = get_config('system','build');
  459. if(intval($curr) == intval($a->argv[3]))
  460. set_config('system','build',intval($curr) + 1);
  461. info( t('Update has been marked successful') . EOL);
  462. goaway($a->get_baseurl(true) . '/admin/dbsync');
  463. }
  464. if($a->argc > 2 && intval($a->argv[2])) {
  465. require_once('update.php');
  466. $func = 'update_' . intval($a->argv[2]);
  467. if(function_exists($func)) {
  468. $retval = $func();
  469. if($retval === UPDATE_FAILED) {
  470. $o .= sprintf( t('Executing %s failed. Check system logs.'), $func);
  471. }
  472. elseif($retval === UPDATE_SUCCESS) {
  473. $o .= sprintf( t('Update %s was successfully applied.', $func));
  474. set_config('database',$func, 'success');
  475. }
  476. else
  477. $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $func);
  478. }
  479. else
  480. $o .= sprintf( t('Update function %s could not be found.'), $func);
  481. return $o;
  482. }
  483. $failed = array();
  484. $r = q("select * from config where `cat` = 'database' ");
  485. if(count($r)) {
  486. foreach($r as $rr) {
  487. $upd = intval(substr($rr['k'],7));
  488. if($upd < 1139 || $rr['v'] === 'success')
  489. continue;
  490. $failed[] = $upd;
  491. }
  492. }
  493. if(! count($failed))
  494. return '<h3>' . t('No failed updates.') . '</h3>';
  495. $o = replace_macros(get_markup_template('failed_updates.tpl'),array(
  496. '$base' => $a->get_baseurl(true),
  497. '$banner' => t('Failed Updates'),
  498. '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
  499. '$mark' => t('Mark success (if update was manually applied)'),
  500. '$apply' => t('Attempt to execute this update step automatically'),
  501. '$failed' => $failed
  502. ));
  503. return $o;
  504. }
  505. /**
  506. * Users admin page
  507. *
  508. * @param App $a
  509. */
  510. function admin_page_users_post(&$a){
  511. $pending = ( x($_POST, 'pending') ? $_POST['pending'] : Array() );
  512. $users = ( x($_POST, 'user') ? $_POST['user'] : Array() );
  513. check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
  514. if (x($_POST,'page_users_block')){
  515. foreach($users as $uid){
  516. q("UPDATE `user` SET `blocked`=1-`blocked` WHERE `uid`=%s",
  517. intval( $uid )
  518. );
  519. }
  520. notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) );
  521. }
  522. if (x($_POST,'page_users_delete')){
  523. require_once("include/Contact.php");
  524. foreach($users as $uid){
  525. user_remove($uid);
  526. }
  527. notice( sprintf( tt("%s user deleted", "%s users deleted", count($users)), count($users)) );
  528. }
  529. if (x($_POST,'page_users_approve')){
  530. require_once("mod/regmod.php");
  531. foreach($pending as $hash){
  532. user_allow($hash);
  533. }
  534. }
  535. if (x($_POST,'page_users_deny')){
  536. require_once("mod/regmod.php");
  537. foreach($pending as $hash){
  538. user_deny($hash);
  539. }
  540. }
  541. goaway($a->get_baseurl(true) . '/admin/users' );
  542. return; // NOTREACHED
  543. }
  544. /**
  545. * @param App $a
  546. * @return string
  547. */
  548. function admin_page_users(&$a){
  549. if ($a->argc>2) {
  550. $uid = $a->argv[3];
  551. $user = q("SELECT * FROM `user` WHERE `uid`=%d", intval($uid));
  552. if (count($user)==0){
  553. notice( 'User not found' . EOL);
  554. goaway($a->get_baseurl(true) . '/admin/users' );
  555. return ''; // NOTREACHED
  556. }
  557. switch($a->argv[2]){
  558. case "delete":{
  559. check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
  560. // delete user
  561. require_once("include/Contact.php");
  562. user_remove($uid);
  563. notice( sprintf(t("User '%s' deleted"), $user[0]['username']) . EOL);
  564. }; break;
  565. case "block":{
  566. check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
  567. q("UPDATE `user` SET `blocked`=%d WHERE `uid`=%s",
  568. intval( 1-$user[0]['blocked'] ),
  569. intval( $uid )
  570. );
  571. notice( sprintf( ($user[0]['blocked']?t("User '%s' unblocked"):t("User '%s' blocked")) , $user[0]['username']) . EOL);
  572. }; break;
  573. }
  574. goaway($a->get_baseurl(true) . '/admin/users' );
  575. return ''; // NOTREACHED
  576. }
  577. /* get pending */
  578. $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
  579. FROM `register`
  580. LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid`
  581. LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;");
  582. /* get users */
  583. $total = q("SELECT count(*) as total FROM `user` where 1");
  584. if(count($total)) {
  585. $a->set_pager_total($total[0]['total']);
  586. $a->set_pager_itemspage(100);
  587. }
  588. $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`
  589. FROM
  590. (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
  591. FROM `item`
  592. WHERE `item`.`type` = 'wall'
  593. GROUP BY `item`.`uid`) AS `lastitem`
  594. RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
  595. `contact`
  596. WHERE
  597. `user`.`uid` = `contact`.`uid`
  598. AND `user`.`verified` =1
  599. AND `contact`.`self` =1
  600. ORDER BY `contact`.`name` LIMIT %d, %d
  601. ",
  602. intval($a->pager['start']),
  603. intval($a->pager['itemspage'])
  604. );
  605. function _setup_users($e){
  606. $a = get_app();
  607. $accounts = Array(
  608. t('Normal Account'),
  609. t('Soapbox Account'),
  610. t('Community/Celebrity Account'),
  611. t('Automatic Friend Account')
  612. );
  613. $e['page-flags'] = $accounts[$e['page-flags']];
  614. $e['register_date'] = relative_date($e['register_date']);
  615. $e['login_date'] = relative_date($e['login_date']);
  616. $e['lastitem_date'] = relative_date($e['lastitem_date']);
  617. $e['is_admin'] = ($e['email'] === $a->config['admin_email']);
  618. return $e;
  619. }
  620. $users = array_map("_setup_users", $users);
  621. // Get rid of dashes in key names, Smarty3 can't handle them
  622. foreach($users as $key => $user) {
  623. $new_user = array();
  624. foreach($user as $k => $v) {
  625. $k = str_replace('-','_',$k);
  626. $new_user[$k] = $v;
  627. }
  628. $users[$key] = $new_user;
  629. }
  630. $t = get_markup_template("admin_users.tpl");
  631. $o = replace_macros($t, array(
  632. // strings //
  633. '$title' => t('Administration'),
  634. '$page' => t('Users'),
  635. '$submit' => t('Submit'),
  636. '$select_all' => t('select all'),
  637. '$h_pending' => t('User registrations waiting for confirm'),
  638. '$th_pending' => array( t('Request date'), t('Name'), t('Email') ),
  639. '$no_pending' => t('No registrations.'),
  640. '$approve' => t('Approve'),
  641. '$deny' => t('Deny'),
  642. '$delete' => t('Delete'),
  643. '$block' => t('Block'),
  644. '$unblock' => t('Unblock'),
  645. '$siteadmin' => t('Site admin'),
  646. '$h_users' => t('Users'),
  647. '$th_users' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account') ),
  648. '$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?'),
  649. '$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?'),
  650. '$form_security_token' => get_form_security_token("admin_users"),
  651. // values //
  652. '$baseurl' => $a->get_baseurl(true),
  653. '$pending' => $pending,
  654. '$users' => $users,
  655. ));
  656. $o .= paginate($a);
  657. return $o;
  658. }
  659. /**
  660. * Plugins admin page
  661. *
  662. * @param App $a
  663. * @return string
  664. */
  665. function admin_page_plugins(&$a){
  666. /**
  667. * Single plugin
  668. */
  669. if ($a->argc == 3){
  670. $plugin = $a->argv[2];
  671. if (!is_file("addon/$plugin/$plugin.php")){
  672. notice( t("Item not found.") );
  673. return '';
  674. }
  675. if (x($_GET,"a") && $_GET['a']=="t"){
  676. check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
  677. // Toggle plugin status
  678. $idx = array_search($plugin, $a->plugins);
  679. if ($idx !== false){
  680. unset($a->plugins[$idx]);
  681. uninstall_plugin($plugin);
  682. info( sprintf( t("Plugin %s disabled."), $plugin ) );
  683. } else {
  684. $a->plugins[] = $plugin;
  685. install_plugin($plugin);
  686. info( sprintf( t("Plugin %s enabled."), $plugin ) );
  687. }
  688. set_config("system","addon", implode(", ",$a->plugins));
  689. goaway($a->get_baseurl(true) . '/admin/plugins' );
  690. return ''; // NOTREACHED
  691. }
  692. // display plugin details
  693. require_once('library/markdown.php');
  694. if (in_array($plugin, $a->plugins)){
  695. $status="on"; $action= t("Disable");
  696. } else {
  697. $status="off"; $action= t("Enable");
  698. }
  699. $readme=Null;
  700. if (is_file("addon/$plugin/README.md")){
  701. $readme = file_get_contents("addon/$plugin/README.md");
  702. $readme = Markdown($readme);
  703. } else if (is_file("addon/$plugin/README")){
  704. $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
  705. }
  706. $admin_form="";
  707. if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
  708. @require_once("addon/$plugin/$plugin.php");
  709. $func = $plugin.'_plugin_admin';
  710. $func($a, $admin_form);
  711. }
  712. $t = get_markup_template("admin_plugins_details.tpl");
  713. return replace_macros($t, array(
  714. '$title' => t('Administration'),
  715. '$page' => t('Plugins'),
  716. '$toggle' => t('Toggle'),
  717. '$settings' => t('Settings'),
  718. '$baseurl' => $a->get_baseurl(true),
  719. '$plugin' => $plugin,
  720. '$status' => $status,
  721. '$action' => $action,
  722. '$info' => get_plugin_info($plugin),
  723. '$str_author' => t('Author: '),
  724. '$str_maintainer' => t('Maintainer: '),
  725. '$admin_form' => $admin_form,
  726. '$function' => 'plugins',
  727. '$screenshot' => '',
  728. '$readme' => $readme,
  729. '$form_security_token' => get_form_security_token("admin_themes"),
  730. ));
  731. }
  732. /**
  733. * List plugins
  734. */
  735. $plugins = array();
  736. $files = glob("addon/*/");
  737. if($files) {
  738. foreach($files as $file) {
  739. if (is_dir($file)){
  740. list($tmp, $id)=array_map("trim", explode("/",$file));
  741. $info = get_plugin_info($id);
  742. $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
  743. }
  744. }
  745. }
  746. $t = get_markup_template("admin_plugins.tpl");
  747. return replace_macros($t, array(
  748. '$title' => t('Administration'),
  749. '$page' => t('Plugins'),
  750. '$submit' => t('Submit'),
  751. '$baseurl' => $a->get_baseurl(true),
  752. '$function' => 'plugins',
  753. '$plugins' => $plugins,
  754. '$form_security_token' => get_form_security_token("admin_themes"),
  755. ));
  756. }
  757. /**
  758. * @param array $themes
  759. * @param string $th
  760. * @param int $result
  761. */
  762. function toggle_theme(&$themes,$th,&$result) {
  763. for($x = 0; $x < count($themes); $x ++) {
  764. if($themes[$x]['name'] === $th) {
  765. if($themes[$x]['allowed']) {
  766. $themes[$x]['allowed'] = 0;
  767. $result = 0;
  768. }
  769. else {
  770. $themes[$x]['allowed'] = 1;
  771. $result = 1;
  772. }
  773. }
  774. }
  775. }
  776. /**
  777. * @param array $themes
  778. * @param string $th
  779. * @return int
  780. */
  781. function theme_status($themes,$th) {
  782. for($x = 0; $x < count($themes); $x ++) {
  783. if($themes[$x]['name'] === $th) {
  784. if($themes[$x]['allowed']) {
  785. return 1;
  786. }
  787. else {
  788. return 0;
  789. }
  790. }
  791. }
  792. return 0;
  793. }
  794. /**
  795. * @param array $themes
  796. * @return string
  797. */
  798. function rebuild_theme_table($themes) {
  799. $o = '';
  800. if(count($themes)) {
  801. foreach($themes as $th) {
  802. if($th['allowed']) {
  803. if(strlen($o))
  804. $o .= ',';
  805. $o .= $th['name'];
  806. }
  807. }
  808. }
  809. return $o;
  810. }
  811. /**
  812. * Themes admin page
  813. *
  814. * @param App $a
  815. * @return string
  816. */
  817. function admin_page_themes(&$a){
  818. $allowed_themes_str = get_config('system','allowed_themes');
  819. $allowed_themes_raw = explode(',',$allowed_themes_str);
  820. $allowed_themes = array();
  821. if(count($allowed_themes_raw))
  822. foreach($allowed_themes_raw as $x)
  823. if(strlen(trim($x)))
  824. $allowed_themes[] = trim($x);
  825. $themes = array();
  826. $files = glob('view/theme/*');
  827. if($files) {
  828. foreach($files as $file) {
  829. $f = basename($file);
  830. $is_experimental = intval(file_exists($file . '/experimental'));
  831. $is_supported = 1-(intval(file_exists($file . '/unsupported'))); // Is not used yet
  832. $is_allowed = intval(in_array($f,$allowed_themes));
  833. $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
  834. }
  835. }
  836. if(! count($themes)) {
  837. notice( t('No themes found.'));
  838. return '';
  839. }
  840. /**
  841. * Single theme
  842. */
  843. if ($a->argc == 3){
  844. $theme = $a->argv[2];
  845. if(! is_dir("view/theme/$theme")){
  846. notice( t("Item not found.") );
  847. return '';
  848. }
  849. if (x($_GET,"a") && $_GET['a']=="t"){
  850. check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't');
  851. // Toggle theme status
  852. toggle_theme($themes,$theme,$result);
  853. $s = rebuild_theme_table($themes);
  854. if($result) {
  855. install_theme($theme);
  856. info( sprintf('Theme %s enabled.',$theme));
  857. }
  858. else {
  859. uninstall_theme($theme);
  860. info( sprintf('Theme %s disabled.',$theme));
  861. }
  862. set_config('system','allowed_themes',$s);
  863. goaway($a->get_baseurl(true) . '/admin/themes' );
  864. return ''; // NOTREACHED
  865. }
  866. // display theme details
  867. require_once('library/markdown.php');
  868. if (theme_status($themes,$theme)) {
  869. $status="on"; $action= t("Disable");
  870. } else {
  871. $status="off"; $action= t("Enable");
  872. }
  873. $readme=Null;
  874. if (is_file("view/theme/$theme/README.md")){
  875. $readme = file_get_contents("view/theme/$theme/README.md");
  876. $readme = Markdown($readme);
  877. } else if (is_file("view/theme/$theme/README")){
  878. $readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
  879. }
  880. $admin_form="";
  881. if (is_file("view/theme/$theme/config.php")){
  882. require_once("view/theme/$theme/config.php");
  883. if(function_exists("theme_admin")){
  884. $admin_form = theme_admin($a);
  885. }
  886. }
  887. $screenshot = array( get_theme_screenshot($theme), t('Screenshot'));
  888. if(! stristr($screenshot[0],$theme))
  889. $screenshot = null;
  890. $t = get_markup_template("admin_plugins_details.tpl");
  891. return replace_macros($t, array(
  892. '$title' => t('Administration'),
  893. '$page' => t('Themes'),
  894. '$toggle' => t('Toggle'),
  895. '$settings' => t('Settings'),
  896. '$baseurl' => $a->get_baseurl(true),
  897. '$plugin' => $theme,
  898. '$status' => $status,
  899. '$action' => $action,
  900. '$info' => get_theme_info($theme),
  901. '$function' => 'themes',
  902. '$admin_form' => $admin_form,
  903. '$str_author' => t('Author: '),
  904. '$str_maintainer' => t('Maintainer: '),
  905. '$screenshot' => $screenshot,
  906. '$readme' => $readme,
  907. '$form_security_token' => get_form_security_token("admin_themes"),
  908. ));
  909. }
  910. /**
  911. * List themes
  912. */
  913. $xthemes = array();
  914. if($themes) {
  915. foreach($themes as $th) {
  916. $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
  917. }
  918. }
  919. $t = get_markup_template("admin_plugins.tpl");
  920. return replace_macros($t, array(
  921. '$title' => t('Administration'),
  922. '$page' => t('Themes'),
  923. '$submit' => t('Submit'),
  924. '$baseurl' => $a->get_baseurl(true),
  925. '$function' => 'themes',
  926. '$plugins' => $xthemes,
  927. '$experimental' => t('[Experimental]'),
  928. '$unsupported' => t('[Unsupported]'),
  929. '$form_security_token' => get_form_security_token("admin_themes"),
  930. ));
  931. }
  932. /**
  933. * Logs admin page
  934. *
  935. * @param App $a
  936. */
  937. function admin_page_logs_post(&$a) {
  938. if (x($_POST,"page_logs")) {
  939. check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
  940. $logfile = ((x($_POST,'logfile')) ? notags(trim($_POST['logfile'])) : '');
  941. $debugging = ((x($_POST,'debugging')) ? true : false);
  942. $loglevel = ((x($_POST,'loglevel')) ? intval(trim($_POST['loglevel'])) : 0);
  943. set_config('system','logfile', $logfile);
  944. set_config('system','debugging', $debugging);
  945. set_config('system','loglevel', $loglevel);
  946. }
  947. info( t("Log settings updated.") );
  948. goaway($a->get_baseurl(true) . '/admin/logs' );
  949. return; // NOTREACHED
  950. }
  951. /**
  952. * @param App $a
  953. * @return string
  954. */
  955. function admin_page_logs(&$a){
  956. $log_choices = Array(
  957. LOGGER_NORMAL => 'Normal',
  958. LOGGER_TRACE => 'Trace',
  959. LOGGER_DEBUG => 'Debug',
  960. LOGGER_DATA => 'Data',
  961. LOGGER_ALL => 'All'
  962. );
  963. $t = get_markup_template("admin_logs.tpl");
  964. $f = get_config('system','logfile');
  965. $data = '';
  966. if(!file_exists($f)) {
  967. $data = t("Error trying to open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f exist and is
  968. readable.");
  969. }
  970. else {
  971. $fp = fopen($f, 'r');
  972. if(!$fp) {
  973. $data = t("Couldn't open <strong>$f</strong> log file.\r\n<br/>Check to see if file $f is readable.");
  974. }
  975. else {
  976. $fstat = fstat($fp);
  977. $size = $fstat['size'];
  978. if($size != 0)
  979. {
  980. if($size > 5000000 || $size < 0)
  981. $size = 5000000;
  982. $seek = fseek($fp,0-$size,SEEK_END);
  983. if($seek === 0) {
  984. $data = escape_tags(fread($fp,$size));
  985. while(! feof($fp))
  986. $data .= escape_tags(fread($fp,4096));
  987. }
  988. }
  989. fclose($fp);
  990. }
  991. }
  992. return replace_macros($t, array(
  993. '$title' => t('Administration'),
  994. '$page' => t('Logs'),
  995. '$submit' => t('Submit'),
  996. '$clear' => t('Clear'),
  997. '$data' => $data,
  998. '$baseurl' => $a->get_baseurl(true),
  999. '$logname' => get_config('system','logfile'),
  1000. // name, label, value, help string, extra data...
  1001. '$debugging' => array('debugging', t("Debugging"),get_config('system','debugging'), ""),
  1002. '$logfile' => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
  1003. '$loglevel' => array('loglevel', t("Log level"), get_config('system','loglevel'), "", $log_choices),
  1004. '$form_security_token' => get_form_security_token("admin_logs"),
  1005. ));
  1006. }
  1007. /**
  1008. * @param App $a
  1009. */
  1010. function admin_page_remoteupdate_post(&$a) {
  1011. // this function should be called via ajax post
  1012. if(!is_site_admin()) {
  1013. return;
  1014. }
  1015. if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
  1016. $remotefile = $_POST['remotefile'];
  1017. $ftpdata = (x($_POST['ftphost'])?$_POST:false);
  1018. doUpdate($remotefile, $ftpdata);
  1019. } else {
  1020. echo "No remote file to download. Abort!";
  1021. }
  1022. killme();
  1023. }
  1024. /**
  1025. * @param App $a
  1026. * @return string
  1027. */
  1028. function admin_page_remoteupdate(&$a) {
  1029. if(!is_site_admin()) {
  1030. return login(false);
  1031. }
  1032. $canwrite = canWeWrite();
  1033. $canftp = function_exists('ftp_connect');
  1034. $needupdate = true;
  1035. $u = checkUpdate();
  1036. if (!is_array($u)){
  1037. $needupdate = false;
  1038. $u = array('','','');
  1039. }
  1040. $tpl = get_markup_template("admin_remoteupdate.tpl");
  1041. return replace_macros($tpl, array(
  1042. '$baseurl' => $a->get_baseurl(true),
  1043. '$submit' => t("Update now"),
  1044. '$close' => t("Close"),
  1045. '$localversion' => FRIENDICA_VERSION,
  1046. '$remoteversion' => $u[1],
  1047. '$needupdate' => $needupdate,
  1048. '$canwrite' => $canwrite,
  1049. '$canftp' => $canftp,
  1050. '$ftphost' => array('ftphost', t("FTP Host"), '',''),
  1051. '$ftppath' => array('ftppath', t("FTP Path"), '/',''),
  1052. '$ftpuser' => array('ftpuser', t("FTP User"), '',''),
  1053. '$ftppwd' => array('ftppwd', t("FTP Password"), '',''),
  1054. '$remotefile'=>array('remotefile','', $u['2'],''),
  1055. ));
  1056. }