Exemplo n.º 1
0
function increment_skip($connection, $username)
{
    $sql_query = "UPDATE googlockusers SET skipped=skipped+1 WHERE username='******'";
    //lock
    put_lock($connection, "googlockusers", "write");
    $temp = mysql_query($sql_query, $connection);
    remove_lock($connection);
    //unlock
}
Exemplo n.º 2
0
function handle_success($file)
{
    if (lock_exists($file)) {
        if (remove_lock($file)) {
            send_email("Uptime Detected for {$file}");
        } else {
            // could not remove lock
        }
    }
}
Exemplo n.º 3
0
    put_lock($connection, "googlockquestions", "read");
    $temp = mysql_query($sql_query, $connection);
    remove_lock($connection);
    //unlock
    $no_of_records = mysql_num_rows($temp);
    for ($i = 0; $i < $no_of_records; $i++) {
        //setcookie( either the cookie method in which a javascript is used to keep tab
        //else we can use a hidden form an check if the values are not null. if null this is the first time this form has been
        //visited, keep a counter and after every 5 refreshes or so give fresh values.also note that after refresh the values are deleted therefore the php script has to check and set the values every time( no need to set fresh values, just the stale ones back again)
    }
    $result3 = mysql_fetch_array($temp);
    $sql_query = "select score from googlockusers where username='******'";
    //lock
    put_lock($connection, "googlockusers", "read");
    $temp = mysql_query($sql_query, $connection);
    remove_lock($connection);
    //unlock
    $result2 = mysql_fetch_array($temp);
    mysql_close($connection);
    if (isset($_COOKIE["time"]) == FALSE || stristr($_COOKIE["time"], "undefined") || stristr($_COOKIE["time"], "NaN")) {
        $raw_time = $duration - $diff;
        $hours = floor($raw_time / 3600);
        $raw_time = $raw_time % 3600;
        $minutes = floor($raw_time / 60);
        $seconds = $raw_time % 60;
        $to_send = $hours . ":" . $minutes . ":" . $seconds . ":";
        setcookie("time", $to_send, 0, '/');
    }
} else {
    session_destroy();
    setcookie("username", "a", time() - 1000);
// check if existing "output/NagiosConfig.tgz" is writable
if (file_exists(NCONFDIR . "/output/NagiosConfig.tgz" and !is_writable(NCONFDIR . "/output/NagiosConfig.tgz"))) {
    $content = "Cannot rename " . NCONFDIR . "/output/NagiosConfig.tgz. Access denied.";
    NConf_DEBUG::set($content, 'ERROR');
    echo NConf_HTML::limit_space(NConf_HTML::show_error('Error'));
    remove_lock();
    exit;
}
// check if static config folder(s) are readable
foreach ($STATIC_CONFIG as $static_folder) {
    if (!is_readable($static_folder)) {
        $content = "<br>Could not access static config folder '" . $static_folder . "'.";
        $content .= "<br>Check your \$STATIC_CONFIG array in 'config/nconf.php'.";
        NConf_DEBUG::set($content, 'ERROR');
        echo NConf_HTML::limit_space(NConf_HTML::show_error('Error'));
        remove_lock();
        exit;
    }
}
// fetch all monitor and collector servers from DB
$servers = array();
$query = "SELECT fk_id_item AS item_id,attr_value,config_class\n                  FROM ConfigValues,ConfigAttrs,ConfigClasses\n                  WHERE id_attr=fk_id_attr\n                      AND naming_attr='yes'\n                      AND id_class=fk_id_class\n                      AND (config_class = 'nagios-collector' OR config_class = 'nagios-monitor') \n                  ORDER BY attr_value";
$result = db_handler($query, "result", "fetch all monitor and collector servers from DB");
while ($entry = mysql_fetch_assoc($result)) {
    $renamed = preg_replace('/-|\\s/', '_', $entry["attr_value"]);
    if ($entry["config_class"] == 'nagios-collector') {
        $renamed = preg_replace('/Nagios|Icinga/i', 'collector', $renamed);
    }
    array_push($servers, $renamed);
}
# GENERATE CONFIG