[PHP] Re: naughty words / filter

2003-08-21 Thread Chris Kranz

> // example #1: in the script the text in the variable $guestbook does not
> get replaced.
>  $dirty_words = array("badword1","badword2","badword3");
> $guestbook = stripslashes($message);
> foreach ($dirty_words as $word){
>  $message = str_replace($word, "", $guestbook);
> }
> echo $message;
> ?>
> .
>

this won't help your script work, but will tidy it up, but try using a
regular expression...

$dirty_words = array("|badword1|i","|badword2|i","|badword3|i"); //the i
will make it case insensetive, which is extra useful...
$message = preg_replace( $dirty_words, "", stripslashes($message) );
echo $message;



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



[PHP] cookies under php 4.06

2003-09-04 Thread Chris Kranz
okay, i know this is stupid, and i'm gonna kick myself when someone points
out the obvious...

i've just put a site online, and found the server's running an older version
of php (4.06). it's virtual hosting, so i have no control over this... also
can't tell you what OS it's running, but it is windows based...

the code works locally, although i had to change all $_COOKIE to
$HTTP_COOKIE_VARS, same with $_POST, $_SERVER, etc. etc.

i've had a quick look through the archives, and googled, but can't find much
help around for older installs of php.

my code, like i said, the functionality works, but it's just plain not
sending the cookie, my little print statements show up and all, but i get no
error, and i also get no cookie.




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



[PHP] Re: cookies under php 4.06

2003-09-04 Thread Chris Kranz

>setcookie("UserName", $HTTP_POST_VARS['UserName'], time()+(60*10), "/",
> $HTTP_SERVER_VARS['SERVER_NAME']);
>setcookie("Password", $password, time()+(60*10), "/",
> $HTTP_SERVER_VARS['SERVER_NAME']);
>print "login - set cookie";


sorry for kinda answering my own post... but anyway...

setcookie("UserName", $HTTP_POST_VARS['UserName']);
setcookie("Password", $password);

solves my problem, although means i can't have a time limit on my cookies i
guess... but can set a time limit with another cookie...

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



[PHP] Re: reverse lookup/domain lookup in PHP

2003-09-11 Thread Chris Kranz

> Is it possible to reverse lookup (like here
http://www.whatismyipaddress.com/reverse.asp) to find the domain with PHP? I
assume a DNS lookup requires an external server somewhere?
>

you can use exec or similar and to a reverse lookup like that... a
traceroute should cover it. please don't copy and paste my code, just giving
you an idea of what you'll do...

exec("traceroute ".$ip." > file.tmp")

then read the contents of file.tmp and you should be able to get the whole
of the traceroute. this brings up certain issues with speed of a traceroute
and run times of a script. also there may be a better way of doing this
other than piping the contents into a temporary file, but i've had issues
with reading what exec() outputs before (or whatever system call function
you'd like to use)

... hope this helps a little

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



[PHP] Re: Edit a String

2003-09-17 Thread Chris Kranz

> format ', x, x, xxx' how can I edit it so that the comma's are
> replaced with line breaks i.e. /n. This will enable me to display the

str_replace ( ",", "\n", $address );

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



[PHP] set_time_limit() on Mac

2003-10-07 Thread Chris Kranz
i gotta wierd one, maybe it's just me being daft...

i'm under the impression that max execution time / set_time_limit() is
server specific, and completely independant of what computer is being served
the pages?

my server is apache 1.3 running php 4.3 on win 2k...

when i run the script from a windows machine, it runs fine. my line that
does a set_time_limit(10) works and the script happily runs for about 2
minutes while a loop does some file copying (across the network to the
server, and independant of whatever machine called the script).

however, if i run the same script from my little iMac (shudders) then it'll
give me a script timeout saying it's gone over the max execution time of 10.
now i know that set_time_limit(10) is being run, as the server default is
30. it just doesn't seem to be resetting this value in the PHP loop. but
surely that's impossible, as it should be all server side?

secondly, i have a timer that (using javascript) writes to the html page how
long the script has been running, and an estimate of how long is left to
run. again, perfect timing on the PC, but when run from the Mac, the timer
counts 1 second roughly every 2 seconds. again, surely this is impossible as
time functions are run from the server???

the other strange thing, if i have the script running off a PC, and the Mac
then also runs it, it'll time perfectly... it'll still time out, but it'll
atleast count proper seconds...

here's a rough idea of the code... i've cut out most of the crap that it
does to give you an idea of what's happening, ignore any syntax errors, as
the script does work... the flush() works nicely to update my form fields
with javascript so i can see the live results of the script working... and
see the problems with how mac seems to be handling it.

anyway, any ideas would be very appreciated, as i don't want to have to
fudge it and stick set_time_limit(1000) at the beginning of the page :(

---code---




 Imposition Uploader
 

 function name(label)
 {
  document.all.currentName.value=label;
 }
 function add(name)
 {
  document.all[name].value++;
 }
 function time(estimate,taken)
 {
  document.all.timeEstimate.value=estimate;
  document.all.timeTaken.value=taken;
 }

 


";
echo"total files read: ";
echo"total files copied: ";
echo"total errors: ";
echo"total edits: ";
echo"db records deleted: ";
echo"db records updated: ";
echo"new db records: ";
echo"";
echo"estimated time: ";
echo"time taken: ";
flush();
//read in a csv file line by line
foreach($csv as $record)
{
 $counter++;
 set_time_limit(10); //this doesn't work for mac!!
  if(file_exists($file))
  {
//do some file copying across the network. $file is located on
NFS and copied to the server...
//also run some extra functions to update our form counters with
JS
  }
  $estimate = round(($sofar/$counter)*$rows);
  $sofar = round(getmicrotime($start));
  echo "time('$estimate','$sofar');";
  echo "";
  flush();
 }
?>



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