Beispiel #1
0
function get_buttons_desktop()
{
    $pinarr = parsefile("pins.conf");
    echo "\n<table id='buttons'>\n";
    foreach ($pinarr as $pininfo) {
        echo "<tr>\n";
        $pinname = $pininfo[0];
        $pinnum = $pininfo[1];
        $onstate = $pininfo[2];
        $pinon = false;
        if ($onstate === exec("gpio read " . $pinnum)) {
            $pinon = true;
        }
        echo "<td><img class='button' id='button" . $pinnum . "' style='max-width: 30%; max-height: 30%;" . "' src='img/" . get_state_image($pinon) . "' onclick='changepin(" . $pinnum . ", " . $onstate . ");'></td>\n";
        echo "<td><h1>" . strtoupper($pinname) . "</h1></td>\n";
        echo "</tr>\n";
        echo "\n";
    }
    echo "</table>\n";
}
Beispiel #2
0
         $page_importSuccessMsg = "<a href=\"" . $urlmode . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . "/admin.php\">Return to Admin page</a>";
     } else {
         $page_importSuccessMsg = "<a href=\"" . $urlmode . $_SERVER['HTTP_HOST'] . $imasroot . "/course/course.php?cid={$cid}\">Return to Course page</a>";
     }
 } elseif ($_FILES['userfile']['name'] != '') {
     //FILE POSTED, STEP 2 DATA MANIPULATION
     $uploaddir = rtrim(dirname(__FILE__), '/\\') . '/import/';
     $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
     $page_fileErrorMsg = "";
     $page_fileNoticeMsg = "";
     if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
         $page_fileHiddenInput = "<input type=hidden name=\"filename\" value=\"" . basename($uploadfile) . "\" />\n";
     } else {
         $page_fileErrorMsg .= "<p>Error uploading file!</p>\n";
     }
     $qdata = parsefile($uploadfile);
     if (!isset($qdata['pack']) && !isset($qdata['libdesc'])) {
         $page_fileErrorMsg .= "This does not appear to be a valid IMathAS file. <a href=\"import.php?cid={$cid}\">Try Again</a>";
     }
     foreach ($qdata as $qnd) {
         if (is_numeric($qnd['uqid'])) {
             $lookup[] = $qnd['uqid'];
         }
     }
     $lookup = implode("','", $lookup);
     $query = "SELECT id,uniqueid FROM imas_questionset WHERE uniqueid IN ('{$lookup}')";
     $result = mysql_query($query) or die("Query failed : " . mysql_error());
     if (mysql_num_rows($result) > 0) {
         $existing = true;
         $page_existingMsg = "<p>This file contains questions with uniqueids that already exist on this system.  With these questions, do you want to:<br/>\n";
         $page_existingMsg .= "<input type=radio name=merge value=\"1\" CHECKED>Update existing questions, <input type=radio name=merge value=\"0\">Add as new question, or <input type=radio name=merge value=\"-1\">Keep existing question</p>\n";
Beispiel #3
0
}
if ($computer->ComputerIP != null) {
    $cdir = $computer->ComputerIP;
} else {
    $cdir = $GLOBALS["COMPUTER"];
}
echo "Scanning {$cdir} and save results to /etc/artica-postfix/{$cdir}.map\n";
$cmd = $users->NMAP_PATH . " -v -F -PE -O {$cdir} -oN /etc/artica-postfix/{$cdir}.map --system-dns --version-light >/dev/null 2>&1";
echo "Executing {$cmd}\n";
system($cmd);
echo "Parsing results for {$cdir}\n";
if (!is_file("/etc/artica-postfix/{$cdir}.map")) {
    echo "Unable to stat /etc/artica-postfix/{$cdir}.map\n";
    exit;
}
parsefile("/etc/artica-postfix/{$cdir}.map", $GLOBALS["COMPUTER"]);
function parsefile($filename, $uid)
{
    $datas = file_get_contents($filename);
    $tbl = explode("\n", $datas);
    if (!is_array($tbl)) {
        return null;
    }
    while (list($num, $ligne) = each($tbl)) {
        if (preg_match("#([0-9]+).+?open\\s+(.+)#", $ligne, $re)) {
            $array[] = $re[1] . ":" . $re[2];
            continue;
        }
        if (preg_match("#^Running:(.+)#", $ligne, $re)) {
            $ComputerRunning = $re[1];
            continue;
Beispiel #4
0
            }
        }
        exit;
    } elseif ($_FILES['userfile']['name'] != '') {
        //STEP 2 DATA MANIPULATION
        $page_fileErrorMsg = "";
        $uploaddir = rtrim(dirname(__FILE__), '/\\') . '/import/';
        $uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
            $page_fileHiddenInput = "<input type=hidden name=\"filename\" value=\"" . basename($uploadfile) . "\" />\n";
        } else {
            echo "<p>Error uploading file!</p>\n";
            echo $_FILES["userfile"]['error'];
            exit;
        }
        list($desc, $itemlist, $item, $questions, $qset) = parsefile($uploadfile);
        if (!isset($desc)) {
            $page_fileErrorMsg .= "This does not appear to be a course items file.  It may be ";
            $page_fileErrorMsg .= "a question or library export.\n";
        }
        $items = unserialize($itemlist);
        $ids = array();
        $types = array();
        $names = array();
        $parents = array();
        getsubinfo($items, '0', '');
    }
}
/******* begin html output ********/
require "../header.php";
if ($overwriteBody == 1) {
Beispiel #5
0
function nmap_scan_single($mac, $ipaddrZ = null)
{
    $unix = new unix();
    $users = new usersMenus();
    if (!is_file($users->NMAP_PATH)) {
        build_progress("{operation_failed} err." . __LINE__, 110);
        return;
    }
    if ($mac == "00:00:00:00:00:00") {
        $mac = null;
    }
    $mac = trim(strtolower($mac));
    if ($mac == null) {
        if ($ipaddrZ == null) {
            build_progress("{operation_failed} err." . __LINE__, 110);
            return;
        }
    }
    build_progress("Determine IP addresses", 5);
    if ($ipaddrZ != null) {
        $ipaddr[$ipaddrZ] = true;
    }
    if ($mac != null) {
        $computer = new computers();
        $uid = $computer->ComputerIDFromMAC($mac);
        if ($uid != null) {
            $computer = new computers($uid);
            $ipaddr[$computer->ComputerIP] = true;
        }
        $q = new mysql_squid_builder();
        $results = $q->QUERY_SQL("SELECT ipaddr,MAC FROM UserAutDB GROUP BY ipaddr,MAC HAVING MAC='{$mac}' AND LENGTH(ipaddr)>0");
        $count = mysql_num_rows($results);
        if ($count > 0) {
            while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
                $ipaddr[$ligne["ipaddr"]] = true;
            }
        }
    }
    if (count($ipaddr) == 0) {
        build_progress("{operation_failed} no ip found err." . __LINE__, 110);
        return;
    }
    build_progress("Scanning " . count($ipaddr) . " nodes", 10);
    $i = 10;
    $NICE = EXEC_NICE();
    while (list($IPADDRESS, $line) = each($ipaddr)) {
        $i = $i + 5;
        build_progress("Scanning {$IPADDRESS}", $i);
        if (!$unix->PingHostCMD($IPADDRESS)) {
            continue;
        }
        $cmd = trim($NICE . " " . $users->NMAP_PATH . " -v -F -PE -PN -O {$IPADDRESS}  --system-dns --version-light 2>&1");
        build_progress("Scanning {$IPADDRESS} done...", $i);
        $resultsScan = array();
        exec($cmd, $resultsScan);
        $tmpfile = $unix->TEMP_DIR() . "/nmap.{$IPADDRESS}.log";
        @file_put_contents($tmpfile, @implode("\n", $resultsScan));
        echo @implode("\n", $resultsScan);
        $array = ExecArrayToArray($resultsScan);
        if ($GLOBALS["VERBOSE"]) {
            echo "\nParsing " . count($array) . " items in sarray\n";
        }
        if (!is_array($array)) {
            continue;
        }
        if ($array["MAC"] != $mac) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$array["MAC"]} <> {$mac} !!!\n";
            }
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo " * * * * *  * * * *\n";
        }
        build_progress("{$mac}:-> {$IPADDRESS} OK", $i + 5);
        echo "{$mac}:-> {$IPADDRESS} OK\n";
        $data = base64_encode(serialize($array));
        $sql = "UPDATE webfilters_nodes SET nmap=1,nmapreport='{$data}' WHERE MAC='{$mac}'";
        $q->QUERY_SQL($sql);
        build_progress("Analyze scan...", $i + 5);
        if ($GLOBALS["VERBOSE"]) {
            echo "Parsing {$tmpfile}\n";
        }
        parsefile($tmpfile, null, $i);
    }
    build_progress("Done...", 100);
}