Wkhtmltopdf - header i footer Kategoria: PHP | Tagi: wkhtmltopdf | Autor: Bartłomiej Gałęzia

wkhtmltopdf --print-media-type --header-html header.html --footer-html footer.html https://google.pl/ google.pdf

Laravel - PHP 8.2 install Kategoria: Laravel | Autor: Bartłomiej Gałęzia

composer create-project laravel/laravel example-app

or if you want to install specific version

composer create-project laravel/laravel:10.x example-app

copy index.php and .htaccess from public to root

cp /home/www/laravel/public/index.php /home/www/laravel/index.php
cp /home/www/laravel/public/.htaccess /home/www/laravel/.htaccess
vim /home/www/laravel/index.php
...

if (file_exists($maintenance = __DIR__ . '/storage/framework/maintenance.php')) {
    require $maintenance;
}

...

require __DIR__ . '/vendor/autoload.php';

...

$app = require_once __DIR__ . '/bootstrap/app.php';

...
vim config/app.php
'url' => env('APP_URL', 'http://localhost/laravel') #pierwszy parametr jest pobierany z pliku .env a drugi to default jeśli w .env nie ma takiej zmiennej

Odwołanie do zmiennych w configu

<?php echo config('app.url'); #pierwsza część "app" to nazwa pliku config a druga to nazwa zmiennej ?>

Wyświetlenie zmiennej w widoku

{{ $post['content'] }} #wyświetla jako surowy tekst
{!! $post['content'] !!} #wyświetla jako HTML

Źródło: https://laravel.com/docs/9.x

Codeigniter 4 - PHP 8.2 install Kategoria: Codeigniter 4 | Autor: Bartłomiej Gałęzia

aptitude install php8.2 php8.2-intl libapache2-mod-php8.2
vim /etc/apache2/apache2.conf
<Directory /home/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
vim /etc/php/8.2/cli/php.ini
extension=intl
service apache2 restart
composer create-project codeigniter4/appstarter moj_projekt

In app

vim app/Config/App.php
public string $baseURL = 'http://localhost/ci4/';

copy index.php and .htaccess from public to root

cp /home/www/ci4/public/index.php /home/www/ci4/index.php
cp /home/www/ci4/public/.htaccess /home/www/ci4/.htaccess
vim /home/www/ci4/index.php
require FCPATH . 'app/Config/Paths.php';

Routing - żeby każdy kontroler był odrazu dostępny przez URL

vim app/Config/Routes.php
$routes->setAutoRoute(true);

Base_url() z ukośnikiem na końcu

vim /system/Helpers/url_helper.php
//return rtrim(site_url($relativePath, $scheme, $config), '/');
return site_url($relativePath, $scheme, $config);

Disable debugbar:

vim app/Config/Filters.php
public array $globals = [
        'before' => [
        ],
        'after' => [
            //'toolbar',
        ],
    ];

Źródło:

https://www.tutsmake.com/codeigniter-4-remove-public-and-index-php-from-url/

https://www.studentstutorial.com/codeigniter/remove_public_index.php

https://codeigniter4.github.io/userguide/testing/debugging.html

Postgrep - Install od Debian Kategoria: MySQL i inne bazy | Tagi: postgres | Autor: Bartłomiej Gałęzia

aptitude install postgresql postgresql-contrib php-pgsql

check version

sudo -u postgres psql -c "SELECT version();"
vim /etc/postgresql/11/main/pg_hba.conf
local all postgres trust
service postgresql restart
sudo su - postgres -c "createuser miethek" //create user
sudo su - postgres -c "createdb empg" //create db
GRANT ALL PRIVILEGES ON DATABASE empg TO miethek;

Połączenie z innych adresów:

vim /etc/postgresql/11/main/postgresql.conf
listen_addresses = '*'
vim /var/lib/pgsql/data/pg_hba.conf
host  all  all 0.0.0.0/0 md5
service postgresql restart

Źródło: https://linuxize.com/post/how-to-install-postgresql-on-debian-10/

$serverName = "serverName";
$connectionInfo = array( "Database"=>"DbName",
                         "UID"=>"UserName",
                         "PWD"=>"Password",
                         "Encrypt"=>true,
                         "TrustServerCertificate"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);

