Current File : /home/users/barii/public_html/finansenl.com.pl/wodki/admin/tmp2.php
<?php        
error_reporting(E_ALL);
ini_set('display_errors', '1');
include('config.php');
$obj = new Admin();

print_r($_POST);

  $f = array(
      "http://www.",
      "http://kartkiswiateczne.fotomagnesy.pl/",
      "http://kalendarze.fotomagnesy.pl/",
      "http://allegrokalendarze.fotomagnesy.pl/",
      "http://allegrokalendarzplakat.fotomagnesy.pl/",
      "http://kalendarzplakat.fotomagnesy.pl/",
      "http://magnesy.fotomagnesy.pl/",
      "http://kreatormagnesow.kreatordruku-prolabel.pl/",
      "http://serca.fotomagnesy.pl/",
      "http://allegroserca.fotomagnesy.pl/",
      "http://prezent.fotomagnesy.pl/",
      "http://www.prezent.fotomagnesy.pl/",
      "http://prostokaty.fotomagnesy.pl/",
      "http://allegroprostokaty.fotomagnesy.pl/",
      "http://kola.fotomagnesy.pl/",
      "http://allegrokola.fotomagnesy.pl/",
      "http://dyplomy.fotomagnesy.pl/",
      "http://allegrodyplomy.fotomagnesy.pl/",
      "http://allegromagnesy.etykietyweselne.pl/",
      "http://magnesy.etykietyweselne.pl/",
      "http://promocja.fotomagnesy.pl/",
      "http://allegro.fotomagnesy.pl/",     
      "http://stopki.fotomagnesy.pl/",    
      "http://malekola.fotomagnesy.pl/",     
      "http://maleprostokaty.fotomagnesy.pl/",
      "http://tablice.etykietyweselne.pl/",
      "http://system.fotomagnesy.pl/",
      "http://system.fotomagnesy.pl/"  
  );
  $p = array(
      "http://",
      "kartkiswiateczne2017/",
      "kalendarze/",
      "kalendarze/",
      "kalendarzplakat/",
      "kalendarzplakat/",
      "magnesy.fotomagnesy.pl/",
      "kreator_magnesow/public/",
      "serca.fotomagnesy.pl/",
      "serca.fotomagnesy.pl/",
      "promocja.fotomagnesy.pl/",
      "promocja.fotomagnesy.pl/",
      "prostokaty.fotomagnesy.pl/",
      "prostokaty.fotomagnesy.pl/",
      "kola.fotomagnesy.pl/",
      "kola.fotomagnesy.pl/",
      "dyplomy.fotomagnesy.pl/",
      "dyplomy.fotomagnesy.pl/",
      "podziekowanianamagnesie/",
      "podziekowanianamagnesie/",
      "promocja.fotomagnesy.pl/",
      "allegro.fotomagnesy.pl/",       
      "stopki.fotomagnesy.pl/",   
      "malekola.fotomagnesy.pl/",   
      "maleprostokaty.fotomagnesy.pl/",  
      "tablice/",   
      "system.fotomagnesy.pl/",   
      "system.fotomagnesy.pl/"                    
  );
  
  //echo count($f).' '.count($p);
  
  //str_replace($pl,$en,strtolower($string));

$nazwapliku = str_replace($f,$p,$_POST['url']);

$zip = new ZipArchive;
$res = $zip->open("../../$nazwapliku");
if ($res === TRUE) {
  $zip->extractTo('tmp/');
  $zip->close();
  
  katalog('tmp/');
  $obj->zmienStatus($_POST['id'],2);  
  
  
$val = "---------------------------------\nRĘCZNIE ZMIENIONO WYMIAR MAGNESU na ".$_POST['rozmiar']." ".Date("Y-m-d H:i:s")."\n";
$sql = "UPDATE kupione SET info = CONCAT('$val',info)  WHERE id='$_POST[id]'";
$res = mysql_query($sql);
  
  
} else {
  echo 'NIE';
}

