Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2005, 03:22 PM
msimonds msimonds is offline
 
Join Date: Aug 2003
Location: Dallas, Texas
Posts: 157
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default preg_match_all problem for mod_rewrite

PHP Code:
<?php
// mod_rewrite, Jeroen's way
// file: cleanurl.inc.php
// date: May 11, 2005
 
$uri $_SERVER['REQUEST_URI'];
//preg_match_all('/^\/([\/a-z\\0-9\\-_\\.\/]*)(.*)\\.html/', $uri, $uri_array, PREG_PATTERN_ORDER);
preg_match_all('/^\/([\/a-z\\-_\\.\/]*)(.*)\\.html/'$uri$uri_arrayPREG_PATTERN_ORDER);
 
$page=$uri_array[1][0];
$optional=$uri_array[2][0];
 
// url => forumid mapping
$url_forum=array(
"nfl" => 280,
"nhl" => 282,
"nba" => 283,
"mlb" => 281,
"ncaa" => 284,
"mark_chalifoux" => 356,
"a_smith" => 357,
"sara_normand" => 358,
"chris_shryock" => 359,
"marcus_hartman" => 360,
"w_peery" => 361,
"john_katrus" => 362,
"callie_spear" => 363,
"john_siskos" => 364,
"ishkur" => 365,
"mike_simonds" => 366,
"interviews" => 350,
"jackass" => 181,
"nfl/cleveland-browns" => 225,
"nfl/dallas-cowboys" => 226,
"nfl/denver-broncos" => 227,
"nfl/detroit-lions" => 228,
"nfl/green-bay-packers" => 229,
"nfl/houston-texans" => 230,
"nfl/indianapolis-colts" => 231,
"nfl/jacksonville-jaguars" => 232,
"nfl/kansas-city-chiefs" => 233,
"nfl/miami-dolphins" => 234,
"nfl/minnesota-vikings" => 235,
"nfl/new-england-patriots" => 236,
"nfl/new-orleans-saints" => 237,
"nfl/new-york-giants" => 238,
"nfl/new-york-jets" => 239,
"nfl/oakland-raiders" => 240,
"nfl/philadelphia-eagles" => 241,
"nfl/pittsburgh-steelers" => 242,
"nfl/san-diego-chargers" => 243,
"nfl/san-francisco-49ers" => 244,
"nfl/seattle-seahawks" => 245,
"nfl/st-louis-rams" => 246,
"nfl/tampa-bay-buccaneers" => 247,
"nfl/tennessee-titans" => 248,
"nfl/washington-redskins" => 249,
"nba/atlanta-hawks" => 319,
"nba/boston-celtics" => 320,
"nba/charlotte-bobcats" => 321,
"nba/chicago-bulls" => 322,
"nba/cleveland-cavaliers" => 323,
"nba/dallas-mavericks" => 324,
"nba/denver-nuggets" => 325,
"nba/detroit-pistons" => 326,
"nba/golden-state-warriors" => 327,
"nba/houston-rockets" => 328,
"nba/indiana-pacers" => 329,
"nba/los-angeles-clippers" => 330,
"nba/los-angeles-lakers" => 331,
"nba/memphis-grizzlies" => 332,
"nba/miami-heat" => 333,
"nba/milwaukee-bucks" => 334,
"nba/minnesota-timberwolves" => 335,
"nba/new-jersey-nets" => 336,
"nba/new-orleans-hornets" => 337,
"nba/new-york-knicks" => 338,
"nba/orlando-magic" => 339,
"nba/philadelphia-76ers" => 340,
"nba/phoenix-suns" => 341,
"nba/portland-trail-blazers" => 342,
"nba/sacramento-kings" => 343,
"nba/san-antonio-spurs" => 344,
"nba/seattle-supersonics" => 345,
"nba/toronto-raptors" => 346,
"nba/utah-jazz" => 347,
"nba/washington-wizards" => 348,
"nhl/anaheim-mighty-ducks" => 250,
"nhl/atlanta-thrashers" => 251,
"nhl/boston-bruins" => 252,
"nhl/buffalo-sabres" => 253,
"nhl/calgary-flames" => 254,
"nhl/carolina-hurricanes" => 255,
"nhl/chicago-blackhawks" => 256,
"nhl/colorado-avalanche" => 257,
"nhl/columbus-blue-jackets" => 258,
"nhl/dallas-stars" => 259,
"nhl/detroit-red-wings" => 285,
"nhl/edmonton-oilers" => 260,
"nhl/florida-panthers" => 261,
"nhl/los-angeles-kings" => 262,
"nhl/minnesota-wild" => 264,
"nhl/montreal-canadiens" => 263,
"nhl/nashville-predators" => 265,
"nhl/new-jersey-devils" => 266,
"nhl/new-york-islanders" => 267,
"nhl/new-york-rangers" => 268,
"nhl/ottawa-senators" => 269,
"nhl/philadelphia-flyers" => 270,
"nhl/phoenix-coyotes" => 271,
"nhl/pittsburgh-penguins" => 272,
"nhl/san-jose-sharks" => 273,
"nhl/st.-louis-blues" => 274,
"nhl/toronto-maple-leafs" => 275,
"nhl/tampa-bay-lightning" => 276,
"nhl/vancouver-canucks" => 277,
"nhl/washington-capitals" => 278,
"mlb/anaheim-angels" => 289,
"mlb/arizona-diamondbacks" => 290,
"mlb/atlanta-braves" => 291,
"mlb/baltimore-orioles" => 292,
"mlb/boston-red-sox" => 293,
"mlb/chicago-cubs" => 294,
"mlb/chicago-white-sox" => 295,
"mlb/cincinnati-reds" => 296,
"mlb/cleveland-indians" => 297,
"mlb/colorado-rockies" => 298,
"mlb/detroit-tigers" => 299,
"mlb/florida-marlins" => 300,
"mlb/houston-astros" => 301,
"mlb/kansas-city-royals" => 302,
"mlb/los-angeles-dodgers" => 303,
"mlb/minnesota-twins" => 304,
"mlb/milwaukee-brewers" => 305,
"mlb/montreal-expos" => 306,
"mlb/new-york-mets" => 307,
"mlb/new-york-yankees" => 308,
"mlb/oakland-athletics" => 309,
"mlb/pittsburgh-pirates" => 310,
"mlb/philadelphia-phillies" => 311,
"mlb/san-diego-padres" => 312,
"mlb/san-francisco-giants" => 313,
"mlb/seattle-mariners" => 314,
"mlb/st.-louis-cardinals" => 315,
"mlb/tampa-bay-devil-rays" => 316,
"mlb/texas-rangers" => 317,
"mlb/toronto-blue-jays" => 318,
"mlb/washington-nationals" => 306,
"ncaa/basketball" => 42,
"ncaa/baseball" => 44,
"ncaa/football" => 41
);
 
