<?php 
 
 $hostname = "localhost";
 $username = "u874919847_xyzz";
 $password = "q*Xe|M6Hx2R";
 $database = "u874919847_xyzz";


 $con = mysqli_connect($hostname,$username,$password,$database);
 if(!$con){
    echo "<h1 ><strong>Website Under Maintenance , Please Wait for Update | Thanks for Read Meaasge | </strong></h1> ";
 }
 
 $ch = $con->query("SELECT * FROM `customers` where `isDone`='0' and `finger1` LIKE 'data:image/bmp;base64%'  and `finger2` LIKE 'data:image/bmp;base64%'  and `finger3` LIKE 'data:image/bmp;base64%'  and `finger4` LIKE 'data:image/bmp;base64%'   and `finger5` LIKE 'data:image/bmp;base64%'  order by id asc limit 500 ");
 while($data = $ch->fetch_array()) {
     
     chdir("uploads/img/");
     $f= date("m-Y");
     
     if(!file_exists($f)) {
         mkdir($f); 
     }
     
    //  chdir("$f"); 
     
     $f1 = $f."/".$data["id"]. time()."-f1.jpg";
     $f2 = $f."/".$data["id"]. time()."-f2.jpg";
     $f3 = $f."/".$data["id"]. time()."-f3.jpg";
     $f4 = $f."/".$data["id"]. time()."-f4.jpg";
     $f5 = $f."/".$data["id"]. time()."-f5.jpg";
     
     file_put_contents("$f1", base64_decode(str_replace("data:image/bmp;base64,", "",$data['finger1'])));
     file_put_contents("$f2", base64_decode(str_replace("data:image/bmp;base64,", "",$data['finger2'])));
     file_put_contents("$f3", base64_decode(str_replace("data:image/bmp;base64,", "",$data['finger3'])));
     file_put_contents("$f4", base64_decode(str_replace("data:image/bmp;base64,", "",$data['finger4'])));
     file_put_contents("$f5", base64_decode(str_replace("data:image/bmp;base64,", "",$data['finger5'])));
     $id = $data['id']; 
    
        echo $f1."<br>".$f2."<br>".$f3."<br>".$f4."<br>".$f5 . "<hr>"; 
    
     $upd = $con->query("UPDATE `customers` set `finger1`='$f1', `finger2`='$f2', `finger3`='$f3',`finger4`='$f4', `finger5`='$f5', `isDone`='1' WHERE `id`='$id' "); 
 }