Jaslabs: High performance Software

High Performance Software

Archive for the 'microsoft' Category

PHP library for Microsoft AJAX

By Justin Silverton

Microsoft has released their AJAX library package for non-windows systems which contains a complete set of client JavaScript components that are included in the full ASP.NET AJAX installation. Developers over at Codeplex have developed a library that allows you to integrate your PHP applications with this package.

requirements

  • PHP 5.2 — 5.2 is required for json_encode/json_decode; For earlier versions, you will need to install php-json

How to install

  1. Download the PHP library from codeplex here
  2. Download the Microsoft AJAX Library here
  3. After extracting both of these, place all the files from the Microsoft Ajax library in a directory called “MicrosoftAjaxLibrary”

Example

The following is a simple example that demonstrates a simple ajax transmission using the microsoft libraries.

(hello.htm)

<html>
<head>
<title>Hello, World!</title>
<script type="text/javascript" src="../../MicrosoftAjaxLibrary/MicrosoftAjax.js"></script>
<script type="text/javascript" src="HelloService.php/js"></script>
</head>
<body>
Name: <input id="name" type="text" /> <input type="button" value="Say Hello" onclick="button_click(); return false;" />
<br />
Response from server: <span id="response"></span>
</body>
<script type="text/javascript">
function button_click() {
HelloService.SayHello($get('name').value, function (result) { $get('response').innerHTML = result; });
}
</script>
</html>

(HelloService.php)

<?php

require_once '../../dist/MSAjaxService.php';

class HelloService extends MSAjaxService
{
function SayHello($name)
{
return "Hello, " . $name . "!";
}
}

$h = new HelloService();
$h->ProcessRequest();

?>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • Slashdot
  • StumbleUpon
  • Technorati
1 comment

Secret Internet Explorer behaviors

By Justin Silverton

Many people don’t realize that there is a way to store up to 100K (1mb per domain) of data within Internet Explorer (supported by 5.5 and above).

These behaviors can be used to preserve information in the browser’s history, in favorites, in an XML store, or directly within a Web page saved to disk. When a user returns to a persisted page, the state of the page can be restored. By allowing information to safely reside on the client, fewer server transactions are required. Custom start pages and Web applications prosper because information can continue to exist without the paternal support of the server, or repeated server queries. A Web page can remain interactive to a degree, after the connection with the host has been severed, by persisting required information on the client.

Code Example

Below is an code example of how to use these behaviors. After typing some text into the box and clicking save, you will now be able to come back to this page and click load, and it will be loaded from the the IE internal persistence store.

<STYLE>
.storeuserData {behavior:url(#default#userData);}
</STYLE>
<SCRIPT>
function fnSaveInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.setAttribute("sPersist",oPersist.value);
oPersist.save("oXMLBranch");
}
function fnLoadInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.load("oXMLBranch");
oPersist.value=oPersist.getAttribute("sPersist");
}
</SCRIPT>
<FORM ID="oPersistForm">
<INPUT CLASS="storeuserData" TYPE="text" ID="oPersistInput">
<table>
<td><INPUT TYPE="button" VALUE="Load" onclick="fnLoadInput()"></td>
<td><INPUT TYPE="button" VALUE="Save" onclick="fnSaveInput()"></td>
</table>
</FORM>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • Slashdot
  • StumbleUpon
  • Technorati
4 comments

How to compile php scripts in ASP.net

By Justin Silverton

Phalanger is a new PHP implementation introducing the PHP language into the family of compiled .NET languages. It provides PHP applications an execution environment that is fast and extremely compatible with the vast array of existing PHP code. Phalanger gives web-application developers the ability to benefit from both the ease-of-use and effectiveness of the PHP language and the power and richness of the .NET platform taking profit from the best from both sides.

Using .net classes

Phalanger supports full interoperability with .NET. This means that you can access almost any .NET classes (written in C#, VB.NET and other managed languages) from your PHP applications. This requires adding several features to the PHP language that allows you to use .NET features like namespace (which are used to organize .NET classes) and generics (used for specifying type parameters of methods and classes). These language extensions are called PHP/CLR and are designed to retain dynamic PHP behavior (for more details see PHP/CLR Language Extensions).

Thanks to the PHP/CLR extensions you can easilly integrate existing PHP and ASP.NET applications, or use classes available for .NET Framework in your PHP application. This gives you for example the possibility to modify open-source PHP applications to use the standard ASP.NET 2.0 Membership (user management) system, which is very powerfull option for integrating web applications.

You can also develop new applications using PHP with the PHP/CLR language extensions and combine PHP and other .NET languages (for example C#) in one project. This gives you the possibility to leverage of the C# strictness in the application logic layer where the safety and strict object orientation is important, but use the simplicity and efficiency of PHP language for developing the presentation layer.

Features

  • compiles PHP to the MSIL (Microsoft Intermediate Language), which is byte-code assembly used by the .NET CLR.
  • Improves execution speed (because of just-in-time compilation)
  • use any .NET object in a PHP application
  • Visual studio integration: supports syntax highlighting for PHP source files and debugging

Benchmarks

How much faster is it than the standard version of PHP?

Download

The latest version of Phalanger can be found Here

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • Slashdot
  • StumbleUpon
  • Technorati
4 comments

5 cool things you can do with windows and php

by Justin Silverton

Many PHP examples out there are designed for a linux/unix operating system. I am going to give some examples of some interesting functionality that only works with php running in a windows environment (IIS or apache).

1) Eject the CD-ROM

//create an instance of Windows Media Player
$mp = new COM("WMPlayer.OCX");
//ejects the first cd-rom on the drive list
$mp->cdromcollection->item(0)->eject();

2) Read and write from/to the registry

