Source for file backups_lib.php
Documentation is available at backups_lib.php
* Database Backup Library
* Database Backup Library
// Get the password before it's too late
$query = "select `hash` from `". BIT_DB_PREFIX. "users_users` where `user_id`=?";
$query = "select `tablename` from `pg_tables` where `tablename` not like 'pg_%' and `tablename` not like 'sql_%'";
$result = $this->mDb->query($query);
while ($res = $result->fetchRow()) {
list ($key, $val) = each($res);
// Now delete the table contents
$query2 = "delete from `$val`";
$result2 = $this->mDb->query($query2);
// $query = "update `".BIT_DB_PREFIX."users_users` set `hash`=? where `login`=?";
// $result = $this->mDb->query($query,array($pwd,'admin'));
@$fp = fopen($filename, "rb");
$line = fread($fp, $len);
//removing the de/cyphering stuff for now as it doesn't work on database restore
// $line = $this->RC4($pwd, $line);
// EXECUTE SQL SENTENCE HERE
$result = $this->mDb->query($line,array());
function RC4($pwd, $data) {
for ($i = 0; $i <= 255; $i++ ) {
$key[$i] = ord(substr($pwd, ($i % $pwd_length) + 1, 1));
for ($i = 0; $i < 255; $i++ ) {
$x = ($x + $box[$i] + $key[$i]) % 256;
for ($i = 0; $i < strlen($data); $i++ ) {
$j = ($j + $box[$a]) % 256;
$k = $box[(($box[$a] + $box[$j]) % 256)];
$cipher .= chr($cipherby);
// Functions to backup the database (mysql?)
ini_set("max_execution_time", "3000");
$query = "select `hash` from `". BIT_DB_PREFIX. "users_users` where `user_id`=?";
@$fp = fopen($filename, "w");
$query = "select `tablename` from `pg_tables` where `tablename` not like 'pg_%' and `tablename` not like 'sql_%'";
$result = $this->mDb->query($query);
while ($res = $result->fetchRow()) {
list ($key, $val) = each($res);
$query2 = "select * from `$val`";
$result2 = $this->mDb->query($query2);
while ($res2 = $result2->fetchRow()) {
foreach ($res2 as $field => $value) {
$fields = '(`' . $field . '`';
// Don't write out empty tables - chokes mysql
if ($sentence != "values()") {
$part = "insert into `$val` $fields $sentence;";
//removing the de/cyphering stuff for now as it doesn't work on database restore
// $part = $this->RC4($pwd, $part);
|