Serghey Rodin пре 13 година
родитељ
комит
2ed6ca4191

+ 1 - 1
web/add/db/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 $TAB = 'DB';

+ 1 - 1
web/add/user/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 $TAB = 'USER';

+ 17 - 0
web/delete/db/index.php

@@ -0,0 +1,17 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+if ($_SESSION['user'] == 'admin') {
+    if (!empty($_GET['database'])) {
+        $v_username = escapeshellarg($user);
+        $v_database = escapeshellarg($_GET['database']);
+        exec (VESTA_CMD."v_delete_database ".$v_username." ".$v_database, $output, $return_var);
+        unset($output);
+    }
+}
+
+header("Location: /list/db/");

+ 78 - 0
web/edit/db/index.php

@@ -0,0 +1,78 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+
+$TAB = 'DB';
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+// Header
+include($_SERVER['DOCUMENT_ROOT'].'/templates/header.html');
+
+// Panel
+top_panel($user,$TAB);
+
+// Are you admin?
+if ($_SESSION['user'] == 'admin') {
+
+    // Check user argument?
+    if (empty($_GET['database'])) {
+        header("Location: /list/db/");
+        exit;
+    }
+
+    $v_database = escapeshellarg($_GET['database']);
+    exec (VESTA_CMD."v_list_database ".$user." ".$v_database." 'json'", $output, $return_var);
+    if ($return_var != 0) {
+        $error = implode('<br>', $output);
+        if (empty($error)) $error = 'Error: vesta did not return any output.';
+        $_SESSION['error_msg'] = $error;
+    } else {
+        $data = json_decode(implode('', $output), true);
+        unset($output);
+        $v_username = $user;
+        $v_database = $_GET['database'];
+        $v_dbuser = $data[$v_database]['DBUSER'];
+        $v_password = "••••••••";
+        $v_host = $data[$v_database]['HOST'];
+        $v_type = $data[$v_database]['TYPE'];
+        $v_charset = $data[$v_database]['CHARSET'];
+        $v_date = $data[$v_database]['DATE'];
+        $v_time = $data[$v_database]['TIME'];
+        $v_suspended = $data[$v_database]['SUSPENDED'];
+        if ( $v_suspended == 'yes' ) {
+            $v_status =  'suspended';
+        } else {
+            $v_status =  'active';
+        }
+
+        // Action
+        if (!empty($_POST['save'])) {
+            $v_username = $user;
+            // Change password
+            if (($v_password != $_POST['v_password']) && (empty($_SESSION['error_msg']))) {
+                $v_password = escapeshellarg($_POST['v_password']);
+                exec (VESTA_CMD."v_change_database_password ".$v_username." ".$v_database." ".$v_password, $output, $return_var);
+                if ($return_var != 0) {
+                    $error = implode('<br>', $output);
+                    if (empty($error)) $error = 'Error: vesta did not return any output.';
+                    $_SESSION['error_msg'] = $error;
+                }
+                $v_password = "••••••••";
+                unset($output);
+            }
+            if (empty($_SESSION['error_msg'])) {
+                $_SESSION['ok_msg'] = "OK: changes has been saved.";
+            }
+        }
+    }
+
+    include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/menu_edit_db.html');
+    include($_SERVER['DOCUMENT_ROOT'].'/templates/admin/edit_db.html');
+    unset($_SESSION['error_msg']);
+    unset($_SESSION['ok_msg']);
+}
+
+// Footer
+include($_SERVER['DOCUMENT_ROOT'].'/templates/footer.html');

