OSDN Git Service

Subversion由来のタグを削除
[nucleus-jp/nucleus-jp-ancient.git] / nucleus / upgrades / upgrade0.96.php
1 <?php
2 /*
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4  * Copyright (C) 2002-2007 The Nucleus Group
5  *
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)
11  */
12
13 function upgrade_do96() {
14
15         if (upgrade_checkinstall(96))
16         return 'インストール済みです';
17
18         // 1. create nucleus_actionlog
19         if (!upgrade_checkIfTableExists('actionlog')) {
20                 $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)) ENGINE=MyISAM;";
21                 upgrade_query("Creating nucleus_actionlog table",$query);
22         }
23         
24         // 2. create nucleus_ban
25         if (!upgrade_checkIfTableExists('ban')) {
26                 $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') ENGINE=MyISAM;";
27                 upgrade_query("Creating nucleus_ban table",$query);
28         }
29         
30         // 3. add ikarma to nucleus_item
31         if (!upgrade_checkIfColumnExists('item','ikarma')) {
32                 $query =  'ALTER TABLE '.sql_table('item')
33                            . " ADD ikarma int(11) NOT NULL default '0'";
34                 upgrade_query("Adding karma-votes to items",$query);
35         }
36         
37         // 4. create nucleus_karma
38         if (!upgrade_checkIfTableExists('karma')) {
39                 $query = 'CREATE TABLE '.sql_table('karma')." ("
40                         ."  itemid int(11) NOT NULL default '0',"
41                         ."  ip char(15) NOT NULL default ''"
42                         .") ENGINE=MyISAM;";
43                 upgrade_query("Creating nucleus_karma table",$query);
44         }
45         
46         // 5. nucleus_config: add MediaURL, AllowedTypes, AllowLoginEdit, AllowUpload
47         
48         // create MediaURL out of IndexURL
49         $mediaURL = $CONF['IndexURL'] . "media/";
50         
51         if (!upgrade_checkIfCVExists('MediaURL')) {
52                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('MediaURL', '$mediaURL');";
53                 upgrade_query("New setting MediaURL",$query);
54         }
55         if (!upgrade_checkIfCVExists('AllowedTypes')) {
56                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('AllowedTypes', 'jpg,jpeg,gif,mpg,mpeg,avi,mov,mp3,swf,png');";
57                 upgrade_query("New setting AllowedTypes",$query);
58         }
59         if (!upgrade_checkIfCVExists('AllowLoginEdit')) {
60                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('AllowLoginEdit', '0');";
61                 upgrade_query("New setting AllowLoginEdit",$query);
62         }
63         if (!upgrade_checkIfCVExists('AllowUpload')) {
64                 $query = 'INSERT INTO '.sql_table('config')." VALUES ('AllowUpload', '1');";
65                 upgrade_query("New setting AllowUpload",$query);
66         }
67         
68         //The following blocks (6 and 7) should check for existing values and only update as needed.
69         // 6. add 'imagepopup' skincontents in skin 'default'
70         
71         $query = 'SELECT sdnumber FROM '.sql_table('skin_desc')." WHERE sdname='default'";
72         $res = sql_query($query);
73         $obj = mysql_fetch_object($res);
74         $skinid = $obj->sdnumber;
75         $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>');";
76         upgrade_query("Adding 'imagepopup' skinparts",$query);
77         
78         // 7. add POPUP_CODE, MEDIA_CODE, IMAGE_CODE to ALL templates
79         $query = 'SELECT tdnumber FROM '.sql_table('template_desc');
80         $res = sql_query($query);       // get all template ids
81         while ($obj = mysql_fetch_object($res)) {
82                 $tid = $obj->tdnumber;  // template id
83         
84                 $query = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'POPUP_CODE', '<%popuplink%>');";
85                 $query2 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'MEDIA_CODE', '<%media%>');";
86                 $query3 = 'INSERT INTO '.sql_table('template')." VALUES ($tid, 'IMAGE_CODE', '<%image%>');";
87                 upgrade_query("Adding popupcode to template $tid",$query);
88                 upgrade_query("Adding mediacode to template $tid",$query2);
89                 upgrade_query("Adding imagecode to template $tid",$query3);
90                 
91         }
92         
93         // 8. add cip to nucleus_comment
94         if(0==$upgrade_failures && !upgrade_checkIfColumnExists('comment', 'cip')){
95                 $query =  'ALTER TABLE '.sql_table('comment')
96                            . " ADD cip varchar(15) NOT NULL default ''";
97                 upgrade_query("Adding IP attribute to comments",$query);
98         }else{
99                 echo "<li>Adding IP attribute to comments ... <span class=\"warning\">NOT EXECUTED</span>\n<blockquote>Errors occurred during upgrade process.</blockquote>";
100         }
101 }
102
103
104 ?>