- Timestamp:
- 12/12/10 20:35:39 (18 months ago)
- Location:
- branches
- Files:
-
- 7 modified
- 1 moved
-
1.4/install/install_functions.php (modified) (1 diff)
-
1.5/Hotaru.php (modified) (1 diff)
-
1.5/README.txt (moved) (moved from branches/1.5/READ_ME.txt)
-
1.5/install/index.php (modified) (23 diffs)
-
1.5/libs/AdminPages.php (modified) (1 diff)
-
1.5/libs/Database.php (modified) (25 diffs)
-
1.5/libs/extensions/Inspekt/Inspekt.php (modified) (1 diff)
-
1.5/libs/extensions/SimplePie/simplepie.php (modified) (528 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.4/install/install_functions.php
r2227 r2295 37 37 function init_database() 38 38 { 39 $ezSQL = new ezSQL_mysql(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 40 $ezSQL->query("SET NAMES 'utf8'"); 41 42 return $ezSQL; 39 return new Database(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 43 40 } 44 41 -
branches/1.5/Hotaru.php
r2288 r2295 104 104 105 105 $this->csrf(FALSE); // set a csrfToken 106 $this->db->setHotaru($this); // pass $h object to EzSQL for error reporting107 106 } 108 107 } -
branches/1.5/install/index.php
r2268 r2295 28 28 * @link http://www.hotarucms.org/ 29 29 */ 30 31 30 // start session: 32 31 session_start(); … … 36 35 37 36 if (file_exists(SETTINGS)) { 38 include_once(SETTINGS);39 $settings_file_exists = true;37 include_once(SETTINGS); 38 $settings_file_exists = true; 40 39 } else { 41 $settings_file_exists = false; 42 } 43 44 if (!defined("SITEURL")) { define("SITEURL", BASEURL); } 40 $settings_file_exists = false; 41 } 42 43 if (!defined("SITEURL")) { 44 define("SITEURL", BASEURL); 45 } 45 46 46 47 // define path constants 47 48 $path_constants = array( 48 "BASE" => "/../",49 "ADMIN" => "/../admin/",50 "INSTALL" => "/",51 "CACHE" => "/../cache/",52 "LIBS" => "/../libs/",53 "EXTENSIONS" => "/../libs/extensions/",54 "FUNCTIONS" => "/../functions/",55 "THEMES" => "/../content/themes/",56 "PLUGINS" => "/../content/plugins/",57 "ADMIN_THEMES" => "/../content/admin_themes/",58 );59 60 foreach ( $path_constants as $key => $value) {61 if (!defined($key))62 define($key, dirname(__FILE__) .$value);49 "BASE" => "/../", 50 "ADMIN" => "/../admin/", 51 "INSTALL" => "/", 52 "CACHE" => "/../cache/", 53 "LIBS" => "/../libs/", 54 "EXTENSIONS" => "/../libs/extensions/", 55 "FUNCTIONS" => "/../functions/", 56 "THEMES" => "/../content/themes/", 57 "PLUGINS" => "/../content/plugins/", 58 "ADMIN_THEMES" => "/../content/admin_themes/", 59 ); 60 61 foreach ($path_constants as $key => $value) { 62 if (!defined($key)) 63 define($key, dirname(__FILE__).$value); 63 64 } 64 65 65 66 require_once('install_tables.php'); 66 67 require_once('install_functions.php'); 67 require_once(BASE .'Hotaru.php');68 require_once(EXTENSIONS .'csrf/csrf_class.php'); // protection against CSRF attacks69 require_once(EXTENSIONS .'Inspekt/Inspekt.php'); // sanitation70 require_once(LIBS .'Database.php'); // database71 72 $h = new Hotaru('start'); // must come before language inclusion73 require_once(INSTALL . 'install_language.php');// language file for install68 require_once(BASE.'Hotaru.php'); 69 require_once(EXTENSIONS.'csrf/csrf_class.php'); // protection against CSRF attacks 70 require_once(EXTENSIONS.'Inspekt/Inspekt.php'); // sanitation 71 require_once(LIBS.'Database.php'); // database 72 73 $h = new Hotaru('start'); // must come before language inclusion 74 require_once(INSTALL.'install_language.php'); // language file for install 74 75 75 76 $version_number = $h->version; 76 77 $cage = init_inspekt_cage(); 77 78 78 $step = $cage->get->getInt('step'); // Installation steps.79 $action = $cage->get->getAlpha('action'); // Install or Upgrade.79 $step = $cage->get->getInt('step'); // Installation steps. 80 $action = $cage->get->getAlpha('action'); // Install or Upgrade. 80 81 81 82 switch ($step) { 82 83 case 0: 83 installation_welcome(); // "Welcome to Hotaru CMS.84 installation_welcome(); // "Welcome to Hotaru CMS. 84 85 break; 85 case 1: 86 case 1: 86 87 if ($action == 'upgrade') { 87 88 database_upgrade(); 88 89 } else { 89 90 // Remove any cookies set in a previous installation: 90 setcookie("hotaru_user", "", time() -3600, "/");91 setcookie("hotaru_key", "", time() -3600, "/");92 91 setcookie("hotaru_user", "", time() - 3600, "/"); 92 setcookie("hotaru_key", "", time() - 3600, "/"); 93 93 94 // database setup (DB name, user, password, prefix...) 94 95 // use this direct call instead of $db = init_database() because db may not exist yet. We need to check and control the response 95 96 $db = new Database(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); 96 97 97 if ($cage->get->getAlpha('type') == 'manual') { database_setup_manual(); } else { database_setup(); } 98 if ($cage->get->getAlpha('type') == 'manual') { 99 database_setup_manual(); 100 } else { 101 database_setup(); 102 } 98 103 } 99 104 break; 100 case 2: 105 case 2: 101 106 if ($action == 'upgrade') { 102 database_upgrade();107 database_upgrade(); 103 108 } else { 104 109 $db = init_database(); 105 database_creation(); // Creates the database tables110 database_creation(); // Creates the database tables 106 111 } 107 112 break; 108 case 3: 113 case 3: 109 114 if ($action == 'upgrade') { 110 115 upgrade_plugins(); 111 116 } else { 112 117 $db = init_database(); 113 register_admin(); // Username and password for Admin user...118 register_admin(); // Username and password for Admin user... 114 119 } 115 120 break; 116 121 case 4: 117 installation_complete(); // Delete "install" folder. Visit your site"122 installation_complete(); // Delete "install" folder. Visit your site" 118 123 break; 119 124 default: 120 125 // Anything other than step=1, 3 or 4 will return user to Step 0 121 126 installation_welcome(); 122 123 127 } 124 128 125 129 exit; 126 127 130 128 131 /** … … 141 144 142 145 // Title 143 $header .= "<TITLE>" . $lang['install_title'] ."</TITLE>\n";146 $header .= "<TITLE>".$lang['install_title']."</TITLE>\n"; 144 147 $header .= "<META HTTP-EQUIV='Content-Type' CONTENT='text'>\n"; 145 148 $header .= "<link rel='stylesheet' type='text/css' href='reset-fonts-grids.css' type='text/css'>\n"; … … 152 155 $header .= "<div id='hd' role='banner'>"; 153 156 $header .= "<img align='left' src='../content/admin_themes/admin_default/images/hotaru.png' style='height:60px; width:60px;'>"; 154 $header .= "<h1>" . $lang['install_title'] . " v." . $version_number."</h1></div>\n";157 $header .= "<h1>".$lang['install_title']." v.".$version_number."</h1></div>\n"; 155 158 $header .= "<div id='bd' role='main'>\n"; 156 159 $header .= "<div class='yui-g'>\n"; … … 158 161 return $header; 159 162 } 160 161 163 162 164 /** … … 170 172 171 173 $footer = "<div class='clear'></div>\n"; // clear floats 172 173 174 // Footer content (a link to the forums) 174 175 $footer .= "<div id='ft' role='contentinfo'>"; 175 $footer .= "<p>" . $lang['install_trouble'] ."</p>";176 $footer .= "<p>".$lang['install_trouble']."</p>"; 176 177 $footer .= "</div>\n"; // close "ft" div 177 178 … … 186 187 } 187 188 188 189 189 /** 190 190 * Step 0 of installation - Welcome message … … 197 197 198 198 // Step title 199 echo "<h2>" . $lang['install_step0'] ."</h2>\n";199 echo "<h2>".$lang['install_step0']."</h2>\n"; 200 200 201 201 // Step content 202 echo "<div class='install_content'>" . $lang['install_step0_welcome'] ."</div>\n";203 echo "<div class='install_content'>" . $lang['install_step0_select'] ."</div>\n";202 echo "<div class='install_content'>".$lang['install_step0_welcome']."</div>\n"; 203 echo "<div class='install_content'>".$lang['install_step0_select']."</div>\n"; 204 204 205 205 // Splash image … … 207 207 208 208 // Step content 209 echo "<div class='center clearfix'>"; 210 echo "<a class='select button floatright' href='index.php?step=1&action=upgrade'>" . $lang['install_upgrade'] ."</a>";211 echo "<a class='select button floatright' href='index.php?step=1&action=install'>" . $lang['install_new'] ."</a>";209 echo "<div class='center clearfix'>"; 210 echo "<a class='select button floatright' href='index.php?step=1&action=upgrade'>".$lang['install_upgrade']."</a>"; 211 echo "<a class='select button floatright' href='index.php?step=1&action=install'>".$lang['install_new']."</a>"; 212 212 echo "</div>"; 213 213 … … 218 218 } 219 219 220 221 /**Step 1 of installation 220 /* * Step 1 of installation 222 221 * 223 222 */ 224 function database_setup() { 223 224 function database_setup() 225 { 225 226 global $lang; //already included so Hotaru can't re-include it 226 227 global $db; 227 228 global $h; 228 global $cage;229 global $settings_file_exists;229 global $cage; 230 global $settings_file_exists; 230 231 231 232 //$h = new Hotaru(); // overwrites current global with fully initialized Hotaru object … … 234 235 if ($cage->post->KeyExists('updated')) { 235 236 236 $error = 0;237 // Test CSRF237 $error = 0; 238 // Test CSRF 238 239 // if (!$h->csrf('check', 'index')) { 239 240 // $h->messages[$lang['install_step3_csrf_error']] = 'red'; 240 241 // $error = 1; 241 242 // } 242 243 // Test baseurl 244 $baseurl_name = $cage->post->testUri('baseurl'); 245 if (!$baseurl_name) { 246 $h->messages[$lang['install_step1_baseurl_error']] = 'red'; 247 $error = 1; 248 } 249 250 // Test dbname 251 $dbuser_name = $cage->post->testAlnumLines('dbuser'); 252 if (!$dbuser_name) { 253 $h->messages[$lang['install_step1_dbuser_error']] = 'red'; 254 $error = 1; 255 } 256 257 // Test dbpassword 258 $dbpassword_name = $cage->post->KeyExists('dbpassword'); 259 if (!$dbpassword_name) { 260 $h->messages[$lang['install_step1_dbpassword_error']] = 'red'; 261 $error = 1; 262 } 263 264 // Test dbname 265 $dbname_name = $cage->post->testAlnumLines('dbname'); 266 if (!$dbname_name) { 267 $h->messages[$lang['install_step1_dbname_error']] = 'red'; 268 $error = 1; 269 } 270 271 // Test dbprefix 272 $dbprefix_name = $cage->post->testAlnumLines('dbprefix'); 273 if (!$dbprefix_name) { 274 $h->messages[$lang['install_step1_dbprefix_error']] = 'red'; 275 $error = 1; 276 } 277 278 // Test dbhost 279 $dbhost_name = $cage->post->testAlpha('dbhost'); 280 if (!$dbhost_name) { 281 $h->messages[$lang['install_step1_dbhost_error']] = 'red'; 282 $error = 1; 283 } 284 243 // Test baseurl 244 $baseurl_name = $cage->post->testUri('baseurl'); 245 if (!$baseurl_name) { 246 $h->messages[$lang['install_step1_baseurl_error']] = 'red'; 247 $error = 1; 248 } 249 250 // Test dbname 251 $dbuser_name = $cage->post->testAlnumLines('dbuser'); 252 if (!$dbuser_name) { 253 $h->messages[$lang['install_step1_dbuser_error']] = 'red'; 254 $error = 1; 255 } 256 257 // Test dbpassword 258 $dbpassword_name = $cage->post->KeyExists('dbpassword'); 259 if (!$dbpassword_name) { 260 $h->messages[$lang['install_step1_dbpassword_error']] = 'red'; 261 $error = 1; 262 } 263 264 // Test dbname 265 $dbname_name = $cage->post->testAlnumLines('dbname'); 266 if (!$dbname_name) { 267 $h->messages[$lang['install_step1_dbname_error']] = 'red'; 268 $error = 1; 269 } 270 271 // Test dbprefix 272 $dbprefix_name = $cage->post->testAlnumLines('dbprefix'); 273 if (!$dbprefix_name) { 274 $h->messages[$lang['install_step1_dbprefix_error']] = 'red'; 275 $error = 1; 276 } 277 278 // Test dbhost 279 $dbhost_name = $cage->post->testAlpha('dbhost'); 280 if (!$dbhost_name) { 281 $h->messages[$lang['install_step1_dbhost_error']] = 'red'; 282 $error = 1; 283 } 285 284 } else { 286 if ($settings_file_exists) {287 $dbuser_name = DB_USER;288 $dbname_name = DB_NAME;289 $dbpassword_name = DB_PASSWORD;290 $dbprefix_name = DB_PREFIX;291 $dbhost_name = DB_HOST;292 $baseurl_name = BASEURL;293 } else {294 $dbuser_name = 'admin';295 $dbname_name = 'hotaru';296 $dbpassword_name = '';297 $dbprefix_name = 'hotaru_';298 $dbhost_name = 'localhost';299 $baseurl_name = "http://"; // . $cage->server->sanitizeTags('HTTP_HOST') . "/";300 }285 if ($settings_file_exists) { 286 $dbuser_name = DB_USER; 287 $dbname_name = DB_NAME; 288 $dbpassword_name = DB_PASSWORD; 289 $dbprefix_name = DB_PREFIX; 290 $dbhost_name = DB_HOST; 291 $baseurl_name = BASEURL; 292 } else { 293 $dbuser_name = 'admin'; 294 $dbname_name = 'hotaru'; 295 $dbpassword_name = ''; 296 $dbprefix_name = 'hotaru_'; 297 $dbhost_name = 'localhost'; 298 $baseurl_name = "http://"; // . $cage->server->sanitizeTags('HTTP_HOST') . "/"; 299 } 301 300 } 302 301 … … 304 303 if ($cage->post->getAlpha('updated') == 'true') { 305 304 if (!$error) { 306 // Try to write file to disk based on form inputs307 $fputs = create_new_settings_file($dbuser_name, $dbpassword_name, $dbname_name, $dbprefix_name, $dbhost_name, $baseurl_name);308 // if file written successfully then309 if ($fputs) {310 $h->messages[$lang['install_step1_update_file_writing_success']] = 'green';311 // if yes set warning message var312 } else {313 $h->messages[$lang['install_step1_update_file_writing_failure']] = 'red';314 }315 } 316 @chmod(SETTINGS,0644);305 // Try to write file to disk based on form inputs 306 $fputs = create_new_settings_file($dbuser_name, $dbpassword_name, $dbname_name, $dbprefix_name, $dbhost_name, $baseurl_name); 307 // if file written successfully then 308 if ($fputs) { 309 $h->messages[$lang['install_step1_update_file_writing_success']] = 'green'; 310 // if yes set warning message var 311 } else { 312 $h->messages[$lang['install_step1_update_file_writing_failure']] = 'red'; 313 } 314 } 315 @chmod(SETTINGS, 0644); 317 316 } 318 317 319 318 // Check whether database and tables exist on this server 320 319 $db->show_errors = false; 321 $database_exists = $db->connect($dbuser_name, $dbpassword_name, $dbname_name, $dbhost_name); 320 $database_exists = $db->connect($dbuser_name, $dbpassword_name, $dbname_name, $dbhost_name); 322 321 if (!$database_exists) { 323 $h->messages[$lang['install_step1_no_db_exists_failure']] = 'red';322 $h->messages[$lang['install_step1_no_db_exists_failure']] = 'red'; 324 323 } else { 325 $show_next = true;326 $table_exists = $db->table_exists('miscdata');324 $show_next = true; 325 $table_exists = $db->table_exists('miscdata'); 327 326 } 328 327 329 328 // Try to write the /hotaru_settings.php file to disk 330 329 // 331 @chmod(SETTINGS,0777);332 333 $settings_file_writeable = is_writeable(SETTINGS);330 @chmod(SETTINGS, 0770); 331 332 $settings_file_writeable = is_writeable(SETTINGS); 334 333 335 334 if ($settings_file_writeable) { 336 global $lang; 337 338 echo html_header(); 339 340 $h->showMessages(); 341 342 // Step title 343 echo "<h2>" . $lang['install_step1'] . "</h2>\n"; 344 345 // Splash image 346 echo "<img align='center' src='../content/admin_themes/admin_default/images/create_db.png' style='float:left;'>"; 347 348 // Step content 349 echo "<div class='install_content clearfix'>" . $lang['install_step1_instructions_create_db'] . "</div>\n"; 350 351 //Manual creation link 352 echo "<div class='install_content clearfix' style='margin-left:54px;'>" . $lang['install_step1_instructions_manual_setup'] . " <a href='?step=1&action=install&type=manual'>" . $lang['install_step1_instructions_manual_setup_click'] . "</a>."; 353 354 // Registration form 355 echo "<form name='install_admin_reg_form' action='../install/index.php?step=1' method='post'>\n"; 356 357 echo "<br/><table>"; 358 359 // BASEURL 360 echo "<tr><td>" . $lang["install_step1_baseurl"] . " </td><td><input type='text' size=30 name='baseurl' value='" . $baseurl_name . "' /> <small>" . $lang["install_step1_baseurl_explain"] . "</small></td></tr>\n"; 361 362 // DB_USER 363 echo "<tr><td>" . $lang["install_step1_dbuser"] . " </td><td><input type='text' size=30 name='dbuser' value='" . $dbuser_name . "' /> <small>" . $lang["install_step1_dbuser_explain"] . "</small></td></tr>\n"; 364 365 // DB_PASSWORD 366 echo "<tr><td>" . $lang["install_step1_dbpassword"] . " </td><td><input type='password' size=30 name='dbpassword' value='" . $dbpassword_name . "' /> <small>" . $lang["install_step1_dbpassword_explain"] . "</small></td></tr>\n"; 367 368 // DB_NAME 369 echo "<tr><td>" . $lang["install_step1_dbname"] . " </td><td><input type='text' size=30 name='dbname' value='" . $dbname_name . "' /> <small>" . $lang["install_step1_dbname_explain"] . "</small></td></tr>\n"; 370 371 // DB_PREFIX 372 echo "<tr><td>" . $lang["install_step1_dbprefix"] . " </td><td><input type='text' size=30 name='dbprefix' value='" . $dbprefix_name . "' /> <small>" . $lang["install_step1_dbprefix_explain"] . "</small></td></tr>\n"; 373 374 // DB_HOST 375 echo "<tr><td>" . $lang["install_step1_dbhost"] . " </td><td><input type='text' size=30 name='dbhost' value='" . $dbhost_name . "' /> <small>" . $lang["install_step1_dbhost_explain"] . "</small></td></tr>\n"; 376 377 378 echo "<input type='hidden' name='csrf' value='" . $h->csrfToken . "' />\n"; 379 echo "<input type='hidden' name='step' value='2' />\n"; 380 echo "<input type='hidden' name='updated' value='true' />\n"; 381 382 // Update button 383 echo "<tr><td> </td><td style='text-align:right;'><input class='update button' class='button' type='submit' value='" . $lang['install_step3_form_update'] . "' /></td></tr>\n"; 384 385 echo "</table>"; 386 echo "</form>\n"; 387 388 if ($cage->post->getAlpha('updated') != 'true' && SETTINGS) { 389 // Alert if Settings file already exists 390 echo "<br/><img align='center' src='../content/admin_themes/admin_default/images/delete.png' style='float:left;'>"; 391 echo $lang["install_step1_settings_file_already_exists"] . "</div><br/>"; 392 } 393 394 if (isset($table_exists) && ($table_exists)) { 395 // Alert if database already exists 396 echo "<br/><img align='center' src='../content/admin_themes/admin_default/images/delete.png' style='float:left;'>"; 397 echo $lang["install_step1_settings_db_already_exists"] . "</div><br/>"; 398 } 399 400 // Previous/Next buttons 401 echo "<div class='back button''><a href='index.php?step=0'>" . $lang['install_back'] . "</a></div>\n"; 402 403 if ($show_next) { 404 // and if db was connected ok 405 echo "<div class='next button''><a href='index.php?step=2'>" . $lang['install_next'] . "</a></div>\n"; 406 } else { 407 // link disbaled 408 echo "<div class='next button''>" . $lang['install_next'] . "</div>\n"; 409 } 410 411 echo html_footer(); 412 335 global $lang; 336 337 echo html_header(); 338 339 $h->showMessages(); 340 341 // Step title 342 echo "<h2>".$lang['install_step1']."</h2>\n"; 343 344 // Splash image 345 echo "<img align='center' src='../content/admin_themes/admin_default/images/create_db.png' style='float:left;'>"; 346 347 // Step content 348 echo "<div class='install_content clearfix'>".$lang['install_step1_instructions_create_db']."</div>\n"; 349 350 //Manual creation link 351 echo "<div class='install_content clearfix' style='margin-left:54px;'>".$lang['install_step1_instructions_manual_setup']." <a href='?step=1&action=install&type=manual'>".$lang['install_step1_instructions_manual_setup_click']."</a>."; 352 353 // Registration form 354 echo "<form name='install_admin_reg_form' action='../install/index.php?step=1' method='post'>\n"; 355 356 echo "<br/><table>"; 357 358 // BASEURL 359 echo "<tr><td>".$lang["install_step1_baseurl"]." </td><td><input type='text' size=30 name='baseurl' value='".$baseurl_name."' /> <small>".$lang["install_step1_baseurl_explain"]."</small></td></tr>\n"; 360 361 // DB_USER 362 echo "<tr><td>".$lang["install_step1_dbuser"]." </td><td><input type='text' size=30 name='dbuser' value='".$dbuser_name."' /> <small>".$lang["install_step1_dbuser_explain"]."</small></td></tr>\n"; 363 364 // DB_PASSWORD 365 echo "<tr><td>".$lang["install_step1_dbpassword"]." </td><td><input type='password' size=30 name='dbpassword' value='".$dbpassword_name."' /> <small>".$lang["install_step1_dbpassword_explain"]."</small></td></tr>\n"; 366 367 // DB_NAME 368 echo "<tr><td>".$lang["install_step1_dbname"]." </td><td><input type='text' size=30 name='dbname' value='".$dbname_name."' /> <small>".$lang["install_step1_dbname_explain"]."</small></td></tr>\n"; 369 370 // DB_PREFIX 371 echo "<tr><td>".$lang["install_step1_dbprefix"]." </td><td><input type='text' size=30 name='dbprefix' value='".$dbprefix_name."' /> <small>".$lang["install_step1_dbprefix_explain"]."</small></td></tr>\n"; 372 373 // DB_HOST 374 echo "<tr><td>".$lang["install_step1_dbhost"]." </td><td><input type='text' size=30 name='dbhost' value='".$dbhost_name."' /> <small>".$lang["install_step1_dbhost_explain"]."</small></td></tr>\n"; 375 376 377 echo "<input type='hidden' name='csrf' value='".$h->csrfToken."' />\n"; 378 echo "<input type='hidden' name='step' value='2' />\n"; 379 echo "<input type='hidden' name='updated' value='true' />\n"; 380 381 // Update button 382 echo "<tr><td> </td><td style='text-align:right;'><input class='update button' class='button' type='submit' value='".$lang['install_step3_form_update']."' /></td></tr>\n"; 383 384 echo "</table>"; 385 echo "</form>\n"; 386 387 if ($cage->post->getAlpha('updated') != 'true' && SETTINGS) { 388 // Alert if Settings file already exists 389 echo "<br/><img align='center' src='../content/admin_themes/admin_default/images/delete.png' style='float:left;'>"; 390 echo $lang["install_step1_settings_file_already_exists"]."</div><br/>"; 391 } 392 393 if (isset($table_exists) && ($table_exists)) { 394 // Alert if database already exists 395 echo "<br/><img align='center' src='../content/admin_themes/admin_default/images/delete.png' style='float:left;'>"; 396 echo $lang["install_step1_settings_db_already_exists"]."</div><br/>"; 397 } 398 399 // Previous/Next buttons 400 echo "<div class='back button''><a href='index.php?step=0'>".$lang['install_back']."</a></div>\n"; 401 402 if ($show_next) { 403 // and if db was connected ok 404 echo "<div class='next button''><a href='index.php?step=2'>".$lang['install_next']."</a></div>\n"; 405 } else { 406 // link disbaled 407 echo "<div class='next button''>".$lang['install_next']."</div>\n"; 408 } 409 410 echo html_footer(); 413 411 } else { 414 @chmod(SETTINGS,0644); 415 database_setup_manual(); 416 } 417 418 } 419 412 @chmod(SETTINGS, 0644); 413 database_setup_manual(); 414 } 415 } 420 416 421 417 /** … … 429 425 430 426 // Step title 431 echo "<h2>" . $lang['install_step1'] ."</h2>\n";427 echo "<h2>".$lang['install_step1']."</h2>\n"; 432 428 433 429 // Step content 434 echo "<div class='install_content'>" . $lang['install_step1_instructions'] .":</div>\n";430 echo "<div class='install_content'>".$lang['install_step1_instructions'].":</div>\n"; 435 431 436 432 echo "<ol class='install_content'>\n"; 437 echo "<li>" . $lang['install_step1_instructions1'] ."</li>\n";438 echo "<li>" . $lang['install_step1_instructions2'] ."</li>\n";439 echo "<li>" . $lang['install_step1_instructions3'] ."</li>\n";440 echo "<li>" . $lang['install_step1_instructions4'] ."</li>\n";441 echo "<li>" . $lang['install_step1_instructions5'] ."</li>\n";433 echo "<li>".$lang['install_step1_instructions1']."</li>\n"; 434 echo "<li>".$lang['install_step1_instructions2']."</li>\n"; 435 echo "<li>".$lang['install_step1_instructions3']."</li>\n"; 436 echo "<li>".$lang['install_step1_instructions4']."</li>\n"; 437 echo "<li>".$lang['install_step1_instructions5']."</li>\n"; 442 438 echo "</ol>\n"; 443 439 444 440 // Warning message 445 441 echo "<br/><img align='center' src='../content/admin_themes/admin_default/images/delete.png' style='float:left;'>"; 446 echo "<div class='install_content'><span style='color: red;'>" . $lang['install_step1_warning'] . "</span>: " . $lang['install_step1_warning_note'] ."</div><br/>\n";442 echo "<div class='install_content'><span style='color: red;'>".$lang['install_step1_warning']."</span>: ".$lang['install_step1_warning_note']."</div><br/>\n"; 447 443 448 444 // Previous/Next buttons 449 echo "<div class='back button''><a href='index.php?step=0'>" . $lang['install_back'] ."</a></div>\n";450 echo "<div class='next button''><a href='index.php?step=2'>" . $lang['install_next'] ."</a></div>\n";445 echo "<div class='back button''><a href='index.php?step=0'>".$lang['install_back']."</a></div>\n"; 446 echo "<div class='next button''><a href='index.php?step=2'>".$lang['install_next']."</a></div>\n"; 451 447 452 448 echo html_footer(); … … 459 455 { 460 456 461 if (file_exists(SETTINGS)) { 462 include_once('install-upgrade.php'); 463 } 464 else { 465 echo 'You need to have a "hotaru_settings.php" file to upgrade Hotaru.'; 466 } 467 } 468 457 if (file_exists(SETTINGS)) { 458 include_once('install-upgrade.php'); 459 } else { 460 echo 'You need to have a "hotaru_settings.php" file to upgrade Hotaru.'; 461 } 462 } 469 463 470 464 /** … … 476 470 global $db; 477 471 global $cage; 478 479 $delete = $cage->get->getAlpha('del'); // Confirm delete.472 473 $delete = $cage->get->getAlpha('del'); // Confirm delete. 480 474 $show_next = false; 481 475 482 476 echo html_header(); 483 477 484 478 // Step title 485 echo "<h2>" . $lang['install_step2'] ."</h2>\n";486 487 $table_exists = $db->table_exists('miscdata'); 479 echo "<h2>".$lang['install_step2']."</h2>\n"; 480 481 $table_exists = $db->table_exists('miscdata'); 488 482 if ($table_exists && $delete != 'DELETE') { 489 483 // Warning message 490 484 echo "<br/><img align='center' src='../content/admin_themes/admin_default/images/delete.png' style='float:left;'>"; 491 echo "<div class='install_content'><span style='color: red;'>" . $lang['install_step1_warning'] . "</span>: " . $lang['install_step2_existing_db'] ."</div>\n";492 echo "<div class='install_content'>" . $lang['install_step2_existing_confirm'] ."</div>\n";485 echo "<div class='install_content'><span style='color: red;'>".$lang['install_step1_warning']."</span>: ".$lang['install_step2_existing_db']."</div>\n"; 486 echo "<div class='install_content'>".$lang['install_step2_existing_confirm']."</div>\n"; 493 487 494 488 // Confirm delete and continue install 495 echo "<form name='install_admin_reg_form' action='index.php?step=2' method='get'>\n";489 echo "<form name='install_admin_reg_form' action='index.php?step=2' method='get'>\n"; 496 490 echo "<div class='center clearfix'> <input type='text' size=10 name='del' value='' />"; 497 echo "<input type='hidden' name='csrf' value='" . $h->csrfToken ."' />\n";491 echo "<input type='hidden' name='csrf' value='".$h->csrfToken."' />\n"; 498 492 echo "<input type='hidden' name='step' value='2' />\n"; 499 500 echo "<input class='update button' class='button' type='submit' value='" . $lang['install_step2_form_delete_confirm'] ."' />";493 494 echo "<input class='update button' class='button' type='submit' value='".$lang['install_step2_form_delete_confirm']."' />"; 501 495 echo "</div></form>\n"; 502 496 503 echo "<div class='install_content'>" . $lang['install_step2_existing_go_upgrade1']; 504 echo "<a href='?step=1&action=upgrade'>" . $lang['install_step2_existing_go_upgrade2'] . "</a></div>\n"; 505 } 506 else { 507 508 $tables = array('blocked', 'categories', 'comments', 'friends', 'messaging', 'miscdata', 'plugins', 'pluginhooks', 'pluginsettings', 'posts', 'postmeta', 'postvotes', 'settings', 'tags', 'tempdata', 'tokens', 'users', 'usermeta', 'useractivity', 'widgets'); 509 510 // delete *all* tables in db: 511 $db->selectDB(DB_NAME); 512 513 514 515 // Used as test to check whether we have tables yet 497 echo "<div class='install_content'>".$lang['install_step2_existing_go_upgrade1']; 498 echo "<a href='?step=1&action=upgrade'>".$lang['install_step2_existing_go_upgrade2']."</a></div>\n"; 499 } else { 500 501 $tables = array('blocked', 'categories', 'comments', 'friends', 'messaging', 'miscdata', 'plugins', 'pluginhooks', 'pluginsettings', 'posts', 'postmeta', 'postvotes', 'settings', 'tags', 'tempdata', 'tokens', 'users', 'usermeta', 'useractivity', 'widgets'); 502 503 // delete *all* tables in db: 504 $db->selectDB(DB_NAME); 505 506 507 508 // Used as test to check whether we have tables yet 516 509 // $sql = "SELECT * FROM `" . DB_PREFIX . "miscdata`"; 517 510 // var_dump($db->get_results($sql)); die; 518 511 519 if ($db->get_col("SHOW TABLES",0)) {520 echo $lang['install_step2_checking_tables'];521 foreach ( $db->get_col("SHOW TABLES",0) as $table_name )522 {523 print $table_name . ', ';524 drop_table($table_name); // table name525 }526 echo '<br /><br />' . $lang['install_step2_deleting_table'] . "'...<br /><br />\n";527 } else {528 echo $lang['install_step2_no_tables'] . "<br/><br />\n";529 } 530 531 532 $create_tables_problem = false;533 //create tables534 foreach ($tables as $table_name) {535 $error = '';536 create_table($table_name);537 $error = mysql_error();538 if ($error) {539 echo $error .' ';540 $create_tables_problem = true;541 }542 }543 544 // Step content545 if (!$create_tables_problem) {546 echo "<div class='install_content'>" . $lang['install_step2_success'] ."</div>\n";547 } else {548 echo "<div class='install_content'>" . $lang['install_step2_fail'] ."</div>\n";549 }550 551 $show_next = true;512 if ($db->get_col("SHOW TABLES", 0)) { 513 echo $lang['install_step2_checking_tables']; 514 foreach ($db->get_col("SHOW TABLES", 0) as $table_name) { 515 print $table_name.', '; 516 drop_table($table_name); // table name 517 } 518 echo '<br /><br />'.$lang['install_step2_deleting_table']."'...<br /><br />\n"; 519 } else { 520 echo $lang['install_step2_no_tables']."<br/><br />\n"; 521 } 522 523 524 $create_tables_problem = false; 525 //create tables 526 foreach ($tables as $table_name) { 527 $error = ''; 528 create_table($table_name); 529 // @todo: the code in the following // comment, was generated by the MySQLi converter. I haven't spent the time to get it working, nor tested it. 530 $error = NULL; // ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)); 531 if ($error) { 532 echo $error.' '; 533 $create_tables_problem = true; 534 } 535 } 536 537 // Step content 538 if (!$create_tables_problem) { 539 echo "<div class='install_content'>".$lang['install_step2_success']."</div>\n"; 540 } else { 541 echo "<div class='install_content'>".$lang['install_step2_fail']."</div>\n"; 542 } 543 544 $show_next = true; 552 545 } 553 546 554 547 // Previous/Next buttons 555 echo "<div class='back button''><a href='index.php?step=1'>" . $lang['install_back'] ."</a></div>\n";548 echo "<div class='back button''><a href='index.php?step=1'>".$lang['install_back']."</a></div>\n"; 556 549 if ($show_next) { 557 550 // active "next" link 558 echo "<div class='next button''><a href='index.php?step=3'>" . $lang['install_next'] ."</a></div>\n";551 echo "<div class='next button''><a href='index.php?step=3'>".$lang['install_next']."</a></div>\n"; 559 552 } else { 560 553 // link disbaled 561 echo "<div class='next button''>" . $lang['install_next'] ."</div>\n";554 echo "<div class='next button''>".$lang['install_next']."</div>\n"; 562 555 } 563 556 564 557 echo html_footer(); 565 558 } 566 567 559 568 560 /** … … 576 568 // Make sure that the cache folders have been created before we call $h for the first time 577 569 // Since we have defined CACHE in install script, the normal Initialize script will think folders are already present 578 $dirs = array('debug_logs/' , 'db_cache/', 'css_js_cache/', 'html_cache/', 'rss_cache/', 'lang_cache/');570 $dirs = array('debug_logs/', 'db_cache/', 'css_js_cache/', 'html_cache/', 'rss_cache/', 'lang_cache/'); 579 571 580 572 foreach ($dirs as $dir) { 581 //print "checking where dir exists at " . CACHE . $dir . '<br/>';582 if (!is_dir(CACHE .$dir)) {583 //print "trying to create " . CACHE . $dir . '<br/>';584 mkdir(CACHE .$dir);585 }586 } 587 588 $h = new Hotaru(); // overwrites current global with fully initialized Hotaru object573 //print "checking where dir exists at " . CACHE . $dir . '<br/>'; 574 if (!is_dir(CACHE.$dir)) { 575 //print "trying to create " . CACHE . $dir . '<br/>'; 576 mkdir(CACHE.$dir); 577 } 578 } 579 580 $h = new Hotaru(); // overwrites current global with fully initialized Hotaru object 589 581 590 582 … … 592 584 593 585 // Step title 594 echo "<h2>" . $lang['install_step3'] ."</h2>\n";586 echo "<h2>".$lang['install_step3']."</h2>\n"; 595 587 596 588 // Step content 597 echo "<div class='install_content'>" . $lang['install_step3_instructions'] .":<br /><br />\n";589 echo "<div class='install_content'>".$lang['install_step3_instructions'].":<br /><br />\n"; 598 590 599 591 $error = 0; 600 if ($h->cage->post->getInt('step') == 4) 601 { 592 if ($h->cage->post->getInt('step') == 4) { 602 593 // Test CSRF 603 594 if (!$h->csrf()) { … … 663 654 if ($error == 0) { 664 655 665 $sql = "SELECT user_username FROM " . TABLE_USERS . " WHERE user_role = %s"; 666 667 if (!$admin_name = $h->db->get_var($h->db->prepare($sql, 'admin'))) 668 { 656 $sql = "SELECT user_username FROM ".TABLE_USERS." WHERE user_role = %s"; 657 658 if (!$admin_name = $h->db->get_var($h->db->prepare($sql, 'admin'))) { 669 659 // Insert default settings 670 $sql = "INSERT INTO " . TABLE_USERS ." (user_username, user_role, user_date, user_password, user_email, user_permissions) VALUES (%s, %s, CURRENT_TIMESTAMP, %s, %s, %s)";660 $sql = "INSERT INTO ".TABLE_USERS." (user_username, user_role, user_date, user_password, user_email, user_permissions) VALUES (%s, %s, CURRENT_TIMESTAMP, %s, %s, %s)"; 671 661 $h->db->query($h->db->prepare($sql, 'admin', 'admin', 'password', 'admin@example.com', serialize($h->currentUser->getDefaultPermissions($h, 'admin')))); 672 662 $user_name = 'admin'; 673 663 $user_email = 'admin@example.com'; 674 664 $user_password = 'password'; 675 } 676 else 677 { 665 } else { 678 666 $user_info = $h->currentUser->getUser($h, 0, $admin_name); 679 667 // On returning to this page via back or next, the fields are empty at this point, so... 680 if (!isset($user_name)) { $user_name = ""; } 681 if (!isset($user_email)){ $user_email = ""; } 682 if (!isset($user_password)) { $user_password = ""; } 668 if (!isset($user_name)) { 669 $user_name = ""; 670 } 671 if (!isset($user_email)) { 672 $user_email = ""; 673 } 674 if (!isset($user_password)) { 675 $user_password = ""; 676 } 683 677 if (($user_name != "") && ($user_email != "") && ($user_password != "")) { 684 678 // There's been a change so update... 685 $sql = "UPDATE " . TABLE_USERS ." SET user_username = %s, user_role = %s, user_date = CURRENT_TIMESTAMP, user_password = %s, user_email = %s, user_email_valid = %d WHERE user_role = %s";679 $sql = "UPDATE ".TABLE_USERS." SET user_username = %s, user_role = %s, user_date = CURRENT_TIMESTAMP, user_password = %s, user_email = %s, user_email_valid = %d WHERE user_role = %s"; 686 680 $h->db->query($h->db->prepare($sql, $user_name, 'admin', $user_password, $user_email, 1, 'admin')); 687 681 $next_button = true; … … 701 695 702 696 // Username 703 echo "<tr><td>" . $lang["install_step3_username"] . " </td><td><input type='text' size=30 name='username' value='" . $user_name ."' /></td></tr>\n";697 echo "<tr><td>".$lang["install_step3_username"]." </td><td><input type='text' size=30 name='username' value='".$user_name."' /></td></tr>\n"; 704 698 705 699 // Email 706 echo "<tr><td>" . $lang["install_step3_email"] . " </td><td><input type='text' size=30 name='email' value='" . $user_email ."' /></td></tr>\n";700 echo "<tr><td>".$lang["install_step3_email"]." </td><td><input type='text' size=30 name='email' value='".$user_email."' /></td></tr>\n"; 707 701 708 702 // Password 709 echo "<tr><td>" . $lang["install_step3_password"] ." </td><td><input type='password' size=30 name='password' value='' /></td></tr>\n";703 echo "<tr><td>".$lang["install_step3_password"]." </td><td><input type='password' size=30 name='password' value='' /></td></tr>\n"; 710 704 711 705 // Password verify 712 echo "<tr><td>" . $lang["install_step3_password_verify"] ." </td><td><input type='password' size=30 name='password2' value='' /></td></tr>\n";713 714 echo "<input type='hidden' name='csrf' value='" . $h->csrfToken ."' />\n";706 echo "<tr><td>".$lang["install_step3_password_verify"]." </td><td><input type='password' size=30 name='password2' value='' /></td></tr>\n"; 707 708 echo "<input type='hidden' name='csrf' value='".$h->csrfToken."' />\n"; 715 709 echo "<input type='hidden' name='step' value='4' />\n"; 716 710 echo "<input type='hidden' name='updated' value='true' />\n"; 717 711 718 712 // Update button 719 echo "<tr><td> </td><td style='text-align:right;'><input class='update button' class='button' type='submit' value='" . $lang['install_step3_form_update'] ."' /></td></tr>\n";713 echo "<tr><td> </td><td style='text-align:right;'><input class='update button' class='button' type='submit' value='".$lang['install_step3_form_update']."' /></td></tr>\n"; 720 714 721 715 echo "</table>"; … … 723 717 724 718 // Make note of password message 725 echo $lang["install_step3_make_note"] ."</div>\n";719 echo $lang["install_step3_make_note"]."</div>\n"; 726 720 727 721 // Previous/Next buttons 728 echo "<div class='back button''><a href='index.php?step=2'>" . $lang['install_back'] ."</a></div>\n";722 echo "<div class='back button''><a href='index.php?step=2'>".$lang['install_back']."</a></div>\n"; 729 723 if ($h->cage->post->getAlpha('updated') == 'true' && isset($next_button)) { 730 724 // active "next" link if user has been updated 731 echo "<div class='next button''><a href='index.php?step=4'>" . $lang['install_next'] ."</a></div>\n";725 echo "<div class='next button''><a href='index.php?step=4'>".$lang['install_next']."</a></div>\n"; 732 726 } else { 733 727 // link disbaled until "update" button pressed 734 echo "<div class='next button''>" . $lang['install_next'] ."</div>\n";728 echo "<div class='next button''>".$lang['install_next']."</div>\n"; 735 729 } 736 730 … … 738 732 } 739 733 740 741 734 /** 742 735 * Step 4 of installation - shows completion. … … 745 738 { 746 739 global $lang; 747 global $cage; 748 749 $h = new Hotaru(); // overwrites current global with fully initialized Hotaru object750 740 global $cage; 741 742 $h = new Hotaru(); // overwrites current global with fully initialized Hotaru object 743 751 744 $phpinfo = $cage->post->getAlpha('phpinfo'); 752 745 753 746 if (!$phpinfo) { 754 //send feedback report755 $systeminfo = new SystemInfo();756 $systeminfo->hotaru_feedback($h);747 //send feedback report 748 $systeminfo = new SystemInfo(); 749 $systeminfo->hotaru_feedback($h); 757 750 } 758 751 … … 760 753 761 754 // Step title 762 echo "<h2>" . $lang['install_step4'] ."</h2>\n";755 echo "<h2>".$lang['install_step4']."</h2>\n"; 763 756 764 757 // Step content 765 766 echo "<div class='install_content'>" . $lang['install_step4_installation_complete'] ."</div>\n";767 echo "<div class='install_content'>" . $lang['install_step4_installation_delete'] ."</div>\n";758 759 echo "<div class='install_content'>".$lang['install_step4_installation_complete']."</div>\n"; 760 echo "<div class='install_content'>".$lang['install_step4_installation_delete']."</div>\n"; 768 761 769 762 770 763 if ($phpinfo) { 771 echo '<br/>';772 $php_version = phpversion();773 $modules = get_loaded_extensions();774 $php_module_not_found = false;775 776 $required = array('mysql'=>'http://php.net/manual/en/book.mysql.php',777 'filter'=>'http://php.net/manual/en/book.filter.php',778 'curl'=>'http://php.net/manual/en/book.curl.php',779 'mbstring'=>'http://www.php.net/manual/en/book.mbstring.php');780 764 echo '<br/>'; 765 $php_version = phpversion(); 766 $modules = get_loaded_extensions(); 767 $php_module_not_found = false; 768 769 $required = array('mysql' => 'http://php.net/manual/en/book.mysql.php', 770 'filter' => 'http://php.net/manual/en/book.filter.php', 771 'curl' => 'http://php.net/manual/en/book.curl.php', 772 'mbstring' => 'http://www.php.net/manual/en/book.mbstring.php'); 773 781 774 /* No longer required: 'bcmath' => 'http://php.net/manual/en/book.bc.php' */ 782 775 783 foreach ($required as $module => $url) { 784 if (!in_array($module, $modules)) { 785 echo $h->showMessage($lang['install_step4_form_check_php_warning'] . '<a href="' . $url . '" target="_blank">' . $module . '</a><br/>','yellow'); 786 $php_module_not_found = true; 787 } 788 } 789 // check for correct version number of php 790 if (version_compare($php_version, '5.2.5', '<')) { echo $h->showMessage($lang['install_step4_form_check_php_version'], 'yellow'); } 791 792 // success of modules 793 if (!$php_module_not_found) { 794 echo $h->showMessage($lang['install_step4_form_check_php_success'], 'green'); 795 } 776 foreach ($required as $module => $url) { 777 if (!in_array($module, $modules)) { 778 echo $h->showMessage($lang['install_step4_form_check_php_warning'].'<a href="'.$url.'" target="_blank">'.$module.'</a><br/>', 'yellow'); 779 $php_module_not_found = true; 780 } 781 } 782 // check for correct version number of php 783 if (version_compare($php_version, '5.2.5', '<')) { 784 echo $h->showMessage($lang['install_step4_form_check_php_version'], 'yellow'); 785 } 786 787 // success of modules 788 if (!$php_module_not_found) { 789 echo $h->showMessage($lang['install_step4_form_check_php_success'], 'green'); 790 } 796 791 } else { 797 echo "<form name='install_admin_reg_form' action='index.php?step=4' method='post'>\n";798 echo "<input type='hidden' name='phpinfo' value='true' />";799 echo "<input type='hidden' name='step' value='4' />";800 echo "<input class='update button' type='submit' value='" . $lang['install_step4_form_check_php'] ."' />";801 echo "</div></form>\n";802 } 803 804 echo "<br/><div class='install_content'>" . $lang['install_step4_installation_go_play'] ."</div><br/><br/>\n";792 echo "<form name='install_admin_reg_form' action='index.php?step=4' method='post'>\n"; 793 echo "<input type='hidden' name='phpinfo' value='true' />"; 794 echo "<input type='hidden' name='step' value='4' />"; 795 echo "<input class='update button' type='submit' value='".$lang['install_step4_form_check_php']."' />"; 796 echo "</div></form>\n"; 797 } 798 799 echo "<br/><div class='install_content'>".$lang['install_step4_installation_go_play']."</div><br/><br/>\n"; 805 800 806 801 // Previous/Next buttons 807 echo "<div class='back button''><a href='index.php?step=3'>" . $lang['install_back'] ."</a></div>\n";808 echo "<div class='next button''><a href='" . BASEURL . "admin_index.php'>" . $lang['install_home'] ."</a></div>\n";802 echo "<div class='back button''><a href='index.php?step=3'>".$lang['install_back']."</a></div>\n"; 803 echo "<div class='next button''><a href='".BASEURL."admin_index.php'>".$lang['install_home']."</a></div>\n"; 809 804 810 805 echo html_footer(); 811 806 } 812 807 813 814 808 /** 815 809 * create new settings file 816 810 */ 817 function create_new_settings_file($dbuser_name, $dbpassword_name, $dbname_name, $dbprefix_name, $dbhost_name, $baseurl_name) { 818 819 ob_start(); 820 821 ?> 822 823 /* Configuration file for Hotaru CMS. */ 824 825 // Paths 826 define("BASEURL", '<?php echo $baseurl_name; ?>'); // e.g. http://www.mysite.com/ Needs trailing slash (/) 827 828 // Database details 829 define("DB_USER", '<?php echo $dbuser_name; ?>'); // Add your own database details 830 define("DB_PASSWORD", '<?php echo $dbpassword_name; ?>'); 831 define("DB_NAME", '<?php echo $dbname_name; ?>'); 832 define("DB_HOST", '<?php echo $dbhost_name; ?>'); // You probably won't need to change this 833 834 // You probably don't need to change these 835 define("DB_PREFIX", '<?php echo $dbprefix_name; ?>'); // Database prefix, e.g. "hotaru_" 836 define("DB_LANG", 'en'); // Database language, e.g. "en" 837 define("DB_ENGINE", 'MyISAM'); // Database Engine, e.g. "MyISAM" 838 define('DB_CHARSET', 'utf8'); // Database Character Set (UTF8 is Recommended), e.g. "utf8" 839 define("DB_COLLATE", 'utf8_unicode_ci'); // Database Collation (UTF8 is Recommended), e.g. "utf8_unicode_ci" 840 841 ?><?php // leave this line squashed up here as we dont want any blank lines at the end of the hotaru_settings file 842 $page = "<?php" . ob_get_contents(); 843 ob_end_clean(); 844 //$page = str_replace("\n", "", $page); 845 $cwd = getcwd(); 846 $file = $cwd . "/../hotaru_settings.php"; 847 @chmod($file,0777); 848 $fw = fopen($file, "w"); 849 $fputs = fputs($fw,$page, strlen($page)); 850 @chmod($file,0644); 851 fclose($fw); 852 853 return $fputs; 854 855 } 856 857 function add_DBPREFIX($table) { 858 return DB_PREFIX . $table; 859 } 811 function create_new_settings_file($dbuser_name, $dbpassword_name, $dbname_name, $dbprefix_name, $dbhost_name, $baseurl_name) 812 { 813 814 ob_start(); 860 815 ?> 816 817 /* Configuration file for Hotaru CMS. */ 818 819 // Paths 820 define("BASEURL", '<?php echo $baseurl_name; ?>'); // e.g. http://www.mysite.com/ Needs trailing slash (/) 821 822 // Database details 823 define("DB_USER", '<?php echo $dbuser_name; ?>'); // Add your own database details 824 define("DB_PASSWORD", '<?php echo $dbpassword_name; ?>'); 825 define("DB_NAME", '<?php echo $dbname_name; ?>'); 826 define("DB_HOST", '<?php echo $dbhost_name; ?>'); // You probably won't need to change this 827 828 // You probably don't need to change these 829 define("DB_PREFIX", '<?php echo $dbprefix_name; ?>'); // Database prefix, e.g. "hotaru_" 830 define("DB_LANG", 'en'); // Database language, e.g. "en" 831 define("DB_ENGINE", 'MyISAM'); // Database Engine, e.g. "MyISAM" 832 define('DB_CHARSET', 'utf8'); // Database Character Set (UTF8 is Recommended), e.g. "utf8" 833 define("DB_COLLATE", 'utf8_unicode_ci'); // Database Collation (UTF8 is Recommended), e.g. "utf8_unicode_ci" 834 835 ?><?php 836 // leave this line squashed up here as we dont want any blank lines at the end of the hotaru_settings file 837 $page = "<?php".ob_get_contents(); 838 ob_end_clean(); 839 //$page = str_replace("\n", "", $page); 840 $cwd = getcwd(); 841 $file = $cwd."/../hotaru_settings.php"; 842 @chmod($file, 0777); 843 $fw = fopen($file, "w"); 844 $fputs = fputs($fw, $page, strlen($page)); 845 @chmod($file, 0644); 846 fclose($fw); 847 848 return $fputs; 849 } 850 851 function add_DBPREFIX($table) 852 { 853 return DB_PREFIX.$table; 854 } 855 ?> -
branches/1.5/libs/AdminPages.php
r2292 r2295 389 389 } 390 390 391 $h->db->selectDB(DB_NAME);392 393 391 if (!$h->db->get_col("SHOW TABLES", 0)) { 394 392 return $db_tables; -
branches/1.5/libs/Database.php
r2292 r2295 6 6 * PHP version 5 7 7 * 8 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as 10 * published by the Free Software Foundation, either version 3 of 11 * the License, or (at your option) any later version. 8 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as 10 * published by the Free Software Foundation, either version 3 of 11 * the License, or (at your option) any later version. 12 12 * 13 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 * FITNESS FOR A PARTICULAR PURPOSE. 13 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15 * FITNESS FOR A PARTICULAR PURPOSE. 16 16 * 17 * You should have received a copy of the GNU General Public License along 17 * You should have received a copy of the GNU General Public License along 18 18 * with Hotaru CMS. If not, see http://www.gnu.org/licenses/. 19 * 19 * 20 20 * @category Content Management System 21 21 * @package HotaruCMS … … 25 25 * @link http://www.hotarucms.org/ 26 26 */ 27 class Database {28 29 public $h; 27 class Database 28 { 29 30 30 public $dbh; 31 31 public $dbuser = false; … … 36 36 public $cache_timeout = 24; // hours 37 37 public $cache_queries = false; 38 public $cache_inserts= false;39 38 public $use_disk_cache; 40 public $func_call;41 39 public $last_result = array(); 42 40 public $last_error; 43 41 public $last_query; 44 public $from_disk_cache; 45 public $captured_errors = array(); 42 private $from_disk_cache; 46 43 public $num_queries = 0; 47 44 public $num_rows = 0; 48 public $queries = array();49 45 public $result; 50 46 public $rows_affected; 51 47 public $col_info = array(); 52 public $show_errors = true; 53 private $error_str = array( 54 1 => 'Require $dbuser and $dbpassword to connect to a database server', 55 2 => 'Error establishing mySQL database connection. Correct user/password? Correct hostname? Database server running?', 56 3 => 'Require $dbname to select a database', 57 4 => 'mySQL database connection is not active', 58 5 => 'Unexpected error while trying to select database' 59 ); 60 61 public function __construct($dbuser='', $dbpassword='', $dbname='', $dbhost='localhost') 62 { 63 $this->dbuser = $dbuser; 64 $this->dbpassword = $dbpassword; 48 49 public function __construct($user, $pass, $dbname, $host='127.0.0.1') 50 { 51 $this->dbuser = $user; 52 $this->dbpassword = $pass; 65 53 $this->dbname = $dbname; 66 $this->dbhost = $ dbhost;54 $this->dbhost = $host; 67 55 } 68 56 … … 76 64 * @return boolean 77 65 */ 78 public function connect($dbuser='', $dbpassword='', $dbhost='localhost') 79 { 80 // Must have a user and a password 81 if (!$dbuser) { 82 $this->register_error($this->error_str[1].' in '.__FILE__.' on line '.__LINE__); 83 if ($this->show_errors) { 84 trigger_error($this->error_str[1], E_USER_WARNING); 85 } 66 public function connect() 67 { 68 $this->dbh = new mysqli($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname); 69 70 if (mysqli_connect_error ()) { 71 trigger_error('Connect Error ('.mysqli_connect_errno().') '.mysqli_connect_error(), E_USER_ERROR); 86 72 return FALSE; 87 73 } 88 74 89 // Try to establish the server database handle 90 if (!$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword, true)) { 91 $this->register_error($this->error_str[2].' in '.__FILE__.' on line '.__LINE__); 92 if ($this->show_errors) { 93 trigger_error($this->error_str[2], E_USER_WARNING); 94 } 75 if (!$this->dbh->set_charset('utf8')) { 76 trigger_error('Error setting character set to "utf8"'); 95 77 return FALSE; 96 78 } 97 79 98 $this->dbuser = $dbuser;99 $this->dbpassword = $dbpassword;100 $this->dbhost = $dbhost;101 80 return TRUE; 102 81 } … … 106 85 * 107 86 * @param string $query 108 * @return mixed 87 * @return mixed 109 88 */ 110 89 public function query($query = '') … … 115 94 116 95 // Flush cached values.. 117 $this->flush(); 96 $this->last_result = array(); 97 $this->col_info = null; 98 $this->last_query = null; 99 $this->from_disk_cache = false; 118 100 119 101 // For reg expressions 120 102 $query = trim($query); 121 122 // Log how the function was called123 $this->func_call = "\$db->query(\"$query\")";124 103 125 104 // Keep track of the last query for debug.. … … 134 113 // but rarely returns anything! 135 114 // Use core file cache function 136 if ($cache = $this->get_cache($query)) { 115 $cache = $this->get_cache($query); 116 if ($cache) { 137 117 return $cache; 138 118 } … … 142 122 143 123 // If there is no existing database connection then try to connect 144 if (!isset($this->dbh) || !$this->dbh) { 145 $this->connect($this->dbuser, $this->dbpassword, $this->dbhost); 146 $this->selectDB($this->dbname); 124 if (!($this->dbh instanceof mysqli)) { 125 $this->connect(); 147 126 } 148 127 149 128 // Perform the query via std mysql_query function.. 150 $this->result = @mysql_query($query, $this->dbh); 151 152 if (defined('SAVEQUERIES') && SAVEQUERIES) { // Borrowed from Wordpress 153 $this->queries[] = array($query, $this->timer_stop(), $this->get_caller()); 154 } 155 129 $this->result = mysqli_query($this->dbh, $query); 156 130 // If there is an error then take note of it.. 157 if ($str = @mysql_error($this->dbh)) { 158 if (defined('DEBUG') && (DEBUG == 'true')) { 159 $subject = SITE_NAME." Database Error"; 160 $body = SITE_NAME." Database Error\r\n\r\n"; 161 $body .= "Date: ".date('d M Y H:i:s')." (timezone: ".date_default_timezone_get().")\r\n\r\n"; 162 $body .= "SQL query:\r\n"; 163 $body .= $query."\r\n\r\n"; 164 $body .= "PHP error log:\r\n"; 165 $body .= $str."\r\n\r\n"; 166 167 if (isset($this->h)) { 168 $body .= "Current User: ".$this->h->currentUser->name." (id: ".$this->h->currentUser->id.")\r\n"; 169 $body .= "User Role: ".$this->h->currentUser->role."\r\n"; 170 $body .= "Page Name: ".$this->h->pageName."\r\n"; 171 $body .= "Sub Page: ".$this->h->subPage."\r\n"; 172 $body .= "Plugin: ".$this->h->plugin->folder."\r\n\r\n"; 173 } 174 175 $body .= "If you need help, visit the forums at http://hotarucms.org\r\n"; 176 EmailFunctions::email( SITE_NAME.' <'.SITE_EMAIL.'>', $subject, $body, SITE_NAME.' <'.SITE_EMAIL.'>'); 177 } 178 179 $is_insert = true; 180 $this->register_error($str); 181 if ($this->show_errors) { 182 trigger_error($str, E_USER_WARNING); 183 } 184 return false; 131 if ($this->result === FALSE) { 132 trigger_error('Query error ('.$this->dbh->errno.') '.$this->dbh->error, E_USER_WARNING); 133 return FALSE; 185 134 } 186 135 … … 188 137 $is_insert = false; 189 138 if (preg_match("/^(insert|delete|update|replace)\s+/i", $query)) { 190 $this->rows_affected = @mysql_affected_rows();139 $this->rows_affected = $this->dbh->affected_rows; 191 140 192 141 // Take note of the insert_id 193 142 if (preg_match("/^(insert|replace)\s+/i", $query)) { 194 $this->insert_id = @mysql_insert_id($this->dbh);143 $this->insert_id = $this->dbh->insert_id; 195 144 } 196 145 197 146 // Return number fo rows affected 198 147 $return_val = $this->rows_affected; 199 } 200 // Query was a select 201 else { 202 203 // Take note of column info 204 $i = 0; 205 if (is_resource($this->result)) { 206 while ($i < @mysql_num_fields($this->result)) { 207 $this->col_info[$i] = @mysql_fetch_field($this->result); 208 $i++; 148 } else { // Query was a select 149 // Store Query Results 150 if ($this->result instanceof mysqli_result) { 151 while ($row = $this->result->fetch_object()) { 152 // Store relults as an objects within main array 153 $this->last_result[] = $row; 209 154 } 210 } 211 212 // Store Query Results 213 $num_rows = 0; 214 if (is_resource($this->result)) { 215 while ($row = @mysql_fetch_object($this->result)) { 216 // Store relults as an objects within main array 217 $this->last_result[$num_rows] = $row; 218 $num_rows++; 219 } 220 } 221 222 if (is_resource($this->result)) { 223 @mysql_free_result($this->result); 224 } 225 226 // Log number of rows the query returned 227 $this->num_rows = $num_rows; 228 229 // Return number of rows selected 230 $return_val = $this->num_rows; 155 156 // Store and return the number of rows the query returned 157 $return_val = $this->num_rows = $this->result->num_rows; 158 159 $this->result->free(); 160 } 231 161 } 232 162 … … 247 177 public function escape($str = '') 248 178 { 249 return mysql _escape_string(stripslashes($str));179 return mysqli_real_escape_string($this->dbh, $str); 250 180 } 251 181 … … 256 186 * @return mixed Sanitized query string or NULL 257 187 */ 258 public function prepare($args=null) 259 { 260 261 if (is_null($args)) 262 return; 188 public function prepare() 189 { 190 191 if (func_num_args() === 0) { 192 return NULL; 193 } 263 194 264 195 $args = func_get_args(); … … 272 203 $query = array_shift($args); 273 204 274 // in case someone mistakenly already singlequoted it 275 $query = str_replace("'%s'", '%s', $query); 276 277 $query = str_replace('"%s"', '%s', $query); // doublequote unquoting 278 279 $query = str_replace('%s', "'%s'", $query); // quote the strings 205 // In case someone mistakenly already singlequoted it, remove the single quotes, 206 // next remove the double quotes, next singlequote %s occurences 207 $query = str_replace('%s', "'%s'", str_replace('"%s"', '%s', str_replace("'%s'", '%s', $query))); // quote the strings 280 208 281 209 foreach ($args as $i => $arg) { 282 $args[$i] = $this->escape($arg); 283 } 284 285 return @vsprintf($query, $args); 210 $args[$i] = $this->dbh->escape_string($arg); 211 } 212 213 // Assign the values to their placeholders in the query. 214 $query = vsprintf($query, $args); 215 216 return $query; 286 217 } 287 218 … … 294 225 * @return mixed 295 226 */ 296 public function get_var($query=null, $col=0, $row=0) 297 { 298 299 // Log how the function was called 300 $this->func_call = "\$db->get_var(\"$query\",$col,$row)"; 301 227 public function get_var($query = NULL, $col = 0, $row = 0) 228 { 302 229 // If there is a query then perform it if not then use cached results.. 303 230 if ($query) { … … 306 233 307 234 // Extract var out of cached results based col,row vals 308 if ($this->last_result[$row]) { 309 unset($this->last_result['CLASSNAME']); 235 if (isset($this->last_result[$row])) { 310 236 $values = array_values(get_object_vars($this->last_result[$row])); 311 237 } 312 238 313 239 // If there is a value return it else return null 314 return (isset($values[$col]) && $values[$col] !== '') ? $values[$col] : null;240 return (isset($values[$col]) && $values[$col] !== '') ? $values[$col] : NULL; 315 241 } 316 242 … … 323 249 * @return mixed 324 250 */ 325 public function get_row($query=null, $output='OBJECT', $row=0) 326 { 327 328 // Log how the function was called 329 $this->func_call = "\$db->get_row(\"$query\",$output,$row)"; 251 public function get_row($query = NULL, $output = 'OBJECT', $row = 0) 252 { 330 253 331 254 // If there is a query then perform it if not then use cached results.. … … 336 259 // If the output is an object then return object using the row offset.. 337 260 if ($output == 'OBJECT') { 338 return $this->last_result[$row]? $this->last_result[$row] : null;261 return isset($this->last_result[$row]) ? $this->last_result[$row] : null; 339 262 } 340 263 // If the output is an associative array then return row as such.. … … 359 282 * @return array 360 283 */ 361 public function get_col($query =null, $col=0)284 public function get_col($query = NULL, $col = 0) 362 285 { 363 286 $ret = array(); … … 384 307 * @return mixed 385 308 */ 386 public function get_results($query=null, $output = 'OBJECT') 387 { 388 389 // Log how the function was called 390 $this->func_call = "\$db->get_results(\"$query\", $output)"; 309 public function get_results($query = NULL, $output = 'OBJECT') 310 { 391 311 392 312 // If there is a query then perform it if not then use cached results.. … … 420 340 421 341 /** 422 * Connect to a database.423 *424 * @param string $dbname425 * @return boolean426 */427 public function selectDB($dbname='')428 {429 $return_val = false;430 431 // Must have a database name432 if (!$dbname) {433 $this->register_error($this->error_str[3].' in '.__FILE__.' on line '.__LINE__);434 if ($this->show_errors) {435 trigger_error($this->error_str[3], E_USER_WARNING);436 }437 }438 439 // Must have an active database connection440 else if (!$this->dbh) {441 $this->register_error($this->error_str[4].' in '.__FILE__.' on line '.__LINE__);442 if ($this->show_errors) {443 trigger_error($this->error_str[4], E_USER_WARNING);444 }445 }446 447 // Try to connect to the database448 else if (!@mysql_select_db($dbname, $this->dbh)) {449 // Try to get error supplied by mysql if not use our own450 if (!$str = @mysql_error($this->dbh)) {451 $str = $this->error_str[5];452 }453 454 $this->register_error($str.' in '.__FILE__.' on line '.__LINE__);455 if ($this->show_errors) {456 trigger_error($str, E_USER_WARNING);457 }458 } else {459 $this->dbname = $dbname;460 $return_val = true;461 }462 463 return $return_val;464 }465 466 /**467 * Set the global Hotaru object468 *469 * @param Hotaru $h The Hotaru instance470 */471 public function setHotaru($h)472 {473 $this->h = $h;474 }475 476 477 /**478 342 * Check if table exists 479 343 * 480 * @param string $table 2check344 * @param string $table_name 481 345 * @return bool 482 346 * 483 347 * Notes: This is a custom function for Hotaru CMS 484 348 */ 485 public function table_exists($table 2check)349 public function table_exists($table_name) 486 350 { 487 351 $tables = $this->get_col("SHOW TABLES", 0); 488 return (bool) in_array(DB_PREFIX.$table2check, $tables); 489 } 490 491 /** 492 * Check if table empty 493 * 494 * @param string $table2check 495 * @return bool 496 * 497 * Notes: This is a custom function for Hotaru CMS 498 */ 499 public function table_empty($table2check) 500 { 501 $rowcount = $this->get_var($this->prepare("SELECT COUNT(*) FROM ".DB_PREFIX.$table2check)); 502 return (!(bool) ($rowcount && $rowcount > 0)); 352 return (bool) in_array(DB_PREFIX.$table_name, $tables); 503 353 } 504 354 … … 506 356 * Check if table column exists 507 357 * 508 * @param string $table 2check358 * @param string $table_name 509 359 * @param string $column 510 360 * @return bool … … 512 362 * Notes: This is a custom function for Hotaru CMS 513 363 */ 514 public function column_exists($table 2check, $column)515 { 516 $sql = "SHOW COLUMNS FROM ".DB_PREFIX.$table 2check;364 public function column_exists($table_name, $column) 365 { 366 $sql = "SHOW COLUMNS FROM ".DB_PREFIX.$table_name; 517 367 foreach ($this->get_col($sql, 0) as $column_name) { 518 368 if ($column_name == $column) { … … 524 374 } 525 375 526 527 376 /** 528 377 * Store a result to the cache … … 535 384 536 385 // disk caching of queries 537 if ($this->use_disk_cache && ( $this->cache_queries && !$is_insert ) || ( $this->cache_inserts && $is_insert )) {386 if ($this->use_disk_cache && ( $this->cache_queries && !$is_insert )) { 538 387 if (!is_dir($this->cache_dir)) { 539 $this->register_error("Could not open cache dir: $this->cache_dir"); 540 if ($this->show_errors) { 541 trigger_error('Could not open cache dir: '.$this->cache_dir, E_USER_WARNING); 542 } 543 } else { 544 545 // Cache all result values 546 $result_cache = array( 547 'col_info' => $this->col_info, 548 'last_result' => $this->last_result, 549 'num_rows' => $this->num_rows, 550 'return_value' => ($this->num_rows == 0) ? 'empty' : $this->num_rows, 551 ); 552 553 error_log('<?php die(); ?>'.serialize($result_cache), 3, $this->cache_dir.'/'.md5($query).'.php'); 554 } 388 trigger_error('Could not open cache dir: '.$this->cache_dir, E_USER_WARNING); 389 return FALSE; 390 } 391 392 // Cache all result values 393 $result_cache = array( 394 'last_result' => $this->last_result, 395 'num_rows' => $this->num_rows, 396 'return_value' => ($this->num_rows == 0) ? 'empty' : $this->num_rows, 397 ); 398 error_log('<?php die(); ?>'.serialize($result_cache), 3, $this->cache_dir.'/'.md5($query).'.php'); 555 399 } 556 400 } … … 577 421 $result_cache = unserialize(file_get_contents($cache_file, NULL, NULL, 15)); 578 422 579 $this->col_info = $result_cache['col_info'];580 423 $this->last_result = $result_cache['last_result']; 581 424 $this->num_rows = $result_cache['num_rows']; … … 588 431 } 589 432 590 /**591 * Print SQL/DB error - over-ridden by specific DB class592 *593 * @param string $err_str594 */595 private function register_error($err_str)596 {597 // Keep track of last error598 $this->last_error = $err_str;599 600 // Capture all errors to an error array no matter what happens601 $this->captured_errors[] = array (602 'error_str' => $err_str,603 'query' => $this->last_query604 );605 }606 607 /**608 * Kill cached query results609 */610 private function flush()611 {612 // Get rid of these613 $this->last_result = null;614 $this->col_info = null;615 $this->last_query = null;616 $this->from_disk_cache = false;617 }618 619 /**620 * Fill Database Object621 *622 * @param array $select - associative array of select terms623 * @param string $table - full table name including prefix624 * @param array $where - associative array of where terms, e.g. array('id = %d' = 5, 'name = %s' = 'tony')625 * @param string $orderby - e.g. "post_date DESC"626 * @param string $limit - e.g. "10" or "5, 10"627 * @param bool $cache - cache results628 * @param bool $query_only - return just the query, not the results?629 */630 private function fillObject($select = array(), $table = '', $where = array(), $orderby = '', $limit = '', $cache = FALSE, $query_only = FALSE)631 {632 if ($select) {633 $this->select = $select;634 }635 if ($table) {636 $this->table = $table;637 }638 if ($where) {639 $this->where = $where;640 }641 if ($orderby) {642 $this->orderby = $orderby;643 }644 if ($limit) {645 $this->limit = $limit;646 }647 if ($cache) {648 $this->cache = true;649 } else {650 $this->cache = false;651 }652 if ($query_only) {653 $this->query_only = true;654 } else {655 $this->query_only = false;656 }657 }658 433 } -
branches/1.5/libs/extensions/Inspekt/Inspekt.php
r2258 r2295 1188 1188 //no explicit func to check if the connection is live, but if it's not $conn would be false 1189 1189 if (isset($conn) && is_resource($conn)) { 1190 return mysql_real_escape_string($value, $conn); 1191 } else { 1192 return mysql_real_escape_string($value); 1190 return mysqli_real_escape_string( $conn, $value); 1193 1191 } 1194 1192 } -
branches/1.5/libs/extensions/SimplePie/simplepie.php
r2175 r2295 43 43 * @todo phpDoc comments 44 44 */ 45 46 45 /** 47 46 * SimplePie Name … … 69 68 * @see SimplePie::set_useragent() 70 69 */ 71 define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION . ' (Feed Parser; ' . SIMPLEPIE_URL . '; Allow like Gecko) Build/' .SIMPLEPIE_BUILD);70 define('SIMPLEPIE_USERAGENT', SIMPLEPIE_NAME.'/'.SIMPLEPIE_VERSION.' (Feed Parser; '.SIMPLEPIE_URL.'; Allow like Gecko) Build/'.SIMPLEPIE_BUILD); 72 71 73 72 /** 74 73 * SimplePie Linkback 75 74 */ 76 define('SIMPLEPIE_LINKBACK', '<a href="' . SIMPLEPIE_URL . '" title="' . SIMPLEPIE_NAME . ' ' . SIMPLEPIE_VERSION . '">' . SIMPLEPIE_NAME .'</a>');75 define('SIMPLEPIE_LINKBACK', '<a href="'.SIMPLEPIE_URL.'" title="'.SIMPLEPIE_NAME.' '.SIMPLEPIE_VERSION.'">'.SIMPLEPIE_NAME.'</a>'); 77 76 78 77 /** … … 396 395 class SimplePie 397 396 { 397 398 398 /** 399 399 * @var array Raw data … … 401 401 */ 402 402 var $data = array(); 403 404 403 /** 405 404 * @var mixed Error string … … 407 406 */ 408 407 var $error; 409 410 408 /** 411 409 * @var object Instance of SimplePie_Sanitize (or other class) … … 414 412 */ 415 413 var $sanitize; 416 417 414 /** 418 415 * @var string SimplePie Useragent … … 421 418 */ 422 419 var $useragent = SIMPLEPIE_USERAGENT; 423 424 420 /** 425 421 * @var string Feed URL … … 428 424 */ 429 425 var $feed_url; 430 431 426 /** 432 427 * @var object Instance of SimplePie_File to use as a feed … … 435 430 */ 436 431 var $file; 437 438 432 /** 439 433 * @var string Raw feed data … … 442 436 */ 443 437 var $raw_data; 444 445 438 /** 446 439 * @var int Timeout for fetching remote files … … 449 442 */ 450 443 var $timeout = 10; 451 452 444 /** 453 445 * @var bool Forces fsockopen() to be used for remote files instead … … 457 449 */ 458 450 var $force_fsockopen = false; 459 460 451 /** 461 452 * @var bool Force the given data/URL to be treated as a feed no matter what … … 465 456 */ 466 457 var $force_feed = false; 467 468 458 /** 469 459 * @var bool Enable/Disable XML dump … … 472 462 */ 473 463 var $xml_dump = false; 474 475 464 /** 476 465 * @var bool Enable/Disable Caching … … 479 468 */ 480 469 var $cache = true; 481 482 470 /** 483 471 * @var int Cache duration (in seconds) … … 486 474 */ 487 475 var $cache_duration = 3600; 488 489 476 /** 490 477 * @var int Auto-discovery cache duration (in seconds) … … 493 480 */ 494 481 var $autodiscovery_cache_duration = 604800; // 7 Days. 495 496 482 /** 497 483 * @var string Cache location (relative to executing script) … … 500 486 */ 501 487 var $cache_location = './cache'; 502 503 488 /** 504 489 * @var string Function that creates the cache filename … … 507 492 */ 508 493 var $cache_name_function = 'md5'; 509 510 494 /** 511 495 * @var bool Reorder feed by date descending … … 514 498 */ 515 499 var $order_by_date = true; 516 517 500 /** 518 501 * @var mixed Force input encoding to be set to the follow value … … 522 505 */ 523 506 var $input_encoding = false; 524 525 507 /** 526 508 * @var int Feed Autodiscovery Level … … 529 511 */ 530 512 var $autodiscovery = SIMPLEPIE_LOCATOR_ALL; 531 532 513 /** 533 514 * @var string Class used for caching feeds … … 536 517 */ 537 518 var $cache_class = 'SimplePie_Cache'; 538 539 519 /** 540 520 * @var string Class used for locating feeds … … 543 523 */ 544 524 var $locator_class = 'SimplePie_Locator'; 545 546 525 /** 547 526 * @var string Class used for parsing feeds … … 550 529 */ 551 530 var $parser_class = 'SimplePie_Parser'; 552 553 531 /** 554 532 * @var string Class used for fetching feeds … … 557 535 */ 558 536 var $file_class = 'SimplePie_File'; 559 560 537 /** 561 538 * @var string Class used for items … … 564 541 */ 565 542 var $item_class = 'SimplePie_Item'; 566 567 543 /** 568 544 * @var string Class used for authors … … 571 547 */ 572 548 var $author_class = 'SimplePie_Author'; 573 574 549 /** 575 550 * @var string Class used for categories … … 578 553 */ 579 554 var $category_class = 'SimplePie_Category'; 580 581 555 /** 582 556 * @var string Class used for enclosures … … 585 559 */ 586 560 var $enclosure_class = 'SimplePie_Enclosure'; 587 588 561 /** 589 562 * @var string Class used for Media RSS <media:text> captions … … 592 565 */ 593 566 var $caption_class = 'SimplePie_Caption'; 594 595 567 /** 596 568 * @var string Class used for Media RSS <media:copyright> … … 599 571 */ 600 572 var $copyright_class = 'SimplePie_Copyright'; 601 602 573 /** 603 574 * @var string Class used for Media RSS <media:credit> … … 606 577 */ 607 578 var $credit_class = 'SimplePie_Credit'; 608 609 579 /** 610 580 * @var string Class used for Media RSS <media:rating> … … 613 583 */ 614 584 var $rating_class = 'SimplePie_Rating'; 615 616 585 /** 617 586 * @var string Class used for Media RSS <media:restriction> … … 620 589 */ 621 590 var $restriction_class = 'SimplePie_Restriction'; 622 623 591 /** 624 592 * @var string Class used for content-type sniffing … … 627 595 */ 628 596 var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer'; 629 630 597 /** 631 598 * @var string Class used for item sources. … … 634 601 */ 635 602 var $source_class = 'SimplePie_Source'; 636 637 603 /** 638 604 * @var mixed Set javascript query string parameter (false, or … … 642 608 */ 643 609 var $javascript = 'js'; 644 645 610 /** 646 611 * @var int Maximum number of feeds to check with autodiscovery … … 649 614 */ 650 615 var $max_checked_feeds = 10; 651 652 616 /** 653 617 * @var array All the feeds found during the autodiscovery process … … 656 620 */ 657 621 var $all_discovered_feeds = array(); 658 659 622 /** 660 623 * @var string Web-accessible path to the handler_favicon.php file. … … 663 626 */ 664 627 var $favicon_handler = ''; 665 666 628 /** 667 629 * @var string Web-accessible path to the handler_image.php file. … … 670 632 */ 671 633 var $image_handler = ''; 672 673 634 /** 674 635 * @var array Stores the URLs when multiple feeds are being initialized. … … 677 638 */ 678 639 var $multifeed_url = array(); 679 680 640 /** 681 641 * @var array Stores SimplePie objects when multiple feeds initialized. … … 683 643 */ 684 644 var $multifeed_objects = array(); 685 686 645 /** 687 646 * @var array Stores the get_object_vars() array for use with multifeeds. … … 690 649 */ 691 650 var $config_settings = null; 692 693 651 /** 694 652 * @var integer Stores the number of items to return per-feed with multifeeds. … … 697 655 */ 698 656 var $item_limit = 0; 699 700 657 /** 701 658 * @var array Stores the default attributes to be stripped by strip_attributes(). … … 704 661 */ 705 662 var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); 706 707 663 /** 708 664 * @var array Stores the default tags to be stripped by strip_htmltags(). … … 739 695 740 696 // Set options if they're passed to the constructor 741 if ($cache_location !== null) 742 { 697 if ($cache_location !== null) { 743 698 $this->set_cache_location($cache_location); 744 699 } 745 700 746 if ($cache_duration !== null) 747 { 701 if ($cache_duration !== null) { 748 702 $this->set_cache_duration($cache_duration); 749 703 } 750 704 751 705 // Only init the script if we're passed a feed URL 752 if ($feed_url !== null) 753 { 706 if ($feed_url !== null) { 754 707 $this->set_feed_url($feed_url); 755 708 $this->init(); … … 770 723 function __destruct() 771 724 { 772 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) 773 { 774 if (!empty($this->data['items'])) 775 { 776 foreach ($this->data['items'] as $item) 777 { 725 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) { 726 if (!empty($this->data['items'])) { 727 foreach ($this->data['items'] as $item) { 778 728 $item->__destruct(); 779 729 } 780 730 unset($item, $this->data['items']); 781 731 } 782 if (!empty($this->data['ordered_items'])) 783 { 784 foreach ($this->data['ordered_items'] as $item) 785 { 732 if (!empty($this->data['ordered_items'])) { 733 foreach ($this->data['ordered_items'] as $item) { 786 734 $item->__destruct(); 787 735 } … … 822 770 function set_feed_url($url) 823 771 { 824 if (is_array($url)) 825 { 772 if (is_array($url)) { 826 773 $this->multifeed_url = array(); 827 foreach ($url as $value) 828 { 774 foreach ($url as $value) { 829 775 $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1); 830 776 } 831 } 832 else 833 { 777 } else { 834 778 $this->feed_url = SimplePie_Misc::fix_protocol($url, 1); 835 779 } … … 845 789 function set_file(&$file) 846 790 { 847 if (is_a($file, 'SimplePie_File')) 848 { 791 if (is_a($file, 'SimplePie_File')) { 849 792 $this->feed_url = $file->url; 850 $this->file = & $file;793 $this->file = & $file; 851 794 return true; 852 795 } … … 988 931 function set_input_encoding($encoding = false) 989 932 { 990 if ($encoding) 991 { 933 if ($encoding) { 992 934 $this->input_encoding = (string) $encoding; 993 } 994 else 995 { 935 } else { 996 936 $this->input_encoding = false; 997 937 } … … 1028 968 function set_cache_class($class = 'SimplePie_Cache') 1029 969 { 1030 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache')) 1031 { 970 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache')) { 1032 971 $this->cache_class = $class; 1033 972 return true; … … 1047 986 function set_locator_class($class = 'SimplePie_Locator') 1048 987 { 1049 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator')) 1050 { 988 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator')) { 1051 989 $this->locator_class = $class; 1052 990 return true; … … 1066 1004 function set_parser_class($class = 'SimplePie_Parser') 1067 1005 { 1068 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser')) 1069 { 1006 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser')) { 1070 1007 $this->parser_class = $class; 1071 1008 return true; … … 1085 1022 function set_file_class($class = 'SimplePie_File') 1086 1023 { 1087 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File')) 1088 { 1024 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File')) { 1089 1025 $this->file_class = $class; 1090 1026 return true; … … 1104 1040 function set_sanitize_class($class = 'SimplePie_Sanitize') 1105 1041 { 1106 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize')) 1107 { 1042 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize')) { 1108 1043 $this->sanitize = new $class; 1109 1044 return true; … … 1123 1058 function set_item_class($class = 'SimplePie_Item') 1124 1059 { 1125 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item')) 1126 { 1060 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item')) { 1127 1061 $this->item_class = $class; 1128 1062 return true; … … 1142 1076 function set_author_class($class = 'SimplePie_Author') 1143 1077 { 1144 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author')) 1145 { 1078 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author')) { 1146 1079 $this->author_class = $class; 1147 1080 return true; … … 1161 1094 function set_category_class($class = 'SimplePie_Category') 1162 1095 { 1163 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category')) 1164 { 1096 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category')) { 1165 1097 $this->category_class = $class; 1166 1098 return true; … … 1180 1112 function set_enclosure_class($class = 'SimplePie_Enclosure') 1181 1113 { 1182 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure')) 1183 { 1114 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure')) { 1184 1115 $this->enclosure_class = $class; 1185 1116 return true; … … 1199 1130 function set_caption_class($class = 'SimplePie_Caption') 1200 1131 { 1201 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption')) 1202 { 1132 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption')) { 1203 1133 $this->caption_class = $class; 1204 1134 return true; … … 1218 1148 function set_copyright_class($class = 'SimplePie_Copyright') 1219 1149 { 1220 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright')) 1221 { 1150 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright')) { 1222 1151 $this->copyright_class = $class; 1223 1152 return true; … … 1237 1166 function set_credit_class($class = 'SimplePie_Credit') 1238 1167 { 1239 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit')) 1240 { 1168 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit')) { 1241 1169 $this->credit_class = $class; 1242 1170 return true; … … 1256 1184 function set_rating_class($class = 'SimplePie_Rating') 1257 1185 { 1258 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating')) 1259 { 1186 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating')) { 1260 1187 $this->rating_class = $class; 1261 1188 return true; … … 1275 1202 function set_restriction_class($class = 'SimplePie_Restriction') 1276 1203 { 1277 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction')) 1278 { 1204 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction')) { 1279 1205 $this->restriction_class = $class; 1280 1206 return true; … … 1294 1220 function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer') 1295 1221 { 1296 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer')) 1297 { 1222 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer')) { 1298 1223 $this->content_type_sniffer_class = $class; 1299 1224 return true; … … 1313 1238 function set_source_class($class = 'SimplePie_Source') 1314 1239 { 1315 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source')) 1316 { 1240 if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source')) { 1317 1241 $this->source_class = $class; 1318 1242 return true; … … 1340 1264 function set_cache_name_function($function = 'md5') 1341 1265 { 1342 if (is_callable($function)) 1343 { 1266 if (is_callable($function)) { 1344 1267 $this->cache_name_function = $function; 1345 1268 } … … 1354 1277 function set_javascript($get = 'js') 1355 1278 { 1356 if ($get) 1357 { 1279 if ($get) { 1358 1280 $this->javascript = (string) $get; 1359 } 1360 else 1361 { 1281 } else { 1362 1282 $this->javascript = false; 1363 1283 } … … 1373 1293 function set_stupidly_fast($set = false) 1374 1294 { 1375 if ($set) 1376 { 1295 if ($set) { 1377 1296 $this->enable_order_by_date(false); 1378 1297 $this->remove_div(false); … … 1402 1321 function strip_htmltags($tags = '', $encode = null) 1403 1322 { 1404 if ($tags === '') 1405 { 1323 if ($tags === '') { 1406 1324 $tags = $this->strip_htmltags; 1407 1325 } 1408 1326 $this->sanitize->strip_htmltags($tags); 1409 if ($encode !== null) 1410 { 1327 if ($encode !== null) { 1411 1328 $this->sanitize->encode_instead_of_strip($tags); 1412 1329 } … … 1420 1337 function strip_attributes($attribs = '') 1421 1338 { 1422 if ($attribs === '') 1423 { 1339 if ($attribs === '') { 1424 1340 $attribs = $this->strip_attributes; 1425 1341 } … … 1459 1375 function set_favicon_handler($page = false, $qs = 'i') 1460 1376 { 1461 if ($page !== false) 1462 { 1463 $this->favicon_handler = $page . '?' . $qs . '='; 1464 } 1465 else 1466 { 1377 if ($page !== false) { 1378 $this->favicon_handler = $page.'?'.$qs.'='; 1379 } else { 1467 1380 $this->favicon_handler = ''; 1468 1381 } … … 1478 1391 function set_image_handler($page = false, $qs = 'i') 1479 1392 { 1480 if ($page !== false) 1481 { 1482 $this->sanitize->set_image_handler($page . '?' . $qs . '='); 1483 } 1484 else 1485 { 1393 if ($page !== false) { 1394 $this->sanitize->set_image_handler($page.'?'.$qs.'='); 1395 } else { 1486 1396 $this->image_handler = ''; 1487 1397 } … … 1502 1412 { 1503 1413 // Check absolute bare minimum requirements. 1504 if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre')) 1505 { 1414 if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre')) { 1506 1415 return false; 1507 1416 } 1508 1417 // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. 1509 elseif (!extension_loaded('xmlreader')) 1510 { 1418 elseif (!extension_loaded('xmlreader')) { 1511 1419 static $xml_is_sane = null; 1512 if ($xml_is_sane === null) 1513 { 1420 if ($xml_is_sane === null) { 1514 1421 $parser_check = xml_parser_create(); 1515 1422 xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); … … 1517 1424 $xml_is_sane = isset($values[0]['value']); 1518 1425 } 1519 if (!$xml_is_sane) 1520 { 1426 if (!$xml_is_sane) { 1521 1427 return false; 1522 1428 } 1523 1429 } 1524 1430 1525 if (isset($_GET[$this->javascript])) 1526 { 1431 if (isset($_GET[$this->javascript])) { 1527 1432 SimplePie_Misc::output_javascript(); 1528 1433 exit; … … 1533 1438 $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen); 1534 1439 1535 if ($this->feed_url !== null || $this->raw_data !== null) 1536 { 1440 if ($this->feed_url !== null || $this->raw_data !== null) { 1537 1441 $this->data = array(); 1538 1442 $this->multifeed_objects = array(); 1539 1443 $cache = false; 1540 1444 1541 if ($this->feed_url !== null) 1542 { 1445 if ($this->feed_url !== null) { 1543 1446 $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url); 1544 1447 // Decide whether to enable caching 1545 if ($this->cache && $parsed_feed_url['scheme'] !== '') 1546 { 1448 if ($this->cache && $parsed_feed_url['scheme'] !== '') { 1547 1449 $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc'); 1548 1450 } 1549 1451 // If it's enabled and we don't want an XML dump, use the cache 1550 if ($cache && !$this->xml_dump) 1551 { 1452 if ($cache && !$this->xml_dump) { 1552 1453 // Load the Cache 1553 1454 $this->data = $cache->load(); 1554 if (!empty($this->data)) 1555 { 1455 if (!empty($this->data)) { 1556 1456 // If the cache is for an outdated build of SimplePie 1557 if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) 1558 { 1457 if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) { 1559 1458 $cache->unlink(); 1560 1459 $this->data = array(); 1561 1460 } 1562 1461 // If we've hit a collision just rerun it with caching disabled 1563 elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) 1564 { 1462 elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) { 1565 1463 $cache = false; 1566 1464 $this->data = array(); 1567 1465 } 1568 1466 // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL. 1569 elseif (isset($this->data['feed_url'])) 1570 { 1467 elseif (isset($this->data['feed_url'])) { 1571 1468 // If the autodiscovery cache is still valid use it. 1572 if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) 1573 { 1469 if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) { 1574 1470 // Do not need to do feed autodiscovery yet. 1575 if ($this->data['feed_url'] === $this->data['url']) 1576 { 1471 if ($this->data['feed_url'] === $this->data['url']) { 1577 1472 $cache->unlink(); 1578 1473 $this->data = array(); 1579 } 1580 else 1581 { 1474 } else { 1582 1475 $this->set_feed_url($this->data['feed_url']); 1583 1476 return $this->init(); … … 1586 1479 } 1587 1480 // Check if the cache has been updated 1588 elseif ($cache->mtime() + $this->cache_duration < time()) 1589 { 1481 elseif ($cache->mtime() + $this->cache_duration < time()) { 1590 1482 // If we have last-modified and/or etag set 1591 if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) 1592 { 1483 if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) { 1593 1484 $headers = array(); 1594 if (isset($this->data['headers']['last-modified'])) 1595 { 1485 if (isset($this->data['headers']['last-modified'])) { 1596 1486 $headers['if-modified-since'] = $this->data['headers']['last-modified']; 1597 1487 } 1598 if (isset($this->data['headers']['etag'])) 1599 { 1600 $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"'; 1488 if (isset($this->data['headers']['etag'])) { 1489 $headers['if-none-match'] = '"'.$this->data['headers']['etag'].'"'; 1601 1490 } 1602 $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen); 1603 if ($file->success) 1604 { 1605 if ($file->status_code === 304) 1606 { 1491 $file = new $this->file_class($this->feed_url, $this->timeout / 10, 5, $headers, $this->useragent, $this->force_fsockopen); 1492 if ($file->success) { 1493 if ($file->status_code === 304) { 1607 1494 $cache->touch(); 1608 1495 return true; 1609 } 1610 else 1611 { 1496 } else { 1612 1497 $headers = $file->headers; 1613 1498 } 1614 } 1615 else 1616 { 1499 } else { 1617 1500 unset($file); 1618 1501 } … … 1620 1503 } 1621 1504 // If the cache is still valid, just return true 1622 else 1623 { 1505 else { 1624 1506 return true; 1625 1507 } 1626 1508 } 1627 1509 // If the cache is empty, delete it 1628 else 1629 { 1510 else { 1630 1511 $cache->unlink(); 1631 1512 $this->data = array(); … … 1633 1514 } 1634 1515 // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. 1635 if (!isset($file)) 1636 { 1637 if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url) 1638 { 1639 $file =& $this->file; 1640 } 1641 else 1642 { 1516 if (!isset($file)) { 1517 if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url) { 1518 $file = & $this->file; 1519 } else { 1643 1520 $file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen); 1644 1521 } 1645 1522 } 1646 1523 // If the file connection has an error, set SimplePie::error to that and quit 1647 if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) 1648 { 1524 if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) { 1649 1525 $this->error = $file->error; 1650 if (!empty($this->data)) 1651 { 1526 if (!empty($this->data)) { 1652 1527 return true; 1653 } 1654 else 1655 { 1528 } else { 1656 1529 return false; 1657 1530 } 1658 1531 } 1659 1532 1660 if (!$this->force_feed) 1661 { 1533 if (!$this->force_feed) { 1662 1534 // Check if the supplied URL is a feed, if it isn't, look for it. 1663 1535 $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class); 1664 if (!$locate->is_feed($file)) 1665 { 1536 if (!$locate->is_feed($file)) { 1666 1537 // We need to unset this so that if SimplePie::set_file() has been called that object is untouched 1667 1538 unset($file); 1668 if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds)) 1669 { 1670 if ($cache) 1671 { 1539 if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds)) { 1540 if ($cache) { 1672 1541 $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); 1673 if (!$cache->save($this)) 1674 { 1542 if (!$cache->save($this)) { 1675 1543 trigger_error("$this->cache_location is not writeable", E_USER_WARNING); 1676 1544 } … … 1678 1546 } 1679 1547 $this->feed_url = $file->url; 1680 } 1681 else 1682 { 1548 } else { 1683 1549 $this->error = "A feed could not be found at $this->feed_url"; 1684 1550 SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); … … 1693 1559 $sniffer = new $this->content_type_sniffer_class($file); 1694 1560 $sniffed = $sniffer->get_type(); 1695 } 1696 else 1697 { 1561 } else { 1698 1562 $data = $this->raw_data; 1699 1563 } … … 1703 1567 1704 1568 // First check to see if input has been overridden. 1705 if ($this->input_encoding !== false) 1706 { 1569 if ($this->input_encoding !== false) { 1707 1570 $encodings[] = $this->input_encoding; 1708 1571 } … … 1712 1575 1713 1576 // RFC 3023 (only applies to sniffed content) 1714 if (isset($sniffed)) 1715 { 1716 if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml') 1717 { 1718 if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) 1719 { 1577 if (isset($sniffed)) { 1578 if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml') { 1579 if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) { 1720 1580 $encodings[] = strtoupper($charset[1]); 1721 1581 } 1722 1582 $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data)); 1723 1583 $encodings[] = 'UTF-8'; 1724 } 1725 elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml') 1726 { 1727 if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) 1728 { 1584 } elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml') { 1585 if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) { 1729 1586 $encodings[] = $charset[1]; 1730 1587 } … … 1732 1589 } 1733 1590 // Text MIME-type default 1734 elseif (substr($sniffed, 0, 5) === 'text/') 1735 { 1591 elseif (substr($sniffed, 0, 5) === 'text/') { 1736 1592 $encodings[] = 'US-ASCII'; 1737 1593 } … … 1747 1603 1748 1604 // If we want the XML, just output that with the most likely encoding and quit 1749 if ($this->xml_dump) 1750 { 1751 header('Content-type: text/xml; charset=' . $encodings[0]); 1605 if ($this->xml_dump) { 1606 header('Content-type: text/xml; charset='.$encodings[0]); 1752 1607 echo $data; 1753 1608 exit; … … 1755 1610 1756 1611 // Loop through each possible encoding, till we return something, or run out of possibilities 1757 foreach ($encodings as $encoding) 1758 { 1612 foreach ($encodings as $encoding) { 1759 1613 // Change the encoding to UTF-8 (as we always use UTF-8 internally) 1760 if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8')) 1761 { 1614 if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8')) { 1762 1615 // Create new parser 1763 1616 $parser = new $this->parser_class(); 1764 1617 1765 1618 // If it's parsed fine 1766 if ($parser->parse($utf8_data, 'UTF-8')) 1767 { 1619 if ($parser->parse($utf8_data, 'UTF-8')) { 1768 1620 $this->data = $parser->get_data(); 1769 if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE) 1770 { 1771 if (isset($headers)) 1772 { 1621 if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE) { 1622 if (isset($headers)) { 1773 1623 $this->data['headers'] = $headers; 1774 1624 } … … 1776 1626 1777 1627 // Cache the file if caching is enabled 1778 if ($cache && !$cache->save($this)) 1779 { 1628 if ($cache && !$cache->save($this)) { 1780 1629 trigger_error("$cache->name is not writeable", E_USER_WARNING); 1781 1630 } 1782 1631 return true; 1783 } 1784 else 1785 { 1632 } else { 1786 1633 $this->error = "A feed could not be found at $this->feed_url"; 1787 1634 SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); … … 1791 1638 } 1792 1639 } 1793 if(isset($parser)) 1794 { 1640 if (isset($parser)) { 1795 1641 // We have an error, just set SimplePie_Misc::error to it and quit 1796 1642 $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); 1797 } 1798 else 1799 { 1643 } else { 1800 1644 $this->error = 'The data could not be converted to UTF-8'; 1801 1645 } 1802 1646 SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); 1803 1647 return false; 1804 } 1805 elseif (!empty($this->multifeed_url)) 1806 { 1648 } elseif (!empty($this->multifeed_url)) { 1807 1649 $i = 0; 1808 1650 $success = 0; 1809 1651 $this->multifeed_objects = array(); 1810 foreach ($this->multifeed_url as $url) 1811 { 1812 if (SIMPLEPIE_PHP5) 1813 { 1652 foreach ($this->multifeed_url as $url) { 1653 if (SIMPLEPIE_PHP5) { 1814 1654 // This keyword needs to defy coding standards for PHP4 compatibility 1815 1655 $this->multifeed_objects[$i] = clone($this); 1816 } 1817 else 1818 { 1656 } else { 1819 1657 $this->multifeed_objects[$i] = $this; 1820 1658 } … … 1824 1662 } 1825 1663 return (bool) $success; 1826 } 1827 else 1828 { 1664 } else { 1829 1665 return false; 1830 1666 } … … 1849 1685 function handle_content_type($mime = 'text/html') 1850 1686 { 1851 if (!headers_sent()) 1852 { 1687 if (!headers_sent()) { 1853 1688 $header = "Content-type: $mime;"; 1854 if ($this->get_encoding()) 1855 { 1856 $header .= ' charset=' . $this->get_encoding(); 1857 } 1858 else 1859 { 1689 if ($this->get_encoding()) { 1690 $header .= ' charset='.$this->get_encoding(); 1691 } else { 1860 1692 $header .= ' charset=UTF-8'; 1861 1693 } … … 1866 1698 function get_type() 1867 1699 { 1868 if (!isset($this->data['type'])) 1869 { 1700 if (!isset($this->data['type'])) { 1870 1701 $this->data['type'] = SIMPLEPIE_TYPE_ALL; 1871 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'])) 1872 { 1702 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'])) { 1873 1703 $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10; 1874 } 1875 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'])) 1876 { 1704 } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'])) { 1877 1705 $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03; 1878 } 1879 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) 1880 { 1706 } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) { 1881 1707 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel']) 1882 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) 1883 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) 1884 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) 1885 { 1708 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) 1709 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) 1710 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) { 1886 1711 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10; 1887 1712 } 1888 1713 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel']) 1889 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) 1890 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) 1891 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) 1892 { 1714 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) 1715 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) 1716 || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) { 1893 1717 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; 1894 1718 } 1895 } 1896 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) 1897 { 1719 } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) { 1898 1720 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; 1899 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) 1900 { 1901 switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) 1902 { 1721 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) { 1722 switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) { 1903 1723 case '0.91': 1904 1724 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; 1905 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) 1906 { 1907 switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) 1908 { 1725 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) { 1726 switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) { 1909 1727 case '0': 1910 1728 $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; … … 1935 1753 } 1936 1754 } 1937 } 1938 else 1939 { 1755 } else { 1940 1756 $this->data['type'] = SIMPLEPIE_TYPE_NONE; 1941 1757 } … … 1953 1769 function get_favicon() 1954 1770 { 1955 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) 1956 { 1771 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) { 1957 1772 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 1958 } 1959 elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url)) 1960 { 1773 } elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url)) { 1961 1774 $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url); 1962 1775 1963 if ($this->cache && $this->favicon_handler) 1964 { 1776 if ($this->cache && $this->favicon_handler) { 1965 1777 $favicon_filename = call_user_func($this->cache_name_function, $favicon); 1966 1778 $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi'); 1967 1779 1968 if ($cache->load()) 1969 { 1970 return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); 1971 } 1972 else 1973 { 1780 if ($cache->load()) { 1781 return $this->sanitize($this->favicon_handler.$favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); 1782 } else { 1974 1783 $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); 1975 1784 1976 if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) 1977 { 1785 if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) { 1978 1786 $sniffer = new $this->content_type_sniffer_class($file); 1979 if (substr($sniffer->get_type(), 0, 6) === 'image/') 1980 { 1981 if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) 1982 { 1983 return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); 1984 } 1985 else 1986 { 1787 if (substr($sniffer->get_type(), 0, 6) === 'image/') { 1788 if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) { 1789 return $this->sanitize($this->favicon_handler.$favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); 1790 } else { 1987 1791 trigger_error("$cache->name is not writeable", E_USER_WARNING); 1988 1792 return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); … … 1990 1794 } 1991 1795 // not an image 1992 else 1993 { 1796 else { 1994 1797 return false; 1995 1798 } 1996 1799 } 1997 1800 } 1998 } 1999 else 2000 { 1801 } else { 2001 1802 return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); 2002 1803 } … … 2012 1813 function subscribe_url() 2013 1814 { 2014 if ($this->feed_url !== null) 2015 { 1815 if ($this->feed_url !== null) { 2016 1816 return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI); 2017 } 2018 else 2019 { 1817 } else { 2020 1818 return null; 2021 1819 } … … 2024 1822 function subscribe_feed() 2025 1823 { 2026 if ($this->feed_url !== null) 2027 { 1824 if ($this->feed_url !== null) { 2028 1825 return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); 2029 } 2030 else 2031 { 1826 } else { 2032 1827 return null; 2033 1828 } … … 2036 1831 function subscribe_outlook() 2037 1832 { 2038 if ($this->feed_url !== null) 2039 { 2040 return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); 2041 } 2042 else 2043 { 1833 if ($this->feed_url !== null) { 1834 return $this->sanitize('outlook'.SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); 1835 } else { 2044 1836 return null; 2045 1837 } … … 2048 1840 function subscribe_podcast() 2049 1841 { 2050 if ($this->feed_url !== null) 2051 { 1842 if ($this->feed_url !== null) { 2052 1843 return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI); 2053 } 2054 else 2055 { 1844 } else { 2056 1845 return null; 2057 1846 } … … 2060 1849 function subscribe_itunes() 2061 1850 { 2062 if ($this->feed_url !== null) 2063 { 1851 if ($this->feed_url !== null) { 2064 1852 return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI); 2065 } 2066 else 2067 { 1853 } else { 2068 1854 return null; 2069 1855 } … … 2081 1867 function subscribe_service($feed_url, $site_url = null) 2082 1868 { 2083 if ($this->subscribe_url()) 2084 { 2085 $return = $feed_url . rawurlencode($this->feed_url); 2086 if ($site_url !== null && $this->get_link() !== null) 2087 { 2088 $return .= $site_url . rawurlencode($this->get_link()); 1869 if ($this->subscribe_url()) { 1870 $return = $feed_url.rawurlencode($this->feed_url); 1871 if ($site_url !== null && $this->get_link() !== null) { 1872 $return .= $site_url.rawurlencode($this->get_link()); 2089 1873 } 2090 1874 return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); 2091 } 2092 else 2093 { 1875 } else { 2094 1876 return null; 2095 1877 } … … 2174 1956 { 2175 1957 $type = $this->get_type(); 2176 if ($type & SIMPLEPIE_TYPE_ATOM_10) 2177 { 2178 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) 2179 { 1958 if ($type & SIMPLEPIE_TYPE_ATOM_10) { 1959 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) { 2180 1960 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]; 2181 1961 } 2182 1962 } 2183 if ($type & SIMPLEPIE_TYPE_ATOM_03) 2184 { 2185 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) 2186 { 1963 if ($type & SIMPLEPIE_TYPE_ATOM_03) { 1964 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) { 2187 1965 return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]; 2188 1966 } 2189 1967 } 2190 if ($type & SIMPLEPIE_TYPE_RSS_RDF) 2191 { 2192 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) 2193 { 1968 if ($type & SIMPLEPIE_TYPE_RSS_RDF) { 1969 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) { 2194 1970 return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]; 2195 1971 } 2196 1972 } 2197 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) 2198 { 2199 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) 2200 { 1973 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { 1974 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) { 2201 1975 return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]; 2202 1976 } … … 2208 1982 { 2209 1983 $type = $this->get_type(); 2210 if ($type & SIMPLEPIE_TYPE_ATOM_ALL) 2211 { 2212 if ($return = $this->get_feed_tags($namespace, $tag)) 2213 { 1984 if ($type & SIMPLEPIE_TYPE_ATOM_ALL) { 1985 if ($return = $this->get_feed_tags($namespace, $tag)) { 2214 1986 return $return; 2215 1987 } 2216 1988 } 2217 if ($type & SIMPLEPIE_TYPE_RSS_10) 2218 { 2219 if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) 2220 { 2221 if (isset($channel[0]['child'][$namespace][$tag])) 2222 { 1989 if ($type & SIMPLEPIE_TYPE_RSS_10) { 1990 if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) { 1991 if (isset($channel[0]['child'][$namespace][$tag])) { 2223 1992 return $channel[0]['child'][$namespace][$tag]; 2224 1993 } 2225 1994 } 2226 1995 } 2227 if ($type & SIMPLEPIE_TYPE_RSS_090) 2228 { 2229 if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) 2230 { 2231 if (isset($channel[0]['child'][$namespace][$tag])) 2232 { 1996 if ($type & SIMPLEPIE_TYPE_RSS_090) { 1997 if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) { 1998 if (isset($channel[0]['child'][$namespace][$tag])) { 2233 1999 return $channel[0]['child'][$namespace][$tag]; 2234 2000 } 2235 2001 } 2236 2002 } 2237 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) 2238 { 2239 if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) 2240 { 2241 if (isset($channel[0]['child'][$namespace][$tag])) 2242 { 2003 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { 2004 if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) { 2005 if (isset($channel[0]['child'][$namespace][$tag])) { 2243 2006 return $channel[0]['child'][$namespace][$tag]; 2244 2007 } … … 2251 2014 { 2252 2015 $type = $this->get_type(); 2253 if ($type & SIMPLEPIE_TYPE_RSS_10) 2254 { 2255 if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image')) 2256 { 2257 if (isset($image[0]['child'][$namespace][$tag])) 2258 { 2016 if ($type & SIMPLEPIE_TYPE_RSS_10) { 2017 if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image')) { 2018 if (isset($image[0]['child'][$namespace][$tag])) { 2259 2019 return $image[0]['child'][$namespace][$tag]; 2260 2020 } 2261 2021 } 2262 2022 } 2263 if ($type & SIMPLEPIE_TYPE_RSS_090) 2264 { 2265 if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image')) 2266 { 2267 if (isset($image[0]['child'][$namespace][$tag])) 2268 { 2023 if ($type & SIMPLEPIE_TYPE_RSS_090) { 2024 if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image')) { 2025 if (isset($image[0]['child'][$namespace][$tag])) { 2269 2026 return $image[0]['child'][$namespace][$tag]; 2270 2027 } 2271 2028 } 2272 2029 } 2273 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) 2274 { 2275 if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) 2276 { 2277 if (isset($image[0]['child'][$namespace][$tag])) 2278 { 2030 if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) { 2031 if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) { 2032 if (isset($image[0]['child'][$namespace][$tag])) { 2279 2033 return $image[0]['child'][$namespace][$tag]; 2280 2034 } … … 2286 2040 function get_base($element = array()) 2287 2041 { 2288 if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) 2289 { 2042 if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) { 2290 2043 return $element['xml_base']; 2291 } 2292 elseif ($this->get_link() !== null) 2293 { 2044 } elseif ($this->get_link() !== null) { 2294 2045 return $this->get_link(); 2295 } 2296 else 2297 { 2046 } else { 2298 2047 return $this->subscribe_url(); 2299 2048 } … … 2307 2056 function get_title() 2308 2057 { 2309 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) 2310 { 2058 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) { 2311 2059 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 2312 } 2313 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) 2314 { 2060 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) { 2315 2061 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 2316 } 2317 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) 2318 { 2062 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) { 2319 2063 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 2320 } 2321 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) 2322 { 2064 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) { 2323 2065 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 2324 } 2325 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) 2326 { 2066 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { 2327 2067 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 2328 } 2329 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) 2330 { 2068 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) { 2331 2069 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2332 } 2333 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) 2334 { 2070 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) { 2335 2071 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2336 } 2337 else 2338 { 2072 } else { 2339 2073 return null; 2340 2074 } … … 2344 2078 { 2345 2079 $categories = $this->get_categories(); 2346 if (isset($categories[$key])) 2347 { 2080 if (isset($categories[$key])) { 2348 2081 return $categories[$key]; 2349 } 2350 else 2351 { 2082 } else { 2352 2083 return null; 2353 2084 } … … 2358 2089 $categories = array(); 2359 2090 2360 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) 2361 { 2091 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { 2362 2092 $term = null; 2363 2093 $scheme = null; 2364 2094 $label = null; 2365 if (isset($category['attribs']['']['term'])) 2366 { 2095 if (isset($category['attribs']['']['term'])) { 2367 2096 $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); 2368 2097 } 2369 if (isset($category['attribs']['']['scheme'])) 2370 { 2098 if (isset($category['attribs']['']['scheme'])) { 2371 2099 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 2372 2100 } 2373 if (isset($category['attribs']['']['label'])) 2374 { 2101 if (isset($category['attribs']['']['label'])) { 2375 2102 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 2376 2103 } 2377 2104 $categories[] = new $this->category_class($term, $scheme, $label); 2378 2105 } 2379 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) 2380 { 2106 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { 2381 2107 // This is really the label, but keep this as the term also for BC. 2382 2108 // Label will also work on retrieving because that falls back to term. 2383 2109 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2384 if (isset($category['attribs']['']['domain'])) 2385 { 2110 if (isset($category['attribs']['']['domain'])) { 2386 2111 $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); 2387 } 2388 else 2389 { 2112 } else { 2390 2113 $scheme = null; 2391 2114 } 2392 2115 $categories[] = new $this->category_class($term, $scheme, null); 2393 2116 } 2394 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) 2395 { 2117 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { 2396 2118 $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 2397 2119 } 2398 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) 2399 { 2120 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) { 2400 2121 $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 2401 2122 } 2402 2123 2403 if (!empty($categories)) 2404 { 2124 if (!empty($categories)) { 2405 2125 return SimplePie_Misc::array_unique($categories); 2406 } 2407 else 2408 { 2126 } else { 2409 2127 return null; 2410 2128 } … … 2414 2132 { 2415 2133 $authors = $this->get_authors(); 2416 if (isset($authors[$key])) 2417 { 2134 if (isset($authors[$key])) { 2418 2135 return $authors[$key]; 2419 } 2420 else 2421 { 2136 } else { 2422 2137 return null; 2423 2138 } … … 2427 2142 { 2428 2143 $authors = array(); 2429 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) 2430 { 2144 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) { 2431 2145 $name = null; 2432 2146 $uri = null; 2433 2147 $email = null; 2434 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 2435 { 2148 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) { 2436 2149 $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2437 2150 } 2438 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 2439 { 2151 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) { 2440 2152 $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 2441 2153 } 2442 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 2443 { 2154 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) { 2444 2155 $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2445 2156 } 2446 if ($name !== null || $email !== null || $uri !== null) 2447 { 2157 if ($name !== null || $email !== null || $uri !== null) { 2448 2158 $authors[] = new $this->author_class($name, $uri, $email); 2449 2159 } 2450 2160 } 2451 if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) 2452 { 2161 if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) { 2453 2162 $name = null; 2454 2163 $url = null; 2455 2164 $email = null; 2456 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 2457 { 2165 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) { 2458 2166 $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2459 2167 } 2460 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 2461 { 2168 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { 2462 2169 $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 2463 2170 } 2464 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 2465 { 2171 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) { 2466 2172 $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2467 2173 } 2468 if ($name !== null || $email !== null || $url !== null) 2469 { 2174 if ($name !== null || $email !== null || $url !== null) { 2470 2175 $authors[] = new $this->author_class($name, $url, $email); 2471 2176 } 2472 2177 } 2473 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) 2474 { 2178 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) { 2475 2179 $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 2476 2180 } 2477 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) 2478 { 2181 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) { 2479 2182 $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 2480 2183 } 2481 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) 2482 { 2184 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) { 2483 2185 $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 2484 2186 } 2485 2187 2486 if (!empty($authors)) 2487 { 2188 if (!empty($authors)) { 2488 2189 return SimplePie_Misc::array_unique($authors); 2489 } 2490 else 2491 { 2190 } else { 2492 2191 return null; 2493 2192 } … … 2497 2196 { 2498 2197 $contributors = $this->get_contributors(); 2499 if (isset($contributors[$key])) 2500 { 2198 if (isset($contributors[$key])) { 2501 2199 return $contributors[$key]; 2502 } 2503 else 2504 { 2200 } else { 2505 2201 return null; 2506 2202 } … … 2510 2206 { 2511 2207 $contributors = array(); 2512 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) 2513 { 2208 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) { 2514 2209 $name = null; 2515 2210 $uri = null; 2516 2211 $email = null; 2517 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 2518 { 2212 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) { 2519 2213 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2520 2214 } 2521 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 2522 { 2215 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) { 2523 2216 $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 2524 2217 } 2525 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 2526 { 2218 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) { 2527 2219 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2528 2220 } 2529 if ($name !== null || $email !== null || $uri !== null) 2530 { 2221 if ($name !== null || $email !== null || $uri !== null) { 2531 2222 $contributors[] = new $this->author_class($name, $uri, $email); 2532 2223 } 2533 2224 } 2534 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) 2535 { 2225 foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) { 2536 2226 $name = null; 2537 2227 $url = null; 2538 2228 $email = null; 2539 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 2540 { 2229 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) { 2541 2230 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2542 2231 } 2543 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 2544 { 2232 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { 2545 2233 $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 2546 2234 } 2547 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 2548 { 2235 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) { 2549 2236 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2550 2237 } 2551 if ($name !== null || $email !== null || $url !== null) 2552 { 2238 if ($name !== null || $email !== null || $url !== null) { 2553 2239 $contributors[] = new $this->author_class($name, $url, $email); 2554 2240 } 2555 2241 } 2556 2242 2557 if (!empty($contributors)) 2558 { 2243 if (!empty($contributors)) { 2559 2244 return SimplePie_Misc::array_unique($contributors); 2560 } 2561 else 2562 { 2245 } else { 2563 2246 return null; 2564 2247 } … … 2568 2251 { 2569 2252 $links = $this->get_links($rel); 2570 if (isset($links[$key])) 2571 { 2253 if (isset($links[$key])) { 2572 2254 return $links[$key]; 2573 } 2574 else 2575 { 2255 } else { 2576 2256 return null; 2577 2257 } … … 2588 2268 function get_links($rel = 'alternate') 2589 2269 { 2590 if (!isset($this->data['links'])) 2591 { 2270 if (!isset($this->data['links'])) { 2592 2271 $this->data['links'] = array(); 2593 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) 2594 { 2595 foreach ($links as $link) 2596 { 2597 if (isset($link['attribs']['']['href'])) 2598 { 2272 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) { 2273 foreach ($links as $link) { 2274 if (isset($link['attribs']['']['href'])) { 2599 2275 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 2600 2276 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); … … 2602 2278 } 2603 2279 } 2604 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) 2605 { 2606 foreach ($links as $link) 2607 { 2608 if (isset($link['attribs']['']['href'])) 2609 { 2280 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) { 2281 foreach ($links as $link) { 2282 if (isset($link['attribs']['']['href'])) { 2610 2283 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 2611 2284 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 2612 2613 2285 } 2614 2286 } 2615 2287 } 2616 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) 2617 { 2288 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) { 2618 2289 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 2619 2290 } 2620 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) 2621 { 2291 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) { 2622 2292 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 2623 2293 } 2624 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) 2625 { 2294 if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { 2626 2295 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 2627 2296 } 2628 2297 2629 2298 $keys = array_keys($this->data['links']); 2630 foreach ($keys as $key) 2631 { 2632 if (SimplePie_Misc::is_isegment_nz_nc($key)) 2633 { 2634 if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) 2635 { 2636 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); 2637 $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; 2299 foreach ($keys as $key) { 2300 if (SimplePie_Misc::is_isegment_nz_nc($key)) { 2301 if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key])) { 2302 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]); 2303 $this->data['links'][$key] = & $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]; 2304 } else { 2305 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = & $this->data['links'][$key]; 2638 2306 } 2639 else 2640 { 2641 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; 2642 } 2643 } 2644 elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) 2645 { 2646 $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; 2307 } elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { 2308 $this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; 2647 2309 } 2648 2310 $this->data['links'][$key] = array_unique($this->data['links'][$key]); … … 2650 2312 } 2651 2313 2652 if (isset($this->data['links'][$rel])) 2653 { 2314 if (isset($this->data['links'][$rel])) { 2654 2315 return $this->data['links'][$rel]; 2655 } 2656 else 2657 { 2316 } else { 2658 2317 return null; 2659 2318 } … … 2667 2326 function get_description() 2668 2327 { 2669 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) 2670 { 2328 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) { 2671 2329 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 2672 } 2673 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) 2674 { 2330 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) { 2675 2331 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 2676 } 2677 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) 2678 { 2332 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) { 2679 2333 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 2680 } 2681 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) 2682 { 2334 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) { 2683 2335 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 2684 } 2685 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) 2686 { 2336 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { 2687 2337 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 2688 } 2689 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) 2690 { 2338 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) { 2691 2339 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2692 } 2693 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) 2694 { 2340 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) { 2695 2341 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2696 } 2697 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) 2698 { 2342 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) { 2699 2343 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 2700 } 2701 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) 2702 { 2344 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) { 2703 2345 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 2704 } 2705 else 2706 { 2346 } else { 2707 2347 return null; 2708 2348 } … … 2711 2351 function get_copyright() 2712 2352 { 2713 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) 2714 { 2353 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) { 2715 2354 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 2716 } 2717 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) 2718 { 2355 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) { 2719 2356 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 2720 } 2721 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) 2722 { 2357 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) { 2723 2358 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2724 } 2725 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) 2726 { 2359 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) { 2727 2360 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2728 } 2729 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) 2730 { 2361 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) { 2731 2362 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2732 } 2733 else 2734 { 2363 } else { 2735 2364 return null; 2736 2365 } … … 2739 2368 function get_language() 2740 2369 { 2741 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) 2742 { 2370 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { 2743 2371 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2744 } 2745 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) 2746 { 2372 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) { 2747 2373 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2748 } 2749 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) 2750 { 2374 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) { 2751 2375 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2752 } 2753 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) 2754 { 2376 } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) { 2755 2377 return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); 2756 } 2757 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) 2758 { 2378 } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) { 2759 2379 return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); 2760 } 2761 elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) 2762 { 2380 } elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) { 2763 2381 return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); 2764 } 2765 elseif (isset($this->data['headers']['content-language'])) 2766 { 2382 } elseif (isset($this->data['headers']['content-language'])) { 2767 2383 return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); 2768 } 2769 else 2770 { 2384 } else { 2771 2385 return null; 2772 2386 } … … 2775 2389 function get_latitude() 2776 2390 { 2777 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) 2778 { 2391 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) { 2779 2392 return (float) $return[0]['data']; 2780 } 2781 elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) 2782 { 2393 } elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) { 2783 2394 return (float) $match[1]; 2784 } 2785 else 2786 { 2395 } else { 2787 2396 return null; 2788 2397 } … … 2791 2400 function get_longitude() 2792 2401 { 2793 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) 2794 { 2402 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) { 2795 2403 return (float) $return[0]['data']; 2796 } 2797 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) 2798 { 2404 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) { 2799 2405 return (float) $return[0]['data']; 2800 } 2801 elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) 2802 { 2406 } elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) { 2803 2407 return (float) $match[2]; 2804 } 2805 else 2806 { 2408 } else { 2807 2409 return null; 2808 2410 } … … 2811 2413 function get_image_title() 2812 2414 { 2813 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) 2814 { 2415 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) { 2815 2416 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2816 } 2817 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) 2818 { 2417 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) { 2819 2418 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2820 } 2821 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) 2822 { 2419 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { 2823 2420 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2824 } 2825 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) 2826 { 2421 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) { 2827 2422 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2828 } 2829 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) 2830 { 2423 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) { 2831 2424 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 2832 } 2833 else 2834 { 2425 } else { 2835 2426 return null; 2836 2427 } … … 2839 2430 function get_image_url() 2840 2431 { 2841 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) 2842 { 2432 if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) { 2843 2433 return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); 2844 } 2845 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) 2846 { 2434 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) { 2847 2435 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2848 } 2849 elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) 2850 { 2436 } elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) { 2851 2437 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2852 } 2853 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url')) 2854 { 2438 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url')) { 2855 2439 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2856 } 2857 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url')) 2858 { 2440 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url')) { 2859 2441 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2860 } 2861 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) 2862 { 2442 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { 2863 2443 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2864 } 2865 else 2866 { 2444 } else { 2867 2445 return null; 2868 2446 } … … 2871 2449 function get_image_link() 2872 2450 { 2873 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) 2874 { 2451 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) { 2875 2452 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2876 } 2877 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) 2878 { 2453 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) { 2879 2454 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2880 } 2881 elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) 2882 { 2455 } elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { 2883 2456 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 2884 } 2885 else 2886 { 2457 } else { 2887 2458 return null; 2888 2459 } … … 2891 2462 function get_image_width() 2892 2463 { 2893 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) 2894 { 2464 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) { 2895 2465 return round($return[0]['data']); 2896 } 2897 elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) 2898 { 2466 } elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { 2899 2467 return 88.0; 2900 } 2901 else 2902 { 2468 } else { 2903 2469 return null; 2904 2470 } … … 2907 2473 function get_image_height() 2908 2474 { 2909 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) 2910 { 2475 if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) { 2911 2476 return round($return[0]['data']); 2912 } 2913 elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) 2914 { 2477 } elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) { 2915 2478 return 31.0; 2916 } 2917 else 2918 { 2479 } else { 2919 2480 return null; 2920 2481 } … … 2925 2486 $max = (int) $max; 2926 2487 $qty = count($this->get_items()); 2927 if ($max === 0) 2928 { 2488 if ($max === 0) { 2929 2489 return $qty; 2930 } 2931 else 2932 { 2490 } else { 2933 2491 return ($qty > $max) ? $max : $qty; 2934 2492 } … … 2938 2496 { 2939 2497 $items = $this->get_items(); 2940 if (isset($items[$key])) 2941 { 2498 if (isset($items[$key])) { 2942 2499 return $items[$key]; 2943 } 2944 else 2945 { 2500 } else { 2946 2501 return null; 2947 2502 } … … 2950 2505 function get_items($start = 0, $end = 0) 2951 2506 { 2952 if (!isset($this->data['items'])) 2953 { 2954 if (!empty($this->multifeed_objects)) 2955 { 2507 if (!isset($this->data['items'])) { 2508 if (!empty($this->multifeed_objects)) { 2956 2509 $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); 2957 } 2958 else 2959 { 2510 } else { 2960 2511 $this->data['items'] = array(); 2961 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) 2962 { 2512 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) { 2963 2513 $keys = array_keys($items); 2964 foreach ($keys as $key) 2965 { 2514 foreach ($keys as $key) { 2966 2515 $this->data['items'][] = new $this->item_class($this, $items[$key]); 2967 2516 } 2968 2517 } 2969 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) 2970 { 2518 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) { 2971 2519 $keys = array_keys($items); 2972 foreach ($keys as $key) 2973 { 2520 foreach ($keys as $key) { 2974 2521 $this->data['items'][] = new $this->item_class($this, $items[$key]); 2975 2522 } 2976 2523 } 2977 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) 2978 { 2524 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) { 2979 2525 $keys = array_keys($items); 2980 foreach ($keys as $key) 2981 { 2526 foreach ($keys as $key) { 2982 2527 $this->data['items'][] = new $this->item_class($this, $items[$key]); 2983 2528 } 2984 2529 } 2985 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) 2986 { 2530 if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) { 2987 2531 $keys = array_keys($items); 2988 foreach ($keys as $key) 2989 { 2532 foreach ($keys as $key) { 2990 2533 $this->data['items'][] = new $this->item_class($this, $items[$key]); 2991 2534 } 2992 2535 } 2993 if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) 2994 { 2536 if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) { 2995 2537 $keys = array_keys($items); 2996 foreach ($keys as $key) 2997 { 2538 foreach ($keys as $key) { 2998 2539 $this->data['items'][] = new $this->item_class($this, $items[$key]); 2999 2540 } … … 3002 2543 } 3003 2544 3004 if (!empty($this->data['items'])) 3005 { 2545 if (!empty($this->data['items'])) { 3006 2546 // If we want to order it by date, check if all items have a date, and then sort it 3007 if ($this->order_by_date && empty($this->multifeed_objects)) 3008 { 3009 if (!isset($this->data['ordered_items'])) 3010 { 2547 if ($this->order_by_date && empty($this->multifeed_objects)) { 2548 if (!isset($this->data['ordered_items'])) { 3011 2549 $do_sort = true; 3012 foreach ($this->data['items'] as $item) 3013 { 3014 if (!$item->get_date('U')) 3015 { 2550 foreach ($this->data['items'] as $item) { 2551 if (!$item->get_date('U')) { 3016 2552 $do_sort = false; 3017 2553 break; … … 3020 2556 $item = null; 3021 2557 $this->data['ordered_items'] = $this->data['items']; 3022 if ($do_sort) 3023 { 2558 if ($do_sort) { 3024 2559 usort($this->data['ordered_items'], array(&$this, 'sort_items')); 3025 2560 } 3026 2561 } 3027 2562 $items = $this->data['ordered_items']; 3028 } 3029 else 3030 { 2563 } else { 3031 2564 $items = $this->data['items']; 3032 2565 } 3033 2566 3034 2567 // Slice the data as desired 3035 if ($end === 0) 3036 { 2568 if ($end === 0) { 3037 2569 return array_slice($items, $start); 3038 } 3039 else 3040 { 2570 } else { 3041 2571 return array_slice($items, $start, $end); 3042 2572 } 3043 } 3044 else 3045 { 2573 } else { 3046 2574 return array(); 3047 2575 } … … 3061 2589 function merge_items($urls, $start = 0, $end = 0, $limit = 0) 3062 2590 { 3063 if (is_array($urls) && sizeof($urls) > 0) 3064 { 2591 if (is_array($urls) && sizeof($urls) > 0) { 3065 2592 $items = array(); 3066 foreach ($urls as $arg) 3067 { 3068 if (is_a($arg, 'SimplePie')) 3069 { 2593 foreach ($urls as $arg) { 2594 if (is_a($arg, 'SimplePie')) { 3070 2595 $items = array_merge($items, $arg->get_items(0, $limit)); 3071 } 3072 else 3073 { 2596 } else { 3074 2597 trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); 3075 2598 } … … 3077 2600 3078 2601 $do_sort = true; 3079 foreach ($items as $item) 3080 { 3081 if (!$item->get_date('U')) 3082 { 2602 foreach ($items as $item) { 2603 if (!$item->get_date('U')) { 3083 2604 $do_sort = false; 3084 2605 break; … … 3086 2607 } 3087 2608 $item = null; 3088 if ($do_sort) 3089 { 2609 if ($do_sort) { 3090 2610 usort($items, array('SimplePie', 'sort_items')); 3091 2611 } 3092 2612 3093 if ($end === 0) 3094 { 2613 if ($end === 0) { 3095 2614 return array_slice($items, $start); 3096 } 3097 else 3098 { 2615 } else { 3099 2616 return array_slice($items, $start, $end); 3100 2617 } 3101 } 3102 else 3103 { 2618 } else { 3104 2619 trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING); 3105 2620 return array(); 3106 2621 } 3107 2622 } 2623 3108 2624 } 3109 2625 3110 2626 class SimplePie_Item 3111 2627 { 2628 3112 2629 var $feed; 3113 2630 var $data = array(); … … 3129 2646 function __destruct() 3130 2647 { 3131 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) 3132 { 2648 if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) { 3133 2649 unset($this->feed); 3134 2650 } … … 3137 2653 function get_item_tags($namespace, $tag) 3138 2654 { 3139 if (isset($this->data['child'][$namespace][$tag])) 3140 { 2655 if (isset($this->data['child'][$namespace][$tag])) { 3141 2656 return $this->data['child'][$namespace][$tag]; 3142 } 3143 else 3144 { 2657 } else { 3145 2658 return null; 3146 2659 } … … 3164 2677 function get_id($hash = false) 3165 2678 { 3166 if (!$hash) 3167 { 3168 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) 3169 { 2679 if (!$hash) { 2680 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) { 3170 2681 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3171 } 3172 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) 3173 { 2682 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) { 3174 2683 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3175 } 3176 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) 3177 { 2684 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) { 3178 2685 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3179 } 3180 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) 3181 { 2686 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) { 3182 2687 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3183 } 3184 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) 3185 { 2688 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) { 3186 2689 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3187 } 3188 elseif (($return = $this->get_permalink()) !== null) 3189 { 2690 } elseif (($return = $this->get_permalink()) !== null) { 3190 2691 return $return; 3191 } 3192 elseif (($return = $this->get_title()) !== null) 3193 { 2692 } elseif (($return = $this->get_title()) !== null) { 3194 2693 return $return; 3195 2694 } 3196 2695 } 3197 if ($this->get_permalink() !== null || $this->get_title() !== null) 3198 { 3199 return md5($this->get_permalink() . $this->get_title()); 3200 } 3201 else 3202 { 2696 if ($this->get_permalink() !== null || $this->get_title() !== null) { 2697 return md5($this->get_permalink().$this->get_title()); 2698 } else { 3203 2699 return md5(serialize($this->data)); 3204 2700 } … … 3207 2703 function get_title() 3208 2704 { 3209 if (!isset($this->data['title'])) 3210 { 3211 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) 3212 { 2705 if (!isset($this->data['title'])) { 2706 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) { 3213 2707 $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 3214 } 3215 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) 3216 { 2708 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) { 3217 2709 $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 3218 } 3219 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) 3220 { 2710 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) { 3221 2711 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 3222 } 3223 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) 3224 { 2712 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) { 3225 2713 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 3226 } 3227 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) 3228 { 2714 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { 3229 2715 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 3230 } 3231 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) 3232 { 2716 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) { 3233 2717 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3234 } 3235 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) 3236 { 2718 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) { 3237 2719 $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3238 } 3239 else 3240 { 2720 } else { 3241 2721 $this->data['title'] = null; 3242 2722 } … … 3247 2727 function get_description($description_only = false) 3248 2728 { 3249 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) 3250 { 2729 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) { 3251 2730 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 3252 } 3253 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) 3254 { 2731 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) { 3255 2732 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 3256 } 3257 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) 3258 { 2733 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) { 3259 2734 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 3260 } 3261 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) 3262 { 2735 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { 3263 2736 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 3264 } 3265 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) 3266 { 2737 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) { 3267 2738 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3268 } 3269 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) 3270 { 2739 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) { 3271 2740 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3272 } 3273 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) 3274 { 2741 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) { 3275 2742 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 3276 } 3277 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) 3278 { 2743 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) { 3279 2744 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3280 } 3281 elseif (!$description_only) 3282 { 2745 } elseif (!$description_only) { 3283 2746 return $this->get_content(true); 3284 } 3285 else 3286 { 2747 } else { 3287 2748 return null; 3288 2749 } … … 3291 2752 function get_content($content_only = false) 3292 2753 { 3293 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) 3294 { 2754 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) { 3295 2755 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0])); 3296 } 3297 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) 3298 { 2756 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) { 3299 2757 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 3300 } 3301 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) 3302 { 2758 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) { 3303 2759 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 3304 } 3305 elseif (!$content_only) 3306 { 2760 } elseif (!$content_only) { 3307 2761 return $this->get_description(true); 3308 } 3309 else 3310 { 2762 } else { 3311 2763 return null; 3312 2764 } … … 3316 2768 { 3317 2769 $categories = $this->get_categories(); 3318 if (isset($categories[$key])) 3319 { 2770 if (isset($categories[$key])) { 3320 2771 return $categories[$key]; 3321 } 3322 else 3323 { 2772 } else { 3324 2773 return null; 3325 2774 } … … 3330 2779 $categories = array(); 3331 2780 3332 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) 3333 { 2781 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { 3334 2782 $term = null; 3335 2783 $scheme = null; 3336 2784 $label = null; 3337 if (isset($category['attribs']['']['term'])) 3338 { 2785 if (isset($category['attribs']['']['term'])) { 3339 2786 $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); 3340 2787 } 3341 if (isset($category['attribs']['']['scheme'])) 3342 { 2788 if (isset($category['attribs']['']['scheme'])) { 3343 2789 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 3344 2790 } 3345 if (isset($category['attribs']['']['label'])) 3346 { 2791 if (isset($category['attribs']['']['label'])) { 3347 2792 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 3348 2793 } 3349 2794 $categories[] = new $this->feed->category_class($term, $scheme, $label); 3350 2795 } 3351 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) 3352 { 2796 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { 3353 2797 // This is really the label, but keep this as the term also for BC. 3354 2798 // Label will also work on retrieving because that falls back to term. 3355 2799 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3356 if (isset($category['attribs']['']['domain'])) 3357 { 2800 if (isset($category['attribs']['']['domain'])) { 3358 2801 $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); 3359 } 3360 else 3361 { 2802 } else { 3362 2803 $scheme = null; 3363 2804 } 3364 2805 $categories[] = new $this->feed->category_class($term, $scheme, null); 3365 2806 } 3366 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) 3367 { 2807 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { 3368 2808 $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 3369 2809 } 3370 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) 3371 { 2810 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) { 3372 2811 $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 3373 2812 } 3374 2813 3375 if (!empty($categories)) 3376 { 2814 if (!empty($categories)) { 3377 2815 return SimplePie_Misc::array_unique($categories); 3378 } 3379 else 3380 { 2816 } else { 3381 2817 return null; 3382 2818 } … … 3386 2822 { 3387 2823 $authors = $this->get_authors(); 3388 if (isset($authors[$key])) 3389 { 2824 if (isset($authors[$key])) { 3390 2825 return $authors[$key]; 3391 } 3392 else 3393 { 2826 } else { 3394 2827 return null; 3395 2828 } … … 3399 2832 { 3400 2833 $contributors = $this->get_contributors(); 3401 if (isset($contributors[$key])) 3402 { 2834 if (isset($contributors[$key])) { 3403 2835 return $contributors[$key]; 3404 } 3405 else 3406 { 2836 } else { 3407 2837 return null; 3408 2838 } … … 3412 2842 { 3413 2843 $contributors = array(); 3414 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) 3415 { 2844 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) { 3416 2845 $name = null; 3417 2846 $uri = null; 3418 2847 $email = null; 3419 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 3420 { 2848 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) { 3421 2849 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3422 2850 } 3423 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 3424 { 2851 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) { 3425 2852 $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 3426 2853 } 3427 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 3428 { 2854 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) { 3429 2855 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3430 2856 } 3431 if ($name !== null || $email !== null || $uri !== null) 3432 { 2857 if ($name !== null || $email !== null || $uri !== null) { 3433 2858 $contributors[] = new $this->feed->author_class($name, $uri, $email); 3434 2859 } 3435 2860 } 3436 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) 3437 { 2861 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) { 3438 2862 $name = null; 3439 2863 $url = null; 3440 2864 $email = null; 3441 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 3442 { 2865 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) { 3443 2866 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3444 2867 } 3445 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 3446 { 2868 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { 3447 2869 $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 3448 2870 } 3449 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 3450 { 2871 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) { 3451 2872 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3452 2873 } 3453 if ($name !== null || $email !== null || $url !== null) 3454 { 2874 if ($name !== null || $email !== null || $url !== null) { 3455 2875 $contributors[] = new $this->feed->author_class($name, $url, $email); 3456 2876 } 3457 2877 } 3458 2878 3459 if (!empty($contributors)) 3460 { 2879 if (!empty($contributors)) { 3461 2880 return SimplePie_Misc::array_unique($contributors); 3462 } 3463 else 3464 { 2881 } else { 3465 2882 return null; 3466 2883 } … … 3470 2887 { 3471 2888 $authors = array(); 3472 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) 3473 { 2889 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) { 3474 2890 $name = null; 3475 2891 $uri = null; 3476 2892 $email = null; 3477 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 3478 { 2893 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) { 3479 2894 $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3480 2895 } 3481 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 3482 { 2896 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) { 3483 2897 $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 3484 2898 } 3485 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 3486 { 2899 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) { 3487 2900 $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3488 2901 } 3489 if ($name !== null || $email !== null || $uri !== null) 3490 { 2902 if ($name !== null || $email !== null || $uri !== null) { 3491 2903 $authors[] = new $this->feed->author_class($name, $uri, $email); 3492 2904 } 3493 2905 } 3494 if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) 3495 { 2906 if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) { 3496 2907 $name = null; 3497 2908 $url = null; 3498 2909 $email = null; 3499 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 3500 { 2910 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) { 3501 2911 $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3502 2912 } 3503 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 3504 { 2913 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { 3505 2914 $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 3506 2915 } 3507 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 3508 { 2916 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) { 3509 2917 $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3510 2918 } 3511 if ($name !== null || $email !== null || $url !== null) 3512 { 2919 if ($name !== null || $email !== null || $url !== null) { 3513 2920 $authors[] = new $this->feed->author_class($name, $url, $email); 3514 2921 } 3515 2922 } 3516 if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) 3517 { 2923 if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) { 3518 2924 $authors[] = new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 3519 2925 } 3520 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) 3521 { 2926 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) { 3522 2927 $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 3523 2928 } 3524 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) 3525 { 2929 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) { 3526 2930 $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 3527 2931 } 3528 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) 3529 { 2932 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) { 3530 2933 $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 3531 2934 } 3532 2935 3533 if (!empty($authors)) 3534 { 2936 if (!empty($authors)) { 3535 2937 return SimplePie_Misc::array_unique($authors); 3536 } 3537 elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) 3538 { 2938 } elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) { 3539 2939 return $authors; 3540 } 3541 elseif ($authors = $this->feed->get_authors()) 3542 { 2940 } elseif ($authors = $this->feed->get_authors()) { 3543 2941 return $authors; 3544 } 3545 else 3546 { 2942 } else { 3547 2943 return null; 3548 2944 } … … 3551 2947 function get_copyright() 3552 2948 { 3553 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) 3554 { 2949 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) { 3555 2950 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 3556 } 3557 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) 3558 { 2951 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) { 3559 2952 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3560 } 3561 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) 3562 { 2953 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) { 3563 2954 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3564 } 3565 else 3566 { 2955 } else { 3567 2956 return null; 3568 2957 } … … 3571 2960 function get_date($date_format = 'j F Y, g:i a') 3572 2961 { 3573 if (!isset($this->data['date'])) 3574 { 3575 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) 3576 { 2962 if (!isset($this->data['date'])) { 2963 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) { 3577 2964 $this->data['date']['raw'] = $return[0]['data']; 3578 } 3579 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) 3580 { 2965 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) { 3581 2966 $this->data['date']['raw'] = $return[0]['data']; 3582 } 3583 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) 3584 { 2967 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) { 3585 2968 $this->data['date']['raw'] = $return[0]['data']; 3586 } 3587 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) 3588 { 2969 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) { 3589 2970 $this->data['date']['raw'] = $return[0]['data']; 3590 } 3591 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) 3592 { 2971 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) { 3593 2972 $this->data['date']['raw'] = $return[0]['data']; 3594 } 3595 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) 3596 { 2973 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) { 3597 2974 $this->data['date']['raw'] = $return[0]['data']; 3598 } 3599 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) 3600 { 2975 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) { 3601 2976 $this->data['date']['raw'] = $return[0]['data']; 3602 } 3603 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) 3604 { 2977 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) { 3605 2978 $this->data['date']['raw'] = $return[0]['data']; 3606 2979 } 3607 2980 3608 if (!empty($this->data['date']['raw'])) 3609 { 2981 if (!empty($this->data['date']['raw'])) { 3610 2982 $parser = SimplePie_Parse_Date::get(); 3611 2983 $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); 3612 } 3613 else 3614 { 2984 } else { 3615 2985 $this->data['date'] = null; 3616 2986 } 3617 2987 } 3618 if ($this->data['date']) 3619 { 2988 if ($this->data['date']) { 3620 2989 $date_format = (string) $date_format; 3621 switch ($date_format) 3622 { 2990 switch ($date_format) { 3623 2991 case '': 3624 2992 return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); … … 3630 2998 return date($date_format, $this->data['date']['parsed']); 3631 2999 } 3632 } 3633 else 3634 { 3000 } else { 3635 3001 return null; 3636 3002 } … … 3639 3005 function get_local_date($date_format = '%c') 3640 3006 { 3641 if (!$date_format) 3642 { 3007 if (!$date_format) { 3643 3008 return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); 3644 } 3645 elseif (($date = $this->get_date('U')) !== null) 3646 { 3009 } elseif (($date = $this->get_date('U')) !== null) { 3647 3010 return strftime($date_format, $date); 3648 } 3649 else 3650 { 3011 } else { 3651 3012 return null; 3652 3013 } … … 3657 3018 $link = $this->get_link(); 3658 3019 $enclosure = $this->get_enclosure(0); 3659 if ($link !== null) 3660 { 3020 if ($link !== null) { 3661 3021 return $link; 3662 } 3663 elseif ($enclosure !== null) 3664 { 3022 } elseif ($enclosure !== null) { 3665 3023 return $enclosure->get_link(); 3666 } 3667 else 3668 { 3024 } else { 3669 3025 return null; 3670 3026 } … … 3674 3030 { 3675 3031 $links = $this->get_links($rel); 3676 if ($links[$key] !== null) 3677 { 3032 if ($links[$key] !== null) { 3678 3033 return $links[$key]; 3679 } 3680 else 3681 { 3034 } else { 3682 3035 return null; 3683 3036 } … … 3686 3039 function get_links($rel = 'alternate') 3687 3040 { 3688 if (!isset($this->data['links'])) 3689 { 3041 if (!isset($this->data['links'])) { 3690 3042 $this->data['links'] = array(); 3691 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) 3692 { 3693 if (isset($link['attribs']['']['href'])) 3694 { 3043 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) { 3044 if (isset($link['attribs']['']['href'])) { 3695 3045 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 3696 3046 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 3697 3698 } 3699 } 3700 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) 3701 { 3702 if (isset($link['attribs']['']['href'])) 3703 { 3047 } 3048 } 3049 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) { 3050 if (isset($link['attribs']['']['href'])) { 3704 3051 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 3705 3052 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 3706 3053 } 3707 3054 } 3708 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) 3709 { 3055 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) { 3710 3056 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 3711 3057 } 3712 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) 3713 { 3058 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) { 3714 3059 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 3715 3060 } 3716 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) 3717 { 3061 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { 3718 3062 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 3719 3063 } 3720 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) 3721 { 3722 if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') 3723 { 3064 if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) { 3065 if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') { 3724 3066 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 3725 3067 } … … 3727 3069 3728 3070 $keys = array_keys($this->data['links']); 3729 foreach ($keys as $key) 3730 { 3731 if (SimplePie_Misc::is_isegment_nz_nc($key)) 3732 { 3733 if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) 3734 { 3735 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); 3736 $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; 3071 foreach ($keys as $key) { 3072 if (SimplePie_Misc::is_isegment_nz_nc($key)) { 3073 if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key])) { 3074 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]); 3075 $this->data['links'][$key] = & $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]; 3076 } else { 3077 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = & $this->data['links'][$key]; 3737 3078 } 3738 else 3739 { 3740 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; 3741 } 3742 } 3743 elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) 3744 { 3745 $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; 3079 } elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { 3080 $this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; 3746 3081 } 3747 3082 $this->data['links'][$key] = array_unique($this->data['links'][$key]); 3748 3083 } 3749 3084 } 3750 if (isset($this->data['links'][$rel])) 3751 { 3085 if (isset($this->data['links'][$rel])) { 3752 3086 return $this->data['links'][$rel]; 3753 } 3754 else 3755 { 3087 } else { 3756 3088 return null; 3757 3089 } … … 3764 3096 { 3765 3097 $enclosures = $this->get_enclosures(); 3766 if (isset($enclosures[$key])) 3767 { 3098 if (isset($enclosures[$key])) { 3768 3099 return $enclosures[$key]; 3769 } 3770 else 3771 { 3100 } else { 3772 3101 return null; 3773 3102 } … … 3786 3115 function get_enclosures() 3787 3116 { 3788 if (!isset($this->data['enclosures'])) 3789 { 3117 if (!isset($this->data['enclosures'])) { 3790 3118 $this->data['enclosures'] = array(); 3791 3119 … … 3809 3137 3810 3138 // CAPTIONS 3811 if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) 3812 { 3813 foreach ($captions as $caption) 3814 { 3139 if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) { 3140 foreach ($captions as $caption) { 3815 3141 $caption_type = null; 3816 3142 $caption_lang = null; … … 3818 3144 $caption_endTime = null; 3819 3145 $caption_text = null; 3820 if (isset($caption['attribs']['']['type'])) 3821 { 3146 if (isset($caption['attribs']['']['type'])) { 3822 3147 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 3823 3148 } 3824 if (isset($caption['attribs']['']['lang'])) 3825 { 3149 if (isset($caption['attribs']['']['lang'])) { 3826 3150 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 3827 3151 } 3828 if (isset($caption['attribs']['']['start'])) 3829 { 3152 if (isset($caption['attribs']['']['start'])) { 3830 3153 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 3831 3154 } 3832 if (isset($caption['attribs']['']['end'])) 3833 { 3155 if (isset($caption['attribs']['']['end'])) { 3834 3156 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 3835 3157 } 3836 if (isset($caption['data'])) 3837 { 3158 if (isset($caption['data'])) { 3838 3159 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3839 3160 } 3840 3161 $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); 3841 3162 } 3842 } 3843 elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) 3844 { 3845 foreach ($captions as $caption) 3846 { 3163 } elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) { 3164 foreach ($captions as $caption) { 3847 3165 $caption_type = null; 3848 3166 $caption_lang = null; … … 3850 3168 $caption_endTime = null; 3851 3169 $caption_text = null; 3852 if (isset($caption['attribs']['']['type'])) 3853 { 3170 if (isset($caption['attribs']['']['type'])) { 3854 3171 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 3855 3172 } 3856 if (isset($caption['attribs']['']['lang'])) 3857 { 3173 if (isset($caption['attribs']['']['lang'])) { 3858 3174 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 3859 3175 } 3860 if (isset($caption['attribs']['']['start'])) 3861 { 3176 if (isset($caption['attribs']['']['start'])) { 3862 3177 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 3863 3178 } 3864 if (isset($caption['attribs']['']['end'])) 3865 { 3179 if (isset($caption['attribs']['']['end'])) { 3866 3180 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 3867 3181 } 3868 if (isset($caption['data'])) 3869 { 3182 if (isset($caption['data'])) { 3870 3183 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3871 3184 } … … 3873 3186 } 3874 3187 } 3875 if (is_array($captions_parent)) 3876 { 3188 if (is_array($captions_parent)) { 3877 3189 $captions_parent = array_values(SimplePie_Misc::array_unique($captions_parent)); 3878 3190 } 3879 3191 3880 3192 // CATEGORIES 3881 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) 3882 { 3193 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) { 3883 3194 $term = null; 3884 3195 $scheme = null; 3885 3196 $label = null; 3886 if (isset($category['data'])) 3887 { 3197 if (isset($category['data'])) { 3888 3198 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3889 3199 } 3890 if (isset($category['attribs']['']['scheme'])) 3891 { 3200 if (isset($category['attribs']['']['scheme'])) { 3892 3201 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 3893 } 3894 else 3895 { 3202 } else { 3896 3203 $scheme = 'http://search.yahoo.com/mrss/category_schema'; 3897 3204 } 3898 if (isset($category['attribs']['']['label'])) 3899 { 3205 if (isset($category['attribs']['']['label'])) { 3900 3206 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 3901 3207 } 3902 3208 $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); 3903 3209 } 3904 foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) 3905 { 3210 foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) { 3906 3211 $term = null; 3907 3212 $scheme = null; 3908 3213 $label = null; 3909 if (isset($category['data'])) 3910 { 3214 if (isset($category['data'])) { 3911 3215 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3912 3216 } 3913 if (isset($category['attribs']['']['scheme'])) 3914 { 3217 if (isset($category['attribs']['']['scheme'])) { 3915 3218 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 3916 } 3917 else 3918 { 3219 } else { 3919 3220 $scheme = 'http://search.yahoo.com/mrss/category_schema'; 3920 3221 } 3921 if (isset($category['attribs']['']['label'])) 3922 { 3222 if (isset($category['attribs']['']['label'])) { 3923 3223 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 3924 3224 } 3925 3225 $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); 3926 3226 } 3927 foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) 3928 { 3227 foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) { 3929 3228 $term = null; 3930 3229 $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; 3931 3230 $label = null; 3932 if (isset($category['attribs']['']['text'])) 3933 { 3231 if (isset($category['attribs']['']['text'])) { 3934 3232 $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); 3935 3233 } 3936 3234 $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); 3937 3235 3938 if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) 3939 { 3940 foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) 3941 { 3942 if (isset($subcategory['attribs']['']['text'])) 3943 { 3236 if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) { 3237 foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) { 3238 if (isset($subcategory['attribs']['']['text'])) { 3944 3239 $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); 3945 3240 } … … 3948 3243 } 3949 3244 } 3950 if (is_array($categories_parent)) 3951 { 3245 if (is_array($categories_parent)) { 3952 3246 $categories_parent = array_values(SimplePie_Misc::array_unique($categories_parent)); 3953 3247 } 3954 3248 3955 3249 // COPYRIGHT 3956 if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) 3957 { 3250 if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) { 3958 3251 $copyright_url = null; 3959 3252 $copyright_label = null; 3960 if (isset($copyright[0]['attribs']['']['url'])) 3961 { 3253 if (isset($copyright[0]['attribs']['']['url'])) { 3962 3254 $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 3963 3255 } 3964 if (isset($copyright[0]['data'])) 3965 { 3256 if (isset($copyright[0]['data'])) { 3966 3257 $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3967 3258 } 3968 3259 $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label); 3969 } 3970 elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) 3971 { 3260 } elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) { 3972 3261 $copyright_url = null; 3973 3262 $copyright_label = null; 3974 if (isset($copyright[0]['attribs']['']['url'])) 3975 { 3263 if (isset($copyright[0]['attribs']['']['url'])) { 3976 3264 $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 3977 3265 } 3978 if (isset($copyright[0]['data'])) 3979 { 3266 if (isset($copyright[0]['data'])) { 3980 3267 $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 3981 3268 } … … 3984 3271 3985 3272 // CREDITS 3986 if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) 3987 { 3988 foreach ($credits as $credit) 3989 { 3273 if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) { 3274 foreach ($credits as $credit) { 3990 3275 $credit_role = null; 3991 3276 $credit_scheme = null; 3992 3277 $credit_name = null; 3993 if (isset($credit['attribs']['']['role'])) 3994 { 3278 if (isset($credit['attribs']['']['role'])) { 3995 3279 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 3996 3280 } 3997 if (isset($credit['attribs']['']['scheme'])) 3998 { 3281 if (isset($credit['attribs']['']['scheme'])) { 3999 3282 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4000 } 4001 else 4002 { 3283 } else { 4003 3284 $credit_scheme = 'urn:ebu'; 4004 3285 } 4005 if (isset($credit['data'])) 4006 { 3286 if (isset($credit['data'])) { 4007 3287 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4008 3288 } 4009 3289 $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); 4010 3290 } 4011 } 4012 elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) 4013 { 4014 foreach ($credits as $credit) 4015 { 3291 } elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) { 3292 foreach ($credits as $credit) { 4016 3293 $credit_role = null; 4017 3294 $credit_scheme = null; 4018 3295 $credit_name = null; 4019 if (isset($credit['attribs']['']['role'])) 4020 { 3296 if (isset($credit['attribs']['']['role'])) { 4021 3297 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 4022 3298 } 4023 if (isset($credit['attribs']['']['scheme'])) 4024 { 3299 if (isset($credit['attribs']['']['scheme'])) { 4025 3300 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4026 } 4027 else 4028 { 3301 } else { 4029 3302 $credit_scheme = 'urn:ebu'; 4030 3303 } 4031 if (isset($credit['data'])) 4032 { 3304 if (isset($credit['data'])) { 4033 3305 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4034 3306 } … … 4036 3308 } 4037 3309 } 4038 if (is_array($credits_parent)) 4039 { 3310 if (is_array($credits_parent)) { 4040 3311 $credits_parent = array_values(SimplePie_Misc::array_unique($credits_parent)); 4041 3312 } 4042 3313 4043 3314 // DESCRIPTION 4044 if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) 4045 { 4046 if (isset($description_parent[0]['data'])) 4047 { 3315 if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) { 3316 if (isset($description_parent[0]['data'])) { 4048 3317 $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4049 3318 } 4050 } 4051 elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) 4052 { 4053 if (isset($description_parent[0]['data'])) 4054 { 3319 } elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) { 3320 if (isset($description_parent[0]['data'])) { 4055 3321 $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4056 3322 } … … 4058 3324 4059 3325 // DURATION 4060 if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) 4061 { 3326 if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) { 4062 3327 $seconds = null; 4063 3328 $minutes = null; 4064 3329 $hours = null; 4065 if (isset($duration_parent[0]['data'])) 4066 { 3330 if (isset($duration_parent[0]['data'])) { 4067 3331 $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 4068 if (sizeof($temp) > 0) 4069 { 3332 if (sizeof($temp) > 0) { 4070 3333 (int) $seconds = array_pop($temp); 4071 3334 } 4072 if (sizeof($temp) > 0) 4073 { 3335 if (sizeof($temp) > 0) { 4074 3336 (int) $minutes = array_pop($temp); 4075 3337 $seconds += $minutes * 60; 4076 3338 } 4077 if (sizeof($temp) > 0) 4078 { 3339 if (sizeof($temp) > 0) { 4079 3340 (int) $hours = array_pop($temp); 4080 3341 $seconds += $hours * 3600; … … 4086 3347 4087 3348 // HASHES 4088 if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) 4089 { 4090 foreach ($hashes_iterator as $hash) 4091 { 3349 if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) { 3350 foreach ($hashes_iterator as $hash) { 4092 3351 $value = null; 4093 3352 $algo = null; 4094 if (isset($hash['data'])) 4095 { 3353 if (isset($hash['data'])) { 4096 3354 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4097 3355 } 4098 if (isset($hash['attribs']['']['algo'])) 4099 { 3356 if (isset($hash['attribs']['']['algo'])) { 4100 3357 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 4101 } 4102 else 4103 { 3358 } else { 4104 3359 $algo = 'md5'; 4105 3360 } 4106 3361 $hashes_parent[] = $algo.':'.$value; 4107 3362 } 4108 } 4109 elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) 4110 { 4111 foreach ($hashes_iterator as $hash) 4112 { 3363 } elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) { 3364 foreach ($hashes_iterator as $hash) { 4113 3365 $value = null; 4114 3366 $algo = null; 4115 if (isset($hash['data'])) 4116 { 3367 if (isset($hash['data'])) { 4117 3368 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4118 3369 } 4119 if (isset($hash['attribs']['']['algo'])) 4120 { 3370 if (isset($hash['attribs']['']['algo'])) { 4121 3371 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 4122 } 4123 else 4124 { 3372 } else { 4125 3373 $algo = 'md5'; 4126 3374 } … … 4128 3376 } 4129 3377 } 4130 if (is_array($hashes_parent)) 4131 { 3378 if (is_array($hashes_parent)) { 4132 3379 $hashes_parent = array_values(SimplePie_Misc::array_unique($hashes_parent)); 4133 3380 } 4134 3381 4135 3382 // KEYWORDS 4136 if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) 4137 { 4138 if (isset($keywords[0]['data'])) 4139 { 3383 if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) { 3384 if (isset($keywords[0]['data'])) { 4140 3385 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 4141 foreach ($temp as $word) 4142 { 3386 foreach ($temp as $word) { 4143 3387 $keywords_parent[] = trim($word); 4144 3388 } 4145 3389 } 4146 3390 unset($temp); 4147 } 4148 elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) 4149 { 4150 if (isset($keywords[0]['data'])) 4151 { 3391 } elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) { 3392 if (isset($keywords[0]['data'])) { 4152 3393 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 4153 foreach ($temp as $word) 4154 { 3394 foreach ($temp as $word) { 4155 3395 $keywords_parent[] = trim($word); 4156 3396 } 4157 3397 } 4158 3398 unset($temp); 4159 } 4160 elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) 4161 { 4162 if (isset($keywords[0]['data'])) 4163 { 3399 } elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) { 3400 if (isset($keywords[0]['data'])) { 4164 3401 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 4165 foreach ($temp as $word) 4166 { 3402 foreach ($temp as $word) { 4167 3403 $keywords_parent[] = trim($word); 4168 3404 } 4169 3405 } 4170 3406 unset($temp); 4171 } 4172 elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) 4173 { 4174 if (isset($keywords[0]['data'])) 4175 { 3407 } elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) { 3408 if (isset($keywords[0]['data'])) { 4176 3409 $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 4177 foreach ($temp as $word) 4178 { 3410 foreach ($temp as $word) { 4179 3411 $keywords_parent[] = trim($word); 4180 3412 } … … 4182 3414 unset($temp); 4183 3415 } 4184 if (is_array($keywords_parent)) 4185 { 3416 if (is_array($keywords_parent)) { 4186 3417 $keywords_parent = array_values(SimplePie_Misc::array_unique($keywords_parent)); 4187 3418 } 4188 3419 4189 3420 // PLAYER 4190 if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) 4191 { 4192 if (isset($player_parent[0]['attribs']['']['url'])) 4193 { 3421 if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) { 3422 if (isset($player_parent[0]['attribs']['']['url'])) { 4194 3423 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4195 3424 } 4196 } 4197 elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) 4198 { 4199 if (isset($player_parent[0]['attribs']['']['url'])) 4200 { 3425 } elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) { 3426 if (isset($player_parent[0]['attribs']['']['url'])) { 4201 3427 $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4202 3428 } … … 4204 3430 4205 3431 // RATINGS 4206 if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) 4207 { 4208 foreach ($ratings as $rating) 4209 { 3432 if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) { 3433 foreach ($ratings as $rating) { 4210 3434 $rating_scheme = null; 4211 3435 $rating_value = null; 4212 if (isset($rating['attribs']['']['scheme'])) 4213 { 3436 if (isset($rating['attribs']['']['scheme'])) { 4214 3437 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4215 } 4216 else 4217 { 3438 } else { 4218 3439 $rating_scheme = 'urn:simple'; 4219 3440 } 4220 if (isset($rating['data'])) 4221 { 3441 if (isset($rating['data'])) { 4222 3442 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4223 3443 } 4224 3444 $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); 4225 3445 } 4226 } 4227 elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) 4228 { 4229 foreach ($ratings as $rating) 4230 { 3446 } elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) { 3447 foreach ($ratings as $rating) { 4231 3448 $rating_scheme = 'urn:itunes'; 4232 3449 $rating_value = null; 4233 if (isset($rating['data'])) 4234 { 3450 if (isset($rating['data'])) { 4235 3451 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4236 3452 } 4237 3453 $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); 4238 3454 } 4239 } 4240 elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) 4241 { 4242 foreach ($ratings as $rating) 4243 { 3455 } elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) { 3456 foreach ($ratings as $rating) { 4244 3457 $rating_scheme = null; 4245 3458 $rating_value = null; 4246 if (isset($rating['attribs']['']['scheme'])) 4247 { 3459 if (isset($rating['attribs']['']['scheme'])) { 4248 3460 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4249 } 4250 else 4251 { 3461 } else { 4252 3462 $rating_scheme = 'urn:simple'; 4253 3463 } 4254 if (isset($rating['data'])) 4255 { 3464 if (isset($rating['data'])) { 4256 3465 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4257 3466 } 4258 3467 $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); 4259 3468 } 4260 } 4261 elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) 4262 { 4263 foreach ($ratings as $rating) 4264 { 3469 } elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) { 3470 foreach ($ratings as $rating) { 4265 3471 $rating_scheme = 'urn:itunes'; 4266 3472 $rating_value = null; 4267 if (isset($rating['data'])) 4268 { 3473 if (isset($rating['data'])) { 4269 3474 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4270 3475 } … … 4272 3477 } 4273 3478 } 4274 if (is_array($ratings_parent)) 4275 { 3479 if (is_array($ratings_parent)) { 4276 3480 $ratings_parent = array_values(SimplePie_Misc::array_unique($ratings_parent)); 4277 3481 } 4278 3482 4279 3483 // RESTRICTIONS 4280 if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) 4281 { 4282 foreach ($restrictions as $restriction) 4283 { 3484 if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) { 3485 foreach ($restrictions as $restriction) { 4284 3486 $restriction_relationship = null; 4285 3487 $restriction_type = null; 4286 3488 $restriction_value = null; 4287 if (isset($restriction['attribs']['']['relationship'])) 4288 { 3489 if (isset($restriction['attribs']['']['relationship'])) { 4289 3490 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 4290 3491 } 4291 if (isset($restriction['attribs']['']['type'])) 4292 { 3492 if (isset($restriction['attribs']['']['type'])) { 4293 3493 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4294 3494 } 4295 if (isset($restriction['data'])) 4296 { 3495 if (isset($restriction['data'])) { 4297 3496 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4298 3497 } 4299 3498 $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); 4300 3499 } 4301 } 4302 elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) 4303 { 4304 foreach ($restrictions as $restriction) 4305 { 3500 } elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) { 3501 foreach ($restrictions as $restriction) { 4306 3502 $restriction_relationship = 'allow'; 4307 3503 $restriction_type = null; 4308 3504 $restriction_value = 'itunes'; 4309 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') 4310 { 3505 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { 4311 3506 $restriction_relationship = 'deny'; 4312 3507 } 4313 3508 $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); 4314 3509 } 4315 } 4316 elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) 4317 { 4318 foreach ($restrictions as $restriction) 4319 { 3510 } elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) { 3511 foreach ($restrictions as $restriction) { 4320 3512 $restriction_relationship = null; 4321 3513 $restriction_type = null; 4322 3514 $restriction_value = null; 4323 if (isset($restriction['attribs']['']['relationship'])) 4324 { 3515 if (isset($restriction['attribs']['']['relationship'])) { 4325 3516 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 4326 3517 } 4327 if (isset($restriction['attribs']['']['type'])) 4328 { 3518 if (isset($restriction['attribs']['']['type'])) { 4329 3519 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4330 3520 } 4331 if (isset($restriction['data'])) 4332 { 3521 if (isset($restriction['data'])) { 4333 3522 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4334 3523 } 4335 3524 $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); 4336 3525 } 4337 } 4338 elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) 4339 { 4340 foreach ($restrictions as $restriction) 4341 { 3526 } elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) { 3527 foreach ($restrictions as $restriction) { 4342 3528 $restriction_relationship = 'allow'; 4343 3529 $restriction_type = null; 4344 3530 $restriction_value = 'itunes'; 4345 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') 4346 { 3531 if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') { 4347 3532 $restriction_relationship = 'deny'; 4348 3533 } … … 4350 3535 } 4351 3536 } 4352 if (is_array($restrictions_parent)) 4353 { 3537 if (is_array($restrictions_parent)) { 4354 3538 $restrictions_parent = array_values(SimplePie_Misc::array_unique($restrictions_parent)); 4355 3539 } 4356 3540 4357 3541 // THUMBNAILS 4358 if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) 4359 { 4360 foreach ($thumbnails as $thumbnail) 4361 { 4362 if (isset($thumbnail['attribs']['']['url'])) 4363 { 3542 if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) { 3543 foreach ($thumbnails as $thumbnail) { 3544 if (isset($thumbnail['attribs']['']['url'])) { 4364 3545 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4365 3546 } 4366 3547 } 4367 } 4368 elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) 4369 { 4370 foreach ($thumbnails as $thumbnail) 4371 { 4372 if (isset($thumbnail['attribs']['']['url'])) 4373 { 3548 } elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) { 3549 foreach ($thumbnails as $thumbnail) { 3550 if (isset($thumbnail['attribs']['']['url'])) { 4374 3551 $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4375 3552 } … … 4378 3555 4379 3556 // TITLES 4380 if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) 4381 { 4382 if (isset($title_parent[0]['data'])) 4383 { 3557 if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) { 3558 if (isset($title_parent[0]['data'])) { 4384 3559 $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4385 3560 } 4386 } 4387 elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) 4388 { 4389 if (isset($title_parent[0]['data'])) 4390 { 3561 } elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) { 3562 if (isset($title_parent[0]['data'])) { 4391 3563 $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4392 3564 } … … 4427 3599 4428 3600 // If we have media:group tags, loop through them. 4429 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) 4430 { 3601 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) { 4431 3602 // If we have media:content tags, loop through them. 4432 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) 4433 { 4434 if (isset($content['attribs']['']['url'])) 4435 { 3603 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) { 3604 if (isset($content['attribs']['']['url'])) { 4436 3605 // Attributes 4437 3606 $bitrate = null; … … 4465 3634 4466 3635 // Start checking the attributes of media:content 4467 if (isset($content['attribs']['']['bitrate'])) 4468 { 3636 if (isset($content['attribs']['']['bitrate'])) { 4469 3637 $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); 4470 3638 } 4471 if (isset($content['attribs']['']['channels'])) 4472 { 3639 if (isset($content['attribs']['']['channels'])) { 4473 3640 $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); 4474 3641 } 4475 if (isset($content['attribs']['']['duration'])) 4476 { 3642 if (isset($content['attribs']['']['duration'])) { 4477 3643 $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); 4478 } 4479 else 4480 { 3644 } else { 4481 3645 $duration = $duration_parent; 4482 3646 } 4483 if (isset($content['attribs']['']['expression'])) 4484 { 3647 if (isset($content['attribs']['']['expression'])) { 4485 3648 $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); 4486 3649 } 4487 if (isset($content['attribs']['']['framerate'])) 4488 { 3650 if (isset($content['attribs']['']['framerate'])) { 4489 3651 $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); 4490 3652 } 4491 if (isset($content['attribs']['']['height'])) 4492 { 3653 if (isset($content['attribs']['']['height'])) { 4493 3654 $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); 4494 3655 } 4495 if (isset($content['attribs']['']['lang'])) 4496 { 3656 if (isset($content['attribs']['']['lang'])) { 4497 3657 $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 4498 3658 } 4499 if (isset($content['attribs']['']['fileSize'])) 4500 { 3659 if (isset($content['attribs']['']['fileSize'])) { 4501 3660 $length = ceil($content['attribs']['']['fileSize']); 4502 3661 } 4503 if (isset($content['attribs']['']['medium'])) 4504 { 3662 if (isset($content['attribs']['']['medium'])) { 4505 3663 $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); 4506 3664 } 4507 if (isset($content['attribs']['']['samplingrate'])) 4508 { 3665 if (isset($content['attribs']['']['samplingrate'])) { 4509 3666 $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); 4510 3667 } 4511 if (isset($content['attribs']['']['type'])) 4512 { 3668 if (isset($content['attribs']['']['type'])) { 4513 3669 $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4514 3670 } 4515 if (isset($content['attribs']['']['width'])) 4516 { 3671 if (isset($content['attribs']['']['width'])) { 4517 3672 $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); 4518 3673 } … … 4520 3675 4521 3676 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel 4522 4523 3677 // CAPTIONS 4524 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) 4525 { 4526 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) 4527 { 3678 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) { 3679 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) { 4528 3680 $caption_type = null; 4529 3681 $caption_lang = null; … … 4531 3683 $caption_endTime = null; 4532 3684 $caption_text = null; 4533 if (isset($caption['attribs']['']['type'])) 4534 { 3685 if (isset($caption['attribs']['']['type'])) { 4535 3686 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4536 3687 } 4537 if (isset($caption['attribs']['']['lang'])) 4538 { 3688 if (isset($caption['attribs']['']['lang'])) { 4539 3689 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 4540 3690 } 4541 if (isset($caption['attribs']['']['start'])) 4542 { 3691 if (isset($caption['attribs']['']['start'])) { 4543 3692 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 4544 3693 } 4545 if (isset($caption['attribs']['']['end'])) 4546 { 3694 if (isset($caption['attribs']['']['end'])) { 4547 3695 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 4548 3696 } 4549 if (isset($caption['data'])) 4550 { 3697 if (isset($caption['data'])) { 4551 3698 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4552 3699 } 4553 3700 $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); 4554 3701 } 4555 if (is_array($captions)) 4556 { 3702 if (is_array($captions)) { 4557 3703 $captions = array_values(SimplePie_Misc::array_unique($captions)); 4558 3704 } 4559 } 4560 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) 4561 { 4562 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) 4563 { 3705 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) { 3706 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) { 4564 3707 $caption_type = null; 4565 3708 $caption_lang = null; … … 4567 3710 $caption_endTime = null; 4568 3711 $caption_text = null; 4569 if (isset($caption['attribs']['']['type'])) 4570 { 3712 if (isset($caption['attribs']['']['type'])) { 4571 3713 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4572 3714 } 4573 if (isset($caption['attribs']['']['lang'])) 4574 { 3715 if (isset($caption['attribs']['']['lang'])) { 4575 3716 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 4576 3717 } 4577 if (isset($caption['attribs']['']['start'])) 4578 { 3718 if (isset($caption['attribs']['']['start'])) { 4579 3719 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 4580 3720 } 4581 if (isset($caption['attribs']['']['end'])) 4582 { 3721 if (isset($caption['attribs']['']['end'])) { 4583 3722 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 4584 3723 } 4585 if (isset($caption['data'])) 4586 { 3724 if (isset($caption['data'])) { 4587 3725 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4588 3726 } 4589 3727 $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); 4590 3728 } 4591 if (is_array($captions)) 4592 { 3729 if (is_array($captions)) { 4593 3730 $captions = array_values(SimplePie_Misc::array_unique($captions)); 4594 3731 } 4595 } 4596 else 4597 { 3732 } else { 4598 3733 $captions = $captions_parent; 4599 3734 } 4600 3735 4601 3736 // CATEGORIES 4602 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) 4603 { 4604 foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) 4605 { 3737 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { 3738 foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) { 4606 3739 $term = null; 4607 3740 $scheme = null; 4608 3741 $label = null; 4609 if (isset($category['data'])) 4610 { 3742 if (isset($category['data'])) { 4611 3743 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4612 3744 } 4613 if (isset($category['attribs']['']['scheme'])) 4614 { 3745 if (isset($category['attribs']['']['scheme'])) { 4615 3746 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4616 } 4617 else 4618 { 3747 } else { 4619 3748 $scheme = 'http://search.yahoo.com/mrss/category_schema'; 4620 3749 } 4621 if (isset($category['attribs']['']['label'])) 4622 { 3750 if (isset($category['attribs']['']['label'])) { 4623 3751 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 4624 3752 } … … 4626 3754 } 4627 3755 } 4628 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) 4629 { 4630 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) 4631 { 3756 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { 3757 foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) { 4632 3758 $term = null; 4633 3759 $scheme = null; 4634 3760 $label = null; 4635 if (isset($category['data'])) 4636 { 3761 if (isset($category['data'])) { 4637 3762 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4638 3763 } 4639 if (isset($category['attribs']['']['scheme'])) 4640 { 3764 if (isset($category['attribs']['']['scheme'])) { 4641 3765 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4642 } 4643 else 4644 { 3766 } else { 4645 3767 $scheme = 'http://search.yahoo.com/mrss/category_schema'; 4646 3768 } 4647 if (isset($category['attribs']['']['label'])) 4648 { 3769 if (isset($category['attribs']['']['label'])) { 4649 3770 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 4650 3771 } … … 4652 3773 } 4653 3774 } 4654 if (is_array($categories) && is_array($categories_parent)) 4655 { 3775 if (is_array($categories) && is_array($categories_parent)) { 4656 3776 $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); 4657 } 4658 elseif (is_array($categories)) 4659 { 3777 } elseif (is_array($categories)) { 4660 3778 $categories = array_values(SimplePie_Misc::array_unique($categories)); 4661 } 4662 elseif (is_array($categories_parent)) 4663 { 3779 } elseif (is_array($categories_parent)) { 4664 3780 $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); 4665 3781 } 4666 3782 4667 3783 // COPYRIGHTS 4668 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) 4669 { 3784 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { 4670 3785 $copyright_url = null; 4671 3786 $copyright_label = null; 4672 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) 4673 { 3787 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) { 4674 3788 $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 4675 3789 } 4676 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) 4677 { 3790 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) { 4678 3791 $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4679 3792 } 4680 3793 $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); 4681 } 4682 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) 4683 { 3794 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { 4684 3795 $copyright_url = null; 4685 3796 $copyright_label = null; 4686 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) 4687 { 3797 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) { 4688 3798 $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 4689 3799 } 4690 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) 4691 { 3800 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) { 4692 3801 $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4693 3802 } 4694 3803 $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); 4695 } 4696 else 4697 { 3804 } else { 4698 3805 $copyrights = $copyrights_parent; 4699 3806 } 4700 3807 4701 3808 // CREDITS 4702 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) 4703 { 4704 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) 4705 { 3809 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) { 3810 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) { 4706 3811 $credit_role = null; 4707 3812 $credit_scheme = null; 4708 3813 $credit_name = null; 4709 if (isset($credit['attribs']['']['role'])) 4710 { 3814 if (isset($credit['attribs']['']['role'])) { 4711 3815 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 4712 3816 } 4713 if (isset($credit['attribs']['']['scheme'])) 4714 { 3817 if (isset($credit['attribs']['']['scheme'])) { 4715 3818 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4716 } 4717 else 4718 { 3819 } else { 4719 3820 $credit_scheme = 'urn:ebu'; 4720 3821 } 4721 if (isset($credit['data'])) 4722 { 3822 if (isset($credit['data'])) { 4723 3823 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4724 3824 } 4725 3825 $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); 4726 3826 } 4727 if (is_array($credits)) 4728 { 3827 if (is_array($credits)) { 4729 3828 $credits = array_values(SimplePie_Misc::array_unique($credits)); 4730 3829 } 4731 } 4732 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) 4733 { 4734 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) 4735 { 3830 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) { 3831 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) { 4736 3832 $credit_role = null; 4737 3833 $credit_scheme = null; 4738 3834 $credit_name = null; 4739 if (isset($credit['attribs']['']['role'])) 4740 { 3835 if (isset($credit['attribs']['']['role'])) { 4741 3836 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 4742 3837 } 4743 if (isset($credit['attribs']['']['scheme'])) 4744 { 3838 if (isset($credit['attribs']['']['scheme'])) { 4745 3839 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4746 } 4747 else 4748 { 3840 } else { 4749 3841 $credit_scheme = 'urn:ebu'; 4750 3842 } 4751 if (isset($credit['data'])) 4752 { 3843 if (isset($credit['data'])) { 4753 3844 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4754 3845 } 4755 3846 $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); 4756 3847 } 4757 if (is_array($credits)) 4758 { 3848 if (is_array($credits)) { 4759 3849 $credits = array_values(SimplePie_Misc::array_unique($credits)); 4760 3850 } 4761 } 4762 else 4763 { 3851 } else { 4764 3852 $credits = $credits_parent; 4765 3853 } 4766 3854 4767 3855 // DESCRIPTION 4768 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) 4769 { 3856 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) { 4770 3857 $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4771 } 4772 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) 4773 { 3858 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) { 4774 3859 $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4775 } 4776 else 4777 { 3860 } else { 4778 3861 $description = $description_parent; 4779 3862 } 4780 3863 4781 3864 // HASHES 4782 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) 4783 { 4784 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) 4785 { 3865 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { 3866 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) { 4786 3867 $value = null; 4787 3868 $algo = null; 4788 if (isset($hash['data'])) 4789 { 3869 if (isset($hash['data'])) { 4790 3870 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4791 3871 } 4792 if (isset($hash['attribs']['']['algo'])) 4793 { 3872 if (isset($hash['attribs']['']['algo'])) { 4794 3873 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 4795 } 4796 else 4797 { 3874 } else { 4798 3875 $algo = 'md5'; 4799 3876 } 4800 3877 $hashes[] = $algo.':'.$value; 4801 3878 } 4802 if (is_array($hashes)) 4803 { 3879 if (is_array($hashes)) { 4804 3880 $hashes = array_values(SimplePie_Misc::array_unique($hashes)); 4805 3881 } 4806 } 4807 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) 4808 { 4809 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) 4810 { 3882 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { 3883 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) { 4811 3884 $value = null; 4812 3885 $algo = null; 4813 if (isset($hash['data'])) 4814 { 3886 if (isset($hash['data'])) { 4815 3887 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4816 3888 } 4817 if (isset($hash['attribs']['']['algo'])) 4818 { 3889 if (isset($hash['attribs']['']['algo'])) { 4819 3890 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 4820 } 4821 else 4822 { 3891 } else { 4823 3892 $algo = 'md5'; 4824 3893 } 4825 3894 $hashes[] = $algo.':'.$value; 4826 3895 } 4827 if (is_array($hashes)) 4828 { 3896 if (is_array($hashes)) { 4829 3897 $hashes = array_values(SimplePie_Misc::array_unique($hashes)); 4830 3898 } 4831 } 4832 else 4833 { 3899 } else { 4834 3900 $hashes = $hashes_parent; 4835 3901 } 4836 3902 4837 3903 // KEYWORDS 4838 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) 4839 { 4840 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) 4841 { 3904 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { 3905 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) { 4842 3906 $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 4843 foreach ($temp as $word) 4844 { 3907 foreach ($temp as $word) { 4845 3908 $keywords[] = trim($word); 4846 3909 } 4847 3910 unset($temp); 4848 3911 } 4849 if (is_array($keywords)) 4850 { 3912 if (is_array($keywords)) { 4851 3913 $keywords = array_values(SimplePie_Misc::array_unique($keywords)); 4852 3914 } 4853 } 4854 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) 4855 { 4856 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) 4857 { 3915 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { 3916 if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) { 4858 3917 $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 4859 foreach ($temp as $word) 4860 { 3918 foreach ($temp as $word) { 4861 3919 $keywords[] = trim($word); 4862 3920 } 4863 3921 unset($temp); 4864 3922 } 4865 if (is_array($keywords)) 4866 { 3923 if (is_array($keywords)) { 4867 3924 $keywords = array_values(SimplePie_Misc::array_unique($keywords)); 4868 3925 } 4869 } 4870 else 4871 { 3926 } else { 4872 3927 $keywords = $keywords_parent; 4873 3928 } 4874 3929 4875 3930 // PLAYER 4876 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 4877 { 3931 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) { 4878 3932 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4879 } 4880 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 4881 { 3933 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) { 4882 3934 $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 4883 } 4884 else 4885 { 3935 } else { 4886 3936 $player = $player_parent; 4887 3937 } 4888 3938 4889 3939 // RATINGS 4890 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) 4891 { 4892 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) 4893 { 3940 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { 3941 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) { 4894 3942 $rating_scheme = null; 4895 3943 $rating_value = null; 4896 if (isset($rating['attribs']['']['scheme'])) 4897 { 3944 if (isset($rating['attribs']['']['scheme'])) { 4898 3945 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4899 } 4900 else 4901 { 3946 } else { 4902 3947 $rating_scheme = 'urn:simple'; 4903 3948 } 4904 if (isset($rating['data'])) 4905 { 3949 if (isset($rating['data'])) { 4906 3950 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4907 3951 } 4908 3952 $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); 4909 3953 } 4910 if (is_array($ratings)) 4911 { 3954 if (is_array($ratings)) { 4912 3955 $ratings = array_values(SimplePie_Misc::array_unique($ratings)); 4913 3956 } 4914 } 4915 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) 4916 { 4917 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) 4918 { 3957 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { 3958 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) { 4919 3959 $rating_scheme = null; 4920 3960 $rating_value = null; 4921 if (isset($rating['attribs']['']['scheme'])) 4922 { 3961 if (isset($rating['attribs']['']['scheme'])) { 4923 3962 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 4924 } 4925 else 4926 { 3963 } else { 4927 3964 $rating_scheme = 'urn:simple'; 4928 3965 } 4929 if (isset($rating['data'])) 4930 { 3966 if (isset($rating['data'])) { 4931 3967 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4932 3968 } 4933 3969 $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); 4934 3970 } 4935 if (is_array($ratings)) 4936 { 3971 if (is_array($ratings)) { 4937 3972 $ratings = array_values(SimplePie_Misc::array_unique($ratings)); 4938 3973 } 4939 } 4940 else 4941 { 3974 } else { 4942 3975 $ratings = $ratings_parent; 4943 3976 } 4944 3977 4945 3978 // RESTRICTIONS 4946 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) 4947 { 4948 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) 4949 { 3979 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { 3980 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) { 4950 3981 $restriction_relationship = null; 4951 3982 $restriction_type = null; 4952 3983 $restriction_value = null; 4953 if (isset($restriction['attribs']['']['relationship'])) 4954 { 3984 if (isset($restriction['attribs']['']['relationship'])) { 4955 3985 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 4956 3986 } 4957 if (isset($restriction['attribs']['']['type'])) 4958 { 3987 if (isset($restriction['attribs']['']['type'])) { 4959 3988 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4960 3989 } 4961 if (isset($restriction['data'])) 4962 { 3990 if (isset($restriction['data'])) { 4963 3991 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4964 3992 } 4965 3993 $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); 4966 3994 } 4967 if (is_array($restrictions)) 4968 { 3995 if (is_array($restrictions)) { 4969 3996 $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); 4970 3997 } 4971 } 4972 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) 4973 { 4974 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) 4975 { 3998 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { 3999 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) { 4976 4000 $restriction_relationship = null; 4977 4001 $restriction_type = null; 4978 4002 $restriction_value = null; 4979 if (isset($restriction['attribs']['']['relationship'])) 4980 { 4003 if (isset($restriction['attribs']['']['relationship'])) { 4981 4004 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 4982 4005 } 4983 if (isset($restriction['attribs']['']['type'])) 4984 { 4006 if (isset($restriction['attribs']['']['type'])) { 4985 4007 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 4986 4008 } 4987 if (isset($restriction['data'])) 4988 { 4009 if (isset($restriction['data'])) { 4989 4010 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 4990 4011 } 4991 4012 $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); 4992 4013 } 4993 if (is_array($restrictions)) 4994 { 4014 if (is_array($restrictions)) { 4995 4015 $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); 4996 4016 } 4997 } 4998 else 4999 { 4017 } else { 5000 4018 $restrictions = $restrictions_parent; 5001 4019 } 5002 4020 5003 4021 // THUMBNAILS 5004 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) 5005 { 5006 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 5007 { 4022 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { 4023 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { 5008 4024 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 5009 4025 } 5010 if (is_array($thumbnails)) 5011 { 4026 if (is_array($thumbnails)) { 5012 4027 $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); 5013 4028 } 5014 } 5015 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) 5016 { 5017 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 5018 { 4029 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { 4030 foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { 5019 4031 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 5020 4032 } 5021 if (is_array($thumbnails)) 5022 { 4033 if (is_array($thumbnails)) { 5023 4034 $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); 5024 4035 } 5025 } 5026 else 5027 { 4036 } else { 5028 4037 $thumbnails = $thumbnails_parent; 5029 4038 } 5030 4039 5031 4040 // TITLES 5032 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) 5033 { 4041 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) { 5034 4042 $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5035 } 5036 elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) 5037 { 4043 } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) { 5038 4044 $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5039 } 5040 else 5041 { 4045 } else { 5042 4046 $title = $title_parent; 5043 4047 } … … 5049 4053 5050 4054 // If we have standalone media:content tags, loop through them. 5051 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) 5052 { 5053 foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) 5054 { 5055 if (isset($content['attribs']['']['url'])) 5056 { 4055 if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) { 4056 foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) { 4057 if (isset($content['attribs']['']['url'])) { 5057 4058 // Attributes 5058 4059 $bitrate = null; … … 5086 4087 5087 4088 // Start checking the attributes of media:content 5088 if (isset($content['attribs']['']['bitrate'])) 5089 { 4089 if (isset($content['attribs']['']['bitrate'])) { 5090 4090 $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); 5091 4091 } 5092 if (isset($content['attribs']['']['channels'])) 5093 { 4092 if (isset($content['attribs']['']['channels'])) { 5094 4093 $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); 5095 4094 } 5096 if (isset($content['attribs']['']['duration'])) 5097 { 4095 if (isset($content['attribs']['']['duration'])) { 5098 4096 $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); 5099 } 5100 else 5101 { 4097 } else { 5102 4098 $duration = $duration_parent; 5103 4099 } 5104 if (isset($content['attribs']['']['expression'])) 5105 { 4100 if (isset($content['attribs']['']['expression'])) { 5106 4101 $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); 5107 4102 } 5108 if (isset($content['attribs']['']['framerate'])) 5109 { 4103 if (isset($content['attribs']['']['framerate'])) { 5110 4104 $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); 5111 4105 } 5112 if (isset($content['attribs']['']['height'])) 5113 { 4106 if (isset($content['attribs']['']['height'])) { 5114 4107 $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); 5115 4108 } 5116 if (isset($content['attribs']['']['lang'])) 5117 { 4109 if (isset($content['attribs']['']['lang'])) { 5118 4110 $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 5119 4111 } 5120 if (isset($content['attribs']['']['fileSize'])) 5121 { 4112 if (isset($content['attribs']['']['fileSize'])) { 5122 4113 $length = ceil($content['attribs']['']['fileSize']); 5123 4114 } 5124 if (isset($content['attribs']['']['medium'])) 5125 { 4115 if (isset($content['attribs']['']['medium'])) { 5126 4116 $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); 5127 4117 } 5128 if (isset($content['attribs']['']['samplingrate'])) 5129 { 4118 if (isset($content['attribs']['']['samplingrate'])) { 5130 4119 $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); 5131 4120 } 5132 if (isset($content['attribs']['']['type'])) 5133 { 4121 if (isset($content['attribs']['']['type'])) { 5134 4122 $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 5135 4123 } 5136 if (isset($content['attribs']['']['width'])) 5137 { 4124 if (isset($content['attribs']['']['width'])) { 5138 4125 $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); 5139 4126 } … … 5141 4128 5142 4129 // Checking the other optional media: elements. Priority: media:content, media:group, item, channel 5143 5144 4130 // CAPTIONS 5145 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) 5146 { 5147 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) 5148 { 4131 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) { 4132 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) { 5149 4133 $caption_type = null; 5150 4134 $caption_lang = null; … … 5152 4136 $caption_endTime = null; 5153 4137 $caption_text = null; 5154 if (isset($caption['attribs']['']['type'])) 5155 { 4138 if (isset($caption['attribs']['']['type'])) { 5156 4139 $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 5157 4140 } 5158 if (isset($caption['attribs']['']['lang'])) 5159 { 4141 if (isset($caption['attribs']['']['lang'])) { 5160 4142 $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 5161 4143 } 5162 if (isset($caption['attribs']['']['start'])) 5163 { 4144 if (isset($caption['attribs']['']['start'])) { 5164 4145 $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 5165 4146 } 5166 if (isset($caption['attribs']['']['end'])) 5167 { 4147 if (isset($caption['attribs']['']['end'])) { 5168 4148 $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 5169 4149 } 5170 if (isset($caption['data'])) 5171 { 4150 if (isset($caption['data'])) { 5172 4151 $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5173 4152 } 5174 4153 $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); 5175 4154 } 5176 if (is_array($captions)) 5177 { 4155 if (is_array($captions)) { 5178 4156 $captions = array_values(SimplePie_Misc::array_unique($captions)); 5179 4157 } 5180 } 5181 else 5182 { 4158 } else { 5183 4159 $captions = $captions_parent; 5184 4160 } 5185 4161 5186 4162 // CATEGORIES 5187 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) 5188 { 5189 foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) 5190 { 4163 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) { 4164 foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) { 5191 4165 $term = null; 5192 4166 $scheme = null; 5193 4167 $label = null; 5194 if (isset($category['data'])) 5195 { 4168 if (isset($category['data'])) { 5196 4169 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5197 4170 } 5198 if (isset($category['attribs']['']['scheme'])) 5199 { 4171 if (isset($category['attribs']['']['scheme'])) { 5200 4172 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 5201 } 5202 else 5203 { 4173 } else { 5204 4174 $scheme = 'http://search.yahoo.com/mrss/category_schema'; 5205 4175 } 5206 if (isset($category['attribs']['']['label'])) 5207 { 4176 if (isset($category['attribs']['']['label'])) { 5208 4177 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 5209 4178 } … … 5211 4180 } 5212 4181 } 5213 if (is_array($categories) && is_array($categories_parent)) 5214 { 4182 if (is_array($categories) && is_array($categories_parent)) { 5215 4183 $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); 5216 } 5217 elseif (is_array($categories)) 5218 { 4184 } elseif (is_array($categories)) { 5219 4185 $categories = array_values(SimplePie_Misc::array_unique($categories)); 5220 } 5221 elseif (is_array($categories_parent)) 5222 { 4186 } elseif (is_array($categories_parent)) { 5223 4187 $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); 5224 } 5225 else 5226 { 4188 } else { 5227 4189 $categories = null; 5228 4190 } 5229 4191 5230 4192 // COPYRIGHTS 5231 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) 5232 { 4193 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { 5233 4194 $copyright_url = null; 5234 4195 $copyright_label = null; 5235 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) 5236 { 4196 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) { 5237 4197 $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 5238 4198 } 5239 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) 5240 { 4199 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) { 5241 4200 $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5242 4201 } 5243 4202 $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); 5244 } 5245 else 5246 { 4203 } else { 5247 4204 $copyrights = $copyrights_parent; 5248 4205 } 5249 4206 5250 4207 // CREDITS 5251 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) 5252 { 5253 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) 5254 { 4208 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) { 4209 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) { 5255 4210 $credit_role = null; 5256 4211 $credit_scheme = null; 5257 4212 $credit_name = null; 5258 if (isset($credit['attribs']['']['role'])) 5259 { 4213 if (isset($credit['attribs']['']['role'])) { 5260 4214 $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 5261 4215 } 5262 if (isset($credit['attribs']['']['scheme'])) 5263 { 4216 if (isset($credit['attribs']['']['scheme'])) { 5264 4217 $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 5265 } 5266 else 5267 { 4218 } else { 5268 4219 $credit_scheme = 'urn:ebu'; 5269 4220 } 5270 if (isset($credit['data'])) 5271 { 4221 if (isset($credit['data'])) { 5272 4222 $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5273 4223 } 5274 4224 $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); 5275 4225 } 5276 if (is_array($credits)) 5277 { 4226 if (is_array($credits)) { 5278 4227 $credits = array_values(SimplePie_Misc::array_unique($credits)); 5279 4228 } 5280 } 5281 else 5282 { 4229 } else { 5283 4230 $credits = $credits_parent; 5284 4231 } 5285 4232 5286 4233 // DESCRIPTION 5287 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) 5288 { 4234 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) { 5289 4235 $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5290 } 5291 else 5292 { 4236 } else { 5293 4237 $description = $description_parent; 5294 4238 } 5295 4239 5296 4240 // HASHES 5297 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) 5298 { 5299 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) 5300 { 4241 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) { 4242 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) { 5301 4243 $value = null; 5302 4244 $algo = null; 5303 if (isset($hash['data'])) 5304 { 4245 if (isset($hash['data'])) { 5305 4246 $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5306 4247 } 5307 if (isset($hash['attribs']['']['algo'])) 5308 { 4248 if (isset($hash['attribs']['']['algo'])) { 5309 4249 $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 5310 } 5311 else 5312 { 4250 } else { 5313 4251 $algo = 'md5'; 5314 4252 } 5315 4253 $hashes[] = $algo.':'.$value; 5316 4254 } 5317 if (is_array($hashes)) 5318 { 4255 if (is_array($hashes)) { 5319 4256 $hashes = array_values(SimplePie_Misc::array_unique($hashes)); 5320 4257 } 5321 } 5322 else 5323 { 4258 } else { 5324 4259 $hashes = $hashes_parent; 5325 4260 } 5326 4261 5327 4262 // KEYWORDS 5328 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) 5329 { 5330 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) 5331 { 4263 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) { 4264 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) { 5332 4265 $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 5333 foreach ($temp as $word) 5334 { 4266 foreach ($temp as $word) { 5335 4267 $keywords[] = trim($word); 5336 4268 } 5337 4269 unset($temp); 5338 4270 } 5339 if (is_array($keywords)) 5340 { 4271 if (is_array($keywords)) { 5341 4272 $keywords = array_values(SimplePie_Misc::array_unique($keywords)); 5342 4273 } 5343 } 5344 else 5345 { 4274 } else { 5346 4275 $keywords = $keywords_parent; 5347 4276 } 5348 4277 5349 4278 // PLAYER 5350 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 5351 { 4279 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) { 5352 4280 $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 5353 } 5354 else 5355 { 4281 } else { 5356 4282 $player = $player_parent; 5357 4283 } 5358 4284 5359 4285 // RATINGS 5360 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) 5361 { 5362 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) 5363 { 4286 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) { 4287 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) { 5364 4288 $rating_scheme = null; 5365 4289 $rating_value = null; 5366 if (isset($rating['attribs']['']['scheme'])) 5367 { 4290 if (isset($rating['attribs']['']['scheme'])) { 5368 4291 $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 5369 } 5370 else 5371 { 4292 } else { 5372 4293 $rating_scheme = 'urn:simple'; 5373 4294 } 5374 if (isset($rating['data'])) 5375 { 4295 if (isset($rating['data'])) { 5376 4296 $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5377 4297 } 5378 4298 $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); 5379 4299 } 5380 if (is_array($ratings)) 5381 { 4300 if (is_array($ratings)) { 5382 4301 $ratings = array_values(SimplePie_Misc::array_unique($ratings)); 5383 4302 } 5384 } 5385 else 5386 { 4303 } else { 5387 4304 $ratings = $ratings_parent; 5388 4305 } 5389 4306 5390 4307 // RESTRICTIONS 5391 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) 5392 { 5393 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) 5394 { 4308 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) { 4309 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) { 5395 4310 $restriction_relationship = null; 5396 4311 $restriction_type = null; 5397 4312 $restriction_value = null; 5398 if (isset($restriction['attribs']['']['relationship'])) 5399 { 4313 if (isset($restriction['attribs']['']['relationship'])) { 5400 4314 $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 5401 4315 } 5402 if (isset($restriction['attribs']['']['type'])) 5403 { 4316 if (isset($restriction['attribs']['']['type'])) { 5404 4317 $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 5405 4318 } 5406 if (isset($restriction['data'])) 5407 { 4319 if (isset($restriction['data'])) { 5408 4320 $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5409 4321 } 5410 4322 $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); 5411 4323 } 5412 if (is_array($restrictions)) 5413 { 4324 if (is_array($restrictions)) { 5414 4325 $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); 5415 4326 } 5416 } 5417 else 5418 { 4327 } else { 5419 4328 $restrictions = $restrictions_parent; 5420 4329 } 5421 4330 5422 4331 // THUMBNAILS 5423 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) 5424 { 5425 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 5426 { 4332 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) { 4333 foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) { 5427 4334 $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 5428 4335 } 5429 if (is_array($thumbnails)) 5430 { 4336 if (is_array($thumbnails)) { 5431 4337 $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); 5432 4338 } 5433 } 5434 else 5435 { 4339 } else { 5436 4340 $thumbnails = $thumbnails_parent; 5437 4341 } 5438 4342 5439 4343 // TITLES 5440 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) 5441 { 4344 if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) { 5442 4345 $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5443 } 5444 else 5445 { 4346 } else { 5446 4347 $title = $title_parent; 5447 4348 } … … 5452 4353 } 5453 4354 5454 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) 5455 { 5456 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') 5457 { 4355 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) { 4356 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') { 5458 4357 // Attributes 5459 4358 $bitrate = null; … … 5473 4372 5474 4373 $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 5475 if (isset($link['attribs']['']['type'])) 5476 { 4374 if (isset($link['attribs']['']['type'])) { 5477 4375 $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 5478 4376 } 5479 if (isset($link['attribs']['']['length'])) 5480 { 4377 if (isset($link['attribs']['']['length'])) { 5481 4378 $length = ceil($link['attribs']['']['length']); 5482 4379 } … … 5487 4384 } 5488 4385 5489 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) 5490 { 5491 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') 5492 { 4386 foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) { 4387 if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') { 5493 4388 // Attributes 5494 4389 $bitrate = null; … … 5508 4403 5509 4404 $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 5510 if (isset($link['attribs']['']['type'])) 5511 { 4405 if (isset($link['attribs']['']['type'])) { 5512 4406 $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 5513 4407 } 5514 if (isset($link['attribs']['']['length'])) 5515 { 4408 if (isset($link['attribs']['']['length'])) { 5516 4409 $length = ceil($link['attribs']['']['length']); 5517 4410 } … … 5522 4415 } 5523 4416 5524 if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) 5525 { 5526 if (isset($enclosure[0]['attribs']['']['url'])) 5527 { 4417 if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) { 4418 if (isset($enclosure[0]['attribs']['']['url'])) { 5528 4419 // Attributes 5529 4420 $bitrate = null; … … 5543 4434 5544 4435 $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); 5545 if (isset($enclosure[0]['attribs']['']['type'])) 5546 { 4436 if (isset($enclosure[0]['attribs']['']['type'])) { 5547 4437 $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 5548 4438 } 5549 if (isset($enclosure[0]['attribs']['']['length'])) 5550 { 4439 if (isset($enclosure[0]['attribs']['']['length'])) { 5551 4440 $length = ceil($enclosure[0]['attribs']['']['length']); 5552 4441 } … … 5557 4446 } 5558 4447 5559 if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) 5560 { 4448 if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) { 5561 4449 // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 5562 4450 $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); … … 5565 4453 $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures'])); 5566 4454 } 5567 if (!empty($this->data['enclosures'])) 5568 { 4455 if (!empty($this->data['enclosures'])) { 5569 4456 return $this->data['enclosures']; 5570 } 5571 else 5572 { 4457 } else { 5573 4458 return null; 5574 4459 } … … 5577 4462 function get_latitude() 5578 4463 { 5579 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) 5580 { 4464 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) { 5581 4465 return (float) $return[0]['data']; 5582 } 5583 elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) 5584 { 4466 } elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) { 5585 4467 return (float) $match[1]; 5586 } 5587 else 5588 { 4468 } else { 5589 4469 return null; 5590 4470 } … … 5593 4473 function get_longitude() 5594 4474 { 5595 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) 5596 { 4475 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) { 5597 4476 return (float) $return[0]['data']; 5598 } 5599 elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) 5600 { 4477 } elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) { 5601 4478 return (float) $return[0]['data']; 5602 } 5603 elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) 5604 { 4479 } elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) { 5605 4480 return (float) $match[2]; 5606 } 5607 else 5608 { 4481 } else { 5609 4482 return null; 5610 4483 } … … 5613 4486 function get_source() 5614 4487 { 5615 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) 5616 { 4488 if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) { 5617 4489 return new $this->feed->source_class($this, $return[0]); 5618 } 5619 else 5620 { 4490 } else { 5621 4491 return null; 5622 4492 } … … 5634 4504 function add_to_service($item_url, $title_url = null, $summary_url = null) 5635 4505 { 5636 if ($this->get_permalink() !== null) 5637 { 5638 $return = $item_url . rawurlencode($this->get_permalink()); 5639 if ($title_url !== null && $this->get_title() !== null) 5640 { 5641 $return .= $title_url . rawurlencode($this->get_title()); 5642 } 5643 if ($summary_url !== null && $this->get_description() !== null) 5644 { 5645 $return .= $summary_url . rawurlencode($this->get_description()); 4506 if ($this->get_permalink() !== null) { 4507 $return = $item_url.rawurlencode($this->get_permalink()); 4508 if ($title_url !== null && $this->get_title() !== null) { 4509 $return .= $title_url.rawurlencode($this->get_title()); 4510 } 4511 if ($summary_url !== null && $this->get_description() !== null) { 4512 $return .= $summary_url.rawurlencode($this->get_description()); 5646 4513 } 5647 4514 return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); 5648 } 5649 else 5650 { 4515 } else { 5651 4516 return null; 5652 4517 } … … 5722 4587 return $this->add_to_service('http://www.technorati.com/search/'); 5723 4588 } 4589 5724 4590 } 5725 4591 5726 4592 class SimplePie_Source 5727 4593 { 4594 5728 4595 var $item; 5729 4596 var $data = array(); … … 5742 4609 function get_source_tags($namespace, $tag) 5743 4610 { 5744 if (isset($this->data['child'][$namespace][$tag])) 5745 { 4611 if (isset($this->data['child'][$namespace][$tag])) { 5746 4612 return $this->data['child'][$namespace][$tag]; 5747 } 5748 else 5749 { 4613 } else { 5750 4614 return null; 5751 4615 } … … 5769 4633 function get_title() 5770 4634 { 5771 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) 5772 { 4635 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) { 5773 4636 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 5774 } 5775 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) 5776 { 4637 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) { 5777 4638 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 5778 } 5779 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) 5780 { 4639 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) { 5781 4640 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 5782 } 5783 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) 5784 { 4641 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) { 5785 4642 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 5786 } 5787 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) 5788 { 4643 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) { 5789 4644 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 5790 } 5791 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) 5792 { 4645 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) { 5793 4646 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5794 } 5795 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) 5796 { 4647 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) { 5797 4648 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5798 } 5799 else 5800 { 4649 } else { 5801 4650 return null; 5802 4651 } … … 5806 4655 { 5807 4656 $categories = $this->get_categories(); 5808 if (isset($categories[$key])) 5809 { 4657 if (isset($categories[$key])) { 5810 4658 return $categories[$key]; 5811 } 5812 else 5813 { 4659 } else { 5814 4660 return null; 5815 4661 } … … 5820 4666 $categories = array(); 5821 4667 5822 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) 5823 { 4668 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) { 5824 4669 $term = null; 5825 4670 $scheme = null; 5826 4671 $label = null; 5827 if (isset($category['attribs']['']['term'])) 5828 { 4672 if (isset($category['attribs']['']['term'])) { 5829 4673 $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); 5830 4674 } 5831 if (isset($category['attribs']['']['scheme'])) 5832 { 4675 if (isset($category['attribs']['']['scheme'])) { 5833 4676 $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 5834 4677 } 5835 if (isset($category['attribs']['']['label'])) 5836 { 4678 if (isset($category['attribs']['']['label'])) { 5837 4679 $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 5838 4680 } 5839 4681 $categories[] = new $this->item->feed->category_class($term, $scheme, $label); 5840 4682 } 5841 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) 5842 { 4683 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { 5843 4684 // This is really the label, but keep this as the term also for BC. 5844 4685 // Label will also work on retrieving because that falls back to term. 5845 4686 $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5846 if (isset($category['attribs']['']['domain'])) 5847 { 4687 if (isset($category['attribs']['']['domain'])) { 5848 4688 $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); 5849 } 5850 else 5851 { 4689 } else { 5852 4690 $scheme = null; 5853 4691 } 5854 4692 $categories[] = new $this->item->feed->category_class($term, $scheme, null); 5855 4693 } 5856 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) 5857 { 4694 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { 5858 4695 $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 5859 4696 } 5860 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) 5861 { 4697 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) { 5862 4698 $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 5863 4699 } 5864 4700 5865 if (!empty($categories)) 5866 { 4701 if (!empty($categories)) { 5867 4702 return SimplePie_Misc::array_unique($categories); 5868 } 5869 else 5870 { 4703 } else { 5871 4704 return null; 5872 4705 } … … 5876 4709 { 5877 4710 $authors = $this->get_authors(); 5878 if (isset($authors[$key])) 5879 { 4711 if (isset($authors[$key])) { 5880 4712 return $authors[$key]; 5881 } 5882 else 5883 { 4713 } else { 5884 4714 return null; 5885 4715 } … … 5889 4719 { 5890 4720 $authors = array(); 5891 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) 5892 { 4721 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) { 5893 4722 $name = null; 5894 4723 $uri = null; 5895 4724 $email = null; 5896 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 5897 { 4725 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) { 5898 4726 $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5899 4727 } 5900 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 5901 { 4728 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) { 5902 4729 $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 5903 4730 } 5904 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 5905 { 4731 if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) { 5906 4732 $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5907 4733 } 5908 if ($name !== null || $email !== null || $uri !== null) 5909 { 4734 if ($name !== null || $email !== null || $uri !== null) { 5910 4735 $authors[] = new $this->item->feed->author_class($name, $uri, $email); 5911 4736 } 5912 4737 } 5913 if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) 5914 { 4738 if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) { 5915 4739 $name = null; 5916 4740 $url = null; 5917 4741 $email = null; 5918 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 5919 { 4742 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) { 5920 4743 $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5921 4744 } 5922 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 5923 { 4745 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { 5924 4746 $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 5925 4747 } 5926 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 5927 { 4748 if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) { 5928 4749 $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5929 4750 } 5930 if ($name !== null || $email !== null || $url !== null) 5931 { 4751 if ($name !== null || $email !== null || $url !== null) { 5932 4752 $authors[] = new $this->item->feed->author_class($name, $url, $email); 5933 4753 } 5934 4754 } 5935 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) 5936 { 4755 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) { 5937 4756 $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 5938 4757 } 5939 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) 5940 { 4758 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) { 5941 4759 $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 5942 4760 } 5943 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) 5944 { 4761 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) { 5945 4762 $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); 5946 4763 } 5947 4764 5948 if (!empty($authors)) 5949 { 4765 if (!empty($authors)) { 5950 4766 return SimplePie_Misc::array_unique($authors); 5951 } 5952 else 5953 { 4767 } else { 5954 4768 return null; 5955 4769 } … … 5959 4773 { 5960 4774 $contributors = $this->get_contributors(); 5961 if (isset($contributors[$key])) 5962 { 4775 if (isset($contributors[$key])) { 5963 4776 return $contributors[$key]; 5964 } 5965 else 5966 { 4777 } else { 5967 4778 return null; 5968 4779 } … … 5972 4783 { 5973 4784 $contributors = array(); 5974 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) 5975 { 4785 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) { 5976 4786 $name = null; 5977 4787 $uri = null; 5978 4788 $email = null; 5979 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 5980 { 4789 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) { 5981 4790 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5982 4791 } 5983 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 5984 { 4792 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) { 5985 4793 $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 5986 4794 } 5987 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 5988 { 4795 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) { 5989 4796 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 5990 4797 } 5991 if ($name !== null || $email !== null || $uri !== null) 5992 { 4798 if ($name !== null || $email !== null || $uri !== null) { 5993 4799 $contributors[] = new $this->item->feed->author_class($name, $uri, $email); 5994 4800 } 5995 4801 } 5996 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) 5997 { 4802 foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) { 5998 4803 $name = null; 5999 4804 $url = null; 6000 4805 $email = null; 6001 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 6002 { 4806 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) { 6003 4807 $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6004 4808 } 6005 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 6006 { 4809 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) { 6007 4810 $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 6008 4811 } 6009 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 6010 { 4812 if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) { 6011 4813 $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6012 4814 } 6013 if ($name !== null || $email !== null || $url !== null) 6014 { 4815 if ($name !== null || $email !== null || $url !== null) { 6015 4816 $contributors[] = new $this->item->feed->author_class($name, $url, $email); 6016 4817 } 6017 4818 } 6018 4819 6019 if (!empty($contributors)) 6020 { 4820 if (!empty($contributors)) { 6021 4821 return SimplePie_Misc::array_unique($contributors); 6022 } 6023 else 6024 { 4822 } else { 6025 4823 return null; 6026 4824 } … … 6030 4828 { 6031 4829 $links = $this->get_links($rel); 6032 if (isset($links[$key])) 6033 { 4830 if (isset($links[$key])) { 6034 4831 return $links[$key]; 6035 } 6036 else 6037 { 4832 } else { 6038 4833 return null; 6039 4834 } … … 6050 4845 function get_links($rel = 'alternate') 6051 4846 { 6052 if (!isset($this->data['links'])) 6053 { 4847 if (!isset($this->data['links'])) { 6054 4848 $this->data['links'] = array(); 6055 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) 6056 { 6057 foreach ($links as $link) 6058 { 6059 if (isset($link['attribs']['']['href'])) 6060 { 4849 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) { 4850 foreach ($links as $link) { 4851 if (isset($link['attribs']['']['href'])) { 6061 4852 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 6062 4853 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); … … 6064 4855 } 6065 4856 } 6066 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) 6067 { 6068 foreach ($links as $link) 6069 { 6070 if (isset($link['attribs']['']['href'])) 6071 { 4857 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) { 4858 foreach ($links as $link) { 4859 if (isset($link['attribs']['']['href'])) { 6072 4860 $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 6073 4861 $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 6074 6075 4862 } 6076 4863 } 6077 4864 } 6078 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) 6079 { 4865 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) { 6080 4866 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 6081 4867 } 6082 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) 6083 { 4868 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) { 6084 4869 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 6085 4870 } 6086 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) 6087 { 4871 if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) { 6088 4872 $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 6089 4873 } 6090 4874 6091 4875 $keys = array_keys($this->data['links']); 6092 foreach ($keys as $key) 6093 { 6094 if (SimplePie_Misc::is_isegment_nz_nc($key)) 6095 { 6096 if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) 6097 { 6098 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); 6099 $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; 4876 foreach ($keys as $key) { 4877 if (SimplePie_Misc::is_isegment_nz_nc($key)) { 4878 if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key])) { 4879 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]); 4880 $this->data['links'][$key] = & $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key]; 4881 } else { 4882 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY.$key] = & $this->data['links'][$key]; 6100 4883 } 6101 else 6102 { 6103 $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; 6104 } 6105 } 6106 elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) 6107 { 6108 $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; 4884 } elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) { 4885 $this->data['links'][substr($key, 41)] = & $this->data['links'][$key]; 6109 4886 } 6110 4887 $this->data['links'][$key] = array_unique($this->data['links'][$key]); … … 6112 4889 } 6113 4890 6114 if (isset($this->data['links'][$rel])) 6115 { 4891 if (isset($this->data['links'][$rel])) { 6116 4892 return $this->data['links'][$rel]; 6117 } 6118 else 6119 { 4893 } else { 6120 4894 return null; 6121 4895 } … … 6124 4898 function get_description() 6125 4899 { 6126 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) 6127 { 4900 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) { 6128 4901 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 6129 } 6130 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) 6131 { 4902 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) { 6132 4903 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 6133 } 6134 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) 6135 { 4904 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) { 6136 4905 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 6137 } 6138 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) 6139 { 4906 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) { 6140 4907 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 6141 } 6142 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) 6143 { 4908 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) { 6144 4909 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 6145 } 6146 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) 6147 { 4910 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) { 6148 4911 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6149 } 6150 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) 6151 { 4912 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) { 6152 4913 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6153 } 6154 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) 6155 { 4914 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) { 6156 4915 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 6157 } 6158 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) 6159 { 4916 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) { 6160 4917 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 6161 } 6162 else 6163 { 4918 } else { 6164 4919 return null; 6165 4920 } … … 6168 4923 function get_copyright() 6169 4924 { 6170 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) 6171 { 4925 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) { 6172 4926 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); 6173 } 6174 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) 6175 { 4927 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) { 6176 4928 return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); 6177 } 6178 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) 6179 { 4929 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) { 6180 4930 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6181 } 6182 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) 6183 { 4931 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) { 6184 4932 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6185 } 6186 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) 6187 { 4933 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) { 6188 4934 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6189 } 6190 else 6191 { 4935 } else { 6192 4936 return null; 6193 4937 } … … 6196 4940 function get_language() 6197 4941 { 6198 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) 6199 { 4942 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) { 6200 4943 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6201 } 6202 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) 6203 { 4944 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) { 6204 4945 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6205 } 6206 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) 6207 { 4946 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) { 6208 4947 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 6209 } 6210 elseif (isset($this->data['xml_lang'])) 6211 { 4948 } elseif (isset($this->data['xml_lang'])) { 6212 4949 return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); 6213 } 6214 else 6215 { 4950 } else { 6216 4951 return null; 6217 4952 } … … 6220 4955 function get_latitude() 6221 4956 { 6222 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) 6223 { 4957 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) { 6224 4958 return (float) $return[0]['data']; 6225 } 6226 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) 6227 { 4959 } elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) { 6228 4960 return (float) $match[1]; 6229 } 6230 else 6231 { 4961 } else { 6232 4962 return null; 6233 4963 } … … 6236 4966 function get_longitude() 6237 4967 { 6238 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) 6239 { 4968 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) { 6240 4969 return (float) $return[0]['data']; 6241 } 6242 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) 6243 { 4970 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) { 6244 4971 return (float) $return[0]['data']; 6245 } 6246 elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) 6247 { 4972 } elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) { 6248 4973 return (float) $match[2]; 6249 } 6250 else 6251 { 4974 } else { 6252 4975 return null; 6253 4976 } … … 6256 4979 function get_image_url() 6257 4980 { 6258 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) 6259 { 4981 if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) { 6260 4982 return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); 6261 } 6262 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) 6263 { 4983 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) { 6264 4984 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 6265 } 6266 elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) 6267 { 4985 } elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) { 6268 4986 return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); 6269 } 6270 else 6271 { 4987 } else { 6272 4988 return null; 6273 4989 } 6274 4990 } 4991 6275 4992 } 6276 4993 6277 4994 class SimplePie_Author 6278 4995 { 4996 6279 4997 var $name; 6280 4998 var $link; … … 6297 5015 function get_name() 6298 5016 { 6299 if ($this->name !== null) 6300 { 5017 if ($this->name !== null) { 6301 5018 return $this->name; 6302 } 6303 else 6304 { 5019 } else { 6305 5020 return null; 6306 5021 } … … 6309 5024 function get_link() 6310 5025 { 6311 if ($this->link !== null) 6312 { 5026 if ($this->link !== null) { 6313 5027 return $this->link; 6314 } 6315 else 6316 { 5028 } else { 6317 5029 return null; 6318 5030 } … … 6321 5033 function get_email() 6322 5034 { 6323 if ($this->email !== null) 6324 { 5035 if ($this->email !== null) { 6325 5036 return $this->email; 6326 } 6327 else 6328 { 5037 } else { 6329 5038 return null; 6330 5039 } 6331 5040 } 5041 6332 5042 } 6333 5043 6334 5044 class SimplePie_Category 6335 5045 { 5046 6336 5047 var $term; 6337 5048 var $scheme; … … 6354 5065 function get_term() 6355 5066 { 6356 if ($this->term !== null) 6357 { 5067 if ($this->term !== null) { 6358 5068 return $this->term; 6359 } 6360 else 6361 { 5069 } else { 6362 5070 return null; 6363 5071 } … … 6366 5074 function get_scheme() 6367 5075 { 6368 if ($this->scheme !== null) 6369 { 5076 if ($this->scheme !== null) { 6370 5077 return $this->scheme; 6371 } 6372 else 6373 { 5078 } else { 6374 5079 return null; 6375 5080 } … … 6378 5083 function get_label() 6379 5084 { 6380 if ($this->label !== null) 6381 { 5085 if ($this->label !== null) { 6382 5086 return $this->label; 6383 } 6384 else 6385 { 5087 } else { 6386 5088 return $this->get_term(); 6387 5089 } 6388 5090 } 5091 6389 5092 } 6390 5093 6391 5094 class SimplePie_Enclosure 6392 5095 { 5096 6393 5097 var $bitrate; 6394 5098 var $captions; … … 6448 5152 $this->type = $type; 6449 5153 $this->width = $width; 6450 if (class_exists('idna_convert')) 6451 { 5154 if (class_exists('idna_convert')) { 6452 5155 $idn = new idna_convert; 6453 5156 $parsed = SimplePie_Misc::parse_url($link); … … 6465 5168 function get_bitrate() 6466 5169 { 6467 if ($this->bitrate !== null) 6468 { 5170 if ($this->bitrate !== null) { 6469 5171 return $this->bitrate; 6470 } 6471 else 6472 { 5172 } else { 6473 5173 return null; 6474 5174 } … … 6478 5178 { 6479 5179 $captions = $this->get_captions(); 6480 if (isset($captions[$key])) 6481 { 5180 if (isset($captions[$key])) { 6482 5181 return $captions[$key]; 6483 } 6484 else 6485 { 5182 } else { 6486 5183 return null; 6487 5184 } … … 6490 5187 function get_captions() 6491 5188 { 6492 if ($this->captions !== null) 6493 { 5189 if ($this->captions !== null) { 6494 5190 return $this->captions; 6495 } 6496 else 6497 { 5191 } else { 6498 5192 return null; 6499 5193 } … … 6503 5197 { 6504 5198 $categories = $this->get_categories(); 6505 if (isset($categories[$key])) 6506 { 5199 if (isset($categories[$key])) { 6507 5200 return $categories[$key]; 6508 } 6509 else 6510 { 5201 } else { 6511 5202 return null; 6512 5203 } … … 6515 5206 function get_categories() 6516 5207 { 6517 if ($this->categories !== null) 6518 { 5208 if ($this->categories !== null) { 6519 5209 return $this->categories; 6520 } 6521 else 6522 { 5210 } else { 6523 5211 return null; 6524 5212 } … … 6527 5215 function get_channels() 6528 5216 { 6529 if ($this->channels !== null) 6530 { 5217 if ($this->channels !== null) { 6531 5218 return $this->channels; 6532 } 6533 else 6534 { 5219 } else { 6535 5220 return null; 6536 5221 } … … 6539 5224 function get_copyright() 6540 5225 { 6541 if ($this->copyright !== null) 6542 { 5226 if ($this->copyright !== null) { 6543 5227 return $this->copyright; 6544 } 6545 else 6546 { 5228 } else { 6547 5229 return null; 6548 5230 } … … 6552 5234 { 6553 5235 $credits = $this->get_credits(); 6554 if (isset($credits[$key])) 6555 { 5236 if (isset($credits[$key])) { 6556 5237 return $credits[$key]; 6557 } 6558 else 6559 { 5238 } else { 6560 5239 return null; 6561 5240 } … … 6564 5243 function get_credits() 6565 5244 { 6566 if ($this->credits !== null) 6567 { 5245 if ($this->credits !== null) { 6568 5246 return $this->credits; 6569 } 6570 else 6571 { 5247 } else { 6572 5248 return null; 6573 5249 } … … 6576 5252 function get_description() 6577 5253 { 6578 if ($this->description !== null) 6579 { 5254 if ($this->description !== null) { 6580 5255 return $this->description; 6581 } 6582 else 6583 { 5256 } else { 6584 5257 return null; 6585 5258 } … … 6588 5261 function get_duration($convert = false) 6589 5262 { 6590 if ($this->duration !== null) 6591 { 6592 if ($convert) 6593 { 5263 if ($this->duration !== null) { 5264 if ($convert) { 6594 5265 $time = SimplePie_Misc::time_hms($this->duration); 6595 5266 return $time; 6596 } 6597 else 6598 { 5267 } else { 6599 5268 return $this->duration; 6600 5269 } 6601 } 6602 else 6603 { 5270 } else { 6604 5271 return null; 6605 5272 } … … 6608 5275 function get_expression() 6609 5276 { 6610 if ($this->expression !== null) 6611 { 5277 if ($this->expression !== null) { 6612 5278 return $this->expression; 6613 } 6614 else 6615 { 5279 } else { 6616 5280 return 'full'; 6617 5281 } … … 6620 5284 function get_extension() 6621 5285 { 6622 if ($this->link !== null) 6623 { 5286 if ($this->link !== null) { 6624 5287 $url = SimplePie_Misc::parse_url($this->link); 6625 if ($url['path'] !== '') 6626 { 5288 if ($url['path'] !== '') { 6627 5289 return pathinfo($url['path'], PATHINFO_EXTENSION); 6628 5290 } … … 6633 5295 function get_framerate() 6634 5296 { 6635 if ($this->framerate !== null) 6636 { 5297 if ($this->framerate !== null) { 6637 5298 return $this->framerate; 6638 } 6639 else 6640 { 5299 } else { 6641 5300 return null; 6642 5301 } … … 6651 5310 { 6652 5311 $hashes = $this->get_hashes(); 6653 if (isset($hashes[$key])) 6654 { 5312 if (isset($hashes[$key])) { 6655 5313 return $hashes[$key]; 6656 } 6657 else 6658 { 5314 } else { 6659 5315 return null; 6660 5316 } … … 6663 5319 function get_hashes() 6664 5320 { 6665 if ($this->hashes !== null) 6666 { 5321 if ($this->hashes !== null) { 6667 5322 return $this->hashes; 6668 } 6669 else 6670 { 5323 } else { 6671 5324 return null; 6672 5325 } … … 6675 5328 function get_height() 6676 5329 { 6677 if ($this->height !== null) 6678 { 5330 if ($this->height !== null) { 6679 5331 return $this->height; 6680 } 6681 else 6682 { 5332 } else { 6683 5333 return null; 6684 5334 } … … 6687 5337 function get_language() 6688 5338 { 6689 if ($this->lang !== null) 6690 { 5339 if ($this->lang !== null) { 6691 5340 return $this->lang; 6692 } 6693 else 6694 { 5341 } else { 6695 5342 return null; 6696 5343 } … … 6700 5347 { 6701 5348 $keywords = $this->get_keywords(); 6702 if (isset($keywords[$key])) 6703 { 5349 if (isset($keywords[$key])) { 6704 5350 return $keywords[$key]; 6705 } 6706 else 6707 { 5351 } else { 6708 5352 return null; 6709 5353 } … … 6712 5356 function get_keywords() 6713 5357 { 6714 if ($this->keywords !== null) 6715 { 5358 if ($this->keywords !== null) { 6716 5359 return $this->keywords; 6717 } 6718 else 6719 { 5360 } else { 6720 5361 return null; 6721 5362 } … … 6724 5365 function get_length() 6725 5366 { 6726 if ($this->length !== null) 6727 { 5367 if ($this->length !== null) { 6728 5368 return $this->length; 6729 } 6730 else 6731 { 5369 } else { 6732 5370 return null; 6733 5371 } … … 6736 5374 function get_link() 6737 5375 { 6738 if ($this->link !== null) 6739 { 5376 if ($this->link !== null) { 6740 5377 return urldecode($this->link); 6741 } 6742 else 6743 { 5378 } else { 6744 5379 return null; 6745 5380 } … … 6748 5383 function get_medium() 6749 5384 { 6750 if ($this->medium !== null) 6751 { 5385 if ($this->medium !== null) { 6752 5386 return $this->medium; 6753 } 6754 else 6755 { 5387 } else { 6756 5388 return null; 6757 5389 } … … 6760 5392 function get_player() 6761 5393 { 6762 if ($this->player !== null) 6763 { 5394 if ($this->player !== null) { 6764 5395 return $this->player; 6765 } 6766 else 6767 { 5396 } else { 6768 5397 return null; 6769 5398 } … … 6773 5402 { 6774 5403 $ratings = $this->get_ratings(); 6775 if (isset($ratings[$key])) 6776 { 5404 if (isset($ratings[$key])) { 6777 5405 return $ratings[$key]; 6778 } 6779 else 6780 { 5406 } else { 6781 5407 return null; 6782 5408 } … … 6785 5411 function get_ratings() 6786 5412 { 6787 if ($this->ratings !== null) 6788 { 5413 if ($this->ratings !== null) { 6789 5414 return $this->ratings; 6790 } 6791 else 6792 { 5415 } else { 6793 5416 return null; 6794 5417 } … … 6798 5421 { 6799 5422 $restrictions = $this->get_restrictions(); 6800 if (isset($restrictions[$key])) 6801 { 5423 if (isset($restrictions[$key])) { 6802 5424 return $restrictions[$key]; 6803 } 6804 else 6805 { 5425 } else { 6806 5426 return null; 6807 5427 } … … 6810 5430 function get_restrictions() 6811 5431 { 6812 if ($this->restrictions !== null) 6813 { 5432 if ($this->restrictions !== null) { 6814 5433 return $this->restrictions; 6815 } 6816 else 6817 { 5434 } else { 6818 5435 return null; 6819 5436 } … … 6822 5439 function get_sampling_rate() 6823 5440 { 6824 if ($this->samplingrate !== null) 6825 { 5441 if ($this->samplingrate !== null) { 6826 5442 return $this->samplingrate; 6827 } 6828 else 6829 { 5443 } else { 6830 5444 return null; 6831 5445 } … … 6835 5449 { 6836 5450 $length = $this->get_length(); 6837 if ($length !== null) 6838 { 6839 return round($length/1048576, 2); 6840 } 6841 else 6842 { 5451 if ($length !== null) { 5452 return round($length / 1048576, 2); 5453 } else { 6843 5454 return null; 6844 5455 } … … 6848 5459 { 6849 5460 $thumbnails = $this->get_thumbnails(); 6850 if (isset($thumbnails[$key])) 6851 { 5461 if (isset($thumbnails[$key])) { 6852 5462 return $thumbnails[$key]; 6853 } 6854 else 6855 { 5463 } else { 6856 5464 return null; 6857 5465 } … … 6860 5468 function get_thumbnails() 6861 5469 { 6862 if ($this->thumbnails !== null) 6863 { 5470 if ($this->thumbnails !== null) { 6864 5471 return $this->thumbnails; 6865 } 6866 else 6867 { 5472 } else { 6868 5473 return null; 6869 5474 } … … 6872 5477 function get_title() 6873 5478 { 6874 if ($this->title !== null) 6875 { 5479 if ($this->title !== null) { 6876 5480 return $this->title; 6877 } 6878 else 6879 { 5481 } else { 6880 5482 return null; 6881 5483 } … … 6884 5486 function get_type() 6885 5487 { 6886 if ($this->type !== null) 6887 { 5488 if ($this->type !== null) { 6888 5489 return $this->type; 6889 } 6890 else 6891 { 5490 } else { 6892 5491 return null; 6893 5492 } … … 6896 5495 function get_width() 6897 5496 { 6898 if ($this->width !== null) 6899 { 5497 if ($this->width !== null) { 6900 5498 return $this->width; 6901 } 6902 else 6903 { 5499 } else { 6904 5500 return null; 6905 5501 } … … 6931 5527 6932 5528 // Process options and reassign values as necessary 6933 if (is_array($options)) 6934 { 5529 if (is_array($options)) { 6935 5530 extract($options); 6936 } 6937 else 6938 { 5531 } else { 6939 5532 $options = explode(',', $options); 6940 foreach($options as $option) 6941 { 5533 foreach ($options as $option) { 6942 5534 $opt = explode(':', $option, 2); 6943 if (isset($opt[0], $opt[1])) 6944 { 5535 if (isset($opt[0], $opt[1])) { 6945 5536 $opt[0] = trim($opt[0]); 6946 5537 $opt[1] = trim($opt[1]); 6947 switch ($opt[0]) 6948 { 5538 switch ($opt[0]) { 6949 5539 case 'audio': 6950 5540 $audio = $opt[1]; … … 6995 5585 6996 5586 // Process values for 'auto' 6997 if ($width === 'auto') 6998 { 6999 if ($mime === 'video') 7000 { 7001 if ($height === 'auto') 7002 { 5587 if ($width === 'auto') { 5588 if ($mime === 'video') { 5589 if ($height === 'auto') { 7003 5590 $width = 480; 7004 } 7005 elseif ($widescreen) 7006 { 7007 $width = round((intval($height)/9)*16); 7008 } 7009 else 7010 { 7011 $width = round((intval($height)/3)*4); 7012 } 7013 } 7014 else 7015 { 5591 } elseif ($widescreen) { 5592 $width = round((intval($height) / 9) * 16); 5593 } else { 5594 $width = round((intval($height) / 3) * 4); 5595 } 5596 } else { 7016 5597 $width = '100%'; 7017 5598 } 7018 5599 } 7019 5600 7020 if ($height === 'auto') 7021 { 7022 if ($mime === 'audio') 7023 { 5601 if ($height === 'auto') { 5602 if ($mime === 'audio') { 7024 5603 $height = 0; 7025 } 7026 elseif ($mime === 'video') 7027 { 7028 if ($width === 'auto') 7029 { 7030 if ($widescreen) 7031 { 5604 } elseif ($mime === 'video') { 5605 if ($width === 'auto') { 5606 if ($widescreen) { 7032 5607 $height = 270; 7033 } 7034 else 7035 { 5608 } else { 7036 5609 $height = 360; 7037 5610 } 7038 } 7039 elseif ($widescreen) 7040 { 7041 $height = round((intval($width)/16)*9); 7042 } 7043 else 7044 { 7045 $height = round((intval($width)/4)*3); 7046 } 7047 } 7048 else 7049 { 5611 } elseif ($widescreen) { 5612 $height = round((intval($width) / 16) * 9); 5613 } else { 5614 $height = round((intval($width) / 4) * 3); 5615 } 5616 } else { 7050 5617 $height = 376; 7051 5618 } 7052 } 7053 elseif ($mime === 'audio') 7054 { 5619 } elseif ($mime === 'audio') { 7055 5620 $height = 0; 7056 5621 } 7057 5622 7058 5623 // Set proper placeholder value 7059 if ($mime === 'audio') 7060 { 5624 if ($mime === 'audio') { 7061 5625 $placeholder = $audio; 7062 } 7063 elseif ($mime === 'video') 7064 { 5626 } elseif ($mime === 'video') { 7065 5627 $placeholder = $video; 7066 5628 } … … 7069 5631 7070 5632 // Make sure the JS library is included 7071 if (!$native) 7072 { 5633 if (!$native) { 7073 5634 static $javascript_outputted = null; 7074 if (!$javascript_outputted && $this->javascript) 7075 { 7076 $embed .= '<script type="text/javascript" src="?' . htmlspecialchars($this->javascript) . '"></script>'; 5635 if (!$javascript_outputted && $this->javascript) { 5636 $embed .= '<script type="text/javascript" src="?'.htmlspecialchars($this->javascript).'"></script>'; 7077 5637 $javascript_outputted = true; 7078 5638 } … … 7080 5640 7081 5641 // Odeo Feed MP3's 7082 if ($handler === 'odeo') 7083 { 7084 if ($native) 7085 { 7086 $embed .= '<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://adobe.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url=' . $this->get_link() . '"></embed>'; 7087 } 7088 else 7089 { 7090 $embed .= '<script type="text/javascript">embed_odeo("' . $this->get_link() . '");</script>'; 5642 if ($handler === 'odeo') { 5643 if ($native) { 5644 $embed .= '<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://adobe.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='.$this->get_link().'"></embed>'; 5645 } else { 5646 $embed .= '<script type="text/javascript">embed_odeo("'.$this->get_link().'");</script>'; 7091 5647 } 7092 5648 } 7093 5649 7094 5650 // Flash 7095 elseif ($handler === 'flash') 7096 { 7097 if ($native) 7098 { 7099 $embed .= "<embed src=\"" . $this->get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>"; 7100 } 7101 else 7102 { 7103 $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$loop', '$type');</script>"; 5651 elseif ($handler === 'flash') { 5652 if ($native) { 5653 $embed .= "<embed src=\"".$this->get_link()."\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\"></embed>"; 5654 } else { 5655 $embed .= "<script type='text/javascript'>embed_flash('$bgcolor', '$width', '$height', '".$this->get_link()."', '$loop', '$type');</script>"; 7104 5656 } 7105 5657 } … … 7107 5659 // Flash Media Player file types. 7108 5660 // Preferred handler for MP3 file types. 7109 elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) 7110 { 5661 elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) { 7111 5662 $height += 20; 7112 if ($native) 7113 { 7114 $embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>"; 7115 } 7116 else 7117 { 7118 $embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '" . rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension()) . "', '$placeholder', '$loop', '$mediaplayer');</script>"; 5663 if ($native) { 5664 $embed .= "<embed src=\"$mediaplayer\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" quality=\"high\" width=\"$width\" height=\"$height\" wmode=\"transparent\" flashvars=\"file=".rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension())."&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\"></embed>"; 5665 } else { 5666 $embed .= "<script type='text/javascript'>embed_flv('$width', '$height', '".rawurlencode($this->get_link().'?file_extension=.'.$this->get_extension())."', '$placeholder', '$loop', '$mediaplayer');</script>"; 7119 5667 } 7120 5668 } … … 7122 5670 // QuickTime 7 file types. Need to test with QuickTime 6. 7123 5671 // Only handle MP3's if the Flash Media Player is not present. 7124 elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) 7125 { 5672 elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) { 7126 5673 $height += 16; 7127 if ($native) 7128 { 7129 if ($placeholder !== '') 7130 { 7131 $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"" . $this->get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; 7132 } 7133 else 7134 { 7135 $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"" . $this->get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; 7136 } 7137 } 7138 else 7139 { 7140 $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '" . $this->get_link() . "', '$placeholder', '$loop');</script>"; 5674 if ($native) { 5675 if ($placeholder !== '') { 5676 $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" href=\"".$this->get_link()."\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; 5677 } else { 5678 $embed .= "<embed type=\"$type\" style=\"cursor:hand; cursor:pointer;\" src=\"".$this->get_link()."\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\"></embed>"; 5679 } 5680 } else { 5681 $embed .= "<script type='text/javascript'>embed_quicktime('$type', '$bgcolor', '$width', '$height', '".$this->get_link()."', '$placeholder', '$loop');</script>"; 7141 5682 } 7142 5683 } 7143 5684 7144 5685 // Windows Media 7145 elseif ($handler === 'wmedia') 7146 { 5686 elseif ($handler === 'wmedia') { 7147 5687 $height += 45; 7148 if ($native) 7149 { 7150 $embed .= "<embed type=\"application/x-mplayer2\" src=\"" . $this->get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>"; 7151 } 7152 else 7153 { 7154 $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '" . $this->get_link() . "');</script>"; 5688 if ($native) { 5689 $embed .= "<embed type=\"application/x-mplayer2\" src=\"".$this->get_link()."\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\"></embed>"; 5690 } else { 5691 $embed .= "<script type='text/javascript'>embed_wmedia('$width', '$height', '".$this->get_link()."');</script>"; 7155 5692 } 7156 5693 } 7157 5694 7158 5695 // Everything else 7159 else $embed .= '<a href="' . $this->get_link() . '" class="' . $altclass . '">' . $alt . '</a>'; 5696 else 5697 $embed .= '<a href="'.$this->get_link().'" class="'.$altclass.'">'.$alt.'</a>'; 7160 5698 7161 5699 return $embed; … … 7165 5703 { 7166 5704 // If it's Odeo, let's get it out of the way. 7167 if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com') 7168 { 5705 if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com') { 7169 5706 return 'odeo'; 7170 5707 } … … 7172 5709 // Mime-types by handler. 7173 5710 $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash 7174 $types_fmedia = array('video/flv', 'video/x-flv', 'flv-application/octet-stream'); // Flash Media Player5711 $types_fmedia = array('video/flv', 'video/x-flv', 'flv-application/octet-stream'); // Flash Media Player 7175 5712 $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime 7176 5713 $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media 7177 5714 $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 7178 5715 7179 if ($this->get_type() !== null) 7180 { 5716 if ($this->get_type() !== null) { 7181 5717 $type = strtolower($this->type); 7182 } 7183 else 7184 { 5718 } else { 7185 5719 $type = null; 7186 5720 } 7187 5721 7188 5722 // If we encounter an unsupported mime-type, check the file extension and guess intelligently. 7189 if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) 7190 { 7191 switch (strtolower($this->get_extension())) 7192 { 5723 if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) { 5724 switch (strtolower($this->get_extension())) { 7193 5725 // Audio mime-types 7194 5726 case 'aac': … … 7310 5842 } 7311 5843 7312 if ($find_handler) 7313 { 7314 if (in_array($type, $types_flash)) 7315 { 5844 if ($find_handler) { 5845 if (in_array($type, $types_flash)) { 7316 5846 return 'flash'; 7317 } 7318 elseif (in_array($type, $types_fmedia)) 7319 { 5847 } elseif (in_array($type, $types_fmedia)) { 7320 5848 return 'fmedia'; 7321 } 7322 elseif (in_array($type, $types_quicktime)) 7323 { 5849 } elseif (in_array($type, $types_quicktime)) { 7324 5850 return 'quicktime'; 7325 } 7326 elseif (in_array($type, $types_wmedia)) 7327 { 5851 } elseif (in_array($type, $types_wmedia)) { 7328 5852 return 'wmedia'; 7329 } 7330 elseif (in_array($type, $types_mp3)) 7331 { 5853 } elseif (in_array($type, $types_mp3)) { 7332 5854 return 'mp3'; 7333 } 7334 else 7335 { 5855 } else { 7336 5856 return null; 7337 5857 } 7338 } 7339 else 7340 { 5858 } else { 7341 5859 return $type; 7342 5860 } 7343 5861 } 5862 7344 5863 } 7345 5864 7346 5865 class SimplePie_Caption 7347 5866 { 5867 7348 5868 var $type; 7349 5869 var $lang; … … 7370 5890 function get_endtime() 7371 5891 { 7372 if ($this->endTime !== null) 7373 { 5892 if ($this->endTime !== null) { 7374 5893 return $this->endTime; 7375 } 7376 else 7377 { 5894 } else { 7378 5895 return null; 7379 5896 } … … 7382 5899 function get_language() 7383 5900 { 7384 if ($this->lang !== null) 7385 { 5901 if ($this->lang !== null) { 7386 5902 return $this->lang; 7387 } 7388 else 7389 { 5903 } else { 7390 5904 return null; 7391 5905 } … … 7394 5908 function get_starttime() 7395 5909 { 7396 if ($this->startTime !== null) 7397 { 5910 if ($this->startTime !== null) { 7398 5911 return $this->startTime; 7399 } 7400 else 7401 { 5912 } else { 7402 5913 return null; 7403 5914 } … … 7406 5917 function get_text() 7407 5918 { 7408 if ($this->text !== null) 7409 { 5919 if ($this->text !== null) { 7410 5920 return $this->text; 7411 } 7412 else 7413 { 5921 } else { 7414 5922 return null; 7415 5923 } … … 7418 5926 function get_type() 7419 5927 { 7420 if ($this->type !== null) 7421 { 5928 if ($this->type !== null) { 7422 5929 return $this->type; 7423 } 7424 else 7425 { 5930 } else { 7426 5931 return null; 7427 5932 } 7428 5933 } 5934 7429 5935 } 7430 5936 7431 5937 class SimplePie_Credit 7432 5938 { 5939 7433 5940 var $role; 7434 5941 var $scheme; … … 7451 5958 function get_role() 7452 5959 { 7453 if ($this->role !== null) 7454 { 5960 if ($this->role !== null) { 7455 5961 return $this->role; 7456 } 7457 else 7458 { 5962 } else { 7459 5963 return null; 7460 5964 } … … 7463 5967 function get_scheme() 7464 5968 { 7465 if ($this->scheme !== null) 7466 { 5969 if ($this->scheme !== null) { 7467 5970 return $this->scheme; 7468 } 7469 else 7470 { 5971 } else { 7471 5972 return null; 7472 5973 } … … 7475 5976 function get_name() 7476 5977 { 7477 if ($this->name !== null) 7478 { 5978 if ($this->name !== null) { 7479 5979 return $this->name; 7480 } 7481 else 7482 { 5980 } else { 7483 5981 return null; 7484 5982 } 7485 5983 } 5984 7486 5985 } 7487 5986 7488 5987 class SimplePie_Copyright 7489 5988 { 5989 7490 5990 var $url; 7491 5991 var $label; … … 7506 6006 function get_url() 7507 6007 { 7508 if ($this->url !== null) 7509 { 6008 if ($this->url !== null) { 7510 6009 return $this->url; 7511 } 7512 else 7513 { 6010 } else { 7514 6011 return null; 7515 6012 } … … 7518 6015 function get_attribution() 7519 6016 { 7520 if ($this->label !== null) 7521 { 6017 if ($this->label !== null) { 7522 6018 return $this->label; 7523 } 7524 else 7525 { 6019 } else { 7526 6020 return null; 7527 6021 } 7528 6022 } 6023 7529 6024 } 7530 6025 7531 6026 class SimplePie_Rating 7532 6027 { 6028 7533 6029 var $scheme; 7534 6030 var $value; … … 7549 6045 function get_scheme() 7550 6046 { 7551 if ($this->scheme !== null) 7552 { 6047 if ($this->scheme !== null) { 7553 6048 return $this->scheme; 7554 } 7555 else 7556 { 6049 } else { 7557 6050 return null; 7558 6051 } … … 7561 6054 function get_value() 7562 6055 { 7563 if ($this->value !== null) 7564 { 6056 if ($this->value !== null) { 7565 6057 return $this->value; 7566 } 7567 else 7568 { 6058 } else { 7569 6059 return null; 7570 6060 } 7571 6061 } 6062 7572 6063 } 7573 6064 7574 6065 class SimplePie_Restriction 7575 6066 { 6067 7576 6068 var $relationship; 7577 6069 var $type; … … 7594 6086 function get_relationship() 7595 6087 { 7596 if ($this->relationship !== null) 7597 { 6088 if ($this->relationship !== null) { 7598 6089 return $this->relationship; 7599 } 7600 else 7601 { 6090 } else { 7602 6091 return null; 7603 6092 } … … 7606 6095 function get_type() 7607 6096 { 7608 if ($this->type !== null) 7609 { 6097 if ($this->type !== null) { 7610 6098 return $this->type; 7611 } 7612 else 7613 { 6099 } else { 7614 6100 return null; 7615 6101 } … … 7618 6104 function get_value() 7619 6105 { 7620 if ($this->value !== null) 7621 { 6106 if ($this->value !== null) { 7622 6107 return $this->value; 7623 } 7624 else 7625 { 6108 } else { 7626 6109 return null; 7627 6110 } 7628 6111 } 6112 7629 6113 } 7630 6114 … … 7634 6118 class SimplePie_File 7635 6119 { 6120 7636 6121 var $url; 7637 6122 var $useragent; … … 7646 6131 function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) 7647 6132 { 7648 if (class_exists('idna_convert')) 7649 { 6133 if (class_exists('idna_convert')) { 7650 6134 $idn = new idna_convert; 7651 6135 $parsed = SimplePie_Misc::parse_url($url); … … 7654 6138 $this->url = $url; 7655 6139 $this->useragent = $useragent; 7656 if (preg_match('/^http(s)?:\/\//i', $url)) 7657 { 7658 if ($useragent === null) 7659 { 6140 if (preg_match('/^http(s)?:\/\//i', $url)) { 6141 if ($useragent === null) { 7660 6142 $useragent = ini_get('user_agent'); 7661 6143 $this->useragent = $useragent; 7662 6144 } 7663 if (!is_array($headers)) 7664 { 6145 if (!is_array($headers)) { 7665 6146 $headers = array(); 7666 6147 } 7667 if (!$force_fsockopen && function_exists('curl_exec')) 7668 { 6148 if (!$force_fsockopen && function_exists('curl_exec')) { 7669 6149 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; 7670 6150 $fp = curl_init(); 7671 6151 $headers2 = array(); 7672 foreach ($headers as $key => $value) 7673 { 6152 foreach ($headers as $key => $value) { 7674 6153 $headers2[] = "$key: $value"; 7675 6154 } 7676 if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) 7677 { 6155 if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) { 7678 6156 curl_setopt($fp, CURLOPT_ENCODING, ''); 7679 6157 } … … 7686 6164 curl_setopt($fp, CURLOPT_USERAGENT, $useragent); 7687 6165 curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); 7688 if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) 7689 { 6166 if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) { 7690 6167 curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); 7691 6168 curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); … … 7693 6170 7694 6171 $this->headers = curl_exec($fp); 7695 if (curl_errno($fp) === 23 || curl_errno($fp) === 61) 7696 { 6172 if (curl_errno($fp) === 23 || curl_errno($fp) === 61) { 7697 6173 curl_setopt($fp, CURLOPT_ENCODING, 'none'); 7698 6174 $this->headers = curl_exec($fp); 7699 6175 } 7700 if (curl_errno($fp)) 7701 { 7702 $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); 6176 if (curl_errno($fp)) { 6177 $this->error = 'cURL error '.curl_errno($fp).': '.curl_error($fp); 7703 6178 $this->success = false; 7704 } 7705 else 7706 { 6179 } else { 7707 6180 $info = curl_getinfo($fp); 7708 6181 curl_close($fp); … … 7710 6183 $this->headers = array_pop($this->headers); 7711 6184 $parser = new SimplePie_HTTP_Parser($this->headers); 7712 if ($parser->parse()) 7713 { 6185 if ($parser->parse()) { 7714 6186 $this->headers = $parser->headers; 7715 6187 $this->body = $parser->body; 7716 6188 $this->status_code = $parser->status_code; 7717 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) 7718 { 6189 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) { 7719 6190 $this->redirects++; 7720 6191 $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); … … 7723 6194 } 7724 6195 } 7725 } 7726 else 7727 { 6196 } else { 7728 6197 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; 7729 6198 $url_parts = parse_url($url); 7730 if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') 7731 { 6199 if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') { 7732 6200 $url_parts['host'] = "ssl://$url_parts[host]"; 7733 6201 $url_parts['port'] = 443; 7734 6202 } 7735 if (!isset($url_parts['port'])) 7736 { 6203 if (!isset($url_parts['port'])) { 7737 6204 $url_parts['port'] = 80; 7738 6205 } 7739 6206 $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); 7740 if (!$fp) 7741 { 7742 $this->error = 'fsockopen error: ' . $errstr; 6207 if (!$fp) { 6208 $this->error = 'fsockopen error: '.$errstr; 7743 6209 $this->success = false; 7744 } 7745 else 7746 { 6210 } else { 7747 6211 stream_set_timeout($fp, $timeout); 7748 if (isset($url_parts['path'])) 7749 { 7750 if (isset($url_parts['query'])) 7751 { 6212 if (isset($url_parts['path'])) { 6213 if (isset($url_parts['query'])) { 7752 6214 $get = "$url_parts[path]?$url_parts[query]"; 7753 } 7754 else 7755 { 6215 } else { 7756 6216 $get = $url_parts['path']; 7757 6217 } 7758 } 7759 else 7760 { 6218 } else { 7761 6219 $get = '/'; 7762 6220 } … … 7764 6222 $out .= "Host: $url_parts[host]\r\n"; 7765 6223 $out .= "User-Agent: $useragent\r\n"; 7766 if (extension_loaded('zlib')) 7767 { 6224 if (extension_loaded('zlib')) { 7768 6225 $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; 7769 6226 } 7770 6227 7771 if (isset($url_parts['user']) && isset($url_parts['pass'])) 7772 { 7773 $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; 6228 if (isset($url_parts['user']) && isset($url_parts['pass'])) { 6229 $out .= "Authorization: Basic ".base64_encode("$url_parts[user]:$url_parts[pass]")."\r\n"; 7774 6230 } 7775 foreach ($headers as $key => $value) 7776 { 6231 foreach ($headers as $key => $value) { 7777 6232 $out .= "$key: $value\r\n"; 7778 6233 } … … 7783 6238 7784 6239 $this->headers = ''; 7785 while (!$info['eof'] && !$info['timed_out']) 7786 { 6240 while (!$info['eof'] && !$info['timed_out']) { 7787 6241 $this->headers .= fread($fp, 1160); 7788 6242 $info = stream_get_meta_data($fp); 7789 6243 } 7790 if (!$info['timed_out']) 7791 { 6244 if (!$info['timed_out']) { 7792 6245 $parser = new SimplePie_HTTP_Parser($this->headers); 7793 if ($parser->parse()) 7794 { 6246 if ($parser->parse()) { 7795 6247 $this->headers = $parser->headers; 7796 6248 $this->body = $parser->body; 7797 6249 $this->status_code = $parser->status_code; 7798 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) 7799 { 6250 if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) { 7800 6251 $this->redirects++; 7801 6252 $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); 7802 6253 return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); 7803 6254 } 7804 if (isset($this->headers['content-encoding'])) 7805 { 6255 if (isset($this->headers['content-encoding'])) { 7806 6256 // Hey, we act dumb elsewhere, so let's do that here too 7807 switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) 7808 { 6257 switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) { 7809 6258 case 'gzip': 7810 6259 case 'x-gzip': 7811 6260 $decoder = new SimplePie_gzdecode($this->body); 7812 if (!$decoder->parse()) 7813 { 6261 if (!$decoder->parse()) { 7814 6262 $this->error = 'Unable to decode HTTP "gzip" stream'; 7815 6263 $this->success = false; 7816 } 7817 else 7818 { 6264 } else { 7819 6265 $this->body = $decoder->data; 7820 6266 } … … 7822 6268 7823 6269 case 'deflate': 7824 if (($body = gzuncompress($this->body)) === false) 7825 { 7826 if (($body = gzinflate($this->body)) === false) 7827 { 6270 if (($body = gzuncompress($this->body)) === false) { 6271 if (($body = gzinflate($this->body)) === false) { 7828 6272 $this->error = 'Unable to decode HTTP "deflate" stream'; 7829 6273 $this->success = false; … … 7839 6283 } 7840 6284 } 7841 } 7842 else 7843 { 6285 } else { 7844 6286 $this->error = 'fsocket timed out'; 7845 6287 $this->success = false; … … 7848 6290 } 7849 6291 } 7850 } 7851 else 7852 { 6292 } else { 7853 6293 $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; 7854 if (!$this->body = file_get_contents($url)) 7855 { 6294 if (!$this->body = file_get_contents($url)) { 7856 6295 $this->error = 'file_get_contents could not read the file'; 7857 6296 $this->success = false; … … 7859 6298 } 7860 6299 } 6300 7861 6301 } 7862 6302 … … 7868 6308 class SimplePie_HTTP_Parser 7869 6309 { 6310 7870 6311 /** 7871 6312 * HTTP Version … … 7875 6316 */ 7876 6317 var $http_version = 0.0; 7877 7878 6318 /** 7879 6319 * Status code … … 7883 6323 */ 7884 6324 var $status_code = 0; 7885 7886 6325 /** 7887 6326 * Reason phrase … … 7891 6330 */ 7892 6331 var $reason = ''; 7893 7894 6332 /** 7895 6333 * Key/value pairs of the headers … … 7899 6337 */ 7900 6338 var $headers = array(); 7901 7902 6339 /** 7903 6340 * Body of the response … … 7907 6344 */ 7908 6345 var $body = ''; 7909 7910 6346 /** 7911 6347 * Current state of the state machine … … 7915 6351 */ 7916 6352 var $state = 'http_version'; 7917 7918 6353 /** 7919 6354 * Input data … … 7923 6358 */ 7924 6359 var $data = ''; 7925 7926 6360 /** 7927 6361 * Input data length (to avoid calling strlen() everytime this is needed) … … 7931 6365 */ 7932 6366 var $data_length = 0; 7933 7934 6367 /** 7935 6368 * Current position of the pointer … … 7939 6372 */ 7940 6373 var $position = 0; 7941 7942 6374 /** 7943 6375 * Name of the hedaer currently being parsed … … 7947 6379 */ 7948 6380 var $name = ''; 7949 7950 6381 /** 7951 6382 * Value of the hedaer currently being parsed … … 7976 6407 function parse() 7977 6408 { 7978 while ($this->state && $this->state !== 'emit' && $this->has_data()) 7979 { 6409 while ($this->state && $this->state !== 'emit' && $this->has_data()) { 7980 6410 $state = $this->state; 7981 6411 $this->$state(); 7982 6412 } 7983 6413 $this->data = ''; 7984 if ($this->state === 'emit' || $this->state === 'body') 7985 { 6414 if ($this->state === 'emit' || $this->state === 'body') { 7986 6415 return true; 7987 } 7988 else 7989 { 6416 } else { 7990 6417 $this->http_version = ''; 7991 6418 $this->status_code = ''; … … 8017 6444 { 8018 6445 return (bool) ($this->data[$this->position] === "\x09" 8019 || $this->data[$this->position] === "\x20"8020 || ($this->data[$this->position] === "\x0A"8021 && isset($this->data[$this->position + 1])8022 && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20")));6446 || $this->data[$this->position] === "\x20" 6447 || ($this->data[$this->position] === "\x0A" 6448 && isset($this->data[$this->position + 1]) 6449 && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20"))); 8023 6450 } 8024 6451 … … 8030 6457 function http_version() 8031 6458 { 8032 if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') 8033 { 6459 if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') { 8034 6460 $len = strspn($this->data, '0123456789.', 5); 8035 6461 $this->http_version = substr($this->data, 5, $len); 8036 6462 $this->position += 5 + $len; 8037 if (substr_count($this->http_version, '.') <= 1) 8038 { 6463 if (substr_count($this->http_version, '.') <= 1) { 8039 6464 $this->http_version = (float) $this->http_version; 8040 6465 $this->position += strspn($this->data, "\x09\x20", $this->position); 8041 6466 $this->state = 'status'; 8042 } 8043 else 8044 { 6467 } else { 8045 6468 $this->state = false; 8046 6469 } 8047 } 8048 else 8049 { 6470 } else { 8050 6471 $this->state = false; 8051 6472 } … … 8059 6480 function status() 8060 6481 { 8061 if ($len = strspn($this->data, '0123456789', $this->position)) 8062 { 6482 if ($len = strspn($this->data, '0123456789', $this->position)) { 8063 6483 $this->status_code = (int) substr($this->data, $this->position, $len); 8064 6484 $this->position += $len; 8065 6485 $this->state = 'reason'; 8066 } 8067 else 8068 { 6486 } else { 8069 6487 $this->state = false; 8070 6488 } … … 8092 6510 { 8093 6511 $this->value = trim($this->value, "\x0D\x20"); 8094 if ($this->name !== '' && $this->value !== '') 8095 { 6512 if ($this->name !== '' && $this->value !== '') { 8096 6513 $this->name = strtolower($this->name); 8097 if (isset($this->headers[$this->name])) 8098 { 8099 $this->headers[$this->name] .= ', ' . $this->value; 8100 } 8101 else 8102 { 6514 if (isset($this->headers[$this->name])) { 6515 $this->headers[$this->name] .= ', '.$this->value; 6516 } else { 8103 6517 $this->headers[$this->name] = $this->value; 8104 6518 } … … 8106 6520 $this->name = ''; 8107 6521 $this->value = ''; 8108 if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A") 8109 { 6522 if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A") { 8110 6523 $this->position += 2; 8111 6524 $this->state = 'body'; 8112 } 8113 elseif ($this->data[$this->position] === "\x0A") 8114 { 6525 } elseif ($this->data[$this->position] === "\x0A") { 8115 6526 $this->position++; 8116 6527 $this->state = 'body'; 8117 } 8118 else 8119 { 6528 } else { 8120 6529 $this->state = 'name'; 8121 6530 } … … 8130 6539 { 8131 6540 $len = strcspn($this->data, "\x0A:", $this->position); 8132 if (isset($this->data[$this->position + $len])) 8133 { 8134 if ($this->data[$this->position + $len] === "\x0A") 8135 { 6541 if (isset($this->data[$this->position + $len])) { 6542 if ($this->data[$this->position + $len] === "\x0A") { 8136 6543 $this->position += $len; 8137 6544 $this->state = 'new_line'; 8138 } 8139 else 8140 { 6545 } else { 8141 6546 $this->name = substr($this->data, $this->position, $len); 8142 6547 $this->position += $len + 1; 8143 6548 $this->state = 'value'; 8144 6549 } 8145 } 8146 else 8147 { 6550 } else { 8148 6551 $this->state = false; 8149 6552 } … … 8157 6560 function linear_whitespace() 8158 6561 { 8159 do 8160 { 8161 if (substr($this->data, $this->position, 2) === "\x0D\x0A") 8162 { 6562 do { 6563 if (substr($this->data, $this->position, 2) === "\x0D\x0A") { 8163 6564 $this->position += 2; 8164 } 8165 elseif ($this->data[$this->position] === "\x0A") 8166 { 6565 } elseif ($this->data[$this->position] === "\x0A") { 8167 6566 $this->position++; 8168 6567 } … … 8179 6578 function value() 8180 6579 { 8181 if ($this->is_linear_whitespace()) 8182 { 6580 if ($this->is_linear_whitespace()) { 8183 6581 $this->linear_whitespace(); 8184 } 8185 else 8186 { 8187 switch ($this->data[$this->position]) 8188 { 6582 } else { 6583 switch ($this->data[$this->position]) { 8189 6584 case '"': 8190 6585 $this->position++; … … 8224 6619 function quote() 8225 6620 { 8226 if ($this->is_linear_whitespace()) 8227 { 6621 if ($this->is_linear_whitespace()) { 8228 6622 $this->linear_whitespace(); 8229 } 8230 else 8231 { 8232 switch ($this->data[$this->position]) 8233 { 6623 } else { 6624 switch ($this->data[$this->position]) { 8234 6625 case '"': 8235 6626 $this->position++; … … 8289 6680 $this->state = 'emit'; 8290 6681 } 6682 8291 6683 } 8292 6684 … … 8298 6690 class SimplePie_gzdecode 8299 6691 { 6692 8300 6693 /** 8301 6694 * Compressed data … … 8305 6698 */ 8306 6699 var $compressed_data; 8307 8308 6700 /** 8309 6701 * Size of compressed data … … 8312 6704 */ 8313 6705 var $compressed_size; 8314 8315 6706 /** 8316 6707 * Minimum size of a valid gzip string … … 8319 6710 */ 8320 6711 var $min_compressed_size = 18; 8321 8322 6712 /** 8323 6713 * Current position of pointer … … 8326 6716 */ 8327 6717 var $position = 0; 8328 8329 6718 /** 8330 6719 * Flags (FLG) … … 8333 6722 */ 8334 6723 var $flags; 8335 8336 6724 /** 8337 6725 * Uncompressed data … … 8341 6729 */ 8342 6730 var $data; 8343 8344 6731 /** 8345 6732 * Modified time … … 8348 6735 */ 8349 6736 var $MTIME; 8350 8351 6737 /** 8352 6738 * Extra Flags … … 8355 6741 */ 8356 6742 var $XFL; 8357 8358 6743 /** 8359 6744 * Operating System … … 8362 6747 */ 8363 6748 var $OS; 8364 8365 6749 /** 8366 6750 * Subfield ID 1 … … 8371 6755 */ 8372 6756 var $SI1; 8373 8374 6757 /** 8375 6758 * Subfield ID 2 … … 8380 6763 */ 8381 6764 var $SI2; 8382 8383 6765 /** 8384 6766 * Extra field content … … 8389 6771 */ 8390 6772 var $extra_field; 8391 8392 6773 /** 8393 6774 * Original filename … … 8396 6777 */ 8397 6778 var $filename; 8398 8399 6779 /** 8400 6780 * Human readable comment … … 8432 6812 function parse() 8433 6813 { 8434 if ($this->compressed_size >= $this->min_compressed_size) 8435 { 6814 if ($this->compressed_size >= $this->min_compressed_size) { 8436 6815 // Check ID1, ID2, and CM 8437 if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08") 8438 { 6816 if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08") { 8439 6817 return false; 8440 6818 } … … 8444 6822 8445 6823 // FLG bits above (1 << 4) are reserved 8446 if ($this->flags > 0x1F) 8447 { 6824 if ($this->flags > 0x1F) { 8448 6825 return false; 8449 6826 } … … 8455 6832 $mtime = substr($this->compressed_data, $this->position, 4); 8456 6833 // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness 8457 if (current(unpack('S', "\x00\x01")) === 1) 8458 { 6834 if (current(unpack('S', "\x00\x01")) === 1) { 8459 6835 $mtime = strrev($mtime); 8460 6836 } … … 8469 6845 8470 6846 // Parse the FEXTRA 8471 if ($this->flags & 4) 8472 { 6847 if ($this->flags & 4) { 8473 6848 // Read subfield IDs 8474 6849 $this->SI1 = $this->compressed_data[$this->position++]; … … 8476 6851 8477 6852 // SI2 set to zero is reserved for future use 8478 if ($this->SI2 === "\x00") 8479 { 6853 if ($this->SI2 === "\x00") { 8480 6854 return false; 8481 6855 } … … 8487 6861 // Check the length of the string is still valid 8488 6862 $this->min_compressed_size += $len + 4; 8489 if ($this->compressed_size >= $this->min_compressed_size) 8490 { 6863 if ($this->compressed_size >= $this->min_compressed_size) { 8491 6864 // Set the extra field to the given data 8492 6865 $this->extra_field = substr($this->compressed_data, $this->position, $len); 8493 6866 $this->position += $len; 8494 } 8495 else 8496 { 6867 } else { 8497 6868 return false; 8498 6869 } … … 8500 6871 8501 6872 // Parse the FNAME 8502 if ($this->flags & 8) 8503 { 6873 if ($this->flags & 8) { 8504 6874 // Get the length of the filename 8505 6875 $len = strcspn($this->compressed_data, "\x00", $this->position); … … 8507 6877 // Check the length of the string is still valid 8508 6878 $this->min_compressed_size += $len + 1; 8509 if ($this->compressed_size >= $this->min_compressed_size) 8510 { 6879 if ($this->compressed_size >= $this->min_compressed_size) { 8511 6880 // Set the original filename to the given string 8512 6881 $this->filename = substr($this->compressed_data, $this->position, $len); 8513 6882 $this->position += $len + 1; 8514 } 8515 else 8516 { 6883 } else { 8517 6884 return false; 8518 6885 } … … 8520 6887 8521 6888 // Parse the FCOMMENT 8522 if ($this->flags & 16) 8523 { 6889 if ($this->flags & 16) { 8524 6890 // Get the length of the comment 8525 6891 $len = strcspn($this->compressed_data, "\x00", $this->position); … … 8527 6893 // Check the length of the string is still valid 8528 6894 $this->min_compressed_size += $len + 1; 8529 if ($this->compressed_size >= $this->min_compressed_size) 8530 { 6895 if ($this->compressed_size >= $this->min_compressed_size) { 8531 6896 // Set the original comment to the given string 8532 6897 $this->comment = substr($this->compressed_data, $this->position, $len); 8533 6898 $this->position += $len + 1; 8534 } 8535 else 8536 { 6899 } else { 8537 6900 return false; 8538 6901 } … … 8540 6903 8541 6904 // Parse the FHCRC 8542 if ($this->flags & 2) 8543 { 6905 if ($this->flags & 2) { 8544 6906 // Check the length of the string is still valid 8545 6907 $this->min_compressed_size += $len + 2; 8546 if ($this->compressed_size >= $this->min_compressed_size) 8547 { 6908 if ($this->compressed_size >= $this->min_compressed_size) { 8548 6909 // Read the CRC 8549 6910 $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2))); 8550 6911 8551 6912 // Check the CRC matches 8552 if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) 8553 { 6913 if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) { 8554 6914 $this->position += 2; 8555 } 8556 else 8557 { 6915 } else { 8558 6916 return false; 8559 6917 } 8560 } 8561 else 8562 { 6918 } else { 8563 6919 return false; 8564 6920 } … … 8566 6922 8567 6923 // Decompress the actual data 8568 if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) 8569 { 6924 if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) { 8570 6925 return false; 8571 } 8572 else 8573 { 6926 } else { 8574 6927 $this->position = $this->compressed_size - 8; 8575 6928 } … … 8578 6931 $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); 8579 6932 $this->position += 4; 8580 /* if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))8581 {8582 return false;8583 }*/6933 /* if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) 6934 { 6935 return false; 6936 } */ 8584 6937 8585 6938 // Check ISIZE of data 8586 6939 $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4))); 8587 6940 $this->position += 4; 8588 if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) 8589 { 6941 if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) { 8590 6942 return false; 8591 6943 } … … 8593 6945 // Wow, against all odds, we've actually got a valid gzip string 8594 6946 return true; 8595 } 8596 else 8597 { 6947 } else { 8598 6948 return false; 8599 6949 } 8600 6950 } 6951 8601 6952 } 8602 6953 8603 6954 class SimplePie_Cache 8604 6955 { 6956 8605 6957 /** 8606 6958 * Don't call the constructor. Please. … … 8622 6974 { 8623 6975 $location_iri = new SimplePie_IRI($location); 8624 switch ($location_iri->get_scheme()) 8625 { 6976 switch ($location_iri->get_scheme()) { 8626 6977 case 'mysql': 8627 if (extension_loaded('mysql')) 8628 { 6978 if (extension_loaded('mysql')) { 8629 6979 return new SimplePie_Cache_MySQL($location_iri, $filename, $extension); 8630 6980 } … … 8635 6985 } 8636 6986 } 6987 8637 6988 } 8638 6989 8639 6990 class SimplePie_Cache_File 8640 6991 { 6992 8641 6993 var $location; 8642 6994 var $filename; … … 8654 7006 function save($data) 8655 7007 { 8656 if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) 8657 { 8658 if (is_a($data, 'SimplePie')) 8659 { 7008 if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) { 7009 if (is_a($data, 'SimplePie')) { 8660 7010 $data = $data->data; 8661 7011 } … … 8663 7013 $data = serialize($data); 8664 7014 8665 if (function_exists('file_put_contents')) 8666 { 7015 if (function_exists('file_put_contents')) { 8667 7016 return (bool) file_put_contents($this->name, $data); 8668 } 8669 else 8670 { 7017 } else { 8671 7018 $fp = fopen($this->name, 'wb'); 8672 if ($fp) 8673 { 7019 if ($fp) { 8674 7020 fwrite($fp, $data); 8675 7021 fclose($fp); … … 8683 7029 function load() 8684 7030 { 8685 if (file_exists($this->name) && is_readable($this->name)) 8686 { 7031 if (file_exists($this->name) && is_readable($this->name)) { 8687 7032 return unserialize(file_get_contents($this->name)); 8688 7033 } … … 8692 7037 function mtime() 8693 7038 { 8694 if (file_exists($this->name)) 8695 { 7039 if (file_exists($this->name)) { 8696 7040 return filemtime($this->name); 8697 7041 } … … 8701 7045 function touch() 8702 7046 { 8703 if (file_exists($this->name)) 8704 { 7047 if (file_exists($this->name)) { 8705 7048 return touch($this->name); 8706 7049 } … … 8710 7053 function unlink() 8711 7054 { 8712 if (file_exists($this->name)) 8713 { 7055 if (file_exists($this->name)) { 8714 7056 return unlink($this->name); 8715 7057 } 8716 7058 return false; 8717 7059 } 8718 } 8719 8720 class SimplePie_Cache_DB 8721 { 8722 function prepare_simplepie_object_for_cache($data) 8723 { 8724 $items = $data->get_items(); 8725 $items_by_id = array(); 8726 8727 if (!empty($items)) 8728 { 8729 foreach ($items as $item) 8730 { 8731 $items_by_id[$item->get_id()] = $item; 8732 } 8733 8734 if (count($items_by_id) !== count($items)) 8735 { 8736 $items_by_id = array(); 8737 foreach ($items as $item) 8738 { 8739 $items_by_id[$item->get_id(true)] = $item; 8740 } 8741 } 8742 8743 if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) 8744 { 8745 $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; 8746 } 8747 elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) 8748 { 8749 $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; 8750 } 8751 elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) 8752 { 8753 $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; 8754 } 8755 elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0])) 8756 { 8757 $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]; 8758 } 8759 else 8760 { 8761 $channel = null; 8762 } 8763 8764 if ($channel !== null) 8765 { 8766 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) 8767 { 8768 unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']); 8769 } 8770 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry'])) 8771 { 8772 unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']); 8773 } 8774 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])) 8775 { 8776 unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']); 8777 } 8778 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])) 8779 { 8780 unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']); 8781 } 8782 if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item'])) 8783 { 8784 unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']); 8785 } 8786 } 8787 if (isset($data->data['items'])) 8788 { 8789 unset($data->data['items']); 8790 } 8791 if (isset($data->data['ordered_items'])) 8792 { 8793 unset($data->data['ordered_items']); 8794 } 8795 } 8796 return array(serialize($data->data), $items_by_id); 8797 } 8798 } 8799 8800 class SimplePie_Cache_MySQL extends SimplePie_Cache_DB 8801 { 8802 var $mysql; 8803 var $options; 8804 var $id; 8805 8806 function SimplePie_Cache_MySQL($mysql_location, $name, $extension) 8807 { 8808 $host = $mysql_location->get_host(); 8809 if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')') 8810 { 8811 $server = ':' . substr($host, 5, -1); 8812 } 8813 else 8814 { 8815 $server = $host; 8816 if ($mysql_location->get_port() !== null) 8817 { 8818 $server .= ':' . $mysql_location->get_port(); 8819 } 8820 } 8821 8822 if (strpos($mysql_location->get_userinfo(), ':') !== false) 8823 { 8824 list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2); 8825 } 8826 else 8827 { 8828 $username = $mysql_location->get_userinfo(); 8829 $password = null; 8830 } 8831 8832 if ($this->mysql = mysql_connect($server, $username, $password)) 8833 { 8834 $this->id = $name . $extension; 8835 $this->options = SimplePie_Misc::parse_str($mysql_location->get_query()); 8836 if (!isset($this->options['prefix'][0])) 8837 { 8838 $this->options['prefix'][0] = ''; 8839 } 8840 8841 if (mysql_select_db(ltrim($mysql_location->get_path(), '/')) 8842 && mysql_query('SET NAMES utf8') 8843 && ($query = mysql_unbuffered_query('SHOW TABLES'))) 8844 { 8845 $db = array(); 8846 while ($row = mysql_fetch_row($query)) 8847 { 8848 $db[] = $row[0]; 8849 } 8850 8851 if (!in_array($this->options['prefix'][0] . 'cache_data', $db)) 8852 { 8853 if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))')) 8854 { 8855 $this->mysql = null; 8856 } 8857 } 8858 8859 if (!in_array($this->options['prefix'][0] . 'items', $db)) 8860 { 8861 if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))')) 8862 { 8863 $this->mysql = null; 8864 } 8865 } 8866 } 8867 else 8868 { 8869 $this->mysql = null; 8870 } 8871 } 8872 } 8873 8874 function save($data) 8875 { 8876 if ($this->mysql) 8877 { 8878 $feed_id = "'" . mysql_real_escape_string($this->id) . "'"; 8879 8880 if (is_a($data, 'SimplePie')) 8881 { 8882 if (SIMPLEPIE_PHP5) 8883 { 8884 // This keyword needs to defy coding standards for PHP4 compatibility 8885 $data = clone($data); 8886 } 8887 8888 $prepared = $this->prepare_simplepie_object_for_cache($data); 8889 8890 if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) 8891 { 8892 if (mysql_num_rows($query)) 8893 { 8894 $items = count($prepared[1]); 8895 if ($items) 8896 { 8897 $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; 8898 } 8899 else 8900 { 8901 $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; 8902 } 8903 8904 if (!mysql_query($sql, $this->mysql)) 8905 { 8906 return false; 8907 } 8908 } 8909 elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql)) 8910 { 8911 return false; 8912 } 8913 8914 $ids = array_keys($prepared[1]); 8915 if (!empty($ids)) 8916 { 8917 foreach ($ids as $id) 8918 { 8919 $database_ids[] = mysql_real_escape_string($id); 8920 } 8921 8922 if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql)) 8923 { 8924 $existing_ids = array(); 8925 while ($row = mysql_fetch_row($query)) 8926 { 8927 $existing_ids[] = $row[0]; 8928 } 8929 8930 $new_ids = array_diff($ids, $existing_ids); 8931 8932 foreach ($new_ids as $new_id) 8933 { 8934 if (!($date = $prepared[1][$new_id]->get_date('U'))) 8935 { 8936 $date = time(); 8937 } 8938 8939 if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql)) 8940 { 8941 return false; 8942 } 8943 } 8944 return true; 8945 } 8946 } 8947 else 8948 { 8949 return true; 8950 } 8951 } 8952 } 8953 elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) 8954 { 8955 if (mysql_num_rows($query)) 8956 { 8957 if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql)) 8958 { 8959 return true; 8960 } 8961 } 8962 elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql)) 8963 { 8964 return true; 8965 } 8966 } 8967 } 8968 return false; 8969 } 8970 8971 function load() 8972 { 8973 if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) 8974 { 8975 $data = unserialize($row[1]); 8976 8977 if (isset($this->options['items'][0])) 8978 { 8979 $items = (int) $this->options['items'][0]; 8980 } 8981 else 8982 { 8983 $items = (int) $row[0]; 8984 } 8985 8986 if ($items !== 0) 8987 { 8988 if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) 8989 { 8990 $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; 8991 } 8992 elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) 8993 { 8994 $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; 8995 } 8996 elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) 8997 { 8998 $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; 8999 } 9000 elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0])) 9001 { 9002 $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]; 9003 } 9004 else 9005 { 9006 $feed = null; 9007 } 9008 9009 if ($feed !== null) 9010 { 9011 $sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC'; 9012 if ($items > 0) 9013 { 9014 $sql .= ' LIMIT ' . $items; 9015 } 9016 9017 if ($query = mysql_unbuffered_query($sql, $this->mysql)) 9018 { 9019 while ($row = mysql_fetch_row($query)) 9020 { 9021 $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]); 9022 } 9023 } 9024 else 9025 { 9026 return false; 9027 } 9028 } 9029 } 9030 return $data; 9031 } 9032 return false; 9033 } 9034 9035 function mtime() 9036 { 9037 if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) 9038 { 9039 return $row[0]; 9040 } 9041 else 9042 { 9043 return false; 9044 } 9045 } 9046 9047 function touch() 9048 { 9049 if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql)) 9050 { 9051 return true; 9052 } 9053 else 9054 { 9055 return false; 9056 } 9057 } 9058 9059 function unlink() 9060 { 9061 if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql))) 9062 { 9063 return true; 9064 } 9065 else 9066 { 9067 return false; 9068 } 9069 } 7060 9070 7061 } 9071 7062 9072 7063 class SimplePie_Misc 9073 7064 { 7065 9074 7066 function time_hms($seconds) 9075 7067 { … … 9078 7070 $hours = floor($seconds / 3600); 9079 7071 $remainder = $seconds % 3600; 9080 if ($hours > 0) 9081 { 7072 if ($hours > 0) { 9082 7073 $time .= $hours.':'; 9083 7074 } … … 9085 7076 $minutes = floor($remainder / 60); 9086 7077 $seconds = $remainder % 60; 9087 if ($minutes < 10 && $hours > 0) 9088 { 9089 $minutes = '0' . $minutes; 9090 } 9091 if ($seconds < 10) 9092 { 9093 $seconds = '0' . $seconds; 7078 if ($minutes < 10 && $hours > 0) { 7079 $minutes = '0'.$minutes; 7080 } 7081 if ($seconds < 10) { 7082 $seconds = '0'.$seconds; 9094 7083 } 9095 7084 … … 9109 7098 { 9110 7099 $output = ''; 9111 while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') 9112 { 7100 while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { 9113 7101 // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, 9114 if (strpos($input, '../') === 0) 9115 { 7102 if (strpos($input, '../') === 0) { 9116 7103 $input = substr($input, 3); 9117 } 9118 elseif (strpos($input, './') === 0) 9119 { 7104 } elseif (strpos($input, './') === 0) { 9120 7105 $input = substr($input, 2); 9121 7106 } 9122 7107 // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, 9123 elseif (strpos($input, '/./') === 0) 9124 { 7108 elseif (strpos($input, '/./') === 0) { 9125 7109 $input = substr_replace($input, '/', 0, 3); 9126 } 9127 elseif ($input === '/.') 9128 { 7110 } elseif ($input === '/.') { 9129 7111 $input = '/'; 9130 7112 } 9131 7113 // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, 9132 elseif (strpos($input, '/../') === 0) 9133 { 7114 elseif (strpos($input, '/../') === 0) { 9134 7115 $input = substr_replace($input, '/', 0, 4); 9135 7116 $output = substr_replace($output, '', strrpos($output, '/')); 9136 } 9137 elseif ($input === '/..') 9138 { 7117 } elseif ($input === '/..') { 9139 7118 $input = '/'; 9140 7119 $output = substr_replace($output, '', strrpos($output, '/')); 9141 7120 } 9142 7121 // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, 9143 elseif ($input === '.' || $input === '..') 9144 { 7122 elseif ($input === '.' || $input === '..') { 9145 7123 $input = ''; 9146 7124 } 9147 7125 // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer 9148 elseif (($pos = strpos($input, '/', 1)) !== false) 9149 { 7126 elseif (($pos = strpos($input, '/', 1)) !== false) { 9150 7127 $output .= substr($input, 0, $pos); 9151 7128 $input = substr_replace($input, '', 0, $pos); 9152 } 9153 else 9154 { 7129 } else { 9155 7130 $output .= $input; 9156 7131 $input = ''; 9157 7132 } 9158 7133 } 9159 return $output .$input;7134 return $output.$input; 9160 7135 } 9161 7136 … … 9164 7139 $return = array(); 9165 7140 $name = preg_quote($realname, '/'); 9166 if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) 9167 { 9168 for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) 9169 { 7141 if (preg_match_all("/<($name)".SIMPLEPIE_PCRE_HTML_ATTRIBUTE."(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { 7142 for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) { 9170 7143 $return[$i]['tag'] = $realname; 9171 7144 $return[$i]['full'] = $matches[$i][0][0]; 9172 7145 $return[$i]['offset'] = $matches[$i][0][1]; 9173 if (strlen($matches[$i][3][0]) <= 2) 9174 { 7146 if (strlen($matches[$i][3][0]) <= 2) { 9175 7147 $return[$i]['self_closing'] = true; 9176 } 9177 else 9178 { 7148 } else { 9179 7149 $return[$i]['self_closing'] = false; 9180 7150 $return[$i]['content'] = $matches[$i][4][0]; 9181 7151 } 9182 7152 $return[$i]['attribs'] = array(); 9183 if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) 9184 { 9185 for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) 9186 { 9187 if (count($attribs[$j]) === 2) 9188 { 7153 if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' '.$matches[$i][2][0].' ', $attribs, PREG_SET_ORDER)) { 7154 for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) { 7155 if (count($attribs[$j]) === 2) { 9189 7156 $attribs[$j][2] = $attribs[$j][1]; 9190 7157 } … … 9200 7167 { 9201 7168 $full = "<$element[tag]"; 9202 foreach ($element['attribs'] as $key => $value) 9203 { 7169 foreach ($element['attribs'] as $key => $value) { 9204 7170 $key = strtolower($key); 9205 $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; 9206 } 9207 if ($element['self_closing']) 9208 { 7171 $full .= " $key=\"".htmlspecialchars($value['data']).'"'; 7172 } 7173 if ($element['self_closing']) { 9209 7174 $full .= ' />'; 9210 } 9211 else 9212 { 7175 } else { 9213 7176 $full .= ">$element[content]</$element[tag]>"; 9214 7177 } … … 9218 7181 function error($message, $level, $file, $line) 9219 7182 { 9220 if ((ini_get('error_reporting') & $level) > 0) 9221 { 9222 switch ($level) 9223 { 7183 if ((ini_get('error_reporting') & $level) > 0) { 7184 switch ($level) { 9224 7185 case E_USER_ERROR: 9225 7186 $note = 'PHP Error'; … … 9266 7227 $cache = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension); 9267 7228 9268 if ($file = $cache->load()) 9269 { 9270 if (isset($file['headers']['content-type'])) 9271 { 9272 header('Content-type:' . $file['headers']['content-type']); 9273 } 9274 else 9275 { 7229 if ($file = $cache->load()) { 7230 if (isset($file['headers']['content-type'])) { 7231 header('Content-type:'.$file['headers']['content-type']); 7232 } else { 9276 7233 header('Content-type: application/octet-stream'); 9277 7234 } 9278 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) .' GMT'); // 7 days7235 header('Expires: '.gmdate('D, d M Y H:i:s', time() + 604800).' GMT'); // 7 days 9279 7236 echo $file['body']; 9280 7237 exit; 9281 7238 } 9282 7239 9283 die('Cached file for ' . $identifier_url .' cannot be found.');7240 die('Cached file for '.$identifier_url.' cannot be found.'); 9284 7241 } 9285 7242 … … 9288 7245 $url = SimplePie_Misc::normalize_url($url); 9289 7246 $parsed = SimplePie_Misc::parse_url($url); 9290 if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') 9291 { 7247 if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') { 9292 7248 return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); 9293 7249 } 9294 7250 9295 if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) 9296 { 7251 if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) { 9297 7252 return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); 9298 7253 } 9299 7254 9300 if ($http === 2 && $parsed['scheme'] !== '') 9301 { 7255 if ($http === 2 && $parsed['scheme'] !== '') { 9302 7256 return "feed:$url"; 9303 } 9304 elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') 9305 { 7257 } elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') { 9306 7258 return substr_replace($url, 'podcast', 0, 4); 9307 } 9308 elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') 9309 { 7259 } elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') { 9310 7260 return substr_replace($url, 'itpc', 0, 4); 9311 } 9312 else 9313 { 7261 } else { 9314 7262 return $url; 9315 7263 } … … 9348 7296 { 9349 7297 $integer = hexdec($match[1]); 9350 if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) 9351 { 7298 if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) { 9352 7299 return chr($integer); 9353 } 9354 else 9355 { 7300 } else { 9356 7301 return strtoupper($match[0]); 9357 7302 } … … 9371 7316 function utf8_bad_replace($str) 9372 7317 { 9373 if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str))) 9374 { 7318 if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str))) { 9375 7319 return $return; 9376 } 9377 elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8'))) 9378 { 7320 } elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8'))) { 9379 7321 return $return; 9380 } 9381 elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches)) 9382 { 7322 } elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches)) { 9383 7323 return implode("\xEF\xBF\xBD", $matches[0]); 9384 } 9385 elseif ($str !== '') 9386 { 7324 } elseif ($str !== '') { 9387 7325 return "\xEF\xBF\xBD"; 9388 } 9389 else 9390 { 7326 } else { 9391 7327 return ''; 9392 7328 } … … 9414 7350 9415 7351 // We fail to fail on non US-ASCII bytes 9416 if ($input === 'US-ASCII') 9417 { 7352 if ($input === 'US-ASCII') { 9418 7353 static $non_ascii_octects = ''; 9419 if (!$non_ascii_octects) 9420 { 9421 for ($i = 0x80; $i <= 0xFF; $i++) 9422 { 7354 if (!$non_ascii_octects) { 7355 for ($i = 0x80; $i <= 0xFF; $i++) { 9423 7356 $non_ascii_octects .= chr($i); 9424 7357 } … … 9428 7361 9429 7362 // This is first, as behaviour of this is completely predictable 9430 if ($input === 'Windows-1252' && $output === 'UTF-8') 9431 { 7363 if ($input === 'Windows-1252' && $output === 'UTF-8') { 9432 7364 return SimplePie_Misc::windows_1252_to_utf8($data); 9433 7365 } 9434 7366 // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported). 9435 elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input))) 9436 { 7367 elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input))) { 9437 7368 return $return; 9438 7369 } 9439 7370 // This is last, as behaviour of this varies with OS userland and PHP version 9440 elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data))) 9441 { 7371 elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data))) { 9442 7372 return $return; 9443 7373 } 9444 7374 // If we can't do anything, just fail 9445 else 9446 { 7375 else { 9447 7376 return false; 9448 7377 } … … 9452 7381 { 9453 7382 // Normalization from UTS #22 9454 switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) 9455 { 7383 switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) { 9456 7384 case 'adobestandardencoding': 9457 7385 case 'csadobestandardencoding': … … 10767 8695 function get_curl_version() 10768 8696 { 10769 if (is_array($curl = curl_version())) 10770 { 8697 if (is_array($curl = curl_version())) { 10771 8698 $curl = $curl['version']; 10772 } 10773 elseif (substr($curl, 0, 5) === 'curl/') 10774 { 8699 } elseif (substr($curl, 0, 5) === 'curl/') { 10775 8700 $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); 10776 } 10777 elseif (substr($curl, 0, 8) === 'libcurl/') 10778 { 8701 } elseif (substr($curl, 0, 8) === 'libcurl/') { 10779 8702 $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); 10780 } 10781 else 10782 { 8703 } else { 10783 8704 $curl = 0; 10784 8705 } … … 10788 8709 function is_subclass_of($class1, $class2) 10789 8710 { 10790 if (func_num_args() !== 2) 10791 { 8711 if (func_num_args() !== 2) { 10792 8712 trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING); 10793 } 10794 elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1)) 10795 { 8713 } elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1)) { 10796 8714 return is_subclass_of($class1, $class2); 10797 } 10798 elseif (is_string($class1) && is_string($class2)) 10799 { 10800 if (class_exists($class1)) 10801 { 10802 if (class_exists($class2)) 10803 { 8715 } elseif (is_string($class1) && is_string($class2)) { 8716 if (class_exists($class1)) { 8717 if (class_exists($class2)) { 10804 8718 $class2 = strtolower($class2); 10805 while ($class1 = strtolower(get_parent_class($class1))) 10806 { 10807 if ($class1 === $class2) 10808 { 8719 while ($class1 = strtolower(get_parent_class($class1))) { 8720 if ($class1 === $class2) { 10809 8721 return true; 10810 8722 } 10811 8723 } 10812 8724 } 10813 } 10814 else 10815 { 8725 } else { 10816 8726 trigger_error('Unknown class passed as parameter', E_USER_WARNNG); 10817 8727 } … … 10830 8740 { 10831 8741 $output = ''; 10832 while (($start = strpos($data, '<!--')) !== false) 10833 { 8742 while (($start = strpos($data, '<!--')) !== false) { 10834 8743 $output .= substr($data, 0, $start); 10835 if (($end = strpos($data, '-->', $start)) !== false) 10836 { 8744 if (($end = strpos($data, '-->', $start)) !== false) { 10837 8745 $data = substr_replace($data, '', 0, $end + 3); 10838 } 10839 else 10840 { 8746 } else { 10841 8747 $data = ''; 10842 8748 } 10843 8749 } 10844 return $output .$data;8750 return $output.$data; 10845 8751 } 10846 8752 … … 10881 8787 $output = ''; 10882 8788 10883 while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) 10884 { 8789 while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) { 10885 8790 $output .= substr($string, $position, $pos - $position); 10886 8791 $position = $pos + 1; 10887 if ($string[$pos - 1] !== '\\') 10888 { 8792 if ($string[$pos - 1] !== '\\') { 10889 8793 $depth++; 10890 while ($depth && $position < $length) 10891 { 8794 while ($depth && $position < $length) { 10892 8795 $position += strcspn($string, '()', $position); 10893 if ($string[$position - 1] === '\\') 10894 { 8796 if ($string[$position - 1] === '\\') { 10895 8797 $position++; 10896 8798 continue; 10897 } 10898 elseif (isset($string[$position])) 10899 { 10900 switch ($string[$position]) 10901 { 8799 } elseif (isset($string[$position])) { 8800 switch ($string[$position]) { 10902 8801 case '(': 10903 8802 $depth++; … … 10909 8808 } 10910 8809 $position++; 10911 } 10912 else 10913 { 8810 } else { 10914 8811 break; 10915 8812 } 10916 8813 } 10917 } 10918 else 10919 { 8814 } else { 10920 8815 $output .= '('; 10921 8816 } … … 10928 8823 function parse_mime($mime) 10929 8824 { 10930 if (($pos = strpos($mime, ';')) === false) 10931 { 8825 if (($pos = strpos($mime, ';')) === false) { 10932 8826 return trim($mime); 10933 } 10934 else 10935 { 8827 } else { 10936 8828 return trim(substr($mime, 0, $pos)); 10937 8829 } … … 10940 8832 function htmlspecialchars_decode($string, $quote_style) 10941 8833 { 10942 if (function_exists('htmlspecialchars_decode')) 10943 { 8834 if (function_exists('htmlspecialchars_decode')) { 10944 8835 return htmlspecialchars_decode($string, $quote_style); 10945 } 10946 else 10947 { 8836 } else { 10948 8837 return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style))); 10949 8838 } … … 10952 8841 function atom_03_construct_type($attribs) 10953 8842 { 10954 if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) 10955 { 8843 if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) { 10956 8844 $mode = SIMPLEPIE_CONSTRUCT_BASE64; 10957 } 10958 else 10959 { 8845 } else { 10960 8846 $mode = SIMPLEPIE_CONSTRUCT_NONE; 10961 8847 } 10962 if (isset($attribs['']['type'])) 10963 { 10964 switch (strtolower(trim($attribs['']['type']))) 10965 { 8848 if (isset($attribs['']['type'])) { 8849 switch (strtolower(trim($attribs['']['type']))) { 10966 8850 case 'text': 10967 8851 case 'text/plain': … … 10979 8863 return SIMPLEPIE_CONSTRUCT_NONE | $mode; 10980 8864 } 10981 } 10982 else 10983 { 8865 } else { 10984 8866 return SIMPLEPIE_CONSTRUCT_TEXT | $mode; 10985 8867 } … … 10988 8870 function atom_10_construct_type($attribs) 10989 8871 { 10990 if (isset($attribs['']['type'])) 10991 { 10992 switch (strtolower(trim($attribs['']['type']))) 10993 { 8872 if (isset($attribs['']['type'])) { 8873 switch (strtolower(trim($attribs['']['type']))) { 10994 8874 case 'text': 10995 8875 return SIMPLEPIE_CONSTRUCT_TEXT; … … 11010 8890 function atom_10_content_construct_type($attribs) 11011 8891 { 11012 if (isset($attribs['']['type'])) 11013 { 8892 if (isset($attribs['']['type'])) { 11014 8893 $type = strtolower(trim($attribs['']['type'])); 11015 switch ($type) 11016 { 8894 switch ($type) { 11017 8895 case 'text': 11018 8896 return SIMPLEPIE_CONSTRUCT_TEXT; … … 11024 8902 return SIMPLEPIE_CONSTRUCT_XHTML; 11025 8903 } 11026 if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') 11027 { 8904 if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') { 11028 8905 return SIMPLEPIE_CONSTRUCT_NONE; 11029 } 11030 else 11031 { 8906 } else { 11032 8907 return SIMPLEPIE_CONSTRUCT_BASE64; 11033 8908 } 11034 } 11035 else 11036 { 8909 } else { 11037 8910 return SIMPLEPIE_CONSTRUCT_TEXT; 11038 8911 } … … 11052 8925 $tokens = array(); 11053 8926 11054 while ($position < $string_length) 11055 { 8927 while ($position < $string_length) { 11056 8928 $len = strcspn($string, $space_characters, $position); 11057 8929 $tokens[] = substr($string, $position, $len); … … 11065 8937 function array_unique($array) 11066 8938 { 11067 if (version_compare(PHP_VERSION, '5.2', '>=')) 11068 { 8939 if (version_compare(PHP_VERSION, '5.2', '>=')) { 11069 8940 return array_unique($array); 11070 } 11071 else 11072 { 8941 } else { 11073 8942 $array = (array) $array; 11074 8943 $new_array = array(); 11075 8944 $new_array_strings = array(); 11076 foreach ($array as $key => $value) 11077 { 11078 if (is_object($value)) 11079 { 11080 if (method_exists($value, '__toString')) 11081 { 8945 foreach ($array as $key => $value) { 8946 if (is_object($value)) { 8947 if (method_exists($value, '__toString')) { 11082 8948 $cmp = $value->__toString(); 8949 } else { 8950 trigger_error('Object of class '.get_class($value).' could not be converted to string', E_USER_ERROR); 11083 8951 } 11084 else 11085 { 11086 trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR); 11087 } 11088 } 11089 elseif (is_array($value)) 11090 { 8952 } elseif (is_array($value)) { 11091 8953 $cmp = (string) reset($value); 11092 } 11093 else 11094 { 8954 } else { 11095 8955 $cmp = (string) $value; 11096 8956 } 11097 if (!in_array($cmp, $new_array_strings)) 11098 { 8957 if (!in_array($cmp, $new_array_strings)) { 11099 8958 $new_array[$key] = $value; 11100 8959 $new_array_strings[] = $cmp; … … 11116 8975 { 11117 8976 $codepoint = (int) $codepoint; 11118 if ($codepoint < 0) 11119 { 8977 if ($codepoint < 0) { 11120 8978 return false; 11121 } 11122 else if ($codepoint <= 0x7f) 11123 { 8979 } else if ($codepoint <= 0x7f) { 11124 8980 return chr($codepoint); 11125 } 11126 else if ($codepoint <= 0x7ff) 11127 { 11128 return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); 11129 } 11130 else if ($codepoint <= 0xffff) 11131 { 11132 return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); 11133 } 11134 else if ($codepoint <= 0x10ffff) 11135 { 11136 return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); 11137 } 11138 else 11139 { 8981 } else if ($codepoint <= 0x7ff) { 8982 return chr(0xc0 | ($codepoint >> 6)).chr(0x80 | ($codepoint & 0x3f)); 8983 } else if ($codepoint <= 0xffff) { 8984 return chr(0xe0 | ($codepoint >> 12)).chr(0x80 | (($codepoint >> 6) & 0x3f)).chr(0x80 | ($codepoint & 0x3f)); 8985 } else if ($codepoint <= 0x10ffff) { 8986 return chr(0xf0 | ($codepoint >> 18)).chr(0x80 | (($codepoint >> 12) & 0x3f)).chr(0x80 | (($codepoint >> 6) & 0x3f)).chr(0x80 | ($codepoint & 0x3f)); 8987 } else { 11140 8988 // U+FFFD REPLACEMENT CHARACTER 11141 8989 return "\xEF\xBF\xBD"; … … 11162 9010 function stripos($haystack, $needle, $offset = 0) 11163 9011 { 11164 if (function_exists('stripos')) 11165 { 9012 if (function_exists('stripos')) { 11166 9013 return stripos($haystack, $needle, $offset); 11167 } 11168 else 11169 { 11170 if (is_string($needle)) 11171 { 9014 } else { 9015 if (is_string($needle)) { 11172 9016 $needle = strtolower($needle); 11173 } 11174 elseif (is_int($needle) || is_bool($needle) || is_double($needle)) 11175 { 9017 } elseif (is_int($needle) || is_bool($needle) || is_double($needle)) { 11176 9018 $needle = strtolower(chr($needle)); 11177 } 11178 else 11179 { 9019 } else { 11180 9020 trigger_error('needle is not a string or an integer', E_USER_WARNING); 11181 9021 return false; … … 11202 9042 $str = explode('&', $str); 11203 9043 11204 foreach ($str as $section) 11205 { 11206 if (strpos($section, '=') !== false) 11207 { 9044 foreach ($str as $section) { 9045 if (strpos($section, '=') !== false) { 11208 9046 list($name, $value) = explode('=', $section, 2); 11209 9047 $return[urldecode($name)][] = urldecode($value); 11210 } 11211 else 11212 { 9048 } else { 11213 9049 $return[urldecode($section)][] = null; 11214 9050 } … … 11228 9064 { 11229 9065 // UTF-32 Big Endian BOM 11230 if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") 11231 { 9066 if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") { 11232 9067 $encoding[] = 'UTF-32BE'; 11233 9068 } 11234 9069 // UTF-32 Little Endian BOM 11235 elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") 11236 { 9070 elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") { 11237 9071 $encoding[] = 'UTF-32LE'; 11238 9072 } 11239 9073 // UTF-16 Big Endian BOM 11240 elseif (substr($data, 0, 2) === "\xFE\xFF") 11241 { 9074 elseif (substr($data, 0, 2) === "\xFE\xFF") { 11242 9075 $encoding[] = 'UTF-16BE'; 11243 9076 } 11244 9077 // UTF-16 Little Endian BOM 11245 elseif (substr($data, 0, 2) === "\xFF\xFE") 11246 { 9078 elseif (substr($data, 0, 2) === "\xFF\xFE") { 11247 9079 $encoding[] = 'UTF-16LE'; 11248 9080 } 11249 9081 // UTF-8 BOM 11250 elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") 11251 { 9082 elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") { 11252 9083 $encoding[] = 'UTF-8'; 11253 9084 } 11254 9085 // UTF-32 Big Endian Without BOM 11255 elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C") 11256 { 11257 if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) 11258 { 9086 elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C") { 9087 if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) { 11259 9088 $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')); 11260 if ($parser->parse()) 11261 { 9089 if ($parser->parse()) { 11262 9090 $encoding[] = $parser->encoding; 11263 9091 } … … 11266 9094 } 11267 9095 // UTF-32 Little Endian Without BOM 11268 elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00") 11269 { 11270 if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) 11271 { 9096 elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00") { 9097 if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) { 11272 9098 $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')); 11273 if ($parser->parse()) 11274 { 9099 if ($parser->parse()) { 11275 9100 $encoding[] = $parser->encoding; 11276 9101 } … … 11279 9104 } 11280 9105 // UTF-16 Big Endian Without BOM 11281 elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C") 11282 { 11283 if ($pos = strpos($data, "\x00\x3F\x00\x3E")) 11284 { 9106 elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C") { 9107 if ($pos = strpos($data, "\x00\x3F\x00\x3E")) { 11285 9108 $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')); 11286 if ($parser->parse()) 11287 { 9109 if ($parser->parse()) { 11288 9110 $encoding[] = $parser->encoding; 11289 9111 } … … 11292 9114 } 11293 9115 // UTF-16 Little Endian Without BOM 11294 elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00") 11295 { 11296 if ($pos = strpos($data, "\x3F\x00\x3E\x00")) 11297 { 9116 elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00") { 9117 if ($pos = strpos($data, "\x3F\x00\x3E\x00")) { 11298 9118 $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')); 11299 if ($parser->parse()) 11300 { 9119 if ($parser->parse()) { 11301 9120 $encoding[] = $parser->encoding; 11302 9121 } … … 11305 9124 } 11306 9125 // US-ASCII (or superset) 11307 elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C") 11308 { 11309 if ($pos = strpos($data, "\x3F\x3E")) 11310 { 9126 elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C") { 9127 if ($pos = strpos($data, "\x3F\x3E")) { 11311 9128 $parser = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); 11312 if ($parser->parse()) 11313 { 9129 if ($parser->parse()) { 11314 9130 $encoding[] = $parser->encoding; 11315 9131 } … … 11318 9134 } 11319 9135 // Fallback to UTF-8 11320 else 11321 { 9136 else { 11322 9137 $encoding[] = 'UTF-8'; 11323 9138 } … … 11327 9142 function output_javascript() 11328 9143 { 11329 if (function_exists('ob_gzhandler')) 11330 { 9144 if (function_exists('ob_gzhandler')) { 11331 9145 ob_start('ob_gzhandler'); 11332 9146 } 11333 9147 header('Content-type: text/javascript; charset: UTF-8'); 11334 9148 header('Cache-Control: must-revalidate'); 11335 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days 11336 ?> 11337 function embed_odeo(link) { 11338 document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>'); 11339 } 11340 11341 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { 11342 if (placeholder != '') { 11343 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); 11344 } 11345 else { 11346 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); 11347 } 11348 } 11349 11350 function embed_flash(bgcolor, width, height, link, loop, type) { 11351 document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>'); 11352 } 11353 11354 function embed_flv(width, height, link, placeholder, loop, player) { 11355 document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>'); 11356 } 11357 11358 function embed_wmedia(width, height, link) { 11359 document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); 11360 } 11361 <?php 11362 } 9149 header('Expires: '.gmdate('D, d M Y H:i:s', time() + 604800).' GMT'); // 7 days 9150 ?> 9151 function embed_odeo(link) { 9152 document.writeln('<embed src="http://odeo.com/flash/audio_player_fullsize.swf" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="440" height="80" wmode="transparent" allowScriptAccess="any" flashvars="valid_sample_rate=true&external_url='+link+'"></embed>'); 9153 } 9154 9155 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { 9156 if (placeholder != '') { 9157 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); 9158 } 9159 else { 9160 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); 9161 } 9162 } 9163 9164 function embed_flash(bgcolor, width, height, link, loop, type) { 9165 document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>'); 9166 } 9167 9168 function embed_flv(width, height, link, placeholder, loop, player) { 9169 document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>'); 9170 } 9171 9172 function embed_wmedia(width, height, link) { 9173 document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); 9174 } 9175 <?php 9176 } 9177 11363 9178 } 11364 9179 … … 11372 9187 class SimplePie_Decode_HTML_Entities 11373 9188 { 9189 11374 9190 /** 11375 9191 * Data to be parsed … … 11379 9195 */ 11380 9196 var $data = ''; 11381 11382 9197 /** 11383 9198 * Currently consumed bytes … … 11387 9202 */ 11388 9203 var $consumed = ''; 11389 11390 9204 /** 11391 9205 * Position of the current byte being parsed … … 11415 9229 function parse() 11416 9230 { 11417 while (($this->position = strpos($this->data, '&', $this->position)) !== false) 11418 { 9231 while (($this->position = strpos($this->data, '&', $this->position)) !== false) { 11419 9232 $this->consume(); 11420 9233 $this->entity(); … … 11432 9245 function consume() 11433 9246 { 11434 if (isset($this->data[$this->position])) 11435 { 9247 if (isset($this->data[$this->position])) { 11436 9248 $this->consumed .= $this->data[$this->position]; 11437 9249 return $this->data[$this->position++]; 11438 } 11439 else 11440 { 9250 } else { 11441 9251 return false; 11442 9252 } … … 11452 9262 function consume_range($chars) 11453 9263 { 11454 if ($len = strspn($this->data, $chars, $this->position)) 11455 { 9264 if ($len = strspn($this->data, $chars, $this->position)) { 11456 9265 $data = substr($this->data, $this->position, $len); 11457 9266 $this->consumed .= $data; 11458 9267 $this->position += $len; 11459 9268 return $data; 11460 } 11461 else 11462 { 9269 } else { 11463 9270 return false; 11464 9271 } … … 11483 9290 function entity() 11484 9291 { 11485 switch ($this->consume()) 11486 { 9292 switch ($this->consume()) { 11487 9293 case "\x09": 11488 9294 case "\x0A": … … 11497 9303 11498 9304 case "\x23": 11499 switch ($this->consume()) 11500 { 9305 switch ($this->consume()) { 11501 9306 case "\x78": 11502 9307 case "\x58": … … 11512 9317 } 11513 9318 11514 if ($codepoint = $this->consume_range($range)) 11515 { 9319 if ($codepoint = $this->consume_range($range)) { 11516 9320 static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); 11517 9321 11518 if ($hex) 11519 { 9322 if ($hex) { 11520 9323 $codepoint = hexdec($codepoint); 11521 } 11522 else 11523 { 9324 } else { 11524 9325 $codepoint = intval($codepoint); 11525 9326 } 11526 9327 11527 if (isset($windows_1252_specials[$codepoint])) 11528 { 9328 if (isset($windows_1252_specials[$codepoint])) { 11529 9329 $replacement = $windows_1252_specials[$codepoint]; 11530 } 11531 else 11532 { 9330 } else { 11533 9331 $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); 11534 9332 } 11535 9333 11536 if (!in_array($this->consume(), array(';', false), true)) 11537 { 9334 if (!in_array($this->consume(), array(';', false), true)) { 11538 9335 $this->unconsume(); 11539 9336 } … … 11548 9345 static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C"); 11549 9346 11550 for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) 11551 { 9347 for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) { 11552 9348 $consumed = substr($this->consumed, 1); 11553 if (isset($entities[$consumed])) 11554 { 9349 if (isset($entities[$consumed])) { 11555 9350 $match = $consumed; 11556 9351 } 11557 9352 } 11558 9353 11559 if ($match !== null) 11560 { 11561 $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); 9354 if ($match !== null) { 9355 $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); 11562 9356 $this->position += strlen($entities[$match]) - strlen($consumed) - 1; 11563 9357 } … … 11565 9359 } 11566 9360 } 9361 11567 9362 } 11568 9363 … … 11574 9369 class SimplePie_IRI 11575 9370 { 9371 11576 9372 /** 11577 9373 * Scheme … … 11581 9377 */ 11582 9378 var $scheme; 11583 11584 9379 /** 11585 9380 * User Information … … 11589 9384 */ 11590 9385 var $userinfo; 11591 11592 9386 /** 11593 9387 * Host … … 11597 9391 */ 11598 9392 var $host; 11599 11600 9393 /** 11601 9394 * Port … … 11605 9398 */ 11606 9399 var $port; 11607 11608 9400 /** 11609 9401 * Path … … 11613 9405 */ 11614 9406 var $path; 11615 11616 9407 /** 11617 9408 * Query … … 11621 9412 */ 11622 9413 var $query; 11623 11624 9414 /** 11625 9415 * Fragment … … 11629 9419 */ 11630 9420 var $fragment; 11631 11632 9421 /** 11633 9422 * Whether the object represents a valid IRI … … 11659 9448 { 11660 9449 $iri = (string) $iri; 11661 if ($iri !== '') 11662 { 9450 if ($iri !== '') { 11663 9451 $parsed = $this->parse_iri($iri); 11664 9452 $this->set_scheme($parsed['scheme']); … … 11682 9470 { 11683 9471 $relative = (string) $relative; 11684 if ($relative !== '') 11685 { 9472 if ($relative !== '') { 11686 9473 $relative = new SimplePie_IRI($relative); 11687 if ($relative->get_scheme() !== null) 11688 { 9474 if ($relative->get_scheme() !== null) { 11689 9475 $target = $relative; 11690 } 11691 elseif ($base->get_iri() !== null) 11692 { 11693 if ($relative->get_authority() !== null) 11694 { 9476 } elseif ($base->get_iri() !== null) { 9477 if ($relative->get_authority() !== null) { 11695 9478 $target = $relative; 11696 9479 $target->set_scheme($base->get_scheme()); 11697 } 11698 else 11699 { 9480 } else { 11700 9481 $target = new SimplePie_IRI(''); 11701 9482 $target->set_scheme($base->get_scheme()); … … 11703 9484 $target->set_host($base->get_host()); 11704 9485 $target->set_port($base->get_port()); 11705 if ($relative->get_path() !== null) 11706 { 11707 if (strpos($relative->get_path(), '/') === 0) 11708 { 9486 if ($relative->get_path() !== null) { 9487 if (strpos($relative->get_path(), '/') === 0) { 11709 9488 $target->set_path($relative->get_path()); 11710 } 11711 elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null) 11712 { 11713 $target->set_path('/' . $relative->get_path()); 11714 } 11715 elseif (($last_segment = strrpos($base->get_path(), '/')) !== false) 11716 { 11717 $target->set_path(substr($base->get_path(), 0, $last_segment + 1) . $relative->get_path()); 11718 } 11719 else 11720 { 9489 } elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null) { 9490 $target->set_path('/'.$relative->get_path()); 9491 } elseif (($last_segment = strrpos($base->get_path(), '/')) !== false) { 9492 $target->set_path(substr($base->get_path(), 0, $last_segment + 1).$relative->get_path()); 9493 } else { 11721 9494 $target->set_path($relative->get_path()); 11722 9495 } 11723 9496 $target->set_query($relative->get_query()); 11724 } 11725 else 11726 { 9497 } else { 11727 9498 $target->set_path($base->get_path()); 11728 if ($relative->get_query() !== null) 11729 { 9499 if ($relative->get_query() !== null) { 11730 9500 $target->set_query($relative->get_query()); 11731 } 11732 elseif ($base->get_query() !== null) 11733 { 9501 } elseif ($base->get_query() !== null) { 11734 9502 $target->set_query($base->get_query()); 11735 9503 } … … 11737 9505 } 11738 9506 $target->set_fragment($relative->get_fragment()); 11739 } 11740 else 11741 { 9507 } else { 11742 9508 // No base URL, just return the relative URL 11743 9509 $target = $relative; 11744 9510 } 11745 } 11746 else 11747 { 9511 } else { 11748 9512 $target = $base; 11749 9513 } … … 11761 9525 { 11762 9526 preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $iri, $match); 11763 for ($i = count($match); $i <= 9; $i++) 11764 { 9527 for ($i = count($match); $i <= 9; $i++) { 11765 9528 $match[$i] = ''; 11766 9529 } … … 11778 9541 { 11779 9542 $output = ''; 11780 while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') 11781 { 9543 while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') { 11782 9544 // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, 11783 if (strpos($input, '../') === 0) 11784 { 9545 if (strpos($input, '../') === 0) { 11785 9546 $input = substr($input, 3); 11786 } 11787 elseif (strpos($input, './') === 0) 11788 { 9547 } elseif (strpos($input, './') === 0) { 11789 9548 $input = substr($input, 2); 11790 9549 } 11791 9550 // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, 11792 elseif (strpos($input, '/./') === 0) 11793 { 9551 elseif (strpos($input, '/./') === 0) { 11794 9552 $input = substr_replace($input, '/', 0, 3); 11795 } 11796 elseif ($input === '/.') 11797 { 9553 } elseif ($input === '/.') { 11798 9554 $input = '/'; 11799 9555 } 11800 9556 // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, 11801 elseif (strpos($input, '/../') === 0) 11802 { 9557 elseif (strpos($input, '/../') === 0) { 11803 9558 $input = substr_replace($input, '/', 0, 4); 11804 9559 $output = substr_replace($output, '', strrpos($output, '/')); 11805 } 11806 elseif ($input === '/..') 11807 { 9560 } elseif ($input === '/..') { 11808 9561 $input = '/'; 11809 9562 $output = substr_replace($output, '', strrpos($output, '/')); 11810 9563 } 11811 9564 // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, 11812 elseif ($input === '.' || $input === '..') 11813 { 9565 elseif ($input === '.' || $input === '..') { 11814 9566 $input = ''; 11815 9567 } 11816 9568 // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer 11817 elseif (($pos = strpos($input, '/', 1)) !== false) 11818 { 9569 elseif (($pos = strpos($input, '/', 1)) !== false) { 11819 9570 $output .= substr($input, 0, $pos); 11820 9571 $input = substr_replace($input, '', 0, $pos); 11821 } 11822 else 11823 { 9572 } else { 11824 9573 $output .= $input; 11825 9574 $input = ''; 11826 9575 } 11827 9576 } 11828 return $output .$input;9577 return $output.$input; 11829 9578 } 11830 9579 … … 11841 9590 { 11842 9591 // Normalise case 11843 if ($case & SIMPLEPIE_LOWERCASE) 11844 { 9592 if ($case & SIMPLEPIE_LOWERCASE) { 11845 9593 $string = strtolower($string); 11846 } 11847 elseif ($case & SIMPLEPIE_UPPERCASE) 11848 { 9594 } elseif ($case & SIMPLEPIE_UPPERCASE) { 11849 9595 $string = strtoupper($string); 11850 9596 } … … 11855 9601 11856 9602 // Loop as long as we have invalid characters, advancing the position to the next invalid character 11857 while (($position += strspn($string, $valid_chars, $position)) < $strlen) 11858 { 9603 while (($position += strspn($string, $valid_chars, $position)) < $strlen) { 11859 9604 // If we have a % character 11860 if ($string[$position] === '%') 11861 { 9605 if ($string[$position] === '%') { 11862 9606 // If we have a pct-encoded section 11863 if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2) 11864 { 9607 if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2) { 11865 9608 // Get the the represented character 11866 9609 $chr = chr(hexdec(substr($string, $position + 1, 2))); 11867 9610 11868 9611 // If the character is valid, replace the pct-encoded with the actual character while normalising case 11869 if (strpos($valid_chars, $chr) !== false) 11870 { 11871 if ($case & SIMPLEPIE_LOWERCASE) 11872 { 9612 if (strpos($valid_chars, $chr) !== false) { 9613 if ($case & SIMPLEPIE_LOWERCASE) { 11873 9614 $chr = strtolower($chr); 11874 } 11875 elseif ($case & SIMPLEPIE_UPPERCASE) 11876 { 9615 } elseif ($case & SIMPLEPIE_UPPERCASE) { 11877 9616 $chr = strtoupper($chr); 11878 9617 } … … 11883 9622 11884 9623 // Otherwise just normalise the pct-encoded to uppercase 11885 else 11886 { 9624 else { 11887 9625 $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2); 11888 9626 $position += 3; … … 11890 9628 } 11891 9629 // If we don't have a pct-encoded section, just replace the % with its own esccaped form 11892 else 11893 { 9630 else { 11894 9631 $string = substr_replace($string, '%25', $position, 1); 11895 9632 $strlen += 2; … … 11898 9635 } 11899 9636 // If we have an invalid character, change into its pct-encoded form 11900 else 11901 { 9637 else { 11902 9638 $replacement = sprintf("%%%02X", ord($string[$position])); 11903 9639 $string = str_replace($string[$position], $replacement, $string); … … 11929 9665 function set_scheme($scheme) 11930 9666 { 11931 if ($scheme === null || $scheme === '') 11932 { 9667 if ($scheme === null || $scheme === '') { 11933 9668 $this->scheme = null; 11934 } 11935 else 11936 { 9669 } else { 11937 9670 $len = strlen($scheme); 11938 switch (true) 11939 { 9671 switch (true) { 11940 9672 case $len > 1: 11941 if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1)) 11942 { 9673 if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1)) { 11943 9674 $this->scheme = null; 11944 9675 $this->valid[__FUNCTION__] = false; … … 11947 9678 11948 9679 case $len > 0: 11949 if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1)) 11950 { 9680 if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1)) { 11951 9681 $this->scheme = null; 11952 9682 $this->valid[__FUNCTION__] = false; … … 11970 9700 function set_authority($authority) 11971 9701 { 11972 if (($userinfo_end = strrpos($authority, '@')) !== false) 11973 { 9702 if (($userinfo_end = strrpos($authority, '@')) !== false) { 11974 9703 $userinfo = substr($authority, 0, $userinfo_end); 11975 9704 $authority = substr($authority, $userinfo_end + 1); 11976 } 11977 else 11978 { 9705 } else { 11979 9706 $userinfo = null; 11980 9707 } 11981 9708 11982 if (($port_start = strpos($authority, ':')) !== false) 11983 { 9709 if (($port_start = strpos($authority, ':')) !== false) { 11984 9710 $port = substr($authority, $port_start + 1); 11985 9711 $authority = substr($authority, 0, $port_start); 11986 } 11987 else 11988 { 9712 } else { 11989 9713 $port = null; 11990 9714 } … … 12002 9726 function set_userinfo($userinfo) 12003 9727 { 12004 if ($userinfo === null || $userinfo === '') 12005 { 9728 if ($userinfo === null || $userinfo === '') { 12006 9729 $this->userinfo = null; 12007 } 12008 else 12009 { 9730 } else { 12010 9731 $this->userinfo = $this->replace_invalid_with_pct_encoding($userinfo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:'); 12011 9732 } … … 12024 9745 function set_host($host) 12025 9746 { 12026 if ($host === null || $host === '') 12027 { 9747 if ($host === null || $host === '') { 12028 9748 $this->host = null; 12029 9749 $this->valid[__FUNCTION__] = true; 12030 9750 return true; 12031 } 12032 elseif ($host[0] === '[' && substr($host, -1) === ']') 12033 { 12034 if (Net_IPv6::checkIPv6(substr($host, 1, -1))) 12035 { 9751 } elseif ($host[0] === '[' && substr($host, -1) === ']') { 9752 if (Net_IPv6::checkIPv6(substr($host, 1, -1))) { 12036 9753 $this->host = $host; 12037 9754 $this->valid[__FUNCTION__] = true; 12038 9755 return true; 12039 } 12040 else 12041 { 9756 } else { 12042 9757 $this->host = null; 12043 9758 $this->valid[__FUNCTION__] = false; 12044 9759 return false; 12045 9760 } 12046 } 12047 else 12048 { 9761 } else { 12049 9762 $this->host = $this->replace_invalid_with_pct_encoding($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=', SIMPLEPIE_LOWERCASE); 12050 9763 $this->valid[__FUNCTION__] = true; … … 12063 9776 function set_port($port) 12064 9777 { 12065 if ($port === null || $port === '') 12066 { 9778 if ($port === null || $port === '') { 12067 9779 $this->port = null; 12068 9780 $this->valid[__FUNCTION__] = true; 12069 9781 return true; 12070 } 12071 elseif (strspn($port, '0123456789') === strlen($port)) 12072 { 9782 } elseif (strspn($port, '0123456789') === strlen($port)) { 12073 9783 $this->port = (int) $port; 12074 9784 $this->valid[__FUNCTION__] = true; 12075 9785 return true; 12076 } 12077 else 12078 { 9786 } else { 12079 9787 $this->port = null; 12080 9788 $this->valid[__FUNCTION__] = false; … … 12092 9800 function set_path($path) 12093 9801 { 12094 if ($path === null || $path === '') 12095 { 9802 if ($path === null || $path === '') { 12096 9803 $this->path = null; 12097 9804 $this->valid[__FUNCTION__] = true; 12098 9805 return true; 12099 } 12100 elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null) 12101 { 9806 } elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null) { 12102 9807 $this->path = null; 12103 9808 $this->valid[__FUNCTION__] = false; 12104 9809 return false; 12105 } 12106 else 12107 { 9810 } else { 12108 9811 $this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/'); 12109 if ($this->scheme !== null) 12110 { 9812 if ($this->scheme !== null) { 12111 9813 $this->path = $this->remove_dot_segments($this->path); 12112 9814 } … … 12125 9827 function set_query($query) 12126 9828 { 12127 if ($query === null || $query === '') 12128 { 9829 if ($query === null || $query === '') { 12129 9830 $this->query = null; 12130 } 12131 else 12132 { 9831 } else { 12133 9832 $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?'); 12134 9833 } … … 12146 9845 function set_fragment($fragment) 12147 9846 { 12148 if ($fragment === null || $fragment === '') 12149 { 9847 if ($fragment === null || $fragment === '') { 12150 9848 $this->fragment = null; 12151 } 12152 else 12153 { 9849 } else { 12154 9850 $this->fragment = $this->replace_invalid_with_pct_encoding($fragment, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?'); 12155 9851 } … … 12167 9863 { 12168 9864 $iri = ''; 12169 if ($this->scheme !== null) 12170 { 12171 $iri .= $this->scheme . ':'; 12172 } 12173 if (($authority = $this->get_authority()) !== null) 12174 { 12175 $iri .= '//' . $authority; 12176 } 12177 if ($this->path !== null) 12178 { 9865 if ($this->scheme !== null) { 9866 $iri .= $this->scheme.':'; 9867 } 9868 if (($authority = $this->get_authority()) !== null) { 9869 $iri .= '//'.$authority; 9870 } 9871 if ($this->path !== null) { 12179 9872 $iri .= $this->path; 12180 9873 } 12181 if ($this->query !== null) 12182 { 12183 $iri .= '?' . $this->query; 12184 } 12185 if ($this->fragment !== null) 12186 { 12187 $iri .= '#' . $this->fragment; 12188 } 12189 12190 if ($iri !== '') 12191 { 9874 if ($this->query !== null) { 9875 $iri .= '?'.$this->query; 9876 } 9877 if ($this->fragment !== null) { 9878 $iri .= '#'.$this->fragment; 9879 } 9880 9881 if ($iri !== '') { 12192 9882 return $iri; 12193 } 12194 else 12195 { 9883 } else { 12196 9884 return null; 12197 9885 } … … 12218 9906 { 12219 9907 $authority = ''; 12220 if ($this->userinfo !== null) 12221 { 12222 $authority .= $this->userinfo . '@'; 12223 } 12224 if ($this->host !== null) 12225 { 9908 if ($this->userinfo !== null) { 9909 $authority .= $this->userinfo.'@'; 9910 } 9911 if ($this->host !== null) { 12226 9912 $authority .= $this->host; 12227 9913 } 12228 if ($this->port !== null) 12229 { 12230 $authority .= ':' . $this->port; 12231 } 12232 12233 if ($authority !== '') 12234 { 9914 if ($this->port !== null) { 9915 $authority .= ':'.$this->port; 9916 } 9917 9918 if ($authority !== '') { 12235 9919 return $authority; 12236 } 12237 else 12238 { 9920 } else { 12239 9921 return null; 12240 9922 } … … 12306 9988 return $this->fragment; 12307 9989 } 12308 } 12309 12310 /** 12311 * Class to validate and to work with IPv6 addresses. 12312 * 12313 * @package SimplePie 12314 * @copyright 2003-2005 The PHP Group 12315 * @license http://www.opensource.org/licenses/bsd-license.php 12316 * @link http://pear.php.net/package/Net_IPv6 12317 * @author Alexander Merz <alexander.merz@web.de> 12318 * @author elfrink at introweb dot nl 12319 * @author Josh Peck <jmp at joshpeck dot org> 12320 * @author Geoffrey Sneddon <geoffers@gmail.com> 12321 */ 12322 class SimplePie_Net_IPv6 12323 { 12324 /** 12325 * Removes a possible existing netmask specification of an IP address. 12326 * 12327 * @param string $ip the (compressed) IP as Hex representation 12328 * @return string the IP the without netmask 12329 * @since 1.1.0 12330 * @access public 12331 * @static 12332 */ 12333 function removeNetmaskSpec($ip) 12334 { 12335 if (strpos($ip, '/') !== false) 12336 { 12337 list($addr, $nm) = explode('/', $ip); 12338 } 12339 else 12340 { 12341 $addr = $ip; 12342 } 12343 return $addr; 12344 } 12345 12346 /** 12347 * Uncompresses an IPv6 address 12348 * 12349 * RFC 2373 allows you to compress zeros in an address to '::'. This 12350 * function expects an valid IPv6 address and expands the '::' to 12351 * the required zeros. 12352 * 12353 * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 12354 * ::1 -> 0:0:0:0:0:0:0:1 12355 * 12356 * @access public 12357 * @static 12358 * @param string $ip a valid IPv6-address (hex format) 12359 * @return string the uncompressed IPv6-address (hex format) 12360 */ 12361 function Uncompress($ip) 12362 { 12363 $uip = SimplePie_Net_IPv6::removeNetmaskSpec($ip); 12364 $c1 = -1; 12365 $c2 = -1; 12366 if (strpos($ip, '::') !== false) 12367 { 12368 list($ip1, $ip2) = explode('::', $ip); 12369 if ($ip1 === '') 12370 { 12371 $c1 = -1; 12372 } 12373 else 12374 { 12375 $pos = 0; 12376 if (($pos = substr_count($ip1, ':')) > 0) 12377 { 12378 $c1 = $pos; 12379 } 12380 else 12381 { 12382 $c1 = 0; 12383 } 12384 } 12385 if ($ip2 === '') 12386 { 12387 $c2 = -1; 12388 } 12389 else 12390 { 12391 $pos = 0; 12392 if (($pos = substr_count($ip2, ':')) > 0) 12393 { 12394 $c2 = $pos; 12395 } 12396 else 12397 { 12398 $c2 = 0; 12399 } 12400 } 12401 if (strstr($ip2, '.')) 12402 { 12403 $c2++; 12404 } 12405 // :: 12406 if ($c1 === -1 && $c2 === -1) 12407 { 12408 $uip = '0:0:0:0:0:0:0:0'; 12409 } 12410 // ::xxx 12411 else if ($c1 === -1) 12412 { 12413 $fill = str_repeat('0:', 7 - $c2); 12414 $uip = str_replace('::', $fill, $uip); 12415 } 12416 // xxx:: 12417 else if ($c2 === -1) 12418 { 12419 $fill = str_repeat(':0', 7 - $c1); 12420 $uip = str_replace('::', $fill, $uip); 12421 } 12422 // xxx::xxx 12423 else 12424 { 12425 $fill = str_repeat(':0:', 6 - $c2 - $c1); 12426 $uip = str_replace('::', $fill, $uip); 12427 $uip = str_replace('::', ':', $uip); 12428 } 12429 } 12430 return $uip; 12431 } 12432 12433 /** 12434 * Splits an IPv6 address into the IPv6 and a possible IPv4 part 12435 * 12436 * RFC 2373 allows you to note the last two parts of an IPv6 address as 12437 * an IPv4 compatible address 12438 * 12439 * Example: 0:0:0:0:0:0:13.1.68.3 12440 * 0:0:0:0:0:FFFF:129.144.52.38 12441 * 12442 * @access public 12443 * @static 12444 * @param string $ip a valid IPv6-address (hex format) 12445 * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format) 12446 */ 12447 function SplitV64($ip) 12448 { 12449 $ip = SimplePie_Net_IPv6::Uncompress($ip); 12450 if (strstr($ip, '.')) 12451 { 12452 $pos = strrpos($ip, ':'); 12453 $ip[$pos] = '_'; 12454 $ipPart = explode('_', $ip); 12455 return $ipPart; 12456 } 12457 else 12458 { 12459 return array($ip, ''); 12460 } 12461 } 12462 12463 /** 12464 * Checks an IPv6 address 12465 * 12466 * Checks if the given IP is IPv6-compatible 12467 * 12468 * @access public 12469 * @static 12470 * @param string $ip a valid IPv6-address 12471 * @return bool true if $ip is an IPv6 address 12472 */ 12473 function checkIPv6($ip) 12474 { 12475 $ipPart = SimplePie_Net_IPv6::SplitV64($ip); 12476 $count = 0; 12477 if (!empty($ipPart[0])) 12478 { 12479 $ipv6 = explode(':', $ipPart[0]); 12480 for ($i = 0; $i < count($ipv6); $i++) 12481 { 12482 $dec = hexdec($ipv6[$i]); 12483 $hex = strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/', '\\1', $ipv6[$i])); 12484 if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex === strtoupper(dechex($dec))) 12485 { 12486 $count++; 12487 } 12488 } 12489 if ($count === 8) 12490 { 12491 return true; 12492 } 12493 elseif ($count === 6 && !empty($ipPart[1])) 12494 { 12495 $ipv4 = explode('.', $ipPart[1]); 12496 $count = 0; 12497 foreach ($ipv4 as $ipv4_part) 12498 { 12499 if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part)) 12500 { 12501 $count++; 12502 } 12503 } 12504 if ($count === 4) 12505 { 12506 return true; 12507 } 12508 } 12509 else 12510 { 12511 return false; 12512 } 12513 12514 } 12515 else 12516 { 12517 return false; 12518 } 12519 } 9990 12520 9991 } 12521 9992 … … 12527 9998 class SimplePie_Parse_Date 12528 9999 { 10000 12529 10001 /** 12530 10002 * Input data … … 12534 10006 */ 12535 10007 var $date; 12536 12537 10008 /** 12538 10009 * List of days, calendar day name => ordinal day number in the week … … 12623 10094 'Κυρ' => 7, 12624 10095 ); 12625 12626 10096 /** 12627 10097 * List of months, calendar month name => calendar month number … … 12768 10238 'Δεκ' => 12, 12769 10239 ); 12770 12771 10240 /** 12772 10241 * List of timezones, abbreviation => offset from UTC … … 12976 10445 'YEKT' => 18000, 12977 10446 ); 12978 12979 10447 /** 12980 10448 * Cached PCRE for SimplePie_Parse_Date::$day … … 12984 10452 */ 12985 10453 var $day_pcre; 12986 12987 10454 /** 12988 10455 * Cached PCRE for SimplePie_Parse_Date::$month … … 12992 10459 */ 12993 10460 var $month_pcre; 12994 12995 10461 /** 12996 10462 * Array of user-added callback methods … … 13000 10466 */ 13001 10467 var $built_in = array(); 13002 13003 10468 /** 13004 10469 * Array of user-added callback methods … … 13017 10482 function SimplePie_Parse_Date() 13018 10483 { 13019 $this->day_pcre = '(' . implode(array_keys($this->day), '|') .')';13020 $this->month_pcre = '(' . implode(array_keys($this->month), '|') .')';10484 $this->day_pcre = '('.implode(array_keys($this->day), '|').')'; 10485 $this->month_pcre = '('.implode(array_keys($this->month), '|').')'; 13021 10486 13022 10487 static $cache; 13023 if (!isset($cache[get_class($this)])) 13024 { 10488 if (!isset($cache[get_class($this)])) { 13025 10489 $all_methods = get_class_methods($this); 13026 10490 13027 foreach ($all_methods as $method) 13028 { 13029 if (strtolower(substr($method, 0, 5)) === 'date_') 13030 { 10491 foreach ($all_methods as $method) { 10492 if (strtolower(substr($method, 0, 5)) === 'date_') { 13031 10493 $cache[get_class($this)][] = $method; 13032 10494 } … … 13034 10496 } 13035 10497 13036 foreach ($cache[get_class($this)] as $method) 13037 { 10498 foreach ($cache[get_class($this)] as $method) { 13038 10499 $this->built_in[] = $method; 13039 10500 } … … 13048 10509 { 13049 10510 static $object; 13050 if (!$object) 13051 { 10511 if (!$object) { 13052 10512 $object = new SimplePie_Parse_Date; 13053 10513 } … … 13065 10525 function parse($date) 13066 10526 { 13067 foreach ($this->user as $method) 13068 { 13069 if (($returned = call_user_func($method, $date)) !== false) 13070 { 10527 foreach ($this->user as $method) { 10528 if (($returned = call_user_func($method, $date)) !== false) { 13071 10529 return $returned; 13072 10530 } 13073 10531 } 13074 10532 13075 foreach ($this->built_in as $method) 13076 { 13077 if (($returned = call_user_func(array(&$this, $method), $date)) !== false) 13078 { 10533 foreach ($this->built_in as $method) { 10534 if (($returned = call_user_func(array(&$this, $method), $date)) !== false) { 13079 10535 return $returned; 13080 10536 } … … 13093 10549 function add_callback($callback) 13094 10550 { 13095 if (is_callable($callback)) 13096 { 10551 if (is_callable($callback)) { 13097 10552 $this->user[] = $callback; 13098 } 13099 else 13100 { 10553 } else { 13101 10554 trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); 13102 10555 } … … 13114 10567 { 13115 10568 static $pcre; 13116 if (!$pcre) 13117 { 10569 if (!$pcre) { 13118 10570 $year = '([0-9]{4})'; 13119 10571 $month = $day = $hour = $minute = $second = '([0-9]{2})'; 13120 10572 $decimal = '([0-9]*)'; 13121 10573 $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))'; 13122 $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/'; 13123 } 13124 if (preg_match($pcre, $date, $match)) 13125 { 10574 $pcre = '/^'.$year.'(?:-?'.$month.'(?:-?'.$day.'(?:[Tt\x09\x20]+'.$hour.'(?::?'.$minute.'(?::?'.$second.'(?:.'.$decimal.')?)?)?'.$zone.')?)?)?$/'; 10575 } 10576 if (preg_match($pcre, $date, $match)) { 13126 10577 /* 13127 Capturing subpatterns:13128 1: Year13129 2: Month13130 3: Day13131 4: Hour13132 5: Minute13133 6: Second13134 7: Decimal fraction of a second13135 8: Zulu13136 9: Timezone ±13137 10: Timezone hours13138 11: Timezone minutes13139 */10578 Capturing subpatterns: 10579 1: Year 10580 2: Month 10581 3: Day 10582 4: Hour 10583 5: Minute 10584 6: Second 10585 7: Decimal fraction of a second 10586 8: Zulu 10587 9: Timezone ± 10588 10: Timezone hours 10589 11: Timezone minutes 10590 */ 13140 10591 13141 10592 // Fill in empty matches 13142 for ($i = count($match); $i <= 3; $i++) 13143 { 10593 for ($i = count($match); $i <= 3; $i++) { 13144 10594 $match[$i] = '1'; 13145 10595 } 13146 10596 13147 for ($i = count($match); $i <= 7; $i++) 13148 { 10597 for ($i = count($match); $i <= 7; $i++) { 13149 10598 $match[$i] = '0'; 13150 10599 } 13151 10600 13152 10601 // Numeric timezone 13153 if (isset($match[9]) && $match[9] !== '') 13154 { 10602 if (isset($match[9]) && $match[9] !== '') { 13155 10603 $timezone = $match[10] * 3600; 13156 10604 $timezone += $match[11] * 60; 13157 if ($match[9] === '-') 13158 { 10605 if ($match[9] === '-') { 13159 10606 $timezone = 0 - $timezone; 13160 10607 } 13161 } 13162 else 13163 { 10608 } else { 13164 10609 $timezone = 0; 13165 10610 } … … 13169 10614 13170 10615 return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; 13171 } 13172 else 13173 { 10616 } else { 13174 10617 return false; 13175 10618 } … … 13192 10635 $output = ''; 13193 10636 13194 while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) 13195 { 10637 while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) { 13196 10638 $output .= substr($string, $position, $pos - $position); 13197 10639 $position = $pos + 1; 13198 if ($string[$pos - 1] !== '\\') 13199 { 10640 if ($string[$pos - 1] !== '\\') { 13200 10641 $depth++; 13201 while ($depth && $position < $length) 13202 { 10642 while ($depth && $position < $length) { 13203 10643 $position += strcspn($string, '()', $position); 13204 if ($string[$position - 1] === '\\') 13205 { 10644 if ($string[$position - 1] === '\\') { 13206 10645 $position++; 13207 10646 continue; 13208 } 13209 elseif (isset($string[$position])) 13210 { 13211 switch ($string[$position]) 13212 { 10647 } elseif (isset($string[$position])) { 10648 switch ($string[$position]) { 13213 10649 case '(': 13214 10650 $depth++; … … 13220 10656 } 13221 10657 $position++; 13222 } 13223 else 13224 { 10658 } else { 13225 10659 break; 13226 10660 } 13227 10661 } 13228 } 13229 else 13230 { 10662 } else { 13231 10663 $output .= '('; 13232 10664 } … … 13246 10678 { 13247 10679 static $pcre; 13248 if (!$pcre) 13249 { 10680 if (!$pcre) { 13250 10681 $wsp = '[\x09\x20]'; 13251 $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp .'+)+)';13252 $optional_fws = $fws .'?';10682 $fws = '(?:'.$wsp.'+|'.$wsp.'*(?:\x0D\x0A'.$wsp.'+)+)'; 10683 $optional_fws = $fws.'?'; 13253 10684 $day_name = $this->day_pcre; 13254 10685 $month = $this->month_pcre; … … 13258 10689 $num_zone = '([+\-])([0-9]{2})([0-9]{2})'; 13259 10690 $character_zone = '([A-Z]{1,5})'; 13260 $zone = '(?:' . $num_zone . '|' . $character_zone . ')'; 13261 $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i'; 13262 } 13263 if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match)) 13264 { 10691 $zone = '(?:'.$num_zone.'|'.$character_zone.')'; 10692 $pcre = '/(?:'.$optional_fws.$day_name.$optional_fws.',)?'.$optional_fws.$day.$fws.$month.$fws.$year.$fws.$hour.$optional_fws.':'.$optional_fws.$minute.'(?:'.$optional_fws.':'.$optional_fws.$second.')?'.$fws.$zone.'/i'; 10693 } 10694 if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match)) { 13265 10695 /* 13266 Capturing subpatterns:13267 1: Day name13268 2: Day13269 3: Month13270 4: Year13271 5: Hour13272 6: Minute13273 7: Second13274 8: Timezone ±13275 9: Timezone hours13276 10: Timezone minutes13277 11: Alphabetic timezone13278 */10696 Capturing subpatterns: 10697 1: Day name 10698 2: Day 10699 3: Month 10700 4: Year 10701 5: Hour 10702 6: Minute 10703 7: Second 10704 8: Timezone ± 10705 9: Timezone hours 10706 10: Timezone minutes 10707 11: Alphabetic timezone 10708 */ 13279 10709 13280 10710 // Find the month number … … 13282 10712 13283 10713 // Numeric timezone 13284 if ($match[8] !== '') 13285 { 10714 if ($match[8] !== '') { 13286 10715 $timezone = $match[9] * 3600; 13287 10716 $timezone += $match[10] * 60; 13288 if ($match[8] === '-') 13289 { 10717 if ($match[8] === '-') { 13290 10718 $timezone = 0 - $timezone; 13291 10719 } 13292 10720 } 13293 10721 // Character timezone 13294 elseif (isset($this->timezone[strtoupper($match[11])])) 13295 { 10722 elseif (isset($this->timezone[strtoupper($match[11])])) { 13296 10723 $timezone = $this->timezone[strtoupper($match[11])]; 13297 10724 } 13298 10725 // Assume everything else to be -0000 13299 else 13300 { 10726 else { 13301 10727 $timezone = 0; 13302 10728 } 13303 10729 13304 10730 // Deal with 2/3 digit years 13305 if ($match[4] < 50) 13306 { 10731 if ($match[4] < 50) { 13307 10732 $match[4] += 2000; 13308 } 13309 elseif ($match[4] < 1000) 13310 { 10733 } elseif ($match[4] < 1000) { 13311 10734 $match[4] += 1900; 13312 10735 } 13313 10736 13314 10737 // Second is optional, if it is empty set it to zero 13315 if ($match[7] !== '') 13316 { 10738 if ($match[7] !== '') { 13317 10739 $second = $match[7]; 13318 } 13319 else 13320 { 10740 } else { 13321 10741 $second = 0; 13322 10742 } 13323 10743 13324 10744 return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; 13325 } 13326 else 13327 { 10745 } else { 13328 10746 return false; 13329 10747 } … … 13339 10757 { 13340 10758 static $pcre; 13341 if (!$pcre) 13342 { 10759 if (!$pcre) { 13343 10760 $space = '[\x09\x20]+'; 13344 10761 $day_name = $this->day_pcre; … … 13347 10764 $year = $hour = $minute = $second = '([0-9]{2})'; 13348 10765 $zone = '([A-Z]{1,5})'; 13349 $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i'; 13350 } 13351 if (preg_match($pcre, $date, $match)) 13352 { 10766 $pcre = '/^'.$day_name.','.$space.$day.'-'.$month.'-'.$year.$space.$hour.':'.$minute.':'.$second.$space.$zone.'$/i'; 10767 } 10768 if (preg_match($pcre, $date, $match)) { 13353 10769 /* 13354 Capturing subpatterns:13355 1: Day name13356 2: Day13357 3: Month13358 4: Year13359 5: Hour13360 6: Minute13361 7: Second13362 8: Timezone13363 */10770 Capturing subpatterns: 10771 1: Day name 10772 2: Day 10773 3: Month 10774 4: Year 10775 5: Hour 10776 6: Minute 10777 7: Second 10778 8: Timezone 10779 */ 13364 10780 13365 10781 // Month … … 13367 10783 13368 10784 // Character timezone 13369 if (isset($this->timezone[strtoupper($match[8])])) 13370 { 10785 if (isset($this->timezone[strtoupper($match[8])])) { 13371 10786 $timezone = $this->timezone[strtoupper($match[8])]; 13372 10787 } 13373 10788 // Assume everything else to be -0000 13374 else 13375 { 10789 else { 13376 10790 $timezone = 0; 13377 10791 } 13378 10792 13379 10793 // Deal with 2 digit year 13380 if ($match[4] < 50) 13381 { 10794 if ($match[4] < 50) { 13382 10795 $match[4] += 2000; 13383 } 13384 else 13385 { 10796 } else { 13386 10797 $match[4] += 1900; 13387 10798 } 13388 10799 13389 10800 return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; 13390 } 13391 else 13392 { 10801 } else { 13393 10802 return false; 13394 10803 } … … 13404 10813 { 13405 10814 static $pcre; 13406 if (!$pcre) 13407 { 10815 if (!$pcre) { 13408 10816 $space = '[\x09\x20]+'; 13409 10817 $wday_name = $this->day_pcre; … … 13413 10821 $year = '([0-9]{4})'; 13414 10822 $terminator = '\x0A?\x00?'; 13415 $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; 13416 } 13417 if (preg_match($pcre, $date, $match)) 13418 { 10823 $pcre = '/^'.$wday_name.$space.$mon_name.$space.$day.$space.$hour.':'.$min.':'.$sec.$space.$year.$terminator.'$/i'; 10824 } 10825 if (preg_match($pcre, $date, $match)) { 13419 10826 /* 13420 Capturing subpatterns:13421 1: Day name13422 2: Month13423 3: Day13424 4: Hour13425 5: Minute13426 6: Second13427 7: Year13428 */10827 Capturing subpatterns: 10828 1: Day name 10829 2: Month 10830 3: Day 10831 4: Hour 10832 5: Minute 10833 6: Second 10834 7: Year 10835 */ 13429 10836 13430 10837 $month = $this->month[strtolower($match[2])]; 13431 10838 return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); 13432 } 13433 else 13434 { 10839 } else { 13435 10840 return false; 13436 10841 } … … 13446 10851 { 13447 10852 $strtotime = strtotime($date); 13448 if ($strtotime === -1 || $strtotime === false) 13449 { 10853 if ($strtotime === -1 || $strtotime === false) { 13450 10854 return false; 13451 } 13452 else 13453 { 10855 } else { 13454 10856 return $strtotime; 13455 10857 } 13456 10858 } 10859 13457 10860 } 13458 10861 … … 13464 10867 class SimplePie_Content_Type_Sniffer 13465 10868 { 10869 13466 10870 /** 13467 10871 * File object … … 13491 10895 function get_type() 13492 10896 { 13493 if (isset($this->file->headers['content-type'])) 13494 { 10897 if (isset($this->file->headers['content-type'])) { 13495 10898 if (!isset($this->file->headers['content-encoding']) 13496 && ($this->file->headers['content-type'] === 'text/plain'10899 && ($this->file->headers['content-type'] === 'text/plain' 13497 10900 || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1' 13498 || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1')) 13499 { 10901 || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1')) { 13500 10902 return $this->text_or_binary(); 13501 10903 } 13502 10904 13503 if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) 13504 { 10905 if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) { 13505 10906 $official = substr($this->file->headers['content-type'], 0, $pos); 13506 } 13507 else 13508 { 10907 } else { 13509 10908 $official = $this->file->headers['content-type']; 13510 10909 } … … 13512 10911 13513 10912 if ($official === 'unknown/unknown' 13514 || $official === 'application/unknown') 13515 { 10913 || $official === 'application/unknown') { 13516 10914 return $this->unknown(); 13517 } 13518 elseif (substr($official, -4) === '+xml' 13519 || $official === 'text/xml' 13520 || $official === 'application/xml') 13521 { 10915 } elseif (substr($official, -4) === '+xml' 10916 || $official === 'text/xml' 10917 || $official === 'application/xml') { 13522 10918 return $official; 13523 } 13524 elseif (substr($official, 0, 6) === 'image/') 13525 { 13526 if ($return = $this->image()) 13527 { 10919 } elseif (substr($official, 0, 6) === 'image/') { 10920 if ($return = $this->image()) { 13528 10921 return $return; 13529 } 13530 else 13531 { 10922 } else { 13532 10923 return $official; 13533 10924 } 13534 } 13535 elseif ($official === 'text/html') 13536 { 10925 } elseif ($official === 'text/html') { 13537 10926 return $this->feed_or_html(); 13538 } 13539 else 13540 { 10927 } else { 13541 10928 return $official; 13542 10929 } 13543 } 13544 else 13545 { 10930 } else { 13546 10931 return $this->unknown(); 13547 10932 } … … 13557 10942 { 13558 10943 if (substr($this->file->body, 0, 2) === "\xFE\xFF" 13559 || substr($this->file->body, 0, 2) === "\xFF\xFE" 13560 || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF" 13561 || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") 13562 { 10944 || substr($this->file->body, 0, 2) === "\xFF\xFE" 10945 || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF" 10946 || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") { 13563 10947 return 'text/plain'; 13564 } 13565 elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) 13566 { 10948 } elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) { 13567 10949 return 'application/octect-stream'; 13568 } 13569 else 13570 { 10950 } else { 13571 10951 return 'text/plain'; 13572 10952 } … … 13583 10963 $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20"); 13584 10964 if (strtolower(substr($this->file->body, $ws, 14)) === '<!doctype html' 13585 || strtolower(substr($this->file->body, $ws, 5)) === '<html' 13586 || strtolower(substr($this->file->body, $ws, 7)) === '<script') 13587 { 10965 || strtolower(substr($this->file->body, $ws, 5)) === '<html' 10966 || strtolower(substr($this->file->body, $ws, 7)) === '<script') { 13588 10967 return 'text/html'; 13589 } 13590 elseif (substr($this->file->body, 0, 5) === '%PDF-') 13591 { 10968 } elseif (substr($this->file->body, 0, 5) === '%PDF-') { 13592 10969 return 'application/pdf'; 13593 } 13594 elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') 13595 { 10970 } elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') { 13596 10971 return 'application/postscript'; 13597 } 13598 elseif (substr($this->file->body, 0, 6) === 'GIF87a' 13599 || substr($this->file->body, 0, 6) === 'GIF89a') 13600 { 10972 } elseif (substr($this->file->body, 0, 6) === 'GIF87a' 10973 || substr($this->file->body, 0, 6) === 'GIF89a') { 13601 10974 return 'image/gif'; 13602 } 13603 elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") 13604 { 10975 } elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") { 13605 10976 return 'image/png'; 13606 } 13607 elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") 13608 { 10977 } elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") { 13609 10978 return 'image/jpeg'; 13610 } 13611 elseif (substr($this->file->body, 0, 2) === "\x42\x4D") 13612 { 10979 } elseif (substr($this->file->body, 0, 2) === "\x42\x4D") { 13613 10980 return 'image/bmp'; 13614 } 13615 else 13616 { 10981 } else { 13617 10982 return $this->text_or_binary(); 13618 10983 } … … 13628 10993 { 13629 10994 if (substr($this->file->body, 0, 6) === 'GIF87a' 13630 || substr($this->file->body, 0, 6) === 'GIF89a') 13631 { 10995 || substr($this->file->body, 0, 6) === 'GIF89a') { 13632 10996 return 'image/gif'; 13633 } 13634 elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") 13635 { 10997 } elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") { 13636 10998 return 'image/png'; 13637 } 13638 elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") 13639 { 10999 } elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") { 13640 11000 return 'image/jpeg'; 13641 } 13642 elseif (substr($this->file->body, 0, 2) === "\x42\x4D") 13643 { 11001 } elseif (substr($this->file->body, 0, 2) === "\x42\x4D") { 13644 11002 return 'image/bmp'; 13645 } 13646 else 13647 { 11003 } else { 13648 11004 return false; 13649 11005 } … … 13661 11017 $pos = strspn($this->file->body, "\x09\x0A\x0D\x20"); 13662 11018 13663 while ($pos < $len) 13664 { 13665 switch ($this->file->body[$pos]) 13666 { 11019 while ($pos < $len) { 11020 switch ($this->file->body[$pos]) { 13667 11021 case "\x09": 13668 11022 case "\x0A": … … 13680 11034 } 13681 11035 13682 if (substr($this->file->body, $pos, 3) === '!--') 13683 { 11036 if (substr($this->file->body, $pos, 3) === '!--') { 13684 11037 $pos += 3; 13685 if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) 13686 { 11038 if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) { 13687 11039 $pos += 3; 13688 } 13689 else 13690 { 11040 } else { 13691 11041 return 'text/html'; 13692 11042 } 13693 } 13694 elseif (substr($this->file->body, $pos, 1) === '!') 13695 { 13696 if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) 13697 { 11043 } elseif (substr($this->file->body, $pos, 1) === '!') { 11044 if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) { 13698 11045 $pos++; 13699 } 13700 else 13701 { 11046 } else { 13702 11047 return 'text/html'; 13703 11048 } 13704 } 13705 elseif (substr($this->file->body, $pos, 1) === '?') 13706 { 13707 if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) 13708 { 11049 } elseif (substr($this->file->body, $pos, 1) === '?') { 11050 if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) { 13709 11051 $pos += 2; 13710 } 13711 else 13712 { 11052 } else { 13713 11053 return 'text/html'; 13714 11054 } 13715 } 13716 elseif (substr($this->file->body, $pos, 3) === 'rss' 13717 || substr($this->file->body, $pos, 7) === 'rdf:RDF') 13718 { 11055 } elseif (substr($this->file->body, $pos, 3) === 'rss' 11056 || substr($this->file->body, $pos, 7) === 'rdf:RDF') { 13719 11057 return 'application/rss+xml'; 13720 } 13721 elseif (substr($this->file->body, $pos, 4) === 'feed') 13722 { 11058 } elseif (substr($this->file->body, $pos, 4) === 'feed') { 13723 11059 return 'application/atom+xml'; 13724 } 13725 else 13726 { 11060 } else { 13727 11061 return 'text/html'; 13728 11062 } … … 13731 11065 return 'text/html'; 13732 11066 } 11067 13733 11068 } 13734 11069 … … 13740 11075 class SimplePie_XML_Declaration_Parser 13741 11076 { 11077 13742 11078 /** 13743 11079 * XML Version … … 13747 11083 */ 13748 11084 var $version = '1.0'; 13749 13750 11085 /** 13751 11086 * Encoding … … 13755 11090 */ 13756 11091 var $encoding = 'UTF-8'; 13757 13758 11092 /** 13759 11093 * Standalone … … 13763 11097 */ 13764 11098 var $standalone = false; 13765 13766 11099 /** 13767 11100 * Current state of the state machine … … 13771 11104 */ 13772 11105 var $state = 'before_version_name'; 13773 13774 11106 /** 13775 11107 * Input data … … 13779 11111 */ 13780 11112 var $data = ''; 13781 13782 11113 /** 13783 11114 * Input data length (to avoid calling strlen() everytime this is needed) … … 13787 11118 */ 13788 11119 var $data_length = 0; 13789 13790 11120 /** 13791 11121 * Current position of the pointer … … 13816 11146 function parse() 13817 11147 { 13818 while ($this->state && $this->state !== 'emit' && $this->has_data()) 13819 { 11148 while ($this->state && $this->state !== 'emit' && $this->has_data()) { 13820 11149 $state = $this->state; 13821 11150 $this->$state(); 13822 11151 } 13823 11152 $this->data = ''; 13824 if ($this->state === 'emit') 13825 { 11153 if ($this->state === 'emit') { 13826 11154 return true; 13827 } 13828 else 13829 { 11155 } else { 13830 11156 $this->version = ''; 13831 11157 $this->encoding = ''; … … 13864 11190 { 13865 11191 $quote = substr($this->data, $this->position, 1); 13866 if ($quote === '"' || $quote === "'") 13867 { 11192 if ($quote === '"' || $quote === "'") { 13868 11193 $this->position++; 13869 11194 $len = strcspn($this->data, $quote, $this->position); 13870 if ($this->has_data()) 13871 { 11195 if ($this->has_data()) { 13872 11196 $value = substr($this->data, $this->position, $len); 13873 11197 $this->position += $len + 1; … … 13880 11204 function before_version_name() 13881 11205 { 13882 if ($this->skip_whitespace()) 13883 { 11206 if ($this->skip_whitespace()) { 13884 11207 $this->state = 'version_name'; 13885 } 13886 else 13887 { 11208 } else { 13888 11209 $this->state = false; 13889 11210 } … … 13892 11213 function version_name() 13893 11214 { 13894 if (substr($this->data, $this->position, 7) === 'version') 13895 { 11215 if (substr($this->data, $this->position, 7) === 'version') { 13896 11216 $this->position += 7; 13897 11217 $this->skip_whitespace(); 13898 11218 $this->state = 'version_equals'; 13899 } 13900 else 13901 { 11219 } else { 13902 11220 $this->state = false; 13903 11221 } … … 13906 11224 function version_equals() 13907 11225 { 13908 if (substr($this->data, $this->position, 1) === '=') 13909 { 11226 if (substr($this->data, $this->position, 1) === '=') { 13910 11227 $this->position++; 13911 11228 $this->skip_whitespace(); 13912 11229 $this->state = 'version_value'; 13913 } 13914 else 13915 { 11230 } else { 13916 11231 $this->state = false; 13917 11232 } … … 13920 11235 function version_value() 13921 11236 { 13922 if ($this->version = $this->get_value()) 13923 { 11237 if ($this->version = $this->get_value()) { 13924 11238 $this->skip_whitespace(); 13925 if ($this->has_data()) 13926 { 11239 if ($this->has_data()) { 13927 11240 $this->state = 'encoding_name'; 13928 } 13929 else 13930 { 11241 } else { 13931 11242 $this->state = 'emit'; 13932 11243 } 13933 } 13934 else 13935 { 11244 } else { 13936 11245 $this->state = 'standalone_name'; 13937 11246 } … … 13940 11249 function encoding_name() 13941 11250 { 13942 if (substr($this->data, $this->position, 8) === 'encoding') 13943 { 11251 if (substr($this->data, $this->position, 8) === 'encoding') { 13944 11252 $this->position += 8; 13945 11253 $this->skip_whitespace(); 13946 11254 $this->state = 'encoding_equals'; 13947 } 13948 else 13949 { 11255 } else { 13950 11256 $this->state = false; 13951 11257 } … … 13954 11260 function encoding_equals() 13955 11261 { 13956 if (substr($this->data, $this->position, 1) === '=') 13957 { 11262 if (substr($this->data, $this->position, 1) === '=') { 13958 11263 $this->position++; 13959 11264 $this->skip_whitespace(); 13960 11265 $this->state = 'encoding_value'; 13961 } 13962 else 13963 { 11266 } else { 13964 11267 $this->state = false; 13965 11268 } … … 13968 11271 function encoding_value() 13969 11272 { 13970 if ($this->encoding = $this->get_value()) 13971 { 11273 if ($this->encoding = $this->get_value()) { 13972 11274 $this->skip_whitespace(); 13973 if ($this->has_data()) 13974 { 11275 if ($this->has_data()) { 13975 11276 $this->state = 'standalone_name'; 13976 } 13977 else 13978 { 11277 } else { 13979 11278 $this->state = 'emit'; 13980 11279 } 13981 } 13982 else 13983 { 11280 } else { 13984 11281 $this->state = false; 13985 11282 } … … 13988 11285 function standalone_name() 13989 11286 { 13990 if (substr($this->data, $this->position, 10) === 'standalone') 13991 { 11287 if (substr($this->data, $this->position, 10) === 'standalone') { 13992 11288 $this->position += 10; 13993 11289 $this->skip_whitespace(); 13994 11290 $this->state = 'standalone_equals'; 13995 } 13996 else 13997 { 11291 } else { 13998 11292 $this->state = false; 13999 11293 } … … 14002 11296 function standalone_equals() 14003 11297 { 14004 if (substr($this->data, $this->position, 1) === '=') 14005 { 11298 if (substr($this->data, $this->position, 1) === '=') { 14006 11299 $this->position++; 14007 11300 $this->skip_whitespace(); 14008 11301 $this->state = 'standalone_value'; 14009 } 14010 else 14011 { 11302 } else { 14012 11303 $this->state = false; 14013 11304 } … … 14016 11307 function standalone_value() 14017 11308 { 14018 if ($standalone = $this->get_value()) 14019 { 14020 switch ($standalone) 14021 { 11309 if ($standalone = $this->get_value()) { 11310 switch ($standalone) { 14022 11311 case 'yes': 14023 11312 $this->standalone = true; … … 14034 11323 14035 11324 $this->skip_whitespace(); 14036 if ($this->has_data()) 14037 { 11325 if ($this->has_data()) { 14038 11326 $this->state = false; 14039 } 14040 else 14041 { 11327 } else { 14042 11328 $this->state = 'emit'; 14043 11329 } 14044 } 14045 else 14046 { 11330 } else { 14047 11331 $this->state = false; 14048 11332 } 14049 11333 } 11334 14050 11335 } 14051 11336 14052 11337 class SimplePie_Locator 14053 11338 { 11339 14054 11340 var $useragent; 14055 11341 var $timeout; … … 14068 11354 function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10, $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer') 14069 11355 { 14070 $this->file = & $file;11356 $this->file = & $file; 14071 11357 $this->file_class = $file_class; 14072 11358 $this->useragent = $useragent; … … 14078 11364 function find($type = SIMPLEPIE_LOCATOR_ALL, &$working) 14079 11365 { 14080 if ($this->is_feed($this->file)) 14081 { 11366 if ($this->is_feed($this->file)) { 14082 11367 return $this->file; 14083 11368 } 14084 11369 14085 if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) 14086 { 11370 if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) { 14087 11371 $sniffer = new $this->content_type_sniffer_class($this->file); 14088 if ($sniffer->get_type() !== 'text/html') 14089 { 11372 if ($sniffer->get_type() !== 'text/html') { 14090 11373 return null; 14091 11374 } 14092 11375 } 14093 11376 14094 if ($type & ~SIMPLEPIE_LOCATOR_NONE) 14095 { 11377 if ($type & ~SIMPLEPIE_LOCATOR_NONE) { 14096 11378 $this->get_base(); 14097 11379 } 14098 11380 14099 if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) 14100 { 11381 if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) { 14101 11382 return $working[0]; 14102 11383 } 14103 11384 14104 if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) 14105 { 14106 if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) 14107 { 11385 if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) { 11386 if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) { 14108 11387 return $working; 14109 11388 } 14110 11389 14111 if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) 14112 { 11390 if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) { 14113 11391 return $working; 14114 11392 } 14115 11393 14116 if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) 14117 { 11394 if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) { 14118 11395 return $working; 14119 11396 } 14120 11397 14121 if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) 14122 { 11398 if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) { 14123 11399 return $working; 14124 11400 } … … 14129 11405 function is_feed(&$file) 14130 11406 { 14131 if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) 14132 { 11407 if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) { 14133 11408 $sniffer = new $this->content_type_sniffer_class($file); 14134 11409 $sniffed = $sniffer->get_type(); 14135 if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) 14136 { 11410 if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) { 14137 11411 return true; 14138 } 14139 else 14140 { 11412 } else { 14141 11413 return false; 14142 11414 } 14143 } 14144 elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) 14145 { 11415 } elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) { 14146 11416 return true; 14147 } 14148 else 14149 { 11417 } else { 14150 11418 return false; 14151 11419 } … … 14157 11425 $this->base = $this->http_base; 14158 11426 $elements = SimplePie_Misc::get_element('base', $this->file->body); 14159 foreach ($elements as $element) 14160 { 14161 if ($element['attribs']['href']['data'] !== '') 14162 { 11427 foreach ($elements as $element) { 11428 if ($element['attribs']['href']['data'] !== '') { 14163 11429 $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data']), $this->http_base); 14164 11430 $this->base_location = $element['offset']; … … 14173 11439 $done = array(); 14174 11440 $feeds = array(); 14175 foreach ($links as $link) 14176 { 14177 if ($this->checked_feeds === $this->max_checked_feeds) 14178 { 11441 foreach ($links as $link) { 11442 if ($this->checked_feeds === $this->max_checked_feeds) { 14179 11443 break; 14180 11444 } 14181 if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data'])) 14182 { 11445 if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data'])) { 14183 11446 $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data']))); 14184 11447 14185 if ($this->base_location < $link['offset']) 14186 { 11448 if ($this->base_location < $link['offset']) { 14187 11449 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base); 14188 } 14189 else 14190 { 11450 } else { 14191 11451 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base); 14192 11452 } 14193 11453 14194 if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) 14195 { 11454 if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) { 14196 11455 $this->checked_feeds++; 14197 11456 $feed = new $this->file_class($href, $this->timeout, 5, null, $this->useragent); 14198 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) 14199 { 11457 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { 14200 11458 $feeds[$href] = $feed; 14201 11459 } … … 14205 11463 } 14206 11464 14207 if (!empty($feeds)) 14208 { 11465 if (!empty($feeds)) { 14209 11466 return array_values($feeds); 14210 } 14211 else { 11467 } else { 14212 11468 return null; 14213 11469 } … … 14217 11473 { 14218 11474 $links = SimplePie_Misc::get_element('a', $this->file->body); 14219 foreach ($links as $link) 14220 { 14221 if (isset($link['attribs']['href']['data'])) 14222 { 11475 foreach ($links as $link) { 11476 if (isset($link['attribs']['href']['data'])) { 14223 11477 $href = trim($link['attribs']['href']['data']); 14224 11478 $parsed = SimplePie_Misc::parse_url($href); 14225 if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme'])) 14226 { 14227 if ($this->base_location < $link['offset']) 14228 { 11479 if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme'])) { 11480 if ($this->base_location < $link['offset']) { 14229 11481 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base); 14230 } 14231 else 14232 { 11482 } else { 14233 11483 $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base); 14234 11484 } … … 14236 11486 $current = SimplePie_Misc::parse_url($this->file->url); 14237 11487 14238 if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) 14239 { 11488 if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) { 14240 11489 $this->local[] = $href; 14241 } 14242 else 14243 { 11490 } else { 14244 11491 $this->elsewhere[] = $href; 14245 11492 } … … 14249 11496 $this->local = array_unique($this->local); 14250 11497 $this->elsewhere = array_unique($this->elsewhere); 14251 if (!empty($this->local) || !empty($this->elsewhere)) 14252 { 11498 if (!empty($this->local) || !empty($this->elsewhere)) { 14253 11499 return true; 14254 11500 } … … 14258 11504 function extension(&$array) 14259 11505 { 14260 foreach ($array as $key => $value) 14261 { 14262 if ($this->checked_feeds === $this->max_checked_feeds) 14263 { 11506 foreach ($array as $key => $value) { 11507 if ($this->checked_feeds === $this->max_checked_feeds) { 14264 11508 break; 14265 11509 } 14266 if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) 14267 { 11510 if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) { 14268 11511 $this->checked_feeds++; 14269 11512 $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); 14270 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) 14271 { 11513 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { 14272 11514 return $feed; 14273 } 14274 else 14275 { 11515 } else { 14276 11516 unset($array[$key]); 14277 11517 } … … 14283 11523 function body(&$array) 14284 11524 { 14285 foreach ($array as $key => $value) 14286 { 14287 if ($this->checked_feeds === $this->max_checked_feeds) 14288 { 11525 foreach ($array as $key => $value) { 11526 if ($this->checked_feeds === $this->max_checked_feeds) { 14289 11527 break; 14290 11528 } 14291 if (preg_match('/(rss|rdf|atom|xml)/i', $value)) 14292 { 11529 if (preg_match('/(rss|rdf|atom|xml)/i', $value)) { 14293 11530 $this->checked_feeds++; 14294 11531 $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); 14295 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) 14296 { 11532 if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { 14297 11533 return $feed; 14298 } 14299 else 14300 { 11534 } else { 14301 11535 unset($array[$key]); 14302 11536 } … … 14305 11539 return null; 14306 11540 } 11541 14307 11542 } 14308 11543 14309 11544 class SimplePie_Parser 14310 11545 { 11546 14311 11547 var $error_code; 14312 11548 var $error_string; … … 14328 11564 { 14329 11565 // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character 14330 if (strtoupper($encoding) === 'US-ASCII') 14331 { 11566 if (strtoupper($encoding) === 'US-ASCII') { 14332 11567 $this->encoding = 'UTF-8'; 14333 } 14334 else 14335 { 11568 } else { 14336 11569 $this->encoding = $encoding; 14337 11570 } … … 14339 11572 // Strip BOM: 14340 11573 // UTF-32 Big Endian BOM 14341 if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") 14342 { 11574 if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") { 14343 11575 $data = substr($data, 4); 14344 11576 } 14345 11577 // UTF-32 Little Endian BOM 14346 elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") 14347 { 11578 elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") { 14348 11579 $data = substr($data, 4); 14349 11580 } 14350 11581 // UTF-16 Big Endian BOM 14351 elseif (substr($data, 0, 2) === "\xFE\xFF") 14352 { 11582 elseif (substr($data, 0, 2) === "\xFE\xFF") { 14353 11583 $data = substr($data, 2); 14354 11584 } 14355 11585 // UTF-16 Little Endian BOM 14356 elseif (substr($data, 0, 2) === "\xFF\xFE") 14357 { 11586 elseif (substr($data, 0, 2) === "\xFF\xFE") { 14358 11587 $data = substr($data, 2); 14359 11588 } 14360 11589 // UTF-8 BOM 14361 elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") 14362 { 11590 elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") { 14363 11591 $data = substr($data, 3); 14364 11592 } 14365 11593 14366 if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false) 14367 { 11594 if (substr($data, 0, 5) === '<?xml' && strspn(substr($data, 5, 1), "\x09\x0A\x0D\x20") && ($pos = strpos($data, '?>')) !== false) { 14368 11595 $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); 14369 if ($declaration->parse()) 14370 { 11596 if ($declaration->parse()) { 14371 11597 $data = substr($data, $pos + 2); 14372 $data = '<?xml version="' . $declaration->version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data; 14373 } 14374 else 14375 { 11598 $data = '<?xml version="'.$declaration->version.'" encoding="'.$encoding.'" standalone="'.(($declaration->standalone) ? 'yes' : 'no').'"?>'.$data; 11599 } else { 14376 11600 $this->error_string = 'SimplePie bug! Please report this!'; 14377 11601 return false; … … 14382 11606 14383 11607 static $xml_is_sane = null; 14384 if ($xml_is_sane === null) 14385 { 11608 if ($xml_is_sane === null) { 14386 11609 $parser_check = xml_parser_create(); 14387 11610 xml_parse_into_struct($parser_check, '<foo>&</foo>', $values); … … 14391 11614 14392 11615 // Create the parser 14393 if ($xml_is_sane) 14394 { 11616 if ($xml_is_sane) { 14395 11617 $xml = xml_parser_create_ns($this->encoding, $this->separator); 14396 11618 xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); … … 14401 11623 14402 11624 // Parse! 14403 if (!xml_parse($xml, $data, true)) 14404 { 11625 if (!xml_parse($xml, $data, true)) { 14405 11626 $this->error_code = xml_get_error_code($xml); 14406 11627 $this->error_string = xml_error_string($this->error_code); … … 14412 11633 xml_parser_free($xml); 14413 11634 return $return; 14414 } 14415 else 14416 { 11635 } else { 14417 11636 libxml_clear_errors(); 14418 11637 $xml = new XMLReader(); 14419 11638 $xml->xml($data); 14420 while (@$xml->read()) 14421 { 14422 switch ($xml->nodeType) 14423 { 11639 while (@$xml->read()) { 11640 switch ($xml->nodeType) { 14424 11641 14425 11642 case constant('XMLReader::END_ELEMENT'): 14426 if ($xml->namespaceURI !== '') 14427 { 11643 if ($xml->namespaceURI !== '') { 14428 11644 $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; 14429 } 14430 else 14431 { 11645 } else { 14432 11646 $tagName = $xml->localName; 14433 11647 } … … 14436 11650 case constant('XMLReader::ELEMENT'): 14437 11651 $empty = $xml->isEmptyElement; 14438 if ($xml->namespaceURI !== '') 14439 { 11652 if ($xml->namespaceURI !== '') { 14440 11653 $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; 14441 } 14442 else 14443 { 11654 } else { 14444 11655 $tagName = $xml->localName; 14445 11656 } 14446 11657 $attributes = array(); 14447 while ($xml->moveToNextAttribute()) 14448 { 14449 if ($xml->namespaceURI !== '') 14450 { 11658 while ($xml->moveToNextAttribute()) { 11659 if ($xml->namespaceURI !== '') { 14451 11660 $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; 14452 } 14453 else 14454 { 11661 } else { 14455 11662 $attrName = $xml->localName; 14456 11663 } … … 14458 11665 } 14459 11666 $this->tag_open(null, $tagName, $attributes); 14460 if ($empty) 14461 { 11667 if ($empty) { 14462 11668 $this->tag_close(null, $tagName); 14463 11669 } … … 14470 11676 } 14471 11677 } 14472 if ($error = libxml_get_last_error()) 14473 { 11678 if ($error = libxml_get_last_error()) { 14474 11679 $this->error_code = $error->code; 14475 11680 $this->error_string = $error->message; … … 14477 11682 $this->current_column = $error->column; 14478 11683 return false; 14479 } 14480 else 14481 { 11684 } else { 14482 11685 return true; 14483 11686 } … … 14520 11723 14521 11724 $attribs = array(); 14522 foreach ($attributes as $name => $value) 14523 { 11725 foreach ($attributes as $name => $value) { 14524 11726 list($attrib_namespace, $attribute) = $this->split_ns($name); 14525 11727 $attribs[$attrib_namespace][$attribute] = $value; 14526 11728 } 14527 11729 14528 if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base'])) 14529 { 11730 if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base'])) { 14530 11731 $this->xml_base[] = SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base)); 14531 11732 $this->xml_base_explicit[] = true; 14532 } 14533 else 14534 { 11733 } else { 14535 11734 $this->xml_base[] = end($this->xml_base); 14536 11735 $this->xml_base_explicit[] = end($this->xml_base_explicit); 14537 11736 } 14538 11737 14539 if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) 14540 { 11738 if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) { 14541 11739 $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang']; 14542 } 14543 else 14544 { 11740 } else { 14545 11741 $this->xml_lang[] = end($this->xml_lang); 14546 11742 } 14547 11743 14548 if ($this->current_xhtml_construct >= 0) 14549 { 11744 if ($this->current_xhtml_construct >= 0) { 14550 11745 $this->current_xhtml_construct++; 14551 if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML) 14552 { 14553 $this->data['data'] .= '<' . end($this->element); 14554 if (isset($attribs[''])) 14555 { 14556 foreach ($attribs[''] as $name => $value) 14557 { 14558 $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"'; 11746 if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML) { 11747 $this->data['data'] .= '<'.end($this->element); 11748 if (isset($attribs[''])) { 11749 foreach ($attribs[''] as $name => $value) { 11750 $this->data['data'] .= ' '.$name.'="'.htmlspecialchars($value, ENT_COMPAT, $this->encoding).'"'; 14559 11751 } 14560 11752 } 14561 11753 $this->data['data'] .= '>'; 14562 11754 } 14563 } 14564 else 14565 { 14566 $this->datas[] =& $this->data; 14567 $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; 11755 } else { 11756 $this->datas[] = & $this->data; 11757 $this->data = & $this->data['child'][end($this->namespace)][end($this->element)][]; 14568 11758 $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); 14569 11759 if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') 14570 || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')) 14571 { 11760 || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')) { 14572 11761 $this->current_xhtml_construct = 0; 14573 11762 } … … 14577 11766 function cdata($parser, $cdata) 14578 11767 { 14579 if ($this->current_xhtml_construct >= 0) 14580 { 11768 if ($this->current_xhtml_construct >= 0) { 14581 11769 $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding); 14582 } 14583 else 14584 { 11770 } else { 14585 11771 $this->data['data'] .= $cdata; 14586 11772 } … … 14589 11775 function tag_close($parser, $tag) 14590 11776 { 14591 if ($this->current_xhtml_construct >= 0) 14592 { 11777 if ($this->current_xhtml_construct >= 0) { 14593 11778 $this->current_xhtml_construct--; 14594 if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) 14595 { 14596 $this->data['data'] .= '</' . end($this->element) . '>'; 14597 } 14598 } 14599 if ($this->current_xhtml_construct === -1) 14600 { 14601 $this->data =& $this->datas[count($this->datas) - 1]; 11779 if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) { 11780 $this->data['data'] .= '</'.end($this->element).'>'; 11781 } 11782 } 11783 if ($this->current_xhtml_construct === -1) { 11784 $this->data = & $this->datas[count($this->datas) - 1]; 14602 11785 array_pop($this->datas); 14603 11786 } … … 14613 11796 { 14614 11797 static $cache = array(); 14615 if (!isset($cache[$string])) 14616 { 14617 if ($pos = strpos($string, $this->separator)) 14618 { 11798 if (!isset($cache[$string])) { 11799 if ($pos = strpos($string, $this->separator)) { 14619 11800 static $separator_length; 14620 if (!$separator_length) 14621 { 11801 if (!$separator_length) { 14622 11802 $separator_length = strlen($this->separator); 14623 11803 } 14624 11804 $namespace = substr($string, 0, $pos); 14625 11805 $local_name = substr($string, $pos + $separator_length); 14626 if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES) 14627 { 11806 if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES) { 14628 11807 $namespace = SIMPLEPIE_NAMESPACE_ITUNES; 14629 11808 } 14630 11809 14631 11810 // Normalize the Media RSS namespaces 14632 if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG) 14633 { 11811 if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG) { 14634 11812 $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS; 14635 11813 } 14636 11814 $cache[$string] = array($namespace, $local_name); 14637 } 14638 else 14639 { 11815 } else { 14640 11816 $cache[$string] = array('', $string); 14641 11817 } … … 14643 11819 return $cache[$string]; 14644 11820 } 11821 14645 11822 } 14646 11823 … … 14650 11827 class SimplePie_Sanitize 14651 11828 { 11829 14652 11830 // Private vars 14653 11831 var $base; 14654 14655 11832 // Options 14656 11833 var $remove_div = true; … … 14669 11846 var $useragent = ''; 14670 11847 var $force_fsockopen = false; 14671 14672 11848 var $replace_url_attributes = array( 14673 11849 'a' => 'href', … … 14689 11865 function set_image_handler($page = false) 14690 11866 { 14691 if ($page) 14692 { 11867 if ($page) { 14693 11868 $this->image_handler = (string) $page; 14694 } 14695 else 14696 { 11869 } else { 14697 11870 $this->image_handler = false; 14698 11871 } … … 14701 11874 function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache') 14702 11875 { 14703 if (isset($enable_cache)) 14704 { 11876 if (isset($enable_cache)) { 14705 11877 $this->enable_cache = (bool) $enable_cache; 14706 11878 } 14707 11879 14708 if ($cache_location) 14709 { 11880 if ($cache_location) { 14710 11881 $this->cache_location = (string) $cache_location; 14711 11882 } 14712 11883 14713 if ($cache_name_function) 14714 { 11884 if ($cache_name_function) { 14715 11885 $this->cache_name_function = (string) $cache_name_function; 14716 11886 } 14717 11887 14718 if ($cache_class) 14719 { 11888 if ($cache_class) { 14720 11889 $this->cache_class = (string) $cache_class; 14721 11890 } … … 14724 11893 function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false) 14725 11894 { 14726 if ($file_class) 14727 { 11895 if ($file_class) { 14728 11896 $this->file_class = (string) $file_class; 14729 11897 } 14730 11898 14731 if ($timeout) 14732 { 11899 if ($timeout) { 14733 11900 $this->timeout = (string) $timeout; 14734 11901 } 14735 11902 14736 if ($useragent) 14737 { 11903 if ($useragent) { 14738 11904 $this->useragent = (string) $useragent; 14739 11905 } 14740 11906 14741 if ($force_fsockopen) 14742 { 11907 if ($force_fsockopen) { 14743 11908 $this->force_fsockopen = (string) $force_fsockopen; 14744 11909 } … … 14747 11912 function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')) 14748 11913 { 14749 if ($tags) 14750 { 14751 if (is_array($tags)) 14752 { 11914 if ($tags) { 11915 if (is_array($tags)) { 14753 11916 $this->strip_htmltags = $tags; 14754 } 14755 else 14756 { 11917 } else { 14757 11918 $this->strip_htmltags = explode(',', $tags); 14758 11919 } 14759 } 14760 else 14761 { 11920 } else { 14762 11921 $this->strip_htmltags = false; 14763 11922 } … … 14771 11930 function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) 14772 11931 { 14773 if ($attribs) 14774 { 14775 if (is_array($attribs)) 14776 { 11932 if ($attribs) { 11933 if (is_array($attribs)) { 14777 11934 $this->strip_attributes = $attribs; 14778 } 14779 else 14780 { 11935 } else { 14781 11936 $this->strip_attributes = explode(',', $attribs); 14782 11937 } 14783 } 14784 else 14785 { 11938 } else { 14786 11939 $this->strip_attributes = false; 14787 11940 } … … 14814 11967 { 14815 11968 $data = trim($data); 14816 if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI) 14817 { 14818 if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) 14819 { 14820 if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) 14821 { 11969 if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI) { 11970 if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) { 11971 if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*'.SIMPLEPIE_PCRE_HTML_ATTRIBUTE.'>)/', $data)) { 14822 11972 $type |= SIMPLEPIE_CONSTRUCT_HTML; 14823 } 14824 else 14825 { 11973 } else { 14826 11974 $type |= SIMPLEPIE_CONSTRUCT_TEXT; 14827 11975 } 14828 11976 } 14829 11977 14830 if ($type & SIMPLEPIE_CONSTRUCT_BASE64) 14831 { 11978 if ($type & SIMPLEPIE_CONSTRUCT_BASE64) { 14832 11979 $data = base64_decode($data); 14833 11980 } 14834 11981 14835 if ($type & SIMPLEPIE_CONSTRUCT_XHTML) 14836 { 14837 if ($this->remove_div) 14838 { 14839 $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '', $data); 11982 if ($type & SIMPLEPIE_CONSTRUCT_XHTML) { 11983 if ($this->remove_div) { 11984 $data = preg_replace('/^<div'.SIMPLEPIE_PCRE_XML_ATTRIBUTE.'>/', '', $data); 14840 11985 $data = preg_replace('/<\/div>$/', '', $data); 14841 } 14842 else 14843 { 14844 $data = preg_replace('/^<div' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/', '<div>', $data); 14845 } 14846 } 14847 14848 if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) 14849 { 11986 } else { 11987 $data = preg_replace('/^<div'.SIMPLEPIE_PCRE_XML_ATTRIBUTE.'>/', '<div>', $data); 11988 } 11989 } 11990 11991 if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) { 14850 11992 // Strip comments 14851 if ($this->strip_comments) 14852 { 11993 if ($this->strip_comments) { 14853 11994 $data = SimplePie_Misc::strip_comments($data); 14854 11995 } … … 14857 11998 // Based on recommendations by Mark Pilgrim at: 14858 11999 // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely 14859 if ($this->strip_htmltags) 14860 { 14861 foreach ($this->strip_htmltags as $tag) 14862 { 14863 $pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU'; 14864 while (preg_match($pcre, $data)) 14865 { 12000 if ($this->strip_htmltags) { 12001 foreach ($this->strip_htmltags as $tag) { 12002 $pcre = "/<($tag)".SIMPLEPIE_PCRE_HTML_ATTRIBUTE."(>(.*)<\/$tag".SIMPLEPIE_PCRE_HTML_ATTRIBUTE.'>|(\/)?>)/siU'; 12003 while (preg_match($pcre, $data)) { 14866 12004 $data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data); 14867 12005 } … … 14869 12007 } 14870 12008 14871 if ($this->strip_attributes) 14872 { 14873 foreach ($this->strip_attributes as $attrib) 14874 { 14875 $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data); 12009 if ($this->strip_attributes) { 12010 foreach ($this->strip_attributes as $attrib) { 12011 $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)'.SIMPLEPIE_PCRE_HTML_ATTRIBUTE.trim($attrib).'(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?'.SIMPLEPIE_PCRE_HTML_ATTRIBUTE.'>/', '\1\2\3>', $data); 14876 12012 } 14877 12013 } … … 14879 12015 // Replace relative URLs 14880 12016 $this->base = $base; 14881 foreach ($this->replace_url_attributes as $element => $attributes) 14882 { 12017 foreach ($this->replace_url_attributes as $element => $attributes) { 14883 12018 $data = $this->replace_urls($data, $element, $attributes); 14884 12019 } 14885 12020 14886 12021 // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags. 14887 if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) 14888 { 12022 if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) { 14889 12023 $images = SimplePie_Misc::get_element('img', $data); 14890 foreach ($images as $img) 14891 { 14892 if (isset($img['attribs']['src']['data'])) 14893 { 12024 foreach ($images as $img) { 12025 if (isset($img['attribs']['src']['data'])) { 14894 12026 $image_url = call_user_func($this->cache_name_function, $img['attribs']['src']['data']); 14895 12027 $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $image_url, 'spi'); 14896 12028 14897 if ($cache->load()) 14898 { 14899 $img['attribs']['src']['data'] = $this->image_handler . $image_url; 12029 if ($cache->load()) { 12030 $img['attribs']['src']['data'] = $this->image_handler.$image_url; 14900 12031 $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); 14901 } 14902 else 14903 { 12032 } else { 14904 12033 $file = new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); 14905 12034 $headers = $file->headers; 14906 12035 14907 if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) 14908 { 14909 if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) 14910 { 14911 $img['attribs']['src']['data'] = $this->image_handler . $image_url; 12036 if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) { 12037 if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) { 12038 $img['attribs']['src']['data'] = $this->image_handler.$image_url; 14912 12039 $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); 14913 } 14914 else 14915 { 12040 } else { 14916 12041 trigger_error("$this->cache_location is not writeable", E_USER_WARNING); 14917 12042 } … … 14926 12051 } 14927 12052 14928 if ($type & SIMPLEPIE_CONSTRUCT_IRI) 14929 { 12053 if ($type & SIMPLEPIE_CONSTRUCT_IRI) { 14930 12054 $data = SimplePie_Misc::absolutize_url($data, $base); 14931 12055 } 14932 12056 14933 if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI)) 14934 { 12057 if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI)) { 14935 12058 $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); 14936 12059 } 14937 12060 14938 if ($this->output_encoding !== 'UTF-8') 14939 { 12061 if ($this->output_encoding !== 'UTF-8') { 14940 12062 $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding); 14941 12063 } … … 14946 12068 function replace_urls($data, $tag, $attributes) 14947 12069 { 14948 if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) 14949 { 12070 if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) { 14950 12071 $elements = SimplePie_Misc::get_element($tag, $data); 14951 foreach ($elements as $element) 14952 { 14953 if (is_array($attributes)) 14954 { 14955 foreach ($attributes as $attribute) 14956 { 14957 if (isset($element['attribs'][$attribute]['data'])) 14958 { 12072 foreach ($elements as $element) { 12073 if (is_array($attributes)) { 12074 foreach ($attributes as $attribute) { 12075 if (isset($element['attribs'][$attribute]['data'])) { 14959 12076 $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base); 14960 12077 $new_element = SimplePie_Misc::element_implode($element); … … 14963 12080 } 14964 12081 } 14965 } 14966 elseif (isset($element['attribs'][$attributes]['data'])) 14967 { 12082 } elseif (isset($element['attribs'][$attributes]['data'])) { 14968 12083 $element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base); 14969 12084 $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data); … … 14976 12091 function do_strip_htmltags($match) 14977 12092 { 14978 if ($this->encode_instead_of_strip) 14979 { 14980 if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) 14981 { 12093 if ($this->encode_instead_of_strip) { 12094 if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) { 14982 12095 $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8'); 14983 12096 $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8'); 14984 12097 return "<$match[1]$match[2]>$match[3]</$match[1]>"; 14985 } 14986 else 14987 { 12098 } else { 14988 12099 return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8'); 14989 12100 } 14990 } 14991 elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) 14992 { 12101 } elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) { 14993 12102 return $match[4]; 14994 } 14995 else 14996 { 12103 } else { 14997 12104 return ''; 14998 12105 } 14999 12106 } 12107 15000 12108 } 15001 15002 ?>