Thursday, 22 April 2021

HTACCESS + PHP | Forcefully Add Ending Slash (/) In URL On Rewrite Rule

 


You can download the whole folder from:
https://unpossiblepog.com/codes/PHP+HTACCESS/HTACCESS-Forcefully-Add-Slash-At-The-End-Of-URL

.htaccess
RewriteEngine on

RewriteRule ^([^\.]+)/$ $1.php [NC,L]

ErrorDocument 404 http://%{HTTP_HOST}/<project-folder>/error.php?ref=%{HTTP_HOST}%{REQUEST_URI}

-----------------------------------------
error.php

<?php

if(isset($_GET['ref'])) {

$path_name=$_GET['ref'];

$file_name_array=explode("?", $path_name);

//echo $this_path."<br/>";

//echo $file_name_array[0]."<br/>";

if(isset($_SERVER['HTTPS'])){$http_https = "https://";}else{$http_https = "http://";}

$file_name=$http_https.$file_name_array[0];

header("location: ".$file_name."/");

  //echo $file_name."<br/>";

}

?>

-----------------------------------------
index.php

<h1>This is INDEX file.
</h1>
-----------------------------------------

about.php

<h1>This is About page.</h1>
-----------------------------------------
hello.php

<h1>This is hello page.</h1>

=======================


Subscribe my Channel:- http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:- https://www.facebook.com/UnpossibleNS

Twitter Account:- https://twitter.com/UnpossiblePOG

Blog :- https://unpossiblepog.blogspot.in/

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

Hey guys, we shall create a code to force browser to add slash at the end of URL using HTACCESS and PHP.


Make sure to use INCOGNITO mode while implementing this because sometimes the HTACCESS code remains in a cookies which won’t help to run the updated code of HTACCESS.


Currently in folder, we have some PHP files, each file contains some text.


And we have the REWRITE RULE in HTACCESS file which will allow you to run the file without using the “.php” extension. And the rule contains an ending slash in first parameter.

So if you enter the URL without extension and end with slash, it will run that page.

But if you remove the ending slash, it will give you a 404 error. The best solution is to forcefully add ending slash in URL using the code.

So in HTACCESS, write the following code, code link is given in the description.

Notice that this file is inside the “tutorial” folder which is inside HTDOCS folder of xampp.

You have to add the URL accordingly.

So I have already created an error.php page which will forcefully add slash. Code is given in the description.

Our strategy is to send the current URL as a request parameter when error occurs.

And as you can see, it redirects and ends with slash.

So that is it, thanks for watching. Like share and subscribe.


Tuesday, 6 April 2021

Clone Private Github Repository Files Inside Live Website With CPANEL, GIT VERSION CONTROL & SSH


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

Putty:- https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

SSH Keygen command:-
ssh-keygen -t rsa -b 4096 -C "username@servername"


Subscribe my Channel:- http://www.youtube.com/user/SanketRooney?sub_confirmation=1


Facebook Page:- https://www.facebook.com/UnpossibleNS


Twitter Account:- https://twitter.com/UnpossiblePOG


Blog :- https://unpossiblepog.blogspot.in/

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

In this video, we shall make a connection between private github repository and live cpanel.

First you must have a domain with cpanel and a github account.

I purchased a domain+cpanel from godaddy. You can choose your own hosting providers but make sure that the SSH access is enabled. For godaddy users, here is the path to find and enable SSH access.

Next, open github, login into your account, or create account if you don’t have one.

Click on plus icon which is before your profile pic, click on new repository.

Give any random name.

You can make repository as private from here or if you forgot to make it private, you can make it afterward.

Just go to settings tab, scroll down, you will see, “Change repository visibility”, click on a button in front of it and can click on private and save it.

Now, login into your domain’s cpanel.
Then open PUTTY. If you don’t have it, download link is given in the description. Install it.

Now copy the IP address from cpanel dashboard.
Paste it in HOST NAME textbox, make sure that the SSH radio button is selected, then click on OPEN.

It will open a command prompt.

Type the username which you use for login into cpanel.

Hit enter.

Now type the cpanel’s login password.
When you type the password, it will not show anything on command prompt, but whatever you are typing is getting stored in the background.

Once you logged in, you will see something like this.

Once connected, you will have to type the command to create public and private key.

It will be given in the description.

In double quote, type username@servername.

Keep the filename & passphrase empty.

Now, go to cpanel and SSH ACCESS : MANAGE SSH KEYS.

