Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

It's late, I'm tired and I can't get this to work.

Featured Replies

I have the following, which works locally. I need to convert it to read from a remote file, but I can't guarantee that allow_url_fopen will be available. I need to somehow refactor the following to use cURL or somesuch, but I can't seem to figure out how to do it line-by-line - all the cURL documentation refers to either echoing or returning the whole file. I can't do that, because the file might be too large.

 

Ideas? I'm too tired for this.

 

function pmp_import_read($file, $limit = 1) {
   // used for logging and limiting
   $row = 1;
   // Script will periodically reload from the last file pointer by location header, 
   // passing the pointer as a GET var as it's run from WP cron rather than 
   // true cron from shell
   $pointer = (isset($_GET['pointer'])) ? $_GET['pointer'] : '';
   if (($handle = fopen($file, "r")) !== false) {
       // First line will always contain the headers
       $headers = fgetcsv($handle, 4096, ",");
       // Check if we need to move the pointer
       if (isset($pointer) && $pointer != '') {
           fseek($handle, $pointer);
       }
       // Loop through the rows until we hit limit
       while (($data = fgetcsv($handle, 4096, ",")) !== false && $row <= $limit) {
           if (count($data) > 1) {
               // Create associative array of headers and data
               $data = array_combine($headers, $data);
               // Insert/update categories
               $cat_id = pmp_process_categories($data['category']);
               // Insert/update product
               pmp_process_product($data, $cat_id);
           } else {
               // Log the error and continue
               pmp_log('Unable to import at line ' . $row);
           }
           $row++;
       } 
       // Tidy up, get new position of pointer and return it
       $newpointer = ftell($handle);
       fclose($handle);
       return $newpointer;
   } else {
       // Couldn't open the file, no point continuing
       pmp_log('Unable to open file: ' . $file);
       return false;
   }

Edited by Renaissance-Design

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.