how to change or disable connection timeout in filezilla

ZCategory No Comments »

Sometimes my server takes a long time to connect.
When i used filezilla recently to update my files filezilla could not connect to my server.
It says connection timed out.

and i opened the settings
Connection -> Under the Timeout option
make it 0 to disable
or you can give any number of seconds like 30 seconds or 60 seconds.
By default i think filezilla sets 20 seconds.

php set socket time out for fsockopen, set time out for fsockopen

PHP Socket No Comments »

Sometimes if a target host is unreachable by a socket connection it takes 60 seconds to know that the socket function cannot connect to the destination. This is when i am using fsockopen function to connect to a remote host. So i was wondering there should be a function to timeout according to our preference and found that stream_set_timeout could do that.

 
$fp = fsockopen("www.example.com", 80);
if (!$fp) {
    echo "Unable to open\n";
} else {
 
    fwrite($fp, "GET / HTTP/1.0\r\n\r\n");
    stream_set_timeout($fp, 2);
    $res = fread($fp, 2000);
 
    $info = stream_get_meta_data($fp);
    fclose($fp);
 
    if ($info['timed_out']) {
        echo 'Connection timed out!';
    } else {
        echo $res;
    }
 
}

where the second parameter of stream_set_timeout is in seconds.

why javascript history.back() toggles between two pages

JavaScript 3 Comments »

I was working in a project where each page had a back button. Because of the designers design the back button was created using anchor tag <a> and as a programmer i thought of using the back button like the following in the anchor tag.

<a href='javascript:;' onclick='window.history.back()'>Back</a>

But what had happened when i press the back button after navigating to various pages was i got locked between the last two navigated pages. It kept toggling between the last visited page and the previous page where as it is supposed to go backward step by step.

So let us say i have navigated from page 1 to 10 and now i am in page 10. When i press the back button in page 10 i came to page 9. But when i pressed the back button in page 9 again it took me to page 10 instead of taking me to page 8. So this keeps happening until i changed the code to the following.

<a href='javascript:window.history.back();'>Back</a>

After modifying to the above code all went well. The back button press worked normal which took me from page 10 all the way to page 1 when i kept on pressing the back button.

and besides the given code there was a style applied to the anchor tag and that was just float right.

Is this an issue needed attention which is to be posted in a blog? I don’t think so but thought of talking to the people to see their responses. If people know why this peculiar behaviour then please post a note of a reply or a reference or whatever which could be of assistance to all people. :)

insert into tablea select fields from tableb for specific values only

MYSQL No Comments »

While using insert into table select * from table there will be a problem that the total fields should match and the datatype should be same. But if there is table a and table b and you want to import table b’s few fields into table a then the above will not work and it will throw an error that total no of fields do not match.

So to import only specific fields then use the following sql in which only the needed fields are specified in the into part and the from part. so insert into table1 column names and select column names form table2.

INSERT INTO tablename (some_column, somecolumn2)
SELECT othercolumn1, othercolumn2 FROM TABLE name WHERE id=somevalue

the where clause is optional.

Reference
http://stackoverflow.com/questions/4421807/sql-flavours-of-insert-into
http://stackoverflow.com/questions/2470924/ignore-some-values-in-insert-into-select-from-sql-stament
Notes to be taken http://stackoverflow.com/questions/1787634/automatically-match-columns-in-insert-into-select-from

US phone number validation by adding hypen automatically using javascript

JavaScript 2 Comments »

The following code will validate the US phone number format. It will not check for open and closing brackets. it will validate the following format xxx-xxx-xxxx.

Besides it will not allow any other characters other than numbers and hypen to be typed. if any other character is typed in then it is removed using the regular expression in the script.

This script was created for an instant purpose and i may expand it so that will have full control on the keypress.

I have called a function whichkey to find the keycode which is a cross browser code. Each browser handles event differently so we need to find the char code number using a cross browser function and here that is whichkey.

<script type="text/javascript">
function mask(e,f){
	var len = f.value.length;
	var key = whichKey(e);
	if(key>47 && key<58)
	{
		if( len==3 )f.value=f.value+'-'
		else if(len==7 )f.value=f.value+'-'
		else f.value=f.value;
	}
	else{
		f.value = f.value.replace(/[^0-9-]/,'')
		f.value = f.value.replace('--','-')
	}
}
 
function whichKey(e) {
	var code;
	if (!e) var e = window.event;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	return code
//	return String.fromCharCode(code);
}
 
