aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorWojciech Polak <polak@gnu.org>2010-04-09 21:33:16 +0200
committerWojciech Polak <polak@gnu.org>2010-04-09 23:10:47 +0200
commitea75b3ba588bff81a67b3b74ded7079e387f0357 (patch)
treeacaea98eaffdc34465cc0727f6f33c965233af5f /frontend
parent5b36ef42d675891b69a8d808042ec735f5b7cc46 (diff)
downloadcheetah-ea75b3ba588bff81a67b3b74ded7079e387f0357.tar.gz
cheetah-ea75b3ba588bff81a67b3b74ded7079e387f0357.tar.bz2
Improve the dispatcher.
Diffstat (limited to 'frontend')
-rw-r--r--frontend/d.php56
-rw-r--r--frontend/fetch.php13
-rw-r--r--frontend/htaccess2
-rw-r--r--frontend/lib/d-files.php49
-rw-r--r--frontend/lib/functions.php15
-rw-r--r--frontend/lib/i18n.php2
-rw-r--r--frontend/login.php7
-rw-r--r--frontend/reader.php11
8 files changed, 89 insertions, 66 deletions
diff --git a/frontend/d.php b/frontend/d.php
index 83adc56..cdec2a7 100644
--- a/frontend/d.php
+++ b/frontend/d.php
@@ -2,7 +2,7 @@
/*
Cheetah News d.php
- Copyright (C) 2005, 2006, 2007, 2008, 2009 Wojciech Polak.
+ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Wojciech Polak.
Copyright (C) 2006 The Cheetah News Team.
This program is free software; you can redistribute it and/or modify it
@@ -20,6 +20,7 @@
*/
require 'lib/include.php';
+require 'lib/d-files.php';
$copyright = "/*
Cheetah News Aggregator.
@@ -40,42 +41,14 @@ $copyright = "/*
with this program. If not, see <http://www.gnu.org/licenses/>.
*/\n\n";
-$files = array ('bt/2' => array ('js', array ('js/v2/i18n.js',
- 'js/v2/boot.js',
- 'js/v2/jquery.js',
- 'js/v2/jquery-ui.js',
- 'js/v2/jquery-extra.js')),
- 'js/2' => array ('js', array ('js/v2/core.js',
- 'js/v2/gui.js',
- 'js/v2/opml.js',
- 'js/v2/filter.js',
- 'js/v2/marker.js',
- 'js/v2/share.js',
- 'js/v2/translate.js',
- 'js/v2/notes.js',
- 'js/v2/weather.js',
- 'js/v2/niftycube.js')),
- 'login' => array ('js', array ('js/v2/login.js')),
- 'tr/2' => array ('xml', array ('xslt/v2/feed.xsl')),
- 'op/2' => array ('xml', array ('xslt/v2/opml.xsl')),
- 'wt/2' => array ('xml', array ('xslt/v2/weather.xsl')),
- 'css/2' => array ('css', array ('css/v2/style1.css',
- 'css/v2/niftyCorners.css')),
- 'css.login' => array ('css', array ('css/v2/login.css')),
- 'css.notice' => array ('css', array ('css/v2/notice.css')),
- 'css.signup' => array ('css', array ('css/v2/signup.css')),
- 'css.changepassword' => array ('css', array ('css/v2/changepassword.css')),
- 'dir' => array ('xml', array ('gen/directory.xml')),
- 'popular' => array ('xml', array ('gen/popular.xml'))
- );
-
getvars ('q');
-if (isset ($files[$q]) && $files[$q][0] == 'js')
- start_session (null, false, 0);
+if ($q == 'popular')
+ $days = 1;
else
- start_session (null, false, 900);
+ $days = 30;
+start_session (null, false, 86400 * $days);
$session->auth ('iflogged');
$headers = getallheaders ();
@@ -86,14 +59,12 @@ if (isset ($files[$q])) {
if ($d[0] == 'js') {
if (!$logged && $q != 'login')
return;
- if ($q == 'js/1' || $q == 'js/2')
- checkReferer ();
$m = $d[1];
array_push ($m, $mofile);
checkModification ($m, true);
header ('Content-Type: application/x-javascript; charset=UTF-8');
echo $copyright;
- if ($q == 'bt/1' || $q == 'bt/2')
+ if ($q == 'bt')
convert_mo ();
printJsCode ($d[1]);
}
@@ -103,25 +74,12 @@ if (isset ($files[$q])) {
printCode ($d[1]);
}
else if ($d[0] == 'xml') {
- checkReferer ();
checkModification ($d[1], false);
header ('Content-Type: application/xml; charset=UTF-8');
printCode ($d[1]);
}
}
-function checkReferer ()
-{
- global $headers;
- foreach ($headers as $k => $v)
- {
- if (strtolower ($k) == 'x-referer' && $v == 'CNA')
- return;
- }
- header ('HTTP/1.1 401 Unauthorized');
- exit ();
-}
-
function checkModification ($files, $checkLang)
{
global $CONF, $session, $headers, $locale;
diff --git a/frontend/fetch.php b/frontend/fetch.php
index 8374713..aa46f71 100644
--- a/frontend/fetch.php
+++ b/frontend/fetch.php
@@ -2,7 +2,7 @@
/*
Cheetah News fetch.php
- Copyright (C) 2005, 2006, 2008 Wojciech Polak.
+ Copyright (C) 2005, 2006, 2008, 2010 Wojciech Polak.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -47,15 +47,13 @@ if ($session->status['afterlogged'] == 'yes')
$safs = 0;
$oldestFirst = 0;
$refresh = 0;
- $invitation = 0;
$lucid = '';
- $db->query ("SELECT showActive,oldestFirst,refresh,invitation,lastUC ".
+ $db->query ("SELECT showActive,oldestFirst,refresh,lastUC ".
"FROM user WHERE id='".$session->id."'");
if ($db->next_record ()) {
$safs = $db->f ('showActive');
$oldestFirst = $db->f ('oldestFirst');
$refresh = $db->f ('refresh');
- $invitation = $db->f ('invitation');
$lucid = $db->f ('lastUC');
if (!empty ($lucid)) $lucid = md5 ($lucid);
}
@@ -85,8 +83,7 @@ if ($session->status['afterlogged'] == 'yes')
this.lang = '".$session->lang."';
this.safs = $safs;
this.oldf = $oldestFirst;
- this.frequency = $refresh;
- this.invitation = $invitation;\n";
+ this.frequency = $refresh;\n";
if ($feedAddSid)
echo " this.feedAddSid = '".encodeJsEntities ($feedAddSid)."';\n";
else if ($feedAddUrl)
@@ -105,7 +102,7 @@ if ($session->status['afterlogged'] == 'yes')
echo " this.folders = {\n";
$i = 1;
foreach ($folders as $k => $v) {
- echo " '".$k."' : '".encodeJsEntities ($v)."'";
+ echo " '".$k."': '".encodeJsEntities ($v)."'";
if ($i++ < $end)
echo ",\n";
}
@@ -126,7 +123,7 @@ if ($session->status['afterlogged'] == 'yes')
$i = 1;
while ($db->next_record ())
{
- echo " '".$db->f ('feedid')."' : ['".
+ echo " '".$db->f ('feedid')."': ['".
encodeJsEntities ($db->f ('description'))
."','".$db->f ('folder')."',".$db->f ('latest')
.",".$db->f ('expand').",".$db->f ('active').",'".$db->f ('url')."']";
diff --git a/frontend/htaccess b/frontend/htaccess
index 595b9cb..f8635b5 100644
--- a/frontend/htaccess
+++ b/frontend/htaccess
@@ -5,7 +5,7 @@
Header always unset TCN
</IfModule>
<IfModule mod_deflate.c>
- AddOutputFilterByType DEFLATE application/x-javascript application/xml text/xml text/css
+ AddOutputFilterByType DEFLATE application/x-javascript application/xml text/xml text/html text/css
</IfModule>
</IfDefine>
diff --git a/frontend/lib/d-files.php b/frontend/lib/d-files.php
new file mode 100644
index 0000000..fc92e6c
--- /dev/null
+++ b/frontend/lib/d-files.php
@@ -0,0 +1,49 @@
+<?php
+
+/*
+ Cheetah News lib/d-files.php
+ Copyright (C) 2010 Wojciech Polak.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+$files = array ('bt' => array ('js', array ('js/v2/i18n.js',
+ 'js/v2/boot.js',
+ 'js/v2/jquery.js',
+ 'js/v2/jquery-ui.js',
+ 'js/v2/jquery-extra.js')),
+ 'js' => array ('js', array ('js/v2/core.js',
+ 'js/v2/gui.js',
+ 'js/v2/opml.js',
+ 'js/v2/filter.js',
+ 'js/v2/marker.js',
+ 'js/v2/share.js',
+ 'js/v2/translate.js',
+ 'js/v2/notes.js',
+ 'js/v2/weather.js',
+ 'js/v2/niftycube.js')),
+ 'login' => array ('js', array ('js/v2/login.js')),
+ 'tr' => array ('xml', array ('xslt/v2/feed.xsl')),
+ 'op' => array ('xml', array ('xslt/v2/opml.xsl')),
+ 'wt' => array ('xml', array ('xslt/v2/weather.xsl')),
+ 'css' => array ('css', array ('css/v2/style1.css',
+ 'css/v2/niftyCorners.css')),
+ 'css.login' => array ('css', array ('css/v2/login.css')),
+ 'css.notice' => array ('css', array ('css/v2/notice.css')),
+ 'css.signup' => array ('css', array ('css/v2/signup.css')),
+ 'css.changepassword' => array ('css', array ('css/v2/changepassword.css')),
+ 'dir' => array ('xml', array ('gen/directory.xml')),
+ 'popular' => array ('xml', array ('gen/popular.xml'))
+ );
+?>
diff --git a/frontend/lib/functions.php b/frontend/lib/functions.php
index 1865111..8d9b39d 100644
--- a/frontend/lib/functions.php
+++ b/frontend/lib/functions.php
@@ -2,7 +2,7 @@
/*
Cheetah News lib/functions.php
- Copyright (C) 2005, 2006 Wojciech Polak.
+ Copyright (C) 2005, 2006, 2010 Wojciech Polak.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -148,4 +148,17 @@ function checkCSRF ($csid) {
}
}
+function dsp ($res, $params=array()) {
+ global $SIGS;
+
+ if (isset ($SIGS[$res]))
+ $params['v'] = $SIGS[$res];
+
+ $p = '';
+ foreach ($params as $k => $v) {
+ $p .= '&amp;'.$k.'='.$v;
+ }
+ return 'd?q='.$res.$p;
+}
+
?>
diff --git a/frontend/lib/i18n.php b/frontend/lib/i18n.php
index 12d3c80..696b36d 100644
--- a/frontend/lib/i18n.php
+++ b/frontend/lib/i18n.php
@@ -397,7 +397,7 @@ function convert_mo()
echo "var gettext_locale = \"$locale\";\n";
echo "gettext_msg = {\n";
for ($q = 1; $q < $str_count; $q++) {
- printf(" '%s' : '%s'", my_addslashes ($msgid[$q]), my_addslashes ($msgstr[$q]));
+ printf(" '%s': '%s'", my_addslashes ($msgid[$q]), my_addslashes ($msgstr[$q]));
if ($q < $str_count-1)
printf(",");
echo "\n";
diff --git a/frontend/login.php b/frontend/login.php
index 7024bb7..ad59cc6 100644
--- a/frontend/login.php
+++ b/frontend/login.php
@@ -2,7 +2,7 @@
/*
Cheetah News login.php
- Copyright (C) 2005, 2006, 2007, 2008, 2009 Wojciech Polak.
+ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Wojciech Polak.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -19,6 +19,7 @@
*/
require_once 'lib/include.php';
+require_once 'lib/d-sigs.php';
require_once 'lib/register.php';
require_once 'Auth/OpenID/Consumer.php';
require_once 'Auth/OpenID/FileStore.php';
@@ -164,9 +165,9 @@ echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$CHEETAH_LANG.'" la
<meta name="description" content="Web-based Personal News Aggregator. The Google Reader Alternative." />
<meta name="keywords" content="cheetah news, web-based personal news aggregator, feedreader, feeds, rss, atom, rdf, web 2.0" />
<meta name="robots" content="index,nofollow" />
-<link rel="stylesheet" href="d?q=css.login" type="text/css" />
+<link rel="stylesheet" href="<?=dsp('css.login')?>" type="text/css" />
<link rel="icon" href="images/favicon.png" type="image/png" />
-<script type="text/javascript" src="d?q=login"></script>
+<script type="text/javascript" src="<?=dsp('login')?>"></script>
</head>
<body>
diff --git a/frontend/reader.php b/frontend/reader.php
index eaef9b6..fb9ea7a 100644
--- a/frontend/reader.php
+++ b/frontend/reader.php
@@ -19,6 +19,7 @@
*/
require 'lib/include.php';
+require 'lib/d-sigs.php';
start_session (null);
$session->auth ('afterlogged');
@@ -33,11 +34,15 @@ if ($session->status['afterlogged'] == 'yes')
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<link id="style" rel="stylesheet" type="text/css" href="d?q=css/2" />
+<link id="style" rel="stylesheet" type="text/css" href="<?=dsp('css')?>" />
<?php if ($CONF['feedEngine'] != 'cthonly') { ?><script type="text/javascript" src="http://www.google.com/jsapi?key=<?=$CONF['google.key']?>"></script>
<? } ?>
-<script type="text/javascript">var fbe='<?=$CONF['feedEngine']?>';</script>
-<script type="text/javascript" src="d?q=bt/2<?php if (!empty ($session->lang)) echo '&amp;'.$session->lang; ?>"></script>
+<script type="text/javascript">
+var fbe = '<?=$CONF['feedEngine']?>';
+var LANG = '<?=$session->lang?>';
+var SIGS = {'js':'<?=$SIGS["js"]?>', 'tr':'<?=$SIGS["tr"]?>', 'wt':'<?=$SIGS["wt"]?>', 'op':'<?=$SIGS["op"]?>', 'dir':'<?=$SIGS["dir"]?>'};
+</script>
+<script type="text/javascript" src="<?=dsp('bt')?><?php if (!empty ($session->lang)) echo '&amp;lang='.$session->lang; ?>"></script>
<title>Cheetah News</title>
</head>

Return to:

Send suggestions and report system problems to the System administrator.