RE: [PHP] Run a script apart from request

2007-04-30 Thread Buesching, Logan J

 -Original Message-
 From: Brad Fuller [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 30, 2007 10:55 AM
 To: php-general@lists.php.net
 Subject: [PHP] Run a script apart from request
 
 Hi all,
 
 I am developing a program that does some intensive data processing,
and is
 triggered from a page hit and/or a SOAP request.
 
 The processing takes on average 30 seconds to 1 minute, which is OK
for a
 web page (I can use set_time_limit(0) and just display a
pseudo-progress bar
 animated gif and a Please wait... message) but I can't leave the
SOAP
 request hanging for that long.  I need to send a response immediately.
 
 What I really need to do is acknowledge the client that their request
has
 been received and will be processed, and terminate that request... and
THEN
 begin the processing.
 
 One way I thought of doing it would be to put the requests into the
database
 and run a cron job every X minutes, but I would like to avoid this if
at all
 possible.
 
 Someone had suggested pcntl_fork() but I'm not sure if that will
accomplish
 what I need it to... if I fork(), then send a response, kill the
parent and
 let the child run the process, will the HTTP request wait for the
child or
 will it die with the parent (like I want it to) ?
 
 Any advice is much appreciated.
 
 Thx,
 
 Brad
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

I am not completely familiar with how forking works in PHP applications,
but I am fairly familiar with how it works in UNIX.  If you kill the
parent process, I believe it will close the HTTP request, but since it
doesn't handle the SIGCHLD signal after the child is done, the child
process will be left as a zombie process.  I believe the only way to
catch the SIGCHLD is to have the script pcntl_waitpid(), which would
then hang the HTTP request.

I haven't tested this, but you can easily test it by:

$pid = pcntl_fork();
 if($pid == -1) {
  // Something went wrong (handle errors here)
 } elseif($pid == 0) {
  // This part is only executed in the child
  usleep(500); //wait 5 seconds... see if the request hangs here
 } else {
  die(); 
 }

Then wait and see what happens.


Maybe there is someone more experience in this area that can put a few
words in, but that is what I believe to be the case.

-Logan

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



RE: [PHP] single signon Solution php and .net

2007-04-29 Thread Buesching, Logan J
The first thing that comes to my mind is to use a database to handle
session data as defined by: 
http://us2.php.net/manual/en/function.session-set-save-handler.php.  You
can then, when attempting to authenticate, pass the session ID back and
forth through your applications.  There may be similar things for .Net,
but I as I am not a .Net web developer, I can't help you out in that
area.

-Logan

 -Original Message-
 From: Murtaza Chang [mailto:[EMAIL PROTECTED]
 Sent: Sunday, April 29, 2007 3:13 PM
 To: php-general@lists.php.net
 Subject: [PHP] single signon Solution php and .net
 
 Hi, me and my fellow developer have built two applications that need
to
 authenticate users using LDAP, we have successfully accomplished it,
 but the
 problem is his application is in .net and mine is in php, my php app
 needs
 to call secure pages of .net and vice versa, now when the user is
 logged
 onto let say my php app he is logged and his session is created and
 when I
 redirect him to .net app he again sees a login form because the
session
 isnt
 created in .net app.
 I need some single sign on solution I found lots of APIs and libraries
 for
 java but have no idea what can I use for php and .net, kindly
 experience
 programmers guide me.
 Thankyou
 
 --
 Murtaza Chang
 http://flickr.com/photos/blackstallion/

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



RE: [PHP] FW: I really need help

2007-04-29 Thread Buesching, Logan J
You will have to find that information out through whoever your host is.
There is no one configuration for that.  

The first question to ask is did you create a MySQL database?  If you
did, then find out whatever the host was for doing that.  Many times,
your host will put it at mysql.___domainname___.com, so since you have
spanishbyproz.com, you can probably try mysql.spanishbyproz.com.

-Logan 

 -Original Message-
 From: Stephen Hernandez [mailto:[EMAIL PROTECTED]
 Sent: Sunday, April 29, 2007 7:29 PM
 To: php-general@lists.php.net
 Subject: [PHP] FW: I really need help
 
 I have literally just started using php and my sql so I really hope
 somebody can help me and I am addressing the right people as I don't
 want to be a pain in the neck. I have tested whether PHP is installed
 and running on the remote web server that hosts my website and it is
 running ok.
 Next I wanted to see if I could access MySQL using PHP.  I downloaded
a
 file from a Web site at janet.valade.com called mysql_up.php as it
 comes
 from a book she has written called PHP  MySQL for Dummies which is
the
 book I am using to learn - as you can tell I am right at the beginning
 :-) .
 I get an error message which relates  to lines 9, 10 and 11 of the
 program which are:
 $host=host;
 $user=mysqlaccount;
 $password=mysqlpassword;
 
 These were the values I had to change which I guess is where the
 problem
 is. I was supposed to change host to the name of the computer where
 MySQL is installed. But I do not know what name I should put, the name
 of my site is spanishbyproz.com. In the example Janet uses she puts
 datebasehost.mycompany.com . What should I write for host ?
 
 I would really appreciate any advice and am sorry it is such a basic
 question.
 
 Many thanks in advance,
 
 Steve

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



RE: [PHP] Object-oriented $_REQUEST?

2007-04-28 Thread Buesching, Logan J
I feel that a 'request' class wouldn't be appropriate for the $_REQUEST
array.  The reason being, is that there isn't to that class other than
the $_REQUEST array, and a bunch of 'get' methods.  If this were to be
expanded upon by adding filtering user input, then it *could* be more
useful.  IMO an entire class just to handle retrieving data an array (or
4 if you include GPC and request) would become unnecessary overhead.

But then again, maybe I am missing the point of this 'request' class. 

-Logan

 -Original Message-
 From: js [mailto:[EMAIL PROTECTED]
 Sent: Saturday, April 28, 2007 2:56 PM
 To: php-general@lists.php.net
 Subject: [PHP] Object-oriented $_REQUEST?
 
 Hi.
 
 I'm looking for implementation of request object
 that represent a request that works like this.
 
 $r = new request();
 if ($r-method == 'GET')
 $name = $r-GET-get('name');
 $age = $r-GET-get('age');
 else if (request.method == 'POST')
 $name = $r-POST-get('name');
 $age = $r-POST-get('age');
 ...
 
 Handling $_GET, $_POST directly is cumbersome for me
 so I tried to make one but I thought it's quite possible that
 some better programmer already make one like this.
 
 Thanks in advance.
 
 --
 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] explode in mysql query

2007-04-27 Thread Buesching, Logan J

 -Original Message-
 From: Paul Novitski [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 27, 2007 3:01 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] explode in mysql query
 
 At 4/26/2007 11:33 PM, Sebe wrote:
 i have a mysql column that looks like this:
 
 groups
 ---
 12,7,10,6,14,11,2
You should never have tables that look like this.  If this is early in
the application development, look into 3rd normal form for SQL tables
(don't worry about 4th or 5th).  In a nutshell, here is what you should
be doing: you have a many to many relationship (big thing to note).
Whatever holds groups (lets call it foo) to groups.

So you should do something like this:

===
Foo --A table
===
Id -- columns
groups
Coln

===
Groups
===
Id
Col1
Col2
Col3

So then you create a 3rd table named

===
Foo_has_groups (or groups_has_foo, whichever sounds best)
===
Fooid
groupsid

So then, you can do much more powerful queries, with much less overhead.

Such as: 
SELECT t1.* FROM foo t1, groups t2 WHERE t1.id=t2.whatever_id AND
(t2.group=7 OR t2.group=14);

If you are reluctant to do any of these optimizations to your database,
then you better not worry about anywhere in your PHP code to do _ANY_
optimizations.  This will be your system bottleneck!  99% of the time
(maybe less) when you get a slow application, your bottlenecks will
be in your sql queries/design. 

Hopefully that all made sense

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



FW: [PHP] Need to POST multiple values with single name

2007-04-27 Thread Buesching, Logan J
Just make sure you use []'s in your name, such as:
select multiple=multiple name=bob[]

Then it will fill $bob as an array, instead of a string.

http://us2.php.net/manual/en/faq.html.php#faq.html.arrays

-Logan

 -Original Message-
 From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
 Sent: Friday, April 27, 2007 4:02 AM
 To: php-general@lists.php.net
 Subject: [PHP] Need to POST multiple values with single name

 Need to POST multiple values with single name.

 Ex.
 -55751342416306771991025074398
 Content-Disposition: form-data; name=licenses

 lic1
 -55751342416306771991025074398
 Content-Disposition: form-data; name=licenses

 lic2


 Function http_post_fields() cannot be used due to an _associative_
array
 of POST values.

 Any ideas?

 Maxim [EMAIL PROTECTED]

 --
 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] ${}

2007-04-25 Thread Buesching, Logan J
Heh, lucky me I was just looking into that earlier today.

http://us.php.net/manual/en/language.types.string.php

Around the Simple Syntax area.

-Logan

-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 25, 2007 9:42 AM
To: Man-wai Chang
Cc: php-general@lists.php.net
Subject: Re: [PHP] ${}

On Wed, 2007-04-25 at 21:23 +0800, Man-wai Chang wrote:
 where can I find the documentation about this symbol?

Maybe in the documentation? A cursory glance from me though didn't turn
anything up. Either way I can inform you of the purpose...

The following two expression have the same result:

$foo = 5;
${'foo'} = 5;

The difference being that the code between { and } is first evaluated to
determine the name of the variable. $foo is preferred and faster but
there may be the odd time when you find doing something like the
following useful:

${'foo_'.$i} = $someValue;

So let's imagine $i = 3, then a variable called $foo_3 has been created
and can even be accessed as $foo_3.

If you are familiar with variable variables then you may be aware that
the above can also be achieved as follows:

$name = 'foo_'.$i;
$$name = $someValue;

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

-- 
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] What determines the relative directory, and can I control it?

2007-04-24 Thread Buesching, Logan J
[snip]
Can I somehow manipulate any of the PHP scripts involved so that the 
HTML within layout.php will look first in it's own directory for 
inclusion of files, such as CSS and javascript and anything else?
[/snip]

If a user accesses http://site.com/index.php, then the HTML that is spit
back out from requesting index.php better have CSS import statements
that point to where the CSS files really are.  

Example:

Requesting http://site.com/index.php returns

script type=text/css
 @import a.css
/script

Then there better be the following:
http://site.com/a.css

There is no way around that (AFAIK), because that is how the web
browsers find such CSS sheets.  In a simplified explanation, they look
for the path of the import, append it to where the request was filed,
and download whatever they get.

You can make it easier on the designer though, in by telling them they
must do something like:

script type=text/css
 @import $path.'a.css'
/script

Then YOUR php files can determine whatever $path needs to be before it
includes the file.

So when they request http://site.com/index.php, it will spit out:

script type=text/css
 @import styles/site1/a.css
/script

I hope this makes sense.

-Logan 

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



RE: [PHP] filetype() and exec() issues

2007-04-24 Thread Buesching, Logan J
You may also want to check and make sure that your ISO isn't more than
4GB.  IIRC, I had some troubles with extremely large files and using
filetype() on them.  But then again, it may have just been something on
my own end.

-Logan

-Original Message-
From: Tijnema ! [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 24, 2007 2:18 AM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] filetype() and exec() issues

On 4/24/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 This question is a two parter

 a) anyone else noticing filetype() failing on ISO image files?

 Warning: filetype(): Lstat failed for /var/lib/samba/some/file.iso

