]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
Merge pull request #1067 from Beanow/feature/noscrape
[friendica.git] / mod / admin.php
index 76129204c327d7ad9f400dc08348323688924e94..176ae9f489a2bc1e3aa08daa3df7e7e1fb106a7d 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')) {
@@ -122,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'),
@@ -168,13 +168,13 @@ function admin_content(&$a) {
        }
 
        if(is_ajax()) {
-               echo $o; 
+               echo $o;
                killme();
                return '';
        } else {
                return $o;
        }
-} 
+}
 
 
 /**
@@ -242,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) {
@@ -278,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);
@@ -360,6 +361,7 @@ function admin_page_site_post(&$a){
        $temppath               =       ((x($_POST,'temppath'))                 ? notags(trim($_POST['temppath']))              : '');
        $basepath               =       ((x($_POST,'basepath'))                 ? notags(trim($_POST['basepath']))              : '');
        $singleuser             =       ((x($_POST,'singleuser'))               ? notags(trim($_POST['singleuser']))            : '');
+       $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
@@ -374,14 +376,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:'),
@@ -393,7 +395,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 "
@@ -483,6 +485,7 @@ function admin_page_site_post(&$a){
        set_config('system','lockpath', $lockpath);
        set_config('system','temppath', $temppath);
        set_config('system','basepath', $basepath);
+       set_config('system','enable_noscrape', $enable_noscrape);
 
        info( t('Site settings updated.') . EOL);
        goaway($a->get_baseurl(true) . '/admin/site' );
@@ -548,12 +551,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 */
@@ -561,7 +569,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"),
@@ -631,15 +639,16 @@ 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."),
 
                '$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")
 
        ));
 
@@ -665,7 +674,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));
@@ -913,9 +922,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') ),
@@ -924,7 +933,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),
@@ -932,9 +941,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;
@@ -1275,7 +1284,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');