ftp_put and $FILE upload in ftp file with 0kb

Good morning, how I fast explained in the title I’ve a problem uploading file via form (wpcf7) in to ftp. File will be upload but with 0kb. I tried and search a solution on web but nothing.

Following the code that upload file with 0kb:

$image = $_FILES['file-799']['tmp_name'];
$image_name = $_FILES['file-799']['name'];
if(ftp_put($ftp_conn, $image_name, $_SERVER['DOCUMENT_ROOT'] . $image,FTP_BINARY));
ftp_close($ftp_conn);
fclose($myfile);

I tried also following code but work worse (doenst upload anything)

$image = $_FILES['file-799']['tmp_name'];
$image_name = $_FILES['file-799']['name'];
if(ftp_put($ftp_conn, $image_name, $image,FTP_BINARY));

Thank you for any feedback

How can i solve my problem with the mail function from PHPMailer?

I am actually working on a website, and right now i am trying to create a function to reset a password when you forget it. Then i want to send an email to the user so he can reset his password. I am struggling on the email part. I looked on the internet that i should try PHPMailer, but i can’t make it work.
For more context, my compagny lended me a sandbox server wich i acceed to by SSH protocol, and its a Debian engine.

For the moment, i just wanted to try sending an regular email
Here is the code im trying :

enter image description here

Also, i think i correctly dowloaded PHPMailer on the debian engine.
When i log into the error log file, here is what i get :

enter image description here

Ty in advance for the people that will try to help !

How to implement slug in laravel

I am having a problem how to display slug data in view file i am using cviebrock/eloquent-sluggable

my model file

use Sluggable;

public function sluggable() {
   return ['slug'=>[
       'source'=>'title',
       'onUpdate'=>true
   ]];
}

public static function boot()
{
    parent::boot();
    self::creating(function($model){
        $model->slug = Str::slug($model->title, '-');
    });
}

my route

Route::get(“tenderview”, “TenderViewController@show”)->name(‘tenderview’);

Route::get(‘/tenderview’, ‘TenderViewController@index’)->name(‘tenderview’);

Controller file

public function index()
{
    return view('tenderview');
}

public function show()
{
    $dataa = Kind::orderBy('created_at', 'DESC')->paginate(8);

    return view('tenderview',['dataa'=>$dataa]);
}

View file
@foreach($dataa as $dater)
{{$dater->name}}
@endforeach

How can i show slug in my view instead of displaying data as a whole, i want to display a link to the actual data. Thank you

My html cart system only out total price until 999.99 if lets say the total price is 1890.00 it only prints 189.00 [closed]

Here is the code

 
            
            <td>RM<?php echo number_format($fetch_cart['price']); ?>/-</td>
            <td>
               <form action="" method="post">
                  <input type="hidden" name="update_quantity_id"  value="<?php echo $fetch_cart['id']; ?>" >
                  <div class="num">
                  <input type="number" name="update_quantity" min="1"  value="<?php echo $fetch_cart['quantity']; ?>" >
                  </div>
                  <input type="submit" value="update" name="update_update_btn">
               </form>   
            </td>
            <td>RM<?php echo $sub_total = number_format($fetch_cart['price'] * $fetch_cart['quantity'],2); ?>/-</td>
            <td><a href="cart.php?remove=<?php echo $fetch_cart['id']; ?>" onclick="return confirm('remove item from cart?')" class="delete-btn"> <i class="fas fa-trash"></i> remove</a></td>
         </tr>
         <?php
           $grand_total .= $sub_total;  
            };
         };
         ?>
        

      </tbody>

i tried formating but its not working but there is a error showing saying non-numeric value at

  <?php
           $grand_total .= $sub_total;  
            };

is there a solution fr this problem ive searched google many time but not working

Perfex CRM xoauth2 not working after the update, outputing that the authorisation is unsuccesful, what may cause this?

Perfex recently introduced the ability to add office with the oauth2. I’ve followed the steps, added application where necessary, however, it authorize it properly, giving this –

SERVER -> CLIENT: 535 5.7.3 Authentication unsuccessful

