Re: [PHP] Is there a way to customize the 'Username' and 'Password' strings in a 401 auth dialog box?

2012-06-28 Thread David OBrien
On Thu, Jun 28, 2012 at 7:23 PM, Daevid Vincent  wrote:

> Is there a way to customize the 'Username' and 'Password' strings in a 401
> auth dialog box?
>
> I want to change mine to say "Webmaster ID" and "Authentication Key".
>
> http://php.net/manual/en/features.http-auth.php
>
>
This  http://www.ietf.org/rfc/rfc2617.txt says the browser actually
controls the prompts all you get to set is the realm.


Re: [PHP] is there a way to stop HTMLPurifier/CSStidy from forcing input CSS into all lowercase?

2012-06-01 Thread Govinda
we got off list, without meaning to, it seems.

Here are  the last few posts in the thread:


> 
>>> On Fri, Jun 1, 2012 at 12:46 AM, Govinda  
>>> wrote:
> Perhaps you should spend some time looking for a better text editor
> for your OS. :)  When the current tools I use does not give
> satisfactory progress in what I'd like to do, I replace the tool(s).
 
 I am happy with my editor.  It (BBedit) has good multi-file 
 search-replace... and I can also generate that/a full list of where all is 
 strtolower()..  BUT I do not want to just willy nilly comment out/remove 
 all those instances of strtolower(), because even if it seems to "work", I 
 won't really know what damage I may have done to the library(ies).  If I 
 can find just the one instance that is the culprit, without spending days 
 trying every single spot, one at a time, then great.. but since a lot of 
 the code in those libraries is a bit over my head (without spending a lot 
 of time on it), I want something more definitive than just stabbing at 
 every strtolower().
 
 I appreciate your time and attention.   When I post my OP, I was/am hoping 
 for a reply where someone knows what really is the situation; where is the 
 specific offending line(s) I can hack in the source, or better yet, just 
 how can we set CSStidy config options through HTMLpurifier at runtime, and 
 so not hack the source at all.
 
 -Govinda
>>> 
>>> You don't need to modify every strtolower statement.  Just open up the
>>> files and look at that code block and the surrounding code blocks.  If
>>> that doesn't make sense, then most likely it's not what you're looking
>>> for.
>> 
>> 
>> I tried that..  and some of the instances of strtolower() I thought very 
>> well could be the culprit.. and so I commented it out... but it did not help 
>> (it was not the culprit, or else it was still being overridden by another 
>> one).
>> 
>> Many other instances I could not tell by looking at the code.
>> 
>> Some were pretty clearly not the culprit.
>> 
>>>  In Notepad++, double clicking on a line in the search results
>>> window will open up the file and bring you right to that line.  If
>>> BBedit doesn't do that, then refer back to my comment about the tools
>>> you use :)  Just my 2 cents.
>> 
>> BBedit too does do that  :-)
>> 
>>> 
>>> BTW, I rather dig through the code 1st and see what strength and
>>> weakness that framework provides and to fully comprehend if all its
>>> bells and whistles are as others claim.  What may work for others may
>>> not for you.  For example, in all my past searches for a PHP
>>> framework, only Yii managed to fulfill the most of what I want in a
>>> framework, including and specifically ability to create CRUD UI by
>>> just specifying the table name after the DB configurations are set.
>>> But more than that, Yii went beyond my expectation by providing the
>>> client side validation for the CRUD too.  Granted the UI doesn't fit
>>> my liking but it does more than the other frameworks I've looked at.
>>> :)
>> 
>> I have been pleased with the frameworks and libraries I have picked to help 
>> me out.. even HTMLpurifier and CSStidy have been great.. It was not until 
>> now (too deep in to want to go back) that I realized I have this one issue.
>> 
>> I am just about to hand off this code.. just need to find a way to 
>> patch/workaround this one thing.. have another new project stating monday.
>> 
>> In case I seem irreverent.. it is not my intention... I appreciate you even 
>> bothering to reply :-)
>> -Govinda
> 
> Have you tried using xdebug and step through the code to look for
> changes?  IIRC, xdebug is capable of monitoring variables and their
> values.

AFAICT that is a brilliant idea -  put a watch on the var(s) until I can trace 
just exactly where the offending line is.  
[snip]
 I have yet to bring my tools up to speed to do that here in PHP.  I won't have 
time before this thing is out the door..   but thanks for reminding me I need 
to check out something like xdebug sooner than later.

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



Re: [PHP] is there a way to stop HTMLPurifier/CSStidy from forcing input CSS into all lowercase?

2012-06-01 Thread Tommy Pham
On Thu, May 31, 2012 at 11:17 PM, Govinda  wrote:
>>
>> You need to get better tools.  I found this with Notepad++ for Windows
>> searching "case" within *.php files filter within the root directory
>> of the extracted zip/tarball:
>>
>>  H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Font.php
>> (6 hits)
>>       Line 45:         $lowercase_string = strtolower($string);
>>       Line 46:         if (isset($system_fonts[$lowercase_string])) {
>>       Line 47:             return $lowercase_string;
>>       Line 61:                 case 0:
>>       Line 77:                 case 1:
>>       Line 131:                 case 2:
>>
>> Haven't looked at the entire file or source code but that looks close
>> enough to me... ;)
>
> Thanks a lot for taking a look Tommy,
>
> I do have a decent text editor I use to code with... and had searched for 
> possible places where is the culprit strtolower() ... and so far no matter 
> which instances(s) I comment out, I cannot seem to turn off the behavior of 
> the library as a whole (either of them, or both) which is forcing the input 
> CSS to lowercase.
>

Perhaps you should spend some time looking for a better text editor
for your OS. :)  When the current tools I use does not give
satisfactory progress in what I'd like to do, I replace the tool(s).

> For example, I also just tried the exact place you suggested: this one:
>
> [snip]htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Font.php
>
> ...and changed line 45 to this:
>
>        //$lowercase_string = strtolower($string);//Govinda hack
>        $lowercase_string = $string;
>
> but still no luck.
>
>
>>> Have you tried http://htmlpurifier.org/phorum/ and did you noticed
>>> "Since the project has been suspended, please only contact me if you
>>> intend to continue maintaining it." for CSSTidy?
>
> I hadn't posted on http://htmlpurifier.org/phorum because last time I did 
> that when I has also posted on stackoverlfow (SO), then the developer of 
> HTMLpurifier scolded me for the dupe ;-) ..  and he has already posted a 
> comment on my (this new) SO post, saying just, "Hmm, that's silly of CSS 
> Tidy. Maybe we should change that default.".  I assume he probably has a lot 
> on his plate, to the point that his answers are incredibly terse and not 
> necessarily very helpful.
>
> I did see the message about CSStidy no longer being developed (if that is the 
> meaning behind "suspended").  Yet when i was researching it, many people were 
> still recommending it.  No?  Do you know/prefer something else for the 
> purpose of cleaning user-input CSS bound for an external style sheet?
>
> Thanks
> -Govinda


Are you sure you fixed ALL of the offending lines containing
strtolower?  This is what Notepad++ returns when I search for
"strtolower":

Search "strtolower" (48 hits in 28 files)
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Background.php
(1 hits)
Line 35: $bits = explode(' ', strtolower($string)); // bits to 
process
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\BackgroundPosition.php
(1 hits)
Line 80: $lbit = ctype_lower($bit) ? $bit : 
strtolower($bit);
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Color.php
(1 hits)
Line 17: $lower = strtolower($color);
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Font.php
(1 hits)
Line 45: $lowercase_string = strtolower($string);
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\ListStyle.php
(1 hits)
Line 30: $bits = explode(' ', strtolower($string)); // bits to 
process
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\TextDecoration.php
(1 hits)
Line 19: $string = strtolower($this->parseCDATA($string));
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS.php
(2 hits)
Line 51: $property = strtolower($property);
Line 59: if (strtolower(trim($value)) !== 'inherit') {
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\Enum.php
(2 hits)
Line 7:  *  built-in strtolower and ctype_lower functions, 
which may
Line 40: $string = ctype_lower($string) ? $string :
strtolower($string);
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\HTML\Color.php
(1 hits)
Line 17: if (isset($colors[strtolower($string)])) return
$colors[$string];
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\HTML\LinkTypes.php
(1 hits)
Line 39: $part = strtolower(trim($part));
  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\Lang.php
(3 hits)
Line 35: $subtags[0] = strtolower($subtags[0]);
Line 50: 

Re: [PHP] is there a way to stop HTMLPurifier/CSStidy from forcing input CSS into all lowercase?

2012-05-31 Thread Govinda
> 
> You need to get better tools.  I found this with Notepad++ for Windows
> searching "case" within *.php files filter within the root directory
> of the extracted zip/tarball:
> 
>  
> H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Font.php
> (6 hits)
>   Line 45: $lowercase_string = strtolower($string);
>   Line 46: if (isset($system_fonts[$lowercase_string])) {
>   Line 47: return $lowercase_string;
>   Line 61: case 0:
>   Line 77: case 1:
>   Line 131: case 2:
> 
> Haven't looked at the entire file or source code but that looks close
> enough to me... ;)

Thanks a lot for taking a look Tommy,

I do have a decent text editor I use to code with... and had searched for 
possible places where is the culprit strtolower() ... and so far no matter 
which instances(s) I comment out, I cannot seem to turn off the behavior of the 
library as a whole (either of them, or both) which is forcing the input CSS to 
lowercase.

For example, I also just tried the exact place you suggested: this one:

[snip]htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Font.php

...and changed line 45 to this:

//$lowercase_string = strtolower($string);//Govinda hack
$lowercase_string = $string;

but still no luck.


>> Have you tried http://htmlpurifier.org/phorum/ and did you noticed
>> "Since the project has been suspended, please only contact me if you
>> intend to continue maintaining it." for CSSTidy?

I hadn't posted on http://htmlpurifier.org/phorum because last time I did that 
when I has also posted on stackoverlfow (SO), then the developer of 
HTMLpurifier scolded me for the dupe ;-) ..  and he has already posted a 
comment on my (this new) SO post, saying just, "Hmm, that's silly of CSS Tidy. 
Maybe we should change that default.".  I assume he probably has a lot on his 
plate, to the point that his answers are incredibly terse and not necessarily 
very helpful.

I did see the message about CSStidy no longer being developed (if that is the 
meaning behind "suspended").  Yet when i was researching it, many people were 
still recommending it.  No?  Do you know/prefer something else for the purpose 
of cleaning user-input CSS bound for an external style sheet?

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



Re: [PHP] is there a way to stop HTMLPurifier/CSStidy from forcing input CSS into all lowercase?

2012-05-31 Thread Tommy Pham
On Thu, May 31, 2012 at 10:48 PM, Tommy Pham  wrote:
> On Thu, May 31, 2012 at 10:33 PM, Govinda  
> wrote:
>> Hi guys
>>
>> anyone here using HTMLpurifier and CSStidy together?  (like e.g. to allow 
>> users to create their own external style sheets via form input)
>>
>> ...for example, in the way this post's answer explains how to use 
>> HTMLpurifier and CSStidy together:
>>
>> http://stackoverflow.com/questions/3241616/
>>
>> If so, do you know how to set CSStidy's config options in that context?
>>
>> I found how to set CSStidy's config options if I was running CSStidy from 
>> the command line, or on its _own_ from PHP runtime, but I do not know how to 
>> set the config options from within HTMLpurifier, or even how to 
>> hack/override either of those libraries to solve my particular issue.  I 
>> looked and hacked and thought for sure I would find the offending line of 
>> code.. but somehow, nothing I have tried is stopping one or both of those 
>> libraries from forcing all my input CSS into lowercase, which I do not want. 
>>  The issue is that I need the input CSS's case to be left as the user input 
>> it (so that for example background image paths in that CSS do not break).

You need to get better tools.  I found this with Notepad++ for Windows
searching "case" within *.php files filter within the root directory
of the extracted zip/tarball:

  
H:\data\Downloads\dev\PHP\htmlpurifier-4.4.0\library\HTMLPurifier\AttrDef\CSS\Font.php
(6 hits)
Line 45: $lowercase_string = strtolower($string);
Line 46: if (isset($system_fonts[$lowercase_string])) {
Line 47: return $lowercase_string;
Line 61: case 0:
Line 77: case 1:
Line 131: case 2:

Haven't looked at the entire file or source code but that looks close
enough to me... ;)

>>
>> more details, attempted fixes, etc.:
>> http://stackoverflow.com/questions/10843600/
>>
>> Thanks for any thoughts/tips of any kind
>> -Govinda
>
> Have you tried http://htmlpurifier.org/phorum/ and did you noticed
> "Since the project has been suspended, please only contact me if you
> intend to continue maintaining it." for CSSTidy?
>
> Regards,
> Tommy

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



Re: [PHP] is there a way to stop HTMLPurifier/CSStidy from forcing input CSS into all lowercase?

2012-05-31 Thread Tommy Pham
On Thu, May 31, 2012 at 10:33 PM, Govinda  wrote:
> Hi guys
>
> anyone here using HTMLpurifier and CSStidy together?  (like e.g. to allow 
> users to create their own external style sheets via form input)
>
> ...for example, in the way this post's answer explains how to use 
> HTMLpurifier and CSStidy together:
>
> http://stackoverflow.com/questions/3241616/
>
> If so, do you know how to set CSStidy's config options in that context?
>
> I found how to set CSStidy's config options if I was running CSStidy from the 
> command line, or on its _own_ from PHP runtime, but I do not know how to set 
> the config options from within HTMLpurifier, or even how to hack/override 
> either of those libraries to solve my particular issue.  I looked and hacked 
> and thought for sure I would find the offending line of code.. but somehow, 
> nothing I have tried is stopping one or both of those libraries from forcing 
> all my input CSS into lowercase, which I do not want.  The issue is that I 
> need the input CSS's case to be left as the user input it (so that for 
> example background image paths in that CSS do not break).
>
> more details, attempted fixes, etc.:
> http://stackoverflow.com/questions/10843600/
>
> Thanks for any thoughts/tips of any kind
> -Govinda

