Changeset 1750


Ignore:
Timestamp:
Jan 24, 2007, 6:07:08 AM (17 years ago)
Author:
rvelices
Message:
  • 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
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/feed.php

    r1639 r1750  
    8989// +-----------------------------------------------------------------------+
    9090
    91 // clean $user array (include/user.inc.php has been executed)
    92 $user = array();
     91$feed_id= isset($_GET['feed']) ? $_GET['feed'] : '';
     92$image_only=isset($_GET['image_only']);
    9393
    9494// echo '<pre>'.generate_key(50).'</pre>';
    95 if (isset($_GET['feed'])
    96     and preg_match('/^[A-Za-z0-9]{50}$/', $_GET['feed']))
     95if ( !empty($feed_id) )
    9796{
    9897  $query = '
    99 SELECT uf.user_id AS id,
    100        ui.status,
    101        uf.last_check,
    102        u.'.$conf['user_fields']['username'].' AS username
    103   FROM '.USER_FEED_TABLE.' AS uf
    104     INNER JOIN '.USER_INFOS_TABLE.' AS ui
    105       ON ui.user_id = uf.user_id
    106     INNER JOIN '.USERS_TABLE.' AS u
    107       ON u.'.$conf['user_fields']['id'].' = uf.user_id
    108   WHERE uf.id = \''.$_GET['feed'].'\'
     98SELECT user_id,
     99       last_check
     100  FROM '.USER_FEED_TABLE.'
     101  WHERE id = \''.$feed_id.'\'
    109102;';
    110   $user = mysql_fetch_array(pwg_query($query));
    111 }
    112 
    113 if ( empty($user) )
    114 {
    115   page_not_found('Unknown/missing feed identifier');
    116 }
    117 
    118 $user['forbidden_categories'] = calculate_permissions($user['id'],
    119                                                       $user['status']);
    120 if ('' == $user['forbidden_categories'])
    121 {
    122   $user['forbidden_categories'] = '0';
     103  $feed_row = mysql_fetch_assoc(pwg_query($query));
     104  if ( empty($feed_row) )
     105  {
     106    page_not_found('Unknown/missing feed identifier');
     107  }
     108  if ($feed_row['user_id']!=$user['id'])
     109  { // new user
     110    $user = array();
     111    $user = build_user( $feed_row['user_id'], true );
     112  }
     113}
     114else
     115{
     116  $image_only = true;
     117  if (!$user['is_the_guest'])
     118  {// auto session was created - so switch to guest
     119    $user = array();
     120    $user = build_user( $conf['guest_id'], true );
     121  }
    123122}
    124123
     
    127126include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php');
    128127
    129 $base_url = get_host_url().cookie_path();
    130 if ( strrpos($base_url, '/') !== strlen($base_url)-1 )
    131 {
    132   $base_url .= '/';
    133 }
    134 $page['root_path']=$base_url;
     128set_make_full_url();
    135129
    136130$rss = new UniversalFeedCreator();
     
    145139// +-----------------------------------------------------------------------+
    146140
    147 if ( !isset($_GET['image_only']) )
    148 {
    149   $news = news($user['last_check'], $dbnow, true, true);
     141if (!$image_only)
     142{
     143  $news = news($feed_row['last_check'], $dbnow, true, true);
    150144
    151145  if (count($news) > 0)
     
    174168UPDATE '.USER_FEED_TABLE.'
    175169  SET last_check = \''.$dbnow.'\'
    176   WHERE id = \''.$_GET['feed'].'\'
     170  WHERE id = \''.$feed_id.'\'
    177171;';
    178172    pwg_query($query);
     
    180174}
    181175else
    182 { // update the last check to avoid deletion by maintenance task
    183   $query = '
    184 UPDATE '.USER_FEED_TABLE.'
    185   SET last_check = \''.$dbnow.'\'
    186   WHERE id = \''.$_GET['feed'].'\'
    187 ;';
    188   pwg_query($query);
     176{
     177  if ( !empty($feed_id) )
     178  {// update the last check to avoid deletion by maintenance task
     179    $query = '
     180  UPDATE '.USER_FEED_TABLE.'
     181    SET last_check = \''.$dbnow.'\'
     182    WHERE id = \''.$feed_id.'\'
     183  ;';
     184    pwg_query($query);
     185  }
    189186}
    190187
     
    196193  $exploded_date = explode_mysqldt($date);
    197194  $item = new FeedItem();
    198   $item->title = l10n_dec('%d element added', '%d elements added', $date_detail['nb_elements']);
     195  $item->title = l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements']);
    199196  $item->title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')';
    200197  $item->link = make_index_url(
     
    212209  $item->description .=
    213210        '<li>'
    214         .l10n_dec('%d element added', '%d elements added', $date_detail['nb_elements'])
     211        .l10n_dec('%d new element', '%d new elements', $date_detail['nb_elements'])
    215212        .' ('
    216213        .'<a href="'.make_index_url(array('section'=>'recent_pics')).'">'
     
    239236          .get_cat_display_name_cache($cat['uppercats'])
    240237          .' ('.
    241           l10n_dec('%d element added',
    242                    '%d elements added', $cat['img_count']).')'
     238          l10n_dec('%d new element',
     239                   '%d new elements', $cat['img_count']).')'
    243240          .'</li>';
    244241  }
  • trunk/include/common.inc.php

    r1744 r1750  
    180180  if ( script_basename() != 'identification' and !is_admin() )
    181181  {
    182     //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
    183     $page['root_path'] = cookie_path();
    184182    echo $lang['gallery_locked_message']
    185       .'<a href="'.get_root_url().'identification.php">.</a>';
     183      .'<a href="'.get_absolute_root_url(false).'identification.php">.</a>';
    186184    exit();
    187185  }
     
    198196    )
    199197{
    200   //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
    201   $page['root_path'] = cookie_path();
    202   redirect (get_root_url().'identification.php');
     198  redirect (get_absolute_root_url(false).'identification.php');
    203199}
    204200
     
    221217  if (count(array_diff($existing, $applied)) > 0)
    222218  {
    223     //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
    224     $page['root_path'] = cookie_path();
    225219    $header_msgs[] = 'Some database upgrades are missing, '
    226       .'<a href="'.get_root_url().'upgrade_feed.php">upgrade now</a>';
     220      .'<a href="'.get_absolute_root_url(false).'upgrade_feed.php">upgrade now</a>';
    227221  }
    228222}
  • trunk/include/functions_session.inc.php

    r1623 r1750  
    112112  }
    113113  $scr = substr($scr,0,strrpos( $scr,'/'));
     114
    114115  // add a trailing '/' if needed
    115   return ($scr{strlen($scr)-1} == '/') ? $scr : $scr . '/';
     116  $scr .= ($scr{strlen($scr)-1} == '/') ? '' : '/';
     117 
     118  if ( substr(PHPWG_ROOT_PATH,0,3)=='../')
     119  { // this is maybe a plugin inside pwg directory
     120    // TODO - what if it is an external script outside PWG ?
     121    $scr = $scr.PHPWG_ROOT_PATH;
     122    while (1)
     123    {
     124      $new = preg_replace('#[^/]+/\.\.(/|$)#', '', $scr);
     125      if ($new==$scr)
     126      {
     127        break;
     128      }
     129      $scr=$new;
     130    }
     131  }
     132  return $scr;
    116133}
    117134
  • trunk/include/functions_url.inc.php

    r1722 r1750  
    3939  }
    4040  else
    41   {
     41  {// TODO - add HERE the possibility to call PWG functions from external scripts
    4242    $root_url = PHPWG_ROOT_PATH;
    4343  }
     
    5353
    5454/**
    55  * returns the url of the current host (e.g. http://www.toto.com )
    56  * TODO: if required by someone, treat https case
    57  */
    58 function get_host_url()
    59 {
    60   $url = "http://";
    61   $url .= $_SERVER['HTTP_HOST'];
    62   if ($_SERVER['SERVER_PORT']!=80)
    63   {
    64     $url .= ':'.$_SERVER['SERVER_PORT'];
    65   }
     55 * returns the absolute url to the root of PWG
     56 * @param boolean with_scheme if false - does not add http://toto.com
     57 */
     58function get_absolute_root_url($with_scheme=true)
     59{
     60  // TODO - add HERE the possibility to call PWG functions from external scripts
     61  $url = '';
     62  if ($with_scheme)
     63  {
     64    $url .= 'http://'.$_SERVER['HTTP_HOST'];
     65    if ($_SERVER['SERVER_PORT']!=80)
     66    {
     67      $url .= ':'.$_SERVER['SERVER_PORT'];
     68    }
     69  }
     70  $url .= cookie_path();
    6671  return $url;
    6772}
     
    420425    }
    421426    $page['save_root_path']['count'] = 1;
    422     $page['root_path'] = get_host_url().cookie_path();
     427    $page['root_path'] = get_absolute_root_url();
    423428  }
    424429  else
  • trunk/include/picture_comment.inc.php

    r1744 r1750  
    210210      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    211211
    212       $del_url = get_host_url().cookie_path()
    213         .'comments.php?delete='.$comm['id'];
     212      $del_url = get_absolute_root_url().'comments.php?delete='.$comm['id'];
    214213
    215214      $content =
     
    222221      {
    223222        $content .=
    224           'Validate: '.get_host_url().cookie_path()
     223          'Validate: '.get_absolute_root_url()
    225224          .'comments.php?validate='.$comm['id'];
    226225      }
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r1732 r1750  
    302302$lang['%d new element'] = '%d new element';
    303303$lang['%d new elements'] = '%d new elements';
    304 $lang['%d element added'] = '%d element added';
    305 $lang['%d elements added'] = '%d elements added';
    306304$lang['%d new user'] = '%d new user';
    307305$lang['%d new users'] = '%d new users';
    308306$lang['%d pictures are also linked to current tags'] = '%d pictures are also linked to current tags';
    309 $lang['%d pictures'] = '%d pictures';
    310307$lang['%d waiting element'] = '%d waiting element';
    311308$lang['%d waiting elements'] = '%d waiting elements';
  • trunk/language/fr_FR.iso-8859-1/common.lang.php

    r1732 r1750  
    302302$lang['%d new element'] = '%d nouvel élément';
    303303$lang['%d new elements'] = '%d nouveaux éléments';
    304 $lang['%d element added'] = '%d élément ajouté';
    305 $lang['%d elements added'] = '%d éléments ajoutés';
    306304$lang['%d new user'] = '%d nouvel utilisateur';
    307305$lang['%d new users'] = '%d nouveaux utilisateurs';
    308306$lang['%d pictures are also linked to current tags'] = '%d images sont également liées aux tags courants';
    309 $lang['%d pictures'] = '%d images';
    310307$lang['%d waiting element'] = '%d élément en attente';
    311308$lang['%d waiting elements'] = '%d éléments en attente';
  • trunk/notification.php

    r1703 r1750  
    5252pwg_query($query);
    5353
    54 $feed_url=PHPWG_ROOT_PATH.'feed.php?feed='.$page['feed'];
    55 $feed_image_only_url=$feed_url.'&amp;image_only';
     54
     55$feed_url=PHPWG_ROOT_PATH.'feed.php';
     56if ($user['is_the_guest'])
     57{
     58  $feed_image_only_url=$feed_url;
     59  $feed_url .= '?feed='.$page['feed'];
     60}
     61else
     62{
     63  $feed_url .= '?feed='.$page['feed'];
     64  $feed_image_only_url=$feed_url.'&amp;image_only';
     65}
    5666
    5767// +-----------------------------------------------------------------------+
  • trunk/register.php

    r1652 r1750  
    6161      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    6262      $username = $_POST['login'];
    63       $admin_url = get_host_url().cookie_path()
     63      $admin_url = get_absolute_root_url().
    6464        .'admin.php?page=user_list&username='.$username;
    6565
  • trunk/ws.php

    • Property svn:keywords set to Author Date Id Revision
    r1698 r1750  
    55// +-----------------------------------------------------------------------+
    66// | branch        : BSF (Best So Far)
    7 // | file          : $URL: svn+ssh://rvelices@svn.gna.org/svn/phpwebgallery/trunk/action.php $
    8 // | last update   : $Date: 2006-12-21 18:49:12 -0500 (Thu, 21 Dec 2006) $
    9 // | last modifier : $Author: rvelices $
    10 // | revision      : $Rev: 1678 $
     7// | file          : $Id$
     8// | last update   : $Date$
     9// | last modifier : $Author$
     10// | revision      : $Rev$
    1111// +-----------------------------------------------------------------------+
    1212// | This program is free software; you can redistribute it and/or modify  |
     
    178178}
    179179
    180 $page['root_path']=get_host_url().cookie_path();
     180set_make_full_url();
    181181$service->run();
    182182
Note: See TracChangeset for help on using the changeset viewer.