Wednesday, July 13, 2022

Blank page on NextJs project even every code was right - culprit was browser extension

 I was working on some Nextjs projects where I have to show the Ads services content, so I created a file called ads-services.js under the pages folder of the NextJs project.

Then, I added the code something like the below:


 






Built it and run it in the browser and everything is blank, cannot see anything.

Found solution after 1/2 hour, either I have to disable the Adblocker extension used in the browser or need to change the ads-service.js file name to something live management-services.js 

Rare headache which makes you bald.


Monday, December 27, 2021

API endpoints collections for the creation of Cryptocurrencies payment modules

https://docs.metamask.io/guide/getting-started.html#basic-considerations

 https://infura.io/docs/eth2

https://marketinsg.zendesk.com/hc/en-us/articles/360045156711-Crypto-com-Pay

http://trufflesuite.com/index.html

https://rarible.com/create/erc-721

Tuesday, December 8, 2020

Fixed: Opencart installation error linux: warning: fopen(system/storage) failed to open stream: Permission denied

Warning: fopen(/var/www/html/webocreation.com/system/storage/session/....): failed to open stream: Permission denied in /var/www/html/webocreation.com/system/library/session/file.php on line 29 Warning: flock() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 31 Warning: fwrite() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 33 Warning: fflush() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 35 Warning: flock() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 37 Warning: fclose() expects parameter 1 to be resource, bool given in /var/www/html/webocreation/system/library/session/file.php on line 39 


 These errors occurs because of the file permissions. In most of the forum, I found that they suggested to give full permission 0777 for the storage folder, this can be dangerous as per the security reason.
I have added the opencart upload folders and files at /var/www/html/webocreation
Following are the commands that I run:
cd /var/www/html/webocreation
Now I am in the folder, then I list the details of the files and folder:
ls -la


Change the ownership of the files and folders to the apache:apache 
sudo chown apache:apache -R . 
Let's make the all files secure by giving permissions of 0644 
find . -type f -exec chmod 0644 {} \; 
 Likewise, let's make the directory accessible for the apache 
find . -type d -exec chmod 0755 {} \;
 Now, let give access to read all files for the httpd server 
sudo chcon -t httpd_sys_content_t . -R 
 Allow write only to specific dirs 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/cache -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/download -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/logs -R
sudo chcon -t httpd_sys_rw_content_t ./system/storage/modification -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/session -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/upload -R 
sudo chcon -t httpd_sys_rw_content_t ./system/storage/vendor -R
Once these commands are run then you are ready to install.


Then, open the browser and run the URL and you may get warning saying config.php file need to be writable, then for that run following two commands:
sudo chcon -t httpd_sys_rw_content_t ./config.php -R 
sudo chcon -t httpd_sys_rw_content_t ./admin/config.php -R

Friday, November 6, 2020

AWS ssh error: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

 I was ssh-ing to AWS EC2 instance and got the error Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

-----------------

sh-3.2# chmod 400 ec2-keypair.pem
sh-3.2# ssh ec2-suer@54.89.86.26 -i ec2-keypair.pem
The authenticity of host '54.89.86.26 (54.89.86.26)' can't be established.
ECDSA key fingerprint is SHA256:LoSxZtmn3jyNZikgW6U50z3owgBM/Gm/pnK0aJNmScQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '54.89.86.26' (ECDSA) to the list of known hosts.
ec2-suer@54.89.86.26: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
sh-3.2# ssh ec2-user@54.89.86.26 -i ./ec2-keypair.pem
       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|
https://aws.amazon.com/amazon-linux-2/
25 package(s) needed for security, out of 39 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-10-0-1-24 ~]$
-----------------

Solution: The solution is just adding the right path, for the key pair that you downloaded. I was in the right folder and I gave the path by just adding "./"

ssh ec2-user@54.89.86.26 -i ./ec2-keypair.pem



Thursday, September 3, 2020

