
How to install Composer in windows 7
In this articles I am going to show how to install composer in windows 7 First we have to download composer link is given below https://getcomposer.org/ Click on Run Click on …
Technical Blogs & News
Fix Email Issues in CyberPanel with SMTP Relay Setup Free Method. First Create a email using your Cyberpanel Under Emai Tab Create Email Second go to the SSL tab and click …
You’ve probably seen many examples of password strength indicators around the web. They let users know the password they’re using is weak and indicate how the strength changes when it’s modified. …
In this articles I am going to show how to install composer in windows 7 First we have to download composer link is given below https://getcomposer.org/ Click on Run Click on …
In this articles I am going to show how to install composer in windows 7
First we have to download composer link is given below
Click on Run
Click on Next
Select Installation path. here i have installed xampp in D drive. You should install xampp before installing Composer
And Select Checkbox on Press Next for continue
Click on Next
Click Install button and continue
Once Successfully installed open command prompt and check composer is installed or not like below
Thanks for reading…
How to create a multi-user auth system in Laravel 8. Different login for user and admin configuration Larave8. Let,s Start composer create-project –prefer-dist laravel/laravel UserRegistrationSystem cd /UserRegistrationSystem create .env file in …
How to create a multi-user auth system in Laravel 8. Different login for user and admin configuration Larave8.
Let,s Start
UserRegistrationSystem~/touch .env
DB_DATABASE=your databse name
DB_USERNAME=Your database username
DB_PASSWORD=Your database password
composer require laravel/breeze
php artisan breeze:install
npm install
npm run dev
php artisan migrate
php artisan serve
Now you can see in the right side top bar login and register link appear
Create model as named Admin and migrate table using below command
php artisan make:model Admin -m
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAdminsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('admins', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('admins');
}
}
Go to the Model folder and open the newly created Admin model and paste the below code
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class Admin extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var string[]
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
Now Set Route for Admin, go to the routes folder and open web.php file, and paste the below code
Route::namespace('Admin')->prefix('admin')->name('admin.')->group(function(){
Route::namespace('Auth')->group(function(){
//login route
});
});
Go to the providers folder and open RouteServiceProvider.php uncomment the line
// protected $namespace = 'App\\Http\\Controllers';
protected $namespace = 'App\\Http\\Controllers';
<?php
namespace App\Http\Controllers\Admin\Auth;
use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\LoginRequest;
use App\Providers\RouteServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AuthenticatedSessionController extends Controller
{
/**
* Display the login view.
*
* @return \Illuminate\View\View
*/
public function create()
{
return view('admin.auth.login');
}
/**
* Handle an incoming authentication request.
*
* @param \App\Http\Requests\Auth\LoginRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(LoginRequest $request)
{
$request->authenticate();
$request->session()->regenerate();
return redirect()->intended(RouteServiceProvider::ADMIN_HOME);
}
/**
* Destroy an authenticated session.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Request $request)
{
Auth::guard('web')->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return redirect('/');
}
}
Go to the providers folder and open the file RouteServiceProvider.php and paste the below code
public const ADMIN_HOME = '/admin/dashboard';
<x-guest-layout>
<x-auth-card>
<x-slot name="logo">
<a href="/">
<x-application-logo class="w-20 h-20 fill-current text-gray-500" />
</a>
Admin Login Page
</x-slot>
<!-- Session Status -->
<x-auth-session-status class="mb-4" :status="session('status')" />
<!-- Validation Errors -->
<x-auth-validation-errors class="mb-4" :errors="$errors" />
<form method="POST" action="{{ route('login') }}">
@csrf
<!-- Email Address -->
<div>
<x-label for="email" :value="__('Email')" />
<x-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email')" required autofocus />
</div>
<!-- Password -->
<div class="mt-4">
<x-label for="password" :value="__('Password')" />
<x-input id="password" class="block mt-1 w-full"
type="password"
name="password"
required autocomplete="current-password" />
</div>
<!-- Remember Me -->
<div class="block mt-4">
<label for="remember_me" class="inline-flex items-center">
<input id="remember_me" type="checkbox" class="rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" name="remember">
<span class="ml-2 text-sm text-gray-600">{{ __('Remember me') }}</span>
</label>
</div>
<div class="flex items-center justify-end mt-4">
@if (Route::has('password.request'))
<a class="underline text-sm text-gray-600 hover:text-gray-900" href="{{ route('password.request') }}">
{{ __('Forgot your password?') }}
</a>
@endif
<x-button class="ml-3">
{{ __('Log in') }}
</x-button>
</div>
</form>
</x-auth-card>
</x-guest-layout>
Go to the web.php file add route
Route::get('login','AuthenticatedSessionController@create')->name('login');
Now create a post for admin login
Route::post('login','AuthenticatedSessionController@store')->name('adminlogin');
Now go to the admin/auth/login.blade.php file and change the form action
<form method="POST" action="{{ route('admin.adminlogin') }}">
Create seed for admin using below command( we can manually import admin data but there will be password issue because we are inserted password has format).
php artisan make:seed AdminSeeder
AdminSeeder.php
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Admin;
class AdminSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
$admin =[
'name'=>'Admin',
'email'=>'admin@gmail.com',
'password'=> bcrypt('password')
];
Admin::create($admin);
}
}
Now we have seed the data into the database using below command
php artisan db:seed
Database seeding completed successfully.
we have to call DatabaseSeeder. Go to the DatabaseSeeder.php file and add the below code
public function run()
{
// \App\Models\User::factory(10)->create();
$this->call(AdminSeeder::class);
}
php artisan migrate:fresh --seed
below the use HasApiTokens, HasFactory, Notifiable;
protected $guard= 'admin';
Now go to the config folder and define the newly created Admin gurd on auth.php file.
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session"
|
*/
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,
];
Then go-to the Http→Middleware→RedirectIfAuthenticated.php and replace the below code
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null ...$guards
* @return mixed
*/
public function handle(Request $request, Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
if(Auth::guard($guard)->check()){
if($guard == 'admin'){
return redirect(RouteServiceProvider::ADMIN_HOME);
}
}
return redirect(RouteServiceProvider::HOME);
}
}
return $next($request);
}
}
dd($request->all());
Login with /login/admin
You can see successfully data has returned
<?php
namespace App\Http\Requests\Auth;
use Illuminate\Auth\Events\Lockout;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
class AdminLoginRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
];
}
/**
* Attempt to authenticate the request's credentials.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function authenticate()
{
$this->ensureIsNotRateLimited();
if (! Auth::guard('admin')->attempt($this->only('email', 'password'), $this->boolean('remember'))) {
RateLimiter::hit($this->throttleKey());
throw ValidationException::withMessages([
'email' => __('auth.failed'),
]);
}
RateLimiter::clear($this->throttleKey());
}
/**
* Ensure the login request is not rate limited.
*
* @return void
*
* @throws \Illuminate\Validation\ValidationException
*/
public function ensureIsNotRateLimited()
{
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
return;
}
event(new Lockout($this));
$seconds = RateLimiter::availableIn($this->throttleKey());
throw ValidationException::withMessages([
'email' => trans('auth.throttle', [
'seconds' => $seconds,
'minutes' => ceil($seconds / 60),
]),
]);
}
/**
* Get the rate limiting throttle key for the request.
*
* @return string
*/
public function throttleKey()
{
return Str::lower($this->input('email')).'|'.$this->ip();
}
}
Create a dashboard for admin
Route::get('dashboard','HomeController@index')->name('dashboard');
php artisan make:controller Admin/HomeController
For windows, user command will
php artisan make:controller Admin\HomeController
And Linux User command will
php artisan make:controller Admin/HomeController
HomeController.php
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class HomeController extends Controller
{
//
public function index()
{
return view('admin.dashboard');
}
}
Now you can see the error of Navigation
AdminLayout.php
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class AdminLayout extends Component
{
/**
* Get the view / contents that represents the component.
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('admin.layouts.app');
}
}
resources→views→admin→layouts→app.blade.php
@include('admin.layouts.navigation')
Note: Under the Admin -layouts folder open navigation.blade.php file and replace all dashboard to admin.dashboard and change {{ Auth::user()->name }} to {{ Auth::guard(‘admin’)->user()->email }}
And most important things to do
Open admin→dashboard.blade.php change <x-app-layout> to<x-admin-layout>
Now you can see I logged in as an admin but when I typed but still access the admin login page, So it should not access the page, now we will solve the issue.
<div class="flex justify-center pt-8 sm:justify-start sm:pt-0">
@auth('admin')
<a href="{{ route('admin.dashboard') }}"> Admin dashboard
@else
<a href="{{ route('admin.login') }}"> Admin Login
@endauth
</div>
Route::post('logout','Auth\AuthenticatedSessionController@destroy')->name('logout');
Now you can see I have logged in as an admin but still access the admin login page. So, it should not access if already logged in, So, for this solution, we create middleware and set configuration
php artisan make:middleware AdminMiddleware
Now got to the middleware folder and open AdminMiddleware.php file and paste below code
AdminMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Auth;
class AdminMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if(!Auth::guard('admin')->check()){
return redirect()->route('admin.lgin');
}
return $next($request);
}
}
Next, go to the web.php file and create a middleware group, and put the protected Url in a middleware group
Route::middleware('admin')->group(function(){
Route::get('dashboard','HomeController@index')->name('dashboard');
});
Now you can see the error Target class admin does not exist. because we have to register the path of admin middleware with kerlnel.php file
'admin'=> \App\Http\Middleware\AdminMiddleware::class;
Now you can see we can’t access the dashboard if I am not logged in but still we have another problem that is we can access the login page as I have already logged in. it should not access if I have already logged in. So we need to add middleware where login route running
middleware('guest:admin')
previous
Route::namespace('Admin')->prefix('admin')->name('admin.')->group(function(){
Route::namespace('Auth')->group(function(){
//login route
Route::get('login','AuthenticatedSessionController@create')->name('login');
Route::post('login','AuthenticatedSessionController@store')->name('adminlogin');
});
After
Route::namespace('Admin')->prefix('admin')->name('admin.')->group(function(){
Route::namespace('Auth')->middleware('guest:admin')->group(function(){
//login route
Route::get('login','AuthenticatedSessionController@create')->name('login');
Route::post('login','AuthenticatedSessionController@store')->name('adminlogin');
});
Thanks for reading…
In this article, I am going to show how to implement loadmore button using API and simple array data How to implement Load more button in React js from fetching API …
In this article, I am going to show how to implement loadmore button using API and simple array data
First, we will see how to implement load more buttons using array data then we will see API implementation
Create a React app using
npx create-react-app appname
import web from "../images/service.svg"
import app from "../images/s2.svg"
import android from "../images/s3.svg"
import digital from "../images/s4.svg"
import marketing from "../images/s5.svg"
import software from "../images/s6.svg"
const data = [
{
id: 1,
img: web,
title: "Web Development",
desc: 'desc 1'
},
{
id: 2,
img: app,
title: "Web Development",
desc: 'desc 2'
},
{
id: 3,
img: android,
title: "Android Development",
desc: 'desc 3'
},
{
id: 4,
img: digital,
title: "Digital Development",
desc: 'desc 4'
},
{
id: 5,
img: marketing,
title: "Marketing Development",
desc: 'desc 5'
},
{
id: 6,
img: software,
title: "Software Development",
desc: 'desc 6'
},
];
export default data
You can see I have import images from the image folder
Service.js
import React, { useState } from 'react';
// import data from './data'
import data from "../data"
const Service = () => {
const [noOfElement, setnoOfElement] = useState(4);
const loadmore = () => {
setnoOfElement(noOfElement + noOfElement);
}
const slice = data.slice(0, noOfElement);
return (
<div className="section-bg">
<section id="Service" className="py-4 container">
{/* <h1 className="my-4 display-5 text-center">Our Services</h1> */}
<div className="section-title">
{/* <h2>Clients</h2> */}
<p>Our Service</p>
</div>
<div className="row justify-content-center">
{slice.map((item, index) => {
return (
<div className="col-11 col-md-6 col-lg-3 mx-0 mb-4">
<div className="card p-0 overflow-hidden h-100 shadow">
<img src={item.img} className="card-img-top" alt="img" />
<div className="card-body">
<h5 className="card-title">{item.title}</h5>
<p className="card-text">{item.desc}</p>
</div>
</div>
</div>
)
})}
</div>
<button className="btn-get-service"
onClick={() => loadmore()}
>
Lodemore
</button>
</section>
</div>
);
};
export default Service
import React from "react";
import Service from "./Service"
export const Home = () => {
return (
<>
<Service />
</>
);
};
npm start
Our Load more button working successfully done
Now we are going to implement the same for API calliing
Service.js
import React, { useState,useEffect } from 'react';
// import data from "../data"
const Service = () => {
const [allData,setAllData]=useState([]);
const [petCount, setDataCount]= useState(4);
const loadmore =()=>{
setDataCount(allData.length)
};
useEffect(()=>{
fetch('http://127.0.0.1:8000/api/productlist')
.then ((res)=> res.json())
.then ((data)=>{
setAllData(data)
});
},[])
return (
<div className="section-bg">
<section id="Service" className="py-4 container">
<div className="section-title">
{/* <h2>Clients</h2> */}
<p>Our Service</p>
</div>
<div className="row justify-content-center" >
{allData.slice(0, petCount).map((pet, id) => (
<div className="col-11 col-md-6 col-lg-3 mx-0 mb-4">
<div className="card p-0 overflow-hidden h-100 shadow">
<img src={"http://127.0.0.1:8000/" + pet.file_path} className="card-img-top" alt="img" />
<div className="card-body">
<h5 className="card-title">{pet.ProductName}</h5>
<p className="card-text">{pet.description}</p>
</div>
</div>
</div>))}
</div>
<button className="btn-get-service"
onClick={() => loadmore()}
>
Lodemore
</button>
</section>
</div>
);
};
export default Service
For API you have to replace this code only
Introduction Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies. It will check which other packages a specific project depends on and …
Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies. It will check which other packages a specific project depends on and install them for you, using the appropriate versions according to the project requirements. Composer is also commonly used to bootstrap new projects based on popular PHP frameworks, such as Symfony and Laravel.
In this tutorial, you’ll install and get started with Composer on an Ubuntu 20.04 system
In order to follow this guide, you will need access to an Ubuntu 20.04 server as a non-root sudo user, and a firewall enabled on your server. To set this up, you can follow our initial server setup guide for Ubuntu 20.04.
In addition to dependencies that should be already included within your Ubuntu 20.04 system, such as git and curl, Composer requires php-cli in order to execute PHP scripts in the command line, and unzip to extract zipped archives. We’ll install these dependencies now.
First, update the package manager cache by running:
sudo apt update
Next, run the following command to install the required packages:
sudo apt install php-cli unzip
You will be prompted to confirm installation by typing Y and then ENTER.
Once the prerequisites are installed, you can proceed to install Composer.
Composer provides an installer script written in PHP. We’ll download it, verify that it’s not corrupted, and then use it to install Composer.
Make sure you’re in your home directory, then retrieve the installer using curl:
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
Next, we’ll verify that the downloaded installer matches the SHA-384 hash for the latest installer found on the Composer Public Keys / Signatures page. To facilitate the verification step, you can use the following command to programmatically obtain the latest hash from the Composer page and store it in a shell variable:
HASH=`curl -sS https://composer.github.io/installer.sig`
If you want to verify the obtained value, you can run:
echo $HASH
Output
756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3
Now execute the following PHP code, as provided in the Composer download page, to verify that the installation script is safe to run:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
You’ll see the following output:
output
Installer verified
If the output says Installer corrupt, you’ll need to download the installation script again and double-check that you’re using the correct hash. Then, repeat the verification process. When you have a verified installer, you can continue.
To install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
You’ll see output similar to this:
output
All settings correct for using Composer Downloading... Composer (version 1.10.5) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer
To test your installation, run:
Output
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.10.5 2020-04-10 11:44:22
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
--no-cache Prevent use of the cache
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
...
This verifies that Composer was successfully installed on your system and is available system-wide.
In this article, I will show how to install a Cyber panel on Digital ocean. One-click install very Simple and easy process In this article, I am going to show how …
In this article, I will show how to install a Cyber panel on Digital ocean. One-click install very Simple and easy process
In this article, I am going to show how to install Cyber Panel on Digitalocean. One-click install very Simple and easy process. Host a PHP based website on Cyberpanel full process Step by Step
Let’s start…
Choose a data center region
Create a Complex Password for your droplet otherwise, you cant create a droplet
Note: You can choose SSH keys this is more secure.
Once your droplet is ready then you can get your droplet IP on the top.
ssh root@your droplet ip
password= your droplet password
Once Successfully log in you were asked for an update. Simply type Y and press Enter. Once Complete the
update restart your terminal or exit.
Again login with ssh and you will get the cyber panel link and PHPMyAdmin link
sudo cat .litespeed_password
This command will generate your cyber panel admin user and password.
Now You can log in with this credential. Cyber Panel Completely installed
Now we are hosting a website using a cyber panel
Main→Websites→Create Website→Select Package→ Default →Select Owner =admin →DomainNam→Email→Select PHP version→Create Website
Note: Before doing these steps you should change your domain nameserver i.e
ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com
Create user for selected domamin
Your website is live now….
Now we will create a database for the same domain
Once create a database import .sql file using PHPMyAdmin.
On the side, the panel go to the listwebsite tab and open with the manage option
Go to the file manager and upload your project and configure the database connection.
All Set now your project will live completely…..
If any questions you can ask me in the comment section
While WordPress itself is a secure platform, this doesn’t make your site immune to break-ins. One of the most common attacks is human or bot hackers trying to force their way …
While WordPress itself is a secure platform, this doesn’t make your site immune to break-ins. One of the most common attacks is human or bot hackers trying to force their way through your login page by trying various username and password combinations until something works. To keep them from succeeding, you can use a WordPress limit login attempts plugin.
By default, people can continuously try to log into your site, with no restrictions on attempts. However, most legitimate users won’t need more than a few tries (at most). Therefore, you can limit the number of login attempts made from a specific IP address in a set amount of time. Any user who goes over the limit can be temporarily or permanently locked out.
In this post, we’re going to show you how to set the feature up using a free WordPress limit login attempts plugin. Then, we’ll share some of the pros and cons of this approach. Let’s get to work!
For most users, a WordPress limit login attempts plugin is the best option to restrict login attempts. There are several quality options, but we recommend the free Limit Login Attempts Reloaded plugin because it’s:
While the plugin is easy to use at a basic level (it starts working as soon as you activate it), it also boasts a variety of configuration options, including some handy extras (such as the ability to whitelist or blacklist both IPs and usernames).
To get started, install and activate the Limit Login Attempts Reloaded plugin at your WordPress site. If you’re not sure how to install a WordPress plugin.
As soon as you activate the plugin, it starts working right away. By default, users get four guesses before the plugin locks them out:
However, the plugin also provides a settings area where you can modify how this functionality works.
To access this area, go to Settings > Limit Login Attempts:
In the Statistics section, you can find details about how many ‘lockouts’ have occurred due to the plugin. This will be empty right now, but you can check back later to see how many potential brute force attempts the plugin has halted.
Then, under Options, you can customize how the lockout system works. This includes deciding how many guesses the plugin will allow, the length of time users will be locked out for, and more. You can even enable a GDPR-compliance setting, which will obfuscate all recorded IPs for privacy reasons.
Scrolling down a bit, you’ll also find sections labeled Whitelist and Blacklist:
Here, you can enter specific IPs and/or usernames. If you add a user to the whitelist, they’ll be able to log into your site as many times as they’d like, and won’t have to worry about getting locked out.
Adding someone to the blacklist, on the other hand, will permanently lock them out. The latter option is handy if you see a lot of suspicious activity coming from one or more specific IP addresses.
Don’t forget to save your changes to this page when you’re done configuring the settings. That’s all you need to do to limit login attempts in WordPress!
Thanks for reading……
What is XML-RPC? XML-RPC is an API that warps the information or data into an XML file and sends it to the mobile app or remote software. This was introduced as …
What is XML-RPC?
XML-RPC is an API that warps the information or data into an XML file and sends it to the mobile app or remote software. This was introduced as in the olden days, internet speed is not fast, instead of writing it online. Users write their content offline and publish it all together using the API. As the internet services improved, most of us does not use the feature anymore, often it was forgotten by us.
XML-RPC is a remote procedure call protocol that allows anyone to interact with your WordPress website remotely. In other words, it’s a way to manage your site without having to log in manually via the standard “wp-login.php” page. It’s widely used by plugins, most famously by Automattic’s own Jetpack plugin. These days, however, the word “XML-RPC” has gotten a bad name. In this tutorial, we will explain what is WordPress XML-RPC and how to stop an XML-RPC attack on your WordPress website.
A quick way to check if your site is vulnerable is to visit the following URL from a browser:
yoursite.com/xmlrpc.php
If it’s enabled, you should get a response that says “XML-RPC server accepts POST requests only.” Like this:
There’s been a lot of back and forth in the WordPress security community about XML-RPC. There are mostly two concerns:
At least, these were possible. WordPress has since plugged loopholes that allowed people to try hundreds of usernames and passwords at once. Since version 4.4, it’s been quite improved. Now WordPress will silently fail all subsequent login attempts as soon as a single XML-RPC call has failed. Great!
However, there are those who are still concerned about the ease by while remote procedure calls like this can be made. So here are a few ways to secure your site against XML-RPC – starting from the lightest touch to the heaviest.
This is a process that uses your server as an unwitting participant in an attack against another server. Basically, someone tells your site “Hey, this URL linked to your blog!” And then your site responds with a “pingback” to that URL. Except that there’s no verification that the URL actually did link back to you. Do this with hundreds of vulnerable WordPress sites, and you have a DDoS attack on your hands! The easiest way to prevent your site from being used in this manner is to add the following code to your theme’s functions.php:
function stop_pings ($vectors) {
unset( $vectors['pingback.ping'] );
return $vectors;
}
add_filter( 'xmlrpc_methods', 'stop_pings');
This second method determines whether you want to allow XML-RPC methods that authenticate users. Take for example, publishing a blog via e-mail. The site will receive your e-mail, authenticate you via XML-RPC, and then publish it if the credentials match.
A lot of people are uncomfortable with the ability of XML-RPC to just take in random calls like this. It’s what led to hundreds or thousands of authentication attempts in the first place. Even though WordPress has since addressed this particular form of hacking, there are those who recommend simply turning it off.
To do that, enter this code in functions.php:
add_filter('xmlrpc_enabled','__return_false');
It’s important to note that this is not the same as the first method. This code only disables authentication methods and leaves all others untouched – like pingbacks for example.
This is the most extreme method that completely disables all XML-RPC functionality. It requires you to edit the .htaccess file at the root of your WordPress directory. Add the following code to the top:
<files xmlrpc.php>
Order allow,deny
Deny from all
</files>
Note: If you find your WordPress installation doesn’t have a .htaccess file at its root folder, simply create one with the following default code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Now with the above denial rules in effect, trying to access xmlrpc.php will be met with the following page:
What is PHP mail? PHP mail is the built in PHP function that is used to send emails from PHP scripts. The mail function accepts the following parameters: Email address Subject …
What is PHP mail?
PHP mail is the built in PHP function that is used to send emails from PHP scripts.
The mail function accepts the following parameters:
In this tutorial, you will learn-
The PHP mail function has the following basic syntax
<?php
mail($to_email_address,$subject,$message,[$headers],[$parameters]);
?>
HERE,
PHP mailer uses Simple Mail Transmission Protocol (SMTP) to send mail.
On a hosted server, the SMTP settings would have already been set.
The SMTP mail settings can be configured from “php.ini” file in the PHP installation folder.
Configuring SMTP settings on your localhost Assuming you are using xampp on windows, locate the “php.ini” in the directory “C:\xampp\php”.
Click on Find… menu
The find dialog menu will appear
Click on Find Next button
PHP Mail Example
Let’s now look at an example that sends a simple mail.
<?php
$to_email = 'name @ company . com';
$subject = 'Testing PHP Mail';
$message = 'This mail is sent using the PHP mail function';
$headers = 'From: noreply @ company . com';
mail($to_email,$subject,$message,$headers);
?>
Output:
Note: the above example only takes the 4 mandatory parameters.
You should replace the above fictitious email address with a real email address.
The above example uses hard-coded values in the source code for the email address and other details for simplicity.
Let’s assume you have to create a contact us form for users fill in the details and then submit.
Let’s create a custom function that validates and sanitizes the email address using the filter_var built-in function.
Filter_var function The filter_var function is used to sanitize and validate the user input data.
It has the following basic syntax.
<?php
filter_var($field, SANITIZATION TYPE);
?>
HERE,
The code below implements uses a custom function to send secure mail.
<?php
function sanitize_my_email($field) {
$field = filter_var($field, FILTER_SANITIZE_EMAIL);
if (filter_var($field, FILTER_VALIDATE_EMAIL)) {
return true;
} else {
return false;
}
}
$to_email = 'name @ company . com';
$subject = 'Testing PHP Mail';
$message = 'This mail is sent using the PHP mail ';
$headers = 'From: noreply @ company. com';
//check if the email address is invalid $secure_check
$secure_check = sanitize_my_email($to_email);
if ($secure_check == false) {
echo "Invalid input";
} else { //send email
mail($to_email, $subject, $message, $headers);
echo "This email is sent using PHP Mail";
}
?>
Output:
Emails can be intercepted during transmission by unintended recipients.
This can exposure the contents of the email to unintended recipients.
Secure mail solves this problem by transmitting emails via Hypertext Transfer Protocol Secure (HTTPS).
HTTPS encrypts messages before sending them.
In this post, we have share tutorial on How to join multiple tables using Eloquent Model in Laravel framework and then after fetch data from multiple table and display on web …
In this post, we have share tutorial on How to join multiple tables using Eloquent Model in Laravel framework and then after fetch data from multiple table and display on web page in HTML table format. So in this post you will find the solution of how to fetch data from multiple table by join multiple table using Eloquent Model under this Laravel framework. In this post we will use inner join for fetch data data from multiple table using Eloquent join table relationship. So by using this tutorial, you can learn How to retrieve data from multiple tables using join multiple table with eloquent model relationship in single query run under this Laravel 8 framework.
So If you want to learn How to Join Multiple Tables in Laravel framework using Eloquent Model relationship then this post will help you, because in this post you can find step by step guide for implement how can we implement inner join for multiple tables join using Eloquent model under this Laravel framework. Under this post we have use Eloquent model in place of simple Laravel join, this is because Laravel Eloquent model is more effective that simple Laravel join while we have to fetch data from multiple table in single query. So for this here we have use Eloquent model for join multiple table in Laravel framework. Below you can find step by step guide for how to join multiple table using Laravel eloquent model.
For download fresh copy of Laravel framework, so first we have to into command prompt and run following command. This command will make join_table directory and under that directory it will download Laravel framework latest version.
composer create-project --prefer-dist laravel/laravel join_table
After download and install Laravel framework and after this we want to make first database connection. So for make database connection, we have to open .env file and under this file, we have to define mysql database configuration. So it will create database connection in Laravel framework.
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=testing
DB_USERNAME=root
DB_PASSWORD=
Once you have make database connection, then after we have to make table in mysql database. So for this you have to run following sql script in your local database, so it will create table in your define mysql database.
--
-- Table structure for table `city`
--
CREATE TABLE `city` (
`city_id` int(11) NOT NULL,
`state_id` int(11) NOT NULL,
`city_name` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `city`
--
INSERT INTO `city` (`city_id`, `state_id`, `city_name`) VALUES
(1, 1, 'New York city'),
(2, 1, 'Buffalo'),
(3, 1, 'Albany'),
(4, 2, 'Birmingham'),
(5, 2, 'Montgomery'),
(6, 2, 'Huntsville'),
(7, 3, 'Los Angeles'),
(8, 3, 'San Francisco'),
(9, 3, 'San Diego'),
(10, 4, 'Toronto'),
(11, 4, 'Ottawa'),
(12, 5, 'Vancouver'),
(13, 5, 'Victoria'),
(14, 6, 'Sydney'),
(15, 6, 'Newcastle'),
(16, 7, 'City of Brisbane'),
(17, 7, 'Gold Coast'),
(18, 8, 'Bangalore'),
(19, 8, 'Mangalore'),
(20, 9, 'Hydrabad'),
(21, 9, 'Warangal');
-- --------------------------------------------------------
--
-- Table structure for table `country`
--
CREATE TABLE `country` (
`country_id` int(11) NOT NULL,
`country_name` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `country`
--
INSERT INTO `country` (`country_id`, `country_name`) VALUES
(1, 'USA'),
(2, 'Canada'),
(3, 'Australia'),
(4, 'India');
-- --------------------------------------------------------
--
-- Table structure for table `state`
--
CREATE TABLE `state` (
`state_id` int(11) NOT NULL,
`country_id` int(11) NOT NULL,
`state_name` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `state`
--
INSERT INTO `state` (`state_id`, `country_id`, `state_name`) VALUES
(1, 1, 'New York'),
(2, 1, 'Alabama'),
(3, 1, 'California'),
(4, 2, 'Ontario'),
(5, 2, 'British Columbia'),
(6, 3, 'New South Wales'),
(7, 3, 'Queensland'),
(8, 4, 'Karnataka'),
(9, 4, 'Telangana');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `city`
--
ALTER TABLE `city`
ADD PRIMARY KEY (`city_id`);
--
-- Indexes for table `country`
--
ALTER TABLE `country`
ADD PRIMARY KEY (`country_id`);
--
-- Indexes for table `state`
--
ALTER TABLE `state`
ADD PRIMARY KEY (`state_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `city`
--
ALTER TABLE `city`
MODIFY `city_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
--
-- AUTO_INCREMENT for table `country`
--
ALTER TABLE `country`
MODIFY `country_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `state`
--
ALTER TABLE `state`
MODIFY `state_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
In Laravel framework, we have to create model class for database related operation. So for create model classe using compost, we have go to command prompt and run following command, this command will make model class file with name Country.php under app/Models folder.
php artisan make:model Country
After create model class, we have to open that file and under that file we have to define mysql table name details and column details.
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
use HasFactory;
protected $table = 'country';
protected $fillable = [
'country_name'
];
}
Under this Laravel framework, for handle HTTP request we have to create controller class. So for create controller using compost, we have go to command prompt and run following command.
php artisan make:controller JointableController
Once your controller class has been create then for open that file, we have go to app/Http/Controllers/JointableController.php file and under this file you have write following code for join multiple table using eloquent model and fetch data from multiple table in single query execution.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Country;
class JointableController extends Controller
{
function index()
{
$data = Country::join('state', 'state.country_id', '=', 'country.country_id')
->join('city', 'city.state_id', '=', 'state.state_id')
->get(['country.country_name', 'state.state_name', 'city.city_name']);
/*Above code will produce following query
Select
`country`.`country_name`,
`state`.`state_name`,
`city`.`city_name`
from `country`
inner join `state`
on `state`.`country_id` = `country`.`country_id`
inner join `city`
on `city`.`state_id` = `state`.`state_id`
*/
return view('join_table', compact('data'));
}
}
?>
For display HTML output in browser, so we have to create view blade file in Laravel framework. In Laravel framework view blade file has been store under resources/views folder. Under this file, we have create join_table.blade.php file. Under this file, it will received data from controller class file. You can find source code of this view blade file in below.
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How to Join Table in Laravel 8 using Eloquent Model</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>
<div class="container">
<br />
<h1 class="text-center text-primary">How to Join Multiple Table in Laravel 8 using Eloquent Model</h1>
<br />
<div class="table-responsive">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Country</th>
<th>State</th>
<th>City</th>
</tr>
</thead>
<tbody>
@foreach($data as $row)
<tr>
<td>{{ $row->country_name }}</td>
<td>{{ $row->state_name }}</td>
<td>{{ $row->city_name }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</body>
</html>
Under this Laravel framework, we have to set route of the controller method. For set route in Laravel 8 framework, we have to open routes/web.php file. In Laravel 8 framework for set route, we have to first import our controller class under this web.php file. And for set route you can find source code below.
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\JointableController;
Route::get('/', function () {
return view('welcome');
});
Route::get('join_table', [JointableController::class, 'index']);
After follow all above steps now all are set now we want to run Laravel application in browser. So for this, we have to go command prompt and run following command.
php artisan serve
Once you have run above command so after run this command it will provide us base url of our Laravel application. So for check above script output, we have to hit following url in browser.
http://127.0.0.1/join_table
If you were given two dates, that is start date and end date and You want to find the difference between two dates in PHP. Its very simple and easy to …
If you were given two dates, that is start date and end date and You want to find the difference between two dates in PHP.
Its very simple and easy to calculate the difference between two dates.
There are two methods to find the difference.
By using date_diff() in-built function to Calculate Difference Between Two Dates in PHP
For PHP version >=5.3 : Create two date objects and then use date_diff() function. It will return PHP Date Interval object.
$date1 = date_create("2018-03-24");
echo "Start date: ".$date1->format("Y-m-d")."<br>";
$date2 = date_create("2019-05-31");
echo "End date: ".$date2->format("Y-m-d")."<br>";
$diff = date_diff($date1,$date2);
echo "Difference between start date and end date: ".$diff->format("%y years, %m months and %d days");
If you execute the above code to find the difference between start date and end date, you will get the below output
Start date: 2018-03-24
End date: 2019-05-31
Difference between start date and end date: 1 years, 2 months and 7 days
You can use strtotime() to convert two dates to UNIX time and then calculate the number of seconds between them. From this it’s rather easy to calculate difference between start date and end date.
$date1 = "2018-03-24";
$date2 = "2019-05-31";
$diff = abs(strtotime($date2) - strtotime($date1));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
printf("%d years, %d months, %d days\n", $years, $months, $days);
If you execute the above code to find the difference between start date and end date using strtotime() function, you will get the below output
1 years, 2 months, 8 days
That’s it. I hope you will like this tutorial. Please share this post with your friends in your social media by clicking share options. Please share your feedback via comments
Thanks