function run() { $fd = false; if (file_exists($this->file_name)) { $fd = fopen($this->file_name, 'r'); } if ($fd !== false) { $csv = new csv(); while ($str = fgets($fd)) { if ($this->encoding != 'utf-8') { $str = iconv($this->encoding, 'utf-8', $str); } $values = $csv->split(trim($str)); if (isset($this->_2d_mode)) { if (!is_array($this->horizontal)) { $this->horizontal = $values; } else { $_2d_count = 0; $hor_ptr = 0; unset($tmp); foreach ($values as $v) { if ($_2d_count < $this->_2d_mode) { $tmp['col' . $_2d_count] = $v; $_2d_count++; $hor_ptr++; } else { $tmp['col' . $_2d_count] = $this->horizontal[$hor_ptr]; $hor_ptr++; $tmp['col' . ($_2d_count + 1)] = $v; if (($this->mode == 'rows' || $this->mode == 'all') && $v != '') { if ($this->row_method == '') { die("\$this->row_method==''"); } $method = $this->row_method; if ($this->row_object != '') { $this->stop = !$this->row_object->{$method}($tmp); } else { $this->stop = !$method($tmp); } } } if ($this->stop) { return false; } } } } else { if (!is_array($this->table_columns) || count($this->table_columns) == 0) { $this->column_count = count($values); $this->first_pass = true; foreach ($values as $i => $v) { $this->table_columns['col' . $i] = array('Field' => 'col' . $i); } } else { if ($this->column_count != count($values)) { $this->stop = true; return false; } } if ($this->mode == 'rows' || $this->mode == 'all') { if ($this->row_method == '') { die("\$this->row_method==''"); } $cnt = 0; foreach ($this->table_columns as $c => $v) { $out[$c] = $values[$cnt++]; } $method = $this->row_method; if ($this->row_object != '') { $this->stop = !$this->row_object->{$method}($out); } else { $this->stop = !$method($out); } unset($out); } } if ($this->stop) { break; } } fclose($fd); } else { return false; } return true; }
function handle_event($ev) { switch ($ev->rem_name) { case 'fn': $file_name = $_POST['val']; $this->unix_fd = fopen('../uploads/utf8.vcf', "w"); $this->win_fd = fopen('../uploads/cp1251.vcf', "w"); $csv = new csv(); $in = file_get_contents('../uploads/' . $file_name); $r = explode("\n", $in); foreach ($r as $line) { if ($line != '') { $row = $csv->split($line); $vc->email = $row[0]; $vc->name = $row[1]; $vc->surname = $row[2]; $this->write2("BEGIN:VCARD"); $this->write2("VERSION:3.0"); $this->write2("REV:2008-06-24T15:18:51Z"); $this->write2("EMAIL;TYPE=OTHER:" . $vc->email); $this->write2("X-EVOLUTION-FILE-AS:" . $vc->surname . "\\, " . $vc->name); $this->write2("N:" . $vc->surname . ";" . $vc->name . ";;;"); $this->write2("FN:" . $vc->name . " " . $vc->surname); $this->write2("END:VCARD"); $this->write2(""); } } fclose($this->unix_fd); fclose($this->win_fd); print "\$i('" . js_escape($ev->context[$ev->parent_name]['res_id']) . "').innerHTML='" . js_escape("<div>" . htmlspecialchars($in) . "</div>" . "<a href='../uploads/utf8.vcf'>utf-8</a> " . "<a href='../uploads/cp1251.vcf'>cp1251</a> ") . "';"; break; case 'do': break; } editor_generic::handle_event($ev); }
function file_contents_out($fd) { global $sql; $csv = new csv(); while ($str = fgets($fd)) { $values = $csv->split(trim($str)); $this->args['o_name'] = $values[0]; $this->args['count'] = $values[1]; $this->keys['name'] = $values[0]; foreach ($this->editors as $e) { $e->bootstrap(); } $rs = $sql->fetch1($sql->query("SELECT id FROM barcodes_raw WHERE isown=0 AND name = '" . $sql->esc($values[0]) . "'")); if ($rs == '') { $rs = $sql->fetch1($sql->query("SELECT id FROM barcodes_mapping WHERE name = '" . $sql->esc($values[0]) . "'")); if ($rs == '') { $this->editors['m_del']->css_style['display'] = 'none'; } else { $this->editors['m_del']->css_style['display'] = 'inline'; } } else { $this->editors['m_del']->css_style['display'] = 'none'; } $oc = $sql->fetch1($sql->query("SELECT `count` FROM barcodes_print WHERE id = '" . $sql->esc($rs) . "' AND task=" . intval($this->args['task']))); if ($oc == $values[1]) { $this->count_td->css_style['background'] = 'green'; } if ($oc != $values[1]) { $this->count_td->css_style['background'] = 'red'; } if ($oc == 0) { $this->count_td->css_style['background'] = 'yellow'; } $this->args['m_id'] = $rs; $this->xdiv->html(); $this->xdiv->id_alloc(); } }