Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


I made a PHP based Looking Glass script, and by me, I mean ChatGPT
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

I made a PHP based Looking Glass script, and by me, I mean ChatGPT

MannDudeMannDude Host Rep, Veteran

I know a bit of PHP but that's about it. A decade ago I wrote a very basic PHP templating system for websites that I still use today and after that I just never got real into it. Most of anything that I'd want created, already existed, and things that existed could be modified.

I'm not a complete idiot however, although, I can skim through code and copy/paste/hack together random things with relative few cusswords spoken but through my abilities alone, I would have not been able to complete what I've done tonight by any means. I don't have the attention span or motivation to learn how to properly code. And besides, now I don't have to.

Enter: ChatGPT

I wanted a looking glass script that I could easily embed and style to match my website's design. I didn't want it to rely on some hipster software stack and I wanted it to run out of the box on modern dependencies.

So after several hours and many different revisions and updates through the day, I present to you: php-lg

Demo it here: https://lg.otr.cx
GitHub: https://github.com/Incognify/php-lg


Features:

  • PHP based (Only tested on PHP 8.0 and PHP 8.2, probably works on older stuff)
  • Built in rate limiting (Though nginx will do this better than PHP)
  • Doesn't allow you to enter bogons by default, but you can adjust this to blacklist other subnets (IPv4 and IPv6)
  • You can also block certain hostnames, if you so desire it. (Currently 'localhost' is the only blocked hostname)
  • It actually doesn't look too bad on mobile. That was an accident, I don't give a shit about mobile functionality.
  • It's only three files. (index.php, result.php, style.css)

System Requirements:

  • PHP

(Tested on Debian 12 w/ PHP 8.X)

To Do:

  • Make the design... better.
  • Probably going to add some test files.
  • More user defined variables to make it easier for you to use this how you want it.
  • Add speedtest features, probably.

I don't want to over complicate this. The goal is to just have a basic and easy to use looking glass script that is both easy to modify and intergrate into existing website designs.


Let me know your thoughts and how to improve it. I'll post updates in this thread. While originally I just wanted to make something for our own use, I figured this could be a useful tool for others as well.

Comments

  • Hey, its looks nice. My only suggestion is, please make the test output more mobile-friendly. 💯

  • LeviLevi Member

    How did you described a job to gpt?

  • MannDudeMannDude Host Rep, Veteran
    edited August 2023

    @LTniger said:
    How did you described a job to gpt?

    The same way I would if I were hiring someone to make a project for me.

    The first prompt was this:

    I'm wanting to build a simple PHP 8.0 driven network looking glass script. Can you write something that will behave based on the below requirements?

    A user can input an IP address in a text field, this may be their remote server or home IP address. From a drop down box next to it, they select, "Ping, ping6, traceroute, traceroute6, mtr, or mtr6". Depending on what they choose is what the script will run.

    For example, if a user inputs 1.1.1.1 into the IP box, and selects, "MTR" from the drop down, the output of the script will show the MTR to the IP 1.1.1.1

    Then it was more or less trial and error and messing around and modifying what it gave me to fit my own needs. For example, at first only IPs worked, not hostnames. I didn't say I wanted hostnames.

    Eventually, I got tired of looking at a page with no styling, so I asked after several back-and-forths later I asked it:

    Can we give the script some simple styling? Dark mode style, with matte pastel styling of the buttons, dropdown and form please.

    And continued to elaborate on what I wanted as it came together and making my own minor adjustments based on what it had provided.

    This entire thing is 99% ChatGPT, 1% me.

    I know AI stuff isn't really news anymore but it's still pretty wild.

  • FatGrizzlyFatGrizzly Member, Host Rep

    Looks good, but gpt got the bgp.tools link wrong

  • MannDudeMannDude Host Rep, Veteran
    edited August 2023

    @FatGrizzly said:
    Looks good, but gpt got the bgp.tools link wrong

    That was the 1% I did, ha. Fixed.

  • xTomxTom Member, Patron Provider

    Cool stuff, looks good.

  • doghouchdoghouch Member
    edited August 2023

    Looks good! You may want to resolve the IP address of host names first (to check for a match on the blocklist).

    (a user can set the IP they want tested on a subdomain and bypass the check altogether)

  • @MannDude said:
    I know a bit of PHP but that's about it. A decade ago I wrote a very basic PHP templating system for websites that I still use today and after that I just never got real into it. Most of anything that I'd want created, already existed, and things that existed could be modified.

    I'm not a complete idiot however, although, I can skim through code and copy/paste/hack together random things with relative few cusswords spoken but through my abilities alone, I would have not been able to complete what I've done tonight by any means. I don't have the attention span or motivation to learn how to properly code. And besides, now I don't have to.

    Enter: ChatGPT

    I wanted a looking glass script that I could easily embed and style to match my website's design. I didn't want it to rely on some hipster software stack and I wanted it to run out of the box on modern dependencies.

    So after several hours and many different revisions and updates through the day, I present to you: php-lg

    Demo it here: https://lg.otr.cx
    GitHub: https://github.com/Incognify/php-lg


    Features:

    • PHP based (Only tested on PHP 8.0 and PHP 8.2, probably works on older stuff)
    • Built in rate limiting (Though nginx will do this better than PHP)
    • Doesn't allow you to enter bogons by default, but you can adjust this to blacklist other subnets (IPv4 and IPv6)
    • You can also block certain hostnames, if you so desire it. (Currently 'localhost' is the only blocked hostname)
    • It actually doesn't look too bad on mobile. That was an accident, I don't give a shit about mobile functionality.
    • It's only three files. (index.php, result.php, style.css)

    System Requirements:

    • PHP

    (Tested on Debian 12 w/ PHP 8.X)

    To Do:

    • Make the design... better.
    • Probably going to add some test files.
    • More user defined variables to make it easier for you to use this how you want it.
    • Add speedtest features, probably.

    I don't want to over complicate this. The goal is to just have a basic and easy to use looking glass script that is both easy to modify and intergrate into existing website designs.


    Let me know your thoughts and how to improve it. I'll post updates in this thread. While originally I just wanted to make something for our own use, I figured this could be a useful tool for others as well.

    Really nice and basic, will use it if you agree.

  • kaitkait Member

    @c1vhosting said: will use it if you agree.

    Its free, open source and has no license, so feel free to use it, you can configure the values on line 7 untill 10 in index.php and in that same file change the stuff in the div on line 101.

    Thanked by 2c1vhosting sillycat
  • @kait said:

    @c1vhosting said: will use it if you agree.

    has no license, so feel free to use it

    Generally if a project has no license then that means all rights are reserved.

    Thanked by 1c1vhosting
  • kaitkait Member

    @itzaname said:

    @kait said:

    @c1vhosting said: will use it if you agree.

    has no license, so feel free to use it

    Generally if a project has no license then that means all rights are reserved.

    Don't care, if its on the web I will steal it :)

    He also said:

    I figured this could be a useful tool for others as well.

    Thanked by 1sillycat
  • MannDudeMannDude Host Rep, Veteran
    edited August 2023

    @itzaname said:

    @kait said:

    @c1vhosting said: will use it if you agree.

    has no license, so feel free to use it

    Generally if a project has no license then that means all rights are reserved.

    Have fun. Would be silly to try to hoard this for myself.

    @doghouch said:
    Looks good! You may want to resolve the IP address of host names first (to check for a match on the blocklist).

    (a user can set the IP they want tested on a subdomain and bypass the check altogether)

    Good idea. I noticed even the popular looking glass scripts will resolve a domain to localhost, for example, so this will be a good useful addition.

  • jmginerjmginer Member, Patron Provider

    It would be perfect for me to be able to integrate Juniper's show route command.

    Of course, for this you need to establish a remote connection to the router and capture the returned result.

    You can do this with Ansible:
    https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_cliconf.html#ansible-collections-junipernetworks-junos-junos-cliconf

    > show route 8.8.8.8
    
    inet.0: 928042 destinations, 3969007 routes (927489 active, 0 holddown, 1205121 hidden)
    + = Active Route, - = Last Active, * = Both
    
    8.8.8.0/24         *[BGP/170] 6w5d 11:53:21, MED 0, localpref 105
                          AS path: 15169 I, validation-state: unverified
                        >  to 185.1.192.25 via ae0.10
                        [BGP/170] 6w5d 11:51:35, localpref 100
                          AS path: 1299 15169 I, validation-state: unverified
                        >  to 62.115.189.201 via ae0.13
                        [BGP/170] 1w3d 02:35:54, MED 0, localpref 100
                          AS path: 3257 15169 I, validation-state: unverified
                        >  to 213.254.219.201 via ae0.12
                        [BGP/170] 2w4d 10:25:40, MED 0, localpref 95
                          AS path: 5511 15169 I, validation-state: unverified
                        >  to 193.251.144.153 via ae0.15
    
    
  • MannDudeMannDude Host Rep, Veteran

    @doghouch said:
    Looks good! You may want to resolve the IP address of host names first (to check for a match on the blocklist).

    (a user can set the IP they want tested on a subdomain and bypass the check altogether)

    Fixed.

    Will push an update later after I add some other stuff.

  • Just out of curiosity, why php in 2023?

    Thanked by 1MannDude
  • APIAPI Member
    edited August 2023

    The rate limit needs to be in the result.php script so that it actually rate limits the queries. However it's session based so take into account ignoring cookies will bypass it - the nginx approach makes more sense, agree.

    Thanked by 1MannDude
  • MannDudeMannDude Host Rep, Veteran

    @johndeo983 said:
    Just out of curiosity, why php in 2023?

    It's quick and simple to use. What would you have chosen?

    @API said:
    The rate limit needs to be in the result.php script so that it actually rate limits the queries. However it's session based so take into account ignoring cookies will bypass it - the nginx approach makes more sense, agree.

    Good point. I'm using nginx to ratelimit on my install, though I'm not certain if the limits are adequate or how it can be improved.

Sign In or Register to comment.