Ejemplo n.º 1
0
function master_sites_callback()
{
    $sites = get_option(SITE_OPT);
    $i = 0;
    ?>
<script type="text/javascript">
function remove_site(button) {
	var row = jQuery(button).parent().parent();
	row.find("input[type=text]").val("");
	row.hide();
}
</script>
<table class="widefat">
	<thead>
		<tr valign="top">
			<th scope="column" class="manage-column check-column"></th>
			<th scope="column" class="manage-column"><?php 
    _e('Address');
    ?>
</th>
			<th scope="column" class="manage-column"><?php 
    _e('Username');
    ?>
</th>
			<th scope="column" class="manage-column"><?php 
    _e('Password');
    ?>
</th>
			<th scope="column" class="manage-column"><?php 
    _e('Status');
    ?>
</th>
			<th scope="column" class="manage-column"></th>
		</tr>
	</thead>
	<tbody>
	<?php 
    foreach ($sites as $site) {
        ?>
	<?php 
        $input_name = SITE_OPT . "[{$i}]";
        ?>
		<tr>
			<td><input type="checkbox" name="<?php 
        _e($input_name . "[enabled]");
        ?>
" value="1"
			     <?php 
        checked(1, isset($site['enabled']) ? 1 : 0);
        ?>
 /></td>
			<td><input type="text" name="<?php 
        _e($input_name . "[name]");
        ?>
" value="<?php 
        echo $site['name'];
        ?>
" ></td>
			<td><input type="text" name="<?php 
        _e($input_name . "[username]");
        ?>
" value="<?php 
        echo $site['username'];
        ?>
" ></td>
			<td><input type="text" name="<?php 
        _e($input_name . "[password]");
        ?>
" value="<?php 
        echo $site['password'];
        ?>
" ></td>
			<td><label><?php 
        echo test_connection($site);
        ?>
</label></td>
			<td><a class="delete-button" href="#" onclick="remove_site(this)">Elimina</a></td>
		</tr>
    <?php 
        $i++;
        ?>
	<?php 
    }
    ?>
	<?php 
    $input_name = SITE_OPT . "[{$i}]";
    ?>
	   <tr>
			<td><input type="checkbox" name="<?php 
    _e($input_name . "[enabled]");
    ?>
" value="1" /></td>
			<td><input type="text" name="<?php 
    _e($input_name . "[name]");
    ?>
" ></td>
			<td><input type="text" name="<?php 
    _e($input_name . "[username]");
    ?>
"  ></td>
			<td><input type="text" name="<?php 
    _e($input_name . "[password]");
    ?>
" ></td>
			<td></td>
		</tr>
	</tbody>
</table>
<?php 
}
Ejemplo n.º 2
0
function current_step($mn)
{
    $step = $_SESSION['step'];
    $menu = bal("p", $step . '. ' . $mn[$step]);
    $connect = test_connection();
    $c = "okay";
    switch ($mn[$step]) {
        case "directories":
            $l = list_of_dirs();
            foreach ($l as $k => $v) {
                if (!is_dir($v)) {
                    $no = "ok";
                }
            }
            if ($no) {
                $ret = instlink('make_dirs', '=');
            } else {
                $ret = $c;
            }
            break;
            //instlink('make_dirs','remove');
        //instlink('make_dirs','remove');
        case "phpini":
            $ret = 'php version: ' . $_SESSION['phpv'] . br();
            if ($_SESSION['phpv'] >= 5.3) {
                if (!is_file('.user.ini')) {
                    w_ini();
                    $ret .= 'php>5.3 : phpini a été installé, pour voir les erreurs';
                } else {
                    $ret = $c;
                }
            } else {
                $ret .= 'php<5.3 : phpini n\'a pas besoin d\'être installé';
            }
            break;
        case "connexion":
            if ($connect == 'pas de connexion') {
                $ret = instlink('connexion', '=');
            } else {
                $ret = $c;
            }
            break;
        case "databases":
            if ($connect != "pas de connexion") {
                if (!mysql_num_rows(mysql_query('SHOW TABLES'))) {
                    $ret = instlink('install_databases', '=');
                } else {
                    $ret = $c;
                }
            }
            w_master_p();
            break;
        case "program":
            $nbp = count($_SESSION['progam']);
            $_SESSION['progam'] = '';
            if (count(dl_dirs()) == $nbp) {
                $ret = $c;
            } else {
                $ret = dl_prog();
            }
            break;
        case "htaccess":
            if (!is_file('.htaccess')) {
                $ret = instlink('htacc', '=');
            } else {
                $ret = $c;
            }
            break;
        case "usefull":
            $ret = instlink('usefull', '=');
            break;
        case "philum":
            $ret = instlink('philum', '=');
            break;
        case "fin":
            $ret = 'Si ' . lien('/', 'tout va bien') . ', ' . lien('?fin==', 'auto-supprimer') . ' ce fichier';
            break;
    }
    return $menu . $ret;
}
Ejemplo n.º 3
0
include_once 'ressources/class.ldap.inc';
include_once 'ressources/class.users.menus.inc';
include_once 'ressources/class.artica.inc';
include_once 'ressources/class.mysql.inc';
include_once 'ressources/class.ini.inc';
include_once 'ressources/class.cyrus.inc';
if (isset($_GET["popup"])) {
    popup();
    exit;
}
if (isset($_GET["wizard"])) {
    wizard();
    exit;
}
if (isset($_GET["test_connection"])) {
    test_connection();
    exit;
}
if (isset($_GET["murder-link"])) {
    murder_link();
    exit;
}
if (isset($_GET["EnableImapMurderedFrontEnd"])) {
    EnableImapMurderedFrontEnd();
    exit;
}
js();
function js()
{
    $page = CurrentPageName();
    $tpl = new templates();
             $adj_sectors[] = 2;
         }
         $Tester = (double) (mt_rand() / mt_getrandmax());
         if ($Tester < 0.95 && sizeof($adj_sectors) > 0) {
             shuffle($adj_sectors);
             $direction = $adj_sectors[0];
             $cutter_data[$i]['Direction'] = $direction;
         } else {
             $direction = (int) (4 * mt_rand() / mt_getrandmax());
             $cutter_data[$i]['Direction'] = $direction;
         }
         // Update Position
         $cutter_data[$i]['Xpos'] = $Xpos;
         $cutter_data[$i]['Ypos'] = $Ypos;
     }
 } while ($uncut_sectors > 0 && !test_connection($cutter_c));
 $Xpos = 0;
 $Ypos = 0;
 for ($curr_sector = $start_sector + 1; $curr_sector <= $start_sector + $curr_size * $curr_size; $curr_sector++) {
     // specifiy the line number in the current 'block'
     $line = floor(($curr_sector - $start_sector - 1) / $curr_size) + 1;
     // sector numbers on the most left, right, up and down
     $right_border = $line * $curr_size + $start_sector;
     $left_border = $right_border - $curr_size + 1;
     $up_border = $curr_sector - $curr_size * ($line - 1);
     $down_border = $curr_sector + $curr_size * ($curr_size - $line);
     $left = $curr_sector - 1;
     if ($left < $left_border) {
         $left = $right_border;
     }
     $right = $curr_sector + 1;
Ejemplo n.º 5
0
//$exit_status = 2;
//display_command_output("who am I ?",$exit_status,$output,$command,"error");
//$command = "cp /tmp/$identity_name-id /tmp/jb-id";
//exec($command,$output,$exit_status);
//$exit_status = 2;
//display_command_output("Copy $identity_name-id to /tmp/jb-id",$exit_status,$output,$command,"error");
//$command = "ls -lrt /tmp";
//exec($command,$output,$exit_status);
//$exit_status = 2;
//display_command_output("liste /tmp",$exit_status,$output,$command,"error");
//$command = "cat /tmp/jb-id";
//exec($command,$output,$exit_status);
//$exit_status = 2;
//display_command_output("cat /tmp/jb-id",$exit_status,$output,$command,"error");
// ------------------- DEPLOYEMENT ----------------------
if (test_connection($hostname, $identity_name, $account_name) == 0) {
    // --------------- checking user account
    if (user_exists($identity_name, $account_name, $hostname) != 0) {
        create_user_account($identity_name, $account_name, $hostname, $account_UID, $account_GID, $account_homedir, $GIDname, $id, $GECOS);
    }
    // --------------- getting homedir of current user
    $homedir = get_homedir($identity_name, $account_name, $hostname);
    if ($homedir != "user not found") {
        // --------------- checking ssh directory
        if (user_ssh_dir_exists($identity_name, $account_name, $hostname, $homedir) != 0) {
            create_user_ssh_dir($identity_name, $account_name, $hostname, $homedir);
            chperm_user_ssh_dir($identity_name, $account_name, $hostname, $homedir);
        }
        // --------------- Testing presence of file
        if (authorized_key_exist($identity_name, $account_name, $hostname, "{$homedir}/.ssh/authorized_keys") == 0) {
            archive_authorized_key_file($identity_name, $account_name, $hostname, "{$homedir}/.ssh/authorized_keys");
Ejemplo n.º 6
0
function deploy_globalfile($id_file, $id_host)
{
    $hostname = get_host_name($id_host);
    $hostip = get_host_ip($id_host);
    $gfiles = mysql_query("SELECT * FROM `globalfiles` WHERE `id` = '{$id_file}'") or die(mysql_error() . "<br>Couldn't execute query: {$query}");
    $nr_gbfiles = mysql_num_rows($gfiles);
    if (!empty($nr_gbfiles)) {
        // Preparing file,path, etc...
        $gfilerow = mysql_fetch_array($gfiles);
        $path = $gfilerow['path'];
        $name = $gfilerow['name'];
        //$filecontents=$gfilerow['text'];
        $localfile = $gfilerow['localfile'];
        $now = date("Ymd-His");
        // Testing connectivity...
        if (test_connection($hostname) != "OK") {
            $message .= "<img src='images/error.gif'>Connection failed. Please see output below.<br>\n";
            return $message;
        } else {
            $message .= "<img src='images/ok.gif'>SSH connection is OK.<br>\n";
        }
        // Testing presence of file
        if (test_presence($hostname, $path / $name) == 1) {
            $message .= "<img src='images/warning.gif'>{$path}/{$name} was not found...<br>\n";
        } else {
            // File is present, we try to back it up
            // Archiving current file
            $output = shell_exec("ssh " . $GLOBALS['sudousr'] . "@{$hostname} cp {$path}/{$name} {$path}/{$name}.{$now} 2>&1");
            if (empty($output)) {
                // Archiving is OK
                $message .= "<img src='images/ok.gif'>{$path}/{$name} has been backup successfully.<br>\n";
            } else {
                $message .= "<img src='images/error.gif'>{$path}/{$name} could not be backed up.<br>\n";
                return $message;
            }
        }
        // Deploying
        $output = shell_exec("scp {$localfile} " . $GLOBALS['sudousr'] . "@{$hostname}:{$path}/{$name} 2>&1");
        if (empty($output)) {
            // File was correctly transfered
            $message .= "<img src='images/ok.gif'>{$path}/{$name} was correctly updated.<br>\n";
            $output = shell_exec("ssh " . $GLOBALS['sudousr'] . "@{$hostname} chmod 440 {$path}/{$name} 2>&1");
            if (empty($output)) {
                $message .= "<img src='images/ok.gif'>Permission changed successfully to 440 for file {$path}/{$name}.<br>\n";
            } else {
                $message .= "<img src='images/error.gif'>Could not change permission to 440 for file {$path}/{$name}.<br>\n";
            }
        } else {
            $message .= "<img src='images/error.gif'>An error occured during the update.<br>\n";
        }
    } else {
        $message .= "<img src='images/error.gif'>No global file found with id {$id}<br>\n";
    }
    return $message;
}