Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

Location:
plugins/importExport/inc
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • plugins/importExport/inc/class.dc.export.flat.php

    r1857 r2566  
    2020          $this->description = __('Exports a blog or a full Dotclear installation to flat file.'); 
    2121     } 
    22       
     22 
    2323     public function process($do) 
    2424     { 
    2525          # Export a blog 
    2626          if ($do == 'export_blog' && $this->core->auth->check('admin',$this->core->blog->id)) 
    27           {               
     27          { 
    2828               $fullname = $this->core->blog->public_path.'/.backup_'.sha1(uniqid()); 
    2929               $blog_id = $this->core->con->escape($this->core->blog->id); 
    30                 
     30 
    3131               try 
    3232               { 
    3333                    $exp = new flatExport($this->core->con,$fullname,$this->core->prefix); 
    3434                    fwrite($exp->fp,'///DOTCLEAR|'.DC_VERSION."|single\n"); 
    35                      
     35 
    3636                    $exp->export('category', 
    3737                         'SELECT * FROM '.$this->core->prefix.'category '. 
     
    7878                         "AND P.blog_id = '".$blog_id."'" 
    7979                    ); 
    80                      
     80 
    8181                    # --BEHAVIOR-- exportSingle 
    8282                    $this->core->callBehavior('exportSingle',$this->core,$exp,$blog_id); 
    83                      
     83 
    8484                    $_SESSION['export_file'] = $fullname; 
    8585                    $_SESSION['export_filename'] = $_POST['file_name']; 
     
    9393               } 
    9494          } 
    95            
     95 
    9696          # Export all content 
    9797          if ($do == 'export_all' && $this->core->auth->isSuperAdmin()) 
     
    118118                    $exp->exportTable('spamrule'); 
    119119                    $exp->exportTable('version'); 
    120                      
     120 
    121121                    # --BEHAVIOR-- exportFull 
    122122                    $this->core->callBehavior('exportFull',$this->core,$exp); 
    123                      
     123 
    124124                    $_SESSION['export_file'] = $fullname; 
    125125                    $_SESSION['export_filename'] = $_POST['file_name']; 
     
    133133               } 
    134134          } 
    135            
     135 
    136136          # Send file content 
    137137          if ($do == 'ok') 
     
    140140                    throw new Exception(__('Export file not found.')); 
    141141               } 
    142                 
     142 
    143143               ob_end_clean(); 
    144                 
     144 
    145145               if (substr($_SESSION['export_filename'],-4) == '.zip') { 
    146146                    $_SESSION['export_filename'] = substr($_SESSION['export_filename'],0,-4);//.'.txt'; 
    147147               } 
    148                 
     148 
    149149               # Flat export 
    150150               if (empty($_SESSION['export_filezip'])) { 
    151                 
     151 
    152152                    header('Content-Disposition: attachment;filename='.$_SESSION['export_filename']); 
    153153                    header('Content-Type: text/plain; charset=UTF-8'); 
    154154                    readfile($_SESSION['export_file']); 
    155                      
     155 
    156156                    unlink($_SESSION['export_file']); 
    157157                    unset($_SESSION['export_file'],$_SESSION['export_filename'],$_SESSION['export_filezip']); 
     
    163163                    { 
    164164                         $file_zipname = $_SESSION['export_filename'].'.zip'; 
    165                           
     165 
    166166                         $fp = fopen('php://output','wb'); 
    167167                         $zip = new fileZip($fp); 
    168168                         $zip->addFile($_SESSION['export_file'],$_SESSION['export_filename']); 
    169                           
     169 
    170170                         header('Content-Disposition: attachment;filename='.$file_zipname); 
    171171                         header('Content-Type: application/x-zip'); 
    172                           
     172 
    173173                         $zip->write(); 
    174                           
     174 
    175175                         unlink($_SESSION['export_file']); 
    176176                         unset($zip,$_SESSION['export_file'],$_SESSION['export_filename'],$file_zipname); 
     
    181181                         unset($zip,$_SESSION['export_file'],$_SESSION['export_filename'],$file_zipname); 
    182182                         @unlink($_SESSION['export_file']); 
    183                           
     183 
    184184                         throw new Exception(__('Failed to compress export file.')); 
    185185                    } 
     
    187187          } 
    188188     } 
    189       
     189 
    190190     public function gui() 
    191191     { 
     
    194194          '<h3>'.__('Single blog').'</h3>'. 
    195195          '<p>'.sprintf(__('This will create an export of your current blog: %s'),'<strong>'.html::escapeHTML($this->core->blog->name)).'</strong>.</p>'. 
    196            
     196 
    197197          '<p><label for="file_name">'.__('File name:').'</label>'. 
    198198          form::field(array('file_name','file_name'),50,255,date('Y-m-d-H-i-').html::escapeHTML($this->core->blog->id.'-backup.txt')). 
    199199          '</p>'. 
    200            
     200 
    201201          '<p><label for="file_zip" class="classic">'. 
    202202          form::checkbox(array('file_zip','file_zip'),1).' '. 
    203203          __('Compress file').'</label>'. 
    204204          '</p>'. 
    205            
     205 
    206206          '<p class="zip-dl"><a href="media.php?d=&amp;zipdl=1">'. 
    207207          __('You may also want to download your media directory as a zip file').'</a></p>'. 
    208            
     208 
    209209          '<p><input type="submit" value="'.__('Export').'" />'. 
    210210          form::hidden(array('do'),'export_blog'). 
    211211          $this->core->formNonce().'</p>'. 
    212            
     212 
    213213          '</form>'; 
    214            
     214 
    215215          if ($this->core->auth->isSuperAdmin()) 
    216216          { 
     
    219219               '<h3>'.__('Multiple blogs').'</h3>'. 
    220220               '<p>'.__('This will create an export of all the content of your database.').'</p>'. 
    221                 
     221 
    222222               '<p><label for="file_name2">'.__('File name:').'</label>'. 
    223223               form::field(array('file_name','file_name2'),50,255,date('Y-m-d-H-i-').'dotclear-backup.txt'). 
    224224               '</p>'. 
    225                 
     225 
    226226               '<p><label for="file_zip2" class="classic">'. 
    227227               form::checkbox(array('file_zip','file_zip2'),1).' '. 
    228228               __('Compress file').'</label>'. 
    229229               '</p>'. 
    230                 
     230 
    231231               '<p><input type="submit" value="'.__('Export').'" />'. 
    232232               form::hidden(array('do'),'export_all'). 
    233233               $this->core->formNonce().'</p>'. 
    234                 
     234 
    235235               '</form>'; 
    236236          } 
    237237     } 
    238238} 
    239 ?> 
  • plugins/importExport/inc/class.dc.ieModule.php

    r1553 r2566  
    1818     public $name; 
    1919     public $description; 
    20       
     20 
    2121     protected $import_url; 
    2222     protected $export_url; 
    2323     protected $core; 
    24       
     24 
    2525     public function __construct($core) 
    2626     { 
    2727          $this->core =& $core; 
    2828          $this->setInfo(); 
    29            
     29 
    3030          if (!in_array($this->type,array('import','export'))) { 
    3131               throw new Exception(sprintf('Unknow type for module %s',get_class($this))); 
    3232          } 
    33            
     33 
    3434          if (!$this->name) { 
    3535               $this->name = get_class($this); 
    3636          } 
    37            
     37 
    3838          $this->id = get_class($this); 
    3939          $this->url = sprintf('plugin.php?p=importExport&type=%s&module=%s',$this->type,$this->id); 
    4040     } 
    41       
     41 
    4242     public function init() 
    4343     { 
    4444     } 
    45       
     45 
    4646     abstract protected function setInfo(); 
    47       
     47 
    4848     final public function getURL($escape=false) 
    4949     { 
    5050          return $escape ? html::escapeHTML($this->url) : $this->url; 
    5151     } 
    52       
     52 
    5353     abstract public function process($do); 
    54       
     54 
    5555     abstract public function gui(); 
    56       
     56 
    5757     protected function progressBar($percent) 
    5858     { 
     
    6363          return '<div class="ie-progress"><div style="width:'.$percent.'%">'.$percent.' %</div></div>'; 
    6464     } 
    65       
     65 
    6666     protected function autoSubmit() 
    6767     { 
    6868          return form::hidden(array('autosubmit'),1); 
    6969     } 
    70       
     70 
    7171     protected function congratMessage() 
    7272     { 
     
    7878     } 
    7979} 
    80 ?> 
  • plugins/importExport/inc/class.dc.import.dc1.php

    r1622 r2566  
    1717     protected $prefix; 
    1818     protected $blog_id; 
    19       
     19 
    2020     protected $action = null; 
    2121     protected $step = 1; 
    22       
     22 
    2323     protected $post_offset = 0; 
    2424     protected $post_limit = 20; 
    2525     protected $post_count = 0; 
    26       
     26 
    2727     protected $has_table = array(); 
    28       
     28 
    2929     protected $vars; 
    3030     protected $base_vars = array( 
     
    3737          'cat_ids' => array() 
    3838     ); 
    39       
     39 
    4040     protected function setInfo() 
    4141     { 
     
    4444          $this->description = __('Import a Dotclear 1.2 installation into your current blog.'); 
    4545     } 
    46       
     46 
    4747     public function init() 
    4848     { 
     
    5050          $this->prefix = $this->core->prefix; 
    5151          $this->blog_id = $this->core->blog->id; 
    52            
     52 
    5353          if (!isset($_SESSION['dc1_import_vars'])) { 
    5454               $_SESSION['dc1_import_vars'] = $this->base_vars; 
    5555          } 
    5656          $this->vars =& $_SESSION['dc1_import_vars']; 
    57            
     57 
    5858          if ($this->vars['post_limit'] > 0) { 
    5959               $this->post_limit = $this->vars['post_limit']; 
    6060          } 
    6161     } 
    62       
     62 
    6363     public function resetVars() 
    6464     { 
     
    6666          unset($_SESSION['dc1_import_vars']); 
    6767     } 
    68       
     68 
    6969     public function process($do) 
    7070     { 
    7171          $this->action = $do; 
    7272     } 
    73       
     73 
    7474     # We handle process in another way to always display something to 
    7575     # user 
     
    130130          } 
    131131     } 
    132       
     132 
    133133     public function gui() 
    134134     { 
     
    138138               $this->error($e); 
    139139          } 
    140            
     140 
    141141          switch ($this->step) 
    142142          { 
     
    147147                    '<p class="warning">'.__('Please note that this process '. 
    148148                    'will empty your categories, blogroll, entries and comments on the current blog.').'</p>'; 
    149                      
     149 
    150150                    printf($this->imForm(1,__('General information'),__('Import my blog now')), 
    151151                    '<p>'.__('We first need some information about your old Dotclear 1.2 installation.').'</p>'. 
     
    189189                    break; 
    190190               case 6: 
    191                     echo  
     191                    echo 
    192192                    '<h3 class="vertical-separator">'.__('Please read carefully').'</h3>'. 
    193193                    '<ul>'. 
     
    195195                    'and will need to ask for a new one by following the "I forgot my password" link on the login page '. 
    196196                    '(Their registered email address has to be valid.)').'</li>'. 
    197                      
     197 
    198198                    '<li>'.sprintf(__('Please note that Dotclear 2 has a new URL layout. You can avoid broken '. 
    199199                    'links by installing <a href="%s">DC1 redirect</a> plugin and activate it in your blog configuration.'), 
    200200                    'http://plugins.dotaddict.org/dc2/details/dc1redirect').'</li>'. 
    201201                    '</ul>'. 
    202                      
     202 
    203203                    $this->congratMessage(); 
    204                      
    205                     break; 
    206           } 
    207      } 
    208       
     204 
     205                    break; 
     206          } 
     207     } 
     208 
    209209     # Simple form for step by step process 
    210210     protected function imForm($step,$legend,$submit_value=null) 
     
    213213               $submit_value = __('next step').' >'; 
    214214          } 
    215            
     215 
    216216          return 
    217217          '<form action="'.$this->getURL(true).'" method="post">'. 
     
    224224          '</form>'; 
    225225     } 
    226       
     226 
    227227     # Error display 
    228228     protected function error($e) 
     
    231231          '<p>'.$e->getMessage().'</p></div>'; 
    232232     } 
    233       
     233 
    234234     # Database init 
    235235     protected function db() 
    236236     { 
    237237          $db = dbLayer::init('mysql',$this->vars['db_host'],$this->vars['db_name'],$this->vars['db_user'],$this->vars['db_pwd']); 
    238            
     238 
    239239          $rs = $db->select("SHOW TABLES LIKE '".$this->vars['db_prefix']."%'"); 
    240240          if ($rs->isEmpty()) { 
    241241               throw new Exception(__('Dotclear tables not found')); 
    242242          } 
    243            
     243 
    244244          while ($rs->fetch()) { 
    245245               $this->has_table[$rs->f(0)] = true; 
    246246          } 
    247            
     247 
    248248          # Set this to read data as they were written in Dotclear 1 
    249249          try { 
    250250               $db->execute('SET NAMES DEFAULT'); 
    251251          } catch (Exception $e) {} 
    252            
     252 
    253253          $db->execute('SET CHARACTER SET DEFAULT'); 
    254254          $db->execute("SET COLLATION_CONNECTION = DEFAULT"); 
     
    256256          $db->execute("SET CHARACTER_SET_SERVER = DEFAULT"); 
    257257          $db->execute("SET CHARACTER_SET_DATABASE = DEFAULT"); 
    258            
     258 
    259259          $this->post_count = $db->select( 
    260260               'SELECT COUNT(post_id) FROM '.$this->vars['db_prefix'].'post ' 
    261261          )->f(0); 
    262            
     262 
    263263          return $db; 
    264264     } 
    265       
     265 
    266266     protected function cleanStr($str) 
    267267     { 
    268268          return text::cleanUTF8(@text::toUTF8($str)); 
    269269     } 
    270       
     270 
    271271     # Users import 
    272272     protected function importUsers() 
     
    275275          $prefix = $this->vars['db_prefix']; 
    276276          $rs = $db->select('SELECT * FROM '.$prefix.'user'); 
    277            
     277 
    278278          try 
    279279          { 
    280280               $this->con->begin(); 
    281                 
     281 
    282282               while ($rs->fetch()) 
    283283               { 
     
    298298                              'post_format' => $rs->user_post_format 
    299299                         )); 
    300                           
     300 
    301301                         $permissions = array(); 
    302302                         switch ($rs->user_level) 
     
    317317                                   break; 
    318318                         } 
    319                           
     319 
    320320                         $this->core->addUser($cur); 
    321321                         $this->core->setUserBlogPermissions( 
     
    326326                    } 
    327327               } 
    328                 
     328 
    329329               $this->con->commit(); 
    330330               $db->close(); 
     
    337337          } 
    338338     } 
    339       
     339 
    340340     # Categories import 
    341341     protected function importCategories() 
     
    344344          $prefix = $this->vars['db_prefix']; 
    345345          $rs = $db->select('SELECT * FROM '.$prefix.'categorie ORDER BY cat_ord ASC'); 
    346            
     346 
    347347          try 
    348348          { 
     
    351351                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    352352               ); 
    353                 
     353 
    354354               $ord = 2; 
    355355               while ($rs->fetch()) 
     
    362362                    $cur->cat_lft      = $ord++; 
    363363                    $cur->cat_rgt      = $ord++; 
    364                      
     364 
    365365                    $cur->cat_id = $this->con->select( 
    366366                         'SELECT MAX(cat_id) FROM '.$this->prefix.'category' 
     
    369369                    $cur->insert(); 
    370370               } 
    371                 
     371 
    372372               $db->close(); 
    373373          } 
     
    378378          } 
    379379     } 
    380       
     380 
    381381     # Blogroll import 
    382382     protected function importLinks() 
     
    385385          $prefix = $this->vars['db_prefix']; 
    386386          $rs = $db->select('SELECT * FROM '.$prefix.'link ORDER BY link_id ASC'); 
    387            
     387 
    388388          try 
    389389          { 
     
    392392                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    393393               ); 
    394                 
     394 
    395395               while ($rs->fetch()) 
    396396               { 
     
    403403                    $cur->link_xfn      = $this->cleanStr($rs->rel); 
    404404                    $cur->link_position = (integer) $rs->position; 
    405                      
     405 
    406406                    $cur->link_id = $this->con->select( 
    407407                         'SELECT MAX(link_id) FROM '.$this->prefix.'link' 
     
    409409                    $cur->insert(); 
    410410               } 
    411                 
     411 
    412412               $db->close(); 
    413413          } 
     
    418418          } 
    419419     } 
    420       
     420 
    421421     # Entries import 
    422422     protected function importPosts(&$percent) 
     
    424424          $db = $this->db(); 
    425425          $prefix = $this->vars['db_prefix']; 
    426            
     426 
    427427          $count = $db->select('SELECT COUNT(post_id) FROM '.$prefix.'post')->f(0); 
    428            
     428 
    429429          $rs = $db->select( 
    430430               'SELECT * FROM '.$prefix.'post ORDER BY post_id ASC '. 
    431431               $db->limit($this->post_offset,$this->post_limit) 
    432432          ); 
    433            
     433 
    434434          try 
    435435          { 
     
    441441                    ); 
    442442               } 
    443                 
     443 
    444444               while ($rs->fetch()) { 
    445445                    $this->importPost($rs,$db); 
    446446               } 
    447                 
     447 
    448448               $db->close(); 
    449449          } 
     
    453453               throw $e; 
    454454          } 
    455            
     455 
    456456          if ($rs->count() < $this->post_limit) { 
    457457               return -1; 
     
    459459               $this->post_offset += $this->post_limit; 
    460460          } 
    461            
     461 
    462462          if ($this->post_offset > $this->post_count) { 
    463463               $percent = 100; 
     
    466466          } 
    467467     } 
    468       
     468 
    469469     protected function importPost($rs,$db) 
    470470     { 
     
    477477          $cur->post_upddt  = $rs->post_upddt; 
    478478          $cur->post_title  = html::decodeEntities($this->cleanStr($rs->post_titre)); 
    479            
     479 
    480480          $cur->post_url = date('Y/m/d/',strtotime($cur->post_dt)).$rs->post_id.'-'.$rs->post_titre_url; 
    481481          $cur->post_url = substr($cur->post_url,0,255); 
    482            
     482 
    483483          $cur->post_format        = $rs->post_content_wiki == '' ? 'xhtml' : 'wiki'; 
    484484          $cur->post_content_xhtml = $this->cleanStr($rs->post_content); 
    485485          $cur->post_excerpt_xhtml = $this->cleanStr($rs->post_chapo); 
    486            
     486 
    487487          if ($cur->post_format == 'wiki') { 
    488488               $cur->post_content = $this->cleanStr($rs->post_content_wiki); 
     
    492492               $cur->post_excerpt = $this->cleanStr($rs->post_chapo); 
    493493          } 
    494            
     494 
    495495          $cur->post_notes        = $this->cleanStr($rs->post_notes); 
    496496          $cur->post_status       = (integer) $rs->post_pub; 
     
    499499          $cur->post_open_tb      = (integer) $rs->post_open_tb; 
    500500          $cur->post_lang         = $rs->post_lang; 
    501            
     501 
    502502          $cur->post_words = implode(' ',text::splitWords( 
    503503               $cur->post_title.' '. 
     
    505505               $cur->post_content_xhtml 
    506506          )); 
    507            
     507 
    508508          $cur->post_id = $this->con->select( 
    509509               'SELECT MAX(post_id) FROM '.$this->prefix.'post' 
    510510               )->f(0) + 1; 
    511            
     511 
    512512          $cur->insert(); 
    513513          $this->importComments($rs->post_id,$cur->post_id,$db); 
    514514          $this->importPings($rs->post_id,$cur->post_id,$db); 
    515            
     515 
    516516          # Load meta if we have some in DC1 
    517517          if (isset($this->has_table[$this->vars['db_prefix'].'post_meta'])) { 
     
    519519          } 
    520520     } 
    521       
     521 
    522522     # Comments import 
    523523     protected function importComments($post_id,$new_post_id,$db) 
    524524     { 
    525525          $count_c = $count_t = 0; 
    526            
     526 
    527527          $rs = $db->select( 
    528528               'SELECT * FROM '.$this->vars['db_prefix'].'comment '. 
    529529               'WHERE post_id = '.(integer) $post_id.' ' 
    530530               ); 
    531            
     531 
    532532          while ($rs->fetch()) 
    533533          { 
     
    542542               $cur->comment_ip        = $rs->comment_ip; 
    543543               $cur->comment_trackback = (integer) $rs->comment_trackback; 
    544                 
     544 
    545545               $cur->comment_site = $this->cleanStr($rs->comment_site); 
    546546               if ($cur->comment_site != '' && !preg_match('!^http://.*$!',$cur->comment_site)) { 
    547547                    $cur->comment_site = substr('http://'.$cur->comment_site,0,255); 
    548548               } 
    549                 
     549 
    550550               if ($rs->exists('spam') && $rs->spam && $rs->comment_status = 0) { 
    551551                    $cur->comment_status = -2; 
    552552               } 
    553                 
     553 
    554554               $cur->comment_words = implode(' ',text::splitWords($cur->comment_content)); 
    555                 
     555 
    556556               $cur->comment_id = $this->con->select( 
    557557                    'SELECT MAX(comment_id) FROM '.$this->prefix.'comment' 
    558558               )->f(0) + 1; 
    559                 
     559 
    560560               $cur->insert(); 
    561                 
     561 
    562562               if ($cur->comment_trackback && $cur->comment_status == 1) { 
    563563                    $count_t++; 
     
    566566               } 
    567567          } 
    568            
     568 
    569569          if ($count_t > 0 || $count_c > 0) 
    570570          { 
     
    577577          } 
    578578     } 
    579       
     579 
    580580     # Pings import 
    581581     protected function importPings($post_id,$new_post_id,$db) 
    582582     { 
    583583          $urls = array(); 
    584            
     584 
    585585          $rs = $db->select( 
    586586               'SELECT * FROM '.$this->vars['db_prefix'].'ping '. 
    587587               'WHERE post_id = '.(integer) $post_id 
    588588               ); 
    589            
     589 
    590590          while ($rs->fetch()) 
    591591          { 
     
    594594                    continue; 
    595595               } 
    596                 
     596 
    597597               $cur = $this->con->openCursor($this->prefix.'ping'); 
    598598               $cur->post_id = (integer) $new_post_id; 
     
    600600               $cur->ping_dt = $rs->ping_dt; 
    601601               $cur->insert(); 
    602                 
     602 
    603603               $urls[$url] = true; 
    604604          } 
    605605     } 
    606       
     606 
    607607     # Meta import 
    608608     protected function importMeta($post_id,$new_post_id,$db) 
     
    612612               'WHERE post_id = '.(integer) $post_id.' ' 
    613613               ); 
    614            
     614 
    615615          if ($rs->isEmpty()) { 
    616616               return; 
    617617          } 
    618            
     618 
    619619          while ($rs->fetch()) { 
    620620               $this->core->meta->setPostMeta($new_post_id,$this->cleanStr($rs->meta_key),$this->cleanStr($rs->meta_value)); 
     
    622622     } 
    623623} 
    624 ?> 
  • plugins/importExport/inc/class.dc.import.feed.php

    r1559 r2566  
    1616     protected $status = false; 
    1717     protected $feed_url = ''; 
    18       
     18 
    1919     public function setInfo() 
    2020     { 
     
    2323          $this->description = __('Add a feed content to the blog.'); 
    2424     } 
    25       
     25 
    2626     public function process($do) 
    2727     { 
     
    3030               return; 
    3131          } 
    32            
     32 
    3333          if (empty($_POST['feed_url'])) { 
    3434               return; 
    3535          } 
    36            
     36 
    3737          $this->feed_url = $_POST['feed_url']; 
    38            
     38 
    3939          $feed = feedReader::quickParse($this->feed_url); 
    4040          if ($feed === false) { 
     
    4444               throw new Exception(__('No items in feed.')); 
    4545          } 
    46            
     46 
    4747          $cur = $this->core->con->openCursor($this->core->prefix.'post'); 
    4848          $this->core->con->begin(); 
     
    5656               $cur->post_status = -2; 
    5757               $cur->post_dt = strftime('%Y-%m-%d %H:%M:%S',$item->TS); 
    58                 
     58 
    5959               try { 
    6060                    $post_id = $this->core->blog->addPost($cur); 
     
    6363                    throw $e; 
    6464               } 
    65                 
     65 
    6666               foreach ($item->subject as $subject) { 
    6767                    $this->core->meta->setPostMeta($post_id,'tag',dcMeta::sanitizeMetaID($subject)); 
    6868               } 
    6969          } 
    70            
     70 
    7171          $this->core->con->commit(); 
    7272          http::redirect($this->getURL().'&do=ok'); 
    73            
     73 
    7474     } 
    75       
     75 
    7676     public function gui() 
    7777     { 
     
    7979               dcPage::success(__('Content successfully imported.')); 
    8080          } 
    81            
     81 
    8282          echo 
    8383          '<form action="'.$this->getURL(true).'" method="post">'. 
    8484          '<p>'.sprintf(__('Add a feed content to the current blog: <strong>%s</strong>.'),html::escapeHTML($this->core->blog->name)).'</p>'. 
    85            
     85 
    8686          '<p><label for="feed_url">'.__('Feed URL:').'</label>'. 
    8787          form::field('feed_url',50,300,html::escapeHTML($this->feed_url)).'</p>'. 
    88            
     88 
    8989          '<p>'. 
    9090          $this->core->formNonce(). 
    9191          form::hidden(array('do'),1). 
    9292          '<input type="submit" value="'.__('Import').'" /></p>'. 
    93            
     93 
    9494          '</form>'; 
    9595     } 
    9696} 
    97 ?> 
  • plugins/importExport/inc/class.dc.import.wp.php

    r1719 r2566  
    1717     protected $prefix; 
    1818     protected $blog_id; 
    19       
     19 
    2020     protected $action = null; 
    2121     protected $step = 1; 
    22       
     22 
    2323     protected $post_offset = 0; 
    2424     protected $post_limit = 20; 
    2525     protected $post_count = 0; 
    26       
     26 
    2727     protected $has_table = array(); 
    28       
     28 
    2929     protected $vars; 
    3030     protected $base_vars = array( 
     
    4545          'permalink_template' => 'p=%post_id%', 
    4646          'permalink_tags' => array( 
    47                '%year%',  
    48                '%monthnum%',  
    49                '%day%',  
    50                '%hour%',  
    51                '%minute%',  
    52                '%second%',  
    53                '%postname%',  
    54                '%post_id%',  
    55                '%category%',  
     47               '%year%', 
     48               '%monthnum%', 
     49               '%day%', 
     50               '%hour%', 
     51               '%minute%', 
     52               '%second%', 
     53               '%postname%', 
     54               '%post_id%', 
     55               '%category%', 
    5656               '%author%' 
    5757          ) 
    5858     ); 
    5959     protected $formaters; 
    60       
     60 
    6161     protected function setInfo() 
    6262     { 
     
    6565          $this->description = __('Import a WordPress installation into your current blog.'); 
    6666     } 
    67       
     67 
    6868     public function init() 
    6969     { 
     
    7171          $this->prefix = $this->core->prefix; 
    7272          $this->blog_id = $this->core->blog->id; 
    73            
     73 
    7474          if (!isset($_SESSION['wp_import_vars'])) { 
    7575               $_SESSION['wp_import_vars'] = $this->base_vars; 
    7676          } 
    7777          $this->vars =& $_SESSION['wp_import_vars']; 
    78            
     78 
    7979          if ($this->vars['post_limit'] > 0) { 
    8080               $this->post_limit = $this->vars['post_limit']; 
     
    8383          $this->formaters = dcAdminCombos::getFormatersCombo(); 
    8484     } 
    85       
     85 
    8686     public function resetVars() 
    8787     { 
     
    8989          unset($_SESSION['wp_import_vars']); 
    9090     } 
    91       
     91 
    9292     public function process($do) 
    9393     { 
    9494          $this->action = $do; 
    9595     } 
    96       
     96 
    9797     # We handle process in another way to always display something to 
    9898     # user 
     
    159159          } 
    160160     } 
    161       
     161 
    162162     public function gui() 
    163163     { 
     
    167167               $this->error($e); 
    168168          } 
    169            
     169 
    170170          switch ($this->step) 
    171171          { 
     
    176176                    '<p class="warning">'.__('Please note that this process '. 
    177177                    'will empty your categories, blogroll, entries and comments on the current blog.').'</p>'; 
    178                      
     178 
    179179                    printf($this->imForm(1,__('General information'),__('Import my blog now')), 
    180180                    '<p>'.__('We first need some information about your old WordPress installation.').'</p>'. 
     
    218218                    form::field('post_limit',3,3,html::escapeHTML($this->vars['post_limit'])).'</p>'. 
    219219                    '</div>'. 
    220                      
     220 
    221221                    '</div>'. 
    222222 
     
    253253                    break; 
    254254               case 6: 
    255                     echo  
     255                    echo 
    256256                    '<p class="message">'.__('Every newly imported user has received a random password '. 
    257257                    'and will need to ask for a new one by following the "I forgot my password" link on the login page '. 
     
    261261          } 
    262262     } 
    263       
     263 
    264264     # Simple form for step by step process 
    265265     protected function imForm($step,$legend,$submit_value=null) 
     
    268268               $submit_value = __('next step').' >'; 
    269269          } 
    270            
     270 
    271271          return 
    272272          '<form action="'.$this->getURL(true).'" method="post">'. 
     
    279279          '</form>'; 
    280280     } 
    281       
     281 
    282282     # Error display 
    283283     protected function error($e) 
     
    286286          '<p>'.$e->getMessage().'</p></div>'; 
    287287     } 
    288       
     288 
    289289     # Database init 
    290290     protected function db() 
    291291     { 
    292292          $db = dbLayer::init('mysql',$this->vars['db_host'],$this->vars['db_name'],$this->vars['db_user'],$this->vars['db_pwd']); 
    293            
     293 
    294294          $rs = $db->select("SHOW TABLES LIKE '".$this->vars['db_prefix']."%'"); 
    295295          if ($rs->isEmpty()) { 
    296296               throw new Exception(__('WordPress tables not found')); 
    297297          } 
    298            
     298 
    299299          while ($rs->fetch()) { 
    300300               $this->has_table[$rs->f(0)] = true; 
    301301          } 
    302            
     302 
    303303          # Set this to read data as they were written 
    304304          try { 
    305305               $db->execute('SET NAMES DEFAULT'); 
    306306          } catch (Exception $e) {} 
    307            
     307 
    308308          $db->execute('SET CHARACTER SET DEFAULT'); 
    309309          $db->execute("SET COLLATION_CONNECTION = DEFAULT"); 
     
    311311          $db->execute("SET CHARACTER_SET_SERVER = DEFAULT"); 
    312312          $db->execute("SET CHARACTER_SET_DATABASE = DEFAULT"); 
    313            
     313 
    314314          $this->post_count = $db->select( 
    315315               'SELECT COUNT(ID) FROM '.$this->vars['db_prefix'].'posts '. 
    316316               'WHERE post_type = \'post\' OR post_type = \'page\'' 
    317317          )->f(0); 
    318            
     318 
    319319          return $db; 
    320320     } 
    321       
     321 
    322322     protected function cleanStr($str) 
    323323     { 
    324324          return text::cleanUTF8(@text::toUTF8($str)); 
    325325     } 
    326       
     326 
    327327     # Users import 
    328328     protected function importUsers() 
     
    331331          $prefix = $this->vars['db_prefix']; 
    332332          $rs = $db->select('SELECT * FROM '.$prefix.'users'); 
    333            
     333 
    334334          try 
    335335          { 
    336336               $this->con->begin(); 
    337                 
     337 
    338338               while ($rs->fetch()) 
    339339               { 
     
    352352                         $cur->user_tz          = $this->core->blog->settings->system->blog_timezone; 
    353353                         $permissions           = array(); 
    354                           
     354 
    355355                         $rs_meta = $db->select('SELECT * FROM '.$prefix.'usermeta WHERE user_id = '.$rs->ID); 
    356356                         while ($rs_meta->fetch()) 
     
    425425          } 
    426426     } 
    427       
     427 
    428428     # Categories import 
    429429     protected function importCategories() 
     
    438438               'ORDER BY t.term_id ASC' 
    439439          ); 
    440            
     440 
    441441          try 
    442442          { 
     
    445445                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    446446               ); 
    447                 
     447 
    448448               $ord = 2; 
    449449               while ($rs->fetch()) 
     
    456456                    $cur->cat_lft      = $ord++; 
    457457                    $cur->cat_rgt      = $ord++; 
    458                      
     458 
    459459                    $cur->cat_id = $this->con->select( 
    460460                         'SELECT MAX(cat_id) FROM '.$this->prefix.'category' 
     
    463463                    $cur->insert(); 
    464464               } 
    465                 
     465 
    466466               $db->close(); 
    467467          } 
     
    472472          } 
    473473     } 
    474       
     474 
    475475     # Blogroll import 
    476476     protected function importLinks() 
     
    479479          $prefix = $this->vars['db_prefix']; 
    480480          $rs = $db->select('SELECT * FROM '.$prefix.'links ORDER BY link_id ASC'); 
    481            
     481 
    482482          try 
    483483          { 
     
    486486                    "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    487487               ); 
    488                 
     488 
    489489               while ($rs->fetch()) 
    490490               { 
     
    495495                    $cur->link_desc     = $this->cleanStr($rs->link_description); 
    496496                    $cur->link_xfn      = $this->cleanStr($rs->link_rel); 
    497                      
     497 
    498498                    $cur->link_id = $this->con->select( 
    499499                         'SELECT MAX(link_id) FROM '.$this->prefix.'link' 
     
    501501                    $cur->insert(); 
    502502               } 
    503                 
     503 
    504504               $db->close(); 
    505505          } 
     
    510510          } 
    511511     } 
    512       
     512 
    513513     # Entries import 
    514514     protected function importPosts(&$percent) 
     
    516516          $db = $this->db(); 
    517517          $prefix = $this->vars['db_prefix']; 
    518            
     518 
    519519          $plink = $db->select( 
    520520                    'SELECT option_value FROM '.$prefix.'options '. 
     
    524524               $this->vars['permalink_template'] = substr($plink,1); 
    525525          } 
    526            
     526 
    527527          $rs = $db->select( 
    528528               'SELECT * FROM '.$prefix.'posts '. 
     
    531531               $db->limit($this->post_offset,$this->post_limit) 
    532532          ); 
    533            
     533 
    534534          try 
    535535          { 
     
    540540                         "WHERE blog_id = '".$this->con->escape($this->blog_id)."' " 
    541541                    ); 
    542                }     
    543                 
     542               } 
     543 
    544544               while ($rs->fetch()) { 
    545545                    $this->importPost($rs,$db); 
    546546               } 
    547                 
     547 
    548548               $db->close(); 
    549549          } 
     
    553553               throw $e; 
    554554          } 
    555            
     555 
    556556          if ($rs->count() < $this->post_limit) { 
    557557               return -1; 
     
    559559               $this->post_offset += $this->post_limit; 
    560560          } 
    561            
     561 
    562562          if ($this->post_offset > $this->post_count) { 
    563563               $percent = 100; 
     
    566566          } 
    567567     } 
    568       
     568 
    569569     protected function importPost($rs,$db) 
    570570     { 
     
    575575               $user_id = $this->vars['user_ids'][$rs->post_author]; 
    576576          } 
    577            
     577 
    578578          $cur = $this->con->openCursor($this->prefix.'post'); 
    579579          $cur->blog_id     = $this->blog_id; 
     
    583583          $cur->post_upddt  = $rs->post_modified; 
    584584          $cur->post_title  = $this->cleanStr($rs->post_title); 
    585            
     585 
    586586          if (!$cur->post_title) { 
    587587               $cur->post_title = 'No title'; 
    588588          } 
    589            
     589 
    590590          if ($this->vars['cat_import'] || $this->vars['cat_as_tags']) 
    591591          { 
     
    601601                    ' ORDER BY t.term_id ASC ' 
    602602                    ); 
    603                if (!$old_cat_ids->isEmpty() && $this->vars['cat_import'])  
     603               if (!$old_cat_ids->isEmpty() && $this->vars['cat_import']) 
    604604               { 
    605605                    $cur->cat_id = $this->vars['cat_ids'][(integer) $old_cat_ids->term_id]; 
    606606               } 
    607607          } 
    608            
     608 
    609609          $permalink_infos = array( 
    610                date('Y',strtotime($cur->post_dt)),  
    611                date('m',strtotime($cur->post_dt)),  
    612                date('d',strtotime($cur->post_dt)),  
    613                date('H',strtotime($cur->post_dt)),  
    614                date('i',strtotime($cur->post_dt)),  
    615                date('s',strtotime($cur->post_dt)),  
    616                $rs->post_name,  
    617                $rs->ID,  
    618                $cur->cat_id,  
     610               date('Y',strtotime($cur->post_dt)), 
     611               date('m',strtotime($cur->post_dt)), 
     612               date('d',strtotime($cur->post_dt)), 
     613               date('H',strtotime($cur->post_dt)), 
     614               date('i',strtotime($cur->post_dt)), 
     615               date('s',strtotime($cur->post_dt)), 
     616               $rs->post_name, 
     617               $rs->ID, 
     618               $cur->cat_id, 
    619619               $cur->user_id 
    620620          ); 
     
    625625          ); 
    626626          $cur->post_url = substr($cur->post_url,0,255); 
    627            
     627 
    628628          if (!$cur->post_url) { 
    629629               $cur->post_url = $rs->ID; 
    630630          } 
    631            
     631 
    632632          $cur->post_format = $this->vars['post_formater']; 
    633633          $_post_content = explode('<!--more-->',$rs->post_content,2); 
     
    639639               $cur->post_content = $this->cleanStr(array_shift($_post_content)); 
    640640          } 
    641            
     641 
    642642          $cur->post_content_xhtml = $this->core->callFormater($this->vars['post_formater'],$cur->post_content); 
    643643          $cur->post_excerpt_xhtml = $this->core->callFormater($this->vars['post_formater'],$cur->post_excerpt); 
    644            
     644 
    645645          switch ($rs->post_status) 
    646646          { 
     
    661661          $cur->post_open_comment = $rs->comment_status == 'open' ? 1 : 0; 
    662662          $cur->post_open_tb      = $rs->ping_status == 'open' ? 1 : 0; 
    663            
     663 
    664664          $cur->post_words = implode(' ',text::splitWords( 
    665665               $cur->post_title.' '. 
     
    667667               $cur->post_content_xhtml 
    668668          )); 
    669            
     669 
    670670          $cur->post_id = $this->con->select( 
    671671               'SELECT MAX(post_id) FROM '.$this->prefix.'post' 
    672672               )->f(0) + 1; 
    673            
     673 
    674674          $cur->post_url = $this->core->blog->getPostURL($cur->post_url,$cur->post_dt,$cur->post_title,$cur->post_id); 
    675            
     675 
    676676          $cur->insert(); 
    677677          $this->importComments($rs->ID,$cur->post_id,$db); 
    678678          $this->importPings($rs->ID,$cur->post_id,$db); 
    679            
     679 
    680680          # Create tags 
    681681          $this->importTags($rs->ID,$cur->post_id,$db); 
    682            
     682 
    683683          if (isset($old_cat_ids)) 
    684684          { 
    685                if (!$old_cat_ids->isEmpty() && $this->vars['cat_as_tags'])  
     685               if (!$old_cat_ids->isEmpty() && $this->vars['cat_as_tags']) 
    686686               { 
    687687                    $old_cat_ids->moveStart(); 
     
    692692          } 
    693693     } 
    694       
     694 
    695695     # Comments import 
    696696     protected function importComments($post_id,$new_post_id,$db) 
    697697     { 
    698698          $count_c = $count_t = 0; 
    699            
     699 
    700700          $rs = $db->select( 
    701701               'SELECT * FROM '.$this->vars['db_prefix'].'comments '. 
    702702               'WHERE comment_post_ID = '.(integer) $post_id.' ' 
    703703               ); 
    704            
     704 
    705705          while ($rs->fetch()) 
    706706          { 
     
    716716               $cur->comment_site = substr($this->cleanStr($rs->comment_author_url),0,255); 
    717717               if ($cur->comment_site == '') $cur->comment_site = NULL; 
    718                 
     718 
    719719               if ($rs->comment_approved == 'spam') { 
    720720                    $cur->comment_status = -2; 
    721721               } 
    722                 
     722 
    723723               $cur->comment_words = implode(' ',text::splitWords($cur->comment_content)); 
    724                 
     724 
    725725               $cur->comment_id = $this->con->select( 
    726726                    'SELECT MAX(comment_id) FROM '.$this->prefix.'comment' 
    727727               )->f(0) + 1; 
    728                 
     728 
    729729               $cur->insert(); 
    730                 
     730 
    731731               if ($cur->comment_trackback && $cur->comment_status == 1) { 
    732732                    $count_t++; 
     
    735735               } 
    736736          } 
    737            
     737 
    738738          if ($count_t > 0 || $count_c > 0) 
    739739          { 
     
    746746          } 
    747747     } 
    748       
     748 
    749749     # Pings import 
    750750     protected function importPings($post_id,$new_post_id,$db) 
     
    752752          $urls = array(); 
    753753          $pings = array(); 
    754            
     754 
    755755          $rs = $db->select( 
    756756               'SELECT pinged FROM '.$this->vars['db_prefix'].'posts '. 
     
    759759          $pings = explode ("\n",$rs->pinged); 
    760760          unset ($pings[0]); 
    761            
     761 
    762762          foreach($pings as $ping_url) 
    763763          { 
     
    766766                    continue; 
    767767               } 
    768                 
     768 
    769769               $cur = $this->con->openCursor($this->prefix.'ping'); 
    770770               $cur->post_id = (integer) $new_post_id; 
    771771               $cur->ping_url = $url; 
    772772               $cur->insert(); 
    773                 
     773 
    774774               $urls[$url] = true; 
    775775          } 
    776776     } 
    777       
     777 
    778778     # Meta import 
    779779     protected function importTags($post_id,$new_post_id,$db) 
     
    789789               ' ORDER BY t.term_id ASC' 
    790790          ); 
    791            
     791 
    792792          if ($rs->isEmpty()) { 
    793793               return; 
    794794          } 
    795            
     795 
    796796          while ($rs->fetch()) { 
    797797               $this->core->meta->setPostMeta($new_post_id,'tag',$this->cleanStr($rs->name)); 
     
    799799     } 
    800800} 
    801 ?> 
  • plugins/importExport/inc/flat/class.flat.backup.php

    r894 r2566  
    1818     private $line_name; 
    1919     private $line_num; 
    20       
     20 
    2121     private $replacement = array( 
    2222          '/(?<!\\\\)(?>(\\\\\\\\)*+)(\\\\n)/u' => "\$1\n", 
     
    2525          '/(\\\\\\\\)/' => '\\' 
    2626     ); 
    27       
     27 
    2828     public function __construct($file) 
    2929     { 
     
    3535          } 
    3636     } 
    37       
     37 
    3838     public function __destruct() 
    3939     { 
     
    4242          } 
    4343     } 
    44       
     44 
    4545     public function getLine() 
    4646     { 
     
    4848               return false; 
    4949          } 
    50            
     50 
    5151          if (substr($line,0,1) == '[') 
    5252          { 
    5353               $this->line_name = substr($line,1,strpos($line,' ')-1); 
    54                 
     54 
    5555               $line = substr($line,strpos($line,' ')+1,-1); 
    5656               $this->line_cols = explode(',',$line); 
    57                 
     57 
    5858               return $this->getLine(); 
    5959          } 
     
    6262               $line = preg_replace('/^"|"$/','',$line); 
    6363               $line = preg_split('/(^"|","|(?<!\\\)\"$)/m',$line); 
    64                 
     64 
    6565               if (count($this->line_cols) != count($line)) { 
    6666                    throw new Exception(sprintf('Invalid row count at line %s',$this->line_num)); 
    6767               } 
    68                 
     68 
    6969               $res = array(); 
    70                 
     70 
    7171               for ($i=0; $i<count($line); $i++) { 
    7272                    $res[$this->line_cols[$i]] = 
    7373                    preg_replace(array_keys($this->replacement),array_values($this->replacement),$line[$i]); 
    7474               } 
    75                 
     75 
    7676               return new flatBackupItem($this->line_name,$res,$this->line_num); 
    7777          } 
     
    8181          } 
    8282     } 
    83       
     83 
    8484     private function nextLine() 
    8585     { 
     
    8888          } 
    8989          $this->line_num++; 
    90            
     90 
    9191          $line = fgets($this->fp); 
    9292          $line = trim($line); 
    93            
     93 
    9494          return empty($line) ? $this->nextLine() : $line; 
    9595     } 
     
    101101     public $__line; 
    102102     private $__data = array(); 
    103       
     103 
    104104     public function __construct($name,$data,$line) 
    105105     { 
     
    108108          $this->__line = $line; 
    109109     } 
    110       
     110 
    111111     public function f($name) 
    112112     { 
    113113          return iconv('UTF-8','UTF-8//IGNORE',$this->__data[$name]); 
    114114     } 
    115       
     115 
    116116     public function __get($name) 
    117117     { 
    118118          return $this->f($name); 
    119119     } 
    120       
     120 
    121121     public function __set($n,$v) 
    122122     { 
    123123          $this->__data[$n] = $v; 
    124124     } 
    125       
     125 
    126126     public function exists($n) 
    127127     { 
    128128          return isset($this->__data[$n]); 
    129129     } 
    130       
     130 
    131131     public function drop() 
    132132     { 
     
    137137          } 
    138138     } 
    139       
     139 
    140140     public function substitute($old,$new) 
    141141     { 
     
    146146     } 
    147147} 
    148 ?> 
  • plugins/importExport/inc/flat/class.flat.export.php

    r840 r2566  
    1616     private $con; 
    1717     private $prefix; 
    18       
     18 
    1919     private $line_reg = array('/\\\\/u',  '/\n/u','/\r/u','/"/u'); 
    2020     private $line_rep = array('\\\\\\\\', '\n'   ,'\r'   ,'\"'); 
    21       
     21 
    2222     public $fp; 
    23       
     23 
    2424     function __construct($con,$out='php://output',$prefix=null) 
    2525     { 
    2626          $this->con =& $con; 
    2727          $this->prefix = $prefix; 
    28            
     28 
    2929          if (($this->fp = fopen($out,'w')) === false) { 
    3030               return false; 
     
    3232          @set_time_limit(300); 
    3333     } 
    34       
     34 
    3535     function __destruct() 
    3636     { 
     
    3939          } 
    4040     } 
    41       
     41 
    4242     function export($name,$sql) 
    4343     { 
    4444          $rs = $this->con->select($sql); 
    45            
     45 
    4646          if (!$rs->isEmpty()) 
    4747          { 
     
    5353          } 
    5454     } 
    55       
     55 
    5656     function exportAll() 
    5757     { 
    5858          $tables = $this->getTables(); 
    59            
     59 
    6060          foreach ($tables as $table) 
    6161          { 
     
    6363          } 
    6464     } 
    65       
     65 
    6666     function exportTable($table) 
    6767     { 
    6868          $req = 'SELECT * FROM '.$this->con->escapeSystem($this->prefix.$table); 
    69            
     69 
    7070          $this->export($table,$req); 
    7171     } 
    72       
     72 
    7373     function getTables() 
    7474     { 
    7575          $schema = dbSchema::init($this->con); 
    7676          $db_tables = $schema->getTables(); 
    77            
     77 
    7878          $tables = array(); 
    7979          foreach ($db_tables as $t) 
     
    8787               } 
    8888          } 
    89            
     89 
    9090          return $tables; 
    9191     } 
    92       
     92 
    9393     function getLine($rs) 
    9494     { 
     
    104104     } 
    105105} 
    106 ?> 
  • plugins/importExport/inc/lib.ie.maintenance.php

    r1989 r2566  
    5858          } 
    5959          else { 
    60                return  
     60               return 
    6161               '<p><label for="file_name">'.__('File name:').'</label>'. 
    6262               form::field('file_name', 50, 255, date('Y-m-d-H-i-').$this->export_name). 
     
    115115          } 
    116116          else { 
    117                return  
     117               return 
    118118               '<p><label for="file_name">'.__('File name:').'</label>'. 
    119119               form::field('file_name', 50, 255, date('Y-m-d-H-i-').$this->export_name). 
Note: See TracChangeset for help on using the changeset viewer.

Sites map