• 4 Posts
  • 27 Comments
Joined 2 years ago
cake
Cake day: September 13th, 2023

help-circle
  • ProtecyaTec@lemmy.worldtoTechnology@lemmy.world*Permanently Deleted*
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    2 months ago

    Not a single modern system does that. It’s terrible practice and won’t even pass automated code reviews with sane settings.

    What you’re talking about is semantics. At a base level, whether you use a templating engine, include / require, or just straight up mix HTML / PHP - PHP “stops execution” to output to the browser. The few exceptions to this that I can think of is if it’s instead handing off that responsibility to JS or some other frontend processor.

    Templating engines are cool. They make it easier to separate your views from logic. It makes interloping more straight-forward and possibly more maintainable (though, not always - Engines don’t save from bad practices), but I do not agree that it’s defacto. I think the strength of PHP is it’s ease to just jump into it and get something working, right “out of the box”. The ease of mixing PHP and HTML is a boon from an entry level aspect. Low entry level leads to wider adoption, leads to more discussions, more volunteers for FOSS, more bug reports, more more more.

    I could create a vanilla PHP application that organizes views just as well without a templating engine which could be understood by someone with baseline PHP knowledge - that’s good thing. It’s inherit to PHP and I won’t need to worry about keeping any templating library updated or ported to a new engine. In my made-up vanilla app, I wouldn’t do what 4chan did in their views, but I may do what WordPress does in your example because, used sparingly, in an organized application, it’s not that big of a deal. For the most part though, I do like to keep my HTML views and my PHP logic separate in an MVC kind of way either through templating or just straight up includes.


  • ProtecyaTec@lemmy.worldtoTechnology@lemmy.world*Permanently Deleted*
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    2 months ago

    I completely disagree.

    Intermingling PHP and HTML is one of PHP strengths. The processing/executing difference you’re describing is almost always negligible due to how PHP is optimized (specifically for this kind of thing - outputting HTML to the browser sometimes).

    Seriously, compare this to the 4chan image board view we really aren’t looking at the same source code. In comparison, the WordPress function is blocked, purposeful, together. It’s a single CSS block output all at once. On the otherhand, in the linked 4chan discussion board PHP file, it echos as strings, broken up by multiple conditionals, and is difficult (even from an IDE perspective on highlighting) to tell where a block starts and where it ends (again due to it being echo’d in strings, and broken by conditionals). Trying to modify this blocked CSS is going to be wayyyyyyyyyyyyyyyyyyyy easier than trying to modify a bunch of printed HTML strings broken up by multiple nested conditionals. Plus it’s just straight-up easier to read and straight-forward to understand what the function does right away.

    To harp on this even more, one of the benefits of blocking HTML in this way is IDE highlighting. In your example, if you were to pop that into a modern IDE like VSCode, it’ll highlight tags and allow collapsing like a normal HTML doc. It’ll probably even highlight the CSS as expected. On the other-hand, by echoing / printing HTML strings, IDEs aren’t going to highlight these things as HTML since they’re PHP strings, and in the case of the imageboard, it’s going to struggle finding matching open/end tags due to PHP strings and broken conditionals. I’d much prefer the WordPress example over echo / printing multiple lines of HTML strings (this is really a pet-peeve of mine).

    I can’t think of a single system that doesn’t “stop PHP executing” at some point to output HTML in some way. Maybe an app that dynamically pulls it’s views in through JS I guess.

    For comparison to future readers, this is just a small portion of the imageboard which goes on like this for another 600 lines:

    	if( $resno ) {
    		$closed = $log[$resno]['closed'] || $log[$resno]['archived'];
    		
    		if( !$stripm ) {
    			$msg .= '<div class="navLinks mobile">
    	<span class="mobileib button"><a href="/' . BOARD_DIR . '/" accesskey="a">' . S_RETURN . '</a></span> <span class="mobileib button"><a href="/' . BOARD_DIR . '/catalog">' . S_CATALOG . '</a></span> <span class="mobileib button"><a href="#bottom">' . S_BOTTOM . '</a></span> <span class="mobileib button"><a href="#top_r" id="refresh_top">' . S_REFRESH . '</a></span>
    </div>';
    		}
    
    			if( !$stripm ) $msg .= '<div id="mpostform"><a href="#" class="mobilePostFormToggle mobile hidden button">' . S_FORM_REPLY . '</a></div>';
    	} else {
    		if( !$stripm ) $msg .= '
    <div class="navLinks mobile">
    	<span class="mobileib button"><a href="#bottom">' . S_BOTTOM . '</a></span> <span class="mobileib button"><a href="/' . BOARD_DIR . '/catalog">' . S_CATALOG . '</a></span> <span class="mobileib button"><a href="#top_r" id="refresh_top">' . S_REFRESH . '</a></span>
    </div>
    <div id="mpostform"><a href="#" class="mobilePostFormToggle mobile hidden button">' . S_FORM_THREAD . '</a></div>';
    	}
    

    Formatting and structure is important for a readable framework / project and longevity. 4chan had none of this - Moot took the bag and ran and whoever took it over just left left the PHP standards/organization in 2003.


  • ProtecyaTec@lemmy.worldtoTechnology@lemmy.world*Permanently Deleted*
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    2 months ago

    Really though, it doesn’t.

    Github -> WordPress

    Github -> 4chan

    I absolutely hate the way 4chan formats their HTML + PHP intermingling in views. That’s not to say WordPress doesn’t do this as well, but oh man in a much better, cleaner, and more sparingly way. The 4chan imageboard view Github -> 4chan is absolute chaos. Why this wasn’t rewritten is beyond me. That’s just the first thing I see as I peruse the source, I can’t imagine it gets much better from here.

    Here’s a fun exercise: What’s the deepest nest in this loop? Github -> 4chan Bonus points: What’s the deepest nested statement in the whole source?


  • First off, there’s nothing we can do about moving away from larger hosting Corporations, not with the technology we currently have. If we want to reach a national or international audience, we need infrastructure, and that has to come from somewhere; a business model makes sense. If you’re hosting to a small community, you’d be able to get away with 1 selfhost, but to scale you’d need redundancies and bandwidth. The best choice we can make is the companies we would rather do business with. At this point, I’m definitely favoring Cloudflare and Azure (in that order) over AWS.

    I would argue that the fractured - often openly hostile - intra-instance infighting on Lemmy feeds directly into OP’s image’s “this is too weird and scary” attitude.

    I see this in a lot of comments about this so while I don’t want to downplay the severity of this, I’ve personally never see instance in-fighting. Maybe it’s the things I’m subscribed to, idk, but I usually visit both my local and all just to see what’s going on. The Hexbear domain being sold is probably one of the first times I’ve run across discussions about other instances. Also, their domain being sold is lowkey hilarious. That was a problem as old as the internet (losing a domain). As we move to decentralization and privatization/ownership of data that’s going to continue to be a thing I think.

    Its the same intra-channel fighting we saw on Reddit,

    Maybe I’m misunderstanding the intra-channel fighting - is it just disagreeable people commenting, or is it like “This community is better than that” or “This instance is better than that”? I often see discussions on Reddit, arguing, bad faith actors, but I wouldn’t classify that as in-channel-fighting. idk.

    There’s not a lot we can do about it individually.

    Complain. JoinLemmy is Open Source on Github. If you have ideas - share them. If you take a look through their issues and feel like adding in your 2 cents, go for it.



  • IMO it’s a logistics problem.

    The wealthy own the Internet. 7/10 of the top websites on the entire Internet are owned by the same people at Trump’s inauguration. The interest is no regulation so that they can keep pouring money into marketing tactics, ethical and unethical, for engagement. The bottom line is wealth, power, control.

    Their websites are visited by Billions, daily. They control the narrative. That doesn’t even get into news networks.

    Education has been eroded for close to a century now.

    Technology has grown far faster than we can keep up with.

    AI is going to make information control, data gathering, and data compiling faster/easier.

    How do you fight a beast this big? How can any other party get their message and their narrative out to the masses on par with the wealthy? How do you convince the ignorant of harmful things that they can neither believe nor fathom?

    I truly have little hope for non-dystopian future.






  • Sure is going to be more difficult to make progressive change in a fascist state. I’ve no doubt conservatives are going to be more open to change than their counterparts, but something tells me that those changes aren’t going to be anywhere near progressive.

    Yeah, I do blame the voters who sat this election out or voted 3rd party. Absolute ignorance in the face of factual, tangible datapoints.

    “Oh, the democrats should have campaigned harder! Oh, they should have been more progressive!” while conservatives just consistently lie through their teeth, skirt the law, and prey on the weak and ill-informed. While conservatives are open-faced about their regressive policies.

    Change takes time, but yeah, let’s sit this one out. Real progressive. Nothing like watching the trolly going toward the wrong side of the track and saying “Oh, not my problem, I didn’t touch the lever! Whatever happens, it’s not my fault because I did nothing to help or hurt the situation! My hands are clean!”


  • I don’t know, y’all can point fingers in every direction, but the fact is - those voters who didn’t show up to vote, voted 3rd party, or voted Republican knew who Trump is and what the outcome would be. Project 2025 was laid out in full right in front of us. We all saw his previous 4 years in office. We saw the repeal of Roe with a majority court. These (potential) voters just don’t care about progress or people and want to speed up the burning of Rome. US Presidential elections have been binary in everyone’s lifetime here.

    There’s no excuse other than simply “I don’t care” regardless of which excuse you want to pick from the box. The House, Senate, and Supreme Court are all lost - they have absolute free reign to do whatever they want in the next 4 years. The best case scenario is that it’s not as bad as last time. The worst case scenario is the US becomes reclusive, regressive, and more corrupt akin to other dictator run countries. Just like those other dictator run countries, in the worst case scenario, there will be no revolution if/when things go “too far” because they hold the power and have the support to stomp down any opposition to dust.

    It’s certainly a sad state of affairs, and in no sane world should DJT have won a 2nd term, but here we are, watching the circus erect their tents while we whisper in the stands.





  • ProtecyaTec@lemmy.worldOPtoSelfhosted@lemmy.worldHTTPS with FreeDNS
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    I don’t know if this will help anyone but damn is the documentation on how to do this kind of thing scarce so here I am. I was quite a struggle both learning all this and implementing it but it’s been fun overall.

    FreeDNS doesn’t seem to have a way to add any kind of SSL Certs as far as I can tell. Not that I needed to, but when I tried explaining my situation to the hosting provider they suggested that the cert needed to be on the DDNS server.

    I also couldn’t get the Asustor Reverse Proxy to work either. Many of the tutorials and user suggestions i ran across suggested that this is the way to get SSL but when I tried to implement it I kept landing at my portal login and nothing was getting proxy’d. The netstat command was showing that whatever the reverse proxy port needed was not open - I also ran across this in a 2020+ thread on Asustor.

    Right now I’ll also need to manually update the certs and go through this process again in 3 months time. There might be a way to automate this process but it’s a lot of steps that I’m not sure can be automated in this seeming (to me) flawed setup. In any case, it’s been challenging but fun and I think in the next 6 months I’ll upgrade out of Asustor and into a bigger server with a core Linux setup. I know nothing about Linux :)


  • ProtecyaTec@lemmy.worldOPtoSelfhosted@lemmy.worldHTTPS with FreeDNS
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    I do appreciate everyone’s suggestions and help. Here’s what I ended up doing.

    FreeDNS via freedns.afraid.org as a DDNS Subdomain

    Domain + Subdomain via hosting provider

    Hosted Subdomain CNAME to the DDNS Subdomain

    Setup DDNS using Asustor > Settings > Manual Connect and setting up a FreeDNS account and input the info it needed. Last DDNS update keeps coming back as Failure but FreeDNS keeps updating my IP so it seems to work, but for whatever reason Asustor doesn’t think it’s working.

    Used openssl + certbot CLI tools to generate a certificate that covers all 3 cases: Hosted Subdomain, Hosted Domain, DDNS Subdomain. Looks like this:

    certbot certonly --key-type rsa --rsa-key-size 2048 --manual --preferred-challenges dns -d hosteddomain.example -d subdomain.hosteddomain.example -d ddns.domain.example
    

    This will set up verification codes that you can create TXT records for on the Hosted Domain and the DDNS Domain. I had to contact FreeDNS to get access to add text records with underscores but they were cool and quick to reply. They look like this:

    _acme-challenge.hosteddomain.example
    8suZTccF9ZpB0fnBr9mgEEXTcX7cqSkDXiBzucTcOfw
    

    Once the certificates are in place I uploaded them to my Hosted Domain and verified that my Hosted Domain was showing the SSL certificate / lock at HTTPS.

    Next I logged into my Asustor and under Settings > Certificate Manager I added my SSL Certificates and assigned it as the primary certificate for the NAS.

    Finally, I needed to enable SSL on my Jellyfin, which required a PFX file.

    openssl pkcs12 --export -out "Z:\Path\To\PFXOutput\jellyfin.pfx" -inkey "Z:\Path\To\Cert\jellyfin.key" -in "Z:\Path\To\Cert\jellyfin.crt"
    

    Under Jellyfin > Dashboard > Networking I enable HTTPS, Require HTTPS, give it the path to the PFX file and the PFX password, and Allow remote connections to the server. I disabled port forwarding from Jellyfin and had to jump into my router to remove the UPnP records it had previously added. All port numbers are default to Jellyfin and no URLs in the Server Address Settings.

    Important to take note of the Jellyfin ports here for both HTTP and HTTPS requests. Important note to restart Jellyfin after this takes effect. Asustor has an App Central where under Installed Apps you can just turn it off and back on again.

    Finally, I added Port Forwarding to my router so that the 443 looks for the Jellyfin HTTPS port and 80 looks for the Jellyfin HTTP port at my NAS IP.

    Now I can access HTTPS subdomain.domain.example and land at my Dockered Jellyfin app.


  • ProtecyaTec@lemmy.worldOPtoSelfhosted@lemmy.worldHTTPS with FreeDNS
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 year ago

    No, I don’t necessarily want other people to access my Jellyfin, but my folx live out in the boons, (visiting on holidays etc.) and that was the only way I could find to reliably access my media. I guess I also come from a web background so it felt right to me. The Asustor I have really limits what I can and can’t do with it. I got it as a like, starter point since it felt out of the box. I’m also on Windows lol.

    Do you have any resources for how I could grant access outside my network with a VPN, wireguard, or tailscale? I’m open to other options, I’m really just kind of fumbling my way through this idea of what I want.



  • I do have port 80 open as well as 443, both going to my Jellyfin HTTP/HTTPS ports respectively. HTTP seems to work for both when I access “pretty” domain and the FreeDNS URLs directly. It’s really only when I try to force HTTPS that I’m having issues.

    I’ll play around with Let’s Encrypt today to see if I can get the FreeDNS cert applied. I’ve tried to use AI to assist me in learning how to do all this, it suggests I need both my “pretty” domain and the FreDNS domain tied to the same Cert, which Im unable to do at my current domain registrar, so I might also need to move that but I’ll take it one step at a time.


  • ProtecyaTec@lemmy.worldOPtoSelfhosted@lemmy.worldHTTPS with FreeDNS
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    1 year ago

    I’m still pretty green so I’m not sure what terminated means in this context.

    My domain registrar for my “pretty” domain (not FreeDNS) allowed me to issue a Let’s Encrypt on it. It gave me the encrypted Cert code, Private Key code, and Immediate Cert code. I was able to bring them down into .crt and .key files respectively and assign them to my NAS. Jellyfin though required a PKCS #12 file so I installed openssl CLI via Choco and fed it my .crt and .key files to generate the necessary pfx file. So, right now all the cert information is tied to my “pretty” domain via my domain register. I would assume that my register and Let’s Encrypt has my private key info, but also my key files uploaded to the NAS and rolled into the PFK file.

    Not sure if that helps or answers your question but that’s the info I got.