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) localtest.me or fuf.me 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 http://opensimulator.org/wiki/NAT_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 :

http://phporacle.mooo.com.localtest.me:8083/

http://phporacle.mooo.com.fuf.me:8083/

WORKS  My home site from inet is without (see below) localtest.me or fuf.me :

http://phporacle.mooo.com:8083/

 

How I did it :

11111 Open port in router and firewall

On Windows XP PC (different router) subdomains like fuf.me or localtest.me 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
127.0.0.1      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 : 89.164.194.29

or
http://www.canyouseeme.org/

https://www.whatismyip.com/

http://www.portchecktool.com/

http://www.yougetsignal.com/tools/open-ports/

https://bestvpn.org/whats-my-ip/

https://www.dynu.com/networktools/portcheck

33333 Send my IP to DDNS provider

DDNS client

or

http://YOURDDNSUSRNAME:YOURDDNS[email protected]/nic/update?hostname=phporacle.mooo.com&myip=89.164.194.29

or

rem J:\zwamp64\vdrive\web\utl\wcurl_phporacle.mooo.com.bat
@cls
cd %~DP0
@echo Updating FreeDNS
@J:\CURL\CURL -k http://freedns.afraid.org/dynamic/update.php?RFFqMGxON2s5V1RXSm51VE84bkJjamdIOjE3MDE3ODUw
@pause

or

rem J:\zwamp64\vdrive\web\utl\wget_phporacle.mooo.com.bat
cd %~DP0
J:\CURL\wget -q –read-timeout=0.0 –waitretry=5 –tries=400 –background http://freedns.afraid.org/dynamic/update.php?RFFqMGxON2s5V1RXSm51VE84bkJjamdIOjE3MDE3ODUw

 

 

Public DNS Pointing To localhost (127.0.0.1)

http://www.fidian.com/programming/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:
127.0.0.1 client1.local
127.0.0.1 client2.dev
127.0.0.1 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 127.0.0.1
dnscmd /RecordAdd local @ 3600 A 127.0.0.1

dnsmasq – Linux, MacOS

On Linux systems, you can install dnsmasq to pretend to be a real DNS server and actually respond with 127.0.0.1 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 http://drhevans.com/blog/posts/106-wildcard-subdomains-of-localhost 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 127.0.0.1 (your local machine).

http://localtest.me:8083/   or  http://fuf.me:8083/    – WORKS same as http://localthost:8083/
or same for:    2011 –  September 2017:

  1. http://fuf.me:8083/ – Managed by me; it will always point to localhost for IPv4 and IPv6
  2. http://localtest.me:8083/ – Also has an SSL cert
  3. http://127-0-0-1.org.uk:8083/
  4. http://42foo.com:8083/
  5. http://vcap.me:8083/
  6. http://beweb.com:8083/
  7. http://yoogle.com:8083/
  8. http://lvh.me:8083/
  9. http://ulh.us:8083/
    no more http://ortkut.com:8083/              http://feacebook.com:8083/
    http://ratchetlocal.com:8083/     http://smackaho.st:8083/
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 http://127-0-0-1.org.uk:8083/ 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.

http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/13_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 http://www.microsoft.com/en-us/download/details.aspx?id=15336

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 http://www.microsoft.com/en-us/download/details.aspx?id=14632

For 32-bit systems: Visual C++ 2010 Redistributables (x32)

Install Win(32/64) OpenSSL v1.0.0k Light from http://www.shininglightpro.com/products/Win32OpenSSL.html.

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 http://curl.haxx.se 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 http://curl.haxx.se/docs/caextract.html.
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.

http://freedns.afraid.org/dynamic/

DDNS record types

Type: A – Point subdomain.domain.com (phporacle.mooo.com) 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 subdomain.domain.com 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 subdomain.domain.com to a IPv6 address. Useful for those who are using IPv6 on their personal networks or those who are using a IPv4 to IPv6 tunnel at home.

Type: CNAME – Point subdomain.domain.com to another hostname. Good for those who are using other dynamic DNS services. You can create a CNAME record to another host and whatever subdomain.domain.com you choose here will go to whatever IP address the CNAMEd host has.

Type: NS – Point subdomain.domain.com to another NAMESERVER. If you choose this option, then whatever subdomain.domain.com 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 subdomain.domain.com is located at. If the host you point an NS record to is not configured to answer for the subdomain.domain.com that you are using in FreeDNS then the subdomain.domain.com 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 https://www.spfwizard.net/ for more details.

