예제 #1
0
function pdo_connect()
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/key/database.php';
    $host = get_mysql_host();
    $db = get_mysql_database();
    $user = get_mysql_user();
    $pwd = get_mysql_password();
    try {
        $pdo = new PDO("mysql:host={$host};dbname={$db};charset=utf8", $user, $pwd);
        return $pdo;
    } catch (PDOException $e) {
        var_dump($e->getMessage());
        exit;
    }
}
예제 #2
0
        show_counts(tra("registered in past 24 hours"), "users_registered_in_past_24_hours", get_mysql_count("user where create_time > (unix_timestamp() - (24*3600))"));
        echo "<tr><th>" . tra("Computers") . "</th><th>#</th></tr>";
        show_counts(tra("with recent credit"), "hosts_with_recent_credit", get_mysql_count("host where expavg_credit>1"));
        show_counts(tra("with credit"), "hosts_with_credit", get_mysql_count("host where total_credit>0"));
        show_counts(tra("registered in past 24 hours"), "hosts_registered_in_past_24_hours", get_mysql_count("host where create_time > (unix_timestamp() - (24*3600))"));
        // 200 cobblestones = 1 GigaFLOPS
        show_counts(tra("current GigaFLOPs"), "current_floating_point_speed", get_mysql_value("SELECT sum(expavg_credit)/200 as value FROM user"));
        end_table();
        echo "</td></tr></table>";
        start_table();
        echo "<tr><th colspan=5>" . tra("Tasks by application") . "</th></tr>";
        row_heading_array(array(tra("application"), tra("unsent"), tra("in progress"), tra("avg runtime of last 100 results in h (min-max)"), tra("users in last 24h")));
        $apps = get_mysql_assoc("SELECT * FROM app WHERE deprecated != 1");
        foreach ($apps as $app) {
            $appid = $app["id"];
            $uf_name = $app["user_friendly_name"];
            echo "<tr><td>{$uf_name}</td>\n            <td>" . number_format(get_mysql_count("result where server_state = 2 and appid = {$appid}")) . "</td>\n            <td>" . number_format(get_mysql_count("result where server_state = 4 and appid = {$appid}")) . "</td>\n            <td>";
            $info = get_runtime_info($appid);
            echo number_format($info->avg, 2) . " (" . number_format($info->min, 2) . " - " . number_format($info->max, 2) . ")";
            echo "</td>\n            <td>" . number_format(get_mysql_user("and appid = {$appid}")) . "</td>\n            </tr>";
        }
        end_table();
    }
}
$xmlstring = "  </database_file_states>\n</server_status>\n";
if ($xml) {
    echo $xmlstring;
} else {
    echo "\n        </td>\n        </tr>\n        </table>\n    ";
    page_tail();
}