php-general Digest 17 Oct 2004 02:59:15 -0000 Issue 3057

Topics (messages 199632 through 199651):

dirty words
        199632 by: Mag
        199633 by: Chris Kay
        199634 by: Mag
        199636 by: Kevin Waterson
        199641 by: Graham Cossey

Re: urlencode() and newlines?
        199635 by: Marek Kilimajer
        199637 by: Nick Wilson
        199638 by: Marek Kilimajer
        199639 by: Nick Wilson

Another regex problem - help!
        199640 by: Murray . PlanetThoughtful
        199643 by: Jason Wong

Fatal error
        199642 by: Pahlevanzadeh Mohsen
        199644 by: Juan Pablo Herrera
        199645 by: Kevin Waterson

Header sending
        199646 by: Pahlevanzadeh Mohsen
        199648 by: Chris Shiflett

Is there a way to...
        199647 by: GH
        199649 by: GH

Re: PHP App User Permissions Tecnique
        199650 by: GH

guessing timezone based on country/state/city
        199651 by: Justin French

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi,
I am useing file_get_contents on a remote page then
using stristr() to make sure there are no "bad words"
and its a family site.
Right now I am checking for just 3 bad words which
means 3 stristr() function calls, but if the bad words
increase then that would mean more calls....

I have seen some forum software before that used to
take an array of bad words and check it against the
post, anybody have an idea what that function would be
like coz I am pretty sure I am going about this the
wrong way...php has a simple solution to most of these
problems...

Thanks,
Mag

=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)


                
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

--- End Message ---
--- Begin Message ---
 
in_array() can check your $string against a array and return if a bad word
is in string

Is this what you are after?

Chris Kay (CK)
[EMAIL PROTECTED]


-----Original Message-----
From: Mag [mailto:[EMAIL PROTECTED] 
Sent: Sunday, 17 October 2004 12:41 AM
To: php php
Subject: [PHP] dirty words

Hi,
I am useing file_get_contents on a remote page then using stristr() to make
sure there are no "bad words"
and its a family site.
Right now I am checking for just 3 bad words which means 3 stristr()
function calls, but if the bad words increase then that would mean more
calls....

I have seen some forum software before that used to take an array of bad
words and check it against the post, anybody have an idea what that function
would be like coz I am pretty sure I am going about this the wrong way...php
has a simple solution to most of these problems...

Thanks,
Mag

=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)


                
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hey!
Thanks, I think in_array() is what I was looking for,
but by a quick glance I think its case sensitive (?),
I didnt want to use a class for this coz it kind of
seemed like using a gun instead of a flyswatter....
:-)

