preg_match(): No ending delimiter - preg-match

We are using ViPER Guestbook in our websites and getting following error messages:
[20-Jun-2015 12:01:40 UTC] PHP Warning: preg_match(): No ending delimiter '/' found in /home/...../...../gb/index.php on line 277
[20-Jun-2015 12:01:40 UTC] PHP Warning: preg_match(): No ending delimiter '/' found in /home/....../...../gb/index.php on line 278
These lines are:
(!preg_match("/^".PFIX."CUSTOM",$_key)) &&
(!preg_match("/^".PFIX."RATING",$_key))) {
The full code is:
$_b = true;
foreach ($arg as $_key => $_val) {
if ((!in_array($_key,$_paramlist)) &&
(!preg_match("/^".PFIX."CUSTOM",$_key)) &&
(!preg_match("/^".PFIX."RATING",$_key))) {
if (is_array($_val)) {
foreach ($_val as $_inkey => $_inval) {
$_param .= "&".urlencode($_key)."[".
urlencode($_inkey)."]=".urlencode($_inval);
}
}
else {
$_param .= "&".urlencode($_key)."=".urlencode($_val);
}
}
elseif ($_key != PFIX."decode")
$_b = false;
}
Where should the ending delimiter '/' be in this code?
Please help.
Thanks.
Lakshmanan

Thanks for your help.
We have corrected the code to as follows:
(!preg_match("/^".PFIX."CUSTOM/",$_key)) &&
(!preg_match("/^".PFIX."RATING/",$_key))) {
and there is no error messages as of now.
Thanks,
Lakshmanan

Related

Writing to /Users/ahmed.d.hamdallah/.config/psysh/psysh_history is not allowed

I have a macbookpro 2017, and i face a problems when use php artisan tinker. Here's a screenshot of what I got:
[![ErrorException : Writing to /Users/ahmed.d.hamdallah/.config/psysh/psysh_history is not allowed.
at /Applications/XAMPP/xamppfiles/htdocs/blog/vendor/psy/psysh/src/ConfigPaths.php:215
211| if (\is_writable($file)) {
212| return $file;
213| }
214|
> 215| \trigger_error(\sprintf('Writing to %s is not allowed.', $file), E_USER_NOTICE);
216|
217| return false;
218| }
219|
Exception trace:
1 trigger_error("Writing to /Users/ahmed.d.hamdallah/.config/psysh/psysh_history is not allowed.")
/Applications/XAMPP/xamppfiles/htdocs/blog/vendor/psy/psysh/src/ConfigPaths.php:215
2 Psy\ConfigPaths::touchFileWithMkdir("/Users/ahmed.d.hamdallah/.config/psysh/psysh_history")
/Applications/XAMPP/xamppfiles/htdocs/blog/vendor/psy/psysh/src/Configuration.php:376
Please use the argument -v to see more details.][1]][1]
[![ErrorException : Writing to /Users/ahmed.d.hamdallah/.config/psysh/psysh_history is not allowed.
at /Applications/XAMPP/xamppfiles/htdocs/blog/vendor/psy/psysh/src/ConfigPaths.php:215
211| if (\is_writable($file)) {
212| return $file;
213| }
214|
> 215| \trigger_error(\sprintf('Writing to %s is not allowed.', $file), E_USER_NOTICE);
216|
217| return false;
218| }
219|
Exception trace:
1 trigger_error("Writing to /Users/ahmed.d.hamdallah/.config/psysh/psysh_history is not allowed.")
/Applications/XAMPP/xamppfiles/htdocs/blog/vendor/psy/psysh/src/ConfigPaths.php:215
2 Psy\ConfigPaths::touchFileWithMkdir("/Users/ahmed.d.hamdallah/.config/psysh/psysh_history")
/Applications/XAMPP/xamppfiles/htdocs/blog/vendor/psy/psysh/src/Configuration.php:376
Please use the argument -v to see more details.][2]][2]

How to fix laravel migrate receiving "Curl error (code 3): <url> malformed"?

I just pulled some updates in a repository. Then when I use the command "php artisan migrate" it gives me an error. See the screenshot below.
How can I fix this?
Or what seems to be causing this?
Thank you!
Edit
Heres the code for Util.php. But I don't think I should be messing with it since it came from vendors directory.
<?php
namespace Monolog\Handler\Curl;
class Util
{
private static $retriableErrorCodes = array(
CURLE_COULDNT_RESOLVE_HOST,
CURLE_COULDNT_CONNECT,
CURLE_HTTP_NOT_FOUND,
CURLE_READ_ERROR,
CURLE_OPERATION_TIMEOUTED,
CURLE_HTTP_POST_ERROR,
CURLE_SSL_CONNECT_ERROR,
);
public static function execute($ch, $retries = 5, $closeAfterDone = true)
{
while ($retries--) {
if (curl_exec($ch) === false) {
$curlErrno = curl_errno($ch);
if (false === in_array($curlErrno, self::$retriableErrorCodes, true) || !$retries) {
$curlError = curl_error($ch);
if ($closeAfterDone) {
curl_close($ch);
}
throw new \RuntimeException(sprintf('Curl error (code %s): %s', $curlErrno, $curlError));
}
continue;
}
if ($closeAfterDone) {
curl_close($ch);
}
break;
}
}
}
Not a permanent fix, but rather than have this you can commented it out throw new \RuntimeException(sprintf('Curl error (code %d): %s', $curlErrno, $curlError)); and the I had return true;

