Example #1
0
<?php

$tablename = $_POST['sky_qs'][0];
$action = $_POST['sky_qs'][1];
if ($tablename == '-multiple-') {
    $tablename = $_POST['tables'];
}
slony::$silent = NULL;
$tables = explode(',', $tablename);
switch ($action) {
    case 'enable':
        slony::add_table($tables);
        break;
    case 'disable':
        foreach ($tables as $table) {
            slony::drop_table($table);
        }
        break;
    default:
}
/*$i = 0;
$SQL = "alter table $tablename $action replication on slave $i";
$dbw->Execute($SQL) or die("$SQL<br>".$dbw->ErrorMsg());

$SQL = "alter table $tablename $action replication";
$dbw->Execute($SQL) or die("$SQL<br>".$dbw->ErrorMsg());

if ($action=='enable') echo 'on';
else echo 'off';
*/
Example #2
0
<?php

echo '<br />';
$tablename = $_POST['table'];
// apply the changes to the database(s)
if ($slony_cluster_name) {
    // if database is being replicated
    slony::$silent = true;
    $dump = slony::propagate_schema_change($_POST['sql']);
    echo $_POST['sql'];
    echo "\n<br />\n<br />";
    //var_dump($dump); //comment
    foreach ($dump['output'] as $line) {
        if (preg_match('#error#i', $line)) {
            echo '<div style="color:red;">' . $line . '</div>';
            $do_not_log = true;
        } else {
            echo $line;
        }
        echo "\n<br />";
    }
    echo "\n<br />";
    if ($do_not_log) {
        echo "<div style='color:red;'>There was an error propagating the schema change on one or more node, you will need to apply the change manually</div>";
    } else {
    }
} else {
    // no replication is going on.. just execute on the database
    echo 'no replication on this database.<br />';
    // make schema change
    $SQL = $_POST['sql'];
Example #3
0
File: ajax.php Project: hshoghi/cms
<?php

if ($_POST['a']) {
    $id = decrypt($_POST['a'], 'slony_node');
}
slony::$silent = false;
switch ($_POST['func']) {
    case 'stop':
        if (!count($pre_dump = slony::get_running_slons())) {
            echo "No Slon daemons are running.  Stop aborted.";
            ?>
<script type='text/javascript'>var nodes=null;</script><?php 
            break;
        }
        ?>
<script type='text/javascript'>var nodes = new Array();</script><?php 
        $proc = slony::stop_slon_on_node($id);
        if (count($dump = slony::get_running_slons())) {
            $i = 0;
            $slons_by_node = slony::get_running_slons_by_node($dump);
            foreach ($slons_by_node as $node => $slon) {
                ?>
<script type='text/javascript'>nodes[<?php 
                echo $i++;
                ?>
]={'ide':'<?php 
                echo $ide = encrypt($node, 'slony_node');
                ?>
','comment':'<?php 
                echo $slon['comment'];
                ?>