aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/common.inc.php11
-rw-r--r--include/functions.inc.php13
-rw-r--r--include/functions_category.inc.php42
-rw-r--r--include/functions_user.inc.php1
-rw-r--r--include/htmlfunctions.inc.php190
5 files changed, 216 insertions, 41 deletions
diff --git a/include/common.inc.php b/include/common.inc.php
index 2478850a9..6a06706ce 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -120,7 +120,6 @@ if( !defined("PHPWG_INSTALLED") )
exit;
}
-define( 'PREFIX_INCLUDE', '' );// en attendant la migration complète
include(PHPWG_ROOT_PATH . 'include/constants.php');
include(PHPWG_ROOT_PATH . 'include/config.inc.php');
include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
@@ -140,7 +139,8 @@ or die ( "Could not connect to database" );
//
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) != '' )
{
- $client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
+ $client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ?
+ $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/",
getenv('HTTP_X_FORWARDED_FOR'), $ip_list) )
@@ -158,13 +158,14 @@ if ( getenv( 'HTTP_X_FORWARDED_FOR' ) != '' )
}
else
{
- $client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
+ $client_ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ?
+ $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
}
$user_ip = encode_ip($client_ip);
//
-// Setup forum wide options, if this fails then we output a CRITICAL_ERROR
-// since basic forum information is not available
+// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
+// since basic gallery information is not available
//
$query = 'SELECT param,value';
$query.= ' FROM '.CONFIG_TABLE;
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 5287bf99e..4cf4a2337 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -24,11 +24,12 @@
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
-include( PHPWG_ROOT_PATH .'include/functions_user.inc.php' );
-include( PHPWG_ROOT_PATH .'include/functions_session.inc.php' );
-include( PHPWG_ROOT_PATH .'include/functions_category.inc.php' );
-include( PHPWG_ROOT_PATH .'include/functions_xml.inc.php' );
-include( PHPWG_ROOT_PATH .'include/functions_group.inc.php' );
+include_once( PHPWG_ROOT_PATH .'include/functions_user.inc.php' );
+include_once( PHPWG_ROOT_PATH .'include/functions_session.inc.php' );
+include_once( PHPWG_ROOT_PATH .'include/functions_category.inc.php' );
+include_once( PHPWG_ROOT_PATH .'include/functions_xml.inc.php' );
+include_once( PHPWG_ROOT_PATH .'include/functions_group.inc.php' );
+include_once( PHPWG_ROOT_PATH .'include/htmlfunctions.inc.php' );
//----------------------------------------------------------- generic functions
@@ -396,7 +397,7 @@ function notify( $type, $infos = '' )
while ( $row = mysql_fetch_array( $result ) )
{
$to = $row['mail_address'];
- include( PREFIX_INCLUDE.'./language/'.$row['language'].'.php' );
+ include( PHPWG_ROOT_PATH.'language/'.$row['language'].'.php' );
$content = $lang['mail_hello']."\n\n";
switch ( $type )
{
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 1652f3b6e..5f8aed0cf 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -111,10 +111,17 @@ function get_user_plain_structure()
{
$category = array();
foreach ( $infos as $info ) {
- if ( $info == 'uc.date_last' )
+ if ( $info == 'uc.date_last')
{
- list($year,$month,$day) = explode( '-', $row['date_last'] );
- $category['date_last'] = mktime(0,0,0,$month,$day,$year);
+ if (empty($row['date_last']))
+ {
+ $category['date_last']= 0;
+ }
+ else
+ {
+ list($year,$month,$day) = explode( '-', $row['date_last'] );
+ $category['date_last'] = mktime(0,0,0,$month,$day,$year);
+ }
}
else if ( isset( $row[$info] ) ) $category[$info] = $row[$info];
else $category[$info] = '';
@@ -239,8 +246,6 @@ function count_user_total_images()
// $cat['site_id']
function get_cat_info( $id )
{
- global $page;
-
$infos = array( 'nb_images','id_uppercat','comment','site_id','galleries_url'
,'dir','date_last','uploadable','status','visible'
,'representative_picture_id','uppercats' );
@@ -270,14 +275,14 @@ function get_cat_info( $id )
$cat['name'] = array();
- $query = 'SELECT name FROM '.CATEGORIES_TABLE;
+ $query = 'SELECT name,id FROM '.CATEGORIES_TABLE;
$query.= ' WHERE id IN ('.$cat['uppercats'].')';
$query.= ' ORDER BY id ASC';
$query.= ';';
$result = mysql_query( $query );
while( $row = mysql_fetch_array( $result ) )
{
- array_push( $cat['name'], $row['name'] );
+ $cat['name'][$row['id']] = $row['name'];
}
return $cat;
@@ -350,28 +355,6 @@ function get_site_url( $category_id )
return $row['galleries_url'];
}
-// The function get_cat_display_name returns a string containing the list
-// of upper categories to the root category from the lowest category shown
-// example : "anniversaires - fete mere 2002 - animaux - erika"
-// You can give two parameters :
-// - $separation : the string between each category name " - " for example
-// - $style : the style of the span tag for the lowest category,
-// "font-style:italic;" for example
-function get_cat_display_name( $array_cat_names, $separation,
- $style, $replace_space = true )
-{
- $output = '';
- foreach ( $array_cat_names as $i => $name ) {
- if ( $i > 0 ) $output.= $separation;
- if ( $i < count( $array_cat_names ) - 1 or $style == '')
- $output.= $name;
- else
- $output.= '<span style="'.$style.'">'.$name.'</span>';
- }
- if ( $replace_space ) return replace_space( $output );
- else return $output;
-}
-
// initialize_category initializes ;-) the variables in relation
// with category :
// 1. calculation of the number of pictures in the category
@@ -633,3 +616,4 @@ function get_first_non_empty_cat_id( $id_uppercat )
return false;
}
?>
+
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 0c6671974..cf3f01fb3 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -260,7 +260,6 @@ function setup_style($style)
{
$template_path = 'template/' ;
$template_name = $style ;
- include_once( PHPWG_ROOT_PATH . $template_path . $template_name.'/htmlfunctions.inc.php' );
$template = new Template(PHPWG_ROOT_PATH . $template_path . $template_name);
return $template;
}
diff --git a/include/htmlfunctions.inc.php b/include/htmlfunctions.inc.php
new file mode 100644
index 000000000..426ef8e82
--- /dev/null
+++ b/include/htmlfunctions.inc.php
@@ -0,0 +1,190 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | htmlfunctions.inc.php |
+// +-----------------------------------------------------------------------+
+// | application : PhpWebGallery <http://phpwebgallery.net> |
+// | branch : BSF (Best So Far) |
+// +-----------------------------------------------------------------------+
+// | file : $RCSfile$
+// | last update : $Date$
+// | last modifier : $Author$
+// | revision : $Revision$
+// +-----------------------------------------------------------------------+
+// | 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 |
+// | |
+// | 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, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+function get_icon( $date_comparaison )
+{
+ global $user, $conf, $lang;
+ $difference = time() - $date_comparaison;
+ $jours = 24*60*60;
+ $output = '';
+ $title = $lang['recent_image'].'&nbsp;';
+ if ( $difference < $user['long_period'] * $jours )
+ {
+ $icon_url = './template/'.$user['template'].'/theme/';
+ if ( $difference < $user['short_period'] * $jours )
+ {
+ $icon_url.= 'new_short.gif';
+ $title .= $user['short_period'];
+ }
+ else
+ {
+ $icon_url.= 'new_long.gif';
+ $title .= $user['long_period'];
+ }
+ $title .= '&nbsp;'.$lang['days'];
+ $size = getimagesize( $icon_url );
+ $output = '<img title="'.$title.'" src="'.$icon_url.'" style="border:0;';
+ $output.= 'height:'.$size[1].'px;width:'.$size[0].'px" alt="" />';
+ }
+ return $output;
+}
+
+function create_navigation_bar( $url, $nb_element, $start,
+ $nb_element_page, $link_class )
+{
+ global $lang;
+ $navigation_bar = "";
+ // 0. détection de la page en cours
+ if( !isset( $start )
+ || !is_numeric( $start )
+ || ( is_numeric( $start ) && $start < 0 ) )
+ {
+ $start = 0;
+ }
+ // on n'affiche la bare de navigation que si on plus de 1 page
+ if ( $nb_element > $nb_element_page )
+ {
+ // 1.une page précédente ?
+ if ( $start != 0 )
+ {
+ $previous = $start - $nb_element_page;
+ $navigation_bar.= '<a href="';
+ $navigation_bar.= add_session_id( $url.'&amp;start='.$previous );
+ $navigation_bar.= '" class="'.$link_class.'">'.$lang['previous_page'];
+ $navigation_bar.= '</a>';
+ $navigation_bar.= ' | ';
+ }
+ // 2.liste des numéros de page
+ $maximum = ceil ( $nb_element / $nb_element_page );
+ for ( $i = 1; $i <= $maximum; $i++ )
+ {
+ $temp_start = ( $i - 1 ) * $nb_element_page;
+ if ( $temp_start == $start )
+ {
+ $navigation_bar.= ' <span style="font-weight:bold;">'.$i.'</span> ';
+ }
+ else
+ {
+ $navigation_bar.= ' <a href="';
+ $navigation_bar.= add_session_id( $url.'&amp;start='.$temp_start );
+ $navigation_bar.= '" class="'.$link_class.'">'.$i.'</a> ';
+ }
+ }
+ // 3.une page suivante ?
+ if ( $nb_element > $nb_element_page
+ && $start + $nb_element_page < $nb_element )
+ {
+ $next = $start + $nb_element_page;
+ $navigation_bar.= ' | <a href="';
+ $navigation_bar.= add_session_id( $url.'&amp;start='.$next );
+ $navigation_bar.= '" class="'.$link_class.'">'.$lang['next_page'].'</a>';
+ }
+ }
+ return $navigation_bar;
+}
+
+//
+// Pick a language, any language ...
+//
+function language_select($default, $select_name = "language")
+{
+ global $lang_info;
+ $dir = opendir(PHPWG_ROOT_PATH . 'language');
+ $available_lang= array();
+
+ while ( $file = readdir($dir) )
+ {
+ if (is_dir ( realpath(PHPWG_ROOT_PATH.'language/'.$file) )
+ && !is_link(realpath(PHPWG_ROOT_PATH . 'language/' . $file))
+ && isset($lang_info['language'][$file]))
+ {
+ $available_lang[$file] = $lang_info['language'][$file];
+ }
+ }
+ closedir($dir);
+ @asort($available_lang);
+ @reset($available_lang);
+
+ $lang_select = '<select name="' . $select_name . '" onchange="this.form.submit()">';
+ while ( list($code, $displayname) = @each($available_lang) )
+ {
+ $selected = ( strtolower($default) == strtolower($code) ) ? ' selected="selected"' : '';
+ $lang_select .= '<option value="' . $code . '"' . $selected . '>' . ucwords($displayname) . '</option>';
+ }
+ $lang_select .= '</select>';
+
+ return $lang_select;
+}
+
+//
+// Pick a template/theme combo,
+//
+function style_select($default_style, $select_name = "style")
+{
+ $dir = opendir(PHPWG_ROOT_PATH . 'template');
+ $style_select = '<select name="' . $select_name . '">';
+ while ( $file = readdir($dir) )
+ {
+ if (is_dir ( realpath(PHPWG_ROOT_PATH.'template/'.$file) )
+ && !is_link(realpath(PHPWG_ROOT_PATH . 'template/' . $file))
+ && !strstr($file,'.'))
+ {
+ $selected = ( $file == $default_style ) ? ' selected="selected"' : '';
+ $style_select .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>';
+ }
+ }
+ closedir($dir);
+ return $style_select;
+}
+
+// The function get_cat_display_name returns a string containing the list
+// of upper categories to the root category from the lowest category shown
+// example : "anniversaires - fete mere 2002 - animaux - erika"
+// You can give this parameters :
+// - $style : the style of the span tag for the lowest category,
+// "font-style:italic;" for example
+function get_cat_display_name( $cat_informations, $separator,
+ $url = 'category.php?cat=', $replace_space = true)
+{
+ $output = '';
+ $i=0;
+ while ( list ($id, $name) = each($cat_informations))
+ {
+ if ( $i ) $output.= $separator;
+ $i++;
+ if (empty($style) && empty($url) || ($i == count( $cat_informations)))
+ $output.= $name;
+ elseif (!empty($url))
+ $output.= '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.$url.$id).'">'.$name."</a>";
+ else
+ $output.= '<span style="'.$style.'">'.$name.'</span>';
+ }
+ if ( $replace_space ) return replace_space( $output );
+ else return $output;
+}
+?>
+