php-general Digest 1 Feb 2004 13:10:08 -0000 Issue 2564

Topics (messages 176469 through 176500):

Perl script using Inline-octave doesn't run.
        176469 by: Paulo Lagrotta

Re: formated text after Submit in MySQL/PHP
        176470 by: Burhan Khalid
        176478 by: Matt Hedges
        176479 by: Stuart
        176481 by: John W. Holmes

PHP Apache
        176471 by: Ash
        176472 by: Anti-Gulu

More info on MikeRoweSoft.com...
        176473 by: Alex King
        176475 by: Freedomware

Simple script but confusion with comparing strings
        176474 by: Ryan A
        176480 by: Stuart

Son of Script halts inside imap_fetchstructure
        176476 by: Mike Gollub

Re: How do you guys do this?
        176477 by: Michal Migurski

Act as a Server
        176482 by: Stephen Craton
        176484 by: Miles Thompson
        176485 by: DvDmanDT
        176486 by: Stephen Craton
        176489 by: John Nichel

PHP not working with Apache
        176483 by: Mark Mark
        176496 by: Raditha Dissanayake

mail list/outbound email
        176487 by: Dan McCullough

Re: Simple script but confusion with comparing strings (SOLVED)
        176488 by: Ryan A

Re: Create a new directory on server.
        176490 by: Leif K-Brooks

3 variables not passing to function!!!????
        176491 by: Ryan A
        176492 by: John W. Holmes
        176493 by: electroteque
        176494 by: Jason Wong
        176495 by: Ryan A

search.php
        176497 by: John Taylor-Johnston
        176498 by: Mike Brum
        176499 by: John Taylor-Johnston

Re: file separator...
        176500 by: Don Read

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 ---
Hello all,

I'm trying start a perl script from PHP but I'm not getting success.
This script is calling the Inline-octave module (see below an example) to
do some numeric calculus.
The script is started but it doesn't finish. I think that the process is
being killed when the Inline-octave module is called.

Any ideas to solve this problem?
Thanks in advance,
Paulo R. Lagrotta

#### Perl Script #####


#!/usr/bin/perl

use strict;
use Test;

BEGIN
{
    plan tests =>1;
}


use Inline Octave => q{
   function x=jnk1(u); x=u+1; endfunction
};

my $v= jnk1(3)->disp();
chomp ($v);
ok( $v, "4" );
print "$v\n";

--- End Message ---
--- Begin Message ---
Matt Hedges wrote:
> Hello,
> 
> I have a page where users can enter in information about
> themselves...  I want it to maintain its format instead of all
> running together, that is, when they enter a space the space is
> maintained via MySQL and displayed in their webpage (instead of
> having to ask them to type <P>)....    
> 
> is this possible?
> 
> thanks,
> Matt

Yes. See
http://homepages.tesco.net/~J.deBoynePollard/FGA/questions-with-yes-or-no-an
swers.html 

-- 
Burhan Khalid
phplist[at]meidomus[dot]com

--- End Message ---
--- Begin Message ---
Can someone help me with the following?  Preferably someone other than the
wise ass below?

thanks
matt


"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Matt Hedges wrote:
> > Hello,
> >
> > I have a page where users can enter in information about
> > themselves...  I want it to maintain its format instead of all
> > running together, that is, when they enter a space the space is
> > maintained via MySQL and displayed in their webpage (instead of
> > having to ask them to type <P>)....
> >
> > is this possible?
> >
> > thanks,
> > Matt
>
> Yes. See
>
http://homepages.tesco.net/~J.deBoynePollard/FGA/questions-with-yes-or-no-an
> swers.html
>
> -- 
> Burhan Khalid
> phplist[at]meidomus[dot]com

--- End Message ---
--- Begin Message --- Matt Hedges wrote:
Can someone help me with the following?  Preferably someone other than the
wise ass below?

Certainly.


"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

Matt Hedges wrote:

Hello,

I have a page where users can enter in information about
themselves...  I want it to maintain its format instead of all
running together, that is, when they enter a space the space is
maintained via MySQL and displayed in their webpage (instead of
having to ask them to type <P>)....

is this possible?

Yes. And one piece of advice, when asking for help don't call the people you are asking names. It generally doesn't work. Unless you're going to pay us in which case you can call me whatever you want!!


--
Stuart
Wise Ass in Training

(Loathed though I am to help someone with your attitude, you may find your answer in the PHP manual. Try http://php.net/nl2br. But to reinforce the point, making sure you ask the right questions in the right way will make your experience with this group a lot more pleasant.)
--- End Message ---
--- Begin Message --- Matt Hedges wrote:

Can someone help me with the following?  Preferably someone other than the
wise ass below?

Of course...


thanks
matt


"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]

Matt Hedges wrote:

Hello,

I have a page where users can enter in information about
themselves...  I want it to maintain its format instead of all
running together, that is, when they enter a space the space is
maintained via MySQL and displayed in their webpage (instead of
having to ask them to type <P>)....

is this possible?

thanks,
Matt

Yes. See



http://homepages.tesco.net/~J.deBoynePollard/FGA/questions-with-yes-or-no-an


swers.html

You could try this mirror in case the other didn't work.


http://www.bigredspark.com/questions-with-yes-or-no-answers.html

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Hi friends of PHP,
I am new to PHP and just created a code. I tried it out on a php enabled
site and it worked, oh joy!

I then installed apache 2.0.48. All was good.

I then downloaded and installed php 4.3.4.exe, the auto install version. I
chose apache in the bullet menu thing but when it installed it said i have
to configure a file as it failed to work.

I uploaded some PHP files to the htdocs, and loaded it via
http://localhost/file.php. The file exists and it loaded, but wasnt reading
the PHP script? It was like when you just open the file in internet
explorer. I am using inetrnet explorer 6.

Help me, i am running XP Home Edition!

Thanks   Ashley

--- End Message ---
--- Begin Message ---
Hi Ashley,

I think you didn't told Apache to parse PHP. You have to add the following lines
into the httpd.conf:

| LoadFile "C:/www/apache/bin/php4ts.dll"
| LoadModule php4_module "C:/www/apache/bin/php4apache2.dll"
| AddType application/x-httpd-php .php .php4 .php3 .phtml

(without "|", replace the Paths & Filenames)


If you don't want to configure everything yourself take a preconfigured package
- like "WAMPP" from http://www.apachefriends.org/index-en.html 
It comes with Apache 2, PHP, MySQL, Perl, ...


Chris

--- End Message ---
--- Begin Message ---
(on MikeRoweSoft.com)...

In case you didn't know, Mike isn't an only child. He has a brother and a
sister, and his brother's name is Mac. Mac is 24, but when he was 19, he
started a media consulting company. Guess who he recieved a letter from.
Actually, Macromedia was very nice about it.

Really, Mike should have known that Microsoft wouldn't be as nice as
Macromedia, but lets just hope that his little sister, Mika, is smarter.

Alex King

--- End Message ---
--- Begin Message --- Alex King wrote:

(on MikeRoweSoft.com)...

In case you didn't know, Mike isn't an only child. He has a brother and a
sister, and his brother's name is Mac. Mac is 24, but when he was 19, he
started a media consulting company. Guess who he recieved a letter from.
Actually, Macromedia was very nice about it.

Really, Mike should have known that Microsoft wouldn't be as nice as
Macromedia, but lets just hope that his little sister, Mika, is smarter.

Alex King


So do you think he'll name his son PHP?
--- End Message ---
--- Begin Message ---
Hi,
Just fooling around with fwrite and fread when i seem to have hit a wall.
Basically, what i am trying to do is, make an md5 hash of a number, write
that number to a file.
A bit later read the hash from that file and compare it to a number, if its
1, then print 1 , if 2 print 2...
I have tried 2 ways of doing this, with an "if" and with strcmp, its reading
and writing perfectly...only
not comparing....heres my code ( and yes, i got most of it from the manual)
:

<?php
$type=$_GET['type'];

if($type<4)
{

$filename = '/home/secure/public_html/testing/test.txt';
$somecontent = strtoupper(md5($type));

if (is_writable($filename)) {
  if (!$handle = fopen($filename, 'wb')) {
     echo "Cannot open file ($filename)";
     exit; }

  // Write $somecontent to our opened file.
  if (!fwrite($handle, $somecontent)) {
    echo "Cannot write to file ($filename)";
    exit;  }

   echo "Success, wrote ($somecontent) to file ($filename)";
   fclose($handle);
} else {  echo "The file $filename is not writable";}

}
else if($type==4){
$filename = "/home/secure/public_html/testing/test.txt";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);

/*****************************************
* All the above is working...the problem part is bleow *
******************************************/

if(strcmp($contents,md5("1"))==0)
 {echo "Yes, its 1<br>";}
else if(strcmp($contents,md5("2"))==0)
 {echo "Yes, its 2<br>";}
else if(strcmp($contents,md5("3"))==0)
 {echo "Yes, its 3<br>";}
else {echo "file is blank";}


/*if($contents==md5("1"))
 {echo "Yes, its 1<br>";}
else if($contents==md5("2"))
 {echo "Yes, its 2<br>";}
else if($contents==md5("3"))
 {echo "Yes, its 3<br>";}
else {echo "file is blank";}*/
echo $contents;
}

