Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (preg_match('/\/(\d+)-(.*).html/i', $uri, $match)) {
- try {
- $code = (int)$match[1];
- if ($code < 1) throw new Exception("Bad ID");
- $setup = parse_ini_file('../is/app/etc/setup.ini');
- $rdb = new PDO('mysql:host=' . $setup['db.host'] . ';dbname=' . $setup['db.dbname'] . ';charset=utf8', $setup['db.username'], $setup['db.password']);
- $sth = $rdb->prepare('SELECT url FROM items i INNER JOIN routes r ON (i.item_id = r.id) WHERE i.item_id = ? AND r.tag = ? AND r.ver = 1 LIMIT 1');
- $sth->execute([$code, 'routeItem']);
- $row = $sth->fetch(PDO::FETCH_ASSOC);
- if ($row['url'] != '') {
- header("Location: " . $row['url'], true, 301);
- exit;
- }
- } catch (Exception $e) {
- }
- header("Location: /");
- exit;
- }
- if (preg_match('/\/(\d+)-(.*)/i', $uri, $match)) {
- try {
- $code = (int)$match[1];
- if ($code < 1) throw new Exception("Bad ID");
- $setup = parse_ini_file('../is/app/etc/setup.ini');
- $rdb = new PDO('mysql:host=' . $setup['db.host'] . ';dbname=' . $setup['db.dbname'] . ';charset=utf8', $setup['db.username'], $setup['db.password']);
- $sth = $rdb->prepare('SELECT url FROM kategorie k LEFT JOIN routes r ON (k.nowa = r.id) WHERE k.stara = ? AND r.tag = ? AND r.ver = 1 LIMIT 1');
- $sth->execute([$code, 'routeCat']);
- $row = $sth->fetch(PDO::FETCH_ASSOC);
- if ($row['url'] != '') {
- header("Location: " . $row['url'], true, 301);
- exit;
- }
- } catch (Exception $e) {
- }
- header("Location: /");
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement