Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. You can't echo something, have it displayed, then remove it. Once the content has been sent to the browser for display it's there. Trying to stream content as a progress indicator is already questionable. It may or may not working depending on what kind of software / buffers are involved in the connection. If you want to progress indication then the ideal thing to do would be to run your tasks as background requests using fetch() and update a display with the progress information as they complete.
  2. Look at the documentation for mysqli_stmt_prepare. Notice it says the function only accepts one parameter which is the connection. Now look at your code and notice that you are passing two parameters, the connection and the SQL string. You need to remove the extra parameter.
  3. You wouldn't match the whole subject, just some identifier. For example the subject may be: [Ticket #1234] Help with something. Then you'd just extract the 1234 and lookup that ticket. Even if someone changes the subject, so long as that prefix is left in it will be fine. In my experience, people do not typically change a subject when replying so it should be fairly reliable. If for some reason you cannot automatically match it to a ticket, you could put the message into some queue for a person to manually assign to a ticket. If you're generating the email then you'll probably need to generate the Message-Id header as well. If you're using a library to create and send emails it might do that automatically.
  4. In my experience, such systems usually just have some identifier in the email, usually the subject which is used to associate the email with the internal ticket system. If you want to try and do it without such an identifier, look at the In-Reply-To and/or References headers which should contain the original email message id.
  5. Sure. First, as mentioned before this is not SMTP, so all the SMTP_* constants you are using are either the wrong values or incorrectly named. Either make new IMAP settings to use or rename your constants. Second, this is based on some code I have that checks an email account for a one-time-password code so I can login and download data from a site. <?php //Example parameters. $host = '{imap.example.com:993/ssl/readonly}'; $mailbox = 'otp@example.com'; $password = ''; function getSecurityCode(string $host, string $mailbox, string $password) : ?string{ $authCode = null; $startTime = time(); do { sleep(5); $handle = imap_open($host, $mailbox, $password, OP_READONLY, 5); if (!$handle){ throw new RuntimeException('Unable to open mailbox'); } $messageList = imap_sort($handle, SORTDATE, 1); foreach ($messageList as $messageNumber){ $messageInfo = imap_fetch_overview($handle, $messageNumber)[0]; if (isOTPEmail($messageInfo) && isReceivedInLast5Minutes($messageInfo)){ $authCode = extractAuthCode(imap_body($handle, $messageNumber)); break; } } imap_close($handle); } while (!$authCode && time() - $startTime < 300); return $authCode; } function isOTPEmail(stdClass $messageInfo) : bool{ if (!isset($messageInfo->subject)){ return false; } return stripos($messageInfo->from, 'donotreply@example.com') !== false && stripos($messageInfo->subject, 'One-Time Passcode') !== false; } function isReceivedInLast5Minutes(stdClass $messageInfo) : bool{ if (!isset($messageInfo->date)){ return false; } $date = DateTime::createFromFormat(DateTimeInterface::RFC2822, $messageInfo->date); if ($date === false){ $date = DateTime::createFromFormat(DateTimeInterface::RFC2822 . ' (\G\M\T)', $messageInfo->date); } if ($date === false){ return false; } $now = new DateTime('', $date->getTimezone()); $now->sub(new DateInterval('PT5M')); return $date > $now; }
  6. Yes, imap leaves the messages on the server until you explicitly delete them.
  7. SMTP is sending emails to servers. Reading sent emails as a client is done with either IMAP or POP. PHP has an extension for that.
  8. I think this is due to your partial running too soon and the console logging being lazy-loaded. At the time you log, window.Swal does not exist (as indicated by the undefined). The debug tools don't evaluate the full properties until you click the expand triangle next to Window and at that time window.Swal has been created. Likely this is due to the fact that all JS modules are deferred by default. Your logging code runs as soon as it's parsed, but deferred modules don't run until just before the DOMContentLoaded event is fired which happens after everything else is parsed. If you change your logging to this, it should show up: <script> window.addEventListener('DOMContentLoaded', ()=>{ console.log(window.Swal); }); </script>
  9. You need to use of not in when doing the equivalent of foreach in php. for (let item of config_data.excludes) { regexes.push(new RegExp(item)); } in loops over the properties of an object, not the values of an iterable.
  10. Use JavaScript to make the link work as a back button instead of a normal link back to the page. You can leave your link as it is now so users that have JS disabled will still go back, just not to the same position. HTML: <a href="previous.html" class="return-link">Return</a> Script: //Using jQuery $('.return-link').click(function(e){ e.preventDefault(); history.back(); });
  11. As you noted, Adding display: inline prevents the width: 25% from having an effect on those elements.
  12. You shouldn't be trying to save a "time remaining" value at all. That's a value you'd want to calculate on the fly when you need it based on the current time. Either save the sub_date and the amount of time they are allowed, or save an expiration date for the subscription and calculate the difference between now and that expiration date to determine the time remaining.
  13. Going back to the original statement of ending the other user's sessions, you can get PHP to do that for you by setting the session lifetime to 0 and invoking a garbage collection pass. //You must end the current session before you can change the lifetime settings. session_write_close(); //If you want to preserve your admin session, save a copy of $_SESSION $sessionCache = $_SESSION; //Make the lifetime 0 so every session is considered expired. ini_set('session.gc_maxlifetime', 0); //Re-start your admin session, GC requires an active session. session_start(); //Restore the saved $_SESSION if desired. $_SESSION = $sessionCache; //Run GC to delete other sessions. session_gc();
  14. FYI, if you're using Mysql 8.0 series you can simplify the query by using the window function. One of rank, dense_rank, or row_number would probably give you what you want. For example: SELECT name , total_received , total_donated , rank() over (ORDER BY total_received DESC, total_donated ASC) as the_rank FROM donation rd1 WHERE total_participant = 1 ORDER BY the_rank; | name | total_received | total_donated | the_rank | | ------- | -------------- | ------------- | -------- | | Dasher | 500 | 250 | 1 | | Cupid | 400 | 370 | 2 | | Prancer | 400 | 370 | 2 | | Comet | 380 | 370 | 4 | | Dancer | 200 | 510 | 5 | | Vixen | 100 | 200 | 6 | | Donner | 100 | 510 | 7 | If you're not on Mysql 8.0, you'll have to stick with Barands way.
  15. Probably you should talk to the company hosting the API as it seems your request is going through fine so if there's a problem it's likely with the data you are sending not being what they expect. They are the only ones that can really tell you for sure if there is a problem with the data. If I had to take a guess, it would be that you seem to be trying to post multiple records when they probably only expect one. If you decide you're query string, you'll see you are posting data like this: 0[id]=6653&0[participacion]=6936&0[beneficio]=cine&0[fecha]=2018-04-16+14:41:59&0[promo]=33&1[id]=6654&1[participacion]=3318&1[beneficio]=payp That seems unusual to me. What would seem more likely is that you'd send one at a time with data such as this: id=6653&participacion=6936&beneficio=cine&fecha=2018-04-16+14:41:59&promo=33
  16. Is there a particular problem you're having, other than 'It doesn't show in the network console.'? Seems like you're request is going through just fine and you're getting a response back.
  17. Exactly, because as I said: There's nothing in pure CSS that lets you go back or up when selecting, only forward and down. If you want to modify some previous element or a parent element, you usually need to get Javascript involved. Depending on how you structure your layout and your columns, you might be able to accomplish what you want by watching for :hover on the parent element and styling the child columns accordingly. For example: .parent:hover > .col { visibility: hidden; } .parent:hover > .col:hover { visibility: visible; } The problem with that is if it is possible to hover over the parent element without hovering over one of the child columns, then all three will vanish. As such, it only is really viable if you can ensure the parent is exactly the size of the three columns with no gaps between them.
  18. If just setting it to true doesn't provide any extra output, then try this: curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_STDERR, $fp = fopen('php://temporary', 'w+')); curl_exec($ch); rewind($fp); fpassthru($fp);
  19. You'll probably need to use Javascript to add/remove a class which will change the opacity of the ones you want hidden. CSS will let you select a next sibling, but not a previous sibling so there's no native CSS way to select the first and second columns when you're hovering over the third column. A simple script like this should do the trick. //using jQuery const $allColumns = $('.col'); $allColumns.on('mouseover', function(e){ $allColumns.addClass('faded'); $(e.currentTarget).removeClass('faded'); }); $allColumns.on('mouseout', function(){ $allColumns.removeClass('faded'); }); With markup that is like this: <div class="col">Column 1</div> <div class="col">Column 2</div> <div class="col">Column 3</div> <style> .col { float: left; height: 100px; margin: 0 20px; border: 1px solid black; } .faded { opacity: 0; } </style> If you want your columns to just fully disappear, you can use visibility: hidden; instead of opacity. If you want to have a faded look or transition animation then you can use opacity.
  20. The browser's network console only shows the requests made by the browser. It will not show requests made by PHP / CURL as it has no idea they even happen since that all happens on the server before the browser gets any of the page's response data. If you want to get extra debugging info about the request, you can enable CURLOPT_VERBOSE in your code. CURL will output a bunch of extra info to the browser as it does the request.
  21. That syntax works just fine. Why do you think it doesn't?
  22. Create your array of domains, then use the in_array function to check if $alloweddomain is contained in that array.
  23. Since you want "sets of images", I would say create a table for your sets of images. You could even store metadata about the set itself that way if you wanted too. create table image_set ( id int not null primary key auto_increment, username varchar(100), createdOn datetime ); create table image_set_image ( id int not null primary key auto_increment, image_set int not null, sortOrder int not null, category varchar(100) not null, image_name varchar(100) not null ); see example Each time someone uploads a batch of images, create a new set for them. Add each of the images to that set. The image_set_image.sortOrder column is just a numeric value you can use to sort the images within that set, you can auto-generated it or let the user specify it somehow. The image_set_image.category column would be your 'BIRD' / whatever value. If you want all the images to be in one category you could move this to the image_set table instead. When you then query the images for display you can then sort the results so each users images are grouped together an just auto-generate a sequential numbering system for the results. With newer mysql versions you can do this right in the query itself.
  24. If you're going to create separate cron tab entries for your jobs, you can pass them as part of the command like just like you would any other app. >setTaskCommandLine('php -f content/admin/admin_task.php "vendor_box" "selected_language" "selected_options" "selected_cid" "parsed_data" "selected_products"') You'd read them using $argv in your script. $vendor_box=$argv[1]; $selected_language=$argv[2]; $selected_options=$argv[3]; $selected_cid=$argv[4]; $parsed_data=$argv[5]; $selected_products=$argv[6]; $feed_import_helper->processProducts($vendor_box, $selected_language, $selected_options, $selected_cid, $parsed_data, $selected_products); You have to be very careful doing something like this though as if you do not properly escape the parameters you open up the potential for a user to run any arbitrary command as part of the cron job. This is one of the reasons why I suggest you do not create dynamic crontab entries and just manually create one that checks for work elsewhere. Doing it that way, passing parameters needs to be part of whatever you code for your job management setup. A common way of handling this would be to simply json_encode an array of data and save it to your file/db then have your crontab worker json_decode that data back into the necessary parameters.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.