I have a CRM for menaging data, so far so good. I am thinking to add some seetings
extra option on my CRM, i am thinking for a route /seeting-value
and on this to display a form. I mean when a user go to this route to personalize CRM as his like, for example site-name, body-background-color, site-description, maybe to change db config. I know this config have to do with .env
and config/myconfig.php
, what i dont know is how to pass this submit form on emv or my config, how it really works. I have search on google but i didnt find any good documentation about this. Any one have an idea?
Category: PHP
Category Added in a WPeMatico Campaign
404 Not Found nginx/1.14.2 after upgrade PHP 8 on Azure – Laravel
I’m trying to upgrade from PHP 7.4 to PHP 8 on Azure App Service (Linux).
It shows the following error:
404 Not Found – nginx/1.14.2
I understood that the problem is that Azure from PHP 8 use NGINX instead Apache.
So I followed the steps given here:
https://azureossd.github.io/2021/09/02/php-8-rewrite-rule/index.html
For a while it’s worked correctly but from the day after it stopped to work and restart to show the error “404 Not Found
nginx/1.14.2”
This is my default file:
server {
#proxy_cache cache;
#proxy_cache_valid 200 1s;
listen 8080;
listen [::]:8080;
root /home/site/wwwroot;
index index.php index.html index.htm;
server_name example.com www.example.com;
location / {
index index.php index.html index.htm hostingstart.html;
try_files $uri $uri/ /index.php?$args;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /html/;
}
# Disable .git directory
#
location ~ /.git {
deny all;
access_log off;
log_not_found off;
}
# Add locations of phpmyadmin here.
#
location ~ [^/].php(/|$) {
fastcgi_split_path_info ^(.+?.php)(|/.*)$;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 3600;
fastcgi_read_timeout 3600;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}
Get all texts between html tags in string php
i have a string like that:
test test test <span> hello </span> test test test <span> hello2 </span>
and i try to get the text between the span tags like:
array [
0 => 'hello',
1 => 'hello2
];
i tried:
$regex = '#<s*?spanb[^>]*>(.*?)</spanb[^>]*>#s';
$matches = [];
$item->text = preg_match($regex, $item->text, $matches);
but there i only get the first match: ‘hello’
Add a feature to a WordPress plugin
I am working on a website and I found the right plugin for the website.
https://github.com/Falcon90/genuine-product-checker
But I want to add a feature to it
I want the user’s search date and time to be recorded when the user first searches for a serial number, and the next time he or she searches to display a message stating that the serial number has already been queried.
Thank you for helping me guys
Symfony 5 – Clear cache contract command
use SymfonyContractsCacheItemInterface;
use SymfonyComponentCacheAdapterFilesystemAdapter;
$cache = new FilesystemAdapter();
$value = $cache->get('my_cache_key', function (ItemInterface $item) {
$item->expiresAfter(3600);
// ... do some HTTP request or heavy computations
$computedValue = 'foobar';
return $computedValue;
});
I use Symfony 5.4 and the cache contracts on an application and some cache expirations are quite long. My problem is that some values need to be changed and to do it properly, I would need to be able to purge the cache with a command line on my production server to be sure to have correct data.
I can make a custom command ex: php bin/console app:cache:custom-clear
that invalidates some tags but I’m surprised I don’t have a native command to do this cache purge operation globally.
It may be that it’s simple and I didn’t understand anything but I don’t see much in the doc on this point.
If anyone has a lead, I’m interested.
i wanna display all of the ids as one variable and decode it in php [closed]
https://friends.roblox.com/v1/users/1498610208/friends?userSort=StatusFrequents
I wanna get al of the ids into one variable and decode it from JSON
I want the ids to be in one variable. help pls
Query returns null for date not existing – PHP & MYSQL
I am beginner with mysql and PHP Larvel. I have a query thats says
Sale::whereDate('created_at', '>=' , $startDate)
->whereDate('created_at', '<=' , $endDate)
->where('company_id',$companyId)
->selectRaw(implode(',', $query))
->get();
The query below returns data for January since the startDate is ‘2022-01-01’ and endDate is ‘2022-01-31’
But when i do same for February, it returns null because there is no 2022-02-31 in reality. But when i set the endDate to ‘2022-02-29’, it returns data.
How can i make my query still bring data even tho 2022-02-31 does not exist on calendar ?
Registering and running own debug function in Symfony
I am developing a web app using Symfony 5.4 and my current goal is to define and run a function
function setTestDate(): void
{
testdate = $_REQUEST['testdate'] ?? null;
if ((int)$_SERVER['APP_DEBUG'] && $testdate !== null) {
CarbonCarbon::setTestNow($testdate); // provided by Carbon, a real life-saver
}
}
as early as possible, already before the Authenticators are called. I previously tried to run this during the event ‘kernel.request’ but this was already too late in the event flow: My authenticator checks the age of a certain token and without a fixed testdate my fixtures would have to be updated all the time.
I know of many bad places to insert this into (index.php, the Authenticator itself, etc), but does anybody know of a “clean” way to call that function, maybe during SymfonyComponentErrorHandlerDebug::enable()
? It seems like none of the built-in events are that early and I’d hate to edit index.php
. I am aware of onVoterVote()
, but this testdate should be used even if no Authenticator was called.
I guess this looks like I’m over-engineering a minor problem, but I am continuously trying to improve my coding style.
Is there a way to restart reset Opcache periodically or invalidate not accessed files
I’m currently using Plesk for a shared hosting server, this allows me to give every website it’s own PHP-FPM handler. This also means that every website has it’s own seperate Opcache.
The issue with this is that every site can fill it’s own cache.
Let’s say there are 10 sites with 64 MB for Opcache, that’s 640 MB in total!
Lot’s of those sites don’t get visited regularly, so the cache could be cleared after a while.
A solution could be to restart the PHP-FPM process for every site, but this will result in errors for visitors.
Another solution would be 1 PHP-FPM handler, but the cache will get filled by the big sites.
This results in automatic Opcache restarts because the memory is full.
My question: is there a way to reset the cache periodically, or is there a way to clear the files from the cache when they haven’t been access for let’s say a week?
Uncaught Error: Non-static method Database::query() cannot be called statically [duplicate]
I am trying to execute a database query but I am getting this error. I am very frustrated.
class Database {
//verbind met onze database
private $host = DB_HOST; //server naam - normaal localhost
private $dbName = DB_NAME; // Naam van de database
private $username = DB_USER; //Pas aan als dit nodig is
private $password = DB_PASS; //In xamppp is dit normaal leeg maar pas aan als dit nodig is.
private $pdo;
public $lastInsertId;
function __construct() {
$this->startConnection();
}
function startConnection() {
$this->pdo = new PDO("mysql:host=".$this->host.";dbname=".$this->dbName,$this->username,$this->password); //Gebruik de variables die we eerder hebben ge-set
}
public function endConnection(){
$this->pdo = null;
}
public function query($query, $params = array()) {
$statement = $this->pdo->prepare($query);
$statement->execute($params);
if (explode(' ', $query)[0] == 'SELECT') {
$data = $statement->fetchAll();
return $data;
}
}
public function lastID($query, $params = array()){
$stmt = $this->pdo->prepare($query);
$stmt->execute($params);
$ID = $this->pdo->lastInsertId();
$this->lastInsertId = $this->pdo->lastInsertId();
return $ID;
}
This is my database class. I of course handle my database stuff here
This is where I get my error from, this is from another page and it says: Fatal error: Uncaught Error: Non-static method Database::query() cannot be called statically in C:xampphtdocsExcellentTasteviewsReservations.php:7 Stack trace: #0
$reservations = Database::query("SELECT * from reserveringen");
Want to show my user name as default entry in the Interview name tab. Using Php and Mysql
PHP: Warn on undefined array write
Let’s preface this with an example of a script with typo:
$bc = getBaseConcept();
$bs['key'] = doOtherStuff($bc['key']);
return $bc;
Obviously in the middle line is a typo. It should be $bc
instead of $bs
. (And yes this was a legit typo of mine just minutes ago before writing this question)
This did not produce a warning.
So my question is: Is there a configuration option that lets this produce a warning?
Specifically: Writing to an array key of a name that was previously undefined.
E_ALL does not seem to help. This should not only generate the warnings for $bar
but I want also a warning for $foo
.
<?php
ini_set('error_reporting', E_ALL);
echo ini_get('error_reporting'), "n";
$foo['bar'] = $bar['foo'];
32767
PHP Warning: Undefined variable $bar in Standard input code on line 4
PHP Warning: Trying to access array offset on value of type null in Standard input code on line 4
ssh: connect to host (myHostName) port 22: Connection timed out when access project via ssh cpanel
I’m trying to access Laravel project from my local machine to run commands inside project like terminal, I’ve tried to access project folders from my local machine like this:
but I get this error:
ssh: connect to host (myHostName) port 22: Connection timed out when access project via ssh cpanel
also I’ve tried to access (Terminal) from C-panel but there is no terminal appear I don’t know how does C-panel without a Terminal:
I tried to Generate new key in (ssh access) but don’t know how to use it to access the folders to run commands inside the project like terminal??
could you help me to appear terminal in C-panel or access the project folders to run a command via ssh in my local machine terminal?
Unable to detect “Enter key” in Javascript with Php
I am working with php and javascript, I have texarea and i want whenever i enter any text and
press “Enter key” then alert should display,But right now text is going to next line instead of display alert box,
Here is my html code
<textarea placeholder="Write a comment1…" id="txt'.$FeedId.'" rows="1" class="reply_post_new" style="overflow:hidden" onkeypress="return Addcomment1(this)"></textarea>
And here is my script code,Where i am wrong ?
<script>
function Addcomment1(e) {
f (e.keyCode == 13) {
alert('Hello world');
return false;
}
}
</script>
Why css files working in local laravel but not in heroku?
I have Laravel app.
I am referencing a CSS file.
The file is inside a public folder, css app.
it is working fine locally when deploying to heroku, it says 404.
web: vendor/bin/heroku-php-apache2 public/
and my .htcsss
is
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/index.php?$1 [END,QSA]
</IfModule>
both in the root and under public folder.