Login Widget With Shortcode

Description

This is a simple login form in the widget. just install the plugin and add the login widget in the sidebar. Change some settings in the login widget panel and you are good to go. Add css as you prefer because the form structure is really very simple.

Installation

Upload widget_login to the /wp-content/plugins/ directory
Activate the plugin through the ‘Plugins’ menu in WordPress.

Screenshots

 

Download from wordpress.org.

The Serbo-Croatian Language translation file is provided by Web Hosting Hub

Rotate div horizontally

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Rotate Image</title>
http://code.jquery.com/jquery-1.10.1.min.js

$( document ).ready(function() {

var i = 0;
setInterval(function(){
$(“#container_1”).css(‘transform’,”rotate(“+i+”deg)”);
i = i+1;
}, 50);

});

<style>
#container_1 {
border:1px solid #FF0000;
width: 100px;
height:100px;
top:100px;
left:100px;
position:fixed;
}

</style>
</head>

<body>

</body>
</html>

Javascript closure example



function celebrityIDFunc () {
var celebrityID = 999;
// We are returning an object with some inner functions
// All the inner functions have access to the outer function's variables
return {
getID: function ()  {
// This inner function will return the UPDATED celebrityID variable
// It will return the current value of celebrityID, even after the changeTheID function changes it
return celebrityID;
},
setID: function (theNewID)  {
// This inner function will change the outer function's variable anytime
celebrityID = theNewID;
}
}

}

var mjID = celebrityIDFunc (); // At this juncture, the celebrityID outer function has returned.
mjID.getID(); // 999
mjID.setID(567); // Changes the outer function’s variable
mjID.getID(); // 567: It returns the updated celebrityId variable

alert(mjID.getID());

Gmap API

Save this file as index.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps AJAX + mySQL/PHP Example</title>
http://maps.google.com/maps/api/js?sensor=false

//

var customIcons = {
restaurant: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_blue.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
},
bar: {
icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png',
shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'
}
};

function load() {
var map = new google.maps.Map(document.getElementById("map"),
{
center: new google.maps.LatLng(22.6343422, 88.3385809),
zoom: 13,
mapTypeId: 'roadmap'
}
);

var infoWindow = new google.maps.InfoWindow;

// Change this depending on the name of your PHP file
downloadUrl("phpsqlajax_genxml_1.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i " + name + "
" + address;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon,
shadow: icon.shadow
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
}

function bindInfoWindow(marker, map, infoWindow, html) {
google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(html);
infoWindow.open(map, marker);
});
}

function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;

request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};

request.open('GET', url, true);
request.send(null);
}

function doNothing() {}

//]]>

</head>

<body onLoad="load()">

</body>
</html>

Create a new file as phpsqlajax_genxml_1.php
<?php
//require("phpsqlajax_dbinfo.php");

// get long lat data from google..
//http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
// PWD Rd, Bally Howrah, WB 711205

function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','&lt;',$htmlStr);
$xmlStr=str_replace('>','&gt;',$xmlStr);
$xmlStr=str_replace('"','&quot;',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&amp;',$xmlStr);
return $xmlStr;
}

// Opens a connection to a MySQL server
/*$connection=mysql_connect (localhost, $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}*/

// Set the active MySQL database
/*$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
*/
// Select all the rows in the markers table
/*$query = "SELECT * FROM markers WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}*/

header("Content-type: text/xml");

// Start XML file, echo parent node
echo '<markers>';

// Iterate through the rows, printing XML nodes for each
//while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'name="' . parseToXML("Belur Math") . '" ';
echo 'address="' . parseToXML("Belur Math, Belur, Howrah, West Bengal") . '" ';
echo 'lat="22.6343422" ';
echo 'lng="88.3385809" ';
echo 'type="restaurant" ';
echo '/>';

echo '<marker ';
echo 'name="' . parseToXML("Bally Ghat") . '" ';
echo 'address="' . parseToXML("PWD Rd, Bally Howrah, WB 711205") . '" ';
echo 'lat="22.6527382" ';
echo 'lng="88.3414109" ';
echo 'type="bar" ';
echo '/>';

//}

// End XML file
echo '</markers>';

?>

Now run the index.php

Public Private Protected variable concepts

private – can be accessed from WITHIN the class only

protected – can be accessed from WITHIN the class and INHERITING classes

public – can be accessed from code OUTSIDE the class as well

