Saturday, August 7, 2010

Easy birthdate dropdown

PHP Code:
/*
using
echo Birthday("22", "09", "1989");
*/
function Birthday($day="01"$month="01"$year="1980"){$rform "";$dayval range('1','31');
foreach (
$dayval as $key){
if(
$key<10){$keyadd "0$key";
}else{
$keyadd "$key";
}
if(
$day==$keyadd){$rform .= "$keyadd";
}else{
$rform .= "$keyadd";
}
}
$rform .= " ";$rform .= "";$monthval = array('1'=>'Jan''Feb''Mar''Apr''May''Jun''Jul''Aug''Sep''Oct''Nov''Dec');
foreach (
$monthval as $val => $months){
if(
$val<10){$keyadd "0$val";
}else{
$keyadd "$val";
}
if(
$month==$keyadd){$rform .= "$months";
}else{
$rform .= "$months";
}
}
$rform .= " ";$rform .= "";$yearval range('1950','2009');//you can define range year here from year -> to year
foreach ($yearval as $key){
if(
$year==$key){$rform .= "$key";
}else{
$rform .= "$key";
}
}
$rform .= "";
return 
$rform;
}  

Easy Paginantion For Lavalair or Maybe For All script ...


PHP Code:
/*
LEGEND
======

$ipp = items_per_pages
$p = $_GET["page"]
$ni = num_items
$np = num_pages
$npc = num_pagesc

$url = like "index.php?action=main&ses=$ses
Using:
echo Paging("$url", $p, $np, $npc, $ipp, $ls, $ni);
*/

if($p=="" || $p<=0)$p=1$noi mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM tablename")); $ni $noi[0]; //changable $ipp5$np ceil($ni/$ipp); $npc ceil($ni/$ipp);
if((
$p>$np)&&$p!=1)$p$np$ls = ($p-1)*$ipp;
$sql "SELECT *  FROM tablename ORDER BY orderid DESC LIMIT $ls, $ipp"$items mysql_query($sql);
echo 
mysql_error();
if(
mysql_num_rows($items)>0){
while (
$item mysql_fetch_array($items)){

}
}else{
echo 
"dataEmpty";
}



echo 
"";
echo 
Paging("?action=$action&session=$session"$p$np$npc$ipp$ls$ni);
// Recall Jump Page if($np>2){ $rets ""$rets .= ""$rets .= ""$rets .= "Jump
"$rets .= "";
echo 
$rets;
}
echo 
"";  








PHP Code:
function Paging($pagename$p$np$npc$ipp$ls$ni){ $nav=' ';
if(
$p<=3){ $px=1$np=$p+3;
}

if(
$p>3){ $px=$p-3$np=$p+3;
}
if(
$p>=($npc-3)){ $np=$npc;
}
for(
$jp=$px$jp<=$np$jp++){
if(
$jp==$p){ $nav .= "[$jp] "
;
}else{ 
$nav .= [$jp] ";
}
}
if(
$p>1){ $pp $p-1$left "«Prev ";
}
if(
$p<$np){ $npg $p+1$right "Next»";
}
if(
$p>4) { $jp=$p-1$first="«First";
}else{ 
$first='';
}
if(
$p<($npc-3)){ $jp=$p+1$last="Last»";
}else{ 
$last='';
}
if(
$ni>$ipp) { $paging "Page $p of $npc"$paging .= "$left  $right
 $first  $nav  $last "
;
}

if(
$ipp>$ni){ $paging .= "Page $np of $np";
}else if(
$ni==0){ $paging .= "Page 0 of 0";
}

return 
$paging;

}  
here is CSS
HTML Code:
.paging{
text-align:center;
}

.disable{
background-color: black;
color:#000;
}





here is random in one day.