New Caller Insert to Database with Codeigniter using the Twilio API

Below is the function to receive all incoming calls in my Controller
public function call_incoming()
{
$blocklist = $this->call_log_model->get_blocklist($_REQUEST['From']);
$tenantNum = $this->call_log_model->get_called_tenant($_REQUEST['From']);
$tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_tenant);
$officeStatus = $this->check_office_hours($tenantInfoByNumber->start_office_hours, $tenantInfoByNumber->end_office_hours);
$calldisposition = $this->calldisp_model->get_call_disposition($tenantInfoByNumber->user_id);
$response = new Services_Twilio_Twiml;
if($blocklist == 0)
{
if($officeStatus == "open")
{
if($_POST['Called'] != AGENTPOOL_NUM)
{
$data = array(
'caller'=>$_REQUEST['From'],
'to_tenant'=>$_POST['Called'],
'date_created'=>date('Y-m-d H:i:s')
);
$this->call_log_model->insert_caller_to_tenant($data);
$dial = $response->dial(NULL, array('callerId' => $_REQUEST['From']));
$dial->number(AGENTPOOL_NUM);
print $response;
}
else
{
$gather = $response->gather(array('numDigits' => 1, 'action'=>HTTP_BASE_URL.'agent/call_controls/call_incoming_pressed', 'timeout'=>'5' , 'method'=>'POST'));
$ctr = 1;
foreach($calldisposition as $val )
{
$gather->say('To go to '.$val->disposition_name.', press '.$ctr, array('voice' => 'alice'));
$gather->pause("");
$ctr++;
}
print $response;
}
}
else
{
$response->say('Thank you for calling. Please be advise that our office hours is from '.$tenantInfoByNumber->start_office_hours.' to '.$tenantInfoByNumber->end_office_hours);
$response->hangup();
print $response;
}
}
else
{
$response->say('This number is blocked. Goodbye!');
$response->hangup();
print $response;
}
}
Please advise if I need to post the model...
Here is whats happening everytime an unknown number calls in, the caller will hear an application error has occurred error message and when checking the Twilio console the error it is giving me is
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: agent/Call_controls.php
Line Number: 357
Please be advised that this error only occurs when the caller is a number not in our database yet. When the call comes from a number already saved in our databse, this codes works...
Thank you for the help...
if($tenantNum) {
$tenantInfoByNumber = $this->account_model->getTenantInfoByNumber($tenantNum->to_t‌​enant);
} else {
$tenantInfoByNumber = ""; // fill this in with relevant fill data
}
This should fix your issue, as there is no TenantNum returned, there is no data, so make it yourself for unknown numbers.

tsung_stats.pl on Mac OS X Mavericks run into "Can't locate Template.pm" error

