Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Friday, September 3, 2010

CSS hack, different browsers

Comprehensive List of Browser-Specific CSS Hacks

/***** Selector Hacks ******/

/* IE6 and below */
* html #uno { color: red }


/* IE7 */
*:first-child+html #dos { color: red }


/* IE7, FF, Saf, Opera */
html>body #tres { color: red }


/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body #cuatro { color: red }


/* Opera 9.27 and below, safari 2 */
html:first-child #cinco { color: red }

/* Safari 2-3 */

html[xmlns*=""] body:last-child #seis { color: red }


/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #siete { color: red }


/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #ocho { color: red }


/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
#diez { color: red }
}


/* iPhone / mobile webkit */
@media screen and (max-device-width: 480px) {
#veintiseis { color: red }

}


/* Safari 2 - 3.1 */
html[xmlns*=""]:root #trece { color: red }


/* Safari 2 - 3.1, Opera 9.25 */
*|html[xmlns*=""] #catorce { color: red }


/* Everything but IE6-8 */
:root *> #quince { color: red }


/* IE7 */
*+html #dieciocho { color: red }


/* Firefox only. 1+ */
#veinticuatro, x:-moz-any-link { color: red }


/* Firefox 3.0+ */
#veinticinco, x:-moz-any-link, x:default { color: red }




/***** Attribute Hacks ******/

/* IE6 */
#once { _color: blue }


/* IE6, IE7 */
#doce { *color: blue; /* or #color: blue */ }


/* Everything but IE6 */
#diecisiete { color/**/: blue }

/* IE6, IE7, IE8 */

#diecinueve { color: blue\9; }

/* IE7, IE8 */

#veinte { color/*\**/: blue\9; }

/* IE6, IE7 -- acts as an !important */

#veintesiete { color: blue !ie; } /* string after ! can be anything */


source : http://paulirish.com/2009/browser-specific-css-hacks/
Thanks to :Paul Irish. as my note

Monday, March 22, 2010

Hide iframe border on IE

<html>
<head>
<body bgcolor="#000000">
</head>
<iframe src="./index.html" frameborder="0" border="0" cellspacing="0" width="100%" marginwidth="0" marginheight="0" height="75%">
</iframe>
<br><br>
<iframe src="./ads.html" noresize="noresize" frameborder="0" border="0" cellspacing="0" scrolling="no" width="100%" marginwidth="0" marginheight="0" height="25%">
</iframe>
</body>
</html>

Monday, March 1, 2010

Send SMS function using PHP

What are usually need to make a sms;



This is a simple function to send sms using php script.


<?php

function PostToHostSMS($host, $port, $username, $password, $data_to_send)
{
$dc = 0;
$bo ="--------453534534534536";

$fp = fsockopen($host, $port, $errno, $errstr);
if (!$fp) {
echo "errno: $errno \n";
echo "errstr: $errstr\n";
return $result;
}

fputs
($fp, "POST / HTTP/1.1\r\n");
if ($username != "") {
$auth = $username . ":" . $password;
echo "auth: $auth\n";
$auth = base64_encode($auth);
echo "auth: $auth\n";
fwrite
($fp, "Authorization: Basic " . $auth . "\r\n");
}
fputs
($fp, "User-Agent: NowSMS PHP Script\r\n");
fputs
($fp, "Accept: */*\r\n");
fputs
($fp, "Content-type: multipart/form-data; boundary=$bo\r\n");

foreach($data_to_send as $key=>$val) {
$ds =sprintf("%s\r\nContent-Disposition: form-data;
name=\"%s\"\r\n%s\r\n"
,$bo,$key,$val);
$dc += strlen($ds);

}
$dc += strlen($bo)+3;
fputs
($fp, "Content-length: $dc\r\n");
fputs
($fp, "\r\n");
fputs
($fp, "This is a MIME message\r\n\r\n");

foreach($data_to_send as $key=>$val) {
$ds =sprintf("%s\r\nContent-Disposition: form-data;
name=\"%s\"\r\n%s\r\n"
,$bo,$key,$val);
fputs
($fp, $ds );
}
$ds = $bo."--\r\n" ;
fputs
($fp, $ds);

$res = "";

while(!feof($fp)) {
$res .= fread($fp,1);
}
fclose
($fp);


return $res;
}

