function migrate_insert_meta($collectionid, $baseid, $fields, &$db, $db_prefix, &$db2) { $name = preg_replace("/([kK]\\.[[:space:]]*[aA])\\.?/", "", trim(stripslashes($fields['name']))); if (strlen($name) > 0 and strlen($fields['vorname']) > 0) { $artistname = $name . ", " . trim(stripslashes($fields['vorname'])); } else { $artistname = ''; } $sql = "REPLACE INTO `{$db_prefix}meta` (`collectionid`" . ", `imageid`" . ", `type`" . ", `status`" . ", `addition`" . ", `title`" . ", `dating`" . ", `material`" . ", `technique`" . ", `format`" . ", `institution`" . ", `literature`" . ", `page`" . ", `figure`" . ", `table`" . ", `isbn`" . ", `keyword`" . ", `insert_date`" . ", `modify_date`" . ", `name1id`" . ", `name2id`" . ", `locationid`" . ", `exp_prometheus`" . ", `exp_sid`" . ", `exp_unimedia`" . ", `metacreator`" . ", `name1`" . ", `location`" . ", `locationsounds`" . " ) VALUES (" . $db->qstr(trim(stripslashes($collectionid))) . ", " . $fields['bildid'] . ", 'image'" . ", 'new'" . ", " . $db->qstr(trim(stripslashes($fields['zusatz']))) . ", " . $db->qstr(trim(stripslashes($fields['titel']))) . ", " . $db->qstr(trim(stripslashes($fields['datierung']))) . ", " . $db->qstr(trim(stripslashes($fields['material']))) . ", " . $db->qstr(trim(stripslashes($fields['technik']))) . ", " . $db->qstr(trim(stripslashes($fields['format']))) . ", " . $db->qstr(trim(stripslashes($fields['institution']))) . ", " . $db->qstr(trim(stripslashes($fields['literatur']))) . ", " . $db->qstr(trim(stripslashes($fields['seite']))) . ", " . $db->qstr(trim(stripslashes($fields['abbildung']))) . ", " . $db->qstr(trim(stripslashes($fields['tafel']))) . ", " . $db->qstr(trim(stripslashes($fields['isbn']))) . ", " . $db->qstr(trim(stripslashes($fields['stichworte']))) . ", " . $db->qstr(trim(stripslashes($fields['insert_date']))) . ", " . $db->qstr(trim(stripslashes($fields['modify_date']))) . ", 1, 0, 1" . ", 0, 0, 0" . ", 'dilps-import'" . ", " . $db->qstr($artistname) . ", " . $db->qstr(trim(stripslashes($fields['stadt']))) . ", " . $db->qstr('.' . soundex2($db->qstr(trim(stripslashes($fields['stadt'])))) . '.') . ");"; echo "{$sql}\n<br>\n"; $db->Execute($sql); dating($db, stripslashes($fields['datierung']), $datelist); if (count($datelist)) { foreach ($datelist as $date) { $sql = "INSERT INTO {$db_prefix}dating(collectionid,imageid,`from`,`to`) VALUES(4,{$fields['bildid']},{$date['from']},{$date['to']})"; echo "{$sql}\n"; $db->Execute($sql); } } migrate_insert_img($collectionid, $baseid, $fields['bildid'], $db, $db_prefix, $db2); }
} $sql2 = "UPDATE `{$db_prefix}meta` SET name2id = " . $db->qstr($rs->fields['id']) . ", name2sounds = " . $db->qstr($rs->fields['sounds']) . " WHERE lower(name2) = " . $db->qstr(strtolower($rs->fields['name'])); echo $sql2 . "\n<br>\n"; $rs2 = $db->Execute($sql2); if (!$rs2) { echo $db->ErrorMsg() . "\n<br>\n"; } $rs->MoveNext(); } $sql = "DELETE FROM {$db_prefix}location WHERE src=" . $db->qstr("dilps"); $rs = $db->Execute($sql); $sql = "SELECT DISTINCT imageid, collectionid, location, locationsounds" . " FROM {$db_prefix}meta WHERE location != ''"; $rs = $db->Execute($sql); while (!$rs->EOF) { $location = trim(stripslashes($rs->fields['location'])); $locationsounds = trim(stripslashes(soundex2($location))); $imageid = trim(stripslashes($rs->fields['imageid'])); $collectionid = trim(stripslashes($rs->fields['collectionid'])); $sql2 = "SELECT * FROM {$db_prefix}location WHERE location = " . $db->qstr($location); $rs2 = $db->GetOne($sql2); if ($rs2 === false) { $sql3 = "INSERT INTO `{$db_prefix}location` (src, source_id, location, sounds) " . "VALUES ('dilps'," . $db->qstr($collectionid . ":" . $imageid) . ", " . $db->qstr($location) . ", " . $db->qstr($locationsounds) . ")"; echo $sql3 . "\n<br>\n"; $rs3 = $db->Execute($sql3); if (!$rs3) { echo $db->ErrorMsg() . "\n<br>\n"; } } $rs->MoveNext(); } $sql = "SELECT * FROM {$db_prefix}location";
function get_sounds_string($string) { $string = strtoupper($string); $sounds_string = '.'; $words = split($this->pattern, $string); if (!empty($words)) { foreach ($words as $word) { $sound = trim(soundex2($word)); //if (empty($sound)) { echo "***empty sound string***$string"; debug ($words, false);} if ($sound != '') { $sounds_string .= $sound . '.'; } } } return $sounds_string; }
function get_artist_where_query($column, $value, $operator) { global $config; $value = strtolower($value); switch ($operator) { case "equals": $where = " (lower({$this->db_prefix}meta.name1) = lower(" . $this->db->qstr("{$value}") . ")" . " or lower({$this->db_prefix}meta.name2) = lower(" . $this->db->qstr("{$value}") . "))"; break; case "like": $where = " (lower({$this->db_prefix}meta.name1) like lower(" . $this->db->qstr("%{$value}%") . ")" . " or lower({$this->db_prefix}meta.name2) like lower(" . $this->db->qstr("%{$value}%") . "))"; break; case "soundslike": include_once $config['includepath'] . 'thesauri/soundex_fr.php'; $sound = trim(soundex2($value)); $where = " ({$this->db_prefix}meta.name1sounds like '%.{$sound}.%' or {$this->db_prefix}meta.name2sounds like '%.{$sound}.%')"; break; /*case "likesoundslike": include_once($config['includepath'].'thesauri/soundex_fr.php'); $sound = trim(soundex2($value)); $where = " ( (lower({$this->db_prefix}meta.name1) like lower(".$this->db->qstr("%$value%").")". " or lower({$this->db_prefix}meta.name2) like lower(".$this->db->qstr("%$value%")."))". " or ({$this->db_prefix}meta.name1sounds like '%.$sound.%' or {$this->db_prefix}meta.name2sounds like '%.$sound.%') )"; break;*/ /*case "likesoundslike": include_once($config['includepath'].'thesauri/soundex_fr.php'); $sound = trim(soundex2($value)); $where = " ( (lower({$this->db_prefix}meta.name1) like lower(".$this->db->qstr("%$value%").")". " or lower({$this->db_prefix}meta.name2) like lower(".$this->db->qstr("%$value%")."))". " or ({$this->db_prefix}meta.name1sounds like '%.$sound.%' or {$this->db_prefix}meta.name2sounds like '%.$sound.%') )"; break;*/ default: $where = ''; break; } return $where; }
function migrate_get_sounds_string($string) { $sounds = array(); $pattern = "[[:space:],]+"; $string = strtoupper($string); $sounds_string = '.'; $words = split($pattern, $string); if (!empty($words)) { foreach ($words as $word) { $sound = trim(soundex2($word)); if ($sound != '') { $sounds_string .= $sound . '.'; } } } return $sounds_string; }
$u = strtoupper($s); $l = strlen($s); $d = $u[0]; $p = NULL; for ($i = 0; $i < $l; $i++) { $c = trim($k[ord($u[$i]) - 65]); if ($c != $p) { if ($i > 0) { $d .= $c; } $p = $c; } } return substr($d . '000', 0, 4); } function strrand2($min = 3, $max = 10) { $s = 'abcdefghijklmnopqrstuvwxyz'; $s_len = strlen($s); $l = mt_rand($min, $max); $p = ''; for ($i = 0; $i < $l; $i++) { $p .= $s[mt_rand(0, $s_len)]; } return $p; } $p = strrand2(); echo $p . "\n"; echo soundex($p) . "\n"; echo soundex2($p) . "\n";