HTML5 New Elements

New Elements in HTML5

The internet has changed a lot since HTML 4.01 became a standard in 1999.

Today, some elements in HTML 4.01 are obsolete, never used, or not used the way they were intended to. These elements are removed or re-written in HTML5.

To better handle today’s internet use, HTML5 includes new elements for better structure, better form handling, drawing, and for media content.

New Semantic/Structural Elements

HTML5 offers new elements for better structure:

Tag Description
<article> Defines an article
<aside> Defines content aside from the page content
<bdi> Isolates a part of text that might be formatted in a different direction from other text outside it
<command> Defines a command button that a user can invoke
<details> Defines additional details that the user can view or hide
<summary> Defines a visible heading for a <details> element
<figure> Specifies self-contained content, like illustrations, diagrams, photos, code listings, etc.
<figcaption> Defines a caption for a <figure> element
<footer> Defines a footer for a document or section
<header> Specifies an introduction, or a group of navigation elements for a document
<hgroup> Groups a set of <h1> to <h6> elements when a heading has multiple levels
<mark> Defines marked/highlighted text
<meter> Defines a scalar measurement within a known range (a gauge)
<nav> Defines navigation links
<progress> Represents the progress of a task
<ruby> Defines a ruby annotation (for East Asian typography)
<rt> Defines an explanation/pronunciation of characters (for East Asian typography)
<rp> Defines what to show in browsers that do not support ruby annotations
<section> Defines a section in a document
<time> Defines a date/time
<wbr> Defines a possible line-break

New Media Elements

HTML5 offers new elements for media content:

Tag Description
<audio> Defines sound content
<video> Defines a video or movie
<source> Defines multiple media resources for <video> and <audio>
<embed> Defines a container for an external application or interactive content (a plug-in)
<track> Defines text tracks for <video> and <audio>

The new <canvas> Element

Tag Description
<canvas> Used to draw graphics, on the fly, via scripting (usually JavaScript)

New Form Elements

HTML5 offers new form elements, for more functionality:

Tag Description
<datalist> Specifies a list of pre-defined options for input controls
<keygen> Defines a key-pair generator field (for forms)
<output> Defines the result of a calculation

Removed Elements

The following HTML 4.01 elements are removed from HTML5:

  • <acronym>
  • <applet>
  • <basefont>
  • <big>
  • <center>
  • <dir>
  • <font>
  • <frame>
  • <frameset>
  • <noframes>
  • <strike>
  • <tt>
  • <u>

Undefined variable: REMOTE_ADDR

Error fixing Undefined variable: index

Many times I have facee this problem as listing below, and I have search a lot and try to fix my wampserver setting and waste my few professional hours. Im writing this so any other developer or designer not waste.

This was the errors:

Notice: Undefined variable: REMOTE_ADDR

Notice: Notice: Undefined variable: REMOTE_ADDR in C:\wamp\www\cms\index.php on line 3

you need to do some minor change on your php.ini file. please follow these steps

open your php.ini from wamp server and search “error_reporting = E_ALL & ~E_NOTICE“

if that module not active, please active it.

and close (replace)

error_reporting  =  E_ALL

to

error_reporting  =  E_ALL

if any place.

——– 2nd step ——

if you wont found this. only found

error_reporting = E_ALL

so replace that to

error_reporting = E_ALL & ~E_NOTICE

once you done please restarts your Apache server or “wamp” then go back to the page where you were getting this error and refresh the web page and you should not see this error anymore.

NOTE: This is just for those who wants to save their time to fix entire coding again to define variables. Otherwise i recommend must define variable before use them to avoid this error.

Warning: .htaccess/php.ini file can stop working your site if you use wrong code, USE ONLY AT YOUR OWN RISK!

Imagine a World Without Free Knowledge

For over a decade, we have spent millions of hours building the largest encyclopedia in human history. Right now, the U.S. Congress is considering legislation that could fatally damage the free and open Internet. For 24 hours, to raise awareness, we are blacking out Wikipedia. Learn more.

What Is SOPA?

If you hadn’t heard of SOPA before, you probably have by now: Some of the internet’s most influential sites—Reddit and Wikipedia among them—are going dark to protest the much-maligned anti-piracy bill. But other than being a very bad thing, what is SOPA? And what will it mean for you if it passes?

SOPA is an anti-piracy bill working its way through Congress…

House Judiciary Committee Chair and Texas Republican Lamar Smith, along with 12 co-sponsors, introduced the Stop Online Piracy Act on October 26th of last year. Debate on H.R. 3261, as it’s formally known, has consisted of one hearing on November 16th and a “mark-up period” on December 15th, which was designed to make the bill more agreeable to both parties. Its counterpart in the Senate is the Protect IP Act (S. 968). Also known by it’s cuter-but-still-deadly name: PIPA. There will likely be a vote on PIPA next Wednesday; SOPA discussions had been placed on hold but will resume in February of this year.

…that would grant content creators extraordinary power over the internet…

The beating heart of SOPA is the ability of intellectual property owners (read: movie studios and record labels) to effectively pull the plug on foreign sites against whom they have a copyright claim. If Warner Bros., for example, says that a site in Italy is torrenting a copy of The Dark Knight, the studio could demand that Google remove that site from its search results, that PayPal no longer accept payments to or from that site, that ad services pull all ads and finances from it, and—most dangerously—that the site’s ISP prevent people from even going there.

…which would go almost comedically unchecked…

Perhaps the most galling thing about SOPA in its original construction is that it let IP owners take these actions without a single court appearance or judicial sign-off. All it required was a single letter claiming a “good faith belief” that the target site has infringed on its content. Once Google or PayPal or whoever received the quarantine notice, they would have five days to either abide or to challenge the claim in court. Rights holders still have the power to request that kind of blockade, but in the most recent version of the bill the five day window has softened, and companies now would need the court’s permission.

The language in SOPA implies that it’s aimed squarely at foreign offenders; that’s why it focuses on cutting off sources of funding and traffic (generally US-based) rather than directly attacking a targeted site (which is outside of US legal jurisdiction) directly. But that’s just part of it.

…to the point of potentially creating an “Internet Blacklist”…

Here’s the other thing: Payment processors or content providers like Visa or YouTube don’t even need a letter shut off a site’s resources. The bill’s “vigilante” provision gives broad immunity to any provider who proactively shutters sites it considers to be infringers. Which means the MPAA just needs to publicize one list of infringing sites to get those sites blacklisted from the internet.

Potential for abuse is rampant. As Public Knowledge points out, Google could easily take it upon itself to delist every viral video site on the internet with a “good faith belief” that they’re hosting copyrighted material. Leaving YouTube as the only major video portal. Comcast (an ISP) owns NBC (a content provider). Think they might have an interest in shuttering some rival domains? Under SOPA, they can do it without even asking for permission.

…while exacting a huge cost from nearly every site you use daily…

SOPA also includes an “anti-circumvention” clause, which holds that telling people how to work around SOPA is nearly as bad as violating its main provisions. In other words: if your status update links to The Pirate Bay, Facebook would be legally obligated to remove it. Ditto tweets, YouTube videos, Tumblr or WordPress posts, or sites indexed by Google. And if Google, Twitter, WordPress, Facebook, etc. let it stand? They face a government “enjoinment.” They could and would be shut down.

The resources it would take to self-police are monumental for established companies, and unattainable for start-ups. SOPA would censor every online social outlet you have, and prevent new ones from emerging.

…and potentially disappearing your entire digital life…

The party line on SOPA is that it only affects seedy off-shore torrent sites. That’s false. As the big legal brains at Bricoleur point out, the potential collateral damage is huge. And it’s you. Because while Facebook and Twitter have the financial wherewithal to stave off anti-circumvention shut down notices, the smaller sites you use to store your photos, your videos, and your thoughts may not. If the government decides any part of that site infringes on copyright and proves it in court? Poof. Your digital life is gone, and you can’t get it back.

…while still managing to be both unnecessary and ineffective…

What’s saddest about SOPA is that it’s pointless on two fronts. In the US, the MPAA, and RIAA already have the Digital Millennium Copyright Act (DMCA) to request that infringing material be taken down. We’ve all seen enough “video removed” messages to know that it works just fine.

As for the foreign operators, you might as well be throwing darts at a tse-tse fly. The poster child of overseas torrenting, Pirate Bay, has made it perfectly clear that they’re not frightened in the least. And why should they be? Its proprietors have successfully evaded any technological attempt to shut them down so far. Its advertising partners aren’t US-based, so they can’t be choked out. But more important than Pirate Bay itself is the idea of Pirate Bay, and the hundreds or thousands of sites like it, as populous and resilient as mushrooms in a marsh. Forget the question of should SOPA succeed. It’s incredibly unlikely that it could. At least at its stated goals.

…but stands a shockingly good chance of passing…

SOPA is, objectively, an unfeasible trainwreck of a bill, one that willfully misunderstands the nature of the internet and portends huge financial and cultural losses. The White House has come out strongly against it. As have hundreds of venture capitalists and dozens of the men and women who helped build the internet in the first place. In spite of all this, it remains popular in the House of Representatives.

That mark-up period on December 15th, the one that was supposed to transform the bill into something more manageable? Useless. Twenty sanity-fueled amendments were flat-out rejected. And while the bill’s most controversial provision—mandatory DNS filtering—was thankfully taken off the table recently, in practice internet providers would almost certainly still use DNS as a tool to shut an accused site down.