+ 2 - 5
web/edit/dns/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 
@@ -19,10 +19,7 @@ if ($_SESSION['user'] == 'admin') {
     // Check user argument?
     if (empty($_GET['domain'])) {
         header("Location: /list/dns/");
-    }
-
-    if (!empty($_POST['cancel'])) {
-        header("Location: /list/dns/");
+        exit;
     }
 
     // Check domain

+ 2 - 5
web/edit/mail/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 
@@ -19,10 +19,7 @@ if ($_SESSION['user'] == 'admin') {
     // Check user argument?
     if (empty($_GET['domain'])) {
         header("Location: /list/mail/");
-    }
-
-    if (!empty($_POST['cancel'])) {
-        header("Location: /list/mail/");
+        exit;
     }
 
     // Check domain

+ 1 - 4
web/edit/user/index.php

@@ -19,10 +19,7 @@ if ($_SESSION['user'] == 'admin') {
     // Check user argument?
     if (empty($_GET['user'])) {
         header("Location: /list/user/");
-    }
-
-    if (!empty($_POST['cancel'])) {
-        header("Location: /list/user/");
+        exit;
     }
 
     // Check user

+ 2 - 5
web/edit/web/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 
@@ -19,10 +19,7 @@ if ($_SESSION['user'] == 'admin') {
     // Check user argument?
     if (empty($_GET['domain'])) {
         header("Location: /list/web/");
-    }
-
-    if (!empty($_POST['cancel'])) {
-        header("Location: /list/web/");
+        exit;
     }
 
     // Check domain

+ 1 - 1
web/list/ip/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 session_start();
 $TAB = 'IP';
 

+ 17 - 0
web/suspend/db/index.php

@@ -0,0 +1,17 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+if ($_SESSION['user'] == 'admin') {
+    if (!empty($_GET['database'])) {
+        $v_username = escapeshellarg($user);
+        $v_database = escapeshellarg($_GET['database']);
+        exec (VESTA_CMD."v_suspend_database ".$v_username." ".$v_database, $output, $return_var);
+        unset($output);
+    }
+}
+
+header("Location: /list/db/");

+ 1 - 1
web/suspend/dns/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");

+ 1 - 1
web/suspend/mail/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");

+ 59 - 0
web/templates/admin/edit_db.html

@@ -0,0 +1,59 @@
+<script type="text/javascript">
+  function elementHideShow(elementToHideOrShow) {
+      var el = document.getElementById(elementToHideOrShow);
+      if (el.style.display == "block") {
+        el.style.display = "none";
+      } else {
+        el.style.display = "block";
+      }
+    }
+
+    function randomString() {
+      var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+      var string_length = 10;
+      var randomstring = '';
+      for (var i=0; i<string_length; i++) {
+        var rnum = Math.floor(Math.random() * chars.length);
+        randomstring += chars.substring(rnum,rnum+1);
+      }
+      document.v_add_user.v_password.value = randomstring;
+    }
+</script>
+
+
+<table class='data'>
+<tr class="data-add">
+    <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
+        <table class="data-col1">
+            <tr><td style="padding: 20px 0 4px 4px;"><a class="data-date" ?><?php echo date("d M Y", strtotime($v_date))?></a></td></tr>
+            <tr><td style="padding: 0 0 6px 4px;"><a class="data-date" ?><?php echo $v_time?></a></td></tr>
+            <tr><td style="padding: 0 0 0 24px;" class="data-<?php echo $v_status ?>"><b><?php echo $v_status ?></b></td></tr>
+        </table>
+    </td>
+    <td class="data-dotted" width="830px" style="vertical-align:top;">
+        <table width="830px"><tr>
+            <td></td>
+        </tr></table>
+        <table class="data-col2" width="600px">
+            <form method="post" name="v_add_user">
+            <tr><td style="padding: 10 0 0 2px; color:99a7af;" >Prefix "<?php echo $user."_"; ?>" will be automaticaly added to database name and database user</td></tr>
+            <tr><td class="add-text" style="padding: 10 0 0 2px;">Database</td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_database" <?php if (!empty($v_database)) echo "value=".$v_database; ?> disabled></td></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;">Username</td></tr>
+            <tr><td></span><input type="text" size="20" class="add-input" name="v_dbuser" <?php if (!empty($v_dbuser)) echo "value=".$v_dbuser; ?> disabled></tr>
+            <tr><td class="add-text" style="padding: 10px 0 0 2px;">Password <a href="javascript:randomString();" class="genpass">generate</a></td></tr>
+            <tr><td><input type="text" size="20" class="add-input" name="v_password"  <?php if (!empty($v_password)) echo "value=".$v_password; ?>></td></tr>
+            <tr><td class="add-text" style="padding: 10 0 0 2px;">Type</td></tr>
+            <tr><td></span><input type="text" size="20" class="add-input" name="v_type" <?php if (!empty($v_type)) echo "value=".$v_type; ?> disabled></tr>
+            <tr><td class="add-text" style="padding: 10 0 0 2px;">Host</td></tr>
+            <tr><td></span><input type="text" size="20" class="add-input" name="v_host" <?php if (!empty($v_host)) echo "value=".$v_host; ?> disabled></tr>
+            <tr><td class="add-text" style="padding: 10 0 0 2px;">Charset</td></tr>
+            <tr><td></span><input type="text" size="20" class="add-input" name="v_charset" <?php if (!empty($v_charset)) echo "value=".$v_charset; ?> disabled></tr>
+            <tr><td style="padding: 24px 0 0 0;">
+                <input type="submit" name="save" value="Save" class="add-button"></form>
+                <input type="button" class="add-button" value="Cancel" onClick="location.href='/list/db/'">
+            </td></tr>
+        </table>
+    </td>
+</tr>
+</table>

+ 59 - 8
web/templates/admin/list_db.html

@@ -5,18 +5,57 @@ foreach ($data as $key => $value) {
     ++$i;
     if ($data[$key]['SUSPENDED'] == 'yes') {
         $status = 'suspended';
-        $spnd_action = 'ususpend' ;
+        $spnd_action = 'unsuspend' ;
     } else {
         $status = 'active';
         $spnd_action = 'suspend' ;
     }
 
-    if (empty($data[$key]['CATCHALL'])) {
-        $data[$key]['CATCHALL'] = 'null';
-    }
+    if ($data[$key]['TYPE'] == 'mysql') $db_admin_link = "http://".$_SERVER["HTTP_HOST"]."/phpMyAdmin/";
+    if ($data[$key]['TYPE'] == 'pgsql') $db_admin_link = "http://".$_SERVER["HTTP_HOST"]."/phpPgAdmin/";
     ?>
 
+
 <tr class="data-row">
+    <script type="text/javascript">
+    $(function(){
+        $('#<?php echo $spnd_action ?>_dialog_<?php echo "$i" ?>').dialog({
+            modal: true,
+            autoOpen: false,
+            width: 360,
+            buttons: {
+                "Ok": function(event, ui) {
+                     location.href = '/<?php echo $spnd_action ?>/db/?database=<?php echo "$key" ?>';
+                },
+                "Cancel": function() {
+                    $(this).dialog("close");
+                }
+            }
+        });
+        $('#<?php echo $spnd_action ?>_link_<?php echo "$i" ?>').click(function(){
+            $('#<?php echo $spnd_action ?>_dialog_<?php echo "$i" ?>').dialog('open');
+            return false;
+        });
+
+        $('#delete_dialog_<?php echo "$i" ?>').dialog({
+            modal: true,
+            autoOpen: false,
+            width: 360,
+            buttons: {
+                "Ok": function(event, ui) {
+                     location.href = '/delete/db/?database=<?php echo "$key" ?>';
+                },
+                "Cancel": function() {
+                    $(this).dialog("close");
+                }
+            }
+        });
+        $('#delete_link_<?php echo "$i" ?>').click(function(){
+            $('#delete_dialog_<?php echo "$i" ?>').dialog('open');
+            return false;
+        });
+    });
+    </script>
     <td class="data-dotted" style="padding: 0px 10px 0px 0px" width="150">
         <table class="data-col1">
             <tr><td style="padding: 18 0 4 18;"><input type="checkbox" name="object" ></td></tr>
@@ -28,10 +67,22 @@ foreach ($data as $key => $value) {
     <td class="data-dotted" width="830px" style="vertical-align:top;">
         <table width="830px"><tr>
             <td></td>
-            <td class="data-controls" width="120px"><img src="/images/new_window.png" width="8px" height="8px"><a href="#"> open web admin</a></td>
-            <td class="data-controls" width="50px"><img src="/images/edit.png" width="8px" height="8px"><a href="#"> edit</a></td>
-            <td class="data-controls" width="80px"><img src="/images/suspend.png" width="7px" height="8px"><a href="#"> <?php echo $spnd_action ?></a></td>
-            <td class="data-controls" width="70px"><img src="/images/delete.png" width="7px" height="7px"><a href="#"> delete</a></td>
+            <td class="data-controls" width="120px"><img src="/images/new_window.png" width="8px" height="8px"> <a href="<?php echo $db_admin_link; ?>" target="_blank"> open web admin</a></td>
+            <td class="data-controls" width="50px"><img src="/images/edit.png" width="8px" height="8px"><a href="/edit/db/?database=<?php echo $key ?>"> edit</a></td>
+            <td class="data-controls" width="80px">
+                <img src="/images/suspend.png" width="7px" height="8px">
+                <a href="#" id="<?php echo $spnd_action ?>_link_<?php echo "$i" ?>"> <?php echo $spnd_action ?></a>
+                <div id="<?php echo $spnd_action ?>_dialog_<?php echo "$i" ?>" title="Confirmation">
+                    <p class="counter-value">Are you sure you want to <?php echo $spnd_action ?> <b><?php echo "$key" ?></b> database?</p>
+                </div>
+            </td>
+            <td class="data-controls" width="70px">
+                <img src="/images/delete.png" width="7px" height="7px">
+                <a href="#" id="delete_link_<?php echo $i ?>"> delete</a>
+                <div id="delete_dialog_<?php echo $i ?>" title="Confirmation">
+                    <p class="counter-value">Are you sure you want to delete <b><?php echo "$key" ?></b> database?</p>
+                </div>
+            </td>
         </tr></table>
 
         <table class="data-col2" width="830px">

+ 15 - 0
web/templates/admin/menu_edit_db.html

@@ -0,0 +1,15 @@
+<table class="sub-menu">
+<tr>
+    <td style="padding: 10px 2px 28px 0;" ><a class="add-name"><b>Editing Database</b></a>
+    <?php 
+        if (!empty($_SESSION['error_msg'])) {
+            echo "<a class=\"add-error\"> → ".$_SESSION['error_msg']."</a>";
+        } else {
+            if (!empty($_SESSION['ok_msg'])) {
+                echo "<a class=\"add-ok\"> → ".$_SESSION['ok_msg']."</a>";
+            }
+        }
+    ?>
+    </td>
+</tr>
+</table>

+ 17 - 0
web/unsuspend/db/index.php

@@ -0,0 +1,17 @@
+<?php
+// Init
+error_reporting(NULL);
+ob_start();
+session_start();
+include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
+
+if ($_SESSION['user'] == 'admin') {
+    if (!empty($_GET['database'])) {
+        $v_username = escapeshellarg($user);
+        $v_database = escapeshellarg($_GET['database']);
+        exec (VESTA_CMD."v_unsuspend_database ".$v_username." ".$v_database, $output, $return_var);
+        unset($output);
+    }
+}
+
+header("Location: /list/db/");

+ 1 - 1
web/unsuspend/dns/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");

+ 1 - 1
web/unsuspend/mail/index.php

@@ -1,6 +1,6 @@
 <?php
 // Init
-//error_reporting(NULL);
+error_reporting(NULL);
 ob_start();
 session_start();
 include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");