Parse error: syntax error, unexpected 'Expires' (T_STRING), expecting ')' in /home/public_html/wp-includes/functions.php on line 1081
i m facing this error in my WordPress site Parse error: syntax error, unexpected 'Expires' (T_STRING), expecting ')' in /home/public_html/wp-includes/functions.php on line 1081
here is the code
if ( $frag ) {
$uri = substr($u
expires Expires header.
* @type string $Cache-Control Cache-Control header.
* }
*/
$headers = (array) apply_filters( 'nocache_headers', $headers );
}
how to fix this?
See also questions close to this topic
-
Permission error with PHP 8 and Session Handler
Dears, I`m refracting old php code 4 to php 8, but I'm having some errors on Session Control. I implementing a SessionHandlerInterface, but I still having error when execute session write
Warning: file_put_contents(../sessions/sess_fc6a0b26f218654ca0f45493861fdf58): failed to open stream: Arquivo ou diretório inexistente in /home/pedro/htdocs/ypanel/session.controller.php on line 36
Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: ../sessions) in Unknown on line 0I'm using Lampp with Mysql on Debian.
Here my class
<?php header('Content-Type: application/json'); //========================================================================================= ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../session')); //========================================================================================= session_save_path("../sessions"); //========================================================================================= error_reporting(2); //========================================================================================= class MySessionHandler implements SessionHandlerInterface { private $savePath; public function open($savePath, $sessionName) { // printf(file_exists($savePath)); // printf(is_dir($this->savePath).' dir'); $this->savePath = $savePath; if (!is_dir($this->savePath)) { chmod($this->savePath,0777); mkdir($this->savePath, 0777,true); } else printf('diretorio ja existe'); return true; } public function close() { return true; } public function read($id) { return (string)@file_get_contents("$this->savePath/sess_$id"); } public function write($id, $data) { return file_put_contents("$this->savePath/sess_$id", $data) === false ? false : true; } public function destroy($id) { $file = "$this->savePath/sess_$id"; if (file_exists($file)) { unlink($file); } return true; } public function gc($maxlifetime) { foreach (glob("$this->savePath/sess_*") as $file) { if (filemtime($file) + $maxlifetime < time() && file_exists($file)) { unlink($file); } } return true; } } $handler = new MySessionHandler(); session_set_save_handler($handler, true); session_start(); ?>
-
Executing PowerShell Script from Server Using PHP
I have a PowerShell script hosted on a server. I am calling PowerShell script from Php as below:
<?php header('Content-Type: text/plain'); $csv = file_get_contents('http://domaincom/wp-content/uploads/csv-samples.csv'); echo $csv; shell_exec('pwsh -File http://domaincom/wp-content/uploads/pscript.ps1'); $psPath = "powershell.exe"; $psDIR = "http://domaincom/wp-content/uploads/"; $psScript = "pscript.ps1"; $runScript = $psDIR. $psScript; $runCMD = $psPath." ".$runScript." 2>&1"; echo "\$psPath $psPath <br>"; echo "\$psDIR $psDIR <br>"; echo "\$psScript $psScript <br>"; echo "\$runScript $runScript <br>"; echo "\$runCMD $runCMD <br>"; exec( $runCMD,$out,$ret); echo "<pre>"; print_r($out); print_r($ret); echo "</pre>"; ?>
Script executes and I can see csv-samples.csv results in browser, but the powershell script doesn't execute. I get below message in browser:
Site,URL,Category Sitepoint,http://www.sitepoint.com/,Web development Html.it,http://www.html.it/,Web development Wamboo,http://www.wamboo.it/,Web development$psPath powershell.exe <br>$psDIR http://domaincom/wp- content/uploads/ <br>$psScript pscript.ps1 <br>$runScript http://domaincom/wp- content/uploads/pscript.ps1 <br>$runCMD powershell.exe http://domaincom/wp- content/uploads/pscript.ps1 2>&1 <br><pre>Array ( [0] => sh: 1: powershell.exe: not found ) 127</pre>
Your help is very much appreciated.
Thank You.
-
mysql select query does not fetch columns
I am trying to log in with php and mysql using the post method, only that when I go to press submit the sql query cannot find the records that exist, and therefore cannot log in this is my code:
<?php session_start(); $hostname=""; $username=""; $password=""; $dbname=""; $conn = new mysqli($hostname,$username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); ?> <script> console.log("Connection to db failed");</script><? } $username = $_POST["username"]; $password = $_POST["password"]; $sql = "SELECT username, password FROM admin WHERE utente = '$username' AND password = '$password'"; if($result = $conn->query($sql)){ if($result->num_rows > 0) echo 'sei loggato!!!'; else echo 'non sei loggato!!!'; } ?>
Could someone tell me what I'm doing wrong? (I did not use prepared statements because it is only a test)
-
How to open a the kiosk mode through a link on a website
i have a problem. I want a page to open in a Firefox Kiosk mode through a link on a website. I am creating a website for schoolchildren through which it should be possible to take exams. The test pages for this should only be opened in kiosk mode to prevent cheating.
I hope someone has an idea.
Greetings
-
Restricted login from WordPress main site to Django web app
I am looking to integrate a wordpress website at mydomain.com with a django web app set up at analytics.mydomain.com. The wordpress website is the main website, where payments are accepted, a user area are that contains the link to the Django analytics tools. The Django app is hosted on another site (e.g Heroku) but is set up as a subdomain.
I would like the database and user authentication and information on WordPress to act as a master to the Django slave rather than vice versa.
How can I integrate authenticated users on the wordpress site, who have paid for analytics functionality, to have access to the django app without requiring login in again, or how can I share the user logins automatically - like an single sign on or something similar?
What is the best way to go about this?
-
Why isnt my ajax response returning anything?
I have an ajax request where I register a user (wordpress). I want the user id to be sent back to the success response, but it just shows undefined, or blank in the case below:
$(document).on('submit', '.register_user_form', function(event){ event.preventDefault(); $.ajax({ type: 'POST', url: '/wp-admin/admin-ajax.php', dataType: 'html', data: { action: 'register_user_form', currentUserName: $("#First_Name").val() + " " + $("#Last_Name").val(), currentUserEmail: $("#email").val(), currentUserPassword: $("#password").val(), }, success: function(res) { console.log(res); } }); });
PHP function (wordpress): function register_user_form() { $user_login = $_POST['currentUserName']; $user_email = $_POST['currentUserEmail']; $user_pass = $_POST['currentUserPassword']; $userdata = compact( 'user_login', 'user_email', 'user_pass' ); $user_id = wp_insert_user($userdata); echo 'this doesnt get returned'; wp_die(); } add_action('wp_ajax_register_user_form', 'register_user_form'); add_action('wp_ajax_nopriv_register_user_form', 'register_user_form');
I have tried
echo json_encode('');
but that doesn't work either. fyi - the user does get registered -
about postfix operator and sequence point
void func(int a){ printf("%d",a); } int main(){ int a= 0; printf("%d", a); func(a++); }
This is my code BUT I can't understand why the result is 0 I think the result has to be 1
Because :
The side effect of updating the stored value of the operand shall occur between the previous and the next sequence point.
"a has to be increased before next sequence point"
All side effects of argument expression evaluations are sequenced before the function is entered
"There's sequence point before function is called"
So Isn't the variable a to be increased before func is called?
Can you tell me what am I understanding wrong?
THANK YOU
-
python invalid syntax during the print function
I typed the following code
a = int(input("Please enter the number of tickets:") b = str(input("PVR Cinemas at Inorbit Mall\n Welcomes You\n Please proceed to select a movie from the given options\nEnter the alphabet preceding to your choice\np:The Hangover - 460/-\nq:The Hunger Games - 500/-\nr:Haikyu - 450/-\ns:Harold - 520/-\n") if b == 'p' print("The total amount billed is:",a*460) elif b == 'q' print("The total amount billed is:",a*560) elif b == 'r' print("The total amount billed is:",a*450) elif b == 's' print("The total amount billed is:",a*520)
-
Beginner PowerShell question: how to combine strings that form a command and run the command in the same script?
I've been working in IS for several years as a PC tech. Mostly hardware & OS troubleshooting. I generally only use
PS
/cmd
for basic tasks - lookup serial #, add/default printers,gpupdate
,DISM
/sfc
, etc. I would like to become more familiar withPowerShell
and creating scripts to start automating some tasks.Since it is customary I present to you my very bad and wrong code:
$PCNAME = Read-Host -Prompt "Enter PC Name" Write-Output $PCNAME $CMD = "Enter-PSSession -ComputerName $PCNAME" iex $CMD
Intended purpose:
- Prompt for PC name input
- Add the entered PC name to the
Enter-PSSession
command - Run
PSSession
command
Just to test if it continues after prompt and executes PSSession command. I've tried quite a few variations using snippets of code I found here and there but I am a PS noob and everything so far either fails to run or exits PS after taking the user's input.
If anyone can show me what a functional version of this looks like I would be greatly appreciative. Thanks!
-
Parse error: syntax error, unexpected ':', expecting ')' displayed
Can someone help me, this is my code I've search for error but i couldnt find it
''''
<?php //Use to fetch product data class Product { public $db = null; public function __construct(DBController $db) { if (!isset($db->con)) return null; $this->db = $db; } //fetch product data using getData method public function getData($table = 'product'){ $result = $this->db->con->query( query: "SELECT * FROM {$table}" ); $resultArray = array(); //fetch product data one by one while ($item = mysqli_fetch_array($result, resulttype: MYSQLI_ASSOC)){ $resultArray[] = $item; } return $resultArray; }
}
''''
Can someone help me?
-
Error ocurred while parsing request parameters (Parse error 783)
I am building an api and my route for POST (create) is /api/v1/studios
The controller
def create @studio = Studio.new(studio_params) if @studio.save render json: @studio, status: :created, location: @studio else render json: @studio.errors, status: :unprocessable_entity end end private def studio_params params.permit(:name) end
When i try to create an instance through curl ->
curl -X POST -v http://localhost:3000/api/v1/studios -H "Content-Type: application/json" -d '{"name":"studio1"}'
All i get is this errori wrote on the title.
Parsing error, could not resolve host: studio1}'
and in the development.log i get:
ActionDispatch::Http::Parameters::ParseError (783: unexpected token at ''{name:Disney}''):
Error occurred while parsing request parameters. Contents:
'{name:Disney}'
-
AJAX Return ParseError with plain text of php file
I am doing an ajax request to a php file to return a certain value. I did some console logs to check the results:
readyState: 4
Status: 200
responseText: php file in plain text
error: parseErrorCan anyone help me?
request:
$.ajax({ type: "get", dataType: 'json', url: "popup.php" , success : function(data) { $("#stock").html("€" + data); }, error:function(xhr,err){ console.log(err); console.log(xhr.responseText) } });
php file:
<?php $array = array(); $url = 'url_name'; $parameters = [ 'start' => '4', 'limit' => '1', 'convert' => 'EUR' ]; $headers = [ 'Accepts: application/json', 'X-CMC_PRO_API_KEY: apikey', 'Content=Type: application/json', ]; $qs = http_build_query($parameters); $request = "{$url}?{$qs}"; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $request, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => 1 )); $response = curl_exec($curl); curl_close($curl); $response_data = json_decode($response); $res_data = $response_data->value; echo json_encode($res_data); ?>
-
Avoid formatString for a specific column
In Apps Script I have this code to convert numbers values in currency values.
And so:function Autocertificazione() { var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var TEMPLATE_ID = 'xxx'; //var TEMPLATE_ID = ss.getRange("TEMPLATEID").getValue(); var ui = SpreadsheetApp.getUi(); if (TEMPLATE_ID === '') { SpreadsheetApp.getUi().alert('TEMPLATE_ID needs to be defined in code.gs') return } var copyFile = DriveApp.getFileById(TEMPLATE_ID).makeCopy(), copyId = copyFile.getId(), copyDoc = DocumentApp.openById(copyId) var docFile = DriveApp.getFileById(copyFile.getId()); // Get Document as File var FILE_NAME = ui.prompt('Inserisci un nome per l\'autocertificazione:', ui.ButtonSet.OK); FILE_NAME.getSelectedButton() == ui.ButtonSet.OK copyDoc.setName(FILE_NAME.getResponseText()) var copyBody = copyDoc.getActiveSection(), activeSheet = SpreadsheetApp.getActiveSheet(), numberOfColumns = activeSheet.getLastColumn(), activeRowIndex = activeSheet.getActiveRange().getRowIndex(), activeRow = activeSheet.getRange(activeRowIndex, 1, 1, numberOfColumns).getValues(), headerRow = activeSheet.getRange(1, 1, 1, numberOfColumns).getValues(), columnIndex = 0 for (;columnIndex < headerRow[0].length; columnIndex++) { var nextValue = formatString(activeRow[0][columnIndex]) copyBody.replaceText('%' + headerRow[0][columnIndex] + '%', nextValue) } copyDoc.saveAndClose() // copyFile.setTrashed(true) SpreadsheetApp.getUi().alert('Autocertificazione creata!!') }
but I would to avoid this for the numbers in col X.
How can I exclude the col X from this function (formatString)? -
Is there any crucial difference between C Compilers?
I'm a newbie to C programming and I've found this strange behaviour while using the following placeholders specification in the function
printf
's argument. I get two different results while using an online C compiler (OnlineGDB) and VSCode with gcc terminal compilation. That's the snippet:#include <stdio.h> int main() { printf("%lld", 4); return 0; }
As Wiki says, "the ll lenght field placeholder is made for integer types, and causes printf to expect a long long-sized integer argument". In the online Compiler I get this:
main.c:13:16: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int’ [-Wformat= ]
4So it prints 4 after a warning.
The result in VSCode is completely different 😲:
15621861207441412
No warnings but where's that number coming from?
Why is there such a different behaviour in such a "simple" situation? Isn't the value 4 also an ll-integer? My guess is that the second one expects a bigger value so it sends me a quite a random value in that interval. Also, I have to study C for a college exam, could you recommend which compiler should I use in compiling sample projects? Thanks a lot for you time.
-
How to allow '{' or '}' characters in a formatted python string
I need to print out a string similar to:
"Field1: {Bob} Field2: {value}"
Where the 1st field is constant, but the second field is formatted from some variable. I tried using a line like this:field_str = "Field1: {Bob} Field2: {}".format(val)
But I get the error:
KeyError: 'Bob'
I'm pretty sure this is because the '{' and '}' characters in the string are being interpreted as something that needs to be formatted even though I want the string to contain those values. This is part of a much larger string, so I would prefer to not manually concatenate the strings together, but I would be ok with somehow adding format characters or something to get it to ignore the values that are inside "{}" in the string.
Is there any way to indicate that a '{' or '}' character is not intended for formatting in a string?