Have you tried http://htmlpurifier.org/phorum/ and did you noticed
"Since the project has been suspended, please only contact me if you
intend to continue maintaining it." for CSSTidy?

Regards,
Tommy

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



Re: [PHP] Is there a way to write to the php error log from a php script?

2010-10-22 Thread vikash . iitb
+1 for log4php. (http://logging.apache.org/log4php/index.html)

I use it regularly and love it.


Thanks,
Vikash Kumar
--
http://vika.sh


On 23 October 2010 08:35, Tommy Pham  wrote:

> > -Original Message-
> > From: Tamara Temple [mailto:tamouse.li...@gmail.com]
> > Sent: Friday, October 22, 2010 5:45 PM
> > To: Daniel P. Brown
> > Cc: PHP General
> > Subject: Re: [PHP] Is there a way to write to the php error log from a
> php
> > script?
> >
> >
> > On Oct 22, 2010, at 7:31 PM, Daniel P. Brown wrote:
> >
> > > On Fri, Oct 22, 2010 at 20:24, Tamara Temple 
> > > wrote:
> > >> I'm trying to log some data for debugging and don't have use of the
> > >> standard output to do so. I'd like to write the info to the php error
> > >> log.
> > >> Can this
> > >> be done from within PHP? I've searched the web site for logging
> > >> functions, but cannot find any.
> > >
> > >Sure.  You can use trigger_error() and error_log() for that.
> >
> > Ah, yes, error_log() is precisely what I'm looking for. Seaching for
> "log"
> gave
> > me the log function, searching for "logging" gave me a bunch of
> references
> I
> > couldn't follow (for some reason the feeds want to open in my Mail.app
> > client and create RSS feeds -- less than useful).
> >
>
> Or you could try this [1], it was ported from log4j.  I used the log4j for
> my java projects and I loved it.
>
> Regards,
> Tommy
>
> [1] http://logging.apache.org/log4php/index.html
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


RE: [PHP] Is there a way to write to the php error log from a php script?

2010-10-22 Thread Tommy Pham
> -Original Message-
> From: Tamara Temple [mailto:tamouse.li...@gmail.com]
> Sent: Friday, October 22, 2010 5:45 PM
> To: Daniel P. Brown
> Cc: PHP General
> Subject: Re: [PHP] Is there a way to write to the php error log from a php
> script?
> 
> 
> On Oct 22, 2010, at 7:31 PM, Daniel P. Brown wrote:
> 
> > On Fri, Oct 22, 2010 at 20:24, Tamara Temple 
> > wrote:
> >> I'm trying to log some data for debugging and don't have use of the
> >> standard output to do so. I'd like to write the info to the php error
> >> log.
> >> Can this
> >> be done from within PHP? I've searched the web site for logging
> >> functions, but cannot find any.
> >
> >Sure.  You can use trigger_error() and error_log() for that.
> 
> Ah, yes, error_log() is precisely what I'm looking for. Seaching for "log"
gave
> me the log function, searching for "logging" gave me a bunch of references
I
> couldn't follow (for some reason the feeds want to open in my Mail.app
> client and create RSS feeds -- less than useful).
> 

Or you could try this [1], it was ported from log4j.  I used the log4j for
my java projects and I loved it.

Regards,
Tommy

[1] http://logging.apache.org/log4php/index.html



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



Re: [PHP] Is there a way to write to the php error log from a php script?

2010-10-22 Thread Tamara Temple


On Oct 22, 2010, at 7:31 PM, Daniel P. Brown wrote:

On Fri, Oct 22, 2010 at 20:24, Tamara Temple  
 wrote:
I'm trying to log some data for debugging and don't have use of the  
standard
output to do so. I'd like to write the info to the php error log.  
Can this
be done from within PHP? I've searched the web site for logging  
functions,

but cannot find any.


   Sure.  You can use trigger_error() and error_log() for that.


Ah, yes, error_log() is precisely what I'm looking for. Seaching for  
"log" gave me the log function, searching for "logging" gave me a  
bunch of references I couldn't follow (for some reason the feeds want  
to open in my Mail.app client and create RSS feeds -- less than useful).




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



Re: [PHP] Is there a way to write to the php error log from a php script?

2010-10-22 Thread Daniel P. Brown
On Fri, Oct 22, 2010 at 20:24, Tamara Temple  wrote:
> I'm trying to log some data for debugging and don't have use of the standard
> output to do so. I'd like to write the info to the php error log. Can this
> be done from within PHP? I've searched the web site for logging functions,
> but cannot find any.

Sure.  You can use trigger_error() and error_log() for that.

-- 

Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



Re: [PHP] is there a way to get more info about *why* the initial (DB PEAR) connect to db is failing?

2009-07-03 Thread Phpster





On Jul 3, 2009, at 7:31 PM, Govinda   
wrote:



my code:

   require 'DB.php';
   // $db=DB::connect('db_program://user:passw...@hostname/database');

   if (DB::isError($db)) { die("Can't connect: " . $db->getMessage 
()); }


is returning:
"Can't connect: DB Error: connect failed"

Any advise to find out WHY this is failing?
(Note: I am fairly new to PHP, and brand spanking new at anything db- 
related with PHP.)


thanks, Govinda

--

P.S.
I realize this had probably been covered countless times (best step  
by step advice how to troubleshoot the first connection to a mysql  
db), so i first did try to search the php list archives, here:

http://marc.info/?l=php-general&w=2&r=1&s=db+connect&q=b
and I am apparently missing something because when I input
"failed db connection"
at the top, in the search box, then it returns posts all over the  
map, and also takes out the middle word in my search string (so now  
it is just "failed db").  Why is that?
I also searched for "failed database connection" which does not  
change my search input, but still the posts I found did not give me  
enough clue to stop me from posting here now.


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



It's usually a simple thing since there are only 3 parameters so it's  
something that you have likely mis-spelled or input in the wrong order.


It's not rocket science to figure it out, the docs are clear about how  
it works.


But a likely guess maybe that you need to connect via localhost  
instead of the full domain name.


  $db=DB::connect('mysql://metheuser:myp...@localhost/mydatabase');


Bastien

Sent from my iPod

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



Re: [PHP] Is there a way to un include a file

2007-03-12 Thread Richard Lynch
No.

You could perhaps wipe out *EVERYTHING* in $_GLOBALS, which would be
the included file and anything in the main file[s] that went before.

If you need an environment that is that "pure" for testing or
something, you can run a different PHP process on each file.

Otherwise, you simply have to architect your application correctly.

Some other solutions to this naming/scope problem include 'packages'
which php doesn't have and 'namespaces' which php doesn't have and...

There have been innumerable flame wars here and on Internals about the
right way to add a new feature to do this, and I don't think there is
any real concensus yet.

On Thu, March 8, 2007 1:18 am, jekillen wrote:
> Hello;
> Is there a way to un include a file once it has been included in a
> script.
> My concern is where two php files might be included in another php
> file they might have code or variables that conflict. I am thinking
> of including files with different names but follow the same pattern
> of code and variables but may have different values for variables
> or different versions of the same function.
> If there is not a specific function for un including a file (I have
> not
> seen any indication from my text books that there is), it seems like
> it would be nice to have one.
> Meanwhile I will be doing some experimentation.
> Thanks in advance;
> Jeff K
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Is there a way to un include a file

2007-03-08 Thread Chris

jekillen wrote:


On Mar 7, 2007, at 11:47 PM, Larry Garfield wrote:


No there is not, because an included file *executes* at the time it is
included and is then done.  Any memory-resident objects (function/class
definitions, variables, etc.) that it defies then exist until you make 
them
un-exist (with unset() for variables or, well, you can't with 
functions and

classes AFAIK).

Include files are libraries.  They are not functions.  What you're 
looking for
is a function.  Don't try to use include files as functions.  Therein 
lies

pain.


I have function definitions in included files all over the place. I do that
so one file will not be too big to keep scrolling back and forth through
to develop and debug. These are mainly in conjunction with multi
phase self processing forms.
Variables I could guess would be overwritten,
but if I have a function fu defined in two different files that are include
in, say, a loop and I want to call one function fu on one iteration from
one included file, then the next iteration I include the next file and
call fu that is a different version, which function would be executed on
the second iteration?


You can't have two functions with the same name for exactly this reason.

$ php -a
Interactive mode enabled

Fatal error: Cannot redeclare a() (previously declared in -:2) in - on 
line 3


So when script '2' is included (ie the 2nd loop), it's going to throw 
this sort of error.



Time to rethink your design.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] Is there a way to un include a file

2007-03-08 Thread jekillen


On Mar 7, 2007, at 11:47 PM, Larry Garfield wrote:


No there is not, because an included file *executes* at the time it is
included and is then done.  Any memory-resident objects (function/class
definitions, variables, etc.) that it defies then exist until you make 
them
un-exist (with unset() for variables or, well, you can't with 
functions and

classes AFAIK).

Include files are libraries.  They are not functions.  What you're 
looking for
is a function.  Don't try to use include files as functions.  Therein 
lies

pain.


I have function definitions in included files all over the place. I do 
that

so one file will not be too big to keep scrolling back and forth through
to develop and debug. These are mainly in conjunction with multi
phase self processing forms.
Variables I could guess would be overwritten,
but if I have a function fu defined in two different files that are 
include

in, say, a loop and I want to call one function fu on one iteration from
one included file, then the next iteration I include the next file and
call fu that is a different version, which function would be executed on
the second iteration?

Thanks for the response, I think I will have to do some experimentation
with this one.
Jeff K

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



Re: [PHP] Is there a way to un include a file

2007-03-07 Thread Larry Garfield
No there is not, because an included file *executes* at the time it is 
included and is then done.  Any memory-resident objects (function/class 
definitions, variables, etc.) that it defies then exist until you make them 
un-exist (with unset() for variables or, well, you can't with functions and 
classes AFAIK).  

Include files are libraries.  They are not functions.  What you're looking for 
is a function.  Don't try to use include files as functions.  Therein lies 
pain.  

On Thursday 08 March 2007 12:18 am, jekillen wrote:
> Hello;
> Is there a way to un include a file once it has been included in a
> script.
> My concern is where two php files might be included in another php
> file they might have code or variables that conflict. I am thinking
> of including files with different names but follow the same pattern
> of code and variables but may have different values for variables
> or different versions of the same function.
> If there is not a specific function for un including a file (I have not
> seen any indication from my text books that there is), it seems like
> it would be nice to have one.
> Meanwhile I will be doing some experimentation.
> Thanks in advance;
> Jeff K

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

"If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it."  -- Thomas 
Jefferson

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



Re: [PHP] Is there a way to un include a file

2007-03-07 Thread Tijnema !

AFAIK there's no function to un include a file, but i don't see a problem
here, as when you include your second file, everything (all conflicting
variables) will be overwritten.
If you still have problems, you might want to use classes around your
functions and variables.

Tijnema


On 3/8/07, jekillen <[EMAIL PROTECTED]> wrote:


Hello;
Is there a way to un include a file once it has been included in a
script.
My concern is where two php files might be included in another php
file they might have code or variables that conflict. I am thinking
of including files with different names but follow the same pattern
of code and variables but may have different values for variables
or different versions of the same function.
If there is not a specific function for un including a file (I have not
seen any indication from my text books that there is), it seems like
it would be nice to have one.
Meanwhile I will be doing some experimentation.
Thanks in advance;
Jeff K

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




Re: [PHP] Is there a way to un include a file

2007-03-07 Thread Børge Holen
On Thursday 08 March 2007 07:18, jekillen wrote:
> Hello;
> Is there a way to un include a file once it has been included in a
> script.

You seems to want the wrong thing... 

I could be mistaken, but from my point of view you would NOT include the file 
if not apropriate at that moment. 


> My concern is where two php files might be included in another php
> file they might have code or variables that conflict. I am thinking
> of including files with different names but follow the same pattern
> of code and variables but may have different values for variables
> or different versions of the same function.
> If there is not a specific function for un including a file (I have not
> seen any indication from my text books that there is), it seems like
> it would be nice to have one.
> Meanwhile I will be doing some experimentation.
> Thanks in advance;
> Jeff K

-- 
---
Børge
Kennel Arivene 
http://www.arivene.net
---

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



Re: [PHP] Is there a way to redefine a constant?

2007-02-09 Thread Jochem Maas
please keep the replies 'on list' ...

Khai Doan wrote:
> Sorry, I hit the Send button by mistake.  My problem is that these
> constant are defined at compile / startup time, before my script get to
> run.  In Perl, I can close STDERR and STDOUT and re-open them to any
> file at anytime.  In Perl, I can also use the BEGIN block.
> Is there a BEGIN block in PHP?

no - there is the auto_prepend_file ini setting - but that won't help you.

> 
> Can I prevent STDERR and STDOUT from being defined at startup time?  

no that I now of (unless you hack the source.)

> I am using CLI.

we figured as much.

can you not redirect stderr/stdout from the cmdline that starts your script?
otherwise you would be stuck with not using those constants and defining 
variables
that point to the stream(s) you want to output to ... AFAIT this should be 
neither
a problem nor a hack.

