forked from MightyGorgon/icy_phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinks.js.php
More file actions
134 lines (114 loc) · 3.66 KB
/
links.js.php
File metadata and controls
134 lines (114 loc) · 3.66 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*
* @Extra credits for this file
* OOHOO < webdev@phpbb-tw.net >
* Stefan2k1 and ddonker from www.portedmods.com
* CRLin from http://mail.dhjh.tcc.edu.tw/~gzqbyr/
*
*/
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
// gzip_compression
$do_gzip_compress = false;
if($config['gzip_compress'])
{
$phpver = phpversion();
if($phpver >= "4.0.4pl1")
{
if(extension_loaded("zlib"))
{
ob_start("ob_gzhandler");
}
}
elseif($phpver > "4.0")
{
if(strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))
{
if(extension_loaded("zlib"))
{
$do_gzip_compress = true;
ob_start();
ob_implicit_flush(0);
header("Content-Encoding: gzip");
}
}
}
}
header ("Cache-Control: no-store, no-cache, must-revalidate");
header ("Cache-Control: pre-check=0, post-check=0, max-age=0", false);
header ("Pragma: no-cache");
header ("Expires: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
// End session management
include_once(IP_ROOT_PATH . 'includes/functions_links.' . PHP_EXT);
$links_config = get_links_config(true);
$link_self_img = $links_config['site_logo'];
$site_logo_height = $links_config['height'];
$site_logo_width = $links_config['width'];
$display_interval = $links_config['display_interval'];
$display_logo_num = $links_config['display_logo_num'];
$template->set_filenames(array('body' => 'links_js_body.tpl'));
$sql = "SELECT link_id, link_title, link_logo_src
FROM " . LINKS_TABLE . "
WHERE link_active = 1
ORDER BY link_hits DESC";
$result = $db->sql_query($sql);
$links_logo = '';
while($row = $db->sql_fetchrow($result))
{
//if (empty($row['link_logo_src'])) $row['link_logo_src'] = 'images/links/no_logo88a.gif';
if ($row['link_logo_src'])
{
//$links_logo .= ('"<a href=\"' . append_sid('links.' . PHP_EXT . '?action=go&link_id=' . $row['link_id']) . '\" target=\"_blank\"><img src=\"' . $row['link_logo_src'] . '\" alt=\"' . stripslashes($row['link_title']) . '\" width=\"' . $site_logo_width . '\" height=\"' . $site_logo_height . '\" border=\"0\" hspace=\"1\" \/><\/a>\",' . "\n");
$links_logo .= ('\'<a href="' . append_sid('links.' . PHP_EXT . '?action=go&link_id=' . $row['link_id']) . '" target="_blank"><img src="' . $row['link_logo_src'] . '" alt="' . stripslashes($row['link_title']) . '" width="' . $site_logo_width . '" height="' . $site_logo_height . '" border="0" hspace="1" \/><\/a>\',' . "\n");
}
}
$db->sql_freeresult($result);
if($links_logo)
{
$links_logo = substr($links_logo, 0, -2);
$template->assign_vars(array(
'S_CONTENT_ENCODING' => $lang['ENCODING'],
'T_BODY_BGCOLOR' => '#' . $theme['td_color1'],
'DISPLAY_INTERVAL' => $display_interval,
'DISPLAY_LOGO_NUM' => $display_logo_num,
'LINKS_LOGO' => $links_logo
)
);
}
$template->pparse('body');
$db->sql_close();
// Compress buffered output if required and send to browser
if($do_gzip_compress)
{
//
// Borrowed from php.net!
//
$gzip_contents = ob_get_contents();
ob_end_clean();
$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, 9);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack("V", $gzip_crc);
echo pack("V", $gzip_size);
}
exit;
?>