Opencart error: Notice: Trying to access array offset on value of type null in ..../vendor/scss.inc.php on line 1753

If you see an error in opencart like below:

Notice: Trying to access array offset on the value of type null in .../vendor/scss.inc.php on line 1753

then the solution is: Open the file .../vendor/scss.inc.php and go to line as given in the above case it is 1753 where you will see code like below:

foreach ($args as $arg) {
    list($key, $value) = $arg;
    $key = $key[1];
    if (empty($key)) {
        $posArgs[] = $value;
    } else {
        $keyArgs[$key] = $value;
    }
}


Then change the line to the following, the changes done is in bold. 

foreach ($args as $arg) {
    list($key, $value) = $arg;
    if (!empty($key[1])) {
        $key = $key[1];
    }
    if (empty($key)) {
        $posArgs[] = $value;
    } else {
        $keyArgs[$key] = $value;
    }
}


 


 




Saturday, December 8, 2018

Opencart objects defined, Opencart development tutorials




Predefined objects’ methods are functionalities which are already defined and you can use it directly.


It prevents from DRY, which means Don't Repeat Yourself. Don’t write code unless you have to. Write code only what you need, if you missed these predefined objects’ methods then you may repeat codes.


You can find predefined objects’ methods at system/library


Opencart has many predefined objects’ methods that can be called in Controller and Model.  Like in admin section we can see predefined objects like: config, log, event, load, request, response, db, session, cache, url, langauge, openbay, document, customer, currency, tax, weight, length, cart, encryption, model_setting_event, user.



Database Object of Opencart is
$this->db

Methods are:
  • $this->db->escape($value) - mysql_real_escape_string() on the value passed
  • $this->db->countAffected() - rows affected by an UPDATE query
  • $this->db->getLastId() - last auto increment id same as mysql_insert_id()
  • $this->db->connected() – Pings a server connection, or tries to reconnect if the connection has gone down
$this->db->query($sql)
All SQL queries are run from $this->db->query method which looks like: $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category WHERE $this->db->query("REPLACE INTO `" . DB_PREFIX . "category_path` SET ...); $this->db->query("INSERT INTO `" . DB_PREFIX . "category_path` SET ...); $this->db->query("DELETE FROM " . DB_PREFIX . "category WHERE ...); $this->db->query("UPDATE " . DB_PREFIX . "category SET image = ...);

$this->db->query method returns three properties:  
$result->num_rows = $query->num_rows; - gets the number of rows in a results  
$result->row = isset($data[0]) ? $data[0] : array(); - get the first row data  
$result->rows = $data; - get an array of row results

Friday, December 7, 2018

How to create the database table in OpenCart?

How to create the database table in OpenCart? Video tutorial - Opencart Development


Things to consider while creating the database
OpenCart supports multistore
It supports multi-language
Multiple Layouts
oc_ is default database prefix if you have not customized one. If you are creating table then better to make 4 tables, one which will contain language specific contents here oc_information_description, another is non-language specific oc_information and other which joins with the store and last one which joins to layout.
Another database table to take into consideration is seo_url if you are creating new pages, if you are creating only for module then it may not be used

Transcript, code and ppt at:
https://webocreation.com/blog/things-consider-creating-database

Tuesday, December 4, 2018

Installing OpenCart Vesrion 3.0.2.0 - Opencart Development tutorials Video 2







  •  Download OpenCart files from http://opencart.com 
  • Create a database
  • Upload files and folders
  • Create config files one at root folder and another inside admin/ folder. 
  • Steps to create custom URL to work locally https://webocreation.com/blog/steps-create-custom-url-work-locally-xampp-localhost-virtual-host
  • Go to the URL
  • If you see any other errors then you have to solve them. One could curl disabled which you have to enable from php.ini
  • Delete the install folder, if you rename the folder then you are a by-passing error message but there will be security holes remained in that folder so the hacker can find it easily and exploit your database so strongly recommended to delete the install folder after installation is complete.