1 | <?php
|
---|
2 | function check_admin() {
|
---|
3 | @require_once("../../../../config.php");
|
---|
4 | $link = @mysql_connect($dbhost, $dbuname, $dbpass);
|
---|
5 | if (!$link)
|
---|
6 | {
|
---|
7 | echo "Non può essere effettuata la connessione a MySQL.<br />";
|
---|
8 | echo "Errore di MySQL: (" . mysql_errno() . ") " . mysql_error() . " \n";
|
---|
9 | die("<br />MANUTENZIONE");
|
---|
10 | }
|
---|
11 | if(isset($HTTP_COOKIE_VARS)) {
|
---|
12 | $_COOKIE = $HTTP_COOKIE_VARS;
|
---|
13 | }
|
---|
14 | $admin = $_COOKIE['admin'];
|
---|
15 |
|
---|
16 | if (!$admin) { echo "NON PRESENTE"; }
|
---|
17 | if (!$admin) { return 0; }
|
---|
18 |
|
---|
19 | static $adminSave;
|
---|
20 |
|
---|
21 | if (isset($adminSave)) return $adminSave;
|
---|
22 | $admin = base64_decode($admin);
|
---|
23 | $admin = addslashes($admin);
|
---|
24 | $admin = explode(':', $admin);
|
---|
25 |
|
---|
26 | $aid = $admin[0];
|
---|
27 | $pwd = $admin[1];
|
---|
28 | $site_id = $admin[3];
|
---|
29 |
|
---|
30 |
|
---|
31 | //echo "- cookie";
|
---|
32 | //echo "<br />- ".$aid;
|
---|
33 | //echo "<br />- ".$pwd;
|
---|
34 | //echo "<br />- ".$site_id;
|
---|
35 |
|
---|
36 |
|
---|
37 | static $adminSave;
|
---|
38 | if (isset($adminSave)) return $adminSave;
|
---|
39 | $aid = substr(addslashes($aid), 0, 25);
|
---|
40 | if (!empty($aid) && !empty($pwd)) {
|
---|
41 | if (empty($siteid) OR ($siteid <'1')) $siteid='1';
|
---|
42 |
|
---|
43 |
|
---|
44 | $query = "SELECT pwd, site_id FROM {$dbname}.{$prefix}_authors WHERE aid='$aid'";
|
---|
45 | $result = mysql_query($query, $link);
|
---|
46 | if (!$result)
|
---|
47 | {
|
---|
48 | echo " Errore di MySQL: (" . mysql_errno() . ") " . mysql_error() . " \n";
|
---|
49 | exit();
|
---|
50 | }
|
---|
51 |
|
---|
52 | $pass = mysql_fetch_row($result);
|
---|
53 | mysql_free_result($result);
|
---|
54 | //echo "<br />Database";
|
---|
55 | //echo "<br />".$pass[0];
|
---|
56 | //echo "<br />".$pass[1];
|
---|
57 |
|
---|
58 |
|
---|
59 | if ((($pass[0] == $pwd && !empty($pass[0])) AND ($pass[1] == $siteid && !empty($pass[1])))) {
|
---|
60 |
|
---|
61 | //echo "<br />1".$adminSave;
|
---|
62 | return $adminSave = 1;
|
---|
63 | } else {
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 | //echo "<br />0".$adminSave;
|
---|
68 | return $adminSave = 0;
|
---|
69 | }
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | check_admin();
|
---|
74 | ?>
|
---|