♥raiwa Posted May 4, 2020 Share Posted May 4, 2020 When using the language file editor in Admin : Tools : Define Languages duplicated CR's are introduced in the file. This looks when edited in Notepad++ like this: Tested with Phoenix 1.0.5.0 UNIX server and edited under Windows with Firefox.. This is probably an old problem which existed through all previous versions. As I do not use the built in editor I didn't realize the problem berfore. Has this been discussed before. Is there any possibility to address this. The original core file looks like this: About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥ecartz Posted May 5, 2020 Share Posted May 5, 2020 I wasn't able to duplicate this in 1.0.5.10 on a Linux server editing with Firefox on Windows. It would convert from Unix to DOS line endings but it didn't go the next step to duplicating the carriage returns even when I edited the file repeatedly. So I think there's more to this than you've diagnosed so far. Have you tried different versions of PHP/Apache? Always back up before making changes. Link to comment Share on other sites More sharing options...
♥raiwa Posted May 5, 2020 Author Share Posted May 5, 2020 Thanks Matt, I checked with 2 more servers and different PHP and Phoneix versions and get everywhere the same result. Sure you checked the file in Notepad++ or similar after editing in admin/define language.php? Server 1 (where the problem was discovered) Apache 2.4.43 PHP 7.3.17 (Zend 3.3.17) Tested with UNIX, Windows and Mac endlines in original file. All same result => duplicated CR’s Also tested with Phoenix 1.0.5.9/10 admin/define_language.php => same result Server 2: Server OS Linux 3.10.0-862.3.2.el7.x86_64 Apache (unknown) PHP 7.1.33 (Zend 3.1.0) Phoenix 1.0.5.1 => Same problem Same Server with Pre Frozen EDGE version => same problem Server 3 HTTP Server: Apache/2.4.43 PHP Version: 7.2.30 (Zend: 3.2.0) Phoenix v1.0.2.5 => Same Problem About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥ecartz Posted May 5, 2020 Share Posted May 5, 2020 24 minutes ago, raiwa said: Sure you checked the file in Notepad++ or similar after editing in admin/define language.php? I checked it with vim -b and xxd which showed me one CR per LF. But as described, I shouldn't have had to do so to get the result that you did. Because it should have showed me extra blank lines. So even without any further checking, it should have been visible. I checked on Apache/2.4.29 (Ubuntu) PHP 7.2.30, which seems similar enough to yours that it should have shown. Have you tried it in a different browser or in safe mode (without extensions) Firefox? Or from a different computer? How do you get the file to Notepad++? Does it load the file for you? I wonder if you have it set in such a way that it tries to convert the file from Unix to Windows line endings, even if the file is already in Windows format. You might try it on the Unix command line with something like xxd, which shows me Quote 00000000: 3c3f 7068 700d 0a2f 2a0d 0a20 2024 4964 <?php../*.. $Id The 0d of course is the carriage return and the 0a the line feed. If you want me to verify that I can view the doubled carriage returns, email me a copy of one of the corrupted files. Or you could try changing $file_contents = stripslashes($_POST['file_contents']); to $file_contents = str_replace("\r\n", "\n", stripslashes($_POST['file_contents'])); I tried that on mine and it left things as Unix line endings. Perhaps yours would leave it as Windows line endings. Always back up before making changes. Link to comment Share on other sites More sharing options...
♥raiwa Posted May 5, 2020 Author Share Posted May 5, 2020 I sent you the mail About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥ecartz Posted May 5, 2020 Share Posted May 5, 2020 When I try editing the corrupted version of the file, I get either CRLFCRLF or LFLF depending on whether I do the replace before saving. A better replacement might be $file_contents = preg_replace("{\r+\n}", "\n", stripslashes($_POST['file_contents'])); But I can't really test it, as I believe that the CRCRLF is getting converted to CRLFCRLF prior to that point. I'll let @burt make the decision about whether it is better to push to core or not. And which version and when. Always back up before making changes. Link to comment Share on other sites More sharing options...
burt Posted May 5, 2020 Share Posted May 5, 2020 What's going on? You are amending the file via the admin/define_language.php You are then downloading the file via FTP You are then amending the file in notepad++ At point 3, you see CR and LF etc everywhere ? Link to comment Share on other sites More sharing options...
♥raiwa Posted May 5, 2020 Author Share Posted May 5, 2020 2 minutes ago, burt said: What's going on? You are amending the file via the admin/define_language.php You are then downloading the file via FTP You are then amending the file in notepad++ At point 3, you see CR and LF etc everywhere ? Yes, I'm seeing then the first screenshot of my first message. About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
♥raiwa Posted May 5, 2020 Author Share Posted May 5, 2020 9 minutes ago, ecartz said: When I try editing the corrupted version of the file, I get either CRLFCRLF or LFLF depending on whether I do the replace before saving. A better replacement might be $file_contents = preg_replace("{\r+\n}", "\n", stripslashes($_POST['file_contents'])); Tested and works for my case. About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
burt Posted May 5, 2020 Share Posted May 5, 2020 What I'd like to do is this; I will log into the Phoenix Demo and amend a file via the define_language I will FTP it down I will attach it here At that point, you can open in your editor a let know what you see... Link to comment Share on other sites More sharing options...
burt Posted May 5, 2020 Share Posted May 5, 2020 specials.php Link to comment Share on other sites More sharing options...
♥raiwa Posted May 5, 2020 Author Share Posted May 5, 2020 Looks O.K. except for the missing backslash. About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
burt Posted May 5, 2020 Share Posted May 5, 2020 So is that file problematic ? Forget the missing backslash, I forgot to backslash it. Link to comment Share on other sites More sharing options...
♥raiwa Posted May 5, 2020 Author Share Posted May 5, 2020 This file is ok regarding the line ends. I understand that you can't recreate the problem. But, I could see it in several occasions under different scenarios and from at least 3 different users like explained above. It would be interesting to know if other users can reproduce it. About Me: http://www.oscommerce.com/forums/user/249059-raiwa/ Need help? How To Get The Help You Need Is your version of osC up to date? You'll find the latest osC community version CE Phoenix here. Public Phoenix Change Log Cheat Set on Google Sheets Link to comment Share on other sites More sharing options...
ce7 Posted May 28, 2020 Share Posted May 28, 2020 Hi all, @raiwa @ecartz @burt tried search long time about text editor, wasted lots of time, finally found out define languages...😓 in my list, it doens't come with sorting order, is there a way to asc desc, and how to change the code? in CE 1.0.5.0 version, I have this addon JcM Background Video Hook V1.0 and it has admin/includes/languages/english/hooks/shop/siteWide/BackgroundVideo.php how to list this hooks language file? many thanks! Lyn Link to comment Share on other sites More sharing options...
burt Posted May 28, 2020 Share Posted May 28, 2020 1 hour ago, ce7 said: Hi all, @raiwa @ecartz @burt tried search long time about text editor, wasted lots of time, finally found out define languages...😓 in my list, it doens't come with sorting order, is there a way to asc desc, and how to change the code? in CE 1.0.5.0 version, I have this addon JcM Background Video Hook V1.0 and it has admin/includes/languages/english/hooks/shop/siteWide/BackgroundVideo.php how to list this hooks language file? many thanks! Lyn You will need to contact a good developer and get it re-coded to suit your needs. If what is made is better than core, maybe you would then allow us to replace what is in core with your new version. Link to comment Share on other sites More sharing options...
ce7 Posted May 29, 2020 Share Posted May 29, 2020 hi burt, @burt thank you for the reply. i dont have budget to contact developer, i self-learning from forum or google these years 😞 I google "php sort filename" and found some tips, my way to sort define_language is as below for others who maybe also want to know find: $result = array_merge($result, tep_opendir($path . $filename)); add below: // sort the filename lowest to highest // ref: https://www.php.net/manual/en/function.sort.php // or can use asort($result); sort ($result); this gave me the result i want, the only thing, i can not figure out is there are few files not sorted at the bottom, and i dont understand why? check the file type, file size, file permission, file modified date and time, what else did i miss? and the hook language files did come out on the list. Lyn Link to comment Share on other sites More sharing options...
♥ecartz Posted May 29, 2020 Share Posted May 29, 2020 I would do it right before the return rather than where you're doing it, for efficiency's sake and to make sure you sort every file. I think that you are implicitly sorting by path most of the time but not always. Try usort($result, function ($a, $b) { return strcmp($a['name'], $b['name']); }); return $result; That explicitly sorts by path. Or even better might be to move it outside the function entirely. foreach (tep_opendir(DIR_FS_CATALOG_LANGUAGES . $_GET['lngdir']) as $file) { to $files = tep_opendir(DIR_FS_CATALOG_LANGUAGES . $_GET['lngdir']); usort($result, function ($a, $b) { return strcmp($a['name'], $b['name']); }); foreach ($files as $file) { Always back up before making changes. Link to comment Share on other sites More sharing options...
ce7 Posted May 31, 2020 Share Posted May 31, 2020 Hi Matt, @ecartz thank you very much for your reply and the code modification, good learning for me.... 👍 👏 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.