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 !
* Switched YAML libraries
* Fixed tag list being a resource hog
* Moved the Tumblr importer
* Call custom Feather filters by their instantiation
* Protected the import_* actions in the Admin
* Admin CSS fixes
vito (author)
Sun Jul 06 15:03:22 -0700 2008
commit  2db32be6ba575c3c12df1f929cdd986ebf1c1775
tree    6818691547ecbbba9ca6f79d8a2d28206b4a9366
parent  4d1eb696c4cd21dea6cefc15e0b5e1474a249aed
...
88
89
90
91
 
92
93
94
...
88
89
90
 
91
92
93
94
0
@@ -88,7 +88,7 @@
0
       $pages = array("manage" => array());
0
 
0
       foreach (Config::current()->enabled_feathers as $index => $feather) {
0
- $info = Spyc::YAMLLoad(FEATHERS_DIR."/".$feather."/info.yaml");
0
+ $info = Horde_Yaml::loadFile(FEATHERS_DIR."/".$feather."/info.yaml");
0
         $subnav["write"]["write_post&feather=".$feather] = array("title" => __($info["name"], $feather),
0
          "attributes" => ' id="list_feathers['.$feather.']"',
0
          "selected" => (isset($_GET['feather']) and $_GET['feather'] == $feather) or
...
3
4
5
6
7
8
9
10
11
12
13
14
...
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
21
22
 
23
24
25
...
32
33
34
35
 
36
37
38
 
39
40
41
...
51
52
53
54
 
55
56
57
...
60
61
62
63
 
64
65
66
 
67
68
69
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
72
73
...
76
77
78
 
79
...
3
4
5
 
 
 
 
 
 
6
7
8
...
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
28
29
30
31
...
38
39
40
 
41
42
43
 
44
45
46
47
...
57
58
59
 
60
61
62
63
...
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
...
99
100
101
102
103
0
@@ -3,12 +3,6 @@
0
 {% block title %}${ "Import" | translate }{% endblock %}
0
 
0
 {% block content %}
0
- {% if success_wordpress %}
0
- <p class="message yay">${ "WordPress content successfully imported!" | translate }</p>
0
- {% endif %}
0
- {% if invalid_wordpress %}
0
- <p class="message boo">${ "File does not seem to be a valid WordPress export file." | translate }</p>
0
- {% endif %}
0
       {% if success_chyrp %}
0
       <p class="message yay">${ "Chyrp content successfully imported!" | translate }</p>
0
       {% endif %}
0
@@ -18,8 +12,20 @@
0
       {% if invalid_chyrp_pages %}
0
       <p class="message boo">${ "Pages file does not seem to be a valid Chyrp export file." | translate }</p>
0
       {% endif %}
0
+ {% if success_wordpress %}
0
+ <p class="message yay">${ "WordPress content successfully imported!" | translate }</p>
0
+ {% endif %}
0
+ {% if invalid_wordpress %}
0
+ <p class="message boo">${ "File does not seem to be a valid WordPress export file." | translate }</p>
0
+ {% endif %}
0
+ {% if success_tumblr %}
0
+ <p class="message yay">${ "Tumblr content successfully imported!" | translate }</p>
0
+ {% endif %}
0
+ {% if invalid_tumblr %}
0
+ <p class="message boo">${ "URL does not seem to be a valid Tumblr site." | translate }</p>
0
+ {% endif %}
0
       <h1>${ "Import" | translate }</h1>
0
- <h2>${ "Chyrp" | translate }</h2>
0
+ <h2>Chyrp</h2>
0
       <form id="import_chyrp_form" class="split" action="{% admin "import_chyrp" %}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
0
         <fieldset>
0
           <p>
0
@@ -32,10 +38,10 @@
0
           </p>
0
           <p>
0
             <label for="media_url">${ "What URL is used for embedded media?" | translate }</label>
0
- <input class="text" type="text" name="media_url" value="$POST.media_url" id="media_url" />
0
+ <input class="text" type="text" name="media_url" value="" id="media_url" />
0
             <span class="sub">${ "(optional)" | translate }</span>
0
             <small>
0
- ${ "Usually something like <code>http://example.com/uploads/</code>" | translate }
0
+ ${ "Usually something like <code>http://example.com/uploads/</code>." | translate }
0
             </small>
0
           </p>
0
 
0
@@ -51,7 +57,7 @@
0
       <br />
0
       <hr />
0
       <br />
0
- <h2>${ "WordPress" | translate }</h2>
0
+ <h2>WordPress</h2>
0
       <form id="import_wordpress_form" class="split" action="{% admin "import_wordpress" %}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
0
         <fieldset>
0
           <p>
0
@@ -60,14 +66,31 @@
0
           </p>
0
           <p>
0
             <label for="media_url">${ "What URL is used for embedded media?" | translate }</label>
0
- <input class="text" type="text" name="media_url" value="$POST.media_url" id="media_url" />
0
+ <input class="text" type="text" name="media_url" value="" id="media_url" />
0
             <span class="sub">${ "(optional)" | translate }</span>
0
             <small>
0
- ${ "Usually something like <code>http://example.com/wp-content/uploads/</code>" | translate }
0
+ ${ "Usually something like <code>http://example.com/wp-content/uploads/</code>." | translate }
0
             </small>
0
           </p>
0
 
0
- ${ trigger.call("import_choose") }
0
+ <p class="buttons">
0
+ <button type="submit" class="yay"><img src="images/icons/success.png" alt="success" />${ "Import" | translate }</button>
0
+ </p>
0
+
0
+ <input type="hidden" name="hash" value="$site.secure_hashkey" id="hash" />
0
+ </fieldset>
0
+ </form>
0
+ <br />
0
+ <hr />
0
+ <br />
0
+ <h2>Tumblr</h2>
0
+ <form id="import_tumblr_form" class="split" action="{% admin "import_tumblr" %}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
0
+ <fieldset>
0
+ <p>
0
+ <label for="tumblr_url">${ "Your Tumblr URL" | translate }</label>
0
+ <input class="text" type="text" name="tumblr_url" value="" id="tumblr_url" />
0
+ <small>${ "Note: Audio tumbles cannot be imported." | translate }</small>
0
+ </p>
0
 
0
           <p class="buttons">
0
             <button type="submit" class="yay"><img src="images/icons/success.png" alt="success" />${ "Import" | translate }</button>
0
@@ -76,4 +99,5 @@
0
           <input type="hidden" name="hash" value="$site.secure_hashkey" id="hash" />
0
         </fieldset>
0
       </form>
0
+ ${ trigger.call("import_choose") }
0
 {% endblock %}
...
122
123
124
 
 
 
125
126
127
...
706
707
708
 
709
710
711
...
122
123
124
125
126
127
128
129
130
...
709
710
711
712
713
714
715
0
@@ -122,6 +122,9 @@ a:visited {
0
 #sub-nav {
0
   margin-top: 1em;
0
 }
0
+#sub-nav li {
0
+ float: left;
0
+}
0
 #sub-nav li a:link,
0
 #sub-nav li a:visited {
0
   float: left;
0
@@ -706,6 +709,7 @@ button.lite img,
0
   color: #999;
0
   border-bottom: 1px solid #ddd;
0
   display: block;
0
+ text-decoration: none !important;
0
 }