Type: LOC – A means for Expressing Location Information in the Domain Name System.

RFC1876 has the complete explanation.

To find your latitude/longitude location, you may find Map-O-Rama of 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 has 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._tcp.mc
Domain: yourdomain.com
Destination: 0 0 25676 dns.yourdomain.com

Type: SRV
Subdomain: _jabber._tcp
Domain: yourdomain.com
Destination: 10 0 5269 jabber.yourdomain.com

Type: SRV
Subdomain: _jabber._tcp
Domain: yourdomain.com
Destination: 20 0 5269 xmpp-server1.l.google.com

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=127.0.0.2 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 available 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 freedns.afraid.org’s 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 ns1.afraid.org” press enter
Default Server:  ns1.afraid.org
Addresses:  2607:f0d0:1102:d5::2
50.23.197.94

then phporacle.mooo.com.afraid.org.fuf.me:8083  = “yourhostname.afraid.org” press enter
*** ns1.afraid.org can’t find phporacle.mooo.com.afraid.org.fuf.me:8083: 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.

tempr.email = Fake email for email askers on inet :
[email protected] https://tempr.email/inbox.htm

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 - http://www.icanhazip.com > 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="http://www.canyouseeme.org/" target="_blank">http://www.canyouseeme.org/</a><br>
<br>
<a href="https://www.whatismyip.com/" target="_blank">https://www.whatismyip.com/</a><br>
<br>
<a href="http://www.portchecktool.com/" target="_blank">http://www.portchecktool.com/</a><br>
<br>
<a href="http://www.yougetsignal.com/tools/open-ports/" 
      target="_blank">http://www.yougetsignal.com/tools/open-ports/</a>&nbsp;
<br>
<a href="https://bestvpn.org/whats-my-ip/" target="_blank"><br>
https://bestvpn.org/whats-my-ip/</a><br>
<br>
<a href="https://www.dynu.com/networktools/portcheck" target="_blank">
     https://www.dynu.com/networktools/portcheck</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@freedns.afraid.org/nic
/update?hostname=phporacle.mooo.com&amp;myip=<?=$wip_web_servera?>" 
target="_blank">http://YOURDDNSUSRNAME:YOURDDNSPSW@freedns.afraid.org/nic
/update?hostname=phporacle.mooo.com&amp;myip=<?=$wip_web_servera?></a>

 

 

9. Main development, test and production menu (& 3 sites) – PHP 7 RC5, Oracle 11g on Windows 10 all 64 bit

HOME – Download Win10 64 bit AMP config and three sites php scripts.

14.8.2016 I changed a lot, see my article 10. This article 9 can be used only for explanations but everything is in code in 1_3sites_mnu_crud_ver1.rar.

22.11.2015 code refactored – i uploaded sites code version 3, (SINGLETON UTILS-HELPERS CLASS, config_site.php…).

Scripts config_site.php, utls.php, utls_glbsetpg.php and lsweb.php explain most important changes. I hope this is final code skeleton, ver4 will be bug fixes and cosmetic updates. (In ver3 I tested only most important lsweb.php but testing others is good exercise – and it shows how difficult this job is).

Statements (functions) flow article (not yet uploaded) should link together all I wanted to say.

Every (vitual) host – I have them 3: dev, test, production – should have in its web site doc root script which tells web server where are resources which are outside doc tree (global fns, settings, css, imgs)

(Problem with resources outside web doc tree is that we need file_get_contents() fn which is disabled by some inet providers. But if you want own SOAP server eg for direct b2b copying einvoice xml – then every your user should have own web site (bad news for some not needed service brokers – posrednici).)

Most important are:
1. “path science” – unexplained enough in learning materials I met (for SPA script very different than for URL called script).
2. Statements (functions) flow (to understand SW & for debugging) – I shall soon write article 10 or 11 (?) about this (SOAP examples for copying xml across inet will also be soon).

I can not understand SPA & frameworks without above two explained. To me seems that framework authors intentionally do not explain important things about their scripts coding (there is to much commercial interests in free SW) – so we have 100 frameworks instead 5-6.

I am shure that Utils class should be, settings should be in global_config.php both outside web doc tree. Local settings in doc tree should owerwrite global.

Eg my : J:\awww\apl\dev1\config_site.php contais:

 < ?php
 // development site (virtual host on home PC) :
 // J:\awww\apl\dev1\config_site.php