> 
> Thanks
> Khai
> Jochem Maas wrote:
> 
>> Khai wrote:
>>  
>>
>>> STDERR and STDOUT are defined as constants.  Is there a way to redefine
>>> these constants?
>>>   
>>
>> only if you use runkit (which is probably not recommended in
>> production environments):
>>
>> http://php.net/runkit
>>
>> consider that constants are called as such for a reason. you should
>> consider that
>> it's probably better to define & use a couple of userland vars to
>> point to whatever
>> it is you want to point to - either that or redirect stdout/stderr in
>> the shell/cmdline that calls
>> your script instead.
>>
>>  
>>
>>> Thanks
>>> Khai
>>>
>>>   
>>
>>  
>>
> 

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



Re: [PHP] Is there a way to redefine a constant?

2007-02-09 Thread Jochem Maas
Khai wrote:
> STDERR and STDOUT are defined as constants.  Is there a way to redefine
> these constants?

only if you use runkit (which is probably not recommended in production 
environments):

http://php.net/runkit

consider that constants are called as such for a reason. you should consider 
that
it's probably better to define & use a couple of userland vars to point to 
whatever
it is you want to point to - either that or redirect stdout/stderr in the 
shell/cmdline that calls
your script instead.

> 
> Thanks
> Khai
> 

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



Re: [PHP] Is there a way to redefine a constant?

2007-02-08 Thread Chris

Khai wrote:
STDERR and STDOUT are defined as constants.  Is there a way to redefine 
these constants?


Nope. Once they're set, they're set.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] Is there a way to get multiple values for a single input in a form submission?

2006-03-23 Thread Richard Lynch
On Tue, March 21, 2006 4:44 pm, mslemko wrote:
> this is what I am trying to do:
>
> On a web form I might have a select input with multiple selections
> enabled, however I want to have access to the list within PHP after
> submission.
>
> 

For PHP, use name='myselect[]'

Then PHP turns it into an array as it processes it.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Is there a way to get multiple values for a singleinput in a form submission?

2006-03-23 Thread sgsweb

Hi Mark,

Actually you can access this variable within Javascript in the following 
manner:



function chgablacted() {
 box = regs['myselect[]'];
 value = box.options[box.selectedIndex].value;
 if (value == 'some value') {
   ...
 } else {
   ...
 }
}

The name of the variable will include the brackets [].

sunil.

mslemko wrote:

Thanks Warren,

This works!

The side effect that is -somewhat- undesirable is that it becomes 
incompatible accessing the field with Javascript. Perhaps there is a 
way to get around that problem though.


-Mark

Warren Vail wrote:

Set the name of your field in html to be;

name="myselect[]"

that way when the form is returned to you each selected value is 
returned to you, for example if you code


$choices = $_POST["myselect"];

choices will be an array containing the actual values selected when 
the form is submitted.


hope this is what you were looking for.

Warren Vail



- clip -



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



Re: [PHP] Is there a way to get multiple values for a singleinput in a form submission?

2006-03-23 Thread mslemko

Thanks Warren,

This works!

The side effect that is -somewhat- undesirable is that it becomes 
incompatible accessing the field with Javascript. Perhaps there is a way 
to get around that problem though.


-Mark

Warren Vail wrote:

Set the name of your field in html to be;

name="myselect[]"

that way when the form is returned to you each selected value is 
returned to you, for example if you code


$choices = $_POST["myselect"];

choices will be an array containing the actual values selected when the 
form is submitted.


hope this is what you were looking for.

Warren Vail



- clip -

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



Re: [PHP] Is there a way to get multiple values for a single input in a form submission?

2006-03-21 Thread tedd

this is what I am trying to do:

On a web form I might have a select input with multiple selections 
enabled, however I want to have access to the list within PHP after 
submission.



 1
 2


so when this is submitted, I can see in the $HTTP_RAW_POST_DATA that 
myselect is submitted twice...

...&myselect=1&myselect=2&...

However, the $_POST array only has the last value eg.
$_POST['myselect'] == '2'
This makes sense because the last value is assigned to the key 'myselect'.

Is there a function or alternate way that will get an array back 
from the post-back without parsing through the $HTTP_RAW_POST_DATA 
(which is not always available since the php.ini file can turn it 
off)?


TIA
-MS



MS:

You're not asking for an array, but simply a return of what value 
'myselect' is.


If your url is sending "&myselect=1&myselect=2&...", then something 
else is wrong.


The following --

$what = $_POST('myselect');
echo($what);

-- should show you what's there.

Also, try print_r($_POST);

I have a very simple exampleof POST/GET at:

http://www.weberdev.com/get_example-4345.html

tedd
--

http://sperling.com

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



Re: [PHP] Is there a way to get multiple values for a single input in a form submission?

2006-03-21 Thread Warren Vail

Set the name of your field in html to be;

name="myselect[]"

that way when the form is returned to you each selected value is returned 
to you, for example if you code


$choices = $_POST["myselect"];

choices will be an array containing the actual values selected when the 
form is submitted.


hope this is what you were looking for.

Warren Vail

At 02:44 PM 3/21/2006, mslemko wrote:

this is what I am trying to do:

On a web form I might have a select input with multiple selections 
enabled, however I want to have access to the list within PHP after submission.



 1
 2


so when this is submitted, I can see in the $HTTP_RAW_POST_DATA that 
myselect is submitted twice...

...&myselect=1&myselect=2&...

However, the $_POST array only has the last value eg.
$_POST['myselect'] == '2'
This makes sense because the last value is assigned to the key 'myselect'.

Is there a function or alternate way that will get an array back from the 
post-back without parsing through the $HTTP_RAW_POST_DATA (which is not 
always available since the php.ini file can turn it off)?


TIA
-MS

--
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] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jake Gardner
Jochem: Your method is long, probably takes more time to run, and is
therefore inefficient in this circumstance. There is a time and place
for a good solid reusable function, or even a class.

Of course things could go wrong when using mySQL connections, but
things can always go wrong.

Bringing people to use PHP on a higher standard? I am sorry, but that
is simply childish. There are plenty of kids that think their way in
programming is the best possible way, the only good way, and that
everyone else should try to imitate them.  They also think that every
problem should be solved in the language they are strongest with.
Eventually one must learn that for every way of doing something, there
are at least 5 other ways. Higher standards? Or YOUR standards?

The situation determines the standards, not the programmer.

On 1/10/06, Mike Smith <[EMAIL PROTECTED]> wrote:
> On 1/10/06, Sue <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > We have a form that contains a Select option for a listing of available
> > dates for the user to choose from.  Right now we have to manually change the
> > dates within the form's Selection list as new dates become available to
> > choose from.  We currently store these available dates in our database, and
> > am wondering if we can somehow extract these dates from the table to display
> > in our form?  This would eliminate alot of maintenance needed to this form.
> > If anyone has any ideas as to reference material etc. that I may look which
> > would give me an idea how to do this using PHP, I'd appreciate it!
> How about...
>
> $format = "m/d/Y";
> $sql = "SELECT datefield FROM table";
> $results = $whatever_db_abstraction_your_using_to_execute__sql($sql);
>
> 
>  foreach($results AS $result){
> echo "".date($format,strtotime($result))."";
> }
> ?>
> 
>
> http://us2.php.net/manual/en/function.strtotime.php
> http://us2.php.net/manual/en/function.date.php
>
> Mike
>
> --
> 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] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Mike Smith
On 1/10/06, Sue <[EMAIL PROTECTED]> wrote:
> Hello,
>
> We have a form that contains a Select option for a listing of available
> dates for the user to choose from.  Right now we have to manually change the
> dates within the form's Selection list as new dates become available to
> choose from.  We currently store these available dates in our database, and
> am wondering if we can somehow extract these dates from the table to display
> in our form?  This would eliminate alot of maintenance needed to this form.
> If anyone has any ideas as to reference material etc. that I may look which
> would give me an idea how to do this using PHP, I'd appreciate it!
How about...

$format = "m/d/Y";
$sql = "SELECT datefield FROM table";
$results = $whatever_db_abstraction_your_using_to_execute__sql($sql);


".date($format,strtotime($result))."";
}
?>


http://us2.php.net/manual/en/function.strtotime.php
http://us2.php.net/manual/en/function.date.php

Mike

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jochem Maas

David Grant wrote:

Jochem,

Jochem Maas wrote:


David Grant wrote:
1. your looping a result set which involves a db connection - lots
of pontential things that could go wrong...



Absolutely, and lots of lessons to learn too.


by that argument your own children shouldn't be sent to
school; and rather than showing then the kitchen stove one should
stick them in the garden with lots of sticks and wait until they learn
how to make fire on their own. (ok that was just to make the point - by
no means am I trying to offend!)

granted that some background is needed to give context to the
rationale (of my point 1 above). although it's questionable as
to have useful the background info could be given the ammount of
peripheral knowledge is required to make sense of some of the issues.





2. its not a centralized 'solution' - code reuse is a good thing.



However, what use is code reuse when you're using it only once.  If you
need to perform the same function again, then refactor the existing code.


you don't really think I wrote that function for her do you?
hopefully Sue got that too. I saw her email, I had the file in question
close at hand, I cut/paste & hit send - done.

besides I doubt that this will be the last dynamic select box Sue will want
to create (assuming she stick with this kind of work).





3. we should encourage people to aim a little higher?



I imagine my first PHP script with a database connection probably looked
much like Adrian's solution, and writing lots and lots of PHP has taught


which is no argument for poluting the public space with even more code of
that ilk.


be some best practices that I now stick to.  However, being told that I


ever heard of the concept of learning from _other_ peoples mistakes? ;-)


need to write reusable functions for iterating a resultset would've had
me running off to another scripting language in a heartbeat.


I'd did tell her she had to use a function - quite clearly she was offered
something that nobody disputes will work as far as it goes.



Tell people to aim higher, sure, but let them make their own mind up,


I said encourage - which is doen by example rather than with a proverbial stick.


make their own mistakes and learn from them. :)


yeah so if Sue speaks I'll listen - Sue you seem to have carte blanche to
rip me to shreds so what are you waiting for :-)





Even the longest journeys start with small steps, and asking someone new
to PHP to separate various tiers might put them off.


which I could spin as a positive thing - raising the lowest commom
denominator
so to speak. besides Sue was the one that came with the many-in-one
question
(i.e. how to a dynamically generate a select box AND how do I grab data
from
a DB).



I'm sure you're not being elitist, but where do you place the bar?


I think I post enough stuff here to rule out major elitism.
the only real bar I would place is that people are making an effort to
research/investigate and document their problems before asking someone
here for a solution.

to be honest Sue's question was vague, contained 'many' implicits and
showed no indication of having researched the issue. but heck she's female
so I let it pass this time ;-)

the bar has nothing to do with skill and everything to do with effort.


Should PHP be made a language that only the experienced can get into?


no not at all - but I do feel that answers on mailing lists should
be quality controlled to some extent - that way more of the correct
assumptions and good practices get through to _us_ programmers.

the bar to entry is low with php - that doen't mean we should encourage
to stay at that low level once they are in. n'est pas?


That sounds like a policy that would only harm the PHP community.


indeed.



David


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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread DarkX
You mean like...

$Link = mysql_connect("Host", "User", "Pass");
mysql_select_db("MyDB");
$Datefield = "Dates";
$Select = mysql_query("SELECT * FROM `Table` WHERE `".$Dates."` LIKE *");
$MySelect = ""
While($Row = @mysql_fetch_assoc($Select)) {
  //Adds each date to the select where the value is also equal to the date
  //You can use an increment as well for the value, or whatever you want
  $MySelect .= "".$Row[$Datefield]."";
}
$MySelect .= "";
mysql_close($Link);

On 1/10/06, Jochem Maas <[EMAIL PROTECTED]> wrote:
>
> Sue wrote:
> > Hello,
> >
> > We have a form that contains a Select option for a listing of available
> > dates for the user to choose from.  Right now we have to manually change
> the
> > dates within the form's Selection list as new dates become available to
> > choose from.  We currently store these available dates in our database,
> and
> > am wondering if we can somehow extract these dates from the table to
> display
> > in our form?  This would eliminate alot of maintenance needed to this
> form.
> > If anyone has any ideas as to reference material etc. that I may look
> which
> > would give me an idea how to do this using PHP, I'd appreciate it!
>
> I am guessing that your php skills are not that hot. filling a select box
> is php 101 here is function that generates a selectbox based on the
> given
> 'data' - now you have to go and figure out how to build the array $items
> (which is passed as the first arg to this function) from the data in your
> table:
>
> /** selectTag()
> *  generate an html select list using the given $items as options.
> *
> * @param   array   $items  - list of items to display as options
> * @param   array   $selected   - value of select item in $items
> * @param   string  $selectname - value of select tag's name attribute
> * @param   numeric $addnone- add a 'blank' option to the top of the
> list
> *   (different types depending on valuepassed)
> * @param   string  $onchange   - value of select tag's onchange attribute
> * @param   string  $selectid   - value of select tag's id attribute
> * @param   boolean $readonly   - whether the select tag is readsonly or
> not
> * @param   array   $readonly   - whether the select tag is readsonly or
> not
> * @param   boolean $option_class_arr   - optional CSS class names for
> individual option tags
> * @param   string  $selectHTMLattribs  - passthru HTML (attributes for the
> select tag)
> *
> * @return  string
> */
> function selectTag($items, $selected = '', $selectname = '',
>   $addnone = 0, $onchange = '', $selectid = '',
>   $readonly = 0, $option_class_arr = array(),
> $selectHTMLattribs = '')
> {
> // must have an array of items
> if (!is_array($items)) {
> return '';
> }
>
> // determine the value of the selected item
> $selected = strtolower(trim($selected));
>
> // list of options we will generate
> $opts = array();
>
> // add item with value 0 ?
> $add_none_value = 0;
> switch ( $addnone )  {
> case '1':   // item display = 'none'
> $zero_id_item = getStr('None');
> break;
> case '3':   // item display = '0'
> $zero_id_item = getStr('zero_digit');
> break;
> case '2':   // item display = 'all'
> case '4':   // item display = 'all ' e.g. 'all 3'
> $zero_id_item = getStr('All');
> break;
> default:
> if(!empty($addnone) && $addnone != '0') {
> if(is_array($addnone)) {
> list($add_none_value, $zero_id_item) =
> @each($addnone);
> } else {
> // here we can drop in a custom 'blank' item:
> $zero_id_item = $addnone;
> }
> }
> break;
> }
> if (isset($zero_id_item)) {
> $thisselected = ($selected > '')  ? '' : ' selected="selected"';
> // FIX THE NEXT LINE - BUT NOT IMPORTANT
> $opts[] = '  .$thisselected'>'.ucwords($zero_id_item).'';
> }
>
> $thisselected = '';
> foreach ($items as  $value => $displayname) {
> $thisselected = ($selected > '' && $selected ==
> strtolower($value)) ? ' selected="selected"' : '';
> $class_var= (isset($option_class_arr[$value])) ? ' class="' .
> $option_class_arr[$value] . '" ' : '';
> $opts[]   = ''.ucwords($displayname).'';
> }
>
> // various select tag attribute values
> $onchange = (($onchange = trim($onchange)) > '')
>   ? " onchange=\"$onchange\""
>   : ''
>   ;
> $id   = ($selectid = strval($selectid))
>   ? " id=\"{$selectid}\""
>   : ''
>   ;
> $readonly = ($readonly == 1)
>   ? ' readonly="readonly"'
>   : ''
>   ;
>
> return " {$selectHTMLattribs}{$id}{$onchange}{$re

Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jochem Maas

Adrian Bruce wrote:
the quickest solution and one that is easy to understand, I am no php 
expert and have never claimed as such so why 'noob'?


Why is this such a poor method? if i type the HTML to be outputted 
correctly then what validation is required? also I think Someone new 
would run from your proposed solution


I don't really care if she runs. actually if she is liable to run then
that probably saves us here a lot of 'silly' questions ;-)

