Monday, March 10, 2008

Difference Between PHP and PHP CLI

Contrary to popular belief, PHP is not just a web server language. PHP can also be used to create regular programs. PHP can be used to create GUI applications, shell scripts, and even daemons, among other things.

The boon is that all (or most) of the usual PHP libraries are available to your PHP CLI program too. MySQL, XML, etc. It's all (or mostly) still available.



Difference Between PHP and PHP CLI

There are some important differences between server-side PHP and PHP CLI. Here's a list of them:

1. There is no $_GET super global array.
2. There is no $_POST super global array.
3. There is no $_COOKIE super global array.
4. When you do a print, the output goes to the standard output and not a web browser.
5. You can get command line arguments via the $argv variable.
6. You can get the number of command line arguments via the $argc variable.


eg:
<?php
print('ARGC = ' . $argc ."\n\n");
foreach ($argv as $k=>$v) {
print("ARGV[$k] = $v\n");
}
?>

on command line
php test1.php apple orange banana pineapple

output
ARGC = 4

ARGV[0] = test1.php
ARGV[1] = apple
ARGV[2] = orange
ARGV[3] = banana
ARGV[4] = pineapple

Saturday, March 8, 2008

Embed Media Player for web Site

Windows Media Player Object Model Reference

Working in IE6 and IE7

<OBJECT ID="Player" width="0" height="0"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<embed type="application/x-mplayer2" id="Player"
pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/"
width="0" height="0" src="song.mp3"
filename="1.mp3" autostart="False"
showcontrols="True" showstatusbar="False"
showdisplay="False" autorewind="True"></embed>
</object>

Method and Properties :-
Player.playState // to get The State of Player (Play,Pause or stop)
Player.controls.play() //to Play
Player.controls.pause() //to Pause
Player.controls.stop() //to Stop
Player.controls.currentPosition //to get Current Postion of File
Player.currentMedia.duration //to get Length of the file


Please Find More Information : -
http://msdn2.microsoft.com/en-us/library/bb249259(VS.85).aspx
http://msdn2.microsoft.com/en-us/library/bb249259%28VS.85%29.aspx> // for Settings object
http://msdn2.microsoft.com/en-us/library/bb262747(VS.85).aspx // for Media Object
http://msdn2.microsoft.com/en-us/library/bb249349(VS.85).aspx // for Player Object

Friday, March 7, 2008

Apple realease IPhone SDK

As you all know Apple just released there iPhone SDK. I was very excited to see it and see what its capability it.

Here are some notes I have gathered while watching iPhone SDK development videos.

iPhone SDK

Development tools in SDK
  • Xcode is the IDE
    • iPhone Management : Making your iphone for development. TEsting with different version
    • Coding
    • Building and Debugging
    • Analysis
  • Instruments: Debugger/tracing
  • Dashcode: Something related to Web applications. ??????
  • Simulator: Run and debug application without iphone





Core OS/Services: fundamental System Services. LibSystem Library

  • Media: Audio/video/Graphic Technology
  • Graphics
    •  Quartz
    •  Core Animation
    •  OpenGL ES


Cocoa Touch
  •  UIKit framework: For controls/Video/Accelerometer
  •  Addressbook framework
  •  Addressbook UI framework
 
 


*Right now Interface Builder is missing in SDK




I took some screenshot of the demo for reference.














Wednesday, February 27, 2008

Cross domain Ajax call

The JSONP approach is necessitated, as I mentioned by the browsers' SOP (Same-origin policy) which prohibits XMLHttpRequests from crossing domains.

There are three ways to make cross domain calls
1. Using Local Proxy : We send the request to another service side page(like php,jsp etc) that makes a request from the server to the web service. But this ultimately result in double bandwidth and latency
2. Flash : NEED Flash
3. Script tag (JSON with Padding. JSONP approach) injection: I am only left with this approach of creating script tag dynamically and setting src attribute to a web service API call. It can be considered as security risk.

Yahoo Using same approach
Article: http://developer.yahoo.com/common/json.html#callbackparam
Example request: http://api.local.yahoo.com/MapsService/V1/geocode?appid=dantheurer&location=la&output=json&callback=getLocation

Delicious is also using JSONP approach
http://feeds.delicious.com/feeds/json/bob/javascript+hack?jsonp=delicious_callbacks%5B12345%5D

Google also uses same approach. I read it in this thread.
http://groups.google.com/group/Google-Maps-API/browse_thread/thread/1e1cecf679dd7c5a
So, google api also uses JSONP(i.e the same script tag hack) approach

Thursday, February 21, 2008

Genuine Windows Validation Test

Have you ever thought how Microsoft perform test to find weather copy is genuine or not......

good guess!!!!! one and only LOGIC registry :)

Hardest LOGIC they can ever think

they find the Product key from registry and compare with "V2C47-MK7JD-3R89F-D2KXW-VPK3J" if matches
validation fails

then they fixed it:(

BUT by adding another key "FCKGW-RHQQ2-YXRKT-8TG6W-2B7Q8"

then "Q6TD9-9FMQ3-FRVF4-VPF7Y-38JV3"

Finely they come up with solution :(


by keeping and updating database of pirated keys :) LOL

so if you know any single product key which is not in their database you can make your copy original

More info

Handle Active Tab and Screen Capture in IE6 & IE7

SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();

IntPtr activeWindowHandle;
mshtml.IHTMLDocument2 myDoc;
mshtml.IHTMLDocument3 myDoc1;
activeWindowHandle = GetForegroundWindow();
IntPtr myIntptr = activeWindowHandle;
int hwndInt = myIntptr.ToInt32();
IntPtr hwnd = myIntptr;
IntPtr hwnd1 = IntPtr.Zero;
hwnd = GetWindow(hwnd, GW_CHILD);
StringBuilder sbc = new StringBuilder(256);
IEnumerator windows = new SHDocVw.ShellWindowsClass().GetEnumerator();
while (windows.MoveNext())
{
if ((windows.Current is SHDocVw.IWebBrowser2) && ((windows.Current as SHDocVw.IWebBrowser2).HWND.ToString() == activeWindowHandle.ToString()))
{
((windows.Current as SHDocVw.IWebBrowser2).Document as IOleWindow).GetWindow(out hwnd);

if (IsWindowVisible(hwnd))
{
break;
}
}
}
myDoc = ((windows.Current as SHDocVw.IWebBrowser2).Document as mshtml.IHTMLDocument2);
myDoc1 = ((windows.Current as SHDocVw.IWebBrowser2).Document as mshtml.IHTMLDocument3);