//$_SERVER['DOCUMENT_ROOT'] = J:\awww\apl\dev1\
 // yii2 advanced site (virtual host on home PC) :
 // J:\awww\apl\dev1\zfw\yii205\frontend\web\config_site.php
 // J:\awww\apl\dev1\zfw\yii205\aplmy\backend\web\config_site.php
 // realpath
 use utlmoj\utlmoj as utl;
 $ds = DIRECTORY_SEPARATOR;
 /**
 * CONVENTION: sitedocroot/../zinc = eg J:/awww/apl/zinc
 * site does not know where (outside site doc tree) are global resources
 * (util scripts, css, img for all sites), so we must assign
 * 1. GLOBAL RESOURCES (INCLUDES) FOLDER :
 */
 $gloresdir = realpath($_SERVER['DOCUMENT_ROOT'].'/../zinc'); // 1.
 require_once($gloresdir.'/utls.php'); // 2. util (helper) scripts
 $utl=utl::uget(); // 3. get or create helper fns object (singleton)
 require_once($gloresdir.'/utls_glbsetpg.php'); // 4. global page properties
 /**
 * IN APPL (IN SPA) IF IT NEEDS C R U D :
 * 2. g l o b a l C R U D :
 * $dbi = 'sqlite'; $dsn = 'cars_makes_names_savings.sqlite';
 * require_once($gloresdir.$ds.'db_conn.php');
 * db_conn.php does:
 * 1. require_once($gloresdir.'/klase/dbi.php');
 * 2. require_once($gloresdir.'/tbl/zodiac_mdl.php);
 * CONVENTION for M D L of concrete tbl :
 * require_once($gloresdir.'/tbl/'
 * .str_replace('.php','_mdl.php', basename($curpgpath)));
 * 3. template crud script :
 * require_once($gloresdir.$ds.'crud.php');
 */
 // ******************************************
 //exit();
 ?>

I am not shure if Utils class should have static or non static or both methods & properties (because you need many years PHP programming experience to be shure). Properties of this two working ways are not clear to me and unexplained enough in my learning sources.

Pitty that somebody – PHP expert – which I am not – does not explain this somewhere.

2.Sept.2015 – site_ver2.rar – improved code for all scripts, eg for lsweb.php and added some dir icons and better presented/explained site dir structure (see awww_DIR_NOT_VISIBLE_TO_ME.txt).

This article is enough for (advanced) beginning PHP programming Oracle and SQLite CRUD. 
Articles 1 to 8 are supplementary info.

This article unites my posts 3. Zwamp menu and 5. CRUD simple table (example 1) with refactored code for 5. CRUD and my (I hope) final site directories structure.

Most important examples in this article (others are in site_verx.rar):

Example Šifrarnik – is not finished, but shows much. Model is table (id, few_columns)

Example web server directories listing – dir items listing can be extended with row filters, sorts, downloads… but so as it is is very useful for web development.
Model (input data) is DirectoryIterator().
I find lsweb.php very useful for web development:
J:\awww\apl\dev1\zinc\utl\ls.php          http://dev1:8083/zinc/utl/ls.php  (or with ?dir=J:\awww\apl\dev1)
J:\awww\apl\dev1\zinc\utl\lsweb.php

Code for article 3. Zwamp menu is also contained in  site_verx.rar – it is to complicated for real life sites (except if you like something like)  but is excellent for learning PHP.

 

Oracle example 1

Model (input data) is simple table (šifrarnik) (id, few_columns), but more than 50% programming techniques can be learned on this and next example.


J:\awww\apl\dev1\zinstalac\ddl\DDL_selfjoin.sql:
-- winkey+X -> Comm.prompt admin
C:
cd C:\oraclexe\app\oracle\product\11.2.0\server\bin
sqlplus hr/hr
sho user
CREATE TABLE ZODIAC (
  ID          NUMBER(10) NOT NULL,
  SIGN        VARCHAR2(11),
  SYMBOL      VARCHAR2(13),
  PLANET      VARCHAR2(7),
  ELEMENT     VARCHAR2(5),
  START_MONTH INTEGER,
  START_DAY   INTEGER,
  END_MONTH   INTEGER,
  END_DAY     INTEGER,
  PRIMARY KEY(ID)
);