You will see the newly created keys there.

Click on MANAGE of the public key, AUTHORIZE it.

Let’s jump to github, open your repository and click on settings tab, then DEPLOY KEYS. Then ADD DEPLOY KEY.

Give any key name.

For public key, go to cpanel, and click on VIEW/DOWNLOAD link in front of public key.

Copy it from start to end and paste it in github’s key textarea.
Check the ALLOW WRITE ACCESS, Of course we already can download files from github to cpanel by default. But giving the WRITE ACCESS means, you can upload changes from cpanel to github.

Once done, open the putty command prompt, type the following command to check if the domain can be connected to github or not.

Now we are successfully authenticated.

From github, lets create a new file. Type anything there. Give it any random name.
Scroll down and commit the change.

You will have a new file in your repository.

Go to cpanel dashboard, click on git version control, then CREATE.

Now open github, click on code, then click on SSH tab, copy the text from the textbox.

Paste it in CLONE URL textbox of cpanel.

For repository path, you can not add those folders which not empty.

For example if I add public_html folder which already has so many files and try to clone it, it will give me an error.

So you can either empty the public_html folder or create a new empty folder which is what I am going to do.

Now you can create a clone of private github repository.

You will be redirected to GIT repository listing. Click on the MANAGE button.

And click on PULL OR DEPLOY.

You will see that those UPDATE AND DEPLOY buttons are disabled.

First, lets check if our original file is copied to our website’s directory by going to the FILE MANAGER.

The file is there and it contains the text that we typed.

Let’s do some changes in github file and try to reflect it to our live site.

To synchronize or pull the changes, lets go to CPANEL’s dashboard : Git version control : MANAGE : PULL OR DEPLOY and click on UPDATE FROM REMOTE.

Lets again go to file manager, and view the file.
Changes are reflected there.

So that is it, thanks for watching. Like share and subscribe.



Sunday, 28 March 2021

Flutter | Convert Database Table's Data Into Row-Map And Display Rows In Flutter Table

 


You can download project from : 

https://unpossiblepog.com/codes/DART+FLUTTER/Flutter-And-Dart-Convert-SQFLITE-Data-Into-Map-And-Display-That-Data-In-Table-UI

Note : Watch the video if you are confused to you want to see the practical approach of instructions which are given below.

########## START ##########

1. Copy-paste the following code just after the declaration of class which is extending the state.

List employeeFinalList;


2. Copy-paste following function just before the ending curly bracket of the same class which is extending the state.

void fixOutputInRows(List<Map<String, dynamic>> emp_data)

{


    var columns=new List();

    var rows_values=new List();

    var properDataArray=new List();

    String first_column="";

    int loop_run=1;

    columns=[];

    rows_values=[];

    properDataArray=[];


    for(var i=0;i<emp_data.length;i++)

    {

      int col_position=0;

      int found_all_colums=0;

      Map m=emp_data[i];

      m.forEach((k,v) =>

      {

        if(loop_run==1)

          {

            first_column='${k}',

          },

        if(loop_run>1 && first_column=='${k}')

          {

            found_all_colums=1,

          },

        if(found_all_colums!=1)

          {

            columns.add('${k}'),

          },

        if(loop_run==1)

        {

          loop_run++,

        },


        rows_values.add('${v}'),

      }

      );

    }


    var added_rows=0;

    double total_rows=0;

    if(columns.length>0)

    {

      total_rows=(rows_values.length/columns.length) as double;

    }

    //print("Total rows : "+(total_rows).toString());


    int value_get_count=0;

    for(var i=0;i<total_rows;i++)

    {

      Map temp_array={};

      for(var j=0;j<columns.length;j++)

      {

        temp_array[columns[j]]=rows_values[value_get_count];

        value_get_count++;

      }

      properDataArray.add(temp_array);

    }

    print(properDataArray);


    if(total_rows>0)

      {

        setState((){

          this.employeeFinalList = properDataArray;

        });

      }


  

}



3. Call that function just after the “for loop” where we can are getting the data from database table.

fixOutputInRows(emp_data);


4. Remove the whole “Center” function and copy-paste the following the code, make sure that it ends with comma (,)


Column(children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: getDynamicTable(),
)])


5. Add the following code just after the ending curly bracket of “Widget build(BuildContext context)”

Table getDynamicTable() {

List<TableRow> rows = [];

 rows.add(TableRow(children: [
Text("Id"),
Text("Name"),
Text("Address"),
]));

if(employeeFinalList!=null)
{
for (int i = 0; i < this.employeeFinalList.length; ++i) {
rows.add(TableRow(children: [
Text(""+employeeFinalList[i]['id'].toString()),
Text("" + employeeFinalList[i]['name'].toString()),
Text("" + employeeFinalList[i]['address'].toString()),
]));

}
}
return Table(
border:TableBorder.all(width: 2.0,color: Colors.black),
columnWidths: {
0: FixedColumnWidth(100.0),
0: FixedColumnWidth(100.0),
1: FlexColumnWidth(),
},
children: rows,

);
}


6. If you want data to be displayed as soon as the app is loaded, then add the following code inside the curly bracket of “Widget build(BuildContext context)

if(employeeFinalList==null)
{
DBConDisplay();
}




Previous flutter tutorial (Flutter Database Connection):- https://youtu.be/S95X7Jp7xeM


Code Link:- https://unpossiblepog.blogspot.com/2021/03/show-database-table-rows-in-flutter-table-ui.html

Subscribe my Channel:- http://www.youtube.com/user/SanketRooney?sub_confirmation=1


Facebook Page:- https://www.facebook.com/UnpossibleNS


Twitter Account:- https://twitter.com/UnpossiblePOG


Blog :- https://unpossiblepog.blogspot.in/

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

In my last flutter database tutorial, I displayed data from table but in columns rather than rows.

This tutorial is a continuation of the previous tutorial.
In this video, we shall display data in flutter table. This tutorial is divided into 2 phases.

Phase 1 is where we are converting data from separate columns into map.

In phase 2, we are displaying those map values in table rows.

If you already have the map structure ready, then skip to phase 2.


Also, I provided the code link in the description, you just have to copy-paste the code as per the instructions.


1st point says, we have to copy-paste the line just after the declaration of a class which is extending the STATE.


2nd point is to copy-paste the whole code just before the ending curly bracket of the same class which is extending the State.


3rd point is to, paste this line after the for loop inside the function which we created to get table data. In my case, the function name is DBConDisplay.


Now, lets refresh the project and see if there map is displaying the data or not.


If the map is displaying in a proper format, it means that our first phase is complete.


In second phase, we shall be adding that map inside flutter table.


So according to the 4th point, remove the CENTER function completely and add the code given in the 4th point. Make sure to add comma at the end of the code where you pasted that function.


As you can see, android studio shows an error at getDyanamicTable function because we haven’t created that function yet.


From 5th point, copy the code and paste it just after the ending curly bracket of widget build function.


Save it.

Now if you have HOT RELOAD enabled, you will see the table appeared on ANDROID SIMULATOR screen. If not, don’t worry. Just go to the 6th point.


From 6th point, copy the code and paste it inside widget build’s curly bracket.


Now, refresh the app, it will display the data as soon as the app loads.


I added some unnecessary texts here, I shall remove it from the document.


So that is it, thanks for watching. Like share and subscribe.



Tuesday, 23 February 2021

Flutter Database Connection Using Dart, Android Studio & SQFLITE | Copy-Paste Code



You can download project from : 
https://unpossiblepog.com/codes/DART+FLUTTER/Flutter-And-Dart-Convert-SQFLITE-Data-Into-Map-And-Display-That-Data-In-Table-UI


Note : Watch the video if you are confused to you want to see the practical approach of instructions which are given below.

########## START ##########

 1. In “pubspec.yaml” file, inside “dependencies”, after “flutter”, paste the following code (make sure that following code should be at the same level as “flutter”):


sqflite: any #stable version at the time of publishing this article

path_provider: any #stable version at the time of publishing this article

intl: ^0.15.7

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

2. Create “database_connector.dart” file at the level of "main.dart" (or at any place which contains dart files )

Then paste the following code in “database_connector.dart” file:


import 'package:sqflite/sqflite.dart';

import 'dart:async';

import 'dart:io';

import 'package:path_provider/path_provider.dart';


class DatabaseConnect{

static Database _database;


Future<Database> get database async {


if (_database == null) {

_database = await initializeDatabase();

}

return _database;

}


Future<Database> initializeDatabase() async {

Directory directory = await getApplicationDocumentsDirectory();

String path = directory.path + 'tutorialdb.db';


var notesDatabase = await openDatabase(path, version: 1, onCreate: createTable);

return notesDatabase;

}


void createTable(Database db, int newVersion) async {


await db.execute('CREATE TABLE employee(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, address TEXT)');

}


Future<int> insertStatic() async {

Database db = await this.database;

var result = await db.rawInsert("INSERT INTO employee(name,address) VALUES('steve rogers','brooklyn')");

return result;

}


Future<List<Map<String, dynamic>>> getList() async {

Database db = await this.database;

var result = await db.rawQuery('SELECT * FROM employee order by id ASC');

return result;

}


}


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

