[PHP] ICQ # validation

2003-03-04 Thread SLanger
 if(ereg(^[0-9]{7,9}$, $_REQUEST[icqnumber])) {
  print(a-okay!);
  } else {
  print(error msg);
  }

Although I'm not too familiar with regexp I'd say the code validates 
because the icq number you are providing actually confimrs to the pattern. 
The first seven to nine digits contain only numbers so the pattern is 
true. Th ce pattern does not check the length of your provided string. 
If I'm correct than 123456789 This is a test will also proof to be 
correct. So you have to do two things first check the whole argument for 
digits like ereg('^[0-9]{'.strlen($_REQUEST['icqnumber']).'}', 
$_REQUEST['icqnumber']) and check length separatly. (U can also use 
[[:digit:]]) Or use the code as mentioned before. 
In your place I would not assume anything about the length of the icq 
number.

Hope that helps
Stefan

P.S.: Please correct me if I'm wrong with the above

[PHP] filesave

2003-03-04 Thread Diksha Neel
dear all,

hi!
i have an html page entry.html in which is
a submit button that connect me to check.php
on clicking it.
but when i click on the validate me button,
i get the file download boxthat asks whether
i want to save the file on disk or open from current
location.
and what i want is that on clicking validate me
button, the check.php should be displayed in internet
explorer.
sending below code for entry.html and check.php.

thanks,
diksha.html
THIS IS ENTRY.HTML
head
meta http-equiv=Content-Language content=en-us
meta http-equiv=Content-Type content=text/html; 
charset=windows-1252
meta name=GENERATOR content=Microsoft FrontPage 4.0
meta name=ProgId content=FrontPage.Editor.Document
titleUser Name/title
/head

body

form method=POST action=check.php
  !--webbot bot=SaveResults
  U-File=\\FORTUNESRV\common\diksha\_private\form_results.txt
  S-Format=TEXT/CSV S-Label-Fields=TRUE --
  pnbsp;/p
  pnbsp;/p
  pnbsp;nbsp;nbsp; User 
Namenbsp;nbsp;nbsp;nbsp;nbsp;nbsp; input type=text 
name=login size=20/p
  pnbsp;nbsp;nbsp; User Password input type=password 
name=pass size=20/p
  
pnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
  a href=regist.htmlSign in/a/p
  pnbsp;nbsp;nbsp; Not registered ?/p
  
pnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
  a href=regist.htmlSign up/a/p
  pnbsp;/p
  pnbsp;/p
  pnbsp;/p
  input type=submit value=validate me
/form
/body
/html

THIS IS CHECK.PHP
?php
 $connection=mysql_connect(localhost,root,)or die(Could 
not connect);
 print Connected successfullybr;
 mysql_select_db(bdoi_change)or die(could not select 
database);

 $query = select * from entry where login='$login' and 
pass='$pass' ;
 $result = mysql_query($query) or die(Query failed);
 $num=mysql_num_rows($result);

 //present results based on validity.
 echo $numbr;
 if($num==1)
  {
   echo PYou are a valid user!br;
  }
 if($num==0)
  {
   echo you are not authorised;
  }
?





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


Re: [PHP] ICQ # validation

2003-03-04 Thread Ales Krajník
Well ...

- the {7,9} means that the previous char/group should repeat 7 to 9 times
...
- ^ means the beginning of the string
- $ means the end of the string

So everything, that validates, is 7 to 9 numbers.

123456789 This is a test won't validate - it contains chars instead of $
(end of string) after [0-9]{7,9} = 7 to 9 numbers.

And yes, you can use something like [[:digit:]] but I must admit I don't use
that much.

Ales

[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
.
  if(ereg(^[0-9]{7,9}$, $_REQUEST[icqnumber])) {
   print(a-okay!);
   } else {
   print(error msg);
   }

 Although I'm not too familiar with regexp I'd say the code validates
 because the icq number you are providing actually confimrs to the pattern.
 The first seven to nine digits contain only numbers so the pattern is
 true. Th ce pattern does not check the length of your provided string.
 If I'm correct than 123456789 This is a test will also proof to be
 correct. So you have to do two things first check the whole argument for
 digits like ereg('^[0-9]{'.strlen($_REQUEST['icqnumber']).'}',
 $_REQUEST['icqnumber']) and check length separatly. (U can also use
 [[:digit:]]) Or use the code as mentioned before.
 In your place I would not assume anything about the length of the icq
 number.

 Hope that helps
 Stefan

 P.S.: Please correct me if I'm wrong with the above



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



[PHP] Is anyone use / evaluate lxp before?

2003-03-04 Thread Patrick LOK
Is anyone use / evaluate lxp before?
How do u comment this product?

rgds
./pl


Re: [PHP] entrycheck

2003-03-04 Thread Hugh Danaher
Add the mysql_error() function to your script and run it again.  Could give
you some hint at what is wrong.

$result = mysql_query($query,$connection) or die(Query
failed.mysql_error());

- Original Message -
From: Diksha Neel [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 03, 2003 10:50 PM
Subject: [PHP] entrycheck


 HI EVERYBODY,

 WHEN I RUN MY PHP SCRIPT TYPED BELOW, I GET 'connected
 successfully
 query failed'.
 i have in bdoi_change database a table called entry with 2
 fields:
 login and pass in which i have put some data.

 can anyone help out?

 regards,
 diksha.

 I HAVE AN HTML FORM BY NAME entry.html the code of
 which is the following:

 form method=POST action=check.php
 User Nameinput type=text name=login
 User Password input type=password name=pass
 input type=submit value=validate me
 /form

 AND THE check.php code is as follows:

 ?php

 $connection=mysql_connect(localhost,root,)or die(Could not
 connect);
 print Connected successfullybr;
 mysql_select_db(bdoi_change)or die(could not select
 database);

 $query = select * from entry where login='$login' and
 pass='$pass' ;
 $result = mysql_query($query,$connection) or die(Query
 failed);
 $num=mysql_num_rows($result);

 //present results based on validity.
 echo $numbr;
 if($num==1)
 {
 echo PYou are a valid user!br;
 }
   if($num==0)
 {
 echo you are not authorised;
 }
 ?





 --
 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



Re: [PHP] query strings

2003-03-04 Thread Sunfire
ok i will try to reword the question for you jason..  and i will also now
that i have a little bit of time post come code too..

i have a form that takes 17 input text fields and 1 textarea field and gives
them to a file called addtolist.php. the addtolist.php file has some error
checking (of course) and a mysql_query that will insert those 18 variables
into a table. now, i added a section of code to that addtolist.php file that
checks to see if a record owned by $company already exists. if not just
insert the new record.. if so then stop and ask the user what he wants to do
with the existing record: modify it (a button) or cancle (a button). if the
user hits the modify button then the file addtolist.php will give all 18
variables from the form to the file called editlist.php where an update
query does the work. the problem is that all the variables transfer fine as
far as im aware of except the last one in the query_string. how would i get
the %20 out of the last variable (which happens to be company name).
here is my code:
//button code
input type=button name=modify value=Modify this record
onclick=window.location='editlist.php?company=$companyname1=$name1name2=$
name2
address1=$address1address2=$address2city=$citystate=$state
zip=$zipac1=$ac1ext1=$ext1num1=$num1
ac2=$ac2ext2=$ext2num2=$num2website=$website
email=$emaildescription=$descriptionflags=$flags
edit_company=$_get[company]
';
onkeypress=window.location='editlist.php?company=$companyname1=$name1name
2=$name2
address1=$address1address2=$address2city=$citystate=$statezip=$zipac1=
$ac1ext1=$ext1num1=$num1
ac2=$ac2ext2=$ext2num2=$num2website=$websiteemail=$emaildescription=$d
escription
flags=$flagsedit_company=$_get[company]
'
//end the button. (sweat that was a lot of code) anyways...
the query in editlist.php that is supposed to make this button work:

//update query that gets the vars from modify button in addtolist.php
?php
include(conf.inc);
mysql_connect($host, $mysqluser, $mysqlpwd);
mysql_select_db($db);
if($query=mysql_query(update members SET Company=\$company\,
Name1='$name1', Name2='$name2', Address1='$address1', Address2='$address2',
City='$city', State='$state', Zip='$zip', AreaCode1='$ac1',
Exchange1='$ext1', Number1='$num1', AreaCode2='$ac2', Exchange2='$ext2',
Number2='$num2', Description='$description', Flags='$flags',
Website='$website', Email='$email' where company='$edit_company' or
'$company')){
//rest of code here
?
hope this helps clear things up...


- Original Message -
From: Jason Paschal [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, March 03, 2003 8:57 PM
Subject: Re: [PHP] query strings


 i think i misinterpreted ur question.
 the value gets passed like that due to url encoding, but when you access
 that query string variable, it won't be there.
 try using the POST method with your form instead if you still have
problems.
   there are also some PHP functions like encode and unencode i think.
 search the php site for them.


 From: Sunfire [EMAIL PROTECTED]
 To: Jason Paschal [EMAIL PROTECTED]
 Subject: Re: [PHP] query strings
 Date: Mon, 3 Mar 2003 18:32:32 -0500
 
 how would you use  post? the stuff is going from a form to the database
but
 a query checks to make sure that record doesnt already exist first...if
it
 does i window comes up with 2 buttons.. a modify button (if you push it
its
 supposed to update the record) and a cancel button (goes back to main
menu)
 if i cant do that how would you use session vars?
 
 
 - Original Message -
 From: Jason Paschal [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, March 03, 2003 3:36 PM
 Subject: Re: [PHP] query strings
 
 
   I think there's a limit on the length of a url or query string,
 something
   like 255 or 256 characters.  If I'm passing a lot of data, or I don't
 know
   how much a user is gonna input but it's possible they can enter a lot,
 then
   i use POST instead of Get.  If a form is not involved, then try saving
 it
 to
   a database and retrieving it, or using session variables.
   Hope this helps!
   Jason
  
  
  
  
  
  
   From: Sunfire [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]
   Subject: [PHP] query strings
   Date: Mon, 3 Mar 2003 15:20:02 -0500
   
   i have a might i say a very very large/long query string i have to
run
 to
   pass variable values from one page to another with a button... the
 button
   works and the query string are passing variables right but at the end
 of
   the
   query string (it passes like 21 variable values) the last variable
 content
   that gets passed gets messed up.. i mean if i have like this:
   page.php?.edit_company=$company
   so lets say company has the value of hi world in it.. the value is
   supposed to be passed with hi world but for some reason i keep
 getting
   hi%20world instead of hi world
   
   any reason for that.. if you need i can post my query string and
button
   code
   
   
   
   
   ---
   Outgoing mail is certified Virus Free.
   Checked by AVG 

[PHP] \n

2003-03-04 Thread John Taylor-Johnston
Nothing fancy. Can't get it to echo ¶

textarea cols=30 rows=5 name=testtextareamary
had
a
little
lamb/textarea

if ($testtextarea)
{
$inputresult = str_replace(\n, '¶'.\n, $testtextarea);
echo textarea cols=30 rows=5 name=testtextarea$inputresult/textarea;
}


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



[PHP] Performance Question

2003-03-04 Thread Patrick Teague
What's the difference in performance between

print( file_get_contents(myfile.html) );

and

include(myfile.html);

is there any particular reason for using one over the other?

Patrick



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



[PHP] Tried: [PHP] \n

2003-03-04 Thread John Taylor-Johnston
I have also tried:
$inputresult = str_replace('\n', '¶\n', $testtextarea);


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



RE: [PHP] \n

2003-03-04 Thread Jon Haworth
Hi John,

 Nothing fancy. Can't get it to echo ¶

Is that a pilcrow sign? If so, have you tried para; instead, like this:

$inputresult = str_replace('\n', 'para;\n', $testtextarea);

Cheers
Jon

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



Re: [PHP] \n

2003-03-04 Thread John Taylor-Johnston
Jon, Anyone,

Paragraph sign actually. I'm filterting some data for MySQL. I need a field delimiter. 
I don't want to use \n. Contents of each field are on a signel line of text.
I have come up with this, unless someone can suggest better:

if ($testtextarea)
{
$inputresult = str_replace(\r, , $testtextarea);
$inputresult = str_replace(\n, ¶\n, $inputresult);
echo textarea cols=30 rows=5 name=testtextarea$inputresult/textarea;
}

Thanks,
John


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



RE: [PHP] Performance Question

2003-03-04 Thread Niklas Lampén
I think that file_get_contents() is quicker, since include() runs what it
gets as normal php code. And that gives you the answer to the other question
as well. :)


Niklas


-Original Message-
From: Patrick Teague [mailto:[EMAIL PROTECTED] 
Sent: 4. maaliskuuta 2003 10:57
To: [EMAIL PROTECTED]
Subject: [PHP] Performance Question


What's the difference in performance between

print( file_get_contents(myfile.html) );

and

include(myfile.html);

is there any particular reason for using one over the other?

Patrick



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

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail. For
more information, connect to http://www.F-Secure.com/

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

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



[PHP] StrPos/stristr

2003-03-04 Thread John Taylor-Johnston
http://www.php.net/manual/en/function.stristr.php
http://www.php.net/manual/en/function.strpos.php

Input from a textarea name=something

I want to scan endless lines of $something. If the First Three characters
of any line begin with au: (case insensitive) I want to filter out that line,
and let $au = that line of text
up to but not including the \n. I was lo0oking at StrPos  stristr.

They don't quite do it do they? Then how do I?

John


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



RE: [PHP] \n

2003-03-04 Thread Niklas Lampén
That should be done like

$inputresult = str_replace(\n, para;\n, $testtextarea);

unless he really wants to output \n, not line change.

?
$foo = lines;
print this is\ntwo $foo;
?

outputs:
this is
two lines

?
$foo = lines;
print 'this is\ntwo lines $foo';
?

outputs:
this is\ntwo $foo

String in enclosed by ' is exact, unlike .


Niklas


-Original Message-
From: Jon Haworth [mailto:[EMAIL PROTECTED] 
Sent: 4. maaliskuuta 2003 11:06
To: '[EMAIL PROTECTED]'
Subject: RE: [PHP] \n


Hi John,

 Nothing fancy. Can't get it to echo ¶

Is that a pilcrow sign? If so, have you tried para; instead, like this:

$inputresult = str_replace('\n', 'para;\n', $testtextarea);

Cheers
Jon

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

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail. For
more information, connect to http://www.F-Secure.com/

###
This message has been scanned by F-Secure Anti-Virus for Internet Mail.
For more information, connect to http://www.F-Secure.com/

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



[PHP] question about smarty

2003-03-04 Thread Sunfire
just wondering... does smarty have to be installed on the server where the
web site or php scripts it makes are going to be ran... or do you just make
the stuff and put on the server like normal php files...




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003


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



[PHP] Re: filesave

2003-03-04 Thread John Taylor-Johnston
It sounds like .php is not enabled on your server?

Diksha Neel wrote:

 dear all,

 hi!
 i have an html page entry.html in which is
 a submit button that connect me to check.php
 on clicking it.
 but when i click on the validate me button,
 i get the file download boxthat asks whether
 i want to save the file on disk or open from current
 location.
 and what i want is that on clicking validate me
 button, the check.php should be displayed in internet
 explorer.

 sending below code for entry.html and check.php.

 thanks,
 diksha.html

 THIS IS ENTRY.HTML
 head
 meta http-equiv=Content-Language content=en-us
 meta http-equiv=Content-Type content=text/html;
 charset=windows-1252
 meta name=GENERATOR content=Microsoft FrontPage 4.0
 meta name=ProgId content=FrontPage.Editor.Document
 titleUser Name/title
 /head

 body

 form method=POST action=check.php
!--webbot bot=SaveResults
U-File=\\FORTUNESRV\common\diksha\_private\form_results.txt
S-Format=TEXT/CSV S-Label-Fields=TRUE --
pnbsp;/p
pnbsp;/p
pnbsp;nbsp;nbsp; User
 Namenbsp;nbsp;nbsp;nbsp;nbsp;nbsp; input type=text
 name=login size=20/p
pnbsp;nbsp;nbsp; User Password input type=password
 name=pass size=20/p

 pnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
a href=regist.htmlSign in/a/p
pnbsp;nbsp;nbsp; Not registered ?/p

 pnbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
a href=regist.htmlSign up/a/p
pnbsp;/p
pnbsp;/p
pnbsp;/p
input type=submit value=validate me
 /form
 /body
 /html

 THIS IS CHECK.PHP
 ?php

   $connection=mysql_connect(localhost,root,)or die(Could
 not connect);
   print Connected successfullybr;
   mysql_select_db(bdoi_change)or die(could not select
 database);

   $query = select * from entry where login='$login' and
 pass='$pass' ;
   $result = mysql_query($query) or die(Query failed);
   $num=mysql_num_rows($result);

   //present results based on validity.
   echo $numbr;
   if($num==1)
{
 echo PYou are a valid user!br;
}
   if($num==0)
{
 echo you are not authorised;
}

 ?

--
John Taylor-Johnston
-
If it's not open-source, it's Murphy's Law.

  ' ' '   Collège de Sherbrooke:
 ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
   - Université de Sherbrooke:
  http://compcanlit.ca/
  819-569-2064



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



[PHP] How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Christian Bartels
Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:
 
function foo1($params) { 
  if (is_array($params)) { 
$object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
HERE); 
  } else { 
$object = new foo2($params); 
  } 
} 

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB


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



[PHP] eval challenge

2003-03-04 Thread neko
- define a string that has a function call in it (that returns a string)
that at the time of declaration is not in scope, eg

$str = this is the name : \$node-getName(); // $node is _not_ defined
currently, so we can't escape out



then, later on in the code, this string will be passed to a function that
has $node in scope, and that's when I want to eval the string to replace the
value.

$node = new Node($argwhatever);
eval(\$str=\$str\;); // $node is now in scope, so I'd really like
$node-getName to return something meaningful

Anyone able to solve this one? Yesterday I could achieve most other
requirements with eval, but this one has me stumped.

cheers,
neko



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



[PHP] Downloading files outside the webserver

2003-03-04 Thread Daniel Silva
Hello,

I'm currently working on a multi-user filemanager, on which each user has
its space on the server and can do all the basic file operations we've all
seen.

I've looked all over the net and the manual, but I can't seem to find the
solution for what I want.

The system I'm creating keeps all user files in a folder outside the
webserver, this is to say, any folder the admin defines, such as
/home/john/webusers .

The site shows all files contained in the userdir and lets him manipulate
them. Of course, I want to let the users download their files, but as they
aren't inside the webserver's scope, I just can't simply link to them.

Is there any way I can implement this? To download a file located at X
directory, anywhere in the system? And taking security into consideration,
of course.

Thanks in advance,

Daniel Silva





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



[PHP] Re: How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Patrick Schnegg
Hi

Instead of worrying how to pass the individual parameters to foo2, simply
pass the whole array to it and process it within the function itself. Seems
more logical to me.

Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:

function foo1($params) {
  if (is_array($params)) {
$object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
HERE);
  } else {
$object = new foo2($params);
  }
}

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB




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



AW: [PHP] How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Christian Bartels
Ok, but how do i pass the vars to the second function (foo2)? 
There is not a fixed number of parameters (and so fields in the $params
array).


---
Gruß 
CB

-Ursprüngliche Nachricht-
Von: Jason Paschal [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 4. März 2003 11:03
An: [EMAIL PROTECTED]
Betreff: Re: [PHP] How to use the fields of an array as individual parameter
for a function


there are all sorts of ways to get elements out of arrays. here's one:

if i don't know how many elements are in the array:

$numinarray = count($array);  //gives me the number of elements in array for
($i=0;$i$numinarray;$i++) {
   $element = $array[$i];
   echo $element is in the array.;
}


there's also a for each loop, but the syntax escapes me






From: Christian Bartels [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP] How to use the fields of an array as individual 
parameter
for a function
Date: Tue, 4 Mar 2003 10:52:26 +0100

Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i
want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:

function foo1($params) {
   if (is_array($params)) {
 $object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL
PARAMETERS
HERE);
   } else {
 $object = new foo2($params);
   }
}

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB


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



_
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail



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



AW: [PHP] Re: How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Christian Bartels
Yes, i thought about this already. But it is more work for me to do, 'cause
i would have to rewrite the constructors of several classes.
Anyways i am interested, whether this (pass the elements as variables) is
possible in php.


---
CB

-Ursprüngliche Nachricht-
Von: Patrick Schnegg [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 4. März 2003 11:11
An: [EMAIL PROTECTED]
Betreff: [PHP] Re: How to use the fields of an array as individual parameter
for a function


Hi

Instead of worrying how to pass the individual parameters to foo2, simply
pass the whole array to it and process it within the function itself. Seems
more logical to me.

Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:

function foo1($params) {
  if (is_array($params)) {
$object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
HERE);
  } else {
$object = new foo2($params);
  }
}

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB




-- 
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



Re: [PHP] Re: How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Patrick Schnegg
In this case, I would write a third function that processes the array for
passing it correctly to foo2. In a way that you will end up with something
like this:

$object = new foo2(processArray($params));

Have you thought about that?


Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Yes, i thought about this already. But it is more work for me to do, 'cause
i would have to rewrite the constructors of several classes.
Anyways i am interested, whether this (pass the elements as variables) is
possible in php.


---
CB

-Ursprüngliche Nachricht-
Von: Patrick Schnegg [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 4. März 2003 11:11
An: [EMAIL PROTECTED]
Betreff: [PHP] Re: How to use the fields of an array as individual parameter
for a function


Hi

Instead of worrying how to pass the individual parameters to foo2, simply
pass the whole array to it and process it within the function itself. Seems
more logical to me.

Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:

function foo1($params) {
  if (is_array($params)) {
$object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
HERE);
  } else {
$object = new foo2($params);
  }
}

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB




--
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



Re: [PHP] How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Tom Rogers
Hi,

Tuesday, March 4, 2003, 7:52:26 PM, you wrote:
CB Hello!

CB I'm new here on the list. I hope you can help me! :)

CB I have a function foo1 which has a parameter $params. In the function i want
CB to pass $params to another function foo2. if $params is an array the
CB elements should be passed to foo2 as individual parameters. Is this
CB possible? How do i do that?

CB Example:
 
CB function foo1($params) { 
CB   if (is_array($params)) { 
CB $object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
CB HERE); 
CB   } else { 
CB $object = new foo2($params); 
CB   } 
CB } 

CB So when this is called:
CB foo1(array('blue', 'red', 'green'));

CB In foo1 foo2 should be called like this:
CB foo2('blue', 'red', 'green');

CB Is this possible?

CB Thanks for any help!

CB (sorry about my english ;-))

CB ---
CB CB


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

You could use eval, something like this:

$num = count($params);
$vars = '$subject = new foo2(';
if($num  0) {
  $i = 0;
  foreach($params as $var){
$vars .= ($i  0)? ',':'';
$vars .= (is_string($var))? '.$var.' : $var;
$i ++;
  }
}
$vars .= ');';
eval($vars);

untested but is similar to something I use as a class loader with
unknown number of variables to pass.
-- 
regards,
Tom


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



AW: [PHP] Re: How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Christian Bartels
Sure. But how do i return the array elements of $params as individual
parameters from processArray?
Any code? Would be great.


---
CB

-Ursprüngliche Nachricht-
Von: Patrick Schnegg [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 4. März 2003 11:40
An: [EMAIL PROTECTED]
Betreff: Re: [PHP] Re: How to use the fields of an array as individual
parameter for a function


In this case, I would write a third function that processes the array for
passing it correctly to foo2. In a way that you will end up with something
like this:

$object = new foo2(processArray($params));

Have you thought about that?


Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Yes, i thought about this already. But it is more work for me to do, 'cause
i would have to rewrite the constructors of several classes. Anyways i am
interested, whether this (pass the elements as variables) is possible in
php.


---
CB

-Ursprüngliche Nachricht-
Von: Patrick Schnegg [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 4. März 2003 11:11
An: [EMAIL PROTECTED]
Betreff: [PHP] Re: How to use the fields of an array as individual parameter
for a function


Hi

Instead of worrying how to pass the individual parameters to foo2, simply
pass the whole array to it and process it within the function itself. Seems
more logical to me.

Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:

function foo1($params) {
  if (is_array($params)) {
$object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
HERE);
  } else {
$object = new foo2($params);
  }
}

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB




--
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



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



AW: [PHP] How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Christian Bartels
Mh...i need this for a class loader.
Could you post your class loader? (i do not want to invent the wheel again)
Thanks!


---
Gruß 
CB

-Ursprüngliche Nachricht-
Von: Tom Rogers [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 4. März 2003 11:49
An: Christian Bartels
Cc: [EMAIL PROTECTED]
Betreff: Re: [PHP] How to use the fields of an array as individual parameter
for a function


Hi,

Tuesday, March 4, 2003, 7:52:26 PM, you wrote:
CB Hello!

CB I'm new here on the list. I hope you can help me! :)

CB I have a function foo1 which has a parameter $params. In the 
CB function i want to pass $params to another function foo2. if $params 
CB is an array the elements should be passed to foo2 as individual 
CB parameters. Is this possible? How do i do that?

CB Example:
 
CB function foo1($params) { 
CB   if (is_array($params)) { 
CB $object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL 
CB PARAMETERS
CB HERE); 
CB   } else { 
CB $object = new foo2($params); 
CB   } 
CB } 

CB So when this is called:
CB foo1(array('blue', 'red', 'green'));

CB In foo1 foo2 should be called like this:
CB foo2('blue', 'red', 'green');

CB Is this possible?

CB Thanks for any help!

CB (sorry about my english ;-))

CB ---
CB CB


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

You could use eval, something like this:

$num = count($params);
$vars = '$subject = new foo2(';
if($num  0) {
  $i = 0;
  foreach($params as $var){
$vars .= ($i  0)? ',':'';
$vars .= (is_string($var))? '.$var.' : $var;
$i ++;
  }
}
$vars .= ');';
eval($vars);

untested but is similar to something I use as a class loader with unknown
number of variables to pass.
-- 
regards,
Tom



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



Re: [PHP] eval challenge

2003-03-04 Thread Dan Hardiker
 - define a string that has a function call in it (that returns a string)
 that at the time of declaration is not in scope, eg

 $str = this is the name : \$node-getName(); // $node is _not_ defined
 currently, so we can't escape out

Ya have 2 options really (from my perspective):

1. Place in jump out's

If you know your evaling routine is using 's then use them to break out of
the parser. Firstly - this is bad coding - as if you can break out, then
so can the rest of the data in the string. If you insist on this method,
on any external data check for the break out char and escape it -
otherwise you have a major security hole.

$str = text here '.\$node-getName().'more text maybe;
eval(\$str = '$str';);

NOTE: there is no ' at the start or end of the string - this is important.

2. Build a string parser and use tagging... easiest done in XML imho

$str = some text here exec$node-getName()/exec;
Then go through the string before the eval executing everything between
exec tags (be security concious for heavens sake - can be dangerous if not
strictly checked) and replace the command with the response.

I can provide sample code for either options ... but would rather not mock
up a test bed if its not gonna get used ;)

PS: Im guessing your building dynamic templates ... have you had a look
into smarty? http://smarty.php.net/


-- 
Dan Hardiker [EMAIL PROTECTED]
ADAM Software  Systems Engineer
First Creative



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



AW: [PHP] How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Christian Bartels
Mh...this works great!
Thanks a lot!


---
Gruß 
CB

-Ursprüngliche Nachricht-
Von: Tom Rogers [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 4. März 2003 11:49
An: Christian Bartels
Cc: [EMAIL PROTECTED]
Betreff: Re: [PHP] How to use the fields of an array as individual parameter
for a function


Hi,

Tuesday, March 4, 2003, 7:52:26 PM, you wrote:
CB Hello!

CB I'm new here on the list. I hope you can help me! :)

CB I have a function foo1 which has a parameter $params. In the 
CB function i want to pass $params to another function foo2. if $params 
CB is an array the elements should be passed to foo2 as individual 
CB parameters. Is this possible? How do i do that?

CB Example:
 
CB function foo1($params) { 
CB   if (is_array($params)) { 
CB $object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL 
CB PARAMETERS
CB HERE); 
CB   } else { 
CB $object = new foo2($params); 
CB   } 
CB } 

CB So when this is called:
CB foo1(array('blue', 'red', 'green'));

CB In foo1 foo2 should be called like this:
CB foo2('blue', 'red', 'green');

CB Is this possible?

CB Thanks for any help!

CB (sorry about my english ;-))

