Changeset 2485:ad130cb12ae6
- Timestamp:
- 10/23/13 15:49:16 (12 years ago)
- Branch:
- 2.6
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
locales/_pot/plugins.pot
r2417 r2485 8 8 "Project-Id-Version: Dotclear 2\n" 9 9 "Report-Msgid-Bugs-To: \n" 10 "POT-Creation-Date: 2013-10- 17 09:38+0200\n"10 "POT-Creation-Date: 2013-10-23 13:44+0000\n" 11 11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 12 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 1535 1535 msgstr "" 1536 1536 1537 #: plugins/importExport/inc/flat/class.flat.import.php:222 1537 #: plugins/importExport/inc/flat/class.flat.import.php:218 1538 #: plugins/importExport/inc/flat/class.flat.import.php:301 1539 #, php-format 1540 msgid "Error raised at line %s" 1541 msgstr "" 1542 1543 #: plugins/importExport/inc/flat/class.flat.import.php:227 1538 1544 msgid "File is not a full export." 1539 1545 msgstr "" 1540 1546 1541 #: plugins/importExport/inc/flat/class.flat.import.php:7 041547 #: plugins/importExport/inc/flat/class.flat.import.php:711 1542 1548 #, php-format 1543 1549 msgid "ID of \"%3$s\" does not match on record \"%1$s\" at line %2$s of backup file." … … 1561 1567 msgstr "" 1562 1568 1563 #: plugins/importExport/index.php:10 51569 #: plugins/importExport/index.php:104 1564 1570 #, php-format 1565 1571 msgid "Export functions are in the page %s." 1566 msgstr ""1567 1568 #: plugins/importExport/index.php:106 plugins/maintenance/_admin.php:161569 #: plugins/maintenance/_admin.php:83 plugins/maintenance/_admin.php:1791570 #: plugins/maintenance/_admin.php:201 plugins/maintenance/index.php:1131571 #: plugins/maintenance/index.php:137 plugins/maintenance/index.php:1531572 #: plugins/maintenance/index.php:1861573 msgid "Maintenance"1574 1572 msgstr "" 1575 1573 -
locales/fr/plugins.po
r2418 r2485 11 11 "Project-Id-Version: Dotclear\n" 12 12 "Report-Msgid-Bugs-To: \n" 13 "POT-Creation-Date: 2013-10- 17 09:38+0200\n"13 "POT-Creation-Date: 2013-10-23 13:44+0000\n" 14 14 "PO-Revision-Date: 2012-11-06 10:04+0100\n" 15 15 "Last-Translator: Franck Paul <carnet.franck.paul@gmail.com>\n" … … 1068 1068 msgstr "Ce fichier n'est pas une exportation d'un blog." 1069 1069 1070 #, php-format 1071 msgid "Error raised at line %s" 1072 msgstr "Erreur détectée ligne %s" 1073 1070 1074 msgid "File is not a full export." 1071 1075 msgstr "Ce fichier n'est pas un fichier de sauvegarde complet." -
plugins/importExport/inc/class.dc.import.flat.php
r1559 r2485 15 15 { 16 16 protected $status = false; 17 17 18 18 public function setInfo() 19 19 { … … 22 22 $this->description = __('Imports a blog or a full Dotclear installation from flat file.'); 23 23 } 24 24 25 25 public function process($do) 26 26 { … … 29 29 return; 30 30 } 31 31 32 32 $to_unlink = false; 33 33 34 34 # Single blog import 35 35 $files = $this->getPublicFiles(); … … 40 40 $single_upl = true; 41 41 } 42 42 43 43 if ($single_upl !== null) 44 44 { … … 53 53 $file = $_POST['public_single_file']; 54 54 } 55 55 56 56 try { 57 57 # Try to unzip file … … 64 64 $bk = new flatImport($this->core,$file); 65 65 } 66 66 67 67 $bk->importSingle(); 68 68 } catch (Exception $e) { … … 79 79 http::redirect($this->getURL().'&do=single'); 80 80 } 81 81 82 82 # Full import 83 83 $full_upl = null; … … 87 87 $full_upl = true; 88 88 } 89 89 90 90 if ($full_upl !== null && $this->core->auth->isSuperAdmin()) 91 91 { … … 93 93 throw new Exception(__('Password verification failed')); 94 94 } 95 95 96 96 if ($full_upl) { 97 97 files::uploadStatus($_FILES['up_full_file']); … … 104 104 $file = $_POST['public_full_file']; 105 105 } 106 106 107 107 try { 108 108 # Try to unzip file … … 115 115 $bk = new flatImport($this->core,$file); 116 116 } 117 117 118 118 $bk->importFull(); 119 119 } catch (Exception $e) { … … 130 130 http::redirect($this->getURL().'&do=full'); 131 131 } 132 132 133 133 header('content-type:text/plain'); 134 134 var_dump($_POST); 135 135 exit; 136 136 137 137 $this->status = true; 138 138 } 139 139 140 140 public function gui() 141 141 { … … 150 150 return; 151 151 } 152 152 153 153 $public_files = array_merge(array('-' => ''),$this->getPublicFiles()); 154 154 $has_files = (boolean) (count($public_files) - 1); 155 155 156 156 echo 157 157 '<script type="text/javascript">'."\n". … … 178 178 "//]]>\n". 179 179 "</script>\n"; 180 180 181 181 echo 182 182 '<form action="'.$this->getURL(true).'" method="post" enctype="multipart/form-data" class="fieldset">'. 183 183 '<h3>'.__('Single blog').'</h3>'. 184 184 '<p>'.sprintf(__('This will import a single blog backup as new content in the current blog: <strong>%s</strong>.'),html::escapeHTML($this->core->blog->name)).'</p>'. 185 185 186 186 '<p><label for="up_single_file">'.__('Upload a backup file'). 187 187 ' ('.sprintf(__('maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')'.' </label>'. 188 188 ' <input type="file" id="up_single_file" name="up_single_file" size="20" />'. 189 189 '</p>'; 190 190 191 191 if ($has_files) { 192 echo 192 echo 193 193 '<p><label for="public_single_file" class="">'.__('or pick up a local file in your public directory').' </label> '. 194 194 form::combo('public_single_file',$public_files). 195 195 '</p>'; 196 196 } 197 198 echo 197 198 echo 199 199 '<p>'. 200 200 $this->core->formNonce(). … … 202 202 form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). 203 203 '<input type="submit" value="'.__('Import').'" /></p>'. 204 204 205 205 '</form>'; 206 206 207 207 if ($this->core->auth->isSuperAdmin()) 208 208 { … … 211 211 '<h3>'.__('Multiple blogs').'</h3>'. 212 212 '<p class="warning">'.__('This will reset all the content of your database, except users.').'</p>'. 213 213 214 214 '<p><label for="up_full_file">'.__('Upload a backup file').' '. 215 215 ' ('.sprintf(__('maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')'.' </label>'. 216 216 '<input type="file" id="up_full_file" name="up_full_file" size="20" />'. 217 217 '</p>'; 218 218 219 219 if ($has_files) { 220 echo 220 echo 221 221 '<p><label for="public_full_file">'.__('or pick up a local file in your public directory').' </label>'. 222 222 form::combo('public_full_file',$public_files). 223 223 '</p>'; 224 224 } 225 225 226 226 echo 227 227 '<p><label for="your_pwd" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Your password:').'</label>'. 228 228 form::password('your_pwd',20,255).'</p>'. 229 229 230 230 '<p>'. 231 231 $this->core->formNonce(). … … 233 233 form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). 234 234 '<input type="submit" value="'.__('Import').'" /></p>'. 235 235 236 236 '</form>'; 237 237 } 238 238 } 239 239 240 240 protected function getPublicFiles() 241 241 { … … 246 246 while (($entry = $dir->read()) !== false) { 247 247 $entry_path = $dir->path.'/'.$entry; 248 248 249 249 if (is_file($entry_path) && is_readable($entry_path)) 250 250 { … … 261 261 return $public_files; 262 262 } 263 263 264 264 protected static function checkFileContent($entry_path) 265 265 { 266 266 $ret = false; 267 267 268 268 $fp = fopen($entry_path,'rb'); 269 269 $ret = strpos(fgets($fp),'///DOTCLEAR|') === 0; 270 270 fclose($fp); 271 271 272 272 return $ret; 273 273 } 274 274 275 275 private function unzip($file) 276 276 { 277 277 $zip = new fileUnzip($file); 278 278 279 279 if ($zip->isEmpty()) { 280 280 $zip->close(); 281 281 return false;//throw new Exception(__('File is empty or not a compressed file.')); 282 282 } 283 283 284 284 foreach($zip->getFilesList() as $zip_file) 285 285 { … … 288 288 continue; 289 289 } 290 290 291 291 # Check zipped file contents 292 292 $content = $zip->unzip($zip_file); … … 295 295 continue; 296 296 } 297 297 298 298 $target = path::fullFromRoot($zip_file,dirname($file)); 299 299 300 300 # Check existing files with same name 301 301 if (file_exists($target)) { … … 304 304 throw new Exception(__('Another file with same name exists.')); 305 305 } 306 306 307 307 # Extract backup content 308 308 if (file_put_contents($target,$content) === false) { … … 311 311 throw new Exception(__('Failed to extract backup file.')); 312 312 } 313 313 314 314 $zip->close(); 315 315 unset($content); 316 316 317 317 # Return extracted file name 318 318 return $target; 319 319 } 320 320 321 321 $zip->close(); 322 322 throw new Exception(__('No backup in compressed file.')); 323 323 } 324 324 } 325 ?> -
plugins/importExport/inc/flat/class.flat.import.php
r1743 r2485 17 17 private $con; 18 18 private $prefix; 19 19 20 20 private $dc_version; 21 21 private $dc_major; 22 22 private $mode; 23 23 24 24 private $blog_url; 25 25 private $blog_name; 26 26 private $blog_desc; 27 27 28 28 private $users = array(); 29 29 30 30 public $old_ids = array( 31 31 'category' => array(), … … 33 33 'media' => array() 34 34 ); 35 35 36 36 public $stack = array( 37 37 'categories'=>null, … … 41 41 'media_id'=>1, 42 42 'comment_id'=>1, 43 'link_id'=>1 43 'link_id'=>1, 44 'log_id' => 1 44 45 ); 45 46 46 47 public $has_categories = false; 47 48 48 49 public function __construct($core,$file) 49 50 { 50 51 parent::__construct($file); 51 52 52 53 $first_line = fgets($this->fp); 53 54 if (strpos($first_line,'///DOTCLEAR|') !== 0) { 54 55 throw new Exception(__('File is not a DotClear backup.')); 55 56 } 56 57 57 58 @set_time_limit(300); 58 59 59 60 $l = explode('|',$first_line); 60 61 61 62 if (isset($l[1])) { 62 63 $this->dc_version = $l[1]; 63 64 } 64 65 65 66 $this->mode = isset($l[2]) ? strtolower(trim($l[2])) : 'single'; 66 67 if ($this->mode != 'full' && $this->mode != 'single') { 67 68 $this->mode = 'single'; 68 69 } 69 70 70 71 if (version_compare('1.2',$this->dc_version,'<=') && 71 72 version_compare('1.3',$this->dc_version,'>')) { … … 74 75 $this->dc_major_version = '2.0'; 75 76 } 76 77 77 78 $this->core =& $core; 78 79 $this->con =& $core->con; 79 80 $this->prefix = $core->prefix; 80 81 81 82 $this->cur_blog = $this->con->openCursor($this->prefix.'blog'); 82 83 $this->cur_category = $this->con->openCursor($this->prefix.'category'); … … 95 96 $this->cur_spamrule = $this->con->openCursor($this->prefix.'spamrule'); 96 97 $this->cur_version = $this->con->openCursor($this->prefix.'version'); 97 98 98 99 # --BEHAVIOR-- importInit 99 100 $this->core->callBehavior('importInit',$this,$this->core); 100 101 } 101 102 102 103 public function importSingle() 103 104 { … … 105 106 throw new Exception(__('File is not a single blog export.')); 106 107 } 107 108 108 109 if (!$this->core->auth->check('admin',$this->core->blog->id)) { 109 110 throw new Exception(__('Permission denied.')); 110 111 } 111 112 112 113 $this->blog_id = $this->core->blog->id; 113 114 114 115 $this->stack['categories'] = $this->con->select( 115 116 'SELECT cat_id, cat_title, cat_url '. … … 117 118 "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 118 119 ); 119 120 120 121 $rs = $this->con->select('SELECT MAX(cat_id) FROM '.$this->prefix.'category'); 121 122 $this->stack['cat_id'] = ((integer) $rs->f(0))+1; 122 123 123 124 $rs = $this->con->select('SELECT MAX(link_id) FROM '.$this->prefix.'link'); 124 125 $this->stack['link_id'] = ((integer) $rs->f(0))+1; 125 126 126 127 $rs = $this->con->select('SELECT MAX(post_id) FROM '.$this->prefix.'post'); 127 128 $this->stack['post_id'] = ((integer) $rs->f(0))+1; 128 129 129 130 $rs = $this->con->select('SELECT MAX(media_id) FROM '.$this->prefix.'media'); 130 131 $this->stack['media_id'] = ((integer) $rs->f(0))+1; 131 132 132 133 $rs = $this->con->select('SELECT MAX(comment_id) FROM '.$this->prefix.'comment'); 133 134 $this->stack['comment_id'] = ((integer) $rs->f(0))+1; 134 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 135 139 $rs = $this->con->select( 136 140 'SELECT MAX(cat_rgt) AS cat_rgt FROM '.$this->prefix.'category '. 137 141 "WHERE blog_id = '".$this->con->escape($this->core->blog->id)."'" 138 142 ); 139 143 140 144 if ((integer) $rs->cat_rgt > 0) { 141 145 $this->has_categories = true; 142 146 $this->stack['cat_lft'][$this->core->blog->id] = (integer) $rs->cat_rgt + 1; 143 147 } 144 148 145 149 $this->con->begin(); 146 150 147 151 try 148 152 { 149 153 $last_line_name = ''; 150 154 $constrained = array('post', 'meta', 'post_media', 'ping', 'comment'); 151 155 152 156 while (($line = $this->getLine()) !== false) 153 157 { … … 156 160 $this->prepareDC12line($line); 157 161 } 158 162 159 163 if ($last_line_name != $line->__name) { 160 164 if (in_array($last_line_name,$constrained)) { … … 163 167 if ($this->con->driver() == 'pgsql') $this->con->execute('SET CONSTRAINTS ALL DEFERRED'); 164 168 } 165 169 166 170 if (in_array($line->__name,$constrained)) { 167 171 # DEFER … … 169 173 if ($this->con->driver() == 'pgsql') $this->con->execute('SET CONSTRAINTS ALL IMMEDIATE'); 170 174 } 171 175 172 176 $last_line_name = $line->__name; 173 177 } 174 178 175 179 switch ($line->__name) 176 180 { … … 200 204 break; 201 205 } 202 206 203 207 # --BEHAVIOR-- importSingle 204 208 $this->core->callBehavior('importSingle',$line,$this,$this->core); 205 209 } 206 210 207 211 if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') $this->con->execute('SET foreign_key_checks = 1'); 208 212 if ($this->con->driver() == 'pgsql') $this->con->execute('SET CONSTRAINTS ALL DEFERRED'); … … 210 214 catch (Exception $e) 211 215 { 216 @fclose($this->fp); 212 217 $this->con->rollback(); 213 throw $e;214 } 215 218 throw new Exception($e->getMessage().' - '.sprintf(__('Error raised at line %s'),$line->__line)); 219 } 220 @fclose($this->fp); 216 221 $this->con->commit(); 217 222 } 218 223 219 224 public function importFull() 220 225 { … … 222 227 throw new Exception(__('File is not a full export.')); 223 228 } 224 229 225 230 if (!$this->core->auth->isSuperAdmin()) { 226 231 throw new Exception(__('Permission denied.')); 227 232 } 228 233 229 234 $this->con->begin(); 230 235 $this->con->execute('DELETE FROM '.$this->prefix.'blog'); … … 232 237 $this->con->execute('DELETE FROM '.$this->prefix.'spamrule'); 233 238 $this->con->execute('DELETE FROM '.$this->prefix.'setting'); 234 239 $this->con->execute('DELETE FROM '.$this->prefix.'log'); 240 235 241 try 236 242 { … … 291 297 catch (Exception $e) 292 298 { 299 @fclose($this->fp); 293 300 $this->con->rollback(); 294 throw $e;295 } 296 301 throw new Exception($e->getMessage().' - '.sprintf(__('Error raised at line %s'),$line->__line)); 302 } 303 @fclose($this->fp); 297 304 $this->con->commit(); 298 305 } 299 306 300 307 private function insertBlog($blog) 301 308 { 302 309 $this->cur_blog->clean(); 303 310 304 311 $this->cur_blog->blog_id = (string) $blog->blog_id; 305 312 $this->cur_blog->blog_uid = (string) $blog->blog_uid; … … 309 316 $this->cur_blog->blog_name = (string) $blog->blog_name; 310 317 $this->cur_blog->blog_desc = (string) $blog->blog_desc; 311 318 312 319 $this->cur_blog->blog_status = $blog->exists('blog_status') ? (integer) $blog->blog_status : 1; 313 320 314 321 $this->cur_blog->insert(); 315 322 } 316 323 317 324 private function insertCategory($category) 318 325 { 319 326 $this->cur_category->clean(); 320 327 321 328 $this->cur_category->cat_id = (string) $category->cat_id; 322 329 $this->cur_category->blog_id = (string) $category->blog_id; … … 324 331 $this->cur_category->cat_url = (string) $category->cat_url; 325 332 $this->cur_category->cat_desc = (string) $category->cat_desc; 326 333 327 334 if (!$this->has_categories && $category->exists('cat_lft') && $category->exists('cat_rgt')) { 328 335 $this->cur_category->cat_lft = (integer) $category->cat_lft; … … 335 342 $this->cur_category->cat_rgt = $this->stack['cat_lft'][$category->blog_id]++; 336 343 } 337 344 338 345 $this->cur_category->insert(); 339 346 } 340 347 341 348 private function insertLink($link) 342 349 { 343 350 $this->cur_link->clean(); 344 351 345 352 $this->cur_link->link_id = (integer) $link->link_id; 346 353 $this->cur_link->blog_id = (string) $link->blog_id; … … 351 358 $this->cur_link->link_xfn = (string) $link->link_xfn; 352 359 $this->cur_link->link_position = (integer) $link->link_position; 353 360 354 361 $this->cur_link->insert(); 355 362 } 356 363 357 364 private function insertSetting($setting) 358 365 { 359 366 $this->cur_setting->clean(); 360 367 361 368 $this->cur_setting->setting_id = (string) $setting->setting_id; 362 369 $this->cur_setting->blog_id = !$setting->blog_id ? null : (string) $setting->blog_id; … … 365 372 $this->cur_setting->setting_type = (string) $setting->setting_type; 366 373 $this->cur_setting->setting_label = (string) $setting->setting_label; 367 374 368 375 $this->cur_setting->insert(); 369 376 } 370 377 371 378 private function insertPref($pref) 372 379 { … … 374 381 return; 375 382 } 376 383 377 384 $this->cur_pref->clean(); 378 385 379 386 $this->cur_pref->pref_id = (string) $pref->pref_id; 380 387 $this->cur_pref->user_id = !$pref->user_id ? null : (string) $pref->user_id; … … 383 390 $this->cur_pref->pref_type = (string) $pref->pref_type; 384 391 $this->cur_pref->pref_label = (string) $pref->pref_label; 385 392 386 393 $this->cur_pref->insert(); 387 394 } 388 395 389 396 private function insertUser($user) 390 397 { … … 392 399 return; 393 400 } 394 401 395 402 $this->cur_user->clean(); 396 403 397 404 $this->cur_user->user_id = (string) $user->user_id; 398 405 $this->cur_user->user_super = (integer) $user->user_super; … … 410 417 $this->cur_user->user_creadt = (string) $user->user_creadt; 411 418 $this->cur_user->user_upddt = (string) $user->user_upddt; 412 419 413 420 $this->cur_user->user_desc = $user->exists('user_desc') ? (string) $user->user_desc : null; 414 421 $this->cur_user->user_options = $user->exists('user_options') ? (string) $user->user_options : null; 415 422 $this->cur_user->user_status = $user->exists('user_status') ? (integer) $user->user_status : 1; 416 423 417 424 $this->cur_user->insert(); 418 425 419 426 $this->stack['users'][$user->user_id] = true; 420 427 } 421 428 422 429 private function insertPermissions($permissions) 423 430 { 424 431 $this->cur_permissions->clean(); 425 432 426 433 $this->cur_permissions->user_id = (string) $permissions->user_id; 427 434 $this->cur_permissions->blog_id = (string) $permissions->blog_id; 428 435 $this->cur_permissions->permissions = (string) $permissions->permissions; 429 436 430 437 $this->cur_permissions->insert(); 431 438 } 432 439 433 440 private function insertPost($post) 434 441 { 435 442 $this->cur_post->clean(); 436 443 437 444 $cat_id = (integer) $post->cat_id; 438 445 if (!$cat_id) { 439 446 $cat_id = null; 440 447 } 441 448 442 449 $post_password = $post->post_password ? (string) $post->post_password : null; 443 450 444 451 $this->cur_post->post_id = (integer) $post->post_id; 445 452 $this->cur_post->blog_id = (string) $post->blog_id; … … 468 475 $this->cur_post->nb_comment = (integer) $post->nb_comment; 469 476 $this->cur_post->nb_trackback = (integer) $post->nb_trackback; 470 477 471 478 $this->cur_post->post_tz = $post->exists('post_tz') ? (string) $post->post_tz : 'UTC'; 472 479 473 480 $this->cur_post->insert(); 474 481 } 475 482 476 483 private function insertMeta($meta) 477 484 { 478 485 $this->cur_meta->clean(); 479 486 480 487 $this->cur_meta->meta_id = (string) $meta->meta_id; 481 488 $this->cur_meta->meta_type = (string) $meta->meta_type; 482 489 $this->cur_meta->post_id = (integer) $meta->post_id; 483 490 484 491 $this->cur_meta->insert(); 485 492 } 486 493 487 494 private function insertMedia($media) 488 495 { 489 496 $this->cur_media->clean(); 490 497 491 498 $this->cur_media->media_id = (integer) $media->media_id; 492 499 $this->cur_media->user_id = (string) $media->user_id; … … 499 506 $this->cur_media->media_upddt = (string) $media->media_upddt; 500 507 $this->cur_media->media_private = (integer) $media->media_private; 501 508 502 509 $this->cur_media->media_dir = $media->exists('media_dir') ? (string) $media->media_dir : dirname($media->media_file); 503 510 504 511 if (!$this->mediaExists()) { 505 512 $this->cur_media->insert(); 506 513 } 507 514 } 508 515 509 516 private function insertPostMedia($post_media) 510 517 { 511 518 $this->cur_post_media->clean(); 512 519 513 520 $this->cur_post_media->media_id = (integer) $post_media->media_id; 514 521 $this->cur_post_media->post_id = (integer) $post_media->post_id; 515 522 516 523 $this->cur_post_media->insert(); 517 524 } 518 525 519 526 private function insertLog($log) 520 527 { 521 528 $this->cur_log->clean(); 522 529 523 530 $this->cur_log->log_id = (integer) $log->log_id; 524 531 $this->cur_log->user_id = (string) $log->user_id; … … 527 534 $this->cur_log->log_ip = (string) $log->log_ip; 528 535 $this->cur_log->log_msg = (string) $log->log_msg; 529 536 530 537 $this->cur_log->insert(); 531 538 } 532 539 533 540 private function insertPing($ping) 534 541 { 535 542 $this->cur_ping->clean(); 536 543 537 544 $this->cur_ping->post_id = (integer) $ping->post_id; 538 545 $this->cur_ping->ping_url = (string) $ping->ping_url; 539 546 $this->cur_ping->ping_dt = (string) $ping->ping_dt; 540 547 541 548 $this->cur_ping->insert(); 542 549 } 543 550 544 551 private function insertComment($comment) 545 552 { 546 553 $this->cur_comment->clean(); 547 554 548 555 $this->cur_comment->comment_id = (integer) $comment->comment_id; 549 556 $this->cur_comment->post_id = (integer) $comment->post_id; … … 559 566 $this->cur_comment->comment_spam_status = (integer) $comment->comment_spam_status; 560 567 $this->cur_comment->comment_trackback = (integer) $comment->comment_trackback; 561 568 562 569 $this->cur_comment->comment_tz = $comment->exists('comment_tz') ? (string) $comment->comment_tz : 'UTC'; 563 570 $this->cur_comment->comment_spam_filter = $comment->exists('comment_spam_filter') ? (integer) $comment->comment_spam_filter : null; 564 571 565 572 $this->cur_comment->insert(); 566 573 } 567 574 568 575 private function insertSpamRule($spamrule) 569 576 { 570 577 $this->cur_spamrule->clean(); 571 578 572 579 $this->cur_spamrule->rule_id = (integer) $spamrule->rule_id; 573 580 $this->cur_spamrule->blog_id = !$spamrule->blog_id ? null : (string) $spamrule->blog_id; 574 581 $this->cur_spamrule->rule_type = (string) $spamrule->rule_type; 575 582 $this->cur_spamrule->rule_content = (string) $spamrule->rule_content; 576 583 577 584 $this->cur_spamrule->insert(); 578 585 } 579 586 580 587 private function insertCategorySingle($category) 581 588 { 582 589 $this->cur_category->clean(); 583 590 584 591 $m = $this->searchCategory($this->stack['categories'],$category->cat_url); 585 592 586 593 $old_id = $category->cat_id; 587 594 if ($m !== false) … … 594 601 $category->cat_id = $cat_id; 595 602 $category->blog_id = $this->blog_id; 596 603 597 604 $this->insertCategory($category); 598 605 $this->stack['cat_id']++; 599 606 } 600 607 601 608 $this->old_ids['category'][(integer) $old_id] = $cat_id; 602 609 } 603 610 604 611 private function insertLinkSingle($link) 605 612 { 606 613 $link->blog_id = $this->blog_id; 607 614 $link->link_id = $this->stack['link_id']; 608 615 609 616 $this->insertLink($link); 610 617 $this->stack['link_id']++; 611 618 } 612 619 613 620 private function insertPostSingle($post) 614 621 { … … 616 623 $post_id = $this->stack['post_id']; 617 624 $this->old_ids['post'][(integer) $post->post_id] = $post_id; 618 625 619 626 $cat_id = $post->cat_id ? $this->old_ids['category'][(integer) $post->cat_id] : null; 620 627 621 628 $post->post_id = $post_id; 622 629 $post->cat_id = $cat_id; 623 630 $post->blog_id = $this->blog_id; 624 631 625 632 $post->post_url = $this->core->blog->getPostURL( 626 633 $post->post_url,$post->post_dt,$post->post_title,$post->post_id 627 634 ); 628 635 629 636 $this->insertPost($post); 630 637 $this->stack['post_id']++; … … 633 640 } 634 641 } 635 642 636 643 private function insertMetaSingle($meta) 637 644 { … … 643 650 } 644 651 } 645 652 646 653 private function insertMediaSingle($media) 647 654 { 648 655 $media_id = $this->stack['media_id']; 649 656 $old_id = $media->media_id; 650 657 651 658 $media->media_id = $media_id; 652 659 $media->media_path = $this->core->blog->settings->system->public_path; 653 660 $media->user_id = $this->getUserId($media->user_id); 654 661 655 662 $this->insertMedia($media); 656 663 $this->stack['media_id']++; 657 664 $this->old_ids['media'][(integer) $old_id] = $media_id; 658 665 } 659 666 660 667 private function insertPostMediaSingle($post_media) 661 668 { … … 664 671 $post_media->media_id = $this->old_ids['media'][(integer) $post_media->media_id]; 665 672 $post_media->post_id = $this->old_ids['post'][(integer) $post_media->post_id]; 666 673 667 674 $this->insertPostMedia($post_media); 668 675 } elseif (!isset($this->old_ids['media'][(integer) $post_media->media_id])) { … … 672 679 } 673 680 } 674 681 675 682 private function insertPingSingle($ping) 676 683 { 677 684 if (isset($this->old_ids['post'][(integer) $ping->post_id])) { 678 685 $ping->post_id = $this->old_ids['post'][(integer) $ping->post_id]; 679 686 680 687 $this->insertPing($ping); 681 688 } else { … … 683 690 } 684 691 } 685 692 686 693 private function insertCommentSingle($comment) 687 694 { 688 695 if (isset($this->old_ids['post'][(integer) $comment->post_id])) { 689 696 $comment_id = $this->stack['comment_id']; 690 697 691 698 $comment->comment_id = $comment_id; 692 699 $comment->post_id = $this->old_ids['post'][(integer) $comment->post_id]; 693 700 694 701 $this->insertComment($comment); 695 702 $this->stack['comment_id']++; … … 698 705 } 699 706 } 700 707 701 708 private static function throwIdError($name,$line,$related) 702 709 { … … 708 715 )); 709 716 } 710 717 711 718 public function searchCategory($rs,$url) 712 719 { … … 717 724 } 718 725 } 719 726 720 727 return false; 721 728 } 722 729 723 730 public function getUserId($user_id) 724 731 { … … 730 737 $user_id = preg_replace('/[^A-Za-z0-9]$/','',$user_id); 731 738 $user_id .= strlen($user_id) < 2 ? '-a' : ''; 732 739 733 740 # We change user_id, we need to check again 734 741 if (!$this->userExists($user_id)) … … 737 744 $this->cur_user->user_id = (string) $user_id; 738 745 $this->cur_user->user_pwd = md5(uniqid()); 739 746 740 747 $this->core->addUser($this->cur_user); 741 748 742 749 $this->stack['users'][$user_id] = true; 743 750 } … … 749 756 } 750 757 } 751 758 752 759 return $user_id; 753 760 } 754 761 755 762 private function userExists($user_id) 756 763 { … … 758 765 return $this->stack['users'][$user_id]; 759 766 } 760 767 761 768 $strReq = 'SELECT user_id '. 762 769 'FROM '.$this->prefix.'user '. 763 770 "WHERE user_id = '".$this->con->escape($user_id)."' "; 764 771 765 772 $rs = $this->con->select($strReq); 766 773 767 774 $this->stack['users'][$user_id] = !$rs->isEmpty(); 768 775 return $this->stack['users'][$user_id]; 769 776 } 770 777 771 778 private function prefExists($pref_ws,$pref_id,$user_id) 772 779 { … … 780 787 $strReq .= "AND user_id = '".$this->con->escape($user_id)."' "; 781 788 } 782 789 783 790 $rs = $this->con->select($strReq); 784 791 785 792 return !$rs->isEmpty(); 786 793 } 787 794 788 795 private function mediaExists() 789 796 { … … 792 799 "WHERE media_path = '".$this->con->escape($this->cur_media->media_path)."' ". 793 800 "AND media_file = '".$this->con->escape($this->cur_media->media_file)."' "; 794 801 795 802 $rs = $this->con->select($strReq); 796 803 797 804 return !$rs->isEmpty(); 798 805 } 799 806 800 807 private function prepareDC12line(&$line) 801 808 { … … 804 811 'dc_wiki_comments','dc_use_smilies','dc_date_format','dc_time_format', 805 812 'dc_url_scan'); 806 813 807 814 switch ($line->__name) 808 815 { … … 830 837 $line->post_content_xhtml = $line->post_content; 831 838 $line->post_excerpt_xhtml = $line->post_chapo; 832 839 833 840 if ($line->post_format == 'wiki') { 834 841 $line->post_content = $line->post_content_wiki; … … 838 845 $line->post_excerpt = $line->post_chapo; 839 846 } 840 847 841 848 $line->post_status = (integer) $line->post_pub; 842 849 $line->post_type = 'post'; 843 850 $line->blog_id = 'default'; 844 851 845 852 $line->drop('post_titre_url','post_content_wiki','post_chapo','post_chapo_wiki','post_pub'); 846 853 847 854 break; 848 855 case 'post_meta': … … 862 869 break; 863 870 } 864 871 865 872 # --BEHAVIOR-- importPrepareDC12 866 873 $this->core->callBehavior('importPrepareDC12',$line,$this,$this->core); 867 874 } 868 875 } 869 ?>
Note: See TracChangeset
for help on using the changeset viewer.