- plugins with own independent scripts work now (cookie_path and url root are
correct) - prepare a bit some url functions so that later we can fully embed pwg in scripts located outside pwg - remove some unnecessary language strings git-svn-id: http://piwigo.org/svn/trunk@1750 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
d71f764762
commit
585d7c434e
10 changed files with 97 additions and 81 deletions
79
feed.php
79
feed.php
|
|
@ -88,50 +88,44 @@ function ts_to_iso8601($ts)
|
|||
// | initialization |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// clean $user array (include/user.inc.php has been executed)
|
||||
$user = array();
|
||||
$feed_id= isset($_GET['feed']) ? $_GET['feed'] : '';
|
||||
$image_only=isset($_GET['image_only']);
|
||||
|
||||
// echo '<pre>'.generate_key(50).'</pre>';
|
||||
if (isset($_GET['feed'])
|
||||
and preg_match('/^[A-Za-z0-9]{50}$/', $_GET['feed']))
|
||||
if ( !empty($feed_id) )
|
||||
{
|
||||
$query = '
|
||||
SELECT uf.user_id AS id,
|
||||
ui.status,
|
||||
uf.last_check,
|
||||
u.'.$conf['user_fields']['username'].' AS username
|
||||
FROM '.USER_FEED_TABLE.' AS uf
|
||||
INNER JOIN '.USER_INFOS_TABLE.' AS ui
|
||||
ON ui.user_id = uf.user_id
|
||||
INNER JOIN '.USERS_TABLE.' AS u
|
||||
ON u.'.$conf['user_fields']['id'].' = uf.user_id
|
||||
WHERE uf.id = \''.$_GET['feed'].'\'
|
||||
SELECT user_id,
|
||||
last_check
|
||||
FROM '.USER_FEED_TABLE.'
|
||||
WHERE id = \''.$feed_id.'\'
|
||||
;';
|
||||
$user = mysql_fetch_array(pwg_query($query));
|
||||
}
|
||||
|
||||
if ( empty($user) )
|
||||
{
|
||||
$feed_row = mysql_fetch_assoc(pwg_query($query));
|
||||
if ( empty($feed_row) )
|
||||
{
|
||||
page_not_found('Unknown/missing feed identifier');
|
||||
}
|
||||
if ($feed_row['user_id']!=$user['id'])
|
||||
{ // new user
|
||||
$user = array();
|
||||
$user = build_user( $feed_row['user_id'], true );
|
||||
}
|
||||
}
|
||||
|
||||
$user['forbidden_categories'] = calculate_permissions($user['id'],
|
||||
$user['status']);
|
||||
if ('' == $user['forbidden_categories'])
|
||||
else
|
||||
{
|
||||
$user['forbidden_categories'] = '0';
|
||||
$image_only = true;
|
||||
if (!$user['is_the_guest'])
|
||||
{// auto session was created - so switch to guest
|
||||
$user = array();
|
||||
$user = build_user( $conf['guest_id'], true );
|
||||
}
|
||||
}
|
||||
|
||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
|
||||
|
||||
$base_url = get_host_url().cookie_path();
|
||||
if ( strrpos($base_url, '/') !== strlen($base_url)-1 )
|
||||
{
|
||||
$base_url .= '/';
|
||||
}
|
||||
$page['root_path']=$base_url;
|
||||
set_make_full_url();
|
||||
|
||||
$rss = new UniversalFeedCreator();
|
||||
|
||||
|
|
@ -144,9 +138,9 @@ $rss->link = $conf['gallery_url'];
|
|||
// | Feed creation |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if ( !isset($_GET['image_only']) )
|
||||
if (!$image_only)
|
||||
{
|
||||
$news = news($user['last_check'], $dbnow, true, true);
|
||||
$news = news($feed_row['last_check'], $dbnow, true, true);
|
||||
|
||||
if (count($news) > 0)
|
||||
{
|
||||
|
|
@ -173,19 +167,22 @@ if ( !isset($_GET['image_only']) )
|
|||
$query = '
|
||||
UPDATE '.USER_FEED_TABLE.'
|
||||
SET last_check = \''.$dbnow.'\'
|
||||
WHERE id = \''.$_GET['feed'].'\'
|
||||
WHERE id = \''.$feed_id.'\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // update the last check to avoid deletion by maintenance task
|
||||
{
|
||||
if ( !empty($feed_id) )
|
||||
{// update the last check to avoid deletion by maintenance task
|
||||
$query = '
|
||||
UPDATE '.USER_FEED_TABLE.'
|
||||
UPDATE '.USER_FEED_TABLE.'
|
||||
SET last_check = \''.$dbnow.'\'
|
||||
WHERE id = \''.$_GET['feed'].'\'
|
||||
;';
|
||||
WHERE id = \''.$feed_id.'\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$dates = get_recent_post_dates( 5, 6, 6);
|
||||
|
|
@ -195,7 +192,7 @@ foreach($dates as $date_detail)
|
|||
$date = $date_detail['date_available'];
|
||||
$exploded_date = explode_mysqldt($date);
|
||||
$item = new FeedItem();
|
||||
$item->title = l10n_dec('%d element added', '%d elements added', $date_detail['nb_elements']);
|
||||
$item->title = l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements']);
|
||||
$item->title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')';
|
||||
$item->link = make_index_url(
|
||||
array(
|
||||
|
|
@ -211,7 +208,7 @@ foreach($dates as $date_detail)
|
|||
|
||||
$item->description .=
|
||||
'<li>'
|
||||
.l10n_dec('%d element added', '%d elements added', $date_detail['nb_elements'])
|
||||
.l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements'])
|
||||
.' ('
|
||||
.'<a href="'.make_index_url(array('section'=>'recent_pics')).'">'
|
||||
.l10n('recent_pics_cat').'</a>'
|
||||
|
|
@ -238,8 +235,8 @@ foreach($dates as $date_detail)
|
|||
'<li>'
|
||||
.get_cat_display_name_cache($cat['uppercats'])
|
||||
.' ('.
|
||||
l10n_dec('%d element added',
|
||||
'%d elements added', $cat['img_count']).')'
|
||||
l10n_dec('%d new element',
|
||||
'%d new elements', $cat['img_count']).')'
|
||||
.'</li>';
|
||||
}
|
||||
$item->description .= '</ul>';
|
||||
|
|
|
|||
|
|
@ -179,10 +179,8 @@ if ($conf['gallery_locked'])
|
|||
|
||||
if ( script_basename() != 'identification' and !is_admin() )
|
||||
{
|
||||
//next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
|
||||
$page['root_path'] = cookie_path();
|
||||
echo $lang['gallery_locked_message']
|
||||
.'<a href="'.get_root_url().'identification.php">.</a>';
|
||||
.'<a href="'.get_absolute_root_url(false).'identification.php">.</a>';
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
|
@ -197,9 +195,7 @@ if ($user['is_the_guest'] and !$conf['guest_access']
|
|||
)
|
||||
)
|
||||
{
|
||||
//next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
|
||||
$page['root_path'] = cookie_path();
|
||||
redirect (get_root_url().'identification.php');
|
||||
redirect (get_absolute_root_url(false).'identification.php');
|
||||
}
|
||||
|
||||
if ($conf['check_upgrade_feed']
|
||||
|
|
@ -220,10 +216,8 @@ SELECT id
|
|||
// which upgrades need to be applied?
|
||||
if (count(array_diff($existing, $applied)) > 0)
|
||||
{
|
||||
//next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
|
||||
$page['root_path'] = cookie_path();
|
||||
$header_msgs[] = 'Some database upgrades are missing, '
|
||||
.'<a href="'.get_root_url().'upgrade_feed.php">upgrade now</a>';
|
||||
.'<a href="'.get_absolute_root_url(false).'upgrade_feed.php">upgrade now</a>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,8 +111,25 @@ function cookie_path()
|
|||
$scr = $_SERVER['SCRIPT_NAME'];
|
||||
}
|
||||
$scr = substr($scr,0,strrpos( $scr,'/'));
|
||||
|
||||
// add a trailing '/' if needed
|
||||
return ($scr{strlen($scr)-1} == '/') ? $scr : $scr . '/';
|
||||
$scr .= ($scr{strlen($scr)-1} == '/') ? '' : '/';
|
||||
|
||||
if ( substr(PHPWG_ROOT_PATH,0,3)=='../')
|
||||
{ // this is maybe a plugin inside pwg directory
|
||||
// TODO - what if it is an external script outside PWG ?
|
||||
$scr = $scr.PHPWG_ROOT_PATH;
|
||||
while (1)
|
||||
{
|
||||
$new = preg_replace('#[^/]+/\.\.(/|$)#', '', $scr);
|
||||
if ($new==$scr)
|
||||
{
|
||||
break;
|
||||
}
|
||||
$scr=$new;
|
||||
}
|
||||
}
|
||||
return $scr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function get_root_url()
|
|||
$root_url = $page['root_path'];
|
||||
}
|
||||
else
|
||||
{
|
||||
{// TODO - add HERE the possibility to call PWG functions from external scripts
|
||||
$root_url = PHPWG_ROOT_PATH;
|
||||
}
|
||||
if ( dirname($root_url)!='.' )
|
||||
|
|
@ -52,17 +52,22 @@ function get_root_url()
|
|||
}
|
||||
|
||||
/**
|
||||
* returns the url of the current host (e.g. http://www.toto.com )
|
||||
* TODO: if required by someone, treat https case
|
||||
* returns the absolute url to the root of PWG
|
||||
* @param boolean with_scheme if false - does not add http://toto.com
|
||||
*/
|
||||
function get_host_url()
|
||||
function get_absolute_root_url($with_scheme=true)
|
||||
{
|
||||
$url = "http://";
|
||||
$url .= $_SERVER['HTTP_HOST'];
|
||||
// TODO - add HERE the possibility to call PWG functions from external scripts
|
||||
$url = '';
|
||||
if ($with_scheme)
|
||||
{
|
||||
$url .= 'http://'.$_SERVER['HTTP_HOST'];
|
||||
if ($_SERVER['SERVER_PORT']!=80)
|
||||
{
|
||||
$url .= ':'.$_SERVER['SERVER_PORT'];
|
||||
}
|
||||
}
|
||||
$url .= cookie_path();
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
@ -419,7 +424,7 @@ function set_make_full_url()
|
|||
$page['save_root_path']['path'] = $page['root_path'];
|
||||
}
|
||||
$page['save_root_path']['count'] = 1;
|
||||
$page['root_path'] = get_host_url().cookie_path();
|
||||
$page['root_path'] = get_absolute_root_url();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -209,8 +209,7 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
|
|||
{
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||
|
||||
$del_url = get_host_url().cookie_path()
|
||||
.'comments.php?delete='.$comm['id'];
|
||||
$del_url = get_absolute_root_url().'comments.php?delete='.$comm['id'];
|
||||
|
||||
$content =
|
||||
'Author: '.$comm['author']."\n"
|
||||
|
|
@ -221,7 +220,7 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
|
|||
if ($comment_action!='validate')
|
||||
{
|
||||
$content .=
|
||||
'Validate: '.get_host_url().cookie_path()
|
||||
'Validate: '.get_absolute_root_url()
|
||||
.'comments.php?validate='.$comm['id'];
|
||||
}
|
||||
pwg_mail( get_webmaster_mail_address(), '',
|
||||
|
|
|
|||
|
|
@ -301,12 +301,9 @@ $lang['%d new comment'] = '%d new comment';
|
|||
$lang['%d new comments'] = '%d new comments';
|
||||
$lang['%d new element'] = '%d new element';
|
||||
$lang['%d new elements'] = '%d new elements';
|
||||
$lang['%d element added'] = '%d element added';
|
||||
$lang['%d elements added'] = '%d elements added';
|
||||
$lang['%d new user'] = '%d new user';
|
||||
$lang['%d new users'] = '%d new users';
|
||||
$lang['%d pictures are also linked to current tags'] = '%d pictures are also linked to current tags';
|
||||
$lang['%d pictures'] = '%d pictures';
|
||||
$lang['%d waiting element'] = '%d waiting element';
|
||||
$lang['%d waiting elements'] = '%d waiting elements';
|
||||
$lang['About'] = 'About';
|
||||
|
|
|
|||
|
|
@ -301,12 +301,9 @@ $lang['%d new comment'] = '%d nouveau commentaire utilisateur';
|
|||
$lang['%d new comments'] = '%d nouveaux commentaires utilisateur';
|
||||
$lang['%d new element'] = '%d nouvel élément';
|
||||
$lang['%d new elements'] = '%d nouveaux éléments';
|
||||
$lang['%d element added'] = '%d élément ajouté';
|
||||
$lang['%d elements added'] = '%d éléments ajoutés';
|
||||
$lang['%d new user'] = '%d nouvel utilisateur';
|
||||
$lang['%d new users'] = '%d nouveaux utilisateurs';
|
||||
$lang['%d pictures are also linked to current tags'] = '%d images sont également liées aux tags courants';
|
||||
$lang['%d pictures'] = '%d images';
|
||||
$lang['%d waiting element'] = '%d élément en attente';
|
||||
$lang['%d waiting elements'] = '%d éléments en attente';
|
||||
$lang['About'] = 'À propos';
|
||||
|
|
|
|||
|
|
@ -51,8 +51,18 @@ INSERT INTO '.USER_FEED_TABLE.'
|
|||
;';
|
||||
pwg_query($query);
|
||||
|
||||
$feed_url=PHPWG_ROOT_PATH.'feed.php?feed='.$page['feed'];
|
||||
$feed_image_only_url=$feed_url.'&image_only';
|
||||
|
||||
$feed_url=PHPWG_ROOT_PATH.'feed.php';
|
||||
if ($user['is_the_guest'])
|
||||
{
|
||||
$feed_image_only_url=$feed_url;
|
||||
$feed_url .= '?feed='.$page['feed'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$feed_url .= '?feed='.$page['feed'];
|
||||
$feed_image_only_url=$feed_url.'&image_only';
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template initialization |
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ if (isset($_POST['submit']))
|
|||
{
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||
$username = $_POST['login'];
|
||||
$admin_url = get_host_url().cookie_path()
|
||||
$admin_url = get_absolute_root_url().
|
||||
.'admin.php?page=user_list&username='.$username;
|
||||
|
||||
$content =
|
||||
|
|
|
|||
10
ws.php
10
ws.php
|
|
@ -4,10 +4,10 @@
|
|||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $URL: svn+ssh://rvelices@svn.gna.org/svn/phpwebgallery/trunk/action.php $
|
||||
// | last update : $Date: 2006-12-21 18:49:12 -0500 (Thu, 21 Dec 2006) $
|
||||
// | last modifier : $Author: rvelices $
|
||||
// | revision : $Rev: 1678 $
|
||||
// | file : $Id$
|
||||
// | last update : $Date$
|
||||
// | last modifier : $Author$
|
||||
// | revision : $Rev$
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | 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 |
|
||||
|
|
@ -177,7 +177,7 @@ if (!is_null($responseFormat))
|
|||
$service->setEncoder($responseFormat, $encoder);
|
||||
}
|
||||
|
||||
$page['root_path']=get_host_url().cookie_path();
|
||||
set_make_full_url();
|
||||
$service->run();
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue