php-general Digest 12 May 2001 07:54:28 -0000 Issue 681

Topics (messages 52513 through 52549):

Encode/Decode Problem
        52513 by: Augusto Cesar Castoldi
        52518 by: Sean Cazzell

OT SQL SERVER
        52514 by: Brandon Orther

Only have one session per user?
        52515 by: Christian Marschalek

PATH_INFO at document root
        52516 by: Simon Kimber

Re: Sending attachments via mail()
        52517 by: Sean Cazzell

protecting video files
        52519 by: Tim Schulte
        52520 by: Michael Kimsal
        52521 by: Tim Schulte
        52523 by: Mark Maggelet
        52528 by: Sean Cazzell

Re: mysql: UPDATE statment
        52522 by: Christian Dechery

verify phone number
        52524 by: Claudia Smith
        52526 by: Johnson, Kirk
        52530 by: Sean Cazzell

Multiple ASP 2 PHP conversion
        52525 by: Brandon Orther

Hidden Input and Quotes?
        52527 by: Jason Caldwell
        52529 by: Sean Cazzell
        52531 by: Young Chi-Yeung Fan
        52533 by: Jason Caldwell
        52534 by: Young Chi-Yeung Fan

Re: Please help me with this.
        52532 by: Young Chi-Yeung Fan

grep all pages
        52535 by: Yamin Prabudy
        52539 by: Young Chi-Yeung Fan

PHP and Unix Shell
        52536 by: YoBro
        52537 by: Jack Dempsey
        52538 by: YoBro

Repeat : I'm Living in cookie hell....
        52540 by: Scott Brown
        52548 by: barce

HallMark uses PHP!!!!
        52541 by: bzero.nullpointer.com

Simulate the Enter key in Unix with PHP
        52542 by: YoBro
        52543 by: Jason Brooke
        52544 by: YoBro
        52549 by: barce

Re: Newbie redirect/variable question
        52545 by: Steve Wade

Site search engine suggestion.
        52546 by: elias
        52547 by: Ryan W. Zajicek

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]


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


I'm using encode/decode with PHP to crypt my database.

Until now was OK, but I one string, and the MySQL return the string this
(without the []...):

[O#M~~"b9S" Z ]

The fact is I can't insert this encode string into MySQL table! My select:

select decode("O#M~~"b9S" Z ", "lPi1QzB5%!.dC;@");

I have a " in the middle of the encoded string. How can I solve this
problem?

regards,

Augusto Cesar Castoldi








> I have a " in the middle of the encoded string. How can I solve this
> problem?

You need to use addslashes().

http://www.zend.com/manual/function.addslashes.php


Regards,

Sean





Hello,

I am woking in PHP an recently got a SQL2000 database that I need to work
with.  What my question is ... is does anyone know how to make a printable
data model so I have something to look at while I program.

Thanks
Brandon





Hi all!

Can I only have one session per user / internet explorer? Or is it 
possible to seperate sessions let's say from script to script?





Hi all,

I want to set up one virtual server with many domains pointing to it which
serves pages depending on the domain name.

Here is how i see it:

1) 3 domains pointing to 1 virtual server, eg. www.foo.com www.bar.com and
www.blah.com

2) If user visits http://www.foo.com/contact.phtml then the PHP script does
this:

<?

include ($DOCUMENT_ROOT . "/" . $SERVER_NAME . $PATH_INFO);

?>

So the question is, how do i get one script called no matter what comes
after the root slash, and pass that info to the script?

Cheers

Simon Kimber





> I have some jpgs I'd like to send as attachments with automatically
> generated (via PHP) e-mails.  Does anyone have any suggestions as to how
> I might go about this?

Check this out: http://www.zend.com/codex.php?id=103&single=1


Regards,

Sean





Hi there -

    I am having some weird problems here. I am try to write a script that
will check to see where a movie file is being called from. I want to define
which web page I will allow a movie to be called from, and block all others.
The script so far looks like this:

The file gets called like this
http://www.hardcorehosting.com/video/playmovie.php?movie=test.mov

============  playmovie.php  ===============
<?php
header("Content-type: video/quicktime");
$file=fopen($movie, "r");
fpassthru($file);
?>
============= end script  ===================


which works fine until I add this at the top

if($HTTP_REFERER != "http://www.hardcorehosting.com/video/test.html";)
{
exit();
}

to check and see where the page is being called from. It then gives me a
broken image. I've checked for space's and can't see what I'm doing wrong
:( Any suggestions ?? Thanks.




Tim Schulte
[EMAIL PROTECTED]










Check for extraneous spaces in your script.

Tim Schulte wrote:

> Hi there -
>
>     I am having some weird problems here. I am try to write a script that
> will check to see where a movie file is being called from. I want to define
> which web page I will allow a movie to be called from, and block all others.
> The script so far looks like this:
>
> The file gets called like this
> http://www.hardcorehosting.com/video/playmovie.php?movie=test.mov
>
> ============  playmovie.php  ===============
> <?php
> header("Content-type: video/quicktime");
> $file=fopen($movie, "r");
> fpassthru($file);
> ?>
> ============= end script  ===================
>
> which works fine until I add this at the top
>
> if($HTTP_REFERER != "http://www.hardcorehosting.com/video/test.html";)
> {
> exit();
> }
>
> to check and see where the page is being called from. It then gives me a
> broken image. I've checked for space's and can't see what I'm doing wrong
> :( Any suggestions ?? Thanks.
>
> Tim Schulte
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]





I did :( went character by character and could find not extra spaces.

At 06:16 PM 5/11/01 -0400, Michael Kimsal wrote:
>Check for extraneous spaces in your script.
>
>Tim Schulte wrote:
>
> > Hi there -
> >
> >     I am having some weird problems here. I am try to write a script that
> > will check to see where a movie file is being called from. I want to define
> > which web page I will allow a movie to be called from, and block all 
> others.
> > The script so far looks like this:
> >
> > The file gets called like this
> > http://www.hardcorehosting.com/video/playmovie.php?movie=test.mov
> >
> > ============  playmovie.php  ===============
> > <?php
> > header("Content-type: video/quicktime");
> > $file=fopen($movie, "r");
> > fpassthru($file);
> > ?>
> > ============= end script  ===================
> >
> > which works fine until I add this at the top
> >
> > if($HTTP_REFERER != "http://www.hardcorehosting.com/video/test.html";)
> > {
> > exit();
> > }
> >
> > to check and see where the page is being called from. It then gives me a
> > broken image. I've checked for space's and can't see what I'm doing wrong
> > :( Any suggestions ?? Thanks.
> >
> > Tim Schulte
> > [EMAIL PROTECTED]
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]






On Fri, 11 May 2001 17:28:25 -0500, WebMaster
([EMAIL PROTECTED]) wrote:
>I did :( went character by character and could find not extra
spaces.
>
>At 06:16 PM 5/11/01 -0400, Michael Kimsal wrote:
>>Check for extraneous spaces in your script.
>>
>>Tim Schulte wrote:
>>
>> > Hi there -
>> >
>> >     I am having some weird problems here. I am try to write a
>>script that
>> > will check to see where a movie file is being called from. I
>>want to define
>> > which web page I will allow a movie to be called from, and block
>>all
>> others.
>> > The script so far looks like this:
>> >
>> > The file gets called like this
>> >
http://www.hardcorehosting.com/video/playmovie.php?movie=test.mov
>> >
>> > ============  playmovie.php  ===============
>> > <?php
>> > header("Content-type: video/quicktime");
>> > $file=fopen($movie, "r");
>> > fpassthru($file);
>> > ?>

some suggestions:
1) use "rb" instead of "r" for binary files
2) you forgot to fclose the file handle.
3) try readfile() instead.







> which works fine until I add this at the top
> 
> if($HTTP_REFERER != "http://www.hardcorehosting.com/video/test.html";)
> {
> exit();
> }
> 


Check to make sure $HTTP_REFERER is being set.  Just create another script
that has something like:

<?php
        print "Referer: $HTTP_REFERER\n";
?>

Then create a link to this new script from the test.html page that you're
trying to show the movie from.


Good luck,

Sean





