0

Due to an growing invasion of registration bots on an OpenCart website, I have decided to install CIDRAM which seems to be a robust solution to try reducing this kind of nuisance.

I though I have implemented the system correctly as log files were effectively created and gave a list of blocked IPs. But actually, I realized that CIDRAM wasn't properly "hooked" to OpenCart: indeed, since it has been installed, some manipulations aren't possible anymore because of the following error:

SyntaxError: JSON.parse: 
unexpected end of data at line 1 column 1 of the JSON data

I must have rummaged about the causes of such an error which isn't totally unknown: maintenance mode, configuration files, user API issue, etc. I have tested various of these known possible origins without success, when I found the following advice in a checklist:

Check if you have added any $_SERVER['REMOTE_ADDR'] into an if block to reject ips on purpose.

At this point, I have to consider that the recent installation of CIDRAM can be the main cause of this error: I removed the "hook" that I had manually added in the main index.php (before requiring vQMOD) and it resolved the error.

// OpenCart Configuration
if (is_file('config.php')) {
    require_once('config.php');
}
// OpenCart Install
if (!defined('DIR_APPLICATION')) {
    header('Location: install/index.php');
    exit;
}
// CIDRAM Hook
require './cidram/loader.php';
// VirtualQMOD
require_once('./vqmod/vqmod.php');
VQMod::bootup();

However, I would still like to be able to properly install CIDRAM in order to fully test its features (and I have of course first ask the maintainers if they know a way to do it).

Thus, the question is now how to correctly "hook" CIDRAM to OpenCart without causing this json errors? Is it appropriate to hook in an other page than index.php or is it practicable to use a specific position in this main page?

P. Mergey
  • 313
  • 4
  • 18
  • When you say "hook into" OpenCart what is it that you're trying to do? Can you share some of the code that generates this error? – Daniel Jul 22 '20 at 22:49
  • I talk about "hook" because it's the term used in [the documentation (Section 2, item 5)](https://github.com/CIDRAM/Docs/blob/master/readme.en.md#SECTION2). I wasn't sure if this was the code that was generating this error (hence my queries) and [it looks like it wasn't](https://github.com/CIDRAM/CIDRAM/issues/185#issuecomment-662429527). I add a code piece to make my initial post more explicit. – P. Mergey Jul 25 '20 at 04:10
  • Oh okay, I see the term "hook" used more in Wordpress development than OpenCart! Do the logs in `/system/storage/logs/error.log` provide anything useful? – Daniel Jul 27 '20 at 06:43
  • 1
    The native `error.log` was not really helpful, but [the CIDRAM one seems to have revealed the reason for the problem](https://github.com/CIDRAM/CIDRAM/issues/185#issuecomment-662429527). I'll post an answer to my own question when I'm sure everything is working fine. Thank you for your attention. – P. Mergey Jul 28 '20 at 06:15
  • Glad you were able to resolve this issue! Is there any chance you'd be willing to create a "how to" article somewhere? I'm sure the community would appreciate that. – Daniel Jul 28 '20 at 07:25

0 Answers0