Example #1
0
function insert_rightscale_data($server_cfg, $game_cfg, $time_slots = '*')
{
    // TODO take the names from config and expand table as and when new machine class is added to config
    $machine_class_default = array('web_count' => 0, 'mb_count' => 0, 'mc_count' => 0, 'db_count' => 0, 'queue_count' => 0, 'proxy_count' => 0, 'admin_count' => 0);
    $game_name = $game_cfg["name"];
    $table = $game_cfg['db_stats_table'];
    $gid = $game_cfg['gameid'];
    // to query for the dau_5min table and to insert into stats_30min;
    $snid = $game_cfg['snid'] ? $game_cfg['snid'] : null;
    $cid = $game_cfg['cid'] ? $game_cfg['cid'] : null;
    $deploy_array = $game_cfg['deployIDs'];
    $deploy_id = $deploy_array[0];
    //
    // get the max value of the supplied timeslots
    // expects that time_slots are given as follows
    // {ts1,ts2}
    //
    preg_match("/\\{(.*)\\}/", $time_slots, $m);
    $timeslot = max(explode(",", $m[1]));
    if (empty($timeslot)) {
        $game_cfg['logger']->log("insert_bd_metric", "null is given as  timeslot", Logger::ERR);
        error_log("null is given as timeslots", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
        return;
    }
    $timestamp = $timeslot * 1800;
    $dauObj = new DAUAdapter();
    $dau = $dauObj->get_timed_dau($timestamp, $gid, $snid, $cid);
    $rsObj = new RightScale($server_cfg, $game_cfg);
    $web_count = null;
    if (isset($game_cfg['id'])) {
        $web_count = $rsObj->get_host_count_per_pool($game_cfg['id'], $deploy_id);
        $game_name = $game_cfg['parent'];
        // to query other machine counts
    }
    $machine_counts = $rsObj->get_host_count_per_class($deploy_id, $game_name);
    $counts_array = get_counts($machine_class_default, $machine_counts, $web_count);
    $query = create_query($table, $timestamp, $dau, $counts_array, $gid);
    $queries = array($query);
    $query_res = execute_queries($server_cfg, $game_cfg, $queries);
    if ($query_res == 0) {
        $game_cfg['logger']->log("insert_bd_metrics", "bd_metrics metrics for " . $game_cfg['name'] . " successfully inserted", Logger::INFO);
        error_log("bd_metrics metrics for {$game_cfg['name']} successfully inserted", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
    } else {
        $game_cfg['logger']->log("insert_bd_metrics", "bd_metrics metrics for " . $game_cfg['name'] . " not inserted", Logger::ERR);
        error_log("bd_metrics metrics for {$game_cfg['name']} successfully inserted", 3, sprintf($server_cfg['log_file'], $game_cfg['name']));
    }
}
// Get the selected panel ID, or use events and narratives if none is specified and
// we're not filtering on a specific post.  In that situation, we want all content types.
if ($_GET['panelId']) {
    $panel_ids[] = $_GET['panelId'];
} else {
    if (!$filtered_by_post_id) {
        $panel_ids[] = array_search('Events', $write_panels);
        $panel_ids[] = array_search('Narratives', $write_panels);
    }
}
$jump_to_id = $_GET['jumpTo'];
$has_more = false;
$query_args = array('cat_id' => $category_id, 'panel_id' => $panel_ids, 'linked_post_id' => $_GET['linkedPostId'], 'importance' => $_GET['importance'], 'chronological' => $_GET['order']);
// If there's an ID we want to jump to, we return all query results and loop through
// them.  Otherwise, we just return one page worth of results.
$pageposts = $wpdb->get_results(create_query($query_args, $jump_to_id ? null : 0));
if ($pageposts) {
    $foundJumpToPost = !isset($jump_to_id);
    $result_count = POSTS_PER_PAGE;
    foreach ($pageposts as $post) {
        if ($result_count == 0) {
            if ($foundJumpToPost) {
                // We've shown this page of results but we still have more in $pageposts.
                $has_more = true;
                break;
            } else {
                // We've finished showing a page but haven't found our jump-to post yet.
                // Display another page.
                $result_count = POSTS_PER_PAGE;
            }
        }
Example #3
0
 foreach (glob("../{$key}/sql/*.zip") as $filename) {
     $zip = new ZipArchive();
     //var_dump($zip);
     //if ($zip->open("../$key/sql/taxons.zip") === TRUE) {
     if ($zip->open("{$filename}") === TRUE) {
         $zip->extractTo("../{$key}/sql/");
         $zip->close();
         //echo 'ok <br>';
     } else {
         // echo 'échec <br>';
     }
     //echo "$filename <br>";
 }
 /*creation du schema de la rubrique $key et du squelette de ses tables*/
 $archi = "../{$key}/sql/archi.sql";
 $query = create_query($archi, $user_codex);
 $result = pg_query($conn_codex, $query);
 /*import des données en base à partir des fichiers sql (sauf fichier archi.sql)*/
 $query = "";
 foreach (glob("../{$key}/sql/*.sql") as $filename) {
     if (strpos($filename, 'archi') === false) {
         //$query .= create_query($data,$user_codex);  //cette requête faisait planter l'installation car remplacer sur un fichier trop lourd est gourmand en mémoire
         $query .= file_get_contents($filename);
         //pour tous les fichiers .sql sauf archi.sql
     }
 }
 /*import des données en base à partir des fichiers .csv avec COPY FROM*/
 //on peut tester si on est sous windows ou linux pour respecter slash et antislash mais a priori avec realpath ça fonctionne
 set_time_limit(0);
 foreach (glob("../{$key}/sql/*.csv") as $filename) {
     //renvoit le chemin relatif des fichiers csv du dossier
// Check if this page is being filtered by a linked post id.
// This will change the behavior of some parts (e.g. don't get linked content)
$filtered_by_post_id = isset($_GET['linkedPostId']);
// Get the selected panel ID, or use events and narratives if none is specified and
// we're not filtering on a specific post.  In that situation, we want all content types.
if ($_GET['panelId']) {
    $panel_ids[] = $_GET['panelId'];
} else {
    if (!$filtered_by_post_id) {
        $panel_ids[] = array_search('Events', $write_panels);
        $panel_ids[] = array_search('Narratives', $write_panels);
    }
}
$has_more = false;
$query_args = array('cat_id' => $_GET['cat'], 'panel_id' => $panel_ids, 'linked_post_id' => $_GET['linkedPostId'], 'importance' => $_GET['importance'], 'chronological' => $_GET['order']);
$pageposts = $wpdb->get_results(create_query($query_args, $_GET['page']));
if ($pageposts) {
    // If we don't specify a page, we want to return everything.
    $result_count = $_GET['page'] ? POSTS_PER_PAGE : -1;
    foreach ($pageposts as $post) {
        if ($result_count == 0) {
            $has_more = true;
            break;
        }
        setup_postdata($post);
        $content_items[] = create_content_item($all_linked_items);
        $result_count--;
    }
}
// Then get all the linked elements. We need to explicitly check
// if $all_linked_items is empty; query_posts doesn't do the right
Example #5
0
$m_axes->y_axis = $y_axis;
//End: Y-axis set up.
//X-axis set up.
$p1 = new stdClass();
$p2 = new stdClass();
$p1->value = 'time';
$p1->text = 'Time';
$p2->value = 'tap';
$p2->text = 'Tap';
$field = 'time';
$param = array($p1, $p2);
$x_axis->field = $field;
$x_axis->param = $param;
$x_axis->round_factor = null;
$m_axes->x_axis = $x_axis;
//End: X-axis set up.
//Main filter set up.
$filter_main->year_min = '15';
$filter_main->date_min = '12/1/2015';
$filter_main->date_max = null;
$filter_main->tap_grade = null;
$m_axes->filter_main = $filter_main;
//End: Main filter set up.
$query = create_query($m_axes);
echo nl2br(spaceToNbsp($query));
?>

</div>


</html>
Example #6
0
 $result = pg_query($conn_appli, "SELECT 1 FROM pg_roles WHERE rolname='{$user_appli}';");
 $user_test = pg_fetch_row($result);
 if ($user_test[0] == null) {
     $result = pg_query($conn_appli, "CREATE USER {$user_appli} PASSWORD '{$pass_appli}';");
     echo "L'utilisateur {$user_appli} a été créé<BR>";
 } else {
     echo "L'utilisateur {$user_appli} existait déjà<BR>";
 }
 /*-------------------*/
 /*Structure de la BDD*/
 $result = pg_query($conn_appli, "SELECT 1 FROM information_schema.tables WHERE table_name='carte_indigenat';");
 $table = pg_fetch_row($result);
 if ($table[0] == null) {
     $conn_user = connexion($host, $port, $user_appli, $pass_appli, $bdd);
     $archi = "./sql/archi_prod_carte.sql";
     $query = create_query($archi, $user_appli);
     $result = pg_query($conn_user, $query);
     echo "L'architecture de la base a été implémentée<BR>";
 } else {
     echo "L'architecture de la base existait déjà<BR>";
 }
 /*------------------------------------------*/
 /*parametrage du ficher de conf sql_connect*/
 if (!file_exists("./_INCLUDE/.sql_config.inc.php")) {
     $sql_file = file_get_contents("./_INCLUDE/.sql_config.inc.example.php");
     $sql_file = str_replace("localhost", $_POST["host"], $sql_file);
     $sql_file = str_replace("5432", $_POST["port"], $sql_file);
     $sql_file = str_replace("user_prod", $_POST["user_appli"], $sql_file);
     $sql_file = str_replace("pass_prod", $_POST["pass_appli"], $sql_file);
     $sql_file = str_replace("postgres", $_POST["user"], $sql_file);
     $sql_file = str_replace("test", $_POST["dbpass"], $sql_file);