root/tags/1.0.1/setup.php

Revision 1553, 8.9 KB (checked in by jeena, 3 years ago)

bugfixes

Line 
1<?php
2/* -- setup.php for Jlog v1.0.0
3   -- last edit Dez 15th 2005 by Jeena Paradies
4   --
5   -- Please delete this file if you have done the setup
6*/
7 define("JLOG_NEW_VERSION", '1.0.0');
8 define("JLOG_SETUP", true);
9 define("JLOG_PHPV", "4.1.1");
10 define("JLOG_MYSQLV", "4.0.0");
11 $basepath = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
12
13 // defining to avoid notifications
14 define("JLOG_WEBSITE", $_SERVER["HTTP_HOST"]);
15 define("JLOG_PATH", dirname("http://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]));
16
17 require('.'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'lang.inc.php');
18 require('.'.DIRECTORY_SEPARATOR.'lang'.DIRECTORY_SEPARATOR.'lang-admin.inc.php');
19 require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'database.class.php');
20 require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'general.func.php'); 
21 require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'settings.class.php');
22 require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'url_syntax.php');
23 $errors = array();
24 
25 $l['admin']['submit'] = $l['admin']['s_install'];
26 $setup = new Settings($l);
27
28 if($_POST) {
29  $setup->get_userdata(strip($_POST));
30
31  // validate user entry
32  if(count($errors = $setup->validate()) == 0) {
33   define("JLOG_BASEPATH", $setup->put_data('basepath'));
34   if(is_writable(JLOG_BASEPATH.'personal'.DIRECTORY_SEPARATOR)) {
35     $c .= "<ul>\n";
36     
37     // build some MySQL tables
38     if(count($errors = create_mysql_tables($setup->put_data(false))) == 0) {
39      $c .= "<li>".$l['admin']['s_tables_ok']."</li>\n";
40
41      // create and chmod on some directories and files
42      if(count($errors = do_personal()) == 0) {
43       $c .= "<li>".$l['admin']['s_personal_ok']."</li>\n";
44
45       // build settings.php
46       if(count($errors = $setup->do_settings()) == 0) $c .= "<li>".$l['admin']['master_ok']."</li>\n";
47      }
48      $c .= "</ul>";
49     }
50   }
51   else {
52    $errors[] = $l['admin']['s_personal_not_wrtbl'];
53   }
54  }
55  if(count($errors) > 0) {
56   $c .= error_output($errors);
57   $c .= $setup->form_output();
58  }
59  else $c .= "<h2>".$l['admin']['s_ready_head']."</h2>"."<p style='text-align: left;'>".$l['admin']['s_ready']."</p>";
60 }
61 else {
62  // validate PHP and MySQL versions
63  if(!version_compare(phpversion(), JLOG_PHPV, ">=") == 1) $errors[] = $l['admin']['s_phpv_tolow'];
64  if(!is_writable($basepath.'personal'.DIRECTORY_SEPARATOR)) $errors[] = $l['admin']['s_personal_not_wrtbl'];
65  if(!is_writable($basepath.'img'.DIRECTORY_SEPARATOR)) $errors[] = $l['admin']['s_img_not_wrtbl'];
66
67  if(empty($errors)) {
68   // output form
69   $setup->get_sugestiondata();
70   $c .= $setup->form_output();
71  }
72  else $c .= error_output($errors);
73 }
74 
75 echo do_htmlpage($c);
76 
77
78
79
80
81#### some needed functions for the setup ####
82
83 function create_mysql_tables($data) {
84  # returns false if all tables were created, if not returns the $errors array
85
86  $sql['content'] = '
87    CREATE TABLE `'.$data['jlog_db_prefix'].'content` (
88      id int(11) auto_increment,
89      url varchar(200),
90      topic varchar(255),
91      date datetime,
92      teaser mediumtext,
93      teaserpic varchar(10),
94      teaserpiconblog tinyint(1),
95      keywords varchar(255),
96      content longtext,
97      comments tinyint(1) default \'1\',
98      allowpingback tinyint(1) default \'1\',
99      section varchar(10) default \'weblog\',
100      UNIQUE KEY id (id),
101      FULLTEXT KEY content_index (content, topic, teaser, keywords)
102    ) TYPE=MyISAM;';
103
104  $sql['comments'] = '
105   CREATE TABLE `'.$data["jlog_db_prefix"].'comments` (
106     id int(11) auto_increment,
107     sid varchar(35),
108     name varchar(255),
109     city varchar(255),
110     email varchar(255),
111     homepage varchar(255),
112     content mediumtext,
113     date datetime,
114     reference int(11),
115     mail_by_comment tinyint(1),
116     type varchar(30) default \'\',
117     PRIMARY KEY (id),
118     UNIQUE KEY sid (sid),
119     FULLTEXT KEY comments_index ( name, city, email, homepage, content )
120   ) TYPE=MyISAM;';
121   
122  $sql['categories'] = '
123   CREATE TABLE `'.$data["jlog_db_prefix"].'categories` (
124     id tinyint(4) auto_increment,
125     name tinytext,
126     url varchar(100),
127     description text,
128     UNIQUE KEY id (id),
129     UNIQUE KEY url (url)
130   ) TYPE=MyISAM;';
131   
132  $sql['catassign'] = '
133   CREATE TABLE `'.$data["jlog_db_prefix"].'catassign` (
134     content_id int(11),
135     cat_id tinyint(4)
136   ) TYPE=MyISAM;';
137
138  $sql['attributes'] = '
139   CREATE TABLE `'.$data["jlog_db_prefix"].'attributes` (
140     id int(10) unsigned NOT NULL auto_increment,
141     entry_id int(10) unsigned NOT NULL default \'0\',
142     name varchar(120) NOT NULL default \'\',
143     value varchar(250) NOT NULL default \'\',
144     PRIMARY KEY (id),
145     KEY entry_id (entry_id)
146   ) TYPE=MyISAM;';
147
148    global $l;
149
150    if(!@mysql_connect($data['jlog_db_url'], $data['jlog_db_user'], $data['jlog_db_pwd'])) $errors[] = "Falsche Zugangsdaten | ".mysql_error();
151    elseif(!@mysql_select_db($data['jlog_db'])) $errors[] = "Datenbank ".$data['jlog_db']." extistiert nicht".mysql_error();
152    elseif(!version_compare(mysql_get_server_info(), JLOG_MYSQLV, ">=") == 1) $errors[] = $l['admin']['s_mysqlv_tolow'];
153    else {
154     $create['content'] = new Query($sql['content']);
155     if($create['content']->error()) $errors[] = "MySQL <pre>".$create['content']->getError()."</pre>";
156     $create['comments'] = new Query($sql['comments']);
157     if($create['comments']->error()) $errors[] = "MySQL <pre>".$create['comments']->getError()."</pre>";   
158     $create['categories'] = new Query($sql['categories']);
159     if($create['categories']->error()) $errors[] = "MySQL <pre>".$create['categories']->getError()."</pre>";
160     $create['catassign'] = new Query($sql['catassign']);
161     if($create['catassign']->error()) $errors[] = "MySQL <pre>".$create['catassign']->getError()."</pre>";
162     $create['attributes'] = new Query($sql['attributes']);
163     if($create['attributes']->error()) $errors[] = "MySQL <pre>".$create['attributes']->getError()."</pre>";
164  }
165   
166   return $errors;
167 }
168 
169 function do_personal() {
170  # returns true if all files and dirs could be generated
171  # if not returns the $errors array
172
173  global $l;
174
175  // make some dirs
176  $oldmask = umask(0);
177
178  // make some files
179  if(!fopen(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."settings.inc.php", "w")) $errors[] = $l['admin']['s_problem_fwrite']." /personal/settings.inc.php";
180  if(!fopen(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."rss.xml", "w")) $errors[] = $l['admin']['s_problem_fwrite']." /personal/rss.xml";
181  if(!fopen(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."rss-full.xml", "w")) $errors[] = $l['admin']['s_problem_fwrite']." /personal/rss-full.xml";
182  if(!fopen(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."subcurrent.inc", "w")) $errors[] = $l['admin']['s_problem_fwrite']." /personal/subcurrent.inc";
183
184  // chmod 777 so that the user have the ability to delete/write to this files
185  if(!chmod(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."settings.inc.php", 0666)) $errors[] = $l['admin']['s_problem_chmod']." /personal/settings.inc.php";
186  if(!chmod(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."rss.xml", 0666)) $errors[] = $l['admin']['s_problem_chmod']." /personal/rss.xml";
187  if(!chmod(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."rss-full.xml", 0666)) $errors[] = $l['admin']['s_problem_chmod']." /personal/rss-full.xml";
188  if(!chmod(JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."subcurrent.inc", 0666)) $errors[] = $l['admin']['s_problem_chmod']." /personal/subcurrent.inc";
189
190  umask($oldmask);
191
192  return $errors;
193 }
194
195 function do_htmlpage($content) {
196
197  return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
198        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
199<html xmlns="http://www.w3.org/1999/xhtml">
200  <title>SETUP Jlog v0.2</title>
201  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
202  <link rel="stylesheet" href="scripts/css/admin.css" type="text/css" />
203  <style type="text/css">
204   body {
205    background: #F3F3F3;
206    color: black;
207    font-family: verdana, sans-serif;
208    font-size: 100.01%;
209   }
210   #container {
211    font-size: 0.9em;
212    background: white;
213    padding: 20px;
214    margin: 1em auto;
215    border: 1px solid #aaa;
216    width: 600px;
217   }
218   h1 {
219    font-family: georgia, "Times New Roman", Times, sans-serif;
220    font-size: 80px;
221    margin: 0 0 0 30px;
222   }
223   #logo { float: right; }
224   h2 { margin: 1.5em 0 0.3em 0; font-weight: normal; clear: right; }
225   .ok { color: green; }
226   .notok, .error { color: red; }
227   table { border-spacing: 0.5em; }
228   fieldset { padding: 1em; border: 1px solid #ccc; }
229   legend { font-weight: bold; padding: 0 1em; }
230   .button { font-size: 3em; }
231   p { text-align: center; }
232   fieldset p { text-align: left; }
233  </style>
234 </head>
235 <body>
236  <div id="container">
237   <h1><a href="http://jeenaparadies.net/webdesign/jlog/" title="Jlog v'.JLOG_NEW_VERSION.'"><img id="logo" src="http://jeenaparadies.net/webdesign/jlog/img/JLOG_logo-0-2-8.png" style="width: 210px; height: 120px;" alt="Jlog" /></a> SETUP</h1>
238    '.$content.'
239  </div>
240 </body>
241</html>';
242 }
243
244?>
Note: See TracBrowser for help on using the browser.