function tasks_list() { $sql = new mysql(); $sock = new sockets(); $sql = "SELECT * FROM backup_schedules ORDER BY ID DESC"; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_backup"); $backup = new backup_protocols(); $cron = new cron_macros(); $storages["usb"] = "{usb_external_drive}"; $storages["smb"] = "{remote_smb_server}"; $storages["rsync"] = "{remote_rsync_server}"; $html = "<table style='width:99%'>\n\t<th> </th>\n\t<th>{task}</th>\n\t<th>{STORAGE_TYPE}</th>\n\t<th>{resource}</th>\n\t<th>{schedule}</th>\n\t</tr>"; while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) { $ressources = unserialize(base64_decode($ligne["datasbackup"])); $sources = count($ressources) . " {sources}"; $html = $html . "<tr " . CellRollOver("TasksListConnectSource({$ligne["ID"]})", "{choose}:{task} {$ligne["ID"]}") . ">\n\t\t<td width=1%><img src='img/fw_bold.gif'></td>\n\t\t<td width=1% nowrap><strong>{task} {$ligne["ID"]}</strong></td>\n\t\t<td style='font-size:12px'>{$storages[$ligne["resource_type"]]}</td>\n\t\t<td style='font-size:12px'>" . $backup->extractFirsRessource($ligne["pattern"]) . "</td>\n\t\t<td style='font-size:12px'>" . $cron->cron_human($ligne["schedule"]) . "</td>\n\t\t</tr>"; } $html = $html . "</table>\n\t<hr>\n\t<div style='width:100%;text-align:right'>" . imgtootltip('32-refresh.png', "{refresh}", "BACKUP_TASKS_LISTS()") . "</div>\n\t"; $tpl = new templates(); echo $tpl->_ENGINE_parse_body($html); }
function ParseMailboxDirRsync($pattern) { $backup = new backup_protocols(); $unix = new unix(); $rsync = $unix->find_program("rsync"); $array = $backup->extract_rsync_protocol($pattern); if (!is_array($array)) { writelogs(date('m-d H:i:s') . " " . "rsync protocol error", __FUNCTION__, __FILE__, __LINE__); return false; } if ($array["PASSWORD"] != null) { $tmpstr = $unix->FILE_TEMP(); @file_put_contents($tmpstr, $array["PASSWORD"]); $pwd = " --password-file={$tmpstr}"; } if ($array["USER"] != null) { $user = "******"USER"]}@"; } $pattern_list = "{$rsync} --list-only{$pwd} rsync://{$user}{$array["SERVER"]}/{$array["FOLDER"]}/ --stats --dry-run 2>&1"; if ($GLOBALS["DEBUG"]) { echo "ParseMailboxDirRsync():: Listing files or directories using \"{$pattern_list}\"\n"; } writelogs(date('m-d H:i:s') . " " . "{$pattern_list}", __FUNCTION__, __FILE__, __LINE__); exec($pattern_list, $results); @unlink($tmpstr); unset($array); while (list($num, $line) = each($results)) { if (preg_match("#^d[rwx\\-]+\\s+[0-9]+\\s+[0-9\\/]+\\s+[0-9\\:]+\\s+(.+)#", $line, $re)) { writelogs($re[1], __FUNCTION__, __FILE__, __LINE__); if (trim($re[1]) == '.') { continue; } $array[trim($re[1])] = trim($re[1]); continue; } } return $array; }
function BACKUP_COMPILE() { $backup = new backup_protocols(); switch ($_SESSION["WIZARD"]["W_RESOURCE"]) { case "usb": $pattern = "usb://{$_SESSION["WIZARD"]["W_UUID"]}"; break; case "smb": $pattern = $backup->build_smb_protocol($_SESSION["WIZARD"]["W_SMB_SERVER"], $_SESSION["WIZARD"]["W_SMB_SHAREDDIR"], $_SESSION["WIZARD"]["W_SMB_USERNAME"], $_SESSION["WIZARD"]["W_SMB_PASSWORD"]); break; case "rsync": $pattern = $backup->build_rsync_protocol($_SESSION["WIZARD"]["W_SMB_SERVER"], $_SESSION["WIZARD"]["W_SMB_SHAREDDIR"], $_SESSION["WIZARD"]["W_SMB_USERNAME"], $_SESSION["WIZARD"]["W_SMB_PASSWORD"]); break; case "automount": $pattern = "automount:{$_SESSION["WIZARD"]["W_AUTOMOUNT_DIR"]}"; case "local": $pattern = "local:{$_SESSION["WIZARD"]["W_LOCALDIR"]}"; default: break; } $cron = new cron_macros(); $ressources_array[0] = "all"; $ressources_array["OPTIONS"]["STOP_IMAP"] = 0; $schedule = $cron->cron_compile_eachday($_SESSION["WIZARD"]["CRON_DAYS"], $_SESSION["WIZARD"]["CRON_HOURS"], $_SESSION["WIZARD"]["CRON_MIN"]); $datasbackup = base64_encode(serialize($ressources_array)); $resource_type = $_SESSION["WIZARD"]["W_RESOURCE"]; $CRON_CONTAINER = $_SESSION["WIZARD"]["CRON_CONTAINER"]; $md5 = md5($schedule . $pattern); $q = new mysql(); $sql = "INSERT INTO backup_schedules(`zMD5`,`resource_type`,`pattern`,`schedule`,`datasbackup`,`container`)\n\tVALUES('{$md5}','{$resource_type}','{$pattern}','{$schedule}','{$datasbackup}','{$CRON_CONTAINER}')"; $q->QUERY_SQL($sql, "artica_backup"); if (!$q->ok) { echo $q->mysql_error; return; } $sock = new sockets(); $sock->SET_INFO("WizardBackupSeen", 1); $sock = new sockets(); $sock->getFrameWork("cmd.php?backup-build-cron=yes"); }
function BACKUP_EVENTS(){ $html="<table style='width:99%'> <th> </th> <th>{date}</th> <th>{source}</th> <th>{resource}</th> <th>{status}</th> </tr>"; $backup=new backup_protocols(); $sql="SELECT * FROM `cyrus_backup_events` ORDER BY `cyrus_backup_events`.`ID` DESC LIMIT 0 , 200"; $q=new mysql(); $results=$q->QUERY_SQL($sql,"artica_events"); while($ligne=@mysql_fetch_array($results,MYSQL_ASSOC)){ $img="status_ok.gif"; if($ligne["success"]==0){$img="status_critical.gif";} $array=$backup->ParseProto($ligne["remote_ressource"]); $html=$html. " <tr ". CellRollOver()."> <td widh=1% valign='top'><img src='img/fw_bold.gif'></td> <td style='font-size:12px' nowrap><strong>{$ligne["zDate"]}</strong></td> <td style='font-size:12px;font-weight:bold' width=98%><code>{$ligne["local_ressource"]}</code></td> <td style='font-size:12px' align='left' nowrap>{$array["SERVER"]}</td> <td width=1% style='font-size:12px' align='left'><img src='img/$img'></td> </tr> <tr><td colspan=5 style='border-bottom:1px solid #005447' align=right><i style='font-size:11px'>{$ligne["events"]}</i></td></tr>"; } $html=$html." </table>"; $tpl=new templates(); echo $tpl->_ENGINE_parse_body($html); }