3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2007 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * @license http://nucleuscms.org/license.txt GNU General Public License
14 * @copyright Copyright (C) 2002-2007 The Nucleus Group
15 * $NucleusJP: upgrade0.96.php,v 1.3.2.1 2007/10/24 05:39:15 kimitake Exp $
19 function upgrade_do96() {
21 if (upgrade_checkinstall(96))
24 // 1. create nucleus_actionlog
25 if (!upgrade_checkIfTableExists('actionlog')) {
26 $query = 'CREATE TABLE '.sql_table('actionlog')." (timestamp datetime NOT NULL default '0000-00-00 00:00:00', message varchar(255) NOT NULL default '', PRIMARY KEY (timestamp)) TYPE=MyISAM;";
27 upgrade_query("Creating nucleus_actionlog table",$query);
30 // 2. create nucleus_ban
31 if (!upgrade_checkIfTableExists('ban')) {
32 $query = 'CREATE TABLE '.sql_table('ban')." ( iprange varchar(15) NOT NULL default '', reason varchar(255) NOT NULL default '', blogid int(11) NOT NULL default '0') TYPE=MyISAM;";
33 upgrade_query("Creating nucleus_ban table",$query);
36 // 3. add ikarma to nucleus_item
37 if (!upgrade_checkIfColumnExists('item','ikarma')) {
38 $query = 'ALTER TABLE '.sql_table('item')
39 . " ADD ikarma int(11) NOT NULL default '0'";
40 upgrade_query("Adding karma-votes to items",$query);
43 // 4. create nucleus_karma
44 if (!upgrade_checkIfTableExists('karma')) {
45 $query = 'CREATE TABLE '.sql_table('karma')." ("
46 ." itemid int(11) NOT NULL default '0',"
47 ." ip char(15) NOT NULL default ''"
49 upgrade_query("Creating nucleus_karma table",$query);
52 // 5. nucleus_config: add MediaURL, AllowedTypes, AllowLoginEdit, AllowUpload
54 // create MediaURL out of IndexURL
55 $mediaURL = $CONF['IndexURL'] . "media/";
57 if (!upgrade_checkIfCVExists('MediaURL')) {
58 $query = 'INSERT INTO '.sql_table('config')." VALUES ('MediaURL', '$mediaURL');";
59 upgrade_query("New setting MediaURL",$query);
61 if (!upgrade_checkIfCVExists('AllowedTypes')) {
62 $query = 'INSERT INTO '.sql_table('config')." VALUES ('AllowedTypes', 'jpg,jpeg,gif,mpg,mpeg,avi,mov,mp3,swf,png');";
63 upgrade_query("New setting AllowedTypes",$query);
65 if (!upgrade_checkIfCVExists('AllowLoginEdit')) {
66 $query = 'INSERT INTO '.sql_table('config')." VALUES ('AllowLoginEdit', '0');";
67 upgrade_query("New setting AllowLoginEdit",$query);
69 if (!upgrade_checkIfCVExists('AllowUpload')) {
70 $query = 'INSERT INTO '.sql_table('config')." VALUES ('AllowUpload', '1');";
71 upgrade_query("New setting AllowUpload",$query);
74 //The following blocks (6 and 7) should check for existing values and only update as needed.
75 // 6. add 'imagepopup' skincontents in skin 'default'
77 $query = 'SELECT sdnumber FROM '.sql_table('skin_desc')." WHERE sdname='default'";
78 $res = sql_query($query);
79 $obj = mysql_fetch_object($res);
80 $skinid = $obj->sdnumber;
81 $query = 'INSERT INTO '.sql_table('skin')." VALUES (" . $skinid . ", 'imagepopup', '<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n <title><%imagetext%></title>\r\n <style type=\"text/css\">\r\n img { border: none; }\r\n </style>\r\n</head>\r\n<body>\r\n <a href=\"javascript:window.close();\"><%image%></a>\r\n</body>\r\n</html>');";
82 upgrade_query("Adding 'imagepopup' skinparts",$query);
84 // 7. add POPUP_CODE, MEDIA_CODE, IMAGE_CODE to ALL templates
85 $query = 'SELECT tdnumber FROM '.sql_table('template_desc');
86 $res = sql_query($query); // get all template ids
87 while ($obj = mysql_fetch_object($res)) {
88 $tid = $obj->tdnumber; // template id
90 $query = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'POPUP_CODE', '<%popuplink%>');";
91 $query2 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'MEDIA_CODE', '<%media%>');";
92 $query3 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'IMAGE_CODE', '<%image%>');";
93 upgrade_query("Adding popupcode to template $tid",$query);
94 upgrade_query("Adding mediacode to template $tid",$query2);
95 upgrade_query("Adding imagecode to template $tid",$query3);
99 // 8. add cip to nucleus_comment
100 if(0==$upgrade_failures && !upgrade_checkIfColumnExists('comment', 'cip')){
101 $query = 'ALTER TABLE '.sql_table('comment')
102 . " ADD cip varchar(15) NOT NULL default ''";
103 upgrade_query("Adding IP attribute to comments",$query);
105 echo "<li>Adding IP attribute to comments ... <span class=\"warning\">NOT EXECUTED</span>\n<blockquote>Errors occurred during upgrade process.</blockquote>";