function przenies($kat,$val,$i){
$obj = new Admin();
$user = $obj->setDate('kupione',$_POST['id']);
                    $wymorg = getimagesize($kat.$val);
                    $wym = explode('x',$_POST['rozmiar']);
                    $wymtmp = explode('x',$_POST['rozmiar']);
                          if($wym[0]<$wym[1]) {
                            $wym[0] = $wymtmp[1];
                            $wym[1] = $wymtmp[0];
                          }

                $image = new Imagick($kat.$val);     
                $image->setimageresolution(300, 300);  
                                         
//echo '<p>'.$kat.$val.' -> '.round(($wym[0]*25.4)/300).'x'.round(($wym[1]*25.4)/300)."</p>\n";
$dod = '';
if (strpos($_POST['url'], 'kola.') !== false) $dod = 'K';
if (strpos($_POST['url'], 'kolosystem.') !== false) $dod = 'K';   
if (strpos($val, 'kolo.') !== false) $dod = 'K';
if (strpos($val, 'zkolo.') !== false) $dod = 'ZK';
if (strpos($val, 'zserce.') !== false) $dod = 'ZS';
if (strpos($val, 'zkwadrat.') !== false) $dod = 'Z';

if (strpos($_POST['url'], 'tablice.') !== false){
echo $_POST['rozmiar'].'--->'.$kat.$val."\n";
}
else{
  if($_POST['rozmiar']) {
  if($wymorg[0]<$wymorg[1]) { //sprawdzam czy pionowe
      $image->scaleimage(round((explode('x',$_POST['rozmiar'])[1]* 300) / 25.4), round((explode('x',$_POST['rozmiar'])[0]* 300) / 25.4));  
      $image->writeimage('./skladki/upload/'.$_POST['rozmiar'].'/'.$user['email'].'-x-'.$user['id'].'-x-'.round(($wymtmp[0]*25.4)/300).'x'.round(($wymtmp[1]*25.4)/300).'-x-'.$i.'.jpg');   
  }
  else{
      $image->scaleimage(round((explode('x',$_POST['rozmiar'])[0]* 300) / 25.4), round((explode('x',$_POST['rozmiar'])[1]* 300) / 25.4));  
      $image->writeimage('./skladki/upload/'.$_POST['rozmiar'].'/'.$user['email'].'-x-'.$user['id'].'-x-'.round(($wymtmp[0]*25.4)/300).'x'.round(($wymtmp[1]*25.4)/300).'-x-'.$i.'.jpg');   
  }
   
                    
  
  
  //echo $_POST['rozmiar'].'--->'.$kat.$val.' -->> test/'.$dod.round(explode('x',$_POST['rozmiar'])[0]).'x'.round(explode('x',$_POST['rozmiar'])[1]).'/'.$user['email'].'-x-'.$user['id'].'-x-'.round(($wymtmp[0]*25.4)/300).'x'.round(($wymtmp[1]*25.4)/300).'-x-'.$i.".jpg \n";
      //copy($kat.$val , 'test/'.$dod.round(explode('x',$_POST['rozmiar'])[0]).'x'.round(explode('x',$_POST['rozmiar'])[1]).'/'.$user['email'].'-x-'.$user['id'].'-x-'.round(($wymtmp[0]*25.4)/300).'x'.round(($wymtmp[1]*25.4)/300).'-x-'.$i.'.jpg');
  }
}

//echo ('./skladki/upload/'.$dod.round(($wym[0]*25.4)/300).'x'.round(($wym[1]*25.4)/300).'/'.$user['email'].'-x-'.$user['id'].'-x-'.round(($wymtmp[0]*25.4)/300).'x'.round(($wymtmp[1]*25.4)/300).'-x-'.$i.'.jpg');

}

function recursiveRemoveDirectory($directory)
{
    foreach(glob("{$directory}/*") as $file)
    {
        if(is_dir($file)) { 
            recursiveRemoveDirectory($file);
        } else {
            unlink($file);
        }
    }
    rmdir($directory);
}

function katalog($val){

    $FoundFiles = array();
    $iterator = new DirectoryIterator($val);
                    $i = 0;
                    foreach ($iterator as $fileinfo) {
                    $i++;
                        if ($fileinfo->isFile()) {
                                przenies($val,$fileinfo->getFilename(),$i);
                        }
                        elseif($fileinfo->getFilename() == '10x15' or $fileinfo->getFilename() == '15x10' or $fileinfo->getFilename() == '100x150' or $fileinfo->getFilename() == '150x100'){
                            katalog($val.$fileinfo->getFilename().'/');
                        }
                        elseif($fileinfo->getFilename() == '7x10' or $fileinfo->getFilename() == '10x7' or $fileinfo->getFilename() == '70x100' or $fileinfo->getFilename() == '100x70'){
                            katalog($val.$fileinfo->getFilename().'/');
                        }          
                        elseif($fileinfo->getFilename() == '5x7' or $fileinfo->getFilename() == '7x5' or $fileinfo->getFilename() == '50x70' or $fileinfo->getFilename() == '70x50'){
                            katalog($val.$fileinfo->getFilename().'/');
                        }
                        elseif($fileinfo->getFilename() == '9x6' or $fileinfo->getFilename() == '6x9' or $fileinfo->getFilename() == '90x60' or $fileinfo->getFilename() == '60x90'){
                            katalog($val.$fileinfo->getFilename().'/');
                        }
                        elseif($fileinfo->getFilename() == '21x14' or $fileinfo->getFilename() == '14x21' or $fileinfo->getFilename() == '210x140' or $fileinfo->getFilename() == '210x140'){
                            katalog($val.$fileinfo->getFilename().'/');
                        }
                        elseif($fileinfo->getFilename() == '124x114' or $fileinfo->getFilename() == '114x124'){
                            katalog($val.$fileinfo->getFilename().'/');
                        }
                        
                    }

}

recursiveRemoveDirectory('tmp/');

?>