RE: [PHP] Using the echo tag...

2005-11-07 Thread Pablo Gosse
[snip]
I'm relatively new at coding PHP but I was hoping someone can help me
with
this.

I'm trying to write the following code into my program but each time it
runs, I get an error message. Can anyone help?

print  EOF
!-INSERT HTML HEADER HERE --
$_SERVER['PHP_SELF']
EOF;

Say that was a part of a HTML Form action tag, everytime I try to run
it, I
get an error message am I doing something wrong or do I have to break
out of
the here document to use this syntax?
[/snip]

What's the error message you're getting?  That will be most helpful in
trying to diagnose the problem.

Likely, though, is the fact that you're trying to output
$_SERVER['PHP_SELF'] within your heredoc syntax, without wrapping it in
curly braces.

It should be:

{$_SERVER['PHP_SELF']}

See
http://www.php.net/manual/en/language.types.string.php#language.types.st
ring.syntax.heredoc for more info.

Cheers,

Pablo

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



RE: [PHP] Security Issues - Where to look?

2005-11-07 Thread Pablo Gosse
[snip]
I've heard that php is not particularly secure, making it problematic if
you
intend to create a web site with commerce, etc. Is there a particular
news
group that addresses security issues? I'm looking for some guidlines on
ensuring that my site is secure from malicious hackers.
[/snip]

It's not so much that PHP is not particularly secure, but rather that
some of the people who use it don't know how to make it work in a secure
manner.

Configured and coded properly a PHP application can be very, very
secure.  

However, without careful configuration and good coding it's also
possible to create very, very insecure applications using PHP.  Or .NET.
Or Java.  Or Cold Fusion.  Or JSP.

It's not the technology that's insecure, but the method by which it's
implemented. 

Why not check out these links:

http://www.google.ca/search?q=php+security

http://www.devshed.com/c/a/PHP/PHP-Security-Mistakes/

http://phpsec.org/

Cheers,

Pablo

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



RE: [PHP] reg ex help

2005-11-04 Thread Pablo Gosse
[snip]
New to php so please bear with me.  I'm trying to parse through a field
that has some information in it, the information is stored with other
information and is delimited in a certain pattern so I figure using reg
ex I can get the information I want out of the text.

So here is an example.

Silver Small Corp;X^%\n#\n
Gold Medium Corp;RE^%\n#\n
Platinum Large Corp;YRE^%\n#\n

Reall all I need is the information on Silver Small Corp, etc and the X
all the rest is gibberish.  Is Reg Ex the best way to do this or would
it be some other way.[/snip]

If the number of semi-colons is fixed, then explode will do the trick.

$foo = 'Silver Small Corp;X^%\n#\n'; $bar = explode(';',
$foo); echo $bar[0];

However if the number of semi-colons is not fixed, then substr in
conjunction with strpos will do the trick.

$foo = 'Silver Small Corp;X^%\n#\n'; $bar = substr($foo, 0,
strpos($foo, ';')); echo $bar;

HTH,

Pablo

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



RE: [PHP] reg ex help

2005-11-04 Thread Pablo Gosse
[snip]
The problem with that is there are about 40 different listings in the
one field.

Silver Small Corp;X^%\n#\n
Gold Medium Corp;RE^%\n#\n
Platinum Large Corp;YRE^%\n#\n

being three of them so maybe this is a bettter way of listing it

... Silver Small Corp;X^%\n#\nGold Medium
Corp;RE^%\n#\nPlatinum Large Corp;YRE^%\n#\n
...[/snip]

Try this:

$values = array(); // we'll put the extracted vars here
$str = This is supposed to be your string;

$tmpStr = explode(#\n, $str);

foreach ($tmpStr as $foo) {
if (strlen(trim($foo))  0) {
array_push($values, substr($foo, 0, strpos($foo, ';')));

}
}

HTH,

Pablo

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



RE: [PHP] extracting foo.bar from path/to/file.php/foo.bar

2005-11-04 Thread Pablo Gosse
[snip]
What do I need to do to extract foo.bar from path/to/file.php/foo.bar
[/snip]

The manual is your friend ;o)

http://www.php.net/basename/

HTH,

Pablo

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



RE: [PHP] protect password?

2005-11-04 Thread Pablo Gosse
[snip]
Some functions need you to provide username and password, for instance 
odbc_connect.  Even though the username/password just has minimum access

privileges to the resource, putting it there in clear text in a script
gives 
me heartburn.  How do people handle username/password in such kind of
cases? 
I'm sure there must be some way to store critical information in some 
encrypted format but it's still readable to scripts for authentication 
purpose.  But don't know how.  Any ideas or pointer would be greatly 
appreciated.
[/snip]

Some time ago Chris Shifflet provided a nice suggestion on how to make
your passwords more secure.  It's still not rock solid, but far better
than storing them in clear text.

The methodology I present below (which Chris presented originally)
assumes Apache as your web server.  Though I've recently gotten into IIS
administration I'm not sure of how you would specifically do this under
IIS.

Create a file outside of your webroot, and in it use SetEnv declarations
to set a username and password as environment vars.

SetEnv dbname username
SetEnv dbpass password

Chown this file such that it is only readable by root, and then
(assuming you're on a shared host) have it included in your virtual host
block of the server config file.  If you're on a dedicated box include
it in the configuration section for the site in question.

Then when the server is restarted you will be able to access the
username and password via $_SERVER['dbuser'] and $_SERVER['dbpass'] in
your scripts.

As the first response to your post, not exactly what you were looking
for, but much more secure than plain text or even simple include files.

HTH.

Cheers,
Pablo

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



RE: [PHP] protect password?

2005-11-04 Thread Pablo Gosse
[snip]
pablo...

i fail to see how your suggestion is much more secure than placing the
user/passwd information in a file that's outside the web access space,
and then including the file.

in either case, the user wouldn't be able to read the include file. 
[/snip]

Greeting, Bruce.

On a dedicated server there wouldn't be much difference.  However if the
site in question were on a shared host (which is usually the case) there
would be a huge difference.

On shared hosts since files to be included need to be readable by the
user the server runs as their permissions must be set to:

-rw-r--r--

And since every one else who has a site on the same server must also
have files to be included set to be readable by the server user, one
could easily write a trolling script to traverse the directories of
other users on the site and grab whatever info they needed.

The shared host I use for my personal site used to have this problem
until I made them aware of it.  In less than two minutes I was able to
find several database usernames and passwords.  They've since made
changes to eliminate this problem.  All that needs to be done is secure
up the directory permissions and the problem goes away.

By setting the file readable only by root this problem is completely
eliminated.  Unless a hacker has the root password, they will not be
able to compromise the information in this file.

This is how I understand it, at least.  If Chris reads this perhaps he
can confirm this for me?

Cheers,

Pablo

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



[PHP] Regex Help

2005-09-28 Thread Pablo Gosse
Hi, folks.   I'm having trouble with a simple regex.  I'm sure it's just
something small that I'm missing but nothing I'm trying is working.

In an HTML file I have comments like this:

!-- START PRINT --
various html crap here
!-- END PRINT --

Here's the regex I'm using:

/!-- START PRINT --(.*?)!-- END PRINT --/

And then the call to preg_match_all():

preg_match_all($printable_reg, $str, $out);

It's been quite a while since I've worked with regular expressions so
I'm not sure what the problem is.  The regex isn't throwing errors, it's
just not matching the content located between the start print and end
print comments.

Can anyone lend a hand or give some advice?

Cheers and TIA,
Pablo

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



RE: [PHP] Regex Help

2005-09-28 Thread Pablo Gosse
Greetings folks.  Thanks Murray and Philip for the quick responses.
Adding the /s modifier worked perfectly.

Cheers,
Pablo

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



[PHP] enabling OpenSSL and curl for PHP on IIS

2005-08-24 Thread Pablo Gosse
Hi, folks.  I'm forced to work on a project using MS Access and running
on IIS on a Windows Server 2003 box.

I've uncommented the following lines in php.ini:

extension=php_curl.dll
extension=php_openssl.dll

but even after I restart IIS I'm not seeing the changes reflect when I
view the results of phpinfo().

One thing that I find strange is that when I look at phpinfo() I see the
following:

Configuration File (php.ini) Path C:\WINDOWS

yet there is no php.ini file under C:\WINDOWS, rather it's in C:\php

Can anyone give any insight into what might be going wrong here?

Cheers and TIA,

Pablo

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



Re: [PHP] enabling OpenSSL and curl for PHP on IIS

2005-08-24 Thread Pablo Gosse
On Wed, 2005-08-24 at 14:05 -0400, Marco Tabini wrote:
 On 8/24/05 11:39 AM, Pablo Gosse [EMAIL PROTECTED] wrote:
 
  Can anyone give any insight into what might be going wrong here?
 
 I think you just need to move your php.ini file to C:\WINDOWS... PHP is
 looking for it there.
 
 Cheers,
 
 
 Marco
 
 

I've tried that and that just results in PHP grinding to a halt.  Any
requests to PHP pages simply result in Document contains no data
errors.

I've tried changing the registry entry for IniFilePath to c:\windows and
moving the php.ini file there, but the same thing results - PHP just
hangs and the pages return nothing.

Other pages on the server work fine.

Any other ideas?  We really need to enable OpenSSL and curl and it's
kind of difficult when you can't effect any changes to the php.ini file!

Hoping someone can offer some advice here ...

Cheers and TIA,

Pablo

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



Re: [PHP] enabling OpenSSL and curl for PHP on IIS

2005-08-24 Thread Pablo Gosse
On Wed, 2005-08-24 at 23:30 +0200, Edin Kadibasic wrote:
 Pablo Gosse wrote:
  I've tried that and that just results in PHP grinding to a halt.  Any
  requests to PHP pages simply result in Document contains no data
  errors.
 
 Have you added c:\php to your system PATH?
 
 Edin

Yup.

c:\php is in the system PATH, just as described here:
http://www.php.net/manual/en/faq.installation.php#faq.installation.findphpini

and I also tried creating the PHPRC environment var as described here:

http://www.php.net/manual/en/faq.installation.php#faq.installation.phprc

to no effect.  It's simply not reading the changes.  I've even commented
out the openssl and curl lines, and am now just changing the value of
allow_url_fopen to Off, but that's not working.

NOTHING seems to have any effect.

Anyone else have any suggestions?  This is very, very strange (and
incredibly frustrating ...)

Cheers and TIA,

Pablo

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



[PHP] RE: Problem using Metabase

2005-08-16 Thread Pablo Gosse
[snip]
I suspect that the problem is with file permissions. I recall that since

Metabase uses include to load class files, the script will not exit when

it fails to include a PHP class file. Assuming that is the case, make 
sure that all Metabase class files are readable by your Web server user.
[/snip]

The permissions seem fine.  However, I've discovered something else.

I was able to use Metabase without any trouble on a linux server to
access a Postgres database.  I then removed the call to
MetabaseSetDatabase and changed the drive to odbc-msaccess, and the
errors returned.  Changed it back to pgsql or mysql and the errors go
away.

I just now tried this on the IIS box and got the same results.  If I
specify postgres I get an error telling me that postgres is not enabled
in that php implementation, and if I specify mysql it works fine.  If I
change it back to odbc-msaccess, the errors are there.

So, the error message I get is only triggered when I specify Access as
the database.

Does this provide any further insight?

Cheers and TIA,

Pablo

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



[PHP] Problem using Metabase

2005-08-15 Thread Pablo Gosse
Hi, folks.  I've recently decided to use Manuel's Metabase instead of
ADOdb as ADOdb doesn't support transactions for MS Access, however I'm
getting the following error when running the sample code:

Fatal error: Class metabase_manager_odbc_class: Cannot inherit from
undefined class metabase_manager_database_class in
C:\Inetpub\wwwroot\etrakFE\classes\metabase\metabase_odbc.php on line 13

Obviously this means that the metabase_manager_odbc_class is being
defined before metabase_manager_database_class, thus throwing an error,
but the problem is I'm not calling this manually, and have used the
sample code exactly as it is in the manual.

Here's my code:

require(classes/metabase/metabase_database.php);
require(classes/metabase/metabase_interface.php);

$error=MetabaseSetupDatabaseObject(array(Type=odbc-msaccess,
IncludePath=classes/metabase), $db);

if($error!=) {
echo Database setup error: $error\n;
exit;
}

$db-SetDatabase(etrakADB);

Does anyone have any idea why I might be getting this error?  As I said
I'm using the sample code exactly as it is in the tutorial, and am not
calling the metabase_manager_odbc_class myself.

Cheers and TIA,

Pablo 

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



[PHP] RE: Problem using Metabase

2005-08-15 Thread Pablo Gosse
[snip]
 Here's my code:
 
 require(classes/metabase/metabase_database.php);
 require(classes/metabase/metabase_interface.php);
 
 $error=MetabaseSetupDatabaseObject(array(Type=odbc-msaccess,
 IncludePath=classes/metabase), $db);
 
 if($error!=) {
   echo Database setup error: $error\n;
   exit;
 }
 
 $db-SetDatabase(etrakADB);

I tried that code here with PHP 4.3.11 and it works perfectly.

Which version of PHP are you using?

Are you using any PHP cache extension like APC or another?

Metabase loads the class files by the right order but it is possible 
that a buggy caching extension may be causing that problem.

You may also try loading the classes as workaround right after the 
includes you make in your script:

require('classes/metabase/metabase_odbc.php');
require('classes/metabase/metabase_odbc_msaccess.php');
require('classes/metabase/manager_odbc.php');
require('classes/metabase/manager_odbc_msaccess.php');
[/snip]

Thanks, Manuel.  I tried what you suggested but it didn't work.  The server 
this project is housed on is an IIS server running PHP 4.4.0.

I installed the metabase package on a linux server, and was able to connect to 
a postgres database with no troubles at all.

It must be something in our PHP configuration that's causing the problem, but 
I'm pretty sure we have a cache extension installed.  This PHP install was done 
rather quickly, unless there's a cache extension installed by default (which 
there is not as far as I understand, but I could be wrong ...) we likely didn't 
install one.

