Jetzt kostenlos Anmelden!

Ruhrzwerg

ist gerade angekommen

1

Montag, 17. März 2008, 18:50

Datenbanksicherung Skript von DjMars

Hallo Zusammen,

so lamgsam zweifel ich an meinem Verstand. Ich hoffe Ihr könnt mir weiterhelfen. Habe das Skribt auf zwei verschiedenen Seiten laufen. Auf der einen Seite funktioniert es einwandfrei.

Auf der Anderen passiert folgendes:
Führe ich das Skript aus, erscheint ein Downloadfenster und es wird mir angezeigt, das ich die include.php runterladen möchte. Zur info, wenn ich es mache habe ich eine Datei mit 0 Byte auf dem Desktop. Passwort und Pfad stimmen.

Habe als Browser den Fuchs, PHP kit 1.6.1.
Die php liegt im hauptverzeichnis, der link ist integriert in der community_admin.html unter templates/navigation.

Bin mit meinem Latein am Ende. Habt Ihr eine Idee was falsch läuft?


Ich danke für Eure Antworten.

Datei community_admin.html:

Quellcode

1
2
3
<a class="nav$navalign" href="admin/admin.php">Administration</a>
<br></br>
<a class="nav$navalign" href="http://www.meineseite.de/include.php?path=sicherung.php&password=abcdefg">Datenbanksicherung</a>

Datei sicherung.php

