public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
chyrp / upgrade.php
100755 1296 lines (1083 sloc) 50.934 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
<?php
    /**
* File: Upgrader
* A task-based general-purpose Chyrp upgrader.
*
* Performs upgrade functions based on individual tasks, and checks whether or not they need to be done.
*
* Version-agnostic. Completely safe to be run at all times, by anyone.
*/
 
    header("Content-type: text/html; charset=UTF-8");
 
    define('DEBUG', true);
    define('CACHE_TWIG', false);
    define('JAVASCRIPT', false);
    define('ADMIN', false);
    define('AJAX', false);
    define('XML_RPC', false);
    define('TRACKBACK', false);
    define('UPGRADING', true);
    define('INSTALLING', false);
    define('TESTER', true);
    define('INDEX', false);
    define('MAIN_DIR', dirname(__FILE__));
    define('INCLUDES_DIR', dirname(__FILE__)."/includes");
    define('MODULES_DIR', MAIN_DIR."/modules");
    define('FEATHERS_DIR', MAIN_DIR."/feathers");
    define('THEMES_DIR', MAIN_DIR."/themes");
 
    if (!AJAX and
        extension_loaded("zlib") and
        !ini_get("zlib.output_compression") and
        isset($_SERVER['HTTP_ACCEPT_ENCODING']) and
        substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], "gzip")) {
        ob_start("ob_gzhandler");
        header("Content-Encoding: gzip");
    } else
        ob_start();
 
    /**
* Function: config_file
* Returns what config file their install is set up for.
*/
    function config_file() {
        if (file_exists(INCLUDES_DIR."/config.yaml.php"))
            return INCLUDES_DIR."/config.yaml.php";
 
        if (file_exists(INCLUDES_DIR."/config.yml.php"))
            return INCLUDES_DIR."/config.yml.php";
 
        if (file_exists(INCLUDES_DIR."/config.php"))
            return INCLUDES_DIR."/config.php";
 
        exit("Config file not found.");
    }
 
    /**
* Function: database_file
* Returns what database config file their install is set up for.
*/
    function database_file() {
        if (file_exists(INCLUDES_DIR."/database.yaml.php"))
            return INCLUDES_DIR."/database.yaml.php";
 
        if (file_exists(INCLUDES_DIR."/database.yml.php"))
            return INCLUDES_DIR."/database.yml.php";
 
        if (file_exists(INCLUDES_DIR."/database.php"))
            return INCLUDES_DIR."/database.php";
 
        return false;
    }
 
    /**
* Function: using_yaml
* Are they using YAML config storage?
*/
    function using_yaml() {
        return (basename(config_file()) != "config.php" and basename(database_file()) != "database.php") or !database_file();
    }
 
    # Evaluate the code in their config files, but with the classes renamed, so we can safely retrieve the values.
    if (!using_yaml()) {
        eval(str_replace(array("<?php", "?>", "Config"),
                         array("", "", "OldConfig"),
                         file_get_contents(config_file())));
 
        if (database_file())
            eval(str_replace(array("<?php", "?>", "SQL"),
                             array("", "", "OldSQL"),
                             file_get_contents(database_file())));
    }
 
    # File: Helpers
    # Various functions used throughout Chyrp's code.
    require_once INCLUDES_DIR."/helpers.php";
 
    # File: Gettext
    # Gettext library.
    require_once INCLUDES_DIR."/lib/gettext/gettext.php";
 
    # File: Streams
    # Streams library.
    require_once INCLUDES_DIR."/lib/gettext/streams.php";
 
    # File: YAML
    # Horde YAML parsing library.
    require_once INCLUDES_DIR."/lib/YAML.php";
 
    # File: SQL
    # See Also:
    # <SQL>
    require INCLUDES_DIR."/class/SQL.php";
 
    /**
* Class: Config
* Handles writing to whichever config file they're using.
*/
    class Config {
        # Array: $yaml
        # Stores all of the YAML data.
        static $yaml = array("config" => array(),
                             "database" => array());
 
        /**
* Function: get
* Returns a config setting.
*
* Parameters:
* $setting - The setting to return.
*/
        static function get($setting) {
            return (isset(Config::$yaml["config"][$setting])) ? Config::$yaml["config"][$setting] : false ;
        }
 
        /**
* Function: set
* Sets a config setting.
*
* Parameters:
* $setting - The config setting to set.
* $value - The value for the setting.
* $message - The message to display with test().
*/
        static function set($setting, $value, $message = null) {
            if (self::get($setting) == $value) return;
 
            if (!isset($message))
                $message = _f("Setting %s to %s...", array($setting, normalize(print_r($value, true))));
 
            Config::$yaml["config"][$setting] = $value;
 
            $protection = "<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>\n";
 
            $dump = $protection.YAML::dump(Config::$yaml["config"]);
 
            echo $message.test(@file_put_contents(INCLUDES_DIR."/config.yaml.php", $dump));
        }
 
        /**
* Function: check
* Goes a config exist?
*
* Parameters:
* $setting - Name of the config to check.
*/
        static function check($setting) {
            return (isset(Config::$yaml["config"][$setting]));
        }
 
        /**
* Function: fallback
* Sets a config setting to $value if it does not exist.
*
* Parameters:
* $setting - The config setting to set.
* $value - The value for the setting.
* $message - The message to display with test().
*/
        static function fallback($setting, $value, $message = null) {
            if (!isset($message))
                $message = _f("Adding %s setting...", array($setting));
 
            if (!self::check($setting))
                echo self::set($setting, $value, $message);
        }
 
        /**
* Function: remove
* Removes a setting if it exists.
*
* Parameters:
* $setting - The setting to remove.
*/
        static function remove($setting) {
            if (!self::check($setting)) return;
 
            unset(Config::$yaml["config"][$setting]);
 
            $protection = "<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>\n";
 
            $dump = $protection.YAML::dump(Config::$yaml["config"]);
 
            echo _f("Removing %s setting...", array($setting)).
                 test(@file_put_contents(INCLUDES_DIR."/config.yaml.php", $dump));
        }
    }
 
    if (using_yaml()) {
        Config::$yaml["config"] = YAML::load(preg_replace("/<\?php(.+)\?>\n?/s", "", file_get_contents(config_file())));
 
        if (database_file())
            Config::$yaml["database"] = YAML::load(preg_replace("/<\?php(.+)\?>\n?/s",
                                                                        "",
                                                                        file_get_contents(database_file())));
        else
            Config::$yaml["database"] = oneof(@Config::$yaml["config"]["sql"], array());
    } else {
        # $config and $sql here are loaded from the eval()'s above.
 
        foreach ($config as $name => $val)
            Config::$yaml["config"][$name] = $val;
 
        foreach ($sql as $name => $val)
            Config::$yaml["database"][$name] = $val;
    }
 
    load_translator("chyrp", INCLUDES_DIR."/locale/".Config::get("locale").".mo");
 
    /**
* Function: test
* Attempts to perform a task, and displays a "success" or "failed" message determined by the outcome.
*
* Parameters:
* $try - The task to attempt. Should return something that evaluates to true or false.
* $message - Message to display for the test.
*/
    function test($try, $message = "") {
        $sql = SQL::current();
 
        if (!empty($sql->error)) {
            $message.= "\n".$sql->error."\n\n";
            $sql->error = "";
        }
 
        $info = $message;
 
        if ($try)
            return " <span class=\"yay\">".__("success!")."</span>\n";
        else
            return " <span class=\"boo\">".__("failed!")."</span>\n".$info;
    }
 
    #---------------------------------------------
    # Upgrading Actions
    #---------------------------------------------
 
    /**
* Function: fix_htaccess
* Repairs their .htaccess file.
*/
    function fix_htaccess() {
        $url = "http://".$_SERVER['HTTP_HOST'].str_replace("/upgrade.php", "", $_SERVER['REQUEST_URI']);
        $index = (parse_url($url, PHP_URL_PATH)) ? "/".trim(parse_url($url, PHP_URL_PATH), "/")."/" : "/" ;
 
        $path = preg_quote($index, "/");
        $htaccess_has_chyrp = (file_exists(MAIN_DIR."/.htaccess") and preg_match("/<IfModule mod_rewrite\.c>\n([\s]*)RewriteEngine On\n([\s]*)RewriteBase {$path}\n([\s]*)RewriteCond %\{REQUEST_FILENAME\} !-f\n([\s]*)RewriteCond %\{REQUEST_FILENAME\} !-d\n([\s]*)RewriteRule (\^\.\+\\$|\!\\.\(gif\|jpg\|png\|css\)) index\.php \[L\]\n([\s]*)RewriteRule \^\.\+\\\.twig\\$ index\.php \[L\]\n([\s]*)<\/IfModule>/", file_get_contents(MAIN_DIR."/.htaccess")));
        if ($htaccess_has_chyrp)
            return;
 
        $htaccess = "<IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase {$index}\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ^.+\$ index.php [L]\nRewriteRule ^.+\\.twig\$ index.php [L]\n</IfModule>";
 
        if (!file_exists(MAIN_DIR."/.htaccess"))
            echo __("Generating .htaccess file...").
                 test(@file_put_contents(MAIN_DIR."/.htaccess", $htaccess), __("Try creating the file and/or CHMODding it to 777 temporarily."));
        else
            echo __("Appending to .htaccess file...").
                 test(@file_put_contents(MAIN_DIR."/.htaccess", "\n\n".$htaccess, FILE_APPEND), __("Try creating the file and/or CHMODding it to 777 temporarily."));
    }
 
    /**
* Function: tweets_to_posts
* Enacts the "tweet" to "post" rename.
*
* Versions: 1.0.2 => 1.0.3
*/
    function tweets_to_posts() {
        if (SQL::current()->query("SELECT * FROM __tweets"))
            echo __("Renaming tweets table to posts...").
                 test(SQL::current()->query("RENAME TABLE __tweets TO __posts"));
 
        if (SQL::current()->query("SELECT add_tweet FROM __groups"))
            echo __("Renaming add_tweet permission to add_post...").
                 test(SQL::current()->query("ALTER TABLE __groups CHANGE add_tweet add_post TINYINT(1) NOT NULL DEFAULT '0'"));
 
        if (SQL::current()->query("SELECT edit_tweet FROM __groups"))
            echo __("Renaming edit_tweet permission to edit_post...").
                 test(SQL::current()->query("ALTER TABLE __groups CHANGE edit_tweet edit_post TINYINT(1) NOT NULL DEFAULT '0'"));
 
        if (SQL::current()->query("SELECT delete_tweet FROM __groups"))
            echo __("Renaming delete_tweet permission to delete_post...").
                 test(SQL::current()->query("ALTER TABLE __groups CHANGE delete_tweet delete_post TINYINT(1) NOT NULL DEFAULT '0'"));
 
        if (Config::check("tweets_per_page")) {
            Config::fallback("posts_per_page", Config::get("tweets_per_page"));
            Config::remove("tweets_per_page");
        }
 
        if (Config::check("tweet_url")) {
            Config::fallback("post_url", Config::get("tweet_url"));
            Config::remove("tweet_url");
        }
 
        if (Config::check("rss_tweets")) {
            Config::fallback("rss_posts", Config::get("rss_posts"));
            Config::remove("rss_tweets");
        }
    }
 
    /**
* Function: pages_parent_id_column
* Adds the @parent_id@ column to the "pages" table.
*
* Versions: 1.0.3 => 1.0.4
*/
    function pages_parent_id_column() {
        if (SQL::current()->query("SELECT parent_id FROM __pages"))
            return;
 
        echo __("Adding parent_id column to pages table...").
             test(SQL::current()->query("ALTER TABLE __pages ADD parent_id INT(11) NOT NULL DEFAULT '0' AFTER user_id"));
    }
 
    /**
* Function: pages_list_order_column
* Adds the @list_order@ column to the "pages" table.
*
* Versions: 1.0.4 => 1.1.0
*/
    function pages_list_order_column() {
        if (SQL::current()->query("SELECT list_order FROM __pages"))
            return;
 
        echo __("Adding list_order column to pages table...").
             test(SQL::current()->query("ALTER TABLE __pages ADD list_order INT(11) NOT NULL DEFAULT '0' AFTER show_in_list"));
    }
 
    /**
* Function: remove_beginning_slash_from_post_url
* Removes the slash at the beginning of the post URL setting.
*/
    function remove_beginning_slash_from_post_url() {
        if (substr(Config::get("post_url"), 0, 1) == "/")
            Config::set("post_url", ltrim(Config::get("post_url"), "/"));
    }
 
    /**
* Function: move_yml_yaml
* Renames config.yml.php to config.yaml.php.
*
* Versions: 1.1.2 => 1.1.3
*/
    function move_yml_yaml() {
        if (file_exists(INCLUDES_DIR."/config.yml.php"))
            echo __("Moving /includes/config.yml.php to /includes/config.yaml.php...").
                 test(@rename(INCLUDES_DIR."/config.yml.php", INCLUDES_DIR."/config.yaml.php"), __("Try CHMODding the file to 777."));
    }
 
    /**
* Function: update_protection
* Updates the PHP protection code in the config file.
*/
    function update_protection() {
        if (!file_exists(INCLUDES_DIR."/config.yaml.php") or
            substr_count(file_get_contents(INCLUDES_DIR."/config.yaml.php"),
                         "<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>"))
            return;
 
        $contents = file_get_contents(INCLUDES_DIR."/config.yaml.php");
        $new_error = preg_replace("/<\?php (.+) \?>/",
                             "<?php header(\"Status: 403\"); exit(\"Access denied.\"); ?>",
                             $contents);
 
        echo __("Updating protection code in config.yaml.php...").
             test(@file_put_contents(INCLUDES_DIR."/config.yaml.php", $new_error), __("Try CHMODding the file to 777."));
    }
 
    /**
* Function: theme_default_to_stardust
* Changes their theme from "default" to "stardust", or leaves it alone if they're not using "default".
*
* Versions: 1.1.3.2 => 2.0
*/
    function theme_default_to_stardust() {
        if (Config::get("theme") != "default") return;
        Config::set("theme", "stardust");
    }
 
    /**
* Function: default_db_adapter_to_mysql
* Adds an "adapter" SQL setting if it doesn't exist, and sets it to "mysql".
*
* Versions: 1.1.3.2 => 2.0
*/
    function default_db_adapter_to_mysql() {
        $sql = SQL::current();
        if (isset($sql->adapter)) return;
        $sql->set("adapter", "mysql");
    }
 
    /**
* Function: move_upload
* Renames the "upload" directory to "uploads".
*/
    function move_upload() {
        if (file_exists(MAIN_DIR."/upload") and !file_exists(MAIN_DIR."/uploads"))
            echo __("Renaming /upload directory to /uploads...").test(@rename(MAIN_DIR."/upload", MAIN_DIR."/uploads"), __("Try CHMODding the directory to 777."));
    }
 
    /**
* Function: make_posts_xml
* Updates all of the post XML data to well-formed non-CDATAized XML.
*
* Versions: 1.1.3.2 => 2.0
*/
    function make_posts_safe() {
        if (!$posts = SQL::current()->query("SELECT * FROM __posts"))
            return;
 
        if (!SQL::current()->query("SELECT xml FROM __posts"))
            return;
 
        function clean_xml(&$input) {
            $input = trim($input);
        }
 
        while ($post = $posts->fetchObject()) {
            if (!substr_count($post->xml, "<![CDATA["))
                continue;
 
            $post->xml = str_replace("<![CDATA[]]>", "", $post->xml);
 
            $xml = simplexml_load_string($post->xml, "SimpleXMLElement", LIBXML_NOCDATA);
 
            $parse = xml2arr($xml);
 
            array_walk_recursive($parse, "clean_xml");
 
            $new_xml = new SimpleXMLElement("<post></post>");
            arr2xml($new_xml, $parse);
 
            echo _f("Sanitizing XML data of post #%d...", array($post->id)).
                 test(SQL::current()->update("posts",
                                             array("id" => $post->id),
                                             array("xml" => $new_xml->asXML())));
        }
    }
 
    /**
* Function: rss_posts_to_feed_items
* Rename the feed items setting.
*
* Versions: 1.1.3.2 => 2.0
*/
    function rss_posts_to_feed_items() {
        if (!Config::check("rss_posts"))
            return;
 
        Config::fallback("feed_items", Config::get("rss_posts"));
        Config::remove("rss_posts");
    }
 
    /**
* Function: update_groups_to_yaml
* Updates the groups to use YAML-based permissions instead of table columns.
*
* Versions: 1.1.3.2 => 2.0
*/
    function update_groups_to_yaml() {
        if (!SQL::current()->query("SELECT view_site FROM __groups")) return;
 
        $get_groups = SQL::current()->query("SELECT * FROM __groups");
        echo __("Backing up current groups table...").test($get_groups);
        if (!$get_groups) return;
 
        $groups = array();
        # Generate an array of groups, name => permissions.
        while ($group = $get_groups->fetchObject()) {
            $groups[$group->name] = array("permissions" => array());
            foreach ($group as $key => $val)
                if ($key != "name" and $key != "id" and $val)
                    $groups[$group->name]["permissions"][] = $key;
                elseif ($key == "id")
                    $groups[$group->name]["id"] = $val;
        }
 
        # Convert permissions array to a YAML dump.
        foreach ($groups as $key => &$val)
            $val["permissions"] = YAML::dump($val["permissions"]);
 
        $drop_groups = SQL::current()->query("DROP TABLE __groups");
        echo __("Dropping old groups table...").test($drop_groups);
        if (!$drop_groups) return;
 
        $groups_table = SQL::current()->query("CREATE TABLE __groups (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) DEFAULT '',
permissions LONGTEXT,
UNIQUE (name)
) DEFAULT CHARSET=utf8");
        echo __("Creating new groups table...").test($groups_table);
        if (!$groups_table) return;
 
        foreach($groups as $name => $values)
            echo _f("Restoring group \"%s\"...", array($name)).
                 test(SQL::current()->insert("groups",
                                             array("id" => $values["id"],
                                                   "name" => $name,
                                                   "permissions" => $values["permissions"])));
    }
 
    /**
* Function: add_permissions_table
* Creates the "permissions" table and fills it in with the default set.
*
* Versions: 1.1.3.2 => 2.0
*/
    function add_permissions_table() {
        if (SQL::current()->query("SELECT * FROM __permissions")) return;
 
        $permissions_table = SQL::current()->query("CREATE TABLE __permissions (
id VARCHAR(100) DEFAULT '' PRIMARY KEY,
name VARCHAR(100) DEFAULT ''
) DEFAULT CHARSET=utf8");
        echo __("Creating new permissions table...").test($permissions_table);
        if (!$permissions_table) return;
 
        $permissions = array("change_settings" => "Change Settings",
                             "toggle_extensions" => "Toggle Extensions",
                             "view_site" => "View Site",
                             "view_private" => "View Private Posts",
                             "view_draft" => "View Drafts",
                             "view_own_draft" => "View Own Drafts",
                             "add_post" => "Add Posts",
                             "add_draft" => "Add Drafts",
                             "edit_post" => "Edit Posts",
                             "edit_draft" => "Edit Drafts",
                             "edit_own_post" => "Edit Own Posts",
                             "edit_own_draft" => "Edit Own Drafts",
                             "delete_post" => "Delete Posts",
                             "delete_draft" => "Delete Drafts",
                             "delete_own_post" => "Delete Own Posts",
                             "delete_own_draft" => "Delete Own Drafts",
                             "add_page" => "Add Pages",
                             "edit_page" => "Edit Pages",
                             "delete_page" => "Delete Pages",
                             "add_user" => "Add Users",
                             "edit_user" => "Edit Users",
                             "delete_user" => "Delete Users",
                             "add_group" => "Add Groups",
                             "edit_group" => "Edit Groups",
                             "delete_group" => "Delete Groups");
 
        foreach ($permissions as $id => $name)
            echo _f("Inserting permission \"%s\"...", array($name)).
                 test(SQL::current()->insert("permissions",
                                             array("id" => $id,
                                                   "name" => $name)));
    }
 
    /**
* Function: add_sessions_table
* Creates the "sessions" table.
*
* Versions: 1.1.3.2 => 2.0
*/
    function add_sessions_table() {
        if (SQL::current()->query("SELECT * FROM __sessions")) return;
 
        echo __("Creating `sessions` table...").
             test(SQL::current()->query("CREATE TABLE __sessions (
id VARCHAR(40) DEFAULT '',
data LONGTEXT,
user_id INTEGER DEFAULT '0',
created_at DATETIME DEFAULT '0000-00-00 00:00:00',
updated_at DATETIME DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (id)
) DEFAULT CHARSET=utf8") or die(mysql_error()));
    }
 
    /**
* Function: update_permissions_table
* Updates the "permissions" table from ## (id) => foo_bar (name) to foo_bar (id) => Foo Bar (name).
*
* Versions: 2.0b => 2.0
*/
    function update_permissions_table() {
        # If there are any non-numeric IDs in the permissions database, assume this is already done.
        $check = SQL::current()->query("SELECT * FROM __permissions");
        while ($row = $check->fetchObject())
            if (!is_numeric($row->id))
                return;
 
        $permissions_backup = array();
        $get_permissions = SQL::current()->query("SELECT * FROM __permissions");
        echo __("Backing up current permissions table...").test($get_permissions);
        if (!$get_permissions) return;
 
        while ($permission = $get_permissions->fetchObject())
            $permissions_backup[] = $permission->name;
 
        $drop_permissions = SQL::current()->query("DROP TABLE __permissions");
        echo __("Dropping old permissions table...").test($drop_permissions);
        if (!$drop_permissions) return;
 
        echo __("Creating new permissions table...").
             test(SQL::current()->query("CREATE TABLE IF NOT EXISTS __permissions (
id VARCHAR(100) DEFAULT '' PRIMARY KEY,
name VARCHAR(100) DEFAULT ''
) DEFAULT CHARSET=utf8"));
 
        $permissions = array("change_settings" => "Change Settings",
                             "toggle_extensions" => "Toggle Extensions",
                             "view_site" => "View Site",
                             "view_private" => "View Private Posts",
                             "view_draft" => "View Drafts",
                             "view_own_draft" => "View Own Drafts",
                             "add_post" => "Add Posts",
                             "add_draft" => "Add Drafts",
                             "edit_post" => "Edit Posts",
                             "edit_draft" => "Edit Drafts",
                             "edit_own_post" => "Edit Own Posts",
                             "edit_own_draft" => "Edit Own Drafts",
                             "delete_post" => "Delete Posts",
                             "delete_draft" => "Delete Drafts",
                             "delete_own_post" => "Delete Own Posts",
                             "delete_own_draft" => "Delete Own Drafts",
                             "add_page" => "Add Pages",
                             "edit_page" => "Edit Pages",
                             "delete_page" => "Delete Pages",
                             "add_user" => "Add Users",
                             "edit_user" => "Edit Users",
                             "delete_user" => "Delete Users",
                             "add_group" => "Add Groups",
                             "edit_group" => "Edit Groups",
                             "delete_group" => "Delete Groups");
 
        foreach ($permissions_backup as $id) {
            $name = isset($permissions[$id]) ? $permissions[$id] : camelize($id, true);
            echo _f("Restoring permission \"%s\"...", array($name)).
                 test(SQL::current()->insert("permissions",
                                             array("id" => $id,
                                                   "name" => $name)));
        }
 
    }
 
    /**
* Function: update_custom_routes
* Updates the custom routes to be path => action instead of # => path.
*
* Versions: 2.0rc1 => 2.0rc2
*/
    function update_custom_routes() {
        $custom_routes = Config::get("routes");
        if (empty($custom_routes)) return;
 
        $new_routes = array();
        foreach ($custom_routes as $key => $route) {
            if (!is_int($key))
                return;
 
            $split = array_filter(explode("/", $route));
 
            if (!isset($split[0]))
                return;
 
            echo _f("Updating custom route %s to new format...", array($route)).
                 test(isset($split[0]) and $new_routes[$route] = $split[0]);
        }
 
        Config::set("routes", $new_routes, "Setting new custom routes configuration...");
    }
 
    /**
* Function: remove_database_config_file
* Removes the database.yaml.php file, which is merged into config.yaml.php.
*
* Versions: 2.0rc1 => 2.0rc2
*/
    function remove_database_config_file() {
        if (file_exists(INCLUDES_DIR."/database.yaml.php"))
            echo __("Removing database.yaml.php file...").
                 test(@unlink(INCLUDES_DIR."/database.yaml.php"), __("Try deleting it manually."));
    }
 
    /**
* Function: rename_database_setting_to_sql
* Renames the "database" config setting to "sql".
*/
    function rename_database_setting_to_sql() {
        if (Config::check("sql")) return;
        Config::set("sql", Config::get("database"));
        Config::remove("database");
    }
 
    /**
* Function: update_post_status_column
* Updates the @status@ column on the "posts" table to be a generic varchar field instead of enum.
*
* Versions: 2.0rc1 => 2.0rc2
*/
    function update_post_status_column() {
        $sql = SQL::current();
        if (!$column = $sql->query("SHOW COLUMNS FROM __posts WHERE Field = 'status'"))
             return;
 
        if ($column->fetchObject()->Type == "varchar(32)")
            return;
 
        echo __("Updating `status` column on `posts` table...")."\n";
 
        echo " - ".__("Backing up `posts` table...").
             test($backup = $sql->select("posts"));
        
        if (!$backup)
            return;
 
        $backups = $backup->fetchAll();
 
        echo " - ".__("Dropping `posts` table...").
             test($drop = $sql->query("DROP TABLE __posts"));
 
        if (!$drop)
            return;
 
        echo " - ".__("Creating `posts` table...").
             test($create = $sql->query("CREATE TABLE IF NOT EXISTS __posts (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
xml LONGTEXT,
feather VARCHAR(32) DEFAULT '',
clean VARCHAR(128) DEFAULT '',
url VARCHAR(128) DEFAULT '',
pinned TINYINT(1) DEFAULT 0,
status VARCHAR(32) DEFAULT 'public',
user_id INTEGER DEFAULT 0,
created_at DATETIME DEFAULT '0000-00-00 00:00:00',
updated_at DATETIME DEFAULT '0000-00-00 00:00:00'
) DEFAULT CHARSET=utf8"));
 
        if (!$create) {
            echo " -".test(false, _f("Backup written to %s.", array("./_posts.bak.txt")));
            return file_put_contents("./_posts.bak.txt", var_export($backups, true));
        }
 
        foreach ($backups as $backup) {
            echo " - "._f("Restoring post #%d...", array($backup["id"])).
                 test($insert = $sql->insert("posts", $backup), _f("Backup written to %s.", array("./_posts.bak.txt")));
 
            if (!$insert)
                return file_put_contents("./_posts.bak.txt", var_export($backups, true));
        }
 
        echo " -".test(true);
    }
 
    /**
* Function: add_post_attributes_table
* Adds the "post_attributes" table.
*
* Versions: 2.0rc1 => 2.0rc2
*/
    function add_post_attributes_table() {
        $sql = SQL::current();
        if ($sql->select("post_attributes"))
            return;
 
        echo __("Creating `post_attributes` table...").
             test($sql->query("CREATE TABLE __post_attributes (
post_id INTEGER NOT NULL ,
name VARCHAR(100) DEFAULT '',
value LONGTEXT,
PRIMARY KEY (post_id, name)
) DEFAULT CHARSET=utf8"));
    }
 
    /**
* Function: post_xml_to_db
* Migrates the XML post attributes to the "post_attributes" table.
*
* Versions: 2.0rc1 => 2.0rc2
*/
    function post_xml_to_db() {
        $sql = SQL::current();
        if (!$rows = $sql->query("SELECT id, xml FROM __posts"))
            return;
 
        function insert_attributes($sql, $row, $xml, &$inserts) {
            foreach ($xml as $name => $value) {
                if (is_array($value))
                    $value = YAML::dump($value);
 
                if (!$sql->insert("post_attributes",
                                  array("post_id" => $row["id"],
                                        "name" => $name,
                                        "value" => $value))) {
                    # Clear successful attribute insertions so the
                    # user can try again without primary key conflicts.
                    foreach ($inserts as $insertion)
                        $sql->delete("post_attributes",
                                     array("post_id" => $insertion["id"],
                                           "name" => $insertion["name"]));
 
                    return false;
                } else
                    $inserts[] = array("id" => $row["id"],
                                       "name" => $name);
            }
 
            return true;
        }
 
        $results = array();
        foreach ($rows->fetchAll() as $row) {
            if (empty($row["xml"]))
                continue;
 
            $xml = xml2arr(new SimpleXMLElement($row["xml"]));
            $inserts = array();
            echo _f("Migrating attributes of post #%d...", array($row["id"])).
                 test($results[] = insert_attributes($sql, $row, $xml, $inserts));
        }
 
        if (!in_array(false, $results)) {
            echo __("Removing `xml` column from `posts` table...")."\n";
 
            echo " - ".__("Backing up `posts` table...").
                 test($backup = $sql->select("posts"));
        
            if (!$backup)
                return;
 
            $backups = $backup->fetchAll();
 
            echo " - ".__("Dropping `posts` table...").
                 test($drop = $sql->query("DROP TABLE __posts"));
 
            if (!$drop)
                return;
 
            echo " - ".__("Creating `posts` table...").
                 test($create = $sql->query("CREATE TABLE IF NOT EXISTS __posts (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
feather VARCHAR(32) DEFAULT '',
clean VARCHAR(128) DEFAULT '',
url VARCHAR(128) DEFAULT '',
pinned TINYINT(1) DEFAULT 0,
status VARCHAR(32) DEFAULT 'public',
user_id INTEGER DEFAULT 0,
created_at DATETIME DEFAULT '0000-00-00 00:00:00',
updated_at DATETIME DEFAULT '0000-00-00 00:00:00'
) DEFAULT CHARSET=utf8"));
 
            if (!$create)
                return file_put_contents("./_posts.bak.txt", var_export($backups, true));
 
            foreach ($backups as $backup) {
                unset($backup["xml"]);
                echo " - "._f("Restoring post #%d...", array($backup["id"])).
                     test($insert = $sql->insert("posts", $backup));
 
                if (!$insert)
                    return file_put_contents("./_posts.bak.txt", var_export($backups, true));
            }
 
            echo " -".test(true);
        }
    }
 
    /**
* Function: add_group_id_to_permissions
* Adds the @group_id@ column to the "permissions" table.
*
* Versions: 2.0rc1 => 2.0rc2
*/
    function add_group_id_to_permissions() {
        $sql = SQL::current();
        if ($sql->select("permissions", "group_id"))
            return;
 
        echo __("Backing up permissions...").
             test($permissions = $sql->select("permissions"));
 
        if (!$permissions)
            return;
 
        $backup = $permissions->fetchAll();
 
        echo __("Dropping `permissions` table...").
             test($sql->query("DROP TABLE __permissions"));
 
        echo __("Creating `permissions` table...").
             test($sql->query("CREATE TABLE __permissions (
id VARCHAR(100) DEFAULT '',
name VARCHAR(100) DEFAULT '',
group_id INTEGER DEFAULT 0,
PRIMARY KEY (id, group_id)
) DEFAULT CHARSET=utf8"));
 
        foreach ($backup as $permission)
            echo _f("Restoring permission `%s`...", array($permission["name"])).
                 test($sql->insert("permissions",
                                   array("id" => $permission["id"],
                                         "name" => $permission["name"],
                                         "group_id" => 0)));
    }
 
    /**
* Function: group_permissions_to_db
* Migrates the group permissions from a YAML column to the "permissions" table.
*
* Versions: 2.0rc1 => 2.0rc2
*/
    function group_permissions_to_db() {
        $sql = SQL::current();
        if (!$sql->select("groups", "permissions"))
            return;
 
        echo __("Backing up groups...").
             test($groups = $sql->select("groups"));
 
        if (!$groups)
            return;
 
        $backup = $groups->fetchAll();
            
        $names = array();
        foreach($backup as $group) {
            $names[$group["id"]] = $group["name"];
            $permissions[$group["id"]] = empty($group["permissions"]) ? array() : YAML::load($group["permissions"]) ;
        }
 
        echo __("Dropping `groups` table...").
             test($sql->query("DROP TABLE __groups"));
 
        echo __("Creating `groups` table...").
             test($sql->query("CREATE TABLE __groups (
id INTEGER PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) DEFAULT '',
UNIQUE (name)
) DEFAULT CHARSET=utf8"));
 
        foreach ($names as $id => $name)
            echo _f("Restoring group `%s`...", array($name)).
                 test($sql->insert("groups",
                                   array("id" => $id,
                                        "name" => $name)));
        
        foreach ($permissions as $id => $permissions)
            foreach ($permissions as $permission)
                echo _f("Restoring permission `%s` on group `%s`...", array($permission, $names[$id])).
                     test($sql->insert("permissions",
                                       array("id" => $permission,
                                             "name" => $sql->select("permissions", "name", array("id" => $permission))->fetchColumn(),
                                             "group_id" => $id)));
    }
 
    /**
* Function: remove_old_files
* Removes old/unused files from previous installs.
*/
    function remove_old_files() {
        if (file_exists(INCLUDES_DIR."/config.php"))
            echo __("Removing `includes/config.php` file...").
                 test(@unlink(INCLUDES_DIR."/config.php"));
 
        if (file_exists(INCLUDES_DIR."/database.php"))
            echo __("Removing `includes/database.php` file...").
                 test(@unlink(INCLUDES_DIR."/database.php"));
 
        if (file_exists(INCLUDES_DIR."/rss.php"))
            echo __("Removing `includes/rss.php` file...").
                 test(@unlink(INCLUDES_DIR."/rss.php"));
 
        if (file_exists(INCLUDES_DIR."/bookmarklet.php"))
            echo __("Removing `includes/bookmarklet.php` file...").
                 test(@unlink(INCLUDES_DIR."/bookmarklet.php"));
    }
 
    /**
* Function: update_user_password_column
* Updates the @password@ column on the "users" table to have a length of 60.
*
* Versions: 2.0rc3 => 2.0
*/
    function update_user_password_column() {
        $sql = SQL::current();
        if (!$column = $sql->query("SHOW COLUMNS FROM __users WHERE Field = 'password'"))
             return;
 
        if ($column->fetchObject()->Type == "varchar(60)")
            return;
 
        echo __("Updating `password` column on `users` table...")."\n";
 
        echo " - ".__("Backing up `users` table...").
             test($backup = $sql->select("users"));
        
        if (!$backup)
            return;
 
        $backups = $backup->fetchAll();
 
        echo " - ".__("Dropping `users` table...").
             test($drop = $sql->query("DROP TABLE __users"));
 
        if (!$drop)
            return;
 
        echo " - ".__("Creating `users` table...").
             test($create = $sql->query("CREATE TABLE IF NOT EXISTS `__users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login` varchar(64) DEFAULT '',
`password` varchar(60) DEFAULT NULL,
`full_name` varchar(250) DEFAULT '',
`email` varchar(128) DEFAULT '',
`website` varchar(128) DEFAULT '',
`group_id` int(11) DEFAULT '0',
`joined_at` datetime DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
UNIQUE KEY `login` (`login`)
) DEFAULT CHARSET=utf8"));
 
        if (!$create) {
            echo " -".test(false, _f("Backup written to %s.", array("./_users.bak.txt")));
            return file_put_contents("./_users.bak.txt", var_export($backups, true));
        }
 
        foreach ($backups as $backup) {
            echo " - "._f("Restoring user #%d...", array($backup["id"])).
                 test($insert = $sql->insert("users", $backup), _f("Backup written to %s.", array("./_users.bak.txt")));
 
            if (!$insert)
                return file_put_contents("./_users.bak.txt", var_export($backups, true));
        }
 
        echo " -".test(true);
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title><?php echo __("Chyrp Upgrader"); ?></title>
<style type="text/css" media="screen">
html, body, ul, ol, li,
h1, h2, h3, h4, h5, h6,
form, fieldset, a, p {
margin: 0;
padding: 0;
border: 0;
}
html {
font-size: 62.5%;
}
body {
font: 1.25em/1.5em normal Verdana, Helvetica, Arial, sans-serif;
color: #626262;
background: #e8e8e8;
padding: 0 0 5em;
}
.window {
width: 30em;
background: #fff;
padding: 2em;
margin: 5em auto 0;
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
}
h1 {
color: #ccc;
font-size: 3em;
margin: 1em 0 .5em;
text-align: center;
}
h1.first {
margin-top: .25em;
}
h1.what_now {
margin-top: .5em;
}
code {
color: #06B;
font-family: Monaco, monospace;
}
a:link, a:visited {
color: #6B0;
}
pre.pane {
height: 15em;
overflow-y: auto;
margin: -2.68em -2.68em 4em;
padding: 2.5em;
background: #333;
color: #fff;
-webkit-border-top-left-radius: 2.5em;
-webkit-border-top-right-radius: 2.5em;
-moz-border-radius-topleft: 2.5em;
-moz-border-radius-topright: 2.5em;
}
span.yay { color: #0f0; }
span.boo { color: #f00; }
a.big,
button {
background: #eee;
display: block;
text-align: center;
margin-top: 2em;
padding: .75em 1em;
color: #777;
text-shadow: #fff .1em .1em 0;
font: 1em normal "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;
text-decoration: none;
border: 0;
cursor: pointer;
-webkit-border-radius: .5em;
-moz-border-radius: .5em;
}
button {
width: 100%;
}
a.big:hover,
button:hover {
background: #f5f5f5;
}
a.big:active,
button:active {
background: #e0e0e0;
}
ul, ol {
margin: 0 0 1em 2em;
}
li {
margin-bottom: .5em;
}
ul {
margin-bottom: 1.5em;
}
p {
margin-bottom: 1em;
}
</style>
</head>
<body>
<div class="window">
<?php if (!empty($_POST) and $_POST['upgrade'] == "yes"): ?>
<pre class="pane"><?php
        # Begin with file/config upgrade tasks.
 
        fix_htaccess();
 
        remove_beginning_slash_from_post_url();
 
        move_yml_yaml();
 
        update_protection();
 
        theme_default_to_stardust();
 
        Config::fallback("routes", array());
        Config::fallback("secure_hashkey", md5(random(32, true)));
        Config::fallback("enable_xmlrpc", true);
        Config::fallback("enable_ajax", true);
        Config::fallback("uploads_path", "/uploads/");
        Config::fallback("chyrp_url", Config::get("url"));
        Config::fallback("sql", Config::$yaml["database"]);
        Config::fallback("timezone", "America/Indiana/Indianapolis");
 
        Config::remove("rss_posts");
        Config::remove("time_offset");
 
        move_upload();
 
        remove_database_config_file();
 
        rename_database_setting_to_sql();
 
        update_custom_routes();
 
        default_db_adapter_to_mysql();
 
        # Perform database upgrade tasks after all the files/config upgrade tasks are done.
 
        # Prepare the SQL interface.
        $sql = SQL::current();
 
        # Set the SQL info.
        foreach (Config::$yaml["config"]["sql"] as $name => $value)
            $sql->$name = $value;
 
        # Initialize connection to SQL server.
        $sql->connect();
 
        tweets_to_posts();
 
        pages_parent_id_column();
 
        pages_list_order_column();
 
        make_posts_safe();
 
        rss_posts_to_feed_items();
 
        update_groups_to_yaml();
 
        add_permissions_table();
 
        add_sessions_table();
 
        update_permissions_table();
 
        update_post_status_column();
 
        add_post_attributes_table();
 
        post_xml_to_db();
 
        add_group_id_to_permissions();
 
        group_permissions_to_db();
 
        remove_old_files();
 
        update_user_password_column();
 
        # Perform Module/Feather upgrades.
 
        foreach ((array) Config::get("enabled_modules") as $module)
            if (file_exists(MAIN_DIR."/modules/".$module."/upgrades.php")) {
                ob_start();
                echo $begin = _f("Calling <span class=\"yay\">%s</span> Module's upgrader...", array($module))."\n";
                require MAIN_DIR."/modules/".$module."/upgrades.php";
                $buf = ob_get_contents();
                if (ob_get_contents() == $begin)
                    ob_end_clean();
                else
                    ob_end_flush();
            }
 
        foreach ((array) Config::get("enabled_feathers") as $feather)
            if (file_exists(MAIN_DIR."/feathers/".$feather."/upgrades.php")) {
                ob_start();
                echo $begin = _f("Calling <span class=\"yay\">%s</span> Feather's upgrader...", array($feather))."\n";
                require MAIN_DIR."/feathers/".$feather."/upgrades.php";
                $buf = ob_get_contents();
                if (ob_get_contents() == $begin)
                    ob_end_clean();
                else
                    ob_end_flush();
            }
?>
 
<?php echo __("Done!"); ?>
 
</pre>
<h1 class="what_now"><?php echo __("What now?"); ?></h1>
<ol>
<li><?php echo __("Look through the results up there for any failed tasks. If you see any and you can't figure out why, you can ask for help at the <a href=\"http://chyrp.net/community/\">Chyrp Community</a>."); ?></li>
<li><?php echo __("If any of your Modules or Feathers have new versions available for this release, check if an <code>upgrades.php</code> file exists in their main directory. If that file exists, run this upgrader again after enabling the Module or Feather and it will run the upgrade tasks."); ?></li>
<li><?php echo __("When you are done, you can delete this file. It doesn't pose any real threat on its own, but you should delete it anyway, just to be sure."); ?></li>
</ol>
<h1 class="tips"><?php echo __("Tips"); ?></h1>
<ul>
<li><?php echo __("If the admin area looks weird, try clearing your cache."); ?></li>
<li><?php echo __("As of v2.0, Chyrp uses time zones to determine timestamps. Please set your installation to the correct timezone at <a href=\"admin/index.php?action=general_settings\">General Settings</a>."); ?></li>
<li><?php echo __("Check the group permissions &ndash; they might have changed, and certain Admin functionality would be disabled until you enabled the permissions for the particular groups. <a href=\"admin/index.php?action=manage_groups\">Manage Groups &rarr;</a>"); ?></li>
</ul>
<a class="big" href="<?php echo (Config::check("url") ? Config::get("url") : Config::get("chyrp_url")); ?>"><?php echo __("All done!"); ?></a>
<?php else: ?>
<h1 class="first"><?php echo __("Halt!"); ?></h1>
<p><?php echo __("That button may look ready for a-clickin&rsquo;, but please take these preemptive measures before indulging:"); ?></p>
<ol>
<li><?php echo __("<strong>Make a backup of your installation.</strong> You never know."); ?></li>
<li><?php echo __("Disable any third-party Modules and Feathers."); ?></li>
<li><?php echo __("Ensure that the Chyrp installation directory is writable by the server."); ?></li>
</ol>
<p><?php echo __("If any of the upgrade processes fail, you can safely keep refreshing &ndash; it will only attempt to do tasks that are not already successfully completed. If you cannot figure something out, please make a topic (with details!) at the <a href=\"http://chyrp.net/community/\">Chyrp Community</a>."); ?></p>
<form action="upgrade.php" method="post">
<button type="submit" name="upgrade" value="yes"><?php echo __("Upgrade me!"); ?></button>
</form>
<?php endif; ?>
</div>
</body>
</html>