stripos function + php < 5

Helps with Argent Dawn's "Craftsman's Writ" quests

Moderator: Rihlsul

stripos function + php < 5

Postby ogixe » Tue Jul 25, 2006 2:38 pm

error:

in writList.php, line 241-246, the function stripos only works in php5, I guess there are still many roster users using php4, including me :D.
Last edited by ogixe on Tue Jul 25, 2006 5:08 pm, edited 3 times in total.
//ogixe
User avatar
ogixe
WR.net Apprentice
WR.net Apprentice
 
Posts: 13
Joined: Tue Jul 04, 2006 9:06 pm

stripos function + php < 5

Postby Averen » Tue Jul 25, 2006 5:02 pm

I think this will work but it is untested.

Code: Select all
   if (stripos($search,'Leather') &&
            ((stripos($search,$wordings[$roster_conf['roster_lang']]['ruggedleather']) !== false) ||
              (stripos($search,$wordings[$roster_conf['roster_lang']]['thickleather']) !== false) ||
             (stripos($search,$wordings[$roster_conf['roster_lang']]['heavyleather']) !== false) ||
             (stripos($search,$wordings[$roster_conf['roster_lang']]['mediumleather']) !== false) ||
             (stripos($search,$wordings[$roster_conf['roster_lang']]['lightleather']) !== false))
      ) {
      return;


to

Code: Select all
   if (preg_match('/leather/i', $search) &&
            ((preg_match('/'.$wordings[$roster_conf['roster_lang']]['ruggedleather'].'/i', $search) !== false) ||
              (preg_match('/'.$wordings[$roster_conf['roster_lang']]['thickleather'].'/i', $search) !== false) ||
             (preg_match('/'.$wordings[$roster_conf['roster_lang']]['heavyleather'].'/i', $search) !== false) ||
             (preg_match('/'.$wordings[$roster_conf['roster_lang']]['mediumleather'].'/i', $search) !== false) ||
             (preg_match('/'.$wordings[$roster_conf['roster_lang']]['lightleather'].'/i', $search) !== false))
      ) {
      return;

Last edited by Averen on Tue Jul 25, 2006 5:08 pm, edited 1 time in total.
User avatar
Averen
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 152
Joined: Thu Jul 20, 2006 5:18 am

stripos function + php < 5

Postby Rihlsul » Tue Jul 25, 2006 5:05 pm

Ah, I was just going to drop the I (strpos).

I'm told:
PHP Manual wrote:Tip: Do not use preg_match() if you only want to check if one string is contained in another string. Use strpos() or strstr() instead as they will be faster.


BTW, that little section of code is to prevent the engine from parsing "Rugged Leather" down into "Heavy Leather" in the thousands.

I may change the logic to that entirely in relation to the fish items.
Last edited by Rihlsul on Tue Jul 25, 2006 5:10 pm, edited 1 time in total.
Rihlsul,
Guild Leader of The Dirty Hordes
User avatar
Rihlsul
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 125
Joined: Tue Jul 04, 2006 8:27 pm

Re: Striping Bug

Postby Averen » Tue Jul 25, 2006 5:08 pm

Oh meh :P T'was only a quick fix as I saw the thread, you can improve it.
User avatar
Averen
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 152
Joined: Thu Jul 20, 2006 5:18 am

Re: Striping Bug

Postby Rihlsul » Tue Jul 25, 2006 5:11 pm

Muchly appreciated sir.

I'm new to this whole 'php' thing. :blackeye:
Rihlsul,
Guild Leader of The Dirty Hordes
User avatar
Rihlsul
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 125
Joined: Tue Jul 04, 2006 8:27 pm

stripos function + php < 5

Postby Averen » Tue Jul 25, 2006 5:15 pm

I presume you could use this...

Code: Select all
   if (stristr($search,'Leather') &&
            ((stristr($search,$wordings[$roster_conf['roster_lang']]['ruggedleather']) !== false) ||
                  (stristr($search,$wordings[$roster_conf['roster_lang']]['thickleather']) !== false) ||
             (stristr($search,$wordings[$roster_conf['roster_lang']]['heavyleather']) !== false) ||
             (stristr($search,$wordings[$roster_conf['roster_lang']]['mediumleather']) !== false) ||
             (stristr($search,$wordings[$roster_conf['roster_lang']]['lightleather']) !== false))
      ) {
      return;
User avatar
Averen
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 152
Joined: Thu Jul 20, 2006 5:18 am

Re: stripos function + php < 5

Postby gvaughan » Sun Jul 30, 2006 12:41 am

Not a big php coder or anything. I am sorry if I am posting in the wrong place or the issue has already been addressed. But this is a bug that one of my users gets when trying to use the addon.

Code: Select all
Fatal error: Call to undefined function: stripos() in /home/sites/site71/users/myths/web/roster/addons/writcalc/writList.php on line 241
gvaughan
WR.net Apprentice
WR.net Apprentice
 
Posts: 15
Joined: Mon Jul 10, 2006 8:08 pm

Re: stripos function + php < 5

Postby Rihlsul » Sun Jul 30, 2006 1:45 am

Heya! Right place to post it.

But, FYI, this issue is definitely resolved in V1.1, as the section of code calling that function has been completely reworked.

Just grab the new version from:
http://wowroster.net/Downloads/details/id=36.html

Delete the old files from your server, put the new version in place (no 'upgrade steps' required.

Give it a whirl and you should be all set!
Rihlsul,
Guild Leader of The Dirty Hordes
User avatar
Rihlsul
Roster AddOn Dev
Roster AddOn Dev
 
Posts: 125
Joined: Tue Jul 04, 2006 8:27 pm


Return to Writ Calculator

Who is online

Users browsing this forum: No registered users and 0 guests

cron