Category Archives: sysadmin

How to hide Send Private Message and Send Public Message – BuddyPress User | https://buddyuser.com/

How to Hide Send Private Message and Send Public Message from the members profile view

Sometimes it becomes prudent to make it more difficult for site members to email other members, for example where you are suffering from spammers.

Where to put code Snippets

Code Snippets for BuddyPress can typically be placed in two locations:

/wp-content/themes/yourchildtheme/functions.php
/wp-content/plugins/bp-custom.php

The preference is to create a bp-custom.php file, since this is independent of the theme you happen to be using.

The code snippet must be wrapped in  <?php  and ?> tags in order to tell you server that it is to run the code as PHP.

Remove “Send Private Message” from users who are not friends of the member whose profile they are viewing
1
2
3
4
5
6
7
add_filter( 'bp_get_send_message_button', function( $array ) {
    if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) {
        return $array;
    } else {
        return '';
    }
} );
Remove “Send Public Message” from users who are not friends of the member whose profile they are viewing
1
2
3
4
5
6
7
8
add_filter( 'bp_get_send_public_message_button', function( $r ) {
    if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) {
        return $r;
    } else {
        $r['component'] = '';
        return $r;
    }
} );

These code snippets were originally posted by Henry Wright in the BuddyPress Forums:
https://buddypress.org/support/topic/disable-or-hide-private-message-button/

Source: How to hide Send Private Message and Send Public Message – BuddyPress User | https://buddyuser.com/

Turn Off Updates • mozillaZine Forums

Here is the policies documentation.

Manage updates, policies & customization
http://support.mozilla.org/en-US/produc … enterprise

Customizing Firefox Using policies.json
http://support.mozilla.org/en-US/kb/cus … liciesjson

Create a folder called distribution where the firefox.exe is located and place the policies.json file there.

CODE: SELECT ALL
{
"policies": {
"DisableAppUpdate": true
}
}

Customizing Firefox Using Group Policy
http://support.mozilla.org/en-US/kb/cus … cy-windows

Local Group Policy Editor (gpedit.msc) is not available in Home versions of Windows 7, 8 or 10.

How to stop Firefox from showing the update nag screen?
http://superuser.com/questions/1407844

Enterprise Policies
http://klaus-hartnegg.de/gpo/2018-05-26-Firefox-Policies.html

Enterprise Policy Generator
http://addons.mozilla.org/firefox/addon/976971

I never tried the Enterprise Policy Generator addon.

policies.json being removed on browser updates via setup.exe (wontfix)
http://bugzilla.mozilla.org/show_bug.cgi?id=1502188

P.S.

I got the DisableAppUpdate policy working with the policies.json file in Firefox Portable 71.0 32-bit.

* C:\FirefoxPortable\App\Firefox\distribution\policies.json

However, I had to remove the following registry keys before I got it working.

* HKEY_CURRENT_USER\Software\Policies\Mozilla
* HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Mozilla

Here is how to test if the DisableAppUpdate policy is working.

Test DisableAppUpdate policy: viewtopic.php?p=14848020#p14848020

Source: Turn Off Updates • mozillaZine Forums

Mozilla Enterprise Policies for Firefox and Thunderbird

The Mozilla Enterprise Policies for Firefox (and Thunderbird)

This feature is meant to help enterprise admins, who deploy Firefox as software package to computers in their organization.

Versions

Policies were first added in Firefox 60, and back then were purely optional.

In Firefox 68 some settings from autoconfig stopped working (for example the option to disable automatic updates), thus it became necessary to at least partially switch to policies.

Thunderbird started to implement policies in version 68, and at the same time also stopped respecting some of the autoconfig options.

Overview

The Enterprise Policy feature provides two new ways to configure Firefox (besides the old autoconfig aka mozilla.cfg):

  • Windows Group Policy Objects (GPO)
  • A config file named policies.json

Interactions:

  • If any policies are set with GPO, the json file is ignored.
  • If autoconfig (old) and policies (new) provide conflicting settings, policies win.

Requirements:

  • Firefox version 60 or later.
  • Thunderbird version 68 or later.
  • In Windows some policies work only if you have either Firefox ESR or domain-joined PCs.
    (It is currently unclear how Firefox detects the domain membership, and whether it must be an Active Directory domain)

Howto use the admx templates (for GPO)

Firefox

  1. Copy firefox.admx to C:\Windows\PolicyDefinitions
  2. Copy firefox.adml to C:\Windows\PolicyDefinitions\en-US
  3. Run <class=”tt”>gpedit.msc or <class=”tt”>RSAT (Remote Server Administration Tools), and open Computer Configuration, Administrative Templates, Firefox.</class=”tt”></class=”tt”>

Thunderbird

Some of the Firefox policies also work in Thunderbird.

