コード例 #1
0
function failed($result)
{
    echo "\n\n";
    echo join("\n", $result);
    printf("Last operation took: %.2f secs\n", lap());
    exit;
}
コード例 #2
0
    }
    $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"];
    printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap());
}
echo "---\n";
foreach ($PRESETS["replicasets"] as $preset) {
    lap();
    $json = json_decode(file_get_contents($preset), true);
    printf("Starting %-20s ...  ", $json["id"]);
    $result = file_get_contents(getMOUri() . "/replica_sets", false, make_ctx(getMOPresetBase() . $preset));
    $decode = json_decode($result, true);
    if (!isset($decode["id"])) {
        failed($decode);
    }
    $SERVERS[$decode["id"]] = isset($decode["mongodb_auth_uri"]) ? $decode["mongodb_auth_uri"] : $decode["mongodb_uri"];
    printf("'%s'\t(took: %.2f secs)\n", $SERVERS[$decode["id"]], lap());
}
file_put_contents($FILENAME, json_encode($SERVERS, JSON_PRETTY_PRINT));
/*
wget --body-data='' --method='GET' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-AUTH
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-24
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-26
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/RS-two
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/RS-arbiter
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-PLAIN
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-X509
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/RS-one
wget --body-data='' --method='DELETE' --header='Accept: application/json' --header='Content-type: application/x-www-form-urlencoded'  http://192.168.112.10:8889/servers/STANDALONE-SSL
コード例 #3
0
ファイル: function.php プロジェクト: jvinhit/php
function online($iduser, $link, $lang = 1, $dangxem_on = 1, $thanhvien_on = 1, $khach_on = 1, $homnay_on = 1, $homqua_on = 1, $tuantruoc_on = 1, $thangtruoc_on = 1, $tong_on = 1)
{
    settype($iduser, "int");
    $ip = $_SERVER['REMOTE_ADDR'];
    $ngay = date("Y-m-d");
    $ngay_so = strtotime("now");
    if (check('users_count', "ip='{$ip}' AND ngay='{$ngay}'", 'id') == 0) {
        $sql = "INSERT INTO users_count (ip,ngay,iduser,ngay_so) VALUES ('{$ip}','{$ngay}','{$iduser}','{$ngay_so}')";
        mysql_query($sql) or die(mysql_error());
    } else {
        $sql = "UPDATE users_count SET dem=dem+1 WHERE ip='{$ip}' AND ngay='{$ngay}'";
        $kq_luu = mysql_query($sql) or die(mysql_error());
    }
    $homqua = date('Y-m-d', strtotime("-1 day"));
    $t2_truoc = date('Y-m-d', strtotime("last Sunday"));
    $cn_truoc = date('Y-m-d', strtotime('-6 day', $t2_truoc));
    $ngaydau_t_truoc = date('Y-m-d', strtotime('last month', strtotime(date('m/01/y'))));
    $ngaycuoi_t_truoc = date('Y/m/d', strtotime('this month', strtotime(date('m/01/y'))) - 1);
    $nguoi_homnay = dem('users_count', "ngay='{$ngay}'");
    $nguoi_homqua = dem('users_count', "ngay='{$homqua}'");
    $nguoi_tuantruoc = dem('users_count', "ngay>='{$cn_truoc}' AND ngay<='{$t2_truoc}'");
    $nguoi_thangtruoc = dem('users_count', "ngay>='{$ngaydau_t_truoc}' AND ngay<='{$ngaycuoi_t_truoc}'");
    $sqlcount1 = "SELECT count(*) FROM users_count GROUP BY ip";
    $rs1 = mysql_query($sqlcount1);
    $rows_rs1 = mysql_fetch_row($rs1);
    $nguoi_tong1 = $rows_rs1[0];
    $sqlcount2 = "SELECT count(*) FROM users_count";
    $rs2 = mysql_query($sqlcount2);
    $rows_rs2 = mysql_fetch_row($rs2);
    $nguoi_tong2 = $rows_rs2[0];
    $nguoi_tong = $nguoi_tong2 - $nguoi_tong1;
    $luot_homnay_lap = lap('users_count', "ngay='{$ngay}'", ' ', ' ', ' ');
    while ($row_luot_homnay_lap = mysql_fetch_assoc($luot_homnay_lap)) {
        $luot_homnay = $luot_homnay + $row_luot_homnay_lap['dem'];
    }
    $luot_homnay;
    settype($luot_homnay, "int");
    $luot_homqua_lap = lap('users_count', "ngay='{$homqua}'", ' ', ' ', ' ');
    while ($row_luot_homqua_lap = mysql_fetch_assoc($luot_homqua_lap)) {
        $luot_homqua = $luot_homqua + $row_luot_homqua_lap['dem'];
    }
    $luot_homqua;
    settype($luot_homqua, "int");
    $luot_tuantruoc_lap = lap('users_count', "ngay>='{$cn_truoc}' AND ngay<='{$t2_truoc}'", ' ', ' ', ' ');
    while ($row_luot_tuantruoc_lap = mysql_fetch_assoc($luot_tuantruoc_lap)) {
        $luot_tuantruoc = $luot_tuantruoc + $row_luot_tuantruoc_lap['dem'];
    }
    $luot_tuantruoc;
    settype($luot_tuantruoc, "int");
    $luot_thangtruoc_lap = lap('users_count', "ngay>='{$ngaydau_t_truoc}' AND ngay<='{$ngaycuoi_t_truoc}'", ' ', ' ', ' ');
    while ($row_luot_thangtruoc_lap = mysql_fetch_assoc($luot_thangtruoc_lap)) {
        $luot_thangtruoc = $luot_thangtruoc + $row_luot_thangtruoc_lap['dem'];
    }
    $luot_thangtruoc;
    settype($luot_thangtruoc, "int");
    $luot_tong_lap = lap('users_count', " ", ' ', ' ', ' ');
    while ($row_luot_tong_lap = mysql_fetch_assoc($luot_tong_lap)) {
        $luot_tong = $luot_tong + $row_luot_tong_lap['dem'];
    }
    $luot_tong;
    settype($luot_tong, "int");
    if ($uo_keepquiet == FALSE) {
        $uo_query = "SELECT count(*) FROM users_online";
        $uo_result = mysql_query($uo_query);
        $uo_count = mysql_fetch_row($uo_result);
        $dangxem = $uo_count[0];
        $uo_query = "SELECT count(*) FROM users_online where username <>''";
        $uo_result = mysql_query($uo_query);
        $uo_count = mysql_fetch_row($uo_result);
        $thanhvien = $uo_count[0];
        $uo_query = "SELECT count(*) FROM users_online where username =''";
        $uo_result = mysql_query($uo_query);
        $uo_count = mysql_fetch_row($uo_result);
        $khach = $uo_count[0];
    }
    echo ngay_run('on_ngay_au', $giatri = 1);
    if ($lang == 1) {
        $dangxem1 = 'Đang xem';
        $thanhvien1 = 'Thành viên';
        $khach1 = 'Khách';
        $homnay1 = 'Trong ngày';
        $tuantruoc1 = 'Trong tuần';
        $thangtruoc1 = 'Trong tháng';
        $tong1 = "Tổng truy cập";
    } elseif ($lang == 2) {
        $dangxem1 = 'Viewing';
        $thanhvien1 = 'Member';
        $khach1 = 'Guest';
        $homnay1 = 'Today';
        $tuantruoc1 = 'Last week';
        $thangtruoc1 = 'Last month';
        $tong1 = "Total";
    }
    if ($dangxem_on == 1) {
        $d1 = "\n\t\t<li>\n\t\t\t<span class='li_span1'>" . $dangxem1 . "</span> \n\t\t\t<span class='li_span2'>: " . $dangxem . "</span>\n\t\t\t<div class='clear'></div>\n\t\t</li>";
    }
    if ($thanhvien_on == 1) {
        $d2 = "\n\t\t<li>\n\t\t\t<span class='li_span1'>" . $thanhvien1 . "</span> \n\t\t\t<span class='li_span2'>: " . $thanhvien . "</span>\n\t\t\t<div class='clear'></div>\n\t\t</li>";
    }
    if ($khach_on == 1) {
        $d3 = "\n\t\t<li>\n\t\t\t<span class='li_span1'>" . $khach1 . "</span> \n\t\t\t<span class='li_span2'>: " . $khach . "</span>\n\t\t\t<div class='clear'></div>\n\t\t</li>";
    }
    if ($homnay_on == 1) {
        $d4 = "\n\t\t<li>\n\t\t\t<span class='li_span1'>" . $homnay1 . "</span> \n\t\t\t<span class='li_span2'>: " . $luot_homnay . "</span>\n\t\t\t<div class='clear'></div>\n\t\t</li>";
    }
    if ($tuantruoc_on == 1) {
        $d5 = "\n\t\t<li>\n\t\t\t<span class='li_span1'>" . $tuantruoc1 . "</span> \n\t\t\t<span class='li_span2'>: " . $luot_tuantruoc . "</span>\n\t\t\t<div class='clear'></div>\n\t\t</li>";
    }
    if ($thangtruoc_on == 1) {
        $d6 = "\n\t\t<li>\n\t\t\t<span class='li_span1'>" . $thangtruoc1 . "</span> \n\t\t\t<span class='li_span2'>: " . $luot_thangtruoc . "</span>\n\t\t\t<div class='clear'></div>\n\t\t</li>";
    }
    if ($tong_on == 1) {
        $d7 = "\n\t\t<li>\n\t\t\t<span class='li_span1'>" . $tong1 . "</span> \n\t\t\t<span class='li_span2'>: " . $luot_tong . "</span>\n\t\t\t<div class='clear'></div>\n\t\t</li>";
    }
    $kq = "<ul class='ul_tktc'>" . $d1 . $d2 . $d3 . $d4 . $d5 . $d6 . $d7 . "</ul>";
    return $kq;
}