Posts

CakePHP 4: Firebase Cloud Messaging Component in CakePHP for Push Notification

Image
Easily deploy an SSD cloud server on @DigitalOcean in 55 seconds. Sign up using this link and receive $100 in cloud credits: https://m.do.co/t/335732d1df0b <?php namespace   App\Controller\Component ; use  Cake\Controller\ Component ; use  Cake\Http\ Client ; class   FirebaseComponent   extends   Component {         public   function   headers () {         $header  =    [ 'headers'   =>    [                                          'Accept'   =>   'application/json' ,                                          'Content-Type'   =>   'application/json' ,                                          'Authorization'   =>   'key=AAAAeh0kVhs4ums9A0SYyO2xbCgXvT_jfUUi-0jXs0GfMpZ5DZPqKylqht-TPXGPiqFVj81hBPLL_st9NkjspAarhbfufFHBQN_7'                                     ]                     ];          return  $header;     }      public   function   sendSingleNotification ()  //FCM     {         $fcToken  =   'e_tHOI1XT3udZvMYS

CakePHP 4 : Using Component inside Command ( Shell )

Image
Easily deploy an SSD cloud server on @DigitalOcean in 55 seconds. Sign up using this link and receive $100 in cloud credits: https://m.do.co/t/335732d1df0b src>Command>AppCommand.php <?php namespace   App\Command ; use  Cake\Console\ Arguments ; use  Cake\Console\ Command ; use  Cake\Console\ ConsoleIo ; use  Cake\Console\ ConsoleOptionParser ; use  Cake\Http\ Client ; use  Cake\Log\ Log ; //need this two line use  Cake\Controller\ ComponentRegistry ; use  App\Controller\Component\ FirebaseComponent ; class   AppCommand   extends   Command {      protected   function   buildOptionParser ( ConsoleOptionParser  $parser) :   ConsoleOptionParser     {         $parser -> addArgument ( 'command' , [ 'help'   =>   'What your parameter?' ]);         $parser -> addArgument ( 'params' , [ 'help'   =>   'What your parameter?' ]);          return  $parser;     }      public   function   execute ( Arguments  $args,  ConsoleIo  $io

LIMIT SSH ACCESS BY COUNTRY

Image
This is useful when being attack of constant login brute-force attempts mainly from countries like China and Russia. Install GeoLite2 Country Database      $ sudo apt-get install geoip-bin Make sure that geoiplookup is working before implementing the script below.      $ geoiplookup 8.8.8.8 Create bash script that will filter ssh access by country.      $ sudo nano /usr/local/bin/sshfilter.sh      #!/bin/bash     # UPPERCASE space-separated country codes to ACCEPT     ALLOW_COUNTRIES="PH"     if [ $# -ne 1 ]; then       echo "Usage:  `basename $0` <ip>" 1>&2       exit 0 # return true in case of config issue     fi     COUNTRY=`geoiplookup $1 | awk -F ": " '{ print $2 }' | awk -F "," '{ print $1 }' | head -n 1`     [[ $COUNTRY = "IP Address not found" || $ALLOW_COUNTRIES =~ $COUNTRY ]] && RESPONSE="ALLOW" || RESPONSE="DENY"     if [ $RESPONSE = "ALLOW" ]     then       e

CakePHP 3/4 File Manager for CKEditor with Roxy Fileman

Image
Create plugins directory in your webroot directory. Download  CKEditor 4 Extract CKEditor inside webroot/plugins directory. Download latest Roxy Fileman  Extract Roxy Fileman inside webroot/plugins  directory. Create uploaded directory inside webroot directory. This is the folder which can be browsed and where the new files will be uploaded. Edit Roxy Fileman conf.json to finish your setup. Below configuration is based the directories we created. Set configuration option INTEGRATION to "ckeditor".  See the  Roxy Fileman configuration options  for details In your view/template add an element that CKEditor should replace:      Load CKEditor. Set these options when initializing CKEditor. All must point to index.html in the Fileman's installation directory. If you encounter this issue E_LoadingAjax /plugins/fileman/php/dirtree.php Comment verifyAction content in your functions.inc.php

How to set the timezone on Ubuntu Server

Image
You can check your current timezone by just running $ date Tue Feb  6 07:35:29 UTC 2018 You can set the timezone $ sudo timedatectl set-timezone Asia/Manila $ date Tue Feb  6 15:36:49 +08 2018

5 Ways to Leverage Facebook and Instagram Ads for Higher Mobile App Downloads

Image
Mobile apps have become an integral part of marketing for brands across industry verticals. With an application, businesses can create a direct connection to their audience to increase engagement and brand awareness. In order to convince consumers to install your mobile app, they have to know it exists, which is where Instagram and Facebook ads come in. A digital marketing agency with expertise in advertising mobile apps on these social media platforms can achieve a high level of success. This is especially true on Instagram, where most users view the platform on their phone. As a result, mobile app downloads happen more easily with just one tap. Instagram is also a newer ad platform, which means brand competition is lower than on Facebook. On the other hand, while consumers prefer ease of use, they also gravitate toward familiar platforms like Facebook. For businesses, this means access to a larger, varied audience. The following tips will assist you in making decisi

Using components in Cakephp 3+

Image
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 <?php namespace App\Shell ; use Cake\Console\Shell ; use Cake\Controller\Component ; use Cake\Controller\ComponentRegistry ; use App\Controller\Component\YourComponent ; class YourShell extends Shell { public function initialize () { parent :: initialize (); $this -> Your = new YourComponent ( new ComponentRegistry ()); } public function yourMethod () { $this -> Your -> component_method ($params1); } } ?>