Nope, didn't fail for me. But what exactly do you want to know about
the file? filetype only check wheter the the argument given is a fifo,
char, dir, block, link, file, or unknown.
What you're doing below with the file command is getting the content
type, there you could use the function mime_content_type, but it is
deprecated, and seems not to work always. The manual forwards you to
the fileinfo functions:
http://www.php.net/manual/en/function.finfo-file.php
example 592 does what you're doing with the file command below.


 b) I have a script that during processing will eventually call

  exec('/usr/bin/file -bi '.$file)

 over 1000 times, I've added a counter and when it dies on this line
it's
 always after 1020 exec calls, regardless of the file name I'm feeding
to
 `file`.  I've reproduced this with both exec, shell_exec, system and
the
 backticks.  What am I missing here?

Why does it die? Is it because te max execution time reached? then you
should extend the max executon time:
http://www.php.net/set_time_limit

Tijnema

snip

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

2007-04-24 Thread Buesching, Logan J
I use Outlook 2003 on Vista, no problem at all, non-digest mode.

-Original Message-
From: Wolf [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 24, 2007 3:18 PM
To: Tijnema !
Cc: Beauford; PHP
Subject: Re: [PHP] List

Welcome to Windows

Tijnema ! wrote:
 On 4/24/07, Beauford [EMAIL PROTECTED] wrote:
 Does anyone else have this problem with the list. It seems that every

 time I
 check my email there is one or more messages from the list that
royally
 screws up Outlook. I usually have to delete all list messages from
the
 actual server and reboot. It only happens with emails from
 [EMAIL PROTECTED]

 Just trying to narrow down the problem. Not sure if this is spam
that's
 sneaking into the list messing things up or what.

 Thanks
 
 I'm using Gmail (Webmail) and it's fine, but i think it is a problem
 because you get a lot of messages from the PHP list, you might want to
 get the emails in a daily digest, instead of every single email.
 
 Tijnema
 

-- 
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] Preventing SQL Injection/ Cross Site Scripting

