Tuesday, September 01, 2009

Dynamically setting the height of an iframe

This is reposted from blog.pixelmedia.com.


Recently, we had a situation that required us to pull in some content from one server to another using an iframe. Generally, this is something we would try to avoid, but we needed to pull some data from a new .NET application into a legacy ColdFusion application.

Unfortunately, the height of the page being pulled in would vary wildly. This led to a fairly disappointing experience where the page was either far too long, or content in the iframe was cut off and the user had to scroll within the iframe to see everything.

We came up with what we thought might be an interesting solution. If the page loading inside of the iframe (the child page) could calculate its height, and somehow let the parent page know, the parent page should be able to reset the height of the iframe.

With a little inspiration, we came up with a pretty neat solution that we’d like to share. Our solution requires that you have the ability to edit the code of both the parent and child pages.

The child page being loaded into the iframe will simply reset the location of the parent page, and include a hash with the height of itself.



<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.js"></script>
<script>
var parentUrl = "http://kingston/other/test/iframe-outside.html";

setHash = function() {
parent.location = parentUrl + "#" + $('body').height();
}();
</script>

We’re using jQuery here to easily get the height of the <body> tag.

On the parent page that includes the iframe, we’ll again use jQuery and write a small function that gets the height from the hash in the URL, and uses that to reset the height of the iframe.

function setHeight() {
var newHeight = parseInt(location.hash.substring(1)) + 50;
$('#hashFrame').attr('height', newHeight);
}

We ran into a bit of an issue: the page we were loading was taking a few seconds to load, and we didn’t want to set our height on the iframe until the content within the iframe had finished loading (and it had a chance to set the proper height to the url hash).

More jQuery to the rescue! The jQuery .load() method allowed us to call our setHeight() function after the iframe had finished loading.

$('#hashFrame').load( function() {
setHeight();
});

Putting it all together gave us a great way to use our new application inside our legacy application, and make it faily seamless to the end user.

Tuesday, May 05, 2009

Installing Joomla

When working with JDMConcept I had problem uploading the files. I was using dodo mobile wireless broadband with just 1 GB data allowance plan so uploading about 12,836 files (7,070 folders) i.e about 40mb was nightmare. So I had to find other ways. Once simple solution was download the archived(compressed) Joomla file directly to the server and decompress it there. Then upload the templates only and add required components, plugins and modules. Easy in theory but practically its tricky. Below I have listed the methods that I have used.

1st Method: Using "JoomlaStart"
1. Download it from http://extensions.joomla.org/extensions/tools/site-management-tools/610/details

"JoomlaStart is a tool that will help you install/upgrade Joomla software much faster just by uploading one file on your server and running it! V1.2 release changes: - added a fix for permissions problems, so you may try to install Joomla by simulating a ftp upload process - you can install now Joomla from your local server, this in case your provider does't allow to use fopen() function remotelly to get the package - for the ftp mode we added an automatic permission changer for the required directories! If you encountered any problems in using this tool please use our forums at http://www.joomlaplug.com/Forum/ ! We will try to help you the best we can!"

2. It has 2 files Joomla.Start.php & ver.txt. Update ver.txt with the link of joomla file to be downloaded.
3. Upload 2 files to the web server.
4. Run Joomla.Start.php and follow the instruction.

Ur Joomla will be ready to be installed.
Upload the template & any other required files to the server using FTP and you are ready.

That time it didnt work as expected for me as there was some issues with the permision in the server..

2nd Method: Installing Joomla with remote Shell Access

I had a SSH previleges on the web server so I started SSH client (bitvise tunnelier/putty).
1.
CD /var/www/html/jdmconcept/

This is there my site goes..( it may be different for other..)

2. Download the joomla file to the server
WGET http://joomlacode.org/gf/download/frsrelease/9910/37907/Joomla_1.5.10-Stable-Full_Package.tar.gz

you should have
Joomla_1.5.10-Stable-Full_Package.tar.gz file in /var/www/html/jdmconcept/

3. Now decompress the file
gunzip 'Joomla_1.5.10-Stable-Full_Package.tar.gz'
tar -xvf 'Joomla_1.5.10-Stable-Full_Package.tar'

