Jump to content

I need some help with logins and sessions and string functions


elite_prodigy

Recommended Posts

Okay, when I built my site, I had no idea I was going to have to get this involved, but apparently I do.

 

I posted earlier about my Dirt Digger thing and now I've had to disable it until I can prevent certain tags from working. I had users posting pornographic images and what have you. I also need to just not even enter the submission into the database if there are words that I may set off a bunk submission such as a rant about nothing with ton of swearing. I don't want to get so involved with this as to build an entire user system and make people log in to make a submission.

 

I think the one function I need is like StripTags("","") or something. I want to remove all tags except for <i>, <br />, <p>, <b> <u> and their counter parts.

 

Plus, I can't think of a simple way to search a string to see if it contains certain words.

Maybe str_search?

 

I also want to record their IP into the DB upon submission.

 

----------------------------------------------------------------

 

I also have a relatively simple ACP/staff area where staff can log in and what not to make submissions to a special page that is "official", however, I want this ACP to recognize them and I need to transfer their user name to another variable and change the code inside the page depending on who logged in because each staff member has a web page and I want them to be able to update only their own page when they log in so I need to change some info in the PHP code so that everything is sent to the right databases.

Link to comment
Share on other sites

php does provide a function  tostrip html tags from a string. Surprisingly its called strip_tags. It can be configured to only allow certain html tags too.

 

You can use str_replace to filter out offensive words, eg:

// add bad words to the bad_words array.
$bad_words = array('badword1', 'badword2', 'etc...');
// now to remove them
$clean_text = str_replace($bad_words, 'replacement_text_here', $text_to_filter);

Link to comment
Share on other sites

Not the best, but its a starting point:

$bad_words = array('apples', 'berries', 'nuts');

$str = 'I like apples and berries';

$bad_word_count = 0;
foreach($bad_words as $bad_word)
{
    if(eregi($bad_word, $str))
    {
        $bad_word_count++;
    }
}

if($bad_word_count == 0)
{
    echo "'$str is clean!";
}
else
{
    echo "bin '$str' not clean!";
}

Link to comment
Share on other sites

Okay, I have just about everything solved, except I keep getting this error with my sessions.

 

I use a file called logout.php to logout:


<?php
session_destroy();
unset($_SESSION[user]);
?>
<html>
<head>
</head>
<body>

<script type="text/javascript">

//using javascript because I can't get the header(":" to go to parrent directory.

window.location="http://www.hasdsecret.co.cc";

</script>

</body>
</html>

 

The above reders this error:

Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/david08/public_html/hasdsecret.co.cc/admin/logout.php on line 2

 

 

Link to comment
Share on other sites

I've fixed this too. Amature's mistake:

 

<?php
session_start(); //forgot to start session for destruction
session_destroy();
unset($_SESSION[user]);
?>
<html>
<head>
</head>
<body>

<script type="text/javascript">

//using javascript because I can't get the header(":" to go to parrent directory.

window.location="http://www.hasdsecret.co.cc";

</script>

</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.