PHP Classes

File: fwphp/glomodul/blog/msgmkd/altervista001c.txt

Recommend this page to a friend!
  Classes of Slavko Srakocic   B12 PHP FW   fwphp/glomodul/blog/msgmkd/altervista001c.txt   Download  
File: fwphp/glomodul/blog/msgmkd/altervista001c.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: Update of fwphp/glomodul/blog/msgmkd/altervista001c.txt
Date: 1 year ago
Size: 21,126 bytes


Class file image Download
1c. Web server at home, DDNS (dynamic DNS), access my dyndns from local network, PHP, CURL, OpenSSL =================================================================================================== [HOME]( DDNS ? Dynamic DNS ================== Access my dyndns from local network ee access my dynamic DNS domain name inside my LAN. I dont want to redirect from Dyn hostname to 192.168.x.x (create an entry in my hosts file with Dyn hostname and the LAN IP), but how i can access from inside network to my dyndns Solution below would be better without (see below) or but I do not know how to do it. I did not used this (not clear explanations): Few home routers support what?s known as NAT Reflection or Loopback, see[\_Loopback\_Routers]( NAT loopback connection basically is accessing a LAN side device via it?s NAT?ed WAN IP from the internal LAN network. Setting up Microsoft Loopback adapter allows you to have multiple service appear at the same port. WORKS My home site from local network : --------------------------------------- []( -------------------------------------------------------------------------------------------- []( -------------------------------------------------------------------------------- WORKS My home site from inet is without (see below) or : ----------------------------------------------------------------------------- []( ------------------------------------------------------------------ How I did it : 11111 Open port in router and firewall -------------------------------------- On Windows XP PC (different router) subdomains like or are not needed, but on Win 8.1 and 10 router Siemens Gigaset SX763 WLAN dsl are now needed (few monts ago not !!). 1\. open port 8083 or simmilar in router ? port 8083 forward to my PC static IP 192.168.x.x (ipv4 network adapter properties !) 2\. open port 8083 in Windows firewall for TCP access (UDP also ) 2.1 WINKEY+R -> type WF.msc 2.2 In the Windows Firewall with Advanced Security, in the left pane, left-click Inbound Rules -> click New Rule in the action pane. 2.3 In the Rule Type dialog box, select Port, and then click Next? ZWAMP does next in Windows firewall : httpd.exe J:\\zwamp64\\vdrive\\.sys\\Apache2\\bin\\httpd.exe mysqld.exe J:\\zwamp64\\vdrive\\.sys\\mysql\\bin\\mysqld.exe My C:\\Windows\\System32\\drivers\\etc\\**hosts** localhost dev1 ::1 localhost dev1 22222 What Is My IP see code at end of this page ------------------------------------------------ The request came from: **fe80::8179:3afd:d500:28f5** My home web server IP : ------------------------------------- or []( []( []( []( []( []( 33333 Send my IP to DDNS provider --------------------------------- DDNS client or []( or rem J:\\zwamp64\\vdrive\\web\\utl\\wcurl\ @cls cd %~DP0 @echo Updating FreeDNS @J:\\CURL\\CURL -k @pause or rem J:\\zwamp64\\vdrive\\web\\utl\\wget\ cd %~DP0 J:\\CURL\\wget -q ?read-timeout=0.0 ?waitretry=5 ?tries=400 ?background Public DNS Pointing To localhost ( ============================================ []( Hosts File ---------- The first and easiest method is where one edits their hosts file (`/etc/hosts` in Linux, `C:\Windows\System32\Drivers\etc\hosts` for some versions of Windows) and add lines like this: ` client1.local` `` ` client3` At work, we have up to five different hostnames for each of our clients. Adding yet another client means dozens of developers that now need to edit their hosts file. Oh, the pain and agony when you have to do this for hundreds of domains! _What if we could have a single top-level domain that always resolved to localhost_ DNS Entries ? Windows --------------------- If you are using Windows DNS, you can create a new zone (I did not): dnscmd /RecordAdd local \* 3600 A dnscmd /RecordAdd local @ 3600 A dnsmasq ? Linux, MacOS ---------------------- On Linux systems, you can install dnsmasq to pretend to be a real DNS server and actually respond with for all subdomains of a top level domain. So, if you wanted \*.local to always resolve to your own domain, then you can use URLs like this: `http://client1.local/` `http://client2.local/` `http://client3.local/` You only need to install and set up dnsmasq. There?s some well-written instructions at []( that you can follow; I won?t repeat them here. The drawback of this setup is that you now have to install and configure dnsmasq on every machine where you want to use this trick. _What if someone set up DNS entries and basically did this for you_ Available Wildcarded DNS Domains -------------------------------- Some kind hearted people already set up wildcarded domains for you already. You can use any top level domain below and any subdomain of these and they will always resolve back to (your local machine). []( or []( ? WORKS same as[http://localthost:8083/](http://localthost:8083/) or same for: **2011 ? September 2017**: 1. ? Managed by me; it will always point to localhost for IPv4 and IPv6 2. ? Also has an SSL cert 3. 4. 5. 6. 7. 8. 9. no more Now, with these wildcarded domains, you don?t need to do any modification of your system for requests to come back to your own server. For instance, you can go to and the web page request will always head back to your own server. You?ll still need to configure your web server to answer on this hostname as above said, but at least the DNS portion of the problem is now solved. Install cURL (SSL-enabled) Win command-line tool ------------------------------------------------- If you install [Git for Windows]( you get Curl automatically too. There are some advantages: * Git takes care of the `PATH` setup during installation automatically. * You get the [GNU bash](, a really powerful shell, in my opinion much better than the native Windows console. * You get many other useful Linux tools like tail, cat, grep, gzip, pdftotext, less, sort, tar, vim and even Perl. [\_2/messagingservice/files/installing\_curl\_command\_line\_tool\_on\_windows.html]( This tutorial shows you how to access Oracle Messaging Cloud Service via the REST interface by using the cURL command-line tool. cURL is free, open software that runs under various operating systems. This tutorial demonstrates cURL on a Windows 64-bit operating system that is enabled for the secure sockets layer (SSL). The authentication aspects of the Messaging Cloud Service require an SSL-enabled environment. Your first task is to install the appropriate version of cURL for your SSL-enabled environment. There is an ordered series of steps to follow to install cURL on Windows. There are two libraries to install and they must be installed before cURL will work with SSL. Also, they must be installed in this order to work. Do not skip the step to install a recent certificate. Install Visual C++ 2008 Redistributable Package. For 64-bit systems: Visual C++ 2008 Redistributables (x64) from []( For 32-bit systems: Visual C++ 2008 Redistributables (x32) Install Visual C++ 2010 Redistributable Package. For 64-bit systems: Visual C++ 2010 Redistributables (x64) from []( For 32-bit systems: Visual C++ 2010 Redistributables (x32) Install Win(32/64) OpenSSL v1.0.0k Light from []( For 64-bit systems: Win64 OpenSSL v1.0.0k Light For 32-bit systems: Win32 OpenSSL v1.0.0k Light In your browser, navigate to the cURL welcome page at []( and click Download. On the cURL Releases and Downloads page, click the link for the SSL-enabled version for your computer?s operating system, download the zip file, and install it in a new folder on your computer. The cURL website offers a wizard to find the appropriate version for your computer?s operating system. For this tutorial, the 64-bit generic, SSL-enabled version for Windows is selected. Copy curl.exe file into your Windows PATH folder. By default, this is C:\\Windows\\System32 Install recent CA Certificates. Do not skip this step. Download cacert.pem, a recent copy of valid CERT files, from []( Copy it to the same folder where you placed `curl.exe` and rename it curl-ca-bundle.crt. Or: Move this file into your Windows PATH folder. Invoke `curl.exe` from a command window (in Windows, click Start > Run and then enter ?cmd? in the Run dialog box). You can enter `curl --help` to see a list of cURL commands. []( DDNS record types ----------------- **Type: A**? Point ( to a hard coded**IP Address**. Most direct and straight forward option, also note any change you make in the FreeDNS program is reflected on the internet and made live immediately. The only way you will not see immediate results is if you have cached a query on your computer by looking it up PRIOR to configuring it in the FreeDNS program. **Type: MX**? Point to a**mail server**. These type of records are special for just mail servers, they can co-exist with A records, and their only use is for routing mail to a different location. All mail implementations check for this record first before attempting to route an e-mail message. If a MX record does not exist for a host, an e-mail delivery would be attempted directly to the IP that the hostname resolves to. **Type: AAAA**? Point to a IPv6 address. Useful for those who are using IPv6 on their personal networks or those who are using a[IPv4 to IPv6]( at home. **Type: CNAME**? Point to another**hostname**. Good for those who are using other dynamic DNS services. You can create a CNAME record to another host and whatever you choose here will go to whatever IP address the CNAMEd host has. **Type: NS**? Point to another**NAMESERVER**. If you choose this option, then whatever address you choose using FreeDNS will have to be configured and setup on the destination ADDRESS (nameserver) that you choose. This option basically means you are delegating a FreeDNS host to another DNS server all together, so when you choose this option you are telling every computer on the internet to ask the ?address? where is located at. If the host you point an NS record to is not configured to answer for the that you are using in FreeDNS then the host will not resolve. **Type: TXT**? Lets you create TXT records, used for a number of different things, most commonly for DKIM records (for combatting spam) so other receiving mail servers can verify email was sent from you by verifying your publically published crypto-signature. Wrap your TXT ?destination? in quotes (don?t worry, the system will remind you if you forget). **Type: SPF**? A anti-spam record, good to have on any domain you?re sending email with. See[]( more details. **Type: LOC**? A means for Expressing Location Information in the Domain Name System. [RFC1876]( the complete explanation. To find your latitude/longitude location, you may find[Map-O-Rama]( use. **Type: RP**? The Responsible Person RR. RP has the following format: RP <mbox-dname> <txt-dname> Both RDATA fields are required in all RP RRs. The first field, <mbox-dname>, is a domain name that specifies the mailbox for the responsible person. The second field, <txt-dname>, is a domain name for which TXT RR?s exist. A subsequent query can be performed to retrieve the associated TXT resource records at . [RFC1183]( the complete explanation. **Type: SRV**? A ?service? record, used by Session Initiation Protocol (SIP), and the Extensible Messaging and Presence Protocol (XMPP). Also used by Minecraft. Some examples: Type: SRV Subdomain: \_service.\_protocol.subdomain Destination: 4 fields, separated by a space (Priority Weight Port Target) Some more random examples: Type: SRV Subdomain: \_minecraft.\ Domain: Destination: 0 0 25676 Type: SRV Subdomain: \_jabber.\_tcp Domain: Destination: 10 0 5269 Type: SRV Subdomain: \_jabber.\_tcp Domain: Destination: 20 0 5269 Cool tips / hidden features --------------------------- 1). If you use other dynamic DNS services and plan to continue using them, one easy way to keep your IP address up to date, is by simply changing your record to a CNAME in the ?subdomains? area to your other dynamic DNS hostname, then you do not need to bother setting up a update script to Free DNS. 2). If you use only Free DNS, and have multiple hostnames to update, you can leave 1 of them a A record, and make the rest of them CNAME?s so you do not have to issue multiple updates each time. 3). If you want to redirect your users to a webpage when you go offline, you can add the string &offline=1 to your update string, and your record will then be converted to a web forward record. To edit the offline URL, click ?subdomains?, then click the subdomain you wish to edit, then click ?forward to URL? and fill it out with all your offline info, then save it. 4). If you are behind a firewall and Free DNS is not detecting your IP address correctly, you can add &address= to the update string, to override Free DNS auto-detection. To see the order and/or HTTP variables checked that Free DNS attempts to detect your IP address, you can[click here]( **DEFINITIONS:** Direct URL? The URL used to update FreeDNS with your current IP address. You can right click the link and copy shortcut to get the update URL. Grab URL Script? This is a link that generates a Windows .bat file you can use to update your IP address. You may however prefer to use[Free DNS Clients]( for a cleaner more automatic solution, not all of these are free. Edit Record? Self explanatory. If you don?t know what this means, contact me for a brutal hazing. The expiration time value is controlled by FreeDNS. In FreeDNS, the cache values (called a TTL, time to live) is set to 3600 seconds by default (1 hour). With that said, you must wait a maximum of one hour for your previous cache to expire. If you wish to verify that your update has made it into FreeDNS, instead of waiting, you can query against nameservers directly from your computer like so: click start menu -> click run -> type ?nslookup? without quotes, press enter. You should see a black box. Inside of it, type: ?server press enter Default Server: Addresses: 2607:f0d0:1102:d5::2 then =? press enter \*\*\* can?t find No response from server There are also 3rd party DNS utilities available for windows that would even let you see how many seconds are left in the cache in your ISPs nameserver. = Fake email for email askers on inet : mojmail@tempr.email Code ==== <php // J:\\awww\\apl\\dev1\\utl\\**ddns\_whatismyip.php** // proxy\_intermediate\_buffer\_server\_request\_hdr is modified // returns first forwarded IP match it finds // forwarded IP is of who started request function forwarded\_ip() { $keys = array( 'HTTP\_X\_FORWARDED\_FOR', 'HTTP\_X\_FORWARDED', 'HTTP\_FORWARDED\_FOR', 'HTTP\_FORWARDED', 'HTTP\_CLIENT\_IP', 'HTTP\_X\_CLUSTER\_CLIENT\_IP', ); foreach($keys as $key) { if(isset($\_SERVER\[$key\])) { $ip\_array = explode(',', $\_SERVER\[$key\]); foreach($ip\_array as $ip) { $ip = trim($ip); if(validate\_ip($ip)) { return $ip; } } } } return ''; } function validate\_ip($ip) { if(filter\_var($ip, FILTER\_VALIDATE\_IP, FILTER\_FLAG\_IPV4 | FILTER\_FLAG\_NO\_PRIV\_RANGE | FILTER\_FLAG\_NO\_RES\_RANGE) === false) { return false; } else { return true; } } $remote\_ip = $\_SERVER\['REMOTE\_ADDR'\]; $forwarded\_ip = forwarded\_ip(); > <span style="font-weight: bold;"></span><br> <h2>22222 What Is My IP</h2> <p>The request came from:<br> <strong><php echo $remote\_ip; ></strong> </p> <php if($forwarded\_ip != '') { > <p>The request was forwarded for:<br> <strong><php echo $forwarded\_ip; ></strong> </p> <php } exec("del wip\_web\_servera.txt"); exec("J:\\CURL\\wget.exe -qO - > wip\_web\_servera.txt"); if (file\_exists("wip\_web\_servera.txt")) { $wip\_web\_servera=trim(file\_get\_contents("wip\_web\_servera.txt")); echo '<h2>'."My home web server IP : $wip\_web\_servera".'</h2>'; } > or<br> <a href="" target="\_blank"></a><br> <br> <a href="" target="\_blank"></a><br> <br> <a href="" target="\_blank"></a><br> <br> <a href="" target="\_blank"></a>&nbsp; <br> <a href="" target="\_blank"><br></a><br> <br> <a href="" target="\_blank"></a><br><br> <br> <h2>33333 Send my IP to DDNS provider</h2> DDNS client<br> <br> or<br> <br> <a href="http://**YOURDDNSUSRNAME:YOURDDNSPSW** /;myip=<=$wip\_web\_servera>" target="\_blank">http://**YOURDDNSUSRNAME:YOURDDNSPSW** /;myip=<=$wip\_web\_servera></a> kod[ edit]($web_docroot_url/inc/utl/edservertxt.php)[ phpinfo]($web_docroot_url/phpinfo_inc.php) EOKOD; /\* call it so: kod\_edit\_run( $idx // script\_dir\_path , $idxscript // script\_name , MDURL); // web\_docroot\_url = (Apache) web server URL \*/ }