Thanks,

Pablo

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



RE: [PHP] RE: Problem using Metabase

2005-08-15 Thread Pablo Gosse
[snip]
It must be something in our PHP configuration that's causing the
problem, but I'm pretty sure we have a cache extension installed.  This
PHP install was done rather quickly, unless there's a cache extension
installed by default (which there is not as far as I understand, but I
could be wrong ...) we likely didn't install one.
[/snip]

Sorry, I meant to say that we likely DO NOT have a cache extension
installed.

Can anyone think of any other reason why the order in which the class
files are loaded would be changed on one server to the next?

Cheers and TIA,

Pablo

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



RE: [PHP] header redirect not working

2005-08-13 Thread Pablo Gosse
[snip]Can you place the following code just before the header() line,
and post what it prints?

die($this-CMS_base_path);

In other words, tell us what the $this-CMS_base_path field contains
when that line is executed.[/snip]

It contains 'https://cms.mydomain.com', which is what it is supposed to
contain.

It's redirecting to the correct domain, just the incorrect page.

Thanks,
Pablo

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



RE: [PHP] header redirect not working

2005-08-13 Thread Pablo Gosse
[snip] I can think of a few, and my first instinct is to check to see
whether your script produces any errors in one environment that it
doesn't in the other. If you're displaying errors, they can affect the
behavior of your scripts when you're also using header(). Replace
header() with echo and compare the behavior.

Also, comparing php.ini can help you identify differences in
configuration. Configuration directives can be modified through other
means, but this is a good starting point (and a good candidate for
version control anyway - inconsistencies can cause you to waste time and
effort).[/snip]

Hi, Chris.

I turned on error reporting for that script in production and no errors
occurred.

However, and this is even stranger to me, if I add the following after
the call to header()

die('foo');

the page redirects to the correct url.

I remove die('foo'); and it redirects to itself again.

I'll take a look at the two ini files to see if I can spot any
differences, but I'm stumped as to what in there might cause just this
one page to redirect to itself rather than the prescribed URL.

The form submits to a controller url, and then is validated using a form
generation/validation class I use for all my applications.  If the
validation fails it redirects back to the form page, with the
appropriate form id appended to the url.  If the validation succeeds,
the delete event method is called, at the end of which the redirect back
to the main event page should occur, but is not for some reason, unless
I add that line of code after it.

I know the form is validating since the event is deleted, since, well,
it is deleted, and there is no form id appended to the url when it is
redirected.

Any other ideas?

Thanks,

Pablo

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



[PHP] PHP, MS Access Transactions

2005-08-13 Thread Pablo Gosse
Hi, folks.

I have the unfortunate task of writing a PHP front-end for a
client-server application that is back-ended in MS Access.

I've tried using the transaction functionality in ADOdb (PHP
implementation of ADO) but it doesn't work seem to work correctly, even
though it says it does.

If I intentionally submit a malformed query as part of a series of
inserts, the ADOdb transaction supposedly rolls back, but when I look at
the database, the inserts carried out before the error occurs are still
there.

Does anyone know if it's possible to use transactions with Access via
PHP?

Cheers and TIA,

Pablo

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



[PHP] header redirect not working

2005-08-12 Thread Pablo Gosse
Hi, folks.  I'm running into an incredibly bizarre problem with a
header() redirect of which I cannot see the cause.

We have a CMS here where I work, in two separate production and training
environments.

Last night I implemented a new events manager module, copying all
necessary files from training to production, adding database tables,
etc. etc.

Everything worked, except for one redirect which happens after a user
deletes an event.  For some reason, the redirect is simply reloading the
event detail page from which the user clicked the delete link.

But the truly bizarre thing is that in the training environment it
works!!!

There is nothing different between the two files except for '-test'
being added to the subdomain (so it's cms-test.mydomain.com instead of
cms.mydomain.com) in any full paths.

The code that deletes the event, and then redirects the user is:

$conn-Execute(delete from cms_events where e_id = {$fd['e_id']}) or
$this-CMS_error(2,$this-mod_name,$query,$conn-ErrorMsg());

header(Location:{$this-CMS_base_path}mods/events_manager/cms.events_ma
nager.dsp.php);

Not to much to see here.  If the query doesn't execute the CMS_error
method is called, and the header would never be reached.

However, the query does execute, the event is deleted, but instead of
going to the appropriate location, it's simply redirecting back to:

/mods/events_manager/cms.events_manager.event_detail.dsp.php?e_id=15

where 15 is whatever the number of the event that was just deleted was,
and ergo it brings up an Invalid event error, and the user can then
click a link at the bottom of the page to go back to the main events
manager page.

Can anyone think of any reason why the above code, just those two lines,
would redirect correctly in one environment, yet simply redirect to the
currently existing page in another?

There are a number of other redirects in the events module that are
working fine, so why this one would work in the training environment and
not in the production environment is mystifying me.

Cheers, and thanks very much in advance for any help. This one hurt my
brain this afternoon.

Pablo

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



[PHP] Feedback on the various PHP-MVC implementations

2005-06-15 Thread Pablo Gosse
Hi, folks.

I'm looking for some feedback on a couple of the php mvc implementations
out there.

The two that I've seen referenced the most are php.MVC
(http://www.phpmvc.net) and Phrame (http://phrame.sourceforge.net).

I've looked around and found some okay opinions on both, but I'd really
like to hear from some people on this list who have used one or both
directly, or any other MVC frameworks that you feel are worth
mentioning.

I've looked through the archives but have not found much from people who
have actually implemented any of these frameworks, just mainly comments
of what they look like on the surface.

If anyone here has any direct experience with either of the above
frameworks, or with any other stable, mature frameworks please let me
know.

Cheers and TIA,

Pablo

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



RE: [PHP] mozilla urlencode

2005-06-04 Thread Pablo Gosse
snip
echo a name=\.urlencode($mydata-district).\/a;
a name=Montr%E9al+District+%234/a

http://foo.org/_private/directory.php#Montr%E9al+District+%234 works in 
IE6, but Mozilla will not accept it.

Mozilla does not work. Am I approaching this wrong? Should I create my 
HTML this way?

echo a name=\.$mydata-district.\/a;
a name=Montréal District #4/a

If I do, Mozilla prferes this:

http://foo.org/_private/directory.php#Montr%E9al%20District%20#4
or
http://foo.org/_private/directory.php#Montr%E9al%20District%20%234

IE refuses it and prefers:

http://foo.org/_private/directory.php#Montr%E9al+District+%234
/snip

I'm not sure, but I see two things that might be causing this.  First, why are 
spaces, which should be translated as %20, being represented as a '+'?

Second, you have a # in the actual bookmark name, which I would assume is not 
valid since the # denotes the beginning of a bookmark.  So perhaps IE 
compensates for this, but Mozilla reads the bookmark as looking for a 
name=4/a because of the #4 at the end of the bookmark name.

HTH,

Pablo

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



[PHP] PHP and SSH

2005-05-19 Thread Pablo Gosse
Hi, folks.  Has anyone had any issues using PHP with the libssh2
library?

I had my sysadmin install it, but he's not certain we should be
developing against it in a production environment since it's still alpha
(0.10).

I'm looking for opinions as to whether anyone out there has run into
problems developing against it, or if the general consensus is that
there are no critical concerns about using it as a core part of a large
project.

I personally don't think there are, since I don't think that PHP would
have bindings to this library if it weren't, but I want to have some
other feedback to give to my sysadmin?

Anyone have any opinions?

Cheers and TIA,

Pablo   

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



RE: [PHP] html editor written in PHP

2005-05-18 Thread Pablo Gosse
snip
Has anyone seen an example of a HTML editor written in PHP (no JS)?  
You know the ones - for adding HTML tags to a text field, etc.
/snip

I think what you're asking for is a logical impossibility.  PHP is
server side, so without javascript a browser-based wysiwyg editor would
be impossible, since there would be no client-side functionality to
respond to any action by the user.

If I'm somehow being incredibly obtuse here and have misconstrued your
question, I apologize.  However I think that what you're thinking about
just isn't possible.

Cheers,

Pablo

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



[PHP] array_diff odities

2005-05-18 Thread Pablo Gosse
Howdy folks.  I'm running into something strange with array_diff that
I'm hoping someone can shed some light on.

I have two tab-delimited text files, and need to find the lines in the
first that are not in the second, and vice-versa.

There are 794 records in the first, and 724 in the second.  

Simple enough, I thought.  The following code should work:

$tmpOriginalGradList = file('/path/to/graduate_list_original.txt');
$tmpNewGradList = file('/path/to/graduate_list_new.txt');

$diff1 = array_diff($tmpOriginalGradList, $tmpNewGradList);
$diff2 = array_diff($tmpNewGradList, $tmpOriginalGradList);

I expected that this would set $diff1 to have all elements of
$tmpOriginalGradList that did not exist in $tmpNewGradList, but it
actually contains many elements that exist in both.

The same is true for $diff2, in that many of its elements exist in both
$tmpOriginalGradList and $tmpNewGradList as well.

Since this returns $diff1 as having 253 elements and $diff2 as having
183, it sort of makes sense, since the difference between those two
numbers is 70, which is the difference between the number of lines in
the two files.  But the bottom line is that both $diff1 and $diff2
contain elements common to both files, which using array_diff simply
should not be the case.

However, when I loop through each file and strip out all the tabs:

foreach ($tmpOriginalGradList as $k=$l) {
$tmp = str_replace(chr(9), '', $l);
$tmpOriginalGradList[$k] = $tmp;
}

foreach ($tmpNewGradList as $k=$l) {
$tmp = str_replace(chr(9), '', $l);
$tmpNewGradList[$k] = $tmp;
}

I get $diff1 as having 75 elements and $diff2 as having 5, which also
sort of makes sense since there numerically there are 70 lines
difference between the two files.

I also manually replaced the tabs and checked about 20 of the elements
in $diff1 and none were found in the new text file, and none of the 5
elements in $diff2 were found in the original text file.

However, if in the code above I replace the tabs with a space instead of
just stripping them out, then the numbers are again 253 and 183.

I'm inclined to think the second set of results is accurate, since I was
unable to find any of the 20 elements I tested in $diff1 in the new text
file, and none of the elements in $diff2 are in the original text file.

Does anyone have any idea why this is happening?  The tab-delimited
files were generated from Excel spreadsheets using the same script, so
there wouldn't be any difference in the formatting of the files.

This one has me confused as I really thought the simple code posted
above should have worked.

If anyone can pass along any advice I would greatly appreciate it.

Cheers and TIA,

Pablo

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



RE: [PHP] Simple Problem

2005-04-12 Thread Pablo Gosse
snip
I can't figure out what I am doing wrong,
this sql string seems to filter out the information I want but it
duplicates the all info, as 'num_rows' is total of rows in the table and
not the correct value of the filtered information?

$sql=SELECT products.productID, products.title,
products.number_per_box, products.stock_level, products.image,
users.username, users.email, users.userID FROM users, products  WHERE
products.userID = $userID; $mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);


