Google reCaptcha V2 & V3 javascript demo and php example code

<?php // google recaptcha v2 $siteKey = ‘siteKey222’; $secret = ‘secret2222’; // google recaptcha v3 $siteKey_v3 = ‘siteKey333’; $secret_v3 = ‘secret3333’; function getRrecaptchaResult($secret_key, $g_recaptcha_response) { $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_URL => ‘https://www.google.com/recaptcha/api/siteverify’, CURLOPT_POSTFIELDS => [ ‘secret’ => $secret_key, ‘response’ => $g_recaptcha_response, ‘remoteip’ => $_SERVER[‘REMOTE_ADDR’] ] ]); $response = …

Example for get value from ngNoForm and combine a search in Angular

ngNoForm: Create New Extractee: All {{e.name}} Status: All Open Finalised .ts index(): let f = document.getElementById(‘search_form’); if (f) { if (f.status.value != ” && f.laravel_id.value != ”) { params = params.set(‘search’, ‘status:’ + f.status.value + ‘;laravel_id:’ + f.laravel_id.value) .set(‘searchFields’, ‘status:=;laravel_id:=’) .set(‘searchJoin’, ‘and’); } else if (f.laravel_id.value != ”) { params = params.set(‘search’, f.laravel_id.value) .set(‘searchFields’, ‘laravel_id:=’); …

How to select all/trigger/unselect checkbox in Angular without use FormArray and ngModel

.html: …… {{item.site.name}} .ts: export interface NewXxxModel extends XxxModel { checkbox_value?: boolean; } …. not_assigned_tasks: NewXxxModel[]; new_tasks_ary: Array = []; …. triggerAll(tasks: string, event: any) { if (tasks == ‘not_assigned_tasks’) { this.new_tasks_ary = []; for (var i = 0; i < this.not_assigned_tasks.length; i++) { if (event && event.target.checked == false) { this.not_assigned_tasks[i].checkbox_value = false; } ...

How to upload multiple files via Angular and reset file input

<!– upload files –> <divclass=”input-group mb-3″ *ngIf=”declaration_status==’Open'”> <divclass=”input-group-prepend”> <spanclass=”input-group-text”id=”basic-addon1″>Upload Attachments</span> </div> <input class=”form-control” #chooseFileInput (change)=”fileChange($event)” type=”file”name=”file” multiple placeholder=”Upload files”accept=”.png,.gif,.jpeg,.pdf,.txt,.csv,.doc,.zip,.gz,.rar”id=”choose_file”> <span *ngIf=”uploading” class=”input-group-text”><i class=”fa fa-spinner fa-spin mr-3 ml-2″aria-hidden=”true”></i> Uploading …</span> </div> ts: fileChange(event: any) { let formData = new FormData(); let fileList: FileList = event.target.files; for (let i = 0; i < fileList.length; i++) { formData.append(‘files[]’, …

How to download/display bolb/bytea file from database use Laravel

We should use raw query instead of eloquent of laravel: $uploadedFile = $this->uploadedFileRepository->findWithoutFail($id); $f = \DB::table(‘uploaded_files’) ->selectRaw(‘*’) ->where(‘id’, ‘=’, $id) ->first(); $file_bytea = stream_get_contents($f->file_content); if (function_exists(‘pg_unescape_bytea’)) { $file_str = pg_unescape_bytea($file_bytea); } else { $file_str = pack(‘H*’, $file_bytea); } header(“Content-type:”.$f->mime_type); //if (strpos($f->mime_type, ‘image’) === false && strpos($f->mime_type, ‘pdf’) === false) { header(“Content-Disposition: attachment; filename=”.$f->file_name); //} echo$file_str; …

How to add select form element in Angular html component file?

.ts: all_lines = [ {id: 1, name: “Line 1”}, {id: 2, name: “Line 2”}, {id: 3, name: “Line 3”}, {id: 4, name: “4”}, {id: 5, name: “5”}, {id: 6, name: “6”}, {id: 7, name: “7”}, {id: 8, name: “8”}, {id: 9, name: “9”}, ]; .html: <select formControlName=”lines” class=”form-control”> <option *ngFor=”let line of all_lines” [ngValue]=”line.id”>{{line.name}}</option> </select>

How to use my owner class in Laravel?

Create a php class file in App\Libraries, eg. CupsPrinter.php namespace App\Libraries; use Smalot\Cups\Builder\Builder; use Smalot\Cups\Manager\PrinterManager; use Smalot\Cups\Transport\Client; use Smalot\Cups\Transport\ResponseParser; use Smalot\Cups\Manager\JobManager; use Smalot\Cups\Model\Job; class CupsPrinter { private $cups_user; private $cups_pass; private $cups_ipp_uri; function __construct($cups_user, $cups_pass, $cups_ipp_uri) { $this->cups_user = $cups_user; $this->cups_pass = $cups_pass; $this->cups_ipp_uri = $cups_ipp_uri; } /** * cups print pdf function * * …