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

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]

Related

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;

How can I run from exception and receive false in this case

I have this code
function checkIBAN($iban)
{
$iban = strtolower(str_replace(' ','',$iban));
$Countries = array('al'=>28,'ad'=>24,'at'=>20,'az'=>28,'bh'=>22,'be'=>16,'ba'=>20,'br'=>29,'bg'=>22,'cr'=>21,'hr'=>21,'cy'=>28,'cz'=>24,'dk'=>18,'do'=>28,'ee'=>20,'fo'=>18,'fi'=>18,'fr'=>27,'ge'=>22,'de'=>22,'gi'=>23,'gr'=>27,'gl'=>18,'gt'=>28,'hu'=>28,'is'=>26,'ie'=>22,'il'=>23,'it'=>27,'jo'=>30,'kz'=>20,'kw'=>30,'lv'=>21,'lb'=>28,'li'=>21,'lt'=>20,'lu'=>20,'mk'=>19,'mt'=>31,'mr'=>27,'mu'=>30,'mc'=>27,'md'=>24,'me'=>22,'nl'=>18,'no'=>15,'pk'=>24,'ps'=>29,'pl'=>28,'pt'=>25,'qa'=>29,'ro'=>24,'sm'=>27,'sa'=>24,'rs'=>22,'sk'=>24,'si'=>19,'es'=>24,'se'=>24,'ch'=>21,'tn'=>24,'tr'=>26,'ae'=>23,'gb'=>22,'vg'=>24);
$Chars = array('a'=>10,'b'=>11,'c'=>12,'d'=>13,'e'=>14,'f'=>15,'g'=>16,'h'=>17,'i'=>18,'j'=>19,'k'=>20,'l'=>21,'m'=>22,'n'=>23,'o'=>24,'p'=>25,'q'=>26,'r'=>27,'s'=>28,'t'=>29,'u'=>30,'v'=>31,'w'=>32,'x'=>33,'y'=>34,'z'=>35);
try{
$cntr=(in_array(substr($iban,0,2),$Countries)) ? $Countries[substr($iban,0,2)] : false;
if(strlen($iban) == $cntr){
$MovedChar = substr($iban, 4).substr($iban,0,4);
$MovedCharArray = str_split($MovedChar);
$NewString = "";
foreach($MovedCharArray AS $key => $value){
if(!is_numeric($MovedCharArray[$key])){
$MovedCharArray[$key] = $Chars[$MovedCharArray[$key]];
}
$NewString .= $MovedCharArray[$key];
}
if(bcmod($NewString, '97') == 1)
{
return TRUE;
}
else{
return FALSE;
}
}
else{
return FALSE;
}
}catch (Exception $e) {
report($e);
return false;
}
}
And I receive this exception in Laravel
{message: "Undefined offset: 21", exception: "ErrorException",…}
exception
:
"ErrorException"
"Undefined offset: 21" in this string $Countries[substr($iban,0,2)]
How can I run from Exception and receive just a false in this case? Because of that fact that my function which is checking iban must receive only true or false not an Exception. If I receive an Exception that is 500error in Ajax
There are quite a few tested iban validation libraries on the packagist.
https://packagist.org/?q=iban&p=0
I'd use one of these instead.
Much better than some crusty code copied off another stackoverflow question.
A "ErrorException" is laravel's error handler turning a php error into an exception. You can avoid the error by adding checks before doing array access.
Consider this example:
$MovedCharArray[$key] = $Chars[$MovedCharArray[$key]];
It assumes that $MovedCharArray has an index of $key and assumes that $Chars has an index of $MovedCharArray[$key]. If any of those don't exist, you'll get that error.
Add some checks before attempting to access those array elements and you can avoid the error.
if(isset($MovedCharArray[$key]) && isset($Chars[$MovedCharArray[$key]])){
$MovedCharArray[$key] = $Chars[$MovedCharArray[$key]];
}else{
//Some error condition you'll need to deal with.
}

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.

preg_match(): No ending delimiter

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

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