Html
Scriptjs
style.css
Html
Scriptjs
style.css
URL encode
<?php
namespace App\Http\Controllers\API;
use Log; use DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class EncodeController extends Controller
{
// UrlEncode
public function urlencode(Request $request)
{
try
{
$myvar = DB::table('cl_master_category')
->select('cl_master_category.category_id', 'cl_master_category.category_name', 'cl_master_category.status', 'cl_master_category.color_code')
->get();
$ciphering = "AES-256-CBC";
$encryption_key = env('ENCRYPTION_KEY');
$encryption_iv = env('ENCRYPTION_IV');
$myencoding = openssl_encrypt($myvar, $ciphering,$encryption_key, 0, $encryption_iv);
return response()->json(['success' => true ,'encoded'=>$myencoding], 200);
}
catch (\Exception\Database\QueryException $e)
{
Log::info('Query: '.$e->getSql());
Log::info('Query: Bindings: '.$e->getBindings());
Log::info('Error: Code: '.$e->getCode());
Log::info('Error: Message: '.$e->getMessage());
return response()->json(['success' => false , 'message' => 'Database Server Error. Please try again later.'], 500);
}
catch (\Exception $e)
{
Log::info('Error: Code: '.$e->getCode());
Log::info('Error: Message: '.$e->getMessage());
return response()->json(['success' => true , 'message' => 'Internal Server Error. Please try again later.'], 500);
}
}
}
********************************************************************
Nextjs code
import React from "react";
import CryptoJS from "crypto-js";
const test = () => {
let keytext = "25c6c7ff35b9979b151f2136cd13b0ff"
let encrypted = "Nb7g0tuktmBmEwUbGrMabzMHlUTN/uyDPg5coE0AHTgmkvkxmwYxapvMu4IaZoCEXphDN+A+PfcMRGGdPso1vbKWJU9X1Yr+oh/eBRobD6hkG4BWJIxnVW79LSkK8WBfieMy05j2FxQH8GzXlPJ9KtcaMcxU2Zj8YERpko2Q8bpcWAlbQVDHXHRaYLMjoR7QvUz2OYqY3CNyLQgXnoc70q5JyAT+eC036Mx/zBnjA16HeVI5xI1MFQ4aFEddd58XwICngKZcuahG0tdUcZ8Z4XgZnmMzMrt+QeunhPg+IQGZhPhL4ZqH2CMYMy2TDtIqClRiAytjekMIcyJErYjVSYPnvGuBQqXiwW23QM69XWMvY0WFmZXXnKQPiwcRUSh3UgEPmbk6Dx023KnL6uw6Maq7/8BzaPzKCJO31gxyXk17NEh+by/59/UDaaLSKnB4fFRu1G/qa+Rg5n5l01XK2uNWITqKne3xWleACeMN652ZVhU1dWPwiWKkwI6hjbCg8m9UtRKw57rq3d6Jt/pN+SUdLJXbIjcTd9oxWlltSUDv4LlstWIlRIx9i6B+SEOMWtEvJvVfDn2DrBtxdo+02SH7ZjNhNi8CEFEHQybPxNBd2KNaiAWyIHgiqCZwmoCDjgPoQh2bWj33jPOVGvqPsCfuFfW10RieWK8yMtZHV2/W16DX3+j3Urt7Cb5o0KvG2+va3+YvTZ123c3a/+UkR+S2odrhEku041VUahIx15Zlhi80ffPn0ngX6E4wDa5QkKAL34kZbQJnZPnzD0P4QOHl34cpn5ZZVP8HsoWAXrAiTM033qG976w43Ld1ewxGG5VhSGRgNHj9CQ42l5+7GQ=="
// let decrypted = "";
let ivtext ="1234567891011121"
const key = CryptoJS.enc.Utf8.parse(keytext);
const iv = CryptoJS.enc.Utf8.parse(ivtext);
var decrypted = CryptoJS.AES.decrypt(encrypted, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
});
text = CryptoJS.enc.Utf8.stringify(decrypted)
console.log("decrypt", CryptoJS.enc.Utf8.stringify(decrypted));
return (
<>
<div> {text}</div>
{/ <div>encrypted Text : {encrypted}</div> /}
{/ <div>Decrypted Text : {decrypted}</div> /}
</>
);
};
export default test;
web.php
<?php
1. Add proper alt text and title text to images.
2. Use headings properly.
3. Use ARIA landmarks. (e.g., role="navigation", role="main")
4. Add labels to form fields.
5. Group related form fields together
6. Provide sufficient color contrast.
7. Avoid using tiny fonts.
8. Respect white space.
9. Provide a visible indication of focus. (e.g., :hover, :focus)
10. Use text, not pictures of text (as possible).
11. Caption video
12. Describe the video
13. Test web pages using a keyboard
14. Giving proper title on <a> tags
15. Responsive testing
Below are some points that should be kept in mind while making laravel project live.
1. php artisan optimize:clear
composer install --optimize-autoloader --no-dev
composer dump-autoload --optimize
Laravel Telescope: If you have installed packages like Laravel Telescope or Debugbar, you should disable or remove them in production: To remove run below command
composer remove laravel/telescope barryvdh/laravel-debugbar
Use Composer to check for any known security vulnerabilities in your dependencies:
composer audit
2. In the .env file
APP_DEBUG=false.
LOG_LEVEL=error.
APP_ENV=production
3. In the app.php
$envKeys = [];
$serverKeys = [];
$cookieKeys = [];
foreach ( $_ENV as $key => $value ) { if(is_string($value)) $envKeys[] = $key; }
foreach ( $_SERVER as $key => $value ) { if(is_string($value)) $serverKeys[] = $key; }
foreach ( $_COOKIE as $key => $value ) { if(is_string($value)) $cookieKeys[] = $key; }
Inside return [
'debug_blacklist' => [
'_COOKIE' => $cookieKeys,
'_SERVER' => $serverKeys,
'_ENV' => $envKeys,
],
4. .htaccess
<Files ~ "\.(git|env|json|config.js|md|gitignore|gitattributes|lock|example)$">
Order allow,deny
Deny from all
</Files>
<Files ~ "(artisan)$">
Order allow,deny
Deny from all
</Files>
5. php artisan storage:link
6. Remove tests folder from project.
Steps to follow
composer create-project laravel/laravel example-app
cd example-app
php artisan serve
Open the .env file and update the database details
Add the below line before LOG_CHANNEL=stack
SESSION_DOMAIN=localhost
php artisan migrate
php artisan serve
composer require laravel/breeze --dev
php artisan breeze:install api
git clone https://github.com/laravel/breeze-next.git
cd breeze-next
npm install
rename the .env.example file to .env.local
npm run dev
Get Geo - location details
function getLocationInfoByIp(){
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = @$_SERVER['REMOTE_ADDR'];
$result = array('country_name'=>'', 'time_zone'=>'');
if(filter_var($client, FILTER_VALIDATE_IP)){
$ip = $client;
}elseif(filter_var($forward, FILTER_VALIDATE_IP)){
$ip = $forward;
}else{
$ip = $remote;
}
$ip_data = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
if($ip_data && $ip_data->geoplugin_countryName != null){
$result['country_name'] = $ip_data->geoplugin_countryName;
$result['time_zone'] = $ip_data->geoplugin_timezone;
}
return $result;
}
@section('script')
<script type="text/javascript">
function restrictAlphabets(e) {
var x = e.which || e.keycode;
if ((x >= 48 && x <= 57))
return true;
else
return false;
}
</script>
@endsection
onkeypress='return restrictAlphabets(event)'
Step 1. In the env file write the code as below.
DB_HOST=127.0.0.1
DB_DATABASE=database1
DB_USERNAME=root
DB_PASSWORD=
DB_HOST2=127.0.0.1
DB_DATABASE2=database2
DB_USERNAME2=root
DB_PASSWORD2=
Step 2. In the config/database.php write the code as below.
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'database' => env('DB_DATABASE', 'database1'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
],
'mysql2' => [
'driver' => 'mysql',
'host' => env('DB_HOST2', '127.0.0.1'),
'database' => env('DB_DATABASE2', 'database2'),
'username' => env('DB_USERNAME2', 'root'),
'password' => env('DB_PASSWORD2', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
],
Step 3. In the model file add a line as below.
protected $connection = 'mysql2';
Step 4.
use App\Models\User;
class UsersController extends BaseController
{
class Order extends Model
{
protected $connection = 'mysql2';
protected $table = 'orders';
}
}
With Query Builder
$data1 = DB::connection('mysql')->table('users')->get(); // DB 1
$data2 = DB::connection('mysql2')->table('orders')->get(); // DB 2
Step 1: import numpy as np import pandas as pd import splitfolders import matplotlib.pyplot as plt import tensorflow as tf from tensorflow i...