Tuesday, 15 September 2020

notification onesignal react native

 Notification One Siganal ---------------------------------


https://www.youtube.com/watch?v=S2ubIsjdKgk&t=129s

 https://bitbucket.org/shagun123/react-native-one-signal/src/master/

 https://documentation.onesignal.com/docs/react-native-sdk-setup


cmd : 

yarn add react-native-onesignal

npx react-native link react-native-onesignal



1. App.js

import OneSignal from 'react-native-onesignal';

//export default class App extends Component {


componentDidMount() {

        OneSignal.init('81a9dced-2283-4acf-985a-79c6d552119b');

        OneSignal.addEventListener('received', (data) => {

            console.log(data);

        });

        OneSignal.inFocusDisplaying(2);

    }


    componentWillUnmount() {

        OneSignal.removeEventListener('received');

    }



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

2. android\app\src\main\AndroidManifest.xml

<application ....>
  <activity
    android:name=".MainActivity"
    android:label="OneSignal Example"
    android:launchMode="singleTask"> <!-- Add this attribute to your main activity -->
  </activity>

3. android\app\build.gradle

apply plugin: "com.android.application"

import com.android.build.OutputFile
after top 2 line add code
buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal 
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.6, 0.99.99]'
    }
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

Tuesday, 8 September 2020

React Native Doc

 1. Build expo react native app  [ .apk .abb]

Video : https://www.youtube.com/watch?v=ueJjgLbWxsY


Expo URL:

https://expo.io/ 

https://expo.io/signup 

https://expo.io/login


Start Application 

cmd : expo start Build apk 

cmd : expo build:android

 

Tuesday, 1 September 2020

Splash Screen in Android

 File : SplashActivity.Java


Thread thread = new Thread()

        {

            public void run()

            {

                try

                {

                    sleep(2000);

                    Intent intent = new Intent(getApplicationContext(), MainActivity.class);

                    startActivity(intent);

                }

                catch (InterruptedException e)

                {

                    e.printStackTrace();

                }

            }

        };

        thread.start();



File : menifest.xml


<activity android:name=".MainActivity"></activity>

        <activity android:name=".SplashActivity">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

 </activity>


Demo https://www.youtube.com/watch?v=G6f6lm3ZCTU



Friday, 28 August 2020

Post data in API

  <head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

</head> 


<h1>Device Id Send with API</h1>


<div id="result">

....

</div>


<button>Add Device Id</button>

<script>

    $(document).ready(function () {

    

       $("button").click(function(){

            

                $('#result').html("");

                 

                $.ajax({

                    type: "POST",

                    url: "http://seemacollegeparbatsar.org/api/notification",

                    data: {'device_id': 'aaaaaa1'},

                    dataType: "json",

                     

                    success: function (data) {

                         

                        

                        $('#result').append(data);

 

                    } 

                });

             

        });

    });

</script>


Full Demo : https://www.itsolutionstuff.com/post/codeigniter-3-restful-api-tutorialexample.html

Code Download : https://drive.google.com/file/d/1Xj9oTWvOFj5UrJh91BD4tKyc9gzX4XRB/view?usp=sharing

Tuesday, 18 August 2020

Using .htaccess to restrict access to Files and Directories

 

1. Deny Access to .htaccess Itself

Add the following lines in your .htaccess file to prevent access to .htaccess file itself.

# Deny access to .htaccess
<Files .htaccess>
Order allow,deny
Deny from all
</Files>


2. Disable Directory Indexing

The following line in .htaccess will remove directory indexing and make the server respond with a 403 forbidden message.

# Disable directory browsing 
Options -Indexes

To simply hide all the contents of the directory without forbidden message, use the IndexIgnore directive.

# Hide the contents of directories
IndexIgnore *

To hide some filetypes only, use

# Hide files of type .png, .zip, .jpg, .gif and .doc from listing
IndexIgnore *.png *.zip *.jpg *.gif *.doc

3. Prevent access to certain files

Even if you remove directories and files from listing, they are still accessible if you type the path.

To remove unauthorized access to cetain file extensions, use

# Deny access to files with extensions .ini, .psd, .log, .sh
<FilesMatch "\.(ini|psd|log|sh)$">
Order allow,deny
Deny from all

</FilesMatch>

To prevent access to all filenames starting with dot(.) like .htaccess, .htpasswd, .env and others use

# Deny access to filenames starting with dot(.)
<FilesMatch "^\.">
Order allow,deny
Deny from all
</FilesMatch>

You may also password protect files and directories and store the passwords in a .htpasswd file

# Password protect files
<FilesMatch "^(execute|index|myfile|anotherfile)*$">
AuthType Basic
AuthName "Mypassword"
AuthUserFile <Full Server Path to .htpasswd file>/.htpasswd
Require valid-user
</FilesMatch>

