Esempio n. 1
0
function write_src($path, $info)
{
    if (empty($info['file']) === true || file_exists($info['file']) === false) {
        return $info;
    }
    global $db;
    $vars = array();
    $results = $db->query('select * from locals where call = ' . $info['call']);
    while ($row = $results->fetchArray()) {
        $vars[$row['name']] = write_var($path, $row, 'l');
    }
    $args = array();
    $results = $db->query('select n.name, v.value, c.call from args n, argvs v, funcs f, calls c where f.func = c.func and n.func = f.func and v.call = c.call and n.seq = v.seq and c.call = ' . $info['call']);
    while ($row = $results->fetchArray()) {
        $args[$row['name']] = write_var($path, $row, 'a');
    }
    $fp = fopen($info['file'], 'r');
    $content = "<pre>\n";
    for ($i = 1; $i < $info['line_start']; ++$i) {
        $content .= write_line_no($i) . htmlspecialchars(fgets($fp));
    }
    for (; $i <= $info['line_end']; ++$i) {
        $content .= write_line_no($i) . write_line(fgets($fp), $i, $info, $vars, $args);
    }
    while (($tmp = fgets($fp)) !== false) {
        $content .= write_line_no($i++) . htmlspecialchars($tmp);
    }
    $content .= "</pre>\n";
    fclose($fp);
    global $globals;
    $params = array('globals' => $globals, 'content' => $content);
    $file = $info['call'] . '_' . basename($info['file']) . '.html';
    if (write_html($params, 'src.template.php', "{$path}/src/{$file}") === true) {
        $info['url'] = "src/{$file}#cur";
    }
    return $info;
}
Esempio n. 2
0
        $mapper = new NoneShardKeyMapper($config);
        break;
    default:
        throw new Exception('Unsupported mapper: ' . $config_database['mapper']);
        break;
}
if (empty($config['gearman'])) {
    /* 
    Add a Shard-Query managed gearmand
    */
    write_line("A gearman server was not seen in your config.  Enter a host to use: [127.0.0.1]");
    $gearman_host = read_line();
    if (!trim($gearman_host)) {
        $gearman_host = '127.0.0.1';
    }
    write_line("A gearman port was not seen in your config.  Enter a port number to use: [7001]");
    $gearman_port = read_line();
    if (!trim($gearman_port)) {
        $gearman_port = 7001;
    }
    $gearman = array(array('hostname' => $gearman_host, 'port' => $gearman_port, 'is_local' => true));
} else {
    /*
    Use externally managed gearmand
    */
    $gearman = $config['gearman'];
    unset($config['gearman']);
    $gearmen = explode(',', $gearman);
    if (!is_array($gearmen)) {
        $gearmen = array($gearman);
    }
if ($create_user === true) {
    //add acount
    write_line("Creating user...");
    $sql = "CREATE USER '{$sq_username}'@'%' IDENTIFIED BY '{$sq_password}'";
    $dbh->query($sql);
    $sql = "CREATE USER '{$sq_username}'@'localhost' IDENTIFIED BY '{$sq_password}'";
    $dbh->query($sql);
    $sql = "GRANT ALL ON `shard_query`.* TO 'shard_query'@'%';";
    $dbh->query($sql);
    $sql = "GRANT ALL ON `shard_query`.* TO 'shard_query'@'localhost';";
    $dbh->query($sql);
}
//Create database + tables
write_line("Installing 'shard_query' database");
$cmd = "mysql -h{$sq_host} -P{$sq_port} -u {$username} ";
if (trim($password) != "") {
    $cmd .= "-p{$password} ";
}
$stmt = $dbh->query("CREATE DATABASE IF NOT EXISTS {$sq_db}") or die("Could not create database (wrong credentials?)!");
$cmd .= "-D {$sq_db} < shard_query.sql";
$result = exec($cmd);
//print if we have error?
if (!empty($result)) {
    echo "ERROR:\n";
    write_line($result);
    exit(1);
}
//done
#write_line("Done!");
// Exit correctly
exit(0);
Esempio n. 4
0
    }
    if (is_numeric($player['deaths'])) {
        $player['deaths'] = number_format($player['deaths']);
    }
    if (is_numeric($player['ratio'])) {
        $player['ratio'] = number_format($player['ratio'], 2);
    }
    if (is_numeric($player['winstreak'])) {
        $player['winstreak'] = number_format($player['winstreak']);
    }
    if (is_numeric($player['losestreak'])) {
        $player['losestreak'] = number_format($player['losestreak']);
    }
    write_line($image, $font_size, 0, $x, $y, $color_stats_text, $font, "Skill: " . $player['skill'], $font_spacing);
    write_line($image, $font_size, 0, $x, $y, $color_stats_text, $font, "Kills: " . $player['kills'], $font_spacing);
    write_line($image, $font_size, 0, $x, $y, $color_stats_text, $font, "Deaths: " . $player['deaths'], $font_spacing);
    write_line($image, $font_size, 0, $x, $y, $color_stats_text, $font, "Ratio: " . $player['ratio'], $font_spacing);
    write_line($image, $font_size, 0, $x, $y, $color_stats_text, $font, "Kill Streak: " . $player['winstreak'], $font_spacing);
    write_line($image, $font_size, 0, $x, $y, $color_stats_text, $font, "Death Streak: " . $player['losestreak'], $font_spacing);
    //write_line( $image, $font_size, 0, $x, $y, $color_stats_text, $font, "Connections: " . number_format($player['connections']), $font_spacing  );
}
// Hosted by box.
define("HOSTED_BY", "XLRstats");
$font = "./fonts/gunplay.ttf";
$font_size = 11;
$box = imagettfbbox($font_size, 0, $font, HOSTED_BY);
$text_width = $box[0] + $box[4];
$text_height = $box[1] - $box[5];
imagefilledrectangle($image, $image_width - ($text_width + 14), $image_height - ($text_height + 6), $image_width - 1, $image_height - 1, $color_hb_shade);
imagerectangle($image, $image_width - ($text_width + 14), $image_height - ($text_height + 6), $image_width - 1, $image_height - 1, $color_hb_border);
imagettftext($image, $font_size, 0, $image_width - ($text_width + 10), $image_height - ($text_height / 2 - 2), $color_hb_text, $font, HOSTED_BY);
Esempio n. 5
0
function if_weiboapi_fail_cmd($api_res, $line = null, $out_put = FALSE)
{
    if (isset($api_res['error_code'])) {
        if ($out_put) {
            $msg = "id:{$sid}\terror_code:{$api_res['error_code']}\terror:{$api_res['error']}\t{$line}\n";
            //            echo $msg;
            write_line($msg);
        }
    }
    if (!$api_res && $out_put) {
        $msg = "weibo api returns nothing.\n";
        //        echo $msg;
        write_line($msg);
    }
}
    $mapper->conn->my_query($sql) or die("SETUP FAILED: " . $mapper->conn->my_error());
}
echo "";
$create_user = true;
if (empty($params['user'])) {
    write_line("Please enter admin credentials for a user with GRANT option (to set up each shard): ");
    write_line("Please enter mysql a administrator username: [root]");
    $username = read_line();
} else {
    $username = $params['user'];
}
if (trim($username) == "") {
    $username = "******";
}
if (empty($params['password'])) {
    write_line("Enter admin password: [default no password]");
    $password = read_line();
} else {
    $password = $params['password'];
}
echo "* Populating/Updating shard list\n";
$mapper->conn->my_query('DELETE IGNORE shards.* from shards join schemata on shards.schema_id = schemata.id where schema_name = "' . $config['schema_name'] . '"') or die($mapper->conn->my_error());
foreach ($shards as $shard_name => $shard) {
    if (!isset($coord_shard_name) || isset($coord_shard_name) && $shard_name == $coord_shard_name) {
        $coord_shard = 1;
    } else {
        $coord_shard = 0;
    }
    $mapper->add_shard($shard_name, $shard, $coord_shard, $accepts_new_rows = true, null, $config['schema_name']);
    if ($create_user) {
        $shard_admin = $shard;