CB ---
CB CB


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

You could use eval, something like this:

$num = count($params);
$vars = '$subject = new foo2(';
if($num  0) {
  $i = 0;
  foreach($params as $var){
$vars .= ($i  0)? ',':'';
$vars .= (is_string($var))? '.$var.' : $var;
$i ++;
  }
}
$vars .= ');';
eval($vars);

untested but is similar to something I use as a class loader with unknown
number of variables to pass.
-- 
regards,
Tom



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



RE: [PHP] question about smarty

2003-03-04 Thread Rich Gray
 just wondering... does smarty have to be installed on the server where the
 web site or php scripts it makes are going to be ran... or do you
 just make
 the stuff and put on the server like normal php files...

No, the Smarty classes and plugins will have to be installed/accessible on
the target server. It can be outside the document root though if it bothers
you...

HTH
Rich


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



Re: [PHP] eval challenge

2003-03-04 Thread neko
Thanks for your time, Dan.

Currently, I'm using defined tags for replacing info from my CMS, eg:

$str = ofa-core:siteMapLink/

Then I have a function that has all the objects in scope, and can perform
the necessary replacements.

I am prototyping some stuff with smarty, but so far have yet to see how it
benefits over my current implementation. I don't have to to worry about
non-technical persons building/maintaining the site, so I'd rather stick
with include() to build my pages from templates/blocks/content.

As I learn more about smarty, I might use it to power the presentation layer
of my CMS, but only when I can see a long-term benefit from using it. My cms
makes use of presentation logic components, which you supply microtemplates
to  in order to produce the final output. These components can reside within
templates, so currently my html redundancy is minimal.

cheers,
neko



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



Re: AW: [PHP] How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Tom Rogers
Hi,

Tuesday, March 4, 2003, 8:53:25 PM, you wrote:
CB Mh...i need this for a class loader.
CB Could you post your class loader? (i do not want to invent the wheel again)
CB Thanks!

This works for me to load modules in a base class so adapt it as you
need.

?
class loaderClass {
var $class_dir;
var $classes;
function loaderClass($class_dir=''){
//you will need to repace $_SERVER['PHPINCDIR'] with your default inc 
dir as this is not a normal
// $_SERVER variable :)
$class_dir = (empty($class_dir))? $_SERVER['PHPINCDIR'] :$class_dir;
$class_dir .= (substr($class_dir,-1) == '/')? '':'/'; // need an 
ending slash
$this-class_dir = $class_dir;
}
// This searches the  class_dir set in constructor then
//php.ini path for the class to load
//All my classess are .inc
function setPath($class){
$r = false;
//first check with this path
$file = $this-class_dir.$class.'.inc';
if(!file_exists($file)){
$paths = split(':',ini_get('include_path'));
$found = false;
while(!$found  list($key,$val) = each($paths)){
$sep = (PHP_OS == 'Windows')? '\\':'/';
$file = $val.$sep.$class.'.inc';
if($found = file_exists($file)){
$r = $file;
}
}
}else{
$r = $file;
}
return $r;
}
//$name is used to id the loaded class
function load($class,$name){
$r = False;
if(isset($this-classes[$name])){
$r = $this-classes[$name];
}else{
if($file = $this-setPath($class)){
$vars = '$this-classes[$name] = new '.$class.'(';
$num_args = func_num_args();
if($num_args  2) {
$arg_list = func_get_args();
for ($i = 2; $i  $num_args; $i++) {
$vars .= ($i  2)? ',':'';
$vars .= (is_string($arg_list[$i]))? 
'.$arg_list[$i].' : $arg_list[$i];
}
}
$vars .= ');';
include_once($file);
eval($vars);
$r = $this-classes[$name];
}
}
return $r;
}
function isLoaded($name) {
$r = False;
if(isset($this-classes[$name])){
$r = $this-classes[$name];
}
return $r;
}
}

//usage for class foo2 called foo2Class in foo2Class.inc
include('loaderClass.inc');
class foo {
var $loader;
var $foo2;
function foo(){
this-loader = new loaderClass('path_to_modules'); 
}
function load($var1,$var2,$var3){
$this-foo2 = 
$this-loader-load('foo2Class','foo2',$var1,$var2,$var3)
}
}

$f = new foo();
$f-load('Hello',2,3)



-- 
regards,
Tom


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



[PHP] Re: How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Dimitris Kossikidis
I suppose that argc  argv variables should be supported in future releases
of php.
At this time only cgi php supports this feature. Am i wrong?

Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:

function foo1($params) {
  if (is_array($params)) {
$object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
HERE);
  } else {
$object = new foo2($params);
  }
}

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB



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



Re: [PHP] eval challenge

2003-03-04 Thread Dan Hardiker
 Currently, I'm using defined tags for replacing info from my CMS, eg:

 $str = ofa-core:siteMapLink/

 Then I have a function that has all the objects in scope, and can
 perform the necessary replacements.

ok ... what would ofa-core:siteMapLink/ represent?
The output of $ofa-core-siteMapLink();?

If your using XML throughout - have you looked at XSLT transformations?


-- 
Dan Hardiker [EMAIL PROTECTED]
ADAM Software  Systems Engineer
First Creative



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



AW: [PHP] Re: How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Christian Bartels
Well, Tom Rogers already posted this solution and it works great:

  $num = count($params);
$vars = '$object = new foo2(';
if($num  0) {
  $i = 0;
  foreach($params as $var){
$vars .= ($i  0)? ',':'';
$vars .= (is_string($var))? '.$var.' : $var;
$i ++;
  }
}
$vars .= ');';

eval($vars);


---
Gruß 
CB

-Ursprüngliche Nachricht-
Von: Dimitris Kossikidis [mailto:[EMAIL PROTECTED] 
Gesendet: Dienstag, 4. März 2003 12:18
An: [EMAIL PROTECTED]
Betreff: [PHP] Re: How to use the fields of an array as individual parameter
for a function


I suppose that argc  argv variables should be supported in future releases
of php. At this time only cgi php supports this feature. Am i wrong?

Christian Bartels [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello!

I'm new here on the list. I hope you can help me! :)

I have a function foo1 which has a parameter $params. In the function i want
to pass $params to another function foo2. if $params is an array the
elements should be passed to foo2 as individual parameters. Is this
possible? How do i do that?

Example:

function foo1($params) {
  if (is_array($params)) {
$object = new foo2(GET THE ELEMENTS OF $params AS INDIVIDUAL PARAMETERS
HERE);
  } else {
$object = new foo2($params);
  }
}

So when this is called:
foo1(array('blue', 'red', 'green'));

In foo1 foo2 should be called like this:
foo2('blue', 'red', 'green');

Is this possible?

Thanks for any help!

(sorry about my english ;-))

---
CB



-- 
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



Re: [PHP] ICQ # validation

2003-03-04 Thread Hans Prins
Also, don't forget to escape the $ character in your expression, since it is
reserved for variable declaration.


Ales KrajníK [EMAIL PROTECTED] schreef in bericht
news:[EMAIL PROTECTED]
 Well ...

 - the {7,9} means that the previous char/group should repeat 7 to 9 times
 ...
 - ^ means the beginning of the string
 - $ means the end of the string

 So everything, that validates, is 7 to 9 numbers.

 123456789 This is a test won't validate - it contains chars instead of $
 (end of string) after [0-9]{7,9} = 7 to 9 numbers.

 And yes, you can use something like [[:digit:]] but I must admit I don't
use
 that much.

 Ales

 [EMAIL PROTECTED] wrote in message

news:[EMAIL PROTECTED]
 .
   if(ereg(^[0-9]{7,9}$, $_REQUEST[icqnumber])) {
print(a-okay!);
} else {
print(error msg);
}
 
  Although I'm not too familiar with regexp I'd say the code validates
  because the icq number you are providing actually confimrs to the
pattern.
  The first seven to nine digits contain only numbers so the pattern is
  true. Th ce pattern does not check the length of your provided string.
  If I'm correct than 123456789 This is a test will also proof to be
  correct. So you have to do two things first check the whole argument for
  digits like ereg('^[0-9]{'.strlen($_REQUEST['icqnumber']).'}',
  $_REQUEST['icqnumber']) and check length separatly. (U can also use
  [[:digit:]]) Or use the code as mentioned before.
  In your place I would not assume anything about the length of the icq
  number.
 
  Hope that helps
  Stefan
 
  P.S.: Please correct me if I'm wrong with the above





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



[PHP] Re: question about smarty

2003-03-04 Thread David Eisenhart
You just put the smarty files on the server like you would load up your php
files.

Note that a common gotcha is when safe mode is enabled on the server -
smarty will not ,by default, run in this case; the resolution is simple and
is explained in the smarty manual.

David Eisenhart


Sunfire [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 just wondering... does smarty have to be installed on the server where the
 web site or php scripts it makes are going to be ran... or do you just
make
 the stuff and put on the server like normal php files...




 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003








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



Re: [PHP] eval challenge

2003-03-04 Thread neko
 ok ... what would ofa-core:siteMapLink/ represent?
 The output of $ofa-core-siteMapLink();?

 If your using XML throughout - have you looked at XSLT transformations?

It's just a symbolic name - the output is created from a few different
objects within the CMS, but it was such a commonly used set of data requests
that I make a tag up to handle them all at once, to make it a bit cleaner.

XSL/XSLT is on my to prototype list ;)

neko



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



Re: [PHP] Getting Numerical Index of a Key

2003-03-04 Thread Justin French
on 04/03/03 5:47 PM, Matt Honeycutt ([EMAIL PROTECTED]) wrote:

 I'm just going to spend the extra 5 minutes and rewrite that little
 chunk of code.

Sounds like the right move :)

Justin


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



Re: [PHP] Keeping existing data in textarea's

2003-03-04 Thread Justin French
Here's a quick sample of how you can structure a form, and all it's
validation, and all it's error messages, and thankyou notes all onto one
script.

I haven't included every little line and data check that I should (otherwise
you'd have to pay me :P), but it works.

The beauty of keeping it all in one script is that you can echo the POSTed
variables back out into the form, with an error message.

This should be a suitable framework for you to further develop into your own
application.



?
// uncomment next 3 lines if register globals off
// $name = $_POST['name'];
// $email = $_POST['email'];
// $action = $_GET['action'];


if(empty($action))
{
$show_form = 1;
}
else
{
$show_form = 0;
}