There are official (but non-functioning) admx-templates on https://github.com/thundernest/policy-templates. They are just a clone of the templates for Firefox, and thus do not have an effect on Thunderbird.

Inofficial templates are on https://github.com/drlellinger/thunderbird-policies (announced here), and they acually work.

  1. Copy thunderbird.admx to C:\Windows\PolicyDefinitions
  2. Copy thunderbird.adml to C:\Windows\PolicyDefinitions\en-US
  3. Run <class=”tt”>gpedit.msc or <class=”tt”>RSAT (Remote Server Administration Tools), and open Computer Configuration, Administrative Templates, Thunderbird.</class=”tt”></class=”tt”>

You can also copy registry keys from Firefox and rename them. For example this one works:

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Mozilla\Thunderbird]
"DisableAppUpdate"=dword:00000001

Howto use create the json file (alternative for GPO)

The currently supported policies are listed here. New policies are added with every version, and so far all new policies are available both in the latest RR (Rapid Release), and in the latest ESR (Extended Service Release).

Multiple policies must be separated with commas. Multiple options to one policy must be placed in curly brackets, and separated with commas.

Generator addon was published (german). More info.

The json file must be placed in a subdirectory named distribution in the program directory. In Windows the path will be something like
C:\Program Files\Mozilla Firefox\distribution\policies.json
This directory does usually not yet exist, you must create it.

Sample file:

{
 "policies": {
    "DisableAppUpdate": true,
    "DisableBuiltinPDFViewer": true,
    "DisableFirefoxAccounts": true,
    "DisableFirefoxStudies": true,
    "DisablePocket": true,
    "DisableProfileRefresh": true,
    "DisableTelemetry": true,
    "DontCheckDefaultBrowser": true,
    "EnableTrackingProtection": { "Value": true, "Locked": false },
    "Proxy": { "Mode": "none", "Locked": false },
    "SearchBar": "separate"
  }
}

Errors in the file are reported on the page “about:policies”, but this feature needs at least Firefox version 63. This is the typical way how Mozilla develops new feature: publish it long before its ready.

Howto not document a feature

Mozilla has created this labyrinth:

It seems that Github is now the official place for documentation. But even there a lot of info is missing. For example that this is supposed to replace autoconfig. And that in Windows several of these options only work if either the ESR version is used, or the PCs are members of a Windows Domain. Also how do the two methods relate to each other and to autoconfig: which one does take precedence?

Lets hope that eventually Mozilla will write some decent documentation for this new feature.

No, I’m not gonna read the source to extract infos from there.


Changelog:

  • 2018-10-22 Thunderbird
  • 2018-09-17 corrected directory, add interactions, add sample
  • 2018-05-31 cleanup
  • 2018-05-30 add howto use the admx templates, and links to generator and source.
  • 2018-05-25 new

Impressum

Source: Mozilla Enterprise Policies for Firefox and Thunderbird

mod_rewrite Cheat Sheet by DaveChild

A mod_rewrite Cheat Sheet – a quick reference guide for mod_rewrite, with rewrite flags, regular expression syntax and sample rules.

mod_re­write Tutorials

mod_re­write Rewrit­eRule Flags

C
Chained with next rule
CO=cookie
Set specified cookie
E=var:­value
Set enviro­nmental variable “var” to “value”
F
Forbidden (403 header)
G
Gone – no longer exists
H=handler
Set handler
L
Last – stop processing rules
N
Next – continue processing
NC
Case insens­itive
NE
Do not escape output
NS
Ignore if subrequest
P
Proxy
PT
Pass through
R[=code]
Redirect to new URL, with optional code (see below)
QSA
Append query string
S=x
Skip next x rules
T=mime­-type
Set mime type

mod_re­write Rewrit­eCond Flags

NC
Case insens­itive
OR
Combine with next rule using ‘OR’ instead of the default of ‘AND’

Redire­ction Header Codes

301
Moved perman­ently
302
Moved tempor­arily (default)

mod_re­write Directives

Rewrit­eEngine
RewriteMap
Rewrit­eOp­tions
Rewrit­eBase
RewriteLog
Rewrit­eCond
Rewrit­eLo­gLevel
Rewrit­eRule
Rewrit­eLock

Regular Expres­sions Syntax

^
Start of string
$
End of string
.
Any single character
(a|b)
a or b
(…)
Group section
[abc]
In range (a, b or c)
[^abc]
Not in range
\s
White space
a?
Zero or one of a
a*
Zero or more of a
a*?
Zero or more, ungreedy
a+
One or more of a
a+?
One or more, ungreedy
a{3}
Exactly 3 of a
a{3,}
3 or more of a
a{,6}
Up to 6 of a
a{3,6}
3 to 6 of a
a{3,6}?
3 to 6 of a, ungreedy
\
Escape character
[:punct:]
Any punctu­ation symbol
[:space:]
Any space character
[:blank:]
Space or tab
There’s an excellent regular expression tester at: http:/­/re­gex­pal.com/