this is the old sql statement which works fine - 
$sql=SELECT productID, title, number_per_box, stock_level, image,
userID FROM products WHERE userID = '$userID';
$mysql_result=mysql_query($sql,$connection);
$num_rows=mysql_num_rows($mysql_result);

what I am I doing wrong.
/snip

In the old query you're jut pulling records from one table.  In the
second, you're joining two tables, but you're still using the same WHERE
clause, products.userID = $userID.

This is causing multiple records to be returned, since there is nothing
specifying how you are joining the users and products table so it
correctly returns a match for every row in the user table.

Change the where clause to:

WHERE products.userID = $userID
AND users.userID = $userID

and this will force the query to limit results to those records in
products that have a matching record in the users table.

HTH.

Pablo

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



[PHP] Displaying Time Intervals

2005-04-07 Thread Pablo Gosse
Hi, folks.

I've added some code to our CMS that tracks the exact amount of time
that a user is logged into the system.  I'm going to use these stats to
track how much time someone has spent practicing in the training
environment before I give them access to our production system.

Can anyone give me some advice on the best way to display intervals of
time?

Basically there are two timestamps - time_in and time_out, and I want to
for each record display the difference between the two in the format of
H:i:s.  I'm pulling the timestamp fields from the database in the format
of number of seconds since the epoch.

Then, cumulatively for each day, I want to display the total time, also
in the format of H:i:s.

Can anyone give me some advice on how to do this?  I thought of date()
and strftime(), but I don't see how those would accommodate for someone
who spends 30 seconds on the CMS in a single session, since that would
need to be displayed as 00:00:30.

Is there an existing class that provides such functionality, or should I
just write one myself?

Cheers and TIA,

Pablo

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



RE: [PHP] HTML meta tag and PHP

2005-03-29 Thread Pablo Gosse
snip
How can I write something like that?
meta http-equiv=Refresh 
content=0;url=registration.php?step=4userId=%php echo 
trim($_POST[userid]); 

This is obviously not working as the  is assumed as the closing  for
the 
meta tag.
/snip

You haven't closed your opening php tag, which is why it's not working.

meta http-equiv=Refresh 
content=0; url=registration.php?step=4userId=%php echo
trim($_POST[userid]); % 

Is how it needs to be to work.

HTH,

Pablo

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



RE: [PHP] HTML meta tag and PHP

2005-03-29 Thread Pablo Gosse
snip
How can I write something like that?
meta http-equiv=Refresh 
content=0;url=registration.php?step=4userId=%php echo 
trim($_POST[userid]); 

This is obviously not working as the  is assumed as the closing  for
the 
meta tag.
/snip

Sorry, I botched my previous reply and left the extra  after userId.
It should be:

meta http-equiv=Refresh 
content=0; url=registration.php?step=4userId=%php echo
trim($_POST[userid]); % 

Pablo.

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



[PHP] PHP Compiler for .NET platform

2005-03-18 Thread Pablo Gosse
Hey folks.

Has anybody played with this the PHP compiler for .NET, Phalanger?

http://www.php-compiler.net/

I'd be interested to hear of any experiences people have had using this.

Cheers,
Pablo


--
Pablo Gosse
Webmaster, University of Northern British Columbia
250.960.5621
[EMAIL PROTECTED]
--

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



RE: [PHP] PHP arrays and javascript

2004-11-26 Thread Pablo Gosse
snip
i know this probally a simple question, but it has been stumping me for
quite some time now. How do i pass a php array to a javascript?

i tryed:
script language=javascript
var myarray = new Array(?PHP echo $myarray; ?);
/script

but it didn't work. Anybody got any ideas?
/snip

You need to generate the javascript array from your PHP array.

Example:

In your script create a php array of the values you wish to use.  Using
indeces is not essential.  If you do not use them, you can just use a
counter var when you loop through the array to create the indeces for
the JS array.

?php
$arrayVar = array('first index'='item 1', 'second index'='item 2',
'third index'='item 3');

$jsVar = var myArray = new Array();\n;

foreach ($arrayVar as $idx=$val) {
$jsVar .= myArray['{$idx}'] = {$val}\n;
}
?

The final output of this will be:

var myArray = new Array();
myArray['first index'] = 'item 1';
myArray['second index'] = 'item 2';
myArray['third index'] = 'item 3';

HTH,

Pablo

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



[PHP] Load testing for PHP Applications

2004-11-10 Thread Pablo Gosse
Hi folks.  I'm wondering if anyone out there can recommend a good tool
for load testing a large php application?  Ideally it would be something
fairly intelligent, that would follow links, remember what links it has
followed and where any problems occurred, etc.

Can anyone provide any recommendations?

Cheers and TIA,

Pablo

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



[PHP] Session object destruction failed

2004-11-04 Thread Pablo Gosse
Hi folks.

Earlier today I received the following error when I tried to log out of
my CMS:

Session object destruction failed in [blah blah blah file info].

I googled this and took a look on bugs.php.net but couldn't find much
useful info.

Everything worked fine before, and has worked fine since, so I'm not
overly concerned.  I'd just like to know what caused it.

Any ideas?

Cheers and TIA,

Pablo

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



RE: [PHP] 'Code Snippets' you couldn't live without

2004-11-03 Thread Pablo Gosse
[snip]Klaus Reimer wrote:
 Murray @ PlanetThoughtful wrote:
 function asl($val){
 function mfr($rset){
 
 This may be ok for private projects but otherwise I don't think it's a
 good idea to create shorthand functions. Other developers (and
 especially new developers beginning to work on the project) are
 getting confused. They must first learn what this functions are
 doing. The names of these functions are not really helpful in
 understanding what's going on.[/snip]

I'm with Klaus on this one.

I see the purpose of creating functions that eliminate repetitive
behaviour by using native PHP functions and doing a little something
extra with the results to suit your needs, but as for just using
asl($val) instead of addslashes($val), well why not just extend the PHP
source to make asl() an actual alias to addslashes()?

My $0.02 (CDN).

Pablo

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



RE: [PHP] 'Code Snippets' you couldn't live without

2004-11-03 Thread Pablo Gosse
[snip]Extending PHP to have shorthand functions? Was that
irony?[/snip]

It most certainly was irony, Klaus.

I was merely trying to illustrate the point that writing a custom
function which does EXACTLY the same thing as a built in function is
redundant.  A number of functions within php do have aliases (sizeof()
is an alias count() for example) but these are throwbacks to equitable
functions in other languages.

As I stated earlier, if your function does more than the built in
function, then yes, you are increasing efficiency, but if all you're
doing is creating a custom alias of which only you will know the useage,
then you only increase obscurity.

As for my favorite piece of reusable code, I hate preparing dates for
insertion into a database when I have to deal with null values, etc.  So
I use a function which takes an array of date field names and a regular
expression, then validates $_POST['field name'] against the regular
expression and returns an array, $dates, each field of which contains
either a date prepared for insertion (wrapped in single quotes) or
simply the string 'null'.

function _formatPostDates($dateArr,$regex)
{
$dates = array();
foreach ($dateArr as $date) {
$dates[$date] = preg_match($regex,$_POST[$date]) ?
'{$_POST['release']}' : null;
}
return $dates;
}

On a page where I have to deal with multiple date fields, this greatly
increases the efficiency of validating the dates and makes things safer
and easier when creating queries.

Cheers,
Pablo

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



RE: [PHP] PEAR Calendar

2004-11-03 Thread Pablo Gosse
[snip]
Greg Beaver wrote:
My country is going to Hell
[/snip]

Don't worry, Greg.  It's not really your country as much as it is your
president ;o)  We hold nothing against you, for you wrote PHPDocumentor!

Cheers,
Pablo

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



RE: [PHP] Re: [users@httpd] November 2, 2004

2004-11-02 Thread Pablo Gosse
[snip]
 This list gets enough traffic as is and a crapload of repeat
 questions/questions that are easily solved by looking in google or
 the manual (aka RTFM questions) and we don't need to add politics to
 it
[/snip]

And further to this point, people who reply to off-topic posts only
further congest the list and push the problem further.

I know it might seem hypocritical of me to state this, since this is in
itself a reply to an off-topic post, but I do so in hopes that everyone
on this list will follow my lead and NOT reply to any more of these
plebian rantings about other countries' (or, if you're an American
citizen, your country's) elections (or other blatantly OT posts, for
that matter).  If nobody replies to these stupid posts, then they will
just go away.

It's like the Simpsons' Halloween Special piece where all the
advertising billboard characters come alive and run amuck in
Springfield, and the marketing company that created them tells Lisa that
people must stop paying attention to them to make them go away.  If
people don't look at them, they will go away.  Simple as that.

If you nobody replies to OT posts, they will go away.

Once again the Simpsons' shows us the way...

Just my $0.02 (CDN).

P.

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



RE: [PHP] Error Code Airhead

