Ejemplo n.º 1
0
function MSD_mysql_connect($encoding = 'utf8', $keycheck_off = false, $actual_table = '')
{
    global $config, $databases;
    $port = isset($config['dbport']) && !empty($config['dbport']) ? ':' . $config['dbport'] : '';
    $socket = isset($config['dbsocket']) && !empty($config['dbsocket']) ? ':' . $config['dbsocket'] : '';
    $config['dbconnection'] = mysql_connect($config['dbhost'] . $port . $socket, $config['dbuser'], $config['dbpass']) or die(SQLError("Database connection error: ", mysql_error()));
    if (!defined('MSD_MYSQL_VERSION')) {
        GetMySQLVersion();
    }
    if (!isset($config['mysql_standard_character_set']) || $config['mysql_standard_character_set'] == '') {
        get_sql_encodings();
    }
    if ($config['mysql_standard_character_set'] != $encoding) {
        $set_encoding = @mysql_query('SET NAMES \'' . $encoding . '\'', $config['dbconnection']);
        if ($set_encoding === false) {
            $config['mysql_can_change_encoding'] = false;
        } else {
            $config['mysql_can_change_encoding'] = true;
        }
    }
    if ($keycheck_off) {
        mysql_query('SET FOREIGN_KEY_CHECKS=0', $config['dbconnection']);
    }
    return $config['dbconnection'];
}
Ejemplo n.º 2
0
function MSD_mysql_connect($encoding = 'utf8', $keycheck_off = false, $actual_table = '')
{
    global $config, $databases;
    if (isset($config['dbconnection']) && is_resource($config['dbconnection'])) {
        return $config['dbconnection'];
    }
    $port = isset($config['dbport']) && !empty($config['dbport']) ? ':' . $config['dbport'] : '';
    $socket = isset($config['dbsocket']) && !empty($config['dbsocket']) ? ':' . $config['dbsocket'] : '';
    $config['dbconnection'] = @mysql_connect($config['dbhost'] . $port . $socket, $config['dbuser'], $config['dbpass']) or die(SQLError("Error establishing a database connection!", mysql_error()));
    if (!defined('MSD_MYSQL_VERSION')) {
        GetMySQLVersion();
    }
    if (!isset($config['mysql_standard_character_set']) || $config['mysql_standard_character_set'] == '') {
        get_sql_encodings();
    }
    if ($config['mysql_standard_character_set'] != $encoding) {
        $set_encoding = @mysql_query('SET NAMES \'' . $encoding . '\'', $config['dbconnection']);
        if ($set_encoding === false) {
            $config['mysql_can_change_encoding'] = false;
        } else {
            $config['mysql_can_change_encoding'] = true;
        }
    }
    if ($keycheck_off) {
        // only called with this param when restoring
        mysql_query('SET FOREIGN_KEY_CHECKS=0', $config['dbconnection']);
        // also set SQL-Mode NO_AUTO_VALUE_ON_ZERO for magento users
        mysql_query('SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"', $config['dbconnection']);
    }
    return $config['dbconnection'];
}
Ejemplo n.º 3
0
function MSD_mysql_connect()
{
    global $config, $databases;
    $port = isset($config['dbport']) && !empty($config['dbport']) ? ":" . $config['dbport'] : "";
    $socket = isset($config['dbsocket']) && !empty($config['dbsocket']) ? ":" . $config['dbsocket'] : "";
    $config['dbconnection'] = @mysql_connect($config['dbhost'] . $port . $socket, $config['dbuser'], $config['dbpass']) or die(SQLError("Datenbankverbindung", mysql_error()));
    if (!defined('MSD_MYSQL_VERSION')) {
        GetMySQLVersion();
    }
    return true;
}
/**
 * Creates the first statusline with information for backup files
 *
 * @return string
 */
