Posts

Showing posts with the label php

I don't understand JWT refresh token's behaviour (LARAVEL)

Image
Clash Royale CLAN TAG #URR8PPP I don't understand JWT refresh token's behaviour (LARAVEL) I have just tried JWT auth with LARAVEL and this https://github.com/tymondesigns/jwt-auth But there's something i can't understand. In their config they put : 'ttl' => env('JWT_TTL', 60), // in munutes 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160), // in minutes What i understant : the token's live is 1hour and can be refreshed within 2 weeks But after 3hours, if i try to query something, it says "token expired". Does this system mean, a user must get his token updated / refreshed within every hour but with a limit of 2 weeks ? I don't get it. How can a user persist login with this kind of system ? How is the refresh Token useful when after the first hour, though it hasn't been 2 weeks yet, i can't get a fresh token ? thanks UPDATE: CODE config/jwt.php 'ttl' => 2, // 2 minutes 'refresh_ttl' => 5,...

Upload files into SFTP server using PHP

Image
Clash Royale CLAN TAG #URR8PPP Upload files into SFTP server using PHP This is my first time using sftp, and I'm stuck "This was pedictable"...I have a csv file dowloanded via web browser into my Downloads Directory using a "Webservice" permetting such thing, and I wanna upload this file into a sftp server. I've tried many codes that I've found here or on other websites but none of them worked. Here is two examples of codes I tried to run: FISRT EXAMPLE: <?php $ftp_server = 'example.server.net'; // Address of FTP server. $ftp_user_name = 'username'; // Username $ftp_user_pass = 'password'; // Password $destination_file = "serverpath"; //where you want to throw the file on the webserver (relative to your login dir) $conn_id = ftp_connect($ftp_server,22) or die("<span style='color:#FF0000'> <h2>Couldn't connect to $ftp_server</h2></span>"); //set up basic connection $login_r...

json_decode foreach into table

Image
Clash Royale CLAN TAG #URR8PPP json_decode foreach into table Having Issues with nested arrays I Want to get the array title into the first cell of the table, having an issue articulated the nested foreach. $content = file_get_contents("https://whattomine.com/asic.json"); $data = json_decode($content); echo "coins"; foreach() { echo "<tr>"; echo "<th>".$coins->coinname."</th>"; echo "<th>".$coins->PoW."</th>"; echo "<th>".$coins->PoS."</th>"; echo "<th>".$coins->height."</th>"; echo "<th>".$coins->diff."</th>"; echo "<th>".$coins->supply."</th>"; echo "</tr>"; } By clicking "Post Your Answer", you acknowledge that you have read our updated terms o...

Retrieve data from second sql table inside a modal using php

Image
Clash Royale CLAN TAG #URR8PPP Retrieve data from second sql table inside a modal using php So the question would be, how can I retrieve data for Locatie (drop-down list) inside the modal if the data is in a second table named locationstbl with the column named address in sql. There might be some way to use JOIN or something like that just to display the data I need in that dropdown list ? Thank you. Here's the code. <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>#</th> <th>Locatie</th> <th>Serie Aparat</th> <th>Tip Joc</th> <th>Cabinet</th> <th>Data Expirare</th> <th>Actiuni</th> </tr> </thead> <tbody> <?php $sql = ...

PHP Sorting an array or arrys by letter

Image
Clash Royale CLAN TAG #URR8PPP PHP Sorting an array or arrys by letter Can anyone help me sort the following array so that the arrays are in alphabetical order? Array ( [k] => Array ( [0] => Array () [1] => Array () ) [A] => Array ( [0] => Array () [1] => Array () ) [M] => Array ( [0] => Array () [1] => Array () ) [B] => Array ( [0] => Array () [1] => Array () ) ) Many thanks Are you looking for ksort ? – Eddie 1 min ago ksort By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that...

How to access AT commands from PHP in Rasspberry Pi3?

