gandalf.corvotempesta Posted November 27, 2012 Share Posted November 27, 2012 Hi to all. I would like to create a small ecommerce hosting service like Prestabox. Will this be possible with Prestashop 1.5 ? Are there any limitations? Prestabox has a customized version of Prestashop or is the same that I'm able to download and install? What I would like is to offer a fully-featured prestabox installation to my customers without needing to install many instances and being able to update all ecommerce in a single time. Link to comment Share on other sites More sharing options...
Dh42 Posted November 27, 2012 Share Posted November 27, 2012 I am not sure of the specifics with reselling Prestabox, but one thing I can tell you is don't automatically upgrate peoples software version. They could be running versions of modules that do not work in a newer version and you will break their site. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 27, 2012 Author Share Posted November 27, 2012 Thank you for the answer. In my service i'll not allow customers to install own modules. I'll offer a customized version of prestashop and capability to choose from a predefined set of template, but customers will be not allowed to install own modules or other things Link to comment Share on other sites More sharing options...
Dh42 Posted November 27, 2012 Share Posted November 27, 2012 You can surely modify a version of Prestashop to do that and write an auto install script. If you are using a dedicated server you can install something like softaculous and set up a custom version of Prestashop with it. Then you can integrate it with your WHM to automatically install your version of Prestashop when someone pays money and creates an account. That is the way that I would recommend doing it. I wouldn't try to have all of the shops on one code base. If one gets hacked, they will all get hacked, I would still have each in its own sandbox. Plus it makes monitoring sever resources either since you won't be using rewrite rules for every shop. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 27, 2012 Author Share Posted November 27, 2012 Probably you misunderstood me. I don't want to make multiple installation of prestashop, i would like to install ONE COPY of prestashop and offer a multistore version like prestabox, as a service. Link to comment Share on other sites More sharing options...
Dh42 Posted November 27, 2012 Share Posted November 27, 2012 Oh, I didn't misunderstand you, I suggested the best way to do it. Multishop does not have the permission set to effectively do that. If you give someone access to the back office they have access to the whole back office, so they can delete someone elses products. I am not to familiar with Prestabox and how it works, but I would be willing to bet each one is a stand alone prestashop installation.. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 27, 2012 Author Share Posted November 27, 2012 Oh, I didn't misunderstand you, I suggested the best way to do it. Multishop does not have the permission set to effectively do that. If you give someone access to the back office they have access to the whole back office, so they can delete someone elses products. I've made some local test and If i create an administrator bound to a single shop, i'm not able to see/manage/delete other shops producst. Link to comment Share on other sites More sharing options...
Dh42 Posted November 27, 2012 Share Posted November 27, 2012 I honestly still do not think the permissions are strong enough to support that. Link to comment Share on other sites More sharing options...
benjamin utterback Posted November 27, 2012 Share Posted November 27, 2012 Hello, I would have to agree with Dh42, this seems like an implausible and ineffective way to manage due to permissions and restrictions you would have to put for each user. Yes, PrestaBox does install one instance of PrestaShop on every store. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 27, 2012 Author Share Posted November 27, 2012 Thanks to all. How does prestabox manage updates? Are they manually updating each instance? In case of hundreds or thousands shop they will need months to update. Which kind of permission is lacking from a multistage prestashop installation? Link to comment Share on other sites More sharing options...
benjamin utterback Posted November 27, 2012 Share Posted November 27, 2012 Hello gandalf, There are a couple problems with this set up. The first glaring one is Sever space, it needs to big and fast. Secondly, if one company needs a certain module and another needs a different, infinite problems could arise. If one back office is messed up, they all are. Not a good situation. I don't think this is feasible. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 27, 2012 Author Share Posted November 27, 2012 Ok but how to manage updates of thousands installation? Link to comment Share on other sites More sharing options...
benjamin utterback Posted November 27, 2012 Share Posted November 27, 2012 Hello, if you have plan to handle a thousand stores, you should first get a warehouse of servers, among other things like human resources. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 27, 2012 Author Share Posted November 27, 2012 This is not an issue we have a datacenter with multiple gigabits connections and 25 employee. My issue is how to automate the update processes and not how to find hardware and human resources We would like to start offering a small saas offer like bigcommerce or shopify. Link to comment Share on other sites More sharing options...
Dh42 Posted November 27, 2012 Share Posted November 27, 2012 Write a script to update things. It is pretty straight forward. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Ok. But I'm still not seeing what issue should arise in a multistore installation. Each administrator will not be able to add custom plugins or access via FTP. They will access only from the admin panel with a limited set of privileges Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 (edited) Probably, using a custom settings.inc.php with settings changed on the fly based on a custom environment from the virtualhost will be a better way. something like this: define('_DB_SERVER_', $_ENV['DBHOST']); define('_DB_NAME_', $_ENV['DBNAME']); define('_DB_USER_', $_ENV['DBUSER']); define('_DB_PASSWD_', $_ENV['DBPASS']); In this way we will be able to manage a single prestashop installation with multiple databases, one for each customer. Edited November 28, 2012 by gandalf.corvotempesta (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted November 28, 2012 Share Posted November 28, 2012 Probably, using a custom settings.inc.php with settings changed on the fly based on a custom environment from the virtualhost will be a better way. something like this: define('_DB_SERVER_', $_ENV['DBHOST']); define('_DB_NAME_', $_ENV['DBNAME']); define('_DB_USER_', $_ENV['DBUSER']); define('_DB_PASSWD_', $_ENV['DBPASS']); In this way we will be able to manage a single prestashop installation with multiple databases, one for each customer. The problem is that customers will request different types of payment modules, themes, custom changes and other modules. These can not be supported just by having different mysql db's as they require different root files. You may want to consider a 'rental' arrangement where you basically host a stand alone ps install and change monthly...you can easily limit the number of products per level of shop. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 The problem is that customers will request different types of payment modules, themes, custom changes and other modules. These can not be supported just by having different mysql db's as they require different root files. Absolutely not. This will not be offered on our service. I'll offer a service with a defined set of payment modules, a defined set of themes to choose from, and NO custom changes. I'll offer a package "as-is", if the predefined features are not good for a customer, that customer will not buy our service. This is why I'm asking if will be possible to manage a single multistore installation, because we will never customize any single line of code on a per user basis. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 I'm asking this because here: http://doc.prestashop.com/display/PS15/Managing+multiple+shops#Managingmultipleshops-Onebackofficetorulethemall is wrote that a single multistore installation can be customized on a per-shop basis for each item. Link to comment Share on other sites More sharing options...
benjamin utterback Posted November 28, 2012 Share Posted November 28, 2012 Hello, what about themes? Will you have one or two standard themes to choose from? Has dh42 mentioned, you could write a script to update each store with each PrestaShop installed separately. The way you are describing seems more risky and messy to me. You can install each PrestaShop independently, lock down their back office so no custom changes. Then you can do a script update as need be. This would be better for error reporting as well, you would know which instance of your individual PrestaShop installation is having the error. It would be easier than having to find an error when stores are grouped together using multistore, imo. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Hello, what about themes? Will you have one or two standard themes to choose from? Has dh42 mentioned, you could write a script to update each store with each PrestaShop installed separately. The way you are describing seems more risky and messy to me. You can install each PrestaShop independently, lock down their back office so no custom changes. Then you can do a script update as need be. This would be better for error reporting as well, you would know which instance of your individual PrestaShop installation is having the error. It would be easier than having to find an error when stores are grouped together using multistore, imo. What do you mean with "lock down their back office so no custom changes"? Which permission should I remove to archieve this? Link to comment Share on other sites More sharing options...
benjamin utterback Posted November 28, 2012 Share Posted November 28, 2012 You can view the Backoffice Permissions under Administration, you can see what options you have there. Link to comment Share on other sites More sharing options...
Dh42 Posted November 28, 2012 Share Posted November 28, 2012 I don't see what the problem is. You asked a question and 3 people that are pretty skilled with Prestashop have told you it is a bad idea, yet you keep arguing for it. Prestashop is secure, but like any software, vulnerabilities happen. I would rather lose control of a few shops databases than loose control of a database that controls 100 shops, good luck on building that back with out losing transactions. I highly doubt that you have a data center, because any network admin would be telling you to run everything instance based. You have to contain and control things. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 I highly doubt that you have a data center, because any network admin would be telling you to run everything instance based. You have to contain and control things. We own a datacenter with, exactly, 847 phisical server and at least 5x-6x VPS. This will be a test project for a new PaaS infrastructure, with a SaaS ecommerce offered as a service, based on our IaaS infrastructure (made with 5 HP bladecenter C7000 fully populated) We have 2 ways to do this: - one LXC container per each shop - one LXC container every 5 or 10 shops, activated on a single instance of Prestashop (one container for 1 instance for 10 shops) (our paas actually is using LXC containers) Probably we will go with the first solution (one container per shop) because it will offer us much more scalability for each customers, but we are just trying to evaluate every possibilities, bacause, as said, this will be a TEST project offered as a beta to many customers (up to 1000). It's mandatory, for us, to automate everything, even software upgrades. I'm testing both solutions right now and actually I don't see which kind of limitations should arise in a single multistore installation, this is why i'm asking for some hints. But, yes, probabily using one instance for each store is the best way, I only have to know how to update automatically with no browser access. AFAIK there is an installation script to be called from browser, in the manual update process. Link to comment Share on other sites More sharing options...
Dh42 Posted November 28, 2012 Share Posted November 28, 2012 Assuming there are no DB changes, update by image. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 (edited) I don't find any update by image here: http://doc.prestashop.com/display/PS15/Updating+PrestaShop Edited November 28, 2012 by gandalf.corvotempesta (see edit history) Link to comment Share on other sites More sharing options...
mohsart Posted November 28, 2012 Share Posted November 28, 2012 If it's going to be so locked down regarding themes/modules/customization, then why upgrade at all? /Mats Link to comment Share on other sites More sharing options...
El Patron Posted November 28, 2012 Share Posted November 28, 2012 Absolutely not. This will not be offered on our service. I'll offer a service with a defined set of payment modules, a defined set of themes to choose from, and NO custom changes. I'll offer a package "as-is", if the predefined features are not good for a customer, that customer will not buy our service. This is why I'm asking if will be possible to manage a single multistore installation, because we will never customize any single line of code on a per user basis. certainly more possible using 1.5.2, you just need to account for theme/modules per customer... p.s. I wrote a complete cli set that interfaces with plesk to build full ps install in <2 seconds based of cron...I no longer offer that service as I lost all my inter-personal skills in the 80's. so when you get to the point of actually doing this pm me and I will sell you the code that does things like creates db/set settings.inc.php...1.4 based but not a stretch to work in 1.5...(note based on plesk api) best of luck... Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 If it's going to be so locked down regarding themes/modules/customization, then why upgrade at all? /Mats Are you suggesting to overwrite everything except our themes and settings file ? That's ok, but we also need to update the DB. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 p.s. I wrote a complete cli set that interfaces with plesk to build full ps install in <2 seconds based of cron...I no longer offer that service as I lost all my inter-personal skills in the 80's. so when you get to the point of actually doing this pm me and I will sell you the code that does things like creates db/set settings.inc.php...1.4 based but not a stretch to work in 1.5...(note based on plesk api) Doing a fresh install is pretty easy and is not more than 3-4 lines of shell script. I have to update a running shop, not installing a fresh one. Link to comment Share on other sites More sharing options...
Dh42 Posted November 28, 2012 Share Posted November 28, 2012 Unless the DB model changes, you don't need to update the database. Link to comment Share on other sites More sharing options...
mohsart Posted November 28, 2012 Share Posted November 28, 2012 I'm saying that I'd be happier with PS 1.2 and my choise of theme/payment methods than with PS 1.5 and a fixed mix of modules /Mats Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Unless the DB model changes, you don't need to update the database. Obviously, but what if prestashop will change the DB structure? OK, i've seen right now that in /install/update/ there are some sql files. I have to run these in order to update the db. Link to comment Share on other sites More sharing options...
Dh42 Posted November 28, 2012 Share Posted November 28, 2012 I think your best bet would be to lifespan things and not update at every update. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Yes, but this doesn't change the update process. Is not possible to manually update thousands of stores and we have to automate things. After the automation, updating one time per year or 10 times per month doesn't change at all. But the update script seems to be runnable from curl without a real webbrower: $ curl http://localhost/_install/upgrade/upgrade.php <?xml version="1.0" encoding="UTF-8"?><action result="ok" error=""> <request result="ok" sqlfile="1.5.2.0"> <sqlQuery><![CDATA[sET NAMES 'utf8']]></sqlQuery> </request> <request result="ok" sqlfile="1.5.2.0"> <sqlQuery><![CDATA[ALTER TABLE `ps_address` CHANGE `company` `company` VARCHAR(32) NULL]]></sqlQuery> </request> <request result="ok" sqlfile="1.5.2.0"> <sqlQuery><![CDATA[/* PHP:fix_cms_shop_1520(); */]]></sqlQuery> </request> </action> this is perfect. As long no questions are asked by the update scripts, we can run it from curl. Link to comment Share on other sites More sharing options...
El Patron Posted November 28, 2012 Share Posted November 28, 2012 Doing a fresh install is pretty easy and is not more than 3-4 lines of shell script. I have to update a running shop, not installing a fresh one. yea, right...you da expert then.. Link to comment Share on other sites More sharing options...
Dh42 Posted November 28, 2012 Share Posted November 28, 2012 Gandalf, I feel that you do not know how e-commerce shops work. They are not windows or photoshop. They shouldn't be updated unless absolutely necessary. Then, you can use the svn to find what you should update if you are trying to plug a hole. Every time a new version of PS comes out, people don't update their shops. Link to comment Share on other sites More sharing options...
benjamin utterback Posted November 28, 2012 Share Posted November 28, 2012 Updating can be time consuming and many require investigations specific to each store. If you are doing it by single installations then its possible and has been done before. Obviously you would need to have a trial run with your update scripts and see what problems arise. It seems like you have the power and human resources to get this done if you do it right. Have you updated a customized PrestaShop store before? Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Gandalf, I feel that you do not know how e-commerce shops work. They are not windows or photoshop. They shouldn't be updated unless absolutely necessary. Then, you can use the svn to find what you should update if you are trying to plug a hole. Every time a new version of PS comes out, people don't update their shops. I know, but in case of bugs we need to. When we need to update, we must have a valid procedure to do this, and I'm trying to detect which kind of procedure should I use. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Updating can be time consuming and many require investigations specific to each store. If you are doing it by single installations then its possible and has been done before. Obviously you would need to have a trial run with your update scripts and see what problems arise. It seems like you have the power and human resources to get this done if you do it right. Our installations will be identical, except for templates, that will be choosen by us after some compatibility test. This should allow us to do an automated upgrade process. Have you updated a customized PrestaShop store before? Absolutely not, it's my first time with PrestaShop. Link to comment Share on other sites More sharing options...
Dh42 Posted November 28, 2012 Share Posted November 28, 2012 Update the affected files, nothing more. Link to comment Share on other sites More sharing options...
mohsart Posted November 28, 2012 Share Posted November 28, 2012 Hehe, only time I have to fix bugs is after a upgrade /Mats Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Update the affected files, nothing more. I'm talking about DB, not files. Can I simply run the sql files (in order) from the /install/update directory? Link to comment Share on other sites More sharing options...
Dh42 Posted November 28, 2012 Share Posted November 28, 2012 Ok. I am guessing that you haven't used PS that long. As long as the data model does not change, you do not need to update the db. You can run several different version of PS on the same db structure. What you do is have a test environment and do a automatic upgrade on it and if the db changes, write a script to change all of the dbs at once. Its a pretty simple problem, especially for a server admin to figure out. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Ok. I am guessing that you haven't used PS that long. I've never used PS. As long as the data model does not change, you do not need to update the db. You can run several different version of PS on the same db structure. What you do is have a test environment and do a automatic upgrade on it and if the db changes, write a script to change all of the dbs at once. Its a pretty simple problem, especially for a server admin to figure out. That's ok. So, if needed, I can run the update sql files from the /install/update directory. Link to comment Share on other sites More sharing options...
benjamin utterback Posted November 28, 2012 Share Posted November 28, 2012 Then I invite you to use our software, make the changes as you would a customer of yours, and run the script update as you expect. Try 1.5.1 to 1.5.2. Or if you have a month or so , you can try 1.5.2 to 1.5.3, which I think would be better. Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 Then I invite you to use our software, make the changes as you would a customer of yours, and run the script update as you expect. Try 1.5.1 to 1.5.2. Thank you. I'll try to do some automated updates on a running PS installation. Link to comment Share on other sites More sharing options...
El Patron Posted November 28, 2012 Share Posted November 28, 2012 here is a function for setting.inc.php (little more than three lines)...includes 1.5.0.1 function PS_CREATE_SETTINGS($etiendaurl,$mem_db_pwd,$bundle_db_prefix,$doc_root,$bundle_name) { //for all generate their individual password keys $COOKIE_KEY = passwdGen(56); // echo $COOKIE_KEY."<br>"; $COOKIE_IV = passwdGen(8); // echo $COOKIE_IV."<br>"; $key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $RIJNDAEL_KEY = passwdGen($key_size); // echo $RIJNDAEL_KEY."<br>"; $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $RIJNDAEL_IV = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND)); // echo $RIJNDAEL_IV."<br>"; switch($bundle_name) { case "ps1451"; case "bundlebase"; $new_settingsincphp = "<?php \n"; $new_settingsincphp .= "define('_DB_SERVER_', 'localhost'); \n"; $new_settingsincphp .= "define('_DB_TYPE_', 'MySQL');\n"; $new_settingsincphp .= "define('_DB_NAME_','".trim($etiendaurl)."');\n"; $new_settingsincphp .= "define('_DB_USER_', '".trim($etiendaurl)."');\n"; $new_settingsincphp .= "define('_DB_PASSWD_','".trim($mem_db_pwd)."');\n"; $new_settingsincphp .= "define('_DB_PREFIX_', '".trim($bundle_db_prefix)."');\n"; $new_settingsincphp .= "define('_MYSQL_ENGINE_', 'InnoDB'); \n"; $new_settingsincphp .= "define('__PS_BASE_URI__', '/'); \n"; $new_settingsincphp .= "define('_PS_CACHING_SYSTEM_', 'MCached'); \n"; $new_settingsincphp .= "define('_PS_CACHE_ENABLED_', '0'); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_1_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_2_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_3_', ''); \n"; $new_settingsincphp .= "define('_THEME_NAME_', 'prestashop'); \n"; $new_settingsincphp .= "define('_COOKIE_KEY_', '".$COOKIE_KEY."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_KEY_', '".$RIJNDAEL_KEY."'); \n"; $new_settingsincphp .= "define('_COOKIE_IV_', '".$COOKIE_IV."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_IV_', '".$RIJNDAEL_IV."'); \n"; $new_settingsincphp .= "define('_PS_CREATION_DATE_','".date("m.d.Y")."'); \n"; $new_settingsincphp .= "define('_PS_VERSION_', '1.4.5.1');\n"; $new_settingsincphp .= "?>"; break; case "ps1473base"; $new_settingsincphp = "<?php \n"; $new_settingsincphp .= "define('_DB_SERVER_', 'localhost'); \n"; $new_settingsincphp .= "define('_DB_TYPE_', 'MySQL'); \n"; $new_settingsincphp .= "define('_DB_NAME_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_USER_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_PASSWD_', '".trim($mem_db_pwd)."'); \n";; $new_settingsincphp .= "define('_DB_PREFIX_', '".trim($bundle_db_prefix)."'); \n"; $new_settingsincphp .= "define('_MYSQL_ENGINE_', 'InnoDB'); \n"; $new_settingsincphp .= "define('__PS_BASE_URI__', '/'); \n"; $new_settingsincphp .= "define('_PS_CACHING_SYSTEM_', 'MCached'); \n"; $new_settingsincphp .= "define('_PS_CACHE_ENABLED_', '0'); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_1_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_2_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_3_', ''); \n"; $new_settingsincphp .= "define('_THEME_NAME_', 'prestashop'); \n"; $new_settingsincphp .= "define('_COOKIE_KEY_', '".$COOKIE_KEY."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_KEY_', '".$RIJNDAEL_KEY."'); \n"; $new_settingsincphp .= "define('_COOKIE_IV_', '".$COOKIE_IV."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_IV_', '".$RIJNDAEL_IV."'); \n"; $new_settingsincphp .= "define('_PS_CREATION_DATE_', '".date("m.d.Y")."'); \n"; $new_settingsincphp .= "define('_PS_VERSION_', '1.4.6.2'); \n"; $new_settingsincphp .= "?>"; break; case "ps1462"; case "ps1462base"; $new_settingsincphp = "<?php \n"; $new_settingsincphp .= "define('_DB_SERVER_', 'localhost'); \n"; $new_settingsincphp .= "define('_DB_TYPE_', 'MySQL'); \n"; $new_settingsincphp .= "define('_DB_NAME_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_USER_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_PASSWD_', '".trim($mem_db_pwd)."'); \n";; $new_settingsincphp .= "define('_DB_PREFIX_', '".trim($bundle_db_prefix)."'); \n"; $new_settingsincphp .= "define('_MYSQL_ENGINE_', 'InnoDB'); \n"; $new_settingsincphp .= "define('__PS_BASE_URI__', '/'); \n"; $new_settingsincphp .= "define('_PS_CACHING_SYSTEM_', 'MCached'); \n"; $new_settingsincphp .= "define('_PS_CACHE_ENABLED_', '0'); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_1_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_2_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_3_', ''); \n"; $new_settingsincphp .= "define('_THEME_NAME_', 'prestashop_new'); \n"; $new_settingsincphp .= "define('_COOKIE_KEY_', '".$COOKIE_KEY."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_KEY_', '".$RIJNDAEL_KEY."'); \n"; $new_settingsincphp .= "define('_COOKIE_IV_', '".$COOKIE_IV."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_IV_', '".$RIJNDAEL_IV."'); \n"; $new_settingsincphp .= "define('_PS_CREATION_DATE_', '".date("m.d.Y")."'); \n"; $new_settingsincphp .= "define('_PS_VERSION_', '1.4.6.2'); \n"; $new_settingsincphp .= "?>"; break; case "ps1410"; $new_settingsincphp = "<?php \n"; $new_settingsincphp .= "define('_DB_SERVER_', 'localhost'); \n"; $new_settingsincphp .= "define('_DB_TYPE_', 'MySQL'); \n"; $new_settingsincphp .= "define('_DB_NAME_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_USER_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_PASSWD_', '".trim($mem_db_pwd)."'); \n"; $new_settingsincphp .= "define('_DB_PREFIX_', '".trim($bundle_db_prefix)."'); \n"; $new_settingsincphp .= "define('_MYSQL_ENGINE_', 'InnoDB'); \n"; $new_settingsincphp .= "define('__PS_BASE_URI__', '/'); \n"; $new_settingsincphp .= "define('_PS_CACHING_SYSTEM_', 'MCached'); \n"; $new_settingsincphp .= "define('_PS_CACHE_ENABLED_', '0'); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_1_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_2_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_3_', ''); \n"; $new_settingsincphp .= "define('_THEME_NAME_', 'prestashop'); \n"; $new_settingsincphp .= "define('_COOKIE_KEY_', '".$COOKIE_KEY."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_KEY_', '".$RIJNDAEL_KEY."'); \n"; $new_settingsincphp .= "define('_COOKIE_IV_', '".$COOKIE_IV."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_IV_', '".$RIJNDAEL_IV."'); \n"; $new_settingsincphp .= "define('_PS_CREATION_DATE_', '2011-12-19'); \n"; $new_settingsincphp .= "define('_PS_VERSION_', '1.4.1.0'); \n"; $new_settingsincphp .= "?>"; break; case "ps1370"; $new_settingsincphp = "<?php \n"; $new_settingsincphp .= "define('_DB_SERVER_', 'localhost'); \n"; $new_settingsincphp .= "define('_DB_TYPE_', 'MySQL'); \n"; $new_settingsincphp .= "define('_DB_NAME_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_USER_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_PASSWD_', '".trim($mem_db_pwd)."'); \n"; $new_settingsincphp .= "define('_DB_PREFIX_', '".trim($bundle_db_prefix)."'); \n"; $new_settingsincphp .= "define('__PS_BASE_URI__', '/'); \n"; $new_settingsincphp .= "define('_THEME_NAME_', 'prestashop'); \n"; $new_settingsincphp .= "define('_COOKIE_KEY_', '".$COOKIE_KEY."'); \n"; $new_settingsincphp .= "define('_COOKIE_IV_', '".$COOKIE_IV."'); \n"; $new_settingsincphp .= "define('_PS_CREATION_DATE_', '".date("m.d.Y")."'); \n"; $new_settingsincphp .= "define('_PS_VERSION_', '1.3.7.0'); \n"; $new_settingsincphp .= "?>"; break; case "ps1501"; $new_settingsincphp = "<?php \n"; $new_settingsincphp .= "define('_DB_SERVER_', 'localhost'); \n"; $new_settingsincphp .= "define('_DB_TYPE_', 'MySQL'); \n"; $new_settingsincphp .= "define('_DB_NAME_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_USER_', '".trim($etiendaurl)."'); \n"; $new_settingsincphp .= "define('_DB_PASSWD_', '".trim($mem_db_pwd)."'); \n"; $new_settingsincphp .= "define('_DB_PREFIX_', '".trim($bundle_db_prefix)."'); \n"; $new_settingsincphp .= "define('_MYSQL_ENGINE_', 'InnoDB'); \n"; $new_settingsincphp .= "define('_PS_CACHING_SYSTEM_', 'CacheMemcache'); \n"; $new_settingsincphp .= "define('_PS_CACHE_ENABLED_', '0'); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_1_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_2_', ''); \n"; $new_settingsincphp .= "define('_MEDIA_SERVER_3_', ''); \n"; $new_settingsincphp .= "define('_COOKIE_KEY_', '".$COOKIE_KEY."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_KEY_', '".$RIJNDAEL_KEY."'); \n"; $new_settingsincphp .= "define('_COOKIE_IV_', '".$COOKIE_IV."'); \n"; $new_settingsincphp .= "define('_RIJNDAEL_IV_', '".$RIJNDAEL_IV."'); \n"; $new_settingsincphp .= "define('_PS_CREATION_DATE_', '".date("m.d.Y")."'); \n"; $new_settingsincphp .= "define('_PS_VERSION_', '1.5.0.1'); \n"; $new_settingsincphp .= "?>"; break; default: echo "Invalid bundle_name, can not build the config/settings.inc.php for: ".$bundle_name; exit (-1); } if(!$file = fopen($doc_root."/httpdocs/config/settings.inc.php", "w")) { echo "<br />Unable to open the settings.inc.php file at: ".$doc_root.$etiendaurl; return false; } fwrite($file,$new_settingsincphp); fclose($file); return; } Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 28, 2012 Author Share Posted November 28, 2012 (edited) You are right, not 5 lines, but 14: $tpl_file="/srv/prestashop/master/config/settings.inc.php"; $cnf_file="/var/www/customer1/config/settings.inc.php"; $master = file_get_contents($tpl_file); $arr = array( 'CREATION_DATE' => date('Y-m-d') ,'COOKIE_KEY' => substr(base64_encode(file_get_contents('/dev/urandom', false, null, -1, 128)),0,56) ,'COOKIE_IV' => substr(base64_encode(file_get_contents('/dev/urandom', false, null, -1, 128)),0,8) ,'RIJNDAEL_KEY' => substr(base64_encode(file_get_contents('/dev/urandom', false, null, -1, 128)),0,mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB)) ,'RIJNDAEL_IV' => base64_encode(file_get_contents('/dev/urandom', false, null, -1, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB))) ); foreach ( $arr as $k => $v ) { $master = str_replace('%%%'.$k.'%%%', $v, $master); } file_put_contents($cnf_file, master); obviously this can be optimized. It all need a master file like this: <?php define('_DB_SERVER_', $_ENV['PAAS_DB_HOST']); define('_DB_NAME_', $_ENV['PAAS_DB_NAME']); define('_DB_USER_', $_ENV['PAAS_DB_USER']); define('_DB_PASSWD_', $_ENV['PAAS_DB_PASSWD']); define('_DB_PREFIX_', 'ps_'); define('_MYSQL_ENGINE_', 'InnoDB'); define('_PS_CACHING_SYSTEM_', 'CacheMemcache'); define('_PS_CACHE_ENABLED_', '0'); define('_MEDIA_SERVER_1_', ''); define('_MEDIA_SERVER_2_', ''); define('_MEDIA_SERVER_3_', ''); define('_PS_DIRECTORY_', '/_install/upgrade/'); define('_PS_CREATION_DATE_', '%%%CREATION_DATE%%%'); define('_PS_VERSION_', '1.5.2.0'); define('_COOKIE_KEY_', '%%%COOKIE_KEY%%%'); define('_COOKIE_IV_', '%%%COOKIE_IV%%%'); define('_RIJNDAEL_KEY_', '%%%RIJNDAEL_KEY%%%'); define('_RIJNDAEL_IV_', '%%%RIJNDAEL_IV%%%'); Edited November 28, 2012 by gandalf.corvotempesta (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted November 28, 2012 Share Posted November 28, 2012 You are right, not 5 lines, but 14: $tpl_file="/srv/prestashop/master/config/settings.inc.php"; $cnf_file="/var/www/customer1/config/settings.inc.php"; $master = file_get_contents($tpl_file); $arr = array( 'CREATION_DATE' => date('Y-m-d') ,'COOKIE_KEY' => substr(base64_encode(file_get_contents('/dev/urandom', false, null, -1, 128)),0,56) ,'COOKIE_IV' => substr(base64_encode(file_get_contents('/dev/urandom', false, null, -1, 128)),0,8) ,'RIJNDAEL_KEY' => substr(base64_encode(file_get_contents('/dev/urandom', false, null, -1, 128)),0,mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB)) ,'RIJNDAEL_IV' => base64_encode(file_get_contents('/dev/urandom', false, null, -1, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB))) ); foreach ( $arr as $k => $v ) { $master = str_replace('%%%'.$k.'%%%', $v, $master); } file_put_contents($cnf_file, master); obviously this can be optimized. It all need a master file like this: <?php define('_DB_SERVER_', $_ENV['PAAS_DB_HOST']); define('_DB_NAME_', $_ENV['PAAS_DB_NAME']); define('_DB_USER_', $_ENV['PAAS_DB_USER']); define('_DB_PASSWD_', $_ENV['PAAS_DB_PASSWD']); define('_DB_PREFIX_', 'ps_'); define('_MYSQL_ENGINE_', 'InnoDB'); define('_PS_CACHING_SYSTEM_', 'CacheMemcache'); define('_PS_CACHE_ENABLED_', '0'); define('_MEDIA_SERVER_1_', ''); define('_MEDIA_SERVER_2_', ''); define('_MEDIA_SERVER_3_', ''); define('_PS_DIRECTORY_', '/_install/upgrade/'); define('_PS_CREATION_DATE_', '%%%CREATION_DATE%%%'); define('_PS_VERSION_', '1.5.2.0'); define('_COOKIE_KEY_', '%%%COOKIE_KEY%%%'); define('_COOKIE_IV_', '%%%COOKIE_IV%%%'); define('_RIJNDAEL_KEY_', '%%%RIJNDAEL_KEY%%%'); define('_RIJNDAEL_IV_', '%%%RIJNDAEL_IV%%%'); btw...not all setting.inc.php are created equal...by version they can have more or less setting's...plus I'm lazy... don't forget you will need to change (in db) employee (add admin) - I forced password recovery so we never knew their password shop domain and ssl (if ssl is used) shop email shop name ------ if you insist on non-standalone then you wil have to address the different root files...but you seem pretty savvy... that's pretty much it...there may be a few more in 1.5.2...none off the top of my head... I think it's a good business...that's why I created capablity...but I don't really do this for the money and I saw to much user interaction...my market was for those not served by paypal and other major cc (s. america)...and subscription based services combined with geo pricing...is all the rage... look forward to seeing how you come out with this... Link to comment Share on other sites More sharing options...
gandalf.corvotempesta Posted November 29, 2012 Author Share Posted November 29, 2012 Just a question: all customer's file will be placed under /upload directory? For example, product images and so on. All other directories are the same on each shop?I'm asking this because we don't have a persistent storage on our PaaS except for a distributed storage that will be mounted under /upload. Link to comment Share on other sites More sharing options...
Recommended Posts