Directory data calculation in MB

 <?php 

/* Directory data calculation in MB */

function folderSize ($dir)

{

    $size = 0;

    foreach (glob(rtrim($dir, '/').'/*', GLOB_NOSORT) as $each) {


 


        $size += is_file($each) ? filesize($each) : folderSize($each);

    }

    return $size;

}


?>

<?php 

$newsDIR =  folderSize("/home/apnaaagaz00/public_html/media");

echo round(($newsDIR/1024/1024)).' Mb';

?>

Thursday, 30 July 2020

date time zone in php

              date_default_timezone_set('Asia/Kolkata');
              $dateTime = date('Y-m-d H:i:s');

Monday, 27 July 2020

session destroy after some time in php



<?php
// 2 hours in seconds
$inactive = 7200; 
ini_set('session.gc_maxlifetime', $inactive); // set the session max lifetime to 2 hours

session_start();

if (isset($_SESSION['testing']) && (time() - $_SESSION['testing'] > $inactive)) {
    // last request was more than 2 hours ago
    session_unset();     // unset $_SESSION variable for this page
    session_destroy();   // destroy session data
}
$_SESSION['testing'] = time(); // Update session
?>

Wednesday, 17 June 2020

count all with where condition in codeiginter sql

Model :
public function getRowcountCardGallery($id){
       
        return $this->db->where('card_id',(int)$id)->from("card_gallery")->count_all_results();
    }

Controller :
$data['rowcount']=$this->Myaccount_model->getRowcountCardGallery($id);

View : 
<?php if(isset($rowcount) && $rowcount!=''){
   
    echo $rowcount;

}


?>

Friday, 12 June 2020

left to right animation

<!DOCTYPE html>
<html>
<head>
<style>
div {
  width: 100px;
  height: 100px;
  background: red;
  position: relative;
  animation: myfirst 5s 2;
  animation-direction: alternate;
}

@keyframes myfirst {
  0%   {background: red; left: 0px; top: 0px;}
  25%  {background: yellow; left: 100px; top: 0px;}
  50%  {background: blue; left: 200px; top: 0px;}
  75%  {background: green; left: 100px; top: 0px;}
  100% {background: red; left: 0px; top: 0px;}
}
</style>
</head>
<body>

<h1>The animation-direction Property</h1>

<p>Play the animation forwards first, then backwards:</p>
<div></div>
<p><strong>Note:</strong> The animation-direction property is not supported in Internet Explorer 9 and earlier versions.</p>

</body>
</html>

Saturday, 6 June 2020

product detail simple Zoom

Demo : https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_image_zoom

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {box-sizing: border-box;}

.img-zoom-container {
  position: relative;
}

.img-zoom-lens {
  position: absolute;
  border: 1px solid #d4d4d4;
  /*set the size of the lens:*/
  width: 40px;
  height: 40px;
}

.img-zoom-result {
  border: 1px solid #d4d4d4;
  /*set the size of the result div:*/
  width: 300px;
  height: 300px;
}
</style>
<script>
function imageZoom(imgID, resultID) {
  var img, lens, result, cx, cy;
  img = document.getElementById(imgID);
  result = document.getElementById(resultID);
  /*create lens:*/
  lens = document.createElement("DIV");
  lens.setAttribute("class", "img-zoom-lens");
  /*insert lens:*/
  img.parentElement.insertBefore(lens, img);
  /*calculate the ratio between result DIV and lens:*/
  cx = result.offsetWidth / lens.offsetWidth;
  cy = result.offsetHeight / lens.offsetHeight;
  /*set background properties for the result DIV:*/
  result.style.backgroundImage = "url('" + img.src + "')";
  result.style.backgroundSize = (img.width * cx) + "px " + (img.height * cy) + "px";
  /*execute a function when someone moves the cursor over the image, or the lens:*/
  lens.addEventListener("mousemove", moveLens);
  img.addEventListener("mousemove", moveLens);
  /*and also for touch screens:*/
  lens.addEventListener("touchmove", moveLens);
  img.addEventListener("touchmove", moveLens);
  function moveLens(e) {
    var pos, x, y;
    /*prevent any other actions that may occur when moving over the image:*/
    e.preventDefault();
    /*get the cursor's x and y positions:*/
    pos = getCursorPos(e);
    /*calculate the position of the lens:*/
    x = pos.x - (lens.offsetWidth / 2);
    y = pos.y - (lens.offsetHeight / 2);
    /*prevent the lens from being positioned outside the image:*/
    if (x > img.width - lens.offsetWidth) {x = img.width - lens.offsetWidth;}
    if (x < 0) {x = 0;}
    if (y > img.height - lens.offsetHeight) {y = img.height - lens.offsetHeight;}
    if (y < 0) {y = 0;}
    /*set the position of the lens:*/
    lens.style.left = x + "px";
    lens.style.top = y + "px";
    /*display what the lens "sees":*/
    result.style.backgroundPosition = "-" + (x * cx) + "px -" + (y * cy) + "px";
  }
  function getCursorPos(e) {
    var a, x = 0, y = 0;
    e = e || window.event;
    /*get the x and y positions of the image:*/
    a = img.getBoundingClientRect();
    /*calculate the cursor's x and y coordinates, relative to the image:*/
    x = e.pageX - a.left;
    y = e.pageY - a.top;
    /*consider any page scrolling:*/
    x = x - window.pageXOffset;
    y = y - window.pageYOffset;
    return {x : x, y : y};
  }
}
</script>
</head>
<body>

