Redirect users from admin pages the optimal solution

On two different sites I use two somewhat different solutions. Are they different in terms of security and performance? Which is better? Are there even better ones?

Solution 1.

/** Redirect users from admin pages if not administrators **/ add_action( 'admin_init', function() {     if( ! current_user_can( 'manage_options' ) && ( ! wp_doing_ajax() ) ) {         wp_safe_redirect( site_url() );         exit;     } } ); 

Solution 2.

/** Redirect users from admin pages if not administrators **/ add_action( 'admin_init', function() {     if( ! in_array( 'administrator', wp_get_current_user()->roles ) ) {         wp_redirect( get_bloginfo( 'wpurl' ) );         exit;     } } ); 

Change the URL of an image from wp_get_attachment_image_src except in the frontpage

This is the code I used that is working, but I want it to work only on product posts and not on the frontpage.

function alterImageSRC($  image, $  attachment_id, $  size, $  icon){         $  image[0] = 'http://newimagesrc.com/myimage.jpg';  return $  image; } add_filter('wp_get_attachment_image_src', 'alterImageSRC', 10, 4); 

Import from other projects not working properly

@Sven I have four projects set up that I use to clean lists.

Each project is creating verified’s from one of four sold SER lists.

Then, I create a new project for whatever I want to link to.

In the past, when I import verified from other projects all the links would be moved to my new project to build on those targets.

Now SER is filtering or something and not all those links are being brought over.

For example, I have 2400 verified links from today’s cleaning.

But when I import from those projects into the new project, only 408 are copied over.

What’s going on that’s causing that?

Implicitly allow requests in IIS from valid hostname

I have a few publicly accessible IIS servers and sites (personal and corporate), these hosts have own domains/subdomains, and all legit access to these https sites happen through domains.

Almost all HTTP app vulnerability scans from bots/rooted servers happen to the servers through IP, without valid hostname, and if there is hostname it is the default reverse DNS host, not the actual domain of the site.

Is there a way in IIS to implicitly only allow requests with proper hostname? The site root app only has bindings to the hostname, but IIS still accepts requests, and responds with 404. The best thing would be to timeout the request similar fashion as if the site doesn’t have HTTP open.

I of course understand that this does not guarantee anything in security wise, the scanner can still figure out the proper hostname in many ways, but it would still filter out 90% of dummy scans.

IPS in firewall can probably do some things, but in some cases I do not have that luxury. Is there way in IIS? Redirect the http request to oblivion? (this would probably just change the error to proxy gateway http errors?)

WordPress redirect from URL with BuddyPress

I am using the plugin BuddyPress on my WordPress site and when the user clicks on their profile they are redirected to the URL "/members/USERNAME/profile/home/". However, I do not want this page to be there and so I would like the profile ‘landing’ page to be the URL "/members/USERNAME/activity/".

I am not experienced with WordPress or PHP but I attempted to code a redirect for this when the user ends up on the ‘home’ page which is placed within my BuddyPress members/single/home.php file within my child theme:

$  redirect_url_home = get_home_url(); $  redirect_url_home_tt = $  redirect_url_home; $  username_redirect_tt = wp_get_current_user(); $  new_redirect_slug = "'/members/'.$  username_redirect_tt->user_login.'/activity/'"; $  redirect_url_home_tt. = $  new_redirect_slug; echo($  redirect_url_home_tt); wp_safe_redirect( $  redirect_url_home_tt ); 

This code doesn’t work but that was my thinking of how to solve my problem and I’m sure there is an easier/nicer way to do what I would like, maybe even without a coded redirect and within BuddyPress itself? I have tried using their forum/documentation for answers but haven’t had a reply or found anything useful.

As I say I have no experience with this sort of stuff so any help would be greatly appreciated! Also, to add, I cannot link the site as it is currently on a localhost.

Thanks!

How do I stop gyroscope-controlled camera from jittering when holding phone still?

I have here a simplified version of my gyro-controlled camera with a sensitivity modification (a side effect of increasing sensitivity is that the jitteriness is exacerbated).

