- 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
87
feed.php
87
feed.php
|
|
@ -88,50 +88,44 @@ function ts_to_iso8601($ts)
|
||||||
// | initialization |
|
// | initialization |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
||||||
// clean $user array (include/user.inc.php has been executed)
|
$feed_id= isset($_GET['feed']) ? $_GET['feed'] : '';
|
||||||
$user = array();
|
$image_only=isset($_GET['image_only']);
|
||||||
|
|
||||||
// echo '<pre>'.generate_key(50).'</pre>';
|
// echo '<pre>'.generate_key(50).'</pre>';
|
||||||
if (isset($_GET['feed'])
|
if ( !empty($feed_id) )
|
||||||
and preg_match('/^[A-Za-z0-9]{50}$/', $_GET['feed']))
|
|
||||||
{
|
{
|
||||||
$query = '
|
$query = '
|
||||||
SELECT uf.user_id AS id,
|
SELECT user_id,
|
||||||
ui.status,
|
last_check
|
||||||
uf.last_check,
|
FROM '.USER_FEED_TABLE.'
|
||||||
u.'.$conf['user_fields']['username'].' AS username
|
WHERE id = \''.$feed_id.'\'
|
||||||
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'].'\'
|
|
||||||
;';
|
;';
|
||||||
$user = mysql_fetch_array(pwg_query($query));
|
$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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if ( empty($user) )
|
|
||||||
{
|
{
|
||||||
page_not_found('Unknown/missing feed identifier');
|
$image_only = true;
|
||||||
}
|
if (!$user['is_the_guest'])
|
||||||
|
{// auto session was created - so switch to guest
|
||||||
$user['forbidden_categories'] = calculate_permissions($user['id'],
|
$user = array();
|
||||||
$user['status']);
|
$user = build_user( $conf['guest_id'], true );
|
||||||
if ('' == $user['forbidden_categories'])
|
}
|
||||||
{
|
|
||||||
$user['forbidden_categories'] = '0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
|
||||||
|
|
||||||
include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
|
include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
|
||||||
|
|
||||||
$base_url = get_host_url().cookie_path();
|
set_make_full_url();
|
||||||
if ( strrpos($base_url, '/') !== strlen($base_url)-1 )
|
|
||||||
{
|
|
||||||
$base_url .= '/';
|
|
||||||
}
|
|
||||||
$page['root_path']=$base_url;
|
|
||||||
|
|
||||||
$rss = new UniversalFeedCreator();
|
$rss = new UniversalFeedCreator();
|
||||||
|
|
||||||
|
|
@ -144,9 +138,9 @@ $rss->link = $conf['gallery_url'];
|
||||||
// | Feed creation |
|
// | 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)
|
if (count($news) > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -173,19 +167,22 @@ if ( !isset($_GET['image_only']) )
|
||||||
$query = '
|
$query = '
|
||||||
UPDATE '.USER_FEED_TABLE.'
|
UPDATE '.USER_FEED_TABLE.'
|
||||||
SET last_check = \''.$dbnow.'\'
|
SET last_check = \''.$dbnow.'\'
|
||||||
WHERE id = \''.$_GET['feed'].'\'
|
WHERE id = \''.$feed_id.'\'
|
||||||
;';
|
;';
|
||||||
pwg_query($query);
|
pwg_query($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // update the last check to avoid deletion by maintenance task
|
{
|
||||||
$query = '
|
if ( !empty($feed_id) )
|
||||||
UPDATE '.USER_FEED_TABLE.'
|
{// update the last check to avoid deletion by maintenance task
|
||||||
SET last_check = \''.$dbnow.'\'
|
$query = '
|
||||||
WHERE id = \''.$_GET['feed'].'\'
|
UPDATE '.USER_FEED_TABLE.'
|
||||||
;';
|
SET last_check = \''.$dbnow.'\'
|
||||||
pwg_query($query);
|
WHERE id = \''.$feed_id.'\'
|
||||||
|
;';
|
||||||
|
pwg_query($query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$dates = get_recent_post_dates( 5, 6, 6);
|
$dates = get_recent_post_dates( 5, 6, 6);
|
||||||
|
|
@ -195,7 +192,7 @@ foreach($dates as $date_detail)
|
||||||
$date = $date_detail['date_available'];
|
$date = $date_detail['date_available'];
|
||||||
$exploded_date = explode_mysqldt($date);
|
$exploded_date = explode_mysqldt($date);
|
||||||
$item = new FeedItem();
|
$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->title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')';
|
||||||
$item->link = make_index_url(
|
$item->link = make_index_url(
|
||||||
array(
|
array(
|
||||||
|
|
@ -211,7 +208,7 @@ foreach($dates as $date_detail)
|
||||||
|
|
||||||
$item->description .=
|
$item->description .=
|
||||||
'<li>'
|
'<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')).'">'
|
.'<a href="'.make_index_url(array('section'=>'recent_pics')).'">'
|
||||||
.l10n('recent_pics_cat').'</a>'
|
.l10n('recent_pics_cat').'</a>'
|
||||||
|
|
@ -238,8 +235,8 @@ foreach($dates as $date_detail)
|
||||||
'<li>'
|
'<li>'
|
||||||
.get_cat_display_name_cache($cat['uppercats'])
|
.get_cat_display_name_cache($cat['uppercats'])
|
||||||
.' ('.
|
.' ('.
|
||||||
l10n_dec('%d element added',
|
l10n_dec('%d new element',
|
||||||
'%d elements added', $cat['img_count']).')'
|
'%d new elements', $cat['img_count']).')'
|
||||||
.'</li>';
|
.'</li>';
|
||||||
}
|
}
|
||||||
$item->description .= '</ul>';
|
$item->description .= '</ul>';
|
||||||
|
|
|
||||||
|
|
@ -179,10 +179,8 @@ if ($conf['gallery_locked'])
|
||||||
|
|
||||||
if ( script_basename() != 'identification' and !is_admin() )
|
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']
|
echo $lang['gallery_locked_message']
|
||||||
.'<a href="'.get_root_url().'identification.php">.</a>';
|
.'<a href="'.get_absolute_root_url(false).'identification.php">.</a>';
|
||||||
exit();
|
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
|
redirect (get_absolute_root_url(false).'identification.php');
|
||||||
$page['root_path'] = cookie_path();
|
|
||||||
redirect (get_root_url().'identification.php');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf['check_upgrade_feed']
|
if ($conf['check_upgrade_feed']
|
||||||
|
|
@ -220,10 +216,8 @@ SELECT id
|
||||||
// which upgrades need to be applied?
|
// which upgrades need to be applied?
|
||||||
if (count(array_diff($existing, $applied)) > 0)
|
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, '
|
$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 = $_SERVER['SCRIPT_NAME'];
|
||||||
}
|
}
|
||||||
$scr = substr($scr,0,strrpos( $scr,'/'));
|
$scr = substr($scr,0,strrpos( $scr,'/'));
|
||||||
|
|
||||||
// add a trailing '/' if needed
|
// 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'];
|
$root_url = $page['root_path'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{// TODO - add HERE the possibility to call PWG functions from external scripts
|
||||||
$root_url = PHPWG_ROOT_PATH;
|
$root_url = PHPWG_ROOT_PATH;
|
||||||
}
|
}
|
||||||
if ( dirname($root_url)!='.' )
|
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 )
|
* returns the absolute url to the root of PWG
|
||||||
* TODO: if required by someone, treat https case
|
* @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://";
|
// TODO - add HERE the possibility to call PWG functions from external scripts
|
||||||
$url .= $_SERVER['HTTP_HOST'];
|
$url = '';
|
||||||
if ($_SERVER['SERVER_PORT']!=80)
|
if ($with_scheme)
|
||||||
{
|
{
|
||||||
$url .= ':'.$_SERVER['SERVER_PORT'];
|
$url .= 'http://'.$_SERVER['HTTP_HOST'];
|
||||||
|
if ($_SERVER['SERVER_PORT']!=80)
|
||||||
|
{
|
||||||
|
$url .= ':'.$_SERVER['SERVER_PORT'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$url .= cookie_path();
|
||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -419,7 +424,7 @@ function set_make_full_url()
|
||||||
$page['save_root_path']['path'] = $page['root_path'];
|
$page['save_root_path']['path'] = $page['root_path'];
|
||||||
}
|
}
|
||||||
$page['save_root_path']['count'] = 1;
|
$page['save_root_path']['count'] = 1;
|
||||||
$page['root_path'] = get_host_url().cookie_path();
|
$page['root_path'] = get_absolute_root_url();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -209,8 +209,7 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
|
||||||
{
|
{
|
||||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||||
|
|
||||||
$del_url = get_host_url().cookie_path()
|
$del_url = get_absolute_root_url().'comments.php?delete='.$comm['id'];
|
||||||
.'comments.php?delete='.$comm['id'];
|
|
||||||
|
|
||||||
$content =
|
$content =
|
||||||
'Author: '.$comm['author']."\n"
|
'Author: '.$comm['author']."\n"
|
||||||
|
|
@ -221,7 +220,7 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
|
||||||
if ($comment_action!='validate')
|
if ($comment_action!='validate')
|
||||||
{
|
{
|
||||||
$content .=
|
$content .=
|
||||||
'Validate: '.get_host_url().cookie_path()
|
'Validate: '.get_absolute_root_url()
|
||||||
.'comments.php?validate='.$comm['id'];
|
.'comments.php?validate='.$comm['id'];
|
||||||
}
|
}
|
||||||
pwg_mail( get_webmaster_mail_address(), '',
|
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 comments'] = '%d new comments';
|
||||||
$lang['%d new element'] = '%d new element';
|
$lang['%d new element'] = '%d new element';
|
||||||
$lang['%d new elements'] = '%d new elements';
|
$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 user'] = '%d new user';
|
||||||
$lang['%d new users'] = '%d new users';
|
$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 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 element'] = '%d waiting element';
|
||||||
$lang['%d waiting elements'] = '%d waiting elements';
|
$lang['%d waiting elements'] = '%d waiting elements';
|
||||||
$lang['About'] = 'About';
|
$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 comments'] = '%d nouveaux commentaires utilisateur';
|
||||||
$lang['%d new element'] = '%d nouvel élément';
|
$lang['%d new element'] = '%d nouvel élément';
|
||||||
$lang['%d new elements'] = '%d nouveaux éléments';
|
$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 user'] = '%d nouvel utilisateur';
|
||||||
$lang['%d new users'] = '%d nouveaux utilisateurs';
|
$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 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 element'] = '%d élément en attente';
|
||||||
$lang['%d waiting elements'] = '%d éléments en attente';
|
$lang['%d waiting elements'] = '%d éléments en attente';
|
||||||
$lang['About'] = 'À propos';
|
$lang['About'] = 'À propos';
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,18 @@ INSERT INTO '.USER_FEED_TABLE.'
|
||||||
;';
|
;';
|
||||||
pwg_query($query);
|
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 |
|
// | template initialization |
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ if (isset($_POST['submit']))
|
||||||
{
|
{
|
||||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||||
$username = $_POST['login'];
|
$username = $_POST['login'];
|
||||||
$admin_url = get_host_url().cookie_path()
|
$admin_url = get_absolute_root_url().
|
||||||
.'admin.php?page=user_list&username='.$username;
|
.'admin.php?page=user_list&username='.$username;
|
||||||
|
|
||||||
$content =
|
$content =
|
||||||
|
|
|
||||||
10
ws.php
10
ws.php
|
|
@ -4,10 +4,10 @@
|
||||||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | branch : BSF (Best So Far)
|
// | branch : BSF (Best So Far)
|
||||||
// | file : $URL: svn+ssh://rvelices@svn.gna.org/svn/phpwebgallery/trunk/action.php $
|
// | file : $Id$
|
||||||
// | last update : $Date: 2006-12-21 18:49:12 -0500 (Thu, 21 Dec 2006) $
|
// | last update : $Date$
|
||||||
// | last modifier : $Author: rvelices $
|
// | last modifier : $Author$
|
||||||
// | revision : $Rev: 1678 $
|
// | revision : $Rev$
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | This program is free software; you can redistribute it and/or modify |
|
// | 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 |
|
// | 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);
|
$service->setEncoder($responseFormat, $encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
$page['root_path']=get_host_url().cookie_path();
|
set_make_full_url();
|
||||||
$service->run();
|
$service->run();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue