1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP control over words

Discussion in 'PHP' started by a4tech, Mar 29, 2013.

  1. #1
    Hello,

    I am wanted to start ads on a website. But website contain adult nude text. Is there any way to block ads to specific words. Like if the page contain word 'porn' do not show ads.

    Looking for reply.
    Thank You.
     
    a4tech, Mar 29, 2013 IP
  2. dombo

    dombo Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    Yes. You can search word "porn" on content. And than if word "porn" true dont show div with ads.
     
    dombo, Mar 29, 2013 IP
  3. HolyRoller

    HolyRoller Well-Known Member

    Messages:
    552
    Likes Received:
    27
    Best Answers:
    1
    Trophy Points:
    150
    #3
    Definitely possibly as mentioned above but would need a bit more information about how the site is setup as to the best way of searching the content. If the site is database driven or dynamically created will have a different solution to static content.
     
    HolyRoller, Mar 29, 2013 IP
  4. dombo

    dombo Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    Example

    <?php
    $text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.";

    if (stripos($text, "dolor") !== false) {
    echo "Something what you want to show instead of ads";
    }
    else{
    echo "ADS";
    }
    ?>
     
    dombo, Mar 29, 2013 IP
  5. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #5
    Just use a word filtering script and leave your ads alone...
     
    Last edited: Mar 29, 2013
    MyVodaFone, Mar 29, 2013 IP
  6. a4tech

    a4tech Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    any suggestion how to control it?
     
    a4tech, Mar 29, 2013 IP
  7. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #7
    Something like this should work, I haven't tested it.
    
     
    <?php
    $flag = '/porn/i';
    $content = '<h1>Page Title</h1>
    <p>This is a paragraph with the word porn inside.</p>';
    if(!preg_match($flag, $content)) {
      // not found show content
      echo $content;
    } else{
    // don't show
    }
    ?>
     
    
    PHP:
     
    Last edited: Mar 29, 2013
    HuggyStudios, Mar 29, 2013 IP
    philzilla likes this.
  8. a4tech

    a4tech Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #8
    I have 3 vars to scan the page but i am unable to find how to do this? Is there any one that can help in this matter.
    $title
    $description
    $tags

    Is there any way to scan the words like aaa, bbb with in $title, $description, and $tags.

    Looking for help.
     
    a4tech, Mar 31, 2013 IP
  9. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #9
    I think everyone already gave you an idea of how to find a specific word to ban so, you need to check three vars... ok! Let's take HuggyStudio's one and let's add just few hacks:

    $flag = '/porn/i';
    $title = "This is the Title"; $description = "Description"; $tags = "Here goes a tag";
    $content = "Here the content";
    if(!preg_match($flag, strip_tags($content." ".$title." ".$description." ".$tags))) {
      echo $ads
    } else{
    // don't show
    }
    PHP:
    Like this it will check content, title, description and tags.
     
    YoGem, Apr 7, 2013 IP