Also, any way to check if a remote file exists?
I am presently using this:
$url='http://www.blah.net/movie.mpg'; 
$addy=parse_url($url); 
$addy['port']=isset($addy['port'])?$addy['port']:80; 
$sh=fsockopen($addy['host'],$addy['port']) or
die('cant open socket'); 
fputs($sh,"HEAD {$addy['path']} HTTP/1.1\r\nHost:
{$addy['host']}\r\n\r\n"); 
while($line=fgets($sh)) 
if(preg_match('/^Content-Length: (d+)/',$line,$m)) 
$size=$m[1]; 
echo isset($size)?"size of $url file is $size": 'no
such file: '.$url; 

Thanks,
Mag


> in_array() can check your $string against a array
> and return if a bad word
> is in string
> 
> Is this what you are after?
> 
> Chris Kay (CK)
> [EMAIL PROTECTED]
> 
> 
> -----Original Message-----
> From: Mag [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, 17 October 2004 12:41 AM
> To: php php
> Subject: [PHP] dirty words
> 
> Hi,
> I am useing file_get_contents on a remote page then
> using stristr() to make
> sure there are no "bad words"
> and its a family site.
> Right now I am checking for just 3 bad words which
> means 3 stristr()
> function calls, but if the bad words increase then
> that would mean more
> calls....
> 
> I have seen some forum software before that used to
> take an array of bad
> words and check it against the post, anybody have an
> idea what that function
> would be like coz I am pretty sure I am going about
> this the wrong way...php
> has a simple solution to most of these problems...
> 
> Thanks,
> Mag
> 
> =====
> ------
> - The faulty interface lies between the chair and
> the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
> 
> 
>               
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We
> finish.
> http://promotions.yahoo.com/new_mail 
> 
> --
> PHP General Mailing List (http://www.php.net/) To
> unsubscribe, visit:
> http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)


                
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

--- End Message ---
--- Begin Message ---
This one time, at band camp, Mag <[EMAIL PROTECTED]> wrote:

> Hi,
> I am useing file_get_contents on a remote page then
> using stristr() to make sure there are no "bad words"
> and its a family site.
> Right now I am checking for just 3 bad words which
> means 3 stristr() function calls, but if the bad words
> increase then that would mean more calls....

  $badwords = array('poo', 'bum', 'perl');

  $goodString = str_replace($badwords, '***', file_get_contents($url);

  echo $goodString;

If you are using php5 you can use str_ireplace() for a case insensitive 
search

Kevin
---------
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

--- End Message ---
--- Begin Message ---
To be case insensitive using PHP < 5 I guess you would have to preg_split()
then iterate through each array element converting to lowercase before doing
the comparison, something like below, or include all case combos in your
$badwrds array, ie poo, Poo, POO etc.

$string = file_get_contents($url);
$wordArray = preg_split(your_regex, $string);
foreach ($wordArray as $word)
{
  if (in_array(strtolower($word),$badwords))
  {
    $string = str_replace($word, '***', $string);
  }
}

Or something along those lines. It's been a long day...
Someone here will surely post a much simpler solution :)

Graham

> -----Original Message-----
> From: Kevin Waterson [mailto:[EMAIL PROTECTED]
> Sent: 16 October 2004 16:12
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] dirty words
>
>
> This one time, at band camp, Mag <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> > I am useing file_get_contents on a remote page then
> > using stristr() to make sure there are no "bad words"
> > and its a family site.
> > Right now I am checking for just 3 bad words which
> > means 3 stristr() function calls, but if the bad words
> > increase then that would mean more calls....
>
>   $badwords = array('poo', 'bum', 'perl');
>
>   $goodString = str_replace($badwords, '***', file_get_contents($url);
>
>   echo $goodString;
>
> If you are using php5 you can use str_ireplace() for a case insensitive
> search
>
> Kevin
> ---------
> "Democracy is two wolves and a lamb voting on what to have for lunch.
> Liberty is a well-armed lamb contesting the vote."
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message --- Nick Wilson wrote:
hello all,

For reasons beyond my immediate control i have to keep some strings of
text in a text *new line delimited* text file. I also have to urlencode
those strings for use in my script.

Like this:

## text file
This is a line\nThis is another line
This is another string\nwith some more\nnew lines

Problem is, that urlencoding those lines doesnt seem to work well the
the \n's - when they get to where they are going (another server, not in
my control) the new lines are no longer there...

Can anyone tell me how to get round this issue without storing the
strings in another way? - many thanks! ;-)

Because what you are doing is not urlencoding. Try

echo urlencode("This is a line\nThis is another line");
--- End Message ---
--- Begin Message ---
* and then Marek Kilimajer declared....
> Nick Wilson wrote:
> >hello all, 
> >
> >For reasons beyond my immediate control i have to keep some strings of
> >text in a text *new line delimited* text file. I also have to urlencode
> >those strings for use in my script.
> >
> >Like this: 
> >
> >## text file
> >This is a line\nThis is another line
> >This is another string\nwith some more\nnew lines
> >
> >Problem is, that urlencoding those lines doesnt seem to work well the
> >the \n's - when they get to where they are going (another server, not in
> >my control) the new lines are no longer there...
> >
> >Can anyone tell me how to get round this issue without storing the
> >strings in another way? - many thanks! ;-)
> 
> Because what you are doing is not urlencoding. Try
> 
> echo urlencode("This is a line\nThis is another line");

Yep, i can see that it's encoded but when the data is POSTed to a form,
it does not come out as a newline...


-- 
Nick W

--- End Message ---
--- Begin Message --- Nick Wilson wrote:
* and then Marek Kilimajer declared....

Nick Wilson wrote:

hello all,

For reasons beyond my immediate control i have to keep some strings of
text in a text *new line delimited* text file. I also have to urlencode
those strings for use in my script.

Like this:

## text file
This is a line\nThis is another line
This is another string\nwith some more\nnew lines

Problem is, that urlencoding those lines doesnt seem to work well the
the \n's - when they get to where they are going (another server, not in
my control) the new lines are no longer there...

