PageRenderTime 62ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/setup/upgrade.php

http://phpwcms.googlecode.com/
PHP | 343 lines | 318 code | 16 blank | 9 comment | 11 complexity | 8d643155a7dc81045f2a268cdde2b634 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, ISC, MIT, LGPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.0, BSD-3-Clause
  1. <?php
  2. /**
  3. * phpwcms content management system
  4. *
  5. * @author Oliver Georgi <oliver@phpwcms.de>
  6. * @copyright Copyright (c) 2002-2013, Oliver Georgi
  7. * @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2
  8. * @link http://www.phpwcms.de
  9. *
  10. **/
  11. $phpwcms = array();
  12. $_this_path = realpath(dirname(__FILE__).'/../');
  13. if(is_file($_this_path.'/config/phpwcms/conf.inc.php')) {
  14. require_once ($_this_path.'/config/phpwcms/conf.inc.php');
  15. } else {
  16. die('Please proof location of "conf.inc.php".');
  17. }
  18. if (!defined('PHPWCMS_INCLUDE_CHECK')) {
  19. define('PHPWCMS_INCLUDE_CHECK', true);
  20. }
  21. require_once ($_this_path.'/include/inc_lib/default.inc.php');
  22. require_once (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php');
  23. require_once (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php');
  24. require_once (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php');
  25. require_once (PHPWCMS_ROOT.'/setup/inc/upgrade.func.inc.php');
  26. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  27. <html xmlns="http://www.w3.org/1999/xhtml">
  28. <head>
  29. <title>Upgrade phpwcms</title>
  30. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  31. <link href="inc/install.css" rel="stylesheet" type="text/css" />
  32. <style type="text/css">
  33. <!--
  34. body {
  35. padding: 0 15px 15px 15px;
  36. margin: 0;
  37. }
  38. -->
  39. </style>
  40. </head>
  41. <body>
  42. <table width="770" border="0" align="center" cellpadding="0" cellspacing="0" summary="">
  43. <tr>
  44. <td colspan="3"><img src="../img/leer.gif" alt="[beliebiger Wert]" width="1" height="7" /></td>
  45. </tr>
  46. <tr>
  47. <td colspan="3"><img src="../img/leer.gif" alt="" width="15" height="1" /><a href="http://www.phpwcms.de" target="_blank"><img src="../img/backend/backend_r1_c3.jpg" alt="phpwcms" width="95" height="24" border="0" /></a></td>
  48. </tr>
  49. <tr>
  50. <td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="7" /></td>
  51. </tr>
  52. <tr bgcolor="#FFFFFF">
  53. <td valign="top" style="background-image:url(../img/backend/backend_r3_c4.jpg); background-repeat:repeat-x; "><img src="../img/backend/backend_r3_c1.jpg" alt="" width="15" height="40" /></td>
  54. <td valign="top" style="background-image:url(../img/backend/backend_r3_c4.jpg); background-repeat:repeat-x; "><table width="740" border="0" cellpadding="0" cellspacing="0" summary="">
  55. <tr>
  56. <td colspan="2"><img src="../img/leer.gif" alt="" width="1" height="9" /></td>
  57. </tr>
  58. <tr>
  59. <td valign="top" class="navtext">PHPWCMS UPGRADE VERSION&nbsp;<?php echo $phpwcms['release'].', RELEASE '.$phpwcms['release_date'] ?></td>
  60. <td align="right" valign="top" class="navtext"><a href="../index.php" target="_top">HOME</a> |
  61. <a href="setup.php">SETUP</a> | <a href="index.php" target="_top">LICENCE</a> | <a href="<?php echo PHPWCMS_URL.get_login_file() ?>" target="_top">LOGIN</a></td>
  62. </tr>
  63. </table></td>
  64. <td valign="top" style="background-image:url(../img/backend/backend_r3_c4.jpg); background-repeat:repeat-x; "><img src="../img/backend/backend_r3_c7.jpg" alt="" width="15" height="40" /></td>
  65. </tr>
  66. <tr bgcolor="#FFFFFF">
  67. <td width="15" bgcolor="#FFFFFF" style="background-image:url(../img/backend/preinfo2_r7_c2.gif);background-repeat:repeat-y;"><img src="../img/leer.gif" alt="" width="15" height="1" /></td>
  68. <td valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:1px dotted #7599BB;" summary="">
  69. <tr>
  70. <td colspan="4"><img src="../img/leer.gif" alt="" width="1" height="6" /></td>
  71. </tr>
  72. <tr>
  73. <td width="6" rowspan="10"><img src="../img/leer.gif" alt="" width="6" height="1" /></td>
  74. <td align="right" class="chatlist">&nbsp;system:&nbsp;</td>
  75. <td class="chatlist" width="100%"><?php echo php_uname() ?></td>
  76. <td width="6" rowspan="10"><img src="../img/leer.gif" alt="" width="6" height="1" /></td>
  77. </tr>
  78. <tr>
  79. <td align="right" class="chatlist">server:&nbsp;</td>
  80. <td class="chatlist"><?php echo $_SERVER['SERVER_SOFTWARE'] ?></td>
  81. </tr>
  82. <tr>
  83. <td align="right" class="chatlist">php:&nbsp;</td>
  84. <td class="chatlist">v<?php echo PHP_VERSION ?></td>
  85. </tr>
  86. <tr>
  87. <td align="right" class="chatlist">mysql:&nbsp;</td>
  88. <td class="chatlist"><?php echo mysql_get_client_info() ?> (is just client information, server might be different)</td>
  89. </tr>
  90. <tr>
  91. <td align="right" class="chatlist">path:&nbsp;</td>
  92. <td class="chatlist"><?php echo html_specialchars(str_replace("\\", '/', preg_replace('/\/setup$/','', dirname(__FILE__)))); ?></td>
  93. </tr>
  94. <tr>
  95. <td align="right" class="chatlist">php.ini:&nbsp;</td>
  96. <td class="chatlist"><?php
  97. if(ini_get('register_globals')) {
  98. echo 'register_globals = On -&gt; should always be set Off because of <a href="http://phpsec.org/projects/guide/1.html#1.3" target="_blank" style="text-decoration:underline">security risks</a>';
  99. } else {
  100. echo 'register_globals = Off -&gt; that\'s good :)';
  101. }
  102. ?></td>
  103. </tr>
  104. <tr>
  105. <td align="right" class="chatlist">&nbsp;</td>
  106. <td class="chatlist"><?php
  107. if(ini_get('safe_mode')) {
  108. echo 'safe_mode = On -&gt; you have limited permissions, you might not be able to use ImageMagick';
  109. } else {
  110. echo 'safe_mode = Off -&gt; good when you want to use ImageMagick, may have some <a href="http://phpsec.org/" target="_blank" style="text-decoration:underline">security risks</a>';
  111. }
  112. ?></td>
  113. </tr>
  114. <tr>
  115. <td align="right" class="chatlist">&nbsp;</td>
  116. <td class="chatlist">GD = <?php
  117. $_phpinfo = parsePHPModules();
  118. if(isset($_phpinfo['gd']['GD Support']) && $_phpinfo['gd']['GD Support'] == 'enabled') {
  119. echo 'On';
  120. echo isset($_phpinfo['gd']['GD Version']) ? ' -&gt; '.$_phpinfo['gd']['GD Version'] : '';
  121. } else {
  122. echo 'Off';
  123. }
  124. ?></td>
  125. </tr>
  126. <tr>
  127. <td colspan="2" class="chatlist"><img src="../img/leer.gif" alt="" width="1" height="6" /></td>
  128. </tr>
  129. <tr>
  130. <td colspan="2" class="chatlist"><div id="warning">
  131. <p><strong>ATTENTION! </strong>Before you start updating &#8212; <strong>backup</strong> all
  132. phpwcms files AND all databases. Sometimes it might be better you merge SQL
  133. files manually. Don't forget to make copies of CSS files, templates,
  134. images, settings and custom scripts.</p>
  135. </div></td>
  136. </tr>
  137. <tr>
  138. <td colspan="4"><img src="../img/leer.gif" alt="" width="1" height="6" /></td>
  139. </tr>
  140. </table>
  141. <h1>When upgrading from releases older than 1.1.9:</h1>
  142. <p> There are some deeper changes. After upgrading db frame the following<br />
  143. files needs to be processed.<br />
  144. 1) <a href="upgrade_filestorage.php" target="_blank"><strong>UPGRADE FILESTORAGE</strong></a> (all
  145. files will be moved and renamed)<br />
  146. 2) <a href="upgrade_articleimages.php" target="_blank"><strong>UPGRADE ARTICLE
  147. CONTENT IMAGE</strong></a><br />
  148. 3) <a href="upgrade_articleimagelist.php" target="_blank"><strong>UPGRADE ARTICLE
  149. CONTENT IMAGELIST</strong></a><br />
  150. 4) <a href="upgrade_articleimg.php" target="_blank"><strong>UPGRADE ARTICLE
  151. SUMMARY IMAGE</strong></a></p>
  152. <h1>When upgrading from releases older than 1.2.9:</h1>
  153. <p>5) <a href="upgrade_pagelayout.php" target="_blank"><strong>UPGRADE PAGELAYOUT</strong></a></p>
  154. <h1>When upgrading from releases older than 1.3.1:</h1>
  155. <p>6) <a href="upgrade_multimedia.php" target="_blank"><strong>UPGRADE CONTENT PART MULTIMEDIA</strong></a></p>
  156. <p>7) <a href="upgrade_articlealias.php" target="_blank"><strong>UPDATE ARTICLE ALIAS</strong></a></p>
  157. <h1>Update old default article end date 2010-12-31, 23:59:59:</h1>
  158. <p>8) <a href="upgrade_articledate.php" target="_blank"><strong>SET ARTICLE END 2010-12-31, 23:59:59 plus 20 YEARS</strong></a></p>
  159. <?php
  160. $do = 0;
  161. if(isset($_POST['sqlfile']) && isset($_GET["do"]) && $_GET["do"] == "upgrade") {
  162. $file = str_replace('inc/showsql.php?f=', '', slweg($_POST['sqlfile']));
  163. if(file_exists("update_sql/".$file)) {
  164. $do = 1;
  165. }
  166. }
  167. if($do) {
  168. @mysql_query('SET storage_engine=MYISAM', $db);
  169. if($phpwcms['db_version'] > 40100) {
  170. $value = "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'";
  171. @mysql_query($value, $db);
  172. $value = "SET NAMES '".$phpwcms['db_charset']."'".(empty($phpwcms['db_collation']) ? '' : " COLLATE '".$phpwcms['db_collation']."'");
  173. @mysql_query($value, $db);
  174. }
  175. $sql_data = read_textfile("update_sql/".$file);
  176. $sql_data = preg_replace("/#.*.\n/", "", $sql_data );
  177. $sql_data = preg_replace("/ `phpwcms/", " `".DB_PREPEND."phpwcms", $sql_data );
  178. $sql = explode(";", $sql_data);
  179. echo '<div id="license" style="width:550px">';
  180. echo '<p><a href="upgrade.php">Chosse another SQL file...</a></p>';
  181. echo '<pre>';
  182. foreach($sql as $key => $value) {
  183. $value = trim($value);
  184. if(!$value) {
  185. unset($sql[$key]);
  186. } else {
  187. if($phpwcms['db_version'] > 40100 && $phpwcms['db_charset']=='utf8') {
  188. $value = utf8_encode($value);
  189. }
  190. if(!mysql_query($value)) echo '<span class="error">ERROR: '.html_entities(@mysql_error())." -&gt; </span>";
  191. echo html_specialchars($value).";\n";
  192. }
  193. }
  194. echo '</pre></div>';
  195. } else {
  196. ?>
  197. <form action="upgrade.php?do=upgrade" method="post" name="form1" id="form1">
  198. <p><strong>Please proof!</strong> Upgrade script will use following data:</p>
  199. <table border="0" cellpadding="0" cellspacing="0" class="sqlselect" summary="">
  200. <?php
  201. if(empty($phpwcms['db_charset']) || empty($phpwcms['db_collation']) || empty($phpwcms['db_version'])) {
  202. ?>
  203. <tr bgcolor="#FFFFFF">
  204. <td align="right" valign="top">MySQL basics:</td>
  205. <td style="color:#FFFFFF;background-color: #CC3300;" valign="top">
  206. <strong>Before you continue proof the following config settings:</strong><br />
  207. $phpwcms['db_charset']<br />
  208. $phpwcms['db_collation']<br />
  209. $phpwcms['db_version']<br />
  210. If you are not sure how to handle this <br />
  211. try to start setup process! <br />
  212. <strong>But STOP SETUP BEFORE SQL IMPORT!!!</strong> </td>
  213. </tr>
  214. <?php
  215. }
  216. ?>
  217. <tr bgcolor="#FFFFFF">
  218. <td align="right">MySQL host:</td>
  219. <td style="font-weight:bold; "><?php echo $phpwcms["db_host"] ?></td>
  220. </tr>
  221. <tr bgcolor="#FFFFFF">
  222. <td align="right">Database:</td>
  223. <td style="font-weight:bold; "><?php echo $phpwcms["db_table"] ?></td>
  224. </tr>
  225. <tr bgcolor="#FFFFFF">
  226. <td align="right">DB user:</td>
  227. <td style="font-weight:bold; "><?php echo $phpwcms["db_user"] ?></td>
  228. </tr>
  229. <tr bgcolor="#FFFFFF">
  230. <td align="right">DB table prefix:</td>
  231. <td style="font-weight:bold; "><?php echo $phpwcms["db_prepend"] ?>&nbsp;</td>
  232. </tr>
  233. <tr bgcolor="#FFFFFF">
  234. <td align="right">&nbsp;select&nbsp;SQL&nbsp;file:</td>
  235. <td><select name="sqlfile" id="sqlfile" onchange="window.open(this.options[this.selectedIndex].value,'sqlqueries')">
  236. <option value="inc/showsql.php" style="font-weight:bold; font-style:italic;">Please select&#8230;</option>
  237. <?php
  238. $dir = 'update_sql';
  239. if(is_dir($dir)) {
  240. $ph = opendir($dir);
  241. $dir_sql = array();
  242. while($pf = readdir($ph)) {
  243. if( $pf != '.' && $pf != '..' && !is_dir($dir.'/'.$pf) && preg_match('/(\.sql)$/', strtolower($pf)) )
  244. {
  245. $dir_sql[] = html_specialchars($pf);
  246. }
  247. }
  248. closedir($ph);
  249. natsort($dir_sql);
  250. foreach($dir_sql as $pf) {
  251. echo '<option value="inc/showsql.php?f='.$pf.'">'.$pf."</option>\n";
  252. }
  253. }
  254. ?>
  255. </select></td>
  256. </tr>
  257. </table>
  258. <p style="margin-top:5px;"><strong>SQL queries to be processed:</strong></p>
  259. <iframe name="sqlqueries" id="sqlqueries" frameborder="0" scrolling="auto" src="inc/showsql.php"></iframe>
  260. <p><input name="submit" type="submit" value="Upgrade database" /></p>
  261. </form>
  262. <?php
  263. }
  264. ?>
  265. </td>
  266. <td width="15" bgcolor="#FFFFFF" style="background-image:url(../img/backend/preinfo2_r7_c7.gif);background-repeat:repeat-y;background-position:right;"><img src="../img/leer.gif" alt="" width="15" height="1" /></td>
  267. </tr>
  268. <tr>
  269. <td><img src="../img/backend/backend_a_r1_c1.gif" alt="" width="15" height="15" border="0" /></td>
  270. <td valign="bottom" bgcolor="#FFFFFF" class="navtext"><img src="../img/backend/backend_r6_c2.jpg" alt="" width="740" height="15" border="0" /></td>
  271. <td valign="bottom" class="navtext"><img src="../img/backend/backend_a_r1_c7.gif" alt="" width="15" height="15" border="0" /></td>
  272. </tr>
  273. <tr>
  274. <td width="15"><img src="../img/leer.gif" alt="" width="14" height="20" /></td>
  275. <td colspan="2" valign="bottom" class="navtext">
  276. <a href="http://www.phpwcms.de" target="_blank">phpwcms</a>
  277. &copy; 2003&#8212;<?php echo date('Y') ?>
  278. <a title="oliver at phpwcms dot de" onclick="location.href='mailto:oliver'+'@'+'phpwcms'+'.'+'de';return false;" href="#">Oliver Georgi</a>.
  279. Licensed under <a href="http://www.gnu.org/licenses/gpl.html" target="_blank">GPL</a>.
  280. Extensions are copyright of their respective owners.</td>
  281. </tr>
  282. <tr>
  283. <td colspan="3"><img src="../img/leer.gif" alt="" width="1" height="8" /></td>
  284. </tr>
  285. </table>
  286. </body>
  287. </html>