PHP-Quelltext

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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<?php
if ($_GET['password'] == "abcdefg") {

// DATABASE-BACKUP
// ==================
$content ="#############################################\n";
$content.="#\n";
$content.="# PHPKIT Database Backup ".formattime(time())."\n";
$content.="# Database ".$database."@".$_ENV['SERVER_NAME']."\n";
$content.="#\n";
$content.="#############################################\n";
$content.="\n\n";

$list_tables=$DB->list_tables();
while ($tables=$DB->fetch_row($list_tables)) {
$tab $tables[0];
if($tab!="plz_data") {
$content.="###########\n";
$content.="# Table ".$tab."\n";
$content.="#\n";
$content.="\n";

$content.="CREATE TABLE ".$tab." (\n";
$getinfo=$DB->query("DESCRIBE ".$tab."");
$count=$DB->num_rows($getinfo);
$c=0;
while($info=$DB->fetch_array($getinfo)) {
$tab_name=$info['Field'];
$tab_type=" ".$info['Type'];
if ($info['Null']==''$tab_null=" NOT NULL";
else $tab_null=" NULL";
if ($info['Default']==''$tab_default='';
else $tab_default=" DEFAULT '".$info['Default']."'";
if ($info['Extra']==''$tab_extra='';
else $tab_extra=" ".$info['Extra'];
$c++;
if($c<$count$tab_komma=",\n";
else $tab_komma='';
$content.=" ".$tab_name.$tab_type.$tab_null.$tab_default.$tab_extra.$tab_komma."";
}

unset($keyarray);
$getinfo=$DB->query("SHOW KEYS FROM ".$tab."");
while($info=$DB->fetch_array($getinfo)) {
$keyname=$info['Key_name'];
$comment=(isset($info['Comment'])) ? $info['Comment'] : "";
$sub_part=(isset($info['Sub_part'])) ? $info['Sub_part'] : "";

if($keyname!="PRIMARY" && $info['Non_unique']==0$keyname="UNIQUE|$keyname";
if($comment=="FULLTEXT"$keyname="FULLTEXT|$keyname";

if(!isset($keyarray[$keyname])) $keyarray[$keyname]=array();
if($sub_part>1$keyarray[$keyname][]=$info['Column_name']."(".$sub_part.")";
else $keyarray[$keyname][]=$info['Column_name'];
}

if (is_array($keyarray)) {
foreach($keyarray as $keyname => $columns) {
$content.=",\n";
if($keyname=="PRIMARY"$content.="PRIMARY KEY (";
elseif(substr($keyname06) == "UNIQUE"$content.="UNIQUE ".substr($keyname7)." (";
elseif(substr($keyname08) == "FULLTEXT"$content.="FULLTEXT ".substr($keyname9)." (";
else $content.="KEY ".$keyname.' (';
$content.=implode($columns,", ").")";
}
}
$content.=");\n";
$content.="\n";


$queryresult=$DB->query("SELECT * FROM ".$tab);
while($info=$DB->fetch_assoc($queryresult)) {
unset($values);
unset($fieldnames);
foreach($info as $field) {
if($values$values.=",".formatfield($field);
else $values=formatfield($field);
}
$content.="INSERT INTO ".$tab." VALUES (".$values.");\n";
}
$content.="\n";
$DB->free_result($queryresult);
}
}

$db_backup $content;

$newzip = new zipwrite();
$newzip->add_file($db_backup"db_auto_".date("dmy").".sql");
$zipcontent $newzip->file();

$Files = array($zipcontent);
$FileNames = array("db_auto_".date("dmy").".zip");

SendMail("admin@meineseite.de""\"name\" <[email]administrator@meineseite.de[/email]>""DB-Backup ".date("d.m.Y"), "Datenbankbackup vom ".date("d.m.Y"), $Files$FileNames);

// ==================

eval ("\$site_body.= \"<table class='standard' cellspacing='1' cellpadding='4' width='100%'><tr><td class='heads'>Backup</td></tr><tr><td class='standard'>Gesendet - ".date("d.m.Y - H:i"time())."!</td></tr></table>\";");
}
else {$event=1; include("admin/config/event.php");}


// ============================================================
// ............................................................
// ============================================================

class zipwrite {

var $datasec;
var $ctrl_dir;
var $eof_ctrl_dir;
var $old_offset;
var $prepend;

function zipwrite($sfxprepend 0) {
$this->datasec = array();
$this->ctrl_dir = array();
$this->eof_ctrl_dir "\x50\x4b\x05\x06\x00\x00\x00\x00";
$this->prepend $sfxprepend;
$this->old_offset $this->prepend;
}

function add_file($data$name)
{
$name str_replace('\\''/'$name);

$fr "\x50\x4b\x03\x04";
$fr .= "\x14\x00"// ver needed to extract
$fr .= "\x00\x00"// gen purpose bit flag
$fr .= "\x08\x00"// compression method
$fr .= "\x00\x00\x00\x00"// last mod time and date

$unc_len strlen($data);
$crc crc32($data);
$zdata gzcompress($data);
$zdata substr(substr($zdata0strlen($zdata) - 4), 2); // fix crc bug
$c_len strlen($zdata);
$fr .= pack('V'$crc); // crc32
$fr .= pack('V'$c_len); // compressed filesize
$fr .= pack('V'$unc_len); // uncompressed filesize
$fr .= pack('v'strlen($name)); // length of filename
$fr .= pack('v'0); // extra field length
$fr .= $name;

// "file data" segment
$fr .= $zdata;

// "data descriptor" segment (optional but necessary if archive is not
// served as file)
// $fr .= pack('V', $crc); // crc32
// $fr .= pack('V', $c_len); // compressed filesize
// $fr .= pack('V', $unc_len); // uncompressed filesize

// add this entry to array
$this -> datasec[] = $fr;
$new_offset $this->prepend strlen(implode(''$this->datasec));
// now add to central directory record
$cdrec "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"// version made by
$cdrec .= "\x14\x00"// version needed to extract
$cdrec .= "\x00\x00"// gen purpose bit flag
$cdrec .= "\x08\x00"// compression method
$cdrec .= "\x00\x00\x00\x00"// last mod time & date
$cdrec .= pack('V'$crc); // crc32
$cdrec .= pack('V'$c_len); // compressed filesize
$cdrec .= pack('V'$unc_len); // uncompressed filesize
$cdrec .= pack('v'strlen($name) ); // length of filename
$cdrec .= pack('v'); // extra field length
$cdrec .= pack('v'); // file comment length
$cdrec .= pack('v'); // disk number start
$cdrec .= pack('v'); // internal file attributes
$cdrec .= pack('V'32 ); // external file attributes - 'archive' bit set

$cdrec .= pack('V'$this -> old_offset ); // relative offset of local header
$this -> old_offset $new_offset;

$cdrec .= $name;

// optional extra field, file comment goes here
// save to central directory
$this -> ctrl_dir[] = $cdrec;
} // end of the 'add_file()' method

function file($comment '')
{
$data implode(''$this -> datasec);
$ctrldir implode(''$this -> ctrl_dir);

return
$data .
$ctrldir .
$this -> eof_ctrl_dir .
pack('v'sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
pack('v'sizeof($this -> ctrl_dir)) . // total # of entries overall
pack('V'strlen($ctrldir)) . // size of central dir
pack('V'strlen($data) + $this->prepend) . // offset to start of central dir
pack('v'strlen($comment)) . // .zip file comment length!
$comment;

} // end of the 'file()' method

// end of the 'zipfile' class

function SendMail($ToReceiver$FromSender$Subject$MsgText$IFile="none"$IFileName="none")
{
global $mimetype$mime_boundary;

$mime_boundary "--==================_846811060==_" ;
$mimetype "application/octet-stream" ;
define("XNL","\r\n") ; // CONSTANT Newline CR

if (!is_array($IFile)) // check for array (multiple attachments)
{
$File[0] = $IFile ;
$FileName[0] = $IFileName ;
}
else
{
for ($i=0;$i<count($IFile);$i++)
{
$File[$i] = $IFile[$i] ;
$FileName[$i] = $IFileName[$i] ;
}
}

$attCount count($File) ;

$attExists FALSE // check if there is really an attachment
for ($i=0;$i<$attCount;$i++)
{
if ($File[$i] != "none")
{
$attExists TRUE ;
}
}

$txtheaders "From: ".$FromSender."\n" // build header for text
//$txtheaders .= "To: ".$ToReceiver."\n" ;
//$txtheaders .= "Reply-To: ".$FromSender."\n" ;
//$txtheaders .= "X-Mailer: PHP\n" ;
//$txtheaders .= "X-Sender: ".$FromSender."\n" ;

if ($attExists// is there an attachment
{

// build header for attachment
$attheaders "MIME-version: 1.0\n" ;
$attheaders .= 'Content-type: multipart/mixed; boundary="'.$mime_boundary.'"'."\n" ;
$attheaders .= "Content-transfer-encoding: 7BIT\n" ;
$attheaders .= "X-attachments: " ;
$firstAtt TRUE ;
for ($i=0;$i<$attCount;$i++)
{
if ($File[$i] != "none")
{
if ($firstAtt)
{
$firstAtt FALSE ;
}
else
{
$attheaders .= "," ;
}
$attheaders .= $FileName[$i] ;
}
}
$attheaders .= ";\n\n" ;

// build attachment itself
$attach "" ;
for ($i=0;$i<$attCount;$i++)
{
if ($File[$i] != "none")
{
$attach .= "--".$mime_boundary."\n" ;
$attach .= "Content-type:".$mimetype.'; name="'.$FileName[$i].'";'."\n" ;
$attach .= "Content-Transfer-Encoding: base64\n" ;
$attach .= 'Content-disposition: attachment; filename="'.$FileName[$i].'"'."\n\n" ;
$attach .= TextEncode($File[$i])."\n" ;
}
}
// build message itself
$message "--".$mime_boundary."\n" ;
$message .= 'Content-Type. text/plain; charset="us-ascii"'."\n\n" ;
$message .= $MsgText."\n" ;
}
else // no attachment
{
$attheaders "" ;
$attach "" ;
$message $MsgText."\n" // send text only
}
// send email
mail($ToReceiver$Subject$message.$attach$txtheaders.$attheaders) ;

}

//
// build attachment as text conforming RFC2045 (76 char per line, end with \r\n)
//
function TextEncode ($cont)
{
$contents base64_encode($cont) ;
$len strlen($contents) ;
$str "" ;
while($len 0)
{
if ($len >= 76)
{
$str .= substr($contents,0,76).XNL ;
$contents substr($contents76) ;
$len $len 76 ;
}
else
{
$str .= $contents.XNL ;
$contents "" ;
$len ;
}
}


return $str ;
}
?>
  • Zum Seitenanfang
  • Zum Seitenende

philosapiens Männlich

Hilfologe

Beiträge: 657

Geschlecht: Männlich

Wohnort: Berlin

PHPKIT Version: 1.6.1

2

Montag, 17. März 2008, 20:01

Hi,

läuft die Seite, bei der es nicht richtig funktioniert bei einem "Free-Hoster" ?
Leider nutze ich das phpkit immer weniger und bastele mehr Eigenes: ^^
  • Zum Seitenanfang
  • Zum Seitenende

reddevil82 Männlich

BFM Stream Cheffe

Beiträge: 1 712

Geschlecht: Männlich

PHPKIT Version: 1.6.5

3

Montag, 17. März 2008, 21:42

haste du evtl auch mal an ein DB Sicherheitsupdate per CronJob nachgedacht? Wäre noch einfacher wie deine Methode
Seit 02.07.2010 Papa einer süssen Tocher !!!!

http://www.burnerfm.de

Mit den besten Hits der 80´s, 90´s und von heute. Plus einigen PHPKit Addons... uvm.
  • Zum Seitenanfang
  • Zum Seitenende

Ruhrzwerg

ist gerade angekommen

4

Montag, 17. März 2008, 21:54

hmm freehoster kann ich nicht mit gewissheit sagen, habe zwar admin rechte, das teil läuft aber auf nem anderen namen. aber ich denke nicht. das mit dem cronjob habe ich schonmal gelesen aber nicht so recht verstanden. bin nda nicht so schwer betucht wie ihr. kannst du mir da weiterhelfen?

aber was ich noch sagen wollte, ich habe das auf der seite schonmal laufen gehabt, das kommt noch hinzu und ist das eigendlich merkwürdige. jetzt hat da noch jemand anders admin rechte, kann das sein das er irgendwas verstellt hat?
  • Zum Seitenanfang
  • Zum Seitenende

Ruhrzwerg

ist gerade angekommen

5

Mittwoch, 2. April 2008, 07:45

Habt Ihr keinen Tipp für mich?
  • Zum Seitenanfang
  • Zum Seitenende

philosapiens Männlich

Hilfologe

Beiträge: 657

Geschlecht: Männlich

Wohnort: Berlin

PHPKIT Version: 1.6.1

6

Mittwoch, 2. April 2008, 11:42

Hi,

ich nutze schon recht lange und erfolgreich den mysqldumperund einen cronjob. Ist garnicht so schwierig! Einfach mal einlesen. :thumbup:
Leider nutze ich das phpkit immer weniger und bastele mehr Eigenes: ^^
  • Zum Seitenanfang
  • Zum Seitenende

Flachzange Männlich

postet ab und an hier

Beiträge: 200

Geschlecht: Männlich

PHPKIT Version: 1.6.5

7

Mittwoch, 2. April 2008, 14:23

Tach Philo,
genau das gleiche wollte ich ihm auch empfehlen. Funktioniert astrein und ist kinderleicht zu installieren bzw. zu konfigurieren.
  • Zum Seitenanfang
  • Zum Seitenende

Ruhrzwerg

ist gerade angekommen

8

Mittwoch, 2. April 2008, 17:36

Vielen Dank für die Antworten,

dann werd ich das mal so angehen. :S
  • Zum Seitenanfang
  • Zum Seitenende