Rabu, Mei 18, 2011

Mass User Creation in WordPress

Case : you want to add mass user in your wordpress
Script :

require( '/wp-load.php' );
wp_create_user('otto', 'password', 'otto@ottodestruct.com');
wp_create_user('fake', 'fakepass', 'fake@example.com');
...


Source : http://wordpress.org/support/topic/mass-user-creation-in-wordpress-30

Kamis, April 14, 2011

20 Things You Must Have on Your Blog

20 things you must have on your blog :
  1. SEO Design
  2. Page : Home
  3. Page : About
  4. Page : Disclaimer
  5. Page : Contact
  6. Addthis
  7. Searchbox
  8. Shoutbox
  9. Follower
  10. Popular Post
  11. Recent Post
  12. Blog Archive
  13. Blogroll
  14. Feedjit
  15. Tagcloud / Wp-Cumulus like
  16. Backlink
  17. Paging
  18. Linkwithin
  19. Share Facebook button
  20. Google Adsense sengihnampakgigi

Source : http://www.google.com

Selasa, Maret 29, 2011

JQuery : Tooltip and Image Preview

Case : You want to create cool tooltip or image preview from your thumbnail
Solution : JQuery
Script :

this.imagePreview = function(){
/* CONFIG */

xOffset = 10;
yOffset = 30;

// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result

/* END CONFIG */
$("a.preview").hover(function(e){
this.t = this.title;
this.title = "";
var c = (this.t != "") ? "
" + this.t : "";
$("body").append("

Image preview"+ c +"

");
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#preview").remove();
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};

// starting the script on page load
$(document).ready(function(){
imagePreview();
});


Source : http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery

PHP : Auto Resize Image on Upload

Case : you want to resize image on upload
Solution : PHP imagecopyresampled
Script :

if ($_SESSION[username_administrasi] != "" && $_POST[submit] == "Simpan") {
$cek = cek("select * from ktp where no_ktp = '$no_ktp' and npwp = '$npwp' ");
if ($cek > 0) {
alert("Data sudah ada !");
loncat("../index.php");
} else {
$tmp_filename = $_FILES[file1][tmp_name];
$filename = $_FILES[file1][name];
$file = explode(".",$filename);
$nama_file = $file[0];
echo $nama_file;
list($old_width, $old_height, $type, $attr) = getimagesize($tmp_filename);
if ($type == 1 || $type == 2 || $type == 3) {
if (($_FILES["file1"]["size"]/1024) > 250) {
if ($type == 1) {
$new_image = imagecreatefromgif($tmp_filename);
} else if ($type == 2) {
$new_image = imagecreatefromjpeg($tmp_filename);
} else if ($type == 3) {
$new_image = imagecreatefrompng($tmp_filename);
}

echo "
width asli = ".$old_width;
echo "
height asli = ".$old_height;
$new_width = 800;

if ($old_width > $old_height) {
$percentage = ($new_width / $old_width);
} else {
$percentage = ($new_width / $old_height);
}

$new_width = round($old_width * $percentage);
$new_height = round($old_height * $percentage);

echo "
width resize = ".$new_width;
echo "
height resize = ".$new_height;

echo "
".$_FILES[file1][type];
echo "
".$_FILES[file1][size];


if (function_exists(imagecreatetruecolor)){
$resized_img = imagecreatetruecolor($new_width,$new_height);
}else{
die("Error: Please make sure you have GD library ver 2+");
}

imagecopyresampled($resized_img, $new_image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);

if ($type == 1) {
imagegif($resized_img,"../images/uploaded/tumb_".$nama_file.".gif");
} else if ($type == 2) {
imagejpeg($resized_img,"../images/uploaded/tumb_".$nama_file.".jpg");
} else if ($type == 3) {
imagepng($resized_img,"../images/uploaded/tumb_".$new_image.".png");
}

$move = move_uploaded_file($_FILES['file1']['tmp_name'], '../images/uploaded/real_'.$filename);

ImageDestroy ($resized_img);
ImageDestroy ($new_image);

loncat("../index.php");
} else {

$move = move_uploaded_file($_FILES['file1']['tmp_name'], '../images/uploaded/real_'.$filename);

if ($move) {
alert("Upload sukses.");
} else {
alert("Upload gagal.");
}
loncat("../index.php");
}
} else {
alert(" Tipe file yang diijinkan : GIF, JPG, JPEG, PNG");
//loncat("../index.php");
}
}
}



Source : http://www.php.net/

Jumat, Maret 25, 2011

Blogger : Show hide Guestbook/Shoutbox/Shoutmix

Script CSS :

#gb{
position:fixed;
top:50px;
z-index:+1000;
}
* html #gb{position:relative;}
.gbtab{
height:200px;
width:30px;
float:left;
cursor:pointer;
background:url("http://purwomartono.googlepages.com/slider_shoutmix.gif") no-repeat;
}
.gbcontent{
float:left;
border:5px solid #000000;
background:#FFFFFF;
padding:5px;
}


Script Javascript :

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-4639370-4']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

window.google_analytics_uacct = "UA-4639370-4";

function showHideGB(){
var gb = document.getElementById("gb");
var w = gb.offsetWidth;
gb.opened ? moveGB(0, 30-w) : moveGB(20-w, 0);
gb.opened = !gb.opened;
}
function moveGB(x0, xf){
var gb = document.getElementById("gb");
var dx = Math.abs(x0-xf) > 10 ? 5 : 1;
var dir = xf>x0 ? 1 : -1;
var x = x0 + dx * dir;
gb.style.right = x.toString() + "px";
if(x0!=xf){setTimeout("moveGB("+x+", "+xf+")", 10);}
}

var gb = document.getElementById("gb");
gb.style.right = (30-gb.offsetWidth).toString() + "px";



Source html :







ShoutMix chat widget






Source : http://rtn-alwaysforyou.blogspot.com/2010/08/membuat-show-hide-guestbook.html? kiss