PrestaShop Forums: [Solved] Modified bankwire mod - ALMOST works - need help - PrestaShop Forums

Jump to content


Welcome to the PrestaShop Forum! We hope you'll share your comments and suggestions with us. We ask that you please post in English to the main sections of the PrestaShop Forum. If you want to write in another language, please post in the corresponding PrestaShop Community section below.

Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

NYC

Vous parlez français ? par ici !


[Solved] Modified bankwire mod - ALMOST works - need help


[Solved] Modified bankwire mod - ALMOST works - need help

#1 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 17 November 2008 - 01:44 PM

I'm creating a Western Union payment module using the "bankwire" module as a base.

It basically works 99%, but the problem is I can only get it to work if I keep all the core variables and methods named the same as in the bankwire module, plus it has to reside in a directory called "bankwire". These two modules can not co-exist obviously so I had to delete the real "bankwire".

Now if I try renaming the module to "westernunion" it will generate a not found in config error on the Modules page. I then tried to rename the Class and all the other variables named "bankwire" into "westernunion", then it will at least appear in the install list but it still fails at install.

Like I said, the module is functional as long as it remains named "bankwire". Agghh!

It seems like the file name of the module appears to be very closely tied to the module objects, but I don't understand the logic, nor do I understand how to overcome this.

Can anyone give me some pointers?

#2 Paul C

    PrestaShop Fanatic

  • 02 Aug 2008
  • Members
  • PipPipPipPip
  • 1003 posts
  • Location:Dundee, Scotland, United Kingdom

Posted 17 November 2008 - 02:54 PM

It's all in the naming. Off the top of my head you'll need to:

1) Rename the module directory to the module name (lowercase) e.g. "westernunion"
2) Rename the main php file containing the module class definition to the module name (lowercase) e.g. "westernunion"
3) In the main php file name the class e.g. "WesternUnion" (must be the same, but can be mixed lower and upper case)
4) In function __construct(), set the class name member variable to the module name (lowercase) e.g. $this->name = 'westernunion';
5) Modify the name of any setting in the module so that they're unique

I thinks that's them all :)

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#3 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 17 November 2008 - 07:17 PM

Indeed I did all of the above. I painstakingly changed every reference to 'bankwire' until they are all gone. I have studied other modules here such as 'creditcard' and 'cashondelivery' and it seems I've done everything correctly, and yet, the thing will not install if renamed.

Can I post the code here, or offsite, for someone to look at ?

#4 Paul C

    PrestaShop Fanatic

  • 02 Aug 2008
  • Members
  • PipPipPipPip
  • 1003 posts
  • Location:Dundee, Scotland, United Kingdom

Posted 17 November 2008 - 07:24 PM

Did you rename the directory?? All the files must be in /modules/

Otherwise upload a zip file here, and we can take a look.

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#5 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 17 November 2008 - 08:24 PM

Thanks Paul. For some reason I am unable to upload the archive here. The site is ignoring the attachment to this message. Here's a link to it here: http://rapidshare.co...esternunion.rar

Take a look at it. In its current state is silently fails to install. Prior to my renaming everything it was working nearly 100%.

I've gone back to square one and renamed bits and pieces of this module a dozen times already - it's getting quite frustrating.

FWIW, I'm building this on prestashop_1.1.0.1

#6 Paul C

    PrestaShop Fanatic

  • 02 Aug 2008
  • Members
  • PipPipPipPip
  • 1003 posts
  • Location:Dundee, Scotland, United Kingdom

Posted 17 November 2008 - 09:01 PM

The only thing I can see that's a problem is:


$os->send_mail = 0; //This should be 1, however it fails, perhaps for the same reasons this entire module fails
$os->template = ""; //This should be "westernunion", however it fails, perhaps for the same reasons this entire module fails


$os->template is a multi-lang field so is an array, you'll need to use the same technique as the status message to fill all 10 elements with the template name. That way you should be able to set $os->send-mail = 1;

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#7 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 18 November 2008 - 03:36 AM

Thanks for the tip on the $os->template!

Thing is, that particular function is trivial and you can comment it out of the module and it makes no difference - still fails.

So are you saying you were otherwise able to install the module and run it ??

#8 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 18 November 2008 - 07:01 PM

It occurred to me that perhaps a simpler challenge would be to show you my working code.

http://rapidshare.co...sternunion_.rar

This code functions correctly as long as it is called "bankwire".

I've tried countless times to rename it to "westernunion" and it always fails in different ways. Should be easy right? Why can't I do it??

BTW, I commented out the custom idOrderState functions in this module, which still has a couple bugs, just so that the focus can be on getting the darn module renamed.

If someone can assist I will be forever grateful, not to mention I'll freely share the working code once it works.

#9 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 23 November 2008 - 02:52 PM