At 21:40 10/5/2001 -0400, [EMAIL PROTECTED] wrote:
>why isnt this working
>
>i need to get 5 values updated in a table called 'user_polls'
>
>how do I do this?
>i have
>
>UPDATE user_polls WHERE id = '$id' VALUES($1, $2..... and so on


your statement is incorrect... the correct UPDATE syntax is:

UPDATE user_polls set field='value', field2='value2', field3=value3 where 
id=$id;

hope it helps...

____________________________
. Christian Dechery (lemming)
. http://www.tanamesa.com.br
. Gaita-L Owner / Web Developer





I am looking for code to verify a phone number has been entered correctly on
a form field.  Requirements would include the area code:  xxx-xxx-xxxx.








One way:

$phone = ereg_replace("[^0-9]", "", $phone);
if(!ereg("^[0-9]{10}$",$phoneHome")) {
  echo "error";
}

You could also check the string length after removing all non-numbers.

Kirk

> -----Original Message-----
> From: Claudia Smith [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 11, 2001 4:52 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] verify phone number
> 
> 
> I am looking for code to verify a phone number has been 
> entered correctly on
> a form field.  Requirements would include the area code:  
> xxx-xxx-xxxx.




> I am looking for code to verify a phone number has been entered correctly on
> a form field.  Requirements would include the area code:  xxx-xxx-xxxx.

You should use a regex for this.  Something like...

if (ereg ("[0-9]{3}-[0-9]{3}-[0-9]{4}", $number)) {
        print "good\n";
} else {
        print "bad\n";
}

The regexp breaks down like this:

[0-9]{3}        [0-9]{3}        [0-9]{4}
(three numbers)-(three numbers)-(four numbers)

I didn't test the code above, so let me know if it won't work for you.


Regards,

Sean





Hello,

I found asp2php to be a great tool.  Does anyone know of a way to make it
convert a whole directory or more than one file at a time?

Brandon





If I have a text box and enter data into that text box with "quotes" around
some of the text... and I want to throw that text into a HTML Hidden Input
Field (on my next screen for example) -- the quotes will somehow jackup or
truncate that text... because HTML uses "quotes" within in the Hidden Input
Field.

So my question is, should I (or, really, can I) encode it?  My thinking is I
want to encode it with the htmlspecialchars() function... however,
eventually, all the data within the Hidden Input Boxes will be stored into
my mySQL database, so I'll want to decode it before I send it (restoring the
quotes)... is there a way to decode the htmlspecialchars() function?  Or, is
there a better way to do this (*without* creating a session)?  -- I want to
use Hidden Input Fields.

Thanks
Jason
[EMAIL PROTECTED]







> So my question is, should I (or, really, can I) encode it?  My thinking is I
> want to encode it with the htmlspecialchars() function... however,
> eventually, all the data within the Hidden Input Boxes will be stored into
> my mySQL database, so I'll want to decode it before I send it (restoring the
> quotes)... is there a way to decode the htmlspecialchars() function?

I ran into almost exactly the same problem.  I was about ready to break
down and hack out a regex when I came across the
get_html_translation_table() function.  This function lets you get the
translation table used for the htmlspecialchars and htmlentities
functions.  So, for example:

function my_htmlspecialchars ($string) {
        $trans_table = get_html_translation_table (HTML_SPECIALCHARS);
        return strtr($string, $trans_table);
}

This uses the strtr (STRing TRanslate) function to do the translation and
does exactly the same thing as php's native htmlspecialchars().  To
reverse things (replace the special chars with normal chars), we just need
to flip the $trans_table around

function strip_htmlspecialchars ($string) {
        $trans_table = get_html_translation_table (HTML_SPECIALCHARS);
        $trans_table = array_flip($trans_table);
        return strtr($string, $trans_table);
}


There ya go :)


Regards,

Sean





Jason Caldwell wrote:

> If I have a text box and enter data into that text box with "quotes" around
> some of the text... and I want to throw that text into a HTML Hidden Input
> Field (on my next screen for example) -- the quotes will somehow jackup or
> truncate that text... because HTML uses "quotes" within in the Hidden Input
> Field.
>
> So my question is, should I (or, really, can I) encode it?  My thinking is I
> want to encode it with the htmlspecialchars() function... however,
> eventually, all the data within the Hidden Input Boxes will be stored into
> my mySQL database, so I'll want to decode it before I send it (restoring the
> quotes)... is there a way to decode the htmlspecialchars() function?  Or, is
> there a better way to do this (*without* creating a session)?  -- I want to
> use Hidden Input Fields.

An easier thing to do would be *not* to use htmlspecialchars(), but instead
replace all instances of " with &quot; . That's assuming your hidden input field
uses " instead of ' to quote the attribute values. You can just do:

ereg_replace("\"", "&quot;", $data);

Then you don't have to decode anything to restore the quotes and other
characters that have been changed. The &quot; will be translated back into "
when your form is submitted.