if($action == validate)
{
$error = '';

// check for empty vars
if(empty($name)) { $error .= - you didn't enter your namebr /; }
if(empty($email)) { $error .= - you didn't enter your emailbr /; }

// perform any other validation as needed

if($error)
{
$show_form = 1;
}
else
{
// insert into database, send email, redirect or whatever
header(Location: {$_SERVER['PHP_SELF']}?action=thanks);
exit;
}
}

?
html
body
?
if($show_form)
{
if($error)
{
echo {$error}br /;
}
echo form action='{$_SERVER['PHP_SELF']}?action=validate'
method='POST'\n;
echo Name: input type='text' name='name' value='{$name}' /br /;
echo Email: input type='text' name='email' value='{$email}' /br /;
echo input type='submit' name='submit' value='submit' /br /;
echo /form;
}

if($action == thanks)
{
echo thanks!!!;
}
?
/body
/html


Justin French


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



Re: [PHP] Downloading files outside the webserver

2003-03-04 Thread Marek Kilimajer
create a download php file:

?php

$res=mysql_query(select * from user_files where filename='$GET['file']');

if($res  mysql_num_rows($res)) {
   $file=mysql_fetch_assoc($res);
   if($_GET['downaload']) {
   header('Content-Type: application/octet-stream');
   header('Content-disposition: attachment; 
filename='.basename($file['filename']));
   } else {
   header('Content-Type: '.$file['mimetype']);
   header('Content-disposition: attachment; 
filename='.basename($file['filename']));
   }
   header('Content-Length: '.filesize($file['filename']));
   readfile($file['filename']);
} else {
   echo 'no such file';
}
?

Then create a link:
a href=file.php?filename=path/fileview/a
a href=file.php?filename=path/fileamp;download=1download/a
This example assumes you have a table user_files, where you store 
uploaded files with their mime types, this is a security check

Daniel Silva wrote:

Hello,

I'm currently working on a multi-user filemanager, on which each user has
its space on the server and can do all the basic file operations we've all
seen.
I've looked all over the net and the manual, but I can't seem to find the
solution for what I want.
The system I'm creating keeps all user files in a folder outside the
webserver, this is to say, any folder the admin defines, such as
/home/john/webusers .
The site shows all files contained in the userdir and lets him manipulate
them. Of course, I want to let the users download their files, but as they
aren't inside the webserver's scope, I just can't simply link to them.
Is there any way I can implement this? To download a file located at X
directory, anywhere in the system? And taking security into consideration,
of course.
Thanks in advance,

Daniel Silva





 



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


Re: [PHP] StrPos/stristr

2003-03-04 Thread Marek Kilimajer
$lines=explode(\n,$something);

foreach($lines as $line) {
   if(eregi('^au: (.*)$',$line,$m)) {
   $au=$m[1];
   // you may want to break here
   }
}
John Taylor-Johnston wrote:

http://www.php.net/manual/en/function.stristr.php
http://www.php.net/manual/en/function.strpos.php
Input from a textarea name=something

I want to scan endless lines of $something. If the First Three characters
of any line begin with au: (case insensitive) I want to filter out that line,
and let $au = that line of text
up to but not including the \n. I was lo0oking at StrPos  stristr.
They don't quite do it do they? Then how do I?

John

 



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


Re: [PHP] Downloading files outside the webserver

2003-03-04 Thread Daniel Silva
That is a very nice solution, the problem is, the files are stored on disk,
not on the DB. I suppose it can be addapted to work with the disk, can't it?

Cheers,

Daniel


Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 create a download php file:

 ?php

 $res=mysql_query(select * from user_files where
filename='$GET['file']');

 if($res  mysql_num_rows($res)) {
 $file=mysql_fetch_assoc($res);
 if($_GET['downaload']) {
 header('Content-Type: application/octet-stream');
 header('Content-disposition: attachment;
 filename='.basename($file['filename']));
 } else {
 header('Content-Type: '.$file['mimetype']);
 header('Content-disposition: attachment;
 filename='.basename($file['filename']));
 }
 header('Content-Length: '.filesize($file['filename']));
 readfile($file['filename']);
 } else {
 echo 'no such file';
 }
 ?

 Then create a link:
 a href=file.php?filename=path/fileview/a
 a href=file.php?filename=path/fileamp;download=1download/a

 This example assumes you have a table user_files, where you store
 uploaded files with their mime types, this is a security check

 Daniel Silva wrote:

 Hello,
 
 I'm currently working on a multi-user filemanager, on which each user has
 its space on the server and can do all the basic file operations we've
all
 seen.
 
 I've looked all over the net and the manual, but I can't seem to find the
 solution for what I want.
 
 The system I'm creating keeps all user files in a folder outside the
 webserver, this is to say, any folder the admin defines, such as
 /home/john/webusers .
 
 The site shows all files contained in the userdir and lets him manipulate
 them. Of course, I want to let the users download their files, but as
they
 aren't inside the webserver's scope, I just can't simply link to them.
 
 Is there any way I can implement this? To download a file located at X
 directory, anywhere in the system? And taking security into
consideration,
 of course.
 
 Thanks in advance,
 
 Daniel Silva
 
 
 
 
 
 
 




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



Re: [PHP] Using PHP to Generate a CSS Style Sheet

2003-03-04 Thread Justin French
on 04/03/03 5:37 PM, Phillip S. Baker ([EMAIL PROTECTED]) wrote:

 I would like to use PHP to make calls from a DB and generate a CSS file.
 Anyone have any ideas on doing this?

every day :)

PHP is some kind of programming language which is PARSED by PHP.  The result
is a TEXT FILE of some description... yes, even a CSS file.

How to do it depends entirely on your database structure and what you want
to achieve.

But a quick example:
---
?
$textColour = 'FF9900'; // a var you retrieved from a DB
$bgColour = 'white';// a var you retrieved from a DB
?
P { color: #?=$textColour?; }
BODY { background-color: #?=$bgColour?; }
---


 Will php commands executre from a .css file or is there a different way to
 do this??

.css files will not *automatically* be parsed by PHP, however you can force
them through with either a .htaccess file, or by editing apache's httpd.conf
file to suit.

this is my .htaccess file:

Files dynamic.css
ForceType application/x-httpd-php
/Files


Or, you can just include() some CSS generated by PHP directly into your PHP
application, and it will just appear as part of the HTML source.


Justin French


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



[PHP] mail() function

2003-03-04 Thread Denis L. Menezes
Hello friends,

Can the mail() function send emails to multiple addresses which are formatted as 
follows :

[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED] etc with a comma or a semicolon 
between them?

Thanks
Denis



Re: [PHP] Downloading files outside the webserver

2003-03-04 Thread Marek Kilimajer
Yes, sure, but you many times won't know the mime type and might be 
forced to use application/octet-stream.
You can do
if(dirname(realpath($user_files_dir . $_GET['filename'])) == 
$user_files_dir)
as a security check

Daniel Silva wrote:

That is a very nice solution, the problem is, the files are stored on disk,
not on the DB. I suppose it can be addapted to work with the disk, can't it?
Cheers,

Daniel

Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 

create a download php file:

?php

$res=mysql_query(select * from user_files where
   

filename='$GET['file']');
 

if($res  mysql_num_rows($res)) {
   $file=mysql_fetch_assoc($res);
   if($_GET['downaload']) {
   header('Content-Type: application/octet-stream');
   header('Content-disposition: attachment;
filename='.basename($file['filename']));
   } else {
   header('Content-Type: '.$file['mimetype']);
   header('Content-disposition: attachment;
filename='.basename($file['filename']));
   }
   header('Content-Length: '.filesize($file['filename']));
   readfile($file['filename']);
} else {
   echo 'no such file';
}
?
Then create a link:
a href=file.php?filename=path/fileview/a
a href=file.php?filename=path/fileamp;download=1download/a
This example assumes you have a table user_files, where you store
uploaded files with their mime types, this is a security check
Daniel Silva wrote:

   

Hello,

I'm currently working on a multi-user filemanager, on which each user has
its space on the server and can do all the basic file operations we've
 

all
 

seen.

I've looked all over the net and the manual, but I can't seem to find the
solution for what I want.
The system I'm creating keeps all user files in a folder outside the
webserver, this is to say, any folder the admin defines, such as
/home/john/webusers .
The site shows all files contained in the userdir and lets him manipulate
them. Of course, I want to let the users download their files, but as
 

they
 

aren't inside the webserver's scope, I just can't simply link to them.

Is there any way I can implement this? To download a file located at X
directory, anywhere in the system? And taking security into
 

consideration,
 

of course.

Thanks in advance,

Daniel Silva







 



 



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


Re: [PHP] pharse file random work with -n lines

2003-03-04 Thread Marek Kilimajer
while(list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei, $vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = fgetcsv ($fp,5,\|) {

	// here you can do what you need to do

}

are you sure you want \| and not |?

WebDev wrote:

how can you return this randomized? 

how can I get every time I call this function a random set of lines ?

Working Code to read 10 first lines and split the individual line into info 
careeners and do something with it 

$i = 0;
$fp = fopen (../../../../../public/httpd/html/datacontainer/data/storage.data, r);
while (!feof ($fp)  $i  10) {
$i++;
   $buffer = fgets($fp, 4096);
   list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei, $vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split (\|, $buffer);
   
\\ do something
}
fclose ($fp);





 



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


[PHP] Re: mail() function

2003-03-04 Thread Patrick Schnegg
The mail() function will only send one mail at a time, to send multiple
mails you would write a loop like this (presuming you had your mail
addresses ready in an array called $emails):

foreach ($emails as $email) {
mail($email, your subject, your message);
}

Denis L. Menezes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello friends,

Can the mail() function send emails to multiple addresses which are
formatted as follows :

[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED] etc with a
comma or a semicolon between them?

Thanks
Denis





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



Re: AW: [PHP] How to use the fields of an array as individual parameter for a function

2003-03-04 Thread Jason Wong
On Tuesday 04 March 2003 18:24, Christian Bartels wrote:
 Ok, but how do i pass the vars to the second function (foo2)?
 There is not a fixed number of parameters (and so fields in the $params
 array).

You can do something along these lines:


function doo($args) {
  // these are the default values for your args
  $element_name = '';
  $method   = 'post';
  $upload   = FALSE;
  $return   = FALSE;

  if (is_array($args)) {
extract($args);
  }
  // You can also check whether a required parameter was given:
  if (!isset($required_parameter)) { echo Error blah blah blah ...; }

  ... your code

}

-- 
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
--
/*
Those lovable Brits department:
They also have trouble pronouncing `vitamin'.
*/


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



Re: [PHP] Re: mail() function

2003-03-04 Thread Jason Wong
On Tuesday 04 March 2003 21:13, Patrick Schnegg wrote:
 The mail() function will only send one mail at a time, to send multiple
 mails you would write a loop like this (presuming you had your mail
 addresses ready in an array called $emails):

 foreach ($emails as $email) {
 mail($email, your subject, your message);
 }

 Denis L. Menezes [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hello friends,

 Can the mail() function send emails to multiple addresses which are
 formatted as follows :

 [EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED] etc with a
 comma or a semicolon between them?

Denis, Patrick, both of you take a look at the example in the manual.

-- 
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
--
/*
Having the fewest wants, I am nearest to the gods.
-- Socrates
*/


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



[PHP] PHP OOP design question

2003-03-04 Thread Joseph Szobody
I have several web projects that are all database driven. I have recently been diving 
into OOP, and rewriting a lot of procedural code in OOP. I have a design question 
about handling the MySQL connection.

I have a mysql() class which handles all my queries, automatic inserts/updates, etc. 
Just about every other class will use the mysql() class at some point.

Should I

1) Make every class extend mysql(), so that they all have direct access to the db 
functions

2) Create a new mysql object inside of each class.

3) Only create the mysql object at the script level, and pass in the object to the 
other classes.
I.e.:
// Create the db object
$mysql = new mysql();

Now create whatever other objects I need, passing in mysql as an argument.
$job = new job($mysql);

4) Some other idea?

Thanks for any help,

Joseph


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



[PHP] Re: mail() function

2003-03-04 Thread Patrick Schnegg
Just in case you don't know, you can easily make an array out of your string
of emails by exploding using the commas as separators:

$emails = explode (,, $stringOfEmails);

Patrick Schnegg [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 The mail() function will only send one mail at a time, to send multiple
 mails you would write a loop like this (presuming you had your mail
 addresses ready in an array called $emails):

 foreach ($emails as $email) {
 mail($email, your subject, your message);
 }

 Denis L. Menezes [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hello friends,

 Can the mail() function send emails to multiple addresses which are
 formatted as follows :

 [EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED] etc with a
 comma or a semicolon between them?

 Thanks
 Denis







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



Re: [PHP] Re: mail() function

2003-03-04 Thread Patrick Schnegg
Oh, silly me. Commas are indeed accepted. My apologies.

- Original Message - 
From: Jason Wong [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 2:18 PM
Subject: Re: [PHP] Re: mail() function


 On Tuesday 04 March 2003 21:13, Patrick Schnegg wrote:
  The mail() function will only send one mail at a time, to send multiple
  mails you would write a loop like this (presuming you had your mail
  addresses ready in an array called $emails):
 
  foreach ($emails as $email) {
  mail($email, your subject, your message);
  }
 
  Denis L. Menezes [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
  Hello friends,
 
  Can the mail() function send emails to multiple addresses which are
  formatted as follows :
 
  [EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED] etc with a
  comma or a semicolon between them?
 
 Denis, Patrick, both of you take a look at the example in the manual.
 
 -- 
 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
 --
 /*
 Having the fewest wants, I am nearest to the gods.
 -- Socrates
 */
 


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



[PHP] Truncating text

2003-03-04 Thread Sebastian
Good morning all.

I have a mysql query that fetches some text. I am limiting the results to
two (2).

Then i am limiting the text to 30 characters and truncating it with some
 Like this:

if(strlen($title) = 30) {
$title = substr(trim($title),0,30);
$title = $title.'..';
}

But when a $title contains a ! (exclamation point) it only shows one result.
Why is an ! interfering?

Any suggestions?

warm regards,
Sebastian - [BBR] Gaming Clan
http://www.broadbandreports.com


[PHP] Re: Truncating text

2003-03-04 Thread Dimitris Kossikidis
Just run this query avoiding all this php code

SELECT SUBSTRING( MyFieldName, 0, 30 ) FROM MyTable


Substring( fieldname, starting position, length )

Sebastian [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Good morning all.

 I have a mysql query that fetches some text. I am limiting the results to
 two (2).

 Then i am limiting the text to 30 characters and truncating it with some
  Like this:

 if(strlen($title) = 30) {
 $title = substr(trim($title),0,30);
 $title = $title.'..';
 }

 But when a $title contains a ! (exclamation point) it only shows one
result.
 Why is an ! interfering?

 Any suggestions?

 warm regards,
 Sebastian - [BBR] Gaming Clan
 http://www.broadbandreports.com




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



[PHP] Doing a Multiple Search

2003-03-04 Thread Hunter, Jess
I know this must be an easy solution, just not seeing what it is.

I have tried to add several options to the below code but can't seem to get
it right.

Here is the Base Line I am working with:

$Query=SELECT * from $TableName WHERE lastname='$Array[lastname] AND
firstname='$Array[firstname]' ;

What I ant to be able to do is a search on both the lastname and the
firstname so if someone just puts in the last name it will display all
people with the queried last name regardless of the first name.  So for the
visual representation

If I search for Bob Smith, it will give me:

Smith   Bob

If I search by last name Smith, it will give me

Smith Bob
Smith John
Smith Mike


Any and all help would be greatly appreciated.

Thanks in Advance

Jess

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



RE: [PHP] Re: mail() function

2003-03-04 Thread M.A.Bond
Not strictly true, the mail function will send to multiple email addresses
separated by a comma, you can also cc and bcc by using headers. See the
manual, which has some good examples of this.

Mark


-Original Message-
From: Patrick Schnegg [mailto:[EMAIL PROTECTED] 
Sent: 04 March 2003 13:14
To: [EMAIL PROTECTED]
Subject: [PHP] Re: mail() function


The mail() function will only send one mail at a time, to send multiple
mails you would write a loop like this (presuming you had your mail
addresses ready in an array called $emails):

foreach ($emails as $email) {
mail($email, your subject, your message);
}

Denis L. Menezes [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello friends,

Can the mail() function send emails to multiple addresses which are
formatted as follows :

[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED] etc with a
comma or a semicolon between them?

Thanks
Denis





-- 
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



[PHP] Re: PHP OOP design question

2003-03-04 Thread neko
Answer - use PEAR for both your database connection and as a data modeling
layer:

http://pear.php.net

check the documentation for more info.

neko

Joseph Szobody [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I have several web projects that are all database driven. I have recently
been diving into OOP, and rewriting a lot of procedural code in OOP. I have
a design question about handling the MySQL connection.





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



Re: [PHP] Doing a Multiple Search

2003-03-04 Thread Marek Kilimajer
There have been plenty answers for this, search the archives.

Hunter, Jess wrote:

I know this must be an easy solution, just not seeing what it is.

I have tried to add several options to the below code but can't seem to get
it right.
Here is the Base Line I am working with:

$Query=SELECT * from $TableName WHERE lastname='$Array[lastname] AND
firstname='$Array[firstname]' ;
What I ant to be able to do is a search on both the lastname and the
firstname so if someone just puts in the last name it will display all
people with the queried last name regardless of the first name.  So for the
visual representation
If I search for Bob Smith, it will give me:

Smith   Bob

If I search by last name Smith, it will give me

Smith Bob
Smith John
Smith Mike
Any and all help would be greatly appreciated.

Thanks in Advance

Jess

 



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


Re: [PHP] PHP OOP design question

2003-03-04 Thread Ernest E Vogelsinger
At 14:24 04.03.2003, Joseph Szobody spoke out and said:
[snip]
I have several web projects that are all database driven. I have recently 
been diving into OOP, and rewriting a lot of procedural code in OOP. I have 
a design question about handling the MySQL connection.

I have a mysql() class which handles all my queries, automatic 
inserts/updates, etc. Just about every other class will use the mysql() 
class at some point.

Should I

1) Make every class extend mysql(), so that they all have direct access to 
the db functions

I wouldn't do that. First of all this would counterfeit the OOP goodies of
encapsulating the actual implementation, i.e. your MySQL class wouldn't be
the transparent blöackbox it ought to be.

2) Create a new mysql object inside of each class.

That's a better way but you need to manage the database connection to avoid
repeated reconnects... only way if to make it class static.

3) Only create the mysql object at the script level, and pass in the object 
to the other classes.

This would be my choice and is exactly what I'm doing, not only for
database objects but for all other objects I'm using.

This is my approach:

I have a centralized object storage. No global variables, only a couple of
public functions. For example, the function (note: not a method)
pos_getobject returns a reference (!) to any object. If it doesn't exist
it will be created. 
The syntax is:
$hObj = pos_getobject($id);
where $id is the object ID. This ID could be either a constant (e.g.
OBJID_DATABASE), or an ID referencing a database-persistent object. In my
case, object ID's that are negative numbers are predefined objects (e.g.
OBJID_DATABASE), positive numbers are DB persistent objects (simply the
row-ID where the object header can be retrieved), and non-numeric IDs are
temporary objects that may be created at runtime.

If you don't need to take such a general approach I'd create a public
function to retrieve the database object:
$hDB = pos_getDB($dbid);
where $dbid is a database identifier in case you need it.

Just my 2c,

-- 
   O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
^ http://www.vogelsinger.at/


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



Re: [PHP] question about smarty

2003-03-04 Thread Sunfire
k then that wont be able to be a choice for me then... will try maguma
studio then..


- Original Message -
From: Rich Gray [EMAIL PROTECTED]
To: Sunfire [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 5:58 AM
Subject: RE: [PHP] question about smarty


  just wondering... does smarty have to be installed on the server where
the
  web site or php scripts it makes are going to be ran... or do you
  just make
  the stuff and put on the server like normal php files...

 No, the Smarty classes and plugins will have to be installed/accessible on
 the target server. It can be outside the document root though if it
bothers
 you...

 HTH
 Rich




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003


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



Re: [PHP] Splitting up big strings

2003-03-04 Thread Chris Hayes
At 19:17 26-2-03, you wrote:
On Thu, 27 Feb 2003 01:02:54 +0800, Jason Wong wrote:
On Thursday 27 February 2003 00:54, {R}ichard Ashton wrote:
 I have the body ov a Usnet article, all of it, in $body. I want to
 split it into lines.

 I have tried

 $lines = explode( X, $body);

 where I have used

 X = 0x0A
 X = '0x0A'
 X = 0x0D
 X = '0x0A'
 X = \r
X = \r
X = '\r'
X = \n
X = '\n'
I then have

echo pieces $pieces[0] br;
echo pieces $pieces[1] br;
echo pieces $pieces[2] br;
echo pieces $pieces[3] br;
echo pieces $pieces[4] br;
echo pieces $pieces[5] br;
If I look at $body with Hex editor there are lots of 0D 0A pairs and
further if I look at the source of the page generated by
echo $body; I can see the CRLF's
I think 0D0A is \r\n (double quotes!).
Maybe you can start with str_replacing all \r\n and \r with \n so you 
can explode by \n only. Use double quotes for best result.

Chris H.



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


[PHP] using preg_match to extract information from pop3

2003-03-04 Thread Henry Grech-Cini
Hi All,

I know that you will probably tell me to RTFM but I have (several times) and
I cannot quite understand it!

So failing that I turn to you for help.

I know that this is very trivial but please humour me.

I have a line containing From: Henry henry @ .com 
(please ignore any spaces between the angled braces  , they are just to
fool outlook express)

And I want to extract the name and the email address into the variables
$name $email. I suspect using preg_match?

TIA

Henry



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



[PHP] Remember scrolled position

2003-03-04 Thread Lars Espelid
I'm trying to implement the following functionality into the file test.php:

When I scroll down the page and then hit a button, the page should remember
the scrolled position, refresh the page and then scroll down to the
remembered position. If I knew how many form-schemas there would be on the
page, this would be easy. But I don't so then I need a way to give each form
a unike name and this name I need to use in the function hentKoordinat().
But when hentKoordinat is executed the variable containing the form-name is
not yet set.

When someone hits a button in one of the form-schemas the following
happens:
1) hentKoordinat() is executed. The form-schemas hidden field named yKoord
gets the value: the amunt of pixels scrolled in y-direction. This doesn't
work because $teller is not yet set (needed to specify which form is
submitted).
2)the page is refreshed and $teller is set to a number whisch says which
form is submitted and $yKoord is set to the amunt of pixels scrolled in
y-direction.
3)onload in body calls the function mScroll which scrolls the page to where
it was when someone clicked the button.

Hoping someone can help, maybe I need to do this a totally different way?

Thanks!

Lars


Tried to explain the code in test.php:

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
http://www.w3.org/TR/html4/loose.dtd;
html
head
titleUntitled Document/title
script language=JavaScript type=text/javascript
!--

function getPageScroll(){

//this function returns scrollX and scrollY as probertys of
getPageScroll. ScrollX and scrollY
//contains the amount of pixels the page has been scrolled in x and y
direction.

var X, Y;
if(typeof window.pageXOffset == 'number'){
X = window.pageXOffset;
Y = window.pageYOffset;
}else{
if((window.document.compatMode)
  (window.document.compatMode == 'CSS1Compat')){
X = window.document.documentElement.scrollLeft;
Y = window.document.documentElement.scrollTop;
}else{
X = window.document.body.scrollLeft;
Y = window.document.body.scrollTop;
}
}
return {scrollX:X,scrollY:Y};
}
function hentKoordinat() {

// this function uses getPageScroll() to find pixels scrolled in y-direction
and inserts this value into the hidden-form-value named yKoord in the form
schema which holds the button clicked (form?php echo $teller; ?).


 //*Here the problem arises. The first time you click a button, $teller
is not set. This method is executed before the page is refreshed. The value
$teller is set when the page is refreshed.*

document.form?php echo $teller; ?.yKoord.value = getPageScroll().scrollY
}

function mScroll() {

//this function scrolls the page so many pixels that $yKoord holds in the
y-direction.
//to avoid error messages I set $yKoord like 0 if it is empty (scrolls
nothing).

 ?php if(!isset($yKoord)) $yKoord=0; ?
 ?php if($yKoord=='') $yKoord=0; ?
 self.scrollTo(0,?php echo $yKoord; ?)
}

//--
/script
/head

body onLoad=mScroll()
?php echo p Ykoordinat:  . $yKoord . p;
echo Teller:  . $teller;

for($i=0; $i150; $i++) {
//prints 150 line breaks so that the page gets scrollable (the content does
not fit the monitor-area)
 echo 'br';
}
for($teller=0; $teller2; $teller++) {
//prints two form-schemas. Later on I will print a varying amount of
form-schemas (depends on the amunt of
//data in a MySQL-table)
//The form name includes $teller so that each form-schema gets a unike name
and I know which
//$yKoord to update in hentKoordinat(). $teller and $yKoord is passed on as
variables when the page refreshes,
//so that I know which form's button1 is submitted and how many pixels there
are to scroll when onload=mScroll()
// in body is called (uses $yKoord).
?
 form action=test.php name=form?php echo $teller; ? onsubmit=return
hentKoordinat()
  input type=hidden name=teller value=?php echo $teller; ?
  input type=hidden name=yKoord
  input name=button1 type=submit value=Send input
 /form
 ?php $teller++; ?
?php
} //for($teller=0; $i2; $i++) {
?
/body
/html



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



Re: [PHP] Doing a Multiple Search

2003-03-04 Thread Ernest E Vogelsinger
At 14:50 04.03.2003, Hunter, Jess spoke out and said:
[snip]
Here is the Base Line I am working with:

$Query=SELECT * from $TableName WHERE lastname='$Array[lastname] AND
firstname='$Array[firstname]' ;

What I ant to be able to do is a search on both the lastname and the
firstname so if someone just puts in the last name it will display all
people with the queried last name regardless of the first name.  So for the
visual representation
[snip] 

$query = select * from $tablename where  .
 (!empty($array['lastname']) ? lastname = '{$array['lastname']}'  .
(!empty($array['firstname']) ? 'and ' : null) : null) .
 (!empty($array['firstname']) ? firstname =
'{$array['firstname']}' ; null);

Note that you need to put curly braces around an array dereference if you
have it in a quoted string.
This doesn't work:
   $s = Some $array[sample];
But this works:
   $s = Some {$array['sample']};


-- 
   O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
^ http://www.vogelsinger.at/


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



[PHP] CLI Current Directory

2003-03-04 Thread Adam Voigt




Anyone know how you would get the directory a user is in when

they call a command line PHP script (assuming it's on the path)?

Like if I execute prog1 and I'm in /usr, and prog1 is in /usr/local/bin,

getcwd() will return /usr/local/bin instead of /usr, I need to reverse

this behavior.



Anyone?



Thanks.





-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP] CLI Current Directory

2003-03-04 Thread Adam Voigt




Crap, just noticed, execute php with -C and it won't change dir's.



On Tue, 2003-03-04 at 09:26, Adam Voigt wrote:

Anyone know how you would get the directory a user is in when 

they call a command line PHP script (assuming it's on the path)? 

Like if I execute prog1 and I'm in /usr, and prog1 is in /usr/local/bin, 

getcwd() will return /usr/local/bin instead of /usr, I need to reverse 

this behavior. 



Anyone? 



Thanks. 





-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP] question about smarty

2003-03-04 Thread rush
Sunfire [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 k then that wont be able to be a choice for me then... will try maguma
 studio then..

I think you have misunderstood the posting, since Smarty can be used in most
web hosting environments. Anyway if you would like to evaluate other
options, you can also give a shot to the TemplateTamer.

rush
--
http://www.templatetamer.com/




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



[PHP] maguma problems with php 4.3 and apache

2003-03-04 Thread Sunfire
hi..

went and installed maguma that has php 4.3 in it and then went to start
apache up again after setting up the new php.ini file.. and ran into a few
problems.. i keep getting a warning from php:
php warning: cant load dynamic library c:\program
files\maguma\php\extensions\php_dbg.dll a device on your computer isnt
functioning.
i get this error twice when trying to start apache and then it freezes up..
the only place i can find anything about the extensions_dir= variable is in
php.ini so i tried to comment it out and that still didnt work.. i tried
putting  around the dir name and it still doesnt work.. also tried checking
to see if the file existed and it does..

any reason for that and any way to fix it?

tnx



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003


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



Re: [PHP] question about smarty

2003-03-04 Thread Sunfire
sigh well im sort of crashed my web server right now because maguma decided
to mess up a few things with extensions and now dont know how to fix it..

but once i get that fixed i guess i can try smarty and see how that goes..


- Original Message -
From: rush [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 9:35 AM
Subject: Re: [PHP] question about smarty


 Sunfire [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  k then that wont be able to be a choice for me then... will try maguma
  studio then..

 I think you have misunderstood the posting, since Smarty can be used in
most
 web hosting environments. Anyway if you would like to evaluate other
 options, you can also give a shot to the TemplateTamer.

 rush
 --
 http://www.templatetamer.com/




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




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003


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



RE: [PHP] maguma problems with php 4.3 and apache

2003-03-04 Thread Barajas, Arturo
Let's check:

1. Do you have that file? I think that maguma needs it, but I'm not sure, since I 
haven't used it.
2. Do you have the extension_dir pointing to the place where the files should be?

Extracted from php.ini:

; Directory in which the loadable extensions (modules) reside.
extension_dir = C:/php/extensions/

Normally it should be pointing to some dir below the main php installation dir.

In my installation (php 4.2.1), that file doesn't exist. Maybe you could try to find 
it and mess a little more with php.ini.
--
Un gran saludo/Big regards...
   Arturo Barajas, IT/Systems PPG MX (SJDR)
   (427) 271-9918, x448

 -Original Message-
 From: Sunfire [mailto:[EMAIL PROTECTED]
 Sent: Martes, 04 de Marzo de 2003 08:46 a.m.
 To: [EMAIL PROTECTED]
 Subject: [PHP] maguma problems with php 4.3 and apache
 
 
 hi..
 
 went and installed maguma that has php 4.3 in it and then 
 went to start
 apache up again after setting up the new php.ini file.. and 
 ran into a few
 problems.. i keep getting a warning from php:
 php warning: cant load dynamic library c:\program
 files\maguma\php\extensions\php_dbg.dll a device on your 
 computer isnt
 functioning.
 i get this error twice when trying to start apache and then 
 it freezes up..
 the only place i can find anything about the extensions_dir= 
 variable is in
 php.ini so i tried to comment it out and that still didnt 
 work.. i tried
 putting  around the dir name and it still doesnt work.. also 
 tried checking
 to see if the file existed and it does..
 
 any reason for that and any way to fix it?
 
 tnx
 
 
 
 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.458 / Virus Database: 257 - Release Date: 2/24/2003
 
 
 -- 
 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



[PHP] Re: Remember scrolled position

2003-03-04 Thread Patrick Schnegg
I would tend to make this with common html using named anchors. Just enclose
every button with a an anchor and define its name numbering it with php.
Then simply make sure that when the button is pressed that number is
appended to the url so it will look like yourdocument.php?yourdata=blah#5
making the browser jump to the anchor named 5.

Lars Espelid [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm trying to implement the following functionality into the file
test.php:

 When I scroll down the page and then hit a button, the page should
remember
 the scrolled position, refresh the page and then scroll down to the
 remembered position. If I knew how many form-schemas there would be on the
 page, this would be easy. But I don't so then I need a way to give each
form
 a unike name and this name I need to use in the function hentKoordinat().
 But when hentKoordinat is executed the variable containing the form-name
is
 not yet set.

 When someone hits a button in one of the form-schemas the following
 happens:
 1) hentKoordinat() is executed. The form-schemas hidden field named yKoord
 gets the value: the amunt of pixels scrolled in y-direction. This doesn't
 work because $teller is not yet set (needed to specify which form is
 submitted).
 2)the page is refreshed and $teller is set to a number whisch says which
 form is submitted and $yKoord is set to the amunt of pixels scrolled in
 y-direction.
 3)onload in body calls the function mScroll which scrolls the page to
where
 it was when someone clicked the button.

 Hoping someone can help, maybe I need to do this a totally different way?

 Thanks!

 Lars


 Tried to explain the code in test.php:

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 http://www.w3.org/TR/html4/loose.dtd;
 html
 head
 titleUntitled Document/title
 script language=JavaScript type=text/javascript
 !--

 function getPageScroll(){

 //this function returns scrollX and scrollY as probertys of
 getPageScroll. ScrollX and scrollY
 //contains the amount of pixels the page has been scrolled in x and y
 direction.

 var X, Y;
 if(typeof window.pageXOffset == 'number'){
 X = window.pageXOffset;
 Y = window.pageYOffset;
 }else{
 if((window.document.compatMode)
   (window.document.compatMode == 'CSS1Compat')){
 X = window.document.documentElement.scrollLeft;
 Y = window.document.documentElement.scrollTop;
 }else{
 X = window.document.body.scrollLeft;
 Y = window.document.body.scrollTop;
 }
 }
 return {scrollX:X,scrollY:Y};
 }
 function hentKoordinat() {

 // this function uses getPageScroll() to find pixels scrolled in
y-direction
 and inserts this value into the hidden-form-value named yKoord in the
form
 schema which holds the button clicked (form?php echo $teller; ?).


  //*Here the problem arises. The first time you click a button,
$teller
 is not set. This method is executed before the page is refreshed. The
value
 $teller is set when the page is refreshed.*

 document.form?php echo $teller; ?.yKoord.value = getPageScroll().scrollY
 }

 function mScroll() {

 //this function scrolls the page so many pixels that $yKoord holds in the
 y-direction.
 //to avoid error messages I set $yKoord like 0 if it is empty (scrolls
 nothing).

  ?php if(!isset($yKoord)) $yKoord=0; ?
  ?php if($yKoord=='') $yKoord=0; ?
  self.scrollTo(0,?php echo $yKoord; ?)
 }

 //--
 /script
 /head

 body onLoad=mScroll()
 ?php echo p Ykoordinat:  . $yKoord . p;
 echo Teller:  . $teller;

 for($i=0; $i150; $i++) {
 //prints 150 line breaks so that the page gets scrollable (the content
does
 not fit the monitor-area)
  echo 'br';
 }
 for($teller=0; $teller2; $teller++) {
 //prints two form-schemas. Later on I will print a varying amount of
 form-schemas (depends on the amunt of
 //data in a MySQL-table)
 //The form name includes $teller so that each form-schema gets a unike
name
 and I know which
 //$yKoord to update in hentKoordinat(). $teller and $yKoord is passed on
as
 variables when the page refreshes,
 //so that I know which form's button1 is submitted and how many pixels
there
 are to scroll when onload=mScroll()
 // in body is called (uses $yKoord).
 ?
  form action=test.php name=form?php echo $teller; ?
onsubmit=return
 hentKoordinat()
   input type=hidden name=teller value=?php echo $teller; ?
   input type=hidden name=yKoord
   input name=button1 type=submit value=Send input
  /form
  ?php $teller++; ?
 ?php
 } //for($teller=0; $i2; $i++) {
 ?
 /body
 /html





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



[PHP] Variables / Memory Allocation

2003-03-04 Thread Adam Voigt




Ok, first, is there any difference in respect to memory or CPU speed

between defining a variable with define() and addressing it without a $,

and simply using $var = whatever.



Second, putting good programming practices aside, what is the cost

in CPU speed for unsetting a variable after it's done being used, and

is it even worth doing so for those few extra bytes free'd, if PHP will undefine

it anyway when execution ends?







-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


[PHP] strange problem

2003-03-04 Thread Denis L. Menezes
Hello friends,

Following is the part html output of my page got from View-source in IE.

The problem is that I gate a big blank gap on the output page from the top until about 
10 lines height and only then the table is displayed. As you see I have no BR tags 
here. Can someone tell me why I get blank space?

Quote :

html
head
titleUntitled Document/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head

body
table width=800 border=0 cellspacing=0 cellpadding=0
  tr 
td colspan=6
  STRONGThe Whatson database has found the following 15 students :/STRONG
/td
  /tr
  tr 
td width=106nbsp;/td
td width=570nbsp;/td
td width=30nbsp;/td
td width=30nbsp;/td
td width=30nbsp;/td
td width=34nbsp;/td
  /tr
  tr 
td 


Unquote

Thanks
Denis

Re: [PHP] Downloading files outside the webserver

2003-03-04 Thread Daniel Silva
There's actually a function in (PHP 4 = 4.3.0) that returns a file's MIME
type.

Here it is:
string mime_content_type ( string filename)


Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Yes, sure, but you many times won't know the mime type and might be
 forced to use application/octet-stream.
 You can do
 if(dirname(realpath($user_files_dir . $_GET['filename'])) ==
 $user_files_dir)
 as a security check

 Daniel Silva wrote:

 That is a very nice solution, the problem is, the files are stored on
disk,
 not on the DB. I suppose it can be addapted to work with the disk, can't
it?
 
 Cheers,
 
 Daniel
 
 
 Marek Kilimajer [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
 create a download php file:
 
 ?php
 
 $res=mysql_query(select * from user_files where
 
 
 filename='$GET['file']');
 
 
 if($res  mysql_num_rows($res)) {
 $file=mysql_fetch_assoc($res);
 if($_GET['downaload']) {
 header('Content-Type: application/octet-stream');
 header('Content-disposition: attachment;
 filename='.basename($file['filename']));
 } else {
 header('Content-Type: '.$file['mimetype']);
 header('Content-disposition: attachment;
 filename='.basename($file['filename']));
 }
 header('Content-Length: '.filesize($file['filename']));
 readfile($file['filename']);
 } else {
 echo 'no such file';
 }
 ?
 
 Then create a link:
 a href=file.php?filename=path/fileview/a
 a href=file.php?filename=path/fileamp;download=1download/a
 
 This example assumes you have a table user_files, where you store
 uploaded files with their mime types, this is a security check
 
 Daniel Silva wrote:
 
 
 
 Hello,
 
 I'm currently working on a multi-user filemanager, on which each user
has
 its space on the server and can do all the basic file operations we've
 
 
 all
 
 
 seen.
 
 I've looked all over the net and the manual, but I can't seem to find
the
 solution for what I want.
 
 The system I'm creating keeps all user files in a folder outside the
 webserver, this is to say, any folder the admin defines, such as
 /home/john/webusers .
 
 The site shows all files contained in the userdir and lets him
manipulate
 them. Of course, I want to let the users download their files, but as
 
 
 they
 
 
 aren't inside the webserver's scope, I just can't simply link to
them.
 
 Is there any way I can implement this? To download a file located at X
 directory, anywhere in the system? And taking security into
 
 
 consideration,
 
 
 of course.
 
 Thanks in advance,
 
 Daniel Silva
 
 
 
 
 
 
 
 
 
 
 
 
 
 




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



Re: [PHP] strange problem

2003-03-04 Thread 1LT John W. Holmes
Look for anything outside of the tr or td tags in the rest of your
table. That's generally what causes things like this.

---John Holmes...

- Original Message -
From: Denis L. Menezes [EMAIL PROTECTED]
To: PHP general list [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 10:40 AM
Subject: [PHP] strange problem


Hello friends,

Following is the part html output of my page got from View-source in IE.

The problem is that I gate a big blank gap on the output page from the top
until about 10 lines height and only then the table is displayed. As you see
I have no BR tags here. Can someone tell me why I get blank space?

Quote :

html
head
titleUntitled Document/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head

body
table width=800 border=0 cellspacing=0 cellpadding=0
  tr
td colspan=6
  STRONGThe Whatson database has found the following 15 students
:/STRONG/td
  /tr
  tr
td width=106nbsp;/td
td width=570nbsp;/td
td width=30nbsp;/td
td width=30nbsp;/td
td width=30nbsp;/td
td width=34nbsp;/td
  /tr
  tr
td


Unquote

Thanks
Denis


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



[PHP] PHP OpenSSL question

2003-03-04 Thread Pierre-Luc Soucy
Hi,

I have loaded the appropriate keys:

//load keys
$ca_file = openssl_x509_read('file://'.$ca_file);
$public_key = openssl_pkey_get_public('file://'.$public_key_file);
$private_key = openssl_pkey_get_private('file://'.$private_key_file);

and can successfully encrypt data:

$to_send = '?xml version=1.0 encoding=UTF-8 standalone=no?
epp xmlns=urn:ietf:params:xml:ns:epp-1.0
 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 xsi:schemaLocation=urn:ietf:params:xml:ns:epp-1.0
 epp-1.0.xsd
  hello/
/epp';

openssl_public_encrypt($to_send, $message, $public_key);

I then write the encrypted data to the socket using socket_write (when
communicating with a server) but the server disconnects me when I attempt to
read its output with socket_read:

 Warning: socket_read() unable to read from socket [54]: Connection reset by
peer

Any idea why? To what I understand, I might need to do a SSL handshake
first? How can that be done with PHP?

Thanks a lot!

Pierre-Luc Soucy



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



[PHP] Problems to log into my application as an Admin

2003-03-04 Thread Ricardo Fitzgerald
Hi to all,

I designed an application for managing mailing lists, but something
really strange happened, I logged in as an admin only once and then it
only allows me to log as a regular user, if I try to use the admin user
it keeps returning the error messages.

I used sessions to distinguish between regular and administrators, but
because I'm not hosting in house, my host provider didn't bring any logs
so I don't know where the error might be.

Any Ideas ?

Rick Fitzgerald

Off Price Closeouts
1700 W 8 Ave
Miami, FL 33010
(305) 888 2555
FAX (305) 884 1761




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



[PHP] Testing for installed components....

2003-03-04 Thread Christopher Ditty
I am trying to write a small script that will test and report what PHP
components are available on a given server.  Is there a quick and easy
way to do this?  I know about php info, but I would prefer to have
something that will spit hte information out in my format where the user
can easily understand it.

Chris

--
03/04/2003, 10:09:13 AM
This e-mail and any attachments represent the views and opinions of only the sender 
and are not necessarily those of Memphis Light, Gas  Water Division, and no such 
inference should be made.

==


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



RE: [PHP] Doing a Multiple Search

2003-03-04 Thread Justin Michael Couto

Hunter,

What you need to do is this:

$Query=SELECT * from $TableName WHERE lastname='$Array[lastname]' OR
firstname='$Array[firstname]' ;

That will get the functionality you are looking for.  You might also
want to consider doing this:

$Query=SELECT * from $TableName WHERE lastname LIKE '$Array[lastname]%'
OR firstname LIKE '$Array[firstname]%' ;

That wil also search on the first name and last name.  In addition, if
you are searching from someone by the name of Bob Smith and you just put
an 'S' in the last name field, you would pull up everyperson that had a
last name that started with 'S'

Good Luck

XXX
I know this must be an easy solution, just not seeing what it is.

I have tried to add several options to the below code but can't seem to
get
it right.

Here is the Base Line I am working with:

$Query=SELECT * from $TableName WHERE lastname='$Array[lastname] AND
firstname='$Array[firstname]' ;

What I ant to be able to do is a search on both the lastname and the
firstname so if someone just puts in the last name it will display all
people with the queried last name regardless of the first name.  So for
the
visual representation

If I search for Bob Smith, it will give me:

Smith   Bob

If I search by last name Smith, it will give me

Smith Bob
Smith John
Smith Mike


Any and all help would be greatly appreciated.

Thanks in Advance

Jess

-- 
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



[PHP] http benchmark tools

2003-03-04 Thread Tamas Arpad
Hi,
I'm searching for a good http benchmark tool. Of course I found some, but 
don't know them and don't know which one to choose.
I found JMeter slow, in other aspects it would be perfect. Used httperf 
before, but I need more complicated test cases. I'd like to simulate visitors 
who first go to the first page, then click there on an article or column and 
so on...
Please if someone have expirience, share it!
I also searched for tools that can use apache's log to make benchmarks by 
resending real-life's request, but couldn't find one. Is there such a tool?
Thanks,
Arpi

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



Re: [PHP] pharse file random work with -n lines

2003-03-04 Thread Marek Kilimajer
Sorry, I forgot about the random part. Append the lines to an array, and 
then use array_rand:

while($tmp= fgetcsv($fp,5,\|)) { $array[]=$tmp; }

$rand_array=array_rand($array, 10);



WebDev wrote:

Yes it works here only this way \|  but I have not figuered it to return
it random
- Original Message -
From: Marek Kilimajer [EMAIL PROTECTED]
To: WebDev [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 5:00 AM
Subject: Re: [PHP] pharse file random work with -n lines
 

while(list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
   

$vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
$ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei,
$End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
$dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = fgetcsv
($fp,5,\|) {
 

// here you can do what you need to do

}

are you sure you want \| and not |?

WebDev wrote:

   

how can you return this randomized?

how can I get every time I call this function a random set of lines ?

Working Code to read 10 first lines and split the individual line into
 

info careeners and do something with it 
 



$i = 0;
$fp = fopen
 

(../../../../../public/httpd/html/datacontainer/data/storage.data, r);
 

while (!feof ($fp)  $i  10) {
$i++;
  $buffer = fgets($fp, 4096);
  list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
 

$vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
$ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei,
$End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
$dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split (\|,
$buffer);
 

\\ do something
}
fclose ($fp);






 



 



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


[PHP] form submit oddities?

2003-03-04 Thread Ray
i have posted the question to phpMyAdmin user list already and after talking 
with someone about my problem, it looks like its not in the phpMyAdmin, but 
in my settings for php, but they seemed to have no clue as to what.

anyways, with a clean install of phpMyAdmin 2.4.0 we can't query the database 
through any form that has a file upload

when we disable file upload totally it works (minus the file uploading)

i tacked
echo pre;
print_r(get_defined_vars());
echo /pre;
at the begining of the file that the form submits to and when the form has 
enctype=multipart/form-data in it
the page outputs

Array
(
[HTTP_POST_VARS] = Array
(
)

[_POST] = Array
(
)

[HTTP_GET_VARS] = Array
(
)

[_GET] = Array
(
)

at the top, and when there isn't the enctype attribute on the form tag 
there is post information available.

Array
(
[HTTP_RAW_POST_DATA] = 
is_js_confirmed=0lang=en-iso-8859-1server=5db=mysqltable=dbpos=0goto=tbl_properties.phpzero_rows=Your+SQL-query+has+been+executed+successfullyprev_sql_query=dummy=Hostsql_query=SELECT+*+FROM+%60db%60+WHERE+1show_query=1sql_file=sql_file_compression=text%2FplainSQL=Go
[HTTP_POST_VARS] = Array
(
[is_js_confirmed] = 0
[lang] = en-iso-8859-1
[server] = 5
[db] = mysql
[table] = db
[pos] = 0
[goto] = tbl_properties.php
[zero_rows] = Your SQL-query has been executed successfully
[prev_sql_query] = 
[dummy] = Host
[sql_query] = SELECT * FROM `db` WHERE 1
[show_query] = 1
[sql_file] = 
[sql_file_compression] = text/plain
[SQL] = Go
)

[_POST] = Array
(
[is_js_confirmed] = 0
[lang] = en-iso-8859-1
[server] = 5
[db] = mysql
[table] = db
[pos] = 0
[goto] = tbl_properties.php
[zero_rows] = Your SQL-query has been executed successfully
[prev_sql_query] = 
[dummy] = Host
[sql_query] = SELECT * FROM `db` WHERE 1
[show_query] = 1
[sql_file] = 
[sql_file_compression] = text/plain
[SQL] = Go
)

[HTTP_GET_VARS] = Array
(
)

[_GET] = Array
(
)


server: win2k, apache 1.3.27, php 4.2.2

clients: 
linux galeon
winxp ie6
win2k ie5  

so, what is most likely wrong with my config/setup?

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



[PHP] short_open_tags = On

2003-03-04 Thread Keith Mastin
I was asked to change this in the php.ini file by a user to make it
easier to use php on the server. Before doing so, I thought I better ask
if there's any know security implications. I checked the wiki, and it
showed that there are 31 instances of this, but didn't actually show any.
:)

The server is on the web and has a number of domains. The user in question
writes a lot of websites using php for maybe 1/2 of the domains.

TIA

-- 
Keith Mastin
BeechTree Information Technology Services Inc.
Toronto, Canada
(416)696-6070





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



Re: [PHP] http benchmark tools

2003-03-04 Thread Tamas Arpad
On Tuesday 04 March 2003 17:43, Jason k Larson wrote:
 How about Apache Bench?

 http://httpd.apache.org/docs/programs/ab.html
It's really a cool program, but too simple. I need to simlute requests that 
are normally made by visitors, not just stress one url.
For example: main page-click on a column-on an article-back-another 
column-another article-search for something etc...
I'm trying to understand how flood works now, it seems to be suitable for 
that.
Any other thoughts?
Thanks,
Arpi

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



[PHP] Re: using preg_match to extract information from pop3

2003-03-04 Thread Henry Grech-Cini
Hi All,

This has to be easy to do using preg_match!
Can no one spare a minute of their time?

Henry

Henry Grech-Cini [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi All,

 I know that you will probably tell me to RTFM but I have (several times)
and
 I cannot quite understand it!

 So failing that I turn to you for help.

 I know that this is very trivial but please humour me.

 I have a line containing From: Henry henry @ .com 
 (please ignore any spaces between the angled braces  , they are just to
 fool outlook express)

 And I want to extract the name and the email address into the variables
 $name $email. I suspect using preg_match?

 TIA

 Henry





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



Re: [PHP] http benchmark tools

2003-03-04 Thread Gerard Samuel
This is what I use -
http://www.joedog.org/siege/index.shtml
Tamas Arpad wrote:

Hi,
I'm searching for a good http benchmark tool. Of course I found some, but 
don't know them and don't know which one to choose.
I found JMeter slow, in other aspects it would be perfect. Used httperf 
before, but I need more complicated test cases. I'd like to simulate visitors 
who first go to the first page, then click there on an article or column and 
so on...
Please if someone have expirience, share it!
I also searched for tools that can use apache's log to make benchmarks by 
resending real-life's request, but couldn't find one. Is there such a tool?
Thanks,
	Arpi

 

--
Gerard Samuel
http://www.trini0.org:81/
http://test1.trini0.org:81/


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


Re: [PHP] http benchmark tools

2003-03-04 Thread Jason k Larson
How about Apache Bench?

http://httpd.apache.org/docs/programs/ab.html

--
Jason k Larson
Tamas Arpad wrote:
Hi,
I'm searching for a good http benchmark tool. Of course I found some, but 
don't know them and don't know which one to choose.
I found JMeter slow, in other aspects it would be perfect. Used httperf 
before, but I need more complicated test cases. I'd like to simulate visitors 
who first go to the first page, then click there on an article or column and 
so on...
Please if someone have expirience, share it!
I also searched for tools that can use apache's log to make benchmarks by 
resending real-life's request, but couldn't find one. Is there such a tool?
Thanks,
	Arpi



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


[PHP] Re: using preg_match to extract information from pop3

2003-03-04 Thread Henry Grech-Cini
I tried

if(preg_match(/^From:(.*)$/, $headers[$line], $info))
   {
   echo [;
print_r($info);
echo ];
echo PRE,HtmlSpecialChars($headers[$line]),/PRE;

   }

But all I get is

[Array ( [0] = From: [1] = ) ]
From: Henry henry @ .com 

Any pointers?


Henry Grech-Cini [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi All,

 I know that you will probably tell me to RTFM but I have (several times)
and
 I cannot quite understand it!

 So failing that I turn to you for help.

 I know that this is very trivial but please humour me.

 I have a line containing From: Henry henry @ .com 
 (please ignore any spaces between the angled braces  , they are just to
 fool outlook express)

 And I want to extract the name and the email address into the variables
 $name $email. I suspect using preg_match?

 TIA

 Henry





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



[PHP] Re: Remember scrolled position

2003-03-04 Thread Lars Espelid
I've tried this and it works fine, but then the user must click the
anchor-link on the top of the page each time he has submitted a form. This
is not what I want. I would like the page to scroll down automatically. Is
it possible to click the anchor-link automatically? If so this could be a
solution. Any other suggestions?

Thanks,

Lars


Patrick Schnegg [EMAIL PROTECTED] skrev i melding
news:[EMAIL PROTECTED]
 I would tend to make this with common html using named anchors. Just
enclose
 every button with a an anchor and define its name numbering it with php.
 Then simply make sure that when the button is pressed that number is
 appended to the url so it will look like yourdocument.php?yourdata=blah#5
 making the browser jump to the anchor named 5.

 Lars Espelid [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  I'm trying to implement the following functionality into the file
 test.php:
 
  When I scroll down the page and then hit a button, the page should
 remember
  the scrolled position, refresh the page and then scroll down to the
  remembered position. If I knew how many form-schemas there would be on
the
  page, this would be easy. But I don't so then I need a way to give each
 form
  a unike name and this name I need to use in the function
hentKoordinat().
  But when hentKoordinat is executed the variable containing the form-name
 is
  not yet set.
 
  When someone hits a button in one of the form-schemas the following
  happens:
  1) hentKoordinat() is executed. The form-schemas hidden field named
yKoord
  gets the value: the amunt of pixels scrolled in y-direction. This
doesn't
  work because $teller is not yet set (needed to specify which form is
  submitted).
  2)the page is refreshed and $teller is set to a number whisch says which
  form is submitted and $yKoord is set to the amunt of pixels scrolled in
  y-direction.
  3)onload in body calls the function mScroll which scrolls the page to
 where
  it was when someone clicked the button.
 
  Hoping someone can help, maybe I need to do this a totally different
way?
 
  Thanks!
 
  Lars
 
 
  Tried to explain the code in test.php:
 
  !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  http://www.w3.org/TR/html4/loose.dtd;
  html
  head
  titleUntitled Document/title
  script language=JavaScript type=text/javascript
  !--
 
  function getPageScroll(){
 
  //this function returns scrollX and scrollY as probertys of
  getPageScroll. ScrollX and scrollY
  //contains the amount of pixels the page has been scrolled in x and y
  direction.
 
  var X, Y;
  if(typeof window.pageXOffset == 'number'){
  X = window.pageXOffset;
  Y = window.pageYOffset;
  }else{
  if((window.document.compatMode)
(window.document.compatMode == 'CSS1Compat')){
  X = window.document.documentElement.scrollLeft;
  Y = window.document.documentElement.scrollTop;
  }else{
  X = window.document.body.scrollLeft;
  Y = window.document.body.scrollTop;
  }
  }
  return {scrollX:X,scrollY:Y};
  }
  function hentKoordinat() {
 
  // this function uses getPageScroll() to find pixels scrolled in
 y-direction
  and inserts this value into the hidden-form-value named yKoord in the
 form
  schema which holds the button clicked (form?php echo $teller; ?).
 
 
   //*Here the problem arises. The first time you click a button,
 $teller
  is not set. This method is executed before the page is refreshed. The
 value
  $teller is set when the page is refreshed.*
 
  document.form?php echo $teller; ?.yKoord.value =
getPageScroll().scrollY
  }
 
  function mScroll() {
 
  //this function scrolls the page so many pixels that $yKoord holds in
the
  y-direction.
  //to avoid error messages I set $yKoord like 0 if it is empty (scrolls
  nothing).
 
   ?php if(!isset($yKoord)) $yKoord=0; ?
   ?php if($yKoord=='') $yKoord=0; ?
   self.scrollTo(0,?php echo $yKoord; ?)
  }
 
  //--
  /script
  /head
 
  body onLoad=mScroll()
  ?php echo p Ykoordinat:  . $yKoord . p;
  echo Teller:  . $teller;
 
  for($i=0; $i150; $i++) {
  //prints 150 line breaks so that the page gets scrollable (the content
 does
  not fit the monitor-area)
   echo 'br';
  }
  for($teller=0; $teller2; $teller++) {
  //prints two form-schemas. Later on I will print a varying amount of
  form-schemas (depends on the amunt of
  //data in a MySQL-table)
  //The form name includes $teller so that each form-schema gets a unike
 name
  and I know which
  //$yKoord to update in hentKoordinat(). $teller and $yKoord is passed on
 as
  variables when the page refreshes,
  //so that I know which form's button1 is submitted and how many pixels
 there
  are to scroll when onload=mScroll()
  // in body is called (uses $yKoord).
  ?
   form action=test.php name=form?php echo $teller; ?
 onsubmit=return
  hentKoordinat()
input type=hidden name=teller value=?php echo $teller; ?
input 

Re: [PHP] short_open_tags = On

2003-03-04 Thread Rasmus Lerdorf
No, there are no security implications.  In fact, it is arguably more 
secure to have short tags enabled as it is then less likely for someone to 
accidentally expose their PHP source code since everything between ? and 
? will be parsed by PHP.  However, keep in mind that XHTML and XML also 
uses ?...? so if you are mixing XHTML or XML with PHP you could run into 
some difficulties.  Nothing that is all that hard to get around.  I tend 
to always use short_tags myself and simply echo ?xml...?; if I need to 
output an xml revision tag, for example.

-Rasmus

On Tue, 4 Mar 2003, Keith Mastin wrote:

 I was asked to change this in the php.ini file by a user to make it
 easier to use php on the server. Before doing so, I thought I better ask
 if there's any know security implications. I checked the wiki, and it
 showed that there are 31 instances of this, but didn't actually show any.
 :)
 
 The server is on the web and has a number of domains. The user in question
 writes a lot of websites using php for maybe 1/2 of the domains.
 
 TIA
 
 


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



Re: [PHP] http benchmark tools

2003-03-04 Thread Tamas Arpad
Experimenting with it, thanks!
Arpi

 This is what I use -
 http://www.joedog.org/siege/index.shtml

 Tamas Arpad wrote:
 Hi,
 I'm searching for a good http benchmark tool. Of course I found some, but
 don't know them and don't know which one to choose.
 I found JMeter slow, in other aspects it would be perfect. Used httperf
 before, but I need more complicated test cases. I'd like to simulate
  visitors who first go to the first page, then click there on an article
  or column and so on...
 Please if someone have expirience, share it!
 I also searched for tools that can use apache's log to make benchmarks by
 resending real-life's request, but couldn't find one. Is there such a
  tool? Thanks,
  Arpi

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



Re: [PHP] pharse file random work with -n lines

2003-03-04 Thread WebDev
the last script gives me no error but it returns nothing on the page only
empty




- Original Message -
From: Marek Kilimajer [EMAIL PROTECTED]
To: WebDev [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 9:11 AM
Subject: Re: [PHP] pharse file random work with -n lines


 You don't need to use fgets after the while loop (you are at the end of
 the file), $rand_array will contain your desired random rows:

 ?php
 $i = 0;
 $fp = fopen (../../../../../home/httpd/html/Classifieds/data/ads.data,
 r);
 while($tmp= fgetcsv($fp,5,\|)) { $array[]=$tmp; }
 fclose ($fp);
 $rand_array=array_rand($array, 10);

 foreach($rand_array as $line) {
 list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
$vier,
 $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat,
 $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3,
 $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei,
 $dreidrei, $dreivier, $dreifunf, $dreisechs ) = $line;

 echo  font face=\Verdana\ size=\1\a

href=\http://www.browseabit.com/cgi-bin/Classifieds/classifieds.cgi?session
 _key=search_and_display_db_button=ondb_id=$adnrquery=retrieval\
 target=\_blanko\$Endzwei $End3/abr/font;
 }

 ?



 WebDev wrote:

 Parse error: parse error in
 /home/virtual/browse/home/httpd/html/Classifieds/infobox.php on line 9
 
 
 ?php
 $i = 0;
 $fp = fopen (../../../../../home/httpd/html/Classifieds/data/ads.data,
 r);
 while($tmp= fgetcsv($fp,5,\|)) { $array[]=$tmp; }
 $rand_array=array_rand($array, 10);
 $buffer = fgets($fp, 4096);
 list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
$vier,
 $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat,
 $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3,
 $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei,
 $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split (\|, $buffer);
 echo  font face=\Verdana\ size=\1\a

href=\http://www.browseabit.com/cgi-bin/Classifieds/classifieds.cgi?sessio
n
 _key=search_and_display_db_button=ondb_id=$adnrquery=retrieval\
 target=\_blanko\$Endzwei $End3/abr/font;
 }
 fclose ($fp);
 ?
 - Original Message -
 From: Marek Kilimajer [EMAIL PROTECTED]
 To: WebDev [EMAIL PROTECTED]; PHP [EMAIL PROTECTED]
 Sent: Tuesday, March 04, 2003 8:25 AM
 Subject: Re: [PHP] pharse file random work with -n lines
 
 
 
 
 Sorry, I forgot about the random part. Append the lines to an array, and
 then use array_rand:
 
 while($tmp= fgetcsv($fp,5,\|)) { $array[]=$tmp; }
 
 $rand_array=array_rand($array, 10);
 
 
 
 WebDev wrote:
 
 
 
 Yes it works here only this way \|  but I have not figuered it to
 
 
 return
 
 
 it random
 - Original Message -
 From: Marek Kilimajer [EMAIL PROTECTED]
 To: WebDev [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Tuesday, March 04, 2003 5:00 AM
 Subject: Re: [PHP] pharse file random work with -n lines
 
 
 
 
 
 
 while(list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
 
 
 
 
 $vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
 $ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei,
 $End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
 $dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = fgetcsv
 ($fp,5,\|) {
 
 
 
 
 // here you can do what you need to do
 
 }
 
 
 are you sure you want \| and not |?
 
 
 WebDev wrote:
 
 
 
 
 
 how can you return this randomized?
 
 how can I get every time I call this function a random set of lines ?
 
 
 Working Code to read 10 first lines and split the individual line
into
 
 
 
 
 info careeners and do something with it 
 
 
 
 
 
 
 
 $i = 0;
 $fp = fopen
 
 
 
 
 (../../../../../public/httpd/html/datacontainer/data/storage.data,
 
 
 r);
 
 
 
 
 while (!feof ($fp)  $i  10) {
 $i++;
   $buffer = fgets($fp, 4096);
   list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
 
 
 
 
 $vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
 $ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei,
 $End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
 $dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split (\|,
 $buffer);
 
 
 
 
 \\ do something
 }
 fclose ($fp);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


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



Re: [PHP] pharse file random work with -n lines

2003-03-04 Thread Marek Kilimajer
I'm not sure what is wrong, you should add print_r function in different 
places to see if the variables really contain what they should.

WebDev wrote:

the last script gives me no error but it returns nothing on the page only
empty


- Original Message -
From: Marek Kilimajer [EMAIL PROTECTED]
To: WebDev [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 9:11 AM
Subject: Re: [PHP] pharse file random work with -n lines
 

You don't need to use fgets after the while loop (you are at the end of
the file), $rand_array will contain your desired random rows:
?php
$i = 0;
$fp = fopen (../../../../../home/httpd/html/Classifieds/data/ads.data,
r);
while($tmp= fgetcsv($fp,5,\|)) { $array[]=$tmp; }
fclose ($fp);
$rand_array=array_rand($array, 10);
foreach($rand_array as $line) {
   list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
   

$vier,
 

$usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat,
$ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3,
$Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei,
$dreidrei, $dreivier, $dreifunf, $dreisechs ) = $line;
echo  font face=\Verdana\ size=\1\a

   

href=\http://www.browseabit.com/cgi-bin/Classifieds/classifieds.cgi?session
 

_key=search_and_display_db_button=ondb_id=$adnrquery=retrieval\
target=\_blanko\$Endzwei $End3/abr/font;
}
?



WebDev wrote:

   

Parse error: parse error in
/home/virtual/browse/home/httpd/html/Classifieds/infobox.php on line 9
?php
$i = 0;
$fp = fopen (../../../../../home/httpd/html/Classifieds/data/ads.data,
r);
while($tmp= fgetcsv($fp,5,\|)) { $array[]=$tmp; }
$rand_array=array_rand($array, 10);
$buffer = fgets($fp, 4096);
  list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,
 

$vier,
 

$usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat,
$ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3,
$Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei,
$dreidrei, $dreivier, $dreifunf, $dreisechs ) = split (\|, $buffer);
echo  font face=\Verdana\ size=\1\a
 

href=\http://www.browseabit.com/cgi-bin/Classifieds/classifieds.cgi?sessio
   

n
 

_key=search_and_display_db_button=ondb_id=$adnrquery=retrieval\
target=\_blanko\$Endzwei $End3/abr/font;
}
fclose ($fp);
?
- Original Message -
From: Marek Kilimajer [EMAIL PROTECTED]
To: WebDev [EMAIL PROTECTED]; PHP [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 8:25 AM
Subject: Re: [PHP] pharse file random work with -n lines


 

Sorry, I forgot about the random part. Append the lines to an array, and
then use array_rand:
while($tmp= fgetcsv($fp,5,\|)) { $array[]=$tmp; }

$rand_array=array_rand($array, 10);



WebDev wrote:



   

Yes it works here only this way \|  but I have not figuered it to

 

return

 

it random
- Original Message -
From: Marek Kilimajer [EMAIL PROTECTED]
To: WebDev [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 5:00 AM
Subject: Re: [PHP] pharse file random work with -n lines




 

while(list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,



   

$vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
$ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei,
$End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
$dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = fgetcsv
($fp,5,\|) {


 

// here you can do what you need to do

}

are you sure you want \| and not |?

WebDev wrote:





   

how can you return this randomized?

how can I get every time I call this function a random set of lines ?

Working Code to read 10 first lines and split the individual line
 

into
 



 

info careeners and do something with it 



 



$i = 0;
$fp = fopen


 

(../../../../../public/httpd/html/datacontainer/data/storage.data,

 

r);

 

 

while (!feof ($fp)  $i  10) {
$i++;
$buffer = fgets($fp, 4096);
list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,


 

$vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url,
$ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei,
$End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne,
$dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split (\|,
$buffer);


 

\\ do something
}
fclose ($fp);










 



 



 



 



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


RE: [PHP] Problems to log into my application as an Admin

2003-03-04 Thread Ricardo Fitzgerald
I'm hosting at a hosting provider, that's not my ISP which is Bellsouth.
They are ezoshosting.com.

Thank you

Rick


Off Price Closeouts
1700 W 8 Ave
Miami, FL 33010
(305) 888 2555
FAX (305) 884 1761


-Mensaje original-
De: Denis L. Menezes [mailto:[EMAIL PROTECTED] 
Enviado el: Tuesday, March 04, 2003 11:14 AM
Para: Ricardo Fitzgerald
Asunto: Re: [PHP] Problems to log into my application as an Admin

Ricardo,

Are you hosting the server yourself or at an ISP?

Denis
- Original Message - 
From: Ricardo Fitzgerald [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, March 05, 2003 12:00 AM
Subject: [PHP] Problems to log into my application as an Admin


 Hi to all,
 
 I designed an application for managing mailing lists, but something
 really strange happened, I logged in as an admin only once and then it
 only allows me to log as a regular user, if I try to use the admin
user
 it keeps returning the error messages.
 
 I used sessions to distinguish between regular and administrators, but
 because I'm not hosting in house, my host provider didn't bring any
logs
 so I don't know where the error might be.
 
 Any Ideas ?
 
 Rick Fitzgerald
 
 Off Price Closeouts
 1700 W 8 Ave
 Miami, FL 33010
 (305) 888 2555
 FAX (305) 884 1761
 
 
 
 
 -- 
 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



[PHP] Re: using preg_match to extract information from pop3

2003-03-04 Thread Henry Grech-Cini
Found a solution

if (preg_match(/Form:[ ]*(.+)[ ]*(.+)/, Form:Henry [EMAIL PROTECTED],
$info))
{
 print_r($info);
}
else
 print Pattern not found;

but I'm refining it so that it doesn't need the last bit, any more pointers
appreciated!!!

Thanks All

Henry

Henry Grech-Cini [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi All,

 I know that you will probably tell me to RTFM but I have (several times)
and
 I cannot quite understand it!

 So failing that I turn to you for help.

 I know that this is very trivial but please humour me.

 I have a line containing From: Henry henry @ .com 
 (please ignore any spaces between the angled braces  , they are just to
 fool outlook express)

 And I want to extract the name and the email address into the variables
 $name $email. I suspect using preg_match?

 TIA

 Henry





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



[PHP] regex makes my head hurt

2003-03-04 Thread Kris Jones
I've been attempting to figure out regex, and I've realized I need to start 
over from scratch. And get lots of help!

I'm inputting a text file containing html which will contain this:

a href=/q?s=IBMd=tIBM/a/font/tdtd nowrap align=center
font face=arial size=-12:59pm/font/td
td nowrapfont face=arial size=-1
b76.17/b/font/tdtd nowrap
I need to be able to match this string via a variable. I would like to put 
everything from the a href to the td nowrap into a variable so I can 
parse it later. I think I can do that bit on my own.

So I borrowed some code from another source, but I need an algorithm that 
will match the above chunk of html.

I give it the name:

$name = IBM;

and it matches everything from the a href to the td nowrap.

   if (preg_match(/ a href part using $name(.*?)td nowrap/, $line, 
$out)) {

   $title = $out[1];
   break;
   }
}
echo $title;
I can't figure out how to escape all the parts of:
a href=/q?s=$named=t
Do the other parts look okay?

_
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail

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


Re: [PHP] deciperhing oop

2003-03-04 Thread Greg Beaver
PHP 5 will allow your assumption, i.e. $db will resolve to the $db in the
class namespace.  If you also have a global variable named $db, you can
refer to it using main::$db, instead of using the global statement.  Pretty
slick, if you ask me.

By the way, check out PEAR's DB and MDB classes,
http://pear.php.net/package-info.php?pacid=46 and
http://pear.php.net/package-info.php?pacid=54

Greg
--
phpDocumentor
http://www.phpdoc.org

Larry Brown [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thank you everyone for helping.  I didn't know you have to put $this- in
 front of all variables in the class.  You learn something new every day
( I
 thought you only needed to use that once to make the variable available
 everywhere in the class up till now).

 Larry S. Brown
 Dimension Networks, Inc.
 (727) 723-8388

 -Original Message-
 From: Jim Lucas [mailto:[EMAIL PROTECTED]
 Sent: Monday, March 03, 2003 6:50 PM
 To: Larry Brown; PHP List
 Subject: Re: [PHP] deciperhing oop

 the second argument in the mysql_select_db call in not in scope.

 you should be using $this-db instead of $db

 Jim
 - Original Message -
 From: Larry Brown [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Sent: Monday, March 03, 2003 2:52 PM
 Subject: [PHP] deciperhing oop


  Can someone who is used to using php oop help me figure out why this
 fails?
  I know there are probably a thousand classes already designed to do this
 and
  probably 100 times more efficient, but this is how I learn.  From what
 I've
  read this should work but there is obviously something I'm missing.
 
  Quick problem description:
  Trying to set up class to connect to mysql db.  Already used a
procedural
  test successfully connecting to db.  Error is displayed as...
 
  Warning: mysql_select_db(): supplied argument is not a valid MySQL -
Link
  resource in /var/www/html/oop.php on line 67
  Database Selection to main failed.
 
  Code:
 
  Class dbConnect
  {
  var $machine;
  var $port;
  var $user;
  var $password;
  var $query;
  var $result;
  var $dbase;
  var $db;
  var $sel;
 
  function dbConnect($machine,$port,$user,$password)
  {
  $this-machine = $machine;
  $this-port = $port;
  $this-user = $user;
  $this-password = $password;
 
  $db = mysql_pconnect ($machine,$user,$password)
  if (!$db)
  {
  die (Initial connection to DB failed.)
  }
  $this-db = $db;
  }
  function setDbase($dbase)
  {
  $this-dbase = $dbase;
 
  $sel = mysql_select_db($dbase,$db);
  if(!$db)
  {
  die (Database Selection to $dbase failed.);
  }
  }
  }
 
  $dbn = new dbConnect(localhost,3306,bob,hjhyt4kl5);
 
  $dbn-setDbase(main);
 
 
 
 
 
 
  So why can't I use $db?  Isn't the statement $this-db=$db making it
  available to the setDbase function?
 
  Larry S. Brown
  Dimension Networks, Inc.
  (727) 723-8388
 
 
 
 
  --
  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



[PHP] php forgetting variables very easily

2003-03-04 Thread Ian A. Gray
Hi everyone.I am probably doing something obviously
wrong but I can't seem to sort it!  It's regarding
variables.In one script, lets call it main.php I make
a variable- say $colour.  It inludes a file which
prints the variable:

main.php
?php
$colour = 'green';
include('new.php')
?

new.php
?php
echo $colour
?

Ok, this works fine for me.  However it doesn't seem
to work when main.php and new.php have html in them. 
The variable seems to be lost and new.php prints
nothing.  Has anyone got any words of wisdom on this? 
It may help if I actually showed the two pages here,
but they are long and I thought it would be a waste of
space.

Best wishes,
Ian

=

-
Ian A. Gray
Manchester, UK
Telephone: +44 (0) 161 224 1635 - Fax: +44 (0) 870 135 0061 - Mobile: +44 (0) 7900 996 
328
US Fax no.:  707-885-3582
E-mail: [EMAIL PROTECTED] - Websites: www.baritone.uk.com (performance)  
www.vocalstudio.co.uk (Tuition)
-


__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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



Re: [PHP] php forgetting variables very easily

2003-03-04 Thread Rasmus Lerdorf
 Ok, this works fine for me.  However it doesn't seem
 to work when main.php and new.php have html in them. 

You are doing something wrong then.  Show us a simple example that doesn't 
work.

-Rasmus


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



[PHP] Debugging fsockopen errno 0?

2003-03-04 Thread Jeff Lewis
I've been trying to use fsockopen and it fails to get by if (!fp) and returns an errno 
of 0.

In the documentation it says that indicates an error initializing the socket. Is there 
anyway I can debug this or find out what is going wrong?

Jeff


  1   2   >