Can anyone tell me how to get round this issue without storing the
strings in another way? - many thanks! ;-)

Because what you are doing is not urlencoding. Try

echo urlencode("This is a line\nThis is another line");


Yep, i can see that it's encoded but when the data is POSTed to a form,
it does not come out as a newline...

Are you sure the other side accepts, does not remove newlines? Create a form with textarea that posts to the server

--- End Message ---
--- Begin Message ---
* and then Marek Kilimajer declared....
> >>
> >>echo urlencode("This is a line\nThis is another line");
> >
> >
> >Yep, i can see that it's encoded but when the data is POSTed to a form,
> >it does not come out as a newline...
> 
> Are you sure the other side accepts, does not remove newlines? Create a 
> form with textarea that posts to the server

yeah, i guess i'll have to, thanks Marek..

-- 
Nick W

--- End Message ---
--- Begin Message ---
Hi All,

I'm trying to match a particular pattern in a multi-line string. The string
might look like:

<string>

Some text.

Some more text.

[[ft1: An example of the search string [[fn2]]]]

[[ft2: Another example of a search string]]

Extra text

</string>

In this case, I'm trying to perform a preg_match using the following
expression:

preg_match("/^\[\[ft".$fn[1].":(.*)\]\]$/m",$content,$ft);

In the above example, the preg_match would be applied twice, once with a
$fn[1] value of 1, the second time with a $fn[1] value of 2. The $content
variable contains the string above.

I'm attempting to accommodate a situation where the target string might
contain "]]" before I want the capture to finish, as in the first example
above. I'm hoping to return both the whole value matched by the preg_match,
as well as the content of the matched string after the ":" character up to
the final closing "]]" for the line.

In essence, the closing "]]" for the match should always be at the end of
the line.

My attempt to build a pattern, as above, isn't working. I'm wondering if
anyone can give me some advice on how to fix it?

Many thanks in advance and much warmth,

Murray

--- End Message ---
--- Begin Message ---
On Sunday 17 October 2004 03:54, Murray @ PlanetThoughtful wrote:

> In this case, I'm trying to perform a preg_match using the following
> expression:
>
> preg_match("/^\[\[ft".$fn[1].":(.*)\]\]$/m",$content,$ft);

Nearly there, except that ']' is not a special char and should not be escaped. 

> In the above example, the preg_match would be applied twice, once with a
> $fn[1] value of 1, the second time with a $fn[1] value of 2. The $content
> variable contains the string above.

Not sure why you would want to apply the regex more than once. You use:

  preg_match_all('/^\[\[ft\d{1}:(.*)]]$/m', $content, $ft)

That will match ft0 upto ft9, season to taste.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Life is difficult because it is non-linear.
*/

--- End Message ---
--- Begin Message ---
Dear members,I get an error,What does mean my error? :
Fatal error: Maximum execution time of 30 seconds
exceeded in /var/www/html/votting/vote_implement.php
on line 8

=====
---------DIGITAL  SIGNATURE-------------------
///Mohsen Pahlevanzadeh////////
     Network administrator  & programmer     
      My home phone is: +98213810146          
My email address is                                  
          m_pahlevanzadeh at yahoo dot com               
My website is: http://webnegar.net            
----------------------------------------------------------------


                
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

--- End Message ---
--- Begin Message ---
In your script use set_time_limit(0), and look
http://ar2.php.net/manual/en/function.set-time-limit.php for understand
the function.
Regards,
JP

> Dear members,I get an error,What does mean my error? :
> Fatal error: Maximum execution time of 30 seconds
> exceeded in /var/www/html/votting/vote_implement.php
> on line 8
>
> =====
> ---------DIGITAL  SIGNATURE-------------------
> ///Mohsen Pahlevanzadeh////////
>     Network administrator  & programmer
>      My home phone is: +98213810146
> My email address is
>          m_pahlevanzadeh at yahoo dot com
> My website is: http://webnegar.net
> ----------------------------------------------------------------
>

--- End Message ---
--- Begin Message ---
This one time, at band camp, Pahlevanzadeh Mohsen <[EMAIL PROTECTED]> wrote:

> Dear members,I get an error,What does mean my error? :
> Fatal error: Maximum execution time of 30 seconds
> exceeded in /var/www/html/votting/vote_implement.php
> on line 8

