XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
page_configsave.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
29 require_once './include/common.inc.php';
30 defined('XOOPS_INSTALL') or die('XOOPS Installation wizard die');
31 
33 $pageHasHelp = false;
34 
35 $vars =& $_SESSION['settings'];
36 
37 if (empty($vars['ROOT_PATH'])) {
38  $wizard->redirectToPage('pathsettings');
39  exit();
40 } else if (empty($vars['DB_HOST'])) {
41  $wizard->redirectToPage('dbsettings');
42  exit();
43 }
44 
45 $error = '';
46 if (!@copy($vars['ROOT_PATH'] . '/mainfile.dist.php', $vars['ROOT_PATH'] . '/mainfile.php')) {
48 } else {
49  clearstatcache();
50 
51  $rewrite = array( 'GROUP_ADMIN' => 1,
52  'GROUP_USERS' => 2,
53  'GROUP_ANONYMOUS' => 3
54  );
55 
56  $rewrite = array_merge($rewrite, $vars);
57  if (!$file = fopen($vars['ROOT_PATH'] . '/mainfile.php', "r")) {
59  } else {
60  $content = fread($file, filesize( $vars['ROOT_PATH'] . '/mainfile.php'));
61  fclose($file);
62 
63  foreach ($rewrite as $key => $val) {
64  if ($key == 'authorized') continue;
65  if (is_int($val) && preg_match("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([0-9]+)\s*\)/", $content)) {
66  $content = preg_replace("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([0-9]+)\s*\)/", "define('XOOPS_{$key}', {$val})", $content);
67  } else if(preg_match("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([\"'])(.*?)\\4\s*\)/", $content)) {
68  $val = str_replace('$', '\$', addslashes($val));
69  $content = preg_replace("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([\"'])(.*?)\\4\s*\)/", "define('XOOPS_{$key}', '{$val}')", $content);
70  } else {
71  //$this->error = true;
72  //$this->report .= _NGIMG.sprintf( ERR_WRITING_CONSTANT, "<strong>$val</strong>")."<br />\n";
73  }
74  }
75  if (!$file = fopen( $vars['ROOT_PATH'] . '/mainfile.php', "w")) {
77  } else {
78  if (fwrite( $file, $content ) == -1) {
80  }
81  fclose($file);
82  }
83  }
84 }
85 
86 //if (!@copy($rewrite['VAR_PATH'] . '/data/secure.dist.php', $rewrite['VAR_PATH'] . '/data/secure.php')) {
87 // $error = ERR_COPY_MAINFILE.$rewrite['VAR_PATH'] . '/data/secure.dist.php';
88 //} else {
89 // clearstatcache();
90 
91 //from XavierS:
92 if (!@copy($vars['VAR_PATH'] . '/data/secure.dist.php', $vars['VAR_PATH'] . '/data/secure.php')) {
93  $error = ERR_COPY_MAINFILE.$vars['VAR_PATH'] . '/data/secure.dist.php';
94  } else {
95  clearstatcache();
96 
97 
98  $rewrite = array_merge($rewrite, $vars);
99 
100  $rewrite = array_merge($rewrite, $vars);
101  if (!$file = fopen($rewrite['VAR_PATH'] . '/data/secure.php', "r")) {
103  } else {
104  $content = fread($file, filesize( $rewrite['VAR_PATH'] . '/data/secure.php'));
105  fclose($file);
106 
107  foreach ($rewrite as $key => $val) {
108  if ($key == 'authorized') continue;
109  if (is_int($val) && preg_match("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([0-9]+)\s*\)/", $content)) {
110  $content = preg_replace("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([0-9]+)\s*\)/", "define('XOOPS_{$key}', {$val})", $content);
111  } else if(preg_match("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([\"'])(.*?)\\4\s*\)/", $content)) {
112  $val = str_replace('$', '\$', addslashes($val));
113  $content = preg_replace("/(define\()([\"'])(XOOPS_{$key})\\2,\s*([\"'])(.*?)\\4\s*\)/", "define('XOOPS_{$key}', '{$val}')", $content);
114  }
115  }
116  if (!$file = fopen( $rewrite['VAR_PATH'] . '/data/secure.php', "w")) {
118  } else {
119  if (fwrite( $file, $content ) == -1) {
121  }
122  fclose($file);
123  }
124  }
125 }
126 
127 $_SESSION['settings']['authorized'] = false;
128 if (empty($error)) {
129  $_SESSION['UserLogin'] = true;
130  $_SESSION['settings']['authorized'] = true;
131  ob_start();
132 ?>
133 
134 <div class="caption"><?php echo SAVED_MAINFILE; ?></div>
135 <div class='x2-note confirmMsg'><?php echo SAVED_MAINFILE_MSG; ?></div>
136 <ul class='diags'>
137  <?php
138  foreach ($vars as $k => $v) {
139  if ($k == 'authorized') continue;
140  echo "<li><strong>XOOPS_{$k}</strong> " . IS_VALOR . " {$v}</li>";
141  }
142  ?>
143 </ul>
144 <?php
145  $content = ob_get_contents();
146  ob_end_clean();
147 } else {
148  $content = '<div class="errorMsg">' . $error . '</div>';
149 }
150 include './include/install_tpl.php';
151 ?>