All the settings from MS side seem to be fine to my knowledge. Is it perhaps some sort of cache issue?

I’ve tried tinkering with settings in MS, double checked if I took the wrong IDs and such, however, I am always still receiving this error

Unable to install php-gd with php8.1 on ubuntu 22.04

If I try to run anything like apt install php8.1-gd or php8-gd or php-gd I run into the same error, which says E: Package ‘php-blabla’ has no installation candidate

System info:

  • Ubuntu 22.04
  • PHP 8.1.17
  • Running in docker container

Packages I’ve tried so far: apt-get install libgd3, apt install php8.1-gd, apt install php8.2-gd, apt install php8.0-gd, apt install php8-gd, apt-get install php_gd2

Has anyone an idea how to fix my problem?

Gitlab runner is using an other php executable than locally

I’m running a Docker container for one of the packages that I’m developing. I’m pushing it to a Gitlab instance with our own Kubernetes runners on it. But for some reasons, it doesn’t look like the runner there is using the same container definition as I’m using locally. I’m not sure what is going on, and I’m slowly losing my mind about this.

I’m installing pre-compiled php extensions in the Dockerfile. Especially the php8.2-sockets one is needed for a successful composer install. Locally it works just fine (You can see the php -m output comparison at the bottom).

It also looks like the main php executable is in a different location when running it in the Gitlab pipeline. Locally it is /usr/bin/php and in the runner it is /usr/local/bin/php.

I’m looking for something that explains the difference between local and pipeline, or at least find a way to install the php8.2-sockets extension in the version that is used by the Gitlab pipeline. I don’t want to use --ignore-platform-req=ext-dom because that makes it impossible to write any subsequent tests.

By the way, if someone know how to collapse code snippets. Please let me know. I’d like to collapse the command outputs so it is a bit more readable. Thanks in advance.


My Dockerfile:

FROM debian:bullseye-slim

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update 
    && apt-get install -y zip git curl supervisor lsb-release ca-certificates libzip-dev libxml2-dev libicu-dev 
    && curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg 
    && sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ bullseye main" > /etc/apt/sources.list.d/php.list' 
    && apt-get update 
    && apt-get install -y 
       php8.2-cli php8.2-fpm 
       php8.2-curl php8.2-sockets php8.2-dom 
    && apt-get autoremove -y 
    && apt-get clean 
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV COMPOSER_ALLOW_SUPERUSER 1

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

WORKDIR /var/www

ENV WWWUSER 1000
ENV WWWGROUP 1001

RUN groupadd --gid $WWWGROUP cbe 
    && useradd -m -g $WWWGROUP -u $WWWUSER cbe

ENTRYPOINT ["/bin/bash"]

My .gitlab-ci.yml

variables:
  FF_GITLAB_REGISTRY_HELPER_IMAGE: 1
  DOCKER_BUILDKIT: 1
  DOCKER_DRIVER: overlay2
  BUILDKIT_PROGRESS: plain

stages:
  - image
  - build

php-image:
  stage: image
  image: docker
  services: [ docker:dind ]
  before_script:
    - echo ${CI_REGISTRY_PASSWORD} | docker login -u ${CI_REGISTRY_USER} --password-stdin ${CI_REGISTRY}
  script:
    - docker build
      --tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
      --build-arg BUILDKIT_INLINE_CACHE=1
      --push
      --progress plain
      -f Docker/Dockerfile .

composer:
  stage: build
  image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}
  needs: [ php-image ]
  script:
    - php -m
    - which php
    - cp phpunit.xml.dist phpunit.xml
    - php composer install --optimize-autoloader --no-ansi --no-interaction --no-progress

php -m comparison

Local

bash-5.1# php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
random
readline
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

[Zend Modules]
Zend OPcache

bash-5.1# which php
/usr/bin/php

Runner

$ php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
random
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
$ which php
/usr/local/bin/php

Laravel – Unique validation ignore on update not working

my email unique validation is not working.

From this form, I am sending a user