</script>
<input type="text" name="phone" id="phone" 
onkeydown="mask(event,this)" onkeyup="mask(event,this)" 
maxlength="12" />

….

with the above code you can add your own code to make it more useful to you. I had made a very simple attempt to do a validation.

ajax cross domain xmlhttprequest in firefox

Ajax No Comments »

I got this cross domain ajax script some where and found it is working. You can run this file just directly from your desktop. You don’t have to have the localhost. The code enables a kind of privilege. This worked in firefox and for internet explorer there is another method for their own use. copy paste the code as html and click the get button.

Besides… I would like to have objections if any and comments about this article so that i can update. It is not just an article but a public document to which people can provide info to testify this. Just like that. How the following will be in future

<script type="text/javascript" language="javascript">
 
// Error: uncaught exception: Permission denied to call method XMLHttpRequest.open
 
  var http_request = false;
 
  function makeRequest(url, parameters) {
 
   try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {
    alert("Permission UniversalBrowserRead denied.");
   }
 
    http_request = false;
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {
      http_request.overrideMimeType('text/xml');
    }
    if (!http_request) {
      alert('Cannot create XMLHTTP instance');
      return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('GET', url + parameters, true);
    http_request.send(null);
  }
 
  function alertContents() {
    if (http_request.readyState == 4) {
      if (http_request.status == 200) {
 
        var string = http_request.responseText;
      alert(string);
 
      } else {
        alert('There was a problem with the request.');
      }
    }
  }
  function updateweather() {
    makeRequest('http://www.wunderground.com/auto/rss_full/global/stations/16239.xml', '');
  }
</script>
<input type="button" name="button" value="GET XML" 
  onclick="javascript:updateweather();">

Microsoft Windows Network The network is not present or not started

Windows Tips No Comments »

Make sure that the cable is not loose. if possible check the network card.
and if it is still so then you have to check the network service.

Click start -> run -> type services.msc

Locate Workstation.

Which will be the last in the list of services.

Make sure it is running else start the service.

I am using kaspersky antivirus. When i close it sometimes it asks whether to close the open network connection and i use to give yes.

It closes gtalk and other open connection which i was not aware.

May be it would have stopped the network service also.

So when i checked using services.msc it has been stopped but not sure whether it is because of anti virus.

Anyway, i started it and i could browse the local area network computers.

Matching newline in multiline text without using DOT but with an alternate char class

Regular Expression No Comments »

The Character class \w matches any word character, and \W matches anything that isn’t a word character.

So, [\w\W] matches anything, including a newline

for example removing c style comments

/\*[\w\W]*?\*/

another example is getting all text within a div

<div class="\&quot;validtext_erea\&quot;">([\w\W]*?)&lt;\/div&gt;</div>

Usually we use it as (.*?) but this matches all characters except newline.

So the alternate char class w is used to find all chars and non chars.

The question mark is used to include laziness because the * chars is greedy.

Reference
http://www.adobe.com/devnet/dreamweaver/articles/regular_expressions_pt2.html
See this for more modifiers
http://www.regular-expressions.info/modifiers.html
For a long time i have been looking for this
http://www.regular-expressions.info/dot.html

Affiliate Network SubId Tracking List

ZCategory No Comments »

List of affiliate networks links with subid tracking query string.

All affiliate networks will provide a request and a response fields to track subid’s. I did not find linkshare in the following list but all networks will provide one in their documentation. it would be a key value pair the key being some thing like subid and the value could be any base64 encoded string. we can pack all data as a string and set it as the value of a key subid or something related to that according to each network and add as a query string.

This is a great list copied from external s ources with many subIDs

Adreporting - Replace “way” with “w” and add =[[subid]]

before: http://www.adreporting.com/dir.php?a=000000&p=00

after : http://www.adreporting.com/dir.php?a=000000&p=00&w=[[subid]]

Agami Media - Add [[subid]] at the end

before: http://partners.agamimedia.com/00/000/0000/

after : http://partners.agamimedia.com/00/000/0000/[[subid]]

AzoogleAds - Add [[subid]] after ?sub=

before: http://azoogleads.com/1LN55

after : http://azoogleads.com/1LN55?sub=[[subid]]

ClickBank Add [[subid]] after ?tid=

before: http://clickbank.hop.clickbank.net/

after : http://clickbank.hop.clickbank.net/?tid=[[subid]]

ClickBooth - Add [[subid]] after &optionalinfo=

before: http://www.clickboothlnk.com/e/?enc=bnnvyvfgvsvd&optionalinfo=&deployid=0&land=0&pid=0

after : http://www.clickboothlnk.com/e/?enc=bnnvyvfgvsvd&optionalinfo=[[subid]]&deployid=0&land=0&pid=0

CommissionXchange - Add [[subid]] at the end

before: http://commissionxchange.directtrack.com/z/00000/CD0000/

after : http://commissionxchange.directtrack.com/z/00000/CD0000/[[subid]]

Commission Junction - Add [[subid]] after ?sid=

before: http://www.tkqlhce.com/click-0000000-00000000

after : http://www.tkqlhce.com/click-0000000-00000000?sid=[[subid]]

Copeac - Add [[subid]] after o=

before: http://www.cpaclicks.com/redirect.asp?a=0000&b=00000&d=0&l=0&o=&p=0

after : http://www.cpaclicks.com/redirect.asp?a=0000&b=00000&d=0&l=0&o=[[subid]]&p=0

CPA Storm - Add [[subid]] at the end

before: http://media303.com/z/0000/CD0000/

after : http://media303.com/z/0000/CD0000/[[subid]]

CPAEmpire - Add [[subid]] at the end

before: http://login.tracking101.com/ez/dxbmwschwmor/

after : http://login.tracking101.com/ez/dxbmwschwmor/[[subid]]

EliteCommission - Add [[subid]] at the end

before: http://partners.elitecommission.com/ez/cilkpzeqq/

after : http://partners.elitecommission.com/ez/cilkpzeqq/[[subid]]

Flux Advertising - Add [[subid]] at the end

before: http://123.fluxads.com/z/2038/CD3712/

after : http://123.fluxads.com/z/2038/CD3712/[[subid]]

Hydra Media - Add [[subid]] after &s=

before: http://www.lynxtrack.com/afclick.php?o=6755&b=gfy5mph6&p=14093&l=1

after : http://www.lynxtrack.com/afclick.php?o=6755&b=gfy5mph6&p=14093&l=1&s=[[subid]]

IncentAClick/Incenta Click - Add [[subid]] after ⊂=

before: http://www.incentaclick.com/nclick.php?id=0000&cid=0000

after : http://www.incentaclick.com/nclick.php?id=0000&cid=0000⊂=[[subid]]

IncentReward - Add [[subid]] at the end

before: http://incentreward.directtrack.com/z/00000/CD000/

after : http://incentreward.directtrack.com/z/00000/CD000/[[subid]]

InstantDollarz - Add [[subid]] after &subid=

before: http://instantdollarz.com/click.php?p=000&c=00000&email=

after : http://instantdollarz.com/click.php?p=000&c=00000&email=&subid=[[subid]]

IronOffers - Add [[subid]] at the end

before: http://aff.ironoffers.com/z/000/CD000/

after : http://aff.ironoffers.com/z/000/CD000/[[subid]]

LeaderClicks - Add [[subid]] after &SID=

before: http://www.leaderclicks.com/redir.aspx?CID=6315&AFID=21345&DID=29107

after : http://www.leaderclicks.com/redir.aspx?CID=6315&AFID=21345&DID=29107&SID=[[subid]]

LeaderMarket - Add [[subid]] at the end

before: http://leadermarkets.com/z/25029/CD8851/

after : http://leadermarkets.com/z/25029/CD8851/[[subid]]

MarketLeverage - Add [[subid]] after &opt=

before: http://advertising-claims.com/adscript.php?affid=CD0000&ban=00000&dep=0&land=0&opt=&pool=0&camp=0000

after : http://advertising-claims.com/adscript.php?affid=CD0000&ban=00000&dep=0&land=0&opt=[[subid]]&pool=0&camp=0000

MaxBounty - Add [[subid]] after &s1=

before: http://www.maxbounty.com/lnk.asp?o=0000&c=00000&a=00000

after : http://www.maxbounty.com/lnk.asp?o=0000&c=00000&a=00000&s1=[[subid]]

Modern Click - Add [[subid]] after &subid1=

before: http://m0dernclick.com/redirect.php?a=CD7820&b=9315&optinfo=&d=0&l=0&p=0

after : http://m0dernclick.com/redirect.php?a=CD7820&b=9315&optinfo=&d=0&l=0&p=0&subid1=[[subid]]

Millnic Media - Just put [[subid]] on end

before: http://affiliates.millnicmedia.com/sw/00000/CD0000/

after : http://affiliates.millnicmedia.com/sw/00000/CD0000/[[subid]]

NeverBlueAds - Add [[subid]] after &subid=

before: http://neverblueads.com/click/?s=224&c=7820

after : http://neverblueads.com/click/?s=224&c=7820&subid=[[subid]]

Panthera Network - Add [[subid]] at the end

before: http://partners.pantheranetwork.com/z/0000/CD000/

after : http://partners.pantheranetwork.com/z/0000/CD000/[[subid]]

PepperJam Network - Add [[subid]] after ?sid=

before: http://www.pntrs.com/t/P0dFREFHQj1GRz9DQw

after : http://www.pntrs.com/t/P0dFREFHQj1GRz9DQw?sid=[[subid]]

Premiere Incentive - Add [[subid]] after &subid=

before: http://www.premiereincentive.com/Click.aspx?publisher_id=4224&campaign_id=0000&creative_id=000

after : http://www.premiereincentive.com/Click.aspx?publisher_id=4224&campaign_id=0000&creative_id=000&subid=[[subid]]

Revenue Loop - Add [[subid]] at the end

before: http://login.revenueloop.com/z/0000/CD0000/

after : http://login.revenueloop.com/z/0000/CD0000/[[subid]]

Revenue Universe - Add [[subid]] after &sid=

before: http://publishers.revenueuniverse.com/click.php?affiliate=000&campaign=000&creative=0000

after : http://publishers.revenueuniverse.com/click.php?affiliate=000&campaign=000&creative=0000&sid=[[subid]]

Rextopia - Add [[subid]] at the end

before: http://rextopia.com/z/20105/CD4560/

after : http://rextopia.com/z/20105/CD4560/[[subid]]

Rocket Profit - Add [[subid]] after &affrefer=

before: http://rocketprofit.com/click.php?bid=454&lpid=102441&rid=rp0257

after : http://rocketprofit.com/click.php?bid=454&lpid=102441&rid=rp0257&affrefer=[[subid]]

Silver iNet - Add [[subid]] at the end

before: http://partners.cpacoreg.com/z/00000/CD000/

after : http://partners.cpacoreg.com/z/00000/CD000/[[subid]]

Tarsus Media - Add [[subid]] at the end

before: http://affiliates.tarsus-media.com/z/000/CD00/

after : http://affiliates.tarsus-media.com/z/000/CD00/[[subid]]

The Affiliated - Take out the garbage at the end (&dp=0&l=0&p=0) and add [[subid]]

before: http://oscartracking.com/ez/dyomrcyoxm/

after : http://oscartracking.com/ez/dyomrcyoxm/[[subid]]

ThinkAction - Add [[subid]] at the end

before: http://network.thinkaction.com/z/0000/CD0000/

after : http://network.thinkaction.com/z/0000/CD0000/[[subid]]

Traffic Venue Direct - Add [[subid]] at the end

before: http://trafficvenuedirect.com/z/0000/CD0000/

after : http://trafficvenuedirect.com/z/0000/CD0000/[[subid]]

WebJamAds - Add [[subid]] at the end

before: http://affiliates.webjamads.com/z/0000/CD000/

after : http://affiliates.webjamads.com/z/0000/CD000/[[subid]]

Xy7.com - Add [[subid]] at the end

before: http://publishers.xy7.com/z/48249/CD5519/

after : http://publishers.xy7.com/z/48249/CD5519/[[subid]]

forcing javascript to abort - stop javascript execution at any time

JavaScript 7 Comments »

How do we abort JavaScript execution at any instance even inside a loop.

Create a function with a name jsexit or jsabort
and have this as its code

function javascript_abort()
{
   throw new Error('This is not an error. This is just to abort javascript');
}

instead of the error string which i have given you can give any string you want. This is really working well for me.

call it anywhere like javascript_abort()
for example

// assume that you have this code inside a nested function.
for(var i=0;i<10;i++)
{
     if(i==5)javascript_abort();
     alert(i);
}
//so at any place it will stop the execution.

But in IE browsers you will see an yellow exclamation to indicate that there is an error in the javascript.

Otherwise every thing is perfect i believe. In other browsers this will not appear. If you have enabled error reporting add-on for firefox then it would show a graphic notification. that too is not at all a problem.

If anybody (the users) clicks the yellow exclamation in IE they see this string as error message ‘This is not an error. This is just to abort javascript’.

But still i need an option to exit javascript execution without making IE or any other browsers that an error has occured when a new error has been thrown.

I would like to have comments, suggestion and objections about this because i would like to know what people think about this.

Entries RSS