php – how to use the function to upload files

I am trying to test a website on which I am testing an upload feature, and it only accepts PDF files. When we invoke the URL where the file is uploaded, a prompt appears instead of content. So I was able to work around it and I upload an HTML file, but when I visit the URL, the download prompt appears and the HTML file does not run in that domain. Instead, it runs after the file has been downloaded. How can I take advantage of this on the main domain.
any ideas?
and it also shows errors if I upload the file with invalid extension.
error: Scan status form scanner FAILED with error code 403 and source message: FileDownloadFailException

Many Thanks

PHP HTTP Request Class – Code Review Stack Exchange

I'd like to hear your opinion about this class used to send an http request (currently only POST method).

It works fine, but I would like to receive an answer to the following questions: maintainability, reusability, security, code formatting, etc.

Class HttpRequest {

private $ POST = & # 39; POST & # 39 ;;
private $ PUT = & # 39; PUT & # 39 ;;
private $ GET = & # 39; GET & # 39 ;;
private $ DELETE = & # 39; DELETE & # 39 ;;
private $ PATCH = & # 39; PATCH & # 39 ;;

private $ body;
private $ options;
private $ handle;
private $ httpCode;
private $ response;

public function __construct () {}


/ **
* Send a request
* @ param-url
* @param header
* @ param options
* @param body
* @json return object
* /
public function ($ url, $ header, $ options, $ body) {
if (! $ this-> handle || get_resource_type ($ this-> handle) == "Unknown") {
$ this-> handle = curl_init ();
}
curl_setopt ($ this-> handle, CURLOPT_URL, $ url);
curl_setopt ($ this-> handle, CURLOPT_HTTPHEADER, $ header);
curl_setopt_array ($ this-> handle, $ options);
// curl_setopt ($ this-> handle, CURLOPT_SSL_VERIFYPEER, true);
// curl_setopt ($ this-> handle, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ this-> handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ this-> handle, CURLOPT_CUSTOMREQUEST, $ this-> POST);
curl_setopt ($ this-> handle, CURLOPT_POSTFIELDS, $ body);
$ this-> response = curl_exec ($ this-> handle);
$ this-> httpCode = curl_getinfo ($ this-> handle, CURLINFO_HTTP_CODE);
curl_close ($ this-> handle);
return this response;
}


public function getResponse () {
return this response;
}

public function getHttpCode () {
return $ this-> httpCode;
}

/ **
* Send a request
* @ param-url
* @param header
* @ param options
* /
public function get ($ url, $ header = array (), $ options = array ()) {
/ **
* @do
* implies this method
* /
}

/ **
* Send patch request
* /
Public Function Patch () {
/ **
* @do
* implies this method
* /
}
/ **
* Send deletion request
* /
public function delete () {
/ **
* @do
* implies this method
* /
}
/ **
* Send a request
* /
public function put () {
/ **
* @do
* implies this method
* /
}
}

?>

php – Laravel eloquent search in areas of related models

I need to do a project search if the $ search variable in the project model matches the name field or name field of the client model

MY CODE

        $ search = "archelier";

$ projects = Projects :: select ()
-> where (& # 39; name & # 39 ;, LIKE & 39 ;,% 39; $ search. & # 39;% & # 39;
-> orWhere (& # 39; clients & # 39 ;, function ($ q) {
$ q-> where (& # 39; name & # 39;, & # 39;% & # 39; $ search. & # 39;% & # 39;);
}) -> get ();

Get the result from the warehouse procedure in MySQL with PHP

Appreciated how I can retrieve the contents of a stick procedure in MySQL with PHP.
I use this code, but I return the following:

Array (1) { [0]=> Array (3) { [0]=> int (153) [1]=> Float (8800) [2]=> int (1)}}

the out of the sp is correct, but i want to be able to do it in php as a variable and do that or json do it to pass it to java as a result.

Enter the code here
$ mysqli = new mysqli ($ DBserver, $ DBuser, $ DBpass, $ DBbase_data);
if ($ mysqli-> connect_error) {

the (& # 39; error in connection & # 39;. $ mysqli-> connect_error);

}
mysqli_set_charset ($ mysqli, "utf8");

// I pass it by hand to test an ID and a value, and it returns these 3 outputs correctly
$ sql = "call orders.SP_quick_qualified (3, 15, @ NewIDOrder, @ Value, @ SeModifico);";
if (! ($ statement = $ mysqli-> prepare ($ sql)))))
echo "Preparation failed: (". $ mysqli-> errno. ")". $ mysqli-> error;
}

if (! $ set-> execute ()) {
echo "Execution failed: (". $ set-> errno. ")". $ statement-> error;
}


do {
if ($ result = $ statement-> get_result ()) {
// aca returns x screen array (1) { [0]=> Array (3) { [0]=> int (153) [1]=> Float (8800) [2]=> int (1)}}
// I want to be able to go through it in a variable
var_dump (mysqli_fetch_all ($ result));
mysqli_free_result ($ result);
} else {
if ($ set-> errno) {
echo "Memory failed: (". $ set-> errno. ")". $ statement-> error;
}
}
} while ($ statement-> more_results () && $ statement-> next_result ());

