<?php
// ziphelper.php
// RJM Programming
// February, 2025

$gzip_read_output=null;
$gzip_open_handle=null;
$gzip_entry_filename='';
$gzip_filename='';
$gzip_entry_len=0;
$gzip_number=0;
$gzip_log_text='';
if (strpos($_SERVER['REQUEST_URI'], 'index.') !== false) {
$hereis='' . dirname(__FILE__) . explode("index.", $_SERVER['REQUEST_URI'])[0];
} else if (basename($_SERVER['SCRIPT_FILENAME']) != '') {
$hereis=explode(basename($_SERVER['SCRIPT_FILENAME']), realpath($_SERVER['SCRIPT_FILENAME']))[0];
} else {
$hereis='' . dirname(__FILE__) . str_replace('//','/',explode("?", $_SERVER['REQUEST_URI'])[0] . '/');
}
$zipisis='' . $hereis . 'slideshow_0.zip';
$alreadythere=false;

if (file_exists($zipisis)) {
$items = glob($hereis . "*[-_][0-9]*of.[jJgGpP][pPiInN]*");
foreach ($items as $key => $val) {
  $alreadythere=true;
}
}

if (!function_exists("zip_entry_read")) {
  function zip_entry_read($zip_read_output, $zip_entry_len) {
    global $gzip_filename, $gzip_number, $gzip_log_text, $gzip_read_output, $gzip_entry_len;
    return 'pork';
  }
}

if (!function_exists("zip_entry_filesize")) {
  function zip_entry_filesize($zip_read_filename) {
    global $gzip_filename, $gzip_number, $gzip_log_text, $gzip_entry_filename;
    return 'pork';
  }
}

if (!function_exists("zip_read")) {
  function zip_read($zip_oben_handle) {
    global $gzip_filename, $gzip_number, $gzip_log_text, $gzip_open_handle;
    return 'pork';
  }
}

if (!function_exists("zip_open")) {
  function zip_open($zip_filename) {
    global $gzip_filename, $gzip_number, $gzip_log_text, $gzip_filename;
    $gzip_filename=$zip_filename;
    $gzip_number=0;
    $gzip_open_handle='pork';
    return 'pork';
  }
}

if (!function_exists("zip_entry_name")) {
  function zip_entry_name($zip_read_output) {
    global $gzip_filename, $gzip_number, $gzip_log_text, $gzip_read_output;
    return 'pork';
  }
}


if (!function_exists("zip_entry_open")) {
  function zip_entry_open($zip_open_handle, $zip_read_output, $inmode) {
    global $gzip_filename, $gzip_number, $gzip_log_text, $gzip_open_handle, $gzip_read_output;
    return 'pork';
  }
}

if (!function_exists("zip_close")) {
  function zip_close($zip_open_handle) {
    global $gzip_filename, $gzip_number, $gzip_log_text, $gzip_open_handle;
    return 'pork';
  }
}

if (file_exists($zipisis)) {
if (!$alreadythere) {
  file_put_contents($hereis . 'please.wait', "cd " . $hereis . ' ; unzip ' . $zipisis);
  sleep(2);
  exec("cd " . $hereis . ' ; unzip ' . $zipisis);
  sleep(2);
  unlink($hereis . 'please.wait');
  //exec("cd " . $hereis . ' ; rm -f please.wait');
  //if (1 == 1) {
  //header('Location: ' . explode('?',$_SERVER['REQUEST_URI'])[0] . '?rand=' . rand(0,674532));
  //exit;
  //} else {
  //sleep(60);
  //exec("cd " . $hereis . ' ; rm -f ' . $hereis . '*[-_][0-9]*of.[jJgGpP][pPiInN]*');
  //}
  //if (basename($_SERVER['SCRIPT_FILENAME']) == 'index.php') {
  //sleep(60);
  //exec("cd " . $hereis . ' ; rm -f ' . $hereis . '*[-_][0-9]*of.[jJgGpP][pPiInN]*');
  //}
  //sleep(9);
  //echo '<html><body onload="location.href=' . "'" . explode("?", $_SERVER['REQUEST_URI'])[0] . '?rand=' . rand(0,5645342) . "';\"></body></html>";
  //exit;
} //else if (basename($_SERVER['SCRIPT_FILENAME']) == 'index.php') {
  //sleep(60);
  //exec("cd " . $hereis . ' ; rm -f ' . $hereis . '*[-_][0-9]*of.[jJgGpP][pPiInN]*');
//}
}


?>