- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/importExport/inc/class.dc.export.flat.php
r1857 r2566 20 20 $this->description = __('Exports a blog or a full Dotclear installation to flat file.'); 21 21 } 22 22 23 23 public function process($do) 24 24 { 25 25 # Export a blog 26 26 if ($do == 'export_blog' && $this->core->auth->check('admin',$this->core->blog->id)) 27 { 27 { 28 28 $fullname = $this->core->blog->public_path.'/.backup_'.sha1(uniqid()); 29 29 $blog_id = $this->core->con->escape($this->core->blog->id); 30 30 31 31 try 32 32 { 33 33 $exp = new flatExport($this->core->con,$fullname,$this->core->prefix); 34 34 fwrite($exp->fp,'///DOTCLEAR|'.DC_VERSION."|single\n"); 35 35 36 36 $exp->export('category', 37 37 'SELECT * FROM '.$this->core->prefix.'category '. … … 78 78 "AND P.blog_id = '".$blog_id."'" 79 79 ); 80 80 81 81 # --BEHAVIOR-- exportSingle 82 82 $this->core->callBehavior('exportSingle',$this->core,$exp,$blog_id); 83 83 84 84 $_SESSION['export_file'] = $fullname; 85 85 $_SESSION['export_filename'] = $_POST['file_name']; … … 93 93 } 94 94 } 95 95 96 96 # Export all content 97 97 if ($do == 'export_all' && $this->core->auth->isSuperAdmin()) … … 118 118 $exp->exportTable('spamrule'); 119 119 $exp->exportTable('version'); 120 120 121 121 # --BEHAVIOR-- exportFull 122 122 $this->core->callBehavior('exportFull',$this->core,$exp); 123 123 124 124 $_SESSION['export_file'] = $fullname; 125 125 $_SESSION['export_filename'] = $_POST['file_name']; … … 133 133 } 134 134 } 135 135 136 136 # Send file content 137 137 if ($do == 'ok') … … 140 140 throw new Exception(__('Export file not found.')); 141 141 } 142 142 143 143 ob_end_clean(); 144 144 145 145 if (substr($_SESSION['export_filename'],-4) == '.zip') { 146 146 $_SESSION['export_filename'] = substr($_SESSION['export_filename'],0,-4);//.'.txt'; 147 147 } 148 148 149 149 # Flat export 150 150 if (empty($_SESSION['export_filezip'])) { 151 151 152 152 header('Content-Disposition: attachment;filename='.$_SESSION['export_filename']); 153 153 header('Content-Type: text/plain; charset=UTF-8'); 154 154 readfile($_SESSION['export_file']); 155 155 156 156 unlink($_SESSION['export_file']); 157 157 unset($_SESSION['export_file'],$_SESSION['export_filename'],$_SESSION['export_filezip']); … … 163 163 { 164 164 $file_zipname = $_SESSION['export_filename'].'.zip'; 165 165 166 166 $fp = fopen('php://output','wb'); 167 167 $zip = new fileZip($fp); 168 168 $zip->addFile($_SESSION['export_file'],$_SESSION['export_filename']); 169 169 170 170 header('Content-Disposition: attachment;filename='.$file_zipname); 171 171 header('Content-Type: application/x-zip'); 172 172 173 173 $zip->write(); 174 174 175 175 unlink($_SESSION['export_file']); 176 176 unset($zip,$_SESSION['export_file'],$_SESSION['export_filename'],$file_zipname); … … 181 181 unset($zip,$_SESSION['export_file'],$_SESSION['export_filename'],$file_zipname); 182 182 @unlink($_SESSION['export_file']); 183 183 184 184 throw new Exception(__('Failed to compress export file.')); 185 185 } … … 187 187 } 188 188 } 189 189 190 190 public function gui() 191 191 { … … 194 194 '<h3>'.__('Single blog').'</h3>'. 195 195 '<p>'.sprintf(__('This will create an export of your current blog: %s'),'<strong>'.html::escapeHTML($this->core->blog->name)).'</strong>.</p>'. 196 196 197 197 '<p><label for="file_name">'.__('File name:').'</label>'. 198 198 form::field(array('file_name','file_name'),50,255,date('Y-m-d-H-i-').html::escapeHTML($this->core->blog->id.'-backup.txt')). 199 199 '</p>'. 200 200 201 201 '<p><label for="file_zip" class="classic">'. 202 202 form::checkbox(array('file_zip','file_zip'),1).' '. 203 203 __('Compress file').'</label>'. 204 204 '</p>'. 205 205 206 206 '<p class="zip-dl"><a href="media.php?d=&zipdl=1">'. 207 207 __('You may also want to download your media directory as a zip file').'</a></p>'. 208 208 209 209 '<p><input type="submit" value="'.__('Export').'" />'. 210 210 form::hidden(array('do'),'export_blog'). 211 211 $this->core->formNonce().'</p>'. 212 212 213 213 '</form>'; 214 214 215 215 if ($this->core->auth->isSuperAdmin()) 216 216 { … … 219 219 '<h3>'.__('Multiple blogs').'</h3>'. 220 220 '<p>'.__('This will create an export of all the content of your database.').'</p>'. 221 221 222 222 '<p><label for="file_name2">'.__('File name:').'</label>'. 223 223 form::field(array('file_name','file_name2'),50,255,date('Y-m-d-H-i-').'dotclear-backup.txt'). 224 224 '</p>'. 225 225 226 226 '<p><label for="file_zip2" class="classic">'. 227 227 form::checkbox(array('file_zip','file_zip2'),1).' '. 228 228 __('Compress file').'</label>'. 229 229 '</p>'. 230 230 231 231 '<p><input type="submit" value="'.__('Export').'" />'. 232 232 form::hidden(array('do'),'export_all'). 233 233 $this->core->formNonce().'</p>'. 234 234 235 235 '</form>'; 236 236 } 237 237 } 238 238 } 239 ?>
Note: See TracChangeset
for help on using the changeset viewer.