3. Then in "main.dart" file, paste the following at top of page below other imports:


import 'dart:async';

import 'package:<your_app_name+path_if_database_connector_is_inside_folder>/database_connector.dart';

import 'package:sqflite/sqflite.dart';

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


4. Then in “main.dart” file, just above the end bracket of class (which extends state), paste the following code:



void JustPrint()

{

print('wow');

}


void DBConInsert(){

DatabaseConnect con = DatabaseConnect();


final Future<Database> dbFuture = con.initializeDatabase();

dbFuture.then((database) {

Future<int> noteListFutureInsert = con.insertStatic();

noteListFutureInsert.then((noteList) {

print(noteList);

});

});


}

void DBConDisplay(){

DatabaseConnect con = DatabaseConnect();


List<Map<String, dynamic>> list=[];

final Future<Database> dbFuture = con.initializeDatabase();

dbFuture.then((database) {


Future<List<Map<String, dynamic>>> noteListFuture = con.getList();

noteListFuture.then((emp_data) {


for(var i=0;i<emp_data.length;i++)

{

Map m=emp_data[i];

m.forEach((k,v) => print('${k}: ${v}'));

}


});

});


}



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


5. If you have a button, then it is good, otherwise add the button. And onPressed of that button, add “JustPrint”

(JustPrint is a normal/temporary function which we pasted in main.dart file, it only prints ‘wow’ in console)


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


6. Then open the console in ANDROID STUDIO (4. Run), run the project and click on button.

If you see ‘wow’ in console, then it is good. Otherwise, check the process again to see if any step is missing.


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


7. If it is displaying ‘wow’, remove the ‘JustPrint’ after ‘onPressed’, and add ‘DBConInsert’ instead.

Save it. Refresh the project. Then click on button only once.

It will insert a new row in database table and display id in console.


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


8. If above step works, remove ‘DBConInsert’ and add ‘DBConDisplay’, then again click on button.

Save it. Refresh the project. Then click on button.

It will display data columnwise.


########## END ##########


IGNORE THE INFORMATION GIVEN BELOW WHICH IS MORE DETAILED VERSION OF ABOVE INSTRUCTIONS.

Subscribe my Channel:- http://www.youtube.com/user/SanketRooney?sub_confirmation=1


Facebook Page:- https://www.facebook.com/UnpossibleNS


Twitter Account:- https://twitter.com/UnpossiblePOG


Blog :- https://unpossiblepog.blogspot.in/


Hey guys, now we shall be connecting the flutter app with database and Insert data. Also we shall display a data but only in console as our main aim is to connect database on SQFLITE.

Now, I created a blog which contains steps & code. Link is given in the description. Then you just have to follow my steps as per the video.


First, we shall create a new flutter application. I am using Android studio.


Observe that in project explorer, there is a “lib” folder and inside it is a dart file.


Now, the first step is to copy code from 1st point and open “pubspec.yaml” and paste code inside dependencies but at the same level as flutter text.


Then a bulb symbol will appear. Click on “pub get”. It shall download dependencies.

Or you can click on the link which appeared at the top side of window.


Lets run an ANDROID SIMULATOR and RUN the project. It will take several minutes to run the project first time.


Once ran, click on the bottom button which increases the CLICK COUNT and displays on screen.


In second step, we have to create a dart file with any name. I would prefer database_connector.dart. Make sure that it should be created inside “LIB” folder.

If you so desire, you can create a package folder and add that file inside it just like I am doing in this video.


Copy-paste the whole code from point 2 and paste it in database_connector.dart file.


In third step, you have to import that file & other libraries.

So paste the code at the top of main.dart file.


Then you need to give specific location of database_connector file. That is, your project name which in my case is “”tutorial1, then /, then package name if you database connector file is inside it, then /, then database connector file name.


Copy the code from 4th point,

Go to the ending curly bracket of class which is extending STATE class.

Paste the code just above the ending curly bracket.


5th point is to call a simple function called JustPrint on press of a button.