mysqli_close ($ mysqli);
?>

php – Taxonomy Brand Archive with integration of product categories

The following code is inserted into a Taxonomy brand page and shows all product_cats for a given brand.

    & # 39; product & # 39 ;,
& # 39; # 39 & posts_per_page; => -1,
& # 39; # 39 & tax_query; => array (
& # 39; relation & # 39; => & 39; AND & # 39 ;,
Array (
& # 39; taxonomy & # 39; => & # 39; product_brand & # 39 ;,
& # 39; field & # 39; => & # 39; term_id & # 39 ;,
& # 39; terms & # 39; => $ term_id
)
)
);
$ porductposts = get_posts ($ argsproduct);

$ outprocatslug = array ();
$ outprocatname = array ();
$ outprocatid = array ();

foreach ($ porductposts as $ porductpost) {
$ terms = get_the_terms ($ porductpost-> ID, & # 39; product_cat & # 39;);

if ($ terms &&! is_wp_error ($ terms)) {
foreach ($ terms as $ term) {
$ outprocatid[] = $ term-> term_id;
$ outprocatslug[] = $ term-> slug;
$ outprocatname[] = $ term-> name;
}
}
}

$ termini = get_terms (array ()
& # 39; taxonomy & # 39; => & # 39; product_cat & # 39 ;,
& # 39; include & # 39; => $ outprocatid,
));
foreach ($ termini as $ appointments) {
Echo & # 39;

AdminPosted on Categories ArticlesTags , , , , , ,

ubuntu – Two versions of PHP in Nginx

Well, I have the installation of two versions of PHP, 5.6 and 7.2, with the fpm,

Until then I have everything clear, also install this:

sudo apt install apache2 libapache2-mod-fcgid

sudo apt install python software properties
sudo add-apt repository ppa: ondrej / php

I check them and they work correctly.

Then in the file conf I have it like this

Server {
listen to 8360;
Listen [::]: 8360;

root / var / www / depildiodo /;
index index.php index.html index.htm index.nginx-debian.html;

Server name 82.223.98.245;

error_page 404 /404.php;
location /404.php {
internally;
}

location ~ * . (jpg | jpeg | png | gif | ico | svg) $ {goes out 365d; } location ~ * . (css | js | pdf) $ {expires 30d; }

location ~  .php $ {
Include-snippet / fastcgi-php.conf;

fastcgi_pass unix: /run/php/php5.6-fpm.sock;
}

location ~ /.ht {
deny everything;
}
}

If I set the php7.2, which was originally installed, instead of php5.6 correctly, but if I put the 5.6, which interests me for this project, I load the Web however empty.

Paste a php file into an array

I'm trying to add and fight a custom PHP script inside the nav menu (before closing).

Code here:

    & # 39; Menu 1 & # 39 ;,
& # 39; # 39 & menu_id; => & # 39; primary menu & # 39 ;,
& # 39; # 39 & items_wrap; => & # 39;
    % 3 $ s
    & # 39 ;. $ addCats. & # 39;
& # 39; )); $ addCats = required_once (& # 39; custom_menu_addon.php & # 39;); ?>

The above code contains the file outside the new one added to the menu:

Enter the image description here

Any recommendations on how to print that in the div?
Am I using the wrong command to get the contents of the file there?

Thank you in advance for your help and guidance! <3

ubuntu – custom cms in php – adding e-mail features

So, I have my cms seductiveapps.com, which is now fully converted to the free couchdb JSON db architecture and now supports users, groups, photo and HTML files stored by either a group or a user.

Now I want to add e-mail features to this setup (and must do so according to regulatory requirements).

I googled a bit, and the best I've seen is to use an LDAP server for your user database and an SMTP and IMAP server for both outbound and inbound emails.

That way, with a PHP library that can connect to an IMAP server, you could see emails in your own interface. This is required for my website, as you can see on my website. Things like semi-transparency become a factor.

my question is :
What is the simplest installation path for the LDAP + SMTP + IMAP servers, starting with a new Ubuntu installation with a ubuntu.com installation file downloaded today.
I also need tips on how to connect and manage PHP from any of these 3 servers.
I also need tips on how to make sure that my entire setup can not be abused to set my SMTP server on blacklists worldwide.

These e-mail features are primarily required to comply with new local laws so law enforcement agencies can communicate with people whose content they suspect is violating this law (eg, calls for terrorism or gun manuals, things like that). take offline. ,
and all other normal e-mail functions between users and groups in the system – and the outside world.
SEMrush

Convert binary string into normal PHP to store mongodb

I am importing a large file in PHP with PHP 7.2.10, but it contains some strings in which they have the prefix & # 39; b & # 39; to have:

$ str = b "SQUARE";

When I try to save in MongoDB, I see the following:

Invalid UTF-8 detected for field path "$ set.field": PRA A

When I run mb_detect_encoding ($ str), "UTF-8" is returned.

When I run iconv (mb_detect_encoding ($ str), "UTF-8 // IGNORE", $ str), "PRAA" is returned. I know that // IGNORE ignores non-Utf8 characters.

What can you do to return the string "SQUARE"?

I need exactly this string.

Thank you