OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



can't upload new css

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

can't upload new css

Postby gabriela » Thu May 04, 2006 8:04 am

Hello,

After upgrading to 2.1.0.1 I can't upload a new css file.
I get the error: "Invalid journal stylesheet format. Accepted format is .css" every time I try to upload a new css file, and it is css as far as I can tell. I tried uploading the original common.css and I got the same error.
Any help is very much appreciated.

Thank you in advance,
Gabriela
gabriela
 
Posts: 18
Joined: Mon Mar 28, 2005 2:53 pm

Postby asmecher » Thu May 04, 2006 12:52 pm

Hi Gabriela,

OJS checks to ensure that stylesheet files are actually CSS as follows:
  • If the php mime_content_type function is available, it is used to fetch the file type.
  • If not, the local "file" tool is executed on the server as follows:
    Code: Select all
    file -bi [filename]
  • The resulting file type must be either text/plain or text/css; otherwise the stylesheet upload fails as you describe.
Often PHP's mime_magic module is not properly configured; see http://ca3.php.net/manual/en/function.mime-content-type.php for information on this.

Alternately, this error could indicate a file permissions problem. Check to make sure that the journal's public files directory (generally public/[journal Id]) is writable by the web server.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Postby gabriela » Fri May 05, 2006 12:14 pm

Hi Alec,

Thank you for you prompt reply, as always, and your useful advice.
I believe the problem is that the mime_magic module is not properly configured. I will be working on this with our system admin, and let you know how it goes.

Best Regards,
Gabriela
gabriela
 
Posts: 18
Joined: Mon Mar 28, 2005 2:53 pm

Postby gabriela » Fri May 05, 2006 2:09 pm

Hello,

After properly configuring the mime_magic module, uploading ccs files worked with no problem.

Thanks,
Gabriela
gabriela
 
Posts: 18
Joined: Mon Mar 28, 2005 2:53 pm

Postby shubhash » Tue Jul 18, 2006 11:22 am

I find this check quite annoying. The stylesheet files seem to be almost always detected as C program files (text/x-c), so stylesheet upload always fails. I can't really see a reliable way of detecting text/css; thus I don't want to mess with the magic.mime file. So I temporarily allowed upload of file types text/x-c by changing the code and I am not really happy about having to do that. Does anyone know of a reliable way of detecting css files?
shubhash
 
Posts: 39
Joined: Tue Feb 28, 2006 10:13 am

Postby asmecher » Tue Jul 18, 2006 12:30 pm

Hi Shubhash,

Agreed, this is an annoying limitation. Unfortunately it's a limitation of PHP's mime_content_type function, which in turn relies on the standard Unix "file" utility. You may be able to improve the precision of the tests in the magic.mime database, but be warned that I've encountered version conflicts between the distributed file utility and PHP's built-in equivalent.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Postby shubhash » Tue Jul 18, 2006 12:56 pm

If the server does not detect the file as a css file (text/css or text/plain), currently there is no way to upload the stylesheets. Because of potential side effects like the version conflict you mentioned, I would rather not play around with the system mime types. So the only remaining option is to change the ojs code. So I changed the line

Code: Select all
if ($type != 'text/plain' && $type != 'text/css') {
to
Code: Select all
if ($type != 'text/plain' && $type != 'text/css' && $type != 'text/x-c') {


Could a similar fix be applied to OJS distribution so that it would work out of the box? I know that the detection would now be less precise but at least it would not be "broken" any more. Alternately, only matching the "text/" part should work too.
shubhash
 
Posts: 39
Joined: Tue Feb 28, 2006 10:13 am

Postby asmecher » Tue Jul 18, 2006 2:01 pm

Hi Shubhash,

I'll take this into consideration. In my opinion, if the server is identifying CSS as C code using the standard toolsets, the server is mis-configured; I don't know if the text/x-c work-around applies to any situations outside your own. It might be worth relaxing the constraint to add text/plain to the list. In the meantime, if this work-around is correcting the problem for you, go ahead with it -- in future releases, even if we don't incorporate a change like this, using the patch upgrade method will prevent having to re-apply this modification.

Note that only matching the text/ prefix may be a security hole. It's possible, for example, that a user could upload a shell script that the server identifies as text/x-csh. Some web servers use mime types to determine how to handle files, which could result in the script being executed.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Postby tello » Sun Jul 23, 2006 2:25 am

Hi Alec,


We also have such kind of problem. In our system we are not using a local host, we hired a remote server so we can not make any changes in php.ini . Also I am sure that our problem is also because of magic.mime properties. In my own computer I am trying something and then I apply the same thing to remote one and I reliazed that when I changed the magic.mime properties I solved problem in local. But in remote it continues.

My question is : Is there any manual way to put this .css file. I mean I thought that (sorry maybe I am wrong) I can put this .css file to server via ftp and make any changes in the database is it possible?

shubhash wrote;

Code:
if ($type != 'text/plain' && $type != 'text/css') {
to
Code:
if ($type != 'text/plain' && $type != 'text/css' && $type != 'text/x-c') {


I also read this solution but because I am not very good at programming I do not want mix with codes. If this can solve my problem where should I put this code??

Thank you very much, tello.
tello
 
Posts: 8
Joined: Sun Apr 23, 2006 2:16 pm
Location: Turkey,METU

Postby asmecher » Sun Jul 23, 2006 6:47 pm

Hi tello,

It's probably easiest to change the OJS code and then upload the CSS as usual. You can make the code change above in the files classes/issue/form/IssueForm.inc.php, and classes/manager/form/setup/JournalSetupStep5Form.inc.php. The line in question should appear once in each file. If you make a mistake when changing the code, you'll probably get an error message -- but you won't destroy anything.

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Postby tello » Mon Jul 24, 2006 12:37 am

I will try this solution immediately. Thank you very much Alec.
tello
 
Posts: 8
Joined: Sun Apr 23, 2006 2:16 pm
Location: Turkey,METU

Postby tello » Mon Jul 24, 2006 7:50 am

Thanks Alec,

I have changed the code in the files and I solved my problem.My new css is working well on both local and remote server. Thank you very much. I learned lots of things from you in very short time. :)

tello.
tello
 
Posts: 8
Joined: Sun Apr 23, 2006 2:16 pm
Location: Turkey,METU

Re: can't upload new css

Postby lwang » Tue Jun 14, 2011 1:53 pm

Hi Alec,

We are on 2.3.4. I have come across the same css file load problem. I modified the code to
if ($type != 'text/plain' && $type != 'text/css' && $type != 'text/x-c') {

in the two files you mentioned here, classes/issue/form/IssueForm.inc.php, and classes/manager/form/setup/JournalSetupStep5Form.inc.php.
But still get the error message:
Invalid journal stylesheet format. Accepted format is .css.

Can you help?

Thanks!

Ling
lwang
 
Posts: 45
Joined: Mon Jan 12, 2009 1:03 pm

Re: can't upload new css

Postby inesgj » Thu Nov 22, 2012 7:22 am

Hello,
I have the same problem in setup step 5:

Errors occurred processing this form:

Invalid journal stylesheet format. Accepted format is .css.

I am using OJS 2.3.7 and have modified ojs code as Alec explained (in both files in "classes" folder), but still doesn't work.

Thank you for your help
Inés
inesgj
 
Posts: 6
Joined: Tue Aug 28, 2012 9:38 am

Re: can't upload new css

Postby asmecher » Thu Nov 22, 2012 9:29 am

asmecher
 
Posts: 8910
Joined: Wed Aug 10, 2005 12:56 pm

Next

Return to OJS Technical Support

Who is online

Users browsing this forum: Google [Bot] and 9 guests