Location: PHPKode > projects > QuickTicket > quickticket/quickticket/install/qti_droptables.php
<?php

// QuickTicket 1.9 build:20080805

session_start();

function SqlDrop($oDB,$strTable,$strConstrain=null)
{
  if ( isset($strConstrain) && $oDB->type=='oci' ) $oDB->Query('ALTER TABLE '.$strTable.' DROP CONSTRAINT '.$strConstrain);
  $oDB->Query('DROP TABLE '.$strTable);
}

// INITIALISATION

include('../bin/qt_lib_db.php');
include('../bin/config.php');
define ('TABDOMAIN', $qti_prefix.'qtidomain');
define ('TABSECTION', $qti_prefix.'qtiforum');
define ('TABUSER', $qti_prefix.'qtiuser');
define ('TABTOPIC', $qti_prefix.'qtitopic');
define ('TABPOST', $qti_prefix.'qtipost');
define ('TABSTATUS', $qti_prefix.'qtistatus');
define ('TABSETTING', $qti_prefix.'qtisetting');
define ('TABLANG', $qti_prefix.'qtilang');

$strAppl = 'QuickTicket 1.9';
include('qti_lang_en.php');

// --------
// HTML START
// --------

echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en">
<head>
<title>Uninstalling ',$strAppl,'</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<link rel="stylesheet" href="../admin/qti_main.css">
</head>

<body>

<!-- PAGE CONTROL -->
<div class="div_qti_page">
<table class="ta_qti_page" width="750" cellspacing="0" style="margin:5px">
<tr class="tr_qti_page">
<td class="td_qti_page">
<!-- PAGE CONTROL -->

<!-- HEADER BANNER -->
<div class="div_banner">
<div class="div_banner_in">
<img src="qti_logo.gif" width="175" height="50" style="border-width:0" alt="QuickTicket" title="QuickTicket"/>
</div>
</div>
<!-- END HEADER BANNER -->

<!-- BODY MAIN -->
<table width="100%" cellspacing="0" style="border-style:solid;border-color:#AAAAAA;border-width:1px;">
<tr class="tr_body">
<td class="td_body">
<!-- BODY MAIN -->
';

echo '1. <b>Opening database connection</b>... ';

$oDB = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn);
if ( !empty($oDB->error) ) die ('<p style="color:red">Connection with database failed.<br/>Check that server is up and running.<br/>Check that the settings in the file <b>bin/config.php</b> are correct for your database.</p>');

echo 'done<br/><br/>';

// SUBMITTED

if ( isset($_GET['a']) )
{
  switch ($_GET['a'])
  {
  case 'Drop ALL tables':
    echo ' Dropping Post...'; SqlDrop($oDB,TABPOST,'pk_'.$qti_prefix.'qtipost'); echo 'done.<br/>';
    echo ' Dropping Topic...'; SqlDrop($oDB,TABTOPIC,'pk_'.$qti_prefix.'qtitopic'); echo 'done.<br/>';
    echo ' Dropping Section...'; SqlDrop($oDB,TABSECTION,'pk_'.$qti_prefix.'qtiforum'); echo 'done.<br/>';
    echo ' Dropping Domain...'; SqlDrop($oDB,TABDOMAIN,'pk_'.$qti_prefix.'qtidomain'); echo 'done.<br/>';
    echo ' Dropping User...'; SqlDrop($oDB,TABUSER,'pk_'.$qti_prefix.'qtiuser'); echo 'done.<br/>';
    echo ' Dropping Status...'; SqlDrop($oDB,TABSTATUS,'pk_'.$qti_prefix.'qtistatus'); echo 'done.<br/>';
    echo ' Dropping Setting...'; SqlDrop($oDB,TABSETTING); echo 'done.<br/>';
    echo ' Dropping Lang...'; SqlDrop($oDB,TABLANG); echo 'done.<br/>';
    break;
  case 'Drop table Post':
    echo ' Dropping Post...'; SqlDrop($oDB,TABPOST,'pk_'.$qti_prefix.'qtipost'); echo 'done.<br/>'; break;
  case 'Drop table Topic':
    echo ' Dropping Topic...'; SqlDrop($oDB,TABTOPIC,'pk_'.$qti_prefix.'qtitopic'); echo 'done.<br/>'; break;
  case 'Drop table Section':
    echo ' Dropping Section...'; SqlDrop($oDB,TABSECTION,'pk_'.$qti_prefix.'qtiforum'); echo 'done.<br/>'; break;
  case 'Drop table Domain':
    echo ' Dropping Domain...'; SqlDrop($oDB,TABDOMAIN,'pk_'.$qti_prefix.'qtidomain'); echo 'done.<br/>'; break;
  case 'Drop table User':
    echo ' Dropping User...'; SqlDrop($oDB,TABUSER,'pk_'.$qti_prefix.'qtiuser'); echo 'done.<br/>'; break;
  case 'Drop table Status':
    echo ' Dropping Status...'; SqlDrop($oDB,TABSTATUS,'pk_'.$qti_prefix.'qtistatus'); echo 'done.<br/>'; break;
  case 'Drop table Setting':
    echo ' Dropping Setting...'; SqlDrop($oDB,TABSETTING); echo 'done.<br/>'; break;
  case 'Drop table Lang':
    echo ' Dropping Lang...'; SqlDrop($oDB,TABLANG); echo 'done.<br/>'; break;
  case 'Add table Post':
    include('qti_setup_post.inc'); echo $_GET['a'],' done'; break;
  case 'Add table Topic':
    include('qti_setup_topic.inc'); echo $_GET['a'],' done'; break;
  case 'Add table Sectionm':
    include('qti_setup_section.inc'); echo $_GET['a'],' done'; break;
  case 'Add table Domain':
    include('qti_setup_domain.inc'); echo $_GET['a'],' done'; break;
  case 'Add table User':
    include('qti_setup_user.inc'); echo $_GET['a'],' done'; break;
  case 'Add table Status':
    include('qti_setup_status.inc'); echo $_GET['a'],' done'; break;
  case 'Add table Setting':
    include('qti_setup_setting.inc'); echo $_GET['a'],' done'; break;
  case 'Add table Lang':
    include('qti_setup_lang.inc'); echo $_GET['a'],' done'; break;
  }
}

