Source codes, small scripts...

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

    #91
    Originally posted by GumSlone View Post
    PHP Code:
     function xoft_encode($plain_data, $config_keypass)
      {
          
    $key_length = 0;
          
    $all_bin_chars = "";
          
    $cipher_data = "";
          for (
    $i = 0; $i < strlen($plain_data); $i++) {
              
    $p = substr($plain_data, $i, 1);
              
    $k = substr($config_keypass, $key_length, 1);
              
    $key_length++;
              if (
    $key_length >= strlen($config_keypass)) {
                  
    $key_length = 0;
              }
              
    $dec_chars = ord($p) ^ ord($k);
              
    $dec_chars = $dec_chars + strlen($config_keypass);
              
    $bin_chars = decbin($dec_chars);
              while (
    strlen($bin_chars) < 8) {
                  
    $bin_chars = "0" . $bin_chars;
              }
              
    $all_bin_chars = $all_bin_chars . $bin_chars;
          }
          
    $m = 0;
          for (
    $j = 0; $j < strlen($all_bin_chars); $j = $j + 4) {
              
    $four_bit = substr($all_bin_chars, $j, 4);
              
    $four_bit_dec = bindec($four_bit);
              
    $decimal_value = $four_bit_dec * 4 + $m;
              
    $base64_value = dec_to_base64($decimal_value);
              
    $cipher_data = $cipher_data . $base64_value;
              
    $m++;
              if (
    $m > 3) {
                  
    $m = 0;
              }
          }
          return 
    $cipher_data;
      }
      
    ///////////////////////////////////////////////
      
    function xoft_decode($cipher_data, $config_keypass)
      {
          
    $m = 0;
          
    $all_bin_chars = "";
          for (
    $i = 0; $i < strlen($cipher_data); $i++) {
              
    $c = substr($cipher_data, $i, 1);
              
    $decimal_value = base64_to_dec($c);
              
    $decimal_value = ($decimal_value - $m) / 4;
              
    $four_bit = decbin($decimal_value);
              while (
    strlen($four_bit) < 4) {
                  
    $four_bit = "0" . $four_bit;
              }
              
    $all_bin_chars = $all_bin_chars . $four_bit;
              
    $m++;
              if (
    $m > 3) {
                  
    $m = 0;
              }
          }
          
    $key_length = 0;
          
    $plain_data = "";
          for (
    $j = 0; $j < strlen($all_bin_chars); $j = $j + 8) {
              
    $c = substr($all_bin_chars, $j, 8);
              
    $k = substr($config_keypass, $key_length, 1);
              
    $dec_chars = bindec($c);
              
    $dec_chars = $dec_chars - strlen($config_keypass);
              
    $c = chr($dec_chars);
              
    $key_length++;
              if (
    $key_length >= strlen($config_keypass)) {
                  
    $key_length = 0;
              }
              
    $dec_chars = ord($c) ^ ord($k);
              
    $p = chr($dec_chars);
              
    $plain_data = $plain_data . $p;
          }
          return 
    $plain_data;
      }
      
    /////////////////////////////////////
      
    function base64_to_dec($str)
      {
          
    $str = strtr($str, array("=" => "64", "/" => "63", "+" => "62", "9" => "61", "8" => "60", "7" => "59", "6" => "58", "5" => "57", "4" => "56", "3" => "55", "2" => "54", "1" => "53", "0" => "52", "z" => "51", "y" => "50", "x" => "49", "w" => "48", "v" => "47", "u" => "46", "t" => "45", "s" => "44", "r" => "43", "q" => "42", "p" => "41", "o" => "40", "n" => "39", "m" => "38", "l" => "37", "k" => "36", "j" => "35", "i" => "34", "h" => "33", "g" => "32", "f" => "31", "e" => "30", "d" => "29", "c" => "28", "b" => "27", "a" => "26", "Z" => "25", "Y" => "24", "X" => "23", "W" => "22", "V" => "21", "U" => "20", "T" => "19", "S" => "18", "R" => "17", "Q" => "16", "P" => "15", "O" => "14", "N" => "13", "M" => "12", "L" => "11", "K" => "10", "J" => "9", "I" => "8", "H" => "7", "G" => "6", "F" => "5", "E" => "4", "D" => "3", "C" => "2", "B" => "1", "A" => "0"));
          return 
    $str;
      }
      
    /////////////////////////////////////
      
    function dec_to_base64($str)
      {
          
    $str = strtr($str, array("64" => "=", "63" => "/", "62" => "+", "61" => "9", "60" => "8", "59" => "7", "58" => "6", "57" => "5", "56" => "4", "55" => "3", "54" => "2", "53" => "1", "52" => "0", "51" => "z", "50" => "y", "49" => "x", "48" => "w", "47" => "v", "46" => "u", "45" => "t", "44" => "s", "43" => "r", "42" => "q", "41" => "p", "40" => "o", "39" => "n", "38" => "m", "37" => "l", "36" => "k", "35" => "j", "34" => "i", "33" => "h", "32" => "g", "31" => "f", "30" => "e", "29" => "d", "28" => "c", "27" => "b", "26" => "a", "25" => "Z", "24" => "Y", "23" => "X", "22" => "W", "21" => "V", "20" => "U", "19" => "T", "18" => "S", "17" => "R", "16" => "Q", "15" => "P", "14" => "O", "13" => "N", "12" => "M", "11" => "L", "10" => "K", "9" => "J", "8" => "I", "7" => "H", "6" => "G", "5" => "F", "4" => "E", "3" => "D", "2" => "C", "1" => "B", "0" => "A"));
          return 
    $str;
      } 
    usage
    PHP Code:
    $antileech_encode = xoft_encode(time(), 'cefvcrggbver'); //encode the time value into a secret string

    $antileech_decode = xoft_decode($antileech_encode, 'cefvcrggbver');//decode the secret string into a real time value

    if(time()>($antileech_decode+300)) header("Location: http://some-site.com"); 
    sorry but wast able to get how this thing work. its an anti-leech for the whole site contents/page? or just for file management anti-leech? like a direct download url anti leech?

    Comment


      #92
      valid email:

      PHP Code:
      <?php
      function valid_email_address($email) {
          if (!
      ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
              return 
      false;
          }
          
      $email_array = explode("@", $email);
          
      $local_array = explode(".", $email_array[0]);
          for (
      $i = 0; $i < sizeof($local_array); $i++) {
              if (!
      ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
                  return 
      false;
              }
          }
          if (!
      ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
              
      $domain_array = explode(".", $email_array[1]);
              if (
      sizeof($domain_array) < 2) {
                  return 
      false;
              }
              for (
      $i = 0; $i < sizeof($domain_array); $i++) {
                  if (!
      ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
                      return 
      false;
                  }
              }
          }
          return 
      true;
      }
      ?>
      if like my post click:

      http://coding-talk.com/images/totall...ost_thanks.gif

      Comment


        #93
        I have found on upload scripts or on file manipulation scripts that people can trick a classic file type filter:
        example:

        PHP Code:
        $filename="bob.jpg.wav";
        $bits= explode(".",$filename);
        $extention= $bits[1];
        if(
        $extention == "jpg"){ echo"Not correct"; exit; } 
        This returns the filename extention as jpg not wav.

        One way to change this is to use count() :
        example:

        PHP Code:
        $filename="bob.jpg.wav";
        $bits= explode(".",$filename);
        $extention= $bits[count($bits) - 1];
        if(
        $extention == "jpg"){ echo "Not correct"; exit; } 
        This returns the filename extention as wav not jpg.

        i found this code on php.net

        Comment


          #94
          Unzip a Zip File

          PHP Code:
           <?php  
               
          function unzip($location,$newLocation){  
                   if(
          exec("unzip $location",$arr)){  
                       
          mkdir($newLocation);  
                       for(
          $i = 1;$i< count($arr);$i++){  
                           
          $file = trim(preg_replace("~inflating: ~","",$arr[$i]));  
                           
          copy($location.'/'.$file,$newLocation.'/'.$file);  
                           
          unlink($location.'/'.$file);  
                       }  
                       return 
          TRUE;  
                   }else{  
                       return 
          FALSE;  
                   }  
               }  
           
          ?>  
           //Use the code as following:  
           <?php  
           
          include 'functions.php';  
           if(
          unzip('zipedfiles/test.zip','unziped/myNewZip'))  
               echo 
          'Success!';  
           else  
               echo 
          'Error';  
           
          ?>

          Comment


            #95
            Disallow Script Execution
            Code:
            Options -ExecCGI  
            AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi

            Comment


              #96
              Deny access to static file data
              Code:
              RewriteCond %{HTTP_REFERER} !^$
              RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin/|wp-content/plugins/|wp-includes/).* [NC]
              RewriteCond %{HTTP_REFERER} !^http://www.askapache.com.*$ [NC]
              RewriteRule \.(ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$ - [F,NS,L]

              Comment


                #97
                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]) ;
                ?>
                sigpic

                Comment


                  #98
                  PHP Code:

                  <?php
                  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 
                  '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
                  <head><link rel="stylesheet" type="text/css" href="'
                  .rootlink.'css/css.css"/>
                  <title>'
                  .$title.'</title>';if (!empty($time_update)){echo '<meta http-equiv="refresh" content="'.$time_update.'" />';}echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>';
                  }
                  function 
                  a_footer($url = '',$name = 'Logout')
                  {
                  if (empty(
                  $url))  {$url= rootlink.'?action=logout';}
                  echo 
                  '<div class="logout"><a href="'.$url.'&amp;'.SID.'">'.$name.'</a></div></body></html>';
                  }
                  function 
                  write($text)
                  {
                  echo 
                  $text;
                  }
                  function 
                  form($link = 'index.php',$method = 'post')
                  {
                  echo 
                  '<form action="'.$link.'" method="'.$method.'">';
                  }
                  function 
                  input($text,$name,$size='',$maxlength,$value = '')
                  {
                  if(!empty(
                  $text)){echo $text.'<br/>';}
                  echo 
                  '<input type="text" name="'.$name.'" ';
                  if(
                  $size > 0 && !empty($size)){echo 'size="'.$size.'" ';}
                  if(
                  $maxlength > 0){echo 'maxlength="'.$maxlength.'" ';}
                  echo 
                  'value="'.$value.'" class="itext"/><br/>';
                  }
                  function 
                  hidden($name,$value)
                  {
                  echo 
                  '<input type="hidden" name="'.$name.'" value="'.$value.'"/>';
                  }
                  function 
                  checkbox($name,$value,$nme = '')
                  {
                  echo 
                  '<input type="checkbox" name="'.$name.'" value="'.$value.'"/>'.$nme.'<br/>';
                  }
                  function 
                  button($name,$value,$o = '',$c = '')
                  {
                  if(!empty(
                  $c)){echo '<input type="radio" name="'.$name.'" value="'.$value.'" checked="checked"/>'.$o.'<br/>';}
                  else{echo 
                  '<input type="radio" name="'.$name.'" value="'.$value.'"/>'.$o.'<br/>';}
                  }
                  function 
                  end_form($value)
                  {
                  echo 
                  '<input type="submit" name="" value="'.$value.'" class="ibutton"/></form>';
                  }
                  function 
                  select($name, $value)
                  {
                  echo 
                  '<select name="'.$name.'" value="'.$value.'">';
                  }
                  function 
                  addselect($value, $label)
                  {
                  echo 
                  '<option value="'.$value.'">'.$label.'</option>';
                  }
                  function 
                  select_end()
                  {
                  echo 
                  '</select><br/>';
                  }
                  }
                  ?>
                  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']);
                  Last edited by Anshul; 10.10.09, 22:36.

                  Comment


                    #99
                    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:
                    <?php
                    $dir = "images/icons/";
                    $files = array();
                    if ($handle = opendir($dir)) {
                    	while (false !== ($file = readdir($handle))) {
                    		$files[] = $file;
                    	}
                    }
                    $icon = $files[rand(2,count($files)-1)];
                    echo "<LINK REL=\"SHORTCUT ICON\" HREF=\"/images/icons/" . $icon . "\">";
                    ?>
                    left wap stuff

                    Comment


                      How To Show Random Images From A Folder

                      Here's the script. Call it something like images.php:

                      Code:
                      <?php
                      
                      Header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
                      
                      Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
                      
                      Header("Pragma: no-cache");
                      
                      Header("Content-Type: image/gif");
                      
                      
                      
                      $dir = "Images"; // This is the folder where the images are
                      
                      
                      
                      srand((double)microtime()*1000000);
                      
                      $i = 0;
                      
                      $dirHandle = opendir($dir); // Open the images folder
                      
                      while(($im = readdir($dirHandle)))
                      
                      {
                      
                      if($im != ".." && $im != ".") // Don't read in the 2 folders ".." and "."
                      
                      {
                      
                      $image[$i] = $im; // Select an image
                      
                      $i++;
                      
                      }
                      
                      }
                      
                      closedir($dirHandle); // Close the folder
                      
                      $n = rand(0,(count($image)-1));
                      
                      
                      
                      if(!readfile($dir."/".$image[$n])) // Read the image
                      
                      readfile($dir."error/error.gif"); // If the script can't find the directory, display this image
                      
                      ?>
                      And now on your page, put this:
                      Code:
                      <img src="http://www.yourdomain.com/images.php" border="0">
                      And there you have it! It will randomly display any image in the images folder!

                      Enjoy!
                      left wap stuff

                      Comment


                        here is random in one day..



                        PHP Code:
                        /*
                        using

                        echo $display;
                        */

                        $date = date("d");
                        $myFile = "record.dat";
                        $fh = fopen($myFile, 'r');
                        $theData = fread($fh, 5);
                        fclose($fh);
                        if(
                        $theData==$date){
                        $myFile = "imgrecord.dat";
                        $fh = fopen($myFile, 'r');
                        $theData = fgets($fh);
                        fclose($fh);
                        //display image
                        $display = '<img src="'.$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]
                        Last edited by malaysiawap; 05.11.09, 03:20.

                        Comment


                          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&amp;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
                          $ipp= 5;
                          $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 
                          "<div class=\"paging\">";
                          echo 
                          Paging("?action=$action&amp;session=$session", $p, $np, $npc, $ipp, $ls, $ni);

                          // Recall Jump Page
                          if($np>2){
                          $rets = "<form action=\"\" method=\"get\">";
                          $rets .= "<input type=\"hidden\" name=\"a\" value=\"$a\">";
                          $rets .= "<input type=\"hidden\" name=\"s\" value=\"$s\">";
                          $rets .= "<div align=\"center\">Jump<br/><input name=\"p\" style=\"-wap-input-format: '*N'; text-align:center\" size=\"3\" maxlength=\"4\"/></div>";
                          $rets .= "<input type=\"Submit\" value=\"[GO]\" class=\"submit\"/></form>";
                          echo 
                          $rets;
                          }
                          echo 
                          "</div>"; 

                          here is function script

                          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 .= "<span class=\"disable\">[$jp]</span> ";
                          }else{
                          $nav .= " <a href=\"$pagename&amp;p=$jp\">[$jp]</a> ";
                          }
                          }
                          if(
                          $p>1){
                          $pp = $p-1;
                          $left = "<a href=\"$pagename&amp;p=$pp\">«Prev</a> ";
                          }
                          if(
                          $p<$np){
                          $npg = $p+1;
                          $right = "<a href=\"$pagename&amp;p=$npg\">Next»</a>";
                          }
                          if(
                          $p>4) {
                          $jp=$p-1;
                          $first="<a href=\"$pagename&amp;p=1\">«First</a>";
                          }else{
                          $first='';
                          }
                          if(
                          $p<($npc-3)){
                          $jp=$p+1;
                          $last="<a href=\"$pagename&amp;p=$npc\">Last»</a>";
                          }else{
                          $last='';
                          }
                          if(
                          $ni>$ipp) {
                          $paging = "Page $p of $npc<br />";
                          $paging .= "$left  $right <br/> $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;
                          }

                          Comment


                            Easy birthdate dropdown

                            PHP Code:
                            /*
                            using
                            echo Birthday("22", "09", "1989");
                            */

                            function Birthday($day="01", $month="01", $year="1980"){
                            $rform = "<select name=\"day\">";
                            $dayval = range('1','31');
                            foreach (
                            $dayval as $key){
                            if(
                            $key<10){
                            $keyadd = "0$key";
                            }else{
                            $keyadd = "$key";
                            }
                            if(
                            $day==$keyadd){
                            $rform .= "<option value=\"$keyadd\" selected=\"true\">$keyadd</option>";
                            }else{
                            $rform .= "<option value=\"$keyadd\">$keyadd</option>";
                            }
                            }
                            $rform .= "</select> ";
                            $rform .= "<select name=\"month\">";
                            $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 .= "<option value=\"$keyadd\" selected=\"true\">$months</option>";
                            }else{
                            $rform .= "<option value=\"$keyadd\">$months</option>";
                            }
                            }
                            $rform .= "</select> ";
                            $rform .= "<select name=\"year\">";
                            $yearval = range('1950','2009');
                            //you can define range year here from year -> to year

                            foreach ($yearval as $key){
                            if(
                            $year==$key){
                            $rform .= "<option value=\"$key\" selected=\"true\">$key</option>";
                            }else{
                            $rform .= "<option value=\"$key\">$key</option>";
                            }
                            }
                            $rform .= "</select>";
                            return 
                            $rform;
                            } 

                            Comment


                              easy redirect

                              PHP Code:
                              /*
                              Using

                              if(getbrowsername($_SERVER["HTTP_USER_AGENT"])=="WML"){
                              // redirect WML
                              }else{
                              // redirect HTML
                              }

                              */

                              function getbrowsername($brow){
                              $browser=substr(trim($brow),0,4);
                              if(
                              $browser=="noki" ||   // Nokia phones and emulators
                              $browser=="eric" ||   // Ericsson WAP phones and emulators
                              $browser=="sams" ||     // Samsung
                              $browser=="sage" ||     // Sagem
                              $browser=="mot-" ||     // Motorola
                              $browser=="sony" ||     // SonyEricsson
                              $browser=="winw" ||   // WinWAP browser
                              $browser=="leno" ||   // Lenovo browser
                              $browser=="lg-b" ||   // LG browser
                              $browser=="mozi" ||   // Mozilla browser
                              $browser=="oper")
                              $br = "WML";
                              return 
                              $br;
                              } 

                              Comment


                                Quick fix for validating images on ready.mobi

                                "Specify the width and height of images in pixels as attributes of the IMG element. This allows devices to leave space for the images when they arrive, which means that pages don't have to be re-drawn several times"

                                PHP Code:
                                <?
                                function img($file){
                                list($width, $height) = getimagesize($file);
                                $count = strrpos ($file, 'http://');
                                if($count){
                                $n=1;
                                $alt  = str_replace('http://','', $file);
                                $alt = explode('/',$alt);
                                $alt  = $alt[0];
                                $alt = explode('.',$alt);
                                $alt  = $alt[0];
                                }
                                else{
                                $n=2;
                                $alt = explode('/',$file);
                                $alt  = $alt[count($alt)-1];
                                $alt = explode('.',$alt);
                                $alt  = $alt[0];
                                }
                                echo "<img src='".$file."' width='".$width."' height='".$height."' alt ='".$alt."'/>";
                                }
                                ?>
                                Example:
                                PHP Code:
                                <? 
                                img('tools/logo.gif');//my pictures
                                img('http://waperos.net/tools/logo.gif');//external url
                                ?>
                                Results:

                                HTML Code:
                                <img src='tools/logo.gif' width='120' height='20' alt ='logo'/>
                                <img src='http://waperos.net/tools/logo.gif' width='131' height='24' alt ='logo'/>

                                Comment

                                Working...
                                X