Young





> The &quot; will be translated back into "
> when your form is submitted.

?? I don't have to convert back??  -- when I eventually submit my Hidden
Input Fields into my mySQL DB, they'll be converted back to " ?

Confused....



"Young Chi-Yeung Fan" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Jason Caldwell wrote:
>
> > If I have a text box and enter data into that text box with "quotes"
around
> > some of the text... and I want to throw that text into a HTML Hidden
Input
> > Field (on my next screen for example) -- the quotes will somehow jackup
or
> > truncate that text... because HTML uses "quotes" within in the Hidden
Input
> > Field.
> >
> > So my question is, should I (or, really, can I) encode it?  My thinking
is I
> > want to encode it with the htmlspecialchars() function... however,
> > eventually, all the data within the Hidden Input Boxes will be stored
into
> > my mySQL database, so I'll want to decode it before I send it (restoring
the
> > quotes)... is there a way to decode the htmlspecialchars() function?
Or, is
> > there a better way to do this (*without* creating a session)?  -- I want
to
> > use Hidden Input Fields.
>
> An easier thing to do would be *not* to use htmlspecialchars(), but
instead
> replace all instances of " with &quot; . That's assuming your hidden input
field
> uses " instead of ' to quote the attribute values. You can just do:
>
> ereg_replace("\"", "&quot;", $data);
>
> Then you don't have to decode anything to restore the quotes and other
> characters that have been changed. The &quot; will be translated back into
"
> when your form is submitted.
>
> Young
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>






Jason Caldwell wrote:

> > The &quot; will be translated back into "
> > when your form is submitted.
>
> ?? I don't have to convert back??  -- when I eventually submit my Hidden
> Input Fields into my mySQL DB, they'll be converted back to " ?
>
> Confused....

If you have <input type="hidden" name="data" value="The word &quot;here&quot; is
in quotes." />, then when you submit your form, $HTTP_POST_VARS["data"] or
$HTTP_GET_VARS["data"] will be:

The word \"here\" is in quotes.

So you can put the value straight into MySQL. The slashes will not show up in
MySQL. The browser converted the &quot; into ", and PHP for some reason (I still
don't know why) adds slashes before your ' and " characters. If you use the
value elsewhere (aside from just inserting it into MySQL), you'll have to use
the stripslashes() function to get rid of the slashes.





"Johan Vikerskog (ECS)" wrote:

> ok.
> I have this problem of mine which i dont know how to solve. therefor i use this 
>great mailing list.
>
> Lets say i have a URL that looks something like below. This URL was generated from a 
>program that starts netscape with this adress. This adress is of course wrong.
>
> http://adam:9000//usr/local/test/test.html
>
> I want to change it so it looks like below with simply starting another scripts that 
>modifies the HTTP_REFERER so it adds the full computer name to the adress window.
>
> I asked this one before but nobody answered. If it isnt possible to be done i can 
>understand it but i atleast wants to know if it is possible. To do it.
>
> http://adam.artwork.com:9000//user/local/test/test.html
>
> Anyone got any tips for me on how to do this?
> Please help me with this.
>

I don't quite understand your question. It looks you have a program that generates the 
wrong URL, in which case it won't reach a page you want to go to. If the server in
the URL is wrong, there's nothing you can do to fix it the problem using PHP. If the 
URL that is generated is to a server you have control over, you can just do a
redirect to the correct address (and you don't need PHP to do this).

Also, you can *read*  $HTTP_REFERER to find out which page linked to the PHP script -- 
so setting it is not meaningful.





Hi there
I like to know can i grep a page say on http://www.somedomain.com
(just the index.html)
if it's possible can any guru out there enlight me how to do that

Yamin Prabudy
 ===========    _   _ _______
   ___   ______  /   |/   /  __/_  _ / Internet
  /  _   \/  __/  _  \/        /  _ /   /  /    For The
 /  .__ /_/    \___/_/|_ /___/ /_/     Profesional 
/_/ http://www.pro.net.id






Yamin Prabudy wrote:

> Hi there
> I like to know can i grep a page say on http://www.somedomain.com
> (just the index.html)
> if it's possible can any guru out there enlight me how to do that

I haven't done what you're trying myself, but the info on these two pages
might be helpful:

http://www.php.net/manual/en/features.remote-files.php
http://www.php.net/manual/en/function.preg-grep.php





Hello,

Is there any way to execute unix commands as though it was being done at the
shell.

I am wanting to add users to an htpasswd file.
Usually I use at the unix shell:

> htpasswd /users/jim/.htpasswd username

then are prompted for the new password

ie > password

then are promoted again to repeat the password

ie > password

I am wanting to carry out this entire process using a PHP script so I don't
have to use telnet anymore, and can then allow authorised users to change
their own password.

Please help.

YoBro







www.php.net/system

check the archives as well for questions relating to this specific issue

-jack

YoBro wrote:
> 
> Hello,
> 
> Is there any way to execute unix commands as though it was being done at the
> shell.
> 
> I am wanting to add users to an htpasswd file.
> Usually I use at the unix shell:
> 
> > htpasswd /users/jim/.htpasswd username
> 
> then are prompted for the new password
> 
> ie > password
> 
> then are promoted again to repeat the password
> 
> ie > password
> 
> I am wanting to carry out this entire process using a PHP script so I don't
> have to use telnet anymore, and can then allow authorised users to change
> their own password.
> 
> Please help.
> 
> YoBro
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]




