Virtuemart Media files lose all meta information when downloading - virtuemart

My media files lose all meta information when downloading. I have a website with downloadable, virtual products. It affects here Android app files, apk's.
If I want to download and install the files, I get the following error.
There was a problem parsing the package.
The Download package (apk) has not include version number, file size, package name. It shows only N/A .
Scenario:
I have downloaded apk file directly via ftp from the vmfiles file folder.
Metadata available - installation ok.
Download Website - File does not include version number, file size, package name. Installation fails with the above message.
I work with:
VirtueMart 3.2.15 Blue Corvus 9877
Joomla 3.8.7
OpenTools Virtuemart Download for sale plugin
I switched the database to utf8mb4 because I need symbols in text and description. Since then, the downloaded products are probably not usable, I think.
I modified the varchar fields, varchar (191), or changed them to text. I just do not know why, how and where the package information is lost.
Here is another phpmyadmin mysql query of variables / collation:
SHOW VARIABLES LIKE 'char%'
--------------------
Web server productive:
-------------------------------------
variable_name value
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8mb4
character_set_server utf8
character_set_system utf8
character_sets_dir / usr / share / mysql / charsets /
----------
Local Host:
-------------------------------------
Variable_name Value
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8mb4
character_set_server utf8mb4
character_set_system utf8
character_sets_dir C: \ xampp \ mysql \ share \ charsets \
I had already purchased the software from OpenTools in February 2016. The Software is not more supported. Maybe I can reach someone in the forum or by email. As I said, the uploaded files on the server are still fine. And the download software reads the file stream via readfile_chunked byte by byte for the download link.
Maybe some base64 or something has to be encoded here? Or is the error somewhere else?
Android Studio says when opening the downloaded .apk file:
Unknown chunk type: 835
java.lang.NullPointerException: Unknown chunk type: 835
Virtuemart works with utf8, mysql supports Multi (utf8 + utf8mb4). My system is set up with utf8mb_unicode_ci.
Should I switch to connection encoding utf8mb4_bin? Does Virtuemart realize that? I will definitely try it now.
I found another code snippet regarding mysql_encoding:
utf8mb4 is missing here:
switch($mysql_encoding[0])
{
case "utf8":
return "utf-8";
break;
case "latin1":
return "iso-8859-1";
break;
default:
return $mysql_encoding[0];
}
Should such a thing be taken into the Virtuemart model with me? Somewhere I have read something from Java Binary Variables specifically for utf8mb4 call handling. That you have to set up this extra. Also, attaching '? UseUnicode = true & characterEncoding = UTF-8' to the JDBC URL download link did not help.

A coding God in another forum could help me further and found the solution :-)
In the used readfile_chunked querier, whether the output buffer is deleted
here. The solution was to put ob_clean () before the while loop.
function readfile_chunked($filename, $retbytes=true)
{
$ chunksize = 1 * (1024 * 1024); // how many bytes by chunk
$ buffer = '';
$ cnt = 0;
                
$ handle = fopen ($ filename, 'rb');
if ($ handle === false)
{
return false;
}
ob_clean ();
while (! feof ($ handle))
{
$ buffer = fread ($ handle, $ chunksize);
echo $ buffer;
ob_flush ();
flush ();
                       
if ($ retbytes)
{
$ cnt + = strlen ($ buffer);
}
}                
$ status = fclose ($ handle);
if ($ retbytes && $ status)
{
return $ cnt; // return num. bytes delivered like readfile () does.
}                
return $ status;
}

Related

.NET Core 2 + System.Data.OracleClient. Chinese characters doesn't work

I'm using .NET Core 2 with the System.Data.OracleClient package published some weeks ago here: https://www.nuget.org/packages/System.Data.OracleClient/
I can read numbers, dates and normal English characters. But not Chinese. Probably a lot of other non-western characters.
Here's a sample program to illustrate the error:
using System;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Data.OracleClient;
namespace OracleConnector
{
class Program
{
static void Main()
{
TestString();
return;
}
private static void TestString()
{
string connStr = "Data Source = XE; User ID = testuser; Password = secret";
using (OracleConnection conn = new OracleConnection(connStr))
{
conn.Open();
var cmd = conn.CreateCommand();
cmd.CommandText = "select 'some text in English language' as a, '储物组合带门/抽屉, 白色 卡维肯, 因维肯 白蜡木贴面' as b from dual";
var reader = cmd.ExecuteReader();
reader.Read();
string sEnglish = reader.GetString(0);
string sChinese = reader.GetString(1);
Trace.WriteLine("English from db: " + sEnglish);
Trace.WriteLine("Chinese from db: " + sChinese);
Trace.WriteLine("Chinese from the code: 储物组合带门 / 抽屉, 白色 卡维肯, 因维肯 白蜡木贴面");
}
}
}
}
It outputs this:
English from db: some text in English languageဂ
Chinese from db: ¿¿¿¿¿¿/¿¿, ¿¿ ¿¿¿, ¿¿¿ ¿¿¿¿¿e
Chinese from the code: 储物组合带门 / 抽屉, 白色 卡维肯, 因维肯 白蜡木贴面
As you can see, Chinese characters from normal code works. But not when it comes from the database. Also, the last character in the English text is some messed up thing. I've also tried the corresponding Mono nuget package with the same result.
Anyone have any clue how to fix this?
Edit: Tried adding Unicode=True to the connection string but Chinese characters still doesn't work.
This is a problem with the System.Data.OracleClient DLL. I am having the same problem where 2, 3, or even 4-byte Unicode characters are getting tacked to the end of my strings.
Switching to Mono.Data.OracleClientCore helped slightly, but I still got some odd characters at the end of some strings (Unicode backspace and backslash).
I just tried the following library, and it seems to work for my needs (so far):
https://github.com/ericmend/oracleClientCore-2.0
You will need to re-compile for Windows (change to #define OCI_WINDOWS in OciCalls.cs). Will update this answer if I find that it doesn't continue to work.
Still, I think that we'll have to wait for Oracle to release their .NET Core supported solution for any sort of production ready library.
Please try
Environment.SetEnvironmentVariable ("NLS_LANG",".UTF8");
before creation of the connection-Object.
The System.Data.OracleClient-Implementations uses external Oracle libraries, which assumes (at least on Windows) the ANSI-Charset.
Setting the NLS_LANG-Environmentvariable informs the Oracle-Libs that you want the UTF8-Encoding.
(much) more Details on the NLS_LANG-FAQ-Page:
http://www.oracle.com/technetwork/database/database-technologies/globalization/nls-lang-099431.html
Append ";Unicode=True" to connectionstring and add Environment.SetEnvironmentVariable ("NLS_LANG",".UTF8"); before create connection
string conn = "DATA SOURCE=hostname.company.org:1521/servicename.company.org;PASSWORD=XYZ;USER ID=ABC;Unicode=True"
Environment.SetEnvironmentVariable("NLS_LANG", ".UTF8");
using (DbConnection conn = create_connection(app_conn))
{
//...
}

Transition from cipher 2.0 to 3.0 fails. Error 26 on attempt to read

I've used sqlcipher for 2 years. Yesterday I've upgraded to version 3.0.1 and tried to compile sqlcipher including arm64.
If I install new version of my app I can use new cipher lib without any problems.
But when I try to upgrade my previous version with DB made with sqlcipher 2.0 I get error 26.
It seems that new cipher can't decrypt my DB.
Also I tried to compile without arm64 support. The same problem.
I've solved my problem by using
PRAGMA cipher_migrate
which help to migrate from older DB structures to sqlcipher 3.0 (Details).
It must be executed right after setting the key.
If you want to read old DB (1.X/2.X) with new sqlcipher 3.0 use
PRAGMA kdf_iter = 4000
to set old value for kdf_iter. Now it equals 64,000 (Details)
In terms of lib sqlite db connection looks as follows:
int errorCode = SQLITE_ERROR;
sqlite3 *database = NULL;
errorCode = sqlite3_open_v2(path, &database, SQLITE_OPEN_READWRITE, NULL);
if (errorCode == SQLITE_OK) {
errorCode = sqlite3_key(database, key, (int)strlen(key));
}
if (errorCode == SQLITE_OK) {
errorCode = sqlite3_exec(database, "PRAGMA kdf_iter = 4000", NULL, NULL, NULL);
}

open a .mdb database with a visual studio 6 program

I try openning a .mdb file using CDaoDatabase, but at Open() catches an error: Unrecognised database format. I created the database first in MSAcces2007 and saved the file as .mdb, then i installed MSAcces2003 and created the file again, but there's the same error. Does anyone have a clue what's happening?
CString pathDB = "SMACDB\\Transports.mdb";
CDaoDatabase dbTransp;
try
{
dbTransp.Open(pathDB);
CDaoRecordset rs(&dbTransp);
COleVariant var1;
rs.Open(dbOpenSnapshot, "SELECT * FROM Transporturi");
while (!rs.IsEOF())
{
var1 = rs.GetFieldValue(1);
CString val = (LPCTSTR)var1.bstrVal;
g_carRestrict.pCarNmb.AddTail(val);
var1 = rs.GetFieldValue(2);
g_carRestrict.pAllowed.AddTail(var1.lVal);
rs.MoveNext();
}
rs.Close();
dbTransp.Close();
}
catch (CDaoException *pEx)
{
pEx->Delete();
}
Visual C++ 6 uses DAO 3.5 by default which does not support Access 2000 or later formats. To have MFC uses DAO 3.6, change the runtime version number to 6.01.
Suggested reading:
You receive an "Unrecognized database format" error message when you open a database created with Access 2000

Error while uploading image to database

When I am trying to upload an Image using below code, I am getting following error : java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested
File image = new File("D:/"+fileName);
preparedStatement = connection.prepareStatement(query);
preparedStatement.setString(1,"Ayush");
fis = new FileInputStream(image);
preparedStatement.setBinaryStream(2, (InputStream)fis, (int)(image.length()));
int s = preparedStatement.executeUpdate();
if(s>0) {
System.out.println("Uploaded successfully !");
flag = true;
}
else {
System.out.println("unsucessfull to upload image.");
flag = false;
}
Please help me out.
DB Script :
CREATE TABLE ESTMT_SAVE_IMAGE
(
NAME VARCHAR2(50),
IMAGE BLOB
)
Its first cause is incompatible conversion but after seeing your DB script, I assume that you are not doing any conversion in your script.
There are other reported causes of the ORA-01460 as well:
Incompatible character sets can cause an ORA-01460
Using SQL Developer, attempting to pass a string to a bind variable value in excess of 4000 bytes can result in an ORA-01460
With ODP, users moving from the 10.2 client and 10.2 ODP to the 11.1 client and 11.1.0.6.10 ODP reported an ORA-01460 error. This was a bug that should be fixed by patching ODP to the most recent version.
Please see this

Problems with CodeIgniter and setting characters

I use CodeIgniter and MySQL. I am getting the following message:
Can't initialize character set iso 8859-15 (path: /usr/share/mysql/charsets/)
I use a hosted server and have no access to the usr directory. This is the function in the CI mysql_driver class regarding charset:
function db_set_charset($charset, $collation) {
if (!isset($this->use_set_names)) {
// mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
$this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
}
if ($this->use_set_names === TRUE) {
return #mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
} else {
return #mysql_set_charset($charset, $this->conn_id);
}
}
The CI Config has the UTF-8 setting:
$config['charset'] = 'utf-8';
My Notepad++ is set to UTF-8 respectively ANSI. How can I change the global MySQL setting to UTF-8? Do I have to add a config.php in my web server settings with MySQL character settings? Like character_set_database="utf-8".
Why does the notice with iso-8859 appear? For me, iso-8859 is good, because it can show German special chars, UTF cannot.
I have the solution: CI is set to the following in the conig.php
$config['charset'] = 'utf-8';
When I use utf8_encode before print, I hardcode the char setting to UTF 8 and it works. If I do not use the function, it will show wrong characters. I do not understand why I have to use the function because the config setting has UTF-8.
I tried to print $config['charset'] to verify, but no output.
Timo

Resources