function convert_array_to_UTF8($arr) { foreach ($arr as $k => $v) { if (!detectUTF8(stripslashes($v))) { $arr[$k] = utf8_encode(stripslashes($v)); } } return $arr; }
function convertUrlNamn($namn) { $from = array("aa", "ae", "oe", "AA", "AE", "OE", "Aa", "Ae", "Oe", "_"); $to = array("å", "ä", "ö", "Å", "Ä", "Ö", "Å", "Ä", "Ö", " "); if (detectUTF8($namn)) { return urldecode($namn); } else { return utf8_encode(urldecode($namn)); } }
function encoding($string) { if (function_exists('iconv') && false) { if (@(!iconv('utf-8', 'cp1251', $string))) { $string = iconv('cp1251', 'utf-8', $string); } return $string; } else { if (detectUTF8($string)) { return $string; } else { return cp1251_utf8($string); } } }
function option($value, $description) { if ($this->ci->config->item('charset') == 'UTF-8' && !detectUTF8($description)) { $description = utf8_encode($description); } $this->options[$value] = $description; }
} // ACTION STARTS HERE // create latin1 and UTF8 connection $db1 = pdoconnect($charset = 'latin1'); $db2 = pdoconnect($charset = 'UTF8'); // for all defined tables foreach ($table_fields as $table => $tabdata) { // read in table data through latin1 connection $query = "SELECT * FROM " . table($table); $result = run_query($db1, $query); $i = 0; while ($line = pdo_fetch_assoc($result)) { // check whether selected fields (read via latin1) contain any valid UTF8 code $has_utf8 = false; foreach ($tabdata['fields'] as $f) { if (detectUTF8($line[$f])) { $has_utf8 = true; } } // if so, write back through UTF8 connection if ($has_utf8) { $i++; // write data back through the utf8 connection, for selected fields $pars = array(); $parstring = array(); foreach ($tabdata['fields'] as $f) { $pars[':' . $f] = $line[$f]; $parstring[] = $f . "=:" . $f; } $pars[':' . $tabdata['id']] = $line[$tabdata['id']]; $query2 = "UPDATE " . table($table) . "\n SET " . implode(", ", $parstring) . "\n WHERE " . $tabdata['id'] . "=:" . $tabdata['id'];
/** * @brief insert referer **/ function insertReferer($oDocument) { if ($_SESSION['textyleReferer'][$oDocument->document_srl]) { return; } $_SESSION['textyleReferer'][$oDocument->document_srl] = true; $referer = $_SERVER['HTTP_REFERER']; if (!$referer) { return; } $_url = parse_url(Context::getRequestUri()); $url_info = parse_url($referer); if ($_url['host'] == $url_info['host']) { return; } $args->module_srl = $oDocument->get('module_srl'); $args->document_srl = $oDocument->get('document_srl'); $args->regdate = date("Ymd"); $args->host = $url_info['host']; $output = executeQuery('textyle.getRefererHost', $args); if (!$output->data->textyle_host_srl) { $args->textyle_host_srl = getNextSequence(); $output = executeQuery('textyle.insertRefererHost', $args); } else { $args->textyle_host_srl = $output->data->textyle_host_srl; $output = executeQuery('textyle.updateRefererHost', $args); } if (!$output->toBool()) { return; } if (preg_match('/(query|q|search_keyword)=([^&]+)/i', $referer, $matches)) { $args->link_word = trim($matches[2]); } $args->link_word = detectUTF8($args->link_word, true); $args->referer_url = $referer; $output = executeQuery('textyle.getReferer', $args); if ($output->data->textyle_referer_srl) { $uArgs->textyle_referer_srl = $output->data->textyle_referer_srl; return executeQuery('textyle.updateReferer', $uArgs); } else { $args->textyle_referer_srl = getNextSequence(); return executeQuery('textyle.insertReferer', $args); } }