I'm trying to run tsung_stats.pl from tsung (installed through brew) on Mac OS X 10.9 and got error:
Can't locate Template.pm in #INC (#INC contains:
/Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.16
/Network/Library/Perl/5.16/darwin-thread-multi-2level
/Network/Library/Perl/5.16 /Library/Perl/Updates/5.16.2
/System/Library/Perl/5.16/darwin-thread-multi-2level
/System/Library/Perl/5.16
/System/Library/Perl/Extras/5.16/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.16 .) at tsung_stats.pl line 564
I searched and it seems I have to install perl templates, so I ran "sudo cpan Template" and yet still get the same error.
cpan and perl are all in /usr/bin/. Tsung is in /usr/local/Cellar/tsung/1.5.0/bin/tsung
Versions are:
perl: perl 5, version 16, subversion 2 (v5.16.2)
cpan: 1.57
tsung: 1.5.0
I searched my system and found no file name Template.pm. The closest I found was two TextTemplate.pm files in
/System/Library/Perl/Extras/5.16/Locale/Maketext/Extract/Plugin/
/System/Library/Perl/Extras/5.12/Locale/Maketext/Extract/Plugin/
The following code snippet in question starts from line 563:
sub html_report {
require Template;
my $titre = 'Tsung ';
my $version = $tagvsn;
my $contact = 'tsung-users#process-one.net';
my $output = 'index.html';
my $tt = Template->new({
INCLUDE_PATH => $template_dir,
PRE_CHOMP => 1,
INTERPOLATE => 1,
}) or die "Template error " . Template->error();
my $xml_conf;
opendir (DIR, ".") or warn "can't open directory .";
while (my $file = readdir (DIR) ) {
if ($file =~ /.xml$/) {
$xml_conf= $file;
}
}
foreach my $type ("mean", "maxmean", "minmean") {
foreach my $data (keys % {$maxval->{$type}} ) {
next if ($data =~ m/^size/);
if ($data =~ m/os_mon/) {
$maxval->{$type}->{$data} = sprintf "%.2f",$maxval->{$type}->{$data};
next;
}
next if not ($data eq "session" or $data eq "connect" or $data eq "request" or $data eq "page" or $data =~ m/^tr_/);
$maxval->{$type}->{$data} = &formattime($maxval->{$type}->{$data});
}
}
foreach my $size ("size_rcv", "size_sent") {
if ($maxval->{rate}->{$size}) {
$maxval->{rate}->{$size} = &formatsize($maxval->{rate}->{$size}*8,"bits");
$maxval->{maxmean}->{$size} = &formatsize($maxval->{maxmean}->{$size},"B");
} else {
warn "$size is equal to 0 !\n";
}
}
my $vars =
{
version => $version,
os_mon => $extra,
errors => $errors,
title => $titre,
subtitle => "Stats Report",
http => $http,
stats_subtitle => "Stats Report ",
graph_subtitle => "Graphs Report ",
contact => $contact,
data => $maxval,
cat_data => $category,
conf => $xml_conf
};
$tt->process("report.thtml", $vars, "report.html") or die $tt->error(), "\n";
$vars =
{
version => $version,
os_mon => $extra,
errors => $errors,
http => $http,
match => $match,
async => $async,
bosh => $bosh,
title => $titre,
subtitle => "Graphs Report",
stats_subtitle => "Stats Report ",
graph_subtitle => "Graphs Report ",
os_mon_other=> $os_mon_other,
contact => $contact,
conf => $xml_conf,
ext => $imgfmt
};
if (not $dygraph) {
$tt->process("graph.thtml", $vars, "graph.html") or die $tt->error(), "\n";
} else {
$tt->process("graph_dy.thtml", $vars, "graph.html") or die $tt->error(), "\n";
copy (($template_dir . "/dygraph-combined.js"), ".") or die "copy failed : $!";
}
}
I believe $template_dir is in this piece of code (start from line 71):
my $prefix ="/usr/local/Cellar/tsung/1.5.0";
unless ($template_dir) {
if (-d (dirname($0) . "/templates/")) {
$template_dir = dirname($0)."/templates/";
} elsif (-d "$ENV{HOME}/.tsung/templates/") {
$template_dir = "$ENV{HOME}/.tsung/templates/";
} elsif (-d "${prefix}/share/tsung/templates") {
$template_dir = "${prefix}/share/tsung/templates";
} elsif (-d "/usr/share/tsung/templates") {
$template_dir = "/usr/share/tsung/templates";
} elsif (-d "/usr/local/share/tsung/templates") {
$template_dir = "/usr/local/share/tsung/templates";
} else {
warn "Can't find template directory !";
}
}
I checked those locations and found some .pm files, but none were Template.pm.
Any help would be appreciated.
As deduced in the comments:
You need to install Template::Toolkit.
For tsung >= 1.6 and perl 5:
sudo cpan Template
just (on windows) run the following lines on cmd
cd C:\Perl64\bin
ppm install Template-Toolkit
If you tried by running cpan Template or cpan Template:Toolkit and still have this issue, check the version number and the path.
The file: tsung_stats.pl is using /usr/bin/perl and if for some reason you have another perl (like me) in /usr/local/Cellar/perl chances are the script never finds the Template you just installed.
Modify the file tsung_stats.pl in the first line from:
#!/usr/bin/perl -w
to
#!/usr/bin/env perl -w
This will load your perl version used by cpan.

Magento Admin > System > Configuration > Advanced > System - Fatal Error

I get this error when I try to access System > Configuration > Advanced > System
Fatal error: Call to a member function toOptionArray() on a non-object in /home/server/public_html/store/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php on line 421
I found this answer: Fatal error: Call to a member function toOptionArray()
However, the code that needs to be replaced according to that answer is different from the code in that file (Form.php):
if ($method) {
if ($fieldType == 'multiselect') {
$optionArray = $sourceModel->$method();
} else {
$optionArray = array();
foreach ($sourceModel->$method() as $value => $label) {
$optionArray[] = array('label' => $label, 'value' => $value);
}
}
} else {
$optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
}
$field->setValues($optionArray);
}
}
}
return $this;
Any ideas? Thanks!
If you look in Form.php from line 398 to 425 you have almost the same code. The code from your answer isn't a fix, is just a way to help you determine your real problem, so you can use that code:
if(is_object($sourceModel)){
$field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
} else {
Mage::log($e->source_model);
}
And then you would have to look into the Magento log file to see what happened.
Also you can try to log debug_print_backtrace();
Probably your problem comes from a badly written extension.
The following steps should solve the error:-
Disable Compilation (System -> Tools -> Compilation)
Refresh Cache (System -> Cache Management)

Resources