Post here source codes of small scripts.....
Source codes, small scripts...
Collapse
This is a sticky topic.
X
X
-
Redirect script webbrowser from wap to web and wapbrowser from web to wap.
PHP Code:<? $htmlredirect = "http://kralj.frih.net"; $wmlredirect = "http://kralj.r8.org"; if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0){ header("Location: ".$wmlredirect);} else{ header("Location: ".$htmlredirect); exit;} ?>
-
Easy listing the text file,you can add links ,images ,and so on
PHP Code:$p = 5; $xfile=file('test.txt'); $countfile=count($xfile); if($npage=="")$npage="1"; echo "Tests:".$countfile."\n"; $second=($p*$npage); $first=($p*($npage-1)); $npages=(int) ceil($countfile/$p); if ($npage<=$npagesAND$npage>1)$gline_rew="<a href=\"$PHP_SELF?npage=".($npage-1)."\">Prev</a>"; if ($npages > 1 AND $npage<$npages) $gline_next = "<a href=\"$PHP_SELF?npage=".($npage+1)."\">Next</a> "; for ($i = $first; $i <=*$second-1; $i++) { $a=explode("?",$xfile[$i]); $test = rtrim($a[0]); echo "$test"; } print " ".$gline_rew." ".$gline_next." ";
Comment
-
Graphic counter.
!!! Dont forget to create count.txt file and cmod 777
if your server does not support Gif image create, use png image create.
Replace
header('Content-Type: image/GIF');
ImageGIF ($im);
with
header('Content-Type: image/PNG');
ImagePNG ($im);
thats all
PHP Code:<? // Image Counter Script if(!file_exists("count.txt")) {$counter=fopen("count.txt", "a");} else {$counter=fopen("count.txt", "r+");} $aufruf=fgets($counter,100); $aufruf=$aufruf+1; rewind($counter); fputs($counter,$aufruf); fclose($counter); $im = @ImageCreate (99, 46) //change the image size here or die ("Kann keinen neuen GD-Bild-Stream erzeugen"); $background_color = ImageColorAllocate ($im, 255, 255, 255); $text_color = ImageColorAllocate ($im, 255, 0, 0); ImageString ($im, 2, 1, 1, "$aufruf", $text_color2); header('Content-Type: image/GIF'); ImageGIF ($im); ?>
Comment
-
Here is countdown script:
k:
PHP Code:<? $day = 1; $month = 1; $year = 2006; $end = mktime(0,0,0,$month,$day,$year); $today= mktime(date("G"),date("i"), date("s"),date("m"),date("d"),date("Y")); $days=($end-$today)/86400; if ($days>0) { $r1 = explode('.',$days); $hours=24*($days-$r1[0]); $r2 = explode('.',$hours); $minutes=60*($hours-$r2[0]); $r3 = explode('.',$minutes); $seconds=60*($minutes-$r3[0]); $r4 = explode('.',$seconds); echo 'Days left: ' .$r1[0]; echo ' Time left: ' . $r2[0] . ':' . $r3[0] . ':' . $r4[0]; } else { echo "Happy new year:)";} ?>
Comment
-
CLINT
<div align="center">RANDOM IMAGE SCRIPT</div>
First create a folder called image.gif and upload your images to it.
When you have done that, make a file in that folder called index.php and add this code
Now by linking to yoursite.com/image.gif (image.gif being the folder) the index file will automatically run and random images will be displayed. That means you can display random images in forums like these.PHP Code:<?php $folder = '.'; $extList = array(); $extList['gif'] = 'image/gif'; $extList['jpg'] = 'image/jpeg'; $extList['jpeg'] = 'image/jpeg'; $extList['png'] = 'image/png'; $img = null; if (substr($folder,-1) != '/') { $folder = $folder.'/'; } if (isset($_GET['img'])) { $imageInfo = pathinfo($_GET['img']); if ( isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) && file_exists( $folder.$imageInfo['basename'] ) ) { $img = $folder.$imageInfo['basename']; } } else { $fileList = array(); $handle = opendir($folder); while ( false !== ( $file = readdir($handle) ) ) { $file_info = pathinfo($file); if ( isset( $extList[ strtolower( $file_info['extension'] ) ] ) ) { $fileList[] = $file; } } closedir($handle); if (count($fileList) > 0) { $imageNumber = time() % count($fileList); $img = $folder.$fileList[$imageNumber]; } } if ($img!=null) { $imageInfo = pathinfo($img); $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ]; header ($contentType); readfile($img); } else { if ( function_exists('imagecreate') ) { header ("Content-type: image/png"); $im = @imagecreate (100, 100) or die ("Cannot initialize new GD image stream"); $background_color = imagecolorallocate ($im, 255, 255, 255); $text_color = imagecolorallocate ($im, 0,0,0); imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color); imagepng ($im); imagedestroy($im); } } ?>
Cool eh?!
Comment
-
WapBuddy File dir script.
PHP Code:<? $conf["items_per_page"] = 20; header("Content-type: text/vnd.wap.wml"); echo "<?xml version=\"1.0\"?>"; echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""." \"http://www.wapforum.org/DTD/wml_1.1.xml\">"; if (!isset($page)) {$page = 0;} $total = 0; if(!($dp = opendir("./"))) die ("Cannot open ./"); $file_array = array(); while ($file = readdir ($dp)) { if(substr($file,0,1) != '.' and $file != "index.php") { $file_array[] = $file; } } $file_count = count ($file_array); sort ($file_array); ?> <wml> <card id="card1" title=""> <p mode="nowrap"> <do type="option" label="Home"><go href="/index.php"/></do> <? echo "<a href=\"/best.php\">*Best STUFF*</a> <a href=\"/index.php\">•Home•</a> "; ?> <? if ($file_count > 0) { $first_record = $page * $conf["items_per_page"]; $last_record = $first_record + $conf["items_per_page"]; while (list($fileIndexValue, $file_name) = each ($file_array)) { if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record)) { echo "<a href=\"$file_name\">$file_name</a> (". round(filesize($file_name)/1024,1) . "kb) "; $total = $total + filesize($file_name); } } if (($file_count > 0) AND ($page != 0)) { // previous button $prev_page = $page -1; echo " <a href=\"".$_SERVER["PHP_SELF"]."?page=$prev_page\">Prev</a> "; } if (($file_count > 0) AND ($last_record < $file_count)) { // next button $next_page = $page + 1; echo " <a href=\"".$_SERVER["PHP_SELF"]."?page=$next_page\">Next</a> "; } echo " Directory: $file_count "; if ($file_count == 1) {echo "file";} else {echo "files";} echo " (" . round($total/1024,1) . "kb)"; echo " <a href=\"/index.php\">•Home•</a>"; echo " <a href=\"/downloads.php\">?Downloads</a>"; echo " <a href=\"page.php\">Pages</a>"; } closedir($dp); ?> </p> </card> </wml>
Comment
-
CLINT
TIME MESSAGES
PHP Code:<?php $TimeZone="8"; ////Change the TimeZone accordingly! $New_Time = time() + ($TimeZone * 60 * 60); $show_date=date("D dS F, Y",$New_Time); $show_time=date("H:i",$New_Time); $Hour=date("G",$New_Time); echo $show_date; echo" "; echo $show_time; echo" "; ////////////////Here you can change the messages, add lines with different hours etc. You could even display a different message every hour.//////////////// if ($Hour <= 4) { echo 'Hello night owl!'; } else if ($Hour <= 11) { echo 'Good morning!'; } else if ($Hour <= 12) { echo 'Enjoy your lunch!'; } else if ($Hour <= 17) { echo 'Good afternoon!'; } else if ($Hour <= 23) { echo 'Good Evening!'; } ?>
Comment
-
FTP UPLOAD SCRIPT IT CAN ALSO BE USED FOR WAP
CODE
PHP Code:<?php $ftp_server = "..."; $ftp_user = "..."; $ftp_pass = "..."; $remote_file = "movie.mpg"; $local_file = "/tmp/movie.mpg"; // set up a connection or die $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); // try to login if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected as $ftp_user@$ftp_server\n"; // upload a file if (ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY)) { echo "successfully uploaded $file\n"; } else { echo "There was a problem while uploading $file\n"; } } else { echo "Couldn't connect as $ftp_user\n"; } // close the connection ftp_close($conn_id); ?>
Comment
-
CLINT
ONLINE USERS
Display who is online. Create a file called besucher.txt and chmod to 777.
Now create a file called online.php or whatever and add this.
I think this is one of GumSlone's scripts.PHP Code:<? header("Content-Type: text/vnd.wap.wml"); echo '<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head> <card title="Online"> <do type="prev" label="Back"><prev/></do>'; print " "; $xfile = @file("besucher.txt"); $xfile = array_reverse($xfile); $p = 150; if ($npage == ""){$npage = "1";} $first = count($xfile) - ($p * ($npage - 1)); $second = count($xfile) - ($p * $npage) + 1; if ($second < 1) {$second = 1;} $npages = (int)(count($xfile) / $p); if ($news_limiter>((int) ($npages*$p))) $npages = $npages+1; if ($npage <= $npages and $npage>1) $gline_rew = "<a href=\"guest.php?npage=".($npage-1)."\">Prev</a>"; if ($npages > 1 and $npage<$npages) $gline_next = "<a href=\"guest.php?npage=".($npage+1)."\">Next</a>"; $line = ""; for ($p = 1; $p <= $npages; $p++) { if ($p != $npage) { $line .= "<a href=\"guest.php?npage=$p\"> $p </a>|";} if ($p == $npage) { $line .= "| $p | "; } } print $line; for ($i = $first-1; $i >= $second-1; $i--) { $ii = $i; $ii++; $udata = explode("&&",$xfile[$i]); print "$udata[1] "; print "-------- "; } print $gline_rew."".$gline_next." <a href=\"/index.php\">LandOfwap.net</a></p> </card> </wml>"; ?>
Comment
-
hits and useronline in one
create folder counter
create besucher.txt
upload useronline.php and guest.php and edit them
add this cod to your main php page
guest.phpPHP Code:$szamlalo_File = "counter/".date("Ymd").".txt"; if (file_exists($szamlalo_File)) { $szamlalo_fp = fopen($szamlalo_File,"r"); $szamlalo_num = fread($szamlalo_fp, filesize($szamlalo_File)); fclose($szamlalo_fp); } $szamlalo_num=$szamlalo_num+1; $szamlalo_fp = fopen($szamlalo_File,"w"); fwrite($szamlalo_fp, $szamlalo_num, 10); fclose($szamlalo_fp); $counter_array = file("counter.dat"); $all = $counter_array[0]+1; $fp = @fopen("counter.dat","wb"); @fputs($fp,$all); @fclose($fp); echo "Visit number: $all Visits today $szamlalo_num Online <a href=\"guest.php\">$anzahl</a>";
useronline.phpPHP Code:<? header("Content-Type: text/vnd.wap.wml"); header("Cache-control: no-cache, must-revalidate"); echo '<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card title="UserOnline"> <do type="prev" label="Back"><prev/></do>'; print " "; $xfile = @file("besucher.txt"); $xfile = array_reverse($xfile); $p = 150; if ($npage == ""){$npage = "1";} $first = count($xfile) - ($p * ($npage - 1)); $second = count($xfile) - ($p * $npage) + 1; if ($second < 1) {$second = 1;} $npages = (int)(count($xfile) / $p); if ($news_limiter>((int) ($npages*$p))) $npages = $npages+1; if ($npage <= $npages and $npage>1) $gline_rew = "<a href=\"guest.php?npage=".($npage-1)."\">prev</a>"; if ($npages > 1 and $npage<$npages) $gline_next = "<a href=\"guest.php?npage=".($npage+1)."\">next</a>"; $line = ""; for ($p = 1; $p <= $npages; $p++) { if ($p != $npage) { $line .= "<a href=\"guest.php?npage=$p\"> $p </a>|";} if ($p == $npage) { $line .= "| $p | "; } } print $line; for ($i = $first-1; $i >= $second-1; $i--) { $ii = $i; $ii++; $udata = explode("&&",$xfile[$i]); print "$udata[1] "; } print $gline_rew."".$gline_next." -------- <a href=\" index.php\">?Back</a>? wapkralj </p> </card> </wml>"; ?>
PHP Code:<? $daten="besucher.txt"; $time = time(); $brow=("$REMOTE_ADDR"); $user = explode ('/', $HTTP_USER_AGENT); $ip = ("Browser: $user[0] IP: $brow"); $ablaufzeit = "$time"-"300"; //zdes mozhno nastroit wremja kak dolgo ip budet xranitsja w txt fajle $pruefung = @file($daten); while (list ($line_num, $line) = @each ($pruefung)) {$zeiten = explode("&&",$line); if($zeiten[0] <= $ablaufzeit) {$fp = fopen( "$daten", "r" ); $contents = fread($fp, filesize($daten)); fclose($fp); $line=quotemeta($line); $string2 = ""; $replace = ereg_replace($line, $string2, $contents); $fh=fopen($daten, "w"); @flock($fp,2); fputs($fh, $replace); @flock($fp,3); fclose($fh);}} $ippruefung = @file($daten); while (list ($line_num, $line) = @each ($ippruefung)) {$ips = explode("&&",$line); if($ips[1] == $ip) {$fp = fopen( "$daten", "r" ); $contents = fread($fp, filesize($daten)); fclose($fp); $line=quotemeta($line); $string2 = ""; $replace = ereg_replace($line, $string2, $contents); $fh=fopen($daten, "w"); @flock($fp,2); fputs($fh, $replace); @flock($fp,3); fclose($fh);}} $fp = fopen("$daten", "a+"); flock($fp,2); fputs ($fp, "$time&&$ip&&\n"); flock($fp,3); fclose ($fp); $anzahldaten = file($daten); $anzahl = count($anzahldaten); //eto pokazivaet koli4estwo 4elowek na sajte, nado sozdat eshe textfile besucher.txt**i ego chmod777, u menja etot script wstawlen tolko w index.php kone4no mozhesh wstawit ego w kazhduju stranicu*/ ?>
Comment
-
CLINT
PHONE ENVIRONMENT
I got this code from a post that GumSlone made in the forums that got deleted.
PHP Code:<? header("Content-type:text/vnd.wap.wml;charset=UTF-8"); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n <wml>\n <head>\n <meta name=\"vnd.up.markable\" content=\"true\" forua=\"true\"/> \n <meta http-equiv=\"Cache-Control\" content=\"max-age=30\" forua=\"true\" /> \n </head>\n <card title=\"Enviroment\">\n"; print "<p align=\"center\"> <img src=\"phone_type.php\" alt=\"\"/> User Agent: $HTTP_USER_AGENT IP-Adress: $REMOTE_ADDR Port: $REMOTE_PORT Accept Mime Types: $HTTP_ACCEPT Language: $HTTP_ACCEPT_LANGUAGE Accept Charset: $HTTP_ACCEPT_CHARSET -------- \n"; echo "<a href=\"http://landofwap.net/index.php\">LandOfWap.net</a> </p></card></wml>\n"; ?>
Comment
-
some of my posts are from that gumslones deleted posts,i will post others too
take look little add on on that, only the host
PHP Code:<? header("Content-type:text/vnd.wap.wml;charset=UTF-8"); print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n <wml>\n <head>\n <meta name=\"vnd.up.markable\" content=\"true\" forua=\"true\"/> \n <meta name=\"Description\" content=\"wapkralj\" forua=\"true\"/> \n <meta name=\"Keywords\" content=\"Free, ringtones, polyphones, mmf, midi, mp3, amr, jar, thm, sis, games, logo, wallpapers, 3gp, videos, pictures, erotic, display, themes, java, nokia, samsung, sonyericsson, se, siemens, wap, chat, forum, wap, exchanger, porn, adult,\" forua=\"true\"/> \n <meta http-equiv=\"Cache-Control\" content=\"max-age=0\" forua=\"true\" /> \n </head>\n <card title=\"Information\">\n"; $hostsnames=gethostbyaddr($REMOTE_ADDR); print " <do type=\"prev\" label=\"Back\"><prev/></do> <p align=\"center\">Informations about your phone or browser</p> Browser: $HTTP_USER_AGENT IP address: $REMOTE_ADDR Port: $REMOTE_PORT Host: $hostsnames Mime types: $HTTP_ACCEPT Language: $HTTP_ACCEPT_LANGUAGE Accept Charset: $HTTP_ACCEPT_CHARSET </p>\n"; echo " <a href=\"index.php/\">Home</a> (c) wapkralj </p></card></wml>\n"; ?>
Comment
-
CLINT
SCRIPT TIMER
PHP Code:<?php function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $time_start = microtime(1); for ($i=0; $i < 100000; $i++) { } $time_end = microtime(1); $time = $time_end - $time_start; echo "Script timer: "; echo "[b]$time [/b]"; echo " seconds\n"; ?>
Comment

Comment