/** * Read the next object from the resource. In this case, the 'row' is the * row in the csv file, and 'line' returns the line number in the file that * the object STARTED on. (CSV objects may span multiple lines, if they * contain newlines). * * @return array|false */ protected function read_object() { $obj = fgetcsv($this->csv_fp, null, $this->csv_delim, $this->csv_encl); $num = $this->line_num; if (!$obj) { return false; } else { // optionally remove the last, probably blank, column if (count($obj) && $this->lastcol_skip) { array_pop($obj); } // Increment line number, including any newlines in the object. // Also check for UTF-8 encoding $this->line_num++; foreach ($obj as $i => $col) { $this->line_num += substr_count($col, "\n"); if (!Encoding::is_utf8($col)) { $obj[$i] = Encoding::convert_to_utf8($col); } } return array('row' => $this->position + ($this->csv_skip ? 2 : 1), 'data' => $obj, 'line' => $num); } }
/** * Trim, utf8-ify and normalize-newlines for a string. * * @param string $str * @return string */ function air2_str_clean($str) { if (is_null($str) || !is_string($str) || strlen($str) == 0) { return $str; } // UTF8-ify $str = Encoding::convert_to_utf8($str); // normalize newlines $str = air2_normalize_newlines($str); // trim $str = trim($str); return $str; }
*/ $post_params = array(); // ensure all values are UTF8 foreach ($_POST as $key => $value) { // skip some special key names if (substr($key, 0, 6) == "X-PIN-") { continue; } if (is_array($value)) { $utf8ified = array(); foreach ($value as $item) { $utf8ified[] = Encoding::convert_to_utf8($item); } $value = $utf8ified; } else { $value = Encoding::convert_to_utf8($value); } $post_params[$key] = $value; } // handle any files $upload_error = false; if ($_FILES) { foreach ($_FILES as $key => $file) { if (isset($file['error']) && $file['error'] === UPLOAD_ERR_NO_FILE) { $post_params[$key] = false; continue; // silently skip it } //Carper::carp(var_export($file,true)); if ($file['error'] !== UPLOAD_ERR_OK) { $err = new UploadException($file['error']);