-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathautolink.php
More file actions
83 lines (52 loc) · 2.45 KB
/
Copy pathautolink.php
File metadata and controls
83 lines (52 loc) · 2.45 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
$code=isset($_GET['code']) ? $_GET['code'] : exit;
$url=isset($_GET['url']) ? $_GET['url'] : '';
$decoded=base64_decode($code);
list($username,$pw)=explode('/',$decoded);
if ($username && $pw) {
require 'config.php';
@mysql_connect(_DB_HOST,_DB_USER,_DB_PW) or die('Could not connect to database');
mysql_select_db(_DB_NAME) or die('Could not find database');
$username=sql_safe($username);
$pw=sql_safe($pw);
$res=mysql_query("SELECT * FROM organizer_user WHERE username='$username' AND user_password='$pw'");
$data=mysql_fetch_object($res);
if (!$data) { echo 'Wrong password, update your "Add Link" URL. Go to <strong>Misc > Help > Misc</strong> to get updated links.'; exit; }
else {
$userid=$data->ID;
$lastlogin=$data->lastlogin;
$timezone=$data->timezone;
$font_face_main=$data->font_face_main;
$font_face_navigation=$data->font_face_navigation;
$font_size=$data->font_size;
$color_main=$data->color_main;
$color_navigation=$data->color_navigation;
$background=$data->background;
# check if session exists
$res=mysql_query('SELECT session_id FROM organizer_session WHERE user='.$userid);
$data=mysql_fetch_object($res);
if (!empty($data)) { $sid=$data->session_id; } else { $sid=''; }
if ($sid < 1) {
$sid=mt_rand(1000000,9999999);
$timestamp=time();
$res=mysql_query("INSERT INTO organizer_session (session_id,create_time,last_active,user,lastlogin,background,color_navigation,color_main,font_face_main,font_face_navigation,font_size,timezone) VALUES ($sid,$timestamp,$timestamp,$userid,'$lastlogin',$background,$color_navigation,$color_main,$font_face_main,$font_face_navigation,$font_size,$timezone)");
}
if (!$res) { echo 'sql error'; exit; }
setcookie('sid',$sid);
if (substr($url,0,8)=='https://') { preg_match("/https:\/\/([a-z0-9]+).([.a-z0-9-]+)/",$url,$dd); }
else if (substr($url,0,7)=='http://') { preg_match("/http:\/\/([a-z0-9]+).([.a-z0-9-]+)/",$url,$dd); }
if (empty($dd)) { $title=''; } else if ($dd[1]!='www') { $title=$dd[1].'.'.$dd[2]; } else { $title=$dd[2]; }
$title=ucwords($title);
$e1=base64_encode($title);
$e2=base64_encode($url);
header("Location: add-link.php?e1=$e1&e2=$e2");
}
} else { echo 'error, contact admin'; }
#
function sql_safe($value) {
if (get_magic_quotes_gpc()) { $value=stripslashes($value); }
if (function_exists('mysql_real_escape_string')) { $value=mysql_real_escape_string($value); }
else { $value=addslashes($value); }
return trim($value);
}
?>