Documentation is available at install_core.php
1 <?php
2 /**
3 * @author Jan H. Andersen <jha@ipwsystems.dk>
4 * @author Martin R. Larsen <mrl@ipwsystems.dk>
5 * @author Jesper Laursen <jl@ipwsystems.dk>
6 * @copyright {@link http://www.ipwsystems.dk/ IPW Systems a.s}
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @package METAjour
9 * $Id: install_core.php,v 1.3 2005/02/11 14:36:51 SYSTEM Exp $
10 */
11
12 function getVars() {
13 global $CONFIG $system_path $system_url
14 return array($CONFIG, $system_path, $system_url);
15 }
16
17 class Screen {
18 var $haserror = false;
19 var $CONFIG = array();
20 var $system_path;
21 var $system_url;
22
23 var $phpversion = '4.3.3';
24 var $mysqlversion = '4.1.1';
25 var $dbfile = 'db.sql';
26
27 function Screen() {
28 list($this->CONFIG, $this->system_path, $this->system_url) = getVars();
29 require_once($this->system_path . 'adodb.php');
30 }
31
32 function setError() {
33 $this->haserror = true;
34 }
35 }
36
37 class Screen1 extends Screen {
38
39 function notablesExists() {
40 $db =& getdbconn();
41
42 $existingTables = $db->getCol('SHOW tables');
43 if (!$existingTables) $existingTables = array();
44
45 $handle = fopen ($this->dbfile, "r");
46 $contents = fread ($handle, filesize ($this->dbfile));
47 preg_match_all("/CREATE TABLE `?(\w+)`?/i", $contents, $tables);
48 $matches = array_intersect($existingTables, $tables[1]);
49
50 if (count($matches) > 0) {
51 $this->setError();
52 return false;
53 } else {
54 return true;
55 }
56 }
57
58 function correctPHPversion() {
59 $tmp = version_compare($this->phpversion, phpversion(), '<=');
60 if (!$tmp) $this->setError();
61 return $tmp;
62 }
63
64 function correctMySQLversion() {
65 $mysqlversion = substr(mysql_get_server_info(), 0, strpos( mysql_get_server_info(), '-'));
66 $tmp = version_compare($this->mysqlversion, $mysqlversion, '<=');
67 if (!$tmp) $this->setError();
68 return $tmp;
69 }
70 }
71
72 class Screen2 extends Screen {
73
74 function checkSystemPath() {
75 if (!file_exists($this->system_path . 'core/basicclass.php')) {
76 $this->setError();
77 return false;
78 }
79 return true;
80 }
81
82 function checkSystemUrl() {
83 if (empty($this->system_url)) {
84 $this->setError();
85 return false;
86 }
87 return true;
88 }
89
90 function checkadodbexists() {
91 return (file_exists($this->system_path . 'core/ado/adodb.inc.php')) ? true : false;
92 }
93
94 function checkDatabaseConn() {
95 $result = false;
96 if ($this->checkadodbexists($this->system_path)) {
97 include_once($this->system_path . 'core/ado/adodb.inc.php');
98 @$conn =& ADONewConnection($this->CONFIG['sql_type']);
99 $result = @$conn->connect($this->CONFIG['sql_host'],
100 $this->CONFIG['sql_user'],
101 $this->CONFIG['sql_password'],
102 $this->CONFIG['sql_database']);
103 if (!$result) {
104 $this->setError();
105 return false;
106 } else {
107 return true;
108 }
109 } else {
110 $this->setError();
111 return false;
112 }
113 }
114 }
115
116 class Screen3 extends Screen {
117
118 function sendquery($query ) {
119
120 $db =& getdbconn();
121 $array = explode( ';', $query );
122 foreach( $array as $value ) {
123 $value=trim($value);
124 if ($value != "") {
125 if( !$result = $db->query( $value )) {
126 $this->setError();
127 break;
128 }
129 }
130 }
131 return $result;
132 }
133
134 function createsql() {
135 echo "Creating tables in database...<BR>";
136 $handle = fopen ($this->dbfile, "r");
137 $contents = fread ($handle, filesize ($this->dbfile));
138 $this->sendquery($contents);
139 fclose ($handle);
140 echo "Tables created!<BR><BR>";
141 }
142 }
143
144 class Screen4 extends Screen {
145
146 }
147 ?>
Documentation generated on Thu, 9 Jun 2005 06:52:39 +0200 by phpDocumentor 1.2.3