Im using laravel 8 with jetstream authentication and bongodb before changing database from mysql to mongodb (using jenssegers/laravel-mongodb) it was everything work fine but when i use mongodb every post methode doesn't work it give me this erreur ('419 PAGE EXPIRED')
i know where is the probleme exactlty is in this function
namespace Illuminate\Foundation\Http\Middleware;
protected function inExceptArray($request)
{
foreach ($this->except as $except) {
if ($except !== '/') {
$except = trim($except, '/');
}
if ($request->fullUrlIs($except) || $request->is($except)) {
return true;
}
}
return false;
}
i dont know what i miss why it always return false
I changed to SESSION_DRIVER=fil and it worked for me
Related
I have an external WebSocket link where im getting data. My requirement is to receive those data in laravel controller and handle them.
How to listen in controller.
Finally i found the solution.
this has helped me.
$clientWebSoket = new \WebSocket\Client(
'wss://somelink'
);
$clientWebSoket->send(
'{"method":"test","symbols":"some data"}'
);
while ($i) {
try {
$message = $clientWebSoket->receive();
dump($message);
} catch (\WebSocket\ConnectionException $e) {
dd($e);
}
}
$clientWebSoket->close();
Would this be the best way to use the native php sessions instead of using their drivers? Since their drivers are just wrappers around session functions; I figured this would be the easiest way.
The reason behind this is I am having issues with locking with mysql database driver and redis driver. I want to use native php sessions and swap in a redis driver at the php level.
This seems to work well. Any thoughts?
<?php
class MY_Session extends CI_Session
{
public function __construct(array $params = array())
{
$CI =& get_instance();
// No sessions under CLI
if (is_cli())
{
log_message('debug', 'Session: Initialization under CLI aborted.');
return;
}
elseif ((bool) ini_get('session.auto_start'))
{
log_message('error', 'Session: session.auto_start is enabled in php.ini. Aborting.');
return;
}
// Configuration ...
$this->_configure($params);
$this->_config['_sid_regexp'] = $this->_sid_regexp;
// Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers
if (isset($_COOKIE[$this->_config['cookie_name']])
&& (
! is_string($_COOKIE[$this->_config['cookie_name']])
OR ! preg_match('#\A'.$this->_sid_regexp.'\z#', $_COOKIE[$this->_config['cookie_name']])
)
)
{
unset($_COOKIE[$this->_config['cookie_name']]);
}
session_start();
// Is session ID auto-regeneration configured? (ignoring ajax requests)
if ((empty($_SERVER['HTTP_X_REQUESTED_WITH']) OR strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest')
&& ($regenerate_time = config_item('sess_time_to_update')) > 0
)
{
if ( ! isset($_SESSION['__ci_last_regenerate']))
{
$_SESSION['__ci_last_regenerate'] = time();
}
elseif ($_SESSION['__ci_last_regenerate'] < (time() - $regenerate_time))
{
$this->sess_regenerate((bool) config_item('sess_regenerate_destroy'));
}
}
// Another work-around ... PHP doesn't seem to send the session cookie
// unless it is being currently created or regenerated
elseif (isset($_COOKIE[$this->_config['cookie_name']]) && $_COOKIE[$this->_config['cookie_name']] === session_id())
{
setcookie(
$this->_config['cookie_name'],
session_id(),
(empty($this->_config['cookie_lifetime']) ? 0 : time() + $this->_config['cookie_lifetime']),
$this->_config['cookie_path'],
$this->_config['cookie_domain'],
$this->_config['cookie_secure'],
TRUE
);
}
$this->_ci_init_vars();
}
}
I'm integrating QuickBooks API in my newly created laravel app. But I'm always stuck with an error of Failed to open required file. I've been searching for the same problem but none of them works. Is there anyone who have tried to integrate QuickBooks API to their laravel app ? Can you guide me on how do it ?
QuickBooks_Loader::load(): Failed opening required 'C:\wamp64\www\...\vendor\consolibyte\quickbooks/QuickBooks\Driver\.php' (include_path='.;C:\php\pear;C:\wamp64\www\...\vendor\consolibyte\quickbooks')
this is how I set up my qbo env variables.
QB_DSN= mysqli://root:#localhost:3306/omni_qbo
QB_TOKEN=AB11573209674XW53cTKF8xf5lY8vva2A4C8aMliPMWgWGUOl7
QB_OAUTH_CONSUMER_KEY= ABsW9nlMQEpjnzYNvl5ySx1FSqpaibMuJEe1DS0xMMt8bKpQoZ
QB_CONSUMER_SECRET=SxbO5CUvclrWWTFTnVCB1ZWvwk8TjqM67shCv3VP
QB_OAUTH_URL=http://localhost:8000/qbo/oauth
QB_SUCCESS_URL=http://localhost:8000/qbo/success
QB_SANDBOX=true
QB_USERNAME=DO_NOT_CHANGE_ME
QB_TENANT=12345
This is the controller sample code I copied from the link . I just followed the steps on how to integrate quickbooks api to laravel but still not working.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class QuickBookController extends Controller
{
private $IntuitAnywhere;
private $context;
private $realm;
public function __construct(){
if (!\QuickBooks_Utilities::initialized(env('QBO_DSN'))) {
// Initialize creates the neccessary database schema for queueing up requests and logging
\QuickBooks_Utilities::initialize(env('QBO_DSN'));
}
$this->IntuitAnywhere = new \QuickBooks_IPP_IntuitAnywhere(env('QBO_DSN'), env('QBO_ENCRYPTION_KEY'), env('QBO_OAUTH_CONSUMER_KEY'), env('QBO_CONSUMER_SECRET'), env('QBO_OAUTH_URL'), env('QBO_SUCCESS_URL'));
}
public function qboConnect(){
if ($this->IntuitAnywhere->check(env('QBO_USERNAME'), env('QBO_TENANT')) && $this->IntuitAnywhere->test(env('QBO_USERNAME'), env('QBO_TENANT'))) {
// Set up the IPP instance
$IPP = new \QuickBooks_IPP(env('QBO_DSN'));
// Get our OAuth credentials from the database
$creds = $this->IntuitAnywhere->load(env('QBO_USERNAME'), env('QBO_TENANT'));
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
\QuickBooks_IPP::AUTHMODE_OAUTH,
env('QBO_USERNAME'),
$creds);
if (env('QBO_SANDBOX')) {
// Turn on sandbox mode/URLs
$IPP->sandbox(true);
}
// This is our current realm
$this->realm = $creds['qb_realm'];
// Load the OAuth information from the database
$this->context = $IPP->context();
return true;
} else {
return false;
}
}
public function qboOauth(){
if ($this->IntuitAnywhere->handle(env('QBO_USERNAME'), env('QBO_TENANT')))
{
; // The user has been connected, and will be redirected to QBO_SUCCESS_URL automatically.
}
else
{
// If this happens, something went wrong with the OAuth handshake
die('Oh no, something bad happened: ' . $this->IntuitAnywhere->errorNumber() . ': ' . $this->IntuitAnywhere->errorMessage());
}
}
public function qboSuccess(){
return view('qbo_success');
}
public function qboDisconnect(){
$this->IntuitAnywhere->disconnect(env('QBO_USERNAME'), env('QBO_TENANT'),true);
return redirect()->intended("/yourpath");// afer disconnect redirect where you want
}
I am trying to get a cache working in my plugin.
In ext_localconf.php
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension'] = [];}
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension']['frontend'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension']['frontend'] = 'TYPO3\\CMS\\Core\\Cache\\Frontend\\StringFrontend';}
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension']['options'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension']['options'] = ['defaultLifetime' => 0];}
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension']['groups'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['myextension']['groups'] = ['pages'];}
In my controller action :
$cacheIdentifier = 'topic' . $topic->getUid();
$cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('myextension');
$result = unserialize($cache->get($cacheIdentifier));
if ($result !== false ) {
DebuggerUtility::var_dump($result);
} else {
$result = $this->postRepository->findByTopic($topic->getUid(), $page, $itemsPerPage);
$cache->set($cacheIdentifier, serialize($result), ['tag1', 'tag2']);
DebuggerUtility::var_dump($result);
}
The first time the page with the action gets loaded all is ok and the entry has been made in de database (cf_myextension and cf_myextension_tags}.
But the 2nd time the cache gets loaded and I get an error. Even DebuggerUtility::var_dump($result); does not work:
Call to a member function map() on null
in ../typo3/sysext/extbase/Classes/Persistence/Generic/QueryResult.php line 96
*/
protected function initialize()
{
if (!is_array($this->queryResult)) {
$this->queryResult = $this->dataMapper->map($this->query->getType(), $this->persistenceManager->getObjectDataByQuery($this->query));
}
}
/**
A normal var_dump works and spits out the cache entry. What is the problem? Do I forget something? Can't a QueryResult together with some other variables not be stored as an array in the cache? I also tried VariableFrontend cache, which produced the same error.
The E-tools GUI application indents and pretty formats HTML, JavaScript, JSON and SQL. To install the e-tools snap package in all currently supported versions of Ubuntu open the terminal and type:
sudo snap install e-tools
I have the below code to check if the user is coming from a mobile, if they are I want to load a different page but it doesn't seem to be working...
Can anyone shed any light on the below:
if($xmlRefresh==1) {
$viewData['content'] = $this->load->view('newquote/policy_xml', $viewData);
$this->load->view('layout', $viewData);
} elseif ($this->agent->is_mobile()) {
$this->_showPage("newquote/policy_mobile", 'Customise', $viewData);
} else {
$this->_showPage("newquote/policy", 'Customise', $viewData);
}
I keep getting an internal server error, can anyone spot the problem...
Look at your system/core/Loader.php, function view() that will be $this->load->view returns void unless you add third parameter. try with:
$viewData2['content'] = $this->load->view('newquote/policy_xml', $viewData1, TRUE);
and
'''
$this->_showPage("newquote/policy_mobile", 'Customise', $viewData2);
Note: $viewData2 is different with $viewData1
are you calling this in controller?
What is the 500 (internal server) error??
Did you load the library user_agent??
$this->load->library('user_agent');
if($xmlRefresh==1) {
$viewData['content'] = $this->load->view('newquote/policy_xml', $viewData);
$this->load->view('layout', $viewData);
} elseif ($this->agent->is_mobile()) {
$this->_showPage("newquote/policy_mobile", 'Customise', $viewData);
} else {
$this->_showPage("newquote/policy", 'Customise', $viewData);
}
Finally if you want serve the mobile pages, use post post or pre hooks to determine the user agent before view is executed (if you want to play around)
i have one idea, may be help u
you can replace redirect()/$this->load->view() to $this->_showPage("newquote/policy_mobile", 'Customise', $viewData);