Exemplo n.º 1
0
function put_sql($import_handle)
{
    global $db_link, $import_handle, $sql, $allow_compression, $temporary_dir, $errors, $delete_tmpfile_after_post;
    $dump = new cMySQLBackUp($temporary_dir, '', $allow_compression);
    $f_name = tempnam($temporary_dir, 'm1bridge_');
    if (!$f_name) {
        generate_error($errors['create_tmp_file']);
    }
    $import_handle = fopen($f_name, "w+");
    $ind = $import_handle;
    if (!$ind) {
        generate_error($errors['open_tmp_file']);
    }
    if ($ind) {
        $ind = (bool) fputs($import_handle, $sql);
        $ind &= fclose($import_handle);
    }
    $import_handle = fopen($f_name, "r");
    if (!$import_handle) {
        generate_error($errors['open_tmp_file']);
    }
    if (!$ind) {
        generate_error($errors['put_tmp_file']);
    }
    $content = running($import_handle);
    if (strlen($content) > 0) {
        echo $content;
    } else {
        echo "0\r\n";
    }
    fclose($import_handle);
    if ($delete_tmpfile_after_post) {
        @unlink($f_name);
        $dump->_clearAll("m1bridge_");
        $dump->_clearAll("m1bridgetmp_");
        $dump->_exit();
    } else {
        @chmod($f_name, 0777);
    }
}