PageRenderTime 30ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/install/class_install.php

http://lansuite.googlecode.com/
PHP | 749 lines | 524 code | 138 blank | 87 comment | 185 complexity | f88be4f1816e610df3091bf5d7edb52a MD5 | raw file
Possible License(s): LGPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. include_once("modules/install/class_import.php");
  3. $import = New Import();
  4. class Install {
  5. function IsWriteableRec($dir) {
  6. $ret = '';
  7. if ($dh = opendir($dir)) {
  8. while (($file = readdir($dh)) !== false) if ($file != '.' and $file != '..' and $file != '.svn') {
  9. if (!is_writable($dir .'/'. $file)) $ret .= $dir .'/'. $file .'<br>';
  10. if (is_dir($dir .'/'. $file)) $ret .= $this->IsWriteableRec($dir .'/'. $file);
  11. }
  12. closedir($dh);
  13. }
  14. return $ret;
  15. }
  16. // Get Config (/inc/base/config.php) an change it
  17. function WriteConfig($values = NULL) {
  18. global $config;
  19. $conf = @file("inc/base/config.php");
  20. $i = 1;
  21. while ($row = $conf[$i]) {
  22. // Get Next Element if this is a Comment or a "Header"
  23. if (stristr($row, ";")) {
  24. $i++;
  25. continue;
  26. }
  27. if (stristr($row, "[")) {
  28. $setting['category'] = substr(trim($row), 1, -1);
  29. $i++;
  30. continue;
  31. }
  32. $setting['name'] = trim(strtok($row, "="));
  33. $tabs = "";
  34. for ($z = 0; $z < (4 - (strlen($setting['name']) / 8)); $z++) $tabs .= "\t";
  35. if ($setting['name']) $conf[$i] = $setting['name'] . $tabs ."= \"". $config[$setting['category']][$setting['name']] ."\"\r\n";
  36. $i++;
  37. } // END while( $row = $conf[$i] )
  38. // Write new settings to the config.php file
  39. // Have we opened the file??? If not, tell the user ...
  40. if($fh = @fopen("inc/base/config.php", "w")) {
  41. foreach($conf AS $row) {
  42. @fwrite($fh, $row, strlen($row));
  43. }
  44. @fclose( $fh );
  45. return 1;
  46. } else return 0;
  47. }
  48. // Connect to DB and create Database, if not exist
  49. function TryCreateDB($createnew = NULL){
  50. global $config, $db;
  51. if(!$db->connect(1))
  52. {
  53. //No success connection
  54. if($db->connectfailure == 1) $ret_val = 0;
  55. elseif($db->connectfailure == 2 and $config['database']['database'] == '') $ret_val = 4;
  56. elseif($db->connectfailure == 2 and $config['database']['database'] != '')
  57. {
  58. //Try to create DB
  59. $db->set_charset();
  60. $query_id = $db->qry('CREATE DATABASE '. $config['database']['database'] .' CHARACTER SET utf8');
  61. if ($query_id) $ret_val = 3; else $ret_val = 2;
  62. }
  63. }
  64. else
  65. {
  66. // If User wants to rewrite all tables, drop databse. It will be created anew in the next step
  67. if (!$_GET["quest"] and $createnew and $_GET["step"] == 3) $this->DeleteAllTables();
  68. if($createnew) $ret_val = 5; else $ret_val = 1;
  69. }
  70. // Return-Values:
  71. // 0 = Server not available
  72. // 1 = DB already exists
  73. // 2 = Create failed (i.e. insufficient rights)
  74. // 3 = Create successe
  75. // 4 = no Database
  76. // 5 = DB overwrite
  77. return $ret_val;
  78. }
  79. // Creates a DB-table using the file $table, located in the mod_settings-directory of the module $mod
  80. function WriteTableFromXMLFile($mod, $rewrite = NULL){
  81. global $db, $config, $import;
  82. // Delete references, if table exists, for they will be recreated in ImportXML()
  83. if (in_array($config['database']['prefix'] .'ref', $import->installed_tables)) $db->qry('TRUNCATE TABLE %prefix%ref');
  84. $import->GetImportHeader("modules/$mod/mod_settings/db.xml");
  85. $import->ImportXML($rewrite);
  86. if ($mod == 'install') {
  87. $this->InsertModules($rewrite);
  88. $this->InsertMenus($rewrite);
  89. }
  90. }
  91. // Scans 'install/db_skeleton/' for non-existand tables and creates them
  92. // Puts the results to the screen, by using $dsp->AddSingleRow for each table, if $display_to_screen = 1
  93. function CreateNewTables($display_to_screen = 1) {
  94. global $dsp, $config, $db, $func;
  95. $tablecreate = Array("anz" => 0, "created" => 0, "exist" => 0, "failed" => "");
  96. if ($display_to_screen) $dsp->AddSingleRow("<b>". t('Tabellen erstellen') ."</b>");
  97. if (is_dir("modules")) {
  98. // Do install-mod first! (for translations-table must exist)
  99. if (is_dir("modules/install/mod_settings")) {
  100. // Try to find DB-XML-File
  101. if (file_exists("modules/install/mod_settings/db.xml")){
  102. $this->WriteTableFromXMLFile('install'); // Calls InsertModules and InsertMenus as well
  103. if ($display_to_screen) $dsp->AddDoubleRow("Modul 'install'", "[<a href=\"index.php?mod=install&action=db&step=7&module=install&quest=1\">".t('zurόcksetzen')."</a>]");
  104. }
  105. }
  106. // Try to find and import db.xml-Files
  107. foreach($func->ActiveModules as $module => $caption) {
  108. if ($module != 'install' and file_exists("modules/$module/mod_settings/db.xml")) {
  109. $this->WriteTableFromXMLFile($module);
  110. if ($display_to_screen) $dsp->AddDoubleRow("Modul '$module'", "[<a href=\"index.php?mod=install&action=db&step=7&module=$module&quest=1\">".t('zurόcksetzen')."</a>]");
  111. }
  112. }
  113. }
  114. if ($display_to_screen) $dsp->AddDoubleRow("<b>". t('Alle Tabellen') ."</b>", "[<a href=\"index.php?mod=install&action=db&step=3&quest=1\">".t('zurόcksetzen')."</a>]");
  115. return $tablecreate;
  116. }
  117. // Insert PLZ-Entrys in DB, if not exist
  118. function InsertPLZs() {
  119. global $db, $cfg;
  120. if ($cfg['guestlist_guestmap'] == 1) {
  121. $return_val = 1;
  122. $find = $db->qry("SELECT * FROM %prefix%locations");
  123. if ($db->num_rows($find) == 0) {
  124. $return_val = 2;
  125. $file = "modules/install/db_insert_locations.php";
  126. // $file = "modules/install/db_insert_locations.sql";
  127. if (file_exists($file)) {
  128. /*
  129. $fp = fopen($file, "r");
  130. $contents = fread($fp, filesize($file));
  131. fclose($fp);
  132. $querys = explode(";", trim($contents));
  133. */
  134. include_once($file);
  135. foreach ($querys as $val) if ($val) {
  136. if (!$db->qry("REPLACE INTO %prefix%locations (plz, breite, laenge) VALUES %plain%", $val)) $return_val = 0;
  137. }
  138. }
  139. }
  140. $db->free_result($find);
  141. } else $return_val = 1;
  142. return $return_val;
  143. // 0 = At least one create failed
  144. // 1 = Alreday existing
  145. // 2 = Create success
  146. }
  147. // Auto-Load Modules from XML-Files
  148. // And boxes
  149. function InsertModules($rewrite = false) {
  150. global $db, $xml, $func;
  151. // Tabelle Modules leeren um Module zu deinstallieren
  152. if($_GET["action"] == "wizard" and $_GET['step'] < 9) {
  153. $db->qry("TRUNCATE TABLE %prefix%modules");
  154. }
  155. $db->qry("TRUNCATE %prefix%plugin");
  156. $mod_list = array();
  157. $modules_dir = opendir("modules/");
  158. while ($module = readdir($modules_dir)) if ($module != "." AND $module != ".." AND $module != ".svn" AND is_dir("modules/$module")) {
  159. // module.xml
  160. $file = "modules/$module/mod_settings/module.xml";
  161. $ModActive = 0;
  162. if (file_exists($file)) {
  163. $handle = fopen ($file, "r");
  164. $xml_file = fread ($handle, filesize ($file));
  165. fclose ($handle);
  166. array_push($mod_list, $module);
  167. $name = $xml->get_tag_content("name", $xml_file);
  168. $caption = $xml->get_tag_content("caption", $xml_file);
  169. $description = $xml->get_tag_content("description", $xml_file);
  170. $author = $xml->get_tag_content("author", $xml_file);
  171. $email = $xml->get_tag_content("email", $xml_file);
  172. $active = $xml->get_tag_content("active", $xml_file);
  173. $changeable = $xml->get_tag_content("changeable", $xml_file);
  174. $version = $xml->get_tag_content("version", $xml_file);
  175. $state = $xml->get_tag_content("state", $xml_file);
  176. $requires = $xml->get_tag_content("requires", $xml_file);
  177. $reqPhp = $xml->get_tag_content("php", $requires);
  178. $reqMysql = $xml->get_tag_content("mysql", $requires);
  179. $ModActive = $active;
  180. $mod_found = $db->qry_first("SELECT 1 AS found FROM %prefix%modules WHERE name = %string%", $module);
  181. if ($name) {
  182. if (!$mod_found["found"]) $db->qry_first("REPLACE INTO %prefix%modules
  183. SET name=%string%, caption=%string%, description=%string%, author=%string%, email=%string%, active=%string%, changeable=%string%, version=%string%, state=%string%, reqphp=%string%, reqmysql=%string%",
  184. $name, $caption, $description, $author, $email, $active, $changeable, $version, $state, $reqPhp, $reqMysql);
  185. elseif ($rewrite) $db->qry_first("REPLACE INTO %prefix%modules
  186. SET name=%string%, caption=%string%, description=%string%, author=%string%, email=%string%, changeable=%string%, version=%string%, state=%string%, reqphp=%string%, reqmysql=%string%",
  187. $name, $caption, $description, $author, $email, $changeable, $version, $state, $reqPhp, $reqMysql);
  188. }
  189. }
  190. if ($ModActive or $func->isModActive($module)) {
  191. // config.xml
  192. $file = "modules/$module/mod_settings/config.xml";
  193. if (file_exists($file)) {
  194. $handle = fopen ($file, "r");
  195. $xml_file = fread ($handle, filesize ($file));
  196. fclose ($handle);
  197. $SettingList = array();
  198. $xml_config = $xml->get_tag_content('config', $xml_file);
  199. // Read types
  200. $xml_types = $xml->get_tag_content_array('typedefinition', $xml_config);
  201. if ($xml_types) while ($xml_type = array_shift($xml_types)) {
  202. $xml_head = $xml->get_tag_content('head', $xml_type);
  203. $name = $xml->get_tag_content('name', $xml_head);
  204. $db->qry("DELETE FROM %prefix%config_selections WHERE cfg_key = %string%", $name);
  205. $xml_entries = $xml->get_tag_content_array('entry', $xml_type);
  206. if ($xml_entries) while ($xml_entry = array_shift($xml_entries)) {
  207. $value = $xml->get_tag_content('value', $xml_entry);
  208. $description = $xml->get_tag_content('description', $xml_entry);
  209. if ($name != '' and $description != '') $db->qry("INSERT INTO %prefix%config_selections SET cfg_key = %string%, cfg_value = %string%, cfg_display = %string%",
  210. $name, $value, $description);
  211. }
  212. }
  213. // Read settings
  214. $xml_groups = $xml->get_tag_content_array('group', $xml_config);
  215. if ($xml_groups) while ($xml_group = array_shift($xml_groups)) {
  216. $xml_head = $xml->get_tag_content('head', $xml_group);
  217. $group = $xml->get_tag_content('name', $xml_head);
  218. $xml_items = $xml->get_tag_content_array('item', $xml_group);
  219. if ($xml_items) while ($xml_item = array_shift($xml_items)) {
  220. $name = $xml->get_tag_content('name', $xml_item);
  221. $type = $xml->get_tag_content('type', $xml_item);
  222. $default = $xml->get_tag_content('default', $xml_item);
  223. $description = $xml->get_tag_content('description', $xml_item);
  224. $pos = $xml->get_tag_content('pos', $xml_item);
  225. array_push($SettingList, $name);
  226. // Insert into DB, if not exists
  227. $found = $db->qry_first("SELECT cfg_key FROM %prefix%config WHERE cfg_key = %string%", $name);
  228. if (!$found['cfg_key']) $db->qry("INSERT INTO %prefix%config SET cfg_key = %string%, cfg_value = %string%, cfg_type = %string%, cfg_group = %string%, cfg_desc = %string%, cfg_module = %string%, cfg_pos = %int%",
  229. $name, $default, $type, $group, $description, $module, $pos);
  230. }
  231. }
  232. // Delete Settings from DB, which are no longer in the modules config.sql
  233. $settings_db = $db->qry("SELECT cfg_key FROM %prefix%config WHERE (cfg_module = %string%)", $module);
  234. while ($setting_db = $db->fetch_array($settings_db)) {
  235. if (!in_array($setting_db["cfg_key"], $SettingList)) $db->qry("DELETE FROM %prefix%config WHERE cfg_key = %string%", $setting_db["cfg_key"]);
  236. }
  237. }
  238. // boxes.xml
  239. $file = "modules/$module/boxes/boxes.xml";
  240. if (file_exists($file)) {
  241. $handle = fopen ($file, "r");
  242. $xml_file = fread ($handle, filesize ($file));
  243. fclose ($handle);
  244. ($module == 'install')? $modTmp = '' : $modTmp = $module;
  245. $boxes = $xml->get_tag_content_array("box", $xml_file);
  246. foreach ($boxes as $box) {
  247. $name = $xml->get_tag_content("name", $box);
  248. $place = $xml->get_tag_content("place", $box);
  249. $pos = $xml->get_tag_content("pos", $box);
  250. $active = $xml->get_tag_content("active", $box);
  251. $internet = $xml->get_tag_content("internet", $box);
  252. $login = $xml->get_tag_content("login", $box);
  253. $source = $xml->get_tag_content("source", $box);
  254. $callback = $xml->get_tag_content("callback", $box);
  255. $mod_found = $db->qry_first("SELECT 1 AS found FROM %prefix%boxes WHERE source = %string% AND module = %string%", $source, $modTmp);
  256. if ($rewrite or !$mod_found['found']) {
  257. $db->qry_first("DELETE FROM %prefix%boxes WHERE source = %string% AND module = %string%", $source, $modTmp);
  258. $db->qry_first("INSERT INTO %prefix%boxes
  259. SET name=%string%, place=%string%, pos=%string%, active=%string%, internet=%string%, login=%string%, source=%string%, callback=%string%, module=%string%",
  260. $name, $place, $pos, $active, $internet, $login, $source, $callback, $modTmp);
  261. }
  262. }
  263. }
  264. // plugins.xml
  265. $file = "modules/$module/plugins/plugins.xml";
  266. if (file_exists($file)) {
  267. $handle = fopen ($file, "r");
  268. $xml_file = fread ($handle, filesize ($file));
  269. fclose ($handle);
  270. $plugins = $xml->get_tag_content_array("plugin", $xml_file);
  271. foreach ($plugins as $plugin) {
  272. $name = $xml->get_tag_content("name", $plugin);
  273. $caption = $xml->get_tag_content("caption", $plugin);
  274. $icon = $xml->get_tag_content("icon", $plugin);
  275. $pos = $xml->get_tag_content("pos", $plugin);
  276. $db->qry("INSERT INTO %prefix%plugin SET module=%string%, pluginType=%string%, caption=%string%, pos=%int%, icon=%string%", $module, $name, $caption, $pos, $icon);
  277. }
  278. }
  279. // translation.xml
  280. $file = "modules/$module/mod_settings/translation.xml";
  281. if (file_exists($file)) {
  282. $handle = fopen ($file, "r");
  283. $xml_file = fread ($handle, filesize ($file));
  284. fclose ($handle);
  285. $entries = $xml->getTagContentArray("entry", $xml_file);
  286. foreach ($entries as $entry) {
  287. $id = $xml->getFirstTagContent("id", $entry);
  288. $org = $xml->getFirstTagContent("org", $entry, 1);
  289. $de = $xml->getFirstTagContent("de", $entry, 1);
  290. $en = $xml->getFirstTagContent("en", $entry, 1);
  291. $es = $xml->getFirstTagContent("es", $entry, 1);
  292. $fr = $xml->getFirstTagContent("fr", $entry, 1);
  293. $nl = $xml->getFirstTagContent("nl", $entry, 1);
  294. $it = $xml->getFirstTagContent("it", $entry, 1);
  295. $file = $xml->getFirstTagContent("file", $entry);
  296. if (strlen($org) > 255) $long = '_long'; else $long = '';
  297. // Insert only, if id-file combination does not exist
  298. $db->qry('INSERT INTO %prefix%translation%plain% SET
  299. id=%string%, file=%string%, org=%string%, de=%string%, en=%string%, es=%string%, fr=%string%, nl=%string%, it=%string%
  300. ON DUPLICATE KEY UPDATE id = id',
  301. $long, $id, $file, $org, $de, $en, $es, $fr, $nl, $it);
  302. }
  303. }
  304. }
  305. }
  306. // Delete non-existend Modules from DB
  307. $mods = $db->qry("SELECT name FROM %prefix%modules");
  308. while($row = $db->fetch_array($mods)) if (!in_array($row["name"], $mod_list)) $db->qry("DELETE FROM %prefix%modules WHERE name = %string%", $row["name"]);
  309. $db->free_result($mods);
  310. // Generate module table, so Lansuite knows, which modules need to be written
  311. $func->getActiveModules();
  312. }
  313. // Auto-Load Menuentries from XML-Files
  314. function InsertMenus($rewrite = false) {
  315. global $db, $xml, $func;
  316. if ($rewrite) $db->qry("TRUNCATE TABLE %prefix%menu");
  317. $menubox = $db->qry_first('SELECT boxid FROM %prefix%boxes WHERE source = \'menu\' AND active = 1');
  318. $modules_dir = opendir("modules/");
  319. while ($module = readdir($modules_dir)) if ($func->isModActive($module)) {
  320. $menu_found = $db->qry_first("SELECT 1 AS found FROM %prefix%menu WHERE module = %string%", $module);
  321. if (!$menu_found["found"]) {
  322. $file = "modules/$module/mod_settings/menu.xml";
  323. if (file_exists($file)) {
  324. $handle = fopen ($file, "r");
  325. $xml_file = fread ($handle, filesize ($file));
  326. fclose ($handle);
  327. $menu = $xml->get_tag_content("menu", $xml_file);
  328. $main_pos = $xml->get_tag_content("pos", $menu);
  329. $entrys = $xml->get_tag_content_array("entry", $menu);
  330. $i = 0;
  331. foreach ($entrys as $entry) {
  332. $action = $xml->get_tag_content("action", $entry);
  333. $file = $xml->get_tag_content("file", $entry);
  334. $caption = $xml->get_tag_content("caption", $entry);
  335. $hint = $xml->get_tag_content("hint", $entry);
  336. $link = $xml->get_tag_content("link", $entry);
  337. $requirement = $xml->get_tag_content("requirement", $entry);
  338. $level = $xml->get_tag_content("level", $entry);
  339. $needed_config = $xml->get_tag_content("needed_config", $entry);
  340. if ($file == "") $file = $action;
  341. if (!$level) $level = 0;
  342. if (!$requirement) $requirement = 0;
  343. ($level == 0)? $pos = $main_pos : $pos = $i;
  344. $i++;
  345. $db->qry_first("INSERT INTO %prefix%menu SET module=%string%, action=%string%, file=%string%, caption=%string%, hint=%string%, link=%string%, requirement=%string%, level=%string%, pos=%string%, needed_config=%string%, boxid=%int%",
  346. $module, $action, $file, $caption, $hint, $link, $requirement, $level, $pos, $needed_config, $menubox['boxid']);
  347. }
  348. }
  349. }
  350. }
  351. }
  352. // System prόfen
  353. function envcheck() {
  354. global $db, $dsp, $func;
  355. $continue = 1;
  356. // Environment Check
  357. $ok = "<span class=\"okay\">".t('Erfolgreich')."</span>" . HTML_NEWLINE;
  358. $failed = "<span class=\"error\">".t('Fehlgeschlagen')."</span>" . HTML_NEWLINE;
  359. $warning = "<span class=\"warning\">".t('Bedenkliche Einstellung')."</span>" . HTML_NEWLINE;
  360. $optimize = "<span class=\"warning\">".t('Optimierungsbedarf')."</span>" . HTML_NEWLINE;
  361. $not_possible = "<span class=\"warning\">".t('Leider nicht mφglich')."</span>" . HTML_NEWLINE;
  362. #### Critical ####
  363. $dsp->AddFieldSetStart("Kritisch - Diese Test mόssen alle erfolgreich sein, damit Lansuite funktioniert");
  364. // PHP-Version
  365. if (version_compare(phpversion(), "4.1.2") >= 0) $phpv_check = $ok . phpversion();
  366. else $phpv_check = $failed . t('Auf deinem System wurde die PHP-Version %1 gefunden. Lansuite benφtigt mindestens PHP Version 4.3.0. Du kannst zwar die Installation fortsetzen, allerdings kann keinerlei Garantie auf die ordnungsgemδίe Funktionsweise gegeben werden. Laden und installiere dir eine aktuellere Version von <a href=\'http://www.php.net\' target=\'_blank\'>www.php.net</a>.', phpversion());
  367. $dsp->AddDoubleRow("PHP Version", $phpv_check);
  368. // MySQL installed?
  369. if (extension_loaded("mysql") or extension_loaded("mysqli")) {
  370. $mysql_version = sprintf("%s\n", $db->client_info());
  371. if (!$mysql_version) $mysql_version = t('Unbekannt');
  372. $mysql_check = $ok . $mysql_version;
  373. } else {
  374. $mysql_check = $failed . t('Die MySQL-Erweiterung ist in PHP nicht geladen. Diese wird benφtigt um auf die Datenbank zuzugreifen. Bevor keine Datenbank verfόgbar ist, kann Lansuite nicht installiert werden. Den MySQL-Server gibt es unter <a href=\'http://www.mysql.com\' target=\'_blank\'>www.mysql.com</a> zum Download.');
  375. $continue = 0;
  376. }
  377. $dsp->AddDoubleRow("MySQL-Extention", $mysql_check);
  378. // config.php Rights
  379. $lansuite_conf = "inc/base/config.php";
  380. if (!file_exists($lansuite_conf)) $cfgfile_check = $failed . t('Die Datei <b>config.php</b> befindet sich <b>nicht</b> im Lansuite-Verzeichnis <b> inc/base/ </b>. Bitte όberprόfe die Datei auf korrekte Groί- und Kleinschreibung.');
  381. elseif (!is_writable($lansuite_conf)) $cfgfile_check = $failed . t('Die Datei <b>config.php</b> im Lansuite-Verzeichnis <b> inc/base/ </b> muss geschrieben werden kφnnen. Δndere bitte die Zugriffsrechte entsprechend. Dies kannst du mit den meisten guten FTP-Clients erledigen. Die Datei muss mindestens die Schreibrechte (chmod) 666 besitzen.');
  382. else $cfgfile_check = $ok;
  383. $dsp->AddDoubleRow(t('Schreibrechte auf die Konfigurationsdatei'), $cfgfile_check);
  384. if ($cfgfile_check != $ok) $continue = 0;
  385. // Ext_inc Rights
  386. $ext_inc = "ext_inc";
  387. if (!file_exists($ext_inc)) $ext_inc_check = $failed . t('Der Ordner <b>ext_inc</b> existiert <b>nicht</b> im Lansuite-Verzeichnis. Bitte όberprόfe den Pfad auf korrekte Groί- und Kleinschreibung. Lege den Ordner gegebenfalls bitte selbst an.');
  388. else {
  389. $ret = $this->IsWriteableRec($ext_inc);
  390. if ($ret != '') $ext_inc_check = $failed . t('In den Ordner <b>ext_inc</b> und alle seine Unterordner muss geschrieben werden kφnnen. Δnder bitte die Zugriffsrechte entsprechend. Dies kannst du mit den meisten guten FTP-Clients erledigen. Die Datei muss mindestens die Schreibrechte (chmod) 666 besitzen. Die folgenden Dateien besitzten noch keinen Schreibzugriff:'). '<br><b>'. $ret .'<b>';
  391. else $ext_inc_check = $ok;
  392. }
  393. $dsp->AddDoubleRow(t('Schreibrechte im Ordner \'ext_inc\''), $ext_inc_check);
  394. // Error Reporting
  395. if (error_reporting() <= (E_ALL ^ E_NOTICE)) $errreport_check = $ok;
  396. else $errreport_check = $warning . t('In deiner php.ini ist \'error_reporting\' so konfiguriert, dass auch unwichtige Fehlermeldungen angezeigt werden. Dies kann dazu fόhren, dass stφrende Fehlermeldungen in Lansuite auftauchen. Wir empfehlen diese Einstellung auf \'E_ALL ^ E_NOTICE\' zu δndern. In dieser Einstellung werden dann nur noch Fehler angezeigt, welche die Lauffδhigkeit des Skriptes beeintrδchtigen.');
  397. $dsp->AddDoubleRow("Error Reporting", $errreport_check);
  398. $dsp->AddFieldSetEnd();
  399. #### Warning ####
  400. $dsp->AddFieldSetStart("Warnungen - Lansuite kann trotz evtl. Fehler verwendet werden");
  401. // GD-Lib
  402. if (extension_loaded ('gd')){
  403. if (function_exists("gd_info")) {
  404. $GD = gd_info();
  405. if (!strstr($GD["GD Version"], "2.0")) $gd_check = $warning . t('Auf deinem System wurde das PHP-Modul <b>GD-Library</b> nur in der Version GD1 gefunden. Damit ist die Qualitδt der erzeugten Bilder wesentlich schlechter. Es wird deshalb empfohlen GD2 zu benutzen. Solltest du die Auswahl zwischen GD und GD2 haben, wδhle immer das neuere GD2. Du kannst die Installation jetzt fortfόhren, allerdings wirst du entsprechende Einschrδnkungen im Gebrauch machen mόssen.');
  406. elseif (!$GD["FreeType Support"]) $gd_check = $warning . t('Auf deinem System wurde das PHP-Modul <b>GD-Library</b> ohne Free-Type Support gefunden. Dadurch werden die Schriftarten in Grafiken (z.b. in den User-Avataren) nicht sehr schφn dargestellt. Du kannst die Installation jetzt fortfόhren, allerdings wirst du entsprechende Einschrδnkungen im Gebrauch machen mόssen.');
  407. else $gd_check = $ok;
  408. $gd_check .= '<table>';
  409. foreach ($GD as $key => $val) $gd_check .= '<tr><td class="content">'. $key .'</td><td class="content">'. $val .'</td></tr>';
  410. $gd_check .= '</table>';
  411. } else $gd_check = $warning . t('Auf deinem System wurde das PHP-Modul <b>GD-Library</b> nur in der Version GD1 gefunden. Damit ist die Qualitδt der erzeugten Bilder wesentlich schlechter. Es wird deshalb empfohlen GD2 zu benutzen. Solltest du die Auswahl zwischen GD und GD2 haben, wδhle immer das neuere GD2. Du kannst die Installation jetzt fortfόhren, allerdings wirst du entsprechende Einschrδnkungen im Gebrauch machen mόssen.');
  412. } else {
  413. $gd_check = $failed . t('Auf deinem System konnte das PHP-Modul <b>GD-Library</b> nicht gefunden werden. Durch diese Programmierbibliothek werden in Lansuite Grafiken, wie z.B. User-Avatare generiert. Ab PHP Version 4.3.0 ist die GD bereits in PHP enthalten. Solltest du PHP 4.3.0 installiert haben und diese Meldung dennoch erhalten, όberprόfe, ob das GD-Modul evtl. deaktiviert ist. In PHP Version 4.2.3 ist die GD nicht enthalten. Wenn du diese Version benutzen muss GD 2.0 separat heruntergeladen, installiert und in PHP einkompiliert werden. Solltest du Windows und PHP 4.2.3 benutzen, empfehlen wir auf PHP 4.3.0 umzusteigen, da du dir auf diese Weise viel Arbeit sparen. Solltest du die Auswahl zwischen GD und GD2 haben, wδhle immer das neuere GD2. Du kannst die Installation jetzt fortfόhren, allerdings wirst du erhebliche Einschrδnkungen im Gebrauch machen mόssen.');
  414. }
  415. $dsp->AddDoubleRow("GD Library", $gd_check);
  416. // Test Safe-Mode
  417. if (!ini_get("safe_mode")) $safe_mode = $ok;
  418. else $safe_mode = $not_possible . t('Auf deinem System ist die PHP-Einstellung <b>safe_mode</b> auf <b>On</b> gesetzt. safe_mode ist dazu gedacht, einige Systemfunktionen auf dem Server zu sperren um Angriffe zu verhindern (siehe dazu: <a href=\'http://de2.php.net/features.safe-mode\' target=\'_blank\'>www.php.net</a>). Doch leider benφtigen einige Lansuite-Module (speziell: LansinTV, Serverstatistiken oder das Server-Modul) Zugriff auf genau diese Funktionen. Du solltest daher, wenn du Probleme in diesen Modulen hast, in deiner <b>PHP.ini</b> die Option <b>safe_mode</b> auf <b>Off</b> setzen! <br />Auίer bei oben genannten Modulen, kann es bei aktiviertem safe_mode auίerdem auch zu Problemen bei dem Generieren von Buttons, wie dem am Ende dieser Seite kommen.');
  419. $dsp->AddDoubleRow("Safe Mode", $safe_mode);
  420. // Testing Safe-Mode and execution of system-programs
  421. if (!ini_get("safe_mode")) {
  422. if (stristr(strtolower($_SERVER['SERVER_SOFTWARE']) , "win") == ""){
  423. if (@shell_exec("cat /proc/uptime") == ""){
  424. $env_stats .= "<strong>/proc/uptime</strong>" . HTML_NEWLINE;
  425. }
  426. if (@shell_exec("/sbin/ifconfig") == "" and @shell_exec("/usr/sbin/ifconfig") == ""){
  427. $env_stats .= "<strong>ifconfig</strong>" . HTML_NEWLINE;
  428. }
  429. if (@shell_exec("cat /proc/loadavg") == ""){
  430. $env_stats .= "<strong>/proc/loadavg</strong>" . HTML_NEWLINE;
  431. }
  432. if (@shell_exec("cat /proc/cpuinfo") == ""){
  433. $env_stats .= "<strong>/proc/cpuinfo</strong>" . HTML_NEWLINE;
  434. }
  435. if (@shell_exec("cat /proc/meminfo") == ""){
  436. $env_stats .= "<strong>/proc/meminfo</strong>" . HTML_NEWLINE;
  437. }
  438. if ($env_stats == "") $server_stats = $ok;
  439. else $server_stats = $not_possible . str_replace("{FEHLER}", $env_stats, t('Auf ihrem System leider nicht mφglich. Der Befehl oder die Datei HTML_NEWLINE{FEHLER} wurde nicht gefunden. Evtl. sind nur die Berechtigungen der Datei nicht ausreichend gesetzt.'));
  440. $config["server_stats"]["status"] = 1;
  441. } else {
  442. system("modules\stats\ls_getinfo.exe", $status);
  443. if ($status == 0){
  444. $server_stats = $ok;
  445. } else {
  446. $env_stats = "<strong>modules/stats/ls_getinfo.exe</strong>" . HTML_NEWLINE;
  447. $server_stats = $not_possible . str_replace("{FEHLER}", $env_stats, t('Auf ihrem System leider nicht mφglich. Der Befehl oder die Datei HTML_NEWLINE{FEHLER} wurde nicht gefunden. Evtl. sind nur die Berechtigungen der Datei nicht ausreichend gesetzt.'));
  448. }
  449. }
  450. $dsp->AddDoubleRow("Server Stats", $server_stats);
  451. }
  452. # // Debug Backtrace
  453. # if (function_exists('debug_backtrace')) $debug_bt_check = $ok;
  454. # else $debug_bt_check = $warning . t('Die Funktion "Debug Backtrace" ist auf deinem System nicht vorhanden. Diese wird jedoch benφtigt, um άbersetzungs-Texte einem bestimmten Modul zuzuordnen. Solange du lansuite nur in Deutsch verwenden willst, sollte dies keine Auswirkung haben');
  455. # $dsp->AddDoubleRow('Debug Backtrace', $debug_bt_check);
  456. // SNMP-Lib
  457. if (extension_loaded('snmp')){
  458. $snmp_check = $ok;
  459. } else {
  460. $snmp_check = $not_possible . t('Auf deinem System konnte das PHP-Modul <b>SNMP-Library</b> nicht gefunden werden. SNMP ermφglicht es, auf Netzwerkdevices zuzugreifen, um detaillierte Informatioen όber diese zu liefern. Ohne diese Bibliothek kann das Lansuite-Modul <b> NOC </b> (Netzwerkόberwachung) nicht arbeiten. Das Modul NOC wird <b>automatisch deaktiviert</b>.');
  461. }
  462. $dsp->AddDoubleRow("SNMP Library", $snmp_check);
  463. // FTP-Lib
  464. if (extension_loaded('ftp')){
  465. $ftp_check = $ok;
  466. } else {
  467. $ftp_check = $not_possible . t('Auf deinem System konnte das PHP-Modul <b>FTP-Library</b> nicht gefunden werden. Dies hat zur Folge haben, dass das Download-Modul nur im Standard-Modus, jedoch nicht im FTP-Modus, verwendet werden kann');
  468. }
  469. $dsp->AddDoubleRow("FTP Library", $ftp_check);
  470. $dsp->AddFieldSetEnd();
  471. #### Information ####
  472. $dsp->AddFieldSetStart(t('Informationen - Interesante Server-Einstellungen im άberblick'));
  473. // Display System-Variables
  474. $dsp->AddFieldSetStart(t('Webserver'));
  475. if (function_exists('disk_total_space') and function_exists('disk_free_space')) $dsp->AddDoubleRow(t('Freier Speicherplatz'), $func->FormatFileSize(disk_free_space('.')) .' / '. $func->FormatFileSize(disk_total_space('.')));
  476. $dsp->AddFieldSetEnd();
  477. $dsp->AddFieldSetStart(t('PHP'));
  478. $dsp->AddDoubleRow('Max. Script-Execution-Time', (float)ini_get('max_execution_time') .' Sec');
  479. $dsp->AddDoubleRow('Max. Data-Input-Zeit', (float)ini_get('max_input_time') .' Sec');
  480. $dsp->AddDoubleRow('Memory Limit', (float)ini_get('memory_limit') .' MB');
  481. $post_max_size = (float)ini_get('post_max_size');
  482. if ($post_max_size > 1000) $post_max_size = $post_max_size / 1024; // For some PHP-Versions use KB, instead of MB
  483. $dsp->AddDoubleRow('Max. Post-Form Size', (float)ini_get('post_max_size') .' MB');
  484. $dsp->AddDoubleRow('Magic Quotes', get_magic_quotes_gpc());
  485. $dsp->AddFieldSetEnd();
  486. if ($db->success) {
  487. $dsp->AddFieldSetStart(t('MySQL'));
  488. // key_buffer_size
  489. $dsp->AddFieldSetStart(t('Key buffer size - MySQL empfiehlt fόr optimale Performance: 25% des Arbeitsspeichers. Oft reicht weniger.'));
  490. $res = $db->qry('SHOW variables LIKE "key_buffer_size"');
  491. while ($row = $db->fetch_array($res)) $dsp->AddDoubleRow($row[0], $row[1]);
  492. $db->free_result($res);
  493. $dsp->AddFieldSetEnd();
  494. // Key_blocks
  495. $dsp->AddFieldSetStart(t('Key blocks - Performance: Key_blocks_unused sollte niemals 0 erreichen! Wenn der Wert nahe 0 ist: key_buffer_size erhφhen'));
  496. $res = $db->qry('SHOW status LIKE "Key_blocks%"');
  497. while ($row = $db->fetch_array($res)) $dsp->AddDoubleRow($row[0], $row[1]);
  498. $db->free_result($res);
  499. $dsp->AddFieldSetEnd();
  500. // Query cache
  501. $dsp->AddFieldSetStart(t('Query cache - Beschleunigt MySQL-Abfragen. Sollte aktiv sein'));
  502. $res = $db->qry('SHOW VARIABLES LIKE \'have_query_cache\'');
  503. while ($row = $db->fetch_array($res)) $dsp->AddDoubleRow($row[0], $row[1]);
  504. $db->free_result($res);
  505. $res = $db->qry('SHOW STATUS LIKE \'Qcache%\'');
  506. while ($row = $db->fetch_array($res)) $dsp->AddDoubleRow($row[0], $row[1]);
  507. $db->free_result($res);
  508. $dsp->AddFieldSetEnd();
  509. $dsp->AddFieldSetEnd();
  510. }
  511. $dsp->AddFieldSetEnd();
  512. #### Information ####
  513. $dsp->AddFieldSetStart(t('Sicherheit - Diese Einstellungen sollten aus Security-Grόnden vorgenommen werden'));
  514. // Session Use Only Cookies
  515. if (ini_get('session.use_only_cookies')) $only_cookies_check = $ok;
  516. else $only_cookies_check = $warning . t('Es wird empfohlen session.use_only_cookies in der php.ini auf 1 zu setzen! Dies verhindert, dass Session-IDs in der URL angezeigt werden. Wenn dies nicht verhindert wird, kφnnen unvorsichtige Benutzer, deren Browser keine Cookies zulassen, durch weiterleiten der URL an Dritte ihre Session preisgeben, was einer Weitergabe des Passwortes gleichkommt.');
  517. $dsp->AddDoubleRow("Session.use_only_cookies", $only_cookies_check);
  518. $dsp->AddFieldSetEnd();
  519. #### Performace ####
  520. $dsp->AddFieldSetStart("Performace - Hier kannst du ansetzen um die Performace deines Servers zu optimieren");
  521. // Register Globals
  522. if (ini_get('register_globals') == FALSE) $check = $ok;
  523. else $check = $optimize . t('Auf deinem System ist die PHP-Einstellung register_globals auf On gesetzt. Dabei muss PHP mehr Speicher fόr Globale Variablen belegen, als eigentlich fόr Lansuite notwendig. Du kannst diese Einstellung in der php.ini δndern. Vergessis nicht deinen Webserver nach dieser Δnderung neu zu starten.');
  524. $dsp->AddDoubleRow("Register Globals", $check);
  525. if (ini_get('expose_php') == FALSE) $check = $ok;
  526. else $check = $optimize . t('Auf deinem System ist die PHP-Einstellung expose_php auf On gesetzt. Diese Einstellung fόgt - wenn sie auf On steht - jedem HTTP-Response einen Headereintrag hinzu, dass die Seite mit PHP erstellt wurde. Das ist unnφtig, denn deine Besucher interessiert das sowieso nicht und aus Performancesicht muss der hinzugefόgte Headereintrag natόrlich mit zum Client όbertragen werden. Also besser auf Off stellen.');
  527. $dsp->AddDoubleRow("Expose PHP", $check);
  528. if (ini_get('register_argc_argv') == FALSE) $check = $ok;
  529. else $check = $optimize . t('Auf deinem System ist die PHP-Einstellung register_argc_argv auf On gesetzt. Diese Einstellung ist nur nόtzlich, wenn man PHP όber die Kommandozeile aufruft und dort Parameter mitgeben mφchte. Das ist fόr Lansuite nicht notwendig und belegt unnφtig Speicher');
  530. $dsp->AddDoubleRow("Register_argc_argv", $check);
  531. $dsp->AddFieldSetEnd();
  532. $dsp->AddFieldSetEnd();
  533. return $continue;
  534. }
  535. // Scans all db.xml-files and deletes all tables listed in them
  536. // This meens lansuite is not able to clean up tables, which changed their name during versions
  537. // But this is much safer than DROP DATABASE, for this clean methode would drop other web-systems using the same DB table, too
  538. function DeleteAllTables () {
  539. global $xml, $db;
  540. $modules_dir = opendir("modules/");
  541. while ($module = readdir($modules_dir)) if ($module != "." AND $module != ".." AND $module != ".svn" AND is_dir("modules/$module")) {
  542. $file = "modules/$module/mod_settings/db.xml";
  543. if (file_exists($file)) {
  544. $handle = fopen ($file, "r");
  545. $xml_file = fread ($handle, filesize ($file));
  546. fclose ($handle);
  547. $tables = $xml->get_tag_content_array("table", $xml_file);
  548. foreach ($tables as $table) {
  549. $table_head = $xml->get_tag_content("table_head", $table, 0);
  550. $table_name = $xml->get_tag_content("name", $table_head);
  551. $db->qry_first("DROP TABLE IF EXISTS %prefix%%plain%", $table_name);
  552. }
  553. }
  554. }
  555. }
  556. function check_updates(){
  557. /*
  558. include("modules/install/class_update.php");
  559. $update = new update();
  560. // Check update for Version 2.0.2
  561. $file = "modules/install/update/update202.php";
  562. if(file_exists($file)) include($file);
  563. */
  564. }
  565. function getModConfigLine($row, $showLinks = 1) {
  566. global $smarty, $db;
  567. $smarty->assign('name', $row['name']);
  568. $smarty->assign('caption', $row['caption']);
  569. $smarty->assign('description', $row['description']);
  570. $smarty->assign('version', $row["version"]);
  571. if ($row["email"]) $author = "<a href=\"mailto:{$row["email"]}\">{$row["author"]}</a>";
  572. else $author = $row["author"];
  573. $smarty->assign('author', $author);
  574. if ($row["reqphp"] or $row["reqmysql"]) {
  575. $req = '<br /><u>'. t('Benφtigt') .'</u>: ';
  576. if ($row["reqphp"]) $req .= 'PHP >= '. $row["reqphp"] .' ';
  577. if ($row["reqmysql"]) $req .= 'MySQL >= '. $row["reqmysql"] .' ';
  578. } else $req = '';
  579. $smarty->assign('req', $req);
  580. $active = '';
  581. if ($row["active"]) $active = ' checked="checked"';
  582. $smarty->assign('active', $active);
  583. $changeable = '';
  584. if (!$row["changeable"]) $changeable = ' disabled';
  585. $smarty->assign('changeable', $changeable);
  586. ($row["state"] == "Stable")? $state = $row["state"] : $state = "<font color=\"red\">{$row["state"]}</font>";
  587. $smarty->assign('state', $state);
  588. (file_exists("modules/{$row["name"]}/icon.gif"))? $img = "modules/{$row["name"]}/icon.gif" : $img = "modules/sample/icon.gif";
  589. $smarty->assign('img', $img);
  590. $smarty->assign('showLinks', $showLinks);
  591. if ($showLinks) {
  592. $find_config = $db->qry_first("SELECT cfg_key FROM %prefix%config WHERE (cfg_module = %string%)", $row["name"]);
  593. if ($find_config["cfg_key"] != '') $settings_link = " | <a href=\"index.php?mod=install&action=mod_cfg&step=10&module={$row["name"]}\">". t('Konfig.') ."</a>";
  594. else $settings_link = "";
  595. $smarty->assign('settings_link', $settings_link);
  596. $find_mod = $db->qry_first("SELECT module FROM %prefix%menu WHERE module=%string%", $row["name"]);
  597. if ($find_mod["module"]) $menu_link = " | <a href=\"index.php?mod=install&action=mod_cfg&step=30&module={$row["name"]}\">". t('Menό') ."</a>";
  598. else $menu_link = "";
  599. $smarty->assign('menu_link', $menu_link);
  600. if (file_exists("modules/{$row["name"]}/mod_settings/db.xml")) $db_link = " | <a href=\"index.php?mod=install&action=mod_cfg&step=40&module={$row["name"]}\">". t('DB') ."</a>";
  601. else $db_link = "";
  602. $smarty->assign('db_link', $db_link);
  603. if (file_exists("modules/{$row["name"]}/docu/{$language}_help.php")) $help_link = " | <a href=\"#\" onclick=\"javascript:var w=window.open('index.php?mod=helplet&action=helplet&design=base&module={$row["name"]}&helpletid=help','_blank','width=700,height=500,resizable=no,scrollbars=yes');\" class=\"Help\">?</a>";
  604. else $help_link = '';
  605. $smarty->assign('help_link', $help_link);
  606. }
  607. return $smarty->fetch('modules/install/templates/module.htm');
  608. }
  609. }
  610. ?>