aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin.php41
-rw-r--r--admin/admin_phpinfo.php82
-rw-r--r--admin/cat_list.php592
-rw-r--r--admin/cat_modify.php2
-rw-r--r--admin/comments.php273
-rw-r--r--admin/configuration.php11
-rw-r--r--admin/include/functions.php20
-rw-r--r--admin/update.php31
8 files changed, 360 insertions, 692 deletions
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 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | admin_phpinfo.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. |
+// +-----------------------------------------------------------------------+
+
+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('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output);
+
+switch ($layout)
+{
+ case 'old':
+ $output = preg_replace('#<table#', '<table class="table1"', $output[1][0]);
+ $output = preg_replace('# bgcolor="\#(\w){6}"#', '', $output);
+ $output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
+ $output = preg_replace('#border="0" cellpadding="3" cellspacing="1" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
+ $output = preg_replace('#<tr valign="top"><td align="left">(.*?<a .*?</a>)(.*?)</td></tr>#s', '<tr class="row1"><td style="{background-color: #9999cc;}"><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td style="{background-color: #9999cc;}">\2</td><td style="{background-color: #9999cc;}">\1</td></tr></table></td></tr>', $output);
+ $output = preg_replace('#<tr valign="baseline"><td[ ]{0,1}><b>(.*?)</b>#', '<tr><td class="row1" nowrap="nowrap">\1', $output);
+ $output = preg_replace('#<td align="(center|left)">#', '<td class="row2">', $output);
+ $output = preg_replace('#<td>#', '<td class="row2">', $output);
+ $output = preg_replace('#valign="middle"#', '', $output);
+ $output = preg_replace('#<tr >#', '<tr>', $output);
+ $output = preg_replace('#<hr(.*?)>#', '', $output);
+ $output = preg_replace('#<h1 align="center">#i', '<h1>', $output);
+ $output = preg_replace('#<h2 align="center">#i', '<h2>', $output);
+ break;
+ case 'new':
+ $output = preg_replace('#<table#', '<table class="table1" align="center"', $output[1][0]);
+ $output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
+ $output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
+ $output = preg_replace('#<tr class="v"><td>(.*?<a .*?</a>)(.*?)</td></tr>#s', '<tr class="throw"><td><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td>\2</td><td>\1</td></tr></table></td></tr>', $output);
+ $output = preg_replace('#<td>#', '<td style="{background-color: #9999cc;}">', $output);
+ $output = preg_replace('#<th>#', '<th class="throw">', $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('#<hr />#', '', $output);
+ preg_match_all('#<div class="center">(.*)</div>#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'] ) )
+
+// Cache management
+
+$query = 'SELECT * FROM '.CATEGORIES_TABLE;
+if ( !isset($_GET['parent_id']))
{
- // 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 );
+ $query.= ' WHERE id_uppercat IS NULL';
}
-if ( isset( $_GET['down'] ) and is_numeric( $_GET['down'] ) )
+else
{
- // 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 );
+ $query.= ' WHERE id_uppercat = '.$_GET['parent_id'];
}
-if ( isset( $_GET['last'] ) and is_numeric( $_GET['last'] ) )
+$query.= ' ORDER BY rank ASC';
+$query.= ';';
+$result = mysql_query( $query );
+while ( $row = mysql_fetch_assoc( $result ) )
{
- // 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 );
+ $categories[$row['rank']]=$row;
}
-if ( isset( $_GET['first'] ) and is_numeric( $_GET['first'] ) )
+
+// Navigation path
+if (isset($_GET['parent_id']))
{
- // 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 );
+ $current_category = get_cat_info($_GET['parent_id']);
+ $url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;parent_id=';
+ $navigation = '<a class="" href="'.add_session_id(PHPWG_ROOT_PATH.'admin.php?page=cat_list').'">';
+ $navigation.= $lang['gallery_index'].'</a>-&gt;';
+ $navigation.= get_cat_display_name($current_category['name'], '-&gt;', $url);
}
-if ( isset( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) )
+
+//--------------------------------------------------------------- rank updates
+$current_rank=0;
+if ( isset( $_GET['up'] ) && is_numeric( $_GET['up'] ))
{
- delete_category( $_GET['delete'] );
- synchronize_all_users();
+ // 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);
+ }
}
-//------------------------------------------------------------------ reordering
-function ordering( $id_uppercat )
+elseif ( isset( $_GET['down'] ) && is_numeric( $_GET['down'] ) )
{
- $rank = 1;
-
- $query = 'SELECT id';
- $query.= ' FROM '.PREFIX_TABLE.'categories';
- if ( !is_numeric( $id_uppercat ) )
+ // 1. searching the id of the category just above at the same level
+ while (list ($id,$current) = each($categories))
{
- $query.= ' WHERE id_uppercat IS NULL';
+ if ($current['id'] == $_GET['down'])
+ {
+ $current_rank = $current['rank'];
+ break;
+ }
}
- else
+ if ($current_rank < count($categories))
{
- $query.= ' WHERE id_uppercat = '.$id_uppercat;
+ // 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;
}
- $query.= ' ORDER BY rank ASC, dir ASC';
- $query.= ';';
- $result = mysql_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
+ else
{
- $query = 'UPDATE '.PREFIX_TABLE.'categories';
- $query.= ' SET rank = '.$rank;
- $query.= ' WHERE id = '.$row['id'];
+ // 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 );
- $rank++;
- ordering( $row['id'] );
+ $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);
}
}
-ordering( 'NULL' );
+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 ( count( $errors ) != 0 )
+if ( sizeof( $errors ) != 0 )
{
- $vtp->addSession( $sub, 'errors' );
- foreach ( $errors as $error ) {
- $vtp->addSession( $sub, 'li' );
- $vtp->setVar( $sub, 'li.content', $error );
- $vtp->closeSession( $sub, 'li' );
+ $template->assign_block_vars('errors',array());
+ for ( $i = 0; $i < sizeof( $errors ); $i++ )
+ {
+ $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i]));
}
- $vtp->closeSession( $sub, 'errors' );
}
-//---------------------------------------------------------------- page display
-function display_cat_manager( $id_uppercat, $indent,
- $uppercat_visible, $level )
+//----------------------------------------------------------- Categories display
+while (list ($id,$category) = each($categories))
{
- 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 ) )
+
+ if ($category['status'] == 'private')
{
- $query.= ' WHERE id_uppercat IS NULL';
+ $category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_lock.gif"
+ width="46" height="25" alt="'.$lang['cat_private'].'" title="'.$lang['cat_private'].'"/>';
+ }
+ elseif (empty($category['dir']))
+ {
+ $category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_link.gif"
+ width="46" height="25" alt="'.$lang['cat_virtual'].'" title="'.$lang['cat_virtual'].'"/>';
}
else
{
- $query.= ' WHERE id_uppercat = '.$id_uppercat;
+ // 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']) ?
+ '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_subfolder.gif" width="46" height="25" alt="" />' :
+ '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder.gif" width="46" height="25" alt="" />';
}
- $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 <th> or <td> 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 ) )
+
+ if ( !isset( $category['dir'] ) ) $category['dir'] = '';
+ $simple_url = PHPWG_ROOT_PATH.'admin.php?page=cat_list&amp;';
+ $url = $simple_url;
+ if (isset($_GET['parent_id']))
+ $url = $simple_url.'parent_id='.$_GET['parent_id'].'&amp;';
+
+ $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&amp;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&amp;cat_id='.$row['id'] ),
+ 'U_CAT_UPDATE'=>add_session_id( PHPWG_ROOT_PATH.'admin.php?page=update&amp;update='.$row['id'] )
+ ));
+
+ if ( !empty($category['dir']))
{
- $query.= ' WHERE id_uppercat IS NULL';
+ $template->assign_block_vars('category.storage' ,array());
}
else
{
- $query.= ' WHERE id_uppercat = '.$id_uppercat;
+ $template->assign_block_vars('category.virtual' ,array());
}
- $query.= ' ORDER BY rank ASC';
- $query.= ';';
- $result = mysql_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
+ $url = add_session_id( './admin.php?page=cat_modify&amp;cat='.$row['id'] );
+ if ( $category['nb_images'] > 0 )
{
- $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&amp;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&amp;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'] );
-
- 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&amp;expand='.$page['expand'];
- $url.= '&amp;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&amp;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&amp;expand='.$page['expand'];
- $url.= '&amp;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&amp;expand='.$page['expand'];
- $url.= '&amp;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&amp;expand='.$page['expand'];
- $url.= '&amp;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&amp;expand='.$page['expand'];
- $url.= '&amp;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&amp;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&amp;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&amp;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( '&nbsp', 4 ),
- $subcat_visible, $level + 1 );
+ $template->assign_block_vars('category.image_info' ,array());
+ }
+ else
+ {
+ $template->assign_block_vars('category.no_image_info' ,array());
}
}
-display_cat_manager( 'NULL', str_repeat( '&nbsp', 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'] )
-{
- $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, '&nbsp;' );
- $vtp->closeSession( $sub, 'associate_LOV' );
-}
-// 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' );
-}
+
//----------------------------------------------------------- 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 @@
-<?php
-// +-----------------------------------------------------------------------+
-// | comments.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. |
-// +-----------------------------------------------------------------------+
-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'], ' &gt; ', '' );
- }
-
- $file = get_filename_wo_extension( $subrow['file'] );
- // name of the picture
- $name = $array_cat_names[$subrow['cat_id']].' &gt; ';
- 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.= '&amp;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 = '<span style="text-decoration:underline;">\1</span>';
- $content = preg_replace( $pattern, $replacement, $content );
-
- // replace *word* by a bolded word
- $pattern = '/\*([^\s]*)\*/';
- $replacement = '<span style="font-weight:bold;">\1</span>';
- $content = preg_replace( $pattern, $replacement, $content );
-
- // replace /word/ by an italic word
- $pattern = '/\/([^\s]*)\//';
- $replacement = '<span style="font-style:italic;">\1</span>';
- $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.= '&amp;last_days='.MAX_DAYS;
- if ( isset( $_GET['show_unvalidated'] ) )
- $url.= '&amp;show_unvalidated=true';
- $url.= '&amp;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.= '&amp;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.= '&amp;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.= '&amp;last_days='.$_GET['last_days'];
- }
- $action.= '&amp;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.= '&amp;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.= '&amp;last_days='.$_GET['last_days'];
- }
- $url.= '&amp;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&amp;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 )<br />';