<form id="edit-form" class="mt-4" action="{{ route('user.update', 1) }}" method="post">
    @csrf @method('put')
</form>

It goes here to my web.php

Route::prefix('/user')->group(function () {
   Route::put('/update/{user}', [AppHttpControllersUserController::class, 'update'])->name('user.update');
});

Then it comes here in the controller

public function update(UpdateUserRequest $request)
{
    dd($request);
}

Which calls this request form:

public function rules(): array
{
    return [
        'email' => ['nullable', Rule::unique('users', 'email')->ignore($this->id, 'id'), 'email:rfc', 'max:255'],
    ];
}

Yet everytime, if I send the same email the model already has, it will say that the email is already in use.

Htaccess file Php Html [closed]

I have this code in htaccess file

RewriteEngine On

RewriteRule (.*).html view.php?id=$1 [QSA,L]

Now all post look /post.html

I need add page.php?id=$1 like this so he shows /page.html

How to do that? Please help with this

view.php?id=1 must go to /post1.html
view.php?id=2 must go to /post2.html

page.php?id=1 must go to /page1.html
page.php?id=2 must go to /page2.html

PHP

$id = (INT)$_GET['id']; 

Not Working

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ view.php?id=$1 [L]
RewriteRule ^(.*)$ page.php?id=$1 [L]

how can we add a “package” using composer where it is available on github, I do found one work, but this one doesn’t

we can add a github repo as below then run composer install

  "config": {
            "allow-plugins": {
                    "composer/installers": true
            }

    },

    "repositories": [
            {
                    "type": "git",
                    "url": "https://github.com/tombenner/wp-mvc.git"
            }
    ],
    "require":{
            "tombenner/wp-mvc": "dev-master"
    }

without any issue, but given,
we have a composer.json as:

   "config": {
            "allow-plugins": {
                    "composer/installers": true
            }

    },

    "repositories": [
            {
                    "type": "git",
                    "url": "https://github.com/sampoyigi/ti-ext-localepicker.git"
            }
    ],
    "require":{
            "sampoyigi/ti-ext-localepicker": "dev-master"
    }

when composer install

In RootPackageLoader.php line 160:

  require.ti-ext-localepicker is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and packag
   name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a
  z0-9]+)*$".


install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--download-only] [--dev] [--no-suggest] [-dev] [--no-autoloader] [--no-progress] [--no-install] [--audit] [--audit-format AUDIT-FORMAT] [-v|vv|vvv|--verbose] [-o|--optimiztoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-rGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>...]

how can we add a “package” using composer where it is available on github.

Integration of php website with Gumroad API

How to integrate my Php website with Gumroad API to verify whether a buyer has bought my online products or not and depending on the result status I will edit a column in the database

I have a php website where I sell online courses and my payment gateway is gumroad I want to get back an API so I can verify whether a user has bought my online course or not – depending on the status I want to edit something in the database

I have signup/login system already

I can’t remove a network plugin

i have installed “Insert PHP Code Snippet” plugin on wordpress, and i want to remove it now but i could’nt a deactivate or remove button in installed plugins.

I think that this plugin is causing problems with the elemenator, as if i want to open the elemenator this error appears: {“message”:”Server error, see Elementor => System Info”}

How to add a user system date and time verification service on website

I want to add user system’s “date and time” verification service to my PHP website just like google. When a user tries to access my website, my site has to check the users system date and time and if the users system date and time is correct, then only allow the user to my site otherwise show an error message.

I have implemented two logic for this but they are not working as expected –

LOGIC 1: Get user system’s date and time and compare it with each country’s date and time on the world, and if any one country’s date and time matches with user system’s date and time then allow user otherwise show error. (This logic is very heavy and affects the performance of the website so it is not reliable).

LOGIC 2: Get user system’s date and time and compare it with my server’s date and time, and if it matches then allow user otherwise show error. (This logic will work for only one country so it is also not reliable).

Both the logics are not working for me. Also, I have found some articles on NTP (Network Time Protocol) but I am not able to understand it properly due to very limited resources.

If anyone has prior experience of implementing this type of logic please help me out a bit.