A PHP compatible MD5 function in c#
By Justin Silverton
The following is a function written in c# that will return a PHP compatible MD5 hash of a file, given the name. The equivalent function in PHP is md5_file().
public string MD5Hash( string sFilePath )
{
try
{
MD5CryptoServiceProvider md5Provider
= new MD5CryptoServiceProvider();
FileStream fs
= new FileStream(sFilePath, FileMode.Open, FileAccess.Read);
Byte[] hashCode
= md5Provider.ComputeHash(fs);
string ret = "";
foreach (byte a in hashCode)
{
if (a<16)
ret += "0" + a.ToString ("x");
else
ret += a.ToString ("x");
}
fs.Close();
return ret;
}
catch( Exception ex )
{
throw ex;
}
}
5 ways to extend Firefox tabs
By Justin Silverton
The following are 5 Firefox extensions that will extend tab functionality.
1) IE tabs

This is a great tool for web developers that allows you to view web pages in Internet Explorer within a firefox tab.
Download Here
2) Informational tab

This extension provides thumbnail-style preview for each tab, does progress meter, and indicates unread status.
Download Here
3) Tab Mix Plus

Tab Mix Plus enhances Firefox’s tab browsing capabilities. It includes such features as duplicating tabs, controlling tab focus, tab clicking options, undo closed tabs and windows, plus much more. It also includes a full-featured session manager with crash recovery that can save and restore combinations of opened tabs and windows.
Download Here
4) TabSidebar
Features:
- Provides navigation options for each tab including history, stop and reload.
- Allows you to move tabs around with drag and drop.
- You can drop links, local files and bookmarks anywhere you like in the tab list.
- Displays the security status of tabs.
- Automatically refreshes the tab preview whenever the page changes.
- Lets you hide the main tab bar when the sidebar is open.
- Bidirectional support making the sidebar work correctly in right-to-left languages.
- Works well with other tab-related extensions allowing you to use their context menu additions from the sidebar.
Download Here
5) Tab Effect

This adds a tab switching cube effect to Firefox.
Download Here
1 commentHow to create a zip archive using PHP
by Justin Silverton
The following is a library that allows you to generate zip file archives using php.
<?php
include("ziplib.php");
$zipfile = new Ziplib;
$zipfile->zl_add_file("This is a test file","path/to/file","g9");
//You can stream the ZIP file or write it in a file on your server
header("Content-type: application/zip");
header("Content-Disposition: attachment; filename=\"testfile.zip\"");
echo $zipfile->zl_pack("zip file comments");
?>
This script will dynamically create a zip archive using the files specified with zl_add_file and output it to the browser (the final zip file will be named: testfile.zip).
Options
zl_add_file allows you to specify the compression level of the file file that will be added to the archive.
- n (none)
- b (bzip)
- g (gzip)
Download
The php zip library can be downloaded Here
11 commentsHow to create Microsoft Office Documents with PHP
By Justin Silverton
There are two main ways to build Excel, Word, and PowerPoint documents using PHP. The first is by using the COM library (only if you are using a Windows server) and the other is by using a more standardized approach such as HTML or CSV.
Dynamically creating a word document:
<?php
$word = new COM("word.application");
$word->Visible = 0;
$word->Documents->Add();
$word->Selection->PageSetup->LeftMargin = '2"';
$word->Selection->PageSetup->RightMargin = '2"';
//Setup the font
$word->Selection->Font->Name = 'Verdana';
$word->Selection->Font->Size = 8;
//Write some text
$word->Selection->TypeText("This is a test document");
//Save the document as DOC file
$word->Documents[1]->SaveAs("c:\\docs\\test1.doc");
//quit and release COM resources
$word->quit();
$word->Release();
$word = null;
?>
Dynamically creating an excel document
<?php
$excel = new COM("excel.application");
$excel->Visible = 0;
//Create a new workbook
$wkb = $excel->Workbooks->Add();
$sheet = $wkb->Worksheets(1);
//This code adds the text 'myvalue' on row 2, column 4
$sheet->activate;
$cell = $sheet->Cells(2,4);
$cell->Activate;
$cell->value = 'myvalue';
$wkb->SaveAs("C:\docs\test.xls");
//close and free resources
$wkb->Close(false);
$excel->Workbooks->Close();
$excel->Quit();
?>
Dynamically creating a powerpoint presentation
<?php
$powerpnt = new COM("powerpoint.application");
//Creating a new presentation
$pres=$powerpnt->Presentations->Add();
//Adds the first slide. "12" means blank slide
$pres->Slides->Add(1,12);
//Adds another slide. "10" means a slide with a clipart and text
$pres->Slides->Add(2,10);
//Adds a textbox
$pres->Slides[1]->Shapes->AddTextbox(1,20,50,300,40);
//Save the document as PPT file
$powerpnt->Presentations[1]->SaveAs("C:\Docs\test1.ppt");
//free resources and quit powerpoint
$powerpnt->quit();
?>
How to find Word, Excel, and Powerpoint functions
The following will show you all of the functions that are possible when accessing Microsoft Office components through php:

- Open Microsoft Word, Excel, or Powerpoint
- Press Alt+F11 to start the Visual Basic Editor
- Press F2
- Find “ThisDocument” on the left. In the right frame you’ll see the available variables and functions that can be used with the COM object.
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
4 comments