<?php
/**
* Define MyClass
*/
class MyClass
{
public $public = 'Public';
protected $protected = 'Protected';
private $private = 'Private';

function printHello()
{
echo $this->public;
echo ‘<br>’;
echo $this->protected;
echo ‘<br>’;
echo $this->private;
echo ‘<br>’;
}
}

//$obj = new MyClass();
//echo $obj->public; // Works
//echo $obj->protected; // Fatal Error
//echo $obj->private; // Fatal Error
//$obj->printHello(); // Shows Public, Protected and Private

/**
* Define MyClass2
*/
class MyClass2 extends MyClass
{
// We can redeclare the public and protected method, but not private
protected $protected = ‘Protected2’;

function printHello2()
{
echo $this->public;
echo ‘<br>’;
echo $this->protected;
echo ‘<br>’;
echo $this->private;
echo ‘<br>’;
}
}

$obj2 = new MyClass2();
//echo $obj2->public; // Works
//echo $obj2->private; // Undefined
//echo $obj2->protected; // Works
$obj2->printHello2(); // Shows Public, Protected2, Undefined

?>

Custom jQuery plugin to manipulate tabs

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Jquery Custom Plugin</title>
http://code.jquery.com/jquery-1.10.1.min.js

(function ($){
$.fn.Tabs = function (options){
var settings = $.extend({
color : “#000000”,
background : “#ffffff”,
container : ”,
dafault : 1
}, options );

this.css({
‘color’: settings.color,
‘background-color’: settings.background
});

$(“#”+settings.container).ResetAll();

$(‘#c’+settings.dafault).show();
$(‘#’+settings.dafault).css( “color”, “red” );

$(this).children(“a”).on(‘click’, function() {
$(“#”+settings.container).ResetAll();
$(‘#c’+$(this).attr(“id”)).fadeIn(“slow”);
$(this).css( “color”, “red” );
});

};

$.fn.ResetAll = function() {
$(this).children(“div”).hide();
this.find( “a” ).css( “color”, “black” );
};

}(jQuery));

$( document ).ready(function() {
$( “#test” ).Tabs({
color: “#000000”,
background: ‘#cccccc’,
container: ‘test’,
dafault : 1
});
});

<style>
.cont{
width:400px;
padding:10px;
border:1px solid #000000;
}
.cont a{
text-decoration: none;
background-color:#FFFFFF;
border:2px solid #000000;
padding:2px;
}
</style>

</head>
<body>

Tab 1
Tab 2
Tab 3

In addition, the primary purpose of an Immediately Invoked Function is to allow us to have our own private variables. Pretend we want a different color green, and we want to store it in a variable.
It’s good practice when writing plugins to only take up one slot within $.fn. This reduces both the chance that your plugin will be overridden, and the chance that your plugin will override other plugins. In other words, this is bad.
.pagerLink {
background-color: #E4F5F8;
border: 1px solid #C0DEED;
text-decoration: none !important;
}

</div>

other 1
other 2
other 3

</body>
</html>

Numaric Captcha

<?php

session_start();

function generate_equation() {
$firstnum = rand(5,8);
$secondnum = rand(1,4);
$coinflip = rand(1,2) % 2;
if($coinflip == 0) {
$math = $firstnum + $secondnum;
$operator = array("+");
} else {
$math = $firstnum - $secondnum;
$operator = array("-");
}

$_SESSION['captcha_equation'] = $firstnum . " " . $operator[0] . " " . $secondnum . " = ";
$_SESSION['captcha_answer'] = $math;

return( $_SESSION['captcha_equation'] );
}

?>

XLS Export

<?php
set_time_limit(0);
require_once(“../includes/connection.php”);
adminSecure();

function xlsBOF() {
echo pack(“ssssss”, 0x809, 0x8, 0x0, 0x10, 0x0, 0x0);
return;
}
// Excel end of file footer
function xlsEOF() {
echo pack(“ss”, 0x0A, 0x00);
return;
}
// Function to write a Number (double) into Row, Col
function xlsWriteNumber($Row, $Col, $Value) {
echo pack(“sssss”, 0x203, 14, $Row, $Col, 0x0);
echo pack(“d”, $Value);
return;
}
// Function to write a label (text) into Row, Col
function xlsWriteLabel($Row, $Col, $Value ) {
$L = strlen($Value);
echo pack(“ssssss”, 0x204, 8 + $L, $Row, $Col, 0x0, $L);
echo $Value;
return;
}

////////////////////////////////////////////////////////////

header(“Pragma: public”);
header(“Expires: 0”);
header(“Cache-Control: must-revalidate, post-check=0, pre-check=0”);
header(“Content-Type: application/force-download”);
header(“Content-Type: application/octet-stream”);
header(“Content-Type: application/download”);;
header(“Content-Disposition: attachment;filename=product.xls”);
header(“Content-Transfer-Encoding: binary “);

xlsBOF();

$data_array = array(
“product_name”,
“brand_id”,
“style_id”,
“frame_id”,
“gender_id”,
“size_id”,
“eyesize_id”,
“bridgesize_id”,
“templelength_id”,
“option_color”,
“option_price”,
“product_url”,
“image_url”,
);

$header_array = array(
“Name”,
“Brand”,
“Style”,
“Frame”,
“Gender”,
“Size”,
“Eyesize”,
“Bridgesize”,
“Templelength”,
“Color”,
“Price”,
“Product Url”,
“Image Url”
);

foreach($header_array as $key => $value){
xlsWriteLabel(0,$key,$value);
}

$k = 2;

$res1 = $obj->selectData(TABLE_PRODUCT.” as p”,””,”p.product_id > 0 and p.product_status=’Active’ order by p.product_added desc”,””);
while($data1 = mysql_fetch_array($res1)){

$res2 = $obj->selectData(TABLE_PRODUCT_OPTION.” as po”,””,”po.option_status=’Active’ and po.product_id='”.$data1[‘product_id’].”‘”,””);
while($data2 = mysql_fetch_array($res2)){

$option_image = $obj->selectData(TABLE_PRODUCT_OPTION_IMAGE.” as poi”,””,”poi.image_status=’Active’ and poi.option_id='”.$data2[‘option_id’].”‘ and poi.option_extra_image<>” limit 1″,1);

$image_url = FURL.PRODUCT_IMAGES.$option_image[‘option_extra_image’];
$product_url = FURL.”products_detail.php?p_id=”.$data2[‘product_id’].”&o_id=”.$data2[‘option_id’].””;

foreach($data_array as $key => $value){
if($value == “product_name”){
xlsWriteLabel($k,$key,$data1[$value]);
} else if($value == “brand_id”){
xlsWriteLabel($k,$key,$obj->getBrandName($data1[$value]));
} else if($value == “style_id”){
xlsWriteLabel($k,$key,$obj->getProductStyle($data1[$value]));
} else if($value == “frame_id”){
xlsWriteLabel($k,$key,$obj->getFrameName($data1[$value]));
} else if($value == “gender_id”){
xlsWriteLabel($k,$key,$obj->getGenderName($data1[$value]));
} else if($value == “size_id”){
xlsWriteLabel($k,$key,$obj->getProductSize($data1[$value]));
} else if($value == “eyesize_id”){
xlsWriteLabel($k,$key,$obj->getProductEyeSize($data1[$value]));
} else if($value == “bridgesize_id”){
xlsWriteLabel($k,$key,$obj->getProductBridgeSize($data1[$value]));
} else if($value == “templelength_id”){
xlsWriteLabel($k,$key,$obj->getProductTempleLength($data1[$value]));
} else if($value == “product_url”){
xlsWriteLabel($k,$key,$product_url);
} else if($value == “image_url”){
xlsWriteLabel($k,$key,$image_url);
} else {
xlsWriteLabel($k,$key,$data2[$value]);
}
}
$k++;
}
}

xlsEOF();
/////////////////////////////////////////////////////

?>

Google Translate

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<meta name="google-translate-customization" content="4bc028f58847675b-c4dbfa7ae83c6fb9-gaade28b55526543d-19"></meta>

function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: ‘en’, layout: google.translate.TranslateElement.InlineLayout.SIMPLE},
‘google_translate_element’);
}
http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit

</head>

<body>

</body>
</html>

zindex manipulation jquery

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.17.custom.css" rel="stylesheet" />
http://js/jquery-1.7.1.min.js
http://js/jquery-ui-1.8.17.custom.min.js

$(function() {
$( ".layer" ).draggable({
start: function( event, ui ) {
setZindex($(this).attr("id"))
}
});
});

function setZindex(ui){
var index_highest = 0;

$(".layer").each(function() {
// always use a radix when using parseInt
var index_current = parseInt($(this).css("zIndex"), 10);
if(index_current > index_highest) {
index_highest = index_current;
}
});

$("#"+ui).css("zIndex", parseInt(index_highest)+1);

}

<style>
.layer{
width:50px;
height:50px;
border:1px solid #000000;
background-color:red;
}
</style>
</head>

<body>


1

3

</div>
</body>
</html>