Source codes, small scripts...

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    //dayly counter counts hits or hosts

    PHP Code:
    $fpt "daily.txt"// path to counter log file - chmod it to 666
    $lock_ip =0// IP locking and logging 1=yes 0=no
    $ip_lock_timeout =30// in minutes
    $fpt_ip "ip.txt"// IP log file - chmod it to 666

    function checkIP($rem_addr) {
    global 
    $fpt_ip,$ip_lock_timeout;
    $ip_array = @file($fpt_ip);
    $reload_dat fopen($fpt_ip,"w");
    $this_time time();
    for (
    $i=0$i<sizeof($ip_array); $i++) {
    list(
    $time_stamp,$ip_addr,$hostname) = split("\|",$ip_array[$i]);
    if (
    $this_time < ($time_stamp+60*$ip_lock_timeout)) {
    if (
    $ip_addr == $rem_addr) {
    $found=1;
    }
    else {
    fwrite($reload_dat,"$time_stamp|$ip_addr|$hostname");
    }
    }
    }
    $host gethostbyaddr($rem_addr);
    if (!
    $host) { $host $rem_addr; }
    fwrite($reload_dat,"$this_time|$rem_addr|$host\n");
    fclose($reload_dat);
    return (
    $found==1) ? 0;
    }
    $this_day=(date("D, j F Y"));
    if (!
    file_exists($fpt)) {
    $count_dat fopen($fpt,"w+");
    $count 1;
    fwrite($count_dat,$count);
    fclose($count_dat);
    }
    else {
    $row file($fpt);
    $test chop($row[0]);
    $count $row[1];
    if (
    $this_day == $test) {
    if (
    $lock_ip==|| ($lock_ip==&& checkIP($REMOTE_ADDR)==0)) {
    $count++;
    }
    }
    else {
    $count 1;
    }
    $count_dat fopen($fpt,"w+");
    fwrite($count_dat,"$this_day\n");
    fwrite($count_dat,$count);
    fclose($count_dat);
    }
    echo 
    "$count"

    Comment


      #17
      Wap ftp checker:
      PHP Code:
      <?php 
      // 1 of 2 attempts to get the WAP browser to flush the cache 
      // 
      header("Content-type: text/vnd.wap.wml"); 
      header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
      header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT"); 
      header("Cache-Control: no-cache, must-revalidate"); 
      header("Pragma: no-cache"); 
      echo 
      "<?xml version=\"1.0\"?>"
      echo 
      "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" 
      " \"http://www.wapforum.org/DTD/wml_1.1.xml\">"
      echo 
      "\n\n"
      ?> 
      <wml> 
      <head> 
      // 2 of 2 attempts to get the WAP browser to flush the cache 
      // 
      <meta http-equiv="Cache-Control" content="must-revalidate" forua="true"/> 
      <meta http-equiv="Cache-Control" content="max-age=0" forua="true"/> 
      </head> 
      <template> 
      <do type="prev" label="Previous"> 
      <prev/> 
      </do> 
      </template> 
      <?php 
      $Uid 
      'ftp_user';
      $Upw 'ftp_password';
      $ftp_server 'some_ftp_server';// this should be your ftp server 
      $conn_id ftp_connect($ftp_server); 
      $login_result  ftp_login($conn_id$Uid$Upw); 
      echo 
      "<card id=\"card2\" title=\"$ftp_server\">"// .. in case we needed reminding 
      echo "

      "

      // 
      if ((!$conn_id) || (!$login_result)) // need a successful connect and login 

      echo 
      "FTP connection failed!"
      echo 
      "
      "

      echo 
      $login_result
      exit; 

      else 

      $dir=ftp_pwd($conn_id); 
      $list=Array();// define an array 
      $list=ftp_rawlist($conn_id"$dir");// run a raw directory listing and store in array 
      // 
      $i0;// initialise (element) counter variable 
      $files0;// initialise file counter variable 
      $dirs** = 0;// initialise directory counter variable 
      // 
      while ( $list[$i] )// .. loop round array.. 

      if( 
      substr($list[$i], 0) == "-" ) { $files++; }// look for real files 
      elseif( substr($list[$i], 0) == "d" ) { $dirs++;} // look for directories 
      $i++;// incr element counter 

      print 
      htmlspecialchars($Uname);// and display the results ! 
      print "
      "

      print 
      "User=$Uid
      $filesfile(s)
      $dirsdir(s)"
      ftp_close($conn_id); 

      ?> 
      </p> 
      </card> 
      </wml>

      Comment


        #18
        LOAD TIME
        PHP Code:
        <?php

        // Insert at the very top of your page

        $time microtime();
        $time explode(" "$time);
        $time $time[1] + $time[0];
        $start $time;

        ?>
        PHP Code:
        <?php

        // Place at the very bottom of your page

        $time microtime();
        $time explode(" "$time);
        $time $time[1] + $time[0];
        $finish $time;
        $totaltime = ($finish $start);
        printf ("Page took %f seconds to load."$totaltime);
        // The above line can be changed but remember to keep %f 

        ?>
        = = = = =
        The more you laugh...the longer you live.
        Read more jokes at
        http://fun-files.co.cc

        Comment


          #19
          Environment variables
          HTTP and HTTP_X_UP Environment variables, used to detect user agent hardware specs and ID
          ================================================== ==============================
          ========================
          Environment Variable Description

          HTTP_ACCEPT List of HDML versions accepted by device
          HTTP_ACCEPT_LANGUAGE Language in use on device
          HTTP_COOKIE HTTP cookies in standard format
          HTTP_REFERER URL of the deck originating the request
          HTTP_USER_AGENT Browser/version & Server/version
          HTTP_X_UP_DEVCAP_CHARSET Character set used by the device
          HTTP_X_UP_DEVCAP_IMMED_ALERT Specifies if device supports immediate alerts
          HTTP_X_UP_DEVCAP_MAX_PDU Maximum packet size supported by device (normally 1492 bytes)
          HTTP_X_UP_DEVCAP_NUMSOFTKEYS Number of softkeys on the device
          HTTP_X_UP_DEVCAP_SCREENPIXELS Width, Height of display in pixels
          HTTP_X_UP_DEVCAP_SMARTDIALING Specifies if device supports smart dialing
          HTTP_X_UP_FAX_ACCEPTS Specifies acceptable fax types
          HTTP_X_UP_FAX_ENCODING List of fax encoding types that the server accepts
          HTTP_X_UP_FAX_LIMIT Maximum fax size in bytes that the server accepts
          HTTP_X_UP_SUBNO Subscriber ID, globally unique device ID
          HTTP_X_UP_UPLINK The host on which the server is installed
          ================================================== ==============================
          ========================

          Below a small Perl demo, donated to Hicon by Aniceto L?pez and Iv?n Font?n from www.latinia.com
          PHP Code:
          #!/usr/bin/perl
          ##########################################
          ##  WAP Environment                               
          ##  Developed by Latinia ([url]www.latinia.com[/url]) 
          ##########################################

          print "Content-type: text/vnd.wap.wml\n\n";
          print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
          print "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n";
          print "<wml>\n";
          print "<card>\n";
          print "

          \n";
          print "USER AGENT : $ENV{'HTTP_USER_AGENT'}\n";
          print "REMOTE ADDRESS : $ENV{'REMOTE_ADDR'}\n";
          print "USER ID : $ENV{'HTTP_X_UP_SUBNO'}\n";
          print "GATEWAY NAME : $ENV{'HTTP_X_UP_UPLINK'}\n";
          print "OPERADOR : $ENV{'REMOTE_ADDR'}\n";
          print "</p>\n";
          print "</card>\n";
          print "</wml>\n";
          Create count.txt and chmod 777
          = = = = =
          The more you laugh...the longer you live.
          Read more jokes at
          http://fun-files.co.cc

          Comment


            #20
            allows of exchange the size of an image in php veiled Ca can be very useful for the site wap/i-mode since it changes as the weight of the file doncs Ca allows as the page would not be too heavy
            size.php :
            /// < img src="size.php?pic=(url of your image)&w_max=(largor maximum)&h_max=(hautor)">
            PHP Code:
            <?php
            $taille 
            getimagesize("$pic"); 
            $h_i $taille[1]; 
            $w_i $taille[0]; 
            if(
            $h_i >$h_max

            $convert=$h_max/$h_i
            $h_i=$h_max
            $w_i=ceil($w_i*$convert); 

            if(
            $w_i >$w_max

            $convert=$w_max/$w_i
            $w_i=$w_max
            $h_i=ceil($h_i*$convert); 
            }; 

            $largeur "$w_i";
            $hauteur ="$h_i";

            header("Content-Type: image/jpeg");
            list(
            $width$height$type$attr) = getimagesize("$pic");

            if(
            $type == "1")
            {
            $img_in imagecreatefromgif($pic);
            }

            if(
            $type == "2")
            {
            $img_in imagecreatefromjpeg($pic);
            }

            if(
            $type == "3")
            {
            $img_in imagecreatefrompng($pic);
            }

            $img_out imagecreatetruecolor($largeur$hauteur);
            imagecopyresampled($img_out$img_in0000imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in));
            $t imagejpeg($img_out);
            echo 
            $t;
            ?>

            Comment


              #21
              SOURCE CODE VIEWER

              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="Source Code Viewer">

              <do type="prev" label="Back"><prev/></do>';
              print "

              ";

              if ($url == "") {
              echo "ENTER URL:
              <input type=\"text\" name=\"url\" maxlength=\"999\" emptyok=\"false\" value=\"http://\"/>
              <anchor>[GO]<go href=\"$PHP_SELF?url=$url\" method=\"post\"><postfield name=\"url\" value=\"$(url)\"/></go></anchor>";
              }


              if ($url == "$url") {
              $udata=@file_get_contents("$url");

              $udata = str_replace("$","$$",$udata);
              $udata = str_replace("&","&amp;",$udata);
              $udata = str_replace("'","&apos;",$udata);
              $udata = str_replace("<","&lt;",$udata);
              $udata = str_replace(">","&gt;",$udata);
              $udata = str_replace("\"","&quot;",$udata);
              $udata = str_replace("-","*",$udata);

              print "$udata
              ";
              }


              print "
              <a href=\"http://LandOfWap.net\">(c) LandOfwap.net</a></p>
              </card>
              </wml>";

              ?>

              Comment


                #22
                Thanx guys for puting all previous scripts and codes back to the forum
                Advertise your mobile site for FREE with AdTwirl

                Comment


                  #23
                  I THINK IT THE MOUST USEFUL REDIRECTOR SCRIPT
                  -----------------------------------------------------------------
                  PHP Code:
                  <? /* Si scripta includine i index.php ar koki kita faila turesite apsauga nuo visokiu source ir mozilla */ 
                  $apsauga=1; if($apsauga==1){ $browser=$_SERVER['HTTP_USER_AGENT']; $pos=strpos($browser,'/'); if($pos!=0) 
                  {
                  $browser2=substr($browser,0,$pos);

                  $words = explode("WinWAP", $browser); 
                  $kik= count($words); if($kik>=2)
                  { $stop=1; }
                  $words = explode("WapSilon", $browser); 
                  $kik= count($words); if($kik>=2)
                  { $stop=1; } 
                  $words = explode("cURL PHP", $browser); 
                  $kik= count($words); if($kik>=2)
                  { $stop=1; } 
                  $words = explode("Mozilla", $browser); 
                  $kik=count($words); if($kik>=2)
                  { $stop=1; }
                  $words = explode("Opera", $browser); 
                  $kik= count($words); if($kik>=2)
                  { $stop=1; }
                  $words = explode("portalmmm", $browser); $kik= count($words); if($kik>=2)
                  { $stop=1; } 
                  $words = explode("ReqwirelessWeb", $browser); $kik= count($words); if($kik>=2)
                  { $stop=1; } 
                  $words = explode("lwp-trivial",$browser); 
                  $kik= count($words);
                  if($kik>=2)
                  { $stop=1; } 
                  $words = explode("Nokia-WAPToolkit", $browser); 
                  $kik= count($words); if($kik>=2)
                  { $stop=1; } if(!$browser)
                  { $stop=1; } if($browser="")
                  { $stop=1; } if($stop==1) { $wmlredirect = "http://hifi-project.net";

                  header("Location: ".$wmlredirect); exit; } }  ?>
                  ------------------------------------------------------------------------------------
                  www.inbuzunar.mobi - Your mobile portal pocket

                  Comment


                    #24
                    WEB/WAP Redirection script

                    PHP Code:
                    if (strpos(strtolower($_SERVER["HTTP_ACCEPT"]), "text/vnd.wap.wml") !== false ||
                    strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "text/html") !== false$wml_device true;
                    else 
                    $wml_device false;

                    if(
                    $wml_device == false)header ('Location: http://wapforum.org.uk/');
                    if(
                    $wml_device == true)header ('Location: http://2wap.net/'); 
                    Advertise your mobile site for FREE with AdTwirl

                    Comment


                      #25
                      one from mobiilichat
                      PHP Code:
                      <?PHP

                      // A file to redirect users based on their browsers.

                      $htmlredirect "home.html";
                      $wmlredirect "home.wml";**if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0) {$br "WML";}
                      else {
                      $browser=substr(trim($HTTP_USER_AGENT),0,4);
                      if(
                      $browser=="Noki" || // Nokia phones and emulators
                      $browser=="Eric" || // Ericsson WAP phones and emulators
                      $browser=="SAMS" || // Samsung
                      $browser=="Sony" || // SonyEricsson
                      $browser=="WapI" || // Ericsson WapIDE 2.0
                      $browser=="MC21" || // Ericsson MC218
                      $browser=="AUR " || // Ericsson R320
                      $browser=="R380" || // Ericsson R380
                      $browser=="UP.B" || // UP.Browser
                      $browser=="WinW" || // WinWAP browser
                      $browser=="UPG1" || // UP.SDK 4.0
                      $browser=="upsi" || // another kind of UP.Browser ??
                      $browser=="QWAP" || // unknown QWAPPER browser
                      $browser=="Jigs" || // unknown JigSaw browser
                      $browser=="Java" || // unknown Java based browser
                      $browser=="Alca" || // unknown Alcatel-BE3 browser (UP based?)
                      $browser=="MITS" || // unknown Mitsubishi browser
                      $browser=="MOT-" || // unknown browser (UP based?)
                      $browser=="My S" || // unknown Ericsson devkit browser ?
                      $browser=="WAPJ" || // Virtual WAPJAG [url]www.wapjag.de[/url]
                      $browser=="fetc" || // fetchpage.cgi Perl script from [url]www.wapcab.de[/url]
                      $browser=="Klon" || // Klondike WapBrowser
                      $browser=="ALAV" || // yet another unknown UP based browser ?
                      $browser=="Oper" || // Opera
                      $browser=="Wapa"// another unknown browser ("Wapalyzer"?)
                      {$br "WML";}
                      else {
                      $br "HTML";
                      }}
                      if(
                      $br == "WML") {
                      header("302 Moved Temporarily");
                      header("Location: ".$wmlredirect);
                      exit;}
                      else 
                      {
                      header("302 Moved Temporarily");
                      header("Location: ".$htmlredirect);
                      exit;}

                      ?>

                      Comment


                        #26
                        ---------------------------CODE-----------------------------------
                        REDIRECTION SCRIPT
                        PHP Code:
                        <?

                        $htmlredirect = "http://abhisar.6te.net/xforum";
                        $wmlredirect = "http://abhisar.6te.net";

                        if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0)
                        {
                        header("Location: ".$wmlredirect);

                        }
                        else
                        {
                        header("Location: ".$htmlredirect);
                        exit;
                        }
                        ?>
                        --------------------------------------------------------------------

                        Comment


                          #27
                          COOL SCRIPT TIMER
                          -------------------------------------------
                          PHP Code:
                          <?php


                          function
                          get_microtime()
                          {
                          list(
                          $usec$sec) = explode(" "microtime());

                          return ((double)
                          $usec+(double)$sec);
                          }
                          $start get_microtime();

                          //Toliau failo turinys

                          $end get_microtime();
                          $native round((float)(($end $start) * 1000), 2);

                          echo 
                          "SCRIPT LOAD: $native ms";

                          ?>
                          -------------------------------------------

                          YEAR COUNTDOWN
                          ------------------------------------
                          PHP Code:
                          <?php $diena=date("z"); $liko=365-$diena; echo"[b]DAYS LEFT:[/b][size="1"] $liko[/size]"?>
                          ------------------------------------
                          www.inbuzunar.mobi - Your mobile portal pocket

                          Comment


                            #28
                            this one works, u forgot a space after the echo kiss

                            PHP Code:
                            <?php $diena=date("z"); $liko=365-$diena; echo "DAYS LEFT: $liko"?>
                            or jst put this anywhere

                            PHP Code:
                            $diena=date("z"); $liko=365-$diena
                            echo 
                            "
                            $liko days left till new years!"
                            8th wonder of the world

                            Comment


                              #29
                              GOOD SOURCE VIEWER
                              -----------------------------------------
                              PHP Code:
                              <?php header("Content-type: text/vnd.wap.wml"); 
                              header("Cache-control: no-store,no-cache,must-revalidate"); 
                              print 
                              '<?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>
                              <card id="index" title="SOURCE VIEWER">
                              <p align="left">'
                              $_GET['id']; if($id == "") { echo"ENTER URL:
                              <input type=\"text\" name=\"url\" maxlength=\"999\" emptyok=\"false\" value=\"http://\"/>
                              "
                              ; echo"<anchor>|get|<go href=\"index.php?id=result\" method=\"post\"><postfield name=\"url\" value=\"$(url)\"/></go></anchor>
                              ----------
                              "
                              ; }   if($id =="result") { echo "SOURCE RESULT OF:
                              <a href=\"
                              $url\">$url</a>
                              "
                              ; echo "
                              "
                              $url $_POST['url']; $ff= @htmlspecialchars(file_get_contents($url)); if(!$ff) { echo"SITE NOT IN ACTION!!!
                              "
                              ; } if(ereg("http://",$url)) { echo"$ff"; } else { echo"SOURCE FAILED!!!";  } } echo "<a href=\"http://hifi-project.net/rating/?cid=1\"><img src=\"http://hifi-project.net/rating/count.php?id=1\" alt=\"w@p rating\"/></a>
                              <a href=\"http://hifi-project.net/index.php\">|home|</a>"
                              ;
                              ?>
                              </p>
                              </card>
                              </wml>
                              -----------------------------------------
                              www.inbuzunar.mobi - Your mobile portal pocket

                              Comment


                                #30
                                Here is the php code for xex collors, it shows color and the hex code

                                PHP Code:
                                <html>
                                <head>
                                <title>Websafe Colors</title>
                                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
                                </head>
                                <body bgcolor="#000000">
                                <?php
                                $hex 
                                = array("00""33""66""99""CC""FF");
                                echo 
                                "<h1><font color='#FFFFFF'>Web Safe Color Chart</font></h1><hr>";
                                echo 
                                "<table border='0'>";
                                for (
                                $r=0$r<count($hex); $r++){ //the red colors loop
                                  
                                for ($g=0$g<count($hex); $g++){ //the green colors loop
                                    
                                echo "<tr>"//Define a row for the six blue colors
                                    
                                for ($b=0$b<count($hex); $b++){ //iterate through the six blue colors
                                      
                                $color $hex[$r].$hex[$g].$hex[$b];
                                      
                                //At this point we decide what font color to use 
                                      
                                if ( $hex[$r] <= "99" && $hex[$g] <= "99" && $hex[$b] <= "99"){

                                        
                                // Use a white font if the color is going to be fairly dark
                                        
                                echo "<td width='100' bgcolor='#".$col."'><font color='#FFFFFF'> ".$col." </font></td>";
                                      } else {
                                        
                                // Use a black font on the lighter colors
                                        
                                echo "<td width='100' bgcolor='#".$col."'><font color='#000000'> ".$col." </font></td>";
                                      } 
                                    } 
                                //End of b-blue innermost loop
                                    
                                echo "</tr>\n\r"// close row after writing six color cells
                                  
                                //End of g-green loop
                                //End of r-red outermost loop
                                ?> 
                                </body>
                                </html>

                                Comment

                                Working...
                                X