unset($readed[0]); // we don't want to process the headers with the data // now we've got the array broken into parts by the expicit end-of-row marker. array_walk($readed, 'walk'); } if (is_uploaded_file($usrfl) && $split == 1) { //******************************* //******************************* // UPLOAD AND SPLIT FILE //******************************* //******************************* // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); //echo "Trying to move file..."; if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, DIR_FS_DOCUMENT_ROOT . $tempdir); } $infp = fopen(DIR_FS_DOCUMENT_ROOT . $tempdir . $usrfl_name, "r"); //toprow has the field headers $toprow = fgets($infp, 32768); $filecount = 1; echo "Creating file EP_Split" . $filecount . ".txt ... "; $tmpfname = DIR_FS_DOCUMENT_ROOT . $tempdir . "EP_Split" . $filecount . ".txt"; $fp = fopen($tmpfname, "w+"); fwrite($fp, $toprow); $linecount = 0; $line = fgets($infp, 32768); while ($line) { // walking the entire file one row at a time // but a line is not necessarily a complete row, we need to split on rows that have "EOREOR" at the end $line = str_replace('"EOREOR"', 'EOREOR', $line);
foreach ($readed as $tkey => $readed_row) { process_row($readed_row, $filelayout, $filelayout_count, $default_these, $ep_separator, $languages, $custom_fields); } // isn't working in PHP 5 // array_walk($readed, $filelayout, $filelayout_count, $default_these, 'process_row'); //******************************* //******************************* // UPLOAD AND SPLIT FILE //******************************* //******************************* } elseif (isset($_FILES['usrfl']) && isset($_GET['split']) && $_GET['split'] == 1) { // move the file to where we can work with it $file = tep_get_uploaded_file('usrfl'); //echo "Trying to move file..."; if (is_uploaded_file($file['tmp_name'])) { tep_copy_uploaded_file($file, EP_TEMP_DIRECTORY); } $infp = fopen(EP_TEMP_DIRECTORY . $file['name'], "r"); $ext_tmp = substr($file['name'], -3, 3); //toprow has the field headers $toprow = fgets($infp, 32768); $filecount = 1; echo "Creating file EP_Split" . $filecount . '.' . $ext_tmp . ' ... '; $tmpfname = EP_TEMP_DIRECTORY . "EP_Split" . $filecount . '.' . $ext_tmp; $fp = fopen($tmpfname, "w+"); fwrite($fp, $toprow); $linecount = 0; $line = fgets($infp, 32768); while ($line) { // walking the entire file one row at a time // but a line is not necessarily a complete row, we need to split on rows that have "EOREOR" at the end