Changeset 1549 for trunk/feed.php
- Timestamp:
- Sep 19, 2006, 12:51:09 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/feed.php
r1331 r1549 110 110 $user = mysql_fetch_array(pwg_query($query)); 111 111 } 112 else 113 { 114 echo l10n('Unknown feed identifier'); 115 exit();112 113 if ( empty($user) ) 114 { 115 page_not_found('Unknown/missing feed identifier'); 116 116 } 117 117 … … 127 127 include_once(PHPWG_ROOT_PATH.'include/feedcreator.class.php'); 128 128 129 $base_url = 'http://'.$_SERVER["HTTP_HOST"].cookie_path(); 130 if ( strrpos($base_url, '/') !== strlen($base_url)-1 ) 131 { 132 $base_url .= '/'; 133 } 134 $page['root_path']=$base_url; 135 129 136 $rss = new UniversalFeedCreator(); 130 137 131 $rss->title = $conf['gallery_title'] .', notifications';138 $rss->title = $conf['gallery_title']; 132 139 $rss->title.= ' (as '.$user['username'].')'; 133 140 … … 138 145 // +-----------------------------------------------------------------------+ 139 146 140 $news = news($user['last_check'], $dbnow );147 $news = news($user['last_check'], $dbnow, true); 141 148 142 149 if (count($news) > 0) 143 150 { 144 $item = new FeedItem(); 151 $item = new FeedItem(); 145 152 $item->title = sprintf(l10n('New on %s'), $dbnow); 146 153 $item->link = $conf['gallery_url']; 147 154 148 155 // content creation 149 156 $item->description = '<ul>'; … … 154 161 $item->description.= '</ul>'; 155 162 $item->descriptionHtmlSyndicated = true; 156 163 157 164 $item->date = ts_to_iso8601(mysqldt_to_ts($dbnow)); 158 $item->author = 'PhpWebGallery notifier'; 159 165 $item->author = 'PhpWebGallery notifier'; 166 $item->guid= sprintf('%s', $dbnow);; 167 160 168 $rss->addItem($item); 161 } 162 163 $query = ' 169 170 $query = ' 164 171 UPDATE '.USER_FEED_TABLE.' 165 172 SET last_check = \''.$dbnow.'\' 166 173 WHERE id = \''.$_GET['feed'].'\' 167 174 ;'; 168 pwg_query($query); 175 pwg_query($query); 176 } 177 178 179 // build items for new images/albums 180 $query = ' 181 SELECT date_available, 182 COUNT(DISTINCT id) nb_images, 183 COUNT(DISTINCT category_id) nb_cats 184 FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id 185 WHERE category_id NOT IN ('.$user['forbidden_categories'].') 186 GROUP BY date_available 187 ORDER BY date_available DESC 188 LIMIT 0,5 189 ;'; 190 $result = pwg_query($query); 191 $dates = array(); 192 while ($row = mysql_fetch_array($result)) 193 { 194 array_push($dates, $row); 195 } 196 197 foreach($dates as $date_detail) 198 { // for each recent post date we create a feed item 199 $date = $date_detail['date_available']; 200 $exploded_date = explode_mysqldt($date); 201 $item = new FeedItem(); 202 $item->title = sprintf(l10n('%d new elements'), $date_detail['nb_images']); 203 $item->title .= ' ('.$lang['month'][(int)$exploded_date['month']].' '.$exploded_date['day'].')'; 204 $item->link = make_index_url( 205 array( 206 'chronology_field' => 'posted', 207 'chronology_style'=> 'monthly', 208 'chronology_view' => 'calendar', 209 'chronology_date' => explode('-', substr($date,0,10) ) 210 ) 211 ); 212 213 $item->description .= 214 '<a href="'.make_index_url().'">'.$conf['gallery_title'].'</a><br/> '; 215 216 $item->description .= 217 '<li>' 218 .sprintf(l10n('%d new elements'), $date_detail['nb_images']) 219 .' (' 220 .'<a href="'.make_index_url(array('section'=>'recent_pics')).'">' 221 .l10n('recent_pics_cat').'</a>' 222 .')' 223 .'</li>'; 224 225 // get some thumbnails ... 226 $query = ' 227 SELECT DISTINCT id, path, name, tn_ext 228 FROM '.IMAGES_TABLE.' INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON id=image_id 229 WHERE category_id NOT IN ('.$user['forbidden_categories'].') 230 AND date_available="'.$date.'" 231 AND tn_ext IS NOT NULL 232 LIMIT 0,6 233 ;'; 234 $result = pwg_query($query); 235 while ($row = mysql_fetch_array($result)) 236 { 237 $tn_src = get_thumbnail_src($row['path'], @$row['tn_ext']); 238 $item->description .= '<img src="'.$tn_src.'"/>'; 239 } 240 $item->description .= '...<br/>'; 241 242 243 $item->description .= 244 '<li>' 245 .sprintf(l10n('%d categories updated'), $date_detail['nb_cats']) 246 .'</li>'; 247 // get some categories ... 248 $query = ' 249 SELECT DISTINCT c.uppercats, COUNT(DISTINCT i.id) img_count 250 FROM '.IMAGES_TABLE.' i INNER JOIN '.IMAGE_CATEGORY_TABLE.' ON i.id=image_id 251 INNER JOIN '.CATEGORIES_TABLE.' c ON c.id=category_id 252 WHERE category_id NOT IN ('.$user['forbidden_categories'].') 253 AND date_available="'.$date.'" 254 GROUP BY category_id 255 ORDER BY img_count DESC 256 LIMIT 0,6 257 ;'; 258 $result = pwg_query($query); 259 $item->description .= '<ul>'; 260 while ($row = mysql_fetch_array($result)) 261 { 262 $item->description .= 263 '<li>' 264 .get_cat_display_name_cache($row['uppercats']) 265 .' ('.sprintf(l10n('%d new elements'), $row['img_count']).')' 266 .'</li>'; 267 } 268 $item->description .= '</ul>'; 269 270 $item->descriptionHtmlSyndicated = true; 271 272 $item->date = ts_to_iso8601(mysqldt_to_ts($date)); 273 $item->author = 'PhpWebGallery notifier'; 274 $item->guid= sprintf('%s', 'pics-'.$date);; 275 276 $rss->addItem($item); 277 } 169 278 170 279 // send XML feed
Note: See TracChangeset
for help on using the changeset viewer.