README.org
61 lines · 1378 bytes
1#+title: ifconfig.php
2
3* what
4php script. shows your ip address, user agent, and related info.
5same idea as ifconfig.me and ifconfig.co.
6
7output as html (default), plain text, xml, or json. single values
8on request.
9
10* use
11#+begin_example
12live at ip.cmc.pub:
13- ?q=text all, plain text
14- ?q=xml all, xml
15- ?q=ip ip only
16- ?q=ua user agent only
17#+end_example
18
19#+begin_src sh
20curl -L -X GET https://ip.cmc.pub/\?q\=text
21#+end_src
22
23apache rewrite so /ifconfig/xml works without the query string:
24
25#+begin_src sh
26RewriteEngine On
27RewriteCond %{REQUEST_FILENAME} !-d
28RewriteCond %{REQUEST_FILENAME} !-f
29RewriteRule ^ifconfig$ ifconfig.php [L]
30RewriteRule ^ifconfig/(.*)$ /ifconfig.php?q=$1 [L]
31#+end_src
32
33* develop
34install php and composer. fedora:
35
36#+begin_src sh
37sudo dnf install php-cli composer
38#+end_src
39
40maxmind-db dependency:
41
42#+begin_src sh
43composer require maxmind-db/reader:~1.0
44composer update
45#+end_src
46
47geolite2 database. not in the repo: maxmind-licensed, ~69mb, and stale
48the day after you download it. sign up for a free maxmind account, then:
49
50#+begin_src sh
51https://www.maxmind.com/en/accounts/current/geoip/downloads
52#+end_src
53
54download GeoLite2-City in mmdb form and put GeoLite2-City.mmdb next to
55ifconfig.php. without it the page still serves, minus the geo block.
56
57dev server:
58
59#+begin_src sh
60sudo php --server localhost:8080 --docroot .
61#+end_src