…unless we do something about it.

The momentum behind the anti-SOPA movement has been slow to build, but we’re finally at a saturation point. Wikipedia, BoingBoing, WordPress, TwitPic: they’ll all be dark on January 18th. An anti-SOPA rally has been planned for tomorrow afternoon in New York. The list of companies supporting SOPA is long but shrinking, thanks in no small part to the emails and phone calls they’ve received in the last few months.

So keep calling. Keep emailing. Most of all, keep making it known that the internet was built on the same principles of freedom that this country was. It should be afforded to the same rights.

WordPress.org Protests The Protect IP Act

Many websites are blacked out today to protest proposed U.S. legislation that threatens internet freedom: the Stop Internet Piracy Act (SOPA) and the Protect IP Act (PIPA). From personal blogs to Wikipedia, sites all over the web — including this one — are asking you to help stop this dangerous legislation from being passed. Please watch the video below to learn how this legislation will affect internet freedom, then scroll down to take action.

Learn More

How To Find The Current page URL In PHP

Some times in your valiant conquest of the web development industry, you will notice that some scripts will require that you know the current URL the user is browsing to provide certain services. It’s required to make dynamic URL.
Here is the idea you can follow to collect current URL of the page.

There are many server variables in PHP, some of them are:
$_SERVER['PHP_SELF']
The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar.

$_SERVER['SERVER_ADDR']
The IP address of the server under which the current script is executing.

$_SERVER['SERVER_NAME']
The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.

$_SERVER['QUERY_STRING']
The query string, if any, via which the page was accessed.

$_SERVER['DOCUMENT_ROOT']
The document root directory under which the current script is executing, as defined in the server’s configuration file.

$_SERVER['HTTP_CONNECTION']
Contents of the Connection: header from the current request, if there is one. Example: ‘Keep-Alive’.

$_SERVER['HTTP_HOST']
Contents of the Host: header from the current request, if there is one.

$_SERVER['REMOTE_ADDR']
The IP address from which the user is viewing the current page.

$_SERVER['REMOTE_PORT']
The port being used on the user’s machine to communicate with the web server.

$_SERVER['REQUEST_URI']
The URI which was given in order to access this page; for instance, ‘/index.html’.

Now we understand how to collect some server variable values in page URL, document root, query string etc.

Example 1 : Current URL without query string

<?php
$rightURL = 'http://www.yourwebsitedomain.com/page.php';
$wrongURL = 'http://www.yourwebsitedomain.com/page.php?id=Dev1234';
$gotRightURL = substr($wrongURL, 0, strpos($wrongURL, '?')); // This line is the key
echo 'You want this URL ' . $rightURL . '<br /><br />';
echo 'You don't want URL with query string: ' . $wrongURL . '<br /><br />';
echo 'You got the URL: ' . $gotRightURL . '<br /><br />';
?>

You can collect url without query string with the help of $_SERVER[] vars. Now try this code below

<?php
// $_SERVER[] vars below might also be helpful:
echo '$_SERVER['PHP_SELF']: ' . $_SERVER['PHP_SELF'] . '<br />';
echo 'Host URL with $_SERVER['HTTP_HOST']: http://' . $_SERVER['HTTP_HOST'] . '<br />';
echo '$_SERVER['REQUEST_URI']: ' . $_SERVER['REQUEST_URI'];
?>

So now if you want complete url of browsed page then just write like below and you are done

<?php echo 'http://' . $_SERVER['HTTP_HOST'] . ''.$_SERVER['REQUEST_URI'];?>

Example 2 : URL maker function, remove duplicated vars

<?php
function makeUrl($path, $qs = false, $qsAdd = false)
{
$var_array = array();
$varAdd_array = array();
$url = $path;

if($qsAdd)
{
$varAdd = explode('&', $qsAdd);
foreach($varAdd as $varOne)
{
$name_value = explode('=', $varOne);

$varAdd_array[$name_value[0]] = $name_value[1];
}
}

if($qs)
{
$var = explode('&', $qs);
foreach($var as $varOne)
{
$name_value = explode('=', $varOne);

//remove duplicated vars
if($qsAdd)
{
if(!array_key_exists($name_value[0], $varAdd_array))
{
$var_array[$name_value[0]] = $name_value[1];
}
}
else
{
$var_array[$name_value[0]] = $name_value[1];
}
}
}

//make url with querystring
$delimiter = "?";

foreach($var_array as $key => $value)
{
$url .= $delimiter.$key."=".$value;
$delimiter = "&";
}

foreach($varAdd_array as $key => $value)
{
$url .= $delimiter.$key."=".$value;
$delimiter = "&";
}

return $url;
}