mod_re­write Server Variables: HTTP Headers

%{HTTP­_US­ER_­AGENT}
%{HTTP­_RE­FERER}
%{HTTP­_CO­OKIE}
%{HTTP­_FO­RWA­RDED}
%{HTTP­_HOST}
%{HTTP­_PR­OXY­_CO­NNE­CTION}
%{HTTP­_AC­CEPT}

mod_re­write Server Variables: Server Internals

%{DOCU­MEN­T_ROOT}
%{SERV­ER_­ADMIN}
%{SERV­ER_­NAME}
%{SERV­ER_­ADDR}
%{SERV­ER_­PORT}
%{SERV­ER_­PRO­TOCOL}
%{SERV­ER_­SOF­TWARE}

mod_re­write Sample Rule: Site Moved

# Site moved perman­ently
Rewrit­eCond %{HTTP­_HOST} ^www.d­oma­in.com$ [NC]
Rewrit­eRule ^(.*)$ http:/­/ww­w.d­oma­in2.com/$1 [R=301,L]
Rewrites domain.com to domain­2.com

mod_re­write Sample Rule: Temporary Page Move

# Page has moved tempor­arily
Rewrit­eRule ^page.h­tml$ new_pa­ge.html [R,NC,L]
Rewrites domain.co­m/p­age.html to domain.co­m/n­ew_­pag­e.html

mod_re­write Sample Rule: Nice URLs

# Nice URLs (no query string)
Rewrit­eRule ^([A-Z­a-z­0-9­-]+)/?$ catego­rie­s.p­hp?­name=$1 [L]
Rewrites domain.co­m/c­ate­gor­y-n­ame-1/ to domain.co­m/c­ate­gor­ies.ph­p?n­ame­=ca­teg­ory­-name-1

mod_re­write Server Variables: Special

%{API_­VER­SION}
%{THE_­REQ­UEST}
%{REQU­EST­_URI}
%{REQU­EST­_FI­LENAME}
%{IS_S­UBREQ}
%{HTTPS}

mod_re­write Server Variables: Request

%{REMO­TE_­ADDR}
%{REMO­TE_­HOST}
%{REMO­TE_­PORT}
%{REMO­TE_­USER}
%{REMO­TE_­IDENT}
%{REQU­EST­_ME­THOD}
%{SCRI­PT_­FIL­ENAME}
%{PATH­_INFO}
%{QUER­Y_S­TRING}
%{AUTH­_TYPE}

mod_re­write Server Variables: Time

%{TIME­_YEAR}
%{TIME­_MON}
%{TIME­_DAY}
%{TIME­_HOUR}
%{TIME­_MIN}
%{TIME­_SEC}
%{TIME­_WDAY}
%{TIME}

Source: mod_rewrite Cheat Sheet by DaveChild – Download free from Cheatography – Cheatography.com: Cheat Sheets For Every Occasion

filtering spam with procmail | http://www.benya.com/

This is a collection of procmail recipes which I use to pre-filter the incoming mail before letting SpamBayes take a crack at it. This combination seems to provide a fairly decent level of protection. Naturally, your mileage may vary.

procmail is a mail processor installed on most Linux systems and used to by the mail server to deliver mail to your mailbox. If your mail server is hosted on linux you may use procmail to remove spam and sort messages before they are placed into your mailbox. If, like me, you prefer to use pine in a shell window to check your e-mail, this type of filtering may be your only defense against spam.

In order to understand these recipes, at least some knowledge of procmail and regular expressions syntax is required. The basics can be learned from procmail man pages and from links on procmail home page. Here is a great procmail documentation project and a library of recipes

Spam filters and other useful procmail recipes

Source: filtering spam with procmail | http://www.benya.com/

List of All Environment Variables in Windows 10

Windows Environment Variables List

ENVIRONMENT VARIABLE CORRESPONDING PATH
%SystemDrive% C:\ (Operating System drive)
%SystemRoot% C:\Windows
%WINDIR% C:\Windows
%HOMEDRIVE% C:\ (Operating System drive)
%HOMEPATH% C:\Users\<Username>
%USERPROFILE% C:\Users\<Username>
%APPDATA% C:\Users\<Username>\AppData\Roaming
%ALLUSERSPROFILE% C:\ProgramData
%PROGRAMFILES% C:\Program Files
%PROGRAMFILES(X86)% C:\Program Files (x86)
%PROGRAMDATA% C:\ProgramData
%TEMP% C:\Users\<Username>\AppData\Local\Temp
%LOCALAPPDATA% C:\Users\<Username>\AppData\Local
%PUBLIC% C:\Users\Public
%COMMONPROGRAMFILES% C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)% C:\Program Files (x86)\Common Files

How to Uninstall Edge Chromium When Windows 10 Won’t Let You

