$stmt->bindValue(":maxstate", $maxstate); $stmt->execute(); $fdata = $stmt->fetchAll(); // initialize array with column headings $column_headings = array("tagGroupingUid", "tagGroupingName de_DE", "tagGroupingDescription de_DE", "tagGroupingAutoTagNameCreation de_DE", "tagGroupingTagNumericalRequired", "tagGroupingGpcId", "tagUid", "tagName de_DE", "tagDescription de_DE", "tagSearchText de_DE", "tagNumericalValueRangeStart", "tagNumericalValueRangeEnd", "tagType", "tagGpcId", "tagGoogleTaxonomyId"); $taglist = array(); foreach ($fdata as $row) { $taglist = array_merge($taglist, getAllTagsForRow($row)); } // http://www.jonasjohn.de/snippets/php/trim-array.htm function trim_r($arr) { return is_array($arr) ? array_map('trim_r', $arr) : trim($arr); } // trim all values $taglist = trim_r($taglist); // eliminate all duplicate tags $taglist = array_map("unserialize", array_unique(array_map("serialize", $taglist))); // eliminate grouping properties for each grouping which occures more than once $taglist = tagGroupingFilterRemoveDuplicate($taglist); $resempty = function ($array, $key) { if (array_key_exists($key, $array)) { return $array[$key]; } return ""; }; header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=tags-" . (isset($import) ? $import['name'] : "ALL") . "-" . date('Ymd') . ".csv"); header("Pragma: no-cache"); header("Expires: 0"); // put out the original CSV
/** * recursively trim the elemts in an array */ public function test_trim_r() { $this->assertArrayEquals(trim_r(array('hello' => array('a' => NULL, 'b' => FALSE, 'c' => array('bar' => "space at the end ", 'bar' => " space at the beginning")))), array('hello' => array('a' => '', 'b' => '', 'c' => array('bar' => "space at the end", 'bar' => "space at the beginning")))); }
/** * recursively trim the elements in an array * * @param array $array * @param string $to_trim * @return void * @author Craig Ulliott */ function trim_r(array $array, $to_trim = ' ') { foreach ($array as $key => $val) { if (is_array($val)) { $array[$key] = trim_r($val); } else { $array[$key] = trim($val, $to_trim); } } return $array; }
function trim_r($arr) { $new_arr = array(); foreach ($arr as $k => $v) { if (is_array($v)) { $v = trim_r($v); } if (is_string($v)) { $v = trim($v); } $new_arr[$k] = $v; } return $new_arr; }
$hide = 0; if (@$path_parts["extension"] == 'info') { $hide = 1; } $result = mysql_query("INSERT INTO incoming(Path,EngName,RusName,VideoInfo,AudioInfo,RusVariants,ImdbVariants,GoogleImageVariants,imdbPersones,imdbCountries,imdbDesription,imdbGenres,rusCountries,rusGenres,rusCompanies,rusDescription,rusPersones,Hide) VALUES('" . addslashes(implode("\r\n", $value["path"])) . "','" . addslashes($names["eng"]) . "','" . addslashes($names["rus"]) . "','','','','','','','','','','','','','','',{$hide})"); } $sql = "SELECT * FROM incoming WHERE Path='" . addslashes(implode("\r\n", $value["path"])) . "'"; $result = mysql_query($sql); if ($result && ($field = mysql_fetch_assoc($result)) && $field["Hide"] == 0) { $file_info = preg_replace($config['multipathpattern'], "", $value["path"][0]) . ".info"; $file_info = $storages->decode_path($file_info); if (!preg_match('/ftp:\\/\\//', $value["path"][0]) && !$field["rusParsed"] && !$field["imdbParsed"] && !$field["RusUrlParse"] && !$field["ImdbUrlParse"] && file_exists($file_info)) { require_once dirname(__FILE__) . "/common/xml/xml.php"; $xml = new XML(); $info = $xml->xml_to_array("<?xml version=\"1.0\" encoding=\"windows-1251\"?>" . implode("", file($file_info))); $info = trim_r(magic_decode_r($info)); $persones = array(); foreach ($info['persones'] as $person) { $persones[] = $person["OzonUrl"] . "|" . $person["RusName"] . "|" . $person["Role"] . ($person["RoleExt"] ? " <b>{$person['RoleExt']}</b>" : "") . "|" . $person["OriginalName"]; } $posters = preg_split("/(\r\n|\r|\n)/i", $info['Poster']); $poster = array_shift($posters); $additionalPosters = array(); for ($i = 0; $i < count($posters); $i++) { $url = $posters[$i]; $additionalPosters[] = "{$url}|{$url}|?|?|1"; } $result = mysql_query("UPDATE incoming SET EngName='" . addslashes($info['OriginalName']) . "'," . " RusName='" . addslashes($info['Name']) . "'," . " imdbYear='" . addslashes($info['Year']) . "'," . " rusDescription='" . addslashes($info['Description']) . "'," . " imdbMPAA='" . addslashes($info['MPAA']) . "'," . " imdbRating='" . addslashes($info['ImdbRating']) . "'," . " ImdbUrlParse='" . addslashes($info['ImdbUrlParse']) . "'," . " rusPosterUrl='" . addslashes($poster) . "'," . " rusTypeOfMovie='" . addslashes($info['TypeOfMovie']) . "'," . " imdbGenres='" . addslashes(implode("|", $info['genres'])) . "'," . " imdbCountries='" . addslashes(implode("|", $info['countries'])) . "'," . " rusCompanies='" . addslashes(implode("|", $info['companies'])) . "'," . " rusPersones='" . addslashes(implode("\r\n", $persones)) . "'," . " imdbOriginalName='" . addslashes($info['OriginalName']) . "'," . " rusRusName='" . addslashes($info['Name']) . "'," . " GoogleImageVariants='" . addslashes(implode("\r\n", $additionalPosters)) . "'," . " imdbParsed=1," . " rusParsed=1" . " WHERE ID=" . (int) $field["ID"]); $sql = "SELECT * FROM incoming WHERE Path='" . addslashes(implode("\r\n", $value["path"])) . "'"; $result = mysql_query($sql); $field = mysql_fetch_assoc($result);