how to fix Issue with codeigniter 4 after pushing to live server - php

After building my website on localhost it works fine but when I launched it to a live server, the homepage displays, and few other pages as others couldn't. Please can someone help me out?
I got this error
rewind($this->fileHandle);
207 }
208
209 $session_data = '';
210 clearstatcache(); // Address https://github.com/codeigniter4/CodeIgniter4/issues/2056
211 for ($read = 0, $length = filesize($this->filePath . $sessionID); $read < $length; $read += strlen($buffer))
212 {
213 if (($buffer = fread($this->fileHandle, $length - $read)) === false)
214 {
215 break;
216 }
217
218 $session_data .= $buffer;
219 }
and this
Fatal error: Uncaught ErrorException: Unknown: Cannot call session save handler in a recursive manner in Unknown:0 Stack trace: #0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'Unknown: Cannot...', 'Unknown', 0, NULL) #1 {main} thrown in Unknown on line 0

Related

SMPP/PHP - SmppException Failed to read reply to command: 0x4 (php/smpp master)

Need pro help
Im trying to send sms to my smpp server using onlinecity/php-smpp lib Master.
Code:
<?php
require_once "smpp/smppclient.class.php";
require_once "smpp/gsmencoder.class.php";
require_once "smpp/sockettransport.class.php";
// Construct transport and client
$transport = new SocketTransport(array("my smpp server ip"),2775);
$transport->setSendTimeout(10000);
//$transport->setRecvTimeout(10000);
$smpp = new SmppClient($transport);
$smpp->debug = true;
$transport->debug = true;
// Open the connection
$transport->open();
$smpp->bindTransmitter("test user", "test pass");
// Optional connection specific overrides
//SmppClient::$sms_null_terminate_octetstrings = false;
//SmppClient::$csms_method = SmppClient::CSMS_PAYLOAD;
//SmppClient::$sms_registered_delivery_flag = SMPP::REG_DELIVERY_SMSC_BOTH;
// Prepare message
$message = 'Hello world bla bla';
$encodedMessage = GsmEncoder::utf8_to_gsm0338($message);
$from = new SmppAddress('SMPP Test',SMPP::TON_ALPHANUMERIC);
$to = new SmppAddress(4512345678,SMPP::TON_INTERNATIONAL,SMPP::NPI_E164);
// Send
$messageID = $smpp->sendSMS($from,$to,$encodedMessage);
// Close connection
$smpp->close();
?>
Browser response:
Fatal error: Uncaught SmppException: Failed to read reply to command: 0x4 in /home1/myproject/ems.myproject.com/smpp/smppclient.class.php:620
Stack trace:
#0 /home1/myproject/ems.myproject.com/smpp/smppclient.class.php(392): SmppClient->sendCommand(4, '\x00\x05\x00SMPP Test\x00\x01\x01...')
#1 /home1/myproject/ems.myproject.com/smpp/smppclient.class.php(340): SmppClient->submit_sm(Object(SmppAddress), Object(SmppAddress), 'Hello Voz bla b...', NULL, 0)
#2 /home1/myproject/ems.myproject.com/send_sms.php(35): SmppClient->sendSMS(Object(SmppAddress), Object(SmppAddress), 'Hello world bla b...')
#3 {main}
thrown in /home1/myproject/ems.myproject.com/smpp/smppclient.class.php on line 620
smppclient.class.php:
614 protected function sendCommand($id, $pduBody)
615 {
616 if (!$this->transport->isOpen()) return false;
617 $pdu = new SmppPdu($id, 0, $this->sequence_number, $pduBody);
618 $this->sendPDU($pdu);
619 $response=$this->readPDU_resp($this->sequence_number, $pdu->id);
620 if ($response === false) throw new SmppException('Failed to read reply to command: 0x'.dechex($id));
621
622 if ($response->status != SMPP::ESME_ROK) throw new SmppException(SMPP::getStatusMessage($response->status), $response->status);
623
624 $this->sequence_number++;
625
626 // Reached max sequence number, spec does not state what happens now, so we re-connect
627 if ($this->sequence_number >= 0x7FFFFFFF) {
628 $this->reconnect();
629 }
630
631 return $response;
Note:
PHP 7.4 on Apache
Anyone please help to identify what im doing wrong.
*** Please advice if there any better updated lib for php/smpp

php foreach loop with urls from file

I am trying to the status of urls which are stored in a text file
in my code i have:
$filestatus = file("urlsmartins_status.txt");
foreach ($filestatus as $filestate){
$filestatusurl = (file_get_contents("$filestate"));
$filestatusurlxml = new SimpleXMLElement ($filestatusurl);
print_r ($filestatusurlxml);
}
in the urlsmartin_status.txt i have 5 urls written
http://172.27.73.5:8080/api/service/
http://172.27.73.6:8080/api/service/
http://172.27.73.7:8080/api/service/
http://172.27.73.8:8080/api/service/
But when i execute the code i have the following result
PHP Warning: file_get_contents(http://172.27.73.5:8080/api/service/
): failed to open stream: HTTP request failed! HTTP/1.1 404 OK
PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in ...
Stack trace:
#0 /opt/rh/httpd24/root/var/www/html/pub/martin.php(56): SimpleXMLElement->__construct('')
#1 {main}
thrown in /opt/rh/httpd24/root/var/www/html/pub/martin.php on line 56
What am i missing here?
Thanks
the problem here is that the lines in your file are not "XML", hence SimpleXMLElement cannot be instantiated.
I get the same error like this:
I managed to fix it via
$filedata = file_get_contents('urlsmartins_status.txt');
$urls = explode("\n", trim($filedata));
foreach($urls as $key => $url) {
$filestatusurl = file_get_contents("$url");
$filestatusurlxml = new SimpleXMLElement ($filestatusurl);
print_r ($filestatusurlxml);

Curl error when try to download file using Dropbox API

This is my first attempt using Dropbox API and I'm just following the "Hello World" from PHP SDK. Upload methods is working fine, but download:
$app = new DropboxApp("...", "...", "...");
$dropbox = new Dropbox($app);
$file = $dropbox->download("/image.png", '/image.png');
Return this warning:
Warning: curl_exec(): Could not call the CURLOPT_WRITEFUNCTION in
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php
on line 40
Fatal error: Uncaught RuntimeException: Unable to open /image.png
using mode w+: fopen(/image.png): failed to open stream: Permission
denied in
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/psr7/src/functions.php:299
Stack trace: #0 [internal function]: GuzzleHttp\Psr7{closure}(2,
'fopen(/unifeal-...', '/srv/www/website/...', 307, Array) #1
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/psr7/src/functions.php(307):
fopen('/image.p...', 'w+') #2
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/psr7/src/LazyOpenStream.php(37):
GuzzleHttp\Psr7\try_fopen('/image.p...', 'w+') #3
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php(31): GuzzleHttp\Psr7\LazyOpenStream->createStream() #4
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php(136):
GuzzleHttp\Psr7\LazyOpenStream->__get('stream') #5
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(380):
GuzzleHttp\Psr7\LazyOpenStream-> in
/srv/www/website/public_html/dropbox/vendor/guzzlehttp/psr7/src/functions.php
on line 299
I'm testing using Vagrant.
UPDATE
I can confirm that is not a permission issue because download works using this script:
$file = $dropbox->download("/image.png");
$contents = $file->getContents();
file_put_contents(__DIR__ . "/image.png", $contents);
$metadata = $file->getMetadata();
But not using the recommended way.

Dropbox API for PHP gives error

I am trying to upload a file in chunks via Dropbox's API for PHP.
This is my code: This gives out the folowing error:
First few chunks are uploaded and then I get this error:-
Fatal error: Uncaught exception 'Dropbox\Exception_NetworkIO' with message 'Erro
r executing HTTP request: Failed to connect to api-content.dropbox.com port 443:
Connection refused' in /home/yashtk1/public_html/dropbox/Dropbox/Curl.php:69
Stack trace:
#0 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(721): Dropbox\Curl->exec
()
#1 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(602): Dropbox\Client->_c
hunkedUpload(Array, '`S\xCDb0\x80`\xA0\xD3\xB7\xEA\x07\xF1\xF7\xB4...')
#2 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(437): Dropbox\Client->ch
unkedUploadContinue('jB2ZQWVyzMQgsX4...', 41943040, '`S\xCDb0\x80`\xA0\xD3\xB7\x
EA\x07\xF1\xF7\xB4...')
#3 /home/yashtk1/public_html/dropbox/Dropbox/RequestUtil.php(278): Dropbox\Clien
t->Dropbox\{closure}()
#4 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(438): Dropbox\RequestUti
l::runWithRetry(3, Object(Closure))
#5 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(381): Dropbox\Client->_u
ploadFileChunked('/ahmd1.zip', Object(Dropbox\WriteMode), Resource i in /home/ya
shtk1/public_html/dropbox/Dropbox/Curl.php on line 69
My script:-
<?php
echo "hi";
set_time_limit(0);
# Include the Dropbox SDK libraries
require_once "Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("config");
$f = fopen("ahmd1.zip", "rb");
$dbxClient = new dbx\Client("Access code", "PHP-Example/1.0");
$mode = dbx\WriteMode::add();
$chunk = $dbxClient->uploadFileChunked("/ahmd1.zip", $mode, $f);
print_r($chunk);
//uploadFileChunked( string $path, Dropbox\WriteMode $writeMode, resource $inStream, integer|null $numBytes = null, integer|null $chunkSize = null );
fclose($f);
?>
Please can anyone point out the mistake ?

Yii: How to create yii application object in another php application?

I want to use Yii functions in another open source project (moodle, joomla, ...) So I can benefit Yii powerful models.
I put following code in one of the files (ROOT/course/edit.php):
$yii = dirname(__FILE__) . '/../mws/framework/yii.php';
$config = dirname(__FILE__) . '/../mws/protected/config/main.php';
defined('YII_DEBUG') or define('YII_DEBUG', TRUE);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once($yii);
Yii::createWebApplication($config);
But I get following error:
PHP warning include(edit.php.php) [function.include]: failed to open stream:
No such file or directory
D:\WAMP\www\millms\mws\framework\YiiBase.php(427) 415
{ 416 include($classFile); 417
if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php')
418 throw new
CException(Yii::t('yii','Class name "{class}" does not match class
file "{file}".', array( 419
'{class}'=>$className, 420
'{file}'=>$classFile, 421 )));
422 break; 423
} 424 } 425 } 426
else 427 include($className.'.php'); 428
} 429 else // class name with namespace in PHP 5.3
430 { 431
$namespace=str_replace('\','.',ltrim($className,'\')); 432
if(($path=self::getPathOfAlias($namespace))!==false) 433
include($path.'.php'); 434 else 435
return false; 436 } 437 return
class_exists($className,false) || interface_exists($className,false);
438 } 439 return true; Stack Trace
#0 + D:\WAMP\www\millms\mws\framework\YiiBase.php(427):
YiiBase::autoload() #1 unknown(0):
YiiBase::autoload("edit.php") #2 unknown(0):
spl_autoload_call("edit.php") #3 –
D:\WAMP\www\millms\lib\formslib.php(831): is_a("edit.php",
"moodle_url") 826 static $formcounter = 1; 827
828 HTML_Common::HTML_Common($attributes); 829
$target = empty($target) ? array() : array('target' => $target);
830 $this->_formName = $formName; 831 if
(is_a($action, 'moodle_url')){ 832 $this->_pageparams
= $action->hidden_params_out(); 833 $action = $action->out(true); 834 } else { 835
$this->_pageparams = ''; 836 } #4 –
D:\WAMP\www\millms\lib\formslib.php(115):
MoodleQuickForm->MoodleQuickForm("course_edit_form", "post",
"edit.php", "", ...) 110 $action =
strip_querystring(qualified_me()); 111 } 112 113
$this->_formname = get_class($this); // '_form' suffix kept in order
to prevent collisions of form id and other element 114
$this->_customdata = $customdata; 115 $this->_form =& new
MoodleQuickForm($this->_formname, $method, $action, $target,
$attributes); 116 if (!$editable){ 117
$this->_form->hardFreeze(); 118 } 119
$this->set_upload_manager(new upload_manager()); 120 #5
– D:\WAMP\www\millms\course\edit.php(448):
moodleform->moodleform("edit.php", array("course" => null, "category"
=> stdClass)) 443 } 444 } 445 446 447 /// first create the form 448 $editform = new
course_edit_form('edit.php', compact('course', 'category')); 449
// now override defaults if course already exists 450 if
(!empty($course)) { 451 $course->enrolpassword =
$course->password; // we need some other name for password field
MDL-9929 452 $editform->set_data($course); 453 }
How I can Create A raw Yii Application Object?

Categories