source: trunk/migrate/index.php @ 782

Revision 782, 10.1 KB checked in by r2, 13 months ago (diff)

копирайты

  • Property svn:executable set to *
Line 
1<?php
2/******************************************************************************/
3//                                                                            //
4//                             InstantCMS v1.8                                //
5//                        http://www.instantcms.ru/                           //
6//                                                                            //
7//                   written by InstantCMS Team, 2007-2010                    //
8//                produced by InstantSoft, (www.instantsoft.ru)               //
9//                                                                            //
10//                        LICENSED BY GNU/GPL v2                              //
11//                                                                            //
12/******************************************************************************/
13
14    session_start();
15
16    define('VALID_CMS', 1);
17   
18    define('PATH', $_SERVER['DOCUMENT_ROOT']);
19
20    require(PATH."/core/cms.php");
21    include(PATH."/includes/config.inc.php");
22
23    $inCore     = cmsCore::getInstance();
24
25    define('HOST', 'http://' . $inCore->getHost());
26
27    $inCore->loadClass('config');       //êîíôèãóðàöèÿ
28    $inCore->loadClass('db');           //áàçà äàííûõ
29    $inCore->loadClass('user');
30
31    $inConf     = cmsConfig::getInstance();
32    $inDB       = cmsDatabase::getInstance();
33
34    $version_prev = '1.7';
35    $version_next = '1.8';
36       
37        $is_was_migrate = false;
38
39// ========================================================================== //
40// ========================================================================== //
41
42    echo '<style type="text/css">
43            body { font-family:Arial; font-size:14px; }
44
45            a { color: #0099CC; }
46            a:hover { color: #375E93; }
47            h2 { color: #375E93; }
48
49            #wrapper { padding:10px 30px; }
50            #wrapper p{ line-height: 20px; }
51
52            .migrate p {
53                           line-height:16px;
54                           padding-left:20px;
55                           margin:2px;
56                           margin-left:20px;                           
57                           background:url(/admin/images/actions/on.gif) no-repeat;
58                       }
59            .important {
60                           margin:20px;
61                           margin-left:0px;
62                           border:solid 1px silver;
63                           padding:15px;
64                           padding-left:65px;
65                           background:url(important.png) no-repeat 15px 15px;
66                       }
67             .nextlink {
68                           margin-top:15px;
69                           font-size:18px;
70             }
71          </style>';
72
73    echo '<div id="wrapper">';
74
75    echo "<h2>Ìèãðàöèÿ InstantCMS {$version_prev} &rarr; {$version_next}</h2>";
76
77// ========================================================================== //
78// ========================================================================== //       
79    if (!$inDB->isFieldExists('cms_modules', 'access_list')){
80        $inDB->query("ALTER TABLE `cms_modules` ADD `access_list` TINYTEXT NOT NULL AFTER `css_prefix`");
81        echo '<p>Ïîëå <strong>access_list</strong> äîáàâëåíî â òàáëèöó <strong>cms_modules</strong></p>';
82                $is_was_migrate = true;
83    }
84// ========================================================================== //
85// ========================================================================== //
86    if ($inDB->isFieldExists('cms_modules', 'allow_group')){
87                $sql    = "SELECT id, allow_group
88                                   FROM cms_modules";
89       
90                $result = $inDB->query($sql);
91       
92                if ($inDB->num_rows($result)){
93                        while($mod = $inDB->fetch_assoc($result)){
94                                if($mod['allow_group'] != -1) {
95       
96                                        $access_list[]  = $mod['allow_group'];
97                                        $access_list_ya = $inCore->arrayToYaml($access_list);
98                                        $inDB->query("UPDATE cms_modules SET `access_list` = '{$access_list_ya}' WHERE id = '{$mod['id']}'");
99                                        unset ($access_list);
100       
101                                }
102                        }
103                }
104       
105                echo '<p>Ìóëüòèäîñòóï ãðóïï ê ìîäóëÿì âûïîëíåí.</p>';
106                $is_was_migrate = true;
107        }
108// ========================================================================== //
109// ========================================================================== //
110    if ($inDB->isFieldExists('cms_modules', 'allow_group')){
111        $inDB->query("ALTER TABLE `cms_modules` DROP `allow_group`");
112        echo '<p>Ïîëå <strong>allow_group</strong> óäàëåíî èç òàáëèöû <strong>cms_modules</strong></p>';
113                $is_was_migrate = true;
114    }
115// ========================================================================== //
116// ========================================================================== //       
117    if (!$inDB->isFieldExists('cms_menu', 'access_list')){
118        $inDB->query("ALTER TABLE `cms_menu` ADD `access_list` TINYTEXT NOT NULL AFTER `template`");
119        echo '<p>Ïîëå <strong>access_list</strong> äîáàâëåíî â òàáëèöó <strong>cms_menu</strong></p>';
120                $is_was_migrate = true;
121    }
122// ========================================================================== //
123// ========================================================================== //
124    if ($inDB->isFieldExists('cms_menu', 'allow_group')){
125                $sql    = "SELECT id, allow_group
126                                   FROM cms_menu";
127       
128                $result = $inDB->query($sql);
129       
130                if ($inDB->num_rows($result)){
131                        while($mod = $inDB->fetch_assoc($result)){
132                                if($mod['allow_group'] != -1) {
133       
134                                        $access_list[]  = $mod['allow_group'];
135                                        $access_list_ya = $inCore->arrayToYaml($access_list);
136                                        $inDB->query("UPDATE cms_menu SET `access_list` = '{$access_list_ya}' WHERE id = '{$mod['id']}'");
137                                        unset ($access_list);
138       
139                                }
140                        }
141                }
142       
143                echo '<p>Ìóëüòèäîñòóï ãðóïï ê ïóíêòàì ìåíþ âûïîëíåí.</p>';
144                $is_was_migrate = true;
145        }
146// ========================================================================== //
147// ========================================================================== //
148    if ($inDB->isFieldExists('cms_menu', 'allow_group')){
149        $inDB->query("ALTER TABLE `cms_menu` DROP `allow_group`");
150        echo '<p>Ïîëå <strong>allow_group</strong> óäàëåíî èç òàáëèöû <strong>cms_menu</strong></p>';
151                $is_was_migrate = true;
152    }
153// ========================================================================== //
154// ========================================================================== //
155    if (!$inDB->isFieldExists('cms_clubs', 'create_karma')){
156        $inDB->query("ALTER TABLE `cms_clubs` ADD `create_karma` INT( 11 ) NOT NULL AFTER `join_karma_limit`");
157        echo '<p>Ïîëå <strong>create_karma</strong> äîáàâëåíî â òàáëèöó <strong>cms_clubs</strong></p>';
158                $is_was_migrate = true;
159    }
160    if (!$inDB->isFieldExists('cms_clubs', 'is_vip')){
161        $inDB->query("ALTER TABLE `cms_clubs` ADD `is_vip` TINYINT NOT NULL DEFAULT '0'");
162        echo '<p>Ïîëå <strong>is_vip</strong> äîáàâëåíî â òàáëèöó <strong>cms_clubs</strong></p>';
163                $is_was_migrate = true;
164    }
165    if (!$inDB->isFieldExists('cms_clubs', 'join_cost')){
166        $inDB->query("ALTER TABLE `cms_clubs` ADD `join_cost` FLOAT NOT NULL");
167        echo '<p>Ïîëå <strong>join_cost</strong> äîáàâëåíî â òàáëèöó <strong>cms_clubs</strong></p>';
168                $is_was_migrate = true;
169    }
170// ========================================================================== //
171// ========================================================================== //
172    if (!$inDB->isFieldExists('cms_comments', 'content_bbcode')){
173        $inDB->query("ALTER TABLE `cms_comments` ADD `content_bbcode` TEXT NOT NULL AFTER `content`");
174        echo '<p>Ïîëå <strong>content_bbcode</strong> äîáàâëåíî â òàáëèöó <strong>cms_comments</strong></p>';
175                $is_was_migrate = true;
176    }
177// ========================================================================== //
178// ========================================================================== //
179
180    $inDB->query("ALTER TABLE `cms_search` CHANGE `link` `link` VARCHAR( 200 ) CHARACTER SET cp1251 COLLATE cp1251_general_ci NOT NULL");
181
182// ========================================================================== //
183// ========================================================================== //
184
185    if (!$inDB->isFieldExists('cms_user_msg', 'to_del')){
186        $inDB->query("ALTER TABLE `cms_user_msg` ADD `to_del` TINYINT NOT NULL DEFAULT '0'");
187        $inDB->query("ALTER TABLE `cms_user_msg` ADD `from_del` TINYINT NOT NULL DEFAULT '0'");
188        echo '<p>Ïîëÿ <strong>to_del</strong>, <strong>from_del</strong> äîáàâëåíû â òàáëèöó <strong>cms_user_msg</strong></p>';
189        $is_was_migrate = true;
190    }   
191
192    if (!$inDB->isFieldExists('cms_board_items', 'is_vip')){
193        $inDB->query("ALTER TABLE `cms_board_items` ADD `is_vip` TINYINT NOT NULL DEFAULT '0'");
194        $inDB->query("ALTER TABLE `cms_board_items` ADD `vipdate` DATETIME NOT NULL");
195        echo '<p>Ïîëÿ <strong>is_vip</strong>, <strong>vipdate</strong> äîáàâëåíû â òàáëèöó <strong>cms_board_items</strong></p>';
196        $is_was_migrate = true;
197    }
198
199    if (!$inDB->isFieldExists('cms_category', 'cost')){
200        $inDB->query("ALTER TABLE `cms_category` ADD `cost` VARCHAR( 5 ) NOT NULL");
201        $is_was_migrate = true;
202    }
203
204    if (!$inDB->isFieldExists('cms_uc_cats', 'cost')){
205        $inDB->query("ALTER TABLE `cms_uc_cats` ADD `cost` VARCHAR( 5 ) NOT NULL");
206        $is_was_migrate = true;
207    }
208
209    if (!$inDB->isFieldExists('cms_forums', 'topic_cost')){
210        $inDB->query("ALTER TABLE `cms_forums` ADD `topic_cost` FLOAT NOT NULL DEFAULT '0'");
211        $is_was_migrate = true;
212    }
213
214    if (!$inDB->isFieldExists('cms_users', 'is_logged_once')){
215        $inDB->query("ALTER TABLE `cms_users` ADD `is_logged_once` TINYINT NOT NULL DEFAULT '1' AFTER `is_deleted`");
216        $is_was_migrate = true;
217    }
218
219// ========================================================================== //
220// ========================================================================== //
221        if ($is_was_migrate) {
222            echo '<div style="margin:15px 0px 15px 0px;font-weight:bold">Ìèãðàöèÿ çàâåðøåíà. Óäàëèòå ïàïêó /migrate/ ïðåæäå ÷åì ïðîäîëæèòü!</div>';
223        } else {
224                echo '<div style="margin:15px 0px 15px 0px;font-weight:bold">Âû óæå ïðîøëè ìèãðàöèþ.</div>';
225        }
226    echo '<div class="nextlink"><a href="/">Ïåðåéòè íà ñàéò</a></div>';
227    echo '</div>';
228
229   
230?>
Note: See TracBrowser for help on using the repository browser.