?>


Create xml rss feed with PHP

First, write a script like below;

<?php header('Content-type: text/xml'); ?>

<?php $phpver = phpversion(); ?>

<rss version="2.0">
<channel>
<title>SapuraTIE</title>
<description>Sapuratie</description>
<language>en-US</language>
<link>http://thegreatestpost.blogspot.com/</link>
<copyright>Your copyright</copyright>
<generator>
XML/RSS feed generator by thegreatestpost(PHP version
<?php echo $phpver; ?>)
</generator>

<managingEditor>Site Editor</managingEditor>
<webMaster>Webmaster Email</webMaster>



<?php
require_once('db_connect.php'); //your connection to database

$query = "SELECT id,content_title,content_data,content_date,
content_page FROM sapurastie_article
WHERE content_section <> 10 AND
content_language =
$lang ORDER BY content_date DESC LIMIT 0,15"; //your query
$execute = mysql_query($query) or die(mysql_error());

while($result = mysql_fetch_array($execute)) {
?>
//Start create item
<item>
<title> <?=htmlentities(strip_tags($result['content_title'])); ?></title>
<description>
<?=htmlentities(strip_tags(substr($result['content_data'],0,500)."...",'ENT_QUOTES'));
?>

</description>

<pubDate>
<?php
echo date('r', strtotime($result['content_date'])); ?>
</pubDate>
<guid>http://thegreatestpost.blogspot.com</guid>
</item>
<?php } ?>

</channel>
</rss>

then, the output will be like;



Created by: thegreatestpost.



Friday, February 12, 2010

List of web text editor - Open Source(free) and Commercial

These are three the best and free text editor for web. They are LGPL license for web application development.










Xinha    


 









More reference visit :  http://www.geniisoft.com/showcase.nsf/WebEditors

Islamic Calendar script - Hijrah/Masihi Calendar converter

Copy this script and paste to your code to add the Islamic Calendar converter

<HTML>
<HEAD>
<SCRIPT language=JavaScript>

function intPart(floatNum){
if (floatNum< -0.0000001){
return Math.ceil(floatNum-0.0000001)
}
return Math.floor(floatNum+0.0000001)
}
function weekDay(wdn){
if(wdn==0){
return "Monday"
}
if(wdn==1){
return "Tuesday"
}
if(wdn==2){
return "Wednesday"
}
if(wdn==3){
return "Thursday"
}
if(wdn==4){
return "Friday"
}
if(wdn==5){
return "Saturday"
}
if(wdn==6){
return "Sunday"
}
return ""

}
function chrToIsl(arg) {
d=parseInt(arg.CDay.value)
m=parseInt(arg.CMonth.value)
y=parseInt(arg.CYear.value)
if ((y>1582)||((y==1582)&&(m>10))||((y==1582)&&(m==10)&&(d>14)))
{
jd=intPart((1461*(y+4800+intPart((m-14)/12)))/4)+intPart((367*(m-2-12*(intPart((m-14)/12))))/12)-
intPart( (3* (intPart( (y+4900+ intPart( (m-14)/12) )/100) ) ) /4)+d-32075
}
else
{
jd = 367*y-intPart((7*(y+5001+intPart((m-9)/7)))/4)+intPart((275*m)/9)+d+1729777
}
arg.JD.value=jd
arg.wd.value=weekDay(jd%7)
l=jd-1948440+10632
n=intPart((l-1)/10631)
l=l-10631*n+354
j=(intPart((10985-l)/5316))*(intPart((50*l)/17719))+(intPart(l/5670))*(intPart((43*l)/15238))
l=l-(intPart((30-j)/15))*(intPart((17719*j)/50))-(intPart(j/16))*(intPart((15238*j)/43))+29
m=intPart((24*l)/709)
d=l-intPart((709*m)/24)
y=30*n+j-30

arg.HDay.value=d
arg.HMonth.value=m
arg.HYear.value=y
}
function islToChr(arg) {
d=parseInt(arg.HDay.value)
m=parseInt(arg.HMonth.value)
y=parseInt(arg.HYear.value)
jd=intPart((11*y+3)/30)+354*y+30*m-intPart((m-1)/2)+d+1948440-385
arg.JD.value=jd
arg.wd.value=weekDay(jd%7)
if (jd> 2299160 )
{
l=jd+68569
n=intPart((4*l)/146097)
l=l-intPart((146097*n+3)/4)
i=intPart((4000*(l+1))/1461001)
l=l-intPart((1461*i)/4)+31
j=intPart((80*l)/2447)
d=l-intPart((2447*j)/80)
l=intPart(j/11)
m=j+2-12*l
y=100*(n-49)+i+l
}
else
{
j=jd+1402
k=intPart((j-1)/1461)
l=j-1461*k
n=intPart((l-1)/365)-intPart(l/1461)
i=l-365*n+30
j=intPart((80*i)/2447)
d=i-intPart((2447*j)/80)
i=intPart(j/11)
m=j+2-12*i
y=4*k+n+i-4716
}

arg.CDay.value=d
arg.CMonth.value=m
arg.CYear.value=y

}
</SCRIPT>
<head>

