forked from Kliqqi-CMS/Kliqqi-CMS
/
out.php
44 lines (36 loc) · 1.33 KB
/
out.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include_once('internal/Smarty.class.php');
$main_smarty = new Smarty;
include('config.php');
include(mnminclude.'html1.php');
include(mnminclude.'link.php');
$requestID = sanitize($_REQUEST['id'], 3);
$requestTitle = sanitize($_REQUEST['title'], 3);
$requestURL = sanitize($_REQUEST['url'], 3);
$requestTitle = sanitize($requestTitle,4);
$requestURL = sanitize($requestURL,4);
$requestURL = preg_replace('/(https?:\/)([^\/])/','$1/$2',$requestURL);
if ($requestTitle != '') {
$requestID = $db->get_var("SELECT link_id FROM " . table_links . " WHERE `link_title_url` = '" . $db->escape($requestTitle) . "';");
}
if ($requestURL != '') {
$requestID = $db->get_var("SELECT link_id FROM " . table_links . " WHERE `link_url` = '" . $db->escape($requestURL) . "';");
}
if (is_numeric($requestID)) {
$id = $requestID;
$link = new Link;
$link->id=$requestID;
$link->read();
if (!isset($_SESSION)) {
session_start();
}
if (!is_array($_SESSION['outphpclicks']) || !isset($_SESSION['outphpclicks'][$id])) {
$sql = "UPDATE " . table_links . " set link_out=link_out+1 WHERE link_id='$id'";
$db->query($sql);
$_SESSION['outphpclicks'][$id] = 1;
}
require_once(mnminclude.'check_behind_proxy.php');
header("HTTP/1.1 301 Moved Permanently");
header('Location: '. $link->url);
}
?>