CREATE SEQUENCE ZODIAC_SEQ;
CREATE or replace TRIGGER ZODIAC_PREINS_TRIG 
BEFORE INSERT ON ZODIAC 
FOR EACH ROW
BEGIN
  -- PRIOR TO 11G :
  SELECT ZODIAC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL;
  -- 11G :
  --:NEW.MSG_ID := ZODIAC_SEQ.NEXTVAL;
END;
/
sho err

DML :
INSERT INTO zodiac VALUES (1,'Aries','Ram','Mars','fire',3,21,4,19);
INSERT INTO zodiac VALUES (2,'Taurus','Bull','Venus','earth',4,20,5,20);
INSERT INTO zodiac VALUES (3,'Gemini','Twins','Mercury','air',5,21,6,21);
INSERT INTO zodiac VALUES (4,'Cancer','Crab','Moon','water',6,22,7,22);
INSERT INTO zodiac VALUES (5,'Leo','Lion','Sun','fire',7,23,8,22);
INSERT INTO zodiac VALUES (6,'Virgo','Virgin','Mercury','earth',8,23,9,22);
INSERT INTO zodiac VALUES (7,'Libra','Scales','Venus','air',9,23,10,23);
INSERT INTO zodiac VALUES (8,'Scorpio','Scorpion','Mars','water',10,24,11,21);
INSERT INTO zodiac VALUES (9,'Sagittarius','Archer','Jupiter','fire',11,22,12,21);
INSERT INTO zodiac VALUES (10,'Capricorn','Goat','Saturn','earth',12,22,1,19);
INSERT INTO zodiac VALUES (11,'Aquarius','Water Carrier','Uranus','air',1,20,2,18);
INSERT INTO zodiac VALUES (12,'Pisces','Fishes','Neptune','water',2,19,3,20);

Scripts directory structure (SPA, MVC domain style)

SPA means scripts are included, only exceptionally URL called. So scripts see all $ variables as own.

In SPA is not posible using relative page adresses because path relative to included script is not relative to includer (SPA) script  – adresses syntax explained here must be used !! To learn dirs science is one of most difficult PHP beginning parts, and allmost NOT EVEN MENTIONED in PHP learning materials.

MVC domain style means Scripts directory structure is “one form (application) one dir (& its subdeirs if needed)”. MVC is basically old structured programming:

  1. initialize (bootstrap, config),
  2. manage (ctr),
  3. input (model),
  4. output (view).

It is interesting that no one MVC promotor mentions this simple truth. Names are most important, but working means not (only) inventing new names but understand+explain.

DDLs are in J:\awww\apl\dev1\zinstalac\ddl\,  eg above  DDL_selfjoin.sql contain also selfjoin DDL & for SQLite.

Global config scripts (.php, .css, .js…most important of all types !) are in J:\awww\apl\dev1\zinc\,  eg  utls.php.

Below zinc are dirs: utl (helpers), slike (img), js…

Three sites (Apache virtual hosts on home PC):

Development URL is http://dev1:8083/ is Windows dir J:\awww\apl\dev1.

Production URL is http://pro1:8083/  is Windows dir J:\awww\apl\pro1.

Simmilar are both test site adresses.

 

After huderts Oracle Forms 6i created from scratch (from existing form ctrl+c,v) in more then 15 years it seems to me, whatever they say :), for PHP & Oracle should be :

CONVENTIONS FOR BETTER SCRIPTS VISIBILITY

  1. No camelcase becouse name higher_lower is (to me) better visible then camelcase higherLower
  2. Scripts sufixes :
    1. controller scripts have no sufix
    2. other scripts :
      1. model scripts: _mdl, _val (validation scripts)
      2. view scripts: _frm, _tbl, _rep
  3. ctr / bootstrap scripts are NOT named index.php, but are named simmilar to DB table name which they (CRUD) manage.Beside script visibility, this enables us to have more/all small tables crud (forms) scripts in one dir.To many dirs is not practical and old principle “one form (application) one dir (& its subdeirs if needed)” is newest fashion (2015 year).
  4. GLOBAL configuration scripts are in $CNFGD=J:\awww\apl\dev1\zinc, eg $CNFGD.$DS.utls.phputls.php (with help of config not static class & namespace) defines PHP $  (adress) variables for all included scripts (SPA !!) (no constants except pi and simmilar). Conf. vars must be defined as $ vars in utls.php and not as concatenation of dirs in all index.php scripts, becouse :
    IF DIR TREE CHANGES -> WE CHANGE ONLY ONE PLACE: utls.php
  5. Some strange names are better for search or for name conflicts (eg zinc instead of includes, chcons instead configclass, this example zodiac…)

 

