]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
Merge remote-tracking branch 'upstream/master'
[friendica.git] / mod / admin.php
index b7d5a5063690b2a930a850f950266481f4d7ff50..fa4f6d7fb4d4d7b4bafb3c529c5a841e47745768 100644 (file)
@@ -33,7 +33,7 @@ function admin_post(&$a){
                                admin_page_users_post($a);
                                break;
                        case 'plugins':
-                               if ($a->argc > 2 && 
+                               if ($a->argc > 2 &&
                                        is_file("addon/".$a->argv[2]."/".$a->argv[2].".php")){
                                                @include_once("addon/".$a->argv[2]."/".$a->argv[2].".php");
                                                if(function_exists($a->argv[2].'_plugin_admin_post')) {
@@ -87,10 +87,11 @@ function admin_content(&$a) {
        if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
                return "";
 
-       if (function_exists("apc_delete")) {
-               $toDelete = new APCIterator('user', APC_ITER_VALUE);
-               apc_delete($toDelete);
-       }
+       // APC deactivated, since there are problems with PHP 5.5
+       //if (function_exists("apc_delete")) {
+       //      $toDelete = new APCIterator('user', APC_ITER_VALUE);
+       //      apc_delete($toDelete);
+       //}
 
        /**
         * Side bar links
@@ -121,7 +122,7 @@ function admin_content(&$a) {
 
        $t = get_markup_template("admin_aside.tpl");
        $a->page['aside'] .= replace_macros( $t, array(
-                       '$admin' => $aside, 
+                       '$admin' => $aside,
                        '$admtxt' => t('Admin'),
                        '$plugadmtxt' => t('Plugin Features'),
                        '$logtxt' => t('Logs'),
@@ -167,13 +168,13 @@ function admin_content(&$a) {
        }
 
        if(is_ajax()) {
-               echo $o; 
+               echo $o;
                killme();
                return '';
        } else {
                return $o;
        }
-} 
+}
 
 
 /**
@@ -241,35 +242,35 @@ function admin_page_site_post(&$a){
        if (x($_POST,'relocate') && x($_POST,'relocate_url') && $_POST['relocate_url']!=""){
                $new_url = $_POST['relocate_url'];
                $new_url = rtrim($new_url,"/");
-               
+
                $parsed = @parse_url($new_url);
                if (!$parsed || (!x($parsed,'host') || !x($parsed,'scheme'))) {
                        notice(t("Can not parse base url. Must have at least <scheme>://<domain>"));
                        goaway($a->get_baseurl(true) . '/admin/site' );
                }
-               
+
                /* steps:
                 * replace all "baseurl" to "new_url" in config, profile, term, items and contacts
                 * send relocate for every local user
                 * */
-               
+
                $old_url = $a->get_baseurl(true);
-               
+
                function update_table($table_name, $fields, $old_url, $new_url) {
                        global $db, $a;
-                       
+
                        $dbold = dbesc($old_url);
                        $dbnew = dbesc($new_url);
-                       
+
                        $upd = array();
                        foreach ($fields as $f) {
                                $upd[] = "`$f` = REPLACE(`$f`, '$dbold', '$dbnew')";
                        }
-                       
+
                        $upds = implode(", ", $upd);
-                       
-                       
-                       
+
+
+
                        $q = sprintf("UPDATE %s SET %s;", $table_name, $upds);
                        $r = q($q);
                        if (!$r) {
@@ -277,30 +278,31 @@ function admin_page_site_post(&$a){
                                goaway($a->get_baseurl(true) . '/admin/site' );
                        }
                }
-               
+
                // update tables
                update_table("profile", array('photo', 'thumb'), $old_url, $new_url);
                update_table("term", array('url'), $old_url, $new_url);
                update_table("contact", array('photo','thumb','micro','url','nurl','request','notify','poll','confirm','poco'), $old_url, $new_url);
+               update_table("unique_contacts", array('url'), $old_url, $new_url);
                update_table("item", array('owner-link','owner-avatar','author-name','author-link','author-avatar','body','plink','tag'), $old_url, $new_url);
 
                // update config
                $a->set_baseurl($new_url);
                set_config('system','url',$new_url);
-               
+
                // send relocate
                $users = q("SELECT uid FROM user WHERE account_removed = 0 AND account_expired = 0");
-               
+
                foreach ($users as $user) {
                        proc_run('php', 'include/notifier.php', 'relocate', $user['uid']);
                }
 
                info("Relocation started. Could take a while to complete.");
-               
+
                goaway($a->get_baseurl(true) . '/admin/site' );
        }
        // end relocate
-       
+
        $sitename               =       ((x($_POST,'sitename'))                 ? notags(trim($_POST['sitename']))              : '');
        $banner                 =       ((x($_POST,'banner'))                   ? trim($_POST['banner'])                        : false);
        $info                   =       ((x($_POST,'info'))                     ? trim($_POST['info'])                  : false);
@@ -329,7 +331,7 @@ function admin_page_site_post(&$a){
        $private_addons                 =       ((x($_POST,'private_addons'))           ? True                                          : False);
        $disable_embedded               =       ((x($_POST,'disable_embedded'))         ? True                                          : False);
        $allow_users_remote_self        =       ((x($_POST,'allow_users_remote_self'))          ? True                                          : False);
-       
+
        $no_multi_reg           =       ((x($_POST,'no_multi_reg'))             ? True                                          : False);
        $no_openid              =       !((x($_POST,'no_openid'))               ? True                                          : False);
        $no_regfullname         =       !((x($_POST,'no_regfullname'))          ? True                                          : False);
@@ -354,13 +356,16 @@ function admin_page_site_post(&$a){
        $use_fulltext_engine    =       ((x($_POST,'use_fulltext_engine'))      ? True                                          : False);
        $itemcache              =       ((x($_POST,'itemcache'))                ? notags(trim($_POST['itemcache']))             : '');
        $itemcache_duration     =       ((x($_POST,'itemcache_duration'))       ? intval($_POST['itemcache_duration'])          : 0);
+       $max_comments           =       ((x($_POST,'max_comments'))             ? intval($_POST['max_comments'])                : 0);
        $lockpath               =       ((x($_POST,'lockpath'))                 ? notags(trim($_POST['lockpath']))              : '');
        $temppath               =       ((x($_POST,'temppath'))                 ? notags(trim($_POST['temppath']))              : '');
        $basepath               =       ((x($_POST,'basepath'))                 ? notags(trim($_POST['basepath']))              : '');
        $singleuser             =       ((x($_POST,'singleuser'))               ? notags(trim($_POST['singleuser']))            : '');
+       $proxy_disabled         =       ((x($_POST,'proxy_disabled'))           ? True                                          : False);
+       $enable_noscrape = ((x($_POST,'enable_noscrape')) ? true : false);
        if($ssl_policy != intval(get_config('system','ssl_policy'))) {
                if($ssl_policy == SSL_POLICY_FULL) {
-                       q("update `contact` set 
+                       q("update `contact` set
                                `url`     = replace(`url`    , 'http:' , 'https:'),
                                `photo`   = replace(`photo`  , 'http:' , 'https:'),
                                `thumb`   = replace(`thumb`  , 'http:' , 'https:'),
@@ -372,14 +377,14 @@ function admin_page_site_post(&$a){
                                `poco`    = replace(`poco`   , 'http:' , 'https:')
                                where `self` = 1"
                        );
-                       q("update `profile` set 
+                       q("update `profile` set
                                `photo`   = replace(`photo`  , 'http:' , 'https:'),
                                `thumb`   = replace(`thumb`  , 'http:' , 'https:')
                                where 1 "
                        );
                }
                elseif($ssl_policy == SSL_POLICY_SELFSIGN) {
-                       q("update `contact` set 
+                       q("update `contact` set
                                `url`     = replace(`url`    , 'https:' , 'http:'),
                                `photo`   = replace(`photo`  , 'https:' , 'http:'),
                                `thumb`   = replace(`thumb`  , 'https:' , 'http:'),
@@ -391,7 +396,7 @@ function admin_page_site_post(&$a){
                                `poco`    = replace(`poco`   , 'https:' , 'http:')
                                where `self` = 1"
                        );
-                       q("update `profile` set 
+                       q("update `profile` set
                                `photo`   = replace(`photo`  , 'https:' , 'http:'),
                                `thumb`   = replace(`thumb`  , 'https:' , 'http:')
                                where 1 "
@@ -403,6 +408,7 @@ function admin_page_site_post(&$a){
        set_config('system','poll_interval',$poll_interval);
        set_config('system','maxloadavg',$maxloadavg);
        set_config('config','sitename',$sitename);
+       set_config('system','suppress_language',$suppress_language);
        if ($banner==""){
                // don't know why, but del_config doesn't work...
                q("DELETE FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
@@ -476,9 +482,12 @@ function admin_page_site_post(&$a){
        set_config('system','use_fulltext_engine', $use_fulltext_engine);
        set_config('system','itemcache', $itemcache);
        set_config('system','itemcache_duration', $itemcache_duration);
+       set_config('system','max_comments', $max_comments);
        set_config('system','lockpath', $lockpath);
        set_config('system','temppath', $temppath);
        set_config('system','basepath', $basepath);
+       set_config('system','proxy_disabled', $proxy_disabled);
+       set_config('system','enable_noscrape', $enable_noscrape);
 
        info( t('Site settings updated.') . EOL);
        goaway($a->get_baseurl(true) . '/admin/site' );
@@ -544,12 +553,17 @@ function admin_page_site(&$a) {
 
        /* Banner */
        $banner = get_config('system','banner');
-       if($banner == false) 
+       if($banner == false)
                $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>';
        $banner = htmlspecialchars($banner);
        $info = get_config('config','info');
        $info = htmlspecialchars($info);
 
+       // Automatically create temporary paths
+       get_temppath();
+       get_lockpath();
+       get_itemcachepath();
+
        //echo "<pre>"; var_dump($lang_choices); die("</pre>");
 
        /* Register policy */
@@ -557,7 +571,7 @@ function admin_page_site(&$a) {
                REGISTER_CLOSED => t("Closed"),
                REGISTER_APPROVE => t("Requires approval"),
                REGISTER_OPEN => t("Open")
-       ); 
+       );
 
        $ssl_choices = array(
                SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
@@ -627,14 +641,17 @@ function admin_page_site(&$a) {
                '$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.")),
                '$suppress_language'    => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),
                '$itemcache'            => array('itemcache', t("Path to item cache"), get_config('system','itemcache'), "The item caches buffers generated bbcode and external images."),
-               '$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).")),
+               '$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). To disable the item cache, set the value to -1.")),
+               '$max_comments'         => array('max_comments', t("Maximum numbers of comments per post"), get_config('system','max_comments'), t("How much comments should be shown for each post? Default value is 100.")),
                '$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."),
                '$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."),
                '$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."),
-               
+               '$proxy_disabled'       => array('proxy_disabled', t("Disable picture proxy"), get_config('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")),
+
                '$relocate_url'     => array('relocate_url', t("New base url"), $a->get_baseurl(), "Change base url for this server. Sends relocate message to all DFRN contacts of all users."),
                
-        '$form_security_token' => get_form_security_token("admin_site"),
+               '$enable_noscrape'=> array('enable_noscrape', t("Enable noscrape"), get_config('system','enable_noscrape'), t("The noscrape feature speeds up directory submissions by using JSON data instead of HTML scraping.")),
+    '$form_security_token' => get_form_security_token("admin_site")
 
        ));
 
@@ -660,7 +677,7 @@ function admin_page_dbsync(&$a) {
                if(function_exists($func)) {
                        $retval = $func();
                        if($retval === UPDATE_FAILED) {
-                               $o .= sprintf( t('Executing %s failed. Check system logs.'), $func); 
+                               $o .= sprintf( t('Executing %s failed. Check system logs.'), $func);
                        }
                        elseif($retval === UPDATE_SUCCESS) {
                                $o .= sprintf( t('Update %s was successfully applied.', $func));
@@ -908,9 +925,9 @@ function admin_page_users(&$a){
                '$delete' => t('Delete'),
                '$block' => t('Block'),
                '$unblock' => t('Unblock'),
-        '$siteadmin' => t('Site admin'),
-        '$accountexpired' => t('Account expired'),
-               
+               '$siteadmin' => t('Site admin'),
+               '$accountexpired' => t('Account expired'),
+
                '$h_users' => t('Users'),
                '$h_newuser' => t('New User'),
                '$th_deleted' => array( t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since') ),
@@ -919,7 +936,7 @@ function admin_page_users(&$a){
                '$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?'),
                '$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?'),
 
-        '$form_security_token' => get_form_security_token("admin_users"),
+               '$form_security_token' => get_form_security_token("admin_users"),
 
                // values //
                '$baseurl' => $a->get_baseurl(true),
@@ -927,9 +944,9 @@ function admin_page_users(&$a){
                '$pending' => $pending,
                'deleted' => $deleted,
                '$users' => $users,
-               '$newusername'  => array('new_user_name', t("Name"), '', t("Name of the new user.")), 
-    '$newusernickname'  => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")), 
-    '$newuseremail'  => array('new_user_email', t("Email"), '', t("Email address of the new user.")),
+               '$newusername'  => array('new_user_name', t("Name"), '', t("Name of the new user.")),
+               '$newusernickname'  => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")),
+               '$newuseremail'  => array('new_user_email', t("Email"), '', t("Email address of the new user.")),
        ));
        $o .= paginate($a);
        return $o;
@@ -1028,13 +1045,24 @@ function admin_page_plugins(&$a){
         */
 
        $plugins = array();
-       $files = glob("addon/*/");
+       $files = glob("addon/*/"); /* */
        if($files) {
-               foreach($files as $file) {      
+               foreach($files as $file) {
                        if (is_dir($file)){
                                list($tmp, $id)=array_map("trim", explode("/",$file));
                                $info = get_plugin_info($id);
-                               $plugins[] = array( $id, (in_array($id,  $a->plugins)?"on":"off") , $info);
+                               $show_plugin = true;
+
+                               // If the addon is unsupported, then only show it, when it is enabled
+                               if ((strtolower($info["status"]) == "unsupported") AND !in_array($id,  $a->plugins))
+                                       $show_plugin = false;
+
+                               // Override the above szenario, when the admin really wants to see outdated stuff
+                               if (get_config("system", "show_unsupported_addons"))
+                                       $show_plugin = true;
+
+                               if ($show_plugin)
+                                       $plugins[] = array($id, (in_array($id,  $a->plugins)?"on":"off") , $info);
                        }
                }
        }
@@ -1045,7 +1073,7 @@ function admin_page_plugins(&$a){
                '$page' => t('Plugins'),
                '$submit' => t('Save Settings'),
                '$baseurl' => $a->get_baseurl(true),
-               '$function' => 'plugins',       
+               '$function' => 'plugins',
                '$plugins' => $plugins,
         '$form_security_token' => get_form_security_token("admin_themes"),
        ));
@@ -1127,16 +1155,16 @@ function admin_page_themes(&$a){
                                $allowed_themes[] = trim($x);
 
        $themes = array();
-    $files = glob('view/theme/*');
-    if($files) {
-        foreach($files as $file) {
-            $f = basename($file);
-            $is_experimental = intval(file_exists($file . '/experimental'));
+       $files = glob('view/theme/*'); /* */
+       if($files) {
+               foreach($files as $file) {
+                       $f = basename($file);
+                       $is_experimental = intval(file_exists($file . '/experimental'));
                        $is_supported = 1-(intval(file_exists($file . '/unsupported'))); // Is not used yet
                        $is_allowed = intval(in_array($f,$allowed_themes));
                        $themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed);
-        }
-    }
+               }
+       }
 
        if(! count($themes)) {
                notice( t('No themes found.'));
@@ -1259,7 +1287,7 @@ function admin_page_themes(&$a){
  *
  * @param App $a
  */
+
 function admin_page_logs_post(&$a) {
        if (x($_POST,"page_logs")) {
         check_form_security_token_redirectOnErr('/admin/logs', 'admin_logs');
@@ -1272,12 +1300,12 @@ function admin_page_logs_post(&$a) {
                set_config('system','debugging',  $debugging);
                set_config('system','loglevel', $loglevel);
 
-               
+
        }
 
        info( t("Log settings updated.") );
        goaway($a->get_baseurl(true) . '/admin/logs' );
-       return; // NOTREACHED   
+       return; // NOTREACHED
 }
 
 /**
@@ -1285,7 +1313,7 @@ function admin_page_logs_post(&$a) {
  * @return string
  */
 function admin_page_logs(&$a){
-       
+
        $log_choices = Array(
                LOGGER_NORMAL => 'Normal',
                LOGGER_TRACE => 'Trace',
@@ -1293,7 +1321,7 @@ function admin_page_logs(&$a){
                LOGGER_DATA => 'Data',
                LOGGER_ALL => 'All'
        );
-       
+
        $t = get_markup_template("admin_logs.tpl");
 
        $f = get_config('system','logfile');
@@ -1325,7 +1353,7 @@ readable.");
                        }
                        fclose($fp);
                }
-       }                       
+       }
 
        return replace_macros($t, array(
                '$title' => t('Administration'),
@@ -1335,7 +1363,7 @@ readable.");
                '$data' => $data,
                '$baseurl' => $a->get_baseurl(true),
                '$logname' =>  get_config('system','logfile'),
-               
+
                                                                        // name, label, value, help string, extra data...
                '$debugging'            => array('debugging', t("Enable Debugging"),get_config('system','debugging'), ""),
                '$logfile'                      => array('logfile', t("Log file"), get_config('system','logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")),
@@ -1354,7 +1382,7 @@ function admin_page_remoteupdate_post(&$a) {
                return;
        }
 
-       
+
        if (x($_POST,'remotefile') && $_POST['remotefile']!=""){
                $remotefile = $_POST['remotefile'];
                $ftpdata = (x($_POST['ftphost'])?$_POST:false);
@@ -1377,14 +1405,14 @@ function admin_page_remoteupdate(&$a) {
 
        $canwrite = canWeWrite();
        $canftp = function_exists('ftp_connect');
-       
+
        $needupdate = true;
        $u = checkUpdate();
        if (!is_array($u)){
                $needupdate = false;
                $u = array('','','');
        }
-       
+
        $tpl = get_markup_template("admin_remoteupdate.tpl");
        return replace_macros($tpl, array(
                '$baseurl' => $a->get_baseurl(true),
@@ -1401,5 +1429,5 @@ function admin_page_remoteupdate(&$a) {
                '$ftppwd'       => array('ftppwd', t("FTP Password"), '',''),
                '$remotefile'=>array('remotefile','', $u['2'],''),
        ));
-       
+
 }