<BODY>
<TABLE border=1>
<TBODY>
<TR>
<TH></TH>
<TH>Day</TH>
<TH>Month</TH>
<TH>Year</TH></TR>
<TR>
<TH>Masehi </TH>
<FORM name=IrgendÃ…¡ppis>
<TH><INPUT size=4 value=1 name=CDay></TH>
<TH><INPUT size=4 value=1 name=CMonth></TH>
<TH><INPUT size=4 value=1996 name=CYear></TH></TR>
<TR>
<TH>Hijrah</TH>
<TH><INPUT size=4 name=HDay></TH>
<TH><INPUT size=4 name=HMonth></TH>
<TH><INPUT size=4 name=HYear></TH></TR></TBODY></TABLE>
<P>
<INPUT onclick=chrToIsl(this.form) type=button value="Masehi to Hijrah" name=CtoH>
<INPUT onclick=islToChr(this.form) type=button value="Hijrah to Masehi" name=HtoC>
<P>Day of the week: <INPUT size=10 name=wd>
<P>Julian Day: <INPUT size=7 name=JD>
<P></FORM>
<HR>
<p><font color="#006600" size="1" face="Century Gothic">Julian dates assign a unique number to each
calendar day. The Julian day number counts the number of days since noon
on January 1, -4712 (astronomical calendar) or January 1, 4713 BC (civil
calendar). This system, widely used by astronomers, was proposed by Julius
J. Scaliger in 1583. Hours and minutes are counted as fractions of a day
since the last noon (Universal Time).</font></p>
<TABLE border=1>
<TBODY>
<TR>
<TH>1</TH>
<TH>Muharram</TH>
<TH></TH>
<TH>7</TH>
<TH>Rajab</TH></TR>
<TR>
<TH>2</TH>
<TH>Safar</TH>
<TH></TH>
<TH>8</TH>
<TH>Sha'ban</TH></TR>
<TR>
<TH>3</TH>
<TH>Rabi'ul Awal</TH>
<TH></TH>
<TH>9</TH>
<TH>Ramadhan</TH>
</TR>
<TR>
<TH>4</TH>
<TH>Rabi'ul Akhir</TH>
<TH></TH>
<TH>10</TH>
<TH>Shawwal</TH></TR>
<TR>
<TH>5</TH>
<TH>Jumadil Awal</TH>
<TH></TH>
<TH>11</TH>
<TH>Zulkaedah</TH>
</TR>
<TR>
<TH>6</TH>
<TH>Jumadil Akhir</TH>
<TH></TH>
<TH>12</TH>
<TH>Zulhijjah</TH>
</TR></TBODY></TABLE>
</BODY>
</HTML>


source: over the internet

Wednesday, February 10, 2010

Object Oriented PHP and Basic example OOP

Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of datafields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, modularity, polymorphism, and inheritance.
- wikipedia.org

let's go....

Define class
------------
Syntax Class classname { }


Class TheGreatestPost
{
      public $word;
      public function print()
      {
       echo $this->word;
       }
}



To print output
---------------

$post = new TheGreatestPost(); //instantiate the object
$post->word = 'hello The Greatest Post';
$post->print();


::output:: “hello The Greatest Post”.


Using    _construct()
-----------------
special method that is used in the first instantiation of an object that allows you to construct the object when it is invoked, as it is triggered whenever a new object is created.