her original question:

"Is there a way to display data from database for Select Options in a form?"

the short answer is: 'yes'
but the way her original question was posted suggests that maybe she has
_absolutely_ no idea about how to use php... I mean google is able to
help her in theory:

http://www.google.com/search?num=100&q=generate+dynamic+select+box+PHP

either she has no idea what to search for or she was to lazy to try -
if the former then she should have not be ashamed to keep asking away, if
the latter then, well, who cares.

the reason I gave her what might be more than she can chew (the function)
was because:

a, her initial question was a bit vague (or rather broad)
b, to show that there can be a little more to generating dynamic elements
like select box.
c, to encourage generic code.
d, test her and she what her reaction is (hopefully she won't run away; instead
maybe she'll come back with a more specific question and DB data extraction)**

** heck I'm on this list for fun :-)



Jochem Maas wrote:


teaching noobs to output html while (oun intended) looping thru a
result set is counter-productive. discuss.

Adrian Bruce wrote:


Something along these lines will work fine

";

while ($row = mysql_fetch_array($query, MYSQL_NUM)){
 echo"$row[1]";

}
echo"";
?>

Regards
Ade

Sue wrote:


Hello,

We have a form that contains a Select option for a listing of 
available dates for the user to choose from.  Right now we have to 
manually change the dates within the form's Selection list as new 
dates become available to choose from.  We currently store these 
available dates in our database, and am wondering if we can somehow 
extract these dates from the table to display in our form?  This 
would eliminate alot of maintenance needed to this form. If anyone 
has any ideas as to reference material etc. that I may look which 
would give me an idea how to do this using PHP, I'd appreciate it!


Thanks!
Sue
 







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



Re: [PHP] Is there a way to display data from database for SelectOptions in a form?

2006-01-10 Thread Jochem Maas

Jay Paulson (CE CEN) wrote:

[snip]Let's look at it another way, why 70-80 lines of code when 4 will do it
properly when done correctly?[/snip]


4 * 20 = 80
so after having created 20 dynamic select boxes the function wins it.
I really don't think that performance here is the issue - one should tackle
that with suitable caching not writing unmanagable speed-freak-code.

on top of that there is a high chance that the 4 lines will be copy/pasted
quite often - a great way to replicate small little errors. in contrast to the
function which keeps the 'template' HMTL output (of the select box) in
a single place (handy for making site wide changes - for instance all a 
requirement
that means all selectboxes must have a certain class attribute value?)

another advantage of the function is that it takes into account
attributes/functionality that you might not need in this particular case now -
but might come in handy. using the function means not having to hack stuff
in later)



I agree with this line of thinking especially for a new person to php.

When I first read the solution that was so long I thought to myself "great and this person is new to php and now they are going to be scared of php."  


Sue 

DON'T PANIC (sorry for the lack of friendly letters)

(the fear argument doesn't wash with me btw; if Sue has more questions she 
should fire away!)
(with regard to fear: go read some Krishnamurti or have children or something - 
either you go
mad or you get over it ;-)



I really think one of the appeals of php is it's simplicity of getting things done and getting those things done quickly.  


Yes it's great having one function to output every select html form but is it 
really necessary?


sheesh - it's not [YouMustBeJokingIfYouThinkDevelopingWithThisIs]QuickForm
(the 'YouMustBeJokingIfYouThinkDevelopingWithThisIs' is silent ;-)







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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread David Grant
Jochem,

Jochem Maas wrote:
> David Grant wrote:
> 1. your looping a result set which involves a db connection - lots
> of pontential things that could go wrong...

Absolutely, and lots of lessons to learn too.

> 2. its not a centralized 'solution' - code reuse is a good thing.

However, what use is code reuse when you're using it only once.  If you
need to perform the same function again, then refactor the existing code.

> 3. we should encourage people to aim a little higher?

I imagine my first PHP script with a database connection probably looked
much like Adrian's solution, and writing lots and lots of PHP has taught
be some best practices that I now stick to.  However, being told that I
need to write reusable functions for iterating a resultset would've had
me running off to another scripting language in a heartbeat.

Tell people to aim higher, sure, but let them make their own mind up,
make their own mistakes and learn from them. :)

>>
>> Even the longest journeys start with small steps, and asking someone new
>> to PHP to separate various tiers might put them off.
> 
> which I could spin as a positive thing - raising the lowest commom
> denominator
> so to speak. besides Sue was the one that came with the many-in-one
> question
> (i.e. how to a dynamically generate a select box AND how do I grab data
> from
> a DB).

I'm sure you're not being elitist, but where do you place the bar?
Should PHP be made a language that only the experienced can get into?
That sounds like a policy that would only harm the PHP community.

David
-- 
David Grant
http://www.grant.org.uk/

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jochem Maas

David Grant wrote:

Jochem,

Jochem Maas wrote:


teaching noobs to output html while (oun intended) looping thru a
result set is counter-productive. discuss.



I disagree, however, I do believe attention should be drawn to reasons
why doing so might be considered bad practice.


1. your looping a result set which involves a db connection - lots
of pontential things that could go wrong...

2. its not a centralized 'solution' - code reuse is a good thing.

3. we should encourage people to aim a little higher?



Even the longest journeys start with small steps, and asking someone new
to PHP to separate various tiers might put them off.


which I could spin as a positive thing - raising the lowest commom denominator
so to speak. besides Sue was the one that came with the many-in-one question
(i.e. how to a dynamically generate a select box AND how do I grab data from
a DB).



David


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



RE: [PHP] Is there a way to display data from database for SelectOptions in a form?

2006-01-10 Thread Jay Paulson \(CE CEN\)
[snip]Let's look at it another way, why 70-80 lines of code when 4 will do it
properly when done correctly?[/snip]

I agree with this line of thinking especially for a new person to php.

When I first read the solution that was so long I thought to myself "great and 
this person is new to php and now they are going to be scared of php."  

I really think one of the appeals of php is it's simplicity of getting things 
done and getting those things done quickly.  

Yes it's great having one function to output every select html form but is it 
really necessary?


Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Adrian Bruce
the quickest solution and one that is easy to understand, I am no php 
expert and have never claimed as such so why 'noob'?


Why is this such a poor method? if i type the HTML to be outputted 
correctly then what validation is required? also I think Someone new 
would run from your proposed solution


Jochem Maas wrote:


teaching noobs to output html while (oun intended) looping thru a
result set is counter-productive. discuss.

Adrian Bruce wrote:


Something along these lines will work fine

";

while ($row = mysql_fetch_array($query, MYSQL_NUM)){
 echo"$row[1]";

}
echo"";
?>

Regards
Ade

Sue wrote:


Hello,

We have a form that contains a Select option for a listing of 
available dates for the user to choose from.  Right now we have to 
manually change the dates within the form's Selection list as new 
dates become available to choose from.  We currently store these 
available dates in our database, and am wondering if we can somehow 
extract these dates from the table to display in our form?  This 
would eliminate alot of maintenance needed to this form. If anyone 
has any ideas as to reference material etc. that I may look which 
would give me an idea how to do this using PHP, I'd appreciate it!


Thanks!
Sue
 







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



RE: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jay Blanchard
[snip]
> [snip]
> teaching noobs to output html while (oun intended) looping thru a
> result set is counter-productive. discuss.
> [/snip]
> 
> Why is this counter-productive?

it's a shit way of doing things - with the added bonus that it usually
comes with shit output (as non-validating, bare-minimum-to-get-it-working
HTML).

is that enough 'why' to start a discussion ;-) probably not :-)
[/snip]

If not, then give us some more. :)

As to why the HTML would be non-validating it would only be because it
wasn't formatted properly in the output.

Let's look at it another way, why 70-80 lines of code when 4 will do it
properly when done correctly?

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jochem Maas

Jay Blanchard wrote:

[snip]
teaching noobs to output html while (oun intended) looping thru a
result set is counter-productive. discuss.
[/snip]

Why is this counter-productive?


it's a shit way of doing things - with the added bonus that it usually
comes with shit output (as non-validating, bare-minimum-to-get-it-working
HTML).

is that enough 'why' to start a discussion ;-) probably not :-)

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread David Grant
Jochem,

Jochem Maas wrote:
> teaching noobs to output html while (oun intended) looping thru a
> result set is counter-productive. discuss.

I disagree, however, I do believe attention should be drawn to reasons
why doing so might be considered bad practice.

Even the longest journeys start with small steps, and asking someone new
to PHP to separate various tiers might put them off.

David
-- 
David Grant
http://www.grant.org.uk/

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



RE: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jay Blanchard
[snip]
teaching noobs to output html while (oun intended) looping thru a
result set is counter-productive. discuss.
[/snip]

Why is this counter-productive?

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jochem Maas

teaching noobs to output html while (oun intended) looping thru a
result set is counter-productive. discuss.

Adrian Bruce wrote:

Something along these lines will work fine

";

while ($row = mysql_fetch_array($query, MYSQL_NUM)){
 echo"$row[1]";

}
echo"";
?>

Regards
Ade

Sue wrote:


Hello,

We have a form that contains a Select option for a listing of 
available dates for the user to choose from.  Right now we have to 
manually change the dates within the form's Selection list as new 
dates become available to choose from.  We currently store these 
available dates in our database, and am wondering if we can somehow 
extract these dates from the table to display in our form?  This would 
eliminate alot of maintenance needed to this form. If anyone has any 
ideas as to reference material etc. that I may look which would give 
me an idea how to do this using PHP, I'd appreciate it!


Thanks!
Sue
 





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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Jochem Maas

Sue wrote:

Hello,

We have a form that contains a Select option for a listing of available 
dates for the user to choose from.  Right now we have to manually change the 
dates within the form's Selection list as new dates become available to 
choose from.  We currently store these available dates in our database, and 
am wondering if we can somehow extract these dates from the table to display 
in our form?  This would eliminate alot of maintenance needed to this form. 
If anyone has any ideas as to reference material etc. that I may look which 
would give me an idea how to do this using PHP, I'd appreciate it!


I am guessing that your php skills are not that hot. filling a select box
is php 101 here is function that generates a selectbox based on the given
'data' - now you have to go and figure out how to build the array $items
(which is passed as the first arg to this function) from the data in your table:

/** selectTag()
 *  generate an html select list using the given $items as options.
 *
 * @param   array   $items  - list of items to display as options
 * @param   array   $selected   - value of select item in $items
 * @param   string  $selectname - value of select tag's name attribute
 * @param   numeric $addnone- add a 'blank' option to the top of the list
 *(different types depending on valuepassed)
 * @param   string  $onchange   - value of select tag's onchange attribute
 * @param   string  $selectid   - value of select tag's id attribute
 * @param   boolean $readonly   - whether the select tag is readsonly or not
 * @param   array   $readonly   - whether the select tag is readsonly or not
 * @param   boolean $option_class_arr   - optional CSS class names for 
individual option tags
 * @param   string  $selectHTMLattribs  - passthru HTML (attributes for the 
select tag)
 *
 * @return  string
 */