Example 2: Web server directories listing programs

Model (input data) is DirectoryIterator() dir items listing.

I find them very useful for web development:
J:\awww\apl\dev1\zinc\utl\ls.php          http://dev1:8083/zinc/utl/ls.php  (or with ?dir=J:\awww\apl\dev1)
J:\awww\apl\dev1\zinc\utl\lsweb.php

 Conclusion

I did not see advantages in my testings compared with programming techniques I explained in this article (and in other before):

  1. AngularJS 1.4.3 CRUD with Oracle 11g
  2. Yii 2.0.6 with PHP 7 beta 3
  3. FatFree PHP fw

But frameworks above:

  1. no Oracle DBI example for normal people given
  2. It seems to me they are unfinished – always in development (uncompatible new versions), always new fws appear.
  3. slower ( min ~ 150 kB code with uncertain future included),
  4. more complicated – another (more) programming languages
  5. They do not even mention reporting (php reports from Eustáquio Rangel or similar) or tab key -> enter key which I made with few lines Javascript code (see site_ver1.rar J:\awww\apl\dev1\zinc\key_pressed.js).
  6. I doubt if they are more productive – learn time for programming techniques I explained in this article is ~ as for them  (lot of time 🙂 )
  7. to many incompatibilities uncertain future (yii2, ng 2),

Until authors of fw sw convince us on CRUD examples I give in this article + master-detail example I can not believe their to simple / not clear CRUD examples.


~~~utls.php $test=1 ~~~end script J:\awww\apl\dev1\index.php   source   phpinfo~~~

 

1. Install Apache, PHP, Oracle DB 11g XE & 11g, Oracle Forms 6i and 12c & Reports on Win 10 (all 64bit)

HOME   Downloads are now:  https://github.com/slavkoss/fwphp

26.oct.2019 I use 64 bit XAMPP: PHP 7.3.7 AND APACHE 2.4.38. on Windows 10 64 bit. PDO: mysql, oci, sqlite ARE WORKING.Oracle db 11gXE (no more E. Rangel pdooci – pdo sintax on oci8 program layer).