dude!

I have already looked there, but the examples are not clear based on what i
am wanting to do.

I was hoping somebody in this group has done it before so I could see some
example code as to executing a statement like in my first message.

"Jack Dempsey" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> www.php.net/system
>
> check the archives as well for questions relating to this specific issue
>
> -jack
>
> YoBro wrote:
> >
> > Hello,
> >
> > Is there any way to execute unix commands as though it was being done at
the
> > shell.
> >
> > I am wanting to add users to an htpasswd file.
> > Usually I use at the unix shell:
> >
> > > htpasswd /users/jim/.htpasswd username
> >
> > then are prompted for the new password
> >
> > ie > password
> >
> > then are promoted again to repeat the password
> >
> > ie > password
> >
> > I am wanting to carry out this entire process using a PHP script so I
don't
> > have to use telnet anymore, and can then allow authorised users to
change
> > their own password.
> >
> > Please help.
> >
> > YoBro
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>






(it's been about 12 hours since I sent this, and havent seen it come
through, so I'm re-building/re-sending it... 'cause I need some help on
this)

I'm confused.  I'm bemuttered.  I'm pulling my hair out.

I have a page which processes a membership request, and includes the
following code:

from /secure/membersignup.php  (will eventually live under an SSL
connection)

   if (!mysql_query($sql))
        $insert_id = 0;
   else {
        $insert_id = mysql_insert_id($connTemp);
        setcookie("YONKAMEMBERID",$insert_id,time()+31536000,"/",$PHP_HOST);
   }

It quite nicely sets the cookie, and the cookie is accessible from any page
on the site.  I know this because (a) I turn on the cookie warnings, and
examine the cookie contents being set, and (b) the cookie contents are
actually thrown out in the header of all my pages (well, any subsequent
pages... I know the limit on cookie processing in PHP).  The cookie is
accessible in any script's subdirectory that I've tried.

Next, I also have a log out page, which unsets the cookie using this code:

from /logout.php

        setcookie("YONKAMEMBERID","",time()-10000,"/");

which quite happily works and after processing, the cookie is no longer set,
and the data is not thrown into the headers of all my pages.