function selectTag($items, $selected = '', $selectname = '',
   $addnone = 0, $onchange = '', $selectid = '',
   $readonly = 0, $option_class_arr = array(), 
$selectHTMLattribs = '')
{
// must have an array of items
if (!is_array($items)) {
return '';
}

// determine the value of the selected item
$selected = strtolower(trim($selected));

// list of options we will generate
$opts = array();

// add item with value 0 ?
$add_none_value = 0;
switch ( $addnone )  {
case '1':   // item display = 'none'
$zero_id_item = getStr('None');
break;
case '3':   // item display = '0'
$zero_id_item = getStr('zero_digit');
break;
case '2':   // item display = 'all'
case '4':   // item display = 'all ' e.g. 'all 3'
$zero_id_item = getStr('All');
break;
default:
if(!empty($addnone) && $addnone != '0') {
if(is_array($addnone)) {
list($add_none_value, $zero_id_item) = @each($addnone);
} else {
// here we can drop in a custom 'blank' item:
$zero_id_item = $addnone;
}
}
break;
}
if (isset($zero_id_item)) {
$thisselected = ($selected > '')  ? '' : ' selected="selected"';
// FIX THE NEXT LINE - BUT NOT IMPORTANT
$opts[] = ''.ucwords($zero_id_item).'';
}

$thisselected = '';
foreach ($items as  $value => $displayname) {
$thisselected = ($selected > '' && $selected == strtolower($value)) ? ' 
selected="selected"' : '';
$class_var= (isset($option_class_arr[$value])) ? ' class="' . 
$option_class_arr[$value] . '" ' : '';
$opts[]   = ''.ucwords($displayname).'';
}

// various select tag attribute values
$onchange = (($onchange = trim($onchange)) > '')
  ? " onchange=\"$onchange\""
  : ''
  ;
$id   = ($selectid = strval($selectid))
  ? " id=\"{$selectid}\""
  : ''
  ;
$readonly = ($readonly == 1)
  ? ' readonly="readonly"'
  : ''
  ;

return "".
   join('', $opts).
   '';
}




Thanks!
Sue 



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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread David Grant
Sue,

Sue wrote:
> We have a form that contains a Select option for a listing of available 
> dates for the user to choose from.  Right now we have to manually change the 
> dates within the form's Selection list as new dates become available to 
> choose from.  We currently store these available dates in our database, and 
> am wondering if we can somehow extract these dates from the table to display 
> in our form?  This would eliminate alot of maintenance needed to this form. 
> If anyone has any ideas as to reference material etc. that I may look which 
> would give me an idea how to do this using PHP, I'd appreciate it!

I'd recommend reading the PHP manual at:

http://www.php.net/docs.php

There you will find chapters on using various database functions, such as:

MySQL
http://www.php.net/manual/en/ref.mysql.php

PostgreSQL
http://www.php.net/manual/en/ref.pgsql.php

Microsoft SQL Server
http://www.php.net/manual/en/ref.mssql.php

Oracle
http://www.php.net/manual/en/ref.oracle.php

David
-- 
David Grant
http://www.grant.org.uk/

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



Re: [PHP] Is there a way to display data from database for Select Options in a form?

2006-01-10 Thread Adrian Bruce

Something along these lines will work fine

";

while ($row = mysql_fetch_array($query, MYSQL_NUM)){
  
   echo"$row[1]";


}
echo"";
?>

Regards
Ade

Sue wrote:


Hello,

We have a form that contains a Select option for a listing of available 
dates for the user to choose from.  Right now we have to manually change the 
dates within the form's Selection list as new dates become available to 
choose from.  We currently store these available dates in our database, and 
am wondering if we can somehow extract these dates from the table to display 
in our form?  This would eliminate alot of maintenance needed to this form. 
If anyone has any ideas as to reference material etc. that I may look which 
would give me an idea how to do this using PHP, I'd appreciate it!


Thanks!
Sue 

 



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