?>

PHP List All Files In A Directory

I am working on a website for a client at the moment, and one of the features I need to do is display a bunch of files in a particular directory.
It is actually a very simple process in PHP and only requires a small amount of code. I have seen a lot of examples on other blog and websites that use a absurd amount of code to get the same result, and I am not quite sure why.
Complete Code :

//path to directory where all files stored
$directory = "../allfiles/team/dev/";

//get all files with a .jpg extension.
$readfilename = glob($directory . "*.jpg");

//print each file name
foreach($filename as $ readfilename)
{
echo $filename."<br/>";
}

Nore : It’s only list all .jpg file from source directory

List files from a folder automatically via PHP

Sometimes many people need to list images on a web page as a image gallery. Nowadays we are using database and programming to collect images details and names from database. Now I am going to use only php programming to list images on a web page without any database using.

// the directory name, where your images are stored
$imgdir = ‘/allimages/’;

// array of file formats
$allowed_types = array(‘png’,'jpg’,'jpeg’,'gif’); want to show

$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$a_img[] = $imgfile;
sort($a_img);
reset ($a_img);
}
}
// total image number
$totimg = count($a_img);

for($x=0; $x < $totimg; $x++)
{
$size = getimagesize($imgdir.’/’.$a_img[$x]);

// do whatever
$halfwidth = ceil($size[0]/2);
$halfheight = ceil($size[1]/2);
echo ‘<li><img src=”%27.$imgdir.%27%27.$a_img%5B$x%5D.%27″></li>’;
}

Display Recent Posts in WordPress

To display recent posts often helps your users to visit them easily specially on the sidebar of a single post page. But in some designing processes people want to display recent posts in many different ways. In this post or in the custom page, we will show you various different ways you can display the recent posts in WordPress.

Recent Posts in a List Format

The list format is often used in sidebars of WordPress pages. You can display the recent posts by simply pasting the following code in a template file of your choosing for example sidebar.php:

<?php get_archives('postbypost', '10', 'custom', '<li>', '</li>'); ?>

You can change the number 10 to the number of posts you like to display. Also you can add custom style for this listing to match the theme colors.

If your website theme supports Widgets, then there is an easier option for you. You can simply head over to the widgets page and add Recent Posts widget to your sidebar. That will save you from editing the codes.

Recent Posts with Summary

Many people like to display recent posts with a title and a short description. There are multiple ways of accomplishing that.

The first way is:

<ul>
<?php query_posts('showposts=10'); ?>

<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>

<li><?php the_excerpt(__('(more...)')); ?></li>
<?php endwhile;?>
</ul>

And you make sure that the excerpt is a short description of the post. You must rewrite the excerpt to make it fit the word limit.

Another way is using the Word Limit which will save you the time of writing an excerpt because the Word Limit Plugin will automatically crop everything after the desired number of characters. For that you need to download a plugin called Limit-Post which you need to download and activate.

Once the plugin is activated paste the following code where you want it displayed in your theme files:

<ul>
<?php query_posts('showposts=10'); ?>

<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>

<li><?php the_content_limit(150); ?></li>
<?php endwhile;?>
</ul>

You may change the 150 to set the character limit of your desire.

Recent Posts with Full Content

Many  people like to display recent posts with full content if WordPress is being used as a Content Management System (CMS).

<ul>
<?php query_posts('showposts=10'); ?>

<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>

<li><?php the_content(__('(more...)')); ?></li>
<?php endwhile;?>
</ul>

You may change the number 10 to whatever you like. This is mostly used to make a page look like your blog page. So you should not need this if you are not running a CMS.

Now you should be able to display Recent Posts in your WordPress blog or a CMS.

WordPress Custom Query to SELECT a Row

To retrieve an entire row from a query, use get_row. The function can return the row as an object, an associative array, or as a numerically indexed array. If more than one row is returned by the query, only the specified row is returned by the function, but all rows are cached for later use. Returns NULL if no result is found.

<?php $wpdb->get_row('query', output_type, row_offset); ?>

query 

(string) The query you wish to run.

output_type

One of three pre-defined constants. Defaults to OBJECT.

OBJECT – result will be output as an object.
ARRAY_A – result will be output as an associative array.
ARRAY_N – result will be output as a numerically indexed array.

row_offset

(integer) The desired row (0 being the first). Defaults to 0.

Examples :

Get all the information about Link 10.

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10");

The properties of the $mylink object are the column names of the result from the SQL query (in this all of the columns from the $wpdb->links table).

echo $mylink->link_id; // prints "10"

In contrast, using

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_A);

would result in an associative array:

echo $mylink['link_id']; // prints "10"

and

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_N);

would result in a numerically indexed array:

echo $mylink[1]; // prints "10"