0
 .more_options_link:hover {
0
   color: #666;
...
60
61
62
63
 
 
64
65
66
67
68
69
 
70
71
72
...
179
180
181
 
 
 
182
183
184
185
 
186
187
188
189
190
191
192
 
193
194
195
...
197
198
199
200
 
201
202
203
204
205
 
206
207
208
...
211
212
213
214
215
 
...
60
61
62
 
63
64
65
66
67
68
69
 
70
71
72
73
...
180
181
182
183
184
185
186
187
188
 
189
190
191
192
193
194
195
 
196
197
198
199
...
201
202
203
 
204
205
206
207
208
 
209
210
211
212
...
215
216
217
 
218
219
0
@@ -60,13 +60,14 @@
0
     unlink($cache_file);
0
 
0
   if (file_exists($cache_file) and filemtime($cache_file) > filemtime($filename)) {
0
- header('Content-type: image/'.$fileextension);
0
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', @filemtime($cache_file)).' GMT');
0
+ header('Content-type: image/'.($fileextension == "jpg" ? "jpeg" : $fileextension));
0
     header("Expires: Mon, 26 Jul 2030 05:00:00 GMT");
0
     header('Content-Disposition: inline; filename='.str_replace("/", "", md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).".".$fileextension));
0
     readfile($cache_file);
0
     exit; # no need to create thumbnail - it already exists in the cache
0
   }
