function parseitem($dowrite, $plu, $itemdesc, $tare, $shelflife, $price, $bycount, $type, $exception, $text, $label, $graphics) { global $FANNIE_ROOT, $FANNIE_SCALES; $CSV_dir = $FANNIE_ROOT . 'item/hobartcsv/csvfiles'; $DGW_dir = $FANNIE_ROOT . 'item/hobartcsv/csv_output'; if (!function_exists('writeitem')) { include 'writecsv.php'; } $session_key = ''; for ($i = 0; $i < 20; $i++) { $num = rand(97, 122); $session_key = $session_key . chr($num); } $i = 0; foreach ($FANNIE_SCALES as $f) { writeitem("{$CSV_dir}/{$session_key}_wi_scale_{$i}.csv", $f['type'], $f['host'], $f['dept'], $dowrite, $plu, $itemdesc, $tare, $shelflife, $price, $bycount, $type, $exception, $label, $graphics); writetext("{$CSV_dir}/{$session_key}_et_scale_{$i}.csv", $f['type'], $f['host'], $f['dept'], $plu, $text); $i++; } for ($i = 0; $i < count($FANNIE_SCALES); $i++) { copy($CSV_dir . "/" . $session_key . "_wi_scale_" . $i . ".csv", $DGW_dir . "/" . $session_key . "_wi_scale_" . $i . ".csv"); unlink($CSV_dir . "/" . $session_key . "_wi_scale_" . $i . ".csv"); copy($CSV_dir . "/" . $session_key . "_et_scale_" . $i . ".csv", $DGW_dir . "/" . $session_key . "_et_scale_" . $i . ".csv"); unlink($CSV_dir . "/" . $session_key . "_et_scale_" . $i . ".csv"); } }
function parseitem($dowrite, $plu, $itemdesc, $tare, $shelflife, $price, $bycount, $type, $exception, $text, $label, $graphics) { include 'ini.php'; $session_key = ''; for ($i = 0; $i < 20; $i++) { $num = rand(97, 122); $session_key = $session_key . chr($num); } for ($i = 0; $i < $num_scales; $i++) { writeitem("{$CSV_dir}/{$session_key}_wi_scale_{$i}.csv", $scale_types[$i], $scale_ips[$i], $department, $dowrite, $plu, $itemdesc, $tare, $shelflife, $price, $bycount, $type, $exception, $label, $graphics); writetext("{$CSV_dir}/{$session_key}_et_scale_{$i}.csv", $scale_types[$i], $scale_ips[$i], $department, $plu, $text); } for ($i = 0; $i < $num_scales; $i++) { exec("cp {$CSV_dir}/{$session_key}_wi_scale_{$i}.csv {$DGW_dir}"); exec("rm -f {$CSV_dir}/{$session_key}_wi_scale_{$i}.csv"); exec("cp {$CSV_dir}/{$session_key}_et_scale_{$i}.csv {$DGW_dir}"); exec("rm -f {$CSV_dir}/{$session_key}_et_scale_{$i}.csv"); } }
} } else { // we're doing "intelligent" parsing using this regex! $str = preg_match_all("#\b([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+\b)#i", $add, $adds); $j = 0; for ($i=0;$i<count($adds[0]);$i++) { $email = fixemail($adds[0][$i]); if (isset($existing[$email])) { $fail[$j]['addr'] = htmlspecialchars($email); $fail[$j]['reason'] = ' Already in list'; } else { // add to list, and existing emails array //echo $email.'<br>'; writeitem($f, $email); $existing[$email] = true; $succ[] = $email; } $j++; } } $done = true; } } ?> <script language="JavaScript"> function chkForm(obj) { if (obj.add.value != '' && obj.addfile.value != '') { return confirm('You have entered text in both the address and the file fields. If you continue, the address field will be ignored.');
if (!preg_match('#^([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+[^\".,?! ])$#i', $addr)) { $err = 'Your email address appears to be invalid. If you are pasting the URL from your confirmation email, make sure the URL wasn\'t split into two lines.'; } if (!isset($err)) { $f = openfile($cfg['listfile']); $exists = false; while ($item = readitem($f)) { if ($item['addr'] == $addr) {$exists = true;break;} } if ($exists) { $err = 'Ten adres mailowy ju¿ znajduje siê na naszej li¶cie'; } } if (!isset($err)) { // subscribe successful writeitem($f, $addr); if (isset($cfg['returnto_sub']) && $cfg['returnto_sub'] != '') { header('Location: '.$cfg['returnto_sub']); } else { printf($cfg['template'], 'Subscribed', 'Twój adres mailowy, '.$addr.', zostal dodany do naszej listy. Dziêkujemy.'); } } else { // problem with subscription echoerr($err); } } function echoerr($err) { printf($GLOBALS['cfg']['template'], 'Error', '<font color="red">Error: '.$err.'</font>');