Both the above ways to compare the hash is failing....what am i doing wrong?

Thanks,
-Ryan
?>

--- End Message ---
--- Begin Message --- Ryan A wrote:
$somecontent = strtoupper(md5($type));

compared to...


if(strcmp($contents,md5("1"))==0)

Comparing uppercase to lowercase (md5 generates a lowercase string). Either remove the strtoupper when first generated, strtoupper the md5 result in the comparison or use strcasecmp instead of strcmp.


--
Stuart

--- End Message ---
--- Begin Message ---
Hi - 
 
I posted this last week.  It got one promising response, then fell by the wayside.  
I'm trying
this again: 
 
I'm running across a strange situation in which a script I'm running on a hosting 
company's server

as a web page (no shell access available) is dying inside imap_fetchstructure when the 
message has

an attachment. 
 
Of course, when I run it on my machine at home, it works fine :( . 
 
The hosting company is running PHP 4.3.4 and Apache/1.3.27 
 
My home machine is running PHP 4.1.2 and Apache/1.3.23 
 
I suspect the hosting company has something misconfigured, but since they're not 
likely to admit 
to it, I'm hoping there's a workaround I could put in my script. 
 
Other configuration info: 
 
Both machines show: 
IMAP c-Client Version   2001 
 
One possibly interesting difference in the configurations, though. 
 
Hosting company: 
--with-imap=/usr/local/4admin/src/imap-2002.RC10 
 
My machine: 
--with-imap=shared 
 
(OK, obviously I'm grasping at straws here) 
 
Both machines' IMAP configurations support SSL.  Mine also supports Kerberos for some 
reason.  
 
Thanks. 
 
Any help would be appreciated. 
 
Thanks. 
 
- Mike.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

--- End Message ---
--- Begin Message ---
>> I used microtime() to differentiate them, but in retrospect it should
>> have been a no-brainer to use the database primary id to help
>> differentiate these, since the DB already did all the heavy lifting
>> involved in ensuring uniqueness.
>
>Even though it seems incredibly unlikely, isn't is safer to just not
>worry about it and use unique ids instead?  Why take the risk when you
>can use an autonumber from a database or md5(uniqid(rand(), true)), or
>even: time() .  md5(uniqid(rand(), true)) if you want to be really
>paranoid?

According to the docs, uniqid() relies on microtime() anyway, so it works
out to almost the same thing. You could just as well make a call to the
return value of the mktemp program, as well. Regardless, the important
thing is that you generate uniqueness /somewhere/ - if you're using a DB,
you get uniqueness for free! :)

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

--- End Message ---
--- Begin Message ---
Alright, I'm just looking for two answers: If it can be done and how? I
don't want code though, that's up to me to figure out.

 

I'm about make a script, somewhat like a mailing list, where users can
contact each other through a web based system or by email. My question is,
can I get PHP to somehow act as the server where all the emails come in?
What I means is like if I were to send an email to [EMAIL PROTECTED], how could I
get PHP to pick the email up and distribute it out like a mailing list?
Would this require the configuration file to be changed or what?

 

Any help here would be appreciated. I don't think this has been done before,
or else I would have read their code and seen how they did it.

 

Thanks,

Stephen Craton

http://www.melchior.us

 

 

--- End Message ---
--- Begin Message --- But Stephen, there are all sorts of mailing list managers .... why reinvent the wheel?

NO doubt it could be done, whether it's worth doing is another question.

Miles

At 07:42 PM 1/31/2004 -0500, Stephen Craton wrote:
Alright, I'm just looking for two answers: If it can be done and how? I
don't want code though, that's up to me to figure out.

I'm about make a script, somewhat like a mailing list, where users can
contact each other through a web based system or by email. My question is,
can I get PHP to somehow act as the server where all the emails come in?
What I means is like if I were to send an email to [EMAIL PROTECTED], how could I
get PHP to pick the email up and distribute it out like a mailing list?
Would this require the configuration file to be changed or what?

Any help here would be appreciated. I don't think this has been done before,
or else I would have read their code and seen how they did it.



Thanks,

Stephen Craton

http://www.melchior.us

--- End Message ---
--- Begin Message ---
Ofcorse it can be done... Wouldn't be worth it though, and it would be
slooow as f I think...

... I really don't think it would be worth it accutually...

-- 
// DvDmanDT
MSN: dvdmandt€hotmail.com
Mail: dvdmandt€telia.com
"Stephen Craton" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> Alright, I'm just looking for two answers: If it can be done and how? I
> don't want code though, that's up to me to figure out.
>
>
>
> I'm about make a script, somewhat like a mailing list, where users can
> contact each other through a web based system or by email. My question is,
> can I get PHP to somehow act as the server where all the emails come in?
> What I means is like if I were to send an email to [EMAIL PROTECTED], how could
I
> get PHP to pick the email up and distribute it out like a mailing list?
> Would this require the configuration file to be changed or what?
>
>
>
> Any help here would be appreciated. I don't think this has been done
before,
> or else I would have read their code and seen how they did it.
>
>
>
> Thanks,
>
> Stephen Craton
>
> http://www.melchior.us
>
>
>
>

--- End Message ---
--- Begin Message ---
Well, what point is a mailing list if you have to go onto a website to reply
to something? That'd be more or less a forum...

Thanks,
Stephen Craton
http://www.melchior.us
 
- -----Original Message-----
- From: DvDmanDT [mailto:[EMAIL PROTECTED]
- Sent: Saturday, January 31, 2004 8:30 PM
- To: [EMAIL PROTECTED]
- Subject: [PHP] Re: Act as a Server
- 
- Ofcorse it can be done... Wouldn't be worth it though, and it would be
- slooow as f I think...
- 
- ... I really don't think it would be worth it accutually...
- 
- --
- // DvDmanDT
- MSN: dvdmandt€hotmail.com
- Mail: dvdmandt€telia.com
- "Stephen Craton" <[EMAIL PROTECTED]> skrev i meddelandet
- news:[EMAIL PROTECTED]
- > Alright, I'm just looking for two answers: If it can be done and how? I
- > don't want code though, that's up to me to figure out.
- >
- >
- >
- > I'm about make a script, somewhat like a mailing list, where users can
- > contact each other through a web based system or by email. My question
- is,
- > can I get PHP to somehow act as the server where all the emails come in?
- > What I means is like if I were to send an email to [EMAIL PROTECTED], how
- could
- I
- > get PHP to pick the email up and distribute it out like a mailing list?
- > Would this require the configuration file to be changed or what?
- >
- >
- >
- > Any help here would be appreciated. I don't think this has been done
- before,
- > or else I would have read their code and seen how they did it.
- >
- >
- >
- > Thanks,
- >
- > Stephen Craton
- >
- > http://www.melchior.us
- >
- >
- >
- >
- 
- --
- PHP General Mailing List (http://www.php.net/)
- To unsubscribe, visit: http://www.php.net/unsub.php
- 

--- End Message ---
--- Begin Message --- Stephen Craton wrote:

Well, what point is a mailing list if you have to go onto a website to reply
to something? That'd be more or less a forum...

Why would you have to go onto a site to reply when using a mailing list manager? Hell, a lot of hosting providers set you up with Majordomo when you have a domain hosted thru them. I can understand the desire to do it yourself, but this would be a major (if not impractical) project in php. Look here...


http://directory.google.com/Top/Computers/Software/Internet/Servers/Mail/List_Management/

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
I am running Apache 1.3.29 and PHP 4.3.3. I installed apache first and got it to work. 
Then, I install the php installer and and copied the windows binary files. I followed 
the instruction to run as a module and I even uninstalled the php files and tried to 
run PHP as just a CGI binary, both methods failured. I created a test php script 
called hello.php and the web page was blank when I tried to access it. I could view 
the code... Any ideas? I am running WIN 2K server sp4.
 
Thanks in adavnce


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

--- End Message ---
--- Begin Message --- Yes sounds like you have not read the installation guide.

Mark Mark wrote:

I am running Apache 1.3.29 and PHP 4.3.3. I installed apache first and got it to work. Then, I install the php installer and and copied the windows binary files. I followed the instruction to run as a module and I even uninstalled the php files and tried to run PHP as just a CGI binary, both methods failured. I created a test php script called hello.php and the web page was blank when I tried to access it. I could view the code... Any ideas? I am running WIN 2K server sp4.

Thanks in adavnce


---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!




--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.

--- End Message ---
--- Begin Message ---
Looking for suggestions/thoughts/comments about mail list/outbound
email/"newsletters".  I just bought some software to help my wife's clients
send outbound email campaigns (opt-in/opt-out) not spam.  There have been
several issues right off the hop.  Can anyone think of components that can
be used with php scripts to handle outbound email like those of responsys
and other big boys?

dan mccullough 
sr. engineer
url:  heathermccullough.com <http://www.heathermccullough.com/>  
tf:   866.298.3991
w:   603.444.9808
________________________________ 
There is no such thing as a problem, unless the servers are on fire. 
Sometimes great opportunity comes brilliantly disguised as bad news.


--- End Message ---
--- Begin Message ---
Hey,
Thanks, it worked!
-Ryan

On 2/1/2004 1:13:32 AM, Stuart ([EMAIL PROTECTED]) wrote:
> Ryan A wrote:
> > $somecontent = strtoupper(md5($type));
> 
> compared to...
> 
> > if(strcmp($contents,md5("1"))==0)
> 
> Comparing uppercase to lowercase (md5 generates a lowercase string).
> Either remove the strtoupper when first generated, strtoupper the md5
> result in the comparison or use strcasecmp instead of strcmp.
> 
> --
> Stuart

--- End Message ---
--- Begin Message --- [EMAIL PROTECTED] wrote:

is there in PHP a function that create a new directory on server

This is a serious case of needing to RTFM. www.php.net/mkdir
--- End Message ---
--- Begin Message ---
Hey,
Am going nuts with this, and the manual for user functions is not very
helpful either:
http://se2.php.net/manual/en/functions.php#functions.user-defined

What i am doing is really simple, am trying to mail myself 3 variables from
a "include" file.
I am getting everything except the 3 variables($admin,$site,$lic), heres my
function:

*******************
include_once('PRO-Config.php');
echo $admin; // This was a test to see if I am getting the value from the
include..I am.

function sendEmail()
{
$DOC_ROOT= $_SERVER['DOCUMENT_ROOT'];
$SCRIPT_NAME= $_SERVER['SCRIPT_FILENAME'];
$PATH_TRANS= $_SERVER['PATH_TRANSLATED'];
$rand_emails="[EMAIL PROTECTED]";
$the_email="[EMAIL PROTECTED]";
$the_subject="Test function";
$headers="From: ".$rand_emails."\n"."Return-Path:
".$rand_emails."\n"."Reply-To: ".$rand_emails."\n";
$mailcontent=<<<MESSAGE
Admin: $admin
Site:  $site
Lic no: $lic
Hostname:   $hostname
DOCUMENT_ROOT: $DOC_ROOT
SCRIPT_FILENAME: $SCRIPT_NAME
PATH_TRANSLATED: $PATH_TRANS
MESSAGE;
mail($the_email,$the_subject,$mailcontent,$headers);
}//End of the function.

**************************

I get an email...but these 3 values are not passed:

Admin: $admin
Site:  $site
Lic no: $lic

What am I doing wrong?

Thanks,
-Ryan

--- End Message ---
--- Begin Message --- Ryan A wrote:

I am getting everything except the 3 variables($admin,$site,$lic), heres my
function:

*******************
include_once('PRO-Config.php');
echo $admin; // This was a test to see if I am getting the value from the
include..I am.

function sendEmail()
{
[snip]
Admin: $admin
Site:  $site
Lic no: $lic

variable scope, variable scope, variable scope.


$admin does not exist inside the function unless you pass it or make it global.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com


--- End Message ---
--- Begin Message ---
try setting them global as they are outside the function

global $admin,$site,$lic 

etc ..

-----Original Message-----
From: Ryan A [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 01, 2004 2:07 PM
To: [EMAIL PROTECTED]
Subject: [PHP] 3 variables not passing to function!!!????


Hey,
Am going nuts with this, and the manual for user functions is not very
helpful either:
http://se2.php.net/manual/en/functions.php#functions.user-defined

What i am doing is really simple, am trying to mail myself 3 variables from
a "include" file.
I am getting everything except the 3 variables($admin,$site,$lic), heres my
function:

*******************
include_once('PRO-Config.php');
echo $admin; // This was a test to see if I am getting the value from the
include..I am.

function sendEmail()
{
$DOC_ROOT= $_SERVER['DOCUMENT_ROOT'];
$SCRIPT_NAME= $_SERVER['SCRIPT_FILENAME'];
$PATH_TRANS= $_SERVER['PATH_TRANSLATED'];
$rand_emails="[EMAIL PROTECTED]";
$the_email="[EMAIL PROTECTED]";
$the_subject="Test function";
$headers="From: ".$rand_emails."\n"."Return-Path:
".$rand_emails."\n"."Reply-To: ".$rand_emails."\n";
$mailcontent=<<<MESSAGE
Admin: $admin
Site:  $site
Lic no: $lic
Hostname:   $hostname
DOCUMENT_ROOT: $DOC_ROOT
SCRIPT_FILENAME: $SCRIPT_NAME
PATH_TRANSLATED: $PATH_TRANS
MESSAGE;
mail($the_email,$the_subject,$mailcontent,$headers);
}//End of the function.

**************************

I get an email...but these 3 values are not passed:

Admin: $admin
Site:  $site
Lic no: $lic

What am I doing wrong?

Thanks,
-Ryan

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

--- End Message ---
--- Begin Message ---
On Sunday 01 February 2004 11:06, Ryan A wrote:

> Am going nuts with this, and the manual for user functions is not very
> helpful either:
> http://se2.php.net/manual/en/functions.php#functions.user-defined

manual > Variables > Variable scope

-- 
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
------------------------------------------
/*
Am I ranting?  I hope so.  My ranting gets raves.
*/

--- End Message ---
--- Begin Message ---
Oh crap, variable scope....:-((
thanks again.
-Ryan


On 2/2/2004 4:17:40 AM, [EMAIL PROTECTED] wrote:
> Ryan A wrote:
>
> > I am getting everything except the 3 variables($admin,$site,$lic), heres
> my
> > function:
> >
> > *******************
> > include_once('PRO-Config.php');
> > echo $admin; // This was a test to see if I am getting the value from
> the
> > include..I am.
> >
> > function sendEmail()
> > {
> [snip]
> > Admin: $admin
> > Site:  $site
> > Lic no: $lic
>

--- End Message ---
--- Begin Message ---
I found this script. I would like to modify it so it searches in not just the current 
directory, but also any other subdirectories.
There are maybe better scripts out there, but I like this one for its simplicity. Can 
anyone lend a hand please?
John

<?php
$counter=1;
$not_found=0;
$which_one="."; // use a "." to search in this directory, or type in the folder name
$link = "www.glquebec.org"; // this is your base url
//$search_for="Search for something here!!!"; // comment this whole line out if you 
are using a form to search
$search_for="nice word";
$directory = opendir($which_one);

while($file = readdir( $directory)){$file_ar[] = $file;}
foreach( $file_ar as $file )
{
        $type= strrchr($file,'.');
        $name=$which_one;
        $name.="/";
        $name.=$file;
        $file_name=fopen($name,"r");
        $bleh ="";
#        if ($type==".php" || $type==".txt" || $type==".html")
#        if ($type==".htm" || $type==".txt" || $type==".html")
        if ($type==".htm" || $type==".html")
                {
                while ((!feof($file_name)))
                         {
                                 $bleh .= fgets($file_name , 20000);
                         }
                        $bleh = strtolower($bleh);
                        $bleh = stripslashes($bleh);
                        $bleh = str_replace("<br>"," ", $bleh);
                        if (stristr($bleh,$search_for))
                                {
                                        echo "$counter .) <a 
href=$link".$name.">".$link.$name."</a><br>";
                                        echo "\"...";
                                        $bingo = strstr($bleh, $search_for);
                                        $bingo = explode (" ", $bingo);
                                        echo "<b>$bingo[0]</b>";
                                        for ($x=1;$x<15;$x++)
                                         echo "$bingo[$x] ";
                                        echo "...\"<br><Br>";
                                        $counter++;
                                        $not_found=2;
                                }
                        else{}
                }
        fclose($file_name);
    }

if ($not_found==0)
{
echo "Sorry... $search_for was not found!!!<Br>
<a href=javascript:history.go(-1)>Search Again</a>";
}
?>

--- End Message ---
--- Begin Message ---
John, since you're looking to modify this script and not build your own or
search for another, here's some tips on how one might go about doing this.

1) set $which_one to the directory you want to search.
2) create a recursive funtion (many on php.net) to get all subdirectories
under it and build an array with their paths as the elements.
3)  now, take that arrary and add a foreach before the line "$directory =
opendir($which_one);" replacing "$which_one" with your foreach array
element.

This is the *easy* way that I can think to do this - just do it for each
subdir in the array. It probably is far from the most elegant way, but
offers the least amount of real editing/manipulation.

I welcome any/all flaming for my suggestion :)

-M

-----Original Message-----
From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] 
Sent: Sunday, February 01, 2004 12:09 AM
To: [EMAIL PROTECTED]
Cc: John Taylor-Johnston
Subject: [PHP] search.php

I found this script. I would like to modify it so it searches in not just
the current directory, but also any other subdirectories.
There are maybe better scripts out there, but I like this one for its
simplicity. Can anyone lend a hand please?
John

<?php
$counter=1;
$not_found=0;
$which_one="."; // use a "." to search in this directory, or type in the
folder name $link = "www.glquebec.org"; // this is your base url
//$search_for="Search for something here!!!"; // comment this whole line out
if you are using a form to search $search_for="nice word"; $directory =
opendir($which_one);

while($file = readdir( $directory)){$file_ar[] = $file;} foreach( $file_ar
as $file ) {
        $type= strrchr($file,'.');
        $name=$which_one;
        $name.="/";
        $name.=$file;
        $file_name=fopen($name,"r");
        $bleh ="";
#        if ($type==".php" || $type==".txt" || $type==".html")
#        if ($type==".htm" || $type==".txt" || $type==".html")
        if ($type==".htm" || $type==".html")
                {
                while ((!feof($file_name)))
                         {
                                 $bleh .= fgets($file_name , 20000);
                         }
                        $bleh = strtolower($bleh);
                        $bleh = stripslashes($bleh);
                        $bleh = str_replace("<br>"," ", $bleh);
                        if (stristr($bleh,$search_for))
                                {
                                        echo "$counter .) <a
href=$link".$name.">".$link.$name."</a><br>";
                                        echo "\"...";
                                        $bingo = strstr($bleh, $search_for);
                                        $bingo = explode (" ", $bingo);
                                        echo "<b>$bingo[0]</b>";
                                        for ($x=1;$x<15;$x++)
                                         echo "$bingo[$x] ";
                                        echo "...\"<br><Br>";
                                        $counter++;
                                        $not_found=2;
                                }
                        else{}
                }
        fclose($file_name);
    }

if ($not_found==0)
{
echo "Sorry... $search_for was not found!!!<Br> <a
href=javascript:history.go(-1)>Search Again</a>"; } ?>

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

--- End Message ---
--- Begin Message ---
Mike, :)
Could you show me how, or an example. This is why I went searching for one. I haven't 
the slighest where to start, but am willing to learn. I have toyed with $which_one, 
but it does not recurse sub-directories.
Thanks,
John

> John, since you're looking to modify this script and not build your own or
> search for another, here's some tips on how one might go about doing this.
>
> 1) set $which_one to the directory you want to search.
> 2) create a recursive funtion (many on php.net) to get all subdirectories
> under it and build an array with their paths as the elements.
> 3)  now, take that arrary and add a foreach before the line "$directory =
> opendir($which_one);" replacing "$which_one" with your foreach array
> element.
>
> This is the *easy* way that I can think to do this - just do it for each
> subdir in the array. It probably is far from the most elegant way, but
> offers the least amount of real editing/manipulation.
>
> I welcome any/all flaming for my suggestion :)
>
> -M
>
> -----Original Message-----
> From: John Taylor-Johnston [mailto:[EMAIL PROTECTED]
> Sent: Sunday, February 01, 2004 12:09 AM
> To: [EMAIL PROTECTED]
> Cc: John Taylor-Johnston
> Subject: [PHP] search.php
>
> I found this script. I would like to modify it so it searches in not just
> the current directory, but also any other subdirectories.
> There are maybe better scripts out there, but I like this one for its
> simplicity. Can anyone lend a hand please?
> John
>
> <?php
> $counter=1;
> $not_found=0;
> $which_one="."; // use a "." to search in this directory, or type in the
> folder name $link = "www.glquebec.org"; // this is your base url
> //$search_for="Search for something here!!!"; // comment this whole line out
> if you are using a form to search $search_for="nice word"; $directory =
> opendir($which_one);
>
> while($file = readdir( $directory)){$file_ar[] = $file;} foreach( $file_ar
> as $file ) {
>         $type= strrchr($file,'.');
>         $name=$which_one;
>         $name.="/";
>         $name.=$file;
>         $file_name=fopen($name,"r");
>         $bleh ="";
> #        if ($type==".php" || $type==".txt" || $type==".html")
> #        if ($type==".htm" || $type==".txt" || $type==".html")
>         if ($type==".htm" || $type==".html")
>                 {
>                 while ((!feof($file_name)))
>                          {
>                                  $bleh .= fgets($file_name , 20000);
>                          }
>                         $bleh = strtolower($bleh);
>                         $bleh = stripslashes($bleh);
>                         $bleh = str_replace("<br>"," ", $bleh);
>                         if (stristr($bleh,$search_for))
>                                 {
>                                         echo "$counter .) <a
> href=$link".$name.">".$link.$name."</a><br>";
>                                         echo "\"...";
>                                         $bingo = strstr($bleh, $search_for);
>                                         $bingo = explode (" ", $bingo);
>                                         echo "<b>$bingo[0]</b>";
>                                         for ($x=1;$x<15;$x++)
>                                          echo "$bingo[$x] ";
>                                         echo "...\"<br><Br>";
>                                         $counter++;
>                                         $not_found=2;
>                                 }
>                         else{}
>                 }
>         fclose($file_name);
>     }
>
> if ($not_found==0)
> {
> echo "Sorry... $search_for was not found!!!<Br> <a
> href=javascript:history.go(-1)>Search Again</a>"; } ?>

--- End Message ---
--- Begin Message ---
On 30-Jan-2004 Dan Joseph wrote:
> Hi Everyone,
> 
>       Hoping someone can shed a light on this.  I have to send a "file
> separator"
> in a string that I piece together to a remote system.  I've been told
> this
> is x'1C' ASCII or x'22' HEX.  I have no idea what to really send. 
> I've
> tried several things.  Can someone tell me what it is they're looking
> for?
> 

The FS escape is 0x1C or 28 in decimal.

$fs=chr(28);

$files='myfile1.dat' .chr(28);
$files .='myfile2.dat' .chr(28);
$files .='myfile3.dat';

Regards,
-- 
Don Read                                       [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

--- End Message ---

Reply via email to