Now comes my problem : I have a page to allow the user to "login" to the
site (reset the cookie to their membership#)...

from /login.php

       $row = mysql_fetch_array($result);
       if ($row[memberid] == $login_id) {
              $bad_attempt=0;

setcookie("YONKAMEMBERID",$login_id,time()+31536000,"/",$PHP_HOST);
              Header("Refresh: 0;url=/");
       }

This code does NOT set the cookie.  The only differences here are the
variable name setting it (which must be valid membership ID# otherwise the
database comparison would not work, and the page would not refresh back to
the main index page.) and the path of the script... but since I'm defining
the path of the cookie to be the root under both instances, it should be
trying to set the same cookie, right?

I've even goen so far as scrape the line out of the working code and insert
it into the login page (then changing the variable)... and it still doesnt
work.

Does anyone have any suggestions?

I'm testing with IE 5.01 SP1, and using PHP4.04pl1 on the backend..... I
havent tried under netscape yet.






Hello Scott,

I took a look at your code, and have a solution for you.

Here's the code:

while ($row = mysql_fetch_array($result) )
{
        if ($row["memberid"] == $login_id)
        {
                // your code here :-)
        }
}

> 
>        $row = mysql_fetch_array($result); // Get one row of data only *BAD*
>        if ($row[memberid] == $login_id) {
>               // [...]
>        }
> 
> the path of the cookie to be the root under both instances, it should be
> trying to set the same cookie, right?

correct, but this only works if the first array returned is equal to the
login_id. since you are returning only the first row of your database
table, you never make it to the memberid that you're hoping is there --
assumming that it is there.

Train harder!

regards,barce




I was just looking at Hallmark Channels' website, and noticed them to be using PHP, 
wow, PHP has rocketed to something, eh.




Hello,

I have been trying to get PHP to execute some code to add users to the
htpasswd file.
So far I have this

system ("htpasswd /users/website/.htpasswd jim");

My browser receives the unix data that reads : Adding user jim printed to
the browser.
Then you are usually prompted for a password in Unix, so the following is
the password I want to submit, but how do I tell it to simulate an ENTER key
press after each submission of the password.

system ("password");  // usually press enter after this
system ("password"); // and enter again.

I am hoping this will fix the problem. If it is beginning to add the user,
then it should work if I can execute the passwords with an ENTER after it as
well.


YoBro






Why don't you just use the -b switch and do it in one hit? 


----- Original Message ----- 
From: "YoBro" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 12, 2001 3:32 PM
Subject: [PHP] Simulate the Enter key in Unix with PHP


> Hello,
> 
> I have been trying to get PHP to execute some code to add users to the
> htpasswd file.
> So far I have this
> 
> system ("htpasswd /users/website/.htpasswd jim");
> 
> My browser receives the unix data that reads : Adding user jim printed to
> the browser.
> Then you are usually prompted for a password in Unix, so the following is
> the password I want to submit, but how do I tell it to simulate an ENTER key
> press after each submission of the password.
> 
> system ("password");  // usually press enter after this
> system ("password"); // and enter again.
> 
> I am hoping this will fix the problem. If it is beginning to add the user,
> then it should work if I can execute the passwords with an ENTER after it as
> well.
> 
> 
> YoBro
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 





Have you got an example of how to use the -b switch.
I am not up with lingo when it comes to unix.


""Jason Brooke"" <[EMAIL PROTECTED]> wrote in message
050d01c0daa6$9ebbada0$[EMAIL PROTECTED]">news:050d01c0daa6$9ebbada0$[EMAIL PROTECTED]...
> Why don't you just use the -b switch and do it in one hit?
>
>
> ----- Original Message -----
> From: "YoBro" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, May 12, 2001 3:32 PM
> Subject: [PHP] Simulate the Enter key in Unix with PHP
>
>
> > Hello,
> >
> > I have been trying to get PHP to execute some code to add users to the
> > htpasswd file.
> > So far I have this
> >
> > system ("htpasswd /users/website/.htpasswd jim");
> >
> > My browser receives the unix data that reads : Adding user jim printed
to
> > the browser.
> > Then you are usually prompted for a password in Unix, so the following
is
> > the password I want to submit, but how do I tell it to simulate an ENTER
key
> > press after each submission of the password.
> >
> > system ("password");  // usually press enter after this
> > system ("password"); // and enter again.
> >
> > I am hoping this will fix the problem. If it is beginning to add the
user,
> > then it should work if I can execute the passwords with an ENTER after
it as
> > well.
> >
> >
> > YoBro
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>






hello,


YoBro wrote:
> 
> Have you got an example of how to use the -b switch.
> I am not up with lingo when it comes to unix.
> 

<?php

/* try this */

if ($pressed)
{

        $result = passthru("htpasswd -b mypasswordlist $user $pass");

        echo "$result<br>\n";
}
else
{
?>

<form method=POST action="<? echo $PHP_SELF; ?>">
user: &nbsp;&nbsp; <input type=text name=user><br>
pass: &nbsp;&nbsp; <input type=password name=user><br>
<input type=submit name=pressed value=' GO '>
</form>


<?

}

?>




Thanks - the hassle is - my isp doesn't use mysql - so i have to use text
files I reckon :-)

swadie


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steve Wade
Youth Outreach Coordinator
Fusion Australia Ltd (Sydney North)
ABN 26 001 273 105
+61 2 9477 1110


-----Original Message-----
From: James Holloway [mailto:[EMAIL PROTECTED]]
Sent: Friday, 11 May 2001 0:29
To: [EMAIL PROTECTED]
Subject: Re: Re[2]: [PHP] Newbie redirect/variable question


