C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$R4JXGWR\include\admin\import.inc.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?php # $Id: import.inc.php 590 2005-10-24 10:13:37Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved.  See LICENSE file for licensing details

if (IN_serendipity !== true) {
    die (
"Don't hack!");
}

if (!
serendipity_checkPermission('adminImport')) {
    return;
}

/* This won't do anything if safe-mode is ON, but let's try anyway since importing could take a while */
@set_time_limit(0);

/* For later use */
class Serendipity_Import {
    var 
$trans_table '';

    function 
getImportNotes() { return ""; }

    function 
getCharsets($utf8_default true) {
        
$charsets = array();
        
        if (!
$utf8_default) {
            
$charsets['native'] = LANG_CHARSET;
        }

        if (
LANG_CHARSET != 'UTF-8') {
            
$charsets['UTF-8'] = 'UTF-8';
        }

        if (
LANG_CHARSET != 'ISO-8859-1') {
            
$charsets['ISO-8859-1'] = 'ISO-8859-1';
        }
        
        if (
$utf8_default) {
            
$charsets['native'] = LANG_CHARSET;
        }
        
        return 
$charsets;
    }

    function &
decode($string) {
        
// xml_parser_* functions to recoding from ISO-8859-1/UTF-8
        
if (LANG_CHARSET == 'ISO-8859-1' || LANG_CHARSET == 'UTF-8') {
            return 
$string;
        }

        
$target $this->data['charset'];

        switch(
$target) {
            case 
'native':
                return 
$string;

            case 
'ISO-8859-1':
                if (
function_exists('iconv')) {
                    
$out iconv('ISO-8859-1'LANG_CHARSET$string);
                } elseif (
function_exists('recode')) {
                    
$out recode('iso-8859-1..' LANG_CHARSET$string);
                } else {
                    return 
$string;
                }
                return 
$out;
            
            case 
'UTF-8':
            default:
                
$out utf8_decode($string);
                return 
$out;
        }
    }

    function 
strtr($data) {
        return 
strtr($this->decode($data), $this->trans_table);
    }

    function 
strtrRecursive($data) {
        foreach (
$data as $key => $val) {
            if (
is_array($val)) {
                
$data[$key] = $this->strtrRecursive($val);
            } else {
                
$data[$key] = $this->strtr($val);
            }
        }

        return 
$data;
    }
    
    function 
getTransTable() {
        if (!
serendipity_db_bool($this->data['use_strtr'])) {
            
$this->trans_table = array();
            return 
true;
        }

        
// We need to convert interesting characters to HTML entities, except for those with special relevance to HTML.
        
$this->trans_table get_html_translation_table(HTML_ENTITIES);
        foreach (
get_html_translation_table(HTML_SPECIALCHARS) as $char => $encoded) {
            if (isset(
$this->trans_table[$char])) {
                unset(
$this->trans_table[$char]);
            }
        }
    }

    function &
nativeQuery($query$db false) {
        global 
$serendipity;

        
mysql_select_db($this->data['name']);
        
$return = &mysql_query($query$db);
        
// print_r($return);
        
mysql_select_db($serendipity['dbName']);
        return 
$return;
    }
}

if (isset(
$serendipity['GET']['importFrom']) && serendipity_checkFormToken()) {

    
/* Include the importer */
    
$class = @require_once(S9Y_INCLUDE_PATH 'include/admin/importers/'basename($serendipity['GET']['importFrom']) .'.inc.php');
    if ( !
class_exists($class) ) {
        die(
'FAILURE: Unable to require import module, possible syntax error?');
    }

    
/* Init the importer with form data */
    
$importer = new $class($serendipity['POST']['import']);

    
/* Yes sir, we are importing if we have valid data */
    
if ( $importer->validateData() ) {
        echo 
IMPORT_STARTING '<br />';

        
/* import() MUST return (bool)true, otherwise we assume it failed */
        
if ( ($result $importer->import()) !== true ) {
            echo 
IMPORT_FAILED .': '$result '<br />';
        } else {
            echo 
IMPORT_DONE '<br />';
        }


    
/* Apprently we do not have valid data, ask for some */
    
} else {
?>

<?php echo IMPORT_PLEASE_ENTER ?>:<br />
<br />
<form action="" method="POST" enctype="multipart/form-data">
  <?php echo serendipity_setFormToken(); ?>
  <table cellpadding="3" cellspacing="2">
    <?php foreach ( $importer->getInputFields() as $field ) { ?>
    <tr>
      <td><?php echo $field['text'?></td>
      <td><?php serendipity_guessInput($field['type'], 'serendipity[import]['$field['name'] .']', (isset($serendipity['POST']['import'][$field['name']]) ? $serendipity['POST']['import'][$field['name']] : $field['default']), $field['default']) ?></td>
    </tr>
    <?php ?>
    <?php if ($notes $importer->getImportNotes()){ ?>
    <tr>
      <td colspan="2">
        <b><?php echo IMPORT_NOTES?></b><br />
        <?php echo $notes ?>
      </td>
    </tr>
    <?php ?>
    <tr>
      <td colspan="2" align="right"><input type="submit" value="<?php echo IMPORT_NOW ?>" class="serendipityPrettyButton"></td>
    </tr>
  </table>
</form>
<?php
    
}

} else {

    
$importpath S9Y_INCLUDE_PATH 'include/admin/importers/';
    
$dir        opendir($importpath);
    
$list       = array();
    while ((
$file readdir($dir)) !== false ) {
        if (!
is_file($importpath $file)) {
            continue;
        }

        
$class = include_once($importpath $file);
        if ( 
class_exists($class) ) {
            
$tmpClass = new $class(array());
            
$list[substr($file0strpos($file'.'))] = $tmpClass->info['software'];
            unset(
$tmpClass);
        }
    }
    
closedir($dir);
    
ksort($list);
?>
<?php 
echo IMPORT_WELCOME ?>.<br />
<?php echo IMPORT_WHAT_CAN ?>. <br />
<br />
<?php echo IMPORT_SELECT ?>:<br />
<br />
<form action="" method="GET">
  <input type="hidden" name="serendipity[adminModule]" value="import">
  <?php echo serendipity_setFormToken(); ?>
  <strong><?php echo IMPORT_WEBLOG_APP ?>: </strong>
  <select name="serendipity[importFrom]">
    <?php foreach ($list as $v=>$k) { ?>
    <option value="<?php echo $v ?>"><?php echo $k ?></option>
    <?php ?>
  </select>
  <input type="submit" value="<?php echo GO ?>" class="serendipityPrettyButton">
</form>
<?php
}

/* vim: set sts=4 ts=4 expandtab : */
?>