by Sundarram P. V.

Wednesday, August 30, 2006

A wild idea but it might just work.......

If you see very closely there is one thing common in many bloggers and that is they all have some kindof counter and it also tracks from where the last request came. The list of free counters can be found by just googling. These statistics site also have something in common that is they all have ranked the users who have put this statistics. so you actually have all the list of users who have these statistics counter on their page.
To increase the traffic in the site here is the idea............
1. First populate all the set of users using these statistics... this can be done by writing a bot to do it which IMHO is not very complex.
2. Now make a request to these people's pages using a bot with the http reference set to your site or another site which redirects to your site or to a google's search page where your page is the first one in the searched items list(that will make them surely visit the google link).
which can be easily done using ajax by
xmlhttprequest.setRequestHeader("Reference", "http://www.yoursite.com");

3. From time to time the bot needs to visit those statistics site to get the new users. And also all the list of users must be maintained in a database.
4. Shouldnt make request very reqularly as this might make people ignore the request.
5. Here the chances of people visting the website are low , possibility would be from 1/10 to 1/20, but you can really narrow down on the audience you want (coz these statistics site have already categorised all their pages)and is a free of cost advertisement which in my opinion is great. Also even if 1 in every 10 or 20 people visit the page, the numbers are huge.
| |

Intimate Closing the window

In many situations , people need to find out whether the user has closed the window or is out of that page.... For that to find out we need to tap into the window.onunload event. make an synchronous call to the server to intimate. this can also be used to post the data in the form. You cant make a "async" or "ajax"
call because the thread wont wait for the request to be completed(async) and the window will be closed before the request gets over.
window.onunload=function ()
{
//req ---> XMLHTTPRequest object

req.open("POST",URL,false/*synchronous call*/);
req.setRequestHeader("Cache-Control","no-cache");
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.send(post-items);
};

but there is a problem here , whenever the user navigates from this page or refreshes the page, the server will get the intimation. Now the problem here is howto distinguish between navigation out of the page and the closing of window. One way to do it would be to have a flag which will be set whenever the user clicks that link.
it will look like this
<a href=URL onclick="navigate-flag = 1;">

This flag can be checked in the onunload event handler.
| |

Monday, August 28, 2006

Setting up the Development Environment.......

I searched for setting up the development environment for web-developers(PHP - JS) extensively over the net but couldnt find anything concrete. I have used many editors and there is nothing as good as eclipse (nothing can beat vi)....ya i accept its bulky and a bit slow(tats java for u)....but it saves you a lot of time in debugging and also while coding.....this is for people who already have a website and a version control in place....
Apache
1. Download the version of apache(sources or binaries or executable) used in the server http://httpd.apache.org/download.cgi
2. Install apache.
(to have a smooth installation shutdown all the services which might use port 80 esp. skype)
(while using linux... its always better to compile the sources)
3. Start the apache service
for windows
control panel -> administrative tools -> services
right click Apache2 -> Start.
(if you dont find apache2 service then try repairing)
for linux
~]# httpd &(to run as a background process) or apachectl start or service httpd start(redhat derivatives)
4. Now try localhost in your favourite browser...If you dont get the test page, it mite be becoz of 2 reasons...
a...your firewall is blocking
b...some other service is using the same port(skype does that)
open the port 80 in firewall and also close all services which might use the same port. if this doesnt work then try repairing in windows.

PHP
1. Download the appropriate version of php from http://www.php.net/downloads.php
2. Now extract the compressed file downloaded to [LOCATION]
3. Go to the [LOCATION] and rename php.ini-recommended to php.ini
4. Add this to the httpd.conf file
for windows
LoadModule php5_module "[LOCATION]/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "[LOCATION]"
for linux
LoadModule php5_module "[LOCATION]/php5apache2.so"
AddType application/x-httpd-php .php
PHPIniDir "[LOCATION]"
5. Restart Apache. Now for testing try putting phpinfo() in a .php file in [htdocs] folder. make a request from your favourite browser.
6. for windows
now copy the file libmysql.dll to c:\windows\system327. now add the extension path to the php.ini file
for windows
extension_dir="[LOCATION]\ext"

for linux (generally)
extension_dir="/usr/lib/php/modules"
or
extension_dir="[LOCATION]/modules"

8. in order to access mysql server add this to the php.ini file
for windows
extension=mysql.dll
extension=mysqli.dll

for linux
extension=mysql.so
extension=mysqli.so

DBG PHP Debugger
1. Download the dbg debugger from http://dd.cron.ru/dbg/downloads.php
2. The versions of php supported by free version of debugger are from 4.0.6 up to 4.4.2 and from 5.0.0 up to 5.1.2.
3. If your version of php is not supported then try using zend debugger but that wont work with phpeclipse. In that case try using the php ide(i had some bad experiences with it).
4.for linux
copy dbg.so-[VER] to the extension folder of php
for windows
copy php_dbg.dll-[VER] to the extension folder of php
5. Add this to php.ini file
[debugger]
debugger.enabled = true
debugger.profiler_enabled = true
debugger.JIT_host = clienthost
debugger.JIT_port = 7869

6. Restart apache and try phpinfo.It will look like this













Eclipse     

1. Download eclipse 3.1.2 from here
The latest release 3.2 doesnt work well with PHPeclipse 1.1.8
2. If you dont have JavaRunTime(J2SE Update 8) then download it from here
3. Install java runtime
4. Extract the eclipse file to any location
5. Eclipse will ask for the location of a workspace, give a location[WORK].
6. To do a manual install of phpeclipse download the compressed file from here
7. Now extract that file in the eclipse folder.
8. Goto the commandline and type eclipse -clean.
You can skip steps 6-8 if you are doing a automatic install.
9. Now to install subclipse(subversion client) follow the instructions on this page .
10. Now change the perspective in eclipse to SVN Repository.
10.1. In the left You will find the SVN Repository Tab

10.2. Now give the location of your repository in this dialog

10.3. Now checkout your repository

10.4. Then you will get this dialog

Then create a new project(PHP) inside the workspace.You can create multiple projects from different repository locations in a single workspace.
11. Now goto project properties

12. You can change the settings for the project accordingly

13. Now open any php file.
13.1. To run or debug you need to set the configuration. When you right click and click run or debug you will get the following dialog box. There create a new configuration.

13.2. In the same window, set the path and file name

Each and every file will have their own configuration for executing and/or debugging.
13.3. In the same window now select the First environment tab. There give the path of the php interpreter.

13.4. Now in the remote debug tab set the remote debugging option and check the path there

14. For editing javascript , aptana plugin is very good . To install aptana follow the following instructions found at this page

15. For javascript you may also install JSEclipse plug-in which is also good. For commercial use, i did suggest you buy it. It can be found at this page

16. All the SVN options can be found in rightclick file -> Team ->
While commiting to svn plz dont commit the .project file.

happy eclipsing!!!!!
Tags |- | | | | |

___