gunzip will uncompress the Gzip archive. This will leave you with the Tar achive: Joomla_1.5.10-Stable-Full_Package.tar.
You want to uncompress this too so so you use tar -xvf.
Regarding -xvf: x if for extract, v is for verbose, and f is for file


Now joomla is ready to Install.

Finally I successfully installed JDMConcept in less than an hour.

I found out later some more methods to install Joomla easily to the server.

Hope it has help you for your Joomla Project.

Friday, March 13, 2009

How to Uninstall Office Genuine Advantage Notifications (KB949810)

Yesterday, My Vista said new important updates are available and I let it update without knowing what it was. Then after restarting I get an error message "This copy of Microsoft Office you are using is not genuine. We apologize for the interruption. The Microsoft Office program has not passed validation. For more details and to identify the most appropriate way to obtain a genuine copy of Microsoft Office, click More Info.

Bloody hell, it came with the laptop and frankly I don’t know. Anyway I don’t have right now any job and have just money to survive for 2 months. Need to find the job within that period and quick. Well that is another story.

Back to the point, I found it was Microsoft latest released office update KB9810 also known as OGA (Office Genuine Advantage). I tried to uninstall the normal way but it didn’t show under "Control Panel", "Add Remove Programs" list even if "Show Updates" checkbox was ticked.

Doing some research, I found:
“According to the Microsoft Director of Genuine Software Initiative this OGA validation process was designed catch the users of non-genuine Office products. Users will receive a pop-up dialog box alerting them their Microsoft Office software is not genuine. The customer will receive this dialog box the first time they open an Office application every day, and again 2 hours later for next month. Users can also receive information on how to learn more about the issue if they click more info link. Eventually Microsoft wants illegal users to acquire genuine copy of Microsoft Office. After receiving these dialogs box notifications for 30 days, Office applications will be marked with a visual reminder that the copy of Office is NOT GENUINE. Both the dialog box and/or the visual reminder will disappear once the customer gets genuine Office and/or uninstalls the non-genuine Office products. None of the visual cues presented will impair a customer from accessing their data or preparing documents.”
Read more at http://en.wikipedia.org/wiki/Office_Genuine_Advantage

After being nagged by the message, I researched for the solution to stop the message. I figured out 3 solutions and 3rd solution worked for me. Go ahead and try them:

Solution 1:
Simply RESTORE to last well known good working restore point before Feb,10th 2009.

Revert back to previous state, If you have a full backup you can restore from your good copy of the backup and remember to decline that update (KB949810) and not install it anywhere again in future because its optional "voluntary Microsoft update".

Solution 2:
  1. Open your computer
  2. Write in the address bar:%SystemRoot% / System32
  3. Menu, select "Tools" and then "Folder Options ..." tab and "View" is selected, make sure that "Show hidden files and folders" and uncheck "Hide extensions for known file types" then press "OK"
  4. Find all files that start with OGA (find files with the extension. Dll and. Exe) and rename the file as a substitute. Old
  5. Check if this is in the same folder as the file and rename WgaTray.exe to WgaTray.old and OGAAddin.dll to OGAAddin.old
  6. Replace display options files as they were initially - See section 3 (optional)
  7. Restart your PC


Solution 3:
  1. Run this DOS command at C:\>
  2. MsiExec.exe /uninstall {B148AB4B-C8FA-474B-B981-F2943C5B5BCD}


You will be prompted if you are sure you want to uninstall. Click ‘Yes’
This will uninstall the OGA notifier 1.7.0105.35.0.

This solution worked for my Vista and may be it will work for your XP too.

Happy computing!

Monday, January 05, 2009

Simplicity and extensibility are the main reasons why PHP became the favourite dynamic language of the Web. In the last decade, PHP has developed from a niche language for adding dynamic functionality to small websites to a powerful tool making strong inroads into large-scale Web systems.

Below I present 30 useful PHP classes and components that you can use to test, develop, debug and deploy your PHP applications. Let me know if I missed anything or if you have something to add.


Database


Creole


