Exemplo n.º 1
0
function __autoload($class_name)
{
    $lowerclass = strtolower($class_name);
    $file = "classes";
    $len = strlen($class_name);
    for ($i = 0; $i < $len; $i++) {
        $a = substr($lowerclass, $i, 1);
        $b = substr($class_name, $i, 1);
        if ($a == $b) {
            $file .= $a;
        } else {
            $file .= "/" . $a;
        }
    }
    $file .= ".php";
    // echo $file."<br />";
    if (file_exists($file)) {
        require_once $file;
    } else {
        Logfile::writeError("Unable to find class file: " . $file);
    }
}
Exemplo n.º 2
0
 function emailResults($email, $emailinterval, $alreadyRunning)
 {
     $mailed = false;
     $title = "WebMonitor: ";
     if ($alreadyRunning) {
         $this->report .= "<h2>ERROR</h2><p>Last scan failed to complete, displaying results from last scan</p>";
         $title .= "ERROR: ";
     }
     $witherrors = " ";
     if (Logfile::getNoErrors() > 0) {
         $witherrors = " (with errors) ";
     }
     if ($this->db->getTotals() === 0) {
         $title .= $witherrors . $this->domain . '  Integrity Report v' . VERSION_NUMBER . " PHP:" . PHP_VERSION;
     } else {
         $title .= $this->domain . '  Change Report (' . $this->db->getTotals() . ') v' . VERSION_NUMBER . " PHP:" . PHP_VERSION;
     }
     echo $title;
     $tested = $this->db->getLastRunDate();
     $this->report .= "<p>Last tested {$tested}.</p>" . PHP_EOL;
     $lastemailsent = $this->db->getLastEmailSentRunDate();
     $this->report .= "<p>Last email sent {$lastemailsent}.</p>" . PHP_EOL;
     //	E-Mail Results
     // 	display discrepancies
     $send = $this->sendEmail($lastemailsent, $emailinterval, $alreadyRunning);
     $this->report .= $this->db->summaryReport();
     echo $this->report;
     if ($send) {
         $headers = "From: admin@" . $this->domain . "\r\n";
         $headers .= "Content-type: text/html\r\n";
         $mailed = mail($email, $title, $this->report, $headers);
         if (!$mailed) {
             Logfile::writeError("Email failed to be sent");
         } else {
             Logfile::writeWhen("Email sent");
         }
     } else {
         Logfile::writeWhen("Email not required");
     }
     $this->db->recordtestDate($mailed);
 }
Exemplo n.º 3
0
 function insertRecord($table, $names, $values)
 {
     $query = "Insert into " . $table;
     $query .= self::createNames($names);
     $query .= self::createValues($values);
     $result = $this->mysqli->query($query);
     if ($result === false) {
         Logfile::writeError($this->error());
         return false;
     }
     return true;
     // we're done for this file
 }
Exemplo n.º 4
0
 function getLastRunDate()
 {
     $tested = "";
     $ok = parent::runQuery("SELECT tested FROM tested ORDER BY tested DESC LIMIT 1");
     if ($ok) {
         $result = parent::getResult();
         $row = $result->fetch_row();
         $tested = $row[0];
     } else {
         Logfile::writeError('Unable to retrieve last test date(' . parent::error());
     }
     Logfile::writeWhen("Last scan date " . $tested);
     return $tested;
 }