I tried 4-5 WAMP server SW WAMP and ZWAMP are ok but XAMPP unzip is  simplest – almost 1 click . WAMP has problem with composer installations from Windows command line. Next shows more details (I do not use ZWAMP recently) :

  1. Unzip zwamp-x64-2.2.1-full.zip to J:\zwamp64
  2. Rename old J:\zwamp64\vdrive\.sys\Apache2 dir to Apache2_2_4_16
  3. Download Apache : http://www.apachelounge.com
    Create dir J:\zwamp64\vdrive\.sys\Apache2.
    Unzip httpd-2.4.20-win64-VC14.zip – it’s Apache24 folder content to :
    ServerRoot J:/zwamp64/vdrive/.sys/Apache2 (or c:/Apache24 = ServerRoot) in httpd.conf
    Default folder for your your webpages is DocumentRoot
    DocumentRoot J:/zwamp64/vdrive/.sys/Apache2/htdocs
    Directories
    ScriptAlias – also when you use extra folder config file(s) change to your location there
  4. No changes in J:\zwamp64\vdrive\.sys\Apache2_2_4_16\conf\extra
  5. changes in J:\zwamp64\vdrive\.sys\Apache2\conf :
    copy here own httpd.conf ver 2.4.16 to conf dir (rename original before copying)
    copy here own vhosts.conf ver 2.4.16 to conf dir
  6. J:\zwamp64\vdrive\.sys\Apache2\conf\httpd.conf :
    LoadModule php7_module /.sys/php/php7apache2_4.dll
    AddType application/x-httpd-php .php# without this OCI8 and PDO MySQL and PDO sqlite are not visible in inet browser
    are visible in php CLI
    PHPIniDir /.sys/php
  7. Download PHP:  http://windows.php.net/download/
    php-7.0.8-Win32-VC14-x64.zip
     same unzip as apache zip above.
  8. Downloadnewest oci8-2.1.1 Extension for php 7.0.8 64 bit on Windows 10 64 bit – april 2016 (older does not work) :
    OCI8 is also for E.Rangels PDOOCI.
    https://pecl.php.net/package/oci8/2.1.1/windows  – Windows dll-s
    https://pecl.php.net/package/oci8   – for Linux
    released by [email protected]
    https://blogs.oracle.com/opal/entry/php_7_oci8_2_1
    php_oci8-2.1.1-7.0-ts-vc14-x64_Jones_pecl.php.net.zip
    Unzip it’s dll-s to: 
    J:\zwamp64\vdrive\.sys\php\ext
    Christopher Jones’s oci8-2.1.1 for php 7 :
    dir J:\zwamp64\vdrive\.sys\php\ext\php_oci*.*
    18.04.2016.  05:20   155.136 php_oci8.dll
    18.04.2016.  05:20   790.528 php_oci8.pdb – WHAT IS THIS ?
    18.04.2016.  05:20   157.184 php_oci8_11g.dll
    18.04.2016.  05:20   790.528 php_oci8_11g.pdb
    18.04.2016.  05:20   158.208 php_oci8_12c.dll
    18.04.2016.  05:20   790.528 php_oci8_12c.pdb
    7 File(s)      2.997.248 bytes
  9. J:\zwamp64\vdrive\.sys\php\php.ini
  10. 2click J:\zwamp64\zwamp.exe -> right click house icon -> restart
    -> started Apache and MySQL. If not both started very useful is :
    J:\zwamp64\vdrive\.sys\Apache2\bin>httpd.exe
    – this report errors, same as :
    php -v
    PHP 7.0.8 (cli) (built: Jun 21 2016 15:15:15) ( ZTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    or
    php -r “var_dump(function_exists(‘oci_connect’));”
    or
    C:\WINDOWS\system32>php -r “if (! $dbc = oci_pconnect(‘hr’, ‘hr’, ‘ora7’, ‘UTF8’)) echo ‘***** 1. UNSUCCESSFULL db connect *****’; else {echo \”\n\”; echo ‘~~~~~~~~~~~  PARSE-BIND-EXECUTE-FETCH ~~~~~~~~~~’; echo \”\n\”; echo ‘SUCCESSFULL db connect’; echo \”\n\”;  $dml=’SELECT first_name, phone_number FROM (SELECT first_name, phone_number FROM employees ORDER BY first_name) where rownum < 3′; echo $dml; echo \”\n\”; $parse_stid = oci_parse($dbc, $dml);  if (!$parse_stid) {   $m = oci_error($conn);    echo ‘skripta: ‘ . __FILE__ ;   echo’ says neuspio oci_parse : ‘ ;   echo $m[‘message’]; }   $exec_ret =  oci_execute($parse_stid);       echo ‘oci_execute returned: ‘;     print_r($exec_ret);        echo \”\n\”; echo ‘oci_fetch_array returned: ‘;  $row = oci_fetch_array($parse_stid, OCI_ASSOC + OCI_RETURN_NULLS); print_r($row); }”WHICH DISPLAYS:~~~~~~~~~~~  PARSE-BIND-EXECUTE-FETCH ~~~~~~~~~~
    SUCCESSFULL db connect
    SELECT first_name, phone_number FROM (SELECT first_name, phone_number FROM employees ORDER BY first_name) where rownum < 3
    oci_execute returned: 1
    oci_fetch_array returned: Array
    (
    [FIRST_NAME] => Adam
    [PHONE_NUMBER] => 650.123.2234
    )
  11. Not needed if we use ZWAMP :
    Install Apache as a service:
    httpd.exe -k install   httpd.exe -k restart, or stop
    ApacheMonitor: (not needed if we use ZWAMP):
    Double click ApacheMonitor.exe, or put it in your Startup folder.

 

 

28.11.2015 INSTALLATION APACHE 2.4.16 (Win64)  & PHP 7.0.0 RC5 MSVC14 (Visual C++ 2015) x64 ON J:\zwamp\vdrive\.sys\Apache2 (& …\php) OR ON C DISK

Install as a service (not needed if using XAMPP or ZWAMP or WAMP):
httpd.exe -k install
httpd.exe -k  restart

httpd.exe -k stop  
ApacheMonitor: Double click ApacheMonitor.exe, or put it in your Startup folder.

Use PGP Signature and/or the SHA Checksums to verify the integrity.
C:\gnuwin32\bin\sha1sum.exe -help
sha1sum.exe -b J:\0downl\1_instalirano\Apache_httpd-2.4.16-win64-VC14.zip :
d917094cf13ecea83938aa58058ea7c5c6ef2756
Checksums created with GPGHash by SmartJuwel
Creation date: 22.07.2015 with GnuPG Version: 1.4.18
SHA1-Checksum for: httpd-2.4.16-win64-VC14.zip:
D917094CF13ECEA83938AA58058EA7C5C6EF2756
or SHA224-Checksum or SHA256-Checksum or SHA384-Checksum

php http://windows.php.net/qa/ For Apache on Windows: Thread Safe

I did not used Instant Client :
Oracle Database drivers for popular languages and environments including Node.js, Python and PHP can use Instant Client to connect to local or remote DBs.
https://community.oracle.com/thread/1051752 :
1. Download 64 or 32-bit Oracle Instant Client – there is no MSVC14 build 6.8.2015
2. put it somewhere useful (I put it under my php directory)
3. Add it to your system’s PATH. (A quick & dirty fix on Windows is to copy
all of the *.dll files   from the 11g InstantClient package* into same dir
as your webserver’s executable (e.g. httpd.exe).)
http://www.oracle.com/technetwork/database/features/instant-client/index-100365.html
4. Edit your php.ini and uncomment extension=php_oci8_11g.dll

I did not 1. to 4. above !

Stories on WEB that excellent (but never finished and abandoned) old 32 bit F6i, R6i SW and new Windows do not work together are not true. See also – they managed same as I (good site, could give more details):
Installing Oracle Developer (forms & reports 6i) on Windows 7 64bit
and
Oracle Developer 6i & Oracle database 11g R2 (11.2.0.1.0)
Great question to Oracle who says “we do not leave our customers who still use F6i & R6i” – but F6i & R6i can not even be downloaded from Oracle:
Why 32 bit F6i & R6i can not be patched to be certificated on 64 bit 11g and 64 bit Windows ? Oracle Power Objects (SW simmilar to F6i & R6i ) is also abandoned SW.
Today is modern to make new SW, worse than old (nobody begins new project with F11 & R11 – they are rather applications than development SW) and forget poor bastards who bought abandoned SW. So they cut their expenses (and our lifes). Simmilar stories are Microsoft ASP-VS2008-Silverlight, Google AngularJS 1.x – 2.x, over 100 development SW around…
Incompetent managers and trade departments cut our lifes, but they should know that life is not child joke.

APACHE – USE THREAD SAFE (TS) VERSIONS OF PHP BINARIES FOR WINDOWS
MULTITHREAD CAPABLE BINARIES BUILDS – INTERACTION WITH A MULTITHREADED SAPI AND PHP LOADED AS A MODULE INTO A WEB SERVER.

Use Apache builds provided by Apache Lounge – PHP official site use their binaries to build Apache SAPIs.

VC9 builds require you to have the Visual C++ Redistributable for Visual Studio 2008 SP1 x86 or x64 installed.
VC11 builds require to have the Visual C++ Redistributable for Visual Studio 2012  x86 or x64 installed. and so on

PECL FOR WINDOWS:PECL extensions for Windows is being worked on. Windows DLL can be downloaded right from thePECL website.
PECL extension release and snapshot build directories are browsable directly.

Not needed for 64 bit Apache, PHP, 11XE all three on home PC..
Download from http://www.oracle.com/technetwork/topics/winx64soft-089540.html
instantclient-basic-windows.x64-12.1.0.1.0.zip (64,939,911 bytes) (cksum – 3658834848)
extract to:  C:\Windows\SysWOW64\instantclient_12_1
and set it on Win PATH variable + H:\Apache24\bin,
(NO:    THERE ARE MORE PHP INSTALLATIONS  (only 1 Apache):    + H:\php)

C:\Apache24\bin>echo %SystemRoot%
outputs: C:\Windows

C:\Apache24\bin>path

extension=php_oci8_11g.dll (remove the “;” from the start of the line)

Restart Apache (XAMPP or WAMP server)

Open  file to see database name as
C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN\tnsnames.ora
// D:\app\Farhan\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora

LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.168.1.2)
)
)

Service name is “orcl.168.1.2”,  my is: XE :

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = sspc)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  ) 
ora7 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = sspc)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  ) 
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

See  https://github.com/slavkoss/fwphp/blob/master/fwphp/glomodul/z_examples/index.php
for  httpd.conf, vhosts.conf, C:\Windows\System32\drivers\etc\hosts, php.ini