function getStatusLine()
{
    // strcuture of status line:
    // -- Status:nrOfTables:nrOfRecords:Multipart:database:script:
    // scriptversion:comment:MySQL-Version:Backupflags(unused):SQLBefore:
    //SQLAfter:Charset:CharsetEXTINFO
    global $databases, $config, $dump;
    if (!defined('MSD_MYSQL_VERSION')) {
        GetMySQLVersion();
    }
    $tline = "-- \n-- TABLE-INFO\r\n";
    foreach ($dump['databases'][$dump['db_actual']]['tables'] as $tableName => $val) {
        $tline .= "-- TABLE|" . $tableName . '|' . $val['records'] . '|' . $val['data_length'] . '|' . $val['update_time'] . '|' . $val['engine'] . "\n";
    }
    $flags = 1;
    $mp = 'MP_0';
    if ($config['multi_part'] == 1) {
        $mp = "MP_" . ($dump['part'] - $dump['part_offset']);
    }
    $statusline = "-- Status:" . $dump['databases'][$dump['db_actual']]['table_count'] . ':' . $dump['databases'][$dump['db_actual']]['records_total'] . ":{$mp}:" . $dump['db_actual'] . ":PHP:" . MSD_VERSION . ":" . $dump['comment'] . ":";
    $statusline .= MSD_MYSQL_VERSION . ":{$flags}:::" . $dump['dump_encoding'] . ":EXTINFO\n" . $tline . "-- " . "EOF TABLE-INFO\n-- ";
    return $statusline;
}
Ejemplo n.º 5
0
/**
 * Receive all possible MySQL character sets and save standard to $config['mysql_standard_charset']
 */
function get_sql_encodings()
{
    global $config;
    unset($config['mysql_possible_character_sets']);
    if (!isset($config['dbconnection'])) {
        MSD_mysql_connect();
    }
    $erg = false;
    $config['mysql_standard_character_set'] = '';
    $config['mysql_possible_character_sets'] = array();
    if (!defined('MSD_MYSQL_VERSION')) {
        GetMySQLVersion();
    }
    $v = explode('.', MSD_MYSQL_VERSION);
    $config['mysql_can_change_encoding'] = false;
    if ($v[0] <= 4 && $v[1] < 1 || $v[0] <= 3) {
        // MySQL < 4.1
        $config['mysql_can_change_encoding'] = false;
        $sqlt = 'SHOW VARIABLES LIKE \'character_set%\'';
        $res = MSD_query($sqlt) or die(SQLError($sqlt, mysql_error()));
        if ($res) {
            while ($row = mysql_fetch_row($res)) {
                if ($row[0] == 'character_set') {
                    $config['mysql_standard_character_set'] = $row[1];
                    if ($v[0] == 3) {
                        $config['mysql_possible_character_sets'][0] = $row[1];
                    }
                }
                if ($row[0] == 'character_sets' && $v[0] > 3) {
                    $config['mysql_possible_character_sets'] = explode(' ', $row[1]);
                    sort($config['mysql_possible_character_sets']);
                }
            }
        }
    } else {
        // MySQL-Version >= 4.1
        $config['mysql_can_change_encoding'] = true;
        $sqlt = 'SHOW CHARACTER SET';
        $res = MSD_query($sqlt) or die(SQLError($sqlt, mysql_error()));
        if ($res) {
            while ($row = mysql_fetch_row($res)) {
                $config['mysql_possible_character_sets'][] = $row[0] . ' - ' . $row[1];
            }
            sort($config['mysql_possible_character_sets']);
        }
        $sqlt = 'SHOW VARIABLES LIKE \'character_set_connection\'';
        $res = MSD_query($sqlt) or die(SQLError($sqlt, mysql_error()));
        if ($res) {
            while ($row = mysql_fetch_row($res)) {
                $config['mysql_standard_character_set'] = $row[1];
            }
        }
    }
}
Ejemplo n.º 6
0
$lastBu = array();
if ($action == '') {
    $action = 'status';
}
include './inc/define_icons.php';
if (isset($_POST['htaccess']) || $action == 'schutz') {
    include './inc/home/protection_create.php';
} elseif ($action == 'edithtaccess') {
    include './inc/home/protection_edit.php';
} elseif ($action == 'deletehtaccess') {
    include './inc/home/protection_delete.php';
}
if ($action == 'status') {
    $htaExists = file_exists('./.htaccess');
    if (!defined('MSD_MYSQL_VERSION')) {
        GetMySQLVersion();
    }
    // find latest backup file
    $dh = opendir($config['paths']['backup']);
    while (false !== ($fileName = readdir($dh))) {
        if ($fileName != '.' && $fileName != '..' && !is_dir($config['paths']['backup'] . $fileName)) {
            $files[] = $fileName;
            $sumFiles++;
            $sumSize += filesize($config['paths']['backup'] . $fileName);
            $ft = filectime($config['paths']['backup'] . $fileName);
            if (!isset($lastBu[2]) || isset($lastBu[2]) && $ft > $lastBu[2]) {
                $lastBu[0] = $fileName;
                $lastBu[1] = date("d.m.Y H:i", $ft);
                $lastBu[2] = $ft;
            }
        }