// Tables do drop

echo '<br/>2. <b>Drop the tables</b><br/>';

echo '<form action="qti_droptables.php" method="get">';
echo '<input type="submit" name="a" value="Drop ALL tables"/> from the database ',$qti_database,'<br/><br/>';
echo '<input type="submit" name="a" value="Drop table Post"/> ',TABPOST,'<br/>';
echo '<input type="submit" name="a" value="Drop table Topic"/> ',TABTOPIC,'<br/>';
echo '<input type="submit" name="a" value="Drop table User"/> ',TABUSER,'<br/>';
echo '<input type="submit" name="a" value="Drop table Section"/> ',TABSECTION,'<br/>';
echo '<input type="submit" name="a" value="Drop table Domain"/> ',TABDOMAIN,'<br/>';
echo '<input type="submit" name="a" value="Drop table Status"/> ',TABSTATUS,'<br/>';
echo '<input type="submit" name="a" value="Drop table Setting"/> ',TABSETTING,'<br/>';
echo '<input type="submit" name="a" value="Drop table Lang"/> ',TABLANG,'<br/><br/>';
echo '<input type="submit" name="a" value="Add table Post"/> ',TABPOST,'<br/>';
echo '<input type="submit" name="a" value="Add table Topic"/> ',TABTOPIC,'<br/>';
echo '<input type="submit" name="a" value="Add table User"/> ',TABUSER,'<br/>';
echo '<input type="submit" name="a" value="Add table Section"/> ',TABSECTION,'<br/>';
echo '<input type="submit" name="a" value="Add table Domain"/> ',TABDOMAIN,'<br/>';
echo '<input type="submit" name="a" value="Add table Status"/> ',TABSTATUS,'<br/>';
echo '<input type="submit" name="a" value="Add table Setting"/> ',TABSETTING,'<br/>';
echo '<input type="submit" name="a" value="Add table Lang"/> ',TABLANG,'<br/>';
echo '</form>';

echo '<p><a href="qti_setup.php">install &raquo;</a></p>';

// --------
// HTML END
// --------

echo '
<!-- END BODY MAIN -->
</td>
</tr>
</table>
<!-- END BODY MAIN -->

<div class="div_footer_copy">
<span class="p_footer_copy">powered by <a href="http://www.qt-cute.org" class="a_footer_copy">QT-cute</a></span>
</div>

<!-- END PAGE CONTROL -->
</td>
</tr>
</table>
</div>
<!-- END PAGE CONTROL -->

</body>
</html>';
?>
Return current item: QuickTicket