예제 #1
0
파일: Project.php 프로젝트: hapebe/filecopy
 function fromDB()
 {
     if (!isset($this->uid) or $this->uid < 0) {
         errlog(__FILE__ . '@' . __LINE__ . ': uid is not valid in fromDB()');
         return false;
     }
     $sql = "SELECT * FROM projects WHERE uid = " . $this->uid . ";";
     $result = @mysql_query($sql);
     if (!$result) {
         errlog(__FILE__ . "@" . __LINE__ . ": " . mysql_error() . " ( SQL = " . $sql . ")");
     }
     if ($row = mysql_fetch_array($result)) {
         $this->name = $row["name"];
         $this->path = $row["path"];
     } else {
         return false;
     }
     return true;
 }
예제 #2
0
 function send_report_mail($recipient)
 {
     global $PATH, $MAIL_CFG, $LNK;
     $fullfilename = $this->fname;
     $msg = "Ein Backup vom Server zum Backup-Server wurde erstellt. Dabei wurde folgendes Protokoll erstellt:\n\n";
     $msg .= $fullfilename . "\n\n";
     $msg .= "Es gab folgende FEHLER (nur solche, die automatisch erfasst werden konnten):\n\n";
     $sql = "select * from reports where klasse like 'ERROR' order by uid asc;";
     $result = mysqli_query($LNK, $sql);
     $txt = "";
     while ($row = mysqli_fetch_assoc($result)) {
         $txt .= $row["datum"] . "\t";
         $txt .= $row["meldung"] . "\n";
     }
     $msg .= $txt;
     if ($txt == "") {
         $msg .= "< KEINE. >";
     }
     $msg .= "\n\n\nEs gab folgende WARNUNGEN:\n\n";
     $sql = "select * from reports where klasse like 'WARNING' order by uid asc;";
     $result = mysqli_query($LNK, $sql);
     $txt = "";
     while ($row = mysqli_fetch_assoc($result)) {
         $txt .= $row["datum"] . "\t";
         $txt .= $row["meldung"] . "\n";
     }
     $msg .= $txt;
     if ($txt == "") {
         $msg .= "< KEINE. >";
     }
     $mail = new htmlMimeMail5();
     $mail->setFrom($MAIL_CFG["from"]);
     $mail->setSubject('Backup-Durchlauf ' . strftime('%d.%m.%y %H:%M:%S', time()));
     $mail->setHeader('Date', date('D, d M y H:i:s O'));
     $mail->setTextCharset('UTF-8');
     $mail->setText($msg);
     $mail->setHtmlCharset('UTF-8');
     $mail->setHTML(file_get_contents($this->fname));
     // $mail->addEmbeddedImage(new fileEmbeddedImage($PATH."img/APPrototype.gif"));
     // $mail->addAttachment(new fileAttachment('example.zip'));
     $mail->setSMTPParams($MAIL_CFG["host"], $MAIL_CFG["port"], $MAIL_CFG["helo"], $MAIL_CFG["auth"], $MAIL_CFG["user"], $MAIL_CFG["pass"]);
     $mail->send(array($recipient), 'smtp');
     // first param is an array!
     if (isset($mail->errors)) {
         echo "\n\n\nFehler beim Versand der Report-Mail an {$recipient} !\n\n\n";
         if (is_array($mail->errors)) {
             echo implode("; ", $mail->errors) . "\n";
             // non-fatal;
         } else {
             errlog($mail->errors) . "\n";
             // non-fatal;
         }
     }
 }
예제 #3
0
파일: inspect.php 프로젝트: hapebe/filecopy
if (isset($nameStats)) {
    echo "Häufigkeiten gleicher Dateinamen:\n";
    $filenameFreqs = array();
    $maxLength = -1;
    $sql = "SELECT DISTINCT fname FROM files WHERE status='C';";
    $result = @mysqli_query($LNK, $sql);
    if (!$result) {
        errlog(__FILE__ . "@" . __LINE__ . ": " . mysqli_error($LNK) . " ( SQL = " . $sql . ")");
    }
    while ($row = mysqli_fetch_assoc($result)) {
        extract($row);
        if (strlen($fname) > $maxLength) {
            $maxLength = mb_strlen($fname);
        }
        $sql2 = "SELECT COUNT(uid) AS cnt FROM files WHERE fname LIKE '" . mysqli_escape_string($LNK, $fname) . "' AND status='C';";
        $result2 = @mysqli_query($LNK, $sql2);
        if (!$result2) {
            errlog(__FILE__ . "@" . __LINE__ . ": " . mysqli_error($LNK) . " ( SQL = " . $sql2 . ")");
        }
        if ($row2 = mysqli_fetch_assoc($result2)) {
            $filenameFreqs[$fname] = $row2['cnt'];
        }
    }
    arsort($filenameFreqs);
    foreach ($filenameFreqs as $fname => $freq) {
        if ($freq < 2) {
            break;
        }
        echo str_pad($fname, $maxLength, " .", STR_PAD_RIGHT) . $freq . "\n";
    }
}
예제 #4
0
require $PATH . "lib/filecopy.lib.php";
$networkPathTranslations = array("D:/projects" => "\\\\chronos\\projects", "D:/public" => "\\\\chronos\\public", "D:/media" => "\\\\chronos\\media", "D:/install" => "\\\\chronos\\install", "D:/angebote" => "\\\\chronos\\angebote", "D:/ina" => "\\\\chronos\\ina");
// echo var_export($_GET, true);
// fetch projects from DB:
$projects = Project::getAll();
$projectFiles = array();
foreach ($projects as $uid => $dummy) {
    $projectFiles[$uid] = array();
}
$recentDays = 60;
$recentTime = makeDBDate(time() - $recentDays * 24 * 60 * 60);
$sql = "SELECT fileid FROM files " . "WHERE extension IN ('ppt','pptx','doc','docx','xls','xlsx','csv','pdf','zip','txt','sav') " . " AND status='C' " . " AND mtime > '" . $recentTime . "' " . "ORDER BY mtime DESC " . "LIMIT 0,1000;";
// warn($sql);
$result = @mysql_query($sql);
if (!$result) {
    errlog(__FILE__ . "@" . __LINE__ . ": " . mysql_error() . " ( SQL = " . $sql . ")");
}
while ($row = mysql_fetch_array($result)) {
    $fileid = $row["fileid"];
    $f = new BackupFile($fileid);
    foreach ($projects as $uid => $project) {
        if (strpos($f->path, $project->path) !== false) {
            // gotcha!
            $projectFiles[$uid][] = $f;
        }
    }
}
$sectionTemplate = new Template(file_get_contents($PATH . "templates/recentUpdates-section.html"));
$lineTemplate = new Template(file_get_contents($PATH . "templates/recentUpdates-line.html"));
$output = array();
foreach ($projects as $uid => $project) {
예제 #5
0
function deletefield($sqlconnection, $settable, $searchfield, $searchf)
{
    //Creating table
    if ($sqlconnection->query("DELETE FROM {$settable} WHERE {$searchfield}='{$searchf}';")) {
        return true;
    }
    //If fails
    return errlog("Error: " . $sqlconnection->error . " Failed to delete {$searchf} in: {$settable}");
}