Image
Clash Royale CLAN TAG #URR8PPP How to access AT commands from PHP in Rasspberry Pi3? I've tried from Raspberry Pi3 use minicom command and it works. SIM module is SIM7600CE. Just could not execute that command from PHP. <?php include '../src/PhpSerial.php'; $serial = new PhpSerial; $serial->deviceSet("/dev/ttyUSB2"); $serial->confBaudRate(115200); $serial->confParity("none"); $serial->confCharacterLength(8); $serial->confStopBits(1); $serial->confFlowControl("none"); $serial->deviceOpen(); $serial->sendMessage('AT+CMGF=1'); $serial->sendMessage(chr(13)); $serial->sendMessage('AT+CMGS="09xxxxxxxx"'); $serial->sendMessage(chr(13)); $serial->sendMessage("THIS IS TEST"); $serial->sendMessage(chr(26)); sleep(6); $read = $serial->readPort(); echo $read; $serial->deviceClose(); The code will return very strange words AT+CMGF=1AT+CAT+CAT+CAT+CAT+CAT+CAT+CAT+CAT+CAT+CAT...

Trying to get PHP responce on ajax

Image
Clash Royale CLAN TAG #URR8PPP Trying to get PHP responce on ajax here I am trying to update the MSQL table using jquery , both PHP code and jquery script is written on the same page, the code working fine to update my tables but the response msg is not getting by the ajax so it always shows me the default message "Some problem occurred, please try again.". here is the code: <!-- HTML code to display msg --> <p class="statusMsg_post"></p> <script> $(document).ready(function(){ $('#btn_publish').click( function(){ var obj_post_postID="<?php echo $post_id; ?>"; var publish_post="publish"; $.ajax({ type:'POST', // url:'post_view.php', data:{ "post_status_update":publish_post, "obj_post_status":obj_post_postID, }, success:function(res){ if(res==...

Reformat first row column based on other rows

Image
Clash Royale CLAN TAG #URR8PPP Reformat first row column based on other rows I have a table which contains US cities, some cities have multiple zip codes and they are one row with one zip code as shown below in the screen shot, I want this to be store as one row per city with their multiple zip codes in comma split format in the zip column, Is there any way to do this? Expected result would be like below image By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to get API key for user using Google's OAuth API?

Image
Clash Royale CLAN TAG #URR8PPP How to get API key for user using Google's OAuth API? Maybe I'm not understanding how the Youtube Data API is supposed to work. But if I have a PHP application that will generate the oauth request and receive the callback (which I have), the data it sends back is not a user's API key. So I don't know if I am doing this wrong, or what, but their documentation is giving me a headache and I have searched and searched and I don't even know if my process is right here: Web Server / OAuth Request (php) require_once 'vendor/autoload.php'; $client = new Google_Client(); $client->setAuthConfig('oauth.json'); $client->setAccessType("offline"); // offline access $client->setIncludeGrantedScopes(true); // incremental auth $client->addScope(Google_Service_YouTube::YOUTUBE_READONLY); $client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/oauth2callback.php'); $auth_url ...

Moodle and SAML2 SSO Auth plugin loops

Image
Clash Royale CLAN TAG #URR8PPP Moodle and SAML2 SSO Auth plugin loops Moodle 3.5.1 plugin auth_saml2sso_moodle35_2018051500.zip question: i guess i have the same error as Naaman Fallouh at https://moodle.org/plugins/auth_saml2sso (comments page 2) i am able to login with phpBB/SAML and have http://moodle.localhost/ and http://moodle.localhost/simplesaml I am able to login using http://moodle.localhost/simplesaml I am able to login using http://moodle.localhost/ but after the login i get stuck in a loop: http://saml_idp.localhost/simplesaml/saml2/idp/SSOService.php?SAMLRequest=chars&RelayState=http%3A%2F%2Fmoodle.localhost%2Flogin%2Findex.php (saml_idp.localhost is indeed my idp) over and over again, with every time other value for chars. I did set in http://moodle.localhost/simplesaml/config/config.php 'session.phpsession.cookiename' => 'MoodleSession', That is the only difference from the phpbb3.localhost/simplesaml/config/config.php. What else could be wrong? W...

Transfer data from aprs server to symfony database

Image
Clash Royale CLAN TAG #URR8PPP Transfer data from aprs server to symfony database I would like to connect symfony to an "aprs-is" server. My data are received by the "aprs" server and i would like to insert them in the database i have created in the doctrine of symfony. My entities are ready but i can't figure out how to do that. I can make an up-link on "aprs" server to redirect the data but i don't know how to architect all that link on both side. Here is the link of aprs-is server archi: http://he.fi/aprsc/ By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