SAVE all files, Refresh the app. Or enable the HOT RELOAD.

The navigator for RUN Console is available at the bottom of android studio. As you can see that this function is only printing the text in RUN CONSOLE.


6th point is just that.


Now in 7th point, we have to call DBConInsert on button’s press event. That function will create a database, an employee table and insert one row.


SAVE IT and DO REFRESH if you don’t have HOT RELOAD.


Once clicked on button, it will display a new ID’s value in console.


Sometimes you may get this error. Just simply close SIMULATOR and ANDROID STUDIO OR VISUAL STUDIO CODE and restart them. And do this step again.


Now,, if you get an ID on click of button, go to 8th and last step. And copy DBCONDISPLAY function and paste it at on press event of button.


Click on button and you will get all the data in console. Lets insert new row. And display them again to confirm.


Now you can play around with code and you can figure out how the code works.


So that is it, thanks for watching. Like share and subscribe.



Tuesday, 5 January 2021

Filmora X : Download Free Effects From Filmstock | For Licensed User Only



Filmstock link : https://filmstock.wondershare.com/


-------------------------------
Subscribe my Channel:- http://www.youtube.com/user/SanketRooney?sub_confirmation=1


Facebook Page:- https://www.facebook.com/UnpossibleNS


Twitter Account:- https://twitter.com/UnpossiblePOG


Blog :- https://unpossiblepog.blogspot.in/

-------------------------------
Hey guys, in this video, we are going to download some free effects in WONDERSHARE Filmora X. Before I start, one thing to let you know is that this video is only for those who purchased a license for this product. Means it is not for CRACKED VERSION.


I have 1 clip and there are some effects already present however you can download some extras legally.

Open the browser and search filmstock wondershare.

Go to filmstock.wondershare.com link.

Now click on JOIN FREE.

Click on “CREATE ACCOUNT” on free column.

You can register and you may get verification email.

However I already created one account so I shall click on login.

I don’t know why they ask you to login twice but any ways.

Login and then click on effects menu.

You can see the green circle which means that effect is free.

I shall find other one because I already downloaded it.

Here is one called 2D Business Pack.

You will see FREE DOWNLOAD button. Click on it.

Then click on OPEN of popup button. Some browsers may show different text instead of OPEN, so click on button other than CLOSE.

It will open filmora’s window and it will start downloading.

It says there are 9 title, 20 elements, 3transitions and 5 overlays.

After that, close this window.

Now if you check EFFECTS tab, you will see a new menu called 2D Business pack.

You can drag-and-drop those effects.

Also in TITLES tab, click on newly downloaded menu, and put any one on video.

Same goes for TRANSITIONS and ELEMENTS.


So that is it, thanks for watching.

Sunday, 8 November 2020

Mysql | Order By Comparing Multiple Columns & Ignore Specific Value While Sorting | Greatest & Least



> SELECT *,greatest(maturity,death) as insurance_date FROM `insurance` order by insurance_date DESC

> SELECT *,least(maturity,if(death='0000-00-00 00:00:00',maturity,death)) as insurance_date FROM `insurance` order by insurance_date DESC


In MYSQL, GREATEST and LEAST are the functions which compares columns columns rather than rows. Best example is an Insurance company’s data where admins want to figure out the day a customer gets his/her money by comparing which date comes first, a maturity date or death date.


Subscribe my Channel:-

http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-

https://www.facebook.com/UnpossibleNS

Twitter Account:-

https://twitter.com/UnpossiblePOG

Blog :-

https://unpossiblepog.blogspot.in/

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

Hey guys, in this video I am going to sort the table by comparing multiple columns.

For example, I have an insurance table, and two columns, maturity and death have the date-time as data-type.

First we shall sort it by the maximum date among maturity and death, so we shall use the GREATEST function and add columns which will be compared.

We give that value of function as “insurance_date” and then use the  ORDER BY clause.

Now as you can see, it gives the output based on which date is maximum and sort accordingly.

However in insurance, the lowest date matters because company has to give money based on which date occurs first.

So for that we are going to use LEAST function.

But the problem is, if a person is not died then, of course the date field will be empty so the output is incorrect.

To fix that, we have to overwrite the the death date. We are going to use the IF condition inside LEAST function, and if death date is zero, we overwrite it with a maturity date. Also, Maturity Date shouldn’t be empty in any case.

And now we got the output we wanted.

Query link is given in the description.

Don’t forget to like, share and subscribe.Thanks for watching.