Edge Chromium is a decent web browser. I’d even go as far as to say it’s worth swapping over to from Google Chrome, given its improvements with memory usage. However, Microsoft has been incredibly annoying about stuffing Edge Chromium down everyone’s throats, and a recent Windows update locks this browser into your OS even more.

Sure, you could just set another app like Firefox or Opera as your default web browser and ignore Edge’s presence (and Windows 10’s incessant notifications to “try the new Edge”), but it’s better to remove Edge Chromium entirely if you never plan to use it.

The thing is, if you try to uninstall the browser from the Apps & Features menu in system settings, the “Uninstall” button next to Edge is now grayed out. If you’re like me, you probably hopped over to the Control Panel to uninstall it via the “Programs and Features” tab…except the update also removed Edge from the list of installed programs, so it can’t be uninstalled that way, either.

There’s a reason for this: some Microsoft apps require Edge to run properly, so Microsoft made it harder to uninstall Edge to avoid unnecessary issues that could be caused by its absence (and it just really wants you to use Edge).

This doesn’t mean Edge Chromium has to take up permanent residence on your computer—you’ll just have to get a little more creative to delete it. And no, you won’t break Windows by uninstalling Edge, though if all you intend to do is disable it and set a different browser as your default app, we’ll show you how to do that, too.

How to disable Edge and set a different default browser

Illustration for article titled How to Uninstall Edge Chromium When Windows 10 Wont Let You
Screenshot: Brendan Hesse

Given Windows 10’s bug-ridden history and the OS’s reliance on Edge, it may be safer to just switch to a new browser instead of uninstalling it completely.

  1. Open the Start Menu
  2. Click Settings and go to Apps > Default apps.
  3. Scroll down and click “Web browser.”
  4. Select the browser you want to use, which you’ll obviously need to have first installed in order to make the switch. Check our lists for the best browsers for ad-blocking and the best browsers for privacy if you need recommendations.
  5. You can also unpin Edge from your taskbar by right-clicking the taskbar icon and selecting “Unpin from taskbar.”

This will hide Edge most of the time, but Windows will still occasionally suggest using the browser, and some apps will open links in Edge even after changing the default program—but you can delete it from your PC if those behaviors bug you.

How to uninstall Edge Chromium

Despite Microsoft’s efforts to prevent users from delete Edge, you can uninstall it from Windows 10 with some simple PowerShell wizardry. We’ll cover two possible options just in case one doesn’t work for you.

Method one:

Illustration for article titled How to Uninstall Edge Chromium When Windows 10 Wont Let You
Screenshot: Brendan Hesse
  1. Open Windows File Explorer
  2. Type “C:\Program Files (x86)\Microsoft\Edge\Application” into the address bar and hit Enter. This should open the Edge installation folder—if not, try navigating to the folder manually, or search for “Edge” in File Explorer.
  3. There should be a folder with a numerical name. The name is the same as the current version of Edge installed on your PC. For example, at the time of writing, the folder on my machine is “83.0.478.58.” Open that folder.
  4. Find and open the “Installer” folder.
  5. In this folder, click the “File” tab in the upper-left of the File Explorer window, then go to File > Open Windows PowerShell > Open Windows PowerShell as administrator.
  6. Click “Yes” when prompted to allow the program to make changes to your system.
  7. Type.\setup.exe -uninstall -system-level -verbose-logging -force-uninstall into PowerShell and press Enter to run the command and let it run.

Assuming everything went according to plan, Edge should now be uninstalled. However, if this method doesn’t work for you, there’s another option you can try.

Method 2:

Illustration for article titled How to Uninstall Edge Chromium When Windows 10 Wont Let You
Screenshot: Brendan Hesse
  1. Search for “PowerShell” from the taskbar or Windows Start menu.
  2. Right-click “Windows PowerShell” from the search results and select “Run as an administrator.”
  3. Select “Yes” when asked if the program is allowed to make changes to your system.
  4. In the PowerShell window, type get-appxpackage *edge* and press Enter.
  5. Several lines of information will show up. Look for “PackageFullName” and copy the text in the column.
  6. Type remove-appxpackage into PowerShell and paste the text you copied from the PackafeFullName column.
  7. Press Enter to run the command. Edge should now be removed from your system.

This story was updated to add more information on why Microsoft is preventing the browser from being removed, plus two additional methods for removing/disabling the browser.

Source: How to Uninstall Edge Chromium When Windows 10 Won’t Let You

Deep scriptblock logging: Record PowerShell commands in the event log

As a powerful tool, PowerShell is not only of interest for admins but also for hackers. To detect suspicious activities, it is helpful to have all executed commands recorded. In addition to recording the history in a text file, PowerShell has also supported logging in the event log since version 5.

Source: Deep scriptblock logging: Record PowerShell commands in the event log