Ive got the error below
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in C:\xampp\htdocs\suitecrm\include\Smarty\Smarty_Compiler.class.php on line 268
I have changed the PHP.ini file to stop showing deprecated errors, but it still shows up
error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT
I've also changed the line in the Smarty_Compiler.class
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
But its not working..
Please advise
I found that and it seems working:
Replace lines from line 262 with:
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search,
function($m) {
return "{php ".str_repeat("\n", substr_count($m[0], "\n"))."}";
},
$source_content);
I have resolved this issue by replacing the code in include/Smarty/Smarty_Compiler.class.php file. I replaced the code on line numbers from 262 to 268 with the below mentioned code. After that delete all the files which are in the cache folder and reload the page. This issue will be resolved.
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content);
My solution:
$source_content = preg_replace_callback($search,
function($m) {
return $this->_quote_replace($this->left_delimiter) .
"php ".str_repeat("\n", substr_count($m[0], "\n")) .
$this->_quote_replace($this->right_delimiter);
},
$source_content);
In solution from Axel De Acetis I miss using of function $this->_quote_replace.
In solution from Sandeep Shivhare I dont like the number 1 in $matches[1], it references wrong string.
Related
i'm experiencing one problem here. Sample will speak for it self.
Queue::after(function (JobProcessed $event) {
$job_details = json_decode($event->job->getRawBody(), true);
)});
This is how $job_details looks like:
'displayName' => 'App\\Jobs\\CommandJob',
'job' => 'Illuminate\\Queue\\CallQueuedHandler#call',
'maxTries' => 10,
'timeout' => NULL,
'data' =>
array (
'commandName' => 'App\\Jobs\\CommandJob',
'command' => 'O:19:"App\\Jobs\\CommandJob":9:{s:32:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'commandName";N;s:30:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'arguments";N;s:28:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'command";s:20:"google:get-campaigns";s:5:"tries";i:10;s:32:"' . "\0" . 'App\\Jobs\\CommandJob' . "\0" . 'nextCommand";a:1:{i:0;s:19:"google:get-adgroups";}s:6:"' . "\0" . '*' . "\0" . 'job";N;s:10:"connection";N;s:5:"queue";s:11:"update_data";s:5:"delay";N;}',
I would like to get some params from $job_details['data']['command'].
Is there some simple way to do this , or i need some home made soultion ?
$event->job->getRawBody returns a string so you can't write $job_details['data']['command'] and you will end up with Illegal string offset error.
I am using Laravel 5.4 and i have managed to retrieve my Job instance using $event->job->payload() then applying the unserialize method according to the documentation.
So what i did is :
$payload = $event->job->payload();
$myJob = unserialize($payload['data']['command']);
$myJob->getMyProperty();
//... Just work with $myJob as if it were your job class
The $job_details["data"]["command"] is a string generated from serialize($value). You can unserialize($str) it to create the job object represented by your string. You will then have access to the properties according to the usual visibility rules.
$job = unserialize($job_details["data"]["command"]);
dump($job->queue;) // "update_data"
I was having error with an email that contained some space in it. To fix the problem and send it, I had to decode the payload of the failed jobs and remove the space in the email.
To do so, in php artisan tinker
// take some specific failed jobs
$failed_job = DB::table('failed_jobs')->where('id', $your_job_id)->first();
$payload = json_decode($failed_job->payload);
$obj = unserialize($payload->data->command);
// here I have the user content, I can see the wrong email
$user = $obj->notifiables;
//update email and save
$user->email = "newemail#something"
$user->update()
As the last step, push again the jobs into the queue.
I have a page retrieved using a Mechanize session and I need to click on a Mechanize::Page::Link as in this example:
my_link = #session.page.link_with(:id => "aPageLink")
# my_link.class == Mechanize::Page::Link
.
.
.
#session.click(my_link)
However, I need to modify the uri used in the link before it is clicked.
my_link = #session.page.link_with(:id => "aPageLink")
# my_link.class == Mechanize::Page::Link
.
.
.
# modify my_link here
.
.
.
#session.click(my_link)
How would I do that?
I should add that I've tried the following already [should have mentioned these earlier then some unrelenting soul wouldn't have marked down my question!]...
my_link.href = "my/modified/uri"
my_link['href'] = "my/modified/uri"
Solution from pguardiario's suggestion is as follows.
my_link = #session.page.link_with(:id => "aPageLink")
# modify my_link
modified_link = my_link.href
modified_link.sub!(/modification/, '')
# #session.click(my_link) <-- now replaced with following line
#session.get modified_link, [], my_link.referer
Many thanks!
In the new version of Googles PHP-API-Cient the Google_Signer_P12 class was removed and now you should create signed urls via Firebase JWT (see https://github.com/google/google-api-php-client/blob/master/UPGRADING.md).
Unfortunately this doesn't work for me (I am trying to generate signed urls for cloud storage downloads). My previous (working) code looked like this:
$signer = new \Google_Signer_P12( 'privatekey.p12' , 'notasecret' );
$stringToSign = 'GET' . "\n" . "\n" . "\n" . $expires . "\n". '/' . $bucketName . '/' . $fileName;
$signature = $signer->sign( utf8_encode( $stringToSign ) );
$finalSignature = \Google_Utils::urlSafeB64Encode( $signature );
I tried to replace this with:
$stringToSign = 'GET' . "\n" . "\n" . "\n" . $expires . "\n". '/' . $bucketName . '/' . $fileName;
$finalSignature = \JWT::encode(
$stringToSign,
'privateKey.p12'
);
but I receive a "SignatureDoesNotMatch" error. Unfortunately I couldn't find anything in the docs on how to upgrade this part of the code.
Is there a way to adjust the size of gorcery CRUD's list thumbnails?
The way it is now it's just silly big, and breaks the table flow.
If possible, it would be nice to have a PHP solution or grocery CRUD setting for this; if not - a CSS rule would be ok, I guess.
Same issue I came across, I'm sure it's a quick-and-dirty solution but it worked for me.
Open your application/library/Grocery_CRUD.php
Download timthumb from here
Place timthumb.php in Root directory (in same directory
level cache folder should be there)
Find function change_list_value
Find around line number 333 in Grocery_CRUD.php
$file_url_anchor .= 'class="image-thumbnail">';
Replace with... following
$file_url_anchor .= ' class="image-thumbnail"><img src="' . base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3' .'" height="50px">';
Again Find function get_upload_file_input
Find around line number 2545 in Grocery_CRUD.php
$input .= $is_image ? " $image_class'>" : "' target='_blank'>$value";
Replace with following
$input .= $is_image ? " $image_class'><img src='".base_url('timthumb.php') . '?src=' . $file_url . '&w=100&h=100&zc=3'."' height='50px'>" : "' target='_blank'>$value";
Hope this would help you to get rid of ugly size in your list as well as add/edit forms
I know this issue has been discussed in different questions but the answers people have given don't seem to work on my end. I'm dealing with the following problem:
if ( (preg_match($suspect, $lowmsg) )
|| (preg_match($suspect, strtolower($_POST['name'])))
|| (preg_match($suspect, strtolower($_POST['email']))))
Now, people have been saying that if I put "/" in front and behind quotes like so '/email/' that this would solve the problem. I tried putting the / for email and name but it still brought me back to the same delimiter error.
I also get a final error of: Warning: Cannot modify header information - headers already sent by (my website's send.php:43) on line 61. Does this have anything to do with it or is this just an error as a result of the earlier error?
Here's the entire code for interested parties:
<?php
if(($_POST['email']=="")||($_POST['name']=="")||($_POST['message']==""))
{
echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>";
if($_POST['name'] == ""){ echo "<li>Name</li>"; }
if($_POST['email'] == ""){ echo "<li>Email</li>"; }
if($_POST['message'] == ""){ echo "<li>Message</li>"; }
echo "</ul><p>Please use your browser's back button to complete the form.</p></body></html>";
}
else
{
$message = "";
$message .= "Name: " . htmlspecialchars($_POST['name'], ENT_QUOTES) . "<br>\n";
$message .= "Email: " . htmlspecialchars($_POST['email'], ENT_QUOTES) . "<br>\n";
$message .= "Message: " . htmlspecialchars($_POST['message'], ENT_QUOTES) . "<br>\n";
$subject = htmlspecialchars($_POST['subject'], ENT_QUOTES);
$pagelink = htmlspecialchars($_POST['pagelink'], ENT_QUOTES);
$repemail = htmlspecialchars($_POST['repemail'], ENT_QUOTES);
$injection_strings = array ( "content-type:","charset=","mime-version:","multipart/mixed","bcc:","cc:");
foreach($injection_strings as $suspect)
{
if((preg_match($suspect, $lowmsg)) || (preg_match($suspect, strtolower($_POST['/name/']))) || (preg_match($suspect, strtolower($_POST['/email/']))))
{
die ( 'Illegal Input. Go back and try again. Your message has not been sent.' );
}
}
$headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: \"" . $_POST['/name/'] . "\" <" . $_POST['/email/'] . ">\r\n";
$headers .= "Reply-To: " . $_POST['/email/'] . "\r\n\r\n";
mail($repemail, $subject, $message, $headers);
header("Location: " . $pagelink . "");
}
?>
You can try other delimiters, such as / # ~
see regexp.reference.delimiters
Hope that helps.
EDIT: you do not need to do backslash inside $_POST
Use $_POST['name'] instead of $_POST['/name/']
EDIT: try
preg_match("/".$suspect."/i", strtolower($_POST['name']);
However, I dont think you would find any of your $injection_strings inside post name. You may need to rethink how you are searching. "content_type" is not going to match "text/html" with your current statement. You'd need to try other regex like
preg_match("/".$suspect."(.*)/i", strtolower($_POST['name'], $output);
So that it would $output[0], your "suspect" variable. I'm not sure if thats what you are looking for, but maybe sending you to the right track.
EDIT: Here.
If you want to look at say "cc:" and find what email it is, use this.
preg_match("/cc:(.*)/i",'cc:'.$_POST['email'],$output);
$output[0]; would equal your email.
To be compatible with your foreach loop, you may want to change it too,
switch this below code within your "if statements"
preg_match("/".$suspect."(.*)/i",$suspect.$_POST['email'])