Steve,

The way you are doing things could leave yourself open with all kinds of
problems - one of which is address spoofing.  A better way would be to TEST
the link against values in the database before updating the link with a hit
and exiting.  Have the URL's marked against an auto-incremented id:

id: 23
name: Steve's page
url: http://www.somewhere.com

Url: redirect.php?id=23

redirect.php:
________________________________________________________

<?

$check = @mysql_query("SELECT url FROM links WHERE id = '$id'",
$connection);

if (mysql_num_rows($check) != 0) {
    $update = @mysql_query("UPDATE links SET out = out + 1 WHERE id =
'$id'", $connection);

    while($row = mysql_fetch_array($check)) {
        $url = $row['url'];
    }

    header("location: $url");
    exit;

} else {

?>
<HTML>
<HEAD>
<TITLE>Link not found</TITLE>
</HEAD>
<BODY>

No corresponding link found!

</BODY>
</HTML>
<? } ?>
________________________________________________________


Much better that way, IMO. At present, if someone typed in a fake address,
the database would attempt to update a non-existant entry....

You could go further, and log the IP of the user, and perhaps even set a
cookie if you were totally paranoid about people repeatedly clicking their
links so that they got more hits out.

Have fun ;)

James.


""Steve Wade"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Ahh - thanks - that's helped :-) (Line 9 was the http_referrer line)
>
> Now the only trouble is, it seems to still treat $fred as null.
>
> The passing line is from index.php:
>
> <a href="redirect.php?fred=www.fusion.org.au">test link</a>
>
>  Should this work?
>
> Thanks,
>
> Steve
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Steve Wade
> Youth Outreach Coordinator
> Fusion Australia Ltd (Sydney North)
> ABN 26 001 273 105
> +61 2 9477 1110
>
>
> -----Original Message-----
> From: Adaran (Marc E. Brinkmann) [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 10 May 2001 22:20
> To: [EMAIL PROTECTED]
> Subject: Re[2]: [PHP] Newbie redirect/variable question
>
>
> Hi Steve,
>
> Thursday, May 10, 2001, 1:39:36 PM, you wrote:
> Steve> Ok - thanks - my new redirect.php is
>
> Steve> <?php
> Steve> if ($fred != "") {
> Steve> #     $statement = "UPDATE links SET hits=hits+1 WHERE
href=\"$u\"";
> Steve> #     mysql_query($statement);
> Steve>     Header("Location: $fred");
> Steve>     exit;
> Steve> } else {
> Steve>     Header("Location: $HTTP_REFERRER");
> Steve>     exit;
> Steve> }
> ?>>
>
> Steve> I get the following message...
> Steve> Warning: Cannot add header information - headers already sent by
> (output
> Steve> started at /home/swadie/public_html/redirect.php:2) in
> Steve> /home/swadie/public_html/redirect.php on line 9
>
> Make sure you have NO Blanks or any other Text before the <?php ! "<?" has
> to be
> the first two characters in the file. Which line is line 9 ?
>
> -----------------------
> EnjoY,
>  Adaran ([EMAIL PROTECTED])
>    check http://www.adaran.net
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]





Hello guys,

I need that badly! I need a suggestion, advise, solution or whatever that
might help!

I need a Site Search script for a page that mostly have .PHP files some are
dynamic and some are not.
Basically i was using WebGlimpse but whenever I search using it, It shows
the source code of the PHP files!
So for example if i search "echo" , WebGlimpse displays the .PHP file source
code!

Any suggestion for a better site search program?

-elias






I use mnoGoSearch http://search.mnogo.ru/ it works great for me and I've
been using it for about a year.

Thank You

Ryan
mailto:[EMAIL PROTECTED]


-----Original Message-----
From: elias [mailto:[EMAIL PROTECTED]]
Sent: Saturday, May 12, 2001 12:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Site search engine suggestion.


Hello guys,

I need that badly! I need a suggestion, advise, solution or whatever that
might help!

I need a Site Search script for a page that mostly have .PHP files some are
dynamic and some are not.
Basically i was using WebGlimpse but whenever I search using it, It shows
the source code of the PHP files!
So for example if i search "echo" , WebGlimpse displays the .PHP file source
code!

Any suggestion for a better site search program?

-elias



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Reply via email to