Creole is a database abstraction layer for PHP5. It abstracts PHP’s native db-specific API to create more portable code while also providing developers with a clean fully object-oriented interface based loosely on the API for Java’s JDBC. Creole was originally created as a sub-project of Propel to meet specific needs that none of the available abstraction layers were able to address in any satisfactory way.

LINQ for PHP

LINQ is a component that adds native data querying capabilities to PHP using a syntax reminiscent of SQL. It defines a set of query operators that can be used to query, project and filter data in arrays, enumerable classes, XML, relational database, and third party data sources.

ADOdb

ADOdb Database Abstraction Library for PHP. It supports MySQL, PostgreSQL, Interbase/Firebird, Informix, Sybase SQL Anywhere, Oracle, MS SQL 7 and 2000, SAP DB, Sybase, DB2, FrontBase, Foxpro, Access, Netezza, LDAP, ODBTP, ADO, and generic ODBC. It also features portable database creation, database-backed session support (with encryption), SQL performance monitoring and database health checks.

Propel

Propel is an Object-Relational Mapping (ORM) framework for PHP5. It allows you to access your database using a set of objects, providing a simple API for storing and retrieving data.

Doctrine

Doctrine is a tool for object-relational mapping in PHP. It sits on top of PDO and is itself divided into two main layers, The DBAL and the ORM. The Doctrine ORM is mainly build around the ActiveRecord, Data Mapper and Metadata Mapping patterns.

PHPillow

PHPillow is an object orientated wrapper for CouchDB.


Development


phpDocumentor


phpDocumentor is the current standard auto-documentation tool for the php language. Similar to Javadoc, and written in php, phpDocumentor can be used from the command line or a web interface to create professional documentation from php source code. phpDocumentor has support for linking between documentation, incorporating user level documents like tutorials and creation of highlighted source code with cross referencing to php general documentation.

HTML Purifier

HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C’s specifications.

PHP CodeSniffer

PHP CodeSniffer is a PHP5 script that tokenises and “sniffs” PHP code to detect violations of a defined set of coding standards. It is an essential development tool that ensures that your code remains clean and consistent. It can even help prevent some common semantic errors made by developers.

GeSHi

GeSHi is a generic syntax highlighter for PHP that takes any source code and highlights it in XHTML and CSS. It features case-sensitive or insensitive highlighting, auto-caps/non-caps of any keyword, an unlimited scope for styling, the use of CSS in which almost any aspect of the source can be highlighted, the use of CSS classes to massively reduce the amount of output code, function-to-URL capabilities, line numbering, and much more.


Unit Testing


PHPUnit


To make code testing viable, good tool support is needed. This is where PHPUnit comes into play. It is a member of the xUnit family of testing frameworks and provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results.

SimpleTest

Unit testing, mock objects and web testing framework for PHP built around test cases. If you know JUnit/JMock or some of the PHPUnit clones this will need no explanation. Includes a native web browser for testing web sites directly.

PHPSpec

PHPSpec allows you to write executable examples reflecting specifications of the desired behaviour of the source code being described. You can write code examples which are repeatable, this means you write an example and may repeat it as often as you wish to ensure the implementation code it relates to continues to abide by the example.


Debugging


PHP Debug


During both the development and deployment phases, developers require a consistent stream of diagnostic information in order to determine whether the application is working as intended. The functionality of the PHP Debug component can be used to write debug messages and measure the execution time.

dBug

dBug is the PHP version of ColdFusion’s cfdump. It outputs coloured and structured tabular variable information and has the ability to force certain types of output.


Deployment


Phing


Phing it’s a project build system based on Apache Ant. You can do anything with it that you could do with a traditional build system like GNU make, and its use of simple XML build files and extensible PHP task classes make it an easy-to-use and highly flexible build framework.

Xinc

Xinc is a continuous integration server written in PHP 5. It has built-in support for Subversion and Phing (and therefore PHPUnit), and can be easily extended to work with alternative version control or build tools.


Security


Securimage


Securimage is an open-source free PHP CAPTCHA library for generating complex images and CAPTCHA codes to protect forms from spam and abuse. It can be easily added into existing forms on your website to provide protection from spam bots. It can run on most any web server as long as you have PHP installed, and GD support within PHP.

Scavenger

