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

  $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://kolosystem.fotomagnesy.pl/",
      "https://www.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/",   
      "system.fotomagnesy.pl/"                    
  );
  
  //echo count($f).' '.count($p);
  
  //str_replace($pl,$en,strtolower($string));

$nazwapliku = str_replace($f,$p,$_POST['url']);
echo $nazwapliku;
$zip = new ZipArchive;
$res = $zip->open("../../$nazwapliku");
if ($res === TRUE) {
  $zip->extractTo('tmp/');
  $zip->close();
  
  katalog('tmp/');
  $obj->zmienStatus($_POST['id'],2);  
  
} else {
  echo 'NIE';
}

function przenies($kat,$val,$i){
$obj = new Admin();
$user = $obj->setDate('kupione',$_POST['id']);
                    $wym = getimagesize($kat.$val);
                    $wymtmp = getimagesize($kat.$val);
                          if($wym[0]<$wym[1]) {
                            $wym[0] = $wymtmp[1];
                            $wym[1] = $wymtmp[0];
                          }
                          
echo '<p>'.$kat.$val.' -> '.round(($wym[0]*25.4)/300).'x'.round(($wym[1]*25.4)/300)."</p>\n";

/*
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){
copy($kat.$val, '../../tablice/skladka/tmp/'.$user['email'].'-x-'.$user['id'].'-x-'.round(($wymtmp[0]*25.4)/300).'x'.round(($wymtmp[1]*25.4)/300).'-x-'.$i.'.jpg');
}
else{
    if (strpos($val, '-kolo.') !== false) $dod = 'K';
    else $dod = '';
    copy($kat.$val , './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');
}

//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/');

?>