Page 1 of 1

help , truoble for a real php n00b ...

Posted: Sun Dec 15, 2002 5:31 am
by EvilCrackMonkey
i have a big problem , im suposed to enter witch forums a hack should be active in , thats a nice long list ,

and im supposed to enter like this :

Code: Select all

// IP&PATH-Hack - Activate only  on "selected" forums(2)
  if ($forumid==2) {
    eval("\$ippathform = "".gettemplate("newthread_ippathform")."";");
  }
  else {
    $ippathform='';
  }
now mine looks like this :

Code: Select all

// IP&PATH-Hack - Activate only  on "selected" forums(2)
  if ($forumid==if (($thread['forumid']==17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,37,38,39,40,41,42,43,44,45,46,47,53,54,55,57,58)) {
    eval("\$ippathform = "".gettemplate("newthread_ippathform")."";");
  }
  else {
    $ippathform='';
  }
so i want these forum id's to be in ..

but how do i separate them , cause php dont like nether commas or semicolon :(

//tnx in advance =)

Posted: Sun Dec 15, 2002 5:37 am
by qartis
$forum_ids = array(1,2,3,4,5,17,280);

And then use in_array();

Posted: Sun Dec 15, 2002 5:40 am
by EvilCrackMonkey
where should in_array(); be? right after " $forum_ids = array(1,2,3,4,5,17,280);"


???


tnx for the answer qartis =)


edit can u/someone

write how it should be enterd...

like :

Code: Select all

// IP&PATH-Hack - Activate only  on "selected" forums(2)
  if ($forumid==2) {
    eval("\$ippathform = "".gettemplate("newthread_ippathform")."";");
  }
  else {
    $ippathform='';
  }
??

i see now that my text is diff. then the one in the install text , gonna try again...

Posted: Sun Dec 15, 2002 2:10 pm
by qartis
If I understand your code correctly, you'll want something along the lines of

Code: Select all

$id_array = array(17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,37,38,39,40,41,42,43,44,45,46,47,53,54,55,57,58);

if (in_array($thread['forumid'],$id_array)) { 
    $ippathform = '"'.gettemplate("newthread_ippathform").'";'; 
} else { 
    $ippathform=''; 
}

But I don't know if I understand that eval() line; Let's pretend gettemplate() will return the string "hello". Did you want $ippathfrom to equal

"hello";

?

I don't think you want that semicolon in there. If not, replace that line with

$ippathform = '"'.gettemplate("newthread_ippathform").'"';