Źródło: https://stackoverflow.com/questions/14959492/connecting-to-mssql-from-php-securely-with-encryption

PHP - Connect to MSSQL database Kategoria: PHP | Tagi: codeigniter, mssql, php | Autor: Bartłomiej Gałęzia

add-apt-repository ppa:ondrej/php -y
apt-get update
apt-get install aptitude vim mc nmap curl apache2 php php-dev php-xml php-pear
apt-get install unixodbc-dev

sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv

printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.1/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.1/mods-available/pdo_sqlsrv.ini

phpenmod -v 8.1 sqlsrv pdo_sqlsrv

curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list

sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install -y unixodbc-dev

service apache2 restart



https://forum.codeigniter.com/thread-69740-post-350441.html

https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver16#installing-the-drivers-on-ubuntu-1604-for-php-70

https://learn.microsoft.com/en-us/sql/connect/php/system-requirements-for-the-php-sql-driver?redirectedfrom=MSDN&view=sql-server-ver16

https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver16

HEIC to JPG batch convetion Kategoria: Linux | Autor: Bartłomiej Gałęzia

sudo apt install libheif-examples
for file in *.HEIC; do heif-convert $file ${file%.HEIC}.jpg; done

Źródło: https://ubuntuhandbook.org/index.php/2021/06/open-heic-convert-jpg-png-ubuntu-20-04/

Wkhtmltopdf - Page Break Kategoria: PHP | Tagi: wkhtmltopdf | Autor: Bartłomiej Gałęzia

HTML

<div class="new-page"></div>

CSS

@media print {
    .new-page {
        page-break-after: always;
    }
}

lub bezpośrednio w HTML

<div style="page-break-after: always;"></div>

Ważne!

Znacznik "new-page" nie może być wewnątrz znacznika <section> bo nie zadziała.

Czasami (np.: na serwerach CyberFolks) trzeba dodaj w komendzie --print-media-type

wkhtmltopdf --print-media-type http://domena.pl/file.html file_pdf.pdf

Przy próbie połączenia przez CURL z Cyber Folks do Zenbox pokazuje się błąd.

"Please wait while your request is being verified..."

"500 Internal Server Error openresty".

Trzeba to zgłosić do Zenboxa, żeby odblokowali IP serwera źródłowego na firewallu.

https://panel.zenbox.pl/index.php?m=pomoc&page=show-ticket&id=1098515

