Results 1 to 10 of 13

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    14
    Plugin Contributions
    0

    Default Re: Updating Language constants dynamically

    Hi, thanks for the reply.

    I thought that I would prob have to write custom code, but it is this I need guidance with.


    I intend to put in place a validation using javascript to make sure that any possible wrong characters cant be used and also I ill be advising the users of this.

    I dont want to give them access to the actual files via ftp and I also think that they would edit the wrong files or upload them in the wrong places etc.

    I know how to open and write to a file but what I am unsure of is how to search through the file for each define statement and return these, and change the appropriate ones where necessary.

    As i said before,
    If you can help at all by even telling me which functions php has which may make this possible I should be able to work out the rest hopefully.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Updating Language constants dynamically

    file() will read in the contents of a file, line by line
    file_get_contents() will read in the entire file
    fopen(), fput(), fclose() will open, write, and close files, respectively
    Parsing will likely need to be done via regular expressions ... ereg(), etc

    The secondary problem you'll have with this is security. In order to be able to write back to the files, they need to be world-writable, which leaves them open as prime targets for hackers.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jul 2007
    Posts
    14
    Plugin Contributions
    0

    Default Re: Updating Language constants dynamically

    Thanks for you help.

    Good point on security.

    I was looking through the php for the admin pages for the shop configuration, and they seem to be set up to modify the database directly.

    Do you know if the values are usually taken from the database first and then placed into the files or are they never 'syncronised' and if not which values are taken as being the 'main' ones the database or the language files?

    I think an alternative may then be to set up the new defines to be canged to be changed in the database directly, and should I require to add custom defines then I can just add rows to the database tables where necessary / create a new custom table.

    what are your thoughts on this?

  4. #4
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: Updating Language constants dynamically

    As far as I remember, constants set in configuration table are available anywhere, so you should check on that (Dr Byte would know the exact answer for this). You can have all the constants stored in db, then load and define them before anything else.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  5. #5
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Updating Language constants dynamically

    Since you're going to need to rewrite file contents, start with the define-pages-editor as a base. The configuration tool is not a good model for reading the entire file.
    Enhance its file-reading facility by adding line-parsing to identify each define statement.
    Build input fields on the screen for each one
    Collect all the info.
    Validate the info, and write the defines back to the file.

    If you want to rewrite the language infrastructure to use the database instead, keep in mind the need to support multiple languages and also to handle code upgrades. You'll still need to create a user interface to present and collect the information, then validate it and save it.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6
    Join Date
    Jul 2007
    Posts
    14
    Plugin Contributions
    0

    Default Re: Updating Language constants dynamically

    DrByte, I just want to clarify to make sure I understand correctly.

    I should take a copy of the define-pages-editor page and alter this as a starting point and
    Then ammend it so that when it reads through the files it parses any instances of the define calls using parse function.
    For each instance of define() I should create an input field (to allow the editing)

    When submit, collect any changes and validate them (ie so no php errors etc caused) and then re-write the file the define statement came from?

    Is this what you are saying or have I missed the point somewhere?

    Thanks for you responses and help!

  7. #7
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Updating Language constants dynamically

    Assuming you intend to proceed with editing language files and plan to deal with security concerns separately, then yes.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Jul 2007
    Posts
    14
    Plugin Contributions
    0

    Default Re: Updating Language constants dynamically

    If I want to do this without affecting security, is there a method of achieving this?

    Can you clarify the difference between the language files and the database configuration table, in terms of which one over-rides the other? If I changed the values in the database - are they reflected through the site or are they over-ridden by the language files?

    Thanks

  9. #9
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Updating Language constants dynamically

    Quote Originally Posted by coldasice1234 View Post
    If I want to do this without affecting security, is there a method of achieving this?
    Yes -- use the database alternative we've been discussing:

    Quote Originally Posted by coldasice1234 View Post
    I think an alternative may then be to set up the new defines to be canged to be changed in the database directly, and should I require to add custom defines then I can just add rows to the database tables where necessary / create a new custom table.
    Quote Originally Posted by DrByte View Post
    If you want to rewrite the language infrastructure to use the database instead, keep in mind the need to support multiple languages and also to handle code upgrades. You'll still need to create a user interface to present and collect the information, then validate it and save it.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Updating Language constants dynamically

    Quote Originally Posted by coldasice1234 View Post
    Do you know if the values are usually taken from the database first and then placed into the files or are they never 'syncronised' and if not which values are taken as being the 'main' ones the database or the language files?
    It all depends how you write your custom code.

    A constant is ... well ... constant. It never changes once defined. So, whatever you set it to be, it will be. You can't change it later without loading a new page.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v152 Forcing a script to use constants from a specific language
    By torvista in forum Addon Language Packs
    Replies: 3
    Last Post: 17 Jan 2014, 12:16 AM
  2. List constants from a specific language file?
    By torvista in forum General Questions
    Replies: 3
    Last Post: 8 Jul 2011, 08:15 PM
  3. Constants coming up instead of text assigned to constants
    By blk00xjc in forum General Questions
    Replies: 3
    Last Post: 25 Mar 2009, 10:11 PM
  4. Just finished updating Hebrew language pack
    By murlex in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 16 Jan 2009, 12:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg