Page 1 of 2
Image Manager - JQuery string incorrect?
Posted: Tue Apr 02, 2013 5:44 pm
by matthe81
Hallo!
I gets the same error when using the image manager that came with Opencart v1.5.5.1. When I trying to browse for a image I gets the admin-login page and underneath jquery output this htmlcode:
Something tells me that the jquery-string isn´t correct. So in the file: /admin/view/template/common/filemanager.tpl I took a look
at line 179
Code: Select all
$(element).find('img').replaceWith('<img src="' + html + '" alt="" title="" />');
And I was thinking maybe the jquery thinks that the string varible ends with the quote-symbol ("), so I changed this line to:
Code: Select all
$(element).find('img').replaceWith('<img src=\"' + html + '\" alt=\"\" title=\"\" />');
with backslashes and tell the jquery that the quote-symbol is olso part of the string varible.
Suddenly the Image Manager is working I can see the images listed and i can select and upload new files.
But only in the installation on my local computer, not in the istallation on my host provider - I still get the htmlcode output as the attachment below. Sins yesterday I have ben trying to delete cache and sessions-files with no luck...
Can someone tell me why its working on my local computer and not on my host privader?
I have olso changed to
\" for al the htmlcode from the jquery-outputs in this tpl-file with the same result... its working on my local machin and not on the host provider..
Thanks in advanced!
Re: Image Manager - JQuery string incorrect?
Posted: Wed Apr 03, 2013 11:50 am
by butte
Among other things, OC does not like magic quotes (in simple terms, they enter into how code escapes are handled), and requires that magic quotes be turned off in php.ini (if you can access it or can make a few specific settings including that one on the public server). In the htaccess.txt file you'll see the basic requirements, and can uncomment the one-liner workarounds (the file itself explains itself). You added escapes, and that is working on your own machine but apparently did nothing on the public machine. That raises the possibilities of changing php.ini or the .htaccess workarounds.
Re: Image Manager - JQuery string incorrect?
Posted: Wed Apr 03, 2013 4:42 pm
by matthe81
Thanks for your reply!
I checked the phpinfo at my host provider, it says:
Code: Select all
magic_quotes_gpc = Off
register_globals = Off
default_charset = no value
memory_limit = 256M
max_execution_time = 120
upload_max_filesize = 220M
safe_mode = Off
mysql.connect_timeout = 60
session.use_cookies = On
session.use_trans_sid = 0
session.gc_maxlifetime = 1440
allow_url_fopen = on
Here is the default settings of admin/php.ini
Code: Select all
magic_quotes_gpc = Off;
register_globals = Off;
default_charset = UTF-8;
memory_limit = 64M;
max_execution_time = 18000;
upload_max_filesize = 999M;
safe_mode = Off;
mysql.connect_timeout = 20;
session.use_cookies = On;
session.use_trans_sid = Off;
session.gc_maxlifetime = 12000000;
allow_url_fopen = on;
session.save_handler = files;
session.save_path = /PATH/TO/sessions;
Much of the server settings at the host provider is already the same as php.ini-file, no luck there

Re: Image Manager - JQuery string incorrect?
Posted: Wed Apr 03, 2013 7:20 pm
by matthe81
So there´s something with the .replaceWith and its ability to take arguments
Here is the orginal code of this function at filemanager.tpl at lines 169 to 184:
Code: Select all
$('#column-right').bind('scrollstop', function() {
$('#column-right a').each(function(index, element) {
var height = $('#column-right').height();
var offset = $(element).offset();
if ((offset.top > 0) && (offset.top < height) && $(element).find('img').attr('src') == '<?php echo $no_image; ?>') {
$.ajax({
url: 'index.php?route=common/filemanager/image&token=<?php echo $token; ?>&image=' + encodeURIComponent('data/' + $(element).find('input[name=\"image\"]').attr('value')),
dataType: 'html',
success: function(html) {
$(element).find('img').replaceWith(html);
/*$(element).find('img').replaceWith('<img src="' + html + '" alt="" title="" />');*/
}
});
}
});
});
Is it possible to rewrite so it wont need this .replaceWith? Any sugestions... I´m not so hitech when it comes to Jquery or javascript, please help.
If it not working and I decide to buy an extension of another image manager, will I might have the same experience and failure in the new one, anyone with experience - any recommendations?
I thinking of
(vQMod) Power Image Manager 1.5.x
Re: Image Manager - JQuery string incorrect?
Posted: Thu Apr 04, 2013 11:08 am
by butte
(1) I'm seeing a substantial difference there in upload_max_filesize. Be sure to use images that have been edited for the web (kb range, not mid to high mb range as nowadays will come out of cameras).
(2) Wait for someone who isn't tired at the moment to look v. carefully at the syntax.
Re: Image Manager - JQuery string incorrect?
Posted: Thu Apr 04, 2013 3:50 pm
by matthe81
In server config it says
But the thing is that I have not ben uploading som files with the manager, firstly I simply can´t because of the failure...
Secondly, I only using the demo-images that was already in place with the installation. I can´t even browse those demo-images...
Re: Image Manager - JQuery string incorrect?
Posted: Thu Apr 04, 2013 4:05 pm
by pprmkr
I looks like it's the same problem posted
here
Check if there are new sessions created for each call, then contact your hoster.
Re: Image Manager - JQuery string incorrect?
Posted: Fri Apr 05, 2013 10:16 am
by butte
It may be that within image/ for some reason the images uploaded into data/ aren't being made into thumbnails in cache/data/.
(1) If you are NOT forced to log back in:
You can pull down via ftp the image/ tree, and look at the contents as photographic icons. (In XP up, icons are photographic, numerous enough to fill the screen at once before scrolling for more, without having to pace them through the viewer). You'd be looking for original images uploaded into place (in image/data/), and for derivative thumbnail images made by OC (in image/cache/data/).
You can try a flush from within phpMyAdmin. You should not need to do that particularly often. Server support can do the flush if you aren't permitted to do it.
(2) If you ARE forced to log back in:
In that other thread, cookie sessions are noted as suspects. That is responded to at
http://forum.opencart.com/viewtopic.php ... 23#p395623
but the idea is to slow down, let the admin panel do one thing at a time, lest it not Save properly or force you to log back in. It needs a moment to save an original image, and it needs a moment to make a thumbnail; let it.
Re: Image Manager - JQuery string incorrect?
Posted: Fri Apr 05, 2013 6:46 pm
by matthe81
I've got got the answer back from my host provider... They say that is no limitation for sessions on the server.
When I are logged in and open the image Manager I see that is generating about 4 or 5 sessions files that is relateted at the specific date and timestamp... (maybe 1 when I is logging in to the system).
Could it be something with de session-folder, according to my host providers guide when installing Opencart its need a session folder placed outside the public_html folder. In php.in it is set to:
Code: Select all
session.save_handler = files;
session.save_path = /PATH/TO/sessions;
The directory is like:
Code: Select all
/mydomain.com/public_html/demo/opencart/
/mydomain.com/sessions/
I pulled down the image-folder to local compter and looked at the icons and I see the objects, its apearing right away (don´t know how fast it should apear, but I see them) and it generated in different sizes.
I have access to phpmyadmin but I dont know what exacly to do to make a flush, please can you guide me thrue the steps and which tables. Maybe I dont have that authority to do that so I may need to ask the support...
Re: Image Manager - JQuery string incorrect?
Posted: Sat Apr 06, 2013 3:54 am
by butte
(1) Quickfixes.
(a) You can ask server support to "Flush" for you if you cannot find a button for that.
(b) You can send the image files into place via ftp (or if necessary via WinSCP or the like), into image/data (where you can also set up subdirectories for keeping track of types of stuff). You do not have to use the OC image manager to put the original files onto the server. When OC needs thumbnails it will generate them, you do NOT have to be logged in as administrator while it does that.
(c) You might prefer to go with (b) while the image manager (if not something else in the shadows riding alongside it) seems to be doing something unintended.
(2) More.
As an example among reasons why the number of sessions should be (relatively) unlimited, if you have 20 customers browsing at once, they'll all need their own cookies, and OC will need to issue those.
The session/ directory sits outside the public area for security. The server reads and writes there, with its own permissions as the ultimate boss, the customer's client browsers just read what the server sends and write to each customer's or your machines.
Having several concurrent sessions for you while you're merely trying to get image files into place seems highly unusual. Perhaps something is needlessly inserted or set to generate cookies.
Under phpMyAdmin, appearances vary among control panel programs and their versions, as well as among servers where those are installed. You'll find under phpMyAdmin a handful of ways to reset or flush. Under databases (or wherever it was put), pick phpMyAdmin. Then under "Settings" or under "More" or under another tab you can find "Reset" and press it. If you choose a particular database, then among the tabs may be (but is not necessarily available) "Operations" among which may be "Reset" or "Flush" option(s).
Re: Image Manager - JQuery string incorrect?
Posted: Sat Apr 06, 2013 10:36 pm
by matthe81
I have asked the support to do flush... so we will see whats happens...
Meanwhile I did some research on the mysql and cache issue. Basicly the share hosting servers often configurate it so it speeds up the connectionproccess and do the response time more quicker, and ofcourse prevent server been overloaded. Basicly what I understands it works like this, A mysqluser sends a request from his application to database and gets his rightful result because its the first query fetched right from the database, not from the cache. When it have sent the result it stores it in the cache, then another mysqluser makes the same type of request and the database engine think its already know the answar and fetches this query and result from cache instead, but the other users request and result mismatch with that stored in cache.
You can ask yourself if the Image Manager is the only thing thats using cache, its only effecting this manager not the rest of the system?
Thats why I asked about other extension earlier in this thread on how it might react, if it might have the same issue or perform better...
About your statement (1b) butte, I could do that way if I was alone and setting up my own system but I do it for the company and we found Opencart to be quite easy and filling the purpose, other people should maintain this website quickly in a easy way, not only me (using it for more like a catalog rather then a store). We have already paid for a nice template that we liked very much and also plan to buy some extensions as well.
Further more I asked my self why the mysql don´t use the cache on individual basis...? I mean if a mysqluser comes from a certain website and do multiple requests at the same type, well it could fetch from the cache, otherwise fetch from the database (not cache) if it is another mysqluser... In that case each user could then maintain their own flush if necessary and its not effecting all other users and databases on that server...
Re: Image Manager - JQuery string incorrect?
Posted: Sun Apr 07, 2013 5:13 am
by butte
While we're awaiting the flush outcome . . .
Yes, you've got the gist. Some servers allow you to do some basic manipulations yourself, others are host-wide and you can't set them, and often support is unaware what to do even when a stray OC user has actually looked at stats and requested resets, for himself and other OC users host-wide. All of that can be frustrating.
For the moment the notions at (1)(b) may be helpful between the local and public OC installations. Of course, among reasons for the image manager is providing a way for "just plain folks" to upload files without having to understand what the two machines are doing to accomplish it.
Re: Image Manager - JQuery string incorrect?
Posted: Mon Apr 08, 2013 12:25 am
by matthe81
Just wondering...
Some time to time I get no template showing either, I believe its due to cache as well because the database stores which template that is used.
Now I looking for the SQL-gueries for the Image Manager but I cant find it, Can someone tell me exacly where to find it? I dont know if anyone have tested it before but I found this article:
http://dev.mysql.com/doc/refman/5.5/en/ ... elect.html
Is it worth trying to add those SELECT-queries with "SQL_NO_CACHE"-arguments and see if its working?
Re: Image Manager - JQuery string incorrect?
Posted: Mon Apr 08, 2013 7:16 am
by butte
Intermittent loss of template(s) isn't much of a good thing, notwithstanding that the database does know about template(s). Find the similarly named appropriate files in every directory branch. Yes, it's worth a try, just first back up whatever you edit.
Re: Image Manager - JQuery string incorrect?
Posted: Mon Apr 08, 2013 3:34 pm
by matthe81
I no longer think that the Image Manager itself use any database and therefore not any SQL-queries to make any request to the mysql-server, I just dont find anything in "/admin/controller/common/filemanager.php". I think its only list those image-files on directory level. The whole application its all written in javascript and jquery, look at "/admin/view/javascript/jquery/".
Please correct me if I'm totally wrong, but is it realy the Mysql-server that cause this issue with Image Manager?
When its do a request to the database it is when its listing those images that you have saved in the product-page (image-tab) or doing an insert new images to the page and click save...
Re: Image Manager - JQuery string incorrect?
Posted: Tue Apr 09, 2013 3:50 am
by butte
If you use admin panel's Settings / Backup to grab a *.sql and open it with a text editor, then "find" ".jpg" or ".png" (whichever or both, as may apply in your case), you'll find that on certain rows, for categories as well as for products, the (categories' and products' respective) images are listed in their own field(s). Yes, the database is aware of them. No, the database is not necessarily the cause of your present problem.
Re: Image Manager - JQuery string incorrect?
Posted: Wed Apr 10, 2013 7:33 am
by zookie
I got the same problem on the same isp.
Any News?
Re: Image Manager - JQuery string incorrect?
Posted: Thu Apr 11, 2013 6:42 pm
by roald92
Same problem here..
Re: Image Manager - JQuery string incorrect?
Posted: Sat Apr 13, 2013 11:12 am
by butte
It's possible that a basic php setting needs to be changed, whether within your own control panels on the host(s) if you can reach php.ini, or via support as to the master php.ini (which you will be unable to reach with shared hosting). It could also appear in certain other server configuration files which you would not be able to reach.
An error message that CAN appear reads, essentially: "You are using PHP's deprecated 'mysql' extension, which is not capable of handling multi queries. The execution of some stored routines may fail! Please use the improved 'mysqli' extension to avoid any problems."
The specific change needed is "mysql" to "mysqli". It will relate, in pertinent part, to versions of php and of mysql running on the server, if the error arises.
Re: Image Manager - JQuery string incorrect?
Posted: Fri May 24, 2013 4:11 pm
by Chrizze
I've found a solution! Server caching was acting up.
Read it here:
http://forum.opencart.com/viewtopic.php ... 18#p408718