Scavenger is an open source real-time vulnerability management tool. It helps you respond to vulnerability findings, track vulnerability findings, review accepted or false-positive answered vulnerabilities, and not ‘nag’ you with old vulnerabilities.

PHP Security Scanner

PHP Security Scanner is a tool written in PHP intended to search PHP code for vulnerabilities. MySQL DB stores patterns to search for as well as the results from the search. The tool can scan any directory on the file system.

PHPIDS

PHPIDS (PHP-Intrusion Detection System) is a simple to use, well structured, fast and state-of-the-art security layer for your PHP based web application. The IDS neither strips, sanitizes nor filters any malicious input, it simply recognizes when an attacker tries to break your site and reacts in exactly the way you want it to.


User Authentication


phpGACL


phpGACL is an set of functions that allows you to apply access control to arbitrary objects (web pages, databases, etc) by other arbitrary objects (users, remote hosts, etc). It offers fine-grained access control with simple management, and is very fast.


XML and PHP


SimplePie


SimplePie is a very fast and easy-to-use class, written in PHP, that puts the “simple” back into “really simple syndication”. Flexible enough to suit beginners and veterans alike, SimplePie is focused on speed, ease of use, compatibility and standards compliance.

PHP Universal Feed Generator

This package can be used to generate feeds in either RSS 1.0, RSS 2.0 or Atom formats.


Image Handling


WideImage


WideImage is an object-oriented library for image manipulation, written in PHP 5. It’s a pure-PHP library and doesn’t require any external libraries apart from the GD2 extension.


Graphs and Charts


pChart


pChart is a PHP class oriented framework designed to create aliased charts. Most of todays chart libraries have a cost, our project is intended to be free. Data can be retrieved from SQL queries, CSV files, or manually provided. Focus has been put on rendering quality introducing an aliasing algorithm to draw eye candy graphics.

JpGraph

JpGraph can be used to create numerous types of graphs either on-line or written to a file. JpGraph makes it easy to draw both “quick and dirty” graphs with a minimum of code as well as complex graphs which requires a very fine grained control. The library assigns context sensitive default values for most of the parameters which minimizes the learning curve.

PHP Google Charts API

The Google Chart API returns a PNG-format image in response to a URL. Several types of image can be generated: line, bar, and pie charts for example. For each image type you can specify attributes such as size, colors, and labels.

PHP/SWF Charts

PHP/SWF Charts is a simple, yet powerful PHP tool to create attractive web charts and graphs from dynamic data. Use PHP scripts to generate or gather the data from databases, then pass it to this tool to generate Flash (swf) charts and graphs.

Open Flash Chart

This is an object oriented library for live-manipulating Open Flash Chart.


Template Engines


Savant


Savant is a powerful but lightweight object-oriented template system for PHP. Unlike other template systems, Savant by default does not compile your templates into PHP; instead, it uses PHP itself as its template language so you don’t need to learn a new markup system. Savant has an object-oriented system of template plugins and output filters so you can add to its behaviour quickly and easily.

Smarty

Smarty is a template engine for PHP. More specifically, it facilitates a manageable way to separate application logic and content from its presentation. One of the unique aspects about Smarty is the template compiling. This means Smarty reads the template files and creates PHP scripts from them. Once they are created, they are executed from then on. Therefore there is no costly template file parsing for each request.

PHPTAL

PHPTAL is a templating engine for PHP5 that implements brilliant Zope Page Templates syntax. PHPTAL is fast thanks to compiled templates and fine-grained caching. Makes it easy to generate well-formed XML/XHTML.


Documents


TCPDF


TCPDF is a PHP class for generating PDF documents without requiring external extensions. TCPDF supports all ISO page formats and custom page formats, custom margins and units of measure, UTF-8 Unicode, RTL languages, some HTML code, barcodes, TrueTypeUnicode, TrueType, Type1 and encoding, JPEG, GIF and PNG images, graphic functions, bookmarks, JavaScript, forms, page compression, and encryption.

PHP Excel

Create Excel documents in PHP. This component provides a set of classes for the PHP programming language, which allow you to write to Excel 2007 files and read from Excel 2007 files. This project is built around Microsoft’s OpenXML standard and PHP.