xpath match first and last child

Image
Clash Royale CLAN TAG #URR8PPP xpath match first and last child Trying to determine if any P tag text's is entirely within strong/B tags // Match (unacceptable, flag to user): <p><strong>Any text and <span>maybe</span> other <em>tags</em></strong></p> // Don't match (acceptable): <p>Any text and <strong>maybe</strong> other <em>tags</em></p> You can compare string(//p) and string(//p/strong) – gangabass Jul 23 at 2:36 string(//p) string(//p/strong) 4 Answers 4 p //p strong //p[.//strong] //p[.//strong[normalize-space(.) != ""]] and no text node descendant with content that has no strong ancestor node: strong //p[ .//strong[normalize-space(.) != ...

how to print 1st reminder, 2nd reminder in gridview yii2 from model?

Image
Clash Royale CLAN TAG #URR8PPP how to print 1st reminder, 2nd reminder in gridview yii2 from model? Here is my view page view.php view.php <div class="dataTables_wrapper form-inline dt-bootstrap"> <?= GridView::widget([ 'dataProvider' => $dataProvider1, 'columns' => [ ['class' => 'yiigridSerialColumn'], [ 'label' =>'Date', 'value' => 'date', ], [ 'label' =>'Reminder', 'value' => function($model){ return Yii::$app->session->get('').' '.$model['type'].' '.'reminder'; } ], [ 'label' =>'To', 'value' => 'recipients', ...

Joomla custom form action doesn't work

Image
Clash Royale CLAN TAG #URR8PPP Joomla custom form action doesn't work I'm learning how to make my own module on Joomla. MyModule mod_planejamentomensal.php is like this: //No direct access defined('_JEXEC') or die; require_once dirname(__FILE__) . '/helper.php'; Jhtml::_('jquery.framework'); Jhtml::_('jquery.ui'); JHtml::_('behavior.formvalidator'); JHtml::script(JURI::base() . '/modules/mod_planejamentomensal/js/jquery-3.3.1.js'); JHtml::script(JURI::base() . '/modules/mod_planejamentomensal/js/jquery.mask.js'); default.php has my form (with some other fields and jQuery, I'm copying part of it here so it won't be too long): <div class="planj-mensal-form"> <form method="post" name="frmCasdastra" class="form-validate" action="<?php JURI::base() . '/modules/mod_planejamentomensal/tmpl/adicionaForm.php' ?>"> <div class="divTa...

SyntaxError: unterminated string literal error

Image
Clash Royale CLAN TAG #URR8PPP SyntaxError: unterminated string literal error I found error like this SyntaxError: unterminated string literal description: '<div><span class="cal-tar">Patient NationalId :</span> 4376 is anything mistake in this if (count($doctor_dates) > 0) { foreach ($doctor_dates as $doctor_date) { ?> { id: '<?php echo $doctor_date->bookingRef; ?>', title: '<?php echo $doctor_date->name; ?>', description: '<?php echo nl2br('<div><span class="cal-tar">Patient NationalId :</span> ' . $doctor_date->nationalID . '</div>'); echo nl2br('<div><span class="cal-tar">Patient Name : </span>' . $doctor_date->bkPatientName . '</div>'); echo nl2br('<div><...

jPlayer multiple instances issue

Image
Clash Royale CLAN TAG #URR8PPP jPlayer multiple instances issue I've created multiple instances of jPlayer on a product list, at main page of my shop. In file product-list.tpl I've attached iframe inside foreach loop which load jPlayer tracks from custom directories - based on a product name. Every instance of jPlayer have individual ID: #jquery_jplayer_1, #jquery_jplayer_2, etc. Everything works fine except playing just from one jPlayer at the same. When some track is playing and then we click on another player there is two songs playing at the same time. I've tried few solutions to solve this problem but nothing seems work. There is script where every instance of jPlayer is created: <script type="text/javascript"> var querystring = window.location.search, match = querystring.match(/playerNumber=(.*)?&*/), playerNumber = match[1]; new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_"+playerNumber, cssSelectorAncestor: "#jp_container_...