[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
[840] | 4 | # This file is part of importExport, a plugin for DotClear2. |
---|
[0] | 5 | # |
---|
[840] | 6 | # Copyright (c) 2003-2012 Olivier Meunier & Association Dotclear |
---|
[0] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | if (!defined('DC_RC_PATH')) { return; } |
---|
| 13 | |
---|
[840] | 14 | class flatImport extends flatBackup |
---|
[0] | 15 | { |
---|
| 16 | private $core; |
---|
| 17 | private $con; |
---|
| 18 | private $prefix; |
---|
[2485] | 19 | |
---|
[0] | 20 | private $dc_version; |
---|
| 21 | private $dc_major; |
---|
| 22 | private $mode; |
---|
[2485] | 23 | |
---|
[0] | 24 | private $blog_url; |
---|
| 25 | private $blog_name; |
---|
| 26 | private $blog_desc; |
---|
[2485] | 27 | |
---|
[0] | 28 | private $users = array(); |
---|
[2485] | 29 | |
---|
[0] | 30 | public $old_ids = array( |
---|
| 31 | 'category' => array(), |
---|
| 32 | 'post' => array(), |
---|
| 33 | 'media' => array() |
---|
| 34 | ); |
---|
[2485] | 35 | |
---|
[0] | 36 | public $stack = array( |
---|
| 37 | 'categories'=>null, |
---|
| 38 | 'cat_id'=>1, |
---|
| 39 | 'cat_lft'=>array(), |
---|
| 40 | 'post_id'=>1, |
---|
| 41 | 'media_id'=>1, |
---|
| 42 | 'comment_id'=>1, |
---|
[2485] | 43 | 'link_id'=>1, |
---|
| 44 | 'log_id' => 1 |
---|
[0] | 45 | ); |
---|
[2485] | 46 | |
---|
[0] | 47 | public $has_categories = false; |
---|
[2485] | 48 | |
---|
[0] | 49 | public function __construct($core,$file) |
---|
| 50 | { |
---|
| 51 | parent::__construct($file); |
---|
[2485] | 52 | |
---|
[0] | 53 | $first_line = fgets($this->fp); |
---|
| 54 | if (strpos($first_line,'///DOTCLEAR|') !== 0) { |
---|
| 55 | throw new Exception(__('File is not a DotClear backup.')); |
---|
| 56 | } |
---|
[2485] | 57 | |
---|
[0] | 58 | @set_time_limit(300); |
---|
[2485] | 59 | |
---|
[0] | 60 | $l = explode('|',$first_line); |
---|
[2485] | 61 | |
---|
[0] | 62 | if (isset($l[1])) { |
---|
| 63 | $this->dc_version = $l[1]; |
---|
| 64 | } |
---|
[2485] | 65 | |
---|
[0] | 66 | $this->mode = isset($l[2]) ? strtolower(trim($l[2])) : 'single'; |
---|
| 67 | if ($this->mode != 'full' && $this->mode != 'single') { |
---|
| 68 | $this->mode = 'single'; |
---|
| 69 | } |
---|
[2485] | 70 | |
---|
[0] | 71 | if (version_compare('1.2',$this->dc_version,'<=') && |
---|
| 72 | version_compare('1.3',$this->dc_version,'>')) { |
---|
| 73 | $this->dc_major_version = '1.2'; |
---|
| 74 | } else { |
---|
| 75 | $this->dc_major_version = '2.0'; |
---|
| 76 | } |
---|
[2485] | 77 | |
---|
[0] | 78 | $this->core =& $core; |
---|
| 79 | $this->con =& $core->con; |
---|
| 80 | $this->prefix = $core->prefix; |
---|
[2485] | 81 | |
---|
[0] | 82 | $this->cur_blog = $this->con->openCursor($this->prefix.'blog'); |
---|
| 83 | $this->cur_category = $this->con->openCursor($this->prefix.'category'); |
---|
| 84 | $this->cur_link = $this->con->openCursor($this->prefix.'link'); |
---|
| 85 | $this->cur_setting = $this->con->openCursor($this->prefix.'setting'); |
---|
| 86 | $this->cur_user = $this->con->openCursor($this->prefix.'user'); |
---|
[233] | 87 | $this->cur_pref = $this->con->openCursor($this->prefix.'pref'); |
---|
[0] | 88 | $this->cur_permissions = $this->con->openCursor($this->prefix.'permissions'); |
---|
| 89 | $this->cur_post = $this->con->openCursor($this->prefix.'post'); |
---|
| 90 | $this->cur_meta = $this->con->openCursor($this->prefix.'meta'); |
---|
| 91 | $this->cur_media = $this->con->openCursor($this->prefix.'media'); |
---|
| 92 | $this->cur_post_media = $this->con->openCursor($this->prefix.'post_media'); |
---|
| 93 | $this->cur_log = $this->con->openCursor($this->prefix.'log'); |
---|
| 94 | $this->cur_ping = $this->con->openCursor($this->prefix.'ping'); |
---|
| 95 | $this->cur_comment = $this->con->openCursor($this->prefix.'comment'); |
---|
| 96 | $this->cur_spamrule = $this->con->openCursor($this->prefix.'spamrule'); |
---|
| 97 | $this->cur_version = $this->con->openCursor($this->prefix.'version'); |
---|
[2485] | 98 | |
---|
[0] | 99 | # --BEHAVIOR-- importInit |
---|
| 100 | $this->core->callBehavior('importInit',$this,$this->core); |
---|
| 101 | } |
---|
[2485] | 102 | |
---|
[0] | 103 | public function importSingle() |
---|
| 104 | { |
---|
| 105 | if ($this->mode != 'single') { |
---|
| 106 | throw new Exception(__('File is not a single blog export.')); |
---|
| 107 | } |
---|
[2485] | 108 | |
---|
[0] | 109 | if (!$this->core->auth->check('admin',$this->core->blog->id)) { |
---|
| 110 | throw new Exception(__('Permission denied.')); |
---|
| 111 | } |
---|
[2485] | 112 | |
---|
[0] | 113 | $this->blog_id = $this->core->blog->id; |
---|
[2485] | 114 | |
---|
[0] | 115 | $this->stack['categories'] = $this->con->select( |
---|
| 116 | 'SELECT cat_id, cat_title, cat_url '. |
---|
| 117 | 'FROM '.$this->prefix.'category '. |
---|
| 118 | "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " |
---|
| 119 | ); |
---|
[2485] | 120 | |
---|
[0] | 121 | $rs = $this->con->select('SELECT MAX(cat_id) FROM '.$this->prefix.'category'); |
---|
| 122 | $this->stack['cat_id'] = ((integer) $rs->f(0))+1; |
---|
[2485] | 123 | |
---|
[0] | 124 | $rs = $this->con->select('SELECT MAX(link_id) FROM '.$this->prefix.'link'); |
---|
| 125 | $this->stack['link_id'] = ((integer) $rs->f(0))+1; |
---|
[2485] | 126 | |
---|
[0] | 127 | $rs = $this->con->select('SELECT MAX(post_id) FROM '.$this->prefix.'post'); |
---|
| 128 | $this->stack['post_id'] = ((integer) $rs->f(0))+1; |
---|
[2485] | 129 | |
---|
[0] | 130 | $rs = $this->con->select('SELECT MAX(media_id) FROM '.$this->prefix.'media'); |
---|
| 131 | $this->stack['media_id'] = ((integer) $rs->f(0))+1; |
---|
[2485] | 132 | |
---|
[0] | 133 | $rs = $this->con->select('SELECT MAX(comment_id) FROM '.$this->prefix.'comment'); |
---|
| 134 | $this->stack['comment_id'] = ((integer) $rs->f(0))+1; |
---|
[2485] | 135 | |
---|
| 136 | $rs = $this->con->select('SELECT MAX(log_id) FROM '.$this->prefix.'log'); |
---|
| 137 | $this->stack['log_id'] = ((integer) $rs->f(0))+1; |
---|
| 138 | |
---|
[0] | 139 | $rs = $this->con->select( |
---|
| 140 | 'SELECT MAX(cat_rgt) AS cat_rgt FROM '.$this->prefix.'category '. |
---|
| 141 | "WHERE blog_id = '".$this->con->escape($this->core->blog->id)."'" |
---|
| 142 | ); |
---|
[2485] | 143 | |
---|
[0] | 144 | if ((integer) $rs->cat_rgt > 0) { |
---|
| 145 | $this->has_categories = true; |
---|
| 146 | $this->stack['cat_lft'][$this->core->blog->id] = (integer) $rs->cat_rgt + 1; |
---|
| 147 | } |
---|
[2485] | 148 | |
---|
[0] | 149 | $this->con->begin(); |
---|
[2485] | 150 | |
---|
[0] | 151 | try |
---|
| 152 | { |
---|
| 153 | $last_line_name = ''; |
---|
| 154 | $constrained = array('post', 'meta', 'post_media', 'ping', 'comment'); |
---|
[2485] | 155 | |
---|
[0] | 156 | while (($line = $this->getLine()) !== false) |
---|
| 157 | { |
---|
| 158 | # import DC 1.2.x, we fix lines before insert |
---|
| 159 | if ($this->dc_major_version == '1.2') { |
---|
| 160 | $this->prepareDC12line($line); |
---|
| 161 | } |
---|
[2485] | 162 | |
---|
[0] | 163 | if ($last_line_name != $line->__name) { |
---|
| 164 | if (in_array($last_line_name,$constrained)) { |
---|
| 165 | # UNDEFER |
---|
[3565] | 166 | if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli' || $this->con->driver() == 'mysqlimb4') $this->con->execute('SET foreign_key_checks = 1'); |
---|
[0] | 167 | if ($this->con->driver() == 'pgsql') $this->con->execute('SET CONSTRAINTS ALL DEFERRED'); |
---|
| 168 | } |
---|
[2485] | 169 | |
---|
[0] | 170 | if (in_array($line->__name,$constrained)) { |
---|
| 171 | # DEFER |
---|
[3565] | 172 | if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli' || $this->con->driver() == 'mysqlimb4') $this->con->execute('SET foreign_key_checks = 0'); |
---|
[0] | 173 | if ($this->con->driver() == 'pgsql') $this->con->execute('SET CONSTRAINTS ALL IMMEDIATE'); |
---|
| 174 | } |
---|
[2485] | 175 | |
---|
[0] | 176 | $last_line_name = $line->__name; |
---|
| 177 | } |
---|
[2485] | 178 | |
---|
[0] | 179 | switch ($line->__name) |
---|
| 180 | { |
---|
| 181 | case 'category': |
---|
| 182 | $this->insertCategorySingle($line); |
---|
| 183 | break; |
---|
| 184 | case 'link': |
---|
| 185 | $this->insertLinkSingle($line); |
---|
| 186 | break; |
---|
| 187 | case 'post': |
---|
| 188 | $this->insertPostSingle($line); |
---|
| 189 | break; |
---|
| 190 | case 'meta': |
---|
| 191 | $this->insertMetaSingle($line); |
---|
| 192 | break; |
---|
| 193 | case 'media': |
---|
| 194 | $this->insertMediaSingle($line); |
---|
| 195 | break; |
---|
| 196 | case 'post_media': |
---|
| 197 | $this->insertPostMediaSingle($line); |
---|
| 198 | break; |
---|
| 199 | case 'ping': |
---|
| 200 | $this->insertPingSingle($line); |
---|
| 201 | break; |
---|
| 202 | case 'comment': |
---|
| 203 | $this->insertCommentSingle($line); |
---|
| 204 | break; |
---|
| 205 | } |
---|
[2485] | 206 | |
---|
[0] | 207 | # --BEHAVIOR-- importSingle |
---|
| 208 | $this->core->callBehavior('importSingle',$line,$this,$this->core); |
---|
| 209 | } |
---|
[2485] | 210 | |
---|
[3565] | 211 | if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli' || $this->con->driver() == 'mysqlimb4') $this->con->execute('SET foreign_key_checks = 1'); |
---|
[0] | 212 | if ($this->con->driver() == 'pgsql') $this->con->execute('SET CONSTRAINTS ALL DEFERRED'); |
---|
| 213 | } |
---|
| 214 | catch (Exception $e) |
---|
| 215 | { |
---|
[2485] | 216 | @fclose($this->fp); |
---|
[0] | 217 | $this->con->rollback(); |
---|
[2485] | 218 | throw new Exception($e->getMessage().' - '.sprintf(__('Error raised at line %s'),$line->__line)); |
---|
[0] | 219 | } |
---|
[2485] | 220 | @fclose($this->fp); |
---|
[0] | 221 | $this->con->commit(); |
---|
| 222 | } |
---|
[2485] | 223 | |
---|
[0] | 224 | public function importFull() |
---|
| 225 | { |
---|
| 226 | if ($this->mode != 'full') { |
---|
| 227 | throw new Exception(__('File is not a full export.')); |
---|
| 228 | } |
---|
[2485] | 229 | |
---|
[0] | 230 | if (!$this->core->auth->isSuperAdmin()) { |
---|
| 231 | throw new Exception(__('Permission denied.')); |
---|
| 232 | } |
---|
[2485] | 233 | |
---|
[0] | 234 | $this->con->begin(); |
---|
| 235 | $this->con->execute('DELETE FROM '.$this->prefix.'blog'); |
---|
| 236 | $this->con->execute('DELETE FROM '.$this->prefix.'media'); |
---|
| 237 | $this->con->execute('DELETE FROM '.$this->prefix.'spamrule'); |
---|
| 238 | $this->con->execute('DELETE FROM '.$this->prefix.'setting'); |
---|
[2485] | 239 | $this->con->execute('DELETE FROM '.$this->prefix.'log'); |
---|
| 240 | |
---|
[0] | 241 | try |
---|
| 242 | { |
---|
| 243 | while (($line = $this->getLine()) !== false) |
---|
| 244 | { |
---|
| 245 | switch ($line->__name) |
---|
| 246 | { |
---|
| 247 | case 'blog': |
---|
| 248 | $this->insertBlog($line); |
---|
| 249 | break; |
---|
| 250 | case 'category': |
---|
| 251 | $this->insertCategory($line); |
---|
| 252 | break; |
---|
| 253 | case 'link': |
---|
| 254 | $this->insertLink($line); |
---|
| 255 | break; |
---|
| 256 | case 'setting': |
---|
| 257 | $this->insertSetting($line); |
---|
| 258 | break; |
---|
| 259 | case 'user': |
---|
| 260 | $this->insertUser($line); |
---|
| 261 | break; |
---|
[233] | 262 | case 'pref': |
---|
| 263 | $this->insertPref($line); |
---|
| 264 | break; |
---|
[0] | 265 | case 'permissions': |
---|
| 266 | $this->insertPermissions($line); |
---|
| 267 | break; |
---|
| 268 | case 'post': |
---|
| 269 | $this->insertPost($line); |
---|
| 270 | break; |
---|
| 271 | case 'meta': |
---|
| 272 | $this->insertMeta($line); |
---|
| 273 | break; |
---|
| 274 | case 'media': |
---|
| 275 | $this->insertMedia($line); |
---|
| 276 | break; |
---|
| 277 | case 'post_media': |
---|
| 278 | $this->insertPostMedia($line); |
---|
| 279 | break; |
---|
| 280 | case 'log'; |
---|
| 281 | $this->insertLog($line); |
---|
| 282 | break; |
---|
| 283 | case 'ping': |
---|
| 284 | $this->insertPing($line); |
---|
| 285 | break; |
---|
| 286 | case 'comment': |
---|
| 287 | $this->insertComment($line); |
---|
| 288 | break; |
---|
| 289 | case 'spamrule': |
---|
| 290 | $this->insertSpamRule($line); |
---|
| 291 | break; |
---|
| 292 | } |
---|
| 293 | # --BEHAVIOR-- importFull |
---|
| 294 | $this->core->callBehavior('importFull',$line,$this,$this->core); |
---|
| 295 | } |
---|
| 296 | } |
---|
| 297 | catch (Exception $e) |
---|
| 298 | { |
---|
[2485] | 299 | @fclose($this->fp); |
---|
[0] | 300 | $this->con->rollback(); |
---|
[2485] | 301 | throw new Exception($e->getMessage().' - '.sprintf(__('Error raised at line %s'),$line->__line)); |
---|
[0] | 302 | } |
---|
[2485] | 303 | @fclose($this->fp); |
---|
[0] | 304 | $this->con->commit(); |
---|
| 305 | } |
---|
[2485] | 306 | |
---|
[0] | 307 | private function insertBlog($blog) |
---|
| 308 | { |
---|
| 309 | $this->cur_blog->clean(); |
---|
[2485] | 310 | |
---|
[0] | 311 | $this->cur_blog->blog_id = (string) $blog->blog_id; |
---|
| 312 | $this->cur_blog->blog_uid = (string) $blog->blog_uid; |
---|
| 313 | $this->cur_blog->blog_creadt = (string) $blog->blog_creadt; |
---|
| 314 | $this->cur_blog->blog_upddt = (string) $blog->blog_upddt; |
---|
| 315 | $this->cur_blog->blog_url = (string) $blog->blog_url; |
---|
| 316 | $this->cur_blog->blog_name = (string) $blog->blog_name; |
---|
| 317 | $this->cur_blog->blog_desc = (string) $blog->blog_desc; |
---|
[2485] | 318 | |
---|
[0] | 319 | $this->cur_blog->blog_status = $blog->exists('blog_status') ? (integer) $blog->blog_status : 1; |
---|
[2485] | 320 | |
---|
[0] | 321 | $this->cur_blog->insert(); |
---|
| 322 | } |
---|
[2485] | 323 | |
---|
[0] | 324 | private function insertCategory($category) |
---|
| 325 | { |
---|
| 326 | $this->cur_category->clean(); |
---|
[2485] | 327 | |
---|
[0] | 328 | $this->cur_category->cat_id = (string) $category->cat_id; |
---|
| 329 | $this->cur_category->blog_id = (string) $category->blog_id; |
---|
| 330 | $this->cur_category->cat_title = (string) $category->cat_title; |
---|
| 331 | $this->cur_category->cat_url = (string) $category->cat_url; |
---|
| 332 | $this->cur_category->cat_desc = (string) $category->cat_desc; |
---|
[2485] | 333 | |
---|
[0] | 334 | if (!$this->has_categories && $category->exists('cat_lft') && $category->exists('cat_rgt')) { |
---|
| 335 | $this->cur_category->cat_lft = (integer) $category->cat_lft; |
---|
| 336 | $this->cur_category->cat_rgt = (integer) $category->cat_rgt; |
---|
| 337 | } else { |
---|
| 338 | if (!isset($this->stack['cat_lft'][$category->blog_id])) { |
---|
| 339 | $this->stack['cat_lft'][$category->blog_id] = 2; |
---|
| 340 | } |
---|
| 341 | $this->cur_category->cat_lft = $this->stack['cat_lft'][$category->blog_id]++; |
---|
| 342 | $this->cur_category->cat_rgt = $this->stack['cat_lft'][$category->blog_id]++; |
---|
| 343 | } |
---|
[2485] | 344 | |
---|
[0] | 345 | $this->cur_category->insert(); |
---|
| 346 | } |
---|
[2485] | 347 | |
---|
[0] | 348 | private function insertLink($link) |
---|
| 349 | { |
---|
| 350 | $this->cur_link->clean(); |
---|
[2485] | 351 | |
---|
[0] | 352 | $this->cur_link->link_id = (integer) $link->link_id; |
---|
| 353 | $this->cur_link->blog_id = (string) $link->blog_id; |
---|
| 354 | $this->cur_link->link_href = (string) $link->link_href; |
---|
| 355 | $this->cur_link->link_title = (string) $link->link_title; |
---|
| 356 | $this->cur_link->link_desc = (string) $link->link_desc; |
---|
| 357 | $this->cur_link->link_lang = (string) $link->link_lang; |
---|
| 358 | $this->cur_link->link_xfn = (string) $link->link_xfn; |
---|
| 359 | $this->cur_link->link_position = (integer) $link->link_position; |
---|
[2485] | 360 | |
---|
[0] | 361 | $this->cur_link->insert(); |
---|
| 362 | } |
---|
[2485] | 363 | |
---|
[0] | 364 | private function insertSetting($setting) |
---|
| 365 | { |
---|
| 366 | $this->cur_setting->clean(); |
---|
[2485] | 367 | |
---|
[0] | 368 | $this->cur_setting->setting_id = (string) $setting->setting_id; |
---|
| 369 | $this->cur_setting->blog_id = !$setting->blog_id ? null : (string) $setting->blog_id; |
---|
| 370 | $this->cur_setting->setting_ns = (string) $setting->setting_ns; |
---|
| 371 | $this->cur_setting->setting_value = (string) $setting->setting_value; |
---|
| 372 | $this->cur_setting->setting_type = (string) $setting->setting_type; |
---|
| 373 | $this->cur_setting->setting_label = (string) $setting->setting_label; |
---|
[2485] | 374 | |
---|
[0] | 375 | $this->cur_setting->insert(); |
---|
| 376 | } |
---|
[2485] | 377 | |
---|
[233] | 378 | private function insertPref($pref) |
---|
| 379 | { |
---|
[294] | 380 | if ($this->prefExists($pref->pref_ws,$pref->pref_id,$pref->user_id)) { |
---|
| 381 | return; |
---|
| 382 | } |
---|
[2485] | 383 | |
---|
[233] | 384 | $this->cur_pref->clean(); |
---|
[2485] | 385 | |
---|
[233] | 386 | $this->cur_pref->pref_id = (string) $pref->pref_id; |
---|
| 387 | $this->cur_pref->user_id = !$pref->user_id ? null : (string) $pref->user_id; |
---|
| 388 | $this->cur_pref->pref_ws = (string) $pref->pref_ws; |
---|
| 389 | $this->cur_pref->pref_value = (string) $pref->pref_value; |
---|
| 390 | $this->cur_pref->pref_type = (string) $pref->pref_type; |
---|
| 391 | $this->cur_pref->pref_label = (string) $pref->pref_label; |
---|
[2485] | 392 | |
---|
[233] | 393 | $this->cur_pref->insert(); |
---|
| 394 | } |
---|
[2485] | 395 | |
---|
[0] | 396 | private function insertUser($user) |
---|
| 397 | { |
---|
| 398 | if ($this->userExists($user->user_id)) { |
---|
| 399 | return; |
---|
| 400 | } |
---|
[2485] | 401 | |
---|
[0] | 402 | $this->cur_user->clean(); |
---|
[2485] | 403 | |
---|
[0] | 404 | $this->cur_user->user_id = (string) $user->user_id; |
---|
| 405 | $this->cur_user->user_super = (integer) $user->user_super; |
---|
| 406 | $this->cur_user->user_pwd = (string) $user->user_pwd; |
---|
| 407 | $this->cur_user->user_recover_key = (string) $user->user_recover_key; |
---|
| 408 | $this->cur_user->user_name = (string) $user->user_name; |
---|
| 409 | $this->cur_user->user_firstname = (string) $user->user_firstname; |
---|
| 410 | $this->cur_user->user_displayname = (string) $user->user_displayname; |
---|
| 411 | $this->cur_user->user_email = (string) $user->user_email; |
---|
| 412 | $this->cur_user->user_url = (string) $user->user_url; |
---|
| 413 | $this->cur_user->user_default_blog = !$user->user_default_blog ? null : (string) $user->user_default_blog; |
---|
| 414 | $this->cur_user->user_lang = (string) $user->user_lang; |
---|
| 415 | $this->cur_user->user_tz = (string) $user->user_tz; |
---|
| 416 | $this->cur_user->user_post_status = (integer) $user->user_post_status; |
---|
| 417 | $this->cur_user->user_creadt = (string) $user->user_creadt; |
---|
| 418 | $this->cur_user->user_upddt = (string) $user->user_upddt; |
---|
[2485] | 419 | |
---|
[0] | 420 | $this->cur_user->user_desc = $user->exists('user_desc') ? (string) $user->user_desc : null; |
---|
| 421 | $this->cur_user->user_options = $user->exists('user_options') ? (string) $user->user_options : null; |
---|
| 422 | $this->cur_user->user_status = $user->exists('user_status') ? (integer) $user->user_status : 1; |
---|
[2485] | 423 | |
---|
[0] | 424 | $this->cur_user->insert(); |
---|
[2485] | 425 | |
---|
[0] | 426 | $this->stack['users'][$user->user_id] = true; |
---|
| 427 | } |
---|
[2485] | 428 | |
---|
[0] | 429 | private function insertPermissions($permissions) |
---|
| 430 | { |
---|
| 431 | $this->cur_permissions->clean(); |
---|
[2485] | 432 | |
---|
[0] | 433 | $this->cur_permissions->user_id = (string) $permissions->user_id; |
---|
| 434 | $this->cur_permissions->blog_id = (string) $permissions->blog_id; |
---|
| 435 | $this->cur_permissions->permissions = (string) $permissions->permissions; |
---|
[2485] | 436 | |
---|
[0] | 437 | $this->cur_permissions->insert(); |
---|
| 438 | } |
---|
[2485] | 439 | |
---|
[0] | 440 | private function insertPost($post) |
---|
| 441 | { |
---|
| 442 | $this->cur_post->clean(); |
---|
[2485] | 443 | |
---|
[0] | 444 | $cat_id = (integer) $post->cat_id; |
---|
| 445 | if (!$cat_id) { |
---|
| 446 | $cat_id = null; |
---|
| 447 | } |
---|
[2485] | 448 | |
---|
[0] | 449 | $post_password = $post->post_password ? (string) $post->post_password : null; |
---|
[2485] | 450 | |
---|
[0] | 451 | $this->cur_post->post_id = (integer) $post->post_id; |
---|
| 452 | $this->cur_post->blog_id = (string) $post->blog_id; |
---|
| 453 | $this->cur_post->user_id = (string) $this->getUserId($post->user_id); |
---|
| 454 | $this->cur_post->cat_id = $cat_id; |
---|
| 455 | $this->cur_post->post_dt = (string) $post->post_dt; |
---|
| 456 | $this->cur_post->post_creadt = (string) $post->post_creadt; |
---|
| 457 | $this->cur_post->post_upddt = (string) $post->post_upddt; |
---|
| 458 | $this->cur_post->post_password = $post_password; |
---|
| 459 | $this->cur_post->post_type = (string) $post->post_type; |
---|
| 460 | $this->cur_post->post_format = (string) $post->post_format; |
---|
| 461 | $this->cur_post->post_url = (string) $post->post_url; |
---|
| 462 | $this->cur_post->post_lang = (string) $post->post_lang; |
---|
| 463 | $this->cur_post->post_title = (string) $post->post_title; |
---|
| 464 | $this->cur_post->post_excerpt = (string) $post->post_excerpt; |
---|
| 465 | $this->cur_post->post_excerpt_xhtml = (string) $post->post_excerpt_xhtml; |
---|
| 466 | $this->cur_post->post_content = (string) $post->post_content; |
---|
| 467 | $this->cur_post->post_content_xhtml = (string) $post->post_content_xhtml; |
---|
| 468 | $this->cur_post->post_notes = (string) $post->post_notes; |
---|
| 469 | $this->cur_post->post_words = (string) $post->post_words; |
---|
| 470 | $this->cur_post->post_meta = (string) $post->post_meta; |
---|
| 471 | $this->cur_post->post_status = (integer) $post->post_status; |
---|
| 472 | $this->cur_post->post_selected = (integer) $post->post_selected; |
---|
| 473 | $this->cur_post->post_open_comment = (integer) $post->post_open_comment; |
---|
| 474 | $this->cur_post->post_open_tb = (integer) $post->post_open_tb; |
---|
| 475 | $this->cur_post->nb_comment = (integer) $post->nb_comment; |
---|
| 476 | $this->cur_post->nb_trackback = (integer) $post->nb_trackback; |
---|
[3323] | 477 | $this->cur_post->post_position = (integer) $post->post_position; |
---|
[2485] | 478 | |
---|
[0] | 479 | $this->cur_post->post_tz = $post->exists('post_tz') ? (string) $post->post_tz : 'UTC'; |
---|
[2485] | 480 | |
---|
[0] | 481 | $this->cur_post->insert(); |
---|
| 482 | } |
---|
[2485] | 483 | |
---|
[0] | 484 | private function insertMeta($meta) |
---|
| 485 | { |
---|
| 486 | $this->cur_meta->clean(); |
---|
[2485] | 487 | |
---|
[0] | 488 | $this->cur_meta->meta_id = (string) $meta->meta_id; |
---|
| 489 | $this->cur_meta->meta_type = (string) $meta->meta_type; |
---|
| 490 | $this->cur_meta->post_id = (integer) $meta->post_id; |
---|
[2485] | 491 | |
---|
[0] | 492 | $this->cur_meta->insert(); |
---|
| 493 | } |
---|
[2485] | 494 | |
---|
[0] | 495 | private function insertMedia($media) |
---|
| 496 | { |
---|
| 497 | $this->cur_media->clean(); |
---|
[2485] | 498 | |
---|
[0] | 499 | $this->cur_media->media_id = (integer) $media->media_id; |
---|
| 500 | $this->cur_media->user_id = (string) $media->user_id; |
---|
| 501 | $this->cur_media->media_path = (string) $media->media_path; |
---|
| 502 | $this->cur_media->media_title = (string) $media->media_title; |
---|
| 503 | $this->cur_media->media_file = (string) $media->media_file; |
---|
| 504 | $this->cur_media->media_meta = (string) $media->media_meta; |
---|
| 505 | $this->cur_media->media_dt = (string) $media->media_dt; |
---|
| 506 | $this->cur_media->media_creadt = (string) $media->media_creadt; |
---|
| 507 | $this->cur_media->media_upddt = (string) $media->media_upddt; |
---|
| 508 | $this->cur_media->media_private = (integer) $media->media_private; |
---|
[2485] | 509 | |
---|
[0] | 510 | $this->cur_media->media_dir = $media->exists('media_dir') ? (string) $media->media_dir : dirname($media->media_file); |
---|
[2485] | 511 | |
---|
[0] | 512 | if (!$this->mediaExists()) { |
---|
| 513 | $this->cur_media->insert(); |
---|
| 514 | } |
---|
| 515 | } |
---|
[2485] | 516 | |
---|
[0] | 517 | private function insertPostMedia($post_media) |
---|
| 518 | { |
---|
| 519 | $this->cur_post_media->clean(); |
---|
[2485] | 520 | |
---|
[0] | 521 | $this->cur_post_media->media_id = (integer) $post_media->media_id; |
---|
| 522 | $this->cur_post_media->post_id = (integer) $post_media->post_id; |
---|
[2485] | 523 | |
---|
[0] | 524 | $this->cur_post_media->insert(); |
---|
| 525 | } |
---|
[2485] | 526 | |
---|
[0] | 527 | private function insertLog($log) |
---|
| 528 | { |
---|
| 529 | $this->cur_log->clean(); |
---|
[2485] | 530 | |
---|
[0] | 531 | $this->cur_log->log_id = (integer) $log->log_id; |
---|
| 532 | $this->cur_log->user_id = (string) $log->user_id; |
---|
| 533 | $this->cur_log->log_table = (string) $log->log_table; |
---|
| 534 | $this->cur_log->log_dt = (string) $log->log_dt; |
---|
| 535 | $this->cur_log->log_ip = (string) $log->log_ip; |
---|
| 536 | $this->cur_log->log_msg = (string) $log->log_msg; |
---|
[2485] | 537 | |
---|
[0] | 538 | $this->cur_log->insert(); |
---|
| 539 | } |
---|
[2485] | 540 | |
---|
[0] | 541 | private function insertPing($ping) |
---|
| 542 | { |
---|
| 543 | $this->cur_ping->clean(); |
---|
[2485] | 544 | |
---|
[0] | 545 | $this->cur_ping->post_id = (integer) $ping->post_id; |
---|
| 546 | $this->cur_ping->ping_url = (string) $ping->ping_url; |
---|
| 547 | $this->cur_ping->ping_dt = (string) $ping->ping_dt; |
---|
[2485] | 548 | |
---|
[0] | 549 | $this->cur_ping->insert(); |
---|
| 550 | } |
---|
[2485] | 551 | |
---|
[0] | 552 | private function insertComment($comment) |
---|
| 553 | { |
---|
| 554 | $this->cur_comment->clean(); |
---|
[2485] | 555 | |
---|
[0] | 556 | $this->cur_comment->comment_id = (integer) $comment->comment_id; |
---|
| 557 | $this->cur_comment->post_id = (integer) $comment->post_id; |
---|
| 558 | $this->cur_comment->comment_dt = (string) $comment->comment_dt; |
---|
| 559 | $this->cur_comment->comment_upddt = (string) $comment->comment_upddt; |
---|
| 560 | $this->cur_comment->comment_author = (string) $comment->comment_author; |
---|
| 561 | $this->cur_comment->comment_email = (string) $comment->comment_email; |
---|
| 562 | $this->cur_comment->comment_site = (string) $comment->comment_site; |
---|
| 563 | $this->cur_comment->comment_content = (string) $comment->comment_content; |
---|
| 564 | $this->cur_comment->comment_words = (string) $comment->comment_words; |
---|
| 565 | $this->cur_comment->comment_ip = (string) $comment->comment_ip; |
---|
| 566 | $this->cur_comment->comment_status = (integer) $comment->comment_status; |
---|
[3148] | 567 | $this->cur_comment->comment_spam_status = (string) $comment->comment_spam_status; |
---|
[0] | 568 | $this->cur_comment->comment_trackback = (integer) $comment->comment_trackback; |
---|
[2485] | 569 | |
---|
[0] | 570 | $this->cur_comment->comment_tz = $comment->exists('comment_tz') ? (string) $comment->comment_tz : 'UTC'; |
---|
[3148] | 571 | $this->cur_comment->comment_spam_filter = $comment->exists('comment_spam_filter') ? (string) $comment->comment_spam_filter : null; |
---|
[2485] | 572 | |
---|
[0] | 573 | $this->cur_comment->insert(); |
---|
| 574 | } |
---|
[2485] | 575 | |
---|
[0] | 576 | private function insertSpamRule($spamrule) |
---|
| 577 | { |
---|
| 578 | $this->cur_spamrule->clean(); |
---|
[2485] | 579 | |
---|
[0] | 580 | $this->cur_spamrule->rule_id = (integer) $spamrule->rule_id; |
---|
| 581 | $this->cur_spamrule->blog_id = !$spamrule->blog_id ? null : (string) $spamrule->blog_id; |
---|
| 582 | $this->cur_spamrule->rule_type = (string) $spamrule->rule_type; |
---|
| 583 | $this->cur_spamrule->rule_content = (string) $spamrule->rule_content; |
---|
[2485] | 584 | |
---|
[0] | 585 | $this->cur_spamrule->insert(); |
---|
| 586 | } |
---|
[2485] | 587 | |
---|
[0] | 588 | private function insertCategorySingle($category) |
---|
| 589 | { |
---|
| 590 | $this->cur_category->clean(); |
---|
[2485] | 591 | |
---|
[0] | 592 | $m = $this->searchCategory($this->stack['categories'],$category->cat_url); |
---|
[2485] | 593 | |
---|
[0] | 594 | $old_id = $category->cat_id; |
---|
| 595 | if ($m !== false) |
---|
| 596 | { |
---|
| 597 | $cat_id = $m; |
---|
| 598 | } |
---|
| 599 | else |
---|
| 600 | { |
---|
| 601 | $cat_id = $this->stack['cat_id']; |
---|
| 602 | $category->cat_id = $cat_id; |
---|
| 603 | $category->blog_id = $this->blog_id; |
---|
[2485] | 604 | |
---|
[0] | 605 | $this->insertCategory($category); |
---|
| 606 | $this->stack['cat_id']++; |
---|
| 607 | } |
---|
[2485] | 608 | |
---|
[0] | 609 | $this->old_ids['category'][(integer) $old_id] = $cat_id; |
---|
| 610 | } |
---|
[2485] | 611 | |
---|
[0] | 612 | private function insertLinkSingle($link) |
---|
| 613 | { |
---|
| 614 | $link->blog_id = $this->blog_id; |
---|
| 615 | $link->link_id = $this->stack['link_id']; |
---|
[2485] | 616 | |
---|
[0] | 617 | $this->insertLink($link); |
---|
| 618 | $this->stack['link_id']++; |
---|
| 619 | } |
---|
[2485] | 620 | |
---|
[0] | 621 | private function insertPostSingle($post) |
---|
| 622 | { |
---|
| 623 | if (!$post->cat_id || isset($this->old_ids['category'][(integer) $post->cat_id])) { |
---|
| 624 | $post_id = $this->stack['post_id']; |
---|
| 625 | $this->old_ids['post'][(integer) $post->post_id] = $post_id; |
---|
[2485] | 626 | |
---|
[0] | 627 | $cat_id = $post->cat_id ? $this->old_ids['category'][(integer) $post->cat_id] : null; |
---|
[2485] | 628 | |
---|
[0] | 629 | $post->post_id = $post_id; |
---|
| 630 | $post->cat_id = $cat_id; |
---|
| 631 | $post->blog_id = $this->blog_id; |
---|
[2485] | 632 | |
---|
[0] | 633 | $post->post_url = $this->core->blog->getPostURL( |
---|
| 634 | $post->post_url,$post->post_dt,$post->post_title,$post->post_id |
---|
| 635 | ); |
---|
[2485] | 636 | |
---|
[0] | 637 | $this->insertPost($post); |
---|
| 638 | $this->stack['post_id']++; |
---|
| 639 | } else { |
---|
[841] | 640 | self::throwIdError($post->__name,$post->__line,'category'); |
---|
[0] | 641 | } |
---|
| 642 | } |
---|
[2485] | 643 | |
---|
[0] | 644 | private function insertMetaSingle($meta) |
---|
| 645 | { |
---|
| 646 | if (isset($this->old_ids['post'][(integer) $meta->post_id])) { |
---|
| 647 | $meta->post_id = $this->old_ids['post'][(integer) $meta->post_id]; |
---|
| 648 | $this->insertMeta($meta); |
---|
| 649 | } else { |
---|
[841] | 650 | self::throwIdError($meta->__name,$meta->__line,'post'); |
---|
[0] | 651 | } |
---|
| 652 | } |
---|
[2485] | 653 | |
---|
[0] | 654 | private function insertMediaSingle($media) |
---|
| 655 | { |
---|
| 656 | $media_id = $this->stack['media_id']; |
---|
| 657 | $old_id = $media->media_id; |
---|
[2485] | 658 | |
---|
[0] | 659 | $media->media_id = $media_id; |
---|
| 660 | $media->media_path = $this->core->blog->settings->system->public_path; |
---|
| 661 | $media->user_id = $this->getUserId($media->user_id); |
---|
[2485] | 662 | |
---|
[0] | 663 | $this->insertMedia($media); |
---|
| 664 | $this->stack['media_id']++; |
---|
| 665 | $this->old_ids['media'][(integer) $old_id] = $media_id; |
---|
| 666 | } |
---|
[2485] | 667 | |
---|
[0] | 668 | private function insertPostMediaSingle($post_media) |
---|
| 669 | { |
---|
| 670 | if (isset($this->old_ids['media'][(integer) $post_media->media_id]) && |
---|
| 671 | isset($this->old_ids['post'][(integer) $post_media->post_id])) { |
---|
| 672 | $post_media->media_id = $this->old_ids['media'][(integer) $post_media->media_id]; |
---|
| 673 | $post_media->post_id = $this->old_ids['post'][(integer) $post_media->post_id]; |
---|
[2485] | 674 | |
---|
[0] | 675 | $this->insertPostMedia($post_media); |
---|
[841] | 676 | } elseif (!isset($this->old_ids['media'][(integer) $post_media->media_id])) { |
---|
| 677 | self::throwIdError($post_media->__name,$post_media->__line,'media'); |
---|
| 678 | }else { |
---|
| 679 | self::throwIdError($post_media->__name,$post_media->__line,'post'); |
---|
[0] | 680 | } |
---|
| 681 | } |
---|
[2485] | 682 | |
---|
[0] | 683 | private function insertPingSingle($ping) |
---|
| 684 | { |
---|
| 685 | if (isset($this->old_ids['post'][(integer) $ping->post_id])) { |
---|
| 686 | $ping->post_id = $this->old_ids['post'][(integer) $ping->post_id]; |
---|
[2485] | 687 | |
---|
[0] | 688 | $this->insertPing($ping); |
---|
| 689 | } else { |
---|
[841] | 690 | self::throwIdError($ping->__name,$ping->__line,'post'); |
---|
[0] | 691 | } |
---|
| 692 | } |
---|
[2485] | 693 | |
---|
[0] | 694 | private function insertCommentSingle($comment) |
---|
| 695 | { |
---|
| 696 | if (isset($this->old_ids['post'][(integer) $comment->post_id])) { |
---|
| 697 | $comment_id = $this->stack['comment_id']; |
---|
[2485] | 698 | |
---|
[0] | 699 | $comment->comment_id = $comment_id; |
---|
| 700 | $comment->post_id = $this->old_ids['post'][(integer) $comment->post_id]; |
---|
[2485] | 701 | |
---|
[0] | 702 | $this->insertComment($comment); |
---|
| 703 | $this->stack['comment_id']++; |
---|
| 704 | } else { |
---|
[841] | 705 | self::throwIdError($comment->__name,$comment->__line,'post'); |
---|
[0] | 706 | } |
---|
| 707 | } |
---|
[2485] | 708 | |
---|
[841] | 709 | private static function throwIdError($name,$line,$related) |
---|
| 710 | { |
---|
| 711 | throw new Exception(sprintf( |
---|
| 712 | __('ID of "%3$s" does not match on record "%1$s" at line %2$s of backup file.'), |
---|
| 713 | html::escapeHTML($name), |
---|
| 714 | html::escapeHTML($line), |
---|
| 715 | html::escapeHTML($related) |
---|
| 716 | )); |
---|
| 717 | } |
---|
[2485] | 718 | |
---|
[0] | 719 | public function searchCategory($rs,$url) |
---|
| 720 | { |
---|
| 721 | while ($rs->fetch()) |
---|
| 722 | { |
---|
| 723 | if ($rs->cat_url == $url) { |
---|
| 724 | return $rs->cat_id; |
---|
| 725 | } |
---|
| 726 | } |
---|
[2485] | 727 | |
---|
[0] | 728 | return false; |
---|
| 729 | } |
---|
[2485] | 730 | |
---|
[0] | 731 | public function getUserId($user_id) |
---|
| 732 | { |
---|
| 733 | if (!$this->userExists($user_id)) |
---|
| 734 | { |
---|
| 735 | if ($this->core->auth->isSuperAdmin()) |
---|
| 736 | { |
---|
| 737 | # Sanitizes user_id and create a lambda user |
---|
| 738 | $user_id = preg_replace('/[^A-Za-z0-9]$/','',$user_id); |
---|
| 739 | $user_id .= strlen($user_id) < 2 ? '-a' : ''; |
---|
[2485] | 740 | |
---|
[0] | 741 | # We change user_id, we need to check again |
---|
| 742 | if (!$this->userExists($user_id)) |
---|
| 743 | { |
---|
| 744 | $this->cur_user->clean(); |
---|
| 745 | $this->cur_user->user_id = (string) $user_id; |
---|
| 746 | $this->cur_user->user_pwd = md5(uniqid()); |
---|
[2485] | 747 | |
---|
[0] | 748 | $this->core->addUser($this->cur_user); |
---|
[2485] | 749 | |
---|
[0] | 750 | $this->stack['users'][$user_id] = true; |
---|
| 751 | } |
---|
| 752 | } |
---|
| 753 | else |
---|
| 754 | { |
---|
| 755 | # Returns current user id |
---|
| 756 | $user_id = $this->core->auth->userID(); |
---|
| 757 | } |
---|
| 758 | } |
---|
[2485] | 759 | |
---|
[0] | 760 | return $user_id; |
---|
| 761 | } |
---|
[2485] | 762 | |
---|
[0] | 763 | private function userExists($user_id) |
---|
| 764 | { |
---|
| 765 | if (isset($this->stack['users'][$user_id])) { |
---|
| 766 | return $this->stack['users'][$user_id]; |
---|
| 767 | } |
---|
[2485] | 768 | |
---|
[0] | 769 | $strReq = 'SELECT user_id '. |
---|
| 770 | 'FROM '.$this->prefix.'user '. |
---|
| 771 | "WHERE user_id = '".$this->con->escape($user_id)."' "; |
---|
[2485] | 772 | |
---|
[0] | 773 | $rs = $this->con->select($strReq); |
---|
[2485] | 774 | |
---|
[0] | 775 | $this->stack['users'][$user_id] = !$rs->isEmpty(); |
---|
| 776 | return $this->stack['users'][$user_id]; |
---|
| 777 | } |
---|
[2485] | 778 | |
---|
[298] | 779 | private function prefExists($pref_ws,$pref_id,$user_id) |
---|
[294] | 780 | { |
---|
| 781 | $strReq = 'SELECT pref_id,pref_ws,user_id '. |
---|
| 782 | 'FROM '.$this->prefix.'pref '. |
---|
| 783 | "WHERE pref_id = '".$this->con->escape($pref_id)."' ". |
---|
| 784 | "AND pref_ws = '".$this->con->escape($pref_ws)."' "; |
---|
| 785 | if (!$user_id) { |
---|
| 786 | $strReq .= "AND user_id IS NULL "; |
---|
| 787 | } else { |
---|
| 788 | $strReq .= "AND user_id = '".$this->con->escape($user_id)."' "; |
---|
| 789 | } |
---|
[2485] | 790 | |
---|
[294] | 791 | $rs = $this->con->select($strReq); |
---|
[2485] | 792 | |
---|
[294] | 793 | return !$rs->isEmpty(); |
---|
| 794 | } |
---|
[2485] | 795 | |
---|
[0] | 796 | private function mediaExists() |
---|
| 797 | { |
---|
| 798 | $strReq = 'SELECT media_id '. |
---|
| 799 | 'FROM '.$this->prefix.'media '. |
---|
[1093] | 800 | "WHERE media_path = '".$this->con->escape($this->cur_media->media_path)."' ". |
---|
| 801 | "AND media_file = '".$this->con->escape($this->cur_media->media_file)."' "; |
---|
[2485] | 802 | |
---|
[0] | 803 | $rs = $this->con->select($strReq); |
---|
[2485] | 804 | |
---|
[0] | 805 | return !$rs->isEmpty(); |
---|
| 806 | } |
---|
[2485] | 807 | |
---|
[0] | 808 | private function prepareDC12line(&$line) |
---|
| 809 | { |
---|
| 810 | $settings = array('dc_theme','dc_nb_post_per_page','dc_allow_comments', |
---|
| 811 | 'dc_allow_trackbacks','dc_comment_pub','dc_comments_ttl', |
---|
| 812 | 'dc_wiki_comments','dc_use_smilies','dc_date_format','dc_time_format', |
---|
| 813 | 'dc_url_scan'); |
---|
[2485] | 814 | |
---|
[0] | 815 | switch ($line->__name) |
---|
| 816 | { |
---|
| 817 | case 'categorie': |
---|
| 818 | $line->substitute('cat_libelle','cat_title'); |
---|
| 819 | $line->substitute('cat_libelle_url','cat_url'); |
---|
| 820 | $line->__name = 'category'; |
---|
| 821 | $line->blog_id = 'default'; |
---|
| 822 | break; |
---|
| 823 | case 'link': |
---|
| 824 | $line->substitute('href','link_href'); |
---|
| 825 | $line->substitute('label','link_title'); |
---|
| 826 | $line->substitute('title','link_desc'); |
---|
| 827 | $line->substitute('lang','link_lang'); |
---|
| 828 | $line->substitute('rel','link_xfn'); |
---|
| 829 | $line->substitute('position','link_position'); |
---|
| 830 | $line->blog_id = 'default'; |
---|
| 831 | break; |
---|
| 832 | case 'post': |
---|
| 833 | $line->substitute('post_titre','post_title'); |
---|
| 834 | $line->post_title = html::decodeEntities($line->post_title); |
---|
| 835 | $line->post_url = date('Y/m/d/',strtotime($line->post_dt)).$line->post_id.'-'.$line->post_titre_url; |
---|
| 836 | $line->post_url = substr($line->post_url,0,255); |
---|
| 837 | $line->post_format = $line->post_content_wiki == '' ? 'xhtml' : 'wiki'; |
---|
| 838 | $line->post_content_xhtml = $line->post_content; |
---|
| 839 | $line->post_excerpt_xhtml = $line->post_chapo; |
---|
[2485] | 840 | |
---|
[0] | 841 | if ($line->post_format == 'wiki') { |
---|
| 842 | $line->post_content = $line->post_content_wiki; |
---|
| 843 | $line->post_excerpt = $line->post_chapo_wiki; |
---|
| 844 | } else { |
---|
| 845 | $line->post_content = $line->post_content; |
---|
| 846 | $line->post_excerpt = $line->post_chapo; |
---|
| 847 | } |
---|
[2485] | 848 | |
---|
[0] | 849 | $line->post_status = (integer) $line->post_pub; |
---|
| 850 | $line->post_type = 'post'; |
---|
| 851 | $line->blog_id = 'default'; |
---|
[2485] | 852 | |
---|
[0] | 853 | $line->drop('post_titre_url','post_content_wiki','post_chapo','post_chapo_wiki','post_pub'); |
---|
[2485] | 854 | |
---|
[0] | 855 | break; |
---|
| 856 | case 'post_meta': |
---|
| 857 | $line->drop('meta_id'); |
---|
| 858 | $line->substitute('meta_key','meta_type'); |
---|
| 859 | $line->substitute('meta_value','meta_id'); |
---|
| 860 | $line->__name = 'meta'; |
---|
| 861 | $line->blog_id = 'default'; |
---|
| 862 | break; |
---|
| 863 | case 'comment': |
---|
| 864 | $line->substitute('comment_auteur','comment_author'); |
---|
| 865 | if ($line->comment_site != '' && !preg_match('!^http://.*$!', $line->comment_site,$m)) { |
---|
| 866 | $line->comment_site = 'http://'.$line->comment_site; |
---|
| 867 | } |
---|
| 868 | $line->comment_status = (integer) $line->comment_pub; |
---|
| 869 | $line->drop('comment_pub'); |
---|
| 870 | break; |
---|
| 871 | } |
---|
[2485] | 872 | |
---|
[0] | 873 | # --BEHAVIOR-- importPrepareDC12 |
---|
| 874 | $this->core->callBehavior('importPrepareDC12',$line,$this,$this->core); |
---|
| 875 | } |
---|
| 876 | } |
---|