diff --git a/admin.php b/admin.php index 7d32565c8..0076d1fb3 100644 --- a/admin.php +++ b/admin.php @@ -89,6 +89,8 @@ switch ( $_GET['page'] ) $title = $lang['title_update']; $page_valide = true; break; case 'configuration': $title = $lang['title_configuration']; $page_valide = true; break; + case 'admin_phpinfo': + $title = $lang['phpinfos']; $page_valide = true; break; case 'help': $title = $lang['title_instructions']; $page_valide = true; break; case 'cat_perm': @@ -172,25 +174,38 @@ include(PHPWG_ROOT_PATH.'include/page_header.php'); $template->set_filenames( array('admin'=>'admin.tpl') ); $template->assign_vars(array( - 'L_CONFIG'=>$lang['menu_config'], - 'L_USERS'=>$lang['menu_users'], - 'L_GROUPS'=>$lang['menu_groups'], - 'L_CATEGORIES'=>$lang['menu_categories'], - 'L_WAITING'=>$lang['menu_waiting'].$nb_waiting, - 'L_COMMENTS'=>$lang['menu_comments'].$nb_comments, - 'L_UPDATE'=>$lang['menu_update'], - 'L_THUMBNAILS'=>$lang['menu_thumbnails'], - 'L_HISTORY'=>$lang['menu_history'], - 'L_FAQ'=>$lang['menu_instructions'], - 'L_RETURN'=>$lang['menu_back'], - + 'L_TITLE'=>$lang['admin_panel'], + 'L_LINKS'=>$lang['links'], + 'L_GALLERY_INDEX'=>$lang['gallery_index'], + 'L_GENERAL'=>$lang['general'], + 'L_CONFIG'=>$lang['config'], + 'L_SITES'=>$lang['remote_site'], + 'L_DEFAULT'=>$lang['gallery_default'], + 'L_PHPINFO'=>$lang['phpinfos'], + 'L_HISTORY'=>$lang['history'], + 'L_FAQ'=>$lang['instructions'], + 'L_CATEGORIES'=>$lang['categories'], + 'L_MANAGE'=>$lang['manage'], + 'L_UPLOAD'=>$lang['upload'], + 'L_IMAGES'=>$lang['pictures'], + 'L_WAITING'=>$lang['waiting'].$nb_waiting, + 'L_COMMENTS'=>$lang['comments'].$nb_comments, + 'L_THUMBNAILS'=>$lang['thumbnails'], + 'L_IDENTIFY'=>$lang['identification'], + 'L_USERS'=>$lang['users'], + 'L_GROUPS'=>$lang['groups'], + 'L_AUTH'=>$lang['permissions'], + 'L_UPDATE'=>$lang['update'], + 'U_CONFIG'=>add_session_id($link_start.'configuration' ), + 'U_PHPINFO'=>add_session_id($link_start.'admin_phpinfo' ), 'U_USERS'=>add_session_id($link_start.'user_search' ), 'U_GROUPS'=>add_session_id($link_start.'group_list' ), 'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ), 'U_WAITING'=>add_session_id($link_start.'waiting' ), 'U_COMMENTS'=>add_session_id($link_start.'comments' ), - 'U_UPDATE'=>add_session_id($link_start.'update' ), + 'U_CAT_UPDATE'=>add_session_id($link_start.'update&update=cats' ), + 'U_IMG_UPDATE'=>add_session_id($link_start.'update&update=all' ), 'U_THUMBNAILS'=>add_session_id($link_start.'thumbnail' ), 'U_HISTORY'=>add_session_id($link_start.'stats' ), 'U_FAQ'=>add_session_id($link_start.'help' ), diff --git a/admin/admin_phpinfo.php b/admin/admin_phpinfo.php new file mode 100644 index 000000000..db0b52bb6 --- /dev/null +++ b/admin/admin_phpinfo.php @@ -0,0 +1,82 @@ + | +// | 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. | +// +-----------------------------------------------------------------------+ + +if( !defined("PHPWG_ROOT_PATH") ) +{ + die ("Hacking attempt!"); +} + +include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); + +ob_start(); +phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES); +$phpinfo = ob_get_contents(); +ob_end_clean(); + +// Get used layout +$layout = (preg_match('#bgcolor#i', $phpinfo)) ? 'old' : 'new'; +$output=''; +// Here we play around a little with the PHP Info HTML to try and stylise +// it along phpBB's lines ... hopefully without breaking anything. The idea +// for this was nabbed from the PHP annotated manual +preg_match_all('#]*>(.*)#siU', $phpinfo, $output); + +switch ($layout) +{ + case 'old': + $output = preg_replace('#(.*?)(.*?)#s', '
\2\1
', $output); + $output = preg_replace('#(.*?)#', '\1', $output); + $output = preg_replace('##', '', $output); + $output = preg_replace('##', '', $output); + $output = preg_replace('#valign="middle"#', '', $output); + $output = preg_replace('##', '', $output); + $output = preg_replace('##', '', $output); + $output = preg_replace('#

#i', '

', $output); + $output = preg_replace('#

#i', '

', $output); + break; + case 'new': + $output = preg_replace('#(.*?)(.*?)#s', '
\2\1
', $output); + $output = preg_replace('##', '', $output); + $output = preg_replace('##', '', $output); + $output = preg_replace('#class="e"#', 'class="row1" nowrap="nowrap"', $output); + $output = preg_replace('#class="v"#', 'class="row2"', $output); + $output = preg_replace('# class="h"#', '', $output); + $output = preg_replace('#
#', '', $output); + preg_match_all('#
(.*)
#siU', $output, $output); + $output = $output[1][0]; + break; +} +$template->assign_var('ADMIN_CONTENT',$output); + +?> \ No newline at end of file diff --git a/admin/cat_list.php b/admin/cat_list.php index 95cf066ce..1f021bf0c 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.php @@ -24,442 +24,262 @@ // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | // | USA. | // +-----------------------------------------------------------------------+ -include_once( './admin/include/isadmin.inc.php' ); -//----------------------------------------------------- template initialization -$sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_list.vtp' ); -$tpl = array( 'cat_edit','cat_up','cat_down','cat_image_info', - 'cat_permission','cat_update','cat_add','cat_parent','submit', - 'cat_virtual','delete','cat_first','cat_last','errors_title' ); -templatize_array( $tpl, 'lang', $sub ); -$vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); -//--------------------------------------------------- adding a virtual category +if( !defined("PHPWG_ROOT_PATH") ) +{ + die ("Hacking attempt!"); +} +include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); + $errors = array(); -if ( isset( $_POST['submit'] ) ) +$categories=array(); +$navigation=$lang['gallery_index']; + +//--------------------------------------------------- virtual categories +if ( isset( $_GET['delete'] ) && is_numeric( $_GET['delete'] ) ) +{ + delete_category( $_GET['delete'] ); + synchronize_all_users(); +} +elseif ( isset( $_POST['submit'] ) ) { // is the given category name only containing blank spaces ? if ( preg_match( '/^\s*$/', $_POST['virtual_name'] ) ) array_push( $errors, $lang['cat_error_name'] ); - // does the uppercat id exists in the database ? - if ( $_POST['associate'] == '' ) - { - $_POST['associate'] = -1; - } - else if ( !is_numeric( $_POST['associate'] ) ) - { - array_push( $errors, $lang['cat_unknown_id'] ); - } - else - { - $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE id = '.$_POST['associate']; - $query.= ';'; - if ( mysql_num_rows( mysql_query( $query ) ) == 0 ) - array_push( $errors, $lang['cat_unknown_id'] ); - } - - if ( count( $errors ) == 0 ) + + if ( !count( $errors )) { // we have then to add the virtual category - $query = 'INSERT INTO '.PREFIX_TABLE.'categories'; - $query.= ' (name,id_uppercat) VALUES '; - if ( $_POST['associate'] == -1 ) - { - $_POST['associate'] = 'NULL'; - } - $query.= " ('".$_POST['virtual_name']."',".$_POST['associate'].")"; + $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL'; + $query = 'INSERT INTO '.CATEGORIES_TABLE; + $query.= ' (name,id_uppercat,rank) VALUES '; + $query.= " ('".$_POST['virtual_name']."',".$parent_id.",".$_POST['rank'].")"; $query.= ';'; mysql_query( $query ); synchronize_all_users(); } } -//--------------------------------------------------------------- rank updates -if ( isset( $_GET['up'] ) and is_numeric( $_GET['up'] ) ) -{ - // 1. searching level (id_uppercat) - // and rank of the category to move - $query = 'SELECT id_uppercat,rank'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE id = '.$_GET['up']; - $query.= ';'; - $row = mysql_fetch_array( mysql_query( $query ) ); - $level = $row['id_uppercat']; - $rank = $row['rank']; - // 2. searching the id and the rank of the category - // just above at the same level - $query = 'SELECT id,rank'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE rank < '.$rank; - if ( $level == '' ) - { - $query.= ' AND id_uppercat IS NULL'; - } - else - { - $query.= ' AND id_uppercat = '.$level; - } - $query.= ' ORDER BY rank DESC'; - $query.= ' LIMIT 0,1'; - $query.= ';'; - $row = mysql_fetch_array( mysql_query( $query ) ); - $new_rank = $row['rank']; - $replaced_cat = $row['id']; - // 3. exchanging ranks between the two categories - $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= ' SET rank = '.$new_rank; - $query.= ' WHERE id = '.$_GET['up']; - $query.= ';'; - mysql_query( $query ); - $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= ' SET rank = '.$rank; - $query.= ' WHERE id = '.$replaced_cat; - $query.= ';'; - mysql_query( $query ); -} -if ( isset( $_GET['down'] ) and is_numeric( $_GET['down'] ) ) -{ - // 1. searching level (id_uppercat) - // and rank of the category to move - $query = 'SELECT id_uppercat,rank'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE id = '.$_GET['down']; - $query.= ';'; - $row = mysql_fetch_array( mysql_query( $query ) ); - $level = $row['id_uppercat']; - $rank = $row['rank']; - // 2. searching the id and the rank of the category - // just below at the same level - $query = 'SELECT id,rank'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE rank > '.$rank; - if ( $level == '' ) - { - $query.= ' AND id_uppercat IS NULL'; - } - else - { - $query.= ' AND id_uppercat = '.$level; - } - $query.= ' ORDER BY rank ASC'; - $query.= ' LIMIT 0,1'; - $query.= ';'; - $row = mysql_fetch_array( mysql_query( $query ) ); - $new_rank = $row['rank']; - $replaced_cat = $row['id']; - // 3. exchanging ranks between the two categories - $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= ' SET rank = '.$new_rank; - $query.= ' WHERE id = '.$_GET['down']; - $query.= ';'; - mysql_query( $query ); - $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= ' SET rank = '.$rank; - $query.= ' WHERE id = '.$replaced_cat; - $query.= ';'; - mysql_query( $query ); -} -if ( isset( $_GET['last'] ) and is_numeric( $_GET['last'] ) ) -{ - // 1. searching level (id_uppercat) of the category to move - $query = 'SELECT id_uppercat,rank'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE id = '.$_GET['last']; - $query.= ';'; - $row = mysql_fetch_array( mysql_query( $query ) ); - $level = $row['id_uppercat']; - // 2. searching the highest rank of the categories of the same parent - $query = 'SELECT MAX(rank) AS max_rank'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ' WHERE id_uppercat'; - if ( $level == '' ) $query.= ' IS NULL'; - else $query.= ' = '.$level; - $query.= ';'; - $row = mysql_fetch_array( mysql_query( $query ) ); - $max_rank = $row['max_rank']; - // 3. updating the rank of our category to be after the previous max rank - $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= ' SET rank = '.($max_rank + 1); - $query.= ' WHERE id = '.$_GET['last']; - $query.= ';'; - mysql_query( $query ); -} -if ( isset( $_GET['first'] ) and is_numeric( $_GET['first'] ) ) -{ - // to place our category as first, we simply say that is rank is 0, then - // reordering will move category ranks correctly (first rank should be 1 - // and not 0) - $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= ' SET rank = 0'; - $query.= ' WHERE id = '.$_GET['first']; - $query.= ';'; - mysql_query( $query ); -} -if ( isset( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) ) -{ - delete_category( $_GET['delete'] ); - synchronize_all_users(); -} -//------------------------------------------------------------------ reordering -function ordering( $id_uppercat ) -{ - $rank = 1; - - $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - if ( !is_numeric( $id_uppercat ) ) - { - $query.= ' WHERE id_uppercat IS NULL'; - } - else - { - $query.= ' WHERE id_uppercat = '.$id_uppercat; - } - $query.= ' ORDER BY rank ASC, dir ASC'; - $query.= ';'; - $result = mysql_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) - { - $query = 'UPDATE '.PREFIX_TABLE.'categories'; - $query.= ' SET rank = '.$rank; - $query.= ' WHERE id = '.$row['id']; - $query.= ';'; - mysql_query( $query ); - $rank++; - ordering( $row['id'] ); - } -} -ordering( 'NULL' ); -//-------------------------------------------------------------- errors display -if ( count( $errors ) != 0 ) -{ - $vtp->addSession( $sub, 'errors' ); - foreach ( $errors as $error ) { - $vtp->addSession( $sub, 'li' ); - $vtp->setVar( $sub, 'li.content', $error ); - $vtp->closeSession( $sub, 'li' ); - } - $vtp->closeSession( $sub, 'errors' ); -} -//---------------------------------------------------------------- page display -function display_cat_manager( $id_uppercat, $indent, - $uppercat_visible, $level ) -{ - global $lang,$conf,$sub,$vtp,$page; - - // searching the min_rank and the max_rank of the category - $query = 'SELECT MIN(rank) AS min, MAX(rank) AS max'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - if ( !is_numeric( $id_uppercat ) ) - { - $query.= ' WHERE id_uppercat IS NULL'; - } - else - { - $query.= ' WHERE id_uppercat = '.$id_uppercat; - } - $query.= ';'; - $result = mysql_query( $query ); - $row = mysql_fetch_array( $result ); - if ( !isset( $row['min'] ) ) $row['min'] = 0; - if ( !isset( $row['max'] ) ) $row['max'] = 0; - $min_rank = $row['min']; - $max_rank = $row['max']; - - // will we use or lines ? - $td = 'td'; - $class = ''; - if ( $level > 0 ) $class = 'row'.$level; - else $td = 'th'; - - $query = 'SELECT id,name,dir,nb_images,status,rank,site_id,visible'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - if ( !is_numeric( $id_uppercat ) ) - { - $query.= ' WHERE id_uppercat IS NULL'; - } - else - { - $query.= ' WHERE id_uppercat = '.$id_uppercat; - } - $query.= ' ORDER BY rank ASC'; - $query.= ';'; - $result = mysql_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) - { - $subcat_visible = true; - if ( !isset( $row['dir'] ) ) $row['dir'] = ''; - $vtp->addSession( $sub, 'cat' ); - // is the category expanded or not ? - if ( isset($page['expand']) && $page['expand'] == 'all' ) - { - $vtp->addSession( $sub, 'bullet_wo_link' ); - $vtp->closeSession( $sub, 'bullet_wo_link' ); - } - else if ( isset($page['tab_expand']) && in_array( $row['id'], $page['tab_expand'] ) ) - { - $vtp->addSession( $sub, 'bullet_expanded' ); - $tab_expand = array_diff( $page['tab_expand'], array( $row['id'] ) ); - $expand = implode( ',', $tab_expand ); - $url = './admin.php?page=cat_list&expand='.$expand; - $vtp->setVar( $sub, 'bullet_expanded.link', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'bullet_expanded' ); - } - else - { - $vtp->addSession( $sub, 'bullet_collapsed' ); - $tab_expand = array_merge( $page['tab_expand'], array( $row['id'] ) ); - $expand = implode( ',', $tab_expand ); - $url = './admin.php?page=cat_list&expand='.$expand; - $vtp->setVar( $sub, 'bullet_collapsed.link', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'bullet_collapsed' ); - } - - $vtp->setVar( $sub, 'cat.td', $td ); - $vtp->setVar( $sub, 'cat.class', $class ); - $vtp->setVar( $sub, 'cat.indent', $indent ); - $vtp->setVar( $sub, 'cat.name', $row['name'] ); +// Cache management - if ( $row['dir'] != '' ) - { - $vtp->addSession( $sub, 'storage' ); - $vtp->setVar( $sub, 'storage.dir', $row['dir'] ); - $vtp->closeSession( $sub, 'storage' ); - // category can't be deleted - $vtp->addSession( $sub, 'no_delete' ); - $vtp->closeSession( $sub, 'no_delete' ); - } - else - { - $vtp->addSession( $sub, 'virtual' ); - $vtp->closeSession( $sub, 'virtual' ); - // category can be deleted - $vtp->addSession( $sub, 'delete' ); - $url = './admin.php?page=cat_list&expand='.$page['expand']; - $url.= '&delete='.$row['id']; - $vtp->setVar( $sub, 'delete.delete_url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'delete' ); - } - if ( $row['visible'] == 'false' or !$uppercat_visible ) - { - $subcat_visible = false; - $vtp->setVar( $sub, 'cat.invisible', $lang['cat_invisible'] ); - } - if ( $row['status'] == 'private' ) - { - $vtp->setVar( $sub, 'cat.private', $lang['private'] ); - } - $vtp->setVar( $sub, 'cat.nb_picture', $row['nb_images'] ); - $url = add_session_id( './admin.php?page=cat_modify&cat='.$row['id'] ); - $vtp->setVar( $sub, 'cat.edit_url', $url ); - if ( $row['rank'] != $min_rank ) - { - $vtp->addSession( $sub, 'up' ); - $url = './admin.php?page=cat_list&expand='.$page['expand']; - $url.= '&up='.$row['id']; - $vtp->setVar( $sub, 'up.up_url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'up' ); - } - else if ( $min_rank != $max_rank ) - { - $vtp->addSession( $sub, 'no_up' ); - $url = './admin.php?page=cat_list&expand='.$page['expand']; - $url.= '&last='.$row['id']; - $vtp->setVar( $sub, 'no_up.last_url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'no_up' ); - } - if ( $row['rank'] != $max_rank ) - { - $vtp->addSession( $sub, 'down' ); - $url = './admin.php?page=cat_list&expand='.$page['expand']; - $url.= '&down='.$row['id']; - $vtp->setVar( $sub, 'down.down_url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'down' ); - } - else if ( $min_rank != $max_rank ) - { - $vtp->addSession( $sub, 'no_down' ); - $url = './admin.php?page=cat_list&expand='.$page['expand']; - $url.= '&first='.$row['id']; - $vtp->setVar( $sub, 'no_down.first_url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'no_down' ); - } - if ( $row['nb_images'] > 0 ) - { - $vtp->addSession( $sub, 'image_info' ); - $url = './admin.php?page=infos_images&cat_id='.$row['id']; - $vtp->setVar( $sub, 'image_info.image_info_url', add_session_id($url) ); - $vtp->closeSession( $sub, 'image_info' ); - } - else - { - $vtp->addSession( $sub, 'no_image_info' ); - $vtp->closeSession( $sub, 'no_image_info' ); - } - if ( $row['status'] == 'private' ) - { - $vtp->addSession( $sub, 'permission' ); - $url=add_session_id('./admin.php?page=cat_perm&cat_id='.$row['id']); - $vtp->setVar( $sub, 'permission.url', $url ); - $vtp->closeSession( $sub, 'permission' ); - } - else - { - $vtp->addSession( $sub, 'no_permission' ); - $vtp->closeSession( $sub, 'no_permission' ); - } - // you can individually update a category only if it is on the main site - // and if it's not a virtual category (a category is virtual if there is - // no directory associated) - if ( $row['site_id'] == 1 and $row['dir'] != '' ) - { - $vtp->addSession( $sub, 'update' ); - $url = add_session_id('./admin.php?page=update&update='.$row['id']); - $vtp->setVar( $sub, 'update.update_url', $url ); - $vtp->closeSession( $sub, 'update' ); - } - else - { - $vtp->addSession( $sub, 'no_update' ); - $vtp->closeSession( $sub, 'no_update' ); - } - - $vtp->closeSession( $sub, 'cat' ); - - if ( in_array( $row['id'], $page['tab_expand'] ) - or $page['expand'] == 'all') - display_cat_manager( $row['id'], $indent.str_repeat( ' ', 4 ), - $subcat_visible, $level + 1 ); - } -} -display_cat_manager( 'NULL', str_repeat( ' ', 4 ), true, 0 ); -// add a virtual category ? -// We only show a List Of Values if the number of categories is less than -// $conf['max_LOV_categories'] -$query = 'SELECT COUNT(id) AS nb_total_categories'; -$query.= ' FROM '.PREFIX_TABLE.'categories'; -$query.= ';'; -$row = mysql_fetch_array( mysql_query( $query ) ); -if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] ) +$query = 'SELECT * FROM '.CATEGORIES_TABLE; +if ( !isset($_GET['parent_id'])) { - $vtp->addSession( $sub, 'associate_LOV' ); - $vtp->addSession( $sub, 'associate_cat' ); - $vtp->setVar( $sub, 'associate_cat.value', '-1' ); - $vtp->setVar( $sub, 'associate_cat.content', '' ); - $vtp->closeSession( $sub, 'associate_cat' ); - $page['plain_structure'] = get_plain_structure( true ); - $structure = create_structure( '', array() ); - display_categories( $structure, ' ' ); - $vtp->closeSession( $sub, 'associate_LOV' ); + $query.= ' WHERE id_uppercat IS NULL'; } -// else, we only display a small text field, we suppose the administrator -// knows the id of its category else { - $vtp->addSession( $sub, 'associate_text' ); - $vtp->closeSession( $sub, 'associate_text' ); + $query.= ' WHERE id_uppercat = '.$_GET['parent_id']; } +$query.= ' ORDER BY rank ASC'; +$query.= ';'; +$result = mysql_query( $query ); +while ( $row = mysql_fetch_assoc( $result ) ) +{ + $categories[$row['rank']]=$row; +} + +// Navigation path +if (isset($_GET['parent_id'])) +{ + $current_category = get_cat_info($_GET['parent_id']); + $url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&parent_id='; + $navigation = '
'; + $navigation.= $lang['gallery_index'].'->'; + $navigation.= get_cat_display_name($current_category['name'], '->', $url); +} + +//--------------------------------------------------------------- rank updates +$current_rank=0; +if ( isset( $_GET['up'] ) && is_numeric( $_GET['up'] )) +{ + // 1. searching the id of the category just above at the same level + while (list ($id,$current) = each($categories)) + { + if ($current['id'] == $_GET['up']) + { + $current_rank = $current['rank']; + break; + } + } + if ($current_rank>1) + { + // 2. Exchanging ranks between the two categories + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = '.($current_rank-1); + $query.= ' WHERE id = '.$_GET['up']; + $query.= ';'; + mysql_query( $query ); + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = '.$current_rank; + $query.= ' WHERE id = '.$categories[($current_rank-1)]['id']; + $query.= ';'; + mysql_query( $query ); + // 3. Updating the cache array + $categories[$current_rank]=$categories[($current_rank-1)]; + $categories[($current_rank-1)] = $current; + } + else + { + // 2. Updating the rank of our category to be after the previous max rank + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = '.(count($categories) + 1); + $query.= ' WHERE id = '.$_GET['up']; + $query.= ';'; + mysql_query( $query ); + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = rank-1'; + $query.= ' WHERE id_uppercat '; + $query.= empty($_GET['parent_id'])?'IS NULL':('= '.$_GET['parent_id']); + $query.= ';'; + mysql_query( $query ); + // 3. Updating the cache array + array_push($categories, $current); + array_shift($categories); + } +} +elseif ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) ) +{ + // 1. searching the id of the category just above at the same level + while (list ($id,$current) = each($categories)) + { + if ($current['id'] == $_GET['down']) + { + $current_rank = $current['rank']; + break; + } + } + if ($current_rank < count($categories)) + { + // 2. Exchanging ranks between the two categories + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = '.($current_rank+1); + $query.= ' WHERE id = '.$_GET['down']; + $query.= ';'; + mysql_query( $query ); + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = '.$current_rank; + $query.= ' WHERE id = '.$categories[($current_rank+1)]['id']; + $query.= ';'; + mysql_query( $query ); + // 3. Updating the cache array + $categories[$current_rank]=$categories[($current_rank+1)]; + $categories[($current_rank+1)] = $current; + } + else + { + // 2. updating the rank of our category to be the first one + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = 0'; + $query.= ' WHERE id = '.$_GET['down']; + $query.= ';'; + mysql_query( $query ); + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = (rank+1)'; + $query.= ' WHERE id_uppercat '; + $query.= empty($_GET['parent_id'])?'IS NULL':('= '.$_GET['parent_id']); + $query.= ';'; + mysql_query( $query ); + // 3. Updating the cache array + array_unshift($categories, $current); + array_pop($categories); + } +} +reset($categories); + +//----------------------------------------------------- template initialization +$template->set_filenames( array('categories'=>'admin/cat_list.tpl') ); + +$template->assign_vars(array( + 'CATEGORIES_NAV'=>$navigation, + 'NEXT_RANK'=>count($categories)+1, + + 'L_ADD_VIRTUAL'=>$lang['cat_add'], + 'L_SUBMIT'=>$lang['submit'], + 'L_STORAGE'=>$lang['storage'], + 'L_NB_IMG'=>$lang['pictures'], + 'L_MOVE_UP'=>$lang['cat_up'], + 'L_MOVE_DOWN'=>$lang['cat_down'], + 'L_EDIT'=>$lang['edit'], + 'L_INFO_IMG'=>$lang['cat_image_info'], + 'L_DELETE'=>$lang['delete'] + )); + +$tpl = array( 'cat_first','cat_last'); + +//-------------------------------------------------------------- errors display +if ( sizeof( $errors ) != 0 ) +{ + $template->assign_block_vars('errors',array()); + for ( $i = 0; $i < sizeof( $errors ); $i++ ) + { + $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); + } +} +//----------------------------------------------------------- Categories display +while (list ($id,$category) = each($categories)) +{ + + if ($category['status'] == 'private') + { + $category_image = ''.$lang['cat_private'].''; + } + elseif (empty($category['dir'])) + { + $category_image = ''.$lang['cat_virtual'].''; + } + else + { + // May be should we have to introduce a computed field in the table to avoid this query + $query = 'SELECT COUNT(id) as sub_cats FROM ' . CATEGORIES_TABLE . ' WHERE id_uppercat = '.$category['id']; + $result = mysql_fetch_array(mysql_query( $query )); + $category_image = ($result['sub_cats']) ? + '' : + ''; + } + + if ( !isset( $category['dir'] ) ) $category['dir'] = ''; + $simple_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&'; + $url = $simple_url; + if (isset($_GET['parent_id'])) + $url = $simple_url.'parent_id='.$_GET['parent_id'].'&'; + + $template->assign_block_vars('category' ,array( + 'CATEGORY_IMG'=>$category_image, + 'CATEGORY_NAME'=>$category['name'], + 'CATEGORY_DIR'=>$category['dir'], + 'CATEGORY_NB_IMG'=>$category['nb_images'], + + 'U_CATEGORY'=>add_session_id( $simple_url.'parent_id='.$category['id']), + 'U_MOVE_UP'=>add_session_id( $url.'up='.$category['id'] ), + 'U_MOVE_DOWN'=>add_session_id( $url.'down='.$category['id'] ), + 'U_CAT_EDIT'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$row['id'] ), + 'U_CAT_DELETE'=>add_session_id( $url.'delete='.$category['id'] ), + 'U_INFO_IMG'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=infos_images&cat_id='.$row['id'] ), + 'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&update='.$row['id'] ) + )); + + if ( !empty($category['dir'])) + { + $template->assign_block_vars('category.storage' ,array()); + } + else + { + $template->assign_block_vars('category.virtual' ,array()); + } + $url = add_session_id( './admin.php?page=cat_modify&cat='.$row['id'] ); + if ( $category['nb_images'] > 0 ) + { + $template->assign_block_vars('category.image_info' ,array()); + } + else + { + $template->assign_block_vars('category.no_image_info' ,array()); + } +} + //----------------------------------------------------------- sending html code -$vtp->Parse( $handle , 'sub', $sub ); +$template->assign_var_from_handle('ADMIN_CONTENT', 'categories'); ?> diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 2f08f8f81..ba1cd7d9d 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -129,7 +129,7 @@ if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = ''; $result = get_cat_info( $row['id'] ); // cat name -$cat_name = get_cat_display_name( $result['name'], ' - ', '' ); +$cat_name = get_cat_display_name( $result['name'], ' - ' ); $vtp->setVar( $sub, 'cat:name', $cat_name ); // cat dir if ( $row['dir'] != '' ) diff --git a/admin/comments.php b/admin/comments.php deleted file mode 100644 index f6672e5a2..000000000 --- a/admin/comments.php +++ /dev/null @@ -1,273 +0,0 @@ - | -// | 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. | -// +-----------------------------------------------------------------------+ -include_once( './admin/include/isadmin.inc.php' ); -$page['plain_structure'] = get_plain_structure(); -//------------------------------------------------------------------- functions -function display_pictures( $mysql_result, $maxtime, $validation_box = false ) -{ - global $vtp,$sub,$lang,$conf, - $array_cat_directories,$array_cat_site_id,$array_cat_names; - - while ( $row = mysql_fetch_array( $mysql_result ) ) - { - $vtp->addSession( $sub, 'picture' ); - // 2. for each picture, getting informations for displaying thumbnail and - // link to the full size picture - $query = 'SELECT name,file,storage_category_id as cat_id,tn_ext'; - $query.= ' FROM '.PREFIX_TABLE.'images'; - $query.= ' WHERE id = '.$row['image_id']; - $query.= ';'; - $subresult = mysql_query( $query ); - $subrow = mysql_fetch_array( $subresult ); - - if ( !isset( $array_cat_directories[$subrow['cat_id']] ) ) - { - $array_cat_directories[$subrow['cat_id']] = - get_complete_dir( $subrow['cat_id'] ); - $cat_result = get_cat_info( $subrow['cat_id'] ); - $array_cat_site_id[$subrow['cat_id']] = $cat_result['site_id']; - $array_cat_names[$subrow['cat_id']] = - get_cat_display_name( $cat_result['name'], ' > ', '' ); - } - - $file = get_filename_wo_extension( $subrow['file'] ); - // name of the picture - $name = $array_cat_names[$subrow['cat_id']].' > '; - if ( isset( $subrow['name'] ) and $subrow['name'] != '' ) - { - $name.= $subrow['name']; - } - else - { - $name.= str_replace( '_', ' ', $file ); - } - $name.= ' [ '.$subrow['file'].' ]'; - $vtp->setVar( $sub, 'picture.title', $name ); - // source of the thumbnail picture - $src = $array_cat_directories[$subrow['cat_id']]; - $src.= 'thumbnail/'.$conf['prefix_thumbnail']; - $src.= $file.'.'.$subrow['tn_ext']; - $vtp->setVar( $sub, 'picture.thumb_src', $src ); - // link to the full size picture - $url = './picture.php?cat='.$subrow['cat_id']; - $url.= '&image_id='.$row['image_id']; - $vtp->setVar( $sub, 'picture.thumb_url', add_session_id( $url ) ); - // 3. for each picture, retrieving all comments - $query = 'SELECT id,date,author,content'; - $query.= ' FROM '.PREFIX_TABLE.'comments'; - $query.= ' WHERE image_id = '.$row['image_id']; - $query.= ' AND date > '.$maxtime; - if ( $validation_box ) $query.= " AND validated = 'false'"; - $query.= ' ORDER BY date DESC'; - $query.= ';'; - $subresult = mysql_query( $query ); - while ( $subrow = mysql_fetch_array( $subresult ) ) - { - $vtp->addSession( $sub, 'comment' ); - $author = $subrow['author']; - if ( $subrow['author'] == '' ) $author = $lang['guest']; - $vtp->setVar( $sub, 'comment.author', $author ); - $displayed_date = format_date( $subrow['date'], 'unix', true ); - $vtp->setVar( $sub, 'comment.date', $displayed_date ); - - $content = nl2br( $subrow['content'] ); - - // replace _word_ by an underlined word - $pattern = '/_([^\s]*)_/'; - $replacement = '\1'; - $content = preg_replace( $pattern, $replacement, $content ); - - // replace *word* by a bolded word - $pattern = '/\*([^\s]*)\*/'; - $replacement = '\1'; - $content = preg_replace( $pattern, $replacement, $content ); - - // replace /word/ by an italic word - $pattern = '/\/([^\s]*)\//'; - $replacement = '\1'; - $content = preg_replace( $pattern, $replacement, $content ); - - $vtp->setVar( $sub, 'comment.content', $content ); - - $vtp->addSession( $sub, 'delete' ); - $url = './admin.php?page=comments'; - if ( isset( $_GET['last_days'] ) ) $url.= '&last_days='.MAX_DAYS; - if ( isset( $_GET['show_unvalidated'] ) ) - $url.= '&show_unvalidated=true'; - $url.= '&del='.$subrow['id']; - $vtp->setVar( $sub, 'delete.link', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'delete' ); - // if the comment has to be validated, we display a checkbox - if ( $validation_box ) - { - $vtp->addSession( $sub, 'validation' ); - $vtp->setVar( $sub, 'validation.id', $subrow['id'] ); - $vtp->closeSession( $sub, 'validation' ); - } - $vtp->closeSession( $sub, 'comment' ); - } - $vtp->closeSession( $sub, 'picture' ); - } -} -//------------------------------------------------------------ comment deletion -if ( isset( $_GET['del'] ) and is_numeric( $_GET['del'] ) ) -{ - $query = 'DELETE FROM '.PREFIX_TABLE.'comments'; - $query.= ' WHERE id = '.$_GET['del']; - $query.= ';'; - mysql_query( $query ); -} -//--------------------------------------------------------- comments validation -if ( isset( $_POST['submit'] ) ) -{ - $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'comments'; - $query.= " WHERE validated = 'false'"; - $query.= ';'; - $result = mysql_query( $query ); - while ( $row = mysql_fetch_array( $result ) ) - { - if ( $_POST['validate-'.$row['id']] == 'true' ) - { - $query = 'UPDATE '.PREFIX_TABLE.'comments'; - $query.= " SET validated = 'true'"; - $query.= ' WHERE id = '.$row['id']; - $query.= ';'; - mysql_query( $query ); - } - } -} -//----------------------------------------------------- template initialization -$sub = $vtp->Open( './template/'.$user['template'].'/admin/comments.vtp' ); -$tpl = array( 'stats_last_days','delete','close','submit','open' ); -templatize_array( $tpl, 'lang', $sub ); -$vtp->setGlobalVar( $sub, 'user_template', $user['template'] ); -//--------------------------------------------------- number of days to display -if ( isset( $_GET['last_days'] ) ) define( 'MAX_DAYS', $_GET['last_days'] ); -else define( 'MAX_DAYS', 0 ); -//----------------------------------------- non specific section initialization -$array_cat_directories = array(); -$array_cat_names = array(); -$array_cat_site_id = array(); -//------------------------------------------------------- last comments display -$vtp->addSession( $sub, 'section' ); -$vtp->setVar( $sub, 'section.title', $lang['comments_last_title'] ); -$vtp->addSession( $sub, 'last_days' ); -foreach ( $conf['last_days'] as $option ) { - $vtp->addSession( $sub, 'last_day_option' ); - $vtp->setVar( $sub, 'last_day_option.option', $option ); - $url = './admin.php?page=comments'; - $url.= '&last_days='.($option - 1); - $vtp->setVar( $sub, 'last_day_option.link', add_session_id( $url ) ); - if ( $option == MAX_DAYS + 1 ) - { - $vtp->setVar( $sub, 'last_day_option.style', 'font-weight:bold;'); - } - $vtp->closeSession( $sub, 'last_day_option' ); -} -$vtp->closeSession( $sub, 'last_days' ); -if ( isset( $_GET['last_days'] ) ) -{ - $vtp->addSession( $sub, 'close' ); - $url = './admin.php?page=comments'; - if ( isset( $_GET['show_unvalidated'] ) ) - { - $url.= '&show_unvalidated='.$_GET['show_unvalidated']; - } - $vtp->setVar( $sub, 'close.url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'close' ); - // 1. retrieving picture ids which have comments recently added - $date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) ); - list($year,$month,$day) = explode( '-', $date); - $maxtime = mktime( 0,0,0,$month,$day,$year ); - $query = 'SELECT DISTINCT(image_id) as image_id'; - $query.= ' FROM '.PREFIX_TABLE.'comments'; - $query.= ', '.PREFIX_TABLE.'images as images'; - $query.= ' WHERE image_id = images.id'; - $query.= ' AND date > '.$maxtime; - $query.= ' ORDER BY date_available DESC'; - $query.= ';'; - $result = mysql_query( $query ); - display_pictures( $result, $maxtime ); -} -$vtp->closeSession( $sub, 'section' ); -//---------------------------------------------- non validated comments display -$vtp->addSession( $sub, 'section' ); -$vtp->setVar( $sub, 'section.title', $lang['comments_non_validated_title'] ); -if ( isset( $_GET['show_unvalidated'] ) ) -{ - // form starts - $vtp->addSession( $sub, 'start_form' ); - $action = './admin.php?page=comments'; - if ( isset( $_GET['last_days'] ) ) - { - $action.= '&last_days='.$_GET['last_days']; - } - $action.= '&show_unvalidated=true'; - $vtp->setVar( $sub, 'start_form.action', add_session_id( $action ) ); - $vtp->closeSession( $sub, 'start_form' ); - // close this section ? - $vtp->addSession( $sub, 'close' ); - $url = './admin.php?page=comments'; - if ( isset( $_GET['last_days'] ) ) - { - $url.= '&last_days='.$_GET['last_days']; - } - $vtp->setVar( $sub, 'close.url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'close' ); - // retrieving all picture ids which have unvalidated comments - $query = 'SELECT DISTINCT(image_id) as image_id'; - $query.= ' FROM '.PREFIX_TABLE.'comments as comments'; - $query.= ', '.PREFIX_TABLE.'images as images'; - $query.= ' WHERE image_id = images.id'; - $query.= " AND comments.validated = 'false'"; - $query.= ' ORDER BY date_available DESC'; - $query.= ';'; - $result = mysql_query( $query ); - display_pictures( $result, 0, true ); - $vtp->addSession( $sub, 'submit' ); - $vtp->closeSession( $sub, 'submit' ); - // form ends - $vtp->addSession( $sub, 'end_form' ); - $vtp->closeSession( $sub, 'end_form' ); -} -else -{ - $vtp->addSession( $sub, 'open' ); - $url = './admin.php?page=comments'; - if ( isset( $_GET['last_days'] ) ) - { - $url.= '&last_days='.$_GET['last_days']; - } - $url.= '&show_unvalidated=true'; - $vtp->setVar( $sub, 'open.url', add_session_id( $url ) ); - $vtp->closeSession( $sub, 'open' ); -} -$vtp->closeSession( $sub, 'section' ); -//----------------------------------------------------------- sending html code -$vtp->Parse( $handle, 'sub', $sub ); -?> diff --git a/admin/configuration.php b/admin/configuration.php index ba77a72f7..92243fb01 100644 --- a/admin/configuration.php +++ b/admin/configuration.php @@ -249,8 +249,8 @@ $template->assign_vars(array( 'L_ACCESS_INFO'=>$lang['conf_general_access_info'], 'L_ACCESS_FREE'=>$lang['conf_general_access_1'], 'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'], - 'L_HISTORY'=>$lang['conf_general_log'], - 'L_HISTORY_INFO'=>$lang['conf_general_log_info'], + 'L_CONF_HISTORY'=>$lang['history'], + 'L_CONF_HISTORY_INFO'=>$lang['conf_general_log_info'], 'L_MAIL_NOTIFICATION'=>$lang['conf_general_mail_notification'], 'L_MAIL_NOTIFICATION_INFO'=>$lang['conf_general_mail_notification_info'], 'L_CONF_COMMENTS'=>$lang['conf_comments_title'], @@ -279,8 +279,8 @@ $template->assign_vars(array( 'L_EXPAND_TREE_INFO'=>$lang['conf_default_expand_info'], 'L_NB_COMMENTS'=>$lang['customize_show_nb_comments'], 'L_NB_COMMENTS_INFO'=>$lang['conf_default_show_nb_comments_info'], - 'L_UPLOAD'=>$lang['conf_upload_available'], - 'L_UPLOAD_INFO'=>$lang['conf_upload_available_info'], + 'L_AUTH_UPLOAD'=>$lang['conf_upload_available'], + 'L_AUTH_UPLOAD_INFO'=>$lang['conf_upload_available_info'], 'L_CONF_UPLOAD'=>$lang['conf_upload_title'], 'L_UPLOAD_MAXSIZE'=>$lang['conf_upload_maxfilesize'], 'L_UPLOAD_MAXSIZE_INFO'=>$lang['conf_upload_maxfilesize_info'], @@ -306,9 +306,6 @@ $template->assign_vars(array( 'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=configuration') )); -$tpl = array( 'conf_confirmation','remote_site','delete', - 'conf_remote_site_delete_info','submit','errors_title' ); - //-------------------------------------------------------------- errors display if ( sizeof( $error ) != 0 ) { diff --git a/admin/include/functions.php b/admin/include/functions.php index 6a690ae4f..84b81e66f 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -136,7 +136,7 @@ function delete_site( $id ) { // destruction of the categories of the site $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' FROM '.CATEGORIES_TABLE; $query.= ' WHERE site_id = '.$id; $query.= ';'; $result = mysql_query( $query ); @@ -190,7 +190,7 @@ function delete_category( $id ) // destruction of the sub-categories $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' FROM '.CATEGORIES_TABLE; $query.= ' WHERE id_uppercat = '.$id; $query.= ';'; $result = mysql_query( $query ); @@ -200,7 +200,7 @@ function delete_category( $id ) } // destruction of the category - $query = 'DELETE FROM '.PREFIX_TABLE.'categories'; + $query = 'DELETE FROM '.CATEGORIES_TABLE; $query.= ' WHERE id = '.$id; $query.= ';'; mysql_query( $query ); @@ -373,9 +373,7 @@ function update_category( $id = 'all' ) { if ( $id == 'all' ) { - $query = 'SELECT id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; - $query.= ';'; + $query = 'SELECT id FROM '.CATEGORIES_TABLE.';'; $result = mysql_query( $query ); while ( $row = mysql_fetch_array( $result ) ) { @@ -399,7 +397,7 @@ function update_category( $id = 'all' ) $query.= ';'; list( $date_available ) = mysql_fetch_array( mysql_query( $query ) ); - $query = 'UPDATE '.PREFIX_TABLE.'categories'; + $query = 'UPDATE '.CATEGORIES_TABLE; $query.= " SET date_last = '".$date_available."'"; $query.= ', nb_images = '.$nb_images; $query.= ' WHERE id = '.$id; @@ -410,7 +408,7 @@ function update_category( $id = 'all' ) // picture of the category is not any more linked to the category, we // have to set representative_picture_id to NULL $query = 'SELECT representative_picture_id'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' FROM '.CATEGORIES_TABLE; $query.= ' WHERE id = '.$id; $row = mysql_fetch_array( mysql_query( $query ) ); // if the category has no representative picture (ie @@ -425,7 +423,7 @@ function update_category( $id = 'all' ) $result = mysql_query( $query ); if ( mysql_num_rows( $result ) == 0 ) { - $query = 'UPDATE '.PREFIX_TABLE.'categories'; + $query = 'UPDATE '.CATEGORIES_TABLE; $query.= ' SET representative_picture_id = NULL'; $query.= ' WHERE id = '.$id; $query.= ';'; @@ -524,7 +522,7 @@ function get_plain_structure( $use_name = false ) $query = 'SELECT id,id_uppercat'; if ( $use_name ) $query.= ',name'; - $query.= ' FROM '.PREFIX_TABLE.'categories'; + $query.= ' FROM '.CATEGORIES_TABLE; $query.= ' ORDER BY id_uppercat ASC, rank ASC'; $query.= ';'; @@ -711,7 +709,7 @@ function update_uppercats( $category_id ) } $string_uppercats = implode( ',', array_reverse( $uppercats ) ); - $query = 'UPDATE '.PREFIX_TABLE.'categories'; + $query = 'UPDATE '.CATEGORIES_TABLE; $query.= ' SET uppercats = '."'".$string_uppercats."'"; $query.= ' WHERE id = '.$final_id; $query.= ';'; diff --git a/admin/update.php b/admin/update.php index 1803d5468..db8790bdf 100644 --- a/admin/update.php +++ b/admin/update.php @@ -27,6 +27,35 @@ include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); //------------------------------------------------------------------- functions +function ordering( $id_uppercat ) +{ + $rank = 1; + + $query = 'SELECT id'; + $query.= ' FROM '.CATEGORIES_TABLE; + if ( !is_numeric( $id_uppercat ) ) + { + $query.= ' WHERE id_uppercat IS NULL'; + } + else + { + $query.= ' WHERE id_uppercat = '.$id_uppercat; + } + $query.= ' ORDER BY rank ASC, dir ASC'; + $query.= ';'; + $result = mysql_query( $query ); + while ( $row = mysql_fetch_array( $result ) ) + { + $query = 'UPDATE '.CATEGORIES_TABLE; + $query.= ' SET rank = '.$rank; + $query.= ' WHERE id = '.$row['id']; + $query.= ';'; + mysql_query( $query ); + $rank++; + ordering( $row['id'] ); + } +} + function insert_local_category( $id_uppercat ) { global $conf, $page, $user, $lang; @@ -677,7 +706,6 @@ $template->assign_vars(array( 'U_ALL_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&update=all' ) )); -$tpl = array('remote_site'); //-------------------------------------------- introduction : choices of update // Display choice if "update" var is not specified if (!isset( $_GET['update'] )) @@ -732,6 +760,7 @@ if ( isset( $_GET['update'] ) { $start = get_moment(); update_category( 'all' ); + ordering('NULL'); $end = get_moment(); echo get_elapsed_time( $start, $end ).' for update_category( all )
'; diff --git a/category.php b/category.php index a4c749e42..ed50a5762 100644 --- a/category.php +++ b/category.php @@ -67,9 +67,7 @@ function display_category( $category, $indent ) $name = $category['name']; if (empty($name)) $name = str_replace( '_', ' ', $category['dir'] ); - $template->assign_block_vars( - 'category', - array( + $template->assign_block_vars('category', array( 'T_NAME' => $style, 'LINK_NAME' => $name, 'INDENT' => $indent, @@ -187,8 +185,7 @@ if ( isset ( $page['cat'] ) ) { if ( is_numeric( $page['cat'] ) ) { - $cat_title = get_cat_display_name( $page['cat_name'], ' > ', - 'font-style:italic;' ); + $cat_title = get_cat_display_name( $page['cat_name'], ' - '); } else { @@ -356,7 +353,7 @@ if ( isset( $page['cat'] ) && $page['cat_nb_images'] != 0 ) $poids = $row['filesize']; $thumbnail_title .= ' : '.$poids.' KB'; // url link on picture.php page - $url_link = './picture.php?cat='.$page['cat']; + $url_link = PHPWG_ROOT_PATH.'picture.php?cat='.$page['cat']; $url_link.= '&image_id='.$row['id']; if ( $page['cat'] == 'search' ) { @@ -473,28 +470,15 @@ else //------------------------------------------------------- category informations if ( isset ( $page['cat'] ) ) { - $cat_name=''; - // total number of pictures in the category - if ( is_numeric( $page['cat'] ) ) + // upload a picture in the category + if ( is_numeric( $page['cat']) && $page['cat_site_id'] == 1 + && $conf['upload_available'] && $page['cat_uploadable'] ) { - $cat_name=get_cat_display_name( $page['cat_name'],' - ','font-style:italic;' ); - // upload a picture in the category - if ( $page['cat_site_id'] == 1 - and $conf['upload_available'] - and $page['cat_uploadable'] ) - { - $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; - $template->assign_block_vars('upload',array('U_UPLOAD'=>add_session_id( $url ))); - } + $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; + $template->assign_block_vars('upload',array('U_UPLOAD'=>add_session_id( $url ))); } - else - { - $cat_name= $page['title']; - } - $template->assign_block_vars('cat_infos',array( - 'CAT_NAME'=>$cat_name, - 'NB_IMG_CAT' => $page['cat_nb_images'] - )); + + $template->assign_block_vars('cat_infos',array('NB_IMG_CAT' => $page['cat_nb_images'])); // navigation bar if ( $page['navigation_bar'] != '' ) 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.= ''.$name.''; - } - 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/template/default/htmlfunctions.inc.php b/include/htmlfunctions.inc.php similarity index 85% rename from template/default/htmlfunctions.inc.php rename to include/htmlfunctions.inc.php index 6031d1e45..426ef8e82 100644 --- a/template/default/htmlfunctions.inc.php +++ b/include/htmlfunctions.inc.php @@ -107,38 +107,6 @@ function create_navigation_bar( $url, $nb_element, $start, return $navigation_bar; } - - -function make_jumpbox($value, $selected, $usekeys=false) -{ - $boxstring = ''; - $nb = sizeof( $value); - $keys = ($usekeys?array_keys($value):$value); - $value = ($usekeys?array_values($value):$value); - for ( $i = 0; $i < $nb; $i++ ) - { - $boxstring .= '