*Most Useful for Multi site purposes* (This module will not work on localhost unless you have setup Virtual IP Address on your local machine.)
Overview
This module is for displaying a splash page to users if they have a option available to visit their country's website in a very cool and configurable pop-up. It also supports different type of animations plus what text you would like to be seen by the website visitors.
It also has a configuration page to add new website urls and flush them in case url is added by mistake.
Usage example, If a United State's visitor visits a Germany website and if United State's website is available which user might not be having knowledge of, visitor will get a pop up that you can visit your country's website or else they can stay on the website itself.
Dependencies:
Libraries
Requirement:
Download the library from https://github.com/lhuria94/sweetalert/archive/master.zip
How to configure:
- Download and extract the sweetalert library to libraries folder.
- To add new website url: Navigate to admin/config/ip-locator/create
- Splash message settings: Navigate to admin/config/ip-locator/splash-message-settings
- To update added urls or list out: Navigate to admin/config/ip-locator/ip-locator-configuration
- That's it!
Highlights:
- No session cookies etc. Uses webstorage mechanism, So it won't break your Varnish
- Easily identifies the geographical location of the user.
- Lightweight
Follows the 2 letter country codes, refer to http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
Drupal project link: IP Locator with Splash
Git URL: http://git.drupal.org/sandbox/lhuria94/2560365.git
Git clone command (Setting up repository for the first time):
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/lhuria94/2560365.git
ip_locator_with_splash
cd ip_locator_with_splash
Manual reviews of other projects
https://www.drupal.org/node/2701911#comment-11150931
https://www.drupal.org/node/2643522#comment-10725862
https://www.drupal.org/node/2640372#comment-10726326
Thank you so much.
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | Status-report.png | 18.81 KB | lhuria94 |
| Splash message configuration.png | 25.2 KB | lhuria94 | |
| Message.png | 22.95 KB | lhuria94 |
Comments
Comment #2
PA robot commentedFixed the git clone URL in the issue summary for non-maintainer users.
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
jlicht commentedI did a manual review of this project, and ran it through the "coder" module - here are my comments:
Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
No: Causes module duplication and/or fragmentation.
(*) There is an existing module (Smart IP - https://www.drupal.org/project/smart_ip) which provides country lookup and geolocation based on the user’s IP address. There are many modules that use it for geolocation functionality. Module duplication and fragmentation is a huge problem on drupal.org and we prefer collaboration over competition. Consider depending on that module to provide geolocation functionality that’s implemented in this module
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
(-) I’m not sure why the third-party code needs to be added as a library, and can’t be included in the module. The license is compatible with being included as part of the Drupla module
README.txt/README.md
No: Does not follow the guidelines for in-project documentation and/or theREADME Template.
(-) There is no need to add hyphens and break up words to make each line exactly 80 characters. It’s OK to have lines in the README that are a bit shorter than 80 characters if it means that words are not broken up, and it is easier to read.
(+) Clearly identify the dependency on the “libraries” module and the steps to install the library, including renaming the library folder
(-) ip_locator_with_splash.module - Line 373: Comment doesn’t match the function
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Some issues identified by the “coder” module:
ip_locator_with_splash.install
(+) Line 73: Potential problem: drupal_set_message() only accepts filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized.
drupal_set_message($msg, 'warning');
ip_locator_with_splash.module
(+) Line 295: Potential problem: FAPI elements '#title' and '#description' only accept filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized.
'#title' => $val->country_label,
Coding style & Drupal API usage
General Comments
(-) The main configuration page (admin/config) should provide a single link to the configuration page for your module, not links to each of the individual configuration settings available through the module. The four options (“Add new website URL”, “Flush All”, “IP Locator Configuration”, and “Splash Message Configuration”) should be accessed through a single “IP Locator Configuration” page.
(+) When viewing one of the individual configuration pages, clicking on “IP Locator Configuration” in the breadcrumb generates an error message: Fatal error: require_once(): Failed opening required ‘/PATH_TO_SITE/sites/all/modules/ip_locator_with_splash/system.admin.inc' (include_path='.:') in /PATH_TO_SITE/cayl_drupal/includes/menu.inc on line 517
ip_locator_with_splash.module
(*) Lines 7-10: There should be no need to separately bootstrap Drupal from within this module
(-) Line 81: Truncating the table should be sufficient here, there’s no need to delete it as well.
(+) Line 291: table names should be enclosed in {curly_brackets} [sql_curly]
$sql = "Select * from country_url_data";
(-) Line 358: It looks like both minimized and development versions of the sweet alert javascript files are added on the site. Only one of them should be necessary.
(*) Line 419: It looks like the module calls out to http://ipinfo.io on every page load, but only uses the results of that call on the home page. For performance reasons, better to first check if you’re on the home page, and only then do the IP lookup.
(+) Line 475: table names should be enclosed in {curly_brackets} [sql_curly]
$result = db_query("Select * from country_url_data");
(+) Line 495: table names should be enclosed in {curly_brackets} [sql_curly]
$result = db_query("Select * from country_url_data");
ip_locator_with_splash.install
(+) Line 69, Line 82 - There is no need to call drupal_install_schema() or drupal_uninstall_schema() - see https://www.drupal.org/update/modules/6/7#install-schema. On Line 82, there’s also no need to truncate the country_url_data table, since it will have been removed.
(-) Line 72: The $msg variable should be translated using t(), not just the text of link.
Comment #4
lhuria94 commentedComment #5
shamsher_alam commentedDefault variable set on admin form and other things working good.
Thanks
Comment #6
shamsher_alam commentedDefault variable set on admin form and other things working good.
Thanks
Comment #7
lhuria94 commentedThanks @Shamsher_Alam for fixing the default variables.
Comment #8
jlicht commentedSet back to "Needs Work" based on my review (which was delayed in posting due to spam filter issues)
Comment #9
lhuria94 commentedHi @jlicht,
Thanks for the review. Sure, Ill work on the issues you have suggested.
Regarding duplication issue, The module Smart IP you have specified is very different from the module I have created.
Did you check the description and let me know in what way Smart IP & my module behave the same? Then maybe ill be able to explain it better.
Thanks
Comment #10
jlicht commentedIt's not that the modules are the same, it's that some of the functionality that's implemented in your module (specifically, the identification of country by IP address) duplicates functionality that's provided by that module. You could require a dependency on that module, and then use their API to retrieve the country.
It's possible that relying on that module introduces some constraints (for example, see "Configuration / Cache Performance Note" on the Smart IP home page) that precludes using it in this module, but it's worth assessing. If it's not a good fit, I'd suggest explaining why in the project documentation. (On that note, it's also probably worthwhile to give some information in the project documentation about the IP geolocation service that you're using).
Hope this helps.
Comment #11
lhuria94 commentedYou are right.
And the most important thing which my module has is it does not php sessions , it uses web storage mechanism and it does not break varnish.
Sure ill add that information.
And ill see if Smart IP is worth using in this module.
Comment #12
lhuria94 commentedHi @jlicht,
We have fixed all the issues you mentioned. Thanks for the review. It was very helpful.
Though, I am not considering Smart IP as for just getting the IP address, I would not want a dependency of the whole module.
As for menu, I believe its good to have the options on configuration page itself so that user can navigate easily. Also I see some other modules are also behaving the same(Displaying the menus of the config page itself). Though I have fixed the breadcrumb issue.
For example: Media have sub-menus like File system,Image styles, Image toolkit.
Thanks
Comment #13
lhuria94 commentedComment #14
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxlhuria942560365git
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #15
smashwini commentedComment #16
gotosolr commentedAutomated Review :
Coder found no warnings, issues with the project.
Manual Review:
Individual user account
Yes, Follows
No duplication
Yes,Follows
Master Branch
Yes: Follows
Licensing
Yes: Follows.
3rd party assets/code :
Yes, follows
Code long/complex enough for review
Yes, follows
Security Code:
Yes,follows
A few recommendations
1. If I do not have the library, it should give me an error message on the configuration page.
2. I did not find a way to remove a country once I set that up.
3. Getting an error because there was no sweetalert-dev.js file in the folder I downloaded from github. You can remove it if its not required.
4. Since you have two configuration pages , you should set them up as menu tabs so its easier to navigate
Comment #17
lhuria94 commentedHi @gotosolr,
Thanks for the review. Suggestions were indeed useful.
Following is the status according to your recommendations:
1. Displayed a error message on Status report when sweetalert library is not available in the libraries directory.
2. Added a delete link for removing the url one by one.
3. Removed dev version callback, its not needed.
4. Have setup menu tabs instead of links Configuration page.
Please let me know if there is any confusion.
Thanks
Comment #18
vijeta14 commentedLast changes looks good. Just did a manual review of this module.
Though I had to setup IP addresses of different countries to test this module. In future, you could create something to test this in a easy way. As far as the complexity of this module is, it looks okay for such lengthy code.
So This looks good to go!!
Thanks
Comment #19
vijeta14 commentedComment #20
naveenvalechaComment #21
lhuria94 commented@naveenvalecha Thanks for the title correction.
Comment #22
kattekrab commentedComment #23
mpdonadioUp next in my queue.
Comment #24
mpdonadioAutomated Review
Review of the 7.x-1.x branch (commit 4df66cf):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
(*) There are two security problems with this module. Assigning to @th_tushar for PAR security training.
ip_locator_with_splash_schema(), you don't need the !db_table_exists('country_url_data'); in fact this may cause weird things to happen.
ip_locator_with_splash_install(), don't build translatable links that wat. See https://www.drupal.org/node/322774
ip_locator_with_splash_enable() is not needed; just use default values (plus, this gets called each time the module is enabled).
ip_locator_with_splash_disable() should be in a hook_uninstall().
ip_locator_with_splash_admin_setting_form_delete_submit() should be able use a $form_state['#redirect'] instead of drupal_goto().
You have a "Implements hook_form()." These are form builder functions. See https://www.drupal.org/node/1354#forms
Try to be consistent with single quotes vs double quotes; single quotes are preferred when possible.
ip_locator_with_splash_splash_setting_form() has a few untranslated strings (Yes, No).
ip_locator_with_splash_admin_setting_form_delete() should be able to get the parameter from the argument and not have to use arg()?
ip_locator_with_splash_preprocess_page() alters the global $base_url? Bad things may happen here.
PhpStorm() is showing some unused variables in ip_locator_with_splash_preprocess_page();
ip_locator_with_splash_preprocess_page(), all variable_get() calls should have default values.
The inline JS ip_locator_with_splash_preprocess_page() should really be in a different file.
ip_locator_with_splash_get_location_info_by_ip(), file_get_contents() of a remote URL may not work on all systems. Use drupal_http_request().
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #25
th_tushar commentedAutomated Review
Review of the 7.x-1.x branch (commit 4df66cf):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
(*) There are two security problems with this module.
* Remove double quotes for package in ip_locator_with_splash.info file.
* After module installation, got the below message, HTML for the link to configuration page is displayed.
Please make sure website urls according to country codes are entered on our module's configuration page for the correct functioning of Locator. Click <a href="/admin/config/system/ip-locator-configuration">here</a> to visit configuration page.* Access callback set to TRUE for admin path "admin/config/system/ip-locator-configuration/%/delete" in ip_locator_with_splash.module file. Please add proper permissions for the admin paths.
* All user facing text should be passed through translate
t()function. Below are the findings,Line #51 in ip_locator_with_splash.admin.inc file, "No result found." should be passed through translate function.
'#markup' => '<div class="ip-locator-help">No result found.</div>',Line #55 in ip_locator_with_splash.admin.inc file, "Update" should be passed through translate function.
$form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Update');Line #140 in ip_locator_with_splash.admin.inc file, "Are you sure want to flush all urls?" should be passed through translate function.
return confirm_form($form, 'Are you sure want to flush all urls?', '/admin/config/system/ip-locator-configuration');* The select list option's array values should be passed through translate function.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #26
lhuria94 commented@th_tushar
Thanks for the insightful review. I have implemented you suggested changes.
Would you mind taking a look back again.
Thanks
Comment #27
lhuria94 commentedHi @mpdonadio
Thanks for the review, Implemented your suggested changes except few points mentioned below:
All other changes I have implemented. And have to say module looks more neat now.
Thanks
Comment #28
lhuria94 commentedComment #29
th_tushar commentedIn "How to configure:" section on project page,
Points #1,#2 and Point #6 means the same, Either keep Points #1,#2 or keep Point #6.
Comment #30
lhuria94 commentedDone. thanks for pointing it out.
Comment #31
lhuria94 commentedComment #32
th_tushar commented* In ip_locator_with_splash.install file, use placeholder in translate function to replace link in
ip_locator_with_splash_install().* For SQL select statements, use
db_select()instead ofdb_query().Check below code, in ip_locator_with_splash_admin_setting_form() fucntion,
$count_nodes = db_query('SELECT id FROM {country_url_data}')->rowCount();Check below code, in ip_locator_with_splash_check_if_website_available() function,
$result = db_query("Select * from {country_url_data}");* Use
drupal_http_header()to fetch the data. Check below code,In ip_locator_with_splash_get_location_info_by_ip() function,
$ip_data = drupal_json_decode(file_get_contents("http://ipinfo.io/" . $ip_addr));* The module is not showing any warnings/errors to user even if the library is not downloaded and placed in libraries folder. sweetalert.min.js file not found error is displaying in browser console.
Please fix the above findings and change the status back to "Needs review".
Comment #33
lhuria94 commentedI did not get
this one. Can you clarify?
Regarding db_query or db_select, I have read "Use db_query for SELECT queries if it is just a simple query string. If the caller or other modules need to change the query, use db_select() instead." db_query is a lot faster than db_select.
What are your thoughts on this?
For the warning/error, I have already added a warning in reports page. See attached for reference.
Comment #34
th_tushar commentedIn ip_locator_with_splash.install file, use placeholder in translate function to replace link in ip_locator_with_splash_install() as it is implemented in below code.
$t('IP Locator with Splash requires Sweetalert library. Please download the Sweetalert library from !link.', array('!link' => l($t('Sweetalert download homepage'), 'https://github.com/lhuria94/sweetalert/archive/master.zip')));You can ignore the db_query statements.
Its fine that you are showing a warning on reports page, but then the library should also not be loaded which is causing a sweetalert.js file not found error.
Comment #35
mpdonadioNone of the current issues raised are blockers. I will look at the security issue resolutions tonight, and post what I had as my notes on what they were.
Comment #36
mpdonadioAutomated Review
Review of the 7.x-1.x branch (commit 90a3dc9):
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Manual Review
From #24, my findings were:
Looks like in ip_locator_with_splash_menu(), $items['admin/config/system/ip-locator-configuration/%/delete'] has 'access callback' => TRUE, which means that anyone can delete an entry. Needs a permission.
Your inline JS in ip_locator_with_splash_preprocess_page() is XSS vulnerable b/c the variables are used rirectly with string concatenation. Move these values to settings and use a separate file.
These look like they are addressed. The menu path has a permission, and the variables are added onto the page via settings (which get escaped in the process).
My security issues were the blocking issues. This is RTBC. Assigning to @naveenvalecha for a second look if he has time. If this is still RTBC in seven days, I will approve.
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #37
lhuria94 commented@th_tushar - I have implemented your suggested changes which were placeholder in install file & remove js to load if library does not exists.
@mpdonadio - Thanks. And I am looking forward to @naveenvalecha taking a second look.
Comment #38
klausiRemoving review bonus tag, the first review link was a review by another user? Can you do one more review and add that?
Comment #39
lhuria94 commented@klausi - No That was mine to @moshnoi on HTML Tag selector.
But Sure, I will do one more.P.S: Added one more review.
Comment #40
lhuria94 commentedComment #41
lhuria94 commentedComment #42
mpdonadioOK, a week at RTBC w/o any objections.
Thanks for your contribution, lhuria94!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #43
lhuria94 commentedThanks @mpdonadio
Sure, I am quite interested in getting involved in one of Drupal community challenges.