2004-11-02 Thread Pablo Gosse
[snip]
 I'm sure I'm missing something really obvious here but
 can't see it. There is a form where one of two promotional codes can
 be entered. I check for the these codes and give the user an error
 message if they enter the wrong code. First one doesn't work, second
 one does with only one code.   
 
 //always gives error message even if one of the two codes entered: if
   ($Promotion_Sub == 'Checked'  ($code != 'D04E' || $code !=
   'Y04KG')) { echo  html
   head
   titleError/title
   /head
   body bgcolor=\#FF\ text=\#00\ link=\#ff\
 vlink=\#660099\
   h3Error/h3
 
   pSorry, that code is invalid./p
 -
 //works:
 if ($Promotion_Sub == 'Checked'  $code != 'D04E') {
[/snip]

I'm not really sure how to answer this!  How does this relate to the US
election?  Isn't this an election list?  HA HA HA HA, just kidding ;o)

You need to check that the code entered doesn't match both valid codes.

Try this instead:

If ($Promotion_Sub == 'Checked'  $code != 'D04E'  $code != 'Y04KG')
{

Do error stuff

}

With the code you have above, it will always give the error message
because you're checking to see if $code is not equal to the first value,
OR if it is not equal to the second value.  So with that, the code
supplied might well match the first ('D04E') but since that obviously
doesn't match the second, it's going to throw the error.

HTH,

Pablo

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



RE: [PHP] Passing marked rows in a table

2004-11-02 Thread Pablo Gosse
[snip]
I create a list of records from a DB and each has a check box.  What is 
the best way to select those that were checked after the form is
submitted?
[/snip]

If the elements all live within the same form, you can add [] to the end
of the name/id attribute, and then all checkboxes with the same name
will be accessible in an array.  So checkboxname[] will show up as
$_POST['checkboxname'] on the receiving end.

This is the best way, and most appropriate to this list since it is all
PHP.

HOWEVER, if the checkboxes are all contained in different forms (each
form in a row with its own processing options), then you will need to
assign a common name to each element (I usually call mine
performMultiple), and then using Javascript loop through all elements on
the page, checking for the proper name, and if found then adding the
value to a comma-delimited list, the value of which will be set to a
hidden input field before the form is submitted.

HTH.

Pablo

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



RE: [PHP] Passing marked rows in a table

2004-11-02 Thread Pablo Gosse
[snip]
Pablo Gosse wrote:
 [snip]
 If the elements all live within the same form, you can add [] to the
end of the name/id attribute, and then all checkboxes with the
 same name will be accessible in an array.  So checkboxname[] will
 show up as $_POST['checkboxname'] on the receiving end. [/snip]
Todd Cary wrote:
 Can I do $MyArray = $_POST['checkboxname'];   
 
 And then access each array element
for ($i = 0; $i  (count($MyAray)); $i++) echo $MyArray[$i];
 
 Todd
[/snip]

Yes, that should work fine.  But remember the caveat that all elements
using the [] notation must be in the same form.

If you've got multiple forms on the page and expect to get all
checkboxname values it will not happen using [].  You'll need to use JS
for that.

Pablo. 

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



RE: [PHP] Session and validation

2004-10-29 Thread Pablo Gosse
[snip]
I had this thread going yesterday.  Then basically
think it reached a stalemate.  I'm wondering has
anyone setup forms using session variables and
validation.  Validation where the validating is done
on the same page, and the redirected on success ?
[/snip]

You need a class which will generate and validate your forms
dynamically.  Pear provides two packages (the second an extension of the
first):

http://pear.php.net/package/HTML_QuickForm
http://pear.php.net/package/HTML_QuickForm_Controller

I've never used these as I wrote my own library to handle this a few
years ago, but from what I understand these two packages will do the
trick.

Basically it will work thusly:

1)  On a page where you need a form, you declare a new form object,
specify all your inputs, how they should be validated, etc., and these
are then stored in the session.

2)  On the receiving page you call the form validation object, passing
in an identifier for which form should be validated.

3)  If it validates your script will continue unfettered, else it will
update the values in the session with the appropriate error message and
redirect you back to the original form, which, since you are using
session variables to display the inputs, will now be updated with the
error messages.

HTH,
Pablo

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



RE: [PHP] fputcsv() error message

2004-10-20 Thread Pablo Gosse
[snip]
Fatal error: Call to undefined function: fputcsv() in
/home/webdev/sites/tracking_site/scripts/report.php on line 19

Is there something that I am missing?  The code that I had entered in:
[/snip]

http://ca.php.net/fputcsv

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



RE: [PHP] Help With Error

2004-10-17 Thread Pablo Gosse
[snip]
Notice: Undefined index: 0 in
L:\localhost\catalog\catalog_0.1.0\includes\classes\tree.class.php on
line
77
[/snip]