Re: [PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-23 Thread Yaswanth Narvaneni
Dirty Code

if((ereg("Nav", getenv("HTTP_USER_AGENT"))) || (ereg("Gold",
getenv("HTTP_USER_AGENT"))) || (ereg("X11",
getenv("HTTP_USER_AGENT"))) || (ereg("Mozilla", getenv(
"HTTP_USER_AGENT"))) || (ereg("Netscape", getenv("HTTP_USER_AGENT")))
AND (!ereg("MSIE", getenv("HTTP_USER_AGENT" $c_browser =
"Netscape";
elseif(ereg("MSIE", getenv("HTTP_USER_AGENT"))) $c_browser = "MSIE";
elseif(ereg("Lynx", getenv("HTTP_USER_AGENT"))) $c_browser = "Lynx";
elseif(ereg("Opera", getenv("HTTP_USER_AGENT"))) $c_browser = "Opera";
elseif(ereg("WebTV", getenv("HTTP_USER_AGENT"))) $c_browser = "WebTV";
elseif(ereg("Konqueror", getenv("HTTP_USER_AGENT"))) $c_browser = "Konqueror";
elseif((eregi("bot", getenv("HTTP_USER_AGENT"))) || (ereg("Google",
getenv("HTTP_USER_AGENT"))) || (ereg("Slurp",
getenv("HTTP_USER_AGENT"))) || (ereg("Scooter",
getenv("HTTP_USER_AGENT"))) || (eregi("Spider",
getenv("HTTP_USER_AGENT"))) || (eregi("Infoseek",
getenv("HTTP_USER_AGENT" $c_browser = "Bot";
else $c_browser = "Other";


On 11/23/05, Frank Armitage <[EMAIL PROTECTED]> wrote:
> twistednetadmin wrote:
> > Thanks guys. That helps alot!
> >
> > But this:
> >  > print $_SERVER['HTTP_USER_AGENT'];
> > ?>
> >
> > Returned this using Mozilla: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> > rv:1.7.12) Gecko/20050915 Firefox/1.0.7
> > And this using IE: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
> >
> > Does that just mean that it's not completely accurate?
> >
>
> Try get_browser()
> http://php.net/manual/en/function.get-browser.php
>
> HTH
> Frank
>
> --
> tradeOver | http://www.tradeover.net
> ready to become the King of the World?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
"In theory there is no difference between theory and practice.
In practice there is." -- Fortune Cookie

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



Re: [PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-23 Thread Frank Armitage
twistednetadmin wrote:
> Thanks guys. That helps alot!
> 
> But this:
>  print $_SERVER['HTTP_USER_AGENT'];
> ?>
> 
> Returned this using Mozilla: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> rv:1.7.12) Gecko/20050915 Firefox/1.0.7
> And this using IE: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
> 
> Does that just mean that it's not completely accurate?
> 

Try get_browser()
http://php.net/manual/en/function.get-browser.php

HTH
Frank

-- 
tradeOver | http://www.tradeover.net
ready to become the King of the World?

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



Re: [PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-23 Thread David Grant
$_SERVER['HTTP_USER_AGENT'] contains whatever the browser passes to the
server to identify itself, which may be faked by certain browsers at the
discretion of the user.

The two user agents you provide as an example are both extremely common.

Cheers,

David Grant

twistednetadmin wrote:
> Thanks guys. That helps alot!
> 
> But this:
>  print $_SERVER['HTTP_USER_AGENT'];
> ?>
> 
> Returned this using Mozilla: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> rv:1.7.12) Gecko/20050915 Firefox/1.0.7
> And this using IE: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
> 
> Does that just mean that it's not completely accurate?
> 

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



Re: [PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-22 Thread twistednetadmin
Thanks guys. That helps alot!

But this:


Returned this using Mozilla: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7.12) Gecko/20050915 Firefox/1.0.7
And this using IE: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

Does that just mean that it's not completely accurate?


Re: [PHP] Is there a way to determine wich browser a visitor uses in php?

2005-11-22 Thread Joe Wollard

On Nov 23, 2005, at 12:43 AM, twistednetadmin wrote:


Is it possible to use PHP to find out wich type of browser is in use?
Or must is this done by javascript or something else?
I would like to have a little statistic on my page that tells me what
browser is currently moet used.



Try:



-Joe W

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



RE: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Daevid Vincent
> He wants a function that, if you put in $x, you get out 'x'
> 
> For *ANY* $variable.
> 
> There is no such function.


> Usually the person asking it is doing something very 
> newbie-ish, and very wrong.

Actually it's not either...

Since you can't easily debug when generating XML, as malformed XML will STB,
I have this function which dumps out an array and recursively sub arrays.

It would be very useful to dump out the name of the variable as part of
this, as a lot of text is on the screen with all the tags and such. 

It always annoyed me about print_r() that it doesn't tell you the variable
name either, so you have to always prefix it with an echo/print just above
the print_r.

/**
* Print out an array in XML form (useful for debugging)
* @access   public
* @paramstring $myArray the array to output in XML format
* @version  1.0
* @date 07/19/05
* @todo It would be nice if we could extract the array's variable
name and output that as an attribute
*/
function print_r_xml($myArray)
{
print xmltag('ARRAY', null, 1);
foreach($myArray as $k => $v)
{
if (is_array($v))
print_r_xml($v);
else
print xmltag($k,htmlspecialchars($v));
}
print xmltag('ARRAY', null, 2);
}

/**
* Add the starting, or ending, or both xml tags
*
* @return   string xml formatted tags and data
* @paramstring $xmltag  is the tag name to surround
* @parammixed $data data to output between the tags, if $data is
an array, it will be expanded as KEY=VALUE in the tag
* @paramint $tagType 1=start tag only, 2=end tag only, 3=default
* @version  1.2
* @date 06/14/05
*/
function xmltag($xmltag, $data, $tagType = 3) 
{
// remove spaces and make uppercase
$xmltag = str_replace(' ','_', $xmltag );
//$xmltag = strtoupper( $xmltag );

$data = str_replace('&','&', $data );   // fix data with &
$data = str_replace('<','<', $data );// fix data with <
$data = str_replace('>','>', $data );// fix data with >

if ($tagType == 3) 
{
if (isset($data))
{
if (is_array($data))
{
$tmp = '<'.$xmltag;

if (is_array($data))
{
foreach($data as $key => $value)
$tmp .= '
'.$key.'="'.$value.'"';
}

$tmp .= " />\r\n";

return $tmp;
}
else
return
'<'.$xmltag.'>'.$data.'\r\n";
}
else
return '<'.$xmltag." />\r\n";
}

if ($tagType == 1)  
{
$tmp = '<'.$xmltag;

if (is_array($data))
{
foreach($data as $key => $value)
$tmp .= ' '.$key.'="'.$value.'"';
}

$tmp .= ">\r\n";

return $tmp;
}

if ($tagType == 2)  return '\r\n";
}

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



RE: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Daevid Vincent
> What I was thinking with debug_backtrace() is that you could get the 
> information for the function that called the function you want the 
> variable name for, *reducing* the likelyhood of duplicate values, but 
> admitedly not eliminating it.
> 
> You could also pass the name of the variable to the function:
> 
> someFunction($foo, $varName=""){ print $varName; }
> 
> call it with -> someFunction($bar, 'bar');
> 
> That would definately get you what you want, but again it 
> would be messy to look at.

Well if you called someFunction('bar');

Function someFunction($myVar)
{
global $$myVar;
echo "the variable name is '$myVar' and has the value of ".$$myVar;
}

But that relies on the global and is also a bit messy in a recursive
situation.

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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Edward Vermillion

Richard Lynch wrote:

[snip]



PS

It's true that your variable could/would/should appear in debug_backtrace,
but how would you pick it out from all the other variables that would
appear in your debug_backtrace?

For that matter, it's in $_GLOBALS, but how would you pick it out?

You could print out all variables that were equal to your variable, and
have a list of candidates...

\n";
  }
?>



What I was thinking with debug_backtrace() is that you could get the 
information for the function that called the function you want the 
variable name for, *reducing* the likelyhood of duplicate values, but 
admitedly not eliminating it.


You could also pass the name of the variable to the function:

someFunction($foo, $varName=""){ print $varName; }

call it with -> someFunction($bar, 'bar');

That would definately get you what you want, but again it would be messy 
to look at.


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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-22 Thread Richard Lynch
On Mon, July 18, 2005 8:24 pm, Ryan A said:
> I didnt totally understand you q in the beginning (and still dont fully),
> but



He wants a function that, if you put in $x, you get out 'x'

For *ANY* $variable.

There is no such function.

Usually the person asking it is doing something very newbie-ish, and very
wrong.

I know, cuz I was that person, many many years ago. :-)

I think what I needed that time was "variable variables"...

The other thing that tends to bring up this question is somebody trying to
write a custom error handler, not knowing about
http://php.net/trigger_error and friends.  Though that only gets you the
line number and filename where the error occured, not a specific variable
name.

If for some reason one *NEEDS* to have "names" and variables and to know
what a variable's "name" is, you *probably* want to use an associative
array and use the "keys" as your names.

Hopefully this is helpful to the Original Poster, or somebody some day.

PS

It's true that your variable could/would/should appear in debug_backtrace,
but how would you pick it out from all the other variables that would
appear in your debug_backtrace?

For that matter, it's in $_GLOBALS, but how would you pick it out?

You could print out all variables that were equal to your variable, and
have a list of candidates...

\n";
  }
?>

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-19 Thread Burhan Khalid

Rasmus Lerdorf wrote:

Daevid Vincent wrote:


Is there a way to get the name of a variable as a string? For example...



Nope, not possible.


Well

ob_start();
echo '$var';
$contents = ob_get_contents();
ob_end_clean();

echo 'Variable Name is : '.substr($contents,strpos($contents,'$')+1);

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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Tyler Kiley
function named_print($var_name) {
  return "echo 'the variable named $var_name is set to ' . \$var_name;"
}

eval(named_print($foo));

;-)

Tyler

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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Edward Vermillion

Edward Vermillion wrote:

Rasmus Lerdorf wrote:


Daevid Vincent wrote:


Is there a way to get the name of a variable as a string? For example...




Nope, not possible.

-Rasmus

Wouldn't the name of the variable show up in a var_dump()? It would be 
messy, but if it's there...




Actually I meant debug_backtrace()... Damn fingers... but it is still a 
question. :)


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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Edward Vermillion

Rasmus Lerdorf wrote:

Daevid Vincent wrote:


Is there a way to get the name of a variable as a string? For example...



Nope, not possible.

-Rasmus

Wouldn't the name of the variable show up in a var_dump()? It would be 
messy, but if it's there...


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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Ryan A
I didnt totally understand you q in the beginning (and still dont fully),
but

> > Is there a way to get the name of a variable as a string? For example...

> Nope, not possible.
> -Rasmus

the man has spoken :-D

-Ryan

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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Rasmus Lerdorf
Daevid Vincent wrote:
> Is there a way to get the name of a variable as a string? For example...

Nope, not possible.

-Rasmus

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



RE: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Rob Agar
hi Daevid

FWIW, I was trying to do the exact same thing a while back, and came to
the conclusion that it wasn't possible.

Rob

> -Original Message-
> From: Daevid Vincent [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, 19 July 2005 11:28 AM
> To: php-general@lists.php.net
> Subject: [PHP] Is there a way to get a variable name as a string?
> 
> 
> Is there a way to get the name of a variable as a string? For 
> example...
> 
> Function myname ($foo)
> {
>   echo "the variable name passed in is ".realname($foo);
> }
> 
> myname($bar);
>
> 
> I want to see printed out:
> 
> "the variable name passed in is bar"
> ^^^
> 
> Dig what I'm trying to do?
> 
> And 'why?' you may ask am I trying to do this... Well, I am 
> sick of always
> putting an "echo 'printing out bar:'; print_r($bar);" all the 
> time. I want
> to make a wrapper function.
> 
> I also have written one for XML that would be nice to make a 
> NAME='bar'
> attribute...
> 
> /**
> * Print out an array in XML form (useful for debugging)
> * @access public
> * @author Daevid Vincent [EMAIL PROTECTED]
> * @since  4.0b4
> * @version1.0
> * @date   07/18/05
> */
> function print_r_xml($myArray)
> {
>   print xmltag('ARRAY', array('NAME'=>'myArray'), 1);
>   foreach($myArray as $k => $v)
>   {
>   if (is_array($v))
>   print_r_xml($v);
>   else
>   print xmltag($k,htmlspecialchars($v));
>   }
>   print xmltag('ARRAY', null, 2);
> }
> 
> -- 
> 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] Is there a way to get a variable name as a string?

2005-07-18 Thread Daevid Vincent
That won't work. Then I will get what the VALUE of $bar is set to. I want
the actual text "bar". Basically everything after the "$" -- ie. The NAME of
the VARIABLE, not it's contents.

The closest I've come so far is to do this.


Function myname($foo)
{
echo "variable named $foo has the contents $$foo";
} 

Myname('bar');

Which is pretty lame.


> -Original Message-
> From: Ryan A [mailto:[EMAIL PROTECTED] 
> Sent: Monday, July 18, 2005 6:57 PM
> To: [EMAIL PROTECTED]
> Cc: php
> Subject: Re: [PHP] Is there a way to get a variable name as a string?
> 
> Maybe something like:
> 
> 
>  Function myname ($foo)
>  {
> $return_value="the variable name passed in is ".$foo;
> return $return_value;
> }
> 
> echo myname($bar);
> 
> 
> Just a guess.
> 
> 
> On 7/19/2005 3:27:57 AM, Daevid Vincent ([EMAIL PROTECTED]) wrote:
> > Is there a way to get the name of a variable as a string? 
> For example...
> >
> > Function myname ($foo)
> > {
> > echo "the variable name passed in is ".realname($foo);
> > }
> >
> > myname($bar);
> > 
> >
> > I want to see printed out:
> >
> > "the variable name passed in is bar"
> > ^^^
> >
> > Dig what
> > I'm trying to do?
> >
> > And 'why?' you may ask am I trying to do this... Well, I am 
> sick of always
> > putting an "echo 'printing
> > out
> > bar:'; print_r($bar);" all the time. I want
> > to make a wrapper function.
> >
> > I also have written one for XML that would be nice to make 
> a NAME='bar'
> > attribute...
> >
> > /**
> > * Print out an array in XML form (useful for debugging)
> > * @access public
> > * @author Daevid Vincent [EMAIL PROTECTED]
> > * @since 4.0b4
> > * @version 1.0
> > * @date07/18/05
> > */
> > function print_r_xml($myArray)
> > {
> > print xmltag('ARRAY', array('NAME'=>'myArray'), 1);
> > foreach($myArray as $k => $v)
> > {
> > if (is_array($v))
> > print_r_xml($v);
> > else
> > print xmltag($k,htmlspecialchars($v));
> > }
> > print xmltag('ARRAY', null, 2);
> > }
> >
> > --
> > P
> 
> 

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



Re: [PHP] Is there a way to get a variable name as a string?

2005-07-18 Thread Ryan A
Maybe something like:


 Function myname ($foo)
 {
$return_value="the variable name passed in is ".$foo;
return $return_value;
}

echo myname($bar);


Just a guess.


On 7/19/2005 3:27:57 AM, Daevid Vincent ([EMAIL PROTECTED]) wrote:
> Is there a way to get the name of a variable as a string? For example...
>
> Function myname ($foo)
> {
> echo "the variable name passed in is ".realname($foo);
> }
>
> myname($bar);
> 
>
> I want to see printed out:
>
> "the variable name passed in is bar"
> ^^^
>
> Dig what
> I'm trying to do?
>
> And 'why?' you may ask am I trying to do this... Well, I am sick of always
> putting an "echo 'printing
> out
> bar:'; print_r($bar);" all the time. I want
> to make a wrapper function.
>
> I also have written one for XML that would be nice to make a NAME='bar'
> attribute...
>
> /**
> * Print out an array in XML form (useful for debugging)
> * @access public
> * @author Daevid Vincent [EMAIL PROTECTED]
> * @since 4.0b4
> * @version 1.0
> * @date07/18/05
> */
> function print_r_xml($myArray)
> {
> print xmltag('ARRAY', array('NAME'=>'myArray'), 1);
> foreach($myArray as $k => $v)
> {
> if (is_array($v))
> print_r_xml($v);
> else
> print xmltag($k,htmlspecialchars($v));
> }
> print xmltag('ARRAY', null, 2);
> }
>
> --
> P

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



Re: [PHP] Is there a way I can read full path names of files on the server and enter it into the database ?

2005-02-21 Thread Richard Lynch
Vaibhav Sibal wrote:
> I wanted to ask whether there is a way whereby a script can read
> filenames from a particular directory on the server and enter those
> filenames with the complete path into the MySQL database? I am trying
> to do this, because I am developing an application where a supervisor
> will be distributing files to different users, and those users are to
> work on the files allocated to them by the supervisor. There is a big
> pool of files containing around 10k-15k files and the supervisor will
> be instructed to allocate around 200 files to a user each day, and the
> user should be able to open that file and work on it. I am using a
> Linux Fedora core 2 server running Apache 2.0.53 and PHP 5.0.3 and
> MySQL, and my clients are Windows clients. So I wanted to ask all of
> you people what would be a better approach to do this, the following
> are the 2 options :

I hope the work load for a single file is rather low -- 200 files to edit
seems like an awful lot...

> (1)As soon as the supervisor selects say around 200 files for a user
> called robert, 200 files from the file pool automatically get copied
> to the home directory of robert. While they are copied to the home
> directory of Robert, the name of each file with their complete path
> name gets logged onto the database. Now I am doing since because I
> need to know where each file went and what user is working on what
> file.  Now since robert is working on a client running on windows, we
> can map a drive of windows onto the home directory of robert. In this
> scenario can we instruct PHP to open files from a local directory
> (i.e. the mapped directory of windows)? Because I need to, somehow,
> log when a user opened the file and when he closed it.

I would avoid this route -- Mainly because to give PHP permission to copy
files onto Robert's computer will open up some pretty major security holes
in every single desktop machine.

> (2) The second scenario is that, I just enter the name of the files
> allocated to a user alongwith the complete pathnames to a database and
> I have another column this time where I store the user's name. Now
> whenever the user logs into our system using his username and
> password, and checks to see his work, he sees a list of files on the
> browser itself, but now we will have to convert this list of files
> into links so that the user can click on the links and directly open
> the file in the required software from the server itself. The issue,
> again, in this kind of design is that how do i open the file in the
> required software and even if i do it then how do i record when the
> user opened the file and when he finished working on it.

This seems perfectly reasonable approach.

Once you have assigned a file to 'robert' in the database, then you can
let 'robert' download the file -- or even a zip file with all 200 files in
it.

The downloaded file will have the correct Windows extension -- or they
will after 'robert' unzips them, and Windows will open the right software,
if 'robert' has it installed and the machine is configured correctly.

If it's not installed or the machine isn't configured correctly, there is
nothing you can do about it from PHP.

Then 'robert' can work on them, and, when they are finished, they can
upload the edited files.

You can track when 'robert' downloaded the files, and when 'robert'
uploaded the files.

If you want to do it one file at a time you could track each and every
download/upload -- but it would be very painful for 'robert' to download
every single file and upload every single file.

Most likely, just knowing that 'robert' downloaded 200 files, took 43
minutes to work on them, and uploaded them again, is plenty of info to
track productivity.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Is there a way to...

2004-10-17 Thread S. Daurer
On Sat, 16 Oct 2004 22:04:33 -0400, Gh <[EMAIL PROTECTED]> wrote:
Your right, this is not what I was expecting, I was thinking there was
another way...  Sounds good.. but any other suggestions?

On Sat, 16 Oct 2004 21:40:56 -0400, Minuk Choi <[EMAIL PROTECTED]>  
wrote:
well, this is probably not what you were expecting... but you can try  
this

admin_template.php
--
$parent = true;
include('important.php');
--
important.php
--
if (!isset($parent) || !$parent)
exit();
//important stuff here.
--
Of course, this only works assuming that the would-be hacker doesn't  
know
HOW you are authenticating the file.  If you are going to try this  
method,
mix it up, use a rather unique variable name and or use a value that is  
hard
to guess.

-Minuk

- Original Message -
From: "GH" <[EMAIL PROTECTED]>
To: "PHP General" <[EMAIL PROTECTED]>
Sent: Saturday, October 16, 2004 9:15 PM
Subject: [PHP] Is there a way to...
> Is there a way to make sure that a page is only loaded via a
>
> require or include statement? or other type of SSI?
>
> I would like to make sure that a 'parent document'  (namely
> admin_template.php) only calls the php file?
>
> Thanks
>
I often do it this way:
main.php:

file.php:

To hack this, the attacker needs filesystem access to your script - an if  
this happens, that should be your smallest problem...

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


Re: [PHP] Is there a way to...

2004-10-17 Thread M Saleh EG
secure it with apache .ht* files for directory and file settings or
the main config file.


On Sun, 17 Oct 2004 15:35:58 +0600, raditha dissanayake
<[EMAIL PROTECTED]> wrote:
> GH wrote:
> 
> >Is there a way to make sure that a page is only loaded via a
> >
> >require or include statement? or other type of SSI?
> >
> >I would like to make sure that a 'parent document'  (namely
> >admin_template.php) only calls the php file?
> >
> >Thanks
> >
> >
> >
> leave if outside htdocs
> 
> --
> Raditha Dissanayake.
> 
> http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
> Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
> Graphical User Inteface. Just 128 KB | with progress bar.
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
M.Saleh.E.G
97150-4779817

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



Re: [PHP] Is there a way to...

2004-10-17 Thread raditha dissanayake
GH wrote:
Is there a way to make sure that a page is only loaded via a 

require or include statement? or other type of SSI? 

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

leave if outside htdocs
--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Is there a way to...

2004-10-16 Thread GH
Your right, this is not what I was expecting, I was thinking there was
another way...  Sounds good.. but any other suggestions?




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

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



Re: [PHP] Is there a way to protect PHP's $_POST, $_GET when user tamper with post string in URL toolbox???

2004-01-08 Thread Christophe Chisogne
Chris Hayes wrote:
It takes a lot more of users to tamper with POST data than with GET
Not a lot more. Simply save the slightly modified form
on a webserver you have access to (hidden field)
-- or better create php code that generate the form
OK, aunt Annie cant do that, but she wouldnt ever thougt about
tampering with html forms ;-)
check whether the referer is from your own site, 
that will also make it a lot harder.
Be carefull, the refer(r)er is _not_ something reliable at all
(I consider you can throw away many --20%?-- of them).
1. It can be faked (a little more difficult than simply creating
   custom html and using a std browser).
2. This can disallow clients from accessing your site.
   Because of some firewall, anonymiser, adaware-like tools, etc
   that remove the referer field, by example. More and more people
   do this to protect their privacy or for security reasons.
   I think this will become default behaviour in years to come.
   NB The referer is an OPTIONAL http field (see rfc2616)
3. It denies direct access to the page via bookmarks or
   typed-in uris (no referer generally sent in these cases)
As many said, just dont rely on unchecked input data:
check it with a 'white list' (use regex by example).
See more info on the security chapter of php manual [1]
and in the well-known www security FAQ [2]
[1] PHP: Security - Manual
http://www.php.net/manual/en/security.index.php
[2] The World Wide Web Security FAQ
by Lincoln D. Stein  & John N. Stewart
http://www.w3.org/Security/Faq/www-security-faq.html
Christophe

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


Re: [PHP] Is there a way to protect PHP's $_POST, $_GET when user tamper with post string in URL toolbox???

2004-01-07 Thread Chris Shiflett
--- Scott Fletcher <[EMAIL PROTECTED]> wrote:
> I wanted to know is is there a way to configure PHP to make it not be
> affected when the web user tamper with the values in the post string
> after a webpage is submitted or something.

If by "after a page is submitted" you mean "after a page is requested",
then you can already be assured that the user cannot tamper with data.
Now, don't be mislead by this, but all it means is that if you have code
such as:



Then, regardless of whether register_globals is enabled or what the user
may do, you can feel comfortable that this script will output "bar". Once
your script begins execution, the user's request has been received, and
the user cannot take any further action that will manipulate data. Of
course, the user can try again on the next request.

> I noticed when I use the hidden html input tag with hidden data in it
> then when I click the submit button to submit the webpage, the hidden
> data then show up in the URL address.

This happens when you specify a method of GET, do not specify a method, or
specify an invalid method (neither POST nor GET).

> I noticed one problem, I can changed the value in the URL toolbar of
> the web-browser and get different result on the webpage.

Yes, but both GET and POST are sent by the user. Surely you wouldn't trust
POST data any more than you would GET.

> So, is there a way to keep that $_REQUEST[], $_GET[] data unchanged?
> Does this require the php.ini configuration or what?

Absolutely not. This requires that you validate all data from the client.
This means GET data, POST data (which may include file uploads), and
cookies are potentially dangerous.

Hope that helps.

Chris

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

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/

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



Re: [PHP] Is there a way to protect PHP's $_POST, $_GET when user tamper with post string in URL toolbox???

2004-01-07 Thread Chris Hayes
At 18:43 7-1-04, you wrote:
Hi!

   I wanted to know is is there a way to configure PHP to make it not be
affected when the web user tamper with the values in the post string after a
webpage is submitted or something.  (Further explanation below)
   I noticed when I use the hidden html input tag with hidden data in it
then when I click the submit button to submit the webpage, the hidden data
then show up in the URL address.  Fine, no problem.  But I noticed one
problem, I can changed the value in the URL toolbar of the web-browser and
get different result on the webpage.   I know it is where $_REQUEST[],
$_GET, etc. come into play.  So, is there a way to keep that $_REQUEST[],
$_GET[] data unchanged?  Does this require the php.ini configuration or
what?
I think when you change the FORM tag by adding
method="POST"
to it is so the form data are send as POST instead of GET. IN the next page 
you will then find the form element values in the $_POST array.

It takes a lot more of users to tamper with POST data than with GET data. 
However you can never trust anything coming over the net and there are ways 
to fake POST data.
In the post-form page check whether the referer is from your own site, that 
will also make it a lot harder.

And try to use methods where it does not help the hacker to try to fool 
you, check their identity on every page.

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


Re: [PHP] Is there a way to protect PHP's $_POST, $_GET when user tamper with post string in URL toolbox???

2004-01-07 Thread Richard Davey
Hello Scott,

Wednesday, January 7, 2004, 5:43:31 PM, you wrote:

SF>I noticed when I use the hidden html input tag with hidden data in it
SF> then when I click the submit button to submit the webpage, the hidden data
SF> then show up in the URL address.  Fine, no problem.  But I noticed one

Only if you use the GET method. This won't happen if you use POST.

You still need to validate the data at the "other end", but it would
stop casual URL hacking.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



Re: [PHP] Is there a way to protect PHP's $_POST, $_GET when user tamper with post string in URL toolbox

2004-01-07 Thread Matt Matijevich
[snip]
   I noticed when I use the hidden html input tag with hidden data in
it
then when I click the submit button to submit the webpage, the hidden
data
then show up in the URL address.
[/snip]

I think if you just change the request method to post, the data will
not show up in the url.

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



Re: [PHP] Is there a way to use the strpos() for next string...

2003-11-21 Thread Scott Fletcher
Yea, plan to file a bug to include an example.  As soon as the strpos()
script work then I'll go ahead.  Right now, mine doesn't work correctly with
the 3rd and 4th line of code, so I'm trying to figure out why.  :-)

Scott

"Mike Ford" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 20 November 2003 20:39, Scott Fletcher wrote:
>
> > Yea, the manual is clear but honestly, don't know what the offset
> > really meant since there is no definition or explaination of how the
> > offset work.
>
> Well, I really don't know how much clearer the sentence that says "The
optional offset parameter allows you to specify which character in haystack
to start searching" can be -- if you can suggest some better wording, that
would have worked for you, then maybe one of us can add a user note to the
manual and/or a documentation bug requesting an enhancement.  And,
notwithstanding the clarity of the description, I agree it would be useful
to have another example showing the use of the 3rd argument, so that could
be done in the same way.
>
> Cheers!
>
> Mike
>
> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP] Is there a way to use the strpos() for next string...

2003-11-21 Thread Ford, Mike [LSS]
On 20 November 2003 20:39, Scott Fletcher wrote:

> Yea, the manual is clear but honestly, don't know what the offset
> really meant since there is no definition or explaination of how the
> offset work.

Well, I really don't know how much clearer the sentence that says "The optional offset 
parameter allows you to specify which character in haystack to start searching" can be 
-- if you can suggest some better wording, that would have worked for you, then maybe 
one of us can add a user note to the manual and/or a documentation bug requesting an 
enhancement.  And, notwithstanding the clarity of the description, I agree it would be 
useful to have another example showing the use of the 3rd argument, so that could be 
done in the same way.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Is there a way to use the strpos() for next string...

2003-11-20 Thread Kelly Hallman
On Thu, 20 Nov 2003, Scott Fletcher wrote:
> > Anyway, don't do that, use an existing XML parser..
>
> I'll try.  I haven't got the PHP XML Parser to work, I think it is
> because the XML stuffs I receive is not a true XML, some of them don't
> have a closing tag either because one tag have actual data as an
> attribute inside one tag.  It is kind of frustrating to on not knowing
> what XML Parser will work.

I was only suggesting that rather than try to perfect your own parser,
you'd be better off spending that time getting comfortable with something
that already exists for this purpose. There is too much debugging,
testing, optimization and research required to build one that is adequate,
and many already exist that probably exceed any home-brew solution.

I have not done too much XML parsing in PHP yet, but you might look to 
PEAR for help with this. I've briefly experimented with the various PEAR 
XML packages, like XML_Tree and XML_Parser. Take a look:
http://pear.php.net/packages.php?catpid=22&catname=XML

If you're dealing with poorly formed XML then you've got another problem
if you're trying to actually parse it. To simply pull one or two values
out of the file, a regex still might be the quickest/dirtiest..

If you do want to move forward testing parsers and stuff, make yourself a
valid XML file to test with, so that is not the issue...worry about fixing
malformed XML later with the provider or through an intermediate filter..

-- 
Kelly Hallman
//Ultrafancy/

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



Re: [PHP] Is there a way to use the strpos() for next string...

2003-11-20 Thread Scott Fletcher
I'll try.  I haven't got the PHP XML Parser to work, I think it is because
the XML stuffs I receive is not a true XML, some of them don't have a
closing tag either because one tag have actual data as an attribute inside
one tag.  It is kind of frustrating to on not knowing what XML Parser will
work.

Scott

"Kelly Hallman" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 20 Nov 2003, Scott Fletcher wrote:
> > How exactly does the 3rd parameter option work.  I tried this but it
> > doesn't work, so I don't know how exactly does it work...  There isn't
> > detail information on the php.net website...
>
> "The optional offset parameter allows you to specify which character in
> haystack to start searching. The position returned is still relative to
> the the beginning of haystack."
>
> So if you are trying to find subsequent occurrences of the string, you'd
> need to make the offset be greater than the last character you checked, or
> you're going to keep getting the first occurrence.
>
> >$XML_Start = (strpos($res_str,"",1);
> >$XML_End = strpos($res_str,"]]>",2);
>
> If you're just trying to pull one bit of data out of a file, you might
> want to look into regex for this purpose. If you're actually trying to
> write a parser, I think you might do well to read up on how other parsers
> work (like, using a stack). Anyway, don't do that, use an existing XML
> parser.. unless you are on a learning quest.. then, by all means!
>
> -- 
> Kelly Hallman
> //Ultrafancy/

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



Re: [PHP] Is there a way to use the strpos() for next string...

2003-11-20 Thread Scott Fletcher
Yea, the manual is clear but honestly, don't know what the offset really
meant since there is no definition or explaination of how the offset work.
All I know the definition of the offset is 'To balance each other out'.
Like a weighting scale where one weight is more than other and I would need
to add a bit of a weight to the lightest part to offset the other.  So, I
knew that is not what the manual meant so don't know how exactly does it
work since there's no explanation or example of it.

But now I understand when I saw your example, so I'll tweak the coding.
I'll also have to customize the codes to check to see if the HTML's CDATA is
returned or not as well as the XML's CDATA is returned or not.  Oh boy!

Thanks,
 Scott

"Mike Ford" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 20 November 2003 17:39, Scott Fletcher wrote:
>
> > How exactly does the 3rd parameter option work.  I tried this
> > but it doesn't
> > work, so I don't know how exactly does it work...  There isn't detail
> > information on the php.net website...
> >
> > --snip--
> >$XML_Start = (strpos($res_str,"",1);
> >$XML_End = strpos($res_str,"]]>",2);
> > --snip--
>
> The manual is perfectly clear -- the third parameter is the offset within
the string of where to start searching, not an occurrence number or any
other way of counting.  And the return value of strpos() is also an offset
within the string.  So, assuming your CDATA segments are nested (which the
above seems to imply), then:
>
> >$XML_Start = strpos($res_str, "", $HTML_Start);
> >$XML_End = strpos($res_str, "]]>", $HTML_End+3);
>
> If they're not nested, then the search order would need to be different
(you need to look for substrings in the order in which they occur in the
string as a whole) but the principle is exactly the same.
>
> Cheers!
>
> Mike
>
> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP] Is there a way to use the strpos() for next string...

2003-11-20 Thread Ford, Mike [LSS]
On 20 November 2003 17:39, Scott Fletcher wrote:

> How exactly does the 3rd parameter option work.  I tried this
> but it doesn't
> work, so I don't know how exactly does it work...  There isn't detail
> information on the php.net website...
> 
> --snip--
>$XML_Start = (strpos($res_str,"",1);
>$XML_End = strpos($res_str,"]]>",2);
> --snip--

The manual is perfectly clear -- the third parameter is the offset within the string 
of where to start searching, not an occurrence number or any other way of counting.  
And the return value of strpos() is also an offset within the string.  So, assuming 
your CDATA segments are nested (which the above seems to imply), then:

>$XML_Start = strpos($res_str, "", $HTML_Start);
>$XML_End = strpos($res_str, "]]>", $HTML_End+3);

If they're not nested, then the search order would need to be different (you need to 
look for substrings in the order in which they occur in the string as a whole) but the 
principle is exactly the same.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Is there a way to use the strpos() for next string...

2003-11-20 Thread Kelly Hallman
On Thu, 20 Nov 2003, Scott Fletcher wrote:
> How exactly does the 3rd parameter option work.  I tried this but it
> doesn't work, so I don't know how exactly does it work...  There isn't
> detail information on the php.net website...

"The optional offset parameter allows you to specify which character in 
haystack to start searching. The position returned is still relative to 
the the beginning of haystack."

So if you are trying to find subsequent occurrences of the string, you'd
need to make the offset be greater than the last character you checked, or
you're going to keep getting the first occurrence.

>$XML_Start = (strpos($res_str,"",1);
>$XML_End = strpos($res_str,"]]>",2);

If you're just trying to pull one bit of data out of a file, you might
want to look into regex for this purpose. If you're actually trying to
write a parser, I think you might do well to read up on how other parsers
work (like, using a stack). Anyway, don't do that, use an existing XML
parser.. unless you are on a learning quest.. then, by all means!

-- 
Kelly Hallman
//Ultrafancy/

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



Re: [PHP] Is there a way to use the strpos() for next string...

2003-11-20 Thread Scott Fletcher
How exactly does the 3rd parameter option work.  I tried this but it doesn't
work, so I don't know how exactly does it work...  There isn't detail
information on the php.net website...

--snip--
   $XML_Start = (strpos($res_str,"",1);
   $XML_End = strpos($res_str,"]]>",2);
--snip--

Scott

"Mike Ford" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 20 November 2003 14:53, Scott Fletcher wrote:
>
> > Hi Everyone!
> >
> > Is there a way to get the strpos() to find the next needle in
> > the haystack instead of just the 1st one only?  (Where the 1st
> > needle is the same string as the next needle)...
>
> Look at the optional 3rd parameter to strpos().
>
> Cheers!
>
> Mike
>
> -
> Mike Ford,  Electronic Information Services Adviser,
> Learning Support Services, Learning & Information Services,
> JG125, James Graham Building, Leeds Metropolitan University,
> Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP] Is there a way to use the strpos() for next string...

2003-11-20 Thread Ford, Mike [LSS]
On 20 November 2003 14:53, Scott Fletcher wrote:

> Hi Everyone!
> 
> Is there a way to get the strpos() to find the next needle in
> the haystack instead of just the 1st one only?  (Where the 1st
> needle is the same string as the next needle)...

Look at the optional 3rd parameter to strpos().

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP] is there a way?

2003-07-31 Thread Jennifer Goodie
> Is there a way to have your html table represent one color,
> Cause when I click the link it turnes purple, and I want it to stay
> 336699
> no matter what state.
>
> I tried to use css, but it does the whole page.
> And I want the 336699 to be in this table alone.
>
> Can anyone help me out with this small problem?

Create a class specifically for that table and it's links.

for example

.yourtable {font-family: Verdana, Arial, Helvetica, sans-serif;font-size:
8pt; color: #ff;}
A.yourtable:link { text-decoration: underline; font-weight: normal; color:
#336699;}
A.yourtable:visited { text-decoration: underline; font-weight: normal;
color: #336699;}
A.yourtable:hover { text-decoration: underline; font-weight: normal; color:
#336699;}
A.yourtable:active { text-decoration: underline; font-weight: normal; color:
#336699;}


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



Re: [PHP] Is there a way to get rid of \' and \" ?

2003-06-22 Thread Philip Olson
On Sun, 22 Jun 2003, Jason Wong wrote:

> On Sunday 22 June 2003 06:00, Dan Anderson wrote:
> > I have a form which feeds into an e-mail.  When I use the mail function
> > all 's turn into \'s and all "s turn into \"s.  
> 
> Are you sure it's the mail() function that's doing it? I doubt it.
> 
> > I tried
> > set_magic_quotes_runtime(0) and it didn't do anything, 
> 
> In php.ini:
> 
>   magic_quotes_gpc = Off

Btw, magic_quotes_gpc and magic_quotes_runtime are totally
different beasts.  You cannot set magic_quotes_gpc at
runtime but may use php.ini as Jason suggests or .htaccess

Before you set it off, be sure you know how it will affect
your SQL queries though.

Regards,
Philip


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



Re: [PHP] Is there a way to get rid of \' and \" ?

2003-06-22 Thread Jason Wong
On Sunday 22 June 2003 06:00, Dan Anderson wrote:
> I have a form which feeds into an e-mail.  When I use the mail function
> all 's turn into \'s and all "s turn into \"s.  

Are you sure it's the mail() function that's doing it? I doubt it.

> I tried
> set_magic_quotes_runtime(0) and it didn't do anything, 

In php.ini:

  magic_quotes_gpc = Off

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

*/


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



Re: [PHP] Is there a way to get rid of \' and \" ?

2003-06-21 Thread Brad Pauly
On Sat, 2003-06-21 at 16:00, Dan Anderson wrote:
> I have a form which feeds into an e-mail.  When I use the mail function
> all 's turn into \'s and all "s turn into \"s.  I tried
> set_magic_quotes_runtime(0) and it didn't do anything, neither did
> urldecode().  Is there a function to strip escape charechters?

I think you want stripslashes().

http://us4.php.net/manual/en/function.stripslashes.php

Brad

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



Re: [PHP] Is there a way to access all the variables in my script?

2003-03-21 Thread Marek Kilimajer
$GLOBALS

Daevid Vincent wrote:

Is there some global array or something that contains all the variable names
(not even values per se) that are used in my script.
Here's the scenario. Like most of you, I do a lot of mySQL db work. So I
tend to use this:
if (mysql_num_rows($result) > 0) { 
 $row = mysql_fetch_array($result,MYSQL_ASSOC);
 while(list($myVariableName,$sqlFieldName)=each($row)) 
   { $$myVariableName = $sqlFieldName; }
}

So now I have a bunch of variables all named say, $company_name,
$company_id, $company_phone, etc...
What I want to do is make a function that can step through all the $company_
variables and unset them all.
(I imagine I'll just string compare to "company_" and then prefix the result
with $$, then set = "", etc. you get the idea)
I suppose I could re-write all my code and use the $row['company_id'] method
instead then clear $row[] but it would be nice to know if there is a way to
do this 'my way' as well...
 



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


Re: [PHP] IS there a way.

2003-03-01 Thread Ernest E Vogelsinger
At 05:40 01.03.2003, Philip J. Newman said:
[snip]
>  Is there a way to PING a URL and check if it returns a valid code like 200
>... ??
[snip] 

Ping doesn't return a "200 OK" code... If you want to check for the
existence of a webserver at the given address you should try to read some
data from it. To check the return code you need a tool to return the HTTP
headers - check out cUrl (also supports SSL), or go on your own using
fsockopen().


-- 
   >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] IS there a way.

2003-02-28 Thread Leif K-Brooks
Try using exec() or backticks.

Philip J. Newman wrote:

 Is there a way to PING a URL and check if it returns a valid code like 200
... ??
--
Philip J. Newman.
Head Developer
[EMAIL PROTECTED]
+64 (9) 576 9491
+64 021-048-3999
--
Friends are like stars
You can't allways see them,
but they are always there.
--
Websites:
PhilipNZ.com - Design.
http://www.philipnz.com/
[EMAIL PROTECTED]
Philip's Domain // Internet Project.
http://www.philipsdomain.com/
[EMAIL PROTECTED]
Vital Kiwi / NEWMAN.NET.NZ.
http://www.newman.net.nz/
[EMAIL PROTECTED]
--
Quote:
"God gave men both a penis and a brain,
but unfortunately not enough blood supply
to run both at the same time."
- Robin Williams
(Commenting on the Clinton/Lewinsky affair).


 

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
to decrypt it will be prosecuted to the full extent of the law.


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


Re: [PHP] Is there a way to "include" php source files in a php script ?

2003-02-23 Thread Sebastian
this question was answered about 15 times already ;)

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

- Original Message -
From: "Sunfire" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 24, 2003 12:52 AM
Subject: Re: [PHP] Is there a way to "include" php source files in a php
script ?


| yes
| include("filename.php");
|
| - Original Message -
| From: "Rohin Gosling" <[EMAIL PROTECTED]>
| To: <[EMAIL PROTECTED]>
| Sent: Sunday, February 23, 2003 2:59 PM
| Subject: [PHP] Is there a way to "include" php source files in a php
script
| ?
|
|
| > Is there a way to include a *.php source file from inside another php
| source
| > file, in a similar fashion to the way you use the "include" directive in
C
| > or C++ ?
| >
| > Rohin


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



Re: [PHP] Is there a way to "include" php source files in a php script ?

2003-02-23 Thread Sunfire
yes
include("filename.php");

- Original Message -
From: "Rohin Gosling" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 23, 2003 2:59 PM
Subject: [PHP] Is there a way to "include" php source files in a php script
?


> Is there a way to include a *.php source file from inside another php
source
> file, in a similar fashion to the way you use the "include" directive in C
> or C++ ?
>
> Rohin
>
>
>
>
>
> --
> 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.443 / Virus Database: 248 - Release Date: 1/11/2003


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



Re: [PHP] Is there a way to "include" php source files in a php script ?

2003-02-23 Thread Ernest E Vogelsinger
At 20:59 23.02.2003, Rohin Gosling said:
[snip]
>Is there a way to include a *.php source file from inside another php source
>file, in a similar fashion to the way you use the "include" directive in C
>or C++ ?
[snip] 


Oh my god, it's soon you'll be asking "is there a way I can do programs
with PHP" ...

Why is it SOOO difficult to do at least SOME reading in the online manual
before asking in public? Isn't it embarrassing to demonstrate general
ignorance?


Ok, I'm feeling better now - yes it is possible. See these pages at the
online manual:
http://www.php.net/manual/en/function.include.php
http://www.php.net/manual/en/function.include-once.php
http://www.php.net/manual/en/function.require.php
http://www.php.net/manual/en/function.require-once.php


-- 
   >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] Is there a way to retrieve an entire source code from a phpfile?

2003-02-05 Thread Chris Hayes


There is a php file that retrieve the source code from the url www.url.com 
and this source is treated and you get content from this file and show it 
on the response page.

Is this possible? Can anyone show me the right direction?
yes, codeword is 'ripping', i found some hits on google with

php ripping html -audio -track -mp3
.


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




Re: [PHP] Is there a way to retrieve an entire source code from aphp file?

2003-02-04 Thread Philip Olson
On 4 Feb 2003, Adam Voigt wrote:

> I believe he meant the HTML source of an HTML page.

An example in the manual does exactly this:
  http://www.php.net/file

Regards,
Philip


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




Re: [PHP] Is there a way to retrieve an entire source code from aphp file?

2003-02-04 Thread Adam Voigt




I believe he meant the HTML source of an HTML page.



On Tue, 2003-02-04 at 11:02, 1LT John W. Holmes wrote:

No, you can only get the output of the PHP script, not it's source code.



---John Holmes...



- Original Message -

From: "The New Source" <[EMAIL PROTECTED]>

To: <[EMAIL PROTECTED]>

Sent: Tuesday, February 04, 2003 11:57 AM

Subject: [PHP] Is there a way to retrieve an entire source code from a php

file?





What I want to know is if it is possible to retrieve a source code from a

url, with a php file.



Something like this:



There is a php file that retrieve the source code from the url www.url.com

and this source is treated and you get content from this file and show it on

the response page.



Is this possible? Can anyone show me the right direction?



Rodrigo.





-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






-- 
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] Is there a way to retrieve an entire source code from a php file?

2003-02-04 Thread 1LT John W. Holmes
No, you can only get the output of the PHP script, not it's source code.

---John Holmes...

- Original Message -
From: "The New Source" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 04, 2003 11:57 AM
Subject: [PHP] Is there a way to retrieve an entire source code from a php
file?


What I want to know is if it is possible to retrieve a source code from a
url, with a php file.

Something like this:

There is a php file that retrieve the source code from the url www.url.com
and this source is treated and you get content from this file and show it on
the response page.

Is this possible? Can anyone show me the right direction?

Rodrigo.


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




Re: [PHP] Is there a way to retrieve an entire source code from aphp file?

2003-02-04 Thread Adam Voigt




$f = fopen("http://www.download.com/index.html","r");

$data = ""

fclose($f);



echo $data;



On Tue, 2003-02-04 at 11:57, The New Source wrote:

What I want to know is if it is possible to retrieve a source code from a url, with a php file.



Something like this:



There is a php file that retrieve the source code from the url www.url.com and this source is treated and you get content from this file and show it on the response page.



Is this possible? Can anyone show me the right direction?



Rodrigo.




-- 
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] Is there a way to undo the md5() encryption??

2003-01-22 Thread Scott Fletcher
I had it figured out!!   Don't need to decrypt it.  Instead, I can encrypt
the account number by javascript.  Grab the unencrypted account number.  Put
it into two variable, encrypt the first one with PHP and match it by
Javascript.  If accept then I use the 2nd variable to grab the data from the
data and put it into the sessions.  This will take care of the problem with
my other project

Cheers!

Thanks,
 Scott F.

"Brad Pauly" <[EMAIL PROTECTED]> wrote in message
1043271786.1236.34.camel@earth">news:1043271786.1236.34.camel@earth...
> > Hi!  Is there a way to do the decryption of the encrypted data with the
use
> > of md5()??
>
> Nope. md5 is a one way function.
>
> http://www.faqs.org/faqs/cryptography-faq/part07/
>
> Brad
>



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




Re: [PHP] Is there a way to undo the md5() encryption??

2003-01-22 Thread Brad Pauly
> Hi!  Is there a way to do the decryption of the encrypted data with the use
> of md5()??

Nope. md5 is a one way function.

http://www.faqs.org/faqs/cryptography-faq/part07/

Brad


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




Re: [PHP] Is there a way to test for a file?

2002-10-08 Thread Andy Woolley

> I'd like PHP to check to see if the image/picture.jpg exists before
> returning the picture.  Is this possible?

Yup - It's in the manual.

http://www.php.net/manual/en/function.file-exists.php

Cheers
Andy


- Original Message -
From: "Doug Coning" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 08, 2002 3:59 PM
Subject: [PHP] Is there a way to test for a file?


> Hi everyone,
>
> I'm a PHP newbie and wanted to know if there is a way to test for a file.
> The reason I'd like to do this is because I'm writing a query to return
> items from a catalog.  However, if the client hasn't uploaded a picture or
> if the picture is misteriously missing from the image folder, instead of
> returning the product with the infamous missing jpeg picture, I would
rather
> the product be skipped altogether.
>
> I'd like PHP to check to see if the image/picture.jpg exists before
> returning the picture.  Is this possible?
>
> Thanks!
>
> Doug Coning
> American Web Studio
> www.americanwebstudio.com
>
>
>
>
>
> --
> 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] Is there a way to test for a file?

2002-10-08 Thread Vidyut Luther

http://www.php.net/manual/en/ref.filesystem.php

you can see that there is a function called file_exists, is_file, is_readable 
etc etc.. 

hope this helps. 

thats the PHP Filesystem function specific manual, 

On Tuesday 08 October 2002 09:59, Doug Coning wrote:
> Hi everyone,
>
> I'm a PHP newbie and wanted to know if there is a way to test for a file.
> The reason I'd like to do this is because I'm writing a query to return
> items from a catalog.  However, if the client hasn't uploaded a picture or
> if the picture is misteriously missing from the image folder, instead of
> returning the product with the infamous missing jpeg picture, I would
> rather the product be skipped altogether.
>
> I'd like PHP to check to see if the image/picture.jpg exists before
> returning the picture.  Is this possible?
>
> Thanks!
>
> Doug Coning
> American Web Studio
> www.americanwebstudio.com

-- 
Vidyut Luther
Linuxpowered, Inc

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




Re: [PHP] Is there a way?

2002-07-16 Thread Chris Crane

Ok so let me ask one last question..
Which it faster, to run my function and part of the function would be to get
data from a website and break it into variables then make all the html and
variables one new variable for printing

or

Get my data put into variables made global and then in my HTML page use tags
like .

The last one is easier to design with, but may slow things down each time it
has to parse out the PHP tag, no?




"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
001a01c22cf3$ef2e01c0$8102a8c0@niigziuo4ohhdt">news:001a01c22cf3$ef2e01c0$8102a8c0@niigziuo4ohhdt...
> [snip]
> In Perl you could print a block of information as it was written like
this;
> print <
> This a whole bunch of HTML code!!!
>
> HTML_END
>
> The best part about this, was that you did not have to escape your " and
you
> could mix in your variables making it easy to design and layout the HTML.
Is
> there a similiar way to do this in PHP?
> [/snip]
>
> $variable = <<< HERE
>
> all kinds of stuff
>
> HERE;
>
> print("$variable");
>
> HTH!
>
> Jay
>
> "Two wrongs are only the beginning"
>
> *
> * Want to meet other PHP developers *
> * in your area? Check out:  *
> * http://php.meetup.com/*
> * No developer is an island ... *
> *
>
>



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




  1   2   >