[#QJIV-9351-ECMM] - ticket z 2024.01.11 nr 1314686

yum remove epel-release

yum clean all

sudo yum -y install yum-utils

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

sudo yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

sudo yum install certbot

sudo yum install certbot-nginx

Źródło: https://stackoverflow.com/questions/53545436/no-package-certbot-available

Ubuntu 20 - Lock screen not working Kategoria: Linux | Autor: Bartłomiej Gałęzia

Menu -> Settings -> Keyboard -> Application shortcuts -> [+Add]

dm-tool lock -> Super + L

Źródło: https://askubuntu.com/questions/1242110/after-upgrading-to-ubuntu-20-04-lockscreen-not-working

Netbeans 13 - Line wrap Kategoria: PHP | Autor: Bartłomiej Gałęzia

Tools -> Options -> Editor -> Formatting

Language: All languages

Line wrap: Anywhere

[Apply]

Źródło: https://smallbusiness.chron.com/wrap-lines-netbeans-49331.html

Acronis - Register agent after server change Kategoria: Acronis | Tagi: acronis, agent | Autor: Bartłomiej Gałęzia

Linux OS

/usr/lib/Acronis/RegisterAgentTool/RegisterAgent -o register -a http://192.168.1.100 -u [username] -p [userpass]

 

Windows OS

Open Command prompt and navigate to C:\Program Files\Acronis\RegisterAgentTool:

cd "%ProgramFiles%\Acronis\RegisterAgentTool"

Issue this command to register the client machine using account and password:

register_agent.exe -o register -a http://192.168.1.100 -u [username] -p [userpass]

 

Źródło: https://kb.acronis.com/content/55244#Linux_OS3

Debian 10 - Possible missing firmware Kategoria: Linux | Tagi: aptitude, debian, nvidia | Autor: Bartłomiej Gałęzia

after aptitude install

W: Possible missing firmware /lib/firmware/nvidia/gp100/gr/sw_method_init.bin for module nouveau
W: Possible missing firmware /lib/firmware/nvidia/gp100/gr/sw_bundle_init.bin for module nouveau
W: Possible missing firmware /lib/firmware/nvidia/gp100/gr/sw_nonctx.bin for module nouveau
W: Possible missing firmware /lib/firmware/nvidia/gp100/gr/sw_ctx.bin for module nouveau
W: Possible missing firmware /lib/firmware/nvidia/gp100/gr/gpccs_sig.bin for module nouveau
W: Possible missing firmware /lib/firmware/nvidia/gp100/gr/gpccs_data.bin for module nouveau
W: Possible missing firmware /lib/firmware/nvidia/gp100/gr/gpccs_inst.bin for module nouveau
...
vim /etc/apt/sources.list

change this

deb http://deb.debian.org/debian/ buster main

to this

deb http://deb.debian.org/debian/ buster main non-free contrib
aptitude update
aptitude install nvidia-detect
nvidia-detect
Detected NVIDIA GPUs:
02:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF100 [GeForce GTX 480] [10de:06c0] (rev a3)

Checking card:  NVIDIA Corporation GF100 [GeForce GTX 480] (rev a3)
Your card is only supported up to the 390 legacy drivers series.
It is recommended to install the
    nvidia-legacy-390xx-driver
package.
aptitude install nvidia-legacy-390xx-driver

Źródło: https://linuxconfig.org/how-to-install-nvidia-driver-on-debian-10-buster-linux

KVM - Migrate Virtualbox to KVM Kategoria: Linux | Tagi: kvm, migrate, Virtualbox | Autor: Bartłomiej Gałęzia

1. Stop the VirtualBox machine.

2. Convert VDI Image to RAW Disk Format

vboxmanage clonehd --format RAW /home/user/VirtualBox_VMs/Debian_vm.vdi /home/user/VirtualBox_VMs/Debian_vm.img

3. Copy RAW image to KVM server

rsync -av --progress /home/user/VirtualBox_VMs/Debian_vm.img user@kvmserver:/home/kvm/Debian_vm.img

4. Convert RAW Image Disk Format to KVM Format

qemu-img convert -f raw Debian_vm.img -O qcow2 Debian_vm.qcow2

Źródło: https://www.tecmint.com/migrate-virtualbox-vms-into-kvm-vms/

KVM - Change default storage location Kategoria: Linux | Tagi: kvm, virsh | Autor: Bartłomiej Gałęzia

mkdir /home/images
virsh pool-destroy default
virsh pool-edit default

change

<path>/var/lib/libvirt/images</path>

to

<path>/home/images</path>
virsh pool-start default

Create new pool for ISO files

virsh pool-define-as --name iso --type dir --target /home/iso/
virsh pool-start iso
virsh pool-autostart iso

https://ostechnix.com/how-to-change-kvm-libvirt-default-storage-pool-location/

- Shut down the guest machine.
- In the 'Display spice' section, select "All interfaces" instead of 'Localhost only' in "Address"
- Restart the guest machine


https://askubuntu.com/questions/780862/virt-manager-to-remote-host-continuous-password-prompt-over-ssh

Plik konfiguracyjny z wirtualką na XEN

kernel = '/usr/lib/xen-4.8/boot/hvmloader'
builder = 'hvm'

vcpus       = '1'
memory      = '2048'
shadow_memory = 8

localtime = 1

#  Disk device(s).
disk        = [
                'file:/xen/ISO/Boot_media.iso,hdb:cdrom,r',
                'phy:/dev/xenvms/restore_disk,xvda,w'

              ]

boot = "dc"

#  Hostname
name        = 'system_restore'

#  Networking
vif         = [ 'mac=00:11:22:33:44:55,bridge=xenbr0' ]

vnc=1
vncconsole=1
vncpasswd='password'

vncunused = 1
vnclisten = '192.168.1.1'

stdvga = 0
serial = 'pty'
usbdevice = 'tablet' # Required for USB mouse


##  Behaviour
on_shutdown = 'destroy'
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

Zobacz całość