<h1>Image Zoom</h1>

<p>Mouse over the image:</p>

<div class="img-zoom-container">
  <img id="myimage" src="img_girl.jpg" width="300" height="240">
  <div id="myresult" class="img-zoom-result"></div>
</div>

<p>The image must be placed inside a container with relative positioning.</p>
<p>The result can be put anywhere on the page, but must have the class name "img-zoom-result".</p>
<p>Make sure both the image and the result have IDs. These IDs are used when a javaScript initiates the zoom effect.</p>

<script>
// Initiate zoom effect:
imageZoom("myimage", "myresult");
</script>

</body>
</html>

image on click popup box like lighbox

Demo : https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal_img

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: Arial, Helvetica, sans-serif;}

#myImg {
  border-radius: 5px;
  cursor: pointer;
  transition: 0.3s;
}

#myImg:hover {opacity: 0.7;}

/* The Modal (background) */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  padding-top: 100px; /* Location of the box */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
}

/* Modal Content (image) */
.modal-content {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
}

/* Caption of Modal Image */
#caption {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
  text-align: center;
  color: #ccc;
  padding: 10px 0;
  height: 150px;
}

/* Add Animation */
.modal-content, #caption {
  -webkit-animation-name: zoom;
  -webkit-animation-duration: 0.6s;
  animation-name: zoom;
  animation-duration: 0.6s;
}

@-webkit-keyframes zoom {
  from {-webkit-transform:scale(0)}
  to {-webkit-transform:scale(1)}
}

@keyframes zoom {
  from {transform:scale(0)}
  to {transform:scale(1)}
}

/* The Close Button */
.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
}

.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}

/* 100% Image Width on Smaller Screens */
@media only screen and (max-width: 700px){
  .modal-content {
    width: 100%;
  }
}
</style>
</head>
<body>

<h2>Image Modal</h2>
<p>In this example, we use CSS to create a modal (dialog box) that is hidden by default.</p>
<p>We use JavaScript to trigger the modal and to display the current image inside the modal when it is clicked on. Also note that we use the value from the image's "alt" attribute as an image caption text inside the modal.</p>

<img id="myImg" src="img_snow.jpg" alt="Snow" style="width:100%;max-width:300px">

<!-- The Modal -->
<div id="myModal" class="modal">
  <span class="close">&times;</span>
  <img class="modal-content" id="img01">
  <div id="caption"></div>
</div>

<script>
// Get the modal
var modal = document.getElementById("myModal");

// Get the image and insert it inside the modal - use its "alt" text as a caption
var img = document.getElementById("myImg");
var modalImg = document.getElementById("img01");
var captionText = document.getElementById("caption");
img.onclick = function(){
  modal.style.display = "block";
  modalImg.src = this.src;
  captionText.innerHTML = this.alt;
}

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
  modal.style.display = "none";
}
</script>

</body>
</html>

Wednesday, 3 June 2020

Checkbox style css

Css : 
/*  check box css */

 .containercheckbox {
  display: block;
  position: relative;
  padding-left: 30px;
  margin-bottom: 12px;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none; 
}

/* Hide the browser's default checkbox */
.containercheckbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

/* Create a custom checkbox */
.checkmark {
  position: absolute;
  top: 7;
  left: 0;
  height: 15px;
  width: 15px;
  background-color: #04B19E;
  border-radius: 4px;
}

/* On mouse-over, add a grey background color */
.containercheckbox:hover input ~ .checkmark {
  background-color: #04B19E;
}

/* When the checkbox is checked, add a blue background */
.containercheckbox input:checked ~ .checkmark {
  background-color: #04B19E;
}

/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

/* Show the checkmark when checked */
.containercheckbox input:checked ~ .checkmark:after {
  display: block;
}

/* Style the checkmark/indicator */
.containercheckbox .checkmark:after {
  left: 5px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 3px 3px 0;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}


HTML : 
<label class="containercheckbox col-sm-2 col-form-label">Vital
  <input type="checkbox" name="vital_check" value="1" class="is_checked" checked="checked">
  <span class="checkmark"></span>
</label>