Hiding HTML Code from being viewed by End Users.Possible??

I was going through the Google Group - Professional PHP Developers . Thought it would be nice to share them with you all.
The question raised was :

i want to know to how i can hide my html script to proptect my
source code ....
I dont want my html page shd show the source script code...
as if u try in gmail .. to view source code .. it doesn't open ..
And a reply cleared this quite well.

Below ideas might possibly be irrelevant according to how you answer the following question:
Why do you want to hide your source code?
-
Another analogy to what you suggest is for a mason to build a brick wall but insist that it be painted over so no one can see the
order in which they have lain the bricks. It makes the wall uglier so that no one might copy them.
It also devalues the work that went into the wall and no one will ever know what a great mason they are.

Further, gmail does indeed reveal code when you view source. At least in FireFox. I just looked.

There are obfuscators of source but there is not much worth hiding in HTML.
Unless you think you have invented a patentable technology using HTML there isn't any point to hiding it. Is there?
It is not a programming language so you can't really invent methods only arrangements.
It is a display language and becoming a purely content containing language, soon to be replaced completely by XML.

Additionally firefox has an option for view 'rendered source'.
Probably all browsers but definitely FireFox and IE read your code and re-write it before displaying it.
So if I view the rendered source, I would see all your obfuscated code un-obfuscated.
'Rendered source' will show anything written to the document with javascript or otherwise. (in IE it is transcribed into 'MSHTML'.
Which is what many wysiwyg editors use to modify a page when edited within the browser itself.)

If you are lucky enough to have someone 'steal' your html... consider it a compliment and boasting rights for your excellence.

If you code sites for clients it would be considered (I think) unprofessional to obfuscate code as you have written it for them.
They should own it unless you have a specific contract that specifies they have 'licensed or subscribed' usages.
For html it would be bad practise to license or subscript out as they could recieve it in a full clean, exposed form from another
html writer.
And if you write code that is worth stealing... why not share it and offer free use with a linkback to you?

Mainly only amateurs will copy and paste an entire page of code anyway.
It is unlikely they will derive commercial benefit from your ideas directly.

Hope you are quite clear now.

Posted byShyam at 7:15 AM 2 comments  

PEAR DB Extension

While developing an application, most of us use MySQL database as the backend. There might come scenarios when we might need to change the Database system to something else like MaxDB / PostgreSQL / SQLServer /anything else.

Had we used many mysql realted functions in our PHP scripts, it would be difficult to hunt them down and make the neccessary changes, even if the SQL statements involved are going to change. Think, changing every mysql_query(), mysql_fetch_array(), mysql_blabla into maxdb_query() and so on. How hard would it be. I believe most of us would not want to be into such tricky situations. There are simple solutions for these.

PHP Pear packages offer ready made simple solutions, for many of the basic needs. And PEAR DB Extension, is one of most used.
The PEAR DB is a set of classes that provides you with :

  • Database abstraction
  • Advanced Error Handling
  • and more..
Check out this : How to install PEAR and PEAR::DB Extension

Let us discuss how can we use PEAR::DB in our PHP applications.

require_once 'DB.php';
The above statement has to be included in all the files where class is used. Note : The PEAR base directory has to be set in your include_path.

Connecting and Disconnecting from a database

$user = 'foo';
$pass = 'bar';
$host = 'localhost';
$db_name = 'clients_db';

// Data Source Name: This is the universal connection string
$dsn = "mysql://$user:$pass@$host/$db_name";
$db = DB::connect($dsn);

// Disconnect
$db->disconnect();

Querying and Fetching Rows from the Database

$sql = "select * from clients";
$result = $db->query($sql); // Querying the Database
while ($row = $result->fetchRow()) {
// Result row
$id = $row[0];
}




Quick data Retrieval

$numrows = $db->getOne('select count(id) from clients');
// getOne retrieves the first result of the first column from a query

$row = $db->getRow($sql)
// getRow will fetch the first row and return it as an array

$all_client_names = $db->getCol('select name from clients');
// getCol will return an array with the data of the selected column. It accepts the column number to retrieve as the second param.


For much more details about this please goto : http://vulcanonet.com/soft/?pack=pear_tut

It is simple.. Right?

Enjoy.

Posted byShyam at 4:02 PM 1 comments  

You know you've done too much PHP when

You know you've done too much PHP when...

You getting F in English because{

You end sentence with a semicolon;

"You put quotations around your essays";

"You"." connect"." words"." with"." periods";

You end a line with \n.

You group paragraph in {braces}.
}

You express 2 squared in a strange way, pow(2,2).

You insist that 2^2 equals 0.

When solving the cube root of 5 to the 30th decimal, you hope you have bcpow() function. After a while, you kick the chair over and screams at the math teacher because you know that bcpow() does not allow fractional exponents.

You check the labels in the supermarket and tell the manager a variable can't start with a number. $1.99

You echo a ampersand should not appear in middle of two words, but instead, numbers.

You never use the word "say" anymore, "echo" become your best friend.

You wondering if the art class installed GD library.

You ask to go to the bathroom for a var_dump during a art lesson, then you remember that will change the header.

You paint 2 fingers green(or gray) and suppose that sticking them out will comment anything in the right.

You exploded things in the lab and try to sort them like arrays.

You get annoyed when people don't see you as a object in the middle class.

You thank a lot of people after getting a award. "I want to thank my parents who always supported me, and a lot other people, " include('thanks.php');

After inscribed these on a tree:

define(LOVE, 'PHP');

You said that LOVE will never change because it is an constant.

Your friends taking about they don't know what's wrong with their relationship. You suggest them try this :

error_reporting (E_ALL);

Your friends look at you with the WTF look. You said:" DUH! ever read the PHP manual?"

class killnoob implements ChineseKungfu{

function __CONSTRUCT(){
global $noob;
die($noob);
//SUCCESS on killing all the noobs in the world.
}
}
__________________________

Believe me I've got a few of them.

Posted byShyam at 11:53 PM 0 comments