Transparent PNG in IE6 simple, easy mode

IE6 should not be supported anymore but, there are alot of users witch use it, becouse they dont know any better or dont know how to install another one.

So the hard part will come to the web developer witch need to make the web page ok for everyone including the IE6 users.

By default IE6 will not show tranparency on a png. But you can do like this:

 

  1. <!–[if lte IE 6]>
  2. DIV#yourDiv{
  3.    background-image: none;
  4.    filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=images/yourImage.png, sizingMethod=’scale’);
  5. }
  6. < ! [endif] –>
Tags: , , ,
Posted in HTML Website's by admin. Comments Off

How to submit sitemap.xml to Ask search engine

Ask.com search engine have a page where you can submit your sitemap.xml for easy crawling .

See the link : http://submissions.ask.com/ping?sitemap=http://wiki.nisi.ro/sitemap.xml

Just copy and paste it in your browser and replace http://wiki.nisi.ro/sitemap.xml with your website sitemap link.

This is it.

Tags: , , , ,
Posted in Tutorials Website's by admin. Comments Off

Convert decimal number to fraction number in PHP

Today I had encountered a nice math problem . To convert a decimal number into it corresponding fraction.

Thanks to this post I had fount an easy solution that you can check bellow. I had not used the gmp_gcd function from PHP (witch was used in the post code version) but made a Great Common Divisor function using recursivity.

 

  1. function convertDec2Fraction($number){
  2.         $reverse = strpos(strrev($number),‘.’);
  3.         $number = (strpos($number,’0′) == ’0′) ? str_replace(’0′,,$number) : $number;
  4.          
  5.         $n1 = str_replace(‘.’,,$number);
  6.         $n2 = pow(’10′,$reverse);
  7.          
  8.         $b = gcd($n1,$n2);
  9.          
  10.         return $n1 / $b . "/" . $n2 / $b . "\n";
  11. }
  12.  
  13. echo(convertDec2Fraction(’3.2′));
  14.  
  15.  
  16. function gcd($a, $b){
  17.     if ($a == 0 || $b == 0)
  18.         return abs( max(abs($a), abs($b)) );
  19.        
  20.     $r = $a % $b;
  21.     return ($r != 0) ?
  22.         gcd($b, $r) :
  23.         abs($b);
  24. }
Tags: , , , , ,
Posted in PHP & MySQL by admin. Comments Off

Get base URL from Javascript, detect http or https

When using ajax requests you have to request data from same domain as the domain as the one from where you requesti it.

www.mydomain.com is not the same with mydomain.com so when you request it you should be careful not to request from wrong domain becouse no data is sent (“for security reasons”).

Following you can find a script to get the right address:

 

  1.    function getServerHost(){  
  2.         var url = window.location.href;  
  3.         url = url.replace("http://", "");
  4.         url = url.replace("https://", "");  
  5.  
  6.         var urlExplode = url.split("/");  
  7.         var serverName = urlExplode[0];  
  8.  
  9.         serverName = window.location.protocol + ‘//’ + serverName;  
  10.         return serverName;  
  11.     }

hope it help and …. please support us visiting some sponsors

Tags: , , , , ,
Posted in Javascript jQuery by admin. Comments Off

How to disable comments notification for WordPress

Do you receive alot of emails sent by your WordPress Blog becouse people comment your posts?

You can turn this off like this:

1. Login to your blog admin page

2. Click on Settings -> Discussion

3. Search in that list for “E-mail me whenever:”

Now by default you receive email when “Anyone posts a comment” and “A comment is held for moderation“. Uncheck any or both of this options as you like.

You should definitely uncheck “Anyone posts a comment”.

Tags: , ,
Posted in Wordpress by admin. Comments Off

$_FILES limitation when uploading files in PHP

Along with the “upload_max_filesize” when uploading files with PHP there is another parameter named “max_file_uploads” witch prevent uploading more files that the value of this parameter.

Default size of this parameter is 20 and is should be enough for more apps then I can count but today I had to repair a bug in a page where a form contain 30 file uploads and just 20 were availble in $_FILES from php script.

How can you change this?

There are 2 methods. One is to change it from php.ini but not always you can access php.ini file

The second method is not using ini_set :( . Tried that and not working.

I did find another method witch need some javascript. The method is when submiting the form a javascript will disable all unused upload elements like this:

  1. jQuery("#upload_files1").submit(function(){
  2.     jQuery(‘input:file[value=""]‘).attr("disabled", true);
  3. });

and the form:

  1.  
  2. <form id="upload_files1" enctype="multipart/form-data" method="post">
  3. <input name="img[]" type="file" />
  4. <input name="img[]" type="file" />
  5. <input name="img[]" type="file" />
  6. <input name="save" type="submit" value="Save" />
  7. </form>
Tags: , , , , ,
Posted in jQuery PHP & MySQL by admin. Comments Off

7pic – the new free photo hosting service

I had stumbled today on 7pic.com website witch is a new and free hosting service for photo sharing. I give it a try and I like it becouse i can use the 7pic uploader to upload picts without to start a browser.

Uploaded images are stored in albums and can be shares as an images witch can be embedded in a blog post or as a link to a page on 7pic.com where anybody can comment that images share on facebook, twitter and other social networks and of course anybody can rate the picture.

 

Tags: , ,
Posted in Websites & Web services by admin. Comments Off

How to use call_user_func_array with a simple function and with class methods

In this post you will see a example of using call_user_func_array (from PHP) to call a simple function, a public static method from a class and a public method.

First I define one function and one class:

  1. function add($p1, $p2){
  2.    return $p1 + $p2;
  3. }
  4.  
  5. class CSimpleMath{
  6.    function __construct($v1) {      
  7.    }
  8.  
  9.    public static function multiply($a, $b){
  10.       return $a * $b;
  11.    }
  12.  
  13.    public function substract($a, $b){
  14.       return $b$a;
  15.    }
  16.  
  17.    function __destruct() {            
  18.    }   
  19. }

Maybe you notice that in the class I did inserted a construct and destruct functions. You dont realy need them for this example to work but I always include them when I write a class.

Call a simple function with call_user_func_array:

  1. echo call_user_func_array(‘add’, array(2, 5));

Call a public static method:

  1. echo call_user_func_array(‘CSimpleMath::multiply’, array(2, 5));

Call a public class method

  1. call_user_func_array(array(‘CSimpleMath’, ‘substract’), array(2, 5));
Tags: , , , , ,
Posted in PHP & MySQL by admin. Comments Off

“Progress bar” for long running cron scripts in PHP

Long running scripts can be a pain if you dont know how much will be running. If you need to see a progress and flush() or ob_flush() do not work becouse of browser cache you can implement an “email progress bar”.

PHP example:

  1. $step = 0;
  2. $last_percent = 0;
  3. $total_rows =
  4. while(1) {
  5.    $step++; //count step
  6.  
  7.    // here should be is the code witch consume time for every loop
  8.    // end consuming time code
  9.  
  10.    $procent = ($step * 100) / $total_rows;
  11.    if ($last_percent != round($procent)){
  12.       // becouse you do not want to receive an email for every step
  13.       $last_percent = round($procent);
  14.       if (($last_percent % 10) == 0){  
  15.          // this will send email from 10 % to 10 % – total 10 emails
  16.          mail(your_email_here, ‘Progress ‘.$last_percent.‘% done’ , "Progress: ".$contor."/".$total_rows);
  17.       }
  18.    }
  19.  
  20. } // end while

As you can see the ideea is very simple and you can implement it in any language.

Tags: , , , ,
Posted in PHP & MySQL Website's by admin. Comments Off