function ScheduleComputers() { $users = new usersMenus(); DeleteCronFilesBackupComputer(); $nice = $users->EXEC_NICE; $array = _get_computers_to_backup(); if (!is_array($array)) { events("No computers scheduled..."); return false; } events(count($array) . " schedule computers"); while (list($num, $computer) = each($array)) { $comp = new computers($computer); $ini = new Bs_IniHandler(); $ini->loadString($comp->ComputerCryptedInfos); if ($ini->_params["BACKUP_PROTO"]["enable_smb"] != 1) { continue; } $username = $ini->_params["ACCOUNT"]["USERNAME"]; $password = $ini->_params["ACCOUNT"]["PASSWORD"]; if ($comp->ComputerIP != null) { if ($comp->ComputerIP != "0.0.0.0") { $computer_ip = $comp->ComputerIP; } } if ($computer_ip == null) { $computer_ip = $comp->ComputerRealName; } $paths = getFoldersList($ini); events("schedule {$computer} " . count($paths) . " paths to backup"); if (count($paths) == 0) { continue; } while (list($index, $folder) = each($paths)) { if (preg_match("#^(.+?)\\/#", $folder, $re)) { $first_folder = $re[1]; $folder = str_replace("{$first_folder}/", "", $folder); } else { $first_folder = $folder; $folder = " "; } $first_folder = str_replace('$', '\\$', $first_folder); $folder = str_replace('$', '\\$', $folder); $schedule = $ini->_params["SCHEDULE"]["cron"]; if (trim($schedule) == null) { continue; } $cmd = "{$schedule} root {$nice}/usr/share/artica-postfix/bin/artica-backup --incremental-computer {$computer_ip} \"{$username}\" \"{$password}\" \"{$first_folder}\" \"{$folder}\" >/dev/null 2>&1\n"; $cron_file = "/etc/cron.d/artica-" . md5($cmd) . "-bcmp"; $rei = @file_put_contents($cron_file, $cmd); if (!$rei) { events("Failed writing {$cron_file}"); } events("schedule {$schedule} smb://{$computer_ip}/{$first_folder} ({$folder}) to backup scheduled for {$cron_file}"); } } }
if ($file !== '.' && $file !== '..' && !is_dir($directory . '/' . $file)) { //If it is a folder $ctime = filemtime($directory . '/' . $file) . ',' . $file; //BRING THE DATE OF THE FOLDER $type = pathinfo($directory, PATHINFO_EXTENSION); $data = file_get_contents($directory . '/' . $file); $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); $results[strtolower($ctime)] = $base64; } } return $results; } $directory = isset($_GET['path']) ? $_GET['path'] : $directory; //THE RESULT OF THE JSON CALL //GET THE CATEGORIES $imagesInRoot = getFoldersList($directory); if (empty($imagesInRoot)) { exit('data is empty'); } else { ?> <!DOCTYPE html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1">
function fixArray($list, $directory) { $return = array(); foreach ($list as $key => $value) { $thumb = 'no'; if (file_exists($directory . '/thumbnails' . '/' . $value)) { //VERIFY IF THERE IS ANY THUMBNAIL FOR THE IMAGE $thumb = 'yes'; } $return[$value] = $thumb; } return $return; } $directory = $_GET['directory']; //THE RESULT OF THE JSON CALL $output = array(); //GET THE CATEGORIES $folders = getFoldersList($directory); //GET THE IMAGES IN ROOT $imagesInRoot = getImagesList($directory); //ADD THE IMAGES IN ROOT $output['All'] = fixArray($imagesInRoot, $directory); //GET THE IMAGES OF EACH CATEGORY foreach ($folders as $key => $value) { $images = getImagesList($directory . "/" . $value); //ADD THE IMAGES OF EACH CATEGORY $output[$value] = fixArray($images, $directory . '/' . $value); } //print_r($output); //echo json_encode($output, JSON_FORCE_OBJECT); // if you are using PHP 5.3 plase use this line instead of the one below echo json_encode($output);
function getSeparatedDirList() { return array_merge(getFoldersList(), getFilesList()); }