| [ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/rss_menu/admin_prefs.php,v $ 14 | $Revision: 1.12 $ 15 | $Date: 2006/10/19 02:49:58 $ 16 | $Author: e107coders $ 17 +----------------------------------------------------------------------------+ 18 */ 19 /* 20 Notes: 21 22 - array_flip method deprecated for delete item detection. 23 - using form handler is deprecated and present only for backwards compatibility. 24 - using generic terms like EDIT and DELETE in Language file is deprecated, use LAN_EDIT etc. instead. 25 - using terms like created, update, options etc..deprecated should use built in terms. 26 - generic admin icons used. ADMIN_ICON_EDIT etc. 27 - using $caption = "whatever", is unneccessary. 28 29 */ 30 31 require_once ("../../class2.php"); 32 if(!getperms("P")){ header("location:".e_BASE."index.php"); } 33 $lan_file = e_PLUGIN."rss_menu/languages/".e_LANGUAGE.".php"; 34 require_once(file_exists($lan_file) ? $lan_file : e_PLUGIN."rss_menu/languages/English.php"); 35 36 require_once(e_ADMIN."auth.php"); 37 38 $imagedir = e_IMAGE."admin_images/"; 39 $lan_file = e_PLUGIN.'rss_menu/languages/'.e_LANGUAGE.'.php'; 40 include_once(file_exists($lan_file) ? $lan_file : e_PLUGIN.'rss_menu/languages/English.php'); 41 require_once(e_PLUGIN.'rss_menu/rss_shortcodes.php'); 42 $rss = new rss; 43 44 global $tp; 45 46 //delete entry 47 if(isset($_POST['delete'])){ 48 $d_idt = array_keys($_POST['delete']); 49 $message = ($sql -> db_Delete("rss", "rss_id='".$d_idt[0]."'")) ? LAN_DELETED : LAN_DELETED_FAILED; 50 $e107cache->clear("rss"); 51 } 52 53 //create rss feed 54 if(isset($_POST['create_rss'])){ 55 $message = $rss -> dbrss("create"); 56 } 57 58 //update rss feed 59 if(isset($_POST['update_rss'])){ 60 $message = $rss -> dbrss("update"); 61 } 62 63 //import rss feed 64 if(isset($_POST['import_rss'])){ 65 $message = $rss -> dbrssimport(); 66 } 67 68 //update_limit 69 if(isset($_POST['update_limit'])){ 70 $message = $rss -> dbrsslimit(); 71 } 72 //update options 73 if(isset($_POST['updatesettings'])){ 74 $message = $rss->dboptions(); 75 } 76 77 //config check 78 if($rss->file_check()){ 79 $message = RSS_LAN_ERROR_2; // space found in file. 80 } 81 82 83 //render message 84 if(isset($message)){ 85 $rss->show_message('', $message); 86 } 87 88 //get template 89 if (is_readable(THEME."rss_template.php")) { 90 require_once (THEME."rss_template.php"); 91 } else { 92 require_once(e_PLUGIN."rss_menu/rss_template.php"); 93 } 94 95 //listing 96 if(e_QUERY){ 97 $qs = explode(".", e_QUERY); 98 $field = (isset($qs[1])) ? $qs[1] : ""; 99 $sort = (isset($qs[2])) ? $qs[2] : ""; 100 } 101 102 //create 103 if(isset($qs[0]) && $qs[0] == 'create' && !$_POST){ 104 $rss -> rssadmincreate(); 105 106 //import 107 }elseif(isset($qs[0]) && $qs[0] == 'import'){ 108 $rss -> rssadminimport(); 109 110 //options 111 }elseif(isset($qs[0]) && $qs[0] == 'options'){ 112 $rss -> rssadminoptions(); 113 114 //list 115 }else{ 116 117 $rss -> rssadminlist(); 118 } 119 120 require_once(e_ADMIN."footer.php"); 121 122 // ##### Display options -------------------------------------------------------------------------- 123 function admin_prefs_adminmenu(){ 124 global $sql, $qs; 125 126 $act = $qs[0]; 127 if($act==""){$act="list";} 128 129 $var['list']['text'] = RSS_LAN_ADMINMENU_2; 130 $var['list']['link'] = e_SELF."?list"; 131 132 $var['create']['text'] = LAN_CREATE; 133 $var['create']['link'] = e_SELF."?create"; 134 135 $var['import']['text'] = RSS_LAN_ADMINMENU_4; 136 $var['import']['link'] = e_SELF."?import"; 137 138 $var['options']['text'] = LAN_OPTIONS; 139 $var['options']['link'] = e_SELF."?options"; 140 141 show_admin_menu(RSS_LAN_ADMINMENU_1, $act, $var); 142 143 } 144 // ##### End -------------------------------------------------------------------------------------- 145 146 147 148 149 150 151 class rss{ 152 153 //check for config 154 function file_check(){ 155 $arrays = file_get_contents(e_BASE."e107_config.php"); 156 $arrays2 = file_get_contents(e_PLUGIN."rss_menu/languages/".e_LANGUAGE.".php"); 157 if($arrays[0] != "<" || $arrays2[0] != "<"){ 158 return TRUE; 159 } 160 } 161 162 163 //admin : list : existing rss feeds 164 function rssadminlist(){ 165 global $qs, $ns, $sql, $rs, $tp, $field, $sort, $rss_shortcodes, $row, $RSS_ADMIN_LIST_HEADER, $RSS_ADMIN_LIST_TABLE, $RSS_ADMIN_LIST_FOOTER; 166 167 $fieldstag = array('id'=>'rss_id','path'=>'rss_path','name'=>'rss_name','url'=>'rss_url','limit'=>'rss_limit'); 168 $order = (isset($fieldstag[$field])) ? "ORDER BY ".$fieldstag[$field]." ".$sort : "ORDER BY rss_id"; 169 170 $query = "SELECT * FROM #rss ".$order; 171 if(!$sql->db_Select_gen($query)) 172 { 173 $this->show_message(LAN_ERROR, RSS_LAN_ERROR_3); 174 } 175 else 176 { 177 $text = $tp -> parseTemplate($RSS_ADMIN_LIST_HEADER, FALSE, $rss_shortcodes); 178 while($row=$sql->db_Fetch()) 179 { 180 $text .= $tp -> parseTemplate($RSS_ADMIN_LIST_TABLE, FALSE, $rss_shortcodes); 181 } 182 $text .= $tp -> parseTemplate($RSS_ADMIN_LIST_FOOTER, FALSE, $rss_shortcodes); 183 $ns->tablerender(RSS_LAN_ADMIN_1, $text); 184 } 185 } 186 187 //create 188 function rssadmincreate(){ 189 global $ns, $qs, $rs, $sql, $tp, $rss_shortcodes, $row, $RSS_ADMIN_CREATE_TABLE; 190 191 if( isset($qs[1]) && $qs[1] == "edit" && isset($qs[2]) && is_numeric($qs[2]) ){ 192 if(!$sql -> db_Select("rss", "*", "rss_id='".intval($qs[2])."' ")){ 193 $this->show_message(LAN_ERROR, RSS_LAN_ERROR_5); 194 }else{ 195 $row = $sql -> db_Fetch(); 196 197 $row['rss_name'] = $tp -> toForm($row['rss_name']); 198 $row['rss_path'] = $tp -> toForm($row['rss_path']); 199 $row['rss_url'] = $tp -> toForm($row['rss_url']); 200 $row['rss_text'] = $tp -> toForm($row['rss_text']); 201 } 202 } 203 $text = $tp -> parseTemplate($RSS_ADMIN_CREATE_TABLE, FALSE, $rss_shortcodes); 204 $ns->tablerender(RSS_LAN_ADMIN_10, $text); 205 } 206 207 //import 208 function rssadminimport(){ 209 global $sql, $ns, $i, $qs, $rs, $tp, $rss_shortcodes, $feed, $pref; 210 global $RSS_ADMIN_IMPORT_HEADER, $RSS_ADMIN_IMPORT_TABLE, $RSS_ADMIN_IMPORT_FOOTER; 211 212 $sqli = new db; 213 $feedlist = array(); 214 215 //news 216 $feed['name'] = ADLAN_0; 217 $feed['url'] = 'news'; //the identifier for the rss feed url 218 $feed['topic_id'] = ''; //the topic_id, empty on default (to select a certain category) 219 $feed['path'] = 'news'; //this is the plugin path location 220 $feed['text'] = RSS_PLUGIN_LAN_7; 221 $feed['class'] = '0'; 222 $feed['limit'] = '9'; 223 $feedlist[] = $feed; 224 225 //news categories 226 if($sqli -> db_Select("news_category", "*","category_id!='' ORDER BY category_name ")){ 227 while($rowi = $sqli -> db_Fetch()){ 228 $feed['name'] = ADLAN_0.' > '.$rowi['category_name']; 229 $feed['url'] = 'news'; 230 $feed['topic_id'] = $rowi['category_id']; 231 $feed['path'] = 'news'; 232 $feed['text'] = RSS_PLUGIN_LAN_10.' '.$rowi['category_name']; 233 $feed['class'] = '0'; 234 $feed['limit'] = '9'; 235 $feedlist[] = $feed; 236 } 237 } 238 239 //download 240 $feed['name'] = ADLAN_24; 241 $feed['url'] = 'download'; 242 $feed['topic_id'] = ''; 243 $feed['path'] = 'download'; 244 $feed['text'] = RSS_PLUGIN_LAN_8; 245 $feed['class'] = '0'; 246 $feed['limit'] = '9'; 247 $feedlist[] = $feed; 248 249 //download categories 250 if($sqli -> db_Select("download_category", "*","download_category_id!='' ORDER BY download_category_order ")){ 251 while($rowi = $sqli -> db_Fetch()){ 252 $feed['name'] = ADLAN_24.' > '.$rowi['download_category_name']; 253 $feed['url'] = 'download'; 254 $feed['topic_id'] = $rowi['download_category_id']; 255 $feed['path'] = 'download'; 256 $feed['text'] = RSS_PLUGIN_LAN_11.' '.$rowi['download_category_name']; 257 $feed['class'] = '0'; 258 $feed['limit'] = '9'; 259 $feedlist[] = $feed; 260 } 261 } 262 263 //comments 264 $feed['name'] = RSS_PLUGIN_LAN_14; 265 $feed['url'] = 'comments'; 266 $feed['topic_id'] = ''; 267 $feed['path'] = 'comments'; 268 $feed['text'] = RSS_PLUGIN_LAN_9; 269 $feed['class'] = '0'; 270 $feed['limit'] = '9'; 271 $feedlist[] = $feed; 272 273 //plugin rss feed, using e_rss.php in plugin folder 274 $plugin_feedlist = array(); 275 foreach($pref['e_rss_list'] as $val) 276 { 277 if (is_readable(e_PLUGIN.$val."/e_rss.php")) { 278 require_once(e_PLUGIN.$val."/e_rss.php"); 279 $plugin_feedlist = $eplug_rss_feed; 280 } 281 } 282 283 /* if($sqli -> db_Select("plugin","plugin_path","plugin_installflag = '1' ORDER BY plugin_path ")){ 284 while($rowi = $sqli -> db_Fetch()){ 285 if (is_readable(e_PLUGIN.$rowi['plugin_path']."/e_rss.php")) { 286 require_once(e_PLUGIN.$rowi['plugin_path']."/e_rss.php"); 287 $plugin_feedlist = $eplug_rss_feed; 288 } 289 } 290 }*/ 291 292 $feedlist = array_merge($feedlist, $plugin_feedlist); 293 294 $render=FALSE; 295 $i=0; 296 $text = $RSS_ADMIN_IMPORT_HEADER; 297 foreach($feedlist as $k=>$feed){ 298 $feed['topic_id'] = $tp -> toDB($feed['topic_id']); 299 $feed['url'] = $tp -> toDB($feed['url']); 300 301 //check if feed is not yet present 302 if(!$sql -> db_Select("rss", "*", "rss_path='".$feed['path']."' AND rss_url='".$feed['url']."' AND rss_topicid='".$feed['topic_id']."' ")) 303 { 304 $render=TRUE; 305 $text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_TABLE, FALSE, $rss_shortcodes); 306 $i++; 307 } 308 } 309 $text .= $tp -> parseTemplate($RSS_ADMIN_IMPORT_FOOTER, FALSE, $rss_shortcodes); 310 311 if(!$render){ 312 $this->show_message(RSS_LAN_ADMIN_11, RSS_LAN_ERROR_6); 313 }else{ 314 $ns->tablerender(RSS_LAN_ADMIN_11, $text); 315 } 316 } 317 318 //options 319 function rssadminoptions(){ 320 global $ns, $qs, $rs, $sql, $tp, $rss_shortcodes, $row, $RSS_ADMIN_OPTIONS_TABLE; 321 322 $text = $tp -> parseTemplate($RSS_ADMIN_OPTIONS_TABLE, FALSE, $rss_shortcodes); 323 $ns->tablerender(LAN_OPTIONS, $text); 324 return; 325 } 326 327 //render message 328 function show_message($caption='', $text=''){ 329 global $ns; 330 $ns -> tablerender($caption, "<div style='text-align:center'><b>$text</b></div>"); 331 } 332 333 //db:create/update 334 function dbrss($mode='create'){ 335 global $qs, $sql, $ns, $rs, $tp, $e107cache; 336 337 if($_POST['rss_name'] && $_POST['rss_url'] && $_POST['rss_path']){ 338 339 $_POST['rss_name'] = $tp -> toDB(trim($_POST['rss_name'])); 340 $_POST['rss_url'] = $tp -> toDB($_POST['rss_url']); 341 $_POST['rss_topicid'] = $tp -> toDB($_POST['rss_topicid']); 342 $_POST['rss_path'] = $tp -> toDB($_POST['rss_path']); 343 $_POST['rss_text'] = $tp -> toDB($_POST['rss_text']); 344 $_POST['rss_class'] = (intval($_POST['rss_class']) ? intval($_POST['rss_class']) : '0'); 345 $_POST['rss_limit'] = intval($_POST['rss_limit']); 346 347 if(isset($_POST['rss_datestamp']) && $_POST['rss_datestamp']!=''){ 348 $datestamp = intval($_POST['rss_datestamp']); 349 }else{ 350 $datestamp = time(); 351 } 352 353 if($mode == 'create'){ 354 $message = ($sql -> db_Insert("rss", "'0', '".$_POST['rss_name']."', '".$_POST['rss_url']."', '".$_POST['rss_topicid']."', '".$_POST['rss_path']."', '".$_POST['rss_text']."', '".$datestamp."', '".$_POST['rss_class']."', '".$_POST['rss_limit']."' ")) ? LAN_CREATED : LAN_CREATED_FAILED; 355 $e107cache->clear("rss"); 356 357 }elseif($mode == 'update'){ 358 $message = ($sql -> db_Update("rss", "rss_name = '".$_POST['rss_name']."', rss_url = '".$_POST['rss_url']."', rss_topicid = '".$_POST['rss_topicid']."', rss_path = '".$_POST['rss_path']."', rss_text = '".$_POST['rss_text']."', rss_datestamp = '".$datestamp."', rss_class = '".$_POST['rss_class']."', rss_limit = '".$_POST['rss_limit']."' WHERE rss_id = '".intval($_POST['rss_id'])."' ")) ? LAN_UPDATED : LAN_UPDATED_FAILED; 359 $e107cache->clear("rss"); 360 } 361 }else{ 362 $message = RSS_LAN_ERROR_7; 363 } 364 return $message; 365 } 366 367 //import rss feeds 368 function dbrssimport(){ 369 global $sql, $tp; 370 371 foreach($_POST['importid'] as $key=>$value) 372 { 373 $rss_topcid = ($_POST['topic_id'][$key] ? $tp -> toDB($_POST['topic_id'][$key]) : ''); 374 $rss_url = ($_POST['url'][$key] ? $tp -> toDB($_POST['url'][$key]) : ''); 375 $rss_path = ($_POST['path'][$key] ? $tp -> toDB($_POST['path'][$key]) : ''); 376 $rss_name = ($_POST['name'][$key] ? $tp -> toDB($_POST['name'][$key]) : ''); 377 $rss_text = ($_POST['text'][$key] ? $tp -> toDB($_POST['text'][$key]) : ''); 378 $rss_datestamp = time(); 379 $rss_class = ($_POST['class'][$key] ? intval($_POST['class'][$key]) : '0'); 380 $rss_limit = ($_POST['limit'][$key] ? intval($_POST['limit'][$key]) : '0'); 381 382 $sql -> db_Insert("rss", "'0', '".$rss_name."', '".$rss_url."', '".$rss_topcid."', '".$rss_path."', '".$rss_text."', '".$rss_datestamp."', '".$rss_class."', '".$rss_limit."' "); 383 } 384 $message = count($_POST['importid'])." ".RSS_LAN_ADMIN_18; 385 return $message; 386 387 } 388 389 function dbrsslimit(){ 390 global $sql, $tp; 391 foreach($_POST['limit'] as $key=>$value) 392 { 393 $sql -> db_Update("rss", "rss_limit = '".intval($value)."' WHERE rss_id = '".intval($key)."' "); 394 } 395 header("location:".e_SELF."?r3"); 396 } 397 398 //update options 399 function dboptions(){ 400 global $tp, $pref; 401 402 $pref['rss_othernews'] = $_POST['rss_othernews']; 403 404 save_prefs(); 405 return LAN_SAVED; 406 } 407 408 409 } //end class 410 411 412 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |