Hiding HTML Code from being viewed by End Users.Possible??
Monday, April 30, 2007
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 myAnd a reply cleared this quite well.
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 ..
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.
Mainly only amateurs will copy and paste an entire page of code anyway.
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?
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
Tags: browser, gmail, html, intellectual-property, security
PEAR DB Extension
Sunday, April 29, 2007
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..
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 Databasewhile ($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
Tags: database, mysql, pear, php
You know you've done too much PHP when
Saturday, April 28, 2007
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
Captcha Images
Whenever a website/webservice goes popular, it attracts more spam content. Automated Scripts are deployed to create many accounts with that Site, and used for Spamming purposes or activities that were not intended to take place there.
Captcha ("Completely Automated Public Turing test to tell Computers and Humans Apart", hey this has been trademarked by CMU) has been able prevent automated software from performing actions which degrade the quality of service of the system, whether due to abuse or resource expenditure. CAPTCHAs are designed to be unreadable by machines.
The above image is Captcha Image. Well let us now how we can make such images, containing Random text.
Steps :
1 ) Create random lines and dots in the background.
2 ) Generate some random text.
3 ) Print each letter of the text into the Image in a random angle (say between -300 to 30o )
4) Save the random text in your Session and then output the image to the browser.
5) When the form is submitted and processed, check whether the text entered by the User and the text in Session Variable are the same.
And thats it. Done.
Now let us look at the PHP Code used to create the above image.
generateCode($characters);Enjoy.
/* font size will be 75% of the image height */
$font_size = $height * 0.4;
$image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */
$background_color = imagecolorallocate($image, 0, 0, 0);
$text_color = imagecolorallocate($image, 230, 210, 150);
$noise_color = imagecolorallocate($image, 70, 70, 180);
/* generate random dots in background */
for( $i=0; $i<($width*$height)/5; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } /* generate random lines in background */ for( $i=0; $i<($width*$height)/350; $i++ ) { imageline($image, mt_rand(10,$width), mt_rand(80,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); } /* create textbox and add text */ $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = (($width - $textbox[4])/2)-35;
$y = (($height - $textbox[5])/2);
for ($i=0;$i<$characters;$i++) { imagettftext($image, $font_size, mt_rand(-25,25), $x+($i*30), $y, $text_color, $this->font , substr($code,$i,1)) or die('Error in imagettftext function');
}
/* output captcha image to browser */
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION['security_code'] = $code;
}
}
$width = isset($_GET['width']) ? $_GET['width'] : '200';
$height = isset($_GET['height']) ? $_GET['height'] : '60';
$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6';
$captcha = new CaptchaSecurityImages($width,$height,$characters);
?>
Posted byShyam at 1:40 PM 0 comments
What is Web 2.0
Web 2.0 .. This has been buzz word in the Internet industry for a couple of years now. Said to be the promising future of the Net, I was really wondering what this was around an year ago. Was this some new kind of technology.. Weird thoughts sprung on me that this might be something like a new language or HTML tags and structure completely changed.. Web 2.0 is nothing but a concept.. No new technologies or development or language or Server side scripting.
Web 2.0 - this phrase was coined by O'Reilly Media in 2004. The Web content will be contributed by the users themselves instead of publishers pushing content through their sites. In other words, Web 2.0 is User Generated Content.
According to Tim O'Reilly, Web 2.0 is about business embracing the web as a platform and utilising its strengths (global audiences, for example). O'Reilly considers that Eric Schmidt's abridged definition, don't fight the internet, encompasses what Web 2.0 is about - building applications and services around the unique features of the Internet, as opposed to building applications and expecting the Internet to suit as a platform - effectively fighting the internet.
By leaving the content to the users, the Web Developers need to concentrate only on the Business Models and Tools to assist the users.
All the business domains are embracing Web 2.0, from Social Networking (Purely Web 2.0) to E-commerce (Ebay) to Instant messaging and Communication (Skype)..
In 1999-2000, everyone were busy at dominating the Internet, trying to make revenue out of it, and it just fell down, leading to closure and bankruptcy of Web firms. But now everyone (yep me too..) this is were Websites can be moneymakers. NewsCorp bought MySpace for $580 mn.
Some of the popular Web 2.0 Sites are :
Wikipedia.org
MySpace.com (Social Networking)
Del.icio.us (Social Bookmarking)
Ebay (User generated Ecommerce)
Digg (User Generated Web News)
Flickr (Social Photosharing)
StumbleUpon
Blogging sites (This one), Blogspot, Wordpress ...
Basecamp (Project Management)
Orkut , Facebook, Tagged, hi5, LikedIn, Fropper .. the list just goes on..
Posted byShyam at 12:32 PM 0 comments
Welcome to W3Dreams
Thursday, April 19, 2007
Welcome W3Dreams Blog. Promising the Web Developers and Designers a great resource for your business.
Doesn't matter whether you are a Newbie or a Experienced. We always have things to share with you. Tips and Tricks on HTML, CSS, Javascript, Server-side scripting Database related issues and everything else.
Frameworks to Tools and Utilities.. Useful websites to developer tips...
Let us have a good time here.
Posted byShyam at 3:33 PM 0 comments