It's telling you that $data['0'], which is used twice in your query, is
not a valid index (ie. it doesn't exist) for the $data array.

Why don't you dump the $data array after it is set to see where the
problem is:

$data = $this-get_cat_coord($child);
print_r($data);
die();

Take a look at what comprises the $data array and you should find your
problem.

HTH,

Pablo

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



RE: [PHP] Referring Page

2004-10-14 Thread Pablo Gosse
[snip]
 I am trying to set up a script that will do different things based on
 the reffering page, without having to include the information in the
 URL.  Does PHP have a built in variable or function that would tell
 the rest of the script what page the user came from?  Any help is
 much appreciated. 
[/snip]

http://ca3.php.net/manual/en/reserved.variables.php#reserved.variables.s
erver

But be warned, they're not that reliable as some firewalls block/muck
with them, and they can also be easily spoofed.

Cheers,
Pablo

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



RE: [PHP] new connection with pg_pconnect

2004-10-14 Thread Pablo Gosse
[snip]
I'm trying to add some new features to an existing project.  The project
uses pg_pconnect and sets it into a global var...

What I'm trying to do is to create a new database class which connects
to a different database on the same server.  By the time my code gets
reached, the pg_pconnect global var $conn has already been initialized.

...

Is the persistent connection open only to the database in which it was
opened for?  How can I choose a different database?
[/snip]

Yes, a persistent connection will only be used when all the connection
parameters are the same.  Ergo a new database requires a new connection.

That said, I would also like to point out that there is a bug which can
be found with php and persistent postgres connections.

http://bugs.php.net/bug.php?id=25404

The solution is to use non-persistent connections.

I'd had a problem over the past few months wherein users of my CMS were
getting logged out for no reason, and yesterday I was finally able to
trace it to this.

Switched to non-persistent connections and not one error has occurred
since, so this might be something to keep in mind.

Cheers and HTH,

Pablo

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



RE: [PHP] new connection with pg_pconnect

2004-10-14 Thread Pablo Gosse
[snip]
I then have the page main.php which has

?php
global $sys_dbhost,$sys_dbuser,$sys_dbpasswd;
$dbconn = pg_connect(user=$sys_dbuser dbname=bisprojects
host=$sys_dbhost password=$sys_dbpasswd); echo '-'.$dbconn.'-'; ?

the scripts just dies whenever I include the pg_connect function... if I
change

echo '-'.$dbconn.'-';
to
echo '-==='.$dbconn.'-';

I'll still see -- on my page
if I remove the pg_connect function, I'll see
-===-;

Basically, no changes to the page take effect when I have the pg_connect
function in place... it just dies or something...
[/snip]

Hmmm, strange.

I used your code, exactly as it is above (but with my username,
password, db and server info) and it works fine.

Check your error logs and see if there's anything showing up there and
let us know what you find.

Pablo

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



RE: [PHP] Form Validation

2004-10-13 Thread Pablo Gosse
Huang, Ou wrote:
 I am currently working on a newsletter mailing list project and
 developed a form in php. I would like to validate before it is
 submitted. What would be the best way to validate a form? Write your
 own routines or using a form validator. I just started learning PHP,
 so don't have much experience on this. I am thinking using a form
 validator but not sure where I can get it. 
 
 Any suggestions would be appreciated!
 
 Thanks.

http://pear.php.net/package/HTML_QuickForm

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



RE: [PHP] creating a folder in php

2004-10-12 Thread Pablo Gosse
Jay Blanchard wrote:
[snip]
 I want an IDE that will let me speak code into it. Anyone else want
 anything? 
[/snip]

Laetitia Casta?

Email me off list to get delivery instructions.

Thanks,
Pablo

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



[PHP] Sessions and Mozilla (Firefox)

2004-10-12 Thread Pablo Gosse
Hi folks.  I've got a quick question about sessions and Mozilla.

I just noticed that if I open up a Mozilla window, log into my CMS, then
open another Mozilla window (not by ctrl-n, but by selecting it from my
programs menu) and bring up the login page in that new window, then it
detects the session from the other window and redirects right to the CMS
control panel.

In IE, this will happen if I ctrl-n a new window, but not if I start a
new instance of the browser from the program list.

Is the correct behavior for sessions in Mozilla?

I've searched the lists but I couldn't find anything which seemed to
answer this.

Cheers and TIA,

Pablo

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



[PHP] Upload problems

2004-10-05 Thread Pablo Gosse
Hi, folks.  I'm running into a strange upload problem and am not sure if
it's a php or apache issue.

I can't seem to upload any files bigger than 511k.  511k will upload
fine, but 512k returns a Document contains no data error.

I've tried this with a text file, adding and removing lines until it
uploaded and wouldn't upload.

I've also tried multiple file formats, and it's the same for all.

Has anyone run into this before?  I thought it might be a problem with
the LimitRequestBody directive in the apache config file, but that
directive is not used anywhere in the file.

Any ideas?

Cheers and TIA,

Pablo

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



RE: [PHP] Upload problems

2004-10-05 Thread Pablo Gosse
[snip]
 What's the upload_max_filesize  set to in your php.ini ? Under File
 Uploads in the php.ini, you will find this value. 
[/snip]

That's not it.  That's set to 30M.  This domain was just transferred
over to a new server, and this problem did not exist on the old one, so
while I am pretty certain it's something on the server side, I thought
I'd throw it out in case anyone else might have run up against this.

Thanks,
Pablo

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



RE: [PHP] Upload problems

2004-10-05 Thread Pablo Gosse
[snip]
 Look in your php.ini for max_upload_size or something like it.
[/snip]

'Twas an apache problem.  Thanks the help.

Cheers,

Pablo

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



[PHP] Security Question (from Chris's OSCON 2004 talk)

2004-09-30 Thread Pablo Gosse
Hi folks.  Thanks to all for the replies to my question about security
on shared hosting the other day.

I've contacted my hosting provider and they will be fixing the issues
I've pointed out to them.

I've got a question about a section of Chris's article on PHP security
from his OSCON 2004 talk.

When talking about protecting database credentials, Chris mentions
creating a file (readable only by root) with the following:

SetEnv DB_USER myuser
SetEnv DB_PASS mypass

and then using this:

Include /path/to/secret-stuff

in the httpd.conf file such that they show up in your $_SERVER array.

I assume that the include directive would be declared inside the section
of the httpd.conf file which defines everything for my site?  This is
probably a stupid question but I want to make sure of what I'm asking my
hosting provider before I send my email.

I'm also going to be asking them to set another environment variable,
INC_PATH, and then I'll use this to reference the files which I'm
including from outside my webroot, such that even if someone reads the
files within my webroot, they won't see either the db username or
password, nor will they see the path from which I am including sensitive
files.

Thoughts?

Cheers and TIA,

Pablo

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



[PHP] Security Question (from Chris's OSCON 2004 talk)

2004-09-30 Thread Pablo Gosse
Hi folks.  Sorry if this gets posted twice, but I sent it originally
almost an hour ago and it hasn't shown up on the list yet.

Thanks to all for the replies to my question about security on shared
hosting the other day.

I've contacted my hosting provider and they will be fixing the issues
I've pointed out to them.

I've got a question about a section of Chris's article on PHP security
from his OSCON 2004 talk.

When talking about protecting database credentials, Chris mentions
creating a file (readable only by root) with the following:

SetEnv DB_USER myuser
SetEnv DB_PASS mypass

and then using this:

Include /path/to/secret-stuff

in the httpd.conf file such that they show up in your $_SERVER array.

I assume that the include directive would be declared inside the section
of the httpd.conf file which defines everything for my site?  This is
probably a stupid question but I want to make sure of what I'm asking my
hosting provider before I send my email.

I'm also going to be asking them to set another environment variable,
INC_PATH, and then I'll use this to reference the files which I'm
including from outside my webroot, such that even if someone reads the
files within my webroot, they won't see either the db username or
password, nor will they see the path from which I am including sensitive
files.

Thoughts?

Cheers and TIA,

Pablo

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



RE: [PHP] Loop within Loop help please

2004-09-28 Thread Pablo Gosse
[snip]
I have a simplified bit of code below:
?php
  foreach($someArray as $someVal) {
//do some stuff
  }
?

What i'd like to do is have a count inside that loop that will trigger
some action every 20 iterations of the foreach. Like this: ?php
  $count=0;
  foreach($someArray as $someVal) {
if($count is divisible by 20 exactly) {
  // do some stuff
}
//do some stuff
  }
?
[/snip]

if ($count%20 == 0)

http://ca3.php.net/manual/en/language.operators.arithmetic.php in the
manual (look for Modulus).

HTH.

Pablo

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



RE: [PHP] php security on shared hosts

2004-09-26 Thread Pablo Gosse
[snip]
I just published a free article on my Web site about shared hosting:

http://shiflett.org/articles/security-corner-mar2004

In short, what you've found is typical for most shared hosts, and
safe_mode (a directive created to help mitigate this problem a bit) does
little to help. However, there are some things you can do as a
developer,
and I give some specific examples.
[/snip]

Hi, Chris.  Thanks for that link.  It was incredibly informative.

I just took your code for the file browser and it was able to read the
information in all users' webroots and all other directories and files
readable by nobody:nobody, including database passwords, .htaccess files
(which contained paths to password and group files), etc.

There was no /etc/passwd file, but this is irrelevant as I was simply
able to browse the /virtual directory to see a list of all users home
directories, and from there their webroots, etc.

I guess it is an inevitable fact that if you are on a shared host, any
script executed from the browser is capable of reading any other script
on the server which is set to be readable by the web server.

I usually store all my files with sensitive information and class files
outside the webroot, but under this setup, anyone could simply read the
contents of the files in the webroot and use the information in those
files to then read the files which are store outside of the webroot.

Unfortunately I don't have access to my server config file (a 'find'
command for httpd.conf returned no results), so is this something a host
would usually change for individual users?

Also, safe_mode is not enabled on this host so I while I assume that I
could enable it using .htaccess for my site, that still would not
prevent anyone else from reading my scripts since their scripts would
not be running in safe mode, right?

Thoughts?

Cheers and TIA,

Pablo.

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



RE: [PHP] php security on shared hosts

2004-09-26 Thread Pablo Gosse
[snip]
In short, what you've found is typical for most shared hosts
[/snip]

I've just been reviewing the way sites are housed on my host, and what
directories are readable by the web server and I'm curious to get
opinions on this.

When I use Chris' file browser script, there is a folder called
'virtual' in the site root, and it is readable by the web browser.

Inside /virtual there are three folders for every site, which I list
below.

--
site357
pablogosse.com
admin357
--

Browsing these for my site I see the following:

site357:

4096   ./
20480  ../
4096   fst/
4096   info/

pablogosse.com and admin357:

4096   ./
4096   ../
4096   bin/
4096   boot/
4096   dev/
4096   etc/
4096   home/
4096   initrd/
4096   lib/
4096   mnt/
4096   opt/
4096   proc/
4096   root/
4096   sbin/
4096   tmp/
4096   usr/
4096   var/
498subdomain
4096   mysql/
7392   dump.xml

Also, if I browse the fst/ folder inside site357, I get the same results
as pablogosse.com and admin357.

I'm then able to browse freely through all the above folders except
/home and /root.

I'm no security expert so I have to ask, is this indeed normal?

Cheers and TIA.

Pablo

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



[PHP] Problems installing smarty on a shared host

2004-09-25 Thread Pablo Gosse
Hi folks.  I've recently moved my site to a shared host, and this is the
first time I've had to set up my site in a really restrictive
environment, and I'm running into problems getting smarty installed.

Using the basic example set up from the Smarty docs, when I run the file
I get the following error:

Warning: main(Smarty.class.php): failed to open stream: No such file or
directory in /home/virtual/site357/fst/var/www/html/smarty.php on line 4

Fatal error: main(): Failed opening required 'Smarty.class.php'
(include_path='.:/php/includes:/usr/share/php:/home/pablogosse/smarty/')
in /home/virtual/site357/fst/var/www/html/smarty.php on line 4

Now, as you can see by the value of my include path, I've got the path
to smarty added, but it's still not finding the file even though
/home/pablogosse/smarty/Smarty.class.php does indeed exist.

Can anyone tell me why this is happening?  As I said up until now I've
been lucky enough to always have access to dedicated servers where
setting this up was never a problem, but I know there's something I'm
missing in understanding why this isn't working.

Any help is appreciated.

Cheers and TIA.

Pablo

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



RE: [PHP] Problems installing smarty on a shared host

2004-09-25 Thread Pablo Gosse
I tried that and got the same error.

I'm trying to place the smarty directories outside my webroot to
minimize security risks, however given my experiences thus far, I don't
really see that being possible.

Would a viable solution perhaps to be to include the smarty directories
in the webroot such that my scripts can access them, but to protect the
directories via .htaccess to prevent direct execution of files from said
directories, since my scripts will be including them but are themselves
executed from valid locations?

Cheers and TIA,

Pablo

-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED] 
Sent: Saturday, September 25, 2004 1:52 PM
To: Pablo Gosse
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Problems installing smarty on a shared host

Pablo Gosse wrote:
 Hi folks.  I've recently moved my site to a shared host, and this is
the
 first time I've had to set up my site in a really restrictive
 environment, and I'm running into problems getting smarty installed.
 
 Using the basic example set up from the Smarty docs, when I run the
file
 I get the following error:
 
 Warning: main(Smarty.class.php): failed to open stream: No such file
or
 directory in /home/virtual/site357/fst/var/www/html/smarty.php on line
4
 
 Fatal error: main(): Failed opening required 'Smarty.class.php'

(include_path='.:/php/includes:/usr/share/php:/home/pablogosse/smarty/')
 in /home/virtual/site357/fst/var/www/html/smarty.php on line 4

You are including from file that is located in 
/home/virtual/site357/fst/var/www/html/, and the smarty class is in 
/home/pablogosse/smarty/? The paths seems strange, what if you try 
include_path = /home/virtual/site357/+ whatever is the relative path to 
Smarty.class.php from smarty.php

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



RE: [PHP] Problems installing smarty on a shared host

2004-09-25 Thread Pablo Gosse
[snip]
 I'm trying to place the smarty directories outside my webroot to
 minimize security risks, however given my experiences thus far, I
don't
 really see that being possible.

It should not matter, unless open_basedir is in effect, but that would 
be another error. I would check if the directories are right, you can 
start by using relative path.
[/snip]

It appears I've found the problem.

I used passthru(ls -l [dirname],$ret) to start reading from /home all
the way up through the following:

/home/
/home/virtual/
/home/virtual/site357/
/home/virtual/site357/fst/

and all returned complete directory listings and a return code of 0.
Now, when I read through 

/home/virtual/site357/fst/var/
/home/virtual/site357/fst/var/www/
/home/virtual/site357/fst/var/www/html/

I see the files that I would see when I SSH in and ls -l the following
paths:

/var/
/var/www/
/var/www/html/

HOWEVER, when I attempt the passthru call on 

/home/virtual/site357/fst/home/

I get no results back, and the return code is 1.  So it appears scripts
running under the apache user cannot access that folder or anything
beneath it

Any ideas?

Cheers and TIA.

Pablo

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



RE: [PHP] Problems installing smarty on a shared host

2004-09-25 Thread Pablo Gosse
[snip]
It should not matter, unless open_basedir is in effect, but that would 
be another error. I would check if the directories are right, you can 
start by using relative path.
[/snip]

Just the relative path from smarty.php,

../../../home/pablogosse/smarty/Smarty.class.php

And I get a permission denied error.  So it appears for sure that I
can't read anything inside my home directory, or outside the webroot it
would seem.

Any ideas?

Cheers and TIA,
Pablo

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



RE: [PHP] Problems installing smarty on a shared host

2004-09-25 Thread Pablo Gosse
[snip]
You'll probably notice that the permissions for /home/pablogosse
are like: drwxr-x--- with user:group pablogosse:pablogosse

If you have permissions to, i would set up a directory like:

  /home/virtual/site357/fst/var/include/smarty/

And then set the include_path appropriatly.
[/snip]

Unfortunately I don't have write access to /var as it is owned by root.

I've just discovered another thing which makes me even more nervous.

I just wrote a script as a quick test and I was able to use
file_get_contents to read a file out of another user's webroot.  So,
anyone who is storing passwords or other valuable information under
their webroot risks having that information being easily accessible to
anyone else hosting here.

As I said earlier, most of my experience until now has been in
situations where the sites I've worked on have been hosted on dedicated
servers, and this has never been a problem.

Is this a common set up for shared hosting?  Is there any way around
this?

Cheers and TIA,
Pablo

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



[PHP] php security on shared hosts

2004-09-25 Thread Pablo Gosse
Hi folks. I recently set up hosting for my site and have noticed
something which is making me nervous.

I can't seem to include files outside of my webroot, so I wrote a script
to test permissions using passthru to output the results of a bunch of
ls -la commands to see what I did and did not have access to. Eventually
I was able to read the directory which holds the root folders for all
sites on the server, and from there I was able to read files (revealing
the php source) from the webroot of another site.

This to me is a huge security issue since if anyone has any sensitive
information there, it could easily be accessed by anyone else hosting on
the same server. And because I can't seem to include files from outside
my webroot, if I stay with this company I'll be forced to include
information such as database passwords inside my webroot, therefore
exposing the information to every other user on the server, and that's
just not acceptable.

All of my experience until now has been in situations where the sites
I've worked on have been hosted on dedicated servers, so this has never
been a problem.

Is this a common set up for shared hosting? Is there any way around
this?

Cheers and TIA.

Pablo

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



[PHP] Strange errors when PHP script called from CRON

2004-09-22 Thread Pablo Gosse
Hi folks.  I've written a CMS where I work, the publishing guts of which
is executed through a php script called from my crontab every minute.

Every so often (it's happened roughly 17 times since July 22) I get
parse errors in my log file when the scripts run into errors while
executing.

This is very strange, since the code in these files doesn't change, and
some of them are from the fairly ubiquitous ADODB class, and some of
them are from my own.

Below are the errors in my log file, and beneath each the code from the
corresponding line which throws the error.

Parse error: parse error in /u0/path/to/classes/adodb/adodb.inc.php on
line 3382
LINE 3382:  $ADODB_LASTDB = $db;

Parse error: parse error in /u0/path/to/classes/adodb/adodb.inc.php on
line 848
LINE 848:   } else if ($this-_queryID === true) {

Parse error: parse error in /u0/path/to/classes/adodb/adodb-time.inc.php
on line 748
LINE 748:   $dates .=
sprintf('%s%04d',($gmt0)?'+':'-',abs($gmt)/36); break;

Parse error: parse error, expecting `')'' in
/u0/path/to/classes/adodb/adodb-time.inc.php on line 850
LINE 850:   $_month_table_leaf =
array(,31,29,31,30,31,30,31,31,30,31,30,31);

Parse error: parse error, expecting `$' in
/u0/path/to/cmsutilDEV/monitor/cms.monitor.monitor_content.inc.php on
line 77
LINE 77:$commit == true ? $this-conn-CommitTrans() :
$this-conn-RollbackTrans();

Parse error: parse error in
/u0/path/to/cmsutilDEV/monitor/cms.monitor.monitor_content.inc.php on
line 520
LINE 520:   if ($rs-RecordCount() = 1)

Does anyone have any idea why I might be getting these errors?  The code
above, to me at least, doesn't look like it should be throwing parse
errors.

The script which is called by my crontab to start this process executes
every minute, so I find it very strange that I'm getting these sporadic
error messages.

Can any one shed any light on this for me?

Cheers and TIA,

Pablo

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



RE: [PHP] Strange errors when PHP script called from CRON

2004-09-22 Thread Pablo Gosse
Jay Blanchard wrote:
 [snip]
 Does anyone have any idea why I might be getting these errors?  The
 code above, to me at least, doesn't look like it should be throwing
 parse errors.  
 
 The script which is called by my crontab to start this process
 executes every minute, so I find it very strange that I'm getting
 these sporadic error messages.  
 
 Can any one shed any light on this for me?
 [/snip]
 
 Perhaps. Could the data being utilized by the code occasionally have
 characters that should be escaped, by aren't? Are you escaping all of
 the escapable characters, especially quotes, both single and double?  

That's what I was thinking initially, but all code that is submitted to
or extracted from the database is encoded using the translation table
from get_html_translation_table plus an additional translation which I
manually apply to replace #039; with \'.

Also, I'm reluctant to think that the problem lies here because once a
page has been scheduled to be published, it is not removed from this
schedule unless the owner of the page does so.

Basically, if a page is scheduled to be published, and some data in the
page caused the error, the error should show up indefinitely, or until
the person has removed the scheduled publishing of the page, since the
page will not be removed from the publishing schedule due to the error
causing the script to stop executing.

Also, if you take a look at the error below in particular,

Parse error: parse error, expecting `')'' in
/u0/path/to/classes/adodb/adodb-time.inc.php on line 850
LINE 850: $_month_table_leaf =
array(,31,29,31,30,31,30,31,31,30,31,30,31);

You'll see that this is a portion of code that utilizes no external data
whatsoever, and is actually in a file (adodb-time.inc.php) which is
never called by my script, but is called internally by ADODB.

In nearly four years of working with PHP, this is the first time I've
ever been completely stumped.

Any other ideas?

Cheers and TIA,

Pablo

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



RE: [PHP] Strange errors when PHP script called from CRON

2004-09-22 Thread Pablo Gosse
Marek Kilimajer wrote:
[snip]
 Perhaps. Could the data being utilized by the code occasionally have
 characters that should be escaped, by aren't? Are you escaping all
 of the escapable characters, especially quotes, both single and
 double? 
 
 
 That's what I was thinking initially, but all code that is submitted
 to or extracted from the database is encoded using the translation
 table from get_html_translation_table plus an additional translation
 which I manually apply to replace #039; with \'.
 
 Also, I'm reluctant to think that the problem lies here because once
 a page has been scheduled to be published, it is not removed from
 this schedule unless the owner of the page does so.
 
 Basically, if a page is scheduled to be published, and some data in
 the page caused the error, the error should show up indefinitely, or
 until the person has removed the scheduled publishing of the page,
 since the page will not be removed from the publishing schedule due
 to the error causing the script to stop executing.
 
 Also, if you take a look at the error below in particular,
 
 Parse error: parse error, expecting `')'' in
 /u0/path/to/classes/adodb/adodb-time.inc.php on line 850 LINE 850:
 $_month_table_leaf = array(,31,29,31,30,31,30,31,31,30,31,30,31);
 
 You'll see that this is a portion of code that utilizes no external
 data whatsoever, and is actually in a file (adodb-time.inc.php) which
 is never called by my script, but is called internally by ADODB.
 
 In nearly four years of working with PHP, this is the first time
 I've ever been completely stumped. 
 
 Any other ideas?

 Is any of the files updated at all? It could be a race condition,
 happened to me few times - I upload a file to the server, impatiently
 reload the page and get parse error. I reload once again and
 everything is fine.
[/snip]

The files from the ADODB class which are throwing errors have NEVER been
updated.

The files which I wrote have been updated maybe once or twice in the
past four months, but the errors have occurred both before and after the
updates.

One file threw an error for the first time this morning when including
another file, and there are no functions in this file which accept any
data as all the data needed is pulled from the database, so that one's
really got me thrown for a loop.

Any other ideas?

Cheers and TIA,

Pablo

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



[PHP] RE: Strange errors when PHP script called from CRON

2004-09-22 Thread Pablo Gosse
Greg Beaver wrote:
[snip]
Does your crontab script use file locking to make sure that it isn't 
accessing a script at the same time as the webserver or another process?
[/snip]

Yes, I create a lock file when the script is called, but the only time
I've ever seen a conflict there is when these parse errors occur and the
lock file is therefore not removed at the end of the script.

In this case what happens is the next time the script is called, it sees
that a previous lock file exists, deletes said file, and waits for the
script to be called next time.

Any other time the scripts encounter internal errors (pages scheduled
for publishing which are not found, etc.) the script exits gracefully,
recording the error and removing the lock file such that the script can
run the next time it's called.

Can you give me an idea of why you think this might raise the parse
errors if the script were accessing a script at the same time as the
server or another process?

Reason I ask is that the scripts accessed by the crontab script are not
accessed by anything but that crontab script.

Cheers and TIA,

Pablo

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



RE: [PHP] Strange errors when PHP script called from CRON

2004-09-22 Thread Pablo Gosse
[snip]
i just skimmed the errors, but it looked like various of them were 
likely due to database failure (i.e., the function didn't have the 
expected data to process). if something spotty is happening with your 
database connection that could give you these transient errors 
(assuming my underlying thinking is correct).
[/snip]

Some of them are at times caused by the functions not getting the
expected data, but for those I always get errors such as call to a
member function on a non-object, for example, when no recordset is
returned where one is expected.

These errors are there as well, but when they are encountered I, as with
the other parse errors, see the lock file staying around until the
script next executes, at which point it's removed and the process is
allowed to continue.

Any other ideas?

Cheers and TIA,

Pablo

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



[PHP] Errors from script running in CRON - MORE DETAILED INFO.

2004-09-22 Thread Pablo Gosse
Hi again folks.  Thanks to those who helped in trying to find the cause
of my problem this afternoon.

Sorry if the code in this message wraps, but I'm writing this through a
tss connection and damned if I can figure out how to change the wrap
point in outlook :o(

The CMS logged a new error a couple of hours ago which I think might
isolate part of the problem.

The following is the error that was logged:

--
Parse error: parse error, expecting `$' in
/u0/path_to_classes/classes/adodb/adodb.inc.php on line 2713
Unable to include database connection file
--

Line 2713 of adodb.inc.php is:

if ($this-_fetch()) {

The last line about being unable to include the database connection file
is the error which is logged from my script, which (obviously) is thrown
when the adodb.inc.php file can't be included.  That this error is
thrown and the monitor exits gracefully tells me that the monitor is
working correctly.

Below is the code from the file called by my crontab:

#!/usr/local/bin/php
?php
define('UTIL_PATH','/path/cmsutilDEV/monitor');
define('ARCHIVE_PATH','/path/cmsutilDEV/archive');
define('CMS_PATH','/path/cms-test.unbc.ca/');
define('WWW_PATH','/path/www2-test.unbc.ca/html');
define('WWW_SITE','http://www2-test.unbc.ca/');
define('LOCK_FILE','/path/cmsutilDEV/monitor/cms.monitor.lck');
define('DATE_STAMP',date('Y-m-d H:i:s'));
define('TIME_STAMP',time());

chdir(UTIL_PATH);

require_once UTIL_PATH.'/cms.monitor.inc.php';
$m = new CMS_monitor();
?

The code in my script up to the point at which the problematic include
file is called is:

?php
class CMS_monitor
{
  var $conn = null;
  var $db_open = false;
  var $errors = array();

  function CMS_monitor()
  {
   if (file_exists(LOCK_FILE)) {
 $this-CMS_exit_monitor(User lock file exists);
   } else {
 touch(LOCK_FILE) or $this-CMS_exit_monitor('err msg');
 $f = fopen(LOCK_FILE,'w+') or $this-CMS_exit_monitor('err msg');
 fwrite($f,DATE_STAMP) or $this-CMS_exit_monitor('err msg');
 fclose($f) or $this-CMS_exit_monitor('err msg');

 $this-CMS_db_connect() or $this-CMS_exit_monitor('Unable to
connect to database');
  }

// rest of script omitted since it's not getting base the first
conditional.

So all that's happening is require_once is being called, but the parse
error is coming in the required file, to which I have NEVER made
changes.

To me this might seem to indicate that it's something other than a bug
in my code which is causing these errors, especially since if there
really was a problem in the required file, this error would be thrown
every minute.

One other thing worth mentioning is that immediately before this error
occurred there was no content scheduled for publishing.  After this
error occurred the monitor ran twice successfully (again with no content
to be scheduled for publishing), then threw a parse error from one of my
files. 

However the point at which the file is included (shortly after where the
database error is thrown above) occurs before any external data is
passed to a function, so I can't see how that could potentially trigger
the error since the file is simply being included, and no external data
is being used.

So, there is no external data from any source being used before either
of the above errors are thrown.  Not sure if that helps narrow down the
problem or not, but if it does any ideas would be greatly appreciated.

Aside from these errors I'm just about ready to switch our site to the
CMS, and while the errors aren't affecting the overall performance (some
updates are delayed a minute or two by the errors occurring) I have to
say it's making me nervous.

Any help is greatly appreciated.

Cheers and TIA,

Pablo 

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



RE: [PHP] Parsing large file

2004-08-31 Thread Pablo Gosse
Adrian Teasdale wrote:
 Hi there
 
 We have a text file that is 2.2gb in size that we are trying to parse
 using PHP to put the content into a mysql database. This file
 contains 40 million individual lines of data.  Basically PHP isn't
 parsing it. Any suggestions of how we could do this?   
 
 Thanks
 
 Ade

Use split to break the file down into parts of manageable size, and then
process those.

split -b nM filename (where n is the number of Megs you wish each part
to be).

man split

HTH.

Pablo

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



[PHP] Problem using fread with https

2004-08-26 Thread Pablo Gosse
Hi folks.  I'm getting the following error when attempting to use
PEAR::HTTP_Request to check the existence of a file.

It's throwing an error from fread on an https stream:

Warning: fread(): SSL: fatal protocol error in
/u0/local/lib/php/Net/Socket.php on line 263

Line 263 is as follows:

return fread($this-fp, $size);

My PHP version is 4.3.4, and it's compiled with openssl, so I can't see
why this is throwing an error since according to the docs as long as
openssl is compiled https is supported.

Does anyone have any suggestions?

Cheers and TIA,

Pablo

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



RE: [PHP] db transactions across multiple pages...

2004-07-30 Thread Pablo Gosse
snip
 the pconnect supposedly allowed an app to use the same connection if
 one was available. so an app would establish the connection on page
 1, and page 2 could use the same db connection... this is required as
 i understand it if you're going to do transactional processing, as
 once the connect dies, the actions being performed are rolled back if
 you haven't done a commit... 
/snip

AFAIK, transactions do not span across multiple script executions, only
multiple queries within the same script execution.

The purpose of a persistent connection is to reduce the total number of
db connections which are open to a server.  AFAIK a persistent
connection will be reused when a request is made for a connection with a
specific username, password and db, and one already exists with said
parameters.

AFAIK it has nothing to do with transactions spanning multiple script
executions.

Once a script has finished executing, as a previous poster wrote, PHP
will close the connection (if it's persistent it's left in the pool to
be reused) and if a transaction was not commited or rolled back, then it
will be rolled back by default.

So if you have one php script which starts a transaction and then
executes five queries, at the end of that script being executed unless
you commit the transaction, it will be rolled back by default.  Even if
you are using persistent connections, if this were to happen the
transaction would still be rolled back.

This is all AFAIK, so I could be wrong.  If I've put some incorrect
information here, please correct it and let me know where I've gone
wrong.

Cheers and HTH,

Pablo

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



[PHP] Error parsing php.ini

2004-07-23 Thread Pablo Gosse
Hi folks.  I've written a CMS which uses a cron job to execute a script
that pushes/pulls content from our website.

It's been working very well, and still is, but this morning I found this
in the CMS error log:

PHP:  Error parsing /u0/local/apache2/conf/php/php.ini on line 102

Has anyone encountered this type of error before?  I've googled it but
have been unable to find any useful information.

If anyone has any advice I'd greatly appreciate it.

Cheers and TIA.

Pablo

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



RE: [PHP] Error parsing php.ini

2004-07-23 Thread Pablo Gosse
Jason Davidson wrote:
 whats on line 102 of the php.ini file ???
 
 Jason
 
 On Fri, 23 Jul 2004 10:27:29 -0700, Pablo Gosse [EMAIL PROTECTED]
 wrote: 
 Hi folks.  I've written a CMS which uses a cron job to execute a
 script that pushes/pulls content from our website.
 
 It's been working very well, and still is, but this morning I found
 this in the CMS error log: 
 
 PHP:  Error parsing /u0/local/apache2/conf/php/php.ini on line 102
 
 Has anyone encountered this type of error before?  I've googled it
 but have been unable to find any useful information.
 
 If anyone has any advice I'd greatly appreciate it.
 
 Cheers and TIA.
 
 Pablo
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Sorry, that might've helped ;o)

That's the strange part.  Lines 102 is the following:

; So only set this entry, if you really want to implement such a 

So it's a comment and should not be parsed.

Any ideas?

Cheers and TIA.

Pablo

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



RE: [PHP] Error parsing php.ini

2004-07-23 Thread Pablo Gosse
snip
Jason Davidson wrote:
 Can you show whats on either side of that too please
/snip

The following are lines 91 - 112

; You can redirect all of the output of your scripts to a function.  For
; example, if you set output_handler to ob_gzhandler, output will be
; transparently compressed for browsers that support gzip or deflate
encoding.
; Setting an output handler automatically turns on output buffering.
output_handler =

; The unserialize callback function will called (with the undefind
class'
; name as parameter), if the unserializer finds an undefined class
; which should be instanciated.
; A warning appears if the specified function is not defined, or if the
; function doesn't include/implement the missing class.
; So only set this entry, if you really want to implement such a
; callback-function.
unserialize_callback_func=

; Transparent output compression using the zlib library
; Valid values for this option are 'off', 'on', or a specific buffer
size
; to be used for compression (default is 4KB)
;
; Note: output_handler must be empty if this is set 'On' 
;
zlib.output_compression = Off

Line 102 is the line which begins with ; So only set this entry,...

The CMS has been working fine all morning.  The error occurred at 9:18
last night, so I'm guessing it might not be that serious since it ran
fine every minute after the error occurred, but it's very strange that
this happened just this once.

Any ideas?

Cheers and TIA.

Pablo

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



RE: [PHP] Error parsing php.ini

2004-07-23 Thread Pablo Gosse
snip
Jason Davidson wrote:
 Oh, it was a one time error, strange, youve never had this error
 before, and this definately is the php.ini file your using, ie, there
 isnt another somewhere thats getting used?  
/snip

Quothe the terminal:

[EMAIL PROTECTED] html]$ find / -type f -name php.ini 2/dev/null
/u0/local/apache2/conf/php/php.ini

Yup.  That's the only php.ini.  This is the only time it happened, and
it was the only error in the log.

Any other ideas?

Cheers and TIA.

Pablo

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



RE: [PHP] Array help

2004-07-23 Thread Pablo Gosse
Robb Kerr wrote:
 On Fri, 23 Jul 2004 14:21:42 -0700 (PDT), Matthew Sims wrote:
 
 imgBkgrnd = array(1= bkgrnd-default.gif, 2 =
 bkgrnd-positive.gif, 3 = bkgrnd-negative.gif);
 
 You got it...
 
 imgBkgrnd = array(1= bkgrnd-default.gif, 2 =
 bkgrnd-positive.gif, 3 = bkgrnd-negative.gif); imgNeeded =
 table['field']; imgName = ???  
 
 Now, how do I get the image name associated with the key number
 obtained from my table out of the array and into the variable so that
 I can use it later in the HTML?  
 
 Thanx, Robb
 --
 Robb Kerr
 Digital IGUANA

$imgBkgrnd[i] where 'i' is the number returned from your DB.

HTH.

Pablo

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



RE: [PHP] textarea/display question...

2004-07-20 Thread Pablo Gosse
Stut wrote:
 On Tue, 20 Jul 2004 11:51:22 -0700, bruce [EMAIL PROTECTED]
 wrote: 
 with an iframe... can i allow the user to make changes... and then
 capture the data as a value for a post within a form..???
 
 in other words...does it closely give me what a textarea does with
 regards to allowing a user to make mods to the information?
 
 What you're looking for is a replace for textarea that supports
 HTML editing. Try http://www.interactivetools.com/products/htmlarea/
 (IE only unfortunately - but there are others, try searching Google
 for edit html textarea or similar to find them).   
 
 ps.. to you guys who said that the textarea doesn't have a
 value=''.. it does...
 
 Erm, no, it doesn't.
 
 --
 Stut

There is a newer version of the HTMLarea from Interactive Tools, and it
is supported by IE 5.x, Mozilla, Firefox, etc.

http://dynarch.com/mishoo/htmlarea.epl

HTH.

Pablo

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



RE: [PHP] Echoing a value

2004-07-12 Thread Pablo Gosse
Ed Curtis wrote:
 I'm having some trouble echoing a value to a file that is being
 pulled from a MySQL database. I've included my code below I'm sure
 it's something really simple but I'm not seeing it.
 $row['users.name'] and $row['users.company'] echo nothing while
 $row['cnt'] echoes it's expected values. If anyone can tell me what
 I'm doing wrong I'd appreciate it. 
 
 Thanks,
 
 Ed
 
 $ap = fopen($ad_path/AdCount$issue.txt, w);
 
 mysql_connect ($local_host, $local_user, $local_pass);
 
 mysql_select_db ($local_db);
 
 $result = mysql_query (SELECT *, COUNT(*) as cnt FROM users,
 listings WHERE listings.user_id = users.id AND listings.active = '1'
 GROUP BY users.company, users.name);  
 
 if ($row = mysql_fetch_array($result)) {
 
   do {
 
   fputs($ap, $row['users.name']);
   fputs($ap, $sp);
   fputs($ap, $sp);
   fputs($ap, $row['users.company']);
   fputs($ap, $sp);
   fputs($ap, $sp);
   fputs($ap, $row['cnt']);
   fputs($ap, $nl);
 
   }
 
 while($row = mysql_fetch_array($result));
 
 mysql_close(); }
 
 fclose($ap);

I'm not sure about MySQL, but I know for PostgreSQL when I prefix a
field name with a table name in a query I don't need to specify the
table name when accessing that fieldname in the query result.

Try changing:

fputs($ap, $row['users.name']);
fputs($ap, $row['users.company']);

To:

fputs($ap, $row['name']);
fputs($ap, $row['company']);

That should do the trick.

Cheers,
Pablo

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



[PHP] Regular Expression Help

2004-06-30 Thread Pablo Gosse
Hi folks.  I'm having a little bit of a stupid moment with a regular
expression which I'm hoping someone can lend a hand with.

The regular expression I have right now matches strings between 2 and
1000 characters in length that start with one of the following
characters:

a-z
A-Z
0-9
(
)

and where the rest of the string may be made up of the following
characters:

a-z
A-Z
0-9
(
)
_
,
.
-
'


Here's the working regular expresssion:

/^[a-zA-Z0-9\(\)]{1}[ a-zA-Z0-9\(\)_\,\.\-\'\]{1,999}$/

Now, I'm trying to add \ to the valid characters but when I add a slash
after \ I get the following error:

Warning: Compilation failed: missing terminating ] for character class
at offset 54 in
/u0/vservers/*/html/classes/forms/forms_validation_functions.class.p
hp on line 184

So I escape the \ with another \, and I still get the error.

Three or four  \ results in the \ character being stripped from the
string that is being tested with the regular expression.

Five \ results in the orignal error which I get with just one \.

Can anyone give any advice as to why this is happening?

Cheers and TIA.

Pablo




/^[a-zA-Z0-9\(\)]{1}[ a-zA-Z0-9\(\)_\,\.\-\'\]{1,999}$/

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



[PHP] Regular Expression Help

2004-06-30 Thread Pablo Gosse
Howdy folks.  Sorry for the message which just showed up truncated.
It's complete in my sent mail, but appeared truncated on the list.  Full
message is below.  TIA for all help.

Hi folks.  I'm having a little bit of a stupid moment with a regular
expression which I'm hoping someone can lend a hand with.

The regular expression I have right now matches strings between 2 and
1000 characters in length that start with one of the following
characters:

a-z
A-Z
0-9
(
)

and where the rest of the string may be made up of the following
characters:

a-z
A-Z
0-9
(
)
_
,
.
-
'


Here's the working regular expresssion:

/^[a-zA-Z0-9\(\)]{1}[ a-zA-Z0-9\(\)_\,\.\-\'\]{1,999}$/

Now, I'm trying to add \ to the valid characters but when I add a slash
after \ I get the following error:

Warning: Compilation failed: missing terminating ] for character class
at offset 54 in
/u0/vservers/*/html/classes/forms/forms_validation_functions.class.p
hp on line 184

So I escape the \ with another \, and I still get the error.

Three or four  \ results in the \ character being stripped from the
string that is being tested with the regular expression.

Five \ results in the orignal error which I get with just one \.

Can anyone give any advice as to why this is happening?

Cheers and TIA.

Pablo

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



[PHP] Messages to List Being Truncated

2004-06-30 Thread Pablo Gosse
Hi folks.  I've just attempted to twice post a message, and for some
reason it's being truncated somewhere between my Sent Items folder and
when it appears on the list.

Has anyone had similar problems.  Anyone have any idea what could be
causing it?

Cheers and TIA.

Pablo

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



RE: [PHP] Messages to List Being Truncated

2004-06-30 Thread Pablo Gosse
snip
 the first one was truncated but the second one was complete. Btw thx
 Chris for opening up yet another thread that could have been avoided
 if your client was configured correctly.  
/snip

This is strange.  At any rate, I've put the message in an html page on
our server.

http://www.unbc.ca/regexp.html

If anyone could take a look and give me a hint as to what the problem
might be I would greatly appreciate it.

Cheers and TIA.

Pablo

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



RE: [PHP] CHAT

2004-06-29 Thread Pablo Gosse
Juan Pablo Herrera wrote:
 Hi!
 I need a chat program in php with GNU License. What's experience
 whith chat program in PHP? regards, Juan Pablo 

G-O-O-G-L-E:

Search:  php chat program gnu

http://www.google.ca/search?q=php+chat+program+gnuie=UTF-8hl=enmeta=

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



[PHP] problem translating single qutoes using ENT_QUOTES

2004-06-21 Thread Pablo Gosse
Hi folks.  I'm running into a problem translating single quotes that I'm
hoping someone can help with.

In my CMS, content is encoded using htmlentities() before it is stored
in the database.  During publishing the encoded content from the db is
decoded before being written to the file.

However, for some reason single quotes (#039;) are not being decoded
even though I'm using ENT_QUOTES.

Here are the functions:

function CMS_encode_html($html, $mode = 1)
{
$html = str_replace($this-CMS_base_path,'/',$html);

if ($mode == 1) {
$html = htmlentities($html, ENT_QUOTES);
} else {
$trans_tbl = get_html_translation_table(HTML_ENTITIES,
ENT_QUOTES);
$trans_tbl = array_flip($trans_tbl);
$html = strtr($html, $trans_tbl);
}
return $html;
}

function SITE_decode_html($html)
{
$trans_tbl = get_html_translation_table(HTML_ENTITIES,
ENT_QUOTES);
$trans_tbl = array_flip($trans_tbl);
$html = strtr($html, $trans_tbl);
return $html;
}

Can anyone give me an idea as to why single quotes are not being
translated here?

I've fixed the problem simply by adding a str_replace() call to replace
all instances of #039; with ' before returning the $html variable in
the decode function, but I really want to know why it's not working
properly.

Can anyone give me any ideas?

Cheers and TIA.

Pablo

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



[PHP] Can I detect size of files which are too large to upload?

2004-06-18 Thread Pablo Gosse
Hi folks.  I'm just tweaking the file manager portion of my CMS, and am
wondering if there is any way I can identify the size of an uploaded
file which exceeded the upload_max_filesize?  I'd like to be able to
tell the user the size of the file they tried to upload, in addition to
telling them the allowable maximum size.

It would seem logical to me that I would not be able to do this, since
if the file exceeds the limit set by upload_max_filesize then the upload
should not continue past that point.

Is this an accurate assumption?

Cheers and TIA.

Pablo

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



RE: [PHP] Can I detect size of files which are too large to upload?

2004-06-18 Thread Pablo Gosse
Ashwin Purohit wrote:
 $userfile=$_FILES['userfile']['tmp_name'];
 $userfile_error=$_FILES['userfile']['error'];
 if ($userfile_error  0)
 {echo 'Problem: ';
 switch($userfile_error)
 {case 1: echo 'File exceeded upload maximum filesize'; break; case 2:
 echo 'File exceeded maximum file size'; break; case 3: echo 'File
 only partially uploaded'; break; case 4: echo 'No file uploaded';
 break; }exit;}   
 
 You can use a switch format like I have done previously shown above.
 Each file error is mentioned in a different case. --
 Ashwin Purohit
 
 On Fri, 18 Jun 2004 10:50:04 -0700, Pablo Gosse [EMAIL PROTECTED]
 wrote: 
 
 Hi folks.  I'm just tweaking the file manager portion of my CMS, and
 am wondering if there is any way I can identify the size of an
 uploaded file which exceeded the upload_max_filesize?  I'd like to be
 able to tell the user the size of the file they tried to upload, in
 addition to telling them the allowable maximum size.
 
 It would seem logical to me that I would not be able to do this,
 since if the file exceeds the limit set by upload_max_filesize then
 the upload should not continue past that point.
 
 Is this an accurate assumption?
 
 Cheers and TIA.
 
 Pablo

Sorry.  I know the error codes, but I'm looking to discover the uploaded
size of the file which exceeded the upload limits.

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



RE: [PHP] Can I detect size of files which are too large to upload?

2004-06-18 Thread Pablo Gosse
Marek Kilimajer wrote:
 Pablo Gosse wrote --- napísal::
 Hi folks.  I'm just tweaking the file manager portion of my CMS, and
 am wondering if there is any way I can identify the size of an
 uploaded file which exceeded the upload_max_filesize?  I'd like to be
 able to tell the user the size of the file they tried to upload, in
 addition to telling them the allowable maximum size.
 
 It would seem logical to me that I would not be able to do this,
 since if the file exceeds the limit set by upload_max_filesize then
 the upload should not continue past that point.
 
 Is this an accurate assumption?
 
 Cheers and TIA.
 
 Pablo
 
 
 Content-Length request header, approximately, it also contains other
 post fields.

H, thanks Marek.  That might work, though I'm not entirely sure.  The form through 
which users upload files can upload five at a time, so I'm assuming that the 
content-length request header would contain the sum total of all uploaded files, and I 
don't really see how I could get the individual sizes.

Thoughts?

Cheers and TIA.

Pablo

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



RE: [PHP] HTTP_REFERER ... ?

2004-05-05 Thread Pablo Gosse
John Nichel wrote:
 [EMAIL PROTECTED] wrote:
 Sadly, I get nothing...
 the other server I'm talking to is owned by our company, it's a
 Lotus Domino server... so in theory, they'll be able to enable this
 variable to be passed? 
 
 I can never remember one day to the other which it is, but I _think_
 it's the browser which sets/sends the REFERER, not the referring
 server. 
 
 --
 John C. Nichel
 KegWorks.com
 716.856.9675
 [EMAIL PROTECTED]

You should avoid using HTTP_REFERER if at all possible.  I found out the
hard way that some firewalls will change HTTP_REFERER to HTTP_WEFERER,
obfuscate it some other way, or just not set it.  This can also be done
by the browser in some cases.

The following is quoted from a previous post by Chris Shifflet:

Referer is just as easy to spoof as the form data you're expecting.

HTH.

Pablo

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



[PHP] Trouble setting include_path

2004-05-02 Thread Pablo Gosse
Hi folks.  I'm trying to use an .htaccess file to set my include path
and for some reason it's not overriding the value in php.ini, but
instead still shows and uses the original value from php.ini, not what
is in the .htaccess file.

I know that include_path is one of the values that can be set anywhere,
so I'm confused as to why this is happening.

I've placed the following .htaccess file in www.mysite.ca/test/: 

php_value include_path /home/pablo/foo

And in www.mysite.ca/test/test.php I have one line:

include_once 'foo.php';

which refers to the file /home/pablo/foo/foo.php

However when I run test.php it does not include foo.php and the error
message informs me that the include_path value being used is still the
one from the php.ini file.

Has anyone run into this before or got any idea why this is happening?

Cheers and TIA.

Pablo

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



RE: [PHP] Trouble setting include_path

2004-05-02 Thread Pablo Gosse
snip
Most default apache configurations now a days dont have .htaccess
enabled by default (for performance reasons.) Or some hosting
services implicitly turn this option off. So no matter what
you put in the .htaccess file, it will be ignored.

You can test this by putting in your .htaccess file something like:
bogus_statment

if you reload your page on your server and dont get a 500 server
error, apache isn't even looking at the .htaccess file. You can
set set the include_path using the php function ini_set().
/snip

Thanks, Curt.  That was indeed the problem.

Cheers,
Pablo

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



RE: [PHP] A to Z incremental

2004-04-22 Thread Pablo Gosse
snip
 Hi!
 Got this script:
 
 ?php
 for($i='A';$i='Z';$i++){  echo $i.' | ';  }
 
 
 The output is:
 A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R
   | S | T | U | V | W | X | Y | Z |  AA | AB | AC |  ... YX | YY | YZ
 | 
 
 where is should display only letters from A to Z.
 Why is that?
 
/snip

Hi, Paul. Try this instead.

$x = 65;
for ($i=0; $i26; $i++)
{
echo chr($x);
$x++;
}

Set $x to 97 to get lowercase letters.

HTH.

Pablo.

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



RE: Re[2]: [PHP] A to Z incremental

2004-04-22 Thread Pablo Gosse
Paul wrote:
 Hello Pablo,
 
 Thursday, April 22, 2004, 4:05:23 PM, you wrote:
 
 Hi!
 Got this script:
 
 ?php
 for($i='A';$i='Z';$i++){  echo $i.' | ';  }
 
 
 The output is:
 A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q |
   R | S | T | U | V | W | X | Y | Z |  AA | AB | AC |  ... YX | YY
 | YZ 
 
 
 where is should display only letters from A to Z.
 Why is that?
 
 
 Hi, Paul. Try this instead.
 ...
 
 
 Thanks Pablo!
 I know that but I was curios why that happens.
 
 
 --
 Best regards,
  Paulmailto:[EMAIL PROTECTED]

Hi Paul.

Since you're dealing with a string, A is less than AA which will be less
than Z.  It's stopping at YZ because if it were to increment once more,
it would be ZZ, which (again, because this is a string) is greater than
Z so thus the loop exits.

HTH.

Cheers,
Pablo

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



RE: [PHP] Why not use assertions for input validation?

2004-04-13 Thread Pablo Gosse
snip
PS. Could you post a link to that article?
/snip

http://www.linuxjournal.com/article.php?sid=7237

Cheers,
Pablo

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



RE: [PHP] (new question on this) http referer

2004-04-08 Thread Pablo Gosse
snip
The referrer is sent by the referring machine.  If that machine isn't 
setting it, you can't get it.  If memory serves, I think I remember 
someone claiming that this could also be blocked at a firewall...don't 
know if that's true or not though.
/snip

Yup, certain firewalls either mangle the HTTP_REFERER such that it
appears it was sent by Elmer Fudd, showing up as HTTP_WEFERER, and
others just eliminate it altogether.

At any rate, if you're relying on HTTP_REFERER to make sure a script is
being called from a certain location, I don't think it's very reliable.

Does anyone have any ideas as to a workaround for this?

Cheers,
Pablo

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



[PHP] Regular Expression Help

2004-04-08 Thread Pablo Gosse
Hi folks.  I'm having a little trouble with a regular expression and I'm
hoping someone can point out what I'm doing wrong.

I want to extract from a large number of html files everything between
the following specified comments, including the comments themselves:

!--Begin CMS Content--...!-- End CMS Content--

The string I'm testing the expression against is:

'Some code that will be ignored.
!--Begin CMS Content--
span class=headlineBreadth Requirement/span
hr class=under /
!-- End CMS Content--
This is some more content that will not be matched.
!--Begin CMS Content--
strongMore Matched Content!/strong
!-- End CMS Content--
Some more ignored code.'

And the regular expression I've got is

'/[!--Begin CMS Content\-\-].+[!-- End CMS Content\-\-]/s'

I expected that when I ran this using preg_match_all I would get two
matches, the comments and the content between them, but instead I get
the following:

Array
(
[0] = Array
(
[0] = Some code that will be ignored.
!--Begin CMS Content--
span class=headlineBreadth Requirement/span
hr class=under /
!-- End CMS Content--
This is some more content that will not be matched.
!--Begin CMS Content--
strongMore Matched Content!/strong
!-- End CMS Content--
Some more ignored code
)

)

which is just a match of the whole string minus the period at the very
end which is not matched.

Can anybody point out where I'm going wrong here?

Cheers and TIA,

Pablo.

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



RE: [PHP] smarty

2004-04-08 Thread Pablo Gosse
snip
Who the fuck you tink you're talkin' to, huh! Whatta you think I am?
Your fuckin' slave! You dont tell me what to do, Sosa. Youre shit! You
want a war, you got it. I'll take you to war!
/snip

Shame on you for misquoting Scarface.

G'nite, Tony.  Next time you're going to quote a classic please get it
right.

Oh, and this is a php list not alt.movies.misquoted ;o)

P.

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



RE: [PHP] cURL upload meter

2004-04-05 Thread Pablo Gosse
Steve Murphy wrote:
 Can cURL be used to create an HTTP or FTP upload meter?
 
 Steve

By upload meter do you mean a progress bar which can tell a user how
much of a large upload has been processed thus far?

As far as I understand it PHP cannot access raw POST data so this cannot
be done with PHP alone.

There exists a set of perl/php scripts at
http://www.raditha.com/php/progress.php which does exactly this.

HTH.

Pablo

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



RE: [PHP] FTP loading

2004-04-01 Thread Pablo Gosse
Lieve Vissenaeken wrote:
 Please help me,
 
 Is it possible with php to load immedeatly pictures into a website by
 users (by use of a ftp-statement) ? I mean: so that any user on my
 website can add a picture to that website which is immedeatly visible
 on that webiste? If this is possible, where can I find the code for
 my problem?
 
 
 Thanks for helping.

http://ca.php.net/features.file-upload

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



RE: [PHP] Tricky array question

2004-04-01 Thread Pablo Gosse
Merlin wrote:
 Hi there,
 
 I am trying to get continent and country info out of an xml file.
 There is a continent element to each country element. 
 
 Now I do have an array with the continent info and one with the
 country info. The goal is to be able to output all countries sorted
 after continents. So I do have: $results[]-countryContinent
 $results[]-countryName   
 
 I tryed to group those values, to do array searches and more, but
 somehow it looks like that there must be a way more easy way to do
 this. Maybe someone has a good hint how to solve that.  
 
 Thanx for any help,
 
 merlin

I would suggest parsing the XML data such that you have an array of
continents, and each element of said array is an array with two elements
- the first being the contintent name and the second array containing
all countries within that continent.

So, after parsing the file you would have:

$contintents[0] = array('North America',array('Canada','United
States','Mexico'));
$contintents[1] = array('South
America',array('Ecuador','Chile','Peru','Columbia','Brazil'));

etc. etc.

HTH.

Pablo.

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



  1   2   >