/*
using

echo $display;
*/
$date date("d");$myFile "record.dat";$fh fopen($myFile'r');$theData fread($fh5);fclose($fh);
if(
$theData==$date){$myFile "imgrecord.dat";$fh fopen($myFile'r');$theData fgets($fh);fclose($fh);//display image$display '.$theData.'" alt="*" border=0 width="281"/>';
}else{
$imglist='';//$img_folder is the variable that holds the path to the banner images. Mine is images/tutorials/
// see that you don't forget about the "/" at the end
$img_folder "imgrandom/";mt_srand((double)microtime()*1000);//use the directory class$imgs dir($img_folder);//read all files from the directory, checks if are images and ads them to a list (see below how to display flash banners)while ($file $imgs->read()) {
if (
eregi("gif"$file) || eregi("jpg"$file) || eregi("png"$file))$imglist .= "$file ";
closedir($imgs->handle);//put all images into an array$imglist explode(" "$imglist);$no sizeof($imglist)-2;//generate a random number between 0 and the number of images$random mt_rand(0$no);$image $imglist[$random];$myFile "record.dat";$fh fopen($myFile'w') or die("can't open file");$stringData $date;fwrite($fh$stringData);fclose($fh);$myFile "imgrecord.dat";$fh fopen($myFile'w') or die("can't open file");$stringData $img_folder.$image;fwrite($fh$stringData);fclose($fh);
}  





dont forget to create this file
record.dat [CHMOD 777]
imgrecord.dat [CHMOD 777]
imgrandom [FOLDER]

How To Show Random Images From A Folder


selects a random favicon

selects a random favicon from a specified directory. copy and paste it into the html head tag and change the dir variable to your icons directory.
Code:
";
?>

chat


PHP Code:

class chat {
function 
a_header($title 'chat-zone.mobi',$time_update '0'){
header("Cache-Control: no-store, no-cache");header("Content-type:text/html; charset=utf-8");

echo 
'
.rootlink.'css/css.css"/>
'
;if (!empty($time_update)){echo '.$time_update.'" />';}echo '';
}
function 
a_footer($url '',$name 'Logout')
{
if (empty(
$url))  {$urlrootlink.'?action=logout';}
echo 
'.$url.'&'.SID.'">'.$name.'
';
}
function 
write($text)
{
echo 
$text;
}
function 
form($link 'index.php',$method 'post')
{
echo 
'.$link.'" method="'.$method.'">';
}
function 
input($text,$name,$size='',$maxlength,$value '')
{
if(!empty(
$text)){echo $text.'
'
;}
echo 
'.$name.'" ';
if(
$size && !empty($size)){echo 'size="'.$size.'" ';}
if(
$maxlength 0){echo 'maxlength="'.$maxlength.'" ';}
echo 
'value="'.$value.'" class="itext"/>
'
;
}
function 
hidden($name,$value)
{
echo 
'.$name.'" value="'.$value.'"/>';
}
function 
checkbox($name,$value,$nme '')
{
echo 
'.$name.'" value="'.$value.'"/>'.$nme.'
'
;
}
function 
button($name,$value,$o '',$c '')
{
if(!empty(
$c)){echo '.$name.'" value="'.$value.'" checked="checked"/>'.$o.'
'
;}
else{echo 
'.$name.'" value="'.$value.'"/>'.$o.'
'
;}
}
function 
end_form($value)
{
echo 
'.$value.'" class="ibutton"/>';
}
function 
select($name$value)
{
echo 
'.$name.'" value="'.$value.'">';
}
function 
addselect($value$label)
{
echo 
'.$value.'">'.$label.'';
}
function 
select_end()
{
echo 
'
'
;
}
}
?>
usage

chat::a_header('chat-zone.mobi');
chat::write('hi');
chat::a_footer();
or
$chatcls = new chat;
$chatcls->input('login',login,'15','15',$_SESSION['nicks']);




Multi Auto Redirection

PHP Code:
  /*
  Multi Auto Redirection
  
      /\             / -------
     /     \   _   /    ----------
    / /     \[.. ]/    ---------
   ////// ' \/ `   ------
  ////  // :    : ------
 // /   /  /`    '----
//          //..\\
          ==UU==UU==
             '//||\\`
  
  By opticalpigion
  */
//set the urls   
$urls = array("http://google.com" ,"http://hotmail.com" ,"http://hawkee.com" );  
   
//set the text links   $text = array("Google" ,"Hotmail" ,"Hawkee");  
        
srand(time());  
   
//set the number in (rand()%3); for however many links there are  
        
$random = (rand()%3);   header'Location:'.$urls[$random]) ; ?>