svetaines1 Posted October 13, 2010 Share Posted October 13, 2010 Hi,I have problem with Presta or web hosting company. When I creating product, looks like everything going alright.No errors or warnings!But product image not appear in BO and in FO. After some research I found out what my new created images have 640 permissions. I tried contact my hosting company (networksolutions) and ask them to change default file permissions to 644, but they don't understand what I want from them. So I will not get from them any support.Please, help me to figure out, how can I update script responsible for image creation, if in result I would like to get image with permission 644? It will be good what presta will generate images with chmod 644.Please help me! I am searching for solution almost one month Link to comment Share on other sites More sharing options...
svetaines1 Posted October 14, 2010 Author Share Posted October 14, 2010 Maybe someone host website in www.networksolutions.com? Do you have same problem, or it is configuration problem?I am using Presta 1.3.2 (before use 1.3.1 but same result) Link to comment Share on other sites More sharing options...
svetaines1 Posted October 15, 2010 Author Share Posted October 15, 2010 Please, someone advice me which file in Presta responsible for products images creation???? Any advice will be appreciated Link to comment Share on other sites More sharing options...
rocky Posted October 15, 2010 Share Posted October 15, 2010 It is the returnDestImage function in images.inc.php that creates the images. PrestaShop doesn't specify permissions though, so it must be your server configuration that's setting the wrong permissions. Link to comment Share on other sites More sharing options...
svetaines1 Posted October 15, 2010 Author Share Posted October 15, 2010 Thank you. I understand that, but my hosting provider doesn't. How I hate them!!!I will try to check that function... Is it possible to modify code and specify permissions with Presta???Nearly two weeks I am trying to solve that problem with my host helps and they just sending stupid email and nothing more.You are my last hope! Link to comment Share on other sites More sharing options...
rocky Posted October 15, 2010 Share Posted October 15, 2010 I did a Google search and found someone else with the same problem. If your host refuses to change your server configuration, it seems your only option is to change the permissions of your img and img/p directory to chmod 777, then change it back to chmod 755 after you've finished uploading images, since it is unsafe to use chmod 777 permissions. Under some configurations imagecreatefromjpeg will create files that are owned by the webserver rather than the php user. For example, php may be run as phpuser and the image will be created under apache.This can lead to permissions problems - only a +0777 will be enough to be able to create a picture. My solution was to chmod over ftp to 0777 just before the picture is written then change back to 0755 when the image has been created.The alternative of course would be to have a properly configured system... Link to comment Share on other sites More sharing options...
svetaines1 Posted October 15, 2010 Author Share Posted October 15, 2010 Thank you rocky. Looks like I have really big problems... For my client it will be unacceptable solution and this time I understand him I will try last time kick in my host ass and I hope they will wake up ..Regards,Vitalij Link to comment Share on other sites More sharing options...
svetaines1 Posted October 15, 2010 Author Share Posted October 15, 2010 One more thing! I wrote little script in php which creates XML file on my server. Almost every time that new created XML file have 640 permission (like my pictures), so problem is really in server side... Probably even changed folder permissions to 777 will not help me in that situation Link to comment Share on other sites More sharing options...
rocky Posted October 15, 2010 Share Posted October 15, 2010 I can't believe your host is refusing to admit there is a problem. Link to comment Share on other sites More sharing options...
svetaines1 Posted October 15, 2010 Author Share Posted October 15, 2010 Probably they understand that, but no result I am getting emails from them what they trying to reach my by phone... Or they doing what they can...But more than 2 weeks still no result (but it is not community problem). Just if someone will suggest how to modify Presta in order to create 644 images, I will be very glad Link to comment Share on other sites More sharing options...
svetaines1 Posted October 18, 2010 Author Share Posted October 18, 2010 Maybe someone know how can I change multiply files permissions with PHP. One file permissions possible to do with such command:$file = "myFile.xml";chmod($file, 0755);But how can I run script for all directory with files??? Link to comment Share on other sites More sharing options...
rocky Posted October 18, 2010 Share Posted October 18, 2010 Try the following code: $dirs = array(); $dirs[] = '/'; while (($dir = array_pop($dirs)) != NULL) { if ($dir == '.' OR $dir == '..') continue; $files = scandir($currentDir . $dir); foreach ($files as $file) { if (is_dir($file)) { chmod($file, 0755); $dirs[] = $file; } else chmod($file, 0644); } } I haven't tested it, but it should recurively set the permissions of all directories to 755 and files to 644 starting from '/'. Change that to the directory you want to start from. Link to comment Share on other sites More sharing options...
svetaines1 Posted October 18, 2010 Author Share Posted October 18, 2010 Try the following code: $dirs = array(); $dirs[] = '/'; while (($dir = array_pop($dirs)) != NULL) { $files = scandir(array_pop($dirs)); foreach ($files as $file) { if (is_dir($file)) { chmod($file, 0755); $dirs[] = $file; } else chmod($file, 0644); } } I haven't tested it, but it should recurively set the permissions of all directories to 755 and files to 644 starting from '/'. Change that to the directory you want to start from. Dear rocky,You can be life saver! I tried your code $dirs = array(); $dirs[] = '/img/p/'; while (($dir = array_pop($dirs)) != NULL) { $files = scandir(array_pop($dirs)); foreach ($files as $file) { if (is_dir($file)) { chmod($file, 0755); $dirs[] = $file; } else chmod($file, 0644); } } but got such mistakes:Warning: scandir() [function.scandir]: Directory name cannot be empty in **/htdocs/test.phpWarning: Invalid argument supplied for foreach() in **/htdocs/test.phpMaybe you can advise what I am doing wrong?Thank you anyway Link to comment Share on other sites More sharing options...
svetaines1 Posted October 18, 2010 Author Share Posted October 18, 2010 Just now finally I got straight answer from that bustards networksolutions. They say what they will not change default files permission to 644 and say what I should modify Prestashop code in order if I want what it will work in their server...It is amazing! networksolutions really suck! 3 weeks they were playing around with me and just now answer clearly Please, someone help me a little bit to modify Presta. How can I code Prestashop to create images with 644 permission. Link to comment Share on other sites More sharing options...
nickny Posted October 18, 2010 Share Posted October 18, 2010 Simply change hosting providers.... Link to comment Share on other sites More sharing options...
svetaines1 Posted October 18, 2010 Author Share Posted October 18, 2010 It is not such simple My client already paid money for whole year and I 90% finish my website..Where should I put chmod($???, 0755); code in images.inc.php file to get images with 644 permissions? Link to comment Share on other sites More sharing options...
nickny Posted October 18, 2010 Share Posted October 18, 2010 You can get a refund, and simply move the files over and setup a new website. I use godaddy.. .. Total time: 20 minutes Link to comment Share on other sites More sharing options...
svetaines1 Posted October 18, 2010 Author Share Posted October 18, 2010 You can get a refund, and simply move the files over and setup a new website. I use godaddy.. .. Total time: 20 minutes And you don't have any problems with godaddy host? What about refund? Is it easy to get it? Link to comment Share on other sites More sharing options...
nickny Posted October 18, 2010 Share Posted October 18, 2010 Personally I don't, but ask other people here. Simply call networks solutions, tell them they suck and you want a refund. They will give you back your money, it's not like you paid them and they can keep it. Link to comment Share on other sites More sharing options...
rocky Posted October 19, 2010 Share Posted October 19, 2010 Try the following code: $dirs = array(); $dirs[] = '/'; while (($dir = array_pop($dirs)) != NULL) { $files = scandir(array_pop($dirs)); foreach ($files as $file) { if (is_dir($file)) { chmod($file, 0755); $dirs[] = $file; } else chmod($file, 0644); } } I haven't tested it, but it should recurively set the permissions of all directories to 755 and files to 644 starting from '/'. Change that to the directory you want to start from. Dear rocky,You can be life saver! I tried your code $dirs = array(); $dirs[] = '/img/p/'; while (($dir = array_pop($dirs)) != NULL) { $files = scandir(array_pop($dirs)); foreach ($files as $file) { if (is_dir($file)) { chmod($file, 0755); $dirs[] = $file; } else chmod($file, 0644); } } but got such mistakes:Warning: scandir() [function.scandir]: Directory name cannot be empty in **/htdocs/test.phpWarning: Invalid argument supplied for foreach() in **/htdocs/test.phpMaybe you can advise what I am doing wrong?Thank you anyway I made a mistake in my code. I've updated my code, but I think it won't keep track of the current directory properly. You are better off just using cPanel to change the file permissions. Link to comment Share on other sites More sharing options...
svetaines1 Posted October 19, 2010 Author Share Posted October 19, 2010 If it will be my website, than I will say no problem But my client is very unsatisfied about that... I will try your updated code and inform you and others about result.Thank you! Link to comment Share on other sites More sharing options...
svetaines1 Posted October 19, 2010 Author Share Posted October 19, 2010 Dear rocky,Your code is almost working It's changing files permissions which are in same directory, but not in different. Maybe, I do something wrong or maybe it is some kind of security restrictions Also, I talk with my client and he agree to change host. God bless him Nickny, godaddy will be good for me, but my client had before problems with them Please suggest any good host in America Also I will try to look in Presta forum.Thank you mates for great support! Link to comment Share on other sites More sharing options...
svetaines1 Posted October 19, 2010 Author Share Posted October 19, 2010 Just for solving that topic. I think there is many people in situation like is mine. Maybe someone tries update Prestashop code in order to get images with 644 permissions? I think it is enough to modify one or two line if you wish to get images with 644 permissions. But which lines??? If yes, please post your solution here and I think you will save not one day for Presta community Also, maybe someone know, why sometimes images created by Presta have 644, but usually 640? Link to comment Share on other sites More sharing options...
rocky Posted October 20, 2010 Share Posted October 20, 2010 Try changing the returnDestImage function on line 225 of images.inc.php from: function returnDestImage($type, $ressource, $filename) { $flag = false; switch ($type) { case 'gif': $flag = imagegif($ressource, $filename); break; case 'png': $flag = imagepng($ressource, $filename, 7); break; case 'jpeg': default: $flag = imagejpeg($ressource, $filename, 90); break; } imagedestroy($ressource); return $flag; } to: function returnDestImage($type, $ressource, $filename) { $flag = false; switch ($type) { case 'gif': $flag = imagegif($ressource, $filename); break; case 'png': $flag = imagepng($ressource, $filename, 7); break; case 'jpeg': default: $flag = imagejpeg($ressource, $filename, 90); break; } chmod($filename, 0644); imagedestroy($ressource); return $flag; } Link to comment Share on other sites More sharing options...
svetaines1 Posted October 20, 2010 Author Share Posted October 20, 2010 Try changing the returnDestImage function on line 225 of images.inc.php from: function returnDestImage($type, $ressource, $filename) { $flag = false; switch ($type) { case 'gif': $flag = imagegif($ressource, $filename); break; case 'png': $flag = imagepng($ressource, $filename, 7); break; case 'jpeg': default: $flag = imagejpeg($ressource, $filename, 90); break; } imagedestroy($ressource); return $flag; } to: function returnDestImage($type, $ressource, $filename) { $flag = false; switch ($type) { case 'gif': $flag = imagegif($ressource, $filename); break; case 'png': $flag = imagepng($ressource, $filename, 7); break; case 'jpeg': default: $flag = imagejpeg($ressource, $filename, 90); break; } chmod($filename, 0644); imagedestroy($ressource); return $flag; } THANK YOU ROCKY!!!!!!!!!!!!!! You save my life! I was just on last step to change host and you found solution!!!!Mate you are great!!!!!So for other people who belongs to Presta community. If you will have issue with pictures permissions on server, just add one line of code in images.inc.php file:Addchmod($filename, 0644); before that code imagedestroy($ressource); return $flag; That's it! Now you will have images with 0644 permissions! Link to comment Share on other sites More sharing options...
Recommended Posts