It means the Maximum execution time of 30 seconds has been exceeded.
Each script has a maximum of 30 seconds to do its thang. This time
limit is set in php.ini and the default is 30 seconds. If your 
script needs a little more time, this can be changed.
What are you doing in a vote script that takes so long?
Look for infinite loops.

Kind regards
Kevin

---------
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

--- End Message ---
--- Begin Message ---
Dear members,I need to post a header without Form tag.
Already i have used input tag (hidden type),But i
don't kbow to how do it.
Please guide me....
Yours,Mohsen 

=====
---------DIGITAL  SIGNATURE-------------------
///Mohsen Pahlevanzadeh////////
     Network administrator  & programmer     
      My home phone is: +98213810146          
My email address is                                  
          m_pahlevanzadeh at yahoo dot com               
My website is: http://webnegar.net            
----------------------------------------------------------------


                
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

--- End Message ---
--- Begin Message ---
--- Pahlevanzadeh Mohsen <[EMAIL PROTECTED]> wrote:
> I need to post a header without Form tag.

The header() function can be used to add a header to the response:

http://www.php.net/header

I'm not sure what this has to do with a form tag...

Chris

=====
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly     HTTP Developer's Handbook - Sams
Coming December 2004        http://httphandbook.org/

--- End Message ---
--- Begin Message ---
Is there a way to make sure that a page is only loaded via a 

require or include statement? or other type of SSI? 

I would like to make sure that a 'parent document'  (namely
admin_template.php) only calls the php file?

Thanks

--- End Message ---
--- Begin Message ---
Your right, this is not what I was expecting, I was thinking there was
another way...  Sounds good.. but any other suggestions?




On Sat, 16 Oct 2004 21:40:56 -0400, Minuk Choi <[EMAIL PROTECTED]> wrote:
> well, this is probably not what you were expecting... but you can try this
> 
> admin_template.php
> --
> $parent = true;
> include('important.php');
> --
> 
> important.php
> --
> if (!isset($parent) || !$parent)
> exit();
> 
> //important stuff here.
> --
> 
> Of course, this only works assuming that the would-be hacker doesn't know
> HOW you are authenticating the file.  If you are going to try this method,
> mix it up, use a rather unique variable name and or use a value that is hard
> to guess.
> 
> -Minuk
> 
> 
> 
> 
> ----- Original Message -----
> From: "GH" <[EMAIL PROTECTED]>
> To: "PHP General" <[EMAIL PROTECTED]>
> Sent: Saturday, October 16, 2004 9:15 PM
> Subject: [PHP] Is there a way to...
> 
> > Is there a way to make sure that a page is only loaded via a
> >
> > require or include statement? or other type of SSI?
> >
> > I would like to make sure that a 'parent document'  (namely
> > admin_template.php) only calls the php file?
> >
> > Thanks
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
>

--- End Message ---
--- Begin Message ---
However I would think that using the db would allow for you to change
the persons while they are using the site and would not make them have
to  relog in....

suggestions?


On Fri, 15 Oct 2004 10:52:53 +0200, Ian Firla <[EMAIL PROTECTED]> wrote:
> 
> Definitely store them in a session. A db lookup will mean a much heavier
> and process intensive procedure.
> 
> Ian
> 
> 
> 
> On Fri, 2004-10-15 at 09:41, Brendon wrote:
> > I am building a web based community forum type software using PHP. I am
> > currently working on how different user privelages are handled. Each
> > user is part of a group and each group has varying degrees of privelages.
> >
> > I need to add in functionality which at the begginning of every script
> > check the permission level of the user accessing the page. There are
> > about 15 different permissions.
> >
> > I am debating whether i should store all the permission abilities into
> > session variables and they can quickly be checked throughout the script,
> > or whether i should query the database to check to see if the user has
> > adequate group permissions to perform a certain function.
> >
> > Could someone give me some advice as to which would be more advisable?
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message --- I have an event CMS where really, I should know the TZ of the events, which can happen world wide. However the user base is not computer heads, so I can't just "ask them".

So, I'm faced with the prospect of making an educated guess based on the Country, State and Capital City information provided by the user... possibly I could interface with the files in /usr/share/zoneinfo/, or perhaps there's a database I can download to hook into.

If I was limiting myself to just Australia, it'd be quite easy to hard code it, but since I'm targeting clients and events world-wide, I really need something less "manual".

TIA,
Justin French

--- End Message ---

Reply via email to