Monday, 22 October 2018
I moved to AMD Platform part 1
Few years ago I decided to move to more powerful platforms at home to serve me longer and easily can be upgraded. Reason was that until that time I only used to use Intel motherboards. Well, before that I had IBM motherboards until IBM stopped to build those hardware and so I switched to Intel motherboards.
Actually my story goes back to Z80 and 8080 and these things. From that time there were people who spontaneously had selected Motorola 6800 instead of 8080. IBM took 4004 and then next generations of Intel's and developed DOS instead of CP/M. IBM made these two the winners but itself gradually left the arena.
When I noticed Intel would not build any motherboards of its own for non-server computers, still I could not use AMD. I was not familiar with their CPU's.
Then I wondered which socket of Intel was more promising than the others. Intel vastly was promoting socket 1366, but suddenly announced that there was an error in creating that socket and no further development would be possible
At the same time Intel marketed socket 2011. I found the idea of having 2011 pins on a microprocessor very stable and promising and also very exciting. I could remember there was a time, an ancient time, that we called a TTL with 24 pins a millipede.
As Intel did not build any motherboard for this socket, after some search I decided to move to ASUS. Well, Gigabyte and MSI and others are also good enough, but ASUS has some reputation I liked to test. When I bought my (Intel chipset) X79 motherboard from ASUS, immediately I noticed that its accompanying CD was outdated in terms of Windows.
True, they had all updates on the motherboard site. But, as I also sent an email to them, it was better if instead of that or on the side of that they put an updated ISO image. Then you can burn it and use it as the motherboard accompanying DVD. That could make me happy; having the latest ISO
It is still advisable if they do that for their new boards with so many fuss that they have about their Republic of Gamers, etc., etc. They can put also an image of the sticker that you need to put on the DVD such that you download and print it make a DVD similar to what was with the motherboard.
Immediately after I finished my build, Intel announced that they would discontinue socket 2011 and marketed a 2011 v3 instead, not compatible with 2011. So my new build fell in the blind end.
I, like many other IT power users/enthusiasts who had chosen socket 2011, continued using my build. The important point was the front side speed; that was almost similar on all sockets. For example, my G.Skill 2400MHz memory cards worked on 1333MHz, not even nominal 1600 MHz of X79.
From 2016, front side speed witnessed a new upgrade. DDR4 memories with new specs replaced DDR3 and we know that they create a new realm not compatible with DDR3 memories. They can push fsb further. Now they talk of 5000 MHz and above for memory (though most of the people who buy those high end memories cannot tune them and memories roll back to 2400 and so). Chipsets need to run faster fsb and these chipsets are still working around 2400-2666 MHz.
With these in mind, and considering that Intel does not have a clear roadmap to be economically feasible for average users (who pays £1800 for a CPU and after a year found it obsolete), I suddenly decided to move to AMD platform. I focused on new low price low power consuming Rayzen platform completely unlocked for overclocking.
I found two platform X370 and X470 accommodating these CPU's.
First I bought an ASUS X370 with a Rayzen 1600 CPU. Unfortunately, with my 512 GB SSD the system randomly would go to the hibernate state and would not wake up, with freezing shut down and reset button. I had to turn off the PSU externally and turn it on back to reboot the system.
Before it becomes late I returned them to seller and refunded my money (I paid £9 for shipping via Parcel Force).
ASUS X370 was flimsy and cheapie and could not be compared with my ASUS Sabertooth I had
X470 boards have a better promise for future upgrades of Rayzen. So I ordered one of them and a better specs Rayzen 2600. I also got a WD Green M2 240GB SSD.
Actually my story goes back to Z80 and 8080 and these things. From that time there were people who spontaneously had selected Motorola 6800 instead of 8080. IBM took 4004 and then next generations of Intel's and developed DOS instead of CP/M. IBM made these two the winners but itself gradually left the arena.
When I noticed Intel would not build any motherboards of its own for non-server computers, still I could not use AMD. I was not familiar with their CPU's.
Then I wondered which socket of Intel was more promising than the others. Intel vastly was promoting socket 1366, but suddenly announced that there was an error in creating that socket and no further development would be possible
At the same time Intel marketed socket 2011. I found the idea of having 2011 pins on a microprocessor very stable and promising and also very exciting. I could remember there was a time, an ancient time, that we called a TTL with 24 pins a millipede.
As Intel did not build any motherboard for this socket, after some search I decided to move to ASUS. Well, Gigabyte and MSI and others are also good enough, but ASUS has some reputation I liked to test. When I bought my (Intel chipset) X79 motherboard from ASUS, immediately I noticed that its accompanying CD was outdated in terms of Windows.
True, they had all updates on the motherboard site. But, as I also sent an email to them, it was better if instead of that or on the side of that they put an updated ISO image. Then you can burn it and use it as the motherboard accompanying DVD. That could make me happy; having the latest ISO
It is still advisable if they do that for their new boards with so many fuss that they have about their Republic of Gamers, etc., etc. They can put also an image of the sticker that you need to put on the DVD such that you download and print it make a DVD similar to what was with the motherboard.
Immediately after I finished my build, Intel announced that they would discontinue socket 2011 and marketed a 2011 v3 instead, not compatible with 2011. So my new build fell in the blind end.
I, like many other IT power users/enthusiasts who had chosen socket 2011, continued using my build. The important point was the front side speed; that was almost similar on all sockets. For example, my G.Skill 2400MHz memory cards worked on 1333MHz, not even nominal 1600 MHz of X79.
From 2016, front side speed witnessed a new upgrade. DDR4 memories with new specs replaced DDR3 and we know that they create a new realm not compatible with DDR3 memories. They can push fsb further. Now they talk of 5000 MHz and above for memory (though most of the people who buy those high end memories cannot tune them and memories roll back to 2400 and so). Chipsets need to run faster fsb and these chipsets are still working around 2400-2666 MHz.
With these in mind, and considering that Intel does not have a clear roadmap to be economically feasible for average users (who pays £1800 for a CPU and after a year found it obsolete), I suddenly decided to move to AMD platform. I focused on new low price low power consuming Rayzen platform completely unlocked for overclocking.
I found two platform X370 and X470 accommodating these CPU's.
First I bought an ASUS X370 with a Rayzen 1600 CPU. Unfortunately, with my 512 GB SSD the system randomly would go to the hibernate state and would not wake up, with freezing shut down and reset button. I had to turn off the PSU externally and turn it on back to reboot the system.
Before it becomes late I returned them to seller and refunded my money (I paid £9 for shipping via Parcel Force).
ASUS X370 was flimsy and cheapie and could not be compared with my ASUS Sabertooth I had
X470 boards have a better promise for future upgrades of Rayzen. So I ordered one of them and a better specs Rayzen 2600. I also got a WD Green M2 240GB SSD.
Friday, 6 January 2017
NetBeans Gets a New Life—or Does It?
(For the latest PDF files Merger Software please have a look at the top of the left margin, inside the red box.)
From the time that Sun Microsystem created Java Café and Java One for developing Java Applications and then acquired NetBeans first as parallel with those and later as consolidating and replacing them until it included further features to develop Fortran and C and C++ and other languages I was an avid user of this easy to use IDE. NetBeans evolved and evolved and for the goals that it had it was much better than Visual Studio, for instance being Intelligent Sense not only in showing the code but also showing the documentation with hyper texting to move around the documents.
NetBeans was acquired by Oracle at the time that Sun Microsystem was acquired by Oracle. There were speculations that support for the NetBeans will be stopped and the IDE will be scrapped. Some people hastily switched to JDeveloper and Eclipse but most Java programmers kept the hope and Oracle also showed sensibility in continuing funding the NetBeans IDE as its own product and NetBeans improved to its present 8.2 Version.
From the time that Sun Microsystem created Java Café and Java One for developing Java Applications and then acquired NetBeans first as parallel with those and later as consolidating and replacing them until it included further features to develop Fortran and C and C++ and other languages I was an avid user of this easy to use IDE. NetBeans evolved and evolved and for the goals that it had it was much better than Visual Studio, for instance being Intelligent Sense not only in showing the code but also showing the documentation with hyper texting to move around the documents.
NetBeans was acquired by Oracle at the time that Sun Microsystem was acquired by Oracle. There were speculations that support for the NetBeans will be stopped and the IDE will be scrapped. Some people hastily switched to JDeveloper and Eclipse but most Java programmers kept the hope and Oracle also showed sensibility in continuing funding the NetBeans IDE as its own product and NetBeans improved to its present 8.2 Version.
In November/December 2016 digital edition of Java Magazine editor gives some news that NetBeans has been moved from its Oracle home to Apache Foundation. I did not find this depressing as some might speculate. I know Apache a better place for such thing. Hence, I leave the whole story to the powerful pen of him.
NetBeans
Gets a New Life—or Does It?
The transition
from Oracle to the Apache Software Foundation marks the beginning of an
uncertain new era for the Java IDE.
At
JavaOne this year, the NetBeans community announced that the project was moving
from its long-time home at Oracle to the Apache Software Foundation (ASF). In a
history that dates back some 20 years, this will be NetBeans’ fifth new home, showing the
product’s remarkable power of endurance. An important
question is whether working under the aegis of the ASF will bring NetBeans new life
and new aficionados, or whether it signals the final chapter of a storied
lifeline.
As
many readers know, NetBeans is one of the four principal Java IDEs. The others
are the open source Eclipse from the Eclipse Foundation, IntelliJ IDEA from
JetBrains (consisting of an open source version and a higher-end closed source version),
and JDeveloper (a free, closed source IDE from Oracle). What few readers might
know is that NetBeans was the first of
these products— beating Borland’s JBuilder by a year. (JDeveloper,
which was based on JBuilder, was next, followed years later by Eclipse and
IntelliJ.)
NetBeans
became a popular Java IDE because of several features, most especially the
lightness of its use. While competing products had a long setup cycle for new
projects and a comparatively “heavy” feel, NetBeans was great for coding on the fly and always felt
light and responsive. While it lacked some of its competitors’ code management features, it was
the first to offer a built-in execution profiler and, if I recall correctly, the
only one to include a small-scale J2EE server, OC4J, to quickly test web
projects locally. It was also
the first IDE to offer a top-quality Swing based GUI-development
tool, called Matisse.
That’s
a lot of quality to come from what was originally a student project at Charles University
in Prague. (The core development team for NetBeans has remained primarily based
in Prague, although marketing and other functions have been based at various
times in the United States and elsewhere.)
Eventually,
NetBeans was acquired by Sun, where it was open sourced. And through the 2011
acquisition of Sun, NetBeans became part of Oracle. At that point, I was quite
surprised to read of Oracle’s commitment to continue developing NetBeans. After
all, the company already offered
JDeveloper for free and sponsored Oracle-specific packages
and extensions for Eclipse. But actually, Oracle did more than just commit to
supporting the platform’s development and promotion; it also began using portions
of NetBeans in its own products,
specifically JDeveloper and VisualVM, and eventually a variety of
other development tools. For this reason, even with the move to the ASF,
NetBeans has secured a commitment from Oracle to underwrite its development for
two more releases: the upcoming 8.x version and the 9.0 release.
If
you were to view NetBeans purely as a programming environment, its fate after
Oracle’s commitment expires would be most uncertain. Although many projects
under the ASF aegis have
flourished (Maven, Hadoop, Spark, and others), more than a few
projects have migrated to the ASF only to die there. (See the Apache Attic for
a list of defunct projects.)
However, over the years, NetBeans evolved from an IDE into a
platform consisting of large-scale components that can be assembled in different ways
to form
desktop applications. This architecture uses a rather different approach than
Eclipse’s OSGi-based system of modules and bundles. (This page compares the
Eclipse and NetBeans architectures.)
Numerous companies— including Oracle—have exploited the benefits of NetBeans’
architecture
and built applications whose runtime includes the platform components.
These
companies have an interest in continuing the forward direction of NetBeans, and
some have committed to work on NetBeans in its new home. I expect—but obviously I don’t
know—that they will contribute either directly or by engaging NetBeans’
current cohort of developers to continue developing the platform. In addition, the
community of users, many of whom are truly dedicated to NetBeans, might well
step up and begin
contributing. It’s difficult to project the extent of
participation because very few projects with so large a user base have been
migrated to the ASF, and so there is little history to provide guidance.
For
users of NetBeans, though, nothing need be done for now or in the near term. The
9.0 release is scheduled for August 2017 and will cover Java 9. By that time,
we will surely have more insight into the transition of NetBeans, the level of
activity, and the level of support from both commercial users and the developer
community.
Andrew
Binstock, Editor in Chief javamag_us@oracle.com
@platypusguy
November/December 2016 digital edition of Java Magazine
Java:
Number One Development Platform:
13
Billion Devices Run Java
ATMs,
Smartcards, POS Terminals, Blu-ray Players, Set Top Boxes, Multifunction Printers,
PCs, Servers, Routers, Switches, Parking Meters, Smart Meters, Lottery Systems,
Airplane Systems, IoT Gateways, Programmable Logic Controllers, Optical
Sensors, Wireless M2M Modules, Access Control Systems, Medical Devices, Building
Controls, Automobiles…
Thursday, 8 October 2015
Web Hosting at Your Home : PHP and Port Forwarding Conflicts
(For the latest PDF files Merger Software please have a look at the top of the left margin, inside the red box.)
From the time that I wrote Web Hosting at Your Home (Revisited) Apache httpd server has seen many revisions. Also people might like to have PHP installed on their web server to be able to load PHP pages.
Assume your web serving computer is clean of any Apache httpd sever of previous versions such as Apache httpd server 2.2. The latest version for Windows operating system is not in the form of an exe file to be run by double clicking and automated install; it even is not compiled for Windows. It is a source file in C programming language that needs compilation.
If you know how to use MinGw or NetBeans IDE or Visual Studio then you need to compile the source and then follow other steps, you even can build an automated EXE file for execution.
The good news is that some people, Apache Lounge, already have done the compilation but still no executable GUI for installation exists. You do not need this far. You can get the compiled server, most likely a zip file, from those people and install it in your comfort.
Create an Apache server folder as near as possible to the root; that is, C:\; for instance, C:\ApacheWeb.
Then download the compiled folder. Mine is httpd-2.4.16-x86-vc11.zip. Note vc11 inside the name of the file. It shows the Visual C distribution version. You need to have your PHP to be of the same flavour, which you can download from PHP download site. Mine is php-5.6.14-Win32-VC11-x86.zip, the same vc11 again. Note please that your PHP is the thread safe. Please, even if your Windows is x64 bits, do not use httpd server x64 or PHP x64 or non thread safe version if you do not like to struggle with forums and their moderators. Also use short names without dot, dash, space and such things for the folders. Behind the scene of software still we are in many aspects at 1999.
Unzip these folders one by one. Bring two unzipped folders into C:\ApacheWeb. Cut Apache24 folder from inside the httpd-2.4.16-win32-VC11 folder nd paste it in C:\ApacheWeb Rename it as Apache. Rename php-5.6.14-Win32-VC11-x86 as just Php, such that now you have two folders as C:\ApacheWeb\Apache, and C:\ApacheWeb\Php. Create a notepad txt file as MyReminder.txt and write in it, "My Apache version is httpd-2.4.16-x86-vc11.zip and my PHP is php-5.6.14-Win32-VC11-x86.zip (thread safe version)." This helps you to remember later what software you have used. Delete every other thing, but these three.
Put your folders and files of your website into C:\ApacheWeb\Apache\htdocs such that your home page to be naked there; that is C:\ApacheWeb\Apache\htdocs\home.html. Change the existing index.htm that comes as default with the Apache httpd server to indexOld.html. Copy and paste your home.html as index.html there, such that now you have both of them.
Now go to the C:\ApacheWeb\Apache\conf. Open httpd.conf file. Add three lines at the bottom
Please note that in the last line there is a space before .php
Change line 37 of the file from ServerRoot "c:/Apache24" to ServerRoot "c:/ApacheWeb/Apache"
Change line 242 of the file from DocumentRoot "c:/Apache24/htdocs" to DocumentRoot "c:/ApacheWeb/Apache/htdocs"
Change line 243 of the file from <Directory "c:/ApacheWeb/Apache/htdocs"> to <Directory "c:/ApacheWeb/Apache/htdocs">
Now you are ready to go. Open a command prompt "As Admin." Change directory to C:/ApacheWeb/Apache/bin and then type httpd.exe -t and run it, where in response you should get "syntax OK;" otherwise, correct the errors that are mentioned. If your config file becomes accepted in this way, then from the same command line run httpd.exe -k install that creates Windows service to run automatically your webserver every time that you turn on your computer. This service is named as Apache2.4 and can be checked for its properties and specifications inside the Windows management for Services. You can see that the "Description" of service comes as Apache/2.4.16 (Win32) PHP/5.6.14. This completes installation of Apache httpd server and PHP.
As in the previous post ( Web Hosting at Your Home (Revisited) ) mentioned you need to do port forwarding and inbound rule for firewall and other things mentioned in previous post.
Change your httpd.conf file listening port wherever you find in the text to, say, 8085, or 9191 and such. Then log into your router and change the port forwarding to 8085; also rename this rule to something else from HTTP to, say, MyWeb in the router. Go to your Windows firewall rule, too, and check if you have configured it with port 80, then change it to the new figure.
If you want to test your local host instead of http://localhost/ type it as http://localhost:8085/ .
Additionally you need to change the free dynamic host IP forwarding from the IP of your home to the new assigned port; for example if your redirecting IP is 188.165.15.29 change it to 188.165.15.29:8085. All such hosts have certain helpful facility to implement this.
From the time that I wrote Web Hosting at Your Home (Revisited) Apache httpd server has seen many revisions. Also people might like to have PHP installed on their web server to be able to load PHP pages.
Assume your web serving computer is clean of any Apache httpd sever of previous versions such as Apache httpd server 2.2. The latest version for Windows operating system is not in the form of an exe file to be run by double clicking and automated install; it even is not compiled for Windows. It is a source file in C programming language that needs compilation.
If you know how to use MinGw or NetBeans IDE or Visual Studio then you need to compile the source and then follow other steps, you even can build an automated EXE file for execution.
The good news is that some people, Apache Lounge, already have done the compilation but still no executable GUI for installation exists. You do not need this far. You can get the compiled server, most likely a zip file, from those people and install it in your comfort.
Create an Apache server folder as near as possible to the root; that is, C:\; for instance, C:\ApacheWeb.
Then download the compiled folder. Mine is httpd-2.4.16-x86-vc11.zip. Note vc11 inside the name of the file. It shows the Visual C distribution version. You need to have your PHP to be of the same flavour, which you can download from PHP download site. Mine is php-5.6.14-Win32-VC11-x86.zip, the same vc11 again. Note please that your PHP is the thread safe. Please, even if your Windows is x64 bits, do not use httpd server x64 or PHP x64 or non thread safe version if you do not like to struggle with forums and their moderators. Also use short names without dot, dash, space and such things for the folders. Behind the scene of software still we are in many aspects at 1999.
Unzip these folders one by one. Bring two unzipped folders into C:\ApacheWeb. Cut Apache24 folder from inside the httpd-2.4.16-win32-VC11 folder nd paste it in C:\ApacheWeb Rename it as Apache. Rename php-5.6.14-Win32-VC11-x86 as just Php, such that now you have two folders as C:\ApacheWeb\Apache, and C:\ApacheWeb\Php. Create a notepad txt file as MyReminder.txt and write in it, "My Apache version is httpd-2.4.16-x86-vc11.zip and my PHP is php-5.6.14-Win32-VC11-x86.zip (thread safe version)." This helps you to remember later what software you have used. Delete every other thing, but these three.
Put your folders and files of your website into C:\ApacheWeb\Apache\htdocs such that your home page to be naked there; that is C:\ApacheWeb\Apache\htdocs\home.html. Change the existing index.htm that comes as default with the Apache httpd server to indexOld.html. Copy and paste your home.html as index.html there, such that now you have both of them.
Now go to the C:\ApacheWeb\Apache\conf. Open httpd.conf file. Add three lines at the bottom
#Following 3 lines have been added by the webserver designer.
LoadModule php5_module "C:/ApacheWeb/Php/php5apache2_4.dll"
PHPIniDir "C:/ApacheWeb/Php"
AddHandler application/x-httpd-php .php
LoadModule php5_module "C:/ApacheWeb/Php/php5apache2_4.dll"
PHPIniDir "C:/ApacheWeb/Php"
AddHandler application/x-httpd-php .php
Please note that in the last line there is a space before .php
Change line 37 of the file from ServerRoot "c:/Apache24" to ServerRoot "c:/ApacheWeb/Apache"
Change line 242 of the file from DocumentRoot "c:/Apache24/htdocs" to DocumentRoot "c:/ApacheWeb/Apache/htdocs"
Change line 243 of the file from <Directory "c:/ApacheWeb/Apache/htdocs"> to <Directory "c:/ApacheWeb/Apache/htdocs">
Now you are ready to go. Open a command prompt "As Admin." Change directory to C:/ApacheWeb/Apache/bin and then type httpd.exe -t and run it, where in response you should get "syntax OK;" otherwise, correct the errors that are mentioned. If your config file becomes accepted in this way, then from the same command line run httpd.exe -k install that creates Windows service to run automatically your webserver every time that you turn on your computer. This service is named as Apache2.4 and can be checked for its properties and specifications inside the Windows management for Services. You can see that the "Description" of service comes as Apache/2.4.16 (Win32) PHP/5.6.14. This completes installation of Apache httpd server and PHP.
As in the previous post ( Web Hosting at Your Home (Revisited) ) mentioned you need to do port forwarding and inbound rule for firewall and other things mentioned in previous post.
Problem : Apache default port 80 may conflict with Skype.
Before running the install command, you might like to change the port that listens to inbound traffic. It is due to the fact that in Windows most of the people have Skype installed. Skype allows using default listening ports 80 which is also default for your Apache. Many believe that they should remove Skype to solve the conflict. This is not necessary.Change your httpd.conf file listening port wherever you find in the text to, say, 8085, or 9191 and such. Then log into your router and change the port forwarding to 8085; also rename this rule to something else from HTTP to, say, MyWeb in the router. Go to your Windows firewall rule, too, and check if you have configured it with port 80, then change it to the new figure.
If you want to test your local host instead of http://localhost/ type it as http://localhost:8085/ .
Additionally you need to change the free dynamic host IP forwarding from the IP of your home to the new assigned port; for example if your redirecting IP is 188.165.15.29 change it to 188.165.15.29:8085. All such hosts have certain helpful facility to implement this.
Problem : Visitor browser shows IP and does not show the domain name URL (IP address is shown in address bar instead of domain).
Regretfully, this shows your IP in the address bar of the visitors' browsers. For instance, you have acquired free dynamic mysite1.somefree.org and pointed it to 188.165.15.29:8085, then visitors' browsers never show mysite1.somefree.org; but shows 188.165.15.29:8085 and you do not like your IP becomes revealed for security reasons.
Most of the free dynamic dns providers, like the one I use, NoIP, allow acquiring more than one free host name. If allowed you can solve the problem by getting a second name, e.g., mysite2.somefree.org. Now, go and configure your free domain names in the dashboard of free provider in the following way.
Now visitor's browser shows mysite2.somefree.org:8085 which is secure.- redirect mysite1.somefree.org to mysite2.somefree.org:8085
- redirect mysite2.somefree.org to your dynamic IP, say, to 188.165.15.29
Please click on my first free domain name, and notice that you'll be redirected to my second domain name on port 8085.
Please note: this is my hobby home server and might be shut down or under my constant tweaking. Mostly it is up between 7.00 AM to 10.00PM (GMT)
Please note: this is my hobby home server and might be shut down or under my constant tweaking. Mostly it is up between 7.00 AM to 10.00PM (GMT)
Monday, 24 February 2014
How to Create a Contact Form for Your Website in an Easy Way : A Set of Step by Step Tutorials Using HTML5, CSS3 and PHP (10)
(For the latest PDF files Merger Software please have a look at the top of the left margin, inside the red box.)
Continues From Part 9
In the previous post I got the IP of the visitor and displayed it on the bottom of the contact page as a courtesy. I also put it inside the messages they might send for me. To keep the IP of any visitor who might send a message or just click on my page, I keep a record of IP's of all the visitors. Allow me to advance further and add more elaborations to my contact form.
Remember that I am not addressing any security issue such as preventing SQL Injection or making PHP codes more accomplished by using advanced functions. Sometimes they are controversial even among the PHP experts. I have done many computer codes from Assembly and machine codes, Fortran, dos to Eifel. Now I only do assembly, C, and Java and sometimes Windows C++. I do not like to become engaged in PHP. See, it is advised to change $Name = $_POST['Name'] to $Name = filter_input(INPUT_POST, 'Name'). This works. but a similar trick, filter_input(INPUT_SERVER, "REMOTE_ADDR") in place of $_SERVER["REMOTE_ADDR"] does not work, uniformly (might work intermittently; mostly dispatches Server Error). It is due to the fact that as you might notice, parameters and references are not uniform. Hence, the interested readers might like to study manuals deeper.
How to make a simple basic database of visitors' IP's?
How to collect (put) visitors' IP records in a text file?
It is usual that web servers use MySQL to gather information in a systematic manner. I make a simple text to keep records of visitors IP. Please remember line (217) of contact form in previous post. This is where the visitors get their IP's upon landing on the page and the best time to catch a record of the visit. Therefore, add the following snippet after this line and before line (218). Hence Line (218) will become Line (228)218 219 220 221 222 223 224 225 226 227 | $ip_file = 'save_ip.txt'; $date_ti = date('Y-m-d H:i:s'); if(file_exists($ip_file)){ $file_content = file_get_contents($ip_file); file_put_contents($ip_file, $file_content . "\r\n" . $date_ti . "\t||\t" . $visitor_ip); } else{//create text file and put header for the table file_put_contents($ip_file, "Date and Time" . "\t||\t" . "Visitors IPs" . "\r\n" . $date_ti . "\t||\t" . $visitor_ip); } |
(Download PHP code in Zip format here or open the code in text format here). On each landing, the code snippet checks if the text file 'save_ip.txt' is already created and exists. If it is the first ever reference to this file it creates the file and puts a simple header for its columns. Then goes to the next line and puts the date, time and IP of the first visitor in the second row. However, if the text file already exists code snippet gets contents of the text, rewrites it. Then goes to the next line and adds one new record to previous records. I tried to add some formatting and vertical bars to separate columns, nevertheless, readers might like to impose their own ways of doing that. Remember that, at the end, one needs to use MySQL to accumulate these information or to invoke third party tools and subscribed services.
Also, it is worth mentioning that one needs to become familiar with PHP tabs, new line, carriage-return, end-of-line and so on. I used the familiar "\t", "\r", "\n" for purposes of this article, but frequently, they do not behave in such a simple way as they should.
You can learn about PHP date and time formats, too, from their wikis.
After two visits you can open the text file in your browser to watch records of visitors IP's or you can download and read them with a text editor, or other ways that your web server allows.
Please check permissions (three digits numbers such as 644) for the created file not to be accessible to unwanted visitors. (In the last snap-shot IP's painted with wrong numbers for privacy of visitors.)
Please click here to open the contact form and then open the saved text to see that your own IP has been added (many times a day I renew the text to keep privacy of previous visitors).
Download this tutorial as PDF format here
Download part 1 to part 10 as PDF format here
Monday, 10 February 2014
How to Create a Contact Form for Your Website in an Easy Way : A Set of Step by Step Tutorials Using HTML5, CSS3 and PHP (9)
(For the latest PDF files Merger Software please have a look at the top of the left margin, inside the red box.)
Continues From Part 8
Look at lines (254) to (272). A function has been added that returns IP address using PHP standard methods. This is very crude implementation of PHP and those methods should be guarded, in principle, against access to any global. Nevertheless it works for now and interested individual can do better by gaining deeper knowledge of PHP.
At line (130) visitor's IP has filled variable $visitor_ip to be displayed later with an echo command. Line (131) defines a $hdshake variable to show a formatted phrase for $visitor_ip and $Email of the visitor.
If the visitor has attempted the contact form, then lines (141) to (143) display their IP and email.
Otherwise, if the visitor has just landed on the contact form page, then the page only displays his IP. This is reflected in the else phrase in lines (216) to (218).
Meanwhile note that lines (174) to (176), where you have sent the visitor's IP back for yourself for having further information to keep in your own database.
This is the snap-shot of page when visitor lands on page.
Above IP has been painted to a wrong number to avoid coincidence with some people's real IP. You can check yours by clicking here, please. In the next article we collect IP's of every visit in a text file.
Download this tutorial as PDF format here
Download part 1 to part 9 as PDF format here
Continues From Part 8
How to get IP addresses of visitors.
As promised, in this refinement I'll get the IP address of the visitor and show inside a formatted division to visitors who come to the contact page. You can use the code inside any other page of your choice. First let me put the final code here for your consideration (download PHP code in Zip format here or open the code in text format here).1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | <!DOCTYPE html> <!-- Created by Peter Jones 10 February, 2014 www.codesforus.blogspot.com copyrights --> <html> <head> <title> Demo-Final: Dysprosium Contact Form, Get IP</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width"> <script type= "text/javascript"> var RecaptchaOptions = { theme: 'white' }; </script> <style> #contact-wrapper { margin: 20px auto; border: 2px solid #ccc; border-radius: 5px; padding: 20px 50px 20px 50px; background: transparent; width: 600px; } #contact-area { width: 600px; margin-top: 25px; } #contact-area label { float: left; margin-right: 15px; padding-top: 5px; width: 100px; text-align: right; font-size: 100%; } #contact-area input, #contact-area textarea { margin: 0px 0px 10px 0px; border: 2px solid #ccc; border-radius: 5px; padding: 5px; width: 471px; font-family: Helvetica, sans-serif; font-size: 110%; } #contact-area textarea { height: 90px; } #contact-area textarea:focus, #contact-area input:focus { border: 2px solid #900; } #contact-area input.submit-button { float: left; cursor: pointer; margin-top:10px; margin-left:112px; background: transparent; width: 100px; font-size: 100%; color: #024d8e } #contact-area input[type="submit"]:hover{ border: 2px solid #900; } #recaptcha_widget_div { margin-top: 20px; margin-bottom: 10px; margin-left: 112px; } #recaptcha_fail_div { margin-top: 20px; margin-bottom: 10px; margin-left: 112px; border:medium groove #A00; border-radius: 5px; border:medium groove #A00; padding:3px; background-color:transparent; width:350px; color:#900; font-weight:bold; font-size:80%; } </style> </head> <body> <div id="contact-wrapper"> <div id="contact-area"> <form method="post" action=""> <label for="Name"><span style="color: red; font-size: 100%">* </span>Name:</label> <input type="text" name="Name" id="Name" value="<?php echo isset($_POST['Name']) ? $_POST['Name'] : '' ?>" /> <label for="City">City:</label> <input type="text" name="City" id="City" value="<?php echo isset($_POST['City']) ? $_POST['City'] : '' ?>" /> <label for="Email"><span style="color: red; font-size: 100%">* </span>Email:</label> <input type="text" name="Email" id="Email" value="<?php echo isset($_POST['Email']) ? $_POST['Email'] : '' ?>" /> <label for="Subject">Subject:</label> <input type="text" name="Subject" id="Subject" value="<?php echo isset($_POST['Subject']) ? $_POST['Subject'] : '' ?>" /> <label for="Message"><span style="color: red; font-size: 100%">* </span>Message:</label> <textarea name="Message" rows="20" cols="20" id="Message"><?php echo isset($_POST['Message']) ? $_POST['Message'] : '' ?></textarea> <p style="margin:20px auto 10px 112px;">Fields shown by <span style="color: red; font-size: 100%">* </span> are required.</p> <div id="recaptcha_widget_div"> <?php require_once('recaptchalib.php'); $publickey = "6LcJA-sSAAAAAPVPHLiHjGTlkhuWhLX2Luj3hS85"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </div> <input type="submit" name="submit" value="Submit" class="submit-button" /> </form> <div style="clear: both;"> </div> <?php $visitor_ip = getVisitorIP(); $hdshake =null; if( isset($_POST['submit']) ) { $error = null; require_once('recaptchalib.php'); $privatekey = "6LcJA-sSAAAAABCEyOe_wqfheVwfxfu4L9idhqhv"; $Name = Trim(stripslashes($_POST['Name'])); $City = Trim(stripslashes($_POST['City'])); $Email = Trim(stripslashes($_POST['Email'])); $Subject = Trim(stripslashes($_POST['Subject'])); $Message = Trim(stripslashes($_POST['Message'])); $hdshake .= '<li>Your IP : '. $visitor_ip .'</li>'; $hdshake .= '<li>Your eMail : '.$Email.'</li>'; echo '<div id="recaptcha_fail_div"><ul>'. $hdshake .'</ul></div>'; if( !empty($Email) ){ list($emailPart, $domainPart) = explode('@', $Email); $one=filter_var($Email, FILTER_VALIDATE_EMAIL); $two=MailIPAddress($domainPart); if (!(($one) && ($two))) { $error .= '<li>Email is invalid .</li>'; echo '<div id="recaptcha_fail_div"> <ul>'. $error .'</ul></div>'; exit(); } } $error .= ( empty($Name) ) ? '<li>Please enter your name.</li>' : null; $error .= ( empty($Email) ) ? '<li>Blank Email is not accepted.</li>' : null; $error .= ( empty($Message) ) ? '<li>Please enter some comments or questions.</li>' : null; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); $error .= ( !($resp->is_valid) ) ? '<li>The captcha code entered is incorrect .</li>' : null; if (!empty($error)) { // What happens when the CAPTCHA was entered incorrectly echo '<div id="recaptcha_fail_div"> <ul>'. $error .'</ul></div>'; exit(); } //Next send contact to website admin. $EmailToAdmin = "carlo.dj@messiahpsychoanalyst.org"; //Put your website admin email here. Don't forget quotes. // body of the email your own admin receives $Body = "RE: Contact from visitors"; $Body .= "\n"; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "City: "; $Body .= $City; $Body .= "\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Visitor's IP: "; $Body .= $visitor_ip; $Body .= "\n"; $Body .= "Message: "; $Body .= "\n"; $Body .= $Message; $Body .= "\n"; // send email to admin $posted = mail($EmailToAdmin, $Subject, $Body, "From: <$Email>"); // redirect to thanks page if ($posted){ echo '<div style=\'margin-top: 20px; margin-left:112px; border: 2px groove blue; border=radius:5px; padding-left: 10px; width:400px;\'> <p>Thanks By <a href="http://messiahpsychoanalyst.org">Dysprosium</a></p> <hr style=\'margin: 1px auto 1px auto; height: 1px; color: #fefefe; width: 82%;\'/> <h1>Your message has been sent! Thanks for Your Message!</h1> <p><a href="Default.html">Click to go to Home page!</a></p> </div>'; //After thank you send an email containing his message to the visitor // prepare email body text $Body = " Madam/Sir,\n Thank you for your message.\n Dysprosium.\n"; $Body .= " ======================================================\n\n"; $Body .= "Name: "; $Body .= $Name; $Body .= ", Esq."; $Body .= "\n"; $Body .= "From: "; $Body .= $City; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Subject: "; $Body .= $Subject; $Body .= "\n"; $Body .= "Message: "; $Body .= "\n"; $Body .= $Message; $Body .= "\n"; // send email mail($Email, $Subject, $Body, "From: <$EmailToAdmin>"); } } else{ echo '<div id="recaptcha_fail_div"> Your IP : '. $visitor_ip .'</div>'; } ?> </div> </div> <?Php /** * http://www.electrictoolbox.com/php-get-mail-server-ip-address/ * Get a mail server's IP address with PHP * Posted November 9th, 2012 in PHP by Chris Hope * Returns an IP address that mail can be delivered to for the passed in domain. * **/ function MailIPAddress($domain) { $ip = false; $records = dns_get_record($domain, DNS_MX); $priority = null; foreach ($records as $record) { if ($priority == null || $record['pri'] < $priority) { $myip = gethostbyname($record['target']); // if the value returned is the same, then the lookup failed if ($myip != $record['target']) { $ip = $myip; $priority = $record['pri']; } } } if (!$ip) { $ip = gethostbyname($domain); // if the value returned is the same, then the lookup failed if ($ip == $domain) { $ip = false; } } return $ip; } ?> <?php function getVisitorIP() { $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR']; if (filter_var($client, FILTER_VALIDATE_IP)) { $ip = $client; } else { if (filter_var($forward, FILTER_VALIDATE_IP)) { $ip = $forward; } else { $ip = $remote; } } return $ip; } ?> </body> </html> |
Look at lines (254) to (272). A function has been added that returns IP address using PHP standard methods. This is very crude implementation of PHP and those methods should be guarded, in principle, against access to any global. Nevertheless it works for now and interested individual can do better by gaining deeper knowledge of PHP.
At line (130) visitor's IP has filled variable $visitor_ip to be displayed later with an echo command. Line (131) defines a $hdshake variable to show a formatted phrase for $visitor_ip and $Email of the visitor.
130 131 | $visitor_ip = getVisitorIP(); $hdshake =null; |
If the visitor has attempted the contact form, then lines (141) to (143) display their IP and email.
141 142 143 | $hdshake .= '<li>Your IP : '. $visitor_ip .'</li>'; $hdshake .= '<li>Your eMail : '.$Email.'</li>'; echo '<div id="recaptcha_fail_div"><ul>'. $hdshake .'</ul></div>'; |
Otherwise, if the visitor has just landed on the contact form page, then the page only displays his IP. This is reflected in the else phrase in lines (216) to (218).
216 217 218 | else{ echo '<div id="recaptcha_fail_div"> Your IP : '. $visitor_ip .'</div>'; } |
Meanwhile note that lines (174) to (176), where you have sent the visitor's IP back for yourself for having further information to keep in your own database.
174 175 176 | $Body .= "Visitor's IP: "; $Body .= $visitor_ip; $Body .= "\n"; |
This is the snap-shot of page when visitor lands on page.
Above IP has been painted to a wrong number to avoid coincidence with some people's real IP. You can check yours by clicking here, please. In the next article we collect IP's of every visit in a text file.
Download this tutorial as PDF format here
Download part 1 to part 9 as PDF format here
Subscribe to:
Posts (Atom)