if (!empty(
$url_forum[$page]))
{
$_REQUEST['f']=$url_forum[$page];
if (!empty(
$optional))
{
$_REQUEST['pagenumber']=$optional;
// set 'page' as well, just to be sure... the old .htaccess rewrote to page, not pagenumber
$_REQUEST['page']=$optional;
}
}
else 
// handle special cases
{
switch (
$page)
{
case 
"index":
     if (!empty(
$optional))
     {
    
$_REQUEST['pagenumber'] = $optional;
    
$_REQUEST['page'] = $optional;
}
break;
case 
"article":
     
$_REQUEST['do'] = 'feature';
     if (!empty(
$optional))
     {
    
$_REQUEST['t'] = $optional;
}
break;
case 
"news":
     
$_REQUEST['do'] = 'default';
     break;
case 
"news-":
$news explode('-',$optional);
$_REQUEST['f'] = $news[0];
$_REQUEST['page'] = $news[1];
$_REQUEST['pagenumber'] = $news[1];
unset(
$news);
break;
 
case 
"makenews":
     
$_REQUEST['do'] = 'make';
     if (!empty(
$optional))
            {
    
$_REQUEST['f'] = $optional;
}
break;
 
case 
"archive":
     
$_REQUEST['do'] = 'archive';
     
$arch explode('-',$optional);
     
$_REQUEST['f'] = $arch[0];
     if (isset(
$arch[1]))
            {
    
$_REQUEST['month'] = $arch[1];
}
     if (isset(
$arch[2]))
            {
    
$_REQUEST['year'] = $arch[2];
}
unset(
$arch);
     break;
 
default:
// redirect to [url]http://www.sportsrant.com[/url]
//Header('HTTP/1.1 301 Moved Permanently');
//Header('Location: http://www.sportsrant.com');
//exit;
 
}
}
 
// print_r($_REQUEST);
// echo "<br />$page / $optional<br />$uri";
 
// clean up motor's internal variables
unset($url_forum);
unset(
$page);
unset(
$optional);
unset(
$uri);
 
?>


this code is for a mod_rewrite function that I have on my site. the only problem is that in the preg_match_all the programmer forgot to add in the ability to have numbers in the url.

Example:

the url for a team page works accoriding to the array: (example)

http://www.sportsrant.com/nfl/san-diego-chargers.html

and the teams with numbers in them do not: (example)

http://www.sportsrant.com/nfl/san-francisco-49ers.html

it redirects back to the home page!

Can someone please help me fix the preg_match_all

TIA,

Mike
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08242 seconds
  • Memory Usage 2,238KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete