Re: [PHP] Too Advanced? Re: Cookies Hidden Image

2003-09-03 Thread Ernest E Vogelsinger
At 23:55 03.09.2003, Nicole said:
[snip]
But the script just gets a blank cookie when accessed this way(via hidden
image); However, if the script was accessed directly, or the thankyou page
resided on the same domain as the tracking script (which created the cookie
to begin with), the cookie has the value that it was set with.
[snip] 

That's it - cookies will only be sent to the same domain (hostname) they
have been generated at. You cannot pass cookies between domains (hostnames).


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

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



Re: [PHP] set_time_limit problem

2003-09-03 Thread Ernest E Vogelsinger
At 01:19 04.09.2003, Colm O'Riain said:
[snip] 
So 2 questions for you all

* Why, if the intitial configuration enabled safe mode, would it not be 
seen to be enabled when I call phpinfo(INFO_CONFIGURATION)?

Because safe_mode might be switched off in php.ini?

* If, in fact, it is in safe_mode, what options do I have to get around
this 30 second limit?

There's also a script timeout on most web servers. Apache by default
imposes a 30 second limit on each page it serves, configurable in httpd.conf:
#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300



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

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



Re: [PHP] Array Push and Keys

2003-08-29 Thread Ernest E Vogelsinger
At 00:14 29.08.2003, Mike Morton said:
[snip]

I am trying to loop through some database results to build an array similar
to:

Array (
[33]=Array (
[usa]=52.00
[sa]=553.00
)
)

And the problem that I am having is that array_push does not want to take
keys when I am using it.
[snip] 

Mike,

the solution is quite simple, and is already buried in some of the
responses until now.

Modifying your sample code, this will work and generate your expected results:

$transactions=Array(); 
While($row=mysql_fetch_array($res) { 
   // array_push($transactions,$row[dealercode]=Array()); 
   $transactions[$row['dealercode']] = Array();
   $another_query=mysql_query(do another query here); 
   while($morerows=mysql_fetch_array($another_query)) { 
  // array_push($transactions[$row[dealercode],
  //$morerows[country]=$morerows[amount];
  $transactions[$row['dealercount']][$morerows['country']]
= $morerows['amount'];
   }
}

Hope this helps,


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

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



Re: [PHP] disable notice errors

2003-08-29 Thread Ernest E Vogelsinger
At 20:56 29.08.2002, fatih olcer said:
[snip]
how to disable notice error output 


i have set error_reporting = 2039 (in PHP.ini);
but it doesnt work.i still get notice :Undefined index..
[snip] 

as a third method, you can explicitly disable warnings and errors for a
single command using the '@' modifier. 

This is widely unknown but a very handy feature: having excessive
error_reporting turned on [error_reporting(E_ALL)] helps a lot in spotting
down possible problems in your code, but again there are numerous locations
where e.g. array keys might be there, or not. You could either use
array_key_exists(), or the @ modifier to suppress the warning.

Example:
// this will raise a warning
$test = $array['nonexisting_key'];

// this avoids array access if the key is not set,
// OTOH the receiving variable might be undefined
if (array_key_exists('nonexisting_key', $array))
$test = $array['nonexisting_key'];

// this is a simple, elegant, and even self-documenting solution
$test = @$array['nonexisting_key'];


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

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



Re: [PHP] Reading an MS Access Database file on *NIX platform using PHP

2003-08-25 Thread Ernest E Vogelsinger
At 03:18 25.08.2003, Weston Cann said:
[snip]
I share a low regard for Access, and I've got a set of standard 
forms/code I use to set up a nice interface to MySQL, and I showed it to 
my friend. He likes that, but there's a problem:

He wants to be able to make changes offline, and then sync up.

This isn't an uncommon desire... I've run into people wanting to do this 
before (with Excel spreadsheets, no less).  And in fact, it's probably 
the most convenient way of doing things, as long as they're warned about 
certain dangers (overwrites from competing unsynced database files).  
There's a certain cumbersome nature about web forms and the time delay 
involved in HTTP transactions.

So anyway, that's the motivation for using Access here.
[snip] 

You could do that without too much effort. Export the data to be synced
from MS Access to a CSV style export format, upload it to the server and
process it. There are a couple of examples how to handle CSV style data on
SourceForge, I believe.


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

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



Re: [PHP] This is getting rediculus

2003-08-20 Thread Ernest E Vogelsinger
At 17:57 20.08.2003, Marek Kilimajer said:
[snip]
I was thinking about it, but how did he manage to send the confirmation 
email. Maybe the list admin did it ;)
[snip] 

When I changed my email address I unsubscribed the old address and
subscribed the new address. After subscribing the new one I left my office
and came back the next day. I immediately acknowledged the subscription,
only to find that the ACK token had already been expired - however I get
messages from the list since then. I believe the acknowledging mechanism
doesn't really work.


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



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



Re: [PHP] CHAT about PHP

2003-08-20 Thread Ernest E Vogelsinger
You can program a site as complicated as this in ASP as well *g*

At 18:19 20.08.2003, P.Agenbag said:
[snip]

Sites like these will drive me to ASP...

On Wed, 2003-08-20 at 17:39, David Otton wrote:
 On 20 Aug 2003 11:31:02 -0400, you wrote:
 
 On Wed, 2003-08-20 at 11:11, Curt Zirzow wrote:
  * Thus wrote Damian Brown ([EMAIL PROTECTED]):
   www.phpexpert.org
   Programming Help
   and General Programming Topics
  
  Is this a joke?
 
 Looks like an email harvester. Why does it need an email address?
 
 Search-engine spammer and an onClose popup ad, too. And multiple!!!
 exclamation!!! marks!!!
 
 Yeah, that's someone I'd do business with.
 


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

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



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



Re: [PHP] ?xml ? parsing problem

2003-06-28 Thread Ernest E Vogelsinger
At 12:33 28.06.2003, Daniele Baroncelli said:
[snip]
I have problem in including this text in my PHP parsed file for XHTML
definition:

?xml version=1.0 encoding=iso-8859-1?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;


It works if I remove the first line:

?xml version=1.0 encoding=iso-8859-1?


So, I am assuming PHP has problems with the ? ? symbols, as they are
recognised to be PHP code delimiters.

I believe short_open_tag is set to On in php.ini, thus when seeing '?',
PHP starts acting.

Considering that I don't have control of the PHP configuration on the
server, does anyone have any idea of how I could handle this parsing
problem, still being able to define the file as XHTML?

Within your PHP code:
echo '?xml...';


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



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



Re: [PHP] Setting focus on a textfield

2003-06-27 Thread Ernest E Vogelsinger
At 09:42 20.03.2003, Angelo Zanetti said:
[snip]

Hi guys how do I set the cursor to start in a particular textfield (password 
field) when my php page starts?

TIA
[snip] 

This is done with a JavaScript OnLoad handler:

body onload=forms[myform].elements[pass].focus();
...[page contents]...
form name=myform method=post ...
input type=password name=pass
/form
...[more page contents]...
/body


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



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



Re: [PHP] Converting Array

2003-06-26 Thread Ernest E Vogelsinger
At 03:37 26.06.2003, John Wulff said:
[snip]
I've got an array in the following format:
Array ( [Jan-1999] = 36.04,140.35,319.53,324.07 [Feb-1999] =
1.78,71.78,320.58,141.97 )

I need it in the following format:
$example_data = array(
array(Feb-1999,1.78,71.78,320.58,141.97),
array(Jan-1999,36.04,140.35,319.53,324.07)
);
[snip] 

This should do:

$array_output = array();
foreach ($array_input as $key = $data) {
   $atmp = explode(',',$data);
   array_unshift($atmp, $key);
   $array_output[] = $atmp;
}

May I ask why you're reformatting the array - maybe you could avoid this step?


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



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



Re: [PHP] if else if statement failed...

2003-06-26 Thread Ernest E Vogelsinger
',
   ),
),
);

function run_test($map)
{
   foreach ($map as $check) {
  if (eval(return ({$check['expr']});)) {
 foreach ($check['check'] as $field = $msg) {
if (empty($_REQUEST[$field])) {
   echo sprintf($check['pattern'], $msg);
   return false;
}
 }
  }
   }
   return 'Pass';
}



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



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



Re: [PHP] Passing Array to object

2003-06-25 Thread Ernest E Vogelsinger
At 20:17 25.06.2003, Daniel J. Rychlik said:
[snip]

Its erroring at my display links function.  This function is inside my main
class.

function DisplayLinks($links) {

while(list($name, $url) = each($links) {

echo :::a href= '$url''$name/a:::\n;

} //End while

} // End DisplayLinks function


I dont see why it wont work...  I even try assigning $links to the array.
[snip] 

The error (in fact it's a warning) points out that your variable $links
is neither array nor object. Add this line on top of your DisplayLinks()
method:

   echo pre ** START DUMP **\n; var_dump($links); echo ** END DUMP
**/pre';

This should give you any info available on $links. If $links is null,
you will see nothing between ** START DUMP ** and ** END DUMP **. Once you
have this info you can investigate further.


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



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



Re: [PHP] identify not only browser, but even browser windows with session

2003-06-24 Thread Ernest E Vogelsinger
At 10:58 24.06.2003, dorgon said:
[snip]
can cookies be stored for single browser instances (windows)?
does the browser send some information that could be uses?
[snip] 

Short answer - no, and no.

Cookies are stored browser-wide, and if the user presses Ctrl+N (or else)
to open a new window you would never detect it. Even using some
sophisticated techniques like session access counters, session serial
numbers, etc, are not guaranteed to work since the browser may have cached
the page contents and simply _locally_ copied it to the new window, not
issuing a new request.

However you may use a serial number in session data that is incremented
with each request. Incorporate this number in any form or session-based
link to have the browser transmit it back to you. Then compare if the
serial number matches the expected vale; if not it's a reload and you can
proceed as seems fit.

However you don't have a chance to recognize if the reload comes from
simply a page reload, or from a window clone.

BTW - this is the reason I have switched off session cookies at my servers.
Having the SID available allows to run more than one session from a single
browser instance.

HTH,

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



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



Re: [PHP] open_basedir

2003-06-20 Thread Ernest E Vogelsinger
At 15:03 20.06.2003, dorgon said:
[snip]
Would it be possible to limit access to open_basedir without the
exception of /tmp, to allow the uploads?
[snip] 

You (or your server admin) should add /tmp to the allowed directories:

open_basedir = /tmp:/www/yourvirtualhost

This should give you access to both trees.


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



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



Re: [PHP] ACL howto

2003-06-16 Thread Ernest E Vogelsinger
At 06:11 16.06.2003, Sn!per said:
[snip]
I have several admin modules for my portal. And I have also several admin 
users who are supposed to have access only to certain modules.

Say, the superadmin can access ALL modules (modA, modB, modC, modD) and
admin-A can only access modA and modB
admin-B can only access modA and modD
...
...

How can I setup my ACL that do bit (XOR) checking ?
[snip] 

You don't want to XOR but you want to OR (set bits) or to AND (test bits):

define('AUTH_APP_A',0x0001);
define('AUTH_APP_B',0x0002);
define('AUTH_APP_C',0x0004);
define('AUTH_APP_D',0x0008);

$adminA-SetAccountRights(AUTH_APP_A | AUTH_APP_B);
$adminA-SetAccountRights(AUTH_APP_A | AUTH_APP_D);

// on top of AppA
if (!($admin-GetAccountRights()  AUTH_APP_A)
header('Location: main_menu.php');

// on top of AppB
if (!($admin-GetAccountRights()  AUTH_APP_B)
header('Location: main_menu.php');

// on top of AppC
if (!($admin-GetAccountRights()  AUTH_APP_C)
header('Location: main_menu.php');

// on top of AppD
if (!($admin-GetAccountRights()  AUTH_APP_D)
header('Location: main_menu.php');

This is fairly crude but quite efficient.


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



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



Re: [PHP] interact with .htaccess

2003-06-15 Thread Ernest E Vogelsinger
At 12:28 15.06.2003, Peter Berglund said:
[snip]
I want to send user and password from php to a protected directory.
For example: If I go directly to the directory I get a popup to enter user
and password, the normallt way.

But if I go through a php-script that checks if I'm a valid user from a
database I will get access to the folder.

So i need a way to send user/password from php to the .htaccess file.
[snip] 

I'm afraid this is not possible for the simple reason that the _client_
needs to transmit the auth credentials to the server.

What you can do however is to somehow include the page contents in your PHP
output. In case the .htaccess-protected content is a simple html page you
could e.g. readfile() it, or process it in a similar way.

HTH,


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



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



Re: [PHP] Re: interact with .htaccess

2003-06-15 Thread Ernest E Vogelsinger
At 13:04 15.06.2003, Adrian said:
[snip]
you could redirect to http://username:[EMAIL PROTECTED]/foo
[snip] 

with the drawback that your highly sensitive account information is visible
at the URL and will be stored in anyone's history files. Well... why
protect it anyway?


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



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



Re: [PHP] Re: interact with .htaccess

2003-06-15 Thread Ernest E Vogelsinger
At 16:32 15.06.2003, Peter Berglund said:
[snip]
ok, I change my question, how do I protect downloadable files from users
that are not valid?
without the use of htaccess?
[snip] 

Have a look at an example on my server:
http://www.vogelsinger.at/protected.html

This should do just what you need, some explanations are within the source
code.


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



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



Re: [PHP] Redirects in PHP

2003-06-13 Thread Ernest E Vogelsinger
At 19:00 13.06.2003, Zak Johnson said:
[snip]
This will not solve the OP's problem; the header will still be output
first, and the client will be immediately redirected.  I am curious
though; why is everyone suggesting to use JavaScript when the following
in the head section of the HTML document will work just as well?

  meta http-equiv=refresh
content=3;URL=http://example.com/new-page.html; /

Am I missing something?
[snip] 

This will (or should...) always work regardless of JS settings. Being a
HTTP equivalent this also means you can transmit it as MIME header as well:

header('Refresh: 5;URL=http://www.microsoft.com;');
echo 'Transferring you to Microsoft in 5 seconds...';
exit;

HTH,

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



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



Re: [PHP] Php code to create php code

2003-06-11 Thread Ernest E Vogelsinger
At 14:05 11.06.2003, Sancar Saran said:
[snip]
Hi,
Is there any example or/and tutorial for create php code with using php.
[snip] 

It's simple, frankly:

$code = EOC
echo 'Hello World, the current time is ', date('H:i:s'), 'br /';
EOC;

eval($code);

The complexity is up to you ;-)


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



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



Re: [PHP] Re: Warning Spammer

2003-06-11 Thread Ernest E Vogelsinger
At 14:08 11.06.2003, Kevin Saenz said:
[snip]
I think we are wy off topic.
But how do you know if they are sending from a legit email account
I know if I was a spammer I would be using made up ones like 
[EMAIL PROTECTED] [EMAIL PROTECTED] how hard is it to forge
email addresses? 
[snip] 

It's extremely simple - just put any email address as From address:

mail('[EMAIL PROTECTED]',
 'Buy me!',
 'Here\'s some spam for you',
 From: [EMAIL PROTECTED] .
 Reply-To: [EMAIL PROTECTED] . 
 X-Mailer: PHPSpam/ . phpversion() . \r\n,
 [EMAIL PROTECTED]);

The last parameter is a sendmail parameter which may be omitted (doesn't
work in safe mode anyway, see http://www.php.net/manual/en/function.mail.php).


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



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



Re: [PHP] Re: Warning Spammer

2003-06-10 Thread Ernest E Vogelsinger
At 01:36 11.06.2003, [EMAIL PROTECTED] said:
[snip]
so do they get the emails from the archive ? ?if so password protect
please !!
[snip] 

Not necessarily from the archives - they might as well subscribe a bot
address to multitude of lists, and simply parse the mails for _real_
addresses. As soon as you post for the first time their bot will add your
email to the database.

Unfortunately a subscription confirmation is of no real value - they would
simply confirm the bots address...

And, to be honest: don't you want to impress your girlfriend? 
*ducking away*


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



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



Re: [PHP] Questions, questions, questions...

2003-06-10 Thread Ernest E Vogelsinger
At 01:34 11.06.2003, Sparky Kopetzky said:
[snip]
Ok - let the war begin...

no war at all...

Question: Why doesn't the PHP community support using an Hungarian style of 
programming if it prevents errors?? I've gotten too darn many times now by a 

It's always a matter of personal likes and dislikes. If you feel
comfortable with it, then stick to it (I do it sometimes, not always, as I
feel it's more important to try to hide stuff like private instance data
than to blindly adhere to rigid coding standards, as long as you can read
your code two months later)

Question: Is there a better way in classes to access/modify var's other than 
get_var, put_var functions? Works great for me and I know whether I'm saving 

That's how OO is meant to be. Do it this way, even if the language doesn't
enforce it. There's _really_ only a very small performance loss (approx.
0.01 msec per access). However take care - accessing _big_ data (like huge
arrays, for example) using access functions may instantly measurable
decrease performance, since variables are _copied_ unless you're using
references.

a variable or accessing it. Sure, I'd like to be able to use a VB style 
Set/Get property but who wouldn't??

Why don't you do it?

class CSampleClass
{
var $m_a = 'value a';
var $m_b = 'value b';

function Get($varname)
{
if (array_key_exists($varname,
get_class_vars(get_class($this
return $this-$varname;
// demo only
echo '[', get_class($this), ::Get: class variable doesn't
exist: $varname];
return null;
}
function Set($varname, $value)
{
if (array_key_exists($varname,
get_class_vars(get_class($this
$this-$varname = $value;
else
echo '[', get_class($this), ::Set: class variable
doesn't exist: $varname];
}
}

$sc = new CSampleClass();
echo m_a = , $sc-Get('m_a'), , m_b = , $sc-Get('m_b'),
 , other = , $sc-Get('other'), \n;
$sc-Set('m_a', 'new data for m_a');
$sc-Set('m_b', 'new data for m_b');
$sc-Set('other', 'new data for other');
echo m_a = , $sc-Get('m_a'), , m_b = , $sc-Get('m_b'),
 , other = , $sc-Get('other'), \n;


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



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



Re: [PHP] Evaluating defines

2003-06-05 Thread Ernest E Vogelsinger
At 13:46 04.06.2003, Yann Larrivee said:
[snip]
My probleme is that i need to return the value of my define and not its
name. My eval doesnt seem to work.

Any body as a sugestion , or a better way to do this without passing by
eval . 

$replace_by[] = eval(echo \$out[2][$i];);
[snip] 

echo'ing the value wouldn't work here - you want the value part of your
defined name in a variable. You need this assignment within the eval:

eval('$replace_by[] = ' . $out[2][$i] . ';');

After this eval, the $replace_by array will contain the correct value.


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



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



Re: [PHP] preg_replace help

2003-06-04 Thread Ernest E Vogelsinger
At 18:43 03.06.2003, Jackson Miller said:
[snip]
I am trying to create a text only version of an HTML formatted message.
I would like to convert all links from:
a href=http://domain.tld.page.ext;link name/a
to:
link name [http://domain.tld/page.ext]

The problem is that some links may have additional modifiers and onthers
may not.  

I have seen many examples of doing the reverse, but I can't seem to find
an example of this.

If anyone has done something similar and would like to share, please do.
[snip] 

This should work:

$result = null;
while (preg_match('!(.*).*?a.*?href\s*=\s*(.*?).*?(.*)!i', $html,
$aresult)) {
$result .= $aresult[1];
if ($aresult[2]) $result .= ' link name [' . $aresult[2] . ']';
$html = $aresult[3];
}
$result .= $html;


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



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



Re: [PHP] preg_replace help

2003-06-04 Thread Ernest E Vogelsinger
At 18:43 03.06.2003, Jackson Miller said:
[snip]
I am trying to create a text only version of an HTML formatted message.
I would like to convert all links from:
a href=http://domain.tld.page.ext;link name/a
to:
link name [http://domain.tld/page.ext]

The problem is that some links may have additional modifiers and onthers
may not.  

I have seen many examples of doing the reverse, but I can't seem to find
an example of this.

If anyone has done something similar and would like to share, please do.
[snip] 

Sorry - you want the enclosed link name
This should work:

$result = null;
while
(preg_match('!(.*).*?a.*?href\s*=\s*(.*?).*?(.*?)\s*/\s*a\s*(.*)!i',
$html, $aresult)) {
$result .= $aresult[1];
if ($aresult[2]  $aresult[3]) $result .= $aresult[3] . ' [' .
$aresult[2] . ']';
$html = $aresult[4];
}
$result .= $html;


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



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



Re: [PHP] preg_replace help

2003-06-04 Thread Ernest E Vogelsinger
At 19:18 03.06.2003, Jackson Miller said:
[snip]
Maybe I should clarify.

$message = 'pVisit a href=http://jaxn.org; target=_topMy personal
site/a to learn more about me./p
pVisit a href=http://memigo.com;memigi/a to learn about current
events.';

What I want is to run a preg_replace to get the following:
Visit My personal site (http://jaxn.org) to learn more about me.

Visit memigo (http://memigo.com) to learn about current events.

stripping the HTML is easy, but before I do I want to convert the links.

The loop I posted does exactly that (using square brackets as to your
initial requirements). The 3rd parameter of preg_match ($aresult) will be
an array that holds the grouped expressions from the regex:
[0] - whole string
[1] - pre-match (all before a href)
[2] - the URL part of the link
[3] - the linked text
[4] - postmatch (all after the closing /a).
Within the loop I use this array to modify the HTML code to read
(pre-match)#linked-text# [#url#]...

which is what you want, after all.


On Tue, 2003-06-03 at 11:59, Ernest E Vogelsinger wrote:
 At 18:43 03.06.2003, Jackson Miller said:
 [snip]
 I am trying to create a text only version of an HTML formatted message.
 I would like to convert all links from:
 a href=http://domain.tld.page.ext;link name/a
 to:
 link name [http://domain.tld/page.ext]
 
 The problem is that some links may have additional modifiers and onthers
 may not.  
 
 I have seen many examples of doing the reverse, but I can't seem to find
 an example of this.
 
 If anyone has done something similar and would like to share, please do.
 [snip] 
 
 Sorry - you want the enclosed link name
 This should work:
 
 $result = null;
 while
 (preg_match('!(.*).*?a.*?href\s*=\s*(.*?).*?(.*?)\s*/\s*a\s*(.*)!i',
 $html, $aresult)) {
 $result .= $aresult[1];
 if ($aresult[2]  $aresult[3]) $result .= $aresult[3] . ' [' .
 $aresult[2] . ']';
 $html = $aresult[4];
 }
 $result .= $html;
 
 
 -- 
O Ernest E. Vogelsinger
(\)ICQ #13394035
 ^ http://www.vogelsinger.at/
 
 
[snip] 

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



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



Re: [PHP] update question

2003-06-03 Thread Ernest E Vogelsinger
At 21:12 02.06.2003, Matt Hedges said:
[snip]
Hello, I am new to PHP and would greatly appreciate any help.

I am building a webpage for my sister's sorority- http://olemissddd.com.  I
have built a page that allows them to update the officers each year-
http://hedges.org/ddd/olemiss/updateofficers.php and then view those
officers- http://hedges.org/ddd/olemiss/officers.php .

However, what I want to be able to do that I can't figure out is for when
they leave one of the fields blank it doesn't change anything.  As it is
now, when they change one of the fields and leave the others blank it will
overwrite the names it had for them with blank spaces.  I want to be able to
do this so for example if they mistype someone's name, etc.  So somehow I
need to be able to tell it that when the user leaves the field blank, not to
change that field in MySQL.
[snip] 

Try something like

if (!empty($_REQUEST['fieldname']))
   dbupdate('fieldname');

http://www.php.net/manual/en/function.empty.php




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



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



Re: [PHP] update question [T20030602013J]

2003-06-03 Thread Ernest E Vogelsinger
At 21:41 02.06.2003, you said:
[snip]
This is an automatic reply to acknowledge that your message has been 
received. PLEASE DO NOT REPLY TO THIS MESSAGE.

--

Dear [EMAIL PROTECTED],

Thank you for submitting your question to our Technical Support Department. 
We received it on 6/2/2003 at 12:41:25 PM. Your tracking number for this 
message is: T20030602013J.  This message and tracking number are your 
assurance that we have received your message and will respond to it as 
quickly as possible.

At BONZI Software we attempt to answer all of the questions we get on a 
first-come, first-served basis, as quickly as possible.  On occasion we 
receive a large volume of e-mail that prevents us from answering your 
message as quickly as we would like.  Please be assured that we have your 
message and will respond to it as quickly as we can.

If your question to us is of a support nature, you can visit 
http://www.bonzi.com/support.htm to try and find an answer to your question 
in our online support center. This will often be quicker than we can reply 
to your message by hand, so we encourage you to try it out.

Sincerely,

Customer Support
BONZI Software
HTTP://www.bonzi.com
[snip] 

Dear [EMAIL PROTECTED],

I _do_ dare and reply., and I hope a lot of the listmembers that have been
spammed by you will do the same.

I never sent a message to you, nor am I interested in any way in your services.

Please refrain from hooking into mailing lists and bombarding the
listmembers with absolutely unneccessary, unsolicited and impolite spams
camouflaged as auto-reply.

Thank you for consideration.

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



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



Re: [PHP] simple password protect script

2003-06-03 Thread Ernest E Vogelsinger
At 02:50 03.06.2003, Matt Hedges said:
[snip]
Hello,

Can anyone tell me the basic PHP script to password protect a php page?
[snip] 

Have a look at http://www.vogelsinger.at/protected.html, maybe this is what
you're looking for.


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



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



RE: [PHP] Broken links report

2003-06-03 Thread Ernest E Vogelsinger
At 07:55 03.06.2003, Kjell Hansen said:
[snip]
Thanx Chris,
this is exactly what I do. And I get
Warning: fopen(http://www.whatever.com/index.html) [function.fopen]: failed
to create stream: HTTP request failed! HTTP/1.1 404 Object Not Found

I don't want to get the warning. I know I can switch it off but there are
other warnings I would like to see.

Somehow I just want to check for HTTP/1.1 404 Object Not Found and if
found show it as a broken link.
[snip] 

You can't do it that way. If a web page is missing, the webserver will
transmit the error page for code 404. You cannot rely that this will always
the string you're looking for, and you cannot be sure that a regular page a
link points to will _not_ contain this string.

Just to omit the warning, you may use the silent-error notation
@fopen($url, 'r');
but this will always work unless the host portion of the URL cannot be
resolved.

You need to employ a method where you receive the MIME headers additional
to the page body. Have a look at cURL
(http://www.php.net/manual/en/ref.curl.php) how to do this.

HTH,

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



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



Re: [PHP] OOP question

2003-06-01 Thread Ernest E Vogelsinger
'; $res_hello = $tee-call_method('hello', 'Called hello() (both
base and extended)');
echo 'hr';  $res_say   = $tee-call_method('say', 'Called say() (only
extended)', 4711);

echo 'hr';
echo 'Hello results: '; print_r($res_hello);
echo 'Say results: '; print_r($res_say);

?


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



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



Re: [PHP] OOP question

2003-06-01 Thread Ernest E Vogelsinger
Just noticed a small glitch in the attach() method - check_object will not
be called for the first object. Use this attach() / check_object()
implementation instead. The var $class instance variable of CTeeObject
can be omitted.

function attach($hObj) {
if (!$this-check_object($hObj))
return false;
$this-arObj[] = $hObj;
return true;
}

// override this method in your derived class
// for additional class checks
function check_object($hObj)
{
// if this is the first object, simply accept it.
// for all successive objects make sure they have
// the same class (or at least derived from).
if (is_object($hObj))
return (!count($this-arObj) || is_a($hObj,
get_class($this-arObj[0])));
return false;
}




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



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



Re: [PHP] static vars question

2003-05-31 Thread Ernest E Vogelsinger
At 00:27 31.05.2003, Martin Helie said:
[snip]
yes, I am familiar with these concepts; I am just starting to experiment
with recursive functions and static variables. Thanks for explaining that
once the function is called and completed, the rest of the first call
continues executing normally. That is what surprised me.
[snip] 

Martin,

then you should be surprised that message based systems work at all - stuff
like XWin, and (yes ;-) even Windoze work exactly like this. Thanks heaven
that language inventors allow functions to continue after they call
others... Maybe you mixed this up with gotos, these never return. Thanks to
Andi Gutman and Zeev Suraski that there's no goto in PHP *smile*


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



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



Re: [PHP] What's wrong with this code??

2003-05-31 Thread Ernest E Vogelsinger
At 01:08 30.04.2003, Beauford said:
[snip]
if ($mo == 06 and $dy  01 and $dy  09) { $wd = 8; }
if ($mo == 06 and $dy  08) { $wd = 9; }
[snip] 

The problem is your notation. If you had written

if ($mo == 6 and $dy  1 and $dy  9) { $wd = 8; }
if ($mo == 6 and $dy  8) { $wd = 9; }

your logic would still look a bit clumsy but work as you intend.

Why? Prefixing a number with a zero makes the intepreter believe you're
using octal numbers. Oczal numbers range from 00 to 07, the decimal number
8 would be 010 in octal notation. Your code, translated in decimal for
better understanding, is seen by the compiler as

if ($mo == 6 and $dy  1 and $dy  2) { $wd = 8; }
if ($mo == 6 and $dy  0) { $wd = 9; }

(08 = decimal 0, 09 = decimal 1). In this case your last statement will
trigger for _any_ day in June.


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



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



Re: [PHP] Function result is an array

2003-05-31 Thread Ernest E Vogelsinger
 Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



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



Re: [PHP] Getting the parsing time of a script

2003-05-31 Thread Ernest E Vogelsinger
At 12:39 31.05.2003, Bix said:
[snip]
Is there any way getting the time taken to parse a script?

IE:

This page took 0.13 seconds to generate.

Is it a predefined variable anywhere?
[snip] 

$start = microtime();
for ($i = 0; $i  1; ++$i)
$n = getdate(time());
$end = microtime();
list($s0, $s1) = explode(' ', $start);
list($e0, $e1) = explode(' ', $end);
echo sprintf('hrThis page took %.2f seconds to generate',
($e0+$e1)-($s0+$s1));


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



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



Re: [PHP] Re: Long screen display cut short.

2003-05-31 Thread Ernest E Vogelsinger
On Fri, 30 May 2003 20:45:08 -0400 [EMAIL PROTECTED] (Floyd Baker) wrote:
[snip] 
 I have a routine that works fine on local win98 but when it runs on
 linux online, the screen output is cut short.  I have lengthened the
 30 second script time max to 45 but that made no difference at all.  
 
 Depending on the particulars, the routine stops at a certain spot.  If
 it is rerun, it stops at the very same spot again.  Putting in other
 particulars cause it to stop at a different point, further down.  It
 seems that changes which affect the number of mysql calculations, make
 some difference in the length of the screen display, but it's only a
 minor amount.  It cuts off somewhere around 4 pages.
[snip] 

I once had this effect on pages exceeding a total size of 8k when running a
test server on an asynchronoous line (ADSL, in 712kB, out 64kB). As long as
the page fits into a single IP packet (which usually equals 8kB) no
problems occur, however if more than one packet is needed to transmit the
page the webserver will only be able to send the first packet. All pages
went fine when using a synchronous connection (in == out).


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



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



Re: [PHP] PHP OOP x Procedural Performance

2003-05-30 Thread Ernest E Vogelsinger
('$ostore[$i]-a[rid] = $i', 'Write-Accessed $i object values
using direct access');
runtest('$ostore[$i]-set(rid, $i)', 'Write-Accessed $i object values
using access method');
runtest('$n = $ostore[$i]-a[rid]', 'Read-Accessed $i object values
using direct access');
runtest('$n = $ostore[$i]-access(rid)', 'Read-Accessed $i object values
using access method');
$ostore2 = arcopy($ostore);
runtest('$ostore[$i] = null', 'Deleted $i object values using store[idx] =
null');
$ostore = $ostore2;
runtest('unset($ostore[$i])', 'Deleted $i object values using
unset(store[idx])');



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



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



Re: [PHP] e-mailing with attachements

2003-05-30 Thread Ernest E Vogelsinger
At 23:20 29.05.2003, Artoo Smith said:
[snip]
How do you send attachments when sending e-mail uisng the mail() command?
[snip] 

If you want to use the builtin mail() function you gotta construct the
complete MIME compliant message, including all headers, yourself. For more
information on MIME you should consult RFC822.

Do yourself a favour and check out the relevant PEAR classes (Mail/Mime and
Mail). http://pear.php.net/packages.php?catpid=14catname=Mail. Performs
just great ;-)


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



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



Re: [PHP] Array conversion

2003-05-30 Thread Ernest E Vogelsinger
At 01:38 30.05.2003, John Wulff said:
[snip]
I'm new to working with complex arrays/objects and need a little help.
Below is the array I need to convert to a different type of array.  The
begin what i have section is data I've succesfully mined from an XML file.
The data labeled desired output is how I need the data to be formatted.
How do I do this?
[snip]

$result = array();
while (list($key, $object) = each($whatihavelist)) {
 $result[] = array($object-name,
   $object-stocks,
   $object-bonds,
   $object-mutual,
   $object-insurance,
   $object-other);
}

But why would you want to skip your nicely named, easily readable objects
in favour of sequentially numbered arrays?

Just wondering...

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



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



Re: [PHP] is register globals off ready for prime time

2003-04-04 Thread Ernest E Vogelsinger
At 09:51 04.04.2003, Ray Todd Stevens said:
[snip]
Working on a project where we have an off shore developer.   We 
are runnig 4.3 and have turned register globals off.  He says that 
this option is not ready for production use and breaks php internally.  
I have never heard this before.   Has anyone heard this, or 
experienced this.
[snip] 

Maybe it breaks _his_ code, but it is off by default since I believe 4.1.0,
and IMHO _should_ remain off at all times. Too easy to inject into your
code as to MHO.#

Either this guy is trying to deceive his own weak code, or he doesn't have
a clue of how PHP works. I'd reconsider hiring such a developer.


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



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



Re: [PHP] Quick Sessions ?

2003-04-04 Thread Ernest E Vogelsinger
At 22:18 04.04.2003, Anthony said:
[snip]
yes, it parses PHP in html files.  The php code works.  I just loose the
session data when going from files in different folders.
[snip] 

Different folders, or different hostnames?

PHP's ability to automatically add the SID to href's, as well as cookies,
are limited to the same hostname.

Example:

www.myhost.com = /html/myhost/www/
www.myotherhost.com = /html/myhost/www/

These two couldn't share the same session, even if they reference the same
physical directory.


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



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



Re: [PHP] Includes confusion

2003-04-04 Thread Ernest E Vogelsinger
At 22:24 04.04.2003, Mike Tuller said:
[snip]
fine except inside functions. So if I have the following:

include /Library/WebServer/includes/database_connection.inc;

function list_search_results()
{
   // my code that lists search results
}

The functions returns an error, but if I do this:


function list_search_results()
{
   include /Library/WebServer/includes/database_connection.inc;
   // my code that lists search results
}

Everything works fine. Shouldn't the function be able to use the 
include file when it is declared outside the function?
[snip] 

This depends on the contents of your library. If you have it included
within the function, all variables and data structures created within the
included file are within the function's scope. If included outside, they're
on a global scope - you would need to use either the $GLOBAL superglobal
array, or to declare them being global within the function that uses them.


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



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



Re: [PHP] Quick Sessions ?

2003-04-04 Thread Ernest E Vogelsinger
At 22:38 04.04.2003, Anthony said:
[snip]
nope, same host I actually call the file by sending this :
header(Location: ../index.htm);
and I loose the session.
[snip] 

You've disabled cookies, either in your browser, or in php.ini completely
(for sessions, that is). Make your redirection like this:

header('Location: ../index.htm' . (SID ? '?' . SID : null));

I assume that your setup has htm files parsed by PHP. Otherwise - where
should the session data go to if you're redirecting to plain html?


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



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



Re: [PHP] Usort

2003-04-03 Thread Ernest E Vogelsinger
At 23:53 03.04.2003, Jonathan Pitcher said:
[snip]
This email is long I apologize for that.  It is my code and then what 
it returns and what I am wanting it to return.  I don't think I 
understand how USORT works or even if I am using the right function for 
what I am looking for.
[snip] 

The compare callback is expected to return anything  0 if the first value
is less than the second (should sort _before_), 0 if they are identical,
and  0 if the first value is greater than the second (should sort _after_).

Taking this, your comparison callback directs PHP this way:

if ($A[STARTDATE]  $B[STARTDATE]) { return 4; } 
if $A starts before $B, $A is greater (after $B).
if both start dates are equal, or $B starts before $A, continue.

else if ($A[STARTTIME]  $B[STARTTIME]) { return 3; } 
if $A starts before $B, $A is greater (after $B).
if both start times are equal, or $B starts before $A, continue.

else if ($A[ENDDATE]  $B[ENDDATE]) { return 2; } 
if $A ends after $B, $A is greater (after $B).
if both end dates are equal, or $A ends before $B, continue.

else if ($A[ENDTIME]  $B[ENDTIME]) { return 1; } 
if $A ends after $B, $A is greater (after $B).
if both end times are equal, or $A ends before $B, continue.

else if ($A[STARTDATE]  $B[STARTDATE]) { return -4; } 
if $A starts after $B, $A is less (before $B).
if both start dates are equal, continue.

else if ($A[STARTIME]  $B[STARTTIME]) { return -3; } 
if $A starts after $B, $A is less (before $B).
if both start times are equal, continue.

else if ($A[ENDDATE]  $B[ENDDATE]) { return -2; } 
if $A ends before $B, $A is less (before $B).
if both end dates are equal, continue.

else if ($A[ENDTIME]  $B[ENDTIME]) { return -1; } 
if $A ends before $B, $A is less (before $B).
if both end times are equal, continue.

else { return 0; }
they are identical.

I believe you see where the problem is. You may express your comparison in
a shorter and possibly clearer form like this (not tested but looks as if
it should work):

if ($A['STARTDATE']  $B['STARTDATE']) return -1; // a starts before B
elseif ($A['STARTDATE'] == $B['STARTDATE']) { // starts at the
same day
if ($A['STARTTIME']  $B['STARTTIME']) return -1; // a starts before B
elseif ($A['STARTTIME'] == $B['STARTTIME']) { // same start day
and time
// here both courses start at the same day/time,
// so we need to sort them by enddate/time
if ($A['ENDDATE']  $B['ENDDATE']) return -1; // a ends before B
elseif ($A['ENDDATE'] == $B['ENDDATE']) { // ends at the
same day
if ($A['ENDTIME']  $B['ENDTIME']) return -1; // a ends before B
elseif ($A['ENDTIME'] == $B['ENDTIME']) { // same end day
and time
// identical
return 0;
}
}
}
}
// we've tested all possibilities for A being less or equal to B
// so there's only one more choice left - A is greater :)
return 1;



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



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



Re: [PHP] directory size?

2003-04-03 Thread Ernest E Vogelsinger
At 00:40 04.04.2003, Mantas Kriauciunas said:
[snip]
Hey
I looked up in the manual but found only 
Disk_total_space
Disk_free_space

Is there anything like total_space for directory?
Or I will have to think of something else?
Like counting every file size and adding it to total.
But if there is like 1000 files with directories in the main directory.
It will take time to count files from all the directories and output
total size of the main directory.
[snip] 

In case you're on Linux, and may run externals, you could
du -s . (prints kilobytes)
du -s -b (prints bytes)

list($dusage, $dir) = explode(' ', `du -s -b .`);
echo sprintf('The current directory has %d kB (%d bytes)', $dusage / 1024,
$dusage);


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



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



Re: [PHP] REPLY NEEDED

2003-04-03 Thread Ernest E Vogelsinger
At 12:28 04.04.2003, PATRICK KOFI said:
[snip]
STRICTLY CONFIDENTIAL

WE ARE MEMBERS OF A SPECIAL COMMITTEE FOR BUDGET AND PLANNING OF THE 
NIGERIAN NATIONAL PETROLEUM CORPORATION (NNPC). THIS COMMITTEE IS 
[snip] 

Oh yes, sure, thank you. In case you need some interactive system to apply
for your incredible funds to be given away I'll make you a special price of
only 10% of your amount, which would make up for only 3.15M USD. This price
includes everything from website design to interactive stuff, e.g. a
chatroom for your partners.

All prices excl. VAT, of course. Additional National Fees may apply.

Just drop me a note...

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



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



Re: [PHP] Problem with PHP and MySQl after install

2003-04-03 Thread Ernest E Vogelsinger
At 16:58 03.04.2003, Don spoke out and said:
[snip]
Further to this point, I've just read that RedHat installed PHP RPM's do not
come with MySQL support.  Now I've d/l the latest stable version form
php.net, version 4.3.1 but I still cannot get MySQL support after compiling
and installing.

So..., how does one remove every trace of a PHP install; I want to start
over from scratch?  I've alrweady upgraded the MySQL package to version
4.0.12.
[snip] 

After recompile make sure Apache uses the module you have just compiled.
Have a look at phpinvo() and check the build date to see if it's using the
very last buld.


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


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



Re: [PHP] Problem with PHP and MySQl after install

2003-04-03 Thread Ernest E Vogelsinger
At 17:09 03.04.2003, Don spoke out and said:
[snip]
The expected MySQL section is not even listed in the phpinfo() page.  This
would explain my undefined function errors when attempting MySQL
functions.  What I can't figure out is why MySQL is not being recognized by
PHP.
[snip] 

I believe it's a directory mismatch between your mysql build and php build.
Usually the mysql build is either located in /usr or /usr/local (check for
directories /usr/include/mysql and /usr/lib/mysql), you need to specify the
correct directory when configuring php.

The next issue may be if you have multipls PHP versions (from RPM, or from
your own builds) on your system - check which version Apache is using.
Check your httpd.conf what installation it uses.


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


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



Re: [PHP] 4.3.1 sessions not expiring / garbage collection not working

2003-04-03 Thread Ernest E Vogelsinger
At 23:25 03.04.2003, Barry Gould said:
[snip]
Following some documentation I found somewhere on php.net, I have the 
permissions on /tmp/php equal to 310:
 ls -l /tmp
d-wx--x---2 apache   apache  17408 Apr  3 11:14 php

Check the umask of the apache process - it should be either 022 or 002,
allowing rwx for apache (022), or for apache and the apache group (002).

There are hundreds of files in there; many are over 1 week old.

I've just tried changing the permissions to 770 (drwxrwx---) and restarting 
apache; it doesn't seem to be making any difference.

Check the permissions on the files too, they should be -rw-rw---, or
-rw--, at least (best...)


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



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



Re: [PHP] Help needed

2003-04-01 Thread Ernest E Vogelsinger
At 16:27 01.04.2003, Andy spoke out and said:
[snip]
Hi Clint
OK hope this is not too much and there are likely to be more errors in it.
Thank you
Andy
[snip] 

At the line 
if ($num == 1)  // login name was found{
you have the curly bracket after the comment slashes - this is
diesregarded. Put it before the comment slashes.

At the line 
if ($num2  0) // password is correct  {
you have the curly bracket after the comment slashes - this is
diesregarded. Put it before the comment slashes.

After this construct
$message_new = $phone is not a valid phone number.
Please try again.;
include(login_form.inc);
exit();
you have a closing curly brace that doesn't belong here. Remove it.


Now your code should run without errors (syntax errors, that is)

Hint: You should make a habit of using a more clear indentation (if your
code is actually as it is in the mail). A single column indentation is not
enough to make block levels clear at the first sight. You better use 4 or 8
columns indentation width.


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


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



Re: [PHP] Help needed

2003-04-01 Thread Ernest E Vogelsinger
At 17:17 01.04.2003, Andy spoke out and said:
[snip]
Thank you Ernest

I am a little confused with the closing curly bracket after
$message_new = $phone is not a valid phone number etc

which one should i delete?
}
  if (!ereg(^[0-9)(xX -]{7,20}$,$phone))
{
unset($do);
$message_new = $phone is not a valid phone number.
Please try again.;
include(login_form.inc);
exit();

directly here after the exit(); line.


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


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



RE: [PHP] Re: Internet Explorer toolbar

2003-03-28 Thread Ernest E Vogelsinger
At 09:35 28.03.2003, Niklas Lampén said:
[snip]
Heh, I think this kind of idiotism and hair splitting is fun for a
change. :)
I personnally like this in this php-list that you can ask allmost
anything and get a desent answer in a short perioid of time. Lets keep
it that way, even if it takes us sometimes to javascript or some other
OT. :)
[snip] 

Ask anything? Really?

Well then - how can I get rich quick, do I need to use JavaScript or can it
be done with PHP?

(sorry couldn't resist...)

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



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



RE: [PHP] Passing data between the web to an Intranet

2003-03-27 Thread Ernest E Vogelsinger
Here's some ideas how I'd go for something like that. I'd have some PHP on
the externally hosted website, and some PHP on the Intranet/CRM-DB server.

At 08:39 27.03.2003, Steve Jackson said:
[snip]
gathering tool. Basically what I'll need to set-up is some sort of
system which:
1) Validates user input from the web (php)

Should be done on the external website box.

2) Sends the information to the external website DB for future customer
login authentication (php mysqlupdate/insert)

Same thing here - PHP on the external box.

3) Sends the information to our internal website DB (Intranet server)
(email or replication?) 

A PHP form residing on the internal box to receive POSTed data from the
external box. The external box would use cURL to post aony content that
needs to go internal.

4) Flags our people here when a new prospect arrives (phpemail)
5) Full front end system for the prospect details etc (Intranet server).
(php/mysql)

Both internally, PHP intranet style.

Using this approach you have full control over what goes into the internal
DB; much better for this task IMHO than replicating a complete DB.

Of course you need to make sure that only the external webbox can post to
the Intranet server, the level of authorization depends on your security
considerations and the network layout. 

If the Intranet host only has a private IP (192.168.*, or 10.*) but can be
reached by the external box via secondary interface this aint really an
issue since it can't be reached from the outside. If the Intranet box
_could_ be reached from the outside I'd recommend to run the receiving form
on an SSL interface, the external box using a client certificate to
authenticate itself. AFAIK this can be done with cURL.

HTH,

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



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



Re: [PHP] What am I not understanding about $GLOBALS['myvar'] vs global $myvar?

2003-03-27 Thread Ernest E Vogelsinger
At 09:24 27.03.2003, Marek Kilimajer said:
[snip]
echo GLOBALS['$key'] = $valuebr\n;
is right because $key is in double quotes (the outermost qoutes)
[snip] 

...almost... the array deref should be in curly quotes then:

echo {GLOBALS['$key']} = $valuebr\n;


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



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



Re: [PHP] What am I not understanding about $GLOBALS['myvar'] vs global $myvar?

2003-03-27 Thread Ernest E Vogelsinger
At 09:46 27.03.2003, Marek Kilimajer said:
[snip]
there is no $ in front of GLOBALS ;)
[snip] 

right you are - I noticed it as soon as the message was out... sometimes
one's too fast hitting the send button ;-)


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



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



Re: [PHP] version

2003-03-27 Thread Ernest E Vogelsinger
At 10:01 27.03.2003, Diana Castillo said:
[snip]
How can I tell which version of php I have? I didnt see it with phpinfo()
[snip] 

phpversion()

http://www.php.net/manual/en/function.phpversion.php


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



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



RE: [PHP] Passing data between the web to an Intranet

2003-03-27 Thread Ernest E Vogelsinger
At 13:53 27.03.2003, Steve Jackson said:
[snip]
That would've been ideal.
However I asked our webhost and they want 2100+ Danish Marks (Dotserv -
tight ###! - needless to say it isn't going to happen) to configure
cURL within their PHP, can't do cron jobs either. 
[snip]

May I suggest switching ISP's - I'm offering you my server farm for half
this price ;-)

[snip]
They suggest I use wget to do the same thing, however the only way I can
think of to do that is display the submissions on a page and and somehow
parse that into SQL to insert it. Any ideas on how I can go about that?
[snip]

I have another idea - you could simply go the other way round, the intranet
box polls the external one by executing a special PHP script. This script
on the external server checks the IP (only your intranet host, rsp. the
gateway is allowed), and maybe some secret token passed to it. It then
responds by transmitting any content that needs to go into the intranet DB,
formatted in a way easy to parse by an intranet script (e.g. ini style, or
xml, whatever). On the intranet box have a cronjob running that polls once
per minute.


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



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



Re: [PHP] Secure coockie is not available as variable

2003-03-25 Thread Ernest E Vogelsinger
At 03:55 25.03.2003, Alexander Weber said:
[snip]
I send a secure cookie an it should be available as varible

setcookie(pbas_usr, $row[usr], time()+600, , , 1);

but the varable is empty. If it send the header without secure flag the
cookie works well

setcookie(pbas_usr, $row[usr], time()+600);

Is there a special way to read out secure cookies?
[snip] 

Is your script running under https?

 From the docs (http://www.php.net/manual/en/function.setcookie.php):
secure indicates that the cookie should only be transmitted over a secure
HTTPS connection. When set to 1, the cookie will only be set if a secure
connection exists. The default is 0. 

Sorry if I'm OT here but you didn't mention https in your posting.

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



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



Re: [PHP] array into another site

2003-03-25 Thread Ernest E Vogelsinger
At 11:21 25.03.2003, Justin French said:
[snip]
1. Missing an equal sign: ?=$ not ?$
window.open('view.php?arr=?=$arr;?','windo...


2. Check out serialize()
http://www.php.net/manual/en/function.serialize.php

window.open('view.php?arr=?=serialize($arr)?','windo...


3. However, this creates a URL which isn't particularly URL friendly (not
sure, but perhaps maybe not even valid -- I don't know), so


4. based on your array's size, I'd just implode() it, and then explode() it
back out on the new site:

window.open('view.php?arr=?=implode('-',$arr)?','windo...
[snip] 

In both cases (serialize, and implode) you should urlencode the results:

window.open('view.php?arr=?=urlencode(serialize($arr))?','windo...
window.open('view.php?arr=?=urlencode(implode('-',$arr))?','windo...

Should make for a valid URL then. However don't forget that passing
application data via URL could pose a security risk to your application,
depending on what the data actually represents, and how it is worked on.
Consider also that URLs have some size limit (don't have the number at hand).


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



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



Re: [PHP] timout in mail script

2003-03-25 Thread Ernest E Vogelsinger
At 12:24 25.03.2003, Wilbert Enserink spoke out and said:
[snip]
I have this script sending 1000 personalized emails. 
However when I press the start button in my browser so the script starts 
mailing I get no response for a long time from the script. Most of the time 
I don't get any response. When I retrieve all the emails I just sent (to 
myself, using 1000 aliases), I retrieve e.g. 1396 emails.

Anybody knows how this is possible? Is it possible that the script is 
adressed again by the browser, so the whole mailing process starts again?
[snip] 

 From what you've said it looks as if your script is running in an endless
loop. You may debug it by _not_ actually sending the mail, but echoing the
mail() command to the browser, together with the vital variables you need.


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


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



Re: [PHP] timout in mail script

2003-03-25 Thread Ernest E Vogelsinger
At 12:53 25.03.2003, W. Enserink spoke out and said:
[snip]
I don't think it is looping, cause I also tried it with 10 and 100 and 250
emails. No problems there...!
[snip] 

Well if you report receiving 1300+ mails when the script is supposed to
send 1000 there's certainly something wrong ;-)

Try to mark the first message so you can possibly see where it's about to
start over again. Then hook in here with your debug efforts to see as to
why it starts over.


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


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



Re: [PHP] Finding out which file is retrieved over HTTP

2003-03-25 Thread Ernest E Vogelsinger
At 13:08 25.03.2003, Jens Lehmann spoke out and said:
[snip]
A thing which seemed a bit confusing to me is that if I open a 
non-existing website (fopen('http://www.amazon.de/nonsensestuff')) I 
always get an error message Success. It's the same thing if I use 
file(). The manual explains that fopen() returns false if the website 
could not be opened, that's why I don't know why this error message 
appears? Besides this Success-message is surely a very bad error 
message. I use PHP 4.2.3.
[snip] 

If the website doesn't exist, but the web SERVER does, it will return
something, usually a 404-message. fopen() doesn't check for HTTP result
codes, it just opens the stream and retuirns whatever gets sent (with the
single exception of omitting the headers, but without looking).

So in fact an fopen() to a non-existing page will be seen as successful by
fopen(). This is by design and afaik documented somewhere.

To actually check on the HTTP status codes you need to run your own, either
using cURL, or by doing your own stuff using fsockopen().


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


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



Re: [PHP] Finding out which file is retrieved over HTTP

2003-03-25 Thread Ernest E Vogelsinger
At 20:48 25.03.2003, Jens Lehmann spoke out and said:
[snip]
 To actually check on the HTTP status codes you need to run your own, either
 using cURL, or by doing your own stuff using fsockopen().

I tried using fsockopen(), but still experience a problem, I want to use 
the following script to retrieve both, the headers and the actual file:

You need to transmit the Host: header so the web server has a chance to
know which virtual host you want to reach. Ideally you would also tell the
server what type of content you can handle (see below). Also note that the
correct line ending for MIME headers is always CRLF (\r\n):

$hostname = 'www.example.com';
$file = '/index.php';

$ip = gethostbyname($hostname);
$fp = fsockopen($ip, 80, $errno, $errstr);
if ($fp)
{
fputs( $fp, GET .$file. HTTP/1.0\r\n .
 Host: $hostname\r\n .
 Accept: text/html\r\n .
 Accept: text/plain\r\n\r\n );

$src = '';
while (!feof ($fp))
$src .= fgets($fp, 4096);
fclose ($fp);

}

This will get you the whole page, including all headers.


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


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



Re: [PHP] is this correct? regular expressions

2003-03-25 Thread Ernest E Vogelsinger
At 23:22 25.03.2003, Jay Paulson said:
[snip]
just trying to say if $phone isn't all numbers set it to all zeros.. so is 
that right? cause i can't seem to get it to work.

   if (!ereg(^[0-9]$,$phone)) {
$phone = 00;
   }

thanks!
[snip] 

This is if $phone is anything else than a single digit. You need to add
either a plus or an asterisk after the closing bracket to denote multiple
instances of the character set:
  if (!ereg(^[0-9]*$,$phone)) {

You could also check if anything _not_ being a number exists within $phone:
  if (ereg([^0-9],$phone)) {



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



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



Re: [PHP] formatting textarea input on output

2003-03-25 Thread Ernest E Vogelsinger
At 23:30 25.03.2003, Charles Kline said:
[snip]
i have a textarea in a form which gets inserted into a table in my 
database (mySQL). When displaying this text back to the screen, how do 
i retain the line breaks etc. that were in the original input?
[snip] 

nl2br()


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



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



Re: [PHP] Odd Parse Error

2003-03-24 Thread Ernest E Vogelsinger
At 11:24 24.03.2003, shaun said:
[snip]
Using the following code i get a parse error for line 137, and i cant see
anything wrong with it, i would be very grateful for someones help here!

if ($num  0){
  if ($values[$i] == 0){
$query = DELETE FROM WMS_Allocatations WHERE User_ID =
'.$_GET[user_id].' AND Project_ID = '.$fields[$i].';
  }
} else {
  if ($values{$i] != 0){ //line 137
$query = INSERT INTO WMS_Allocatations (User_ID, Project_ID) VALUES
('.$_GET[user_id].', '.$fields[$i].');
  }
}
[snip] 

Shouldn't that be

  if ($values[$i] != 0){ //line 137

Note the curly vs. square brackets in $values



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



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



Re: [PHP] Quick snippet to convert text files to unix based line endings

2003-03-24 Thread Ernest E Vogelsinger
At 20:36 24.03.2003, Mike Zornek said:
[snip]
I'm writing a little script that is parcing a excel generated csv file.
While all the users will be using windows I'd like to make it safe for all
file types.

Any one have a quick snippet that I could use to convert a temp file to use
all \n based line endings for consistency?
[snip] 

$in = array(/\n\r/, /\r\n/, /\r/);
$out = array(\n, \n, \n);
$cleaned = preg_replace($in, $out, $dirty);


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



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



Re: [PHP] mail() Bcc:

2003-03-24 Thread Ernest E Vogelsinger
At 23:51 24.03.2003, CPT John W. Holmes said:
[snip]
If I'm wrong, someone please let me know, but some servers may only accept
Bcc: instead of bcc: or BCC:, etc... ?? Does anyone know if that matters? If
it does, is it only dependant upon the sending SMTP server and not any
servers the message is sent through or the receiving server?
[snip] 

AFAIK the Bcc: address list is never found in the MIME headers at it is a
list of _blind_ addresses - i.e. addresses that do _not_ show up in the
messages, but whom the
mail is delvered to as well. They do show up in the SMTP envelope, as RCPT
TO: addresses during SMTP conversation.

This is an example of how such a conversation could look like:

S: 220 mail.mydomain.com; ESMTP Tue, Mar 25 2003, 00:49:12
C: HELO bluebear.mydomain.com
S: 250 mail.mydomain.com Hello bluebear.mydomain.com Pleased to meet you
C: MAIL FROM: [EMAIL PROTECTED]
S: 250 2.1.0 [EMAIL PROTECTED] Sender ok
C: RCPT TO: [EMAIL PROTECTED]
S: 250 2.1.5 [EMAIL PROTECTED] Recipient ok
C: RCPT TO: [EMAIL PROTECTED]
S: 250 2.1.5 [EMAIL PROTECTED] Recipient ok
C: DATA
S: 354 Enter mail, end with . on a line by itself
C: From: [EMAIL PROTECTED]
C: To: [EMAIL PROTECTED]
C: Subject: Test message
C:
C: Dear Saundra, this is only a test, please disregard.
C: .
S: 250 2.0.0 h2ONqQm26855 Message accepted for delivery
C: QUIT
S: 221 2.0.0 mail.mydomain.com closing connection

You see the main recipient is listed in the MIME header (To:), but the
Bcc recipient ([EMAIL PROTECTED]) is not; it only shows up during the SMTP
conversation (the envelope part).

AFAIK it's a feature of the mail client; be it an email program or a mailer
class.


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



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



Re: [PHP] more issues with variales within strings

2003-03-23 Thread Ernest E Vogelsinger
At 04:55 23.03.2003, Dan Rossi said:
[snip]
hi guys , i am sure this worked on an earlier version of php,


'NOT_ALLOWED_EXTENSION' = Not Allowed File Extension, the following
filetypes are allowed : ($this-type)\n, this is inside an array

then i used to do

$this-extract_filetypes($this-imgtypes);
$this-error_codes[NOT_ALLOWED_EXTENSION];

[snip] 

If you put $this-type in curly quotes it will work:

$emsg = array('NOT_ALLOWED_EXTENSION' = Not Allowed File Extension, the
following filetypes are allowed : ({$this-type})\n,
);


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



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



Re: [PHP] Test the server.

2003-03-22 Thread Ernest E Vogelsinger
At 21:59 22.03.2003, Vincent M. said:
[snip]
Yes I know but my aim is to make a php script which checks automaticly 
if the php and the shell functions I need are available.
[snip] 

You can use function_exists() and class_exists() o test against needed
implementations. Some extensions may have functions returning the installed
version as well.


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



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



Re: [PHP] array insert help

2003-03-22 Thread Ernest E Vogelsinger
At 20:59 22.03.2003, Jason Dulberg said:
[snip]
My problem is that I'm not sure how to set up the array for the fields and
how to take the input fields and insert them. Do I need a multidimensional
array for this?

ie.
input type=text name=address[address][]
input type=text name=address[city][]

How would I decode that to create an insert statement??
[snip] 

I believe your example would work. However since you have a definite number
of adresses you could add the index directly, as here:

bHome Address:/bbr /
input type=text name=address[address][0]
input type=text name=address[city][0]

bWork Address:/bbr /
input type=text name=address[address][1]
input type=text name=address[city][1]

When the form is received you will have an array for adress that looks like
this:

$_REQUEST['address'] = array(
'address' = array(0 = 'home address', 1 = 'work address'),
'city' = array(0 = 'home city', 1 = 'work city'));

To insert the home address you'd create an SQL statement like this:

for($i = 0; $i = $number_of_addresses; ++$i) {
$sql = insert into address(adress, city) values ( .
{$_REQUEST['address']['address'][$i]}, .
{$_REQUEST['address']['city'][$i]});
// more code
}

Hope this helps,

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



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



RE: [PHP] array insert help

2003-03-22 Thread Ernest E Vogelsinger
At 22:24 22.03.2003, Jason Dulberg said:
[snip]
Thanks for your help...

I tried the code as you suggested however when I attempted to echo the
variables for testing but nothing showed.

for($i = 0; $i = 1; ++$i) {
   echo paddress.$_POST['address']['address'][$i];
   echo brcity.$_POST['address']['city'][$i];
}
[snip] 

Jason,

I tried the following and it worked:

form method=post
bHome Address:/bbr /
input type=text name=address[address][0] value=?php echo
$_POST['address']['address'][0]; ?
input type=text name=address[city][0] value=?php echo
$_POST['address']['city'][0]; ?
br /
bWork Address:/bbr /
input type=text name=address[address][1] value=?php echo
$_POST['address']['address'][1]; ?
input type=text name=address[city][1] value=?php echo
$_POST['address']['city'][1]; ?
br /
input type=submit
/form
?php

for($i = 0; $i = 1; ++$i) {
   echo paddress $i: .$_POST['address']['address'][$i];
   echo brcity $i: .$_POST['address']['city'][$i];
}



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



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



Re: [PHP] $siteGalleryUserPath when it is made by PHP dose not give 0777 access for $destination to be made.

2003-03-21 Thread Ernest E Vogelsinger
At 04:43 21.03.2003, Philip J. Newman said:
[snip]
MY ERROR:

Warning: mkdir(/home/newmanpj/public_html/galleries/philip/20030320223553) 
[function.mkdir]: Permission denied in 
/home/crushme/public_html/siteadmin/upload_set_step3.php on line 72

MY PROBLEM:

$siteGalleryUserPath when it is made by PHP dose not give 0777 access for 
$destination to be made.
[snip] 

The access mode of a directory created by any webserver-run application is
dictated by the umask of the webserver process which is usually 022 or 002,
giving rw/access only to the owner (the webserver user), or to the owner
and owner group.

The error you are receiving points to a different situation though - it
seems that either the directory where your script wants to create a
subdirectory in doesn't grant write permission to the webserver user, or
the subdirectory below (...ies/philips) does not (yet) exist.


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



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



Re: [PHP] test for associative or numerically indexed array

2003-03-20 Thread Ernest E Vogelsinger
At 08:52 20.03.2003, cpaul said:
[snip]
ok thanks - that makes sense.  sort of doesn't solve my problem, because
if my function receives an enumerated array, i want it to treat it as an
associative array, using the value as the key.
[snip] 

What would be the value then?

If I get you correctly, you would treat an array that comes like
[0] = entry 0
[1] = entry 1
[2] = entry 2
as
[entry 0] = ??
[entry 1] = ??
[entry 2] = ??

What happens when there are duplicate values in the source array? You will
loose entries on duplicate values.

If I got you right here have a look at array_flip()
(http://www.php.net/manual/en/function.array-flip.php) to exchange array sides.

You can't tell with absolute certainty if an array is enumerated, or built
as associative array. Take this example:
$a = array('one','two','three');
$b = array(); $b[0] = 'one'; $b[1] = 'two'; $b[2] = 'three';
$c = array(0 = 'one', 1 = 'two', 2 = 'three');

Which one would you believe is enumerated, and which one is associative?

What you can do is walk the array keys and check if there is at least a
single non-numeric key. If you found one the array is associative. If you
found none it may be likely that the array is enumerated, but you can't be
sure in a general way, except your application is designed in a way that
uses always non-numeric keys for associative arrays.



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



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



Re: [PHP] test for associative or numerically indexed array

2003-03-20 Thread Ernest E Vogelsinger
At 09:57 20.03.2003, cpaul said:
[snip]
 as associative array. Take this example:
 $a = array('one','two','three');
 $b = array(); $b[0] = 'one'; $b[1] = 'two'; $b[2] = 'three';
 $c = array(0 = 'one', 1 = 'two', 2 = 'three');
 
 Which one would you believe is enumerated, and which one is associative?

they'd all be enumerated, except perhaps $c -- but i've grown :) and now
understand that $c winds up being an enumerated array.. or is it?

Well, all these 3 arrays are _exactly_ the same. If you print_r() them
you'd see
Array {
0 = one
1 = two
2 = three
}
The key to this issue seems to be understanding that it makes no difference
how the array keys are constructed... an array is an association of key to
value, being a hash  always if you want to see it that way.

in my code

 $q = mysql_query ( SELECT production_id, title FROM productions ORDER 
BY title; );
 $this-all_productions[] = ;
 while ( $row = mysql_fetch_array( $q ) ) {  
   $this-all_productions[$row[production_id]] = $row[title];
 }

the array is kept in order when i foreach the array - wouldn't they sort
themselves into 0,1,2,3,4,5,etc if my while loop was populating an 
enumerated array?   or are all arrays in php actually a keyed hash?

You're chosing your own keys here - so this makes a perfect associative
array, even if the keys ($row['production_id']) would be a sequenced
number. If you would just add the titles up ($this-all_productions[] =
$row['title']), PHP would choose an index key for you - the most general
thing it can do is to enumerate it. Basically what it does is
 array[count(array)] = new_element

So much for the theory - what are you really trying to achieve? Maybe
there's something you can redesign so you're not relying on the fact if an
array is enumerated or not.


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



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



Re: [PHP] Changing pages on another PC remotely?

2003-03-20 Thread Ernest E Vogelsinger
At 12:49 20.03.2003, Denis L. Menezes spoke out and said:
[snip]
This is a difficult one, but I need to try for my project.

Can I have make a script where, pressing a button on one page in one PC 
causes a webpage change on another PC which is also on the internet?
[snip] 

This dependes primarily on the application the _other_ PC has running.

Basically the answer to your question is yes if you are in control of the
website the _other_ PC just visits. This website needs some JavaScript to
refresh its content - that's where you can come in.

I've answered a similar question a week ago that you might find in the
archives - look for OT Inactivity Timeout. Should give you a starter.


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


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



Re: [PHP] internally stored binary image

2003-03-20 Thread Ernest E Vogelsinger
At 15:57 20.03.2003, [EMAIL PROTECTED] spoke out and said:
[snip]
In order to distribute a single script I would like to store a small
image internally. Is this at all possible with PHP? How would I go about
it? Please feel free to rtfm me to the relevant sections.
[snip] 

You could make some script to retrieve the hex values of the image byte by
byte, then create a source file like
$imgdata = '\xff\x19\x00\x12   etc...;

Then when you're about to send the image simply transmit the correct
header() and echo out the data.

This little sample works just perfectly:


// use one of your files here, of course...
$file = 'images/dart.gif';
$hf = fopen($file, 'r') or die(Can't open $file for reading);
$bin = fread($hf, filesize($file));
fclose($hf);
$asc = '$img_data = ';
for ($i = 0, $len = strlen($bin); $i  $len; ++$i) {
if ($i  !($i % 16))
$asc .= \ .\n\t\;
$asc .= '\\x' . bin2hex(substr($bin, $i, 1));
}
$asc .= ';';

// $asc now contains the hex-coded binary file.
// Example (a real gif - try it)
$img_data =
\x47\x49\x46\x38\x39\x61\x20\x00\x20\x00\xa2\xff\x00\x00\x00\x00 .
\xff\x00\x00\xff\xff\x00\x00\x00\xff\xc0\xc0\xc0\x00\x00\x00\x00 .
\x00\x00\x00\x00\x00\x21\xf9\x04\x01\x00\x00\x04\x00\x2c\x00\x00 .
\x00\x00\x20\x00\x20\x00\x40\x03\xae\x48\xba\xac\xf0\x10\x34\x36 .
\x06\x83\x21\x87\xc8\xa3\xd0\xd0\x82\x65\xe3\xd6\x81\x0f\x2a\x89 .
\x25\x79\x6a\xe6\x33\xb1\x29\x6c\xab\x80\xd0\x94\x11\x8c\x7d\x31 .
\x80\xca\x51\x0b\xde\x70\xc3\x19\xa1\xc3\x8c\x28\x67\xcd\xe8\xa2 .
\x52\xb9\xb4\x82\x57\x41\xc8\x2a\x74\x15\x6f\xda\xe2\x96\x27\x7e .
\x0c\x04\x5a\xd5\x90\xfc\x6d\xf5\xbc\x34\x5f\xd4\x2d\x83\x5e\x8f .
\xc1\xe7\x93\xa9\xef\x2f\xe7\x75\x53\x54\x76\x6f\x36\x1d\x0a\x02 .
\x55\x3b\x77\x78\x26\x5a\x84\x5d\x5e\x4d\x19\x1f\x4e\x71\x38\x91 .
\x5e\x69\x49\x7f\x91\x8c\x94\x31\x49\x6c\x72\x39\x40\x5e\x6b\x65 .
\x9e\x66\x03\xa9\xa8\xaa\x99\x1c\xa4\xa2\xad\x8d\xa1\x70\x44\xb0 .
\x85\x92\xb9\x2b\xb8\xbc\x93\x38\x90\xb5\x86\x5b\x7b\xb1\x37\x87 .
\x7e\x34\x73\xca\xcd\xce\x09\x00\x3b; 

// Now write the stuff to a file
$hf = fopen($file.asc, 'w') or die(Can't open $file.asc for writing);
fwrite($hf, $asc);
fclose($hf);

// Here you may either include the file, or copy/paste its contents into
your own code.
// The next lines are just to test the stuff - adjust the Content-Type
header to your needs:

header('Content-Type: image/gif');
eval($asc);  // this will render the binary content into $img_data
echo $img_data;  // send it
exit;// and voila


Note that reading the file is only needed once as a tool to create the
ascii version of the binary file.


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


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



RE: [PHP] credit card validations..

2003-03-20 Thread Ernest E Vogelsinger
At 20:00 20.03.2003, Edward Peloke spoke out and said:
[snip]
Forgive my ignorance of the subject but would this just say the card was
valid?  How do you go about actually charging the users card and get the
funds?
[snip] 

To be able to actually charge a CC you need a contract with a clearing
house (FirePay,  for example). There's no standard to it; every
clearinghouse I've ever dealt with uses its own protocol.

Generally this involves transmitting data via POST and receiving
(asynchronously) transaction data via SSL. You might consider using cURL
for this kind of stuff; most of them have working examples in Java, PHP,
ASP, etc.


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


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



RE: [PHP] I.P. range authentication

2003-03-19 Thread Ernest E Vogelsinger
At 02:51 19.03.2003, John W. Holmes said:
[snip]
 $abytes = explode('.', $ip); // explode the IP string
 $ip = 0;
 foreach ($abytes as $byte) $ip = ($ip  8) + $byte;
 
 This will give you the valid numeric equivalent of the IP address.

Isn't that what ip2long() does?

Also, the man page on ip2long() has some good notes and code that may
help the OP. 

http://www.php.net/manual/en/function.ip2long.php
[snip] 

Thanks - didn't come around this function yet...


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



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



Re: [PHP] Which is quicker, if-else statements

2003-03-19 Thread Ernest E Vogelsinger
At 04:38 19.03.2003, -{ Rene Brehmer }- said:
[snip]
I'm totally lost here ... what does that mean???

Reminds me of assembler, except that assembler is more like:
0001 jnp e002 e003 0005
0002 jmp e002 e003 0008

And so on (not sure if that's fully correct ... haven't touched assembler
since '92) ...

Please ellaborate Ernest ...
[snip] 

Yup, assembler, specifically Intel x86 using the 32bit registers (I said
Intel speak before the code). The code you present must be for a
different processor that I don't know... well, haven't programmed in asm
since - wait let me think - 85? Have still some asm manuals around, but I
don't think the timing numbers are still relevant for todays caching cpu's...


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



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



Re: [PHP] Ereg sass

2003-03-18 Thread Ernest E Vogelsinger
At 10:36 18.03.2003, Jason k Larson said:
[snip]
It's seeing the - as a range identifier, escape it to get the literal hyphen.

How about this:
[a-zA-Z0-9_\-.]*

In my tests, the period didn't need to be escaped with the \.
[snip] 

The period is a regex placeholder for any character. Thus it will match a
period, but also a #, a @, and everything that's not allowed in the planned
regex.

By escaping the period you're changing the meaning from any character to
or a period (in this context) so I believe that's what you want to do.


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



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



Re: [PHP] Forced Download Using header()

2003-03-18 Thread Ernest E Vogelsinger
At 11:16 18.03.2003, Kevin Kaiser said:
[snip]
   I have a simple php download script that streams a
 non-web-accessible file
to the browser using this generally accepted method:

 header(Expires: 0);
 header(Cache-Control: private);
 header(Content-Type: application/save);
 header(Content-Length: .filesize($total) );
 header(Content-Disposition: attachment; filename=.$file_Path);
 header(Content-Transfer-Encoding: binary);
 $fh = fopen($total, rb);
 fpassthru($fh);

   While it works, this is fairly useless in my situation where files
 range
from 5mb to over 100mb, because due to fpassthru() or readfile() or whatever
method used to stream the data to the recipient, the 'save as'/'open' dialog
doesn't open until the entire file has been downloaded. This is very
impractical since the user has no clue how much has been downloaded / how
much longer is left, not to mention that on very large files (~75mb) apache
will actually freeze up and become unresponsive to all users (sending cpu
usage to 100%) for nearly 10 minutes or more, assumedly because it is still
reading the file (regardless of whether the 'stop' button has been clicked
or not).

   With the last 2 lines commented out (fopen() and fpassthru()), the
 save-as
dialog opens instantly.. is there any way fopen/fpassthru() could be delayed
until after the user chooses to open or save the file ? How would you guys
go about handling large file downloads while keeping the files themselves
non-web-accessible (aka not a direct link/redirector)?
[snip] 

Disclaimer - this is just an idea, I've never dealt with downloading that
big files.

If apache freezes because the file it's reading is too big to be handled
I'd suggest to try a chunked approach, not using fpassthrough or a single
file read. The reason is that for every system I/O the operating systems
get a chance to switch process context, and to allow cooperative multitasking.

Would go something like that:

define('CHUNKSIZE', 8192);
$fp = fopen($file, 'r') or die (Cannot open $file);

header(Expires: 0);
header(Cache-Control: private);
header(Content-Type: application/save);
header(Content-Length: .filesize($total) );
header(Content-Disposition: attachment; filename=.$file_Path);
header(Content-Transfer-Encoding: binary);
   // --
while ($buffer = fread($fp, CHUNKSIZE)) {
echo $buffer;
}
fclose($fp);

You may need to experiment with the size of the chunks to keep up an
acceptable transfer rate. If you still encounter big holdups for other
processes you might consider using usleep() every 10th chunk or so, but use
your calculator to check how that would extend the overall transmission
time. For example, for a 100MB file, going to usleep for 50 msec after each
9kb chunk would mean that your process will sleep for 1.82 hours (!!) until
the file is delivered...


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



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



RE: [PHP] Re: newbie:restricting users to change data in a textar ea

2003-03-18 Thread Ernest E Vogelsinger
At 11:42 18.03.2003, Jon Haworth said:
[snip]
... Good programmers look both ways before crossing
one-way streets.
[snip] 

I like that one. The US administration should have some good programmers
hired then, I believe.


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



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



Re: [PHP] Random array values from associative

2003-03-18 Thread Ernest E Vogelsinger
At 12:40 18.03.2003, Awlad Hussain said:
[snip]
I have an associative like array[name]=hello;
I am trying to get two random values from the array, the key name and the 
value, but using the codes below from the PHP manual i am getting the inex 
key value rather than the name.

$rand_keys = array_rand ($input, 2);
print $input[$rand_keys[0]].\n;
print $input[$rand_keys[1]].\n;

so instead of getting two random values like key=name  value=hello i am 
getting key=0 and value=hello.
[snip] 

array_rand only operates on the value side of an array. To retrieve
random keys from an associative array, use array_keys() of the assoc. array
as input rather that the assoc. array itself:

$rand_keys = array_rand (array_keys($input), 2);
print $input[$rand_keys[0]].\n;
print $input[$rand_keys[1]].\n;



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



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



Re: [PHP] Random array values from associative

2003-03-18 Thread Ernest E Vogelsinger
At 12:48 18.03.2003, Awlad Hussain said:
[snip]
Thanks for your reply, I now have only the keys but I need both keys and the
value.
[snip] 

But you can get the value if you have the keys, no?


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



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



Re: [PHP] One set of php for multiple subdomains

2003-03-18 Thread Ernest E Vogelsinger
At 23:43 17.03.2003, Radu Manole said:
[snip]
Hi guys,

I have 2 scripts located in a directory and 3 dirs with 3 subdomain.
Something like this.

/scripts
- input.php
- output.php

/user1  - subdomain user1.mysite.com
/user2  - subdomain user2.mysite.com
/user3  - subdomain user3.mysite.com

What can I do to execute the input.php script from any subdomain and get
output.php (response) in the same subdomain?
Do I need to copy the scripts directory in each subdomain dir?
[snip] 

If you're on *nix you can simply create symbolic links to the directory:

ln -s /scripts /user1/scripts
ln -s /scripts /user2/scripts
ln -s /scripts /user3/scripts

Now all 3 user directory will contain a symbolic link to the /scripts
directory, within their domain tree.


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



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



Re: [PHP] what's the best way to handle this?

2003-03-18 Thread Ernest E Vogelsinger
At 14:38 18.03.2003, Edward Peloke said:
[snip]
When a user 'registers' with our site, I want to generate their personal
webpage for them.  Currently, I have a webpage where the contents are
generated from their personal info in the db and I have a drop down to view
client pages but it is just the same page but I pass in the clientid so it
will display their data.  This is fine but I want the users to be able to
tell others..Visit my home page at www.eddiessite.com/Johnny  or something
like that...I don't want them to have to say visit my page
www.eddissite/client_pages?clientid=43  does that make sense?  Should I just
generate a folder for them with an index page that redirects then to the
clientpage with their id?
[snip] 

You could either use Apache's mod_rewrite to rewrite the URL, or use an
ErrorDocument handler to deliver the correct page.


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



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



Re: [PHP] Which is quicker, if-else statements

2003-03-18 Thread Ernest E Vogelsinger
At 21:02 18.03.2003, Liam Gibbs said:
[snip]
Is it just as quick to do:

if($r == 0) {
} else if($r != 0) {
}

than to do:

if($r == 0) {
} else {
}

The reason I like the former method is because, in a large IF-ELSE block, 
it's clear what belongs to what IF and what's going on. But does this make 
it lag? And, if so, is it really all that noticeable?
[snip] 

Noticeable? Probably not, except you're timing loops of a million or more
cycles... but it's clear that the second method needs more time (in terms
of cpu cycles) than the first one.

In Intel speak, what would a compiler translate these code examples to?

if (a == b) {} else {}
mov  eax,   {a}
cmp  eax,   {b}
jnz  L01
; the true block goes here
jmp  L02
L01:
; the false (else) block goes here
L02:

As you can see there's two memory operations and one comparison.

Your second example:
if (a == b) {} else if (a != b) {}
mov  eax,   {a}
cmp  eax,   {b}
jnz  L01
; the true block goes here
jmp  L02
L01:
mov  eax,   {a}
cmp  eax,   {b}
jz   L02
; the second block goes here
L02:

There's four memory operations, and two comparisons.

As another poster already pointed out, there's also a slight difference
comparing something to zero, or to false:

if (a == 0)
mov eax, {a}
cmp eax, 0
jnz L01

if (!a)
mov eax, {a}
or  eax, eax
jnz L01

The latter version consumes approx. half of the time (in cpu cycles)
compared to the first one.

Modern compilers will leverage the need for a to deal with these efforts.
The multi-pass optimizers usually detect situations like these and would
use the if (!a) {} else {} construct, without regard what your original
input is.

However, PHP is _not_ a compiler, it's an interpreter. It compiles code
at runtime and has not the ability to perform exhaustive optimizations
which would cost far more time than can be gained within a single
execution. Additionally there's the time needed to parse the input stream
(tokenize, add to symbol table, execute token and expression parser, etc
etc). With interpreting languages the differences will rocket skyhigh
compared to compiled executables.

Well, it's still to be measured in nanoseconds for a single instance,
thanks to modern processor power...


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



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



Re: [PHP] I.P. range authentication

2003-03-18 Thread Ernest E Vogelsinger
At 23:04 18.03.2003, Will Bown said:
[snip]
I am having trouble verifying if a user is within a specified I.P. range.
The idea is that if a user is at a library within an I.P. range like
231.55.*.* and their I.P. address is 231.55.122.226 a session would be
registered for them. See my code below. This works but only for some I.P.'s
in a range. 

Can anyone suggest a solution or resource that can help me?

$sql = select  *  from customers where ip1 =\$remote_address\ and ip2
=\$remote_address\;
$sql_result = mysql_query($sql,$connection)
 or die(Couldn't execute query. AUTO SIGN IN SELECT);

while ($row = mysql_fetch_array($sql_result)) {
 $ip1 = $row[ip1];
 $ip2 = $row[ip2];
   $fname = $row[fname];
  $lname = $row[lname];
  $institution = $row[institution];

$num = mysql_num_rows($sql_result);
$sign_in=$fname $lname $institution;

if($num0){
 session_register(sign_in);
 }
else{echo you can't see this page}
[snip] 

You need to create a number out of the dotted IP string to use them in
valid = and = comparisons. This is a valid procedure, since the IP
basically _IS_ a number, it's just written in the dotted notation to aid us
miserable human beings.

$abytes = explode('.', $ip); // explode the IP string
$ip = 0;
foreach ($abytes as $byte) $ip = ($ip  8) + $byte;

This will give you the valid numeric equivalent of the IP address.


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



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



Re: [PHP] posting values from email

2003-03-17 Thread Ernest E Vogelsinger
At 11:21 17.03.2003, Tony Burgess said:
[snip]
I have a form which gets sent as an email, the user then fills in details
using textboxes etc.
After filling in all the required fields the user hits the submit button,
this should open a new window and pass all necessary information to this
page. I have tried using both POST and GET methods for this and the GET
method works to an extent but doesn't allow me to have any hidden values. If
anyone has an alternative method then please let me know.
[snip] 

Maybe you could send some code snippets what you're trying to do, or
elaborate a bit more so we can help you. POST'ing web forms is said to
work, I've heard.


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



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



Re: [PHP] Frames

2003-03-17 Thread Ernest E Vogelsinger
At 13:29 17.03.2003, shaun said:
[snip]
I am designing a system which will have a different menu option for
different users i.e. admin/standard etc.

If I am using frames how could I change the page a user sees in the top
frame for each different type of user? I know how to do this with standard
pages, its just the frames that are pickling my brain!
[snip] 

Either reload the master frameset containing the correct hrefs, or use
JavaScript in your main pages onLoad handler to change the location of
another frame, something like that (untested):

hFrame = parent.topframe; // topframe is the name of the frame
if (hFrame) hFrame.location.href = 'otherurl';


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



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



Re: [PHP] help from experienced devr's

2003-03-17 Thread Ernest E Vogelsinger
At 00:18 18.03.2003, Dennis Gearon said:
[snip]
Simple question, only related to this forum in that all of us use 
libraries that are compressed.

I'm trying to use adodb, and I uploaded it's zipped archive to a linux 
box and gunzip won't unzip it. Says 'multiple entries'. Anyone know  how 
to upload it, short of unzipping in on a windbloze box, then ftping all 
files up?
[snip] 

on your linux box, cd to the directory containing the archive, then enter
tar -xzf {archivename}

In most cases (also for adodb) this will create a directory tree containing
the extracted distribution files in the correct layout. The directory name
is usually similar to the archive name (depends on the archive contents of
course, but in case of adodb it's adodb and a version number (I believe).


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



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



Re: [PHP] Re Sessionid

2003-03-16 Thread Ernest E Vogelsinger
At 14:20 16.03.2003, Peter Goggin said:
[snip]
Is the value returned by session_id (), called after session_star() always a
unique string?
The results of several trials gave me:
6f88d2d3fd7d0d47aea1e45087368adc
3cc2c1b299fcaa6f4fd107683d78a00c
115e8da118af1c5d88d6db1c1481077a
26dda220f9d64de593ce2f2de6b4bb6e
26dda220f9d64de593ce2f2de6b4bb6e

i.e. every time i started a new session I got a unique string, while the
string remained the sme within the same session.
[snip] 

That's exactly how it should be. The session ID is the unique key to the
session private data, and is passed between client and server either via
cookie, or via request parameter, whatever is necessary (PHP can determine
this automatically).

The key is supposed to be unique on a single server. It is derived by
calculating a random value, starting with the current systems sec/usec, and
a random number. If an external entropy source is available the resulting
ID is further randomized using this entropy. Finally it is converted to a
hex string. (If you're interested in the actual code to accomplish this,
you may find it in {php_source_directory}/ext/session.c, _php_create_id(),
and {php_source_directory}/ext/standard/lcg.c, php_combined_lcg()).


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



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



Re: [PHP] Re: str_replace

2003-03-15 Thread Ernest E Vogelsinger
At 07:23 15.03.2003, Sebastian said:
[snip]
doesn't work but also doesn't give any errors, I will try to explain what I
am trying to do:

I am trying to remove the header and footer to create a printer friendly
page with just the content, here's what my pages look like, I need to
remove header and footer when they visit: file.php?action=print

?php
include(../config.php);

if($_GET[action] == print)
{
   $header = str_replace('include($header);', '', $header);
   $footer = str_replace('include($footer);', '', $footer);
}

include($header);
?

// html

?php include($footer); ?
[snip] 

Hmm - can't work because the variable $header doesn't include the string
include($header);.

Try it this way:

?php
include(../config.php);

if($_GET[action] == print) {
  $header = null;
  $footer = null;
}

if ($header) include($header);
?

// html

?php if ($footer) include($footer); ?


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



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



Re: [PHP] can't get any string replacements to clean this

2003-03-14 Thread Ernest E Vogelsinger
At 08:43 14.03.2003, Dennis Gearon said:
[snip]
I finally got something to do it, at least, in inline code.

I couldn't figure out how to remove NULLS, anybody know? A search on:
[snip] 

I just found this thread, pardon me if I'm off topic, but something like
this should work for you. It makes use of the fact that all of the replace
functions can take arrays as input parameters.

$from = array(/(\r\n)+/, /(\n\r)+/, /(\r)+/, /[\x0..\x19]/);
$repl = array(\n, \n, \n, null);
$str_cleaned = preg_replace($from, $to, $str_uncleaned);

This construction should convert the occurrence of one or more successive
newline combinations with a single newline character, and remove control
characters at large (untested).


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



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



Re: [PHP] can't get any string replacements to clean this

2003-03-14 Thread Ernest E Vogelsinger
Correction - $to should of course read $repl :-


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



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



Re: [PHP] OT Inactivity Timeout

2003-03-14 Thread Ernest E Vogelsinger
At 17:03 14.03.2003, Luis Lebron said:
[snip]
This may be more of a javascript question than a php question. But how can I
set up an inactivity timeout that will logout a person after let's say 20
minutes of inactivity?
[snip] 

That's an interesting question - something that might be handled
server-side (which is usually a lot safer than on the client side),
supporting (javascript-based) client requests if it is still logged-in.

I have tried a quick sample and believe a scenario like this could work
quite well in a production environment:

(1) handle login status server-side:
After authenticating the user, establish a timeout until that the login
will be valid WITHOUT user interaction (you may e.g. choose 5 minutes, i.e.
time() + (5*60)). Store this timeout value in session data
($_SESSION['login_valid_until']);

(2) update the timeout on every user interaction
Simply refresh the session based timeout value using the same formula.

(3) Have a special entry (either a special script, or a certain parameter)
where the client may ask if the login is still valid. Make sure this script
(and only this!) DOES NOT increment the timeout value since it will be
called by client javascript, not by user interaction.

(A) Header pseudocode for interactive pages (normal application scripts):
login valid and validates against timeout?
NO: transfer to you have been logged out page
YES: increase timeout; continue processing;

(B) Pseudocode for timeout-checking script:
login valid and validates against timeout?
NO: transfer to you have been logged out page
YES: return 204 no response status code

(C) Javascript to be used on any page:
script language=JavaScript
function checkHandler() {
window.location.href=yourcheckscripthere.php??php echo SID; ?;
onloadHandler();
}
function onloadHandler() {
setTimeout('checkHandler();', 6);
}
/script
body onLoad=onloadHandler();

The main feature here is the use of the server status code 204 which means
No Response. Cited from RFC2616 (HTTP 1.1 draft standard):

10.2.5   204 No Content
The server has fulfilled the request but does not need to return an
entity-body, 
[...]
If the client is a user agent, it SHOULD NOT change its document view from
that which caused the request to be sent. This response is primarily
intended to allow input for actions to take place without causing a change
to the user agent's active document view, [...]
The 204 response MUST NOT include a message-body, and thus is always
terminated by the first empty line after the header fields. 



So: if the server sees the login status (in session data) is still valid,
the reload request issued by JavaScript doesn't lead to a new page but lets
the browser remain in idle mode. However the timeout needs to be set
again; it seems that the JS engine clears all timers _before_ the reload
request (which would make sense; it can't clean them up on another page).

However if the server sees the user has exceeded its timeout (by not
activating some interactive action that would cause the timeout to be
extended), the javascript reload will immediately transfer the user agent
to the you're outta here page.


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



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



Re: [PHP] IF statement madness

2003-03-14 Thread Ernest E Vogelsinger
At 19:21 14.03.2003, James E Hicks III said:
[snip]
Help save my sanity! What can I do to the IF statement in the following
code to
make it print the line that says By God they are equal in value.? I have 
tried
the following changes;

   1. using === instead of ==
   2. placing (float) in front of the $i and $target inside and before
 the IF
statement.

?
$start = 215;
$end = 217;
$target = 216;
for ($i=$start; $i=$end; $i+=.1){
if ( $i ==  $target ){
echo (BR$i - $target, By God, the are equal in value.);
} else {
echo (BR$i - $target, Eternal Damnation, they aren't
equal!);
}
}
?
[snip] 

Before the if statement in your loop place this line:
echo \$i is now: $ibr /;

You'll notice that most probably your $i variable will miss $target by some
hunderths or thousandths, since you're working with it as a float. This is
due to the way fp numbers are stored and calculated (using exponents and
mantissa).

Workaround: don't use floats if you want to hit a certain value at the spot:

?
$start = 215;
$end = 217;
$target = 216;
for ($i=($start*10); $i=($end*10); $i++){
   if ( $i == ($target*10) ){
   echo (BR$i - $target, By God, the are equal in value.);
   } else {
   echo (BR$i - $target, Eternal Damnation, they aren't
equal!);
   }
}
?


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



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



  1   2   3   4   5   6   >