Changeset 393 for trunk/comments.php
- Timestamp:
- Mar 20, 2004, 1:52:37 AM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/comments.php
r369 r393 27 27 28 28 //----------------------------------------------------------- include 29 define('PHPWG_ROOT_PATH','./'); 30 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 29 if (!defined('IN_ADMIN')) 30 { 31 define('PHPWG_ROOT_PATH','./'); 32 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); 33 } 31 34 32 35 //--------------------------------------------------- number of days to display … … 37 40 $array_cat_names = array(); 38 41 $array_cat_site_id = array(); 42 43 // comment deletion 44 if ( isset( $_POST['delete'] ) ) 45 { 46 $mod_sql=''; 47 while( list($id, $row_id) = @each($_POST['comment_id']) ) 48 { 49 $mod_sql .= ( ( $mod_sql != '' ) ? ', ' : '' ) . $row_id; 50 } 51 $query = 'DELETE FROM '.COMMENTS_TABLE.' WHERE id IN ('.$mod_sql.');'; 52 mysql_query( $query ); 53 } 54 55 //--------------------------------------------------------- comments validation 56 if ( isset( $_POST['validate'] ) ) 57 { 58 $mod_sql=''; 59 while( list($id, $row_id) = @each($_POST['comment_id']) ) 60 { 61 $mod_sql .= ( ( $mod_sql != '' ) ? ', ' : '' ) . $row_id; 62 } 63 $query = 'UPDATE '.COMMENTS_TABLE; 64 $query.= " SET validated = 'true'"; 65 $query.=' WHERE id IN ('.$mod_sql.');'; 66 mysql_query( $query ); 67 } 39 68 //------------------------------------------------------- last comments display 40 69 … … 42 71 // Start output of page 43 72 // 44 $title= $lang['title_comments']; 45 include(PHPWG_ROOT_PATH.'include/page_header.php'); 73 if (!defined('IN_ADMIN')) 74 { 75 $title= $lang['title_comments']; 76 include(PHPWG_ROOT_PATH.'include/page_header.php'); 77 } 46 78 47 79 $template->set_filenames( array('comments'=>'comments.tpl') ); 48 initialize_template();49 50 80 $template->assign_vars(array( 51 'L_TITLE' => $lang['title_comments'], 52 'L_STATS' => $lang['stats_last_days'], 53 'L_RETURN' => $lang['search_return_main_page'], 81 'L_COMMENT_TITLE' => $title, 82 'L_COMMENT_STATS' => $lang['stats_last_days'], 83 'L_COMMENT_RETURN' => $lang['search_return_main_page'], 84 'L_DELETE' =>$lang['delete'], 85 'L_VALIDATE'=>$lang['submit'], 54 86 55 'U_HOME' => add_session_id( 'category.php' ) 87 'T_DEL_IMG' =>PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/delete.gif', 88 89 'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ) 56 90 ) 57 91 ); 58 92 59 93 foreach ( $conf['last_days'] as $option ) { 60 $url = './comments.php?last_days='.($option - 1); 94 $url = $PHP_SELF.'?last_days='.($option - 1); 95 if (defined('IN_ADMIN')) $url.= '&page=comments'; 61 96 $template->assign_block_vars('last_day_option', array ( 62 97 'OPTION'=>$option, … … 71 106 $maxtime = mktime( 0,0,0,$month,$day,$year ); 72 107 $query = 'SELECT DISTINCT(ic.image_id) as image_id,'; 73 $query 74 $query.= ' FROM '. PREFIX_TABLE.'commentsAS c';75 $query.= ', '.PREFIX_TABLE.'image_categoryAS ic';108 $query.= '(ic.category_id) as category_id'; 109 $query.= ' FROM '.COMMENTS_TABLE.' AS c'; 110 $query.= ', '.IMAGE_CATEGORY_TABLE.' AS ic'; 76 111 $query.= ' WHERE c.image_id = ic.image_id'; 77 112 $query.= ' AND date > '.$maxtime; 78 $query.= " AND validated = 'true'"; 79 // we must not show pictures of a forbidden category 80 if ( $user['forbidden_categories'] != '' ) 81 { 82 $query.= ' AND category_id NOT IN '; 83 $query.= '('.$user['forbidden_categories'].')'; 113 if ( $user['status'] != 'admin' ) 114 { 115 $query.= " AND validated = 'true'"; 116 // we must not show pictures of a forbidden category 117 if ( $user['forbidden_categories'] != '' ) 118 { 119 $query.= ' AND category_id NOT IN '; 120 $query.= '('.$user['forbidden_categories'].')'; 121 } 84 122 } 85 123 $query.= ' ORDER BY ic.image_id DESC'; 86 124 $query.= ';'; 87 125 $result = mysql_query( $query ); 88 126 if ( $user['status'] == 'admin' ) 127 { 128 $template->assign_block_vars('validation', array()); 129 } 89 130 while ( $row = mysql_fetch_array( $result ) ) 90 131 { … … 113 154 // name of the picture 114 155 $name = $array_cat_names[$category_id].' > '; 115 if ( $subrow['name'] != '') $name.= $subrow['name'];156 if (!empty($subrow['name'])) $name.= $subrow['name']; 116 157 else $name.= str_replace( '_', ' ', $file ); 117 158 $name.= ' [ '.$subrow['file'].' ]'; … … 121 162 $src.= $file.'.'.$subrow['tn_ext']; 122 163 // link to the full size picture 123 $url = './picture.php?cat='.$category_id;164 $url = PHPWG_ROOT_PATH.'picture.php?cat='.$category_id; 124 165 $url.= '&image_id='.$row['image_id']; 125 166 … … 131 172 132 173 // for each picture, retrieving all comments 133 $query = 'SELECT id,date,author,content'; 134 $query.= ' FROM '.COMMENTS_TABLE; 174 $query = 'SELECT * FROM '.COMMENTS_TABLE; 135 175 $query.= ' WHERE image_id = '.$row['image_id']; 136 176 $query.= ' AND date > '.$maxtime; 137 $query.= " AND validated = 'true'"; 177 if ( $user['status'] != 'admin' ) 178 { 179 $query.= " AND validated = 'true'"; 180 } 138 181 $query.= ' ORDER BY date DESC'; 139 182 $query.= ';'; … … 142 185 { 143 186 $author = $subrow['author']; 144 if ( $subrow['author'] == '') $author = $lang['guest'];187 if ( empty($subrow['author'] )) $author = $lang['guest']; 145 188 $content = nl2br( $subrow['content'] ); 146 189 … … 160 203 $content = preg_replace( $pattern, $replacement, $content ); 161 204 $template->assign_block_vars('picture.comment',array( 162 ' AUTHOR'=>$author,163 ' DATE'=>format_date( $subrow['date'], 'unix', true ),164 'CO NTENT'=>$content,205 'COMMENT_AUTHOR'=>$author, 206 'COMMENT_DATE'=>format_date( $subrow['date'], 'unix', true ), 207 'COMMENT'=>$content, 165 208 )); 209 if ( $user['status'] == 'admin' ) 210 { 211 $template->assign_block_vars('picture.comment.validation', array( 212 'ID'=> $subrow['id'], 213 'CHECKED'=>($subrow['validated']=='false')?'checked="checked"': '' 214 )); 215 } 166 216 } 167 217 } 168 218 //----------------------------------------------------------- html code display 169 $template->pparse('comments'); 170 include(PHPWG_ROOT_PATH.'include/page_tail.php'); 219 if (defined('IN_ADMIN')) 220 { 221 $template->assign_var_from_handle('ADMIN_CONTENT', 'comments'); 222 } 223 else 224 { 225 $template->assign_block_vars('title',array()); 226 $template->pparse('comments'); 227 include(PHPWG_ROOT_PATH.'include/page_tail.php'); 228 } 171 229 ?>
Note: See TracChangeset
for help on using the changeset viewer.