0
-
0
+exit;
0
   # determine php and gd versions
0
   $ver = (int) str_replace(".", "", phpversion());
0
   if ($ver >= 430)
0
@@ -179,17 +180,20 @@
0
     imagestring($thumbnail, $font, 2, $thumb_height-10, $string, $white);
0
   }
0
 
0
+ error_log($filename);
0
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s', @filemtime($filename)).' GMT');
0
+
0
   switch ($image_type) {
0
     case 2: # JPG
0
       header('Content-type: image/jpeg');
0
- header('Content-Disposition: inline; filename='.str_replace('/','',md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.jpeg'));
0
+ header('Content-Disposition: inline; filename='.md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.jpeg');
0
       imagejpeg($thumbnail, $cache_file, $quality);
0
       imagejpeg($thumbnail, "", $quality);
0
 
0
       break;
0
     case 3: # PNG
0
       header('Content-type: image/png');
0
- header('Content-Disposition: inline; filename='.str_replace('/','',md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.png'));
0
+ header('Content-Disposition: inline; filename='.md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.png');
0
       imagepng($thumbnail, $cache_file);
0
       imagepng($thumbnail);
0
       break;
0
@@ -197,12 +201,12 @@
0
     case 1: # GIF
0
       if (function_exists('imagegif')) {
0
         header('Content-type: image/gif');
0
- header('Content-Disposition: inline; filename='.str_replace('/','',md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.gif'));
0
+ header('Content-Disposition: inline; filename='.md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.gif');
0
         imagegif($thumbnail, $cache_file);
0
         imagegif($thumbnail);
0
       } else {
0
         header('Content-type: image/jpeg');
0
- header('Content-Disposition: inline; filename='.str_replace('/','',md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.jpg'));
0
+ header('Content-Disposition: inline; filename='.md5($filename.$thumb_size.$thumb_size_x.$thumb_size_y.$quality).'.jpg');
0
         imagejpeg($thumbnail, $cache_file);
0
         imagejpeg($thumbnail);
0
       }
0
@@ -211,4 +215,4 @@
0
 
0
   //clear memory
0
   imagedestroy($image);
0
- imagedestroy($thumbnail);
0
\ No newline at end of file
0
+ imagedestroy($thumbnail);
...
129
130
131
132
 
133
134
135
...
163
164
165
166
 
167
168
169
...
129
130
131
 
132
133
134
135
...
163
164
165
 
166
167
168
169
0
@@ -129,7 +129,7 @@
0
         error(__("Access Denied"), __("You do not have sufficient privileges to enable/disable extensions."));
0
 
0
       $dir = ($_POST['type'] == "module") ? MODULES_DIR : FEATHERS_DIR ;
0
- $info = Spyc::YAMLLoad($dir."/".$_POST['check']."/info.yaml");
0
+ $info = Horde_Yaml::loadFile($dir."/".$_POST['check']."/info.yaml");
0
       fallback($info["confirm"], "");
0
 
0
       if (!empty($info["confirm"]))
0
@@ -163,7 +163,7 @@
0
       if (file_exists($folder."/".$_POST["extension"]."/locale/".$config->locale.".mo"))
0
         load_translator($_POST["extension"], $folder."/".$_POST["extension"]."/locale/".$config->locale.".mo");
0
 
0
- $info = Spyc::YAMLLoad($folder."/".$_POST["extension"]."/info.yaml");
0
+ $info = Horde_Yaml::loadFile($folder."/".$_POST["extension"]."/info.yaml");
0
       fallback($info["uploader"], false);
0
       fallback($info["notifications"], array());
0
 
...
159
160
161
162
 
163
164
165
...
178
179
180
181
 
182
183
184
...
159
160
161
 
162
163
164
165
...
178
179
180
 
181
182
183
184
0
@@ -159,7 +159,7 @@
0
     if (file_exists(FEATHERS_DIR."/".$the_feather."/locale/".$config->locale.".mo"))
0
       load_translator($the_feather, FEATHERS_DIR."/".$the_feather."/locale/".$config->locale.".mo");
0
 
0
- $info = Spyc::YAMLLoad(FEATHERS_DIR."/".$the_feather."/info.yaml");
0
+ $info = Horde_Yaml::loadFile(FEATHERS_DIR."/".$the_feather."/info.yaml");
0
 ?>
0
       <li id="list_feathers[<?php echo $the_feather; ?>]" class="nav_<?php echo $the_feather; ?><?php if ($feather == $the_feather) echo ' selected'; ?>">
0
         <a href="javascript:activate_nav_tab('<?php echo $the_feather; ?>')"><?php echo $info["name"]; ?></a>
0
@@ -178,7 +178,7 @@
0
     if (file_exists(FEATHERS_DIR."/".$the_feather."/locale/".$config->locale.".mo"))
0
       load_translator($the_feather, FEATHERS_DIR."/".$the_feather."/locale/".$config->locale.".mo");
0
 
0
- $info = Spyc::YAMLLoad(FEATHERS_DIR."/".$the_feather."/info.yaml");
0
+ $info = Horde_Yaml::loadFile(FEATHERS_DIR."/".$the_feather."/info.yaml");
0
 ?>
0
       <form action="<?php echo $config->chyrp_url."/admin/?action=add_post"; ?>" id="<?php echo $the_feather; ?>_form" style="display: <?php echo $style; ?>" method="post" accept-charset="utf-8" enctype="multipart/form-data">
0
 <?php foreach ($feathers[$the_feather]->fields as $field): ?>
...
25
26
27
28
 
29
30
31
...
62
63
64
65
 
66
67
68
...
86
87
88
89
 
90
91
92
...
25
26
27
 
28
29
30
31
...
62
63
64
 
65
66
67
68
...
86
87
88
 
89
90
91
92
0
@@ -25,7 +25,7 @@
0
      * $file - The YAML file to load into <Config>.
0
      */
0
     public function load($file) {
0
- $this->yaml = Spyc::YAMLLoad($file);
0
+ $this->yaml = Horde_Yaml::loadFile($file);
0
       $arrays = array("enabled_modules", "enabled_feathers", "routes");
0
       foreach ($this->yaml as $setting => $value)
0
         if (in_array($setting, $arrays) and empty($value))
0
@@ -62,7 +62,7 @@
0
         Trigger::current()->call("change_setting", $setting, $value, $overwrite);
0
 
0
       # Generate the new YAML settings
0
- $contents.= Spyc::YAMLDump($this->yaml, 2, 60);
0
+ $contents.= Horde_Yaml::dump($this->yaml, 2, 60);
0
 
0
       if (!@file_put_contents(INCLUDES_DIR."/config.yaml.php", $contents) and is_array($errors))
0
         $errors[] = _f("Could not set \"<code>%s</code>\" configuration setting because <code>%s</code> is not writable.", array($setting, "/includes/config.yaml.php"));
0
@@ -86,7 +86,7 @@
0
         unset($this->yaml[0]);
0
 
0
       # Generate the new YAML settings
0
- $contents.= Spyc::YAMLDump($this->yaml, 2, 60);
0
+ $contents.= Horde_Yaml::dump($this->yaml, 2, 60);
0
 
0
       file_put_contents(INCLUDES_DIR."/config.yaml.php", $contents);
0
     }
...
45
46
47
48
 
49
50
51
...
75
76
77
78
 
79
80
81
...
45
46
47
 
48
49
50
51
...
75
76
77
 
78
79
80
81
0
@@ -45,7 +45,7 @@
0
      * $file - The YAML file to load into <SQL>.
0
      */
0
     public function load($file) {
0
- $this->yaml = Spyc::YAMLLoad($file);
0
+ $this->yaml = Horde_Yaml::loadFile($file);
0
       foreach ($this->yaml as $setting => $value)
0
         if (!is_int($setting)) # Don't load the "---"
0
           $this->$setting = $value;
0
@@ -75,7 +75,7 @@
0
         unset($this->yaml['<?php header("Status']);
0
 
0
       # Generate the new YAML settings
0
- $contents.= Spyc::YAMLDump($this->yaml, false, 0);
0
+ $contents.= Horde_Yaml::dump($this->yaml, false, 0);
0
 
0
       if (!@file_put_contents(INCLUDES_DIR."/database.yaml.php", $contents) and is_array($errors))
0
         $errors[] = _f("Could not set \"<code>%s</code>\" database setting because <code>%s</code> is not writable.", array($setting, "/includes/database.yaml.php"));
...
66
67
68
69
 
70
71
72
...
201
202
203
204
 
205
206
207
...
234
235
236
237
 
238
239
240
...
250
251
252
253
 
254
255
256
...
66
67
68
 
69
70
71
72
...
201
202
203
 
204
205
206
207
...
234
235
236
 
237
238
239
240
...
250
251
252
 
253
254
255
256
0
@@ -66,7 +66,7 @@
0
   require_once INCLUDES_DIR."/class/Query.php"; # SQL query handler
0
   require_once INCLUDES_DIR."/class/QueryBuilder.php"; # SQL query builder
0
   require_once INCLUDES_DIR."/class/Timestamp.php"; # A smarter DateTime class
0
- require_once INCLUDES_DIR."/lib/spyc.php"; # YAML parser
0
+ require_once INCLUDES_DIR."/lib/Yaml.php"; # YAML parser
0
 
0
   require_once INCLUDES_DIR."/class/Config.php"; # Configuration
0
   require_once INCLUDES_DIR."/class/SQL.php"; # Database/SQL jazz
0
@@ -201,7 +201,7 @@
0
 
0
     require FEATHERS_DIR."/".$feather."/".$feather.".php";
0
 
0
- $info = Spyc::YAMLLoad(FEATHERS_DIR."/".$feather."/info.yaml");
0
+ $info = Horde_Yaml::loadFile(FEATHERS_DIR."/".$feather."/info.yaml");
0
     $pluralizations[$feather] = $pluralizations["feathers"][$feather] = fallback($info["plural"], pluralize($feather), true);
0
   }
0
 
0
@@ -234,7 +234,7 @@
0
     $feathers[$feather] = new $camelized;
0
     $feathers[$feather]->safename = $feather;
0
 
0
- foreach (Spyc::YAMLLoad(FEATHERS_DIR."/".$feather."/info.yaml") as $key => $val)
0
+ foreach (Horde_Yaml::loadFile(FEATHERS_DIR."/".$feather."/info.yaml") as $key => $val)
0
       $feathers[$feather]->$key = $val;
0
   }
0
 
0
@@ -250,7 +250,7 @@
0
     $modules[$module] = new $camelized;
0
     $modules[$module]->safename = $module;
0
 
0
- foreach (Spyc::YAMLLoad(MODULES_DIR."/".$module."/info.yaml") as $key => $val)
0
+ foreach (Horde_Yaml::loadFile(MODULES_DIR."/".$module."/info.yaml") as $key => $val)
0
       $modules[$module]->$key = $val;
0
   }
0
 
...
830
831
832
833
834
835
 
836
837
 
 
 
 
 
838
839
840
...
843
844
845
846
 
 
 
 
 
847
848
849
 
850
851
 
 
852
853
854
855
856
857
858
 
 
859
860
 
 
 
861
862
863
...
900
901
902
903
904
905
906
907
908
 
 
 
 
 
909
910
911
912
 
913
914
 
 
915
916
917
...
976
977
978
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
979
980
981
...
995
996
997
998
 
999
1000
1001
...
1038
1039
1040
1041
 
1042
1043
1044
...
1074
1075
1076
1077
 
1078
1079
1080
...
1105
1106
1107
1108
 
1109
1110
1111
...
1140
1141
1142
1143
 
1144
1145
1146
...
830
831
832
 
 
 
833
834
 
835
836
837
838
839
840
841
842
...
845
846
847
 
848
849
850
851
852
853
 
 
854
855
 
856
857
858
 
859
 
 
 
 
860
861
862
 
863
864
865
866
867
868
...
905
906
907
 
 
 
908
909
910
911
912
913
914
915
916
917
918
 
919
920
921
922
923
924
925
926
...
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
...
1130
1131
1132
 
1133
1134
1135
1136
...
1173
1174
1175
 
1176
1177
1178
1179
...
1209
1210
1211
 
1212
1213
1214
1215
...
1240
1241
1242
 
1243
1244
1245
1246
...
1275
1276
1277
 
1278
1279
1280
1281
0
@@ -830,11 +830,13 @@
0
       if (!Visitor::current()->group()->can("add_post"))
0
         show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
0
 
0
- foreach (array("success_wordpress",
0
- "invalid_wordpress",
0
- "success_chyrp",
0
+ foreach (array("success_chyrp",
0
        "invalid_chyrp_posts",
0
- "invalid_chyrp_pages") as $message)
0
+ "invalid_chyrp_pages",
0
+ "success_wordpress",
0
+ "invalid_wordpress",
0
+ "success_tumblr",
0
+ "invalid_tumblr") as $message)
0
         $this->context[$message] = isset($_GET[$message]);
0
     }
0
 
0
@@ -843,21 +845,24 @@
0
      * Chyrp importing.
0
      */
0
     public function import_chyrp() {
0
- $trigger = Trigger::current();
0
+ if (empty($_POST))
0
+ redirect("/admin/?action=import");
0
+
0
+ if (!Visitor::current()->group()->can("add_post"))
0
+ show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
0
 
0
- if (isset($_FILES['posts_file']) and $_FILES['posts_file']['error'] == 0) {
0
- $posts = simplexml_load_file($_FILES['posts_file']['tmp_name']);
0
+ $trigger = Trigger::current();
0
 
0
- if (!$posts or $posts->generator != "Chyrp")
0
+ if (isset($_FILES['posts_file']) and $_FILES['posts_file']['error'] == 0)
0
+ if (!$posts = simplexml_load_file($_FILES['posts_file']['tmp_name']) or $posts->generator != "Chyrp")
0
           redirect("/admin/?action=import&invalid_chyrp_posts");
0
- }
0
 
0
- if (isset($_FILES['pages_file']) and $_FILES['pages_file']['error'] == 0) {
0
- $pages = simplexml_load_string(file_get_contents($_FILES['pages_file']['tmp_name']));
0
-
0
- if (!$pages or $pages->generator != "Chyrp")
0
+ if (isset($_FILES['pages_file']) and $_FILES['pages_file']['error'] == 0)
0
+ if (!$pages = simplexml_load_file($_FILES['pages_file']['tmp_name']) or $pages->generator != "Chyrp")
0
           redirect("/admin/?action=import&invalid_chyrp_pages");
0
- }
0
+
0
+ if (ini_get("memory_limit") < 20)
0
+ ini_set("memory_limit", "20M");
0
 
0
       if (isset($_FILES['posts_file']) and $_FILES['posts_file']['error'] == 0)
0
         foreach ($posts->entry as $entry) {
0
@@ -900,18 +905,22 @@
0
      * WordPress importing.
0
      */
0
     public function import_wordpress() {
0
- $trigger = Trigger::current();
0
- $config = Config::current();
0
-
0
       if (empty($_POST))
0
         redirect("/admin/?action=import");
0
 
0
+ if (!Visitor::current()->group()->can("add_post"))
0
+ show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
0
+
0
+ $config = Config::current();
0
+
0
       if (!in_array("text", $config->enabled_feathers))
0
         error(__("Missing Feather"), __("Importing from WordPress requires the Text feather to be installed and enabled."));
0
 
0
- if (ini_get("memory_limit") < 20) # Some imports are relatively large.
0
+ if (ini_get("memory_limit") < 20)
0
         ini_set("memory_limit", "20M");
0
 
0
+ $trigger = Trigger::current();
0
+
0
       $stupid_xml = file_get_contents($_FILES['xml_file']['tmp_name']);
0
       $sane_xml = preg_replace(array("/<wp:comment_content>/", "/<\/wp:comment_content>/"),
0
        array("<wp:comment_content><![CDATA[", "]]></wp:comment_content>"),
0
@@ -976,6 +985,132 @@
0
     }
0
 
0
     /**
0
+ * Function: import_tumblr
0
+ * Tumblr importing.
0
+ */
0
+ public function import_tumblr() {
0
+ if (empty($_POST))
0
+ redirect("/admin/?action=import");
0
+
0
+ if (!Visitor::current()->group()->can("add_post"))
0
+ show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
0
+
0
+ $config = Config::current();
0
+ if (!in_array("text", $config->enabled_feathers) or
0
+ !in_array("video", $config->enabled_feathers) or
0
+ !in_array("audio", $config->enabled_feathers) or
0
+ !in_array("chat", $config->enabled_feathers) or
0
+ !in_array("photo", $config->enabled_feathers) or
0
+ !in_array("quote", $config->enabled_feathers) or
0
+ !in_array("link", $config->enabled_feathers))
0
+ error(__("Missing Feather"), __("Importing from Tumblr requires the Text, Video, Audio, Chat, Photo, Quote, and Link feathers to be installed and enabled."));
0
+
0
+ if (ini_get("memory_limit") < 20)
0
+ ini_set("memory_limit", "20M");
0
+
0
+ if (!parse_url($_POST['tumblr_url'], PHP_URL_SCHEME))
0
+ $_POST['tumblr_url'] = "http://".$_POST['tumblr_url'];
0
+
0
+ set_time_limit(3600);
0
+ $url = rtrim($_POST['tumblr_url'], "/")."/api/read?num=50";
0
+ $api = preg_replace("/<(\/?)([^\-]+)\-([^ >]+)/", "<\\1\\2_\\3", get_remote($url));
0
+ $api = preg_replace("/ ([a-z]+)\-([a-z]+)=/", " \\1_\\2=", $api);
0
+ $xml = simplexml_load_string($api);
0
+
0
+ if (!isset($xml->tumblelog))
0
+ redirect("/admin/?action=import&invalid_tumblr");
0
+
0
+ $already_in = $posts = array();
0
+ foreach ($xml->posts->post as $post) {
0
+ $posts[] = $post;
0
+ $already_in[] = $post->attributes()->id;
0
+ }
0
+
0
+ while ($xml->posts->attributes()->total > count($posts)) {
0
+ set_time_limit(3600);
0
+ $api = preg_replace("/<(\/?)([a-z]+)\-([a-z]+)/", "<\\1\\2_\\3", get_remote($url."&start=".count($posts)));
0
+ $api = preg_replace("/ ([a-z]+)\-([a-z]+)=/", " \\1_\\2=", $api);
0
+ $xml = simplexml_load_string($api, "SimpleXMLElement", LIBXML_NOCDATA);
0
+ foreach ($xml->posts->post as $post)
0
+ if (!in_array($post->attributes()->id, $already_in)) {
0
+ $posts[] = $post;
0
+ $already_in[] = $post->attributes()->id;
0
+ }
0
+ }
0
+
0
+ function reverse($a, $b) {
0
+ if (empty($a) or empty($b)) return 0;
0
+ return (strtotime($a->attributes()->date) < strtotime($b->attributes()->date)) ? -1 : 1 ;
0
+ }
0
+
0
+ set_time_limit(3600);
0
+ usort($posts, "reverse");
0
+
0
+ foreach ($posts as $key => $post) {
0
+ set_time_limit(3600);
0
+ if ($post->attributes()->type == "audio")
0
+ continue; # Can't import Audio posts since Tumblr has the files locked in to Amazon.
0
+
0
+ $translate_types = array("regular" => "text", "conversation" => "chat");
0
+
0
+ $clean = "";
0
+ switch($post->attributes()->type) {
0
+ case "regular":
0
+ $title = fallback($post->regular_title);
0
+ $values = array("title" => $title,
0
+ "body" => $post->regular_body);
0
+ $clean = sanitize($title);
0
+ break;
0
+ case "video":
0
+ $values = array("embed" => $post->video_player,
0
+ "caption" => fallback($post->video_caption));
0
+ break;
0
+ case "conversation":
0
+ $title = fallback($post->conversation_title);
0
+
0
+ $lines = array();
0
+ foreach ($post->conversation_line as $line)
0
+ $lines[] = $line->attributes()->label." ".$line;
0
+
0
+ $values = array("title" => $title,
0
+ "dialogue" => implode("\n", $lines));
0
+ $clean = sanitize($title);
0
+ break;
0
+ case "photo":
0
+ $values = array("filename" => upload_from_url($post->photo_url[0]),
0
+ "caption" => fallback($post->photo_caption));
0
+ break;
0
+ case "quote":
0
+ $values = array("quote" => $post->quote_text,
0
+ "source" => preg_replace("/^&mdash; /", "",
0
+ fallback($post->quote_source)));
0
+ break;
0
+ case "link":
0
+ $name = fallback($post->link_text);
0
+ $values = array("name" => $name,
0
+ "source" => $post->link_url,
0
+ "description" => fallback($post->link_description));
0
+ $clean = sanitize($name);
0
+ break;
0
+ }
0
+
0
+
0
+ $_POST['status'] = "public";
0
+ $_POST['pinned'] = false;
0
+ $_POST['created_at'] = datetime((int) $post->attributes()->unix_timestamp);
0
+ $_POST['feather'] = str_replace(array_keys($translate_types),
0
+ array_values($translate_types),
0
+ $post->attributes()->type);
0
+
0
+ $new_post = Post::add($values, $clean, Post::check_url($clean));
0
+
0
+ Trigger::current()->call("import_tumble", $post, $new_post);
0
+ }
0
+
0
+ redirect("/admin/?action=import&success_tumblr");
0
+ }
0
+
0
+ /**
0
      * Function: extend_modules
0
      * Module enabling/disabling.
0
      */
0
@@ -995,7 +1130,7 @@
0
           if (file_exists(MODULES_DIR."/".$folder."/locale/".$config->locale.".mo"))
0
             load_translator($folder, MODULES_DIR."/".$folder."/locale/".$config->locale.".mo");
0
 
0
- $info = Spyc::YAMLLoad(MODULES_DIR."/".$folder."/info.yaml");
0
+ $info = Horde_Yaml::loadFile(MODULES_DIR."/".$folder."/info.yaml");
0
 
0
      &nb