-
Notifications
You must be signed in to change notification settings - Fork 6
/
class_init.php
98 lines (91 loc) · 3.69 KB
/
class_init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* @package class_init.php
* @author John Doe <[email protected]>
* @since 2011-12-16
* @version 2011-12-19
*/
/*
12/16/11 initial release
12/19/11 'group' => 'group_name'
*/
error_reporting(E_ALL);
require_once './incs/functions.inc.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE><?php print gettext('Classes Database Initialization');?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<META HTTP-EQUIV="Expires" CONTENT="0">
<META HTTP-EQUIV="Cache-Control" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Pragma" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
<LINK REL=StyleSheet HREF="default.css" TYPE="text/css" />
<SCRIPT>
/**
*
* @returns {undefined}
*/
function depart() {location.href = "index.php"; }
</SCRIPT>
</HEAD>
<BODY>
<?php
if (array_key_exists('initialize', $_POST)) {
$query = "DROP TABLE IF EXISTS `$GLOBALS[mysql_prefix]courses`;";
$result = mysql_query($query) or do_error($query,'mysql_query() failed',mysql_error(), basename( __FILE__), __LINE__);
$query = " CREATE TABLE `$GLOBALS[mysql_prefix]courses` (
`id` int(7) NOT NULL AUTO_INCREMENT,
`course` varchar(48) NOT NULL,
`group_name` varchar(48) DEFAULT NULL,
`ident` varchar(48) DEFAULT NULL,
`credits` varchar(48) DEFAULT NULL,
`duration` varchar(48) DEFAULT NULL,
`source` varchar(48) DEFAULT NULL,
`sort` int(7) DEFAULT '0',
`_by` int(7) DEFAULT '0',
`_from` varchar(16) DEFAULT NULL,
`_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$result = mysql_query($query) or do_error($query,'mysql_query() failed',mysql_error(), basename( __FILE__), __LINE__);
$query = "DROP TABLE IF EXISTS `$GLOBALS[mysql_prefix]courses_taken`;";
$result = mysql_query($query) or do_error($query,'mysql_query() failed',mysql_error(), basename( __FILE__), __LINE__);
$query = "CREATE TABLE `$GLOBALS[mysql_prefix]courses_taken` (
`id` int(7) NOT NULL AUTO_INCREMENT,
`courses_id` int(7) NOT NULL,
`user_id` int(7) NOT NULL,
`date` date NOT NULL,
`info` varchar(64) DEFAULT NULL,
`_by` int(7) DEFAULT '0',
`_from` varchar(16) DEFAULT NULL,
`_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;";
$result = mysql_query($query) or do_error($query,'mysql_query() failed',mysql_error(), basename( __FILE__), __LINE__);
?>
<br /><br /><br /><br /><br /><br /><center>
<h2>
<?php print gettext('Classes database initialization complete!');?>
</h2>
<input type = button value = "<?php print gettext('Finished');?>" onClick = "setTimeout('depart()',750);" />
<?php
}
else {
?>
<br /><br /><br /><br /><br /><br /><center>
<h2>
<?php print gettext('Press <i>Proceed</i> to initialize Classes Database - cannot be undone!');?>
</h2>
<form name = 'init_form' method = post action = '<?php echo basename(__FILE__);?>'>
<input type = button value = "<?php print gettext('Proceed');?>" onClick = "if (confirm('<?php print gettext('Last chance - click OK to proceed');?>)) {this.form.submit();}" />
<input type = hidden name = 'initialize' value = 'initialize' />
</form>
<br /><br /><br />
<input type = button value = "<?php print gettext('Cancel');?>" onClick = "setTimeout('depart()',750);" />
<?php
}
?>
</BODY>
</HTML>