public class GyroControl : MonoBehaviour{  private Transform _rawGyroRotation; Vector3 gyroAdjust; [SerializeField] private float _smoothing = 0.1f;  void Start() {     Input.gyro.enabled = true;     Application.targetFrameRate = 60;      _rawGyroRotation = new GameObject("GyroRaw").transform;     _rawGyroRotation.position = transform.position;     _rawGyroRotation.rotation = transform.rotation;  }  private void Update() {     _rawGyroRotation.rotation = Input.gyro.attitude;      gyroAdjust = _rawGyroRotation.rotation.eulerAngles * 2; //increase rotation sensitivity     transform.rotation = Quaternion.Euler(gyroAdjust);      transform.rotation = Quaternion.Slerp(transform.rotation, _rawGyroRotation.rotation, _smoothing);  }} 

When in motion, the jittering isn’t noticeable. But when you hold the phone still, there’s what I assume to be just analogue noise that causes jittering. I would really appreciate any help or advice on how to add a filter or something to reduce the jittering for this kind of controller.

Thanks.

Healthy Food Blog with original content from a nutrition coach

Topic: Healthy food blog from a nutrition coach. Healthy tips, popular recipes, products reviews.
Age: 6 years
Monthly users: 1900
Earnings per month: $ 8.5
Number of articles: 41

The blog has a good perspective due to the current situation with covid. Cooking at home is a strong trend because of the lockdowns around the world. People don’t go to restaurants and cook themselves. Also the healthy food trend is becoming more popular. The topic is quite a narrow niche, so it is easier to be…

Healthy Food Blog with original content from a nutrition coach

Why the exported result is different from the evaluated result

enter image description here

Why the exported result is different from the evaluated result? How to set to make them the same!

Here’s the code, It needs the package MaTeX. It’s Ok, If you don’t use this package, just make sure the text remain the same size when evaluating and exporting.

\[Gamma] = 7/18 \[Pi]; a1 = Graphics3D[{Opacity[0.4], LightBlue, Sphere[], Opacity[1], Black,      Thick, Line[{{-1, 0, 0}, {1, 0, 0}}],      Line[{{0, 1, 0}, {0, -1, 0}}], Line[{{0, 0, -1}, {0, 0, 1}}]}]; a2 = ParametricPlot3D[{Cos[t], Sin[t], 0}, {t, 0, 2 \[Pi]},     PlotStyle -> {Black, Dashed}]; a3 = ParametricPlot3D[{0, Cos[t], Sin[t]}, {t, -\[Pi]/2, \[Pi]/2},     PlotStyle -> {Black, Dashed}]; a4 = ParametricPlot3D[{Cos[t], 0, Sin[t]}, {t, -\[Pi], \[Pi]},     PlotStyle -> {Black, Dashed}]; data = Table[{0, Cos[t], Sin[t]}, {t, 3 \[Pi]/2, 5 \[Pi]/4, -0.01}]; a5 = Graphics3D[{Green, Arrowheads[0.035], Arrow[Tube[data, 0.01]]}]; data = Table[{0, Cos[t], Sin[t]}, {t, \[Pi], 1.5 \[Pi]/2, -0.01}]; a6 = Graphics3D[{Green, Arrowheads[0.035], Arrow[Tube[data, 0.01]]}]; data = Table[{0, Cos[t], Sin[t]}, {t, \[Pi]/2, 3 \[Pi]/2, 0.01}]; a7 = Graphics3D[{Green, Tube[data, 0.01]}]; a8 = Graphics3D[{Green, Sphere[{0, -1, 0}, 0.05]}]; a9 = Show[{a1, a2, a3, a4, a5, a6, a7, a8}, BoxStyle -> Opacity[0],     ViewPoint -> {\[Pi], -1.4 \[Pi], \[Pi]/1.5}]; data = Table[{-Cos[t] Sin[\[Gamma]], Cos[t] Cos[\[Gamma]],      Sin[t]}, {t, (1.5 \[Pi])/2, (1.75 \[Pi])/2, 0.01}]; b1 = Graphics3D[{Green, Arrowheads[0.035], Arrow[Tube[data, 0.01]]}]; data = Table[{-Cos[t] Sin[\[Gamma]], Cos[t] Cos[\[Gamma]],     Sin[t]}, {t, (2 \[Pi])/2, (2.25 \[Pi])/2, 0.01}]; b2 =   Graphics3D[{Green, Arrowheads[0.035],     Arrow[Tube[data, 0.01]]}]; data =   Table[{-Cos[t] Sin[\[Gamma]], Cos[t] Cos[\[Gamma]],     Sin[t]}, {t, \[Pi]/2, (3 \[Pi])/2, 0.01}]; b3 =   Graphics3D[{Green, Tube[data, 0.01]}]; data = Table[{0.2 Sin[t], -0.2 Cos[t], 0}, {t, 0, \[Gamma],     0.01}]; b4 =   Graphics3D[{Red, Arrowheads[0.015], Arrow[Tube[data, 0.008]]}]; b5 =   Graphics3D[{Red,     Tube[{{0, 0, 0}, {Sin[\[Gamma]], -Cos[\[Gamma]], 0}}, 0.008]}]; b6 = Rasterize[   Show[{a9, b1, b2, b3, b4, b5}, ImageSize -> {1000, 1000}],    RasterSize -> 3000]  c1 = Graphics[    Text[MaTeX[      TeXForm[StringTemplate["\[Gamma] = ``\[Degree]"][        Floor[\[Gamma] 180/\[Pi]]]], FontSize -> 30], {0, -0.1}]]; c2 = Canvas[c1, FrameStyle -> False, PlotRange -> {{-1, 1}, {-1, 1}},    Background -> b6, ImageSize -> {1000, 1000}] Export["带闭合路径的庞加莱球   " <>     DateString[{"(Date ", "ISODate", " Time ", "Hour", "-", "Minute",       "-", "Second", ")"}] <> ".pdf", c2] // SystemOpen ````