Class TheGreatestPost
{
     public $word;
     public function __construct($word)
    {
        $this->word = $word;
    }

   public function print()
   {
       echo $this->word;
    }
}

$post = new TheGreatestPost('hello The Greatest Post');
$post->print();


::output:: “hello The Greatest Post”




Class Inheritance
-----------------
Through this, an extended class inherits methods and members of its parent class defined in the extend declaration.




class TheGreatestPost
{
    public function print()
    {
      echo $this->word;
     }
}

class TheGreatestPost2 extends TheGreatestPost
{
     protected $word = 'hello The Greatest Post';
}

$post = new TheGreatestPost2();
$post->print();



::output:: hello The Greatest Post

 
Simple code created by thegreatestpost.


Need more tutorial?? visit: http://www.killerphp.com/tutorials/object-oriented-php/ ( include video tutorial)
thanks to killerphp.com for video tutorial.

Thursday, January 21, 2010

Convert number to Roman numerals in PHP

This script is the way how to convert number (1,2,3,4) to roman number ( i,ii,iii,iv).
Basic roman number:

<?
function numberToRoman($num,$type){

if($type == 1){ //upper character number
// Make sure that we only use the integer portion of the value

$n = intval($num);
$result = '';

// Declare a lookup array that we will use to traverse the number:
$lookup = array('M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400,
'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40,
'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1);

foreach ($lookup as $roman => $value){
// Determine the number of matches
$matches = intval($n / $value);

// Store that many characters
$result .= str_repeat($roman, $matches);

// Substract that from the number
$n = $n % $value;
}
// The Roman numeral should be built, return it
return $result;
}
elseif($type == 2){ //low character number

// Make sure that we only use the integer portion of the value
$n = intval($num);
$result = '';

// Declare a lookup array that we will use to traverse the number:

$lookup = array('m' => 1000, 'cm' => 900, 'd' => 500, 'cd' => 400,
'c' => 100, 'xc' => 90, 'l' => 50, 'xl' => 40,
'x' => 10, 'ix' => 9, 'v' => 5, 'iv' => 4, 'i' => 1);

foreach ($lookup as $roman => $value){
// Determine the number of matches
$matches = intval($n / $value);

// Store that many characters
$result .= str_repeat($roman, $matches);

// Substract that from the number
$n = $n % $value;
}
// The Roman numeral should be built, return it
return $result;
}
}
// and your condition to call them (use function )
for($i=1;$i<1000;$i++){
echo numberToRoman($i,1)."<br>";

}
?>


modify from - go4expert.com

Wednesday, January 20, 2010

PHP list Directory and File


Script below to list directory and file using function opendir(); This is a simple code to define directory name, file name, object type and also file extension.


<?php

$dirname = "radio"; // set directory name
$dir = opendir($dirname); // open directory

while(false != ($file = readdir($dir))){

if(($file != ".") and ($file != "..")){ // prevent list hidden directory
echo filetype($dirname."/".$file); //print object type ( dir. or file )
echo "--ext. name:".pathinfo($file, PATHINFO_EXTENSION)."--"; // print file extention
echo("<a href='".$dirname."/$file'>$file</a> <br />"); // print file and the url

}

}

?>


You can customize to be photo, video, music and also others file gallery.

Folder or directory as the category and file in the directory as the item of the category.

For video you can download the plug-in form FLV JW player( posted in article before ) .

Example video listing.


Example file listing


Need a simple script? download here .

have fun!!!


- Created By Thegreatestpost.blogspot.com

Tuesday, January 19, 2010

PHP and jquery file upload with progress bar

A very nice code to add into your application, easy to understand and simple to use.
Just configure 1 php script and 1 html script.
Provide tutorial by www.webdeveloperplus.com.

This is a screen shot of my test on it.




Visit http://demo.webdeveloperplus.com/jquery-swfupload/ to download and test it, http://webdeveloperplus.com/jquery/multiple-file-upload-with-progress-bar-using-jquery/ to heaving tutorial. http://demo.webdeveloperplus.com/jquery-swfupload/ for the demonstration

Thanks to : http://webdeveloperplus.com

Monday, January 18, 2010

A way to prevent SQL injection in PHP

Add this function into yr code.

function cleanInputData($data)
{

$cleaned = trim($data);
$cleaned = mysql_real_escape_string($cleaned);
return $cleaned;

}

Friday, October 16, 2009

.htaccess url rewriting


Rewriting domain.com/index.php?page=home to domain.com/home


Add the following code to the .htaccess file.:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1


Rewriting index.php?id=12 to index/aboutus/12.html


RewriteEngine on
RewriteRule ^index/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ index.php?id=$2

Tuesday, September 29, 2009

Free FLV JW Player by Logtail video

For webmaster who are looking for video player to embed to your web, JW player is a write choice choose and free.
Just download from:

If you want to used wmv video download from :

You can get like this:


The required file that you need is :

1. player-viral.swf
2. swfobject.js
3. Your tumbnail image for video
4. Your video then
5. Your script to call video.

How to embed? use this simple code:

<script type='text/javascript' src='swfobject.js'></script> <div id='mediaspace'>This text will be replaced</div> <script type='text/javascript'>
var so = new SWFObject('player-viral.swf','ply','470','320','9','#ffffff'); so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always'); //
so.addParam('wmode','opaque'); so.addVariable('file','video.flv');
so.write('mediaspace'); </script>

* make sure your patch is correct.

To customize UI just add / modified the parameter:

Color

so.addVariable('backcolor','FFFFFF'); //background color so.addVariable('frontcolor','FFFFFF'); //frontcolor color so.addVariable('lightcolor','FFFFFF'); //lightcolor color so.addVariable('screencolor','FFFFFF'); //screen color

Size

var so = new SWFObject('player-viral.swf','ply','470','320','9','#ffffff');

For more properties visit :

Thanks to :

Monday, September 28, 2009

Basic Javascript in web

Window popup

<head>
<script type="text/javascript">
<!--
function myPopup() {
window.open( "http://www.google.com/" )
}
//-->
</script>
</head>
<body>
<form>
<input type="button" onClick="myPopup()" value="POP!">
</form>
<p onClick="myPopup()">CLICK ME TOO!</p>
</body>


Alert box

<form>
<input type="button" onclick=
"alert('Are you like the greatest post?')"
value="Confirmation Alert">
</form>


Page redirect

<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
window.location = "../javascriptredirect.php"
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<h2>Prepare to be redirected!</h2>
<p>This page is a time delay redirect, have fun with the greatset post</p>

</body>
</html>


for more... wait for update soon..

FLV video Streaming with PHP

The simple meaning of video streaming is you no need to download video to play but play the video via web, youtube.com as example.

I found a source how to make a video streaming with PHP ( flv format)
Click Here ( credit to FlashComGuru )

visit : www.flashcomguru.com

Tuesday, July 28, 2009

Export data to Excel in PHP

I will show you how to export data html to excel using php with oop implementation.
1. Create file viewhtml.php and excel.class.php(class file)

2. Write code in viewhtml.php :
*******************************

<?

ob_start(); //output buffering is active no output is sent from the script

include 'excel.class.php';

$data = "<table><tr><td>The Greatest Post</td><td>dot blogspot</td></tr></table>"; // the data you want to print

echo $data;

if(isset($_GET['export'])){

for ($i=1;$i<=5;$i++){
echo $data;
}

$create = new Excel; // create obj.

$create->CreateExcel($data,$_GET[export]); //call func. creat

}

?>

<a href="viewhtml.php?export=sini_letak_nama_file">Export Excel</a>

3. Write code in excel.class.php

**************************************

<?php

class Excel {

function CreateExcel($datatoprint,$filename){
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $datatoprint;
}

}

?>

**********************************************

4. Run page viewhtml.php then click link to test.
Have try....!!


Monday, July 27, 2009

PHP Manual

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
For who want the guide or reference to write the code, click the icon to download the manual.
"Learn then Share".



Special thanks to http://www.php.net/

Thanks to who share this manual.
Thanks to 000webhost.com to sponsor the hosting.

MySQL Manual

Mysql is a relational database management system (RDBMS) which has more than 6 million installations. MySQL stands for "My Structured Query Language".
To who are new in mysql, you can download by click the icon. "Learn then Share".




Thanks to who share this manual.
Thanks to 000webhost.com to sponsor the hosting.

Special thanks to http://www.mysql.com/