Just a bump to see if I can persuade anyone to have a look at renaming this module. It's must be something obvious, but I'm totally stumped.

#10 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 04 December 2008 - 08:06 AM

Another bump. I have been working on renaming the module for 3 weeks now and no joy. It's ridiculous. Obviously there is some quirk in the naming of the modules which is not documented. PLEASE can somebody who has done it before take a look at the code and rename this module? It can't be that hard.

http://rapidshare.co...sternunion_.rar

#11 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 10 December 2008 - 04:57 PM

I managed to solve this problem and finish the module, however the solution is ridiculous and I can't explain it.

It all boiled down to a single line of code!!

The original code:

$this->displayName = $this->l('Bank Wire');

which I had changed to

$this->displayName = $this->l('Western Union');

Seems innocuous, no?

Turns out the word "Union" within the displayName variable completely screws up Prestashop!! I have changed it to this for the time being:

$this->displayName = $this->l('Western Onion');

And it works just fine.

Can ANYONE explain why this is a bug????

#12 rocky

    PrestaShop Superstar

  • 16 Oct 2008
  • US Moderators
  • 9981 posts
  • Location:Australia

Posted 11 December 2008 - 01:40 AM

I believe it is because the word 'union' is blacklisted. You can remove UNION from the blacklist in db.php, but that will create a security hole. It might be better to use empty html tags to split the word.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

Guides Performance Guide | Installation Guide | Development Guide

Modules AJAX Sliding Categories | AJAX Dropdown Categories | Carousel | Image Gallery | Sliding Menu

All free and paid software, modules, themes and modifications are subject to the terms and conditions here.

#13 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 11 December 2008 - 02:40 AM

Interesting. Is that a sql injection security hole?

I tried this, it nearly worked but it failed at the final payment step :
Western Union


#14 rocky

    PrestaShop Superstar

  • 16 Oct 2008
  • US Moderators
  • 9981 posts
  • Location:Australia

Posted 11 December 2008 - 03:02 AM

Try Western Union. If that doesn't work, it must be another problem.
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

Guides Performance Guide | Installation Guide | Development Guide

Modules AJAX Sliding Categories | AJAX Dropdown Categories | Carousel | Image Gallery | Sliding Menu

All free and paid software, modules, themes and modifications are subject to the terms and conditions here.

#15 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 11 December 2008 - 11:49 AM

Sadly, your suggestion does not work - results in "hack attempt" error.

Neither does "Western_Union".

#16 whitelighter

    PrestaShop Addict

  • 01 Dec 2008
  • Members
  • PipPipPip
  • 550 posts

Posted 11 December 2008 - 04:06 PM

Try using double quotes instead of single. You can try using an sql escape function like mysql_real_escape_string or a substitute from the db class too.

#17 kacrut

    PrestaShop Newbie

  • 04 Dec 2008
  • Members
  • Pip
  • 19 posts

Posted 13 December 2008 - 09:03 AM

re move UNION from the blacklist in db.php

#18 Me 8084

    PrestaShop Apprentice

  • 20 Oct 2008
  • Members
  • PipPip
  • 87 posts

Posted 13 December 2008 - 11:17 AM

hello

am not using the check module so I made it a western union module by changing lang variables only

now if someone chooses it it says:

name - mobile phone - location

is that the same you are aiming at??
Wedding Gowns
+
Sexy Lingerie
World Wide

#19 clokwise

    PrestaShop Apprentice

  • 16 Nov 2008
  • Members
  • PipPip
  • 40 posts

Posted 14 December 2008 - 05:06 PM

From 1229007983:

Try using double quotes instead of single. You can try using an sql escape function like mysql_real_escape_string or a substitute from the db class too.


Just tried and both ideas failed!

So apart from renaming to "Onion" or some such thing, it seems like removing UNION from the blacklist in db.php is the only solution. Really??? However that requires user modifying core code, which could make the module break during an upgrade. Also, it's in the blacklist for a reason, so it must be a security concern.

#20 rocky

    PrestaShop Superstar

  • 16 Oct 2008
  • US Moderators
  • 9981 posts
  • Location:Australia

Posted 15 December 2008 - 05:37 AM

I think the Prestashop team are trying to come up with an alternative to the blacklist. Until then, you could try using codes like U or the union symbol ∪ in place of the U in union or if that doesn't work then |_|. There must be a way to write "Union" that isn't a security risk and so won't be blacklisted. You might need to be creative. :)
Check out Nethercott Constructions for PrestaShop guides and modules. Like us on Facebook for news updates.

Guides Performance Guide | Installation Guide | Development Guide

Modules AJAX Sliding Categories | AJAX Dropdown Categories | Carousel | Image Gallery | Sliding Menu

All free and paid software, modules, themes and modifications are subject to the terms and conditions here.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users