2007-04-23 Thread Buesching, Logan J
No.  That is a common mistake amongst the uninformed.  Addslashes
doesn't take into effect character encodings, while
mysql_real_escape_string does.  Please take a look at this article:
http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-st
ring

-Logan 

-Original Message-
From: Weber Sites [mailto:[EMAIL PROTECTED] On Behalf Of WeberSites
LTD
Sent: Monday, April 23, 2007 10:49 AM
To: Buesching, Logan J; 'Dotan Cohen'; 'php php'
Subject: RE: [PHP] Preventing SQL Injection/ Cross Site Scripting

I'm trying to understand from the examples why anyone 
that has get_magic_quotes_gpc() returning true would
need to use stripslashes() and then mysql_real_escape_string().

wouldn't that just add slashes to the same places?

berber

-Original Message-
From: Buesching, Logan J [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 23, 2007 2:35 AM
To: Dotan Cohen; php php
Subject: RE: [PHP] Preventing SQL Injection/ Cross Site Scripting

There are many good resources out there, and one of my favorites for
this
type of information is from Chris Shiflett.
http://shiflett.org/articles/sql-injection
http://shiflett.org/articles/foiling-cross-site-attacks
http://shiflett.org/blog/2007/mar/allowing-html-and-preventing-xss


Those are a few articles on the subject, maybe some reader comments have
more good links.

Also, just as a best-practice, you usually don't want to reassign things
into the super globals.  Also to note, your filtering may be a bit too
aggressive, and not all-inclusive at the same time.  Too aggressive
because
if I want to talk about java in a comment, it will filter out every time
I
say java.  Too lax because you are forgetting all of the HTML onclick,
onhover etc... that don't need to have a script tag in them to be
executed.  Any of the preg_replace's with an = in them is redundant
because
you have already filtered out all of the ='s, but also note that you can
have multiple spaces between href and =.  You are banking that they will
have 0 or 1.

If available, you can look into PHP 5.2 which added some filter
functions
(albeit I myself haven't checked them out).  You can also look into
OWASP's
PHP project, http://www.owasp.org/index.php/Category:OWASP_PHP_Project.
That is a pretty good resource in secure coding best-practices.

-Logan

-Original Message-
From: Dotan Cohen [mailto:[EMAIL PROTECTED]
Sent: Friday, April 20, 2007 9:08 PM
To: php php
Subject: [PHP] Preventing SQL Injection/ Cross Site Scripting

I've got a comments form that I'd like to harden against SQL Injection /
XSS
attacks. The data is stored in UTF-8 in a mysql database. I currently
parse
the data as such:

$_POST[commentform]=str_replace (', '', $_POST[commentform]);
  //q-qq
$_POST[commentform]=str_replace (--, , $_POST[commentform]);
 //-- - x
$_POST[commentform]=str_replace (;, , $_POST[commentform]);
//; - x
$_POST[commentform]=str_replace (=, '', $_POST[commentform]);
  //= - x
$_POST[commentform]=preg_replace (/java/i, '',
$_POST[commentform]);
$_POST[commentform]=preg_replace (/script/i, '',
$_POST[commentform]); $_POST[commentform]=preg_replace (/src=/i,
'',
$_POST[commentform]); $_POST[commentform]=preg_replace (/src =/i,
'', $_POST[commentform]); $_POST[commentform]=preg_replace
(/iframe/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/rel=/i, '',
$_POST[commentform]);
$_POST[commentform]=preg_replace (/rel =/i, '',
$_POST[commentform]); $_POST[commentform]=preg_replace (/href=/i,
'', $_POST[commentform]); $_POST[commentform]=preg_replace (/href
=/i, '', $_POST[commentform]); $_POST[commentform]=preg_replace
(//i, '', $_POST[commentform]);
$_POST[commentform]=htmlspecialchars( mysql_real_escape_string
($_POST[commentform]) );

The first statement doubles up quotes, it's a bit difficult to see in
the
code.

After seeing this:
http://ha.ckers.org/xss.html
and another similar one for SQL injection, I'm worried that my filters
are
not enough. What do the pro php programers out there use?

Thanks in advance.

Dotan Cohen

http://lyricslist.com/
http://what-is-what.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] PhpMyAdmin slow on windows but fast on linux

2007-04-22 Thread Buesching, Logan J
You say they both have the same config, so do you mean that they both
have the same version of PHP, same computer setup (Memory, CPU speed,
HDD speed), both running the same version of Apache, and that both are
running as either CGI or an apache module?

-Logan

-Original Message-
From: Don Don [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 22, 2007 4:34 PM
To: PHP List
Subject: [PHP] PhpMyAdmin slow on windows but fast on linux

Hi all how can i make my phpmyadmin run fast on windows ?  I installed
phpmyadmin on a linux and windows machines, but the windows version runs
(executes) too slow, i.e. it takes to long for a page to be loaded,
while it take less that 3 secs for the linux version.  Both however run
on the same system config.
   
  Cheers

   
-
Ahhh...imagining that irresistible new car smell?
 Check outnew cars at Yahoo! Autos.

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



RE: [PHP] Why do i get this error message?

2007-04-22 Thread Buesching, Logan J
Could you also send the code? Maybe 5 lines before and 5 lines after the
line it is pointing to?

It also means it tried to allocate 2KB of memory, which put you over
your 8MB in whatever script you are running.  You can set the maximum
amount of memory a PHP script can use in your PHP.ini file.

-Original Message-
From: H.T [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 22, 2007 6:48 PM
To: php-general@lists.php.net
Subject: [PHP] Why do i get this error message?

I get this error message when i try to check my site on localhost
running
IIS and PHP 5.1.2 :

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 24576 bytes) in ...

and it points to the line which is pure html code!
What could be the cause of this problem?

-- 
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] Preventing SQL Injection/ Cross Site Scripting

2007-04-22 Thread Buesching, Logan J
There are many good resources out there, and one of my favorites for this type 
of information is from Chris Shiflett.
http://shiflett.org/articles/sql-injection
http://shiflett.org/articles/foiling-cross-site-attacks
http://shiflett.org/blog/2007/mar/allowing-html-and-preventing-xss


Those are a few articles on the subject, maybe some reader comments have more 
good links.

Also, just as a best-practice, you usually don't want to reassign things into 
the super globals.  Also to note, your filtering may be a bit too aggressive, 
and not all-inclusive at the same time.  Too aggressive because if I want to 
talk about java in a comment, it will filter out every time I say java.  Too 
lax because you are forgetting all of the HTML onclick, onhover etc... that 
don't need to have a script tag in them to be executed.  Any of the 
preg_replace's with an = in them is redundant because you have already filtered 
out all of the ='s, but also note that you can have multiple spaces between 
href and =.  You are banking that they will have 0 or 1.

If available, you can look into PHP 5.2 which added some filter functions 
(albeit I myself haven't checked them out).  You can also look into OWASP's PHP 
project, http://www.owasp.org/index.php/Category:OWASP_PHP_Project.  That is a 
pretty good resource in secure coding best-practices.

-Logan

-Original Message-
From: Dotan Cohen [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 20, 2007 9:08 PM
To: php php
Subject: [PHP] Preventing SQL Injection/ Cross Site Scripting

I've got a comments form that I'd like to harden against SQL Injection
/ XSS attacks. The data is stored in UTF-8 in a mysql database. I
currently parse the data as such:

$_POST[commentform]=str_replace (', '', $_POST[commentform]);
  //q-qq
$_POST[commentform]=str_replace (--, , $_POST[commentform]);
 //-- - x
$_POST[commentform]=str_replace (;, , $_POST[commentform]);
//; - x
$_POST[commentform]=str_replace (=, '', $_POST[commentform]);
  //= - x
$_POST[commentform]=preg_replace (/java/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/script/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/src=/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/src =/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/iframe/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/rel=/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/rel =/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/href=/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (/href =/i, '', $_POST[commentform]);
$_POST[commentform]=preg_replace (//i, '', $_POST[commentform]);
$_POST[commentform]=htmlspecialchars( mysql_real_escape_string
($_POST[commentform]) );

The first statement doubles up quotes, it's a bit difficult to see in the code.

After seeing this:
http://ha.ckers.org/xss.html
and another similar one for SQL injection, I'm worried that my filters
are not enough. What do the pro php programers out there use?

Thanks in advance.

Dotan Cohen

http://lyricslist.com/
http://what-is-what.com/

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



RE: [PHP] echo date('Y-m-d', $mydata-timestamp);

2007-04-22 Thread Buesching, Logan J
You are misunderstanding what timestamp means.  The value of a timestamp
is from UNIX epoch http://en.wikipedia.org/wiki/Unix_time.  It is
calculated by the number of seconds after January 1st, 1970.  Also note,
that you are overflowing the integer, which is giving you a
http://en.wikipedia.org/wiki/Year_2038_problem Y2K38 problem.

If you want the UNIX timestamp of 4/19/2007 16:21:23, you can do
mktime(16,21,23,4,19,2007);
(http://us.php.net/manual/en/function.mktime.php).

-Logan

-Original Message-
From: John Taylor-Johnston
[mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 22, 2007 2:05 AM
To: PHP-General
Cc: John Taylor-Johnston
Subject: [PHP] echo date('Y-m-d', $mydata-timestamp);

$mydata-timestamp = 20070419162123;

echo date('Y-m-d', $mydata-timestamp);


result: 2038-01-18

?? What is wrong?? Should be 2007-04-19?

-- 
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] should I be looking to eliminate all notices?

2007-04-22 Thread Buesching, Logan J
[snip]
I don't really want to do a isset check for every index  I have.
[/snip]

Premature optimization is the root of all evil.  Checks like this will
take nanoseconds to check.  Find another way to optimize, like writing
better SQL queries.

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



RE: [PHP] serialize an object

2007-04-19 Thread Buesching, Logan J
From the PHP manual:


-Original Message-
From: Zoltán Németh [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 19, 2007 8:40 AM
To: Tobias Wurst
Cc: php-general@lists.php.net
Subject: Re: [PHP] serialize an object

as far as I know serialize() saves all the properties of the object...

and I think you can store objects in session without serializing it
since PHP serializes-unserializes it for you automatically - or not?

greets
Zoltán Németh

2007. 04. 19, csütörtök keltezéssel 13.17-kor Tobias Wurst ezt írta:
 hi,
 i use serialize() to save my object in $_SESSION.
 But i have one Problem:
 the member-variables from the baseclass are not saved.. :(
 How can i fix this?
 
 thanks in advance 
 

-- 
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] serialize an object

2007-04-19 Thread Buesching, Logan J
Sorry for that ctrl+enter sends, when I wanted ctrl+V to paste :(

All registered variables are serialized after the request finishes. Registered 
variables which are undefined are marked as being not defined. On subsequent 
accesses, these are not defined by the session module unless the user defines 
them later.
Warning

Some types of data can not be serialized thus stored in sessions. It includes 
resource variables or objects with circular references (i.e. objects which 
passes a reference to itself to another object).

Note: Session handling was added in PHP 4.0.0. 

Note: Please note when working with sessions that a record of a session is 
not created until a variable has been registered using the session_register() 
function or by adding a new key to the $_SESSION superglobal array. This holds 
true regardless of if a session has been started using the session_start() 
function.

So I'd assume his class has a circular reference if it cannot be serialized, 
and how to fix that I'm going to pass on.

-Original Message-
From: Zoltán Németh [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 19, 2007 8:40 AM
To: Tobias Wurst
Cc: php-general@lists.php.net
Subject: Re: [PHP] serialize an object

as far as I know serialize() saves all the properties of the object...

and I think you can store objects in session without serializing it
since PHP serializes-unserializes it for you automatically - or not?

greets
Zoltán Németh

2007. 04. 19, csütörtök keltezéssel 13.17-kor Tobias Wurst ezt írta:
 hi,
 i use serialize() to save my object in $_SESSION.
 But i have one Problem:
 the member-variables from the baseclass are not saved.. :(
 How can i fix this?
 
 thanks in advance 
 

-- 
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] Problems when trying to use ibm_db2 extension

2007-04-16 Thread Buesching, Logan J
My first guess would be to make sure that the version of PHP that you
are running from CLI is the same as the one running as an apache module,
and that they are configured the same.  When running the CLI, do an 

?php phpinfo(); ?

And compare the output with what you get from doing the same thing from
the web.

-Logan

-Original Message-
From: Leo Jokinen [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 16, 2007 10:22 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
php-general@lists.php.net
Subject: [PHP] Problems when trying to use ibm_db2 extension

Hi all,

I've been banging my head into the wall cause I can't get ibm_db2 
extension working with Apache 2.0.59 and PHP 5.2.1 (as apache module).
(Operating system is winxp pro SP2)

For some reason, this code is working on command line but not when 
placed to htdocs folder:

 ?php
 if(function_exists('db2_connect')) {
   echo 'Function db2_connect() exists';
 } else {
   echo 'Unknown function db2_connect()';
   exit;
 }
 
 echo \nTrying to connect DB2 database..\n;
 
 $database = 'services';
 $user = 'db2admin';
 $password = 'xxx';
 $hostname = '127.0.0.1';
 $port = 5;
 $conn_string = DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database; .

HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;;
 $conn = db2_connect($conn_string, '', '');
 
 if ($conn) {
   echo OK: Connection established\n;
   db2_close($conn);
 } else {
   echo ERROR: Connection failed\n;
 }
 ?

Command line output:
 C:\php c:\db2_test.php
 Function db2_connect() exists
 Trying to connect DB2 database..
 OK: Connection established

Web output:
 Unknown function db2_connect()

Some extra output:
 Fatal error: Call to undefined function db2_connect() in
F:\www\services.itella.net\app\webroot\index.php on line 57

Also, phpinfo() won't say nothing that module ibm_db2 is in use

More info:

php_ibm_db2.dll file is in folder C:/php-5.2.1/ext

php.ini:
extension_dir = C:/php-5.2.1/ext
extension=php_ibm_db2.dll

httpd.conf:
AddType application/x-httpd-php .php
LoadModule php5_module C:/php-5.2.1/php5apache2.dll
PHPIniDir C:/php-5.2.1/


Can someone point out the right direction for me?

Regards

Leo Jokinen

-- 
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] preg_replace and regular expressions.

2007-04-15 Thread Buesching, Logan J
In your regex, you have a greedy matcher, i.e. .* will match as much
as it can to satisfy its condition.  I believe you can do .*? and it
will work, as .*? will match as little as it can to be satisfied.

-Logan

-Original Message-
From: Travis Moore [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 15, 2007 12:22 AM
To: [EMAIL PROTECTED]
Subject: [PHP] preg_replace and regular expressions.

Okay, so what I have is a BB code type of thing for a CMS, which I for 
obvious reasons can't allow HTML.

Here's the snippet of my function:


function bbCode($str)
  {
   $db = new _Mysql;
   $strOld = $str;
   $strNew = $str;
   $getRegexs = $db-query(SELECT `regex`,`replace`,`search` FROM 
`_bb_codes`);
   while ($getRegex = mysql_fetch_assoc($getRegexs))
{
 $search = base64_decode($getRegex['search']);
 $regex = base64_decode($getRegex['regex']);
 $replace = base64_decode($getRegex['replace']);
 if (preg_match($search,$strNew) == 1)
  {
   for ($i = 1; $i  20; $i++)
{
 $strNew = $strOld;
$strNew = preg_replace($regex,$replace,$strNew);
 if ($strNew == $strOld)
  {
   break;
  }
 else
  {
   $strOld = $strNew;
  }
}
  }
}
   $return = $strNew;
   return $return;
  }
**

But, for something like this:

[quote][quote]Quote #2[/quote]Quote #1[/quote]No quote.

I'll get:

div class=quoteContainer
[quote]Quote #2[/quote]Quote #1/div
No quote.

Despite being in the loop.

Regex is: /\[quote\]((.*|\n)*)\[\/quote\]/
Replace is: div class=messageQuote$1/div

Both are stored base64 encoded in a database.

Any help / suggestions much appreciated.

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

2007-04-15 Thread Buesching, Logan J
 how I understand:
 clause one: isset($_GET['var'])
 clause two: ($_GET['var'] == 'foo')
 if clause two is true, clause one MUST be true.
 if clause one is true, clause two could be true or false.

 means, if I look for solutions where ($_GET['var'] == 'foo') they wil
 lautomaticaly cover isset($_GET['var']) part.
 if ($_GET['var'] != 'foo') I erally do not care isset($_GET['var']) or
 !isset($_GET['var']).

If you are looking for 

isset($_GET['var'])

to return true if the value exists, but may be null, you can always use 

if (isset($_GET['var']) || is_null($_GET['var]))

Albeit, I'm unsure if this will generate a warning if $_GET['var']
doesn't exist for the is_null() call.  And in this case, I believe it
would be appropriate to ignore that one warning.

-Logan

-Original Message-
From: Larry Garfield [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 15, 2007 1:17 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] isset

On Sunday 15 April 2007 12:07 pm, [EMAIL PROTECTED] wrote:

  of course it's your call whether you write/run code that spits out
  E_NOTICEs all over the place due to usage of uninitialized vars.

 not quite sure. if $_GET['var'] doesn't exists it's DEFINITLY not
equal to
 'foo', right?


 or I'm missing something here?

 I have E_NOTICE turned off. :)

And right there is your first mistake.  The only time to not have
E_NOTICE on 
is when you're using legacy code that isn't E_NOTICE compliant and you
don't 
have the time to upgrade it to be compliant.  Developing without
E_NOTICE 
means you're telling the computer it's OK, let me just randomly guess
where 
this bug or security hole or random typo is.  *Bad* idea.  

*Always* develop in the tightest, most restricted, most nit-picky
setting you 
can get, regardless of the language.  

If you want your syntax to be a bit simpler, I frequently use helper
functions 
along these lines:

function http_get_int($var, $default=0) {
  return isset($_GET[$var]) ? (int) $_GET[$var] : $default;
}

if (http_get_int('var') ==5) {
  // Do stuff
}

Clean to read, easy defaults, (reasonably) type-safe, and E_NOTICE
friendly.

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

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



RE: [PHP] PHP editor

2007-04-13 Thread Buesching, Logan J
Komodo, written in python and XUL (yes, the firefox extention engine).

-Original Message-
From: Jarrel Cobb [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 13, 2007 12:08 PM
To: Tijnema !
Cc: M. Sokolewicz; Philip Thompson; php General List
Subject: Re: [PHP] PHP editor

No, C is not a scripting language.  There probably are some editors
written in python though...which is a scripting language.

On 4/13/07, Tijnema ! [EMAIL PROTECTED] wrote:

 On 4/13/07, M.Sokolewicz [EMAIL PROTECTED] wrote:
  Philip Thompson wrote:
   On Apr 13, 2007, at 10:26 AM, Jay Blanchard wrote:
  
   [snip]
   Just showing my ignorance, probably, but what exactly is meant by

   a PHP editor?
  
   Does it mean an editor for editing PHP scripts, or an editor 
   written in PHP?
   [/snip]
  
   Something to edit PHP with...unless you're trying to be funny
  
  
   LOL! I don't know why this was so funny, but I laughed at Jay's
 comment
   (I can just see the light bulb turn on). Nonetheless, this
ignorant
   user brings up a thought - are there any editors written in PHP?
  
   ~Philip
  I sure hope not. Editors should never be written in 
  scripting-languages in my opinion.
 
  - tul


 Uhm, C is a scripting language too right?

 Most editors are written in C :)

 Tijnema

 --
 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] Dreamhost! PHP as CGI!???

2007-04-13 Thread Buesching, Logan J
You can't really do `php -v` on the command line, unless you know which
php you are using.  If you have several installations of PHP, then doing
`php -v` will just get you the version of PHP for which is loaded first
from your path.  I'd do a `which php` to make sure you are using php 5
first before `php -v`

-Logan

-Original Message-
From: Sebe [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 13, 2007 6:27 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; php php
Subject: Re: [PHP] Dreamhost! PHP as CGI!???

Richard Lynch wrote:
 On Fri, April 13, 2007 3:46 am, Micky Hulse wrote:
   
 I think I just read that PHP is ran as CGI on Dreamhost... this does
 not
 sound good. Can anyone confirm?
 

 You could confirm what you have on YOUR setup with:
 ?php phpinfo();?
 faster and with more assurance of correctness than any mailing list
 answer

yeah or `php -v` via cmdline.

by the way, isn't PHP w/FastCGI faster than using apache module?

-- 
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] PHP Eclipse on Linux

2007-04-12 Thread Buesching, Logan J
I haven't used Eclipse on Linux in awhile, but I believe that they have
some executable script (like, go to the eclipse directory and type
./eclipse) that you can just run and it will start up eclipse and
everything.


-Original Message-
From: Bagus Nugroho [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 12, 2007 8:12 PM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP Eclipse on Linux

Hi All,
 
When I'm trying to use eclipse on Linux, using command java
-startup.jar, it was show an error like this
Could not create Java Virtual Machine
 
Is my command wrong.
Java already installed and eclipse was put on /opt
 
Thanks in advance
bn 
 

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



RE: [PHP] location of the PHP executable

2007-04-11 Thread Buesching, Logan J
  IF db not exists THEN
locate -u 
  END-IF

I'd hate to see the time it'd take to create a first-time database...
this could take awhile to run.

-Original Message-
From: Davi [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, April 11, 2007 6:10 PM
To: php-general@lists.php.net
Subject: Re: [PHP] location of the PHP executable

Em Quarta 11 Abril 2007 18:50, Jarrel Cobb escreveu:
 Don't you have to run locate -u first to generate the database before
using
 locate?  You can't just assume a database exists already can you?


If you can use locate, you can use which... =P

BTW, do something to check OS then:

IF OS == *nix THEN
  IF exists /usr/bin/which THEN
which php
  ELSE
IF exists /usr/bin/locate THEN
  locate php | grep -iE php$
ELSE
  IF exists /usr/bin/find THEN
find / -name php | grep -iE php$
  ELSE
 cd /  ls php -Rv
  END-IF
   END-IF
  END-IF
ELSE
  cd \
  dir php*.exe /s
END-IF


Check if I don't miss any END-IF... =P

[]s

-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
rugged, adj.:
Too heavy to lift.

-- 
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] Array remove function?

2007-04-10 Thread Buesching, Logan J
Something along these lines?

$flipped=array_flip($arr);
unset($flipped[$val])
return array_flip($flipped);

From the manual of array_flip: 
If a value has several occurrences, the latest key will be used as its
values, and all others will be lost.

-Logan

-Original Message-
From: Tijnema ! [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 10, 2007 3:53 PM
To: [EMAIL PROTECTED]
Cc: PHP
Subject: Re: [PHP] Array remove function?

On 4/10/07, Richard Lynch [EMAIL PROTECTED] wrote:
 http://php.net/unset

That works when you know the key, but will that work when you only
know the value?

Tijnema


 On Tue, April 10, 2007 2:49 pm, Tijnema ! wrote:
  Hi,
 
  Is there currently a function that removes a key/value from an
array?
  I use this code right now:
  function array_remove($array,$remove,$remove_value = true)
  {
foreach($array as $key = $value) {
if($remove_value  $value != $remove) {
$new_array[$key] = $value;
} elseif (!$remove_value  $key != $remove) {
$new_array[$key] = $value;
}
}
return $new_array;
  }
 
  array_remove(array(1=2,2=3),2,true); // array (2=3)
  array_remove(array(1=2,2=3),2,false); // array (1=2)
 
  Anyone knows if there already exists such function?
 
  Else should i create future request?
 
  Tijnema
 
  --
  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 indie 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

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



RE: [PHP] PHP Directory List Script Files over 2 GB

2007-04-10 Thread Buesching, Logan J
I didn't take too much time to look at this, but I believe that where
you see:

---
sprintf(_f('%s',%d, .
---

Try and change that to:

---
sprintf(_f('%s',%u, .
---

From what information you provided, it seems that this is what would
work.

-Logan 

-Original Message-
From: Robert M [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 10, 2007 3:59 PM
To: php-general@lists.php.net
Subject: [PHP] PHP Directory List Script Files over 2 GB

Hello everyone

My OS information is
PHP Version 5.1.6
Apache/2.2.2 (Fedora)
Fedora Core 5 Kernel 2.6.20-1.2307.fc5


I am having some trouble with a script that displays files within a
directory.
the script does not appear to be displaying large files and the date
thaty
is displayed on these large files is Dec-31-69

I did not create the script I downloaded it from
www.celerondude.com/php-indexer
I also tried to get some assistance from the authors site but have not
been
repsonded to yet, so I thought I would try here.

The script itself is using php readdir and some javascript functions
which
is why I am so confused.

the main portions of the script is

?php
// This block MUST be at the very top of the page!
@ob_start('ob_gzhandler');
if(isset($_GET['icon']))
{
$e=$_GET['icon'];
$I['file']='ENCODED gif files (*** I REMOVED to save SPACE ***)';
header('Cache-control: max-age=2592000');
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T',time()+2592000));
header('Content-type: image/gif');
print base64_decode(isset($I[$e])?$I[$e]:$I['file']);
exit;
}
// End block

// Start configs
$sitename='BACKUPS';
$date='M-d-y'; // date format
//
$ignore=array('.','..','.htaccess','index.php','icon.php','iconup.php','
netdirs.php','main.css','index.html','Thumbs.db'); // ignore these files
$ignore=array('.','..');
// End configs
//
$root=dirname(__FILE__);
$root=/archive1/AutoBackups;

$dir=isset($_GET['dir'])?$_GET['dir']:'';if(strstr($dir,'..'))$dir='';

$path=$root/$dir/;

$dirs=$files=array();

if(!is_dir($path)||false==($h=opendir($path)))exit('Directory does not
exist.');
while(false!==($f=readdir($h)))
{
if(in_array($f,$ignore))continue;


if(is_dir($path.$f))$dirs[]=array('name'=$f,'date'=filemtime($path.$f)
,'url'='/backupdirs1.php?dir='.rawurlencode(trim($dir/$f,'/')));


else$files[]=array('name'=$f,'size'=filesize($path.$f),'date'=filemti
me($path.$f),'url'=trim($root/$dir/.rawurlencode($f),'/'));
}
closedir($h);
$current_dir_name = basename($dir);
$up_dir=dirname($dir);
$up_url=($up_dir!=''$up_dir!='.')?'/backupdirs1.php?dir='.rawurlencode
($up_dir):'/backupdirs1.php';
// END PHP ?


Then within the actual HTML I have the following javascript
script type=text/javascript
!--
var _c1='#fefefe'; var _c2='#fafafa'; var _ppg=25; var _cpg=1; var
_files=[]; var _dirs=[]; var _tpg=null; var _tsize=0; var _sort='date';
var
_sdir={'type':0,'name':0,'size':0,'date':1}; var idx=null; var tbl=null;
function _obj(s){return document.getElementById(s);}
function _ge(n){n=n.substr(n.lastIndexOf('.')+1);return
n.toLowerCase();}
function _nf(n,p){if(p=0){var t=Math.pow(10,p);return
Math.round(n*t)/t;}}
function _s(v,u){if(!u)u='B';if(v1024u=='B')return
_s(v/1024,'KB');if(v1024u=='KB')return
_s(v/1024,'MB');if(v1024u=='MB')return _s(v/1024,'GB');return
_nf(v,1)+'nbsp;'+u;}
function
_f(name,size,date,url,rdate){_files[_files.length]={'dir':0,'name':name,
'size':size,'date':date,'type':_ge(name),'url':url,'rdate':rdate,'icon':
'/backupdirs1.php?icon='+_ge(name)};_tsize+=size;}
function
_d(name,date,url){_dirs[_dirs.length]={'dir':1,'name':name,'date':date,'
url':url,'icon':'/backupdirs1.php?icon=dir'};}
function _np(){_cpg++;_tbl();}
function _pp(){_cpg--;_tbl();}
function
_sa(l,r){return(l['size']==r['size'])?0:(l['size']r['size']?1:-1);}
function
_sb(l,r){return(l['type']==r['type'])?0:(l['type']r['type']?1:-1);}
function
_sc(l,r){return(l['rdate']==r['rdate'])?0:(l['rdate']r['rdate']?1:-1);}
function _sd(l,r){var a=l['name'].toLowerCase();var
b=r['name'].toLowerCase();return(a==b)?0:(ab?1:-1);}
function
_srt(c){switch(c){case'type':_sort='type';_files.sort(_sb);if(_sdir['typ
e'])_files.reverse();break;case'name':_sort='name';_files.sort(_sd);if(_
sdir['name'])_files.reverse();break;case'size':_sort='size';_files.sort(
_sa);if(_sdir['size'])_files.reverse();break;case'date':_sort='date';_fi
les.sort(_sc);if(_sdir['date'])_files.reverse();break;}_sdir[c]=!_sdir[c
];_obj('sort_type').style.fontStyle=(c=='type'?'italic':'normal');_obj('
sort_name').style.fontStyle=(c=='name'?'italic':'normal');_obj('sort_siz
e').style.fontStyle=(c=='size'?'italic':'normal');_obj('sort_date').styl
e.fontStyle=(c=='date'?'italic':'normal');_tbl();return
false;}

function _head()
{
if(!idx)return;
_tpg=Math.ceil((_files.length+_dirs.length)/_ppg);
idx.innerHTML='div class=rounded gray style=padding:5px 10px 5px
7px;color:#202020' +
'p class=left' +


RE: [PHP] Copying PHP array into a Javascript array

2007-04-10 Thread Buesching, Logan J
Something along the lines of the following:

script type=text/javascript
var myArray=new Array();
?php
$files=getFiles($d);
foreach ($files as $key=$val) {
?
myArray[?php echo $key;?]=?php echo $val;?;
?php
}
?
/script

Although it looks nasty, I believe it could be a quick hack.

-Original Message-
From: Otto Wyss [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 10, 2007 4:37 PM
To: php-general@lists.php.net
Subject: [PHP] Copying PHP array into a Javascript array

I don't know if I should ask this question here or in the JavaScript 
group. I'll try it here since people usually are more helpful.

I've an array of file names

   $files = getFiles ($d);

but would like to use this array in a JavaScript array. How can I copy 
this $files into a JavaScript variable?

O. Wyss

-- 
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] DOM and XSLTProcessor

2007-04-10 Thread Buesching, Logan J
Thanks everyone,

I was able to get it to work by using CDATA and disable-output-escaping.
I guess I was not doing one or the other when I was testing.  Thanks for
all the help it replace a really... _really_ nasty regex, decode,
output.

-Logan

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 10, 2007 7:57 PM
To: Buesching, Logan J
Cc: Tijnema !; php-general@lists.php.net
Subject: RE: [PHP] DOM and XSLTProcessor

On Mon, April 9, 2007 3:50 am, Buesching, Logan J wrote:
 This could offer a possible workaround.

 Let me first state that I cannot simply do:

 echo htmlspecialchars_decode($proc-transformToXML($doc));

 If I were to do that, then it would assume that all of these encodings
 need to be decoded; which definitely is not the case.  I only want to
 do
 this for a few of the encodings, which I will know before the XSL
 processing.  I guess I can do some processing after it went through
 the
 XSL Processor to decode some of the encodings that I do not want, but
 that just seems like it would add a lot of unnecessary overhead if it
 can be avoided.

Can you special decode the limited subset on output, rather than doing
all of them on output, or hacking into the XML on input?

As I understand it...

The point is that the DATA can't have  and  in it, so if you want
that data to come through, you're going to have to encode/decode
somewhere along the line.

PHP automatically encodes for you for this very reason.

It's still up to you to interpret the data correctly at the output end.

Though I am kinda surprised the CDATA solution didn't do it...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie 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



[PHP] DOM and XSLTProcessor

2007-04-09 Thread Buesching, Logan J
Greetings,

 

I apologize if this is a little long, but I am trying to put as much
information as I have done in this first post.  I am running PHP 5 and
attempting to use DOM to create data to show on a webpage and using
XSLTProcessor with an XSLT sheet to output it into XHTML.  Everything is
pretty fine an dandy until I wish to print raw text, such as xdebug and
var_dump.

 

My knowledge of DOM and XSLTProcessor is about a 5/10, such that I know
most basics, but not the more advanced things.  Whenever I try to add
data using createTextNode, it is always escaped, such that if I do
strongsomething/strong, when shown to the screen, it shows
lt;stronggt; etc...  

 

Here is the general outline:

 

?php

$doc=new DOMDocument(1.0);

$root=$doc-createElement(root);

$wantedCode=$doc-createTextNode(strongSomething/strong);

$root-appendChild($wantedCode);

$doc-appendChild($root);

$proc=new XSLTProcessor;

$proc-importStylesheet(DOMDocument::load(test.xslt));

echo $proc-transformToXML($doc);

?

 

SomeSheet is something like:

xsl:template match=/

xsl:value-of select=./

/xsl:template

 

The expected output that I would like to get is:

strongSomething/strong

(This would just bold my text, not literally see the strong tags).

 

The actual output is:

lt;stronggt;Somethinglt;/stronggt;

(This outputs the strong tags to the end user, which is what I do not
want).

 

I checked the manual at:
http://us3.php.net/manual/en/function.dom-domdocument-createtextnode.php
.  A user comment suggested to use CDATA nodes, so I attempted to change
my code to the following:

 

?php

$doc=new DOMDocument(1.0);

$root=$doc-createElement(root);

//note the change right here

$wantedCode=$doc-createCDATASection(strongSomething/strong);

$root-appendChild($wantedCode);

$doc-appendChild($root);

$proc=new XSLTProcessor;

$proc-importStylesheet(DOMDocument::load(test.xslt));

echo $proc-transformToXML($doc);

 

?

 

But this was of no success; it just had the same output.

 

Is there anyone that is able to help me out here?

 

Thanks,

Logan



RE: [PHP] DOM and XSLTProcessor

2007-04-09 Thread Buesching, Logan J
This could offer a possible workaround.  

Let me first state that I cannot simply do:

echo htmlspecialchars_decode($proc-transformToXML($doc));

If I were to do that, then it would assume that all of these encodings
need to be decoded; which definitely is not the case.  I only want to do
this for a few of the encodings, which I will know before the XSL
processing.  I guess I can do some processing after it went through the
XSL Processor to decode some of the encodings that I do not want, but
that just seems like it would add a lot of unnecessary overhead if it
can be avoided.

Thanks for the idea though.

-Logan 

-Original Message-
From: Tijnema ! [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 09, 2007 4:40 AM
To: Buesching, Logan J
Cc: php-general@lists.php.net
Subject: Re: [PHP] DOM and XSLTProcessor

On 4/9/07, Buesching, Logan J [EMAIL PROTECTED] wrote:
 Greetings,



 I apologize if this is a little long, but I am trying to put as much
 information as I have done in this first post.  I am running PHP 5 and
 attempting to use DOM to create data to show on a webpage and using
 XSLTProcessor with an XSLT sheet to output it into XHTML.  Everything
is
 pretty fine an dandy until I wish to print raw text, such as xdebug
and
 var_dump.



 My knowledge of DOM and XSLTProcessor is about a 5/10, such that I
know
 most basics, but not the more advanced things.  Whenever I try to add
 data using createTextNode, it is always escaped, such that if I do
 strongsomething/strong, when shown to the screen, it shows
 lt;stronggt; etc...



 Here is the general outline:



 ?php

 $doc=new DOMDocument(1.0);

 $root=$doc-createElement(root);

 $wantedCode=$doc-createTextNode(strongSomething/strong);

 $root-appendChild($wantedCode);

 $doc-appendChild($root);

 $proc=new XSLTProcessor;

 $proc-importStylesheet(DOMDocument::load(test.xslt));

 echo $proc-transformToXML($doc);

 ?



 SomeSheet is something like:

 xsl:template match=/

xsl:value-of select=./

 /xsl:template



 The expected output that I would like to get is:

 strongSomething/strong

 (This would just bold my text, not literally see the strong tags).



 The actual output is:

 lt;stronggt;Somethinglt;/stronggt;

 (This outputs the strong tags to the end user, which is what I do
not
 want).



 I checked the manual at:

http://us3.php.net/manual/en/function.dom-domdocument-createtextnode.php
 .  A user comment suggested to use CDATA nodes, so I attempted to
change
 my code to the following:



 ?php

 $doc=new DOMDocument(1.0);

 $root=$doc-createElement(root);

 //note the change right here

 $wantedCode=$doc-createCDATASection(strongSomething/strong);

 $root-appendChild($wantedCode);

 $doc-appendChild($root);

 $proc=new XSLTProcessor;

 $proc-importStylesheet(DOMDocument::load(test.xslt));

 echo $proc-transformToXML($doc);



 ?



 But this was of no success; it just had the same output.



 Is there anyone that is able to help me out here?



 Thanks,

 Logan


Try using htmlspecialchars_decode before outputting your data:
http://www.php.net/manual/en/function.htmlspecialchars-decode.php

Tijnema



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



RE: [PHP] Curious Problem with $_POST

2007-04-09 Thread Buesching, Logan J
You may also want to take a look at
http://us.php.net/features.file-upload.  That is a good resource for
starting in file uploads.

-Logan

-Original Message-
From: Stephen [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 09, 2007 8:54 PM
To: PHP-General
Subject: [PHP] Curious Problem with $_POST

I have a form for uploading files. It is intended to upload photos. I 
have it listed at the end.

When I upload a jpg everything is fine. The $_POST variable is populated

as expected.

If I upload a zip file, it is empty!

print_r ($_POST); gives

Array ( )

If I upload a jpg Print_r gives:

Array ( [form] = uploadimagesform [MAX_FILE_SIZE] = 10 [category] 
= 1 [photo_caption] = Array ( [0] = [1] = [2] = [3] = ) [submit] 
= Add Photos )

I am at a total loss to understand this, and don't know where to begin.

Help!

Thanks in advance
Stephen

form enctype=multipart/form-data action=up.php method=post 
name=upload_formbr /
input name=form type=hidden value=uploadimagesform /
label for=categorySelect Category/label
select id=category name=category
option value=1Name/option
option value=2Purple/option
/selectbr /br /
label for=Photo1Photo 1:/label
input id=photo_filename[] name=photo_filename[] type=file 
/br /
label for=Caption1Caption: /label
textarea id=photo_caption[] name=photo_caption[]/textareabr

/br /  
label for=Photo2Photo 2:/label
input id=photo_filename[] name=photo_filename[] type=file 
/br /
label for=Caption2Caption: /label
textarea id=photo_caption[] name=photo_caption[]/textareabr

/br /   
label for=Photo3Photo 3:/label
input id=photo_filename[] name=photo_filename[] type=file 
/br /
label for=Caption3Caption: /label
textarea id=photo_caption[] name=photo_caption[]/textareabr

/br /  
label for=Photo4Photo 4:/label
input id=photo_filename[] name=photo_filename[] type=file 
/br /
label for=Caption4Caption: /label
textarea id=photo_caption[] name=photo_caption[]/textareabr

/br /  
input type=submit name=submit value=Add Photos /
/form

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

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



[PHP] RE: HTDIGEST FILE FORMAT

2007-04-01 Thread Buesching, Logan J
The password is the hash of the entire thing, not just the password.  So
it would be the following:

echo admin:trac:.md5('admin:trac:admin');

-Logan

-Original Message-
From: Manolet Gmail [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 01, 2007 5:28 PM
To: php-general@lists.php.net
Subject: HTDIGEST FILE FORMAT

hi, i want a php script to create htdigest file...

the correct file is:
username:admin
digest:trac
pass:admin

admin:trac:71ea86385b35d5e2575b0baec1904ded

i try to do it on php with this:

echo admin:trac:.md5(admin);

but i receive this:

admin:trac:21232f297a57a5a743894a0e4a801fc3

how is the htdigest format?

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