Example #1
0
<?php

/*
Copyright (C)

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$connection = @mssql_connect($_SESSION['datasource_name'], $_SESSION['datasource_username'], $_SESSION['datasource_password']) or die(throwSQLError('general connection failure to the database'));
if (!empty($_GET['dbname'])) {
    $db = urldecode($_GET['dbname']);
    mssql_select_db($db);
    $_SESSION['database'] = $db;
}
Example #2
0
				<td align="center" style="background: #D0DCE0">
					<input type="submit" value="Run Query">
				</td>
			</tr>
		</table>
		</form>

		<script language="javascript">
			document.form1.query.focus();
		</script>
<?php 
if ($_POST['query'] == '') {
    include 'inc/footer.php';
}
mssql_select_db($_SESSION['database']);
$data_query = @mssql_query($_POST['query']) or die(throwSQLError('unable to complete query'));
echo '<table width="' . $_SETTINGS['mobilescreenwidth'] . '" cellpadding="2" cellspacing="0" style="border: 1px solid">';
$toggle = true;
$colors = array('#DDDDDD', '#CCCCCC');
$isempty = true;
$fields = array();
if (mssql_num_rows($data_query) > 0) {
    while ($row = mssql_fetch_array($data_query)) {
        if ($isempty) {
            $isempty = false;
        }
        if ($toggle) {
            $bg = $colors[0];
        } else {
            $bg = $colors[1];
        }
Example #3
0
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
mssql_select_db($_SESSION['database']);
$data_query = @mssql_query('sp_helptext \'' . urldecode($_GET['procedure']) . '\'') or die(throwSQLError('unable to retrieve procedure'));
if (!@mssql_num_rows($data_query)) {
    $schema_query = @mssql_query('SELECT SPECIFIC_SCHEMA FROM INFORMATION_SCHEMA.ROUTINES WHERE SPECIFIC_NAME = \'' . urldecode($_GET['procedure']) . '\';');
    if ($schema_query) {
        $schema_array = mssql_fetch_array($schema_query);
        if ($schema_array['SPECIFIC_SCHEMA'] != 'dbo') {
            $_GET['procedure'] = $schema_array['SPECIFIC_SCHEMA'] . '.' . urldecode($_GET['procedure']);
        }
    }
}
@mssql_query('DROP PROCEDURE ' . urldecode($_GET['procedure']) . ';') or die(throwSQLError('unable to delete procedure'));
if (empty($_GET['returnto'])) {
    $_GET['returnto'] = 'database_properties.php';
}
echo '<meta http-equiv="refresh" content="0;url=' . $_GET['returnto'] . '">';
include 'inc/footer.php';
Example #4
0
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
$db_info_query = @mssql_query('sp_helpdb') or die(throwSQLError('unable to retrieve databases'));
$dbinfo = array();
while ($row = mssql_fetch_array($db_info_query)) {
    if (!in_array($row['name'], $_SETTINGS['dbexclude'])) {
        $dbinfo[] = $row['name'] . ':' . number_format($row['db_size'], 2);
    }
}
?>

<table width="90%">
	<tr>
		<td align="left" valign="top" width="45%">
			<form name="form1" method="post" action="database_create.php?step=1">
			<table cellpadding="5" cellspacing="0" width="100%" style="border: 1px solid; border-color: black">
				<tr>
					<td align="center" colspan="2" style="background: #D0DCE0; border-bottom: 1px solid">
Example #5
0
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
mssql_select_db($_SESSION['database']);
if (!empty($_POST['query'])) {
    if (!@mssql_query($_POST['query'])) {
        throwSQLError('unable to create trigger');
    } else {
        echo '<meta http-equiv="refresh" content="0;url=database_properties.php">';
        include 'inc/footer.php';
    }
} else {
    $_POST['query'] = 'CREATE TRIGGER NewTrig;';
}
?>
		<form name="form1" method="post" action="trigger_create.php">
		<table cellpadding="3" cellspacing="3" style="border: 1px solid">
			<tr>
				<td align="center" style="background: #D0DCE0">
					<b>Create Trigger</b>
				</td>
			</tr>
Example #6
0
			<b>Triggers</b>
		</td>
	</tr>
	<tr>
		<td style="background: #D0DCE0">&nbsp;</td>
		<td align="center" style="background: #D0DCE0">
			<b>Name</b>
		</td>
		<td align="center" colspan="2" style="background: #D0DCE0">
			<b>Action</b>
		</td>
	</tr>
	<?php 
$toggle = true;
$colors = array('#DDDDDD', '#CCCCCC');
$trig_query = @mssql_query('sp_helptrigger \'' . urldecode($_GET['table']) . '\'') or die(throwSQLError('unable to retrieve list of stored procedures'));
while ($row = mssql_fetch_assoc($trig_query)) {
    if ($row['trigger_schema'] != '') {
        $fullname = $row['trigger_schema'] . '.' . $row['trigger_name'];
    } else {
        $fullname = $row['trigger_name'];
    }
    if ($toggle) {
        $bg = $colors[0];
    } else {
        $bg = $colors[1];
    }
    $toggle = !$toggle;
    echo '<tr>';
    echo '<td align="center" style="background: ' . $bg . '" nowrap><input type="checkbox" name="triggers[]" value="' . $fullname . '"></td>';
    echo '<td style="background: ' . $bg . '" nowrap>' . $row['trigger_name'] . '</td>';
Example #7
0
    @mssql_query($query) or die(throwSQLError('unable to lock database', $query));
    $query = 'ALTER DATABASE ' . urldecode($_GET[dbname]) . ' SET READ_ONLY';
    @mssql_query($query) or die(throwSQLError('unable to make database READ-ONLY', $query));
    $query = 'ALTER DATABASE ' . urldecode($_GET[dbname]) . ' SET MULTI_USER';
    @mssql_query($query) or die(throwSQLError('unable to re-enable mutli-user mode on database', $query));
    echo '<meta http-equiv="refresh" content="0;url=home.php">';
} else {
    if ($confirm == 'readwrite') {
        $_SESSION['database'] = 'master';
        mssql_select_db('master');
        $query = 'ALTER DATABASE ' . urldecode($_GET[dbname]) . ' SET SINGLE_USER';
        @mssql_query($query) or die(throwSQLError('unable to lock database', $query));
        $query = 'ALTER DATABASE ' . urldecode($_GET[dbname]) . ' SET READ_WRITE';
        @mssql_query($query) or die(throwSQLError('unable to make database READ-WRITE', $query));
        $query = 'ALTER DATABASE ' . urldecode($_GET[dbname]) . ' SET MULTI_USER';
        @mssql_query($query) or die(throwSQLError('unable to re-enable mutli-user mode on database', $query));
        echo '<meta http-equiv="refresh" content="0;url=home.php">';
    } else {
        $status_query = @mssql_query('sp_helpdb') or die(throwError('unable to retrive database information'));
        while ($row = mssql_fetch_array($status_query)) {
            if ($row['name'] == $_GET['dbname']) {
                $status = explode(', ', $row['status']);
                foreach ($status as $value) {
                    $split = explode('=', $value);
                    if ($split[0] == 'Updateability') {
                        if ($split[1] == 'READ_WRITE') {
                            $newmode = 'READ_ONLY';
                        } else {
                            $newmode = 'READ_WRITE';
                        }
                    }
Example #8
0
/*
Copyright (C)

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
@mssql_select_db($_SESSION['database']) or die(throwSQLError('unable to select database'));
if ($_POST['tables'][0] == '') {
    @mssql_query('DROP TABLE ' . urldecode($_GET['table']) . ';') or die(throwSQLError('unable to complete drop'));
} else {
    for ($counter = 0; $counter < count($_POST['tables']); $counter++) {
        @mssql_query('DROP TABLE ' . urldecode($_POST['tables'][$counter]) . ';') or die(throwSQLError('unable to complete drop'));
    }
}
if ($_SESSION['expanded'] != '') {
    echo '<script language="javascript">parent.left.location.reload();</script>';
}
echo '<meta http-equiv="refresh" content="0;url=database_properties.php?dbname=' . urlencode($_SESSION['database']) . '">';
include 'inc/footer.php';
Example #9
0
     $colquery = 'sp_columns @table_name = N\'' . $tablesep[0] . '\'';
 }
 $column_query = @mssql_query($colquery) or throwSQLError('unable to retrieve column data');
 while ($row = mssql_fetch_array($column_query)) {
     if (substr_count($row['TYPE_NAME'], 'identity') > 0) {
         $idcol = $row['COLUMN_NAME'];
     }
 }
 // END IDENTITY ISOLATION CODE
 if (substr($query, -6) == ' WHERE') {
     $query = substr($query, 0, -6);
 }
 if (!empty($_POST['orderbyfield'])) {
     $query .= ' ORDER BY ' . $_POST['orderbyfield'] . ' ' . $_POST['orderbyorder'];
 }
 $data_query = @mssql_query($query) or throwSQLError('unable to complete query', $query);
 if ($data_query) {
     echo '<table width="300" cellpadding="3" cellspacing="3" style="border: 1px solid">';
     $toggle = true;
     $colors = array('#DDDDDD', '#CCCCCC');
     $isempty = true;
     $fields = array();
     while ($row = mssql_fetch_array($data_query)) {
         if ($isempty) {
             $isempty = false;
         }
         if ($toggle) {
             $bg = $colors[0];
         } else {
             $bg = $colors[1];
         }
Example #10
0
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
if (!empty($_POST['confirm'])) {
    $confirm = $_POST['confirm'];
} else {
    $confirm = '';
}
if ($confirm == 'detach') {
    $_SESSION['database'] = 'master';
    mssql_select_db('master');
    $result = @mssql_query('sp_detach_db \'' . urldecode($_POST[dbname]) . '\',\'false\'') or die(throwSQLError('unable to detach database'));
    if ($result) {
        echo '<script language="javascript">parent.left.location.reload();</script>';
        echo '<meta http-equiv="refresh" content="0;url=home.php">';
    }
} else {
    ?>

<form name="form1" method="post" action="database_detach.php?dbname=<?php 
    echo $_GET['dbname'];
    ?>
">
<input type="hidden" name="dbname" value="<?php 
    echo $_GET['dbname'];
    ?>
">
Example #11
0
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
@mssql_select_db($_SESSION['database']) or die(throwSQLError('unable to select database'));
if ($_GET['showall'] != 'yes') {
    if (substr_count(urldecode($_GET['table']), '.') > 0) {
        $data_query = @mssql_query('SELECT TOP 100 * FROM ' . urldecode($_GET['table'])) or die(throwSQLError('unable to complete query'));
    } else {
        $data_query = @mssql_query('SELECT TOP 100 * FROM [' . urldecode($_GET['table']) . ']') or die(throwSQLError('unable to complete query'));
    }
} else {
    if (substr_count(urldecode($_GET['table']), '.') > 0) {
        $data_query = @mssql_query('SELECT * FROM ' . urldecode($_GET['table'])) or die(throwSQLError('unable to complete query'));
    } else {
        $data_query = @mssql_query('SELECT * FROM [' . urldecode($_GET['table']) . ']') or die(throwSQLError('unable to complete query'));
    }
}
echo '<table width="' . $_SETTINGS['mobilescreenwidth'] . '" cellpadding="2" cellspacing="0" style="border: 1px solid">';
$toggle = true;
$colors = array('#DDDDDD', '#CCCCCC');
$isempty = true;
$fields = array();
while ($row = mssql_fetch_array($data_query)) {
    if ($isempty) {
        $isempty = false;
    }
    if ($toggle) {
        $bg = $colors[0];
    } else {
        $bg = $colors[1];
Example #12
0
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
mssql_select_db($_SESSION['database']);
if (!empty($_POST['query'])) {
    if (!@mssql_query($_POST['query'])) {
        throwSQLError('unable to create procedure');
    } else {
        echo '<meta http-equiv="refresh" content="0;url=database_properties.php">';
    }
} else {
    $_POST['query'] = 'CREATE PROCEDURE NewProc;';
}
?>
		<form name="form1" method="post" action="procedure_create.php">
		<table cellpadding="3" cellspacing="3" style="border: 1px solid">
			<tr>
				<td align="center" style="background: #D0DCE0">
					<b>Create Stored Procedure</b>
				</td>
			</tr>
			<tr>
Example #13
0
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
?>

<?php 
include 'inc/header.php';
if (empty($_POST['mdf'])) {
    $result = @mssql_query('CREATE DATABASE ' . $_POST['dbname']) or die(throwSQLError('unable to create database'));
} else {
    if (substr_count($_POST['mdf'], '\\') == 0 || substr_count($_POST['ldf'], '\\') == 0 && $_POST['ldf'] != '') {
        mssql_select_db('master');
        $path_query = @mssql_query('sp_helpfile') or die(throwSQLError('unable to retrieve file path'));
        $path_array = mssql_fetch_array($path_query);
        if (substr_count($_POST['mdf'], '\\') == 0) {
            $_POST['mdf'] = substr($path_array['filename'], 0, strrpos($path_array['filename'], '\\')) . $_POST['mdf'];
        }
        if (substr_count($_POST['ldf'], '\\') == 0) {
            $_POST['ldf'] = substr($path_array['filename'], 0, strrpos($path_array['filename'], '\\')) . $_POST['ldf'];
        }
    }
    if ($_POST['ldf'] == '') {
        $result = @mssql_query('sp_attach_single_file_db \'' . $_POST['dbname'] . '\',\'' . $_POST['mdf'] . '\'') or die(throwSQLError('unable to attach database'));
    } else {
        $result = @mssql_query('sp_attach_db \'' . $_POST['dbname'] . '\',\'' . $_POST['mdf'] . '\',\'' . $_POST['ldf'] . '\'') or die(throwSQLError('unable to attach database'));
    }
}
if ($result) {
    echo '<script language="javascript">parent.left.location.reload();</script>';
    echo '<meta http-equiv="refresh" content="0;url=database_properties.php?dbname=' . $_POST['dbname'] . '">';
}
include 'inc/footer.php';
Example #14
0
    $data_query = @mssql_query($_POST['query']) or die(throwSQLError('unable to save view'));
    if ($data_query) {
        throwSuccess('view saved');
    }
} else {
    mssql_select_db($_SESSION['database']);
    $lines = array();
    $doit = false;
    $data_query = @mssql_query('sp_helptext \'' . urldecode($_GET['view']) . '\'') or die(throwSQLError('unable to retrieve procedure'));
    if (!@mssql_num_rows($data_query)) {
        $schema_query = @mssql_query('SELECT TABLE_SCHEMA FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = \'' . urldecode($_GET['view']) . '\';');
        if ($schema_query) {
            $schema_array = mssql_fetch_array($schema_query);
            $_GET['view'] = $schema_array['TABLE_SCHEMA'] . '.' . urldecode($_GET['view']);
            unset($data_query);
            $data_query = @mssql_query('sp_helptext \'' . $_GET['view'] . '\'') or die(throwSQLError('unable to retrieve view'));
            if (@mssql_num_rows($data_query)) {
                $doit = true;
            }
        }
    } else {
        $doit = true;
    }
    if ($doit) {
        while ($row = mssql_fetch_array($data_query)) {
            $lines[] = $row['Text'];
        }
    } else {
        $lines[] = 'I am unable to read this view.';
    }
}
Example #15
0
/*
Copyright (C)

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
@mssql_select_db($_SESSION['database']) or die(throwSQLError('unable to select database'));
if (empty($_POST['tablecount'])) {
    @mssql_query('DELETE FROM ' . urldecode($_GET['table']) . ';') or die(throwSQLError('unable to complete empty'));
} else {
    for ($counter = 0; $counter < $_POST['tablecount']; $counter++) {
        if ($_POST['tables'][$counter] == 'yes') {
            @mssql_query('DELETE FROM ' . urldecode($_POST['tables'][$counter]) . ';') or die(throwSQLError('unable to complete empty'));
        }
    }
}
echo '<meta http-equiv="refresh" content="0;url=database_properties.php?dbname=' . urlencode($_SESSION['database']) . '">';
include 'inc/footer.php';
Example #16
0
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
if (!empty($_POST['newname'])) {
    mssql_select_db($_SESSION['database']);
    $query = 'sp_rename \'' . $_POST['oldname'] . '\', \'' . $_POST['newname'] . '\'';
    $result = @mssql_query($query) or throwSQLError('unable to renable table', $query);
    if ($result) {
        echo '<script language="javascript">parent.left.location.reload();</script>';
        echo '<meta http-equiv="refresh" content="0;url=database_properties.php">';
        exit;
    }
} else {
    ?>

<form name="form1" method="post" action="table_rename.php">
<input type="hidden" name="oldname" value="<?php 
    echo urldecode($_GET['table']);
    ?>
">
<table cellpadding="3" cellspacing="3" width="300" style="border: 1px solid">
	<tr>
Example #17
0
    $_SESSION['expanded'] = 'yes';
} else {
    $expand = '';
    $_SESSION['expanded'] = 'no';
}
$db_query = @mssql_query('sp_databases') or die(throwSQLError('unable to retrieve a list of databases'));
while ($row = mssql_fetch_array($db_query)) {
    if (!in_array($row['DATABASE_NAME'], $_SETTINGS['dbexclude'])) {
        $encoded = urlencode($row['DATABASE_NAME']);
        if ($expand != $encoded) {
            echo '<a href="menu.php?expand=' . $encoded . '">+</a>&nbsp;<a href="database_properties.php?dbname=' . $encoded . '" oncontextmenu="javascript:genDBLink(\'' . $encoded . '\');return(false);" target="right">' . $row['DATABASE_NAME'] . '</a><br>';
        } else {
            echo '<a href="menu.php">+</a>&nbsp;<a href="database_properties.php?dbname=' . $encoded . '" oncontextmenu="javascript:genDBLink(\'' . $encoded . '\');return(false);" target="right">' . $row['DATABASE_NAME'] . '</a><br>';
            $_SESSION['database'] = $row['DATABASE_NAME'];
            @mssql_select_db($row['DATABASE_NAME']) or die(throwSQLError('unable to select database'));
            $table_query = @mssql_query('sp_tables') or die(throwSQLError('unable to retrieve a list of tables'));
            while ($row2 = mssql_fetch_array($table_query)) {
                if ($row2['TABLE_TYPE'] == 'TABLE' && $row2['TABLE_NAME'] != 'dtproperties' || $_SETTINGS['showsysdata']) {
                    if ($row2['TABLE_OWNER'] != 'dbo') {
                        $row2['TABLE_NAME'] = $row2['TABLE_OWNER'] . '.' . $row2['TABLE_NAME'];
                    }
                    echo '&nbsp;&nbsp;&nbsp;-&nbsp;<font size="-1"><a href="table_properties.php?table=' . urlencode($row2['TABLE_NAME']) . '&dbname=' . $_GET['expand'] . '" oncontextmenu="javascript:genTableLink(\'' . urlencode($row2['TABLE_NAME']) . '\',\'' . $_GET['expand'] . '\');return(false);" target="right">' . $row2['TABLE_NAME'] . '</a></font><br>';
                }
            }
        }
    }
}
?>

</body>
</html>
Example #18
0
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
mssql_select_db($_SESSION['database']);
$doit = false;
$data_query = @mssql_query('sp_helptext \'' . urldecode($_GET['view']) . '\'') or die(throwSQLError('unable to retrieve procedure'));
if (!@mssql_num_rows($data_query)) {
    $schema_query = @mssql_query('SELECT TABLE_SCHEMA FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = \'' . urldecode($_GET['view']) . '\';');
    if ($schema_query) {
        $schema_array = mssql_fetch_array($schema_query);
        if ($schema_array['TABLE_SCHEMA'] != 'dbo') {
            $_GET['view'] = $schema_array['TABLE_SCHEMA'] . '.' . urldecode($_GET['view']);
        }
    }
}
@mssql_query('DROP VIEW ' . urldecode($_GET['view']) . ';') or die(throwSQLError('unable to delete procedure'));
if ($_GET['returnto'] == '') {
    $_GET['returnto'] = 'database_properties.php';
}
echo '<meta http-equiv="refresh" content="0;url=' . $_GET['returnto'] . '">';
include 'inc/footer.php';
Example #19
0
    if ($data_query) {
        throwSuccess('procedure saved');
    }
    $lines = explode("\n", $_POST['query']);
} else {
    mssql_select_db($_SESSION['database']);
    $lines = array();
    $doit = false;
    $data_query = @mssql_query('sp_helptext \'' . urldecode($_GET['procedure']) . '\'') or die(throwSQLError('unable to retrieve procedure'));
    if (!@mssql_num_rows($data_query)) {
        $schema_query = @mssql_query('SELECT SPECIFIC_SCHEMA FROM INFORMATION_SCHEMA.ROUTINES WHERE SPECIFIC_NAME = \'' . urldecode($_GET['procedure']) . '\';');
        if ($schema_query) {
            $schema_array = mssql_fetch_array($schema_query);
            $_GET['procedure'] = $schema_array['SPECIFIC_SCHEMA'] . '.' . urldecode($_GET['procedure']);
            unset($data_query);
            $data_query = @mssql_query('sp_helptext \'' . $_GET['procedure'] . '\'') or die(throwSQLError('unable to retrieve procedure'));
            if (@mssql_num_rows($data_query)) {
                $doit = true;
            }
        }
    } else {
        $doit = true;
    }
    if ($doit) {
        while ($row = mssql_fetch_array($data_query)) {
            $lines[] = str_replace('CREATE', 'ALTER', $row['Text']);
        }
    } else {
        $lines[] = 'I am unable to read this stored procedure.';
    }
}
Example #20
0
document.form1.delimiter.focus();
</script>

<?php 
} else {
    @mssql_select_db($_SESSION['database']) or die(throwSQLError('unable to select database'));
    if ($_POST['fieldquote'] == 'single') {
        $quote = '\'';
    } else {
        $quote = '"';
    }
    echo '<form name="form1" method="post" action="table_export_download.php">';
    echo '<textarea name="data" rows="30" cols="75">';
    $tablecount = count($_POST['tables']);
    for ($counter = 0; $counter < $tablecount; $counter++) {
        $table_query = @mssql_query('SELECT * FROM ' . $_POST['tables'][$counter] . ';') or die(throwSQLError('unable to retrieve table data'));
        while ($row = mssql_fetch_array($table_query)) {
            if (!isset($schema)) {
                $schema = array();
                foreach ($row as $key => $value) {
                    if (!is_int($key)) {
                        $schema[] = $key;
                    }
                }
            }
            $values = array();
            foreach ($schema as $col) {
                if ($quote == '\'') {
                    $values[] = '\'' . str_replace('\'', '\'\'', $row[$col]) . '\'';
                } else {
                    $values[] = '"' . $row[$col] . '"';
Example #21
0
<html>
<head>
<title>phpMSAdmin</title>
</head>
<body bgcolor="#D0DCE0" style="font-family: <?php 
echo $_SETTINGS['fontfamily'];
?>
">
<center>
<font style="font-size: 24pt; font-weight: bold"><font style="color: #2A00A6">php</font><font style="color: #B90000">MS</font><font style="color: #006300">Admin</font></font>
<br><br>

<?php 
include 'inc/funclib.php';
if (!empty($_POST['username'])) {
    $c = @mssql_connect($_POST['datasource'], $_POST['username'], $_POST['password']) or die(throwSQLError('unable to establish a connection'));
    mssql_close($c);
    session_start();
    $_SESSION['updatetime'] = date('U');
    $_SESSION['datasource_name'] = $_POST['datasource'];
    $_SESSION['datasource_username'] = $_POST['username'];
    $_SESSION['datasource_password'] = $_POST['password'];
    $_SESSION['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
    $_SESSION['HTTP_USER_AGENT'] = $_SERVER['HTTP_USER_AGENT'];
    echo '<meta http-equiv="refresh" content="0;url=frameset.php">';
    exit;
}
$sources = array();
if (!$_SETTINGS['detectionoff']) {
    if (!isset($_SERVER['WINDIR']) && file_exists($_SETTINGS['freetdspath'])) {
        $sourcefile = array();
Example #22
0
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
mssql_select_db($_SESSION['database']);
if (!empty($_POST['query'])) {
    if (!@mssql_query($_POST['query'])) {
        throwSQLError('unable to create view');
    } else {
        echo '<meta http-equiv="refresh" content="0;url=database_properties.php">';
        include 'inc/footer';
    }
} else {
    $_POST['query'] = 'CREATE VIEW NewView AS ();';
}
?>
		<form name="form1" method="post" action="view_create.php">
		<table cellpadding="3" cellspacing="3" style="border: 1px solid">
			<tr>
				<td align="center" style="background: #D0DCE0">
					<b>Create View</b>
				</td>
			</tr>
Example #23
0
		<td align="center" style="background: #D0DCE0" nowrap>
			&nbsp;<b>Username</b>&nbsp;
		</td>
		<td align="center" style="background: #D0DCE0" nowrap>
			&nbsp;<b>Default DB</b>&nbsp;
		</td>
		<td align="center" colspan="2" style="background: #D0DCE0" nowrap>
			&nbsp;<b>Actions</b>&nbsp;
		</td>
	</tr>

<?php 
$toggle = true;
$colors = array('#DDDDDD', '#CCCCCC');
$skiplist = array('##MS_AgentSigningCertificate##', 'NT AUTHORITY\\NETWORK SERVICE', 'NT AUTHORITY\\SYSTEM', 'sa');
$login_query = @mssql_query('sp_helplogins;') or die(throwSQLError('unable to retrieve user list'));
while ($row = mssql_fetch_array($login_query)) {
    if ($row['AUser'] == 'yes' && substr_count($row['LoginName'], '$') == 0 && !in_array($row['LoginName'], $skiplist)) {
        if ($toggle) {
            $bg = $colors[0];
        } else {
            $bg = $colors[1];
        }
        $toggle = !$toggle;
        echo '<tr>';
        echo '<td style="background: ' . $bg . '" nowrap>&nbsp;' . $row['LoginName'] . '&nbsp;</td>';
        echo '<td style="background: ' . $bg . '" nowrap>&nbsp;' . $row['DefDBName'] . '&nbsp;</td>';
        echo '<td style="background: ' . $bg . '" nowrap>&nbsp;<a href="users_modify.php?user='******'LoginName']) . '">Modify</a>&nbsp;</td>';
        echo '<td style="background: ' . $bg . '" nowrap>&nbsp;<a href="users_drop.php?user='******'LoginName']) . '">Drop</a>&nbsp;</td>';
        echo '</tr>';
    }
Example #24
0
			<b>Views</b>
		</td>
	</tr>
	<tr>
		<td style="background: #D0DCE0">&nbsp;</td>
		<td align="center" style="background: #D0DCE0">
			<b>Name</b>
		</td>
		<td align="center" colspan="3" style="background: #D0DCE0">
			<b>Action</b>
		</td>
	</tr>
	<?php 
$toggle = true;
$colors = array('#DDDDDD', '#CCCCCC');
$view_query = @mssql_query('sp_help') or die(throwSQLError('unable to retrieve list of stored procedures'));
while ($row = mssql_fetch_assoc($view_query)) {
    if ($row['Object_type'] == 'view' && ($row['Owner'] == 'dbo' || $_SETTINGS['showsysdata'])) {
        if ($toggle) {
            $bg = $colors[0];
        } else {
            $bg = $colors[1];
        }
        $toggle = !$toggle;
        echo '<tr>';
        echo '<td align="center" style="background: ' . $bg . '"><input type="checkbox" name="views[]" value="' . $row['Name'] . '"></td>';
        echo '<td style="background: ' . $bg . '" nowrap>' . $row['Name'] . '</td>';
        echo '<td align="center" style="background: ' . $bg . '"><a href="table_select.php?view=' . urlencode($row['Name']) . '">Select</a></td>';
        echo '<td align="center" style="background: ' . $bg . '"><a href="view_modify.php?view=' . urlencode($row['Name']) . '">Modify</a></td>';
        echo '<td align="center" style="background: ' . $bg . '"><a href="view_drop.php?view=' . urlencode($row['Name']) . '&returnto=view_list.php">Drop</a></td>';
        echo '</tr>';
Example #25
0
		<td colspan="2" style="background: #D0DCE0">
			<input type="radio" name="primarykey" value="" <?php 
            if ($primary_array['index_keys'] != urldecode($_GET['column'])) {
                echo 'checked';
            }
            ?>
> No Primary Key
		</td>
	</tr>
</table>
</form>

<script language="javascript">
document.form1.elements["name"].focus();
</script>

<?php 
        }
    } else {
        if ($_GET['mode'] == 'drop') {
            @mssql_select_db($_SESSION['database']) or die(throwSQLError('unable to select database'));
            $query = 'ALTER TABLE ' . urldecode($_GET['table']) . ' DROP COLUMN ' . urldecode($_GET['column']) . ';';
            @mssql_query($query) or die(throwSQLError('unable to drop column', $query));
            echo '<meta http-equiv="refresh" content="0;url=table_properties.php?table=' . $_GET['table'] . '">';
        }
    }
}
?>

<?php 
include 'inc/footer.php';
Example #26
0
<?php

/*
Copyright (C)

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
mssql_select_db($_SESSION['database']);
@mssql_query('DROP TRIGGER ' . urldecode($_GET['trigger'])) or die(throwSQLError('unable to delete trigger'));
if (empty($_GET['returnto'])) {
    $_GET['returnto'] = 'database_properties.php';
}
echo '<meta http-equiv="refresh" content="0;url=' . $_GET['returnto'] . '">';
include 'inc/footer.php';
Example #27
0
			<b>Value</b>
		</td>
	</tr>
	<?php 
mssql_select_db($_SESSION['database']);
$_GET['table'] = urldecode($_GET['table']);
$existing_query = @mssql_query('SELECT * FROM ' . $_GET['table'] . ' WHERE ' . $_GET['col'] . '=\'' . $_GET['id'] . '\'') or throwSQLError('unable to retrieve existing row');
$existing_array = mssql_fetch_assoc($existing_query);
if (substr_count($_GET['table'], '.') > 0) {
    $tablesep = explode('.', $_GET['table']);
    $query = 'sp_columns @table_name = N\'' . $tablesep[1] . '\'';
    $query .= ', @table_owner = N\'' . $tablesep[0] . '\'';
} else {
    $query = 'sp_columns @table_name = N\'' . $_GET['table'] . '\'';
}
$column_query = @mssql_query($query) or die(throwSQLError('unable to retrieve column data'));
$counter = 0;
$toggle = true;
$colors = array('#CCCCCC', '#DDDDDD');
while ($row = mssql_fetch_array($column_query)) {
    if ($toggle) {
        $bg = $colors[0];
    } else {
        $bg = $colors[1];
    }
    $toggle = !$toggle;
    if (substr_count($row['TYPE_NAME'], 'identity') > 0) {
        $status = 'disabled readonly';
    } else {
        $status = '';
    }
Example #28
0
<?php

/*
Copyright (C)

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
mssql_select_db($_SESSION['database']);
@mssql_query('DROP FUNCTION ' . urldecode($_GET['function']) . ';') or die(throwSQLError('unable to delete function'));
if (empty($_GET['returnto'])) {
    $_GET['returnto'] = 'database_properties.php';
}
echo '<meta http-equiv="refresh" content="0;url=' . $_GET['returnto'] . '">';
include 'inc/footer.php';
Example #29
0
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
if ($_POST['query'] != '') {
    $data_query = @mssql_query($_POST['query']) or die(throwSQLError('unable to save procedure'));
    if ($data_query) {
        throwSuccess('procedure saved');
    }
} else {
    mssql_select_db($_SESSION['database']);
    $lines = array();
    $doit = false;
    $data_query = @mssql_query('sp_helptext \'' . urldecode($_GET['trigger']) . '\'') or die(throwSQLError('unable to retrieve trigger'));
    if ($data_query) {
        while ($row = mssql_fetch_array($data_query)) {
            $lines[] = $row['Text'];
        }
        $lines[1] = str_replace('CREATE', 'ALTER', $lines[1]);
    } else {
        $lines[] = 'I am unable to read this trigger.';
    }
}
?>
		<form name="form1" method="post" action="trigger_modify.php?trigger=<?php 
echo $_GET['trigger'];
?>
">
		<table width="<?php 
Example #30
0
<?php

/*
Copyright (C)

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
include 'inc/header.php';
@mssql_query('sp_dropuser ' . urldecode($_GET['user']) . ';') or die(throwSQLError('unable to drop user'));
echo '<meta http-equiv="refresh" content="0;url=users_list.php">';
include 'inc/footer.php';