Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $dbArray = include(dirname(dirname(dirname(__FILE__))) . "/typo3conf/LocalConfiguration.php"); // das holt natürlich nicht die richtigen DB-Einstellungen aus AdditionalConfiguration!!!
- include(dirname(dirname(dirname(__FILE__))) . "/typo3conf/AdditionalConfiguration.php");
- $dbhost = $dbArray['DB']['host'];
- $dbuser = $dbArray['DB']['username'];
- $dbpassword = $dbArray['DB']['password'];
- $dbname = $dbArray['DB']['database'];
- // get AdditionalConfiguration if applicable:
- if (isset($GLOBALS['TYPO3_CONF_VARS']['DB']['username'])) {
- $dbhost = $GLOBALS['TYPO3_CONF_VARS']['DB']['host'];
- $dbuser = $GLOBALS['TYPO3_CONF_VARS']['DB']['username'];
- $dbpassword = $GLOBALS['TYPO3_CONF_VARS']['DB']['password'];
- $dbname = $GLOBALS['TYPO3_CONF_VARS']['DB']['database'];
- }
- $mysqli = new mysqli($dbhost, $dbuser, $dbpassword, $dbname);
- $mysqli->query('set names utf8');
- $code = $mysqli->real_escape_string($_GET['code']);
- $host = 'http://' . filter_input(INPUT_SERVER, 'HTTP_HOST');
- function redirect($alsoRetrieveOldOnes=false) {
- global $mysqli, $code, $host;
- $betweenFilter = 'and pid BETWEEN 833 AND 847';
- if ($alsoRetrieveOldOnes) {
- $betweenFilter = '';
- }
- $res = $mysqli->query("SELECT realurl_headline FROM tx_davtravel_domain_model_travel where hidden=0 and deleted=0 ".$betweenFilter." and bookingcode='$code' limit 0,1");
- $row = $res->fetch_assoc();
- if(!is_null($row)) {
- $url = $host . '/reisedetails/detail/' . $row['realurl_headline'] . '.html';
- header('Location:' . $url, 301);
- exit;
- }
- }
- redirect();
- // Look if there is an archived version that we may want to display:
- redirect(true);
- function slugify($text, $substitutes = null) {
- $invalid = array();
- // use default substitutes if none were given
- if ($substitutes == null || !is_array($substitutes))
- $invalid = array(
- 'Ä' => 'ae', 'Ü' => 'ue', 'Ö' => 'oe',
- 'ä' => 'ae', 'ü' => 'ue', 'ö' => 'oe',
- );
- else
- $invalid = $substitutes;
- // substitute umlauts
- $text = str_replace(array_keys($invalid), array_values($invalid), $text);
- // lowercase
- $text = strtolower($text);
- // replace non letter or digits by -
- $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
- // trim
- $text = trim($text, '-');
- // transliterate
- if (function_exists('iconv')) {
- $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
- }
- // remove unwanted characters
- $text = preg_replace('~[^-\w]+~', '', $text);
- if (empty($text))
- return 'n-a';
- return $text;
- }
- // Look if we can unarchive an old one and fetch it:
- $res = $mysqli->query("SELECT * FROM tx_davtravel_domain_model_travel where bookingcode='$code' order by crdate desc limit 0,1");
- while($row = $res->fetch_assoc()) {
- $correctRealUrl = '';
- if ($row['realurl_headline'] == '') {
- $headline = $row['headline'];
- if ($headline == '') {
- $headline = $row['reise_titel'];
- }
- $correctRealUrl = ', realurl_headline="'.slugify($headline).'"';
- }
- $mysqli->query("UPDATE tx_davtravel_domain_model_travel SET hidden=0 $correctRealUrl WHERE uid=".$row['uid']);
- // $url = $host . '/reisedetails/detail/' . $row['realurl_headline'] . '.html';
- // header('Location:' . $url, 301);
- // exit;
- }
- //try again:
- redirect(true);
- header('Location:' . $host, 301);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement