<?
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
//***************************************************
// http://www.scriptindonesia.com
// Solusi Hemat Script Bisnis Online Anda
// Menerima Jasa Pembuatan Website & Template Website
//***************************************************
?>

<!-- UPLOAD AWAL -->
<!-- Info WebPro -->
<? include "infowebpro.php"; ?>

<h6><font color="#549423">Home / Upload Foto</font><br />
Anda telah login sebanyak : <font color="#0000FF"><?= $a[counter];?></font> kali</h6>
<hr />
<h3><font color="#FF0000">Foto Anda</font></h3>
<h5><strong><?= $panggil ?> <font color="#0000FF"><?= $a[nama];?></font></strong> Yth,<br>
    Halaman ini untuk upload foto Anda di <font color="#0000FF"><?= $_SESSION[user_domain] ?></font></h5>
<hr />

                    <div class="progress">
                        <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;">
                            <span><?= $a[nama];?> - <?= $a[kota];?> - <?= $a[propinsi];?></span>
                        </div>
                    </div>

Ketentuan foto :
<ul>
    <li>File .GIF .JPG .BMP atau .PNG</li>
    <li>Ukuran file tidak boleh lebih dari 100 KB</li>
    <li>Ukuran foto diusahakan tidak lebih dari 400 x 400 pixel.</li>
</ul>
<p></p>

<? $awrandom = 'scriptindonesia'.date("Ymd_his_",time());//echo "$awrandom"; ?>
<? $acak     = rand(1,99); ?>

               <div class="row">
                <div class="col-md-12">
                    <!-- Form Elements -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Upload Foto Anda :
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-md-6">
                                    
                                    <form name="image_upload" action="?m=upload&page=submit" method="POST" enctype="multipart/form-data">

                                        <div class="form-group">
                                            <label>File Gambar : <font color="#FF0000">*</font></label>
                                            <input type="file" name="uploadgbr" />
                                        </div>

                                        <input name="submit" type="submit" class="btn btn-danger" value="Upload Foto Sekarang">

<?

//-----submit----
if($page == "submit")
{

// Filtering white list file extension
   $whitelist = array("jpg", "JPG", "gif", "GIF", "bmp", "BMP", "png", "PNG");
   foreach ($whitelist as $exts) {
//  if (end(explode('.',$_FILES['uploadgbr']['name'])) == $exts) { //awrev18

		$exts = explode('.',$_FILES['uploadgbr']['name']);
		if (end($exts)) {
		$nextfilter=True;
        break;
    }
    else {
	$nextfilter=False;
    }
   }

   if (!$nextfilter) {
     echo "<font color=\"#FF0000\">Pesan : ...</font> File gambar tidak dikenali!!!";

     echo "
                                 

                                 <hr>
                                 Terima Kasih<br />

                                 <div class='bingkai-foto-8lg'>
                                     <center>
                                         <img src='../images/logo.png' alt='$_SESSION[user_domain]' title='$_SESSION[user_domain] - $_SESSION[user_caption]'>
                                     </center>
                                 </div>

                                 <a href='http://$_SESSION[user_domain]/$_SESSION[user_session]' target='_blank'><font color='#0000FF'>$_SESSION[user_domain]</font></a><br>
                                 Email : <a href='mailto:$_SESSION[admin_email]'><font color='#0000FF'>$_SESSION[admin_email]</font></a><br><br>
                                 Web Support Bisnis Team <font color='#0000ff'>$_SESSION[user_title1] $_SESSION[user_title2]</font><br />
                                 $_SESSION[user_caption]<br />
                                 design website by <a href='http://www.$set_develop/' target='_blank'><font color='#ff6700'>www.$set_develop</font></a><br /><br />

          ";

     exit;
   }


     $uploaddir = 'images/';
     $nmfile = basename($_FILES['uploadgbr']['name']);
     $uploadfile = $uploaddir . $awrandom.$nmfile;
//   $uploadfile = $uploaddir . basename($_FILES['uploadgbr']['name']);
//   echo $uploadfile;

//   hapus
     $filedelete  = $a[foto];             // nama foto
     $imagedelete = "images/$filedelete"; // alamat tempat foto
     unlink($imagedelete);                // script delete folder
//   echo $imagedelete;

     if (move_uploaded_file($_FILES['uploadgbr']['tmp_name'], $uploadfile)) {

         list($lebar_asli, $tinggi_asli) = getimagesize($uploadfile);
         echo "<br><br> Keterangan Foto Anda : ".$nmfile."<br>";
         echo "Lebar = $lebar_asli px<br>";
         echo "Tinggi = $tinggi_asli px<br>";

         if($lebar_asli <= 400 and $tinggi_asli <= 400) {
//           echo "Upload berhasil.";
             mysql_query("UPDATE member SET foto='$awrandom$nmfile' WHERE email='$_SESSION[user_email]'");
             echo "<p align=center><strong>Foto telah berhasil di-upload.</strong></p>";
             echo "<meta http-equiv='refresh' content='0;URL=?m=upload'>";
         } else {
             unlink($uploadfile);
             echo "<br>Resolusi(ukuran) foto yang diupload masih terlalu besar.<br>Ukuran foto maks (400 px) x (400 px)";
           //echo $uploadfile;
           //break;
         }

                

     }
     else {
         echo "Upload foto gagal.";
     }



}
?>



                                    </form>

                                </div>
                            </div>

                            

                            <hr>
                            Terima Kasih<br />

                            <div class="bingkai-foto-8lg">
                                 <center>
                                     <img src="../images/logo.png" alt="<?= $_SESSION[user_domain] ?>" title="<?= $_SESSION[user_domain] ?> - <?= $_SESSION[user_caption] ?>">
                                 </center>
                            </div>

                            <!--<img src="../images/logo.png" border="1"><br />-->
                            <a href="http://<?= $_SESSION[user_domain] ?>/<?= $_SESSION[user_session] ?>" target="_blank"><font color="#0000FF"><?= $_SESSION[user_domain] ?></font></a><br>
                            Email : <a href="mailto:<?= $_SESSION[admin_email] ?>"><font color="#0000FF"><?= $_SESSION[admin_email] ?></font></a><br><br>
                            Web Support Bisnis Team <font color=#0000ff><?= $_SESSION[user_title1] ?> <?= $_SESSION[user_title2] ?></font><br />
                            <?= $_SESSION[user_caption] ?><br />
                            design website by <a href="http://www.<?= $set_develop ?>/" target="_blank"><font color="#ff6700">www.<?= $set_develop ?></font></a><br /><br />

                        </div>
                    </div>
                     <!-- End Form Elements -->
                </div>
            </div>