If I understand correctly, PHP is a very “straight forward” language.
For example:
<?php
$x = "Hi"
echo $x;
?>
This should be outputted as Hi to the user and nothing we would put inside the code block will prevent this from happening or change the output that the user gets.
But how can this be?
I mean,
If PHP “broadcasts” line after line to the end-user (as long as it’s not an empty line or a code comment line) than why not?
Why a compilation wouldn’t allow to “bias” previous code segments in the same document?
I think I am wrong in relating to compilers more than I should but if a compiler gets some input and translates it to the output (which can be input) in another language, than I assume that it can also bias an early code segment, example pseudocode:
$x = 1
echo $x
POSTPROCESS $x = 2
// 2 is echoed
In theory, a compiler programmed to do so could change 1 to 2 just before runtime is finished. You might say that it’s useless but would you really say it’s impossible?..
A content management system creates some HTML link elements which I don’t want.
Removing these elements via CSS (display:none) or JavaScript (remove()) isn’t useful because then crawlers could still access any webpage linked from these elements.
I don’t want to remove the PHP creating these elements directly from the complex content management system source code but I still want them not to take effect and I am not sure how.
What cms are you using. There might be a better option to remove these specific elements based on the cms. Many cms platforms have ways to alter output through various post processing mechanisms. There might also be a way to prevent the link from rendering by adding code outside the source itself.
As with deleting, due to the hardcoding nature of MediaWiki this requires broad studying of the PHP MediaWiki source code which at least now I as a non PHP programmer cannot do, hence I seek postprocessing as I have described already.
Such postprocessing would allow me to change any element, based on its CSS selector, into an empty string, or something of that sort, I guess.
An alternative we’re using quite often at work is to proxy the site through NGiNX and use sub_filter.
Just make sure to request the page from the origin without any compression, otherwise it won’t work.
upstream website.tld {
keepalive 4;
server {IP OF ACTUAL SERVER BEING PROXIED}:443; # Or 80 if using HTTP
}
server {
listen 443 ssl;
location / {
proxy_pass https://website.tld; # or http:// if applicable
proxy_set_header Connection ""; # Prevent sending Connection: close from client to backend
proxy_set_header Accept-Encoding ""; # no compression allowed or sub_filter won't work
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1
# This will actually remove the link
sub_filter_once off; # Replace all occurences, not just the first one
sub_filter '<a href="/some/link">Foo</a>' '';
}
And then point the DNS for website.tld at the proxy server instead of the actual server.