function registry_read($folder, $key)
{
$WshShell = new COM("WScript.Shell");

$registry = "HKEY_LOCAL_MACHINE\SOFTWARE\\" . $folder . "\\" . $key;
$result = $WshShell->RegRead($registry);

return($result);
}

$key = registry_read("RegisteredApplications","Firefox");

parameters:

  • Folder name - (key path past HKEY_LOCAL_MACHINE\SOFTWARE\\)
  • key - the key name to read from

function registry_write($folder, $key, $value,$type="REG_SZ")
{
$WshShell = new COM("WScript.Shell");

$registry = "HKEY_LOCAL_MACHINE\SOFTWARE\\" . $folder . "\\" . $key;
$result = $WshShell->RegRead($registry);
$result = $WshShell->RegWrite($registry,$value, $type);

return($result);
}

parameters:

  • Folder name - (key path past HKEY_LOCAL_MACHINE\SOFTWARE\\)
  • key - the key name to write to
  • value - value that will be written to the key
  • type - key type (default: REG_SZ)

3) register and un-register phpscripts as a windows service

# registering a service

win32_create_service(array(
’service’ => ‘myservice’, # the name of your service
‘display’ => ’sample dummy PHP service’, # description
‘params’ => ‘c:\path\to\script.php run’, # path to the script and parameters
));

# un-registering a service

win32_delete_service(’myservice’);

# code run as a service

if ($argv[1] == 'run') {
win32_start_service_ctrl_dispatcher('myservice');

while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {
# write script here
# as a general rule, keep it below 30 seconds through each loop iteration
}
}

This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:

  • Download the main library (it’s included in the main PECL extension download from php.net) here
  • extract php_win32service.dll to your ext directory (where your php extension .dlls are located)
  • add the following line to your php.ini: extension=php_win32service.dll

4) print pages/data

#this is an example function that will format a host/printer name, for printing to shared printers over the network

function getPrinter($host,$SharedPrinterName) {
return “\\\\”.$host.”\\”.$SharedPrinterName;
}

#this opens the printer
$handle = printer_open(getPrinter(”my computer 2″,”my printer”));

An extensive list of functions for printing can be found here

#this is possible in *nix as well. Here is some example code

function lpr($string,$printer) {
$prn=(isset($printer) && strlen($printer))?”$printer”:C_DEFAULTPRN ;
$CMDLINE=”lpr -P $printer “;
$pipe=popen(”$CMDLINE” , ‘w’ );
if (!$pipe) {print “pipe failed.”; return “”; }
fputs($pipe,$string);
pclose($pipe);
}

This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:

  • Download the main library (it’s included in the main PECL extension download from php.net) here
  • extract php_printer.dll to your ext directory (where your php extension .dlls are located)
  • add the following line to your php.ini: extension=php_printer.dll

5) List the current system processes

# list all the current processes running on the system

print_r(win32_ps_list_procs());

other related commands:

# Retrieves statistics about the global memory utilization
print_r(win32_ps_stat_mem());

# Retrieves statistics about the process with the process id pid (if no process id is given, the current process will be used)
print_r(win32_ps_stat_proc(int processid));

This uses the windows API Service DLL, which is not enabled by default. Here is how to install it:

  • Download the main library (it’s included in the main PECL extension download from php.net) here
  • extract php_win32ps.dll to your ext directory (where your php extension .dlls are located)
  • add the following line to your php.ini: extension=php_win32ps.dll
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • Slashdot
  • StumbleUpon
  • Technorati
12 comments

Xenix: The Microsoft Linux

By Justin Silverton

History of Xenix

Microsoft created their own variant of the unix operating system called xenix. They purchased a license for Version 7 Unix from AT&T in 1979, and announced on August 25, 1980 that it would make it available for the 16-bit microcomputer market.

Xenix varied from its 7th Edition origins by incorporating elements from BSD, and soon possessed the most widely installed base of any Unix flavour due to the popularity of the inexpensive x86 processor, even though the port created for Tandy Corporation computers proved to be more robust.

Microsoft did not sell Xenix directly to end users; instead, they licensed it to software OEMs such as Intel, Tandy, Altos and SCO, who then ported it to their own proprietary computer architectures. Microsoft Xenix originally ran on the PDP-11; the first port was for the Zilog Z8001 16-bit processor. Altos shipped a version for their computers early in 1982, Tandy Corporation shipped TRS-XENIX for their 68000-based systems in January 1983, and SCO released their port to the Intel 8086 processor in September 1983. A port to the 68000-based Apple Lisa also existed. At the time, Xenix was based on AT&T’s UNIX System III.

Version 2.0 of Xenix was released in 1985 and was based on UNIX System V. An update numbered 2.1.1 added support for the Intel 80286 processor. Subsequent releases improved System V compatibility.

The end of an era

Xenix served as a workhorse for small businesses. It had the following features that many businesses were looking for in an operating system:

  • Simple, small, and stable
  • Unlimited-user licenses
  • Command-line administration

With all of the benefits, Xenix had some major disadvantages. CD-ROMs, PCI, and mice were not supported (or barely functional) and it just barely supported SCSI disks and tapes, or Networking.

Later versions of Xenix did have networking support (and increased hardware support), but by this time, Linux had already started making its way into the business world.

Screenshot

Source: http://en.wikipedia.org/wiki/Xenix

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • Slashdot
  • StumbleUpon
  • Technorati
No comments

Next Page »