[PHP] Bug with register_globals on versus 1 and php_value vs php_flag?

2002-11-26 Thread Daevid Vincent
I don't know if this is a known bug or it's supposed to work like this,
but after randomly trying things, this finally worked:


DocumentRoot /home/interact/public_html
ServerName interact
ServerAlias www.interact.com *.interact.*
ErrorLog logs/interact-error_log
CustomLog logs/interact-access_log common

php_value register_globals 1




Whereas:


php_flag register_globals on


Didn't work (as I would assume it should)

I'm running:

PHP 4.2.2
Apache 2.0.40
Zend engine 1.2.0
RedHat 8.0
Kernel 2.4.18


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




RE: [PHP] include "problem" -- how to use an external 'template' file and still use PHP variables?

2002-12-30 Thread Daevid Vincent
I have a similar question/problem. However, I want to use an external
"email template" as it were, so that the sales guys can edit it as they
like and simply shuffle the three variables around that they need
$username, $password, $code  (either with or without the  tags).

I don't want them mucking around in my code and potentially screwing it
up. Not to mention having a huge 'email' text in between those
HTMLMESSAGE markers is ugly as hell and ends up making the color-coding
in HomeSite all kinds of whack at the end of it.

I tried to use:

$message = << in the customer_email.php the field is blank (like it's
being parsed but doesn't have a value for it or something), instead of
being converted to their actual PHP values. I also tried to put the
"global" keyword in the customer_email.php file at the top.

Is there no way to accomplish this?

> -Original Message-
> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] 
> 
> 
> Use a here-doc:
> 
> echo << [$data]  $titulo ($user) $intro  $texto
>  (comentarios=$contador)
> EOB;


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




[PHP] Possible bug with PHP v4.1.1 and bits?

2003-01-03 Thread Daevid Vincent
I'm not even sure how to classify this...

Given:



Where $Enabled is either a 0 or 1 as read from a database ( TINYINT(1)
);

And

echo "action = ".$_POST[action]."";
if ($_POST[action] == "1" || $_POST[action] == "0")
  echo = "UPDATE Company SET Enabled = ".!(intval($_POST[action]))."
WHERE CompanyID = $id";

(skipping all the obvious bits -- no pun intended)

I cannot figure out how to simply make the 0 and 1 invert or negate or
toggle as it were.

When I submit the form, my output is:

action = 0
UPDATE Company SET Enabled = 1 WHERE CompanyID = 89

action = 1
UPDATE Company SET Enabled = WHERE CompanyID = 17

I've tried all kinds of combinations, but whenever the action is 1 to
begin with, the 'inverted' version is always blank or -2 when I would
expect it to be 0.

If I use 
  echo = "UPDATE Company SET Enabled = ".~(intval($_POST[action]))."
WHERE CompanyID = $id";

action = 1
UPDATE Company SET Enabled = -2 WHERE CompanyID = 17


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




RE: [PHP] locally enabling register_globals?

2003-01-05 Thread Daevid Vincent
This might help... Put this at the top of each page:

reset ($_POST);
while (list ($key, $val) = each ($_POST)) {
//echo "$key => $val\n";
$$key = $val;
}

You could do the same for $_GET if you need to as well.

DÆVID.

> -Original Message-
> From: Michael Greenspon [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, January 03, 2003 5:51 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] locally enabling register_globals?
> 
> 
> Thanks. This is what we've chosen to do-- 'fix' the code.
> Unfortunately this was all written 'old style' by novices, so 'fixing'
> it by putting in references to $_GET, $_POST etc. doesn't really lend
> any clarity to it. Values are still splayed out across multiple pages
> with no structure. But at least it works now. Still uncertain why the
> php_flag in htaccess didn't do it-- perhaps not enabled with Apache.
> Cheers
> M.
> 
> 
> "Michael J. Pawlowsky" wrote:
> > 
> > Why not just fix your code?
> > 
> > *** REPLY SEPARATOR  ***
> > 
> > On 03/01/2003 at 2:50 PM Michael Greenspon wrote:
> > 
> > >Our hosting provider installed PHP 4.2 and thus disabled
> > >register_globals by default which our scripts depend on. 
> We don't have
> > >access to php.ini to change this. This is with Apache. I 
> tried putting
> > >
> > >php_flags register_globals on
> > >
> > >into .htaccess in the directory(s) with pages that need 
> this but it does
> > >not seem to work. How can I enable register_globals 
> selectively for some
> > >directories of pages so that our old scripts work again?
> > >
> > >Thanks
> > >Michael
> > >
> > >--
> > >PHP General Mailing List (http://www.php.net/)
> > >To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




RE: [PHP] building web album - design questions

2003-01-10 Thread Daevid Vincent
Why re-invent the wheel. There are plenty of these out there...

Two I suggest are

[1] mine... http://daevid.com/photo_album.phtml

And

[2] http://www.andymack.com/freescripts/


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




[PHP] how can I use an external 'template' file and still use PHP variables?

2003-01-10 Thread Daevid Vincent
I've posted this a few weeks ago with no response. I want to use an
external
"email template" as it were, so that the sales guys can edit it as they
like and simply shuffle the variables around that they need
$username and $password (either with or without the  tags).

I don't want them mucking around in my code and potentially screwing it
up. Not to mention having a huge 'email' text in between those
HTMLMESSAGE markers is ugly as hell and ends up making the color-coding
in HomeSite all kinds of whack at the end of it.

I tried to use:

$message = << in the customer_email.php the field is blank (like it's
being parsed but doesn't have a value for it or something), instead of
being converted to their actual PHP values. I also tried to put the
"global" keyword in the customer_email.php file at the top.

Ideally I would like to set things up so we have varoius form letter
emails and I can switch them around based upon say a "special order
code", where the $user/$pw is always the same (depending on the database
user of course), but the email content is different formats.

Is there no way to accomplish this? Am I not being clear on what it is
I'm trying to accomplish?

My final thought is to use some regex to search for  in
$message after it's all been read in, and replace it with the variable
$username or make up my own tag codes like [!username!] or something
like that. This seems like such a hack, when PHP should be able to do
this natively somehow.

Surely somebody out there has had to do this type of thing?




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




RE: [PHP] how can I use an external 'template' file and still use PHP variables? [solved]

2003-01-10 Thread Daevid Vincent
Benjamin, you are my father! Dude! That worked perfectly...

In case you all didn't understand what I was trying to do, attached are
some examples... This worked thanks to "Benjamin Vincent" ;-)

 snip 'customer_email.php' --




Untitled





Username
Password
Company
Code




 snip 'customer_email.php' --

 snip 'emailtest.php' --




EMAIL include test



\r\n";
 $headers .= "To: ".$email."\r\n";
 $headers .= "Reply-To: ".$myname." <".$myreplyemail.">\r\n";
 $headers .= "X-Mailer: Linux Server";
 mail($email, $subject, $message, $headers);

echo $message;
?>
check your email to see if this worked.


 snip 'emailtest.php' --

> -Original Message-
> From: Benjamin Niemann [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, January 10, 2003 2:02 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] how can I use an external 'template' file 
> and still use PHP variables?
> 
> 
> I think this should make it:
> 
> ob_start();
> include("/pathto/customer_email.php");
> $message = ob_get_contents();
> ob_end_clean();
> 
> - Original Message -
> From: "Daevid Vincent" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, January 10, 2003 10:48 AM
> Subject: [PHP] how can I use an external 'template' file and 
> still use PHP
> variables?
> 
> 
> > I've posted this a few weeks ago with no response. I want to use an
> > external
> > "email template" as it were, so that the sales guys can 
> edit it as they
> > like and simply shuffle the variables around that they need
> > $username and $password (either with or without the  tags).
> >
> > I don't want them mucking around in my code and potentially 
> screwing it
> > up. Not to mention having a huge 'email' text in between those
> > HTMLMESSAGE markers is ugly as hell and ends up making the 
> color-coding
> > in HomeSite all kinds of whack at the end of it.
> >
> > I tried to use:
> >
> > $message = << >   include("/pathto/customer_email.php");
> > HTMLMESSAGE;
> >
> > But $message has the literal string
> > ''include("/pathto/customer_email.php");'' instead of including the
> > file. Grr.. (wouldn't it make sense that an include() 
> should be parsed
> > FIRST with the contents put in place basically? This seems 
> like a 'bug'
> > not a feature.
> >
> > I also tried:
> >
> > $filename = "/pathto/customer_email.php";
> > $fd = fopen ($filename, "r");
> > $message = fread ($fd, filesize ($filename));
> > fclose ($fd);
> >
> > But all the $username, etc. are treated as literals and if I use
> >  in the customer_email.php the field is blank 
> (like it's
> > being parsed but doesn't have a value for it or something), 
> instead of
> > being converted to their actual PHP values. I also tried to put the
> > "global" keyword in the customer_email.php file at the top.
> >
> > Ideally I would like to set things up so we have varoius form letter
> > emails and I can switch them around based upon say a "special order
> > code", where the $user/$pw is always the same (depending on 
> the database
> > user of course), but the email content is different formats.
> >
> > Is there no way to accomplish this? Am I not being clear on 
> what it is
> > I'm trying to accomplish?
> >
> > My final thought is to use some regex to search for 
>  in
> > $message after it's all been read in, and replace it with 
> the variable
> > $username or make up my own tag codes like [!username!] or something
> > like that. This seems like such a hack, when PHP should be 
> able to do
> > this natively somehow.
> >
> > Surely somebody out there has had to do this type of thing?
> 


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




RE: [PHP] Re: Favorite Email validation routine?

2003-01-14 Thread Daevid Vincent
I just use a simple Javascript function. I figure if it's remotely
close, then good, if not then it's going to be an invalid email address
most likely anyways:

function emailCheck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
   return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 ||
str.indexOf(at)==lstr){
   return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 ||
str.indexOf(dot)==lstr){
return false
}

 if (str.indexOf(at,(lat+1))!=-1){
return false
 }

 if (str.substring(lat-1,lat)==dot ||
str.substring(lat+1,lat+2)==dot){
return false
 }

 if (str.indexOf(dot,(lat+2))==-1){
return false
 }

 if (str.indexOf(" ")!=-1){
return false
 }

 return true
}

DÆVID.

"A good friend will come and bail you out of jail...but a true friend
will be sitting next to you in the holding cell, laughing and saying
-'That was fucking awesome!'" 

> -Original Message-
> From: Manuel Lemos [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, January 12, 2003 9:30 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: Favorite Email validation routine?
> 
> 
> Hello,
> 
> On 01/13/2003 03:21 AM, Peter Janett wrote:
> > I'm looking for everyone's favorite email syntax validation 
> routine.  Code
> > that takes an email address and does regex on it to 
> determine if it's
> > formatted correctly.
> > 
> > I know there are some on phpclasses.org that actually check 
> the mx record
> > and server of the domain, but I'm just looking for a good, 
> clean and fast
> > email address syntax check.
> > 
> > So, what is your favorite bit of code to do that?
> 
> This class that I don't know if you seen also comes with 
> complex regex 
> for simple e-mail address validation:
> 
http://www.phpclasses.org/emailvalidation

-- 

Regards,
Manuel Lemos


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


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




RE: [PHP] Making alternate rows of different colour

2003-01-17 Thread Daevid Vincent

>

> > Can someone please help me with the code?
> 
>$cols = array('#ff','#00ff00');
>$i = 0;
>while(your_loop_to_output_each_row) {
>   echo '$row_data';
>}


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




RE: [PHP] Sessions or Cookies?

2003-01-17 Thread Daevid Vincent
Agreed. Sessions are much more secure and convienient to use too. Since
it's not reliant on the client to have cookies enabled, that's another
benefit. Plus it's MUCH harder for a client to spoof/alter a session
variable if you use the $_SESSION['myvar'] 

> -Original Message-
> From: Chris Shiflett [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, January 17, 2003 9:29 AM
> To: Cesar Aracena; [EMAIL PROTECTED]
> Subject: Re: [PHP] Sessions or Cookies?
> 
> 
> --- Cesar Aracena <[EMAIL PROTECTED]> wrote:
> > Should I use the no-so-secure old cookies method
> > or should I start a new session every time a client
> > drops in and handle each cart by session name or ID?
> 
> My advice is to only use cookies to identify a Web client.
> Any data you want to associate with that Web client (user
> data, for example) should be stored on the server -
> database, session store, etc.
> 


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




[PHP] How to make id/name table into array?

2003-01-21 Thread Daevid Vincent
Is there a better way to do this in PHP? It seems that a single number
(key) and single name (value) would lend itself perfectly to an (indexed
or associative) array. I would think there is some PHP API call that I'm
unaware of that will just take the whole result set and stuff it into an
array for me no? If not, there should be. Perfect for things like
ListBoxes, or table lookups so you don't have to hit the database
constantly with joins et. al.

$sql = "SELECT id, name FROM mytable ORDER BY id";
if ( !($result = mysql_query($sql,$link)) ) { echo "failed\n"; }
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) 
  $myarray[$row['id']] = $row['name'];



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




[PHP] Strange anomolie with each() and mysql_fetch_array()

2003-01-23 Thread Daevid Vincent
How come I *can* do these commands:

$row = mysql_fetch_array($result,MYSQL_ASSOC);
while(list($myVariableName,$sqlFieldName)=each($row)) 
{ $$myVariableName = $sqlFieldName; }

But I can't do this command?


while(list($myVariableName,$sqlFieldName)=each(mysql_fetch_array($result
,MYSQL_ASSOC))) 
{ $$myVariableName = $sqlFieldName; }

Notice the only differenceis that the first one assigns the array to
$row FIRST, whereas the second tries to avoid that extra call,
especially since I know I'm only getting one row back. Hmmm?


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




RE: [PHP] Strange anomolie with each() and mysql_fetch_array()

2003-01-24 Thread Daevid Vincent
> First, if you expect only a single row returned, why are you 
> using a while(){} construct?
> Third, each() operates on succeeding elements of an array; 
> there are only two elements aparrently,
> so what are you expecting eac() to do?

Because that magic incantation that Rasmus taught me many years ago will
take every field/column of the returned database row and make a variable
named the same thing with the corresponding value. So, for example, I
will get $customer_id = 5, $customer_name = "Joe Blow", etc... And when
you have a pant load of fields in one row, it comes in very very handy.

> Second, mysql_fetch_array() does not like to operate within 
> another function call.  I've tried it on
> multiple occasions; failed.

That seems like a bug to me then. Hence the reason I bring it up.
Seems to me there is no reason the second statement shouldn't work just
as the first.
 
> - Original Message -
> From: "Daevid Vincent" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, January 23, 2003 11:38 PM
> Subject: [PHP] Strange anomolie with each() and mysql_fetch_array()
> 
> 
> How come I *can* do these commands:
> 
> $row = mysql_fetch_array($result,MYSQL_ASSOC);
> while(list($myVariableName,$sqlFieldName)=each($row))
> { $$myVariableName = $sqlFieldName; }
> 
> But I can't do this command?
> 
> 
> while(list($myVariableName,$sqlFieldName)=each(mysql_fetch_arr
> ay($result
> ,MYSQL_ASSOC)))
> { $$myVariableName = $sqlFieldName; }
> 
> Notice the only differenceis that the first one assigns the array to
> $row FIRST, whereas the second tries to avoid that extra call,
> especially since I know I'm only getting one row back. Hmmm?


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




RE: [PHP] Webyog Releases SQLyog 3.02

2003-02-06 Thread Daevid Vincent
Dude. That freakin' form that asks for my email/name EVERY time has to
go.
Make that shit voluntary. It's annoying as hell, and is just forcing me
(and others) to enter bunk info everytime we want an update to this
product.

> -Original Message-
> From: Insanely Great [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, February 06, 2003 12:13 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Webyog Releases SQLyog 3.02
> 
> 
> SQLyog v3.02 - The definitive Windows Front End for MySQL, has been
> released. It is a superfast, compact and easy to use Front 
> End for MySQL. A
> must for MySQL & PHP developers. SQLyog is FREE!
> 
> Some of the new features added in SQLyog 3.02 are -
> 
> -- ODBC Import. The simplest and the most powerful tool to 
> import data from
> any ODBC compliant database to MySQL.
> -- Database Synchronization Tool. Bring your remote databases 
> in Sync with a
> single mouseclick.
> -- Connection Manager.
> -- Manage relationships on InnoDB tables. All other options 
> fully InnoDB
> compliant.
> -- Column Reordering.
> -- Copy databases between two MySQL hosts.
> -- Insert/Update on the Resultset of a query.
> -- Fully updated keyword list for syntax highlighting.
> -- Picklist for Enum/Set values in Insert/Update Dialog.
> -- Improved datagrid. Allows multiple row deletion.
> -- Option to add column name while exporting data in CSV.
> -- Multi selection of tables in export as SQL Scripts dialog.
> -- Empty a database with a single click.
> -- Show/Hide edit window.
> -- Improved error messages.
> -- Lot of bugfixes and enhancements.
> 
> You can download the new SQLyog at
> http://www.webyog.com/sqlyog/download.html.
> 
> Send your comments, suggestions, feature request through their NEW
> discussion board at http://www.webyog.com/forums/index.php
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




RE: [PHP] jumping between php and html or using echo for printing html-tags.

2003-02-06 Thread Daevid Vincent
Fatal error: Call to undefined function: floatval() in
/home/dae51d/public_html/examples/echotest.php on line 14 

> -Original Message-
> From: Chris Shiflett [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, February 06, 2003 2:40 PM
> To: anders thoresson; [EMAIL PROTECTED]
> Subject: Re: [PHP] jumping between php and html or using echo 
> for printing html-tags.
> 
> 
> --- anders thoresson <[EMAIL PROTECTED]> wrote:
> > Which is more efficient:
> 
> Your first method is more efficient according to my quick
> test, though I find myself preferring the second when I
> write code due to the readability advantages. The
> difference is small, however. Here is the code I used to
> test, so you can try it out (and verify my method of
> testing) for yourself:
> 
>  $foo = 'bar';
> 
> # TIME FIRST METHOD
> list($microseconds, $seconds) = explode(' ', microtime());
> $start_time = floatval($seconds) + floatval($microseconds);
> for ($i = 0; $i < 100; $i++)
> {
>  echo "a href=\"" . $_SERVER['PHP_SELF'] . "?action=" .
> $foo . "\">\n";
> }
> list($microseconds, $seconds) = explode(' ', microtime());
> $end_time = floatval($seconds) + floatval($microseconds);
> $total_time_first = $end_time - $start_time;
> 
> # TIME SECOND METHOD
> list($microseconds, $seconds) = explode(' ', microtime());
> $start_time = floatval($seconds) + floatval($microseconds);
> for ($i = 0; $i < 100; $i++)
> {
> ?>
> 
>  }
> list($microseconds, $seconds) = explode(' ', microtime());
> $end_time = floatval($seconds) + floatval($microseconds);
> $total_time_second = $end_time - $start_time;
> 
> # OUTPUT RESULTS
> echo "First method took  " . $total_time_first . "
> seconds\n";
> echo "Second method took " . $total_time_second . "
> seconds\n";
> ?>
> 
> Chris
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




[PHP] How do I force a 'timeout' in a loop for that itteration, or conversley how to timeout a 'ping" request?

2003-02-07 Thread Daevid Vincent
I'm trying to automate finding pingable domains given an IP or a domain.
The problem is that some domains don't actually return "pings", and on
Linux, it just sits there forever (ugh!). So... Can someone tell me how
to 'abort' or 'timeout' an itteration of a loop. Maybe start a timer and
then check if a number of millis has gone by? But it seems that won't
work b/c PHP isn't threaded, it will just hang at the exec() command
right? Converseley, anyone know how to force a /bin/ping to
automatically timeout (sans hitting CTRL+C)? I 'man ping' but it didn't
seem to have that option.
Here is the code I'm using...

$typeArray = array ('www' => false,  
'ftp' => false,
'mail' => false,
'exchange' => false,
'owa' => false,
'dns' => false,
'dns1' => false,
'dns2' => false,
'dns3' => false,
'router' => false,
'firewall' => false,
'fw' => false,
'fw1' => false,
'sql' => false,
'db' => false,
'database' => false,
'crm' => false
);

reset($typeArray);
while ( list($key, $val) = each($typeArray) )
{
$testDomain = $key.".".$domain;
$pingtest = exec("/bin/ping -c 1 -q ".$testDomain);
//echo "pingtest of ".$testDomain." =
".$pingtest."\n";
if ( strstr($pingtest,"rtt min") ) 
{
$typeArray[$key] = gethostbyname($testDomain);
echo "".$testDomain."
(".$typeArray[$key].")\n";
$ipCounter++;
}
//sleep(3);
}
if ($ipCounter == 0)
echo "No pingable domains found in our test
list";


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




RE: [PHP] Re: How do I force a 'timeout' in a loop for that itteration, or conversley how to timeout a 'ping" request?

2003-02-10 Thread Daevid Vincent
On linux it says:

-t ttl  Set the IP Time to Live for multicasted packets.  This flag
only
 applies if the ping destination is a multicast address.

> -Original Message-
> From: Philip Hallstrom [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, February 07, 2003 4:31 PM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: [PHP] Re: How do I force a 'timeout' in a loop for 
> that itteration, or conversley how to timeout a 'ping" request?
> 
> 
> Not sure on linux, but on freebsd ping's man page says:
> 
> -t timeout Specify a timeout, in seconds, before ping exits regardless
> of how many packets have been recieved.
> 
> On Fri, 7 Feb 2003, Daevid Vincent wrote:
> 
> > I'm trying to automate finding pingable domains given an IP 
> or a domain.
> > The problem is that some domains don't actually return 
> "pings", and on
> > Linux, it just sits there forever (ugh!). So... Can someone 
> tell me how
> > to 'abort' or 'timeout' an itteration of a loop. Maybe 
> start a timer and
> > then check if a number of millis has gone by? But it seems 
> that won't
> > work b/c PHP isn't threaded, it will just hang at the exec() command
> > right? Converseley, anyone know how to force a /bin/ping to
> > automatically timeout (sans hitting CTRL+C)? I 'man ping' 
> but it didn't
> > seem to have that option.
> > Here is the code I'm using...
> >
> > $typeArray = array ('www' => false,
> > 'ftp' => false,
> > 'mail' => false,
> > 'exchange' => false,
> > 'owa' => false,
> > 'dns' => false,
> > 'dns1' => false,
> > 'dns2' => false,
> > 'dns3' => false,
> > 'router' => false,
> > 'firewall' => false,
> > 'fw' => false,
> > 'fw1' => false,
> > 'sql' => false,
> > 'db' => false,
> > 'database' => false,
> > 'crm' => false
> > );
> >
> > reset($typeArray);
> > while ( list($key, $val) = each($typeArray) )
> > {
> > $testDomain = $key.".".$domain;
> > $pingtest = exec("/bin/ping -c 1 -q ".$testDomain);
> > //echo "pingtest of ".$testDomain." =
> > ".$pingtest."\n";
> > if ( strstr($pingtest,"rtt min") )
> > {
> > $typeArray[$key] = gethostbyname($testDomain);
> > echo " > VALUE='".$typeArray[$key]."' CHECKED>".$testDomain."
> > (".$typeArray[$key].")\n";
> > $ipCounter++;
> > }
> > //sleep(3);
> > }
> > if ($ipCounter == 0)
> > echo "No pingable domains found in our test
> > list";
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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




[PHP] How to use fopen() with protected directory (i.e .htaccess)

2003-02-10 Thread Daevid Vincent
How can I pass in a user/pw to an fopen() (or something similar)?

I am trying to render a dynamic db/php page into a static .html page --
or more specifically, I'm trying to email me back an html version of a
report page on remote servers. The reports are located behind an
https:// Apache user/pass authenticated directory.

I tried:
$file =
fopen("https://username:[EMAIL PROTECTED]/admin/report.php","r";)
; 

If I try to do something like:
$file = fopen("/www/htdocs/admin/report.php","r"); 

But then the PHP isn't executed, it just dumps me the straight source
code.


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




[PHP] How can I have PHP set the linux system date/time?

2003-02-13 Thread Daevid Vincent
Yep, I am trying to have a php web page change the linux system
date/time, but obviously running into the snag that /bin/date, while
"chmod 775" doesn't allow a user to set the date/time. Why is that,
given the permissions? Sure it makes sense, but it's annoying. Ideas on
how to circumvent this problem? 

-rwxr-xr-x1 root root26780 Jul 23  2001 /bin/date

Seems to me that anyone should be able to use it then right? Where is
the "write" portion defined? The 'info date' page says, "You must have
appropriate privileges to set the system clock." But it doesn't say what
that is or how to change them.

If anyone cares, here's a nice bit-o-code:




Change Time / Date




New Date

%02d\n",$i);
}
?>
 / 

%02d\n",$i);
}
?>
 / 

>2003
>2004
>2005
>2006


New Time

%02d\n",$i);
}
?>
 : 

%02d\n",$i);
}
?>











You entered an
invalid date, so it was converted to ".$NewDateTime."\n";
?>


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




RE: [PHP] How can I have PHP set the linux system date/time?

2003-02-13 Thread Daevid Vincent
I'm not sure what I'm doing wrong...

In changetime.php:

$binDate = date ("mdhiY",
mktime($hour,$minute,0,$month,$day,$year));
$execString = "/usr/bin/sudo /bin/date ".$binDate."";
//echo $execString."";
exec($execString); 

And then in /etc/sudoers:

nobody  ALL=NOPASSWD: /bin/date  

If I run the command (as daevid) "/usr/bin/sudo /bin/date 011304042003"
for example, it works fine.

Apache is running as nobody it seems:

[daevid=pts/6]4:10am@dev:{/www/htdocs}> ps aux | grep "httpd"
root   590  0.0  1.5  4996 1988 ?SFeb12   0:00
/www/bin/httpd -D
nobody 592  0.0  2.9  5396 3704 ?SFeb12   0:01
/www/bin/httpd -D
nobody 593  0.0  3.0  5524 3804 ?SFeb12   0:00
/www/bin/httpd -D
nobody 594  0.0  3.0  5556 3856 ?SFeb12   0:01
/www/bin/httpd -D

So What is the problem? Ideas?

> -Original Message-
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, February 13, 2003 3:43 AM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] How can I have PHP set the linux system date/time?
> 
> 
> You need root priviledges, that means /bin/date must run as root. You 
> can use sudo
> 
> Daevid Vincent wrote:
> 
> >Yep, I am trying to have a php web page change the linux system
> >date/time, but obviously running into the snag that /bin/date, while
> >"chmod 775" doesn't allow a user to set the date/time. Why is that,
> >given the permissions? Sure it makes sense, but it's 
> annoying. Ideas on
> >how to circumvent this problem? 
> >
> >-rwxr-xr-x1 root root26780 Jul 23  2001 /bin/date
> >
> >Seems to me that anyone should be able to use it then right? Where is
> >the "write" portion defined? The 'info date' page says, "You 
> must have
> >appropriate privileges to set the system clock." But it 
> doesn't say what
> >that is or how to change them.
> >
> >If anyone cares, here's a nice bit-o-code:
> >
> > > if ($year == "") $year = date("Y");
> > if ($month == "") $month = date("m");
> > if ($day == "") $day = date("d");
> > if ($hour == "") $hour = date("h");
> > if ($minute == "") $minute = date("i");
> > 
> > $NewDateTime = date ("m/d/Y H:i", mktime
> >($hour,$minute,0,$month,$day,$year));
> >
> > $binDate = date ("mdhiY", mktime
> >($hour,$minute,0,$month,$day,$year));
> > exec("/bin/date ".$binDate); //TODO: um, yeah, how do you expect
> >this to work? you have to be root to do this
> >?>
> >
> >
> >Change Time / Date
> >
> >
> >
> >
> >New Date
> > 
> >  > for($i = 1; $i <= 12; $i++)
> > {
> > echo " > if ($month == $i) echo " SELECTED";
> > printf(">%02d\n",$i);
> > }
> > ?>
> >  / 
> > 
> >  > for($i = 1; $i <= 31; $i++)
> > {
> > echo " > if ($day == $i) echo " SELECTED";
> > printf(">%02d\n",$i);
> > }
> > ?>
> >  / 
> > 
> >  >?>>2003
> >  >?>>2004
> >  >?>>2005
> >  >?>>2006
> > 
> >
> >New Time
> > 
> >  > for($i = 0; $i <= 23; $i++)
> > {
> > echo " > if ($hour == $i) echo " SELECTED";
> > printf(">%02d\n",$i);
> > }
> > ?>
> >  : 
> > 
> >  > for($i = 0; $i <= 59; $i++)
> > {
> > echo " > if ($minute == $i) echo " SELECTED";
> > printf(">%02d\n",$i);
> > }
> > ?>
> > 
> >
> >
> >
> >
> > class=button>
> >
> >
> >
> >
> >
> > > if (!checkdate($month,$day,$year)) print "\nYou entered an
> >invalid date, so it was converted to ".$NewDateTime."\n";
> >?>
> >
> >
> >  
> >
> 


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




[PHP] I need examples of WRITING to XML wth PHP

2003-02-13 Thread Daevid Vincent
I see tons of examples of how to read in an xml schema and use the
variables and such, but how do I then change values and re-save the
schema again? Can someone point me at a simple but function form that
simply reads a .xml file, populates the form, and allows you to change
values in the form and then resave the .xml file again. This seems like
it should be so basic, yet I can't find anything... Thanks in advance.


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




[PHP] How do I set the timezone on redhat via PHP? Ie. How to convert GMT to symbolic link?

2003-02-14 Thread Daevid Vincent
Given that I have a GMT offset via the select box below, how the hell do
I turn that into a symbolic link to one of these files? How do I know
which file to link too?!!! UGH. This is such a stupid way to set the
timezone, why didn't RedHat just have a file with the offset in it?
Something like "echo -0800GMT > /etc/timezone" would have been
sufficient doncha think?

PHP's date("O") function = "-0800".

[dae51d=pts/0]12:50am@daevid:{/etc}> ll /etc/localtime 
lrwxrwxrwx1 root root   39 Dec 13 11:26 /etc/localtime
-> /usr/share/zoneinfo/America/Los_Angeles

[dae51d=pts/0]12:50am@daevid:{/etc}> ls /usr/share/zoneinfo/
Africa  Australia  Cuba Etc  GMT0   Iceland  Japan
MST  Poland  right  UCTzone.tab
America Brazil EET  Europe   GMT-0  Indian
Kwajalein  MST7MDT  PortugalROCUniversal  Zulu
Antarctica  Canada EgyptFactory  GMT+0  Iran Libya
Navajo   posix   ROKUS
Arctic  CETEire GB   Greenwich  iso3166.tab  MET
NZ   posixrules  Singapore  UTC
AsiaChile  EST  GB-Eire  Hongkong   Israel   Mexico
NZ-CHAT  PRC SystemVWET
AtlanticCST6CDTEST5EDT  GMT  HSTJamaica  Mideast
Pacific  PST8PDT Turkey W-SU

And since I couldn't figure out a graceful way to do this
programatically, I just typed them all out.

Time Zone
";?>

>GMT -12 Hours
>GMT -11.5 Hours
>GMT -11 Hours
>GMT -10.5 Hours
>GMT -10 Hours
>GMT -9.5 Hours
>GMT -9 Hours
>GMT -8.5 Hours
>GMT -8 Hours
>GMT -7.5 Hours
>GMT -7 Hours
>GMT -6.5 Hours
>GMT -6 Hours
>GMT -5.5 Hours
>GMT -5 Hours
>GMT -4.5 Hours
>GMT -4 Hours
>GMT -3.5 Hours
>GMT -3 Hours
>GMT -2.5 Hours
>GMT -2 Hours
>GMT -1.5 Hours
>GMT -1 Hours
>GMT 0 Hours
>GMT +0.5 Hours
>GMT +1 Hours
>GMT +1.5 Hours
>GMT +2 Hours
>GMT +2.5 Hours
>GMT +3 Hours
>GMT +3.5 Hours
>GMT +4 Hours
>GMT +4.5 Hours
>GMT +5 Hours
>GMT +5.5 Hours
>GMT +6 Hours
>GMT +6.5 Hours
>GMT +7 Hours
>GMT +7.5 Hours
>GMT +8 Hours
>GMT +8.5 Hours
>GMT +9 Hours
>GMT +9.5 Hours
>GMT +10 Hours
>GMT +10.5 Hours
>GMT +11 Hours
>GMT +11.5 Hours
>GMT +12 Hours




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




RE: [PHP] RedHat 8.0 MySQL Problem

2003-03-05 Thread Daevid Vincent
Wouldn't that technically be "downgrade", since RH8 ships with Apache 2.0
*smirk*

But yes, however, keep in mind that when you do 'downgrade' you will run
into the constant annoyance that up2date will always want to install a newer
php and httpd (they don't even call it apache for the rpm grrr), so things
like 'squirrelmail' and the other RH web config type programs will shit on
you. So, keep that in mind, but if it is production environment, you prolly
don't want to be running apache 2.0 just yet -- especially if youre doing
SSL stuff. 

> -Original Message-
> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, March 04, 2003 10:44 PM
> To: Darren Young
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] RedHat 8.0 MySQL Problem
> 
> 
> Have you actually enabled the MySQL extension?  You should 
> have a line in
> your php.ini that says:
> 
>   extension=mysql.so
> 
> By the way, the Apache that comes with RH8 when combined with 
> PHP does not
> give you a production-quality solution.  So if you are 
> running this thing
> for any sort of important service, you really need to upgrade your web
> server to Apache 1.3.27.
> 
> -Rasmus
> 
> On Tue, 4 Mar 2003, Darren Young wrote:
> 
> > I have an app that runs just fine on RedHat 7.2 with 
> compiled Apache and
> > PHP along with MySQL binaries installed from MySQL's site. 
> I have a new
> > machine running RedHat 8.0 that is completely "generic", 
> i.e only RedHat
> > Apache, PHP and MySQL RPM's installed. The error message 
> I'm getting is:
> >
> > [04-Mar-2003 23:38:46] PHP Fatal error:  Call to undefined function:
> > mysql_pconnect() in /var/www/html/zzmysql.php on line 49
> >
> > That's in the app log file by the way, we all the errors 
> there. The page
> > displayed is completely blank at the moment in time the error fires.
> >
> >
> > Persistent MySQL connections are disabled in the RedHat RPM's?
> >
> > RPM's installed are currently (via rpm -qa):
> >
> > httpd-2.0.40-11
> > php-devel-4.2.2-8.0.7
> > php-imap-4.2.2-8.0.7
> > php-odbc-4.2.2-8.0.7
> > php-snmp-4.2.2-8.0.7
> > php-ldap-4.2.2-8.0.7
> > php-pgsql-4.2.2-8.0.7
> > php-4.2.2-8.0.7
> > php-manual-4.2.2-8.0.7
> > php-mysql-4.2.2-8.0.7
> >
> > I'd really like to keep the RedHat install generic and 
> would prefer no
> > compile from source for this app. The onIy other change 
> I've made is to
> > copy the php.ini from the 7.2 machine over to /etc/php.ini 
> to get the
> > config the same. If I restore the original php.ini back the page
> > displays but the app just does not work. It seems as though 
> the mysql
> > functions just don't work quite right.
> >
> > Thoughts would be most appreciated.
> >
> > thx.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] wont display anything but a white page!!!

2003-03-08 Thread Daevid Vincent
I have the same problem, and I've found that if you set
error_reporting(E_ALL); at the top of the page you're working on, you
will at least get some info.

You may also set that in the /etc/php.ini file

I also suggest you make a "phpinfo.php" page wich contains simply:



And browse that to see all the PHP settings you have. Maybe you have a
local vs. master conflict.

Daevid.

> -Original Message-
> From: John W. Holmes [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, March 08, 2003 5:49 PM
> To: 'Karl James'; [EMAIL PROTECTED]
> Subject: RE: [PHP] wont display anything but a white page!!!
> 
> 
> > http://66.12.3.67/webdb/webdb13/assignment_1.phps
> > 
> > Can anyone tell me why I only get a white page
> > And no text to be on the browser?
> 
> Is display errors turned on in php.ini? Usually you get a 
> page like then
> when there was an error, but displaying it is not activated 
> in php.ini.
> 
> ---John W. Holmes...
> 
> PHP Architect - A monthly magazine for PHP Professionals. Get 
> your copy
> today. http://www.phparch.com/
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] how can I logout autamaitcally (using session)

2003-07-01 Thread Daevid Vincent
Did you even read the docs on sessions?

http://us4.php.net/manual/en/function.session-destroy.php

http://us4.php.net/manual/en/function.session-unset.php

http://us4.php.net/manual/en/function.session-unregister.php

*sigh*

Please people, think and at least do the simplest of searching on the site
before firing off an email to 10,000 people on this list. 

> -Original Message-
> From: sunwei [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 01, 2003 2:13 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] how can I logout autamaitcally (using session)
> 
> 
> when the user close all the IE windows, should the session be 
> destroyed autamatically? 
> it seems in my website, the session is not destroyed 
> autamatically, so that other people 
> open the IE and see that he can access the website without 
> logging in. so what I should do?
> 
> thanks a lot for any help or suggestion.
> 
> wei sun
> 


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



[PHP] DHCP web interface. New version.

2003-07-28 Thread Daevid Vincent
Heya. I've just put up a new version of the DHCP web front end if anyone is
using it or has a need for this type of thing.

Major feature of this version:

* a bug where if the arp table showed an "(incomplete)", I ignored the entry
  since the MAC is the hash key, many machines wouldn't show up as they kept
  over writing each other (of course, they were bunk anyways)
* ping & nmap tests (if ping fails, nmap is used as a backup)
  this is useful for firewalls that may block ICMP
* tests can be disabled for radically faster page rendering (off by default)
* 10 minute refresh by default rather than 10 second.
* SORTING! by IP now, rather than arp entries
* many more icons (tivo, zaurus, replay, linux, notebook, servers, DAR, etc)
* complete/incomplete tally
* Name in config file is only used if dhcp doesn't show a name already

This is also IMHO an excellent way for a beginer or advanced coder alike to
see some very useful OOP/PHP coding as I use arrays of objects, sorting by
variables IN the object (custom sort algorithm with key integrity), hashing,
system calls, regex parsing, DHTML, etc. 

If anyone knows how to force the arp table to be current, that would help.
Sometimes a machine is on the network, and I *know* for a fact it is, but it
doesn't show up in "arp -n" *grumble*. 

Follow the link below. 
http://daevid.com/examples/dhcp/

Check out my resume. Hire me. ;-)
http://resume.daevid.com/

N'joy. 

Daevid.
 


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



RE: [PHP] DHCP web interface. New version.

2003-07-29 Thread Daevid Vincent
I already to that with ping and nmap. The problem lies BEFORE getting the
list. :)

"Arp -n" is my master IP generator/table. So if the IP isn't in there, I
don't know about it. I need a way to send a command line switch (which there
isn't) or another call to force "arp" to rebuild it's cache.

> -Original Message-
> From: Tom Rogers [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 29, 2003 1:51 AM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] DHCP web interface. New version.
> 
> 
> Hi,
> 
> Tuesday, July 29, 2003, 2:40:55 PM, you wrote:
> 
> 
> DV> If anyone knows how to force the arp table to be current, 
> that would help.
> DV> Sometimes a machine is on the network, and I *know* for a 
> fact it is, but it
> DV> doesn't show up in "arp -n" *grumble*. 
> 
> DV> Follow the link below. 
> DV> http://daevid.com/examples/dhcp/
> 
> DV> Check out my resume. Hire me. ;-)
> DV> http://resume.daevid.com/
> 
> DV> N'joy. 
> 
> DV> Daevid.
>  
> You could loop through your ip adddresses that you are interested in
> and send a couple of pings.
> That should force the arp cache to be current for those ip's that
> exist
> 
> -- 
> regards,
> Tom
> 


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



RE: [PHP] DHCP web interface. New version.

2003-07-29 Thread Daevid Vincent
Well, a quick click on the URL I gave (http://daevid.com/examples/dhcp/)
would immediately show you what it was (live on my server), but in a
nutshell. I have a home LAN with many computers and other IP enabled devices
-- two TiVos, replayTV, Dell Audio Reciever, Zaurus, 8 computers!, three
notebooks, etc. (it's a big house!) and I'm an open wifi node. I wanted to
know what was on my network easily and in real time, complete with the
windows names for the computers. Then I kinda went buck-wild and added
icons, custom names, ping/nmap tests, sorting by IP, etc Amazingly I
couldn't find a tool -- command line or otherwise that did this seemingly
simple task. I mean, windows has 'network neighborhood', but that's only
good for windows machines or other conforming types.

This comes in very handy for any LAN, but you have to put it on the machine
that has the most 'arp' info. This is usually your DHCP server as it also
reads the dhcp.leases file to harvest names and lease times.

Pretty straight forward setup. Almost none in fact. Edit the .ini file with
your mac addresses and icons you want to use (if any).

Anyways, it's free and there for you if you want to see/play/use it.

d

> -Original Message-
> From: Chris W. Parker [mailto:[EMAIL PROTECTED] 
> Sent: Monday, July 28, 2003 10:56 PM
> To: Daevid Vincent; [EMAIL PROTECTED]
> Subject: RE: [PHP] DHCP web interface. New version.
> 
> 
> Daevid Vincent <mailto:[EMAIL PROTECTED]>
> on Monday, July 28, 2003 9:41 PM said:
> 
> > Heya. I've just put up a new version of the DHCP web front end if
> > anyone is using it or has a need for this type of thing.
> 
> New version? I din't even know you HAD a version.
> 
> So for us people that have never heard of this, what exactly 
> does it do?
> 
> 
> thanks,
> chris.


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



RE: [PHP] DHCP web interface. New version.

2003-07-29 Thread Daevid Vincent
> > Pretty straight forward setup. Almost none in fact. Edit the .ini
> > file with your mac addresses and icons you want to use (if any).
> 
> Does this mean it doesn't go out, search your network, and then report
> back with everything it's found? Do you mean that I have to manually
> specify each device I want to list? Am I misunderstanding you?

No. it *does* an 'arp -n' to find all the nodes on your network
automatically. It also uses that info to determine your active interfaces
(eth0, eth1, wlan0, etc...). So if your arp cache is up to date, then so is
this.

It shows if they are "(inactive)" by the ban circle.

It shows ping and nmap results. (only namps if ping fails. Assumes nmap will
pass if ping passes).

The dhcp_map.ini is used ONLY for custom icons and for custom names if the
MAC doesn't already have a name associated with it in /var/lib/dhcp.leases
file. This is useful for machines that have static IP's on your network for
example, or linux boxes that don't send that info (only windows boxes
send/set names automatically).


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



RE: [PHP] System() works on /usr/sbin commands

2003-07-31 Thread Daevid Vincent
Add an entry to /etc/sudoers like so:

nobody  ALL=NOPASSWD: /bin/date


Daevid Vincent
http://daevid.com
 

> -Original Message-
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, July 31, 2003 3:02 AM
> To: tirumal b
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] System() works on /usr/sbin commands
> 
> 
> Check out sudo (man sudo), but you must be carefull.
> 
> tirumal b wrote:
> 
> > hello,
> > 
> >   yes the /usr/sbin commands require root permissions
> > but is there any way to run these commands using
> > system() through suid or something.please let me know
> > 
> > Thank you
> > 
> > __
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> > http://sitebuilder.yahoo.com
> > 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Re: Password storage system

2003-08-08 Thread Daevid Vincent
Thanks, but I guess I forgot to mention it should be web-interface...
 
http://passwordms.sourceforge.net/index.php
For anyone wanting to look.

> -Original Message-
> Try PMS: Password Management System. I believe it can be found on
> sourceforge.


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



[PHP] REQ: Password storage system

2003-08-14 Thread Daevid Vincent
I'm in search of an 'enterprise level' password storage system. 

I have looked at phpMyPass and it looks promising, but the demo doesn't seem
to have everything I want.
http://freshmeat.net/releases/127316/
While this one says v2.0
http://www.phpmypass.paniris.com/
Says 1.0 ??

I need it to be multiuser, have different security levels/access, encrypt
and decrypt on the fly (phpmypass has all the passwords in the rendered HTML
page :-( ), grouping of passwords (i.e. 'internal servers', websites, banks,
clients sites, personal, etc).

Ideally it should use mod_auth_mysql for security. The storage should be
encrypted so that even root can't see the passwords in the database without
the decryption key. Perhaps use a strong crypto algorithm for the important
fields, not just the pw.

I'd like to store: common name, url, username, pw, notes, incept date, last
mod date at least.

I could build this myself, or I could take phpMyPass and run with it, but I
thought I'd see if there were anything else out there before I build this.

http://daevid.com


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



RE: [PHP] Use PHP or MySQL for MD5 function

2003-08-25 Thread Daevid Vincent
Well, IMHO it's better to use PHP. My reasoning is this: you want to hit the
db and get out of there as quick as possible since you have limited threads.
Plus, I try to keep my code as db agnostic as possible, so that it's
portable. Having said that, if it's a quick project or something simple, I'd
probably use the mysql version just for the ease of use factor. 

If you really care, just make a program like this and do some MD5() calls in
both mysql and php to see which is faster. I'd be curious to know as well...
You'll have to modify appropriately, and only do a single MD5 check because
I think looping 1 mysql MD5 calls will be slower automatically since
there is the connection to the db and stuff to contend with, so keep that in
mind.


Daevid Vincent
http://daevid.com

--- test ---


blah 
version one: \t$time1 seconds\n";
echo "version two: \t$time2 seconds\n";
?>

 

> -Original Message-
> From: Sid [mailto:[EMAIL PROTECTED] 
> Sent: Monday, August 25, 2003 1:25 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Use PHP or MySQL
> 
> 
> Hello,
> 
> This question has been lingering in my mind for some time -
> Say we have a function such as MD5, which is available on 
> both PHP and MySQL? Which is faster - the PHP version or the 
> MySQL one. Have any benchmarks been made on this? We can use 
> the same question for say... arithmetic operations, string 
> contentation...
> 
> Thanks in advance.
> 
> - Sid 
> 

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



RE: [PHP] Zip Way of life.

2003-03-19 Thread Daevid Vincent
You could use the exec() or shell_exec() and just do it via command line
method...

> -Original Message-
> From: Vincent M. [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, March 19, 2003 12:36 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Zip Way of life.
> 
> 
> Hello,
> 
> I'd like to uncompress to the Hard disk a zip file send by 
> the browser.
> 
> At this time I do this:
> 
> function uncompresszip($zipfile) {
>copy($zipfile, 
> dirname($_SERVER['PATH_TRANSLATED'])."/zip/zipfile.zip") ;
> }
> 
> But I do not understand how to uncompress the zip file, I 
> tried for exemple:
> $retour = 
> readgzfile(dirname($_SERVER['PATH_TRANSLATED'])."/zip/zipfile.zip");
> 
> But as mentionned in the php doc it outputs the content of 
> the zip file 
> in the browser :-(
> 
> How to uncompress a zip file in a directory ? I just want all 
> the files 
> which are in the zip file...
> 
> Thanks,
> Vincent.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Zip Way of life.

2003-03-20 Thread Daevid Vincent
> zip file and unzip is not installed by on Unix servers. :-(

So either install it on the servers that need it, or distribute the un/zip
exe with your package in your projects local directory -- this also saves
you having to deal with different versions on different servers that may not
always do what you expect. At least this way it's a controlled environment. 


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



RE: [PHP] Zero Fill -> Number Format

2003-03-20 Thread Daevid Vincent
Just an observer, but I love how you each had a different way of
accomplishing this task! ;-)

And Mike, looks like you have some re-writing to do now that Martin and
Kevin showed you a WAY simpler (and faster) way to accomplish what you did.
LOL.

http://daevid.com

> -Original Message-
> From: Martin Towell [mailto:[EMAIL PROTECTED] 
> 
> sprintf/printf("%7d", $num)


-Original Message-
>From: Kevin Waterson [mailto:[EMAIL PROTECTED] 
>
>print str_pad($something, 7, "0", STR_PAD_LEFT);


-Original Message-
From: Mike Brum [mailto:[EMAIL PROTECTED] 

This is what I did for a dynamic zero-fill for renaming batches of files:

// Get "Zero Padding" For New Image Names
$zero_padding = strlen(count($image_array));

  foreach($image_array as $temp){
$n++;
$n_length = strlen($n);
for($i = 0; $i < ($zero_padding - $n_length); $i++){
$n = "0" . $n;
  }
$new_name = $image_inbox . "/" . $newName . "-" . $n . ".jpg";
rename("$image_inbox/$temp", $new_name);
  }


I'm not sure if this will be applicable to your situation, but it works
perfectly for me since it will zero-fill for any length of numbers and pad
the shorter numbers appropriately.


> -Original Message-
> From: Harry.de [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 20, 2003 10:09 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Zero Fill -> Number Format
> 
> 
> How can I put out a Zero Fill for numbers
> The result should be
> 
> $something=26;
> echo $something;
> 
> e.g.
> 026


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



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

2003-03-20 Thread Daevid Vincent
Is there some global array or something that contains all the variable names
(not even values per se) that are used in my script.

Here's the scenario. Like most of you, I do a lot of mySQL db work. So I
tend to use this:

if (mysql_num_rows($result) > 0) { 
  $row = mysql_fetch_array($result,MYSQL_ASSOC);
  while(list($myVariableName,$sqlFieldName)=each($row)) 
{ $$myVariableName = $sqlFieldName; }
}

So now I have a bunch of variables all named say, $company_name,
$company_id, $company_phone, etc...

What I want to do is make a function that can step through all the $company_
variables and unset them all.
(I imagine I'll just string compare to "company_" and then prefix the result
with $$, then set = "", etc. you get the idea)

I suppose I could re-write all my code and use the $row['company_id'] method
instead then clear $row[] but it would be nice to know if there is a way to
do this 'my way' as well...


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



RE: [PHP] Re: how to pass variable for $_GET

2003-03-23 Thread Daevid Vincent
Don't know if you realize this or not, but when you pass the variables, you
DO NOT enclose them in ' marks...

So... 

http://blah.com/myscript.php?date=2003-2-1%2000:00:01'%20AND%20'2003-3-1%202
3:59:59&othervar=1234

Then on your myscript.php page, 

$_GET['date'] will equal "2003-1-3 00:00:01 AND 2003-3-10 23:59:59" (sans
the " marks)
$_GET['othervar'] will equal "1234"

The browser pads the spaces with %20

If you really do need the ' marks, put them in the myscript.php page where
needed like this:

$sql = "SELECT * FROM foo WHERE blah = '".$_GET['othervar']."'";

> -Original Message-
> From: DomIntCom [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, March 23, 2003 2:08 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: how to pass variable for $_GET
> 
> 
> thanks - found a solution...  both method's worked for me
> 
> 
> "Nate" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > stripslashes("\'2003-1-3 00:00:01\' AND \'2003-3-10 23:59:59\'");
> >
> > "Domintcom" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > ok - found urldecode which is now giving me the following;
> > >
> > >  \'2003-1-3 00:00:01\' AND \'2003-3-10 23:59:59\'
> > >
> > > original string;
> > >
> > > '2003-1-3 00:00:01' AND '2003-3-10 23:59:59'
> > >
> > >
> > > "Domintcom" <[EMAIL PROTECTED]> wrote in message
> > > news:[EMAIL PROTECTED]
> > > > ok - I know how to pass these variables by appending 
> variables to the
> > > link.
> > > > however, I'm trying to pass the following string;
> > > >
> > > > '2003-1-1 00:00:01' AND '2003-3-20 23:59:59'
> > > >
> > > > now - when I pass it what I get is the following;
> > > >
> > > > date='2003-2-1%2000:00:01'%20AND%20'2003-3-1%2023:59:59'
> > > >
> > > > it seems what I'm going to have to do is replace %20 
> with a space, but
> > I'm
> > > > unclear of how to do that with php.
> > > >
> > > > thanks,
> > > >
> > > > Jeff
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Using include() or require() with PDF module

2003-03-25 Thread Daevid Vincent
Two things come to mind... 
First, make sure the file is indeed being included/required and you don't
have your paths messed up.

Second, make sure you have the PDF stuff compiled into PHP.
Make a page with  as the only thing in it, then load it
in your web browser and find the words "PDF" in there.

I've not used PDF myself, so that's about the extent of my help. Sorry.

d

> -Original Message-
> From: Bill Hudspeth [mailto:[EMAIL PROTECTED] 
> Sent: Monday, March 24, 2003 11:50 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Using include() or require() with PDF module
> 
> 
> I wish to use the include() and/or the require() functions to 
> include a
> block of PHP multiple times in my file. The block contains code for
> outputting PDF elements. Although other external code (functions for
> example) are successfully referenced using these commands, 
> the PHP's PDF
> functions don't seem to work.
> 
> Any ideas?
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



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

2003-03-26 Thread Daevid Vincent
How come this function works, but the one below does not?? 

function clearContactVars()
{
  global $contact_id;   $contact_id = "";
  global $contact_timestamp;$contact_timestamp = "";
  global $contact_incept;   $contact_incept = "";
  global $contact_dept_table_id;$contact_dept_table_id = "";
  global $contact_fname;$contact_fname = "";
  global $contact_lname;$contact_lname = "";
  global $contact_title;$contact_title = "";
  global $contact_phone;$contact_phone = "";
  global $contact_email;$contact_email = "";
  global $contact_address1; $contact_address1 = "";
  global $contact_address2; $contact_address2 = "";
  global $contact_city; $contact_city = "";
  global $contact_state;$contact_state = "";
  global $contact_zip;  $contact_zip = "";
  global $contact_country;  $contact_country = "";
  global $contact_notes;$contact_notes = "";
}

This one does NOT work the way I would expect it to?

function clearContactVars()
{
foreach ($GLOBALS as $key => $value) {
if ( substr($key,0,8) == "contact_" ) {
  //echo "GLOBALS['$key'] = $value\n";
  $GLOBALS['$key'] = "";
}
}
clearPostVars();
}

(this is located in an require() file and do I even need to do this?):
function clearPostVars()
{   
foreach ($_POST as $key => $value) {
//echo "_POST['$key'] = Value: $value\n";
$_POST['$key'] = "";
}
}

I use these variables on a web page like so:


Phone:



So after a successful insert/update/whatever, I need to clear the fields.

The only other relevant part is that at the top of each page in a require()
file, I have this:

reset ($_POST);
while (list ($key, $val) = each ($_POST)) {
//echo "$key => $val\n";
$$key = $val;
}

But it doesn't make sence to me that the first function does in fact clear
the variables, when the second one does not. I thought that would be even
more direct, since "global $contact_id" from what I read is only a reference
to the global variable named $contact_id. Which in effect should be exactly
$GLOBALS['contact_id'] right?
http://www.php.net/manual/tw/migration4.variables.php


--
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-26 Thread Daevid Vincent
Actually I didn't.  ;-)

$GLOBALS[$key] is incorrect and depricated AFAIK.
$GLOBALS['$key'] (with the single quotes) is the proper way to write these
types of associative arrays/hashs.

For shits and giggles however I tried your way and it made no difference to
the code. Still didn't work right.

> -Original Message-
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, March 26, 2003 1:16 PM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] What am I not understanding about 
> $GLOBALS['myvar'] vs global $myvar?
> 
> 
> 
> 
> Daevid Vincent wrote:
> 
> >This one does NOT work the way I would expect it to?
> >
> > function clearContactVars()
> > {
> > foreach ($GLOBALS as $key => $value) {
> > if ( substr($key,0,8) == "contact_" ) {
> >   //echo "GLOBALS['$key'] = $value\n";
> >   $GLOBALS['$key'] = "";
> >
> I did not read your whole message, but you very likely mean
> 
> $GLOBALS[$key] = "";
> (no single quotes)
> 
> > }
> > }
> > clearPostVars();
> > }
> >
> >  
> >
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Microsoft SQL Server varchar(500) field text concatenated at 255 characters.

2003-03-28 Thread Daevid Vincent
http://www.mysql.com/doc/en/CHAR.html

VARCHAR can only be 255 characters in length.

Here's some useful info:

# BIGINTUNSIGNED = 8 Byte =  = 18446744073709551615
# INT   UNSIGNED = 4 Byte =  = 4294967295
# MEDIUMINT UNSIGNED = 3 Byte = FF   = 16777215
# SMALLINT  UNSIGNED = 2 Byte =  = 65535
# TINYINT   UNSIGNED = 1 Byte = FF   = 255

# BIGINTSIGNED = -9223372036854775808  to 9223372036854775807  
# INT   SIGNED = -2147483648 to 2147483647 
# MEDIUMINT SIGNED = -8388608  to 8388607  
# SMALLINT  SIGNED = -32768  to 32767 
# TINYINT   SIGNED = -128  to 127

# TINYTEXT   = 255
# TEXT   = 65535
# MEDIUMTEXT = 16777215
# LONGTEXT   = 4294967295

> -Original Message-
> From: Scott Houseman [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 28, 2003 3:35 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Microsoft SQL Server varchar(500) field text 
> concatenated at 255 characters.
> 
> 
> Hi There.
> 
> I am using PHP 4.3.0 on WIN32 to query data from a Microsoft 
> SQL Server.
> One field I am requesting is type VARCHAR size 500. For some 
> reason, PHP
> is returning only the first 255 characters of the text from 
> that field.
> 
> If I change the field type to TEXT, all of the data in that 
> field is returned.
> 
> Unfortunately, an ASP application is also using that 
> database, and when I change
> the field type to TEXT, it pukes completely.
> I would rather try to resolve the issue in PHP than waste my 
> time looking at ASP code.
> 
> Has anyone got an idea why this might be hapenning?
> 
> Many thanks.
> 
> Scott
> -- 
> Scott Houseman
> Senior Software Developer
> Junk Mail Publishing (Pty) Ltd
> Tel. +27 12 342 3840 x3806
> Fax. +27 12 342 1842
> Mob. +27 82 491 8021
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Submit Image Button

2003-04-03 Thread Daevid Vincent
Anyone know if this annoying behaviour will ever be 'fixed' in future HTML
specs? I can't believe what a glaring oversight this is that the 'value'
doesn't get GET/POSTED like with a normal 'submit' button... WTF were they
thinking?


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



RE: [PHP] RE: newbie Dynamic Drop down lists using mysql

2003-04-03 Thread Daevid Vincent
Not that this hasn't been coverd a million times already Bobby -- check the
archives...

   function ListboxMatch($size, $name, $query, $matchtothis) 
   {
   $items = 0;
   //echo "".$query."";
   if ( $qry = mysql_query($query) )
   {
   if (mysql_num_rows($qry) > 0)
   {
echo "\n";
if ($size == 1) echo "\t\n";
while (list($value, $text, $description) =
mysql_fetch_row($qry))
{
$items++;
echo "\t";
echo stripslashes($text);
if ($description) echo "
(".stripslashes($description).")";
echo "\n";
}
  echo "";
   }
   else echo "No data for Listbox\n";
   mysql_free_result($qry);
   }
   else echo "Listbox cannot be built because of an invalid
SQL query.";
   
   return $items;
   } // end ListboxMatch

> -Original Message-
> From: Bobby Rahman [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, April 03, 2003 5:34 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] RE: newbie Dynamic Drop down lists using mysql
> 
> 
> 
> 
> 
> Hiya
> 
> Im looking for any tutorials/snippets of code to show me how 
> to code a 
> dynamic drop down box/list in a php form.
> 
> e.g a drop down menu of all current users (I assume this will need to 
> connect to mysql db and select all usernames from table user 
> and place in 
> the menu.
> 
> here what I have so far
>  $connection = db_connect();
> $querystring = ("select username from user");
> $db_result = mysql_query($querystring);
> 
> (if mysql_num_rows($db_result))
> {
>   while ($row = mysql_fetch_row($db_result))
>{
>   print("$row[0]");
>}
> }
> else
> {
> print("No users created yet");
> }
> 
> 
> ?>
> 
> Any URLS will be much appreciated.
> 
> Thanks
> 
> Bob
> 
> _
> Express yourself with cool emoticons http://www.msn.co.uk/messenger
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



[PHP] Found a bug in 4.2.3 re: and echo vs.

2003-04-04 Thread Daevid Vincent
Here, try this bullshit...

I can't upgrade to a more recent version as I'm not in control of the
server, but I've tried it with both 4.1.2 and 4.2.3 on linux with a RH
install. Can anyone confirm or dispute this bug exists in later versions?

How does a parsing error like this go un-noticed for so long?

Obviously I took out all the interesting stuff in the page and so that can't
be blamed. This is about as bare skeleton test case as you can get.

*sigh*

snip

";
}

function alarmLightMySQL()
{
echo alarmLightYMD();
}
?>


FUCKED UP PHP Bug #1234170238741023



PHP Version 4.1.2
PHP Version 4.2.3

Why the FUCK doesn't this work


";
echo "".alarmLightMySQL()."";
echo "this fails!";
 echo "";
} 
?>




YET THIS DOES!



 

this works
 





snip



"Ezekiel 25:17. The path of the righteous man is beset on all sides by the
inequities of the selfish and the tyranny of evil men. Blessed is he who in
the name of charity and goodwill shepherds the weak through the valley of
darkness, for he is TRULY his brother's keeper and the finder of lost
children. And I will strike down upon thee with GREAT vengeance and
FU-U-U-URIOUS anger, those who attempt to poison, and destroy my brothers!
And you will KNOW my name is the Lord, when I lay my vengeance upon thee!" 


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



RE: [PHP] Re: Found a bug in 4.2.3 re: and echo vs.

2003-04-04 Thread Daevid Vincent
Mmm. I'm still not following and not completely convinced.

Changing "echo alarmLightYMD();" to simply "alarmLightYMD();" in the bottom
function doesn't print anything in the table cell at all (for the first test
case).

While your idea at first makes sense and does seem like a newbie mistake
(and you are correct, I do have nested "echo" statements come to think of
it). What I don't get is why it's not consistent. "Expanding" the relevant
lines, it should be like this:

echo "".(echo "")."";

Which fails, and the other line would be (which works):

"); ?>

In my book, they're both double echoing the output if you will... Are you
with me on that?

So again, why does the second one work and the first one doesn't?

> -Original Message-
> From: Philip Hallstrom [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 04, 2003 5:20 PM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: [PHP] Re: Found a bug in 4.2.3 re:  and echo vs. 
> 
> 
> It's a coding error... at least I think so.
> 
> change alarmLightMySQL just return the results not "echo" 
> them... echoing
> them doesn't make much sense inside another echo statement...
> 
> On Fri, 4 Apr 2003, Daevid Vincent wrote:
> 
> > Here, try this bullshit...
> >
> > I can't upgrade to a more recent version as I'm not in 
> control of the
> > server, but I've tried it with both 4.1.2 and 4.2.3 on 
> linux with a RH
> > install. Can anyone confirm or dispute this bug exists in 
> later versions?
> >
> > How does a parsing error like this go un-noticed for so long?
> >
> > Obviously I took out all the interesting stuff in the page 
> and so that can't
> > be blamed. This is about as bare skeleton test case as you can get.
> >
> > *sigh*
> >
> > snip
> >
> >  > function alarmLightYMD()
> > {
> > return "";
> > }
> >
> > function alarmLightMySQL()
> > {
> > echo alarmLightYMD();
> > }
> > ?>
> > 
> > 
> > FUCKED UP PHP Bug #1234170238741023
> > 
> >
> > 
> > PHP Version 4.1.2
> > PHP Version 4.2.3
> > 
> > Why the FUCK doesn't this work
> > 
> > 
> >  > for ($i = 0; $i < 10; $i++ ) {
> >  echo "";
> > echo "".alarmLightMySQL()."";
> > echo "this fails!";
> >  echo "";
> > }
> > ?>
> > 
> >
> > 
> >
> > YET THIS DOES!
> > 
> > 
> > 
> >  
> > 
> > this works
> >  
> > 
> > 
> > 
> > 
> >
> > snip
> >
> >
> >
> > "Ezekiel 25:17. The path of the righteous man is beset on 
> all sides by the
> > inequities of the selfish and the tyranny of evil men. 
> Blessed is he who in
> > the name of charity and goodwill shepherds the weak through 
> the valley of
> > darkness, for he is TRULY his brother's keeper and the 
> finder of lost
> > children. And I will strike down upon thee with GREAT vengeance and
> > FU-U-U-URIOUS anger, those who attempt to poison, and 
> destroy my brothers!
> > And you will KNOW my name is the Lord, when I lay my 
> vengeance upon thee!"
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Re: Found a bug in 4.2.3 re: and echo vs. [solved]

2003-04-05 Thread Daevid Vincent
HH! Now that makes perfect sense. 
Thank you Rasmus for that indepth reply and also the , vs . "trick"

> -Original Message-
> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
> Sent: Friday, April 04, 2003 10:11 PM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP] Re: Found a bug in 4.2.3 re:  and echo 
> vs. 
> 
> 
> You are getting completely mixed up.  Simplifying your example:
> 
> function foo() { echo "foo"; }
> 
> $a = "".foo()."";
> 
> Will you agree that this is bogus code?  foo() is not going to return
> anything, so the resulting value of $a is going to be "".
> Correct?  But while that assignment is happening the foo() 
> function echoes
> something, so you will see "foo" in the output, but it has 
> nothing to do
> with what ends up in $a.  Nothing changes when you change the 
> code to be:
> 
> function foo() { echo "foo"; }
> 
> echo "".foo()."";
> 
> The parser is going to build a string to be echoed since you used the
> string concatenation operator (dot).  While building that 
> string one of
> the components happen to output something, so that something will get
> output.  Then the string that was built will be output.  So 
> what you see
> is:
> 
> foo
> 
> Perhaps it is clearer if we make the function return something:
> 
> function foo() { echo "foo"; return "bar"; }
> 
> echo "".foo()."";
> 
> What do you think the output will be here?  We build a string 
> out of the
> components, but while building, foo() happens to echo "foo", then we
> finish constructing the string and output the final string.  
> So the result
> is:
> 
>foobar
> 
> As someone else pointed out, if you use commas here, things 
> change a bit:
> 
> function foo() { echo "foo"; }
> 
> echo "",foo(),"";
> 
> The comma syntax for echo is basically a shortcut for executing echo
> multiple times.  The above is equivalent to writing:
> 
> echo "";
> echo foo();
> echo "";
> 
> In this case things will be output in the correct order as we are no
> concatenating a bunch of parts to make a single string before 
> echoing it
> in this case.
> 
> -Rasmus
> 
> On Fri, 4 Apr 2003, Daevid Vincent wrote:
> 
> > Mmm. I'm still not following and not completely convinced.
> >
> > Changing "echo alarmLightYMD();" to simply 
> "alarmLightYMD();" in the bottom
> > function doesn't print anything in the table cell at all 
> (for the first test
> > case).
> >
> > While your idea at first makes sense and does seem like a 
> newbie mistake
> > (and you are correct, I do have nested "echo" statements 
> come to think of
> > it). What I don't get is why it's not consistent. 
> "Expanding" the relevant
> > lines, it should be like this:
> >
> > echo "".(echo "")."";
> >
> > Which fails, and the other line would be (which works):
> >
> > "); ?>
> >
> > In my book, they're both double echoing the output if you 
> will... Are you
> > with me on that?
> >
> > So again, why does the second one work and the first one doesn't?
> >
> > > -Original Message-
> > > From: Philip Hallstrom [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, April 04, 2003 5:20 PM
> > > To: Daevid Vincent
> > > Cc: [EMAIL PROTECTED]
> > > Subject: [PHP] Re: Found a bug in 4.2.3 re:  and echo 
> vs. 
> > >
> > >
> > > It's a coding error... at least I think so.
> > >
> > > change alarmLightMySQL just return the results not "echo"
> > > them... echoing
> > > them doesn't make much sense inside another echo statement...
> > >
> > > On Fri, 4 Apr 2003, Daevid Vincent wrote:
> > >
> > > > Here, try this bullshit...
> > > >
> > > > I can't upgrade to a more recent version as I'm not in
> > > control of the
> > > > server, but I've tried it with both 4.1.2 and 4.2.3 on
> > > linux with a RH
> > > > install. Can anyone confirm or dispute this bug exists in
> > > later versions?
> > > >
> > > > How does a parsing error like this go un-noticed for so long?
> > > >
> > > &g

RE: [PHP] RE: newbie alternate row colours in dynamic table

2003-04-05 Thread Daevid Vincent
Wow you guys are going about that way more complicated than it needs to
be:

$i = 0;
echo "";

Then it just alternates and takes care of itself (plus you get a nice
little index counter as well  as a bonus if you want to use $i 

DÆVID.

"A good friend will come and bail you out of jail...but a true friend
will be sitting next to you in the holding cell, laughing and saying
-'That was fucking awesome!'" 

> -Original Message-
> From: Bobby Rahman [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, April 05, 2003 2:09 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] RE: newbie alternate row colours in dynamic table
> 
> 
> 
> 
> Hiya people
> 
> After a lot of soul searching, exploring the web and help 
> from many people I 
> came up with this simple solution:
> 
> Thank you Chris for explaining the toggle $colorset. In the 
> end I decided 
> this made life alot simplier.
> 
> (clearly the brackets have to be correctly aligned)
> 
> while( $row = mysql_fetch_array($db_result) )
> {
> echo("
>  
>  " . $row['bugid'] . "
>  
>  ");
> if ( !isset($c) )
> {
> $c = "bgcolor=#FF";
> echo $c;
> }
> else
> {
> unset($c);
> }
> }
> 
> 
> 
> 
> >From: Chris Hayes <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: Re: [PHP] RE: newbie alternate row colours in dynamic table
> >Date: Sat, 05 Apr 2003 22:32:17 +0200
> >
> >At 22:14 5-4-2003, you wrote:
> >
> >
> >>Hiya I have a dynamic table and am trying to get the rows to be two 
> >>different alternate colours. well Ive looked at a couple of 
> snippets of 
> >>this colour code and previous mails regarding this. Im having major 
> >>troubles intergrating any of these suggestions with my 
> code. Can anyone 
> >>suggest where I am going wrong. Main problems are
> >>1. where to put the loop for changing the colour 
> (complicated due to the 
> >>loop retrieving data from db)i.e in the do loopin the 
> while loop?
> >Within the loop that prints the rows, whcih is usually a 
> while loop. But 
> >that depends on your preferences.
> >
> >
> >>2. Also how to echo my rows in the colours.(something like 
> this I think)
> >>print ""$db_fetch['bugid']; ?>;
> >>
> >>
> >>e.g here is the code snippet for alternate coloured rows
> >>$trcolor="#F0F8FF";
> >>while ($myrow = mysql_fetch_array($result)){
> >>$colorset=0;
> >>if ($trcolor=='#F0F8FF'){
> >>$trcolor='#B0C4DE';
> >>$colorset=1;
> >>}
> >>if ($colorset==0){
> >>if ($trcolor=='#B0C4DE'){
> >>$trcolor='#F0F8FF';}
> >>}
> >>print "";
> >>}
> >I see that you are using a helping variable $colorset.
> >I have a problem reading your code in email, as i do not see 
> hte indents 
> >well, so i restructure it here with _ underscores to make 
> the indents 
> >survive the email program.
> >
> >
> >$trcolor="#F0F8FF"; //1
> >
> >while ($myrow = mysql_fetch_array($result))
> >{
> >___$colorset=0;
> >___if ($trcolor=='#F0F8FF')//1
> >___{$trcolor='#B0C4DE'; //2
> >$colorset=1;
> >___}
> >
> >___if ($colorset==0)
> >___{ if ($trcolor=='#B0C4DE')   //2
> >__{$trcolor='#F0F8FF';   //1
> >__}
> >___}
> >
> >print "";
> >}
> >
> >Lets walk through.
> >In the 1st walk,
> >1a) you enter with color#1 and colorset=0.
> >2b) the first 'if' then sets it to color#2 and colorset=1
> >3c) The second if sees that both conditions are true and set 
> the color back 
> >to color#1.
> >
> >So the first row prints color1.
> >
> >Ok. The code remembers the values, which are color#1 and colorset1.
> >In the next walkthrough,
> >2a) the colorset is set to 0 to start with.
> >At this moment you have the exact situation as with 1a).
> >
> >do you see that? it would be much easier to see what is 
> happening if you 
> >would have only colorset toggling its value and just before 
> printing, 
> >decide what the color is as a result of the value of colorset.
> >Give it a try!
> >
> >Basically:
> >
> >$colorset=0;
> >
> >while ()
> >{ toggle collorset (toggle: if 1 then 0 and opposite)
> >  if colorser=0 color=ff else color=a
> >  print color.
> >}
> >
> >Chris Hayes
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> _
> Surf together with new Shared Browsing 
> http://join.msn.com/?page=features/browse&pgmarket=en-gb&XAPID
> =74&DI=1059
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] RE: newbie alternate row colours in dynamic table -- timed tests

2003-04-05 Thread Daevid Vincent
I had to know... ;-)

Output:

version one:0.56761503219604 seconds
version two:0.3099730014801 seconds
version three:  0.36320495605469 secondss

So the boolean (V2)is faster:

Mine is slightly slower by a 'smidge' (0.06 seconds)

Top one is cleanest but slower.

--- test ---

\n";

$time_start = getmicrotime();
$tf = TRUE;
for ($i = 1; $i < $ITERATIONS; $i++)
{
$tf=!$tf;
($tf) ? "'C7D0E2" : "E3E8F0";
}
$time_end = getmicrotime();
$time2 = $time_end - $time_start;
echo "version two: \t$time2 seconds\n";

$time_start = getmicrotime();
$r = 0;
for ($i = 1; $i < $ITERATIONS; $i++)
{
(($r++ % 2 == 0) ? "'C7D0E2" : "E3E8F0");
}
$time_end = getmicrotime();
$time3 = $time_end - $time_start;
echo "version three: \t$time3 seconds\n";
?>


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



[PHP] Timing test of the parser... Makes no difference

2003-04-05 Thread Daevid Vincent
It seems that it makes almost no difference if you switch in and out of
the parser or stay within it...
Does this seem like a fair test? Having said that, I would suggest
always using the first method as it's much cleaner to read and color
coding works in most editors.

-- output ---

version one:0.098537087440491 seconds
version two:0.096035003662109 seconds

--- test ---


blah 
version one: \t$time1 seconds\n";
echo "version two: \t$time2 seconds\n";
?>



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



[PHP] need config file parsing code.

2003-06-16 Thread Daevid Vincent
I am writing an open source web page that I can't believe doesn't exist
already. basically i want to see all the DHCP clients on my network AND
their nice windows names -- that is the tricky part -- I can't find a
tool that does that part. GRRR...
 
Anyways, here is what I have so far if you want to see it:
http://daevid.com/examples/dhcp/index.php
 
To match up the names however I need to parse the
/var/lib/dhcp/dhcp.leases file and map the "client-hostname" tag to the
proper MAC address.
 
So my question is, does anyone have some code (PHP preferred obviously,
but any language should work or be portable) that will take a file of
the form below and split it into the chunks required. Or anything even
close? For example, a 'chunk' would be between the { and } . I'm sure I
can figure this out, but before I go re-inventing the wheel, thought
someone might have done this already to some degree.
 
lease 192.168.1.3 {
  starts 1 2003/06/16 07:38:55;
  ends 1 2003/06/16 07:48:55;
  binding state active;
  next binding state free;
  hardware ethernet 00:80:45:31:d8:29;
}
lease 192.168.1.6 {
  starts 1 2003/06/16 07:39:27;
  ends 1 2003/06/16 07:49:27;
  binding state active;
  next binding state free;
  hardware ethernet 48:54:e8:26:23:38;
  uid "\001HT\350";
  client-hostname "jme";
}
 
when the script is finished I'll post it up for anyone to use on their
own servers...
 
by the way, does anyone know why "arp -n" (what i'm using) shows
machines that are NOT even turned on? like my notebook shows up despite
having been off for several hours? Is there a way to get a real time
list of the machines on my network? I thought that's what arp did, but
apparently not. :(
 
d


RE: [PHP] need config file parsing code.

2003-06-16 Thread Daevid Vincent
Off the top of your head huh? Damn... That's some code you churned out
there. Just glanced through it, but I'm impressed you took that much time!
Thanks! I'll clean it up and give it a go.

d

> -Original Message-
> From: Lars Torben Wilson [mailto:[EMAIL PROTECTED] 
> Sent: Monday, June 16, 2003 2:45 AM
> To: Daevid Vincent
> Cc: 'PHP-General'
> Subject: Re: [PHP] need config file parsing code.
> 
> 
> On Mon, 2003-06-16 at 01:14, Daevid Vincent wrote:
> > So my question is, does anyone have some code (PHP 
> preferred obviously,
> > but any language should work or be portable) that will take 
> a file of
> > the form below and split it into the chunks required. Or 
> anything even
> > close? For example, a 'chunk' would be between the { and } 
> . I'm sure I
> > can figure this out, but before I go re-inventing the wheel, thought
> > someone might have done this already to some degree.
> >  
> > lease 192.168.1.3 {
> >   starts 1 2003/06/16 07:38:55;
> >   ends 1 2003/06/16 07:48:55;
> >   binding state active;
> >   next binding state free;
> >   hardware ethernet 00:80:45:31:d8:29;
> > }
> > lease 192.168.1.6 {
> >   starts 1 2003/06/16 07:39:27;
> >   ends 1 2003/06/16 07:49:27;
> >   binding state active;
> >   next binding state free;
> >   hardware ethernet 48:54:e8:26:23:38;
> >   uid "\001HT\350";
> >   client-hostname "jme";
> > }
> 
> I just banged this off the top of my head. Little error 
> checking but you
> should be able to see where to add it. It should be tweakable 
> for what 
> you need, at least to get you going.
> 
>  error_reporting(E_ALL);
> ini_set('display_errors', true);
> 
> class LeaseParser {
> // List designators valid within lease blocks here.
> // Add/modify/remove to suit.
> var $_valid_items = 
> array('starts 1',
>   'ends 1',
>   'binding state active',
>   'next binding state',
>   'hardware ethernet',
>   'uid',
>   'client-hostname');
> 
> // Stores any errors we generate during the run. Theses can be
> output
> // directly by calling showErrors();
> var $_errors;
> 
> // Storage for the contents of the lease file while it's being
> working on.
> var $_file_contents;
> 
> // Stores the parsed lease array.
> var $_leases;
> 
> // Put any options you want to define in here, and use setOption()
> to modify
> // it.
> var $_options = 
> array('file_name' => '');
> 
> 
> // Private method. Attempts to load the leases file.
> function _loadFile() {
> if (!$fp = fopen($this->_options['file_name'], 'r')) {
> $this->_errors[] = "LeaseParser::_loadFile(): 
> Failed to load
> {$this->_options['file_name']}";
> return false;
> }
> 
> if (!$file = fread($fp, 
> filesize($this->_options['file_name'])))
> {
> $this->_errors[] = "LeaseParser::_loadFile(): 
> Failed to read
> {$this->_options['file_name']}";
> return false;
> }
> 
> $this->_file_contents =& $file;
> 
> return true;
> }
> 
> 
> // Private method. Attempts to parse the loaded file 
> contents into a
> usable format.
> function _parseFile() {
> if (empty($this->_file_contents)) {
> $this->_errors[] = "LeaseParser::_parseFile(): No leases
> file data to parse.";
> return false;
> }
> 
> $f_temp = explode('}', $this->_file_contents);
> 
> $leases = array();
> 
> foreach ($f_temp as $lease_record) {
> // echo "";
> // print_r($lease_record);
> if (!preg_match('/^\s*lease
> (([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3}))/i',
> $lease_record, $lease_matches)) {
> continue;
> }
> // echo "{$lease_matches[1]}\n";
> $leases[$lease_matches[1]] = array();
> $working_lease =& $leases[$lease_matches[1]];
> foreach ($this->_valid_items as $valid_item) {
> $matches = array();
> $pattern = "/ *({$valid_item}) (.*)\n/i";
> // echo "Checking for $valid_item; $pattern\n";
>   

[PHP] How do I get the exit code of an external program?

2003-06-22 Thread Daevid Vincent
I wish to use Ping to test if some IP addresses are up... Now I could run
the command and parse to find various string components like this:

[EMAIL PROTECTED] bin]# ping -n -c 3 -w 2 -q 192.168.1.60
PING 192.168.1.60 (192.168.1.60) from 192.168.1.1 : 56(84) bytes of data.
--- 192.168.1.60 ping statistics ---
2 packets transmitted, 0 received, 100% loss, time 1012ms


[EMAIL PROTECTED] bin]# ping -n -c 3 -w 2 -q 192.168.1.4 
PING 192.168.1.4 (192.168.1.4) from 192.168.1.1 : 56(84) bytes of data.
--- 192.168.1.4 ping statistics ---
2 packets transmitted, 2 received, 0% loss, time 999ms
rtt min/avg/max/mdev = 0.322/0.340/0.358/0.018 ms


but it would be much more efficient if I could just use the built in exit
codes that 'ping' provides as per 'man ping':

"If ping does not receive any reply packets at all  it  will  exit  with
 code  1.  If  a packet count and deadline are both specified, and fewer
 than count packets are received by the time the deadline  has  arrived,
 it  will  also  exit with code 1.  On other error it exits with code 2.
 Otherwise it exits with code 0. This makes it possible to use the  exit
 code to see if a host is alive or not."

So it seems to me there needs to be another PHP function like exec(),
shell(), etc. that is the equivillent of the php exit() function but for
external programs. One that simply returns the integer exit code of an
executed shell program...


http://daevid.com


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



FW: [PHP] How do I get the exit code of an external program?

2003-06-22 Thread Daevid Vincent


-Original Message-
From: Daevid Vincent [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 22, 2003 8:05 PM
To: 'Don Read'
Subject: RE: [PHP] How do I get the exit code of an external program?




> -Original Message-
> From: Don Read [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, June 22, 2003 7:58 PM
> To: Daevid Vincent
> Cc: PHP Lists
> Subject: Re: [PHP] How do I get the exit code of an external program?
> 
> 
> 
> On 23-Jun-2003 Daevid Vincent wrote:
> > I wish to use Ping to test if some IP addresses are up... 
> Now I could run
> > the command and parse to find various string components like this:
> > 
> 
> 
> > 
> > So it seems to me there needs to be another PHP function 
> like exec(),
> > shell(), etc. that is the equivillent of the php exit() 
> function but for
> > external programs. One that simply returns the integer exit 
> code of an
> > executed shell program...
> > 
> > 
> 
> exec(), system(), & popen()/pclose() will return exit code.
> 
> The manual is your friend.

http://us3.php.net/manual/en/function.exec.php
string exec ( string command [, array output [, int return_var]])
exec() executes the given command, however it does not output anything. It
simply returns the last line from the result of the command.

However, you are correct in that there is the optional parameter that I've
never used before. Thanks for pointing that out...

http://us3.php.net/manual/en/function.system.php
string system ( string command [, int return_var])
system() is just like the C version of the function in that it executes the
given command and outputs the result. If a variable is provided as the
second argument, then the return status code of the executed command will be
written to this variable. 

The problem is that system want's to dump the output to the screen!!! I need
a command that will allow me to execute/system the command "silently" and
then *I* can do something based upon the exit code...


function active_nMap()
{
$test = exec("/usr/bin/nmap -sP ".$this->IP);
if ( strstr($test,"1 host up") ) 
$this->active = true;
else
$this->active = false;

return $this->active;
}

function active_ping()
{
$test = `ping -n -c 1 -w 1 -q $this->IP`;
if ( strstr($test,"100% loss") ) 
$this->active = false;
else
$this->active = true;

return $this->active;
}


function active_ping_exit()
{
//http://us3.php.net/manual/en/function.system.php
$test = system("ping -n -c 1 -w 1 -q $this->IP", $code);
if ( $code == 0 ) 
$this->active = true;
else
$this->active = false;

return $this->active;
}





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



[PHP] DHCP client web page

2003-06-23 Thread Daevid Vincent
Okay, my dhcp client web page is pretty much done...
http://daevid.com/examples/dhcp/
The .tgz file is linked at the bottom if you want it.

This was also an extreme amount of work just to simply see the active leases
and 'client-hostname' associated with an IP/MAC?! Seems to me there should
have been a tool included with dhcpd that does this at the command line.
*sigh*

Much thanks to Lars Torben Wilson for the dhcpd.leases parser.

-


What I don't understand is why my dhcpd.leases file doesn't have an entry
for my notebook (10.10.10.69) yet I specifically put this entry in
/etc/dhcpd.conf

host orinoco.daevid.com {
   hardware ethernet 00:02:2D:3C:7C:FB; 
   fixed-address 10.10.10.69; 
}

So I do get assigned the IP and everything works from a network standpoint,
but why doesn't the /var/lib/dhcp/dhcpd.leases file have an entry that
should look something like:

lease 10.10.10.69 {
  starts 1 2003/06/23 08:40:11;
  ends 1 2003/06/23 08:50:11;
  binding state active;
  next binding state free;
  hardware ethernet 00:02:2D:3C:7C:FB;
  client-hostname "locutus";
} 

Yet I don't. :( In fact, it seems that ANY devices that I assign an IP using
the MAC (such as TiVo, Replay, other servers), don't have entries in the
dhcpd.leases file?! Why is that? Is this a bug or by design?

I'm running a RedHat 8.0 system with the following RPMs:
dhcpcd-1.3.22pl1-7
dhcp-3.0pl1-26 



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



RE: [PHP] free web host needed.

2003-06-24 Thread Daevid Vincent
On a 'non sarcastic' note... Perhaps the original poster should just set
up their own linux box and run it off their home cable/dsl line. I've
been doing it for years and it works wonderfully. I'm even now a
free-node on the Seattlewireless.net network for people in the hood who
need a quick bit-fix (the amount of bandwidth they consume in the 1 hour
or less they squat is negligible and I encourage all of you to open your
wifi nodes up (with a good firewall ruleset of course)). I digress...

I host several virtual domains/hosts for various friends of mine for
free. So, it's not unheard of that you could find or ask someone to host
you. When I started out in 1995, my local ISP liked my domain name (I
used to own "TheMatrix.com" which was the name of my recording studio
and hosted me for free).

You can also look around in your community. Fe. The bay area has some
free hosting solutions that are funded by the state for non-profit orgs.
So, say you set up a "Coping with Fibromyalgia" website, they will give
you the space and host you. This has carried up here to Seattle as well.

Anyways, if you're looking for a  free host, then you prolly aren't
doing a site with that much traffic. If you start to make money with
your site, then you'll have the funds to pay a real ISP.

http://daevid.com

> -Original Message-
> From: Jerry M. Howell II [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, June 24, 2003 7:31 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Expensive WEB HOST NEEDED!
> 
> 
> > > -Original Message-
> > > From: Jay Blanchard [mailto:[EMAIL PROTECTED]
> > > Sent: 24 June 2003 13:20
> > > To: Denis 'Alpheus' Cahuk; [EMAIL PROTECTED]
> > > 
> > > [snip]
> > > Like I said, I need a web host.
> > > It MUST support PHP, mySQl and sending emails, optional.
> > > It shouldn't have any ads (pop-ups, ads), but I will 
> allow if it has
> > > watermarks (SMALL! watermarks).
> > > It should be TOTALY FREE!
> > > [/snip]
> You must be kidding. You probably will find one that supports 
> one or two
> of these features for free but anyplace thats free will probably have
> banners and mabe even watermarks. Most anyone can probably 
> send you to a
> cheep place as prices have droped since I started but what your asking
> is for someone not to make a living? Kinda unreasonable. 
> Anyways, I try
> and avoid these threads as they waste mucho bandwith but here I am :)
> 
> -- 
> Jerry M. Howell II
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] PHP script in C SHELL

2003-06-25 Thread Daevid Vincent
Do this:

snip-
#!/bin/php(or wherevery you have the php executable binary stored)
>8)&0xFF;
}
?>
snip-
chmod 755 myfile.php

Then just execute "myfile.php" as any other program.



> -Original Message-
> From: Marcos [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, June 25, 2003 6:18 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP script in C SHELL
> 
> 
> I need to execute the archive php below in the server Apache, but I
> perceived that I obtain the waited result if I use csh (C 
> shell) and not
> using bash, somebody could say me as to execute this script in csh?
> 
> $pipe = "$username\n$password\n";
> $pwauth = "/usr/local/apache/bin/pwauth";
> if($cmd = popen ($pwauth, "w")) {
> fwrite($cmd, $pipe);
> $status=(pclose($cmd)>>8)&0xFF;
> }
> 
> Thank's
> 
> Marcos
> [EMAIL PROTECTED]
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.491 / Virus Database: 290 - Release Date: 18/06/03
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Forms

2003-06-30 Thread Daevid Vincent
Additionally, you could put this in a header file or the top of your page:


reset ($_GET);
while (list ($key, $val) = each ($_GET)) {
//echo "$key => $val\n";
$$key = $val;
}

reset ($_POST);
while (list ($key, $val) = each ($_POST)) {
//echo "$key => $val\n";
$$key = $val;
}

reset ($_SESSION);
while (list ($key, $val) = each ($_SESSION)) {
//echo "$key => $val\n";
$$key = $val;
}

So you can leave register_globals = off and get mostly the same
functionality (and security issues if you're worried about them too).

> -Original Message-
> From: Petre Agenbag [mailto:[EMAIL PROTECTED] 
> Sent: Monday, June 30, 2003 7:14 AM
> To: Simon Chappell
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Forms
> 
> 
> Have you checked register_globals = on/off in your php.ini?
> If register_globals=off, then you must access your POST variables by:
> 
> $_POST['whatever'];
> 
> and your get (the stuff you put at the end of your URL's):
> 
> $_GET['whatever'];
> 
> 
> On Mon, 2003-06-30 at 15:48, Simon Chappell wrote:
> > Hi can anyone help me with this?
> > 
> > I have been failing to get any forms working with PHP now I 
> have run out of 
> > ideas? Having bought 3 books the latest one being php & mysql for 
> > dummies(which might be appropriate for me) I am still 
> failing at this hurdle.
> > 
> > the following script is a classic example taken straight 
> out of the book, I 
> > get round the $PHP_SELF problem ok but then all the script 
> does is loop back 
> > to itself? 
> > 
> > 
> > 
> > 
> > SQL Query Sender
> > 
> > 
> >  >  $user="root";
> >  $host="localhost";
> >  $password="";
> > 
> >  /* Section that executes query */
> >  if (@$form == "yes")
> >  {
> >mysql_connect($host,$user,$password);
> >mysql_select_db($database);
> >$query = stripSlashes($query) ;
> >$result = mysql_query($query);
> >echo "Database Selected: $database
> >   Query: $query
> >   Results
> >   ";
> >if ($result == 0)
> >   echo("Error " . mysql_errno() . ": " . 
> mysql_error() . "");
> > 
> >elseif (@mysql_num_rows($result) == 0)
> >   echo("Query completed. No results returned.");
> >else
> >{
> >  echo "
> >
> > ";
> >  for ($i = 0; $i < mysql_num_fields($result); $i++) 
> >  {
> >  echo("" . mysql_field_name($result,$i) 
> . "");
> >  }
> >  echo " 
> >
> >";
> >  for ($i = 0; $i < mysql_num_rows($result); $i++)
> >  {
> > echo "";
> > $row = mysql_fetch_row($result);
> > for ($j = 0; $j < mysql_num_fields($result); $j++)
> > {
> >   echo("" . $row[$j] . "");
> > }
> > echo "";
> >  }
> >  echo "
> >   ";
> >}
> >echo "
> >  
> >   
> >   
> >value=\"New Query\">
> >value=\"Edit Query\">
> >  ";
> >unset($form);
> >exit();
> >  }
> > 
> >  /* Section that requests user input of query */
> >  @$query = stripSlashes($query);
> >  if (@$queryButton != "Edit Query")
> >  {
> >$database = " ";
> >$query = " ";
> >  }
> > ?>
> > 
> > ?form=yes method="post">
> >  
> >   
> >Type in database name
> >
> >   $database ?> >
> >
> >   
> >   
> >Type in SQL query
> >   echo $query 
> > ?>
> >
> >   
> >   
> > value="Submit 
> > Query">
> >   
> >  
> > 
> >  
> > 
> > 
> > 
> > Any ideas would be greatly appreciated as I am floundering badly!
> > 
> > Simon
> > 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


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



RE: [PHP] Need help with Apache and .htaccess vs. directive. -- SOLVED

2002-08-09 Thread Daevid Vincent

Tim, you are my father! That was it. That stupid trailing /*

Making it: 
 
instead of:
 
worked

> -Original Message-
> From: Tim [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, August 08, 2002 11:36 PM
> 
> 
> What if you remove the /* from the directory-path in the
>  directive?  If 
> /home/epiller/public_html/vrexhibits/* doesn't match 
> /home/epiller/public_html/vrexhibits that would explain why 
> it didn't work in the .htaccess file (because the 
> AllowOverride wouldn't be
> applied) and why the  directive didn't apply.  Just a guess.
> 
>   - Tim
> 
> > -----Original Message-
> > On Thu, Aug 08, 2002 at 06:16:03AM -0700, Daevid Vincent wrote:
> >
> > I'm baffled. Using the example I found here:
> > http://www.devarticles.com/content.php?articleId=143&page=3
> > 
> > I have a working site here:
> > http://daevid.com/examples/vrexhibits/vrbooth
> > 
> > There is a .htaccess file in the vrexhibits directory that contains:
> >  
> >   ForceType application/x-httpd-php 
> > 
> > And of course the PHP file named "vrbooth" in the same dir as 
> > illustrated above.
> > 
> > Now...
> > 
> > I'm trying to have a virtual host of the same site basically here
> > (this is running on the SAME server!):
> > 
> > http://www.vrexhibits.com/vrbooth
> > 
> > Why doesn't that page show up correctly. It is speweing out
> the source
> > code instead. If I rename the page to vrbooth.phtml and reload, it
> > works fine, but of course, that isn't what I want/need.
> > 
> > I had the same .htaccess file and everything. Then I tried
> it without
> > the .htaccess and moving the  directive into the VirtualHost
> > section (for security as well), but still it spews out 
> code. Ugh. What
> > am I missing here? It is as if the .htaccess file was totally being
> > ignored and it's also being ignored or over-ridden in here too 
> > somehow.
> > 
> > 
> > DocumentRoot /home/epiller/public_html/vrexhibits
> > ServerName VRExhibits.com
> > ServerAlias www.VRExhibits.com *.VRExhibits.*
> > User epiller
> > Group epiller
> > 
> > Options All +Includes
> > AllowOverride All
> > Order allow,deny
> > Allow from all
> > 
> >   ForceType application/x-httpd-php 
> >  
> > 
> > 


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




[PHP] About the code display on php.net

2002-10-29 Thread Daevid Vincent
Could someone please fix the function pages on http://www.php.net, so
that when people submit code all nice and formatted, it retains that
formatting in the contributed notes section? There are some really
intricate examples, and it just makes it that much easier to read. Not
to mention, the left aligned code detracts from the professional look of
an otherwise excellent resource/site.

I should think this fix is as simple as using   tags (rather
than, or in addition to the  tags you have now).

While you're at it, please expand the  on this page:
http://www.php.net/manual/add-note.php
To facilitate someone entering in their code without being squished into
these itty bitty 40 column by 6 row spot.


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




RE: [PHP] Who can tell me where I can get the cracked Zend Encoder3.0 ?

2002-10-31 Thread Daevid Vincent
I have it. You can download it from my website here:
http://www.siia.net/piracy/

idiot.

> -Original Message-
> From: jianking [mailto:liaus@;10mail.net] 
> Sent: Thursday, October 31, 2002 7:00 AM
> 
> 
> Who can tell me where I can get the cracked Zend Encoder 3.0 ?


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




[PHP] How do I convert an array into a mask?

2002-11-05 Thread Daevid Vincent
Does anyone know of a nice efficient way to convert an array of values
into a "mask"...

Here's the deal. Given an array such that:

$purchitem[0] = 1;
$purchitem[1] = 3;
$purchitem[2] = 4;

I want to end up with a variable like this:

$mask = "10110";

Additionally, my theory is that then the person purchases another book
later

$purchitem[0] = 2;

My new mask should be $purchmask = "01000";

Then I can load their previous mask from the database and boolean OR it
with the new mask to set the correct permissions. i.e.

$newmask = $mask | $purchmask;

Or ideally = "0"

Can I boolean OR strings like that in the way I 'hope' it will work? Do
I need to convert it to an intermediate stage or cast it or anything?

Does this make sense? It's for an online book shopping cart. I have the
reverse working, where I can split the mask into what books. And I also
have the $purchitem[] working.


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




RE: [PHP] How do I convert an array into a mask?

2002-11-06 Thread Daevid Vincent
Michael, I like your idea, and had I designed this site, I would have
the bitmask simmilar to what you suggest. However, I'm a contractor
modding an existing/legacy site. Basically the way they have it, is that
each user has a field in the db that is simply a string/mask of which
books a person has access to see. So given the example below, "10110"
means that the person can view books 1, 3, and 4, but not 2 or 5. dig?

Now, I can brute force this, since there are only a few books. That
doesn't lend itself nicely to expansion, but may be my only way. I just
have a gut feeling that it can be automated somehow. To turn 1,3,4 into
10110 seems like there is some 'math' there that can work. I also
thought there might be a built in PHP function that may point me in the
right direction. I'll post my solution when I get it working if it's
elegant...

Thanks anyways.

P.s. thanks for the correction on boolean vs bitwise OR. Duh. I should
have known that ;-)

> -Original Message-
> Does anyone know of a nice efficient way to convert an array 
> of values into a "mask"...
> 
> Here's the deal. Given an array such that:
> 
> $purchitem[0] = 1;
> $purchitem[1] = 3;
> $purchitem[2] = 4;
> 
> I want to end up with a variable like this:
> 
> $mask = "10110";
> 
> Additionally, my theory is that then the person purchases 
> another book later
> 
> $purchitem[0] = 2;
> 
> My new mask should be $purchmask = "01000";
> 
> Then I can load their previous mask from the database and 
> bitwise OR it with the new mask to set the correct permissions. i.e.
> 
> $newmask = $mask | $purchmask;
> 
> Or ideally = "0"
> 
> Can I boolean OR strings like that in the way I 'hope' it 
> will work? Do I need to convert it to an intermediate stage 
> or cast it or anything?
> 
> Does this make sense? It's for an online book shopping cart. 
> I have the reverse working, where I can split the mask into 
> what books. And I also have the $purchitem[] working.


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




RE: [PHP] How do I convert an array into a mask?

2002-11-06 Thread Daevid Vincent
That's the EASY part John!

The hard part is converting the array (which was a checkbox array from a
form submission) into the binary string (as per the original post)

> Here's the deal. Given an array such that:
> $purchitem[0] = 1;  //purchased book #1 checkbox enabled
> $purchitem[1] = 3;  //purchased book #3 checkbox enabled
> $purchitem[2] = 4;  //purchased book #4 checkbox enabled
> I want to end up with a variable like this:
> $mask = "10110";

Get it now? ;-)
 

> -Original Message-
> From: John W. Holmes [mailto:holmes072000@;charter.net] 
> Sent: Wednesday, November 06, 2002 4:19 AM
> To: 'Jon Haworth'; [EMAIL PROTECTED]
> Subject: RE: [PHP] How do I convert an array into a mask?
> 
> 
> > Hi John,
> > 
> > > > So given the example below, "10110"
> > > > means that the person can view books 1, 3, and 4,
> > > > but not 2 or 5. dig?
> > >
> > > Explain that to me... I know binary, but I can't see
> > > how that equates to 1, 3, and 4.
> > 
> > Because you know binary :-)
> > 
> > The above is a series of yes/no flags, not a binary number. Reading
> from
> > left to right:
> > 
> > book 1 : yes
> > book 2 : no
> > book 3 : yes
> > book 4 : yes
> > book 5 : no
> > 
> > Cheers
> > Jon
> 
> Ok, so knowing binary and now knowing that, :)
> 
> Couldn't you just treat the number as a string and tear it 
> apart to see what permissions the user has?
> 
>  
> $var = "10110";
> 
> $l = strlen($var);
> 
> for($x=0;$x<$l;$x++)
> {
>   if($var{$x}) 
>   { echo "Permission for book $x is good\n"; }
>   else
>   { echo "Permission for book $x is bad\n"; }
> }
> 
> ?>


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




RE: [PHP] How do I convert an array into a mask?

2002-11-06 Thread Daevid Vincent
Ernest, close but you have it reversed for my needs (i.e. true binary
form). Notice that my LSB is to the left, not right.

As Evan Nemerson pointed out to me, the decbin(), bindec(), Dec2Bin()
and Bin2Dec() functions shed some light. What I need is the equivillant
functions but with a way to flip the order of the bits from LSB to MSB.
I believe that is called "little endian" and "big endian"?

I've been playing with one function to convert my purchitem[] to a
decimal value, then use the decbin() to get a string, then reverse it...
Seems cumbersome but mebbe that's the solution?

function Array2Dec($array)
{
$decimal = 0;
while ( list($Key, $Val) = each($array) ) 
{  
  //notice the ($Val - 1) because 
//our array starts at index 0, not 1
$decBit = pow(2, ($Val - 1));
$decimal += $decBit;
echo "array[".$Key."] = ".$Val." :: ".$decBit;
} 
return $decimal;
}

function reverseString($myString)
{
$charArray = preg_split('//', $myString, -1,
PREG_SPLIT_NO_EMPTY);
$revchars = array_reverse($charArray);
$revString = "";
while ( list($Key, $Val) = each($revchars) ) { $revString .=
$Val; }
return $revString;
}


> -Original Message-
> From: Ernest E Vogelsinger [mailto:ernest@;vogelsinger.at] 
> Sent: Wednesday, November 06, 2002 1:28 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] How do I convert an array into a mask?
> 
> 
> At 10:18 06.11.2002, Daevid Vincent said:
> [snip]
> >doesn't lend itself nicely to expansion, but may be my only 
> way. I just 
> >have a gut feeling that it can be automated somehow. To turn 
> 1,3,4 into 
> >10110 seems like there is some 'math' there that can work. I also
> [snip] 
> 
> It's quite easy using the left-shift operator "<<". Note that 
> the function below only works for values 1-31 on 32bit systems.
> 
>  
> function makebits(&$array)
> {
> $result = 0;
> foreach ($array as $seq) {
> if (is_numeric($seq)) {
> $i = 1 << ($seq-1); 
> // assuming ID's are 1-based
> $result += $i;
> }
> }
> return $result;
> }
> 
> $a = array(1,3,5,9);// 0001 0001 0101 = 0x115
> echo '', sprintf('0x%x', makebits($a)), "\n";
> 
> ?>


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




RE: [PHP] How do I convert an array into a mask?

2002-11-06 Thread Daevid Vincent
Oooh! I think you're on to something there. Nice!

Hey, what's the "@" symbol for? I see in the manual the "&" is a
reference (like a pointer in C I assume), but I can't find the "@"
explained.

>   if(@$purchitem[$y] == $x)


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




[PHP] For ... <= max($myArray) vs For ... <= $max

2002-11-08 Thread Daevid Vincent
Is PHP smart enough to optimize loops?

That is, are these two 'for...loops' equivalent or is one slower than
the other?

$max = max($myArray);
for( $x = 1; $x <= $length; $x++ ) {}

 -- OR --

for( $x = 1; $x <= max($myArray); $x++ ) {}

My gut instinct tells me since PHP is interpreted, that the top one is
the better way to go, but with the Zend Optimizer, I don't know if PHP
handles them the same way or not?


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




RE: [PHP] For ... <= max($myArray) vs For ... <= $max

2002-11-08 Thread Daevid Vincent
> From: Kjartan Mannes [mailto:kjartan@;zind.net] 
> 
> Friday, November 8, 2002, 12:13:01 PM, Daevid Vincent wrote:
> > $max = max($myArray);
> > for( $x = 1; $x <= $length; $x++ ) {}
> 
> >  -- OR --
> 
> > for( $x = 1; $x <= max($myArray); $x++ ) {}
> 
> > My gut instinct tells me since PHP is interpreted, that the 
> top one is 
> > the better way to go, but with the Zend Optimizer, I don't 
> know if PHP handles them the same way or not?
> 
> The first one is faster, but it depends on the site of the 
> array and how often you call the loop. I prefer doing it like 
> this though:
> 
>  for($x = 1, $max = count($myArray); $x <= $max; $x++ ) {}

Just a little point-out that I used max() not count() because I need to
loop on the *largest value* in the array, not how many *elements* are
actually in the array. But the logic is still sound, and it is true that
calling a function is sub-optimal it seems, even though my array doesn't
change in any way when the for loop is called. PHP still calls the max()
or count() function each time anyways. So alas, I have to create another
variable that serves one single purpose and has a very finite lifespan.
;-)

> For some good optimization (and other) tips check out:
>   http://phplens.com/lens/php-book/optimizing-debugging-php.php
>   http://www.lerdorf.com/tips.pdf

Thanx for the pointers. I'll check 'em out.

d


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




[PHP] How I Got PHP4.2.2, Apache 2.0, mySQL and RedHat 8.0 to work

2002-11-18 Thread Daevid Vincent
Well, it seems there are some glitches with and snags and other fun
stuff to deal with when doing a straight RedHat 8.0 install. It turns
out you have to edit your /etc/php.ini and uncomment out the
"extension=mysql.so" line for starters. It also helps to set
"short_open_tag = On".

Another fun thing to contend with is the fact that "register_globals" is
now off by default, s, read this page:
http://www.zend.com/zend/art/art-sweat4.php to see how to get around
this (without turning RG on of course).

I have some sites that use .php and some that use .phtml and you'd think
it would be as simple as modifying /etc/httpd/conf.d/php.conf, dupe the
entry and change the extension. Wrong. What I did was change it to:

 
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 524288

DirectoryIndex index.php index.phtml

I use virtual hosts but none use SSL currently, and haven't figured that
part out with the SSL.conf so I just renamed it to ssl.conf.disabled and
created a virtual-hosts.conf that looks like this:


DocumentRoot /home/foo/public_html
ServerName foo.com
ServerAlias ww.foo.com *.foo.*
ErrorLog logs/foo-error_log
CustomLog logs/foo-access_log common


And at the end of the httpd.conf file you have to turn VH on by
uncommenting "NameVirtualHost *"
And I also added this at the bottom to catch all that don't match with
an entry in my virtual-hosts.conf file above:


ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName localhost
ErrorLog /etc/httpd/logs/error_log
CustomLog /etc/httpd/logs/access_log common


I also went ahead and installed mySQL-MAX, so you need to create a
/etc/my.cnf file and put something like:

[mysqld]

# You can write your other MySQL server options here
# ...

innodb_data_home_dir=

#  Data file(s) must be able to
#  hold your data and indexes.
#  Make sure you have enough
#  free disk space.
innodb_data_file_path = ibdata1:10M:autoextend

#  Set buffer pool size to
#  50 - 80 % of your computer's
#  memory
set-variable = innodb_buffer_pool_size=70M
set-variable = innodb_additional_mem_pool_size=10M

#  Set the log file size to about
#  25 % of the buffer pool size
set-variable = innodb_log_file_size=20M
set-variable = innodb_log_buffer_size=8M

#  Set ..flush_log_at_trx_commit
#  to 0 if you can afford losing
#  some last transactions 
innodb_flush_log_at_trx_commit=1

set-variable = innodb_lock_wait_timeout=50
#innodb_flush_method=fdatasync
#set-variable = innodb_thread_concurrency=5

skip-locking
set-variable = max_connections=200
#set-variable = read_buffer_size=1M
set-variable = sort_buffer=1M
#  Set key_buffer to 5 - 50%
#  of your RAM depending on how
#  much you use MyISAM tables, but
#  keep key_buffer + InnoDB
#  buffer pool size < 80% of
#  your RAM
set-variable = key_buffer=10M

Somehow the pretty "/etc/rc.d/init.d/mysql" script has changed (probably
due to mysqlMax) I like the old one with the green [ OK ] messages like
everything else there and I'm not sure how to get it back :( but it
works for now and I have innoDB tables, so I can't complain too much.

Hope this helps someone and saves them the nearly 7 hours I've spent
today getting it all working. Most of that is sifting through a million
web pages and trying to find the magic incantation on Google to get the
solutions.

DÆVID.
http://daevid.com


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




[PHP] How do I split an alphabetical list (array) into A-M and N-Z?

2002-07-03 Thread Daevid Vincent

Anyone have a function that will take an alphabetical list of names (in
an array already) and split it into two 'chunks' (arrays) A-M and N-Z?

So, let's say I have:

Abby Road
BobbyCraft
Darren's doodads
Farenheit 456
generic name
MyCom.com
Ninety Nine
NoCo
O U 1
O'reilly Publishing
Oracle
PSI
Test Company

I want to end up with one array/chunk that has (A-M):

Abby Road
BobbyCraft
Darren's doodads
Farenheit 456
generic name
MyCom.com

And the other that contains (N-Z):

Ninety Nine
NoCo
O U 1
O'reilly Publishing
Oracle
PSI
Test Company



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




[PHP] Need to convert seconds to DD:HH:MM:SS

2003-09-19 Thread Daevid Vincent
So clearly I'm being stupid and this seemingly basic math is beyond my
abilities at the moment. I've tried various things, but can't seem to figure
out how to get the number of days integrated in here for $hh that are > 24.
I've googled for code fragments and can't find one. All seem to deal with
the Epoch and dates. I just want to take a number of seconds and convert it
to days:hours:minutes:seconds...  This function works for what it does, can
someone embelish it to handle days too?

function convertToHHMMSS($seconds)
{
$hoursPerDay= 24;
$SecondsPerHour = 3600;
$SecondsPerMinute   = 60;
$MinutesPerHour = 60;

$hh = intval($seconds / $SecondsPerHour);
$mm = intval($seconds / $SecondsPerMinute) % $MinutesPerHour;
$ss = $seconds % $SecondsPerMinute;

return $hh."h:".$mm."m:".$ss."s";
}

Daevid Vincent
http://daevid.com
 

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



[PHP] How can I populate or bypass the mod_auth_mysql prompt

2003-09-19 Thread Daevid Vincent
I am using mod_auth_mysql to protect some directories. All works great.
However, when someone joins up, I send them a username/pw for them to login
with. What I'd like is in addition, to shoot them into the protected section
so they don't have to login with these credentials (the first time). I tried
to set these PHP variables, but I still am prompted. Is there some other
trick or way to do this?

$_SERVER['PHP_AUTH_USER'] = $login;
$_SERVER['PHP_AUTH_PW'] = $password;

Daevid Vincent
http://daevid.com
 

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



RE: [PHP] How can I populate or bypass the mod_auth_mysql prompt

2003-09-19 Thread Daevid Vincent
Thanks for the reply, however that seems extremely insecure as both user and
pw are in the url. Got any other suggestions to try?
 

> -Original Message-
> From: Paul Nicholson [mailto:[EMAIL PROTECTED] 
> Sent: Friday, September 19, 2003 6:46 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] How can I populate or bypass the 
> mod_auth_mysql prompt
> 
> 
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On Friday 19 September 2003 09:36 pm, Daevid Vincent wrote:
> > I am using mod_auth_mysql to protect some directories. All 
> works great.
> > However, when someone joins up, I send them a username/pw 
> for them to login
> > with. What I'd like is in addition, to shoot them into the protected
> > section so they don't have to login with these credentials 
> (the first
> > time). I tried to set these PHP variables, but I still am 
> prompted. Is
> > there some other trick or way to do this?
> 8< snip
> 
> Hey Daevid,
> Redirect them to the page using: 
> http://username:[EMAIL PROTECTED]/protected_section/
> HTH!  HAND!
> ~Paul 
> 
> - -- 
> ~Paul Nicholson
> Design Specialist @ WebPower Design
> [EMAIL PROTECTED]
> www.webpowerdesign.net
> "The webthe way you want it!"
> 
> 
> "It said uses Windows 98 or better, so I loaded Linux!"
> Registered Linux User #183202 using Register Linux System # 81891
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.0.7 (GNU/Linux)
> 
> iD8DBQE/a7EcDyXNIUN3+UQRAnr0AJ9LubzjwlqYpv/agFEaDlRGDGUqqACeN3Bw
> yPJzxGXPY7BuXUTZShuRfa0=
> =fr4z
> -END PGP SIGNATURE-
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



[PHP] How to achieve bi-directional communication between two servers?

2003-09-22 Thread Daevid Vincent
I have a script on all my client machines that checks into a master server
to dump statistical information into a mysql database. That works great
(using $_GET and an encrypted string). However, now I'd like to have the
client check in to the master and see if it needs any updates. If so, it
will set flags in its own database. How do I establish the link back without
the client running a webserver of it's own?

Scenario:

Client checks into master Update server and blindly dumps it's statistics
into the master database.

Master database wants to give the client more data to process or update a
field in the client's own database.

Client accepts the data from the master, changes it's own database, and
reports back an ACK that it was successful.

Master marks it's own database that the handshake happened and both are in
synch.


Now, I've seen this NuSOAP thing that that seems to do this concept, however
it's a bit overkill for my needs and I also don't want to be dependant upon
a 'third party' software for this task. Also, my XML is not so good ;-)

Is http://us3.php.net/function.fsockopen what I need? Whatever the solution,
it is mission critical that it works. I'll be tunneling through SSL too, but
that should be transparent I'd think.

Daevid Vincent
http://daevid.com
 

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



[PHP] What is the proper way to use mysql db on a multipage site?

2003-09-26 Thread Daevid Vincent
I sent this to php-db with no reply, so I'll try it here then...
 

-Original Message-
From: Daevid Vincent [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 24, 2003 4:21 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] What is the proper way to use mysql db on a multipage
site?


I've been coding with PHP and mySQL for years. And this part has never sat
right with me and finally I'm getting the nerve to ask how the pros out
there do this...

What I do is have a "db.php" file that contains:

$db = mysql_connect ("localhost","username","password") 
or die ("Could not connect to SQL server.");
mysql_select_db ("mydb",$db) 
or die ("Could not select Database");


Then at the top of every page, I require_once("db.php");

But it just seems so wasteful to keep making that mysql_connect().

Isn't there a way to store the $db result so I don't have to keep
connecting.
And how about the mysql_select_db() part too? Since I'm going to stay in the
same db most of the time.

I thought I read that I can't use a $_SESSION for it, and that's the only
way I know of to have it be available on each page?


Daevid Vincent
http://daevid.com
 

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

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



RE: [PHP] where are the good examples of using OOP?

2003-09-28 Thread Daevid Vincent
http://daevid.com/examples/dhcp/index.php

Was my first try with php's OOP. Source linked at bottom of page.

> -Original Message-
> From: anders thoresson [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, September 28, 2003 3:53 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] where are the good examples of using OOP?
> 
> 
> Hi,
> 
>   I'm just about to take the first step into OOP with PHP. 
> I've searched 
> the web for tutorials, and even if there are alot, most of them use 
> metaphores with houses or cars or other real life things to 
> explain what 
> classes and methods are.
> 
>   I wonder if someone can point me to tutorials that uses 
> real PHP examples 
> instead, examples that shows me in a direct way how to use 
> OOP. My biggest 
> trouble right now is what should be the classes and what 
> should be the 
> methods.
> 
>   Also, I wonder if someone could name a blog-application och web 
> album-application that uses OOP in a good way and which I can 
> have a look 
> at to see how things are done.
> 
>   Best regards,
> 
> -- 
> anders thoresson
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



php-general@lists.php.net

2003-10-10 Thread Daevid Vincent
How can I cause PHP to fire off a unix program and NOT wait for a reply.
Basically I want to use the "&" love the unix provides, but it seems that
exec, passthrough, system and even ` ` all wait for a return despite my
putting something like exec("/bin/scan &"); or `/bin/scan &`

*sigh*

The sitch is that I'm scanning/pinging/nmap a HUGE amount of IP addresses.
Perhaps 254 - 65000 or more individual iP addresses. We have a multithreaded
scanner that we wrote in C that can to this quickly, but it's still a wait.
It pulls from a db the ips to scan and sets their up/down flags. My php
scheduler page queries to get the ones that are up. 

So as you see, I don't want to wait for a return code, I know the status via
the db and how many rows are done/need to be done. 

Daevid Vincent.
http://daevid.com

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



php-general@lists.php.net

2003-10-10 Thread Daevid Vincent
Yeah, that is the 'hack' solution I came up with too. LOL.

I guess I was hoping for something more elegant...

Is there a reason that PHP doesn't handle the & properly? I mean, it seems
as though you'd have to go out of your way to force it NOT to spawn the task
in the background. If PHP was just executing the command in a shell, it
seems that the OS would handle the & for you... 
  
d

> -Original Message-
> From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 10, 2003 4:31 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: How to fire off a unix command WITHOUT 
> waiting for it to return (I want to use &)
> 
> On Fri, 10 Oct 2003 16:07:54 -0700, Daevid Vincent 
> <[EMAIL PROTECTED]> 
> wrote:
> 
> > How can I cause PHP to fire off a unix program and NOT wait 
> for a reply.
> > Basically I want to use the "&" love the unix provides, but 
> it seems that
> > exec, passthrough, system and even ` ` all wait for a 
> return despite my
> > putting something like exec("/bin/scan &"); or `/bin/scan &`
> >
> > *sigh*
> 
> write simple shell script wrapper that does it for you:
> 
> #!/bin/sh
> /bin/scan &
> 
> 
> Then call the wrapper.
> 
> 
> HTH, Curt.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



[PHP] BUG: sprintf(%u) and ip2long

2003-10-14 Thread Daevid Vincent
Could be my not understanding of something, but I think there is a bug in
using ip2long() and sprintf(%u) as indicated on this page:
http://us4.php.net/manual/en/function.ip2long.php

Look at the example below:

//this conversion seems broken
//  $startIP_long = sprintf("%u",ip2long($QRange1));
//  $endIP_long = sprintf("%u",ip2long($QRange2));

$startIP_long = ip2long($QRange1);
$endIP_long = ip2long($QRange2);

echo "QRange1 = ".$QRange1." and QRange2 = ".$QRange2."";
echo "startIP_long = ".$startIP_long." and endIP_long =
".$endIP_long."";
echo "startIP_long = ".long2ip($startIP_long)." and endIP_long =
".long2ip($endIP_long)."";


The first //commented block will give:

QRange1 = 192.169.12.40 and QRange2 = 192.169.20.40
startIP_long = 3232304168 and endIP_long = 3232306216  
startIP_long = 127.255.255.255 and endIP_long = 127.255.255.255

(wtf did the "127.255.255.255" come from?!)

While the second works properly...

QRange1 = 192.169.12.40 and QRange2 = 192.169.20.40
startIP_long = -1062663128 and endIP_long = -1062661080 
startIP_long = 192.169.12.40 and endIP_long = 192.169.20.40

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



RE: [PHP] BUG: sprintf(%u) and ip2long

2003-10-14 Thread Daevid Vincent
Good point...

v4.1.2, Linux stripples.devel.redhat.com 2.4.18-11smp #1 SMP Thu Aug 15
06:41:59 EDT 2002 i686 unknown
This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.1.1, Copyright (c) 1998-2001 Zend Technologies
with Zend Optimizer v2.1.0, Copyright (c) 1998-2003, by Zend
Technologies
Apache/1.3.22

Also, if you notice, in my example, the problem was using the sprintf (%u)
as per the example on the php website. Just doing like you did works for me
too...

> -Original Message-
> From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 14, 2003 2:25 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] BUG: sprintf(%u) and ip2long
> 
> * Thus wrote Daevid Vincent ([EMAIL PROTECTED]):
> > Could be my not understanding of something, but I think 
> there is a bug in
> > using ip2long() and sprintf(%u) as indicated on this page:
> > http://us4.php.net/manual/en/function.ip2long.php
> 
> What version of php? It works find in 4.3.3.
> 
> echo long2ip(3232304168);
> ---
> 192.169.12.40

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



php-general@lists.php.net

2003-10-14 Thread Daevid Vincent
Okay, I thought the hack of doing this (scan.sh) might work, but running
some timing tests, it's apparent that it's not...
The more IP addresses I schedule to scan, the longer it takes to return my
browser page.

#!/bin/sh
/bin/scan &

And while if I run it on the command line in bash, it works just fine, PHP
seems to STILL wait until the /bin/scan is done. UGH!

I tried this exec() suggestion and that didn't work right either.
exec("/bin/scan & > /dev/null 2>/dev/null");

Then I thought I might try this
http://us2.php.net/manual/en/function.pcntl-fork.php
But frustratingly, "Process Control support in PHP is not enabled by
default. You have to compile the CGI or CLI version of PHP with
--enable-pcntl configuration option when compiling PHP to enable Process
Control support. " and I'm using RPMs without the ability to recompile, as
this PHP code is to be deployed on many boxes that are all ghost images of
the one I'm developing on.

Rasmus or someone in the know, please tell me how I can fire off a process
without having PHP wait for the return.

I'm doing:

$time_start = getmicrotime();
echo "executing scan.sh";
exec("/www/datasafe/scan.sh &");
$time_end = getmicrotime();
echo "command took: ".($time_end - $time_start)." seconds";

And I see things like 7, 14 and 28 seconds depending on if I use a /24, /22,
/21 CIDR range for the IP address subnet. Furthermore, calculating the list
of IP's to put in the db doesn't take more than a second or two in all
cases. And I don't think that the mySQL overhead is taking up the other
time.

Daevid.

> -Original Message-
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, October 11, 2003 5:02 AM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] How to fire off a unix command WITHOUT 
> waiting for it to return (I want to use &)
> 
> Try
> exec("/bin/scan & > /dev/null 2>/dev/null");
> 
> Daevid Vincent wrote:
> > How can I cause PHP to fire off a unix program and NOT wait 
> for a reply.
> > Basically I want to use the "&" love the unix provides, but 
> it seems that
> > exec, passthrough, system and even ` ` all wait for a 
> return despite my
> > putting something like exec("/bin/scan &"); or `/bin/scan &`
> > 
> > *sigh*
> > 
> > The sitch is that I'm scanning/pinging/nmap a HUGE amount 
> of IP addresses.
> > Perhaps 254 - 65000 or more individual iP addresses. We 
> have a multithreaded
> > scanner that we wrote in C that can to this quickly, but 
> it's still a wait.
> > It pulls from a db the ips to scan and sets their up/down 
> flags. My php
> > scheduler page queries to get the ones that are up. 
> > 
> > So as you see, I don't want to wait for a return code, I 
> know the status via
> > the db and how many rows are done/need to be done. 
> > 
> > Daevid Vincent.
> > http://daevid.com
> > 
> 
> 

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



RE: [PHP] variables in e-mail 2nd

2003-10-17 Thread Daevid Vincent
What I do is make a PHP page/template with php variables in place.

Then do something like this...

$report = "path/to/mytemp.php";

$today = date();

ob_start();
include($report);
$message = ob_get_contents();
ob_end_clean();
//echo $message;

    $to = "Daevid Vincent <[EMAIL PROTECTED]>";
    //$to .= ", "."Daevid Vincent <[EMAIL PROTECTED]>"; // note the
comma

$headers  = "MIME-Version: 1.0\r\n";
//$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: CRiMson <".WEBMASTER.">\r\n";
//$headers .= "Cc: [EMAIL PROTECTED]";
//$headers .= "Bcc: [EMAIL PROTECTED]";
//$headers .= "Reply-To: ".$myname." <".$myreplyemail.">\r\n";
//$headers .= "X-Priority: 1\r\n";
//$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: CRiMson Server";

$subject = "my report";

//  echo $message;

mail($to, $subject, $message, $headers);

That's the slick as shit solution. Then PHP will pull in your 'template'
page and any variables or whatever are executed in the template $report,
plus any that you have in your program (such as $today) are passed in to
$message as well...

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: christian tischler [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 17, 2003 7:10 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] variables in e-mail 2nd
> 
> I would like to use a form in a html page to pass the 
> variables to a php
> page, which sends an mail including these variables.
> 
> All I get in the mail though is a 1 rather than the string 
> that I put into
> the form???
> 
> Can anyone help please!
> 
> Some code I use
> .
> .
> .
> $messagepart1 = '
>   Free Subscription  
> Somebody would like to have a free subscription!!! ';
>   $messagepart2 = (echo $salutation);
>   $messagepart3 = '   ';
> $message = $messagepart1.$messagepart2.$messagepart3;
> .
> .
> .
> mail([EMAIL PROTECTED], "Free Subscription Application", $message, $headers);
> .
> .
> .
> 
> The $salutation comes from the form and is handed over 
> correctly, but the
> syntax for to display the value of the variable in the html 
> e-mail seems to
> be the problem...
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



[PHP] Sending htaccess auth information through php

2003-10-17 Thread Daevid Vincent
This is what I use. IE is smart enough to parse out the user/pw from the
location bar, so you should be pretty good. FYI, some forms of media may
need this sent too, like mediaplayer -- which is annoying b/c it tries to
authenticate! Bastards.

http://$username:[EMAIL PROTECTED]/protected/

And for media, try this...
http://$username:[EMAIL PROTECTED]/protected/mymovie.wmv

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, October 15, 2003 7:06 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Sending htaccess auth information through php
> 
> Hi there, i was wondering if there was a way to send htaccess auth
> information through php. My application is loading a parent 
> flash movie
> which externally loads flash videos within a directory i want 
> to password
> protect with htaccess. I was wondering how could it be 
> possible to send
> headers to that the parent flash can load the external videos 
> without a
> password box popping up ?
> 
> Basically there is two solutions. Password protect the 
> directory and work
> out a way to get flash to load the flash videos without a password box
> popping up.
> 
> Or doing a fopen and fread on flash files outside the web 
> directory like so.
> 
> header("Content-type: application/x-shockwave-flash");
> $fp = @fopen("/path/".$_GET['filename'],"r");
> $swf = @fread($fp,filesize("/path/".$_GET['filename']));
> @fclose ($fp);
> echo $swf;
> 
> This will output the binary information, then the parent 
> flash loads that
> php file with the filename into a movie container. It works but is it
> slower than the first solution ?
> 
> Let me know.
> 
> Dan
> (whos punctuation is hopefully better than in the past)

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



[PHP] What's a good regex to validate an email address? ;)

2003-10-17 Thread Daevid Vincent
Not PHP, but in js, I use this:

function emailCheck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
   return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 ||
str.indexOf(at)==lstr){
   return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 ||
str.indexOf(dot)==lstr){
return false
}

 if (str.indexOf(at,(lat+1))!=-1){
return false
 }

 if (str.substring(lat-1,lat)==dot ||
str.substring(lat+1,lat+2)==dot){
return false
 }

 if (str.indexOf(dot,(lat+2))==-1){
return false
 }

 if (str.indexOf(" ")!=-1){
return false
 }

 return true        
}

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: John W. Holmes [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, October 15, 2003 9:29 PM
> To: php list
> Subject: [PHP] What's a good regex to validate an email address? ;)
> 
> Heh... I was adding a note to the PHP Manual and I thought it 
> was really 
> funny they had to include this note in the "rules":
> 
>   (And if you're posting an example of validating email addresses, 
> please don't bother. Your example is almost certainly wrong for some 
> small subset of cases. See this information from O'Reilly Mastering 
> Regular Expressions book for the gory details.)
> 
> lol...
> 
> The link is http://examples.oreilly.com/regex/readme.html in 
> case anyone 
> is interested...
> 
> -- 
> ---John Holmes...
> 
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
> 
> php|architect: The Magazine for PHP Professionals - www.phparch.com

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



RE: [PHP] variables in e-mail 2nd

2003-10-17 Thread Daevid Vincent
Oh, one more thing that's worthy of note. This method "renders" a page so
you don't have to worry about htaccess protected content and authentication.

What do I mean by that? Well, for example, my CRiMson project uses
mod_auth_mysql to validate a user and let them in. It protects the entire
/crimson/ tree at the apache level. Using the method below, I can use
graphics, includes, .css, .js, etc all found in that dir tree in my template
email. Then when I send it, the user does NOT have to authenticate/login
just to read the email :-)

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: Daevid Vincent [mailto:[EMAIL PROTECTED] 
> Sent: Friday, October 17, 2003 10:55 AM
> To: 'christian tischler'; [EMAIL PROTECTED]
> Subject: RE: [PHP] variables in e-mail 2nd
> 
> What I do is make a PHP page/template with php variables in place.
> 
> Then do something like this...
> 
>   $report = "path/to/mytemp.php";
> 
>   $today = date();
> 
>   ob_start();
>   include($report);
>   $message = ob_get_contents();
>   ob_end_clean();
>   //echo $message;
> 
>   $to = "Daevid Vincent <[EMAIL PROTECTED]>";
>   //$to .= ", "."Daevid Vincent <[EMAIL PROTECTED]>"; // note the
> comma
> 
>   $headers  = "MIME-Version: 1.0\r\n";
>   //$headers .= "Content-type: text/plain; 
> charset=iso-8859-1\r\n";
>   $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
>   $headers .= "From: CRiMson <".WEBMASTER.">\r\n";
>   //$headers .= "Cc: [EMAIL PROTECTED]";
>   //$headers .= "Bcc: [EMAIL PROTECTED]";
>   //$headers .= "Reply-To: ".$myname." <".$myreplyemail.">\r\n";
>   //$headers .= "X-Priority: 1\r\n";
>   //$headers .= "X-MSMail-Priority: High\r\n";
>   $headers .= "X-Mailer: CRiMson Server";
>   
>   $subject = "my report";
> 
> //    echo $message;
>   
> mail($to, $subject, $message, $headers);
> 
> That's the slick as shit solution. Then PHP will pull in your 
> 'template'
> page and any variables or whatever are executed in the 
> template $report,
> plus any that you have in your program (such as $today) are 
> passed in to
> $message as well...
> 
> Daevid Vincent
> http://daevid.com
>   
> 
> > -Original Message-
> > From: christian tischler [mailto:[EMAIL PROTECTED] 
> > Sent: Friday, October 17, 2003 7:10 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] variables in e-mail 2nd
> > 
> > I would like to use a form in a html page to pass the 
> > variables to a php
> > page, which sends an mail including these variables.
> > 
> > All I get in the mail though is a 1 rather than the string 
> > that I put into
> > the form???
> > 
> > Can anyone help please!
> > 
> > Some code I use
> > .
> > .
> > .
> > $messagepart1 = '
> >   Free Subscription  
> > Somebody would like to have a free subscription!!! ';
> >   $messagepart2 = (echo $salutation);
> >   $messagepart3 = '   ';
> > $message = $messagepart1.$messagepart2.$messagepart3;
> > .
> > .
> > .
> > mail([EMAIL PROTECTED], "Free Subscription Application", $message, 
> $headers);
> > .
> > .
> > .
> > 
> > The $salutation comes from the form and is handed over 
> > correctly, but the
> > syntax for to display the value of the variable in the html 
> > e-mail seems to
> > be the problem...
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



RE: [PHP] there has to be a better way...

2003-10-22 Thread Daevid Vincent
Here is a snippet from my dhcp web page found on my site below... Not
exactly what you want, but could help you start...

// read in the dhcp_map.ini file to map MAC addresses to images
$mapFile = "./dhcp_map.ini";
if( $fp = @fopen($mapFile, "r") )
{
while( $line = fgets($fp, 1024) )
if ($line{0} != "#") $tempMap .= $line;  // strip
out # comments
} else echo "ERROR: Can't read ".$mapFile."";
fclose ($fp);
$map = explode("\n", $tempMap);
//print_r($map);
for($i = 0; $i < count($map); $i++)
{
list($mac, $image, $name) = preg_split("/\s/",$map[$i], -1,
PREG_SPLIT_NO_EMPTY);
//if ( array_key_exists($mac, $machine))
$machine[$mac]->setImage($image);
if ( isset($machine[$mac]) )
$machine[$mac]->setImage($image);
if ( isset($machine[$mac]) && $name != "" &&
$machine[$mac]->getName() == "") $machine[$mac]->name = $name;
}
unset($tempMap);
unset($map);


#  "dhcp_map.ini" file
#  MAC ADDRESS: GIF IMAGE:  NAME:
00:09:12:86:48:54   linux   LINUX
00:0B:AD:31:AA:A6   tivoThad's
00:0B:AD:08:38:C3   tivoDaevid's



Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: jsWalter [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, October 22, 2003 1:11 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] there has to be a better way...
> 
> I need to read (write comes later) from a config file that we 
> used to handle
> manually.
> 
> I'm getting lazy, so I'm writing a web interface for this.
> 
> What I have does this...
>   - open a given file
>   - dump entire file into a string
>   - explode string into an array at the EOL marker
>   - walk down this new array
>   - decide if there is anything in current element
>   - decide if current line is a comment
>   - split line at '=' into 2 variables
>   - add new key and value from these variables back into array
>   - kill original array element
> 
> There must be a better way to do this.
> 
> All this seems a bit over kill to me.
> 
> Does anyone have any ideas on this?
> 
> Thanks
> 
> Walter
> 
> This is what I have...
> 
>  
> $config = $list . '/home/walter/vmd/config';
> 
> // Open the file
> $handle = fopen ($config, "r");
> 
> // Read entire file into var
> $content = fread($handle, filesize($config));
> 
> // convert var into array and explode file via line break
> $content = split("\r\n", $content);
> 
> // close file
> fclose($handle);
> 
> // Loop through file contents array
> foreach ($content as $i => $value)
> {
>// If we have any data in this line
>if (! empty ($value))
>{
>   // If this line is not a comment
>   if ( $value{0} != '#')
>   {
>  list($a, $b) = split("=", $value);
>  $content[$a] = $b;
>   }
> 
>   // kill original array element
>   unset($content[$i]);
>}
> }
> 
> // show me what I have
> echo '';
> echo print_r($content);
> echo '';
> 
> ?>
> 
> # Sample config file data, just 2 lines from the file...
> #
> # The "Personal Name" of the list, used in outgoing headers.
> # If empty, default is the same as the list's username.
> # if explicitly `false', then it is redefined empty.
> LIST_NAME="RMT Working Group"
> 
> # The address of the list's admin or owner.
> # if explicitly `false', then it is redefined empty.
> [EMAIL PROTECTED]
> 
> ...
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



RE: [PHP] there has to be a better way...

2003-10-22 Thread Daevid Vincent
> -Original Message-
> From: Walter Torres [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, October 22, 2003 3:27 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] there has to be a better way...
> 
> 
> "Daevid Vincent" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Here is a snippet from my dhcp web page found on my site 
> below... Not
> > exactly what you want, but could help you start...
> 
> thanks!
> 
> 
> > // read in the dhcp_map.ini file to map MAC addresses to images
> > $mapFile = "./dhcp_map.ini";
> > if( $fp = @fopen($mapFile, "r") )
> > {
> > while( $line = fgets($fp, 1024) )
> 
> this pulls out 1024 bytes of data form the file. right?
> or does this pull UPTO 1024 bytes of data or the EOL, which 
> ever is first?
> if fgets() onlt pulls out so much data, not to EOL, why use it?

Yes. Keeps getting 1024 byte chunks until EOL as per the documentation.

> 
> > if ($line{0} != "#") $tempMap .= $line;  // strip
> > out # comments
> > } else echo "ERROR: Can't read ".$mapFile."";
> > fclose ($fp);
> > $map = explode("\n", $tempMap);
> 
> Now make an array of these line. Right?

Ignore comment lines (#) 
Yes, explode the entire file in to one line per array key.

> > for($i = 0; $i < count($map); $i++)
> > {
> > list($mac, $image, $name) = preg_split("/\s/",$map[$i], -1,
> > PREG_SPLIT_NO_EMPTY);
> 
> walk down the map array.
> split each element on the SPACE, but don't deal with blank lines

Take each line/key of the array and split it into another array of 'stuff'
Ignore any spaces between chunks of data. If you look at the data file,
you'll understand.

> seems almost the same.
> nice use of PREG_SPLIT. I guess that helps with the BLANK lines.

It helps with blank space between MAC, image and name columns on a single
line.

> If I understand right, if I pull out 1028 of data, the '#' on 
> each line
> could be anywhere in that buffer, not just at the first character.

Yeah, in my case, I only count a # at the beginning of a line AKA $line{0}

> That's why I pulled in the entire file into a string var and 
> then exploded it into an array split on EOL characters.
> 
> Am I missing something?
> 
> Thanks for your sample.

Np.

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



[PHP] BUG: require_once() or die(); = fatal error

2003-11-26 Thread Daevid Vincent
Using PHP 4.2.2 on Linux RH8:

In a PHP script run from command line,

require_once("gibberator_data.php") or die("No Data file found\n");

Causes:

[EMAIL PROTECTED] gibberator]# ./gibberator.php 

Fatal error:  Failed opening required '1'
(include_path='.:/php/includes;/usr/share/phpwebtools') in
/home/gibberator/gibberator.php on line 13

However 

require_once("gibberator_data.php"); 

Works just fine.

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



RE: [PHP] BUG: require_once() or die(); = fatal error

2003-11-28 Thread Daevid Vincent
Hmm... Well Rasmus, I do see your point, however it still seems to me it
'should' at least compile and work as I expect it to.

My way, the logic is that the file *is* 'required' (whereas I view 'include'
files as optional), and I want to exit the program with a graceful message
instead of the fatal error (which doesn't really doesn't tell me what the
problem is -- "Failed opening required '1'" doesn't mean anything to me or
the user) that is shown. My intent was to put a  @require_once() so that I
could do just that. Especially since I'm running my script on the command
line, and your stock fatal error message uses HTML tags.

Not a critical bug or a show stopper, but I do still feel it is a bug.

> -Original Message-
> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 26, 2003 8:55 PM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] BUG: require_once() or die(); = fatal error
> 
> This code doesn't make much sense.  By definition, if require 
> cannot open
> a file it throws a fatal error, so you would never hit the "or" case
> anyway.  Hence there is no return code from require and you 
> can't write
> code like this.  If you want to test the return code you need to use
> 'include' instead.
> 
> -Rasmus
> 
> On Wed, 26 Nov 2003, Daevid Vincent wrote:
> 
> > Using PHP 4.2.2 on Linux RH8:
> >
> > In a PHP script run from command line,
> >
> > require_once("gibberator_data.php") or die("No Data 
> file found\n");
> >
> > Causes:
> >
> > [EMAIL PROTECTED] gibberator]# ./gibberator.php
> > 
> > Fatal error:  Failed opening required '1'
> > (include_path='.:/php/includes;/usr/share/phpwebtools') in
> > /home/gibberator/gibberator.php on line 13
> >
> > However
> >
> > require_once("gibberator_data.php");
> >
> > Works just fine.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 

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



RE: [PHP] BUG: fatal error uses html in cgi version (WAS: require_once() or die(); = fatal error)

2003-11-30 Thread Daevid Vincent
Hmm.. It's not turning it off for me. Hence the reason I tried to handle it
gracefully myself. ;-)

I get exactly what you see there below for the fatal error. This is from an
RPM package for RH8. perhaps it is fixed in a version since 4.2.2? 

> -Original Message-
> From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, November 29, 2003 10:48 PM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: RE: [PHP] BUG: require_once() or die(); = fatal error
> 
> By default the CLI version turns off the html in the error 
> messages.  And no, really, there is no bug here.  You are testing the
return code of 
> something that doesn't have one.  It doesn't make sense.
> 
> -Rasmus
> 
> On Fri, 28 Nov 2003, Daevid Vincent wrote:
> 
> > Hmm... Well Rasmus, I do see your point, however it still 
> seems to me it
> > 'should' at least compile and work as I expect it to.
> > 
> > My way, the logic is that the file *is* 'required' (whereas 
> I view 'include'
> > files as optional), and I want to exit the program with a 
> graceful message
> > instead of the fatal error (which doesn't really doesn't 
> tell me what the
> > problem is -- "Failed opening required '1'" doesn't mean 
> anything to me or
> > the user) that is shown. My intent was to put a  
> @require_once() so that I
> > could do just that. Especially since I'm running my script 
> on the command
> > line, and your stock fatal error message uses HTML tags.
> > 
> > Not a critical bug or a show stopper, but I do still feel 
> it is a bug.
> > 
> > > -Original Message-
> > > From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED] 
> > > Sent: Wednesday, November 26, 2003 8:55 PM
> > > To: Daevid Vincent
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] BUG: require_once() or die(); = fatal error
> > > 
> > > This code doesn't make much sense.  By definition, if require 
> > > cannot open
> > > a file it throws a fatal error, so you would never hit 
> the "or" case
> > > anyway.  Hence there is no return code from require and you 
> > > can't write
> > > code like this.  If you want to test the return code you 
> need to use
> > > 'include' instead.
> > > 
> > > -Rasmus
> > > 
> > > On Wed, 26 Nov 2003, Daevid Vincent wrote:
> > > 
> > > > Using PHP 4.2.2 on Linux RH8:
> > > >
> > > > In a PHP script run from command line,
> > > >
> > > > require_once("gibberator_data.php") or die("No Data 
> > > file found\n");
> > > >
> > > > Causes:
> > > >
> > > > [EMAIL PROTECTED] gibberator]# ./gibberator.php
> > > > 
> > > > Fatal error:  Failed opening required '1'
> > > > (include_path='.:/php/includes;/usr/share/phpwebtools') in
> > > > /home/gibberator/gibberator.php on line 13
> > > >
> > > > However
> > > >
> > > > require_once("gibberator_data.php");
> > > >
> > > > Works just fine.
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > > 
> > 
> 

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



[PHP] PEAR: HTML_Progress -- how do I actually use this now?!

2003-12-01 Thread Daevid Vincent
I was very excited when I saw this link and the examples on the site. So
I've downloaded all the files and installed them all. Now I don't know what
to do with it or how to use it!?

The package doesn't have any humanly useable tutorials or quick start or
even a text file describing how I would put this in a web page of my own
site. Instead it seems to force me to use phpDocumentor to build the
corresponding .html files. Ugh!

So, I went through the extremely tedious process of (installing
phpDocumentor and) building the options.ini and stylesheet.css file with a
directory path that gave me carpal-tunnel...
"PEAR\data\PhpDocumentor\phpDocumentor\Converters\HTML\frames\templates\DOM\
earthli\templates\media\stylesheet.css"

Then I deciphered what the heck the author's README file meant to come up
with thiis magic incantation which he could have just typed out and said,
"run this command", or better yet, a shell script that builds the above dir
path, copies the files and runs the below commands.

phpdoc -f /usr/local/lib/php/HTML/Progress.php  -d
/usr/local/lib/php/HTML/Progress -po HTML_Progress -o
HTML:frames:DOM/earthli -t /tmp/Progress/ 

Then trying to get what would appear to be the thing I need to actually use
this tool -- the tutorial -- I get an error that doesn't give any indication
of what file to look at to fix.

phpdoc -f /usr/local/lib/php/HTML/Progress.php  -d
/usr/local/lib/php/HTML/Progress/tutorials -po HTML_Progress -o
HTML:frames:DOM/earthli -t /tmp/Progress/
Parsing configuration file phpDocumentor.ini...
done
using experimental tokenizer Parser
directory: ''  not found

The website doesn't give a single tutorial (or example that I could copy and
change)...
http://pear.laurent-laville.org/HTML_Progress/apidoc/
http://pear.laurent-laville.org/HTML_Progress/examples/

And the progress maker bombs out at the end after you go through 5 tabs of
options.
http://pear.laurent-laville.org/HTML_Progress/examples/ProgressMaker.php

Could someone PLEASE tell me how to use this seemingly useful class? And I
guess, before we even started, what I want to do is query a mySQL database
every second and use the results to show the progress bar, without reloading
the web page. Can that be done with this project, or did I just waste a day?

Excuse my frustration please, but this seems way more complicated than it
should be. But perhaps that's the way PEAR is and since I've never used it,
I've been blissfully ignorant building my own things.

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: Burhan Khalid [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, November 27, 2003 2:47 AM
> To: Astron of BrOnX; [EMAIL PROTECTED]
> Subject: Re: [PHP] Does anyone have Upload meter php codes?
> 
> Astron of BrOnX wrote:
> > Hi everyone, i am looking for upload meter progress bar 
> codes. I have looked
> > up arround and the most of them needs for patching PHP to get upload
> > variables. And also they are for Linux. I have need a 
> solution for windows.
> > It can be a extra DLL file for PHP but i dont know how i can find?
> 
> http://pear.php.net/package/HTML_Progress
> 
> -- 
> Burhan Khalid
> phplist[at]meidomus[dot]com
> http://www.meidomus.com
> ---
> "Documentation is like sex: when it is good,
>   it is very, very good; and when it is bad,
>   it is better than nothing."
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



RE: [PHP] DHCP web interface. New version.

2003-12-03 Thread Daevid Vincent
Once again, I have a new version of my DHCP web page. The major fix in this
one is that it does an "nmap -v -p 80 192.168.1.0/24" (thanks to Mike Klinke
for the idea) to re-populate the "arp -n". The old version of my program
would not always show ALL devices on the network. Some would also show up as
"incomplete". I have removed all incomplete ones for this version, but you
could simply comment out the line to put them back if you want them. You can
specify the server's IP manually (as in the case of dual NIC cards), or let
the script figure it out for you. 

http://daevid.com/examples/dhcp/

Daevid.


> -----Original Message-
> From: Daevid Vincent [mailto:[EMAIL PROTECTED] 
> Sent: Monday, July 28, 2003 9:41 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] DHCP web interface. New version.
> 
> Heya. I've just put up a new version of the DHCP web front 
> end if anyone is
> using it or has a need for this type of thing.
> 
> Major feature of this version:
> 
> * a bug where if the arp table showed an "(incomplete)", I 
> ignored the entry
>   since the MAC is the hash key, many machines wouldn't show 
> up as they kept
>   over writing each other (of course, they were bunk anyways)
> * ping & nmap tests (if ping fails, nmap is used as a backup)
>   this is useful for firewalls that may block ICMP
> * tests can be disabled for radically faster page rendering 
> (off by default)
> * 10 minute refresh by default rather than 10 second.
> * SORTING! by IP now, rather than arp entries
> * many more icons (tivo, zaurus, replay, linux, notebook, 
> servers, DAR, etc)
> * complete/incomplete tally
> * Name in config file is only used if dhcp doesn't show a name already
> 
> This is also IMHO an excellent way for a beginer or advanced 
> coder alike to
> see some very useful OOP/PHP coding as I use arrays of 
> objects, sorting by
> variables IN the object (custom sort algorithm with key 
> integrity), hashing,
> system calls, regex parsing, DHTML, etc. 
> 
> If anyone knows how to force the arp table to be current, 
> that would help.
> Sometimes a machine is on the network, and I *know* for a 
> fact it is, but it
> doesn't show up in "arp -n" *grumble*. 
> 
> Follow the link below. 
> http://daevid.com/examples/dhcp/

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



[PHP] How do I apt-get newer php4 cgi with mysql on debian?

2003-12-08 Thread Daevid Vincent
I am setting up a Soekris box (256MB CF card) that needs a newer PHP with
mySQL support.

I followed some instructions I googled and finally got a v4.1.2 of PHP that
has mysql working even though phpinfo() says  '--without-mysql' (?!). But
this is a pretty old version of PHP.

I do NOT need the webserver and all that overhead as this is simply going to
connect to another remote DB (via PHP). I don't have the tools to compile it
on there either, nor do I want them.

Please tell me how to apt-get a newer version of the CGI PHP with mySQL
support.

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



RE: [PHP] how and when to use ->

2003-12-10 Thread Daevid Vincent
-> is for classes / objects... 

It points to a variable in the object class (this case $path) or 
a function like $d->setColor("green");

http://us4.php.net/manual/en/language.oop.php

OOP is hella cool when you "get it". But it can also be overkill for many
things too. Basically I think of it this way, if I need to store 'records'
like with a database, but don't need a database per se, OOP is perfect. For
a great example, I would refer you to my simple DHCP web page project:
http://daevid.com/examples/dhcp/ you can download the .tgz file at the
bottom and see how it's structured.


Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: Dave Reinhardt [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 10, 2003 1:26 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] how and when to use ->
> 
> how and when to use -> as in
> echo "Path: ".$d->path."\n";
> what does this mean and how is it used?
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



RE: [PHP] problems with starting session

2003-12-10 Thread Daevid Vincent
You can't print any output before you start the session AFAIK.

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: obsidianchrysalis [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, December 09, 2003 3:51 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] problems with starting session
> 
> this code snippet is used to autheticate a user's id. 
> however, it generates
> errors pertaining to the script not being able to send 
> headers with the
> session data.
> 
> // function authenticate()
>   //  {
>   // import variables to be read from form
>   import_request_variables("p", "s_");
> 
>   // set variables to connect to database
>   $db_host = "localhost";
>   $db_user = "login_1";
>   $db_pass = "addUser";
>   $db_name = "jamison_id";
> 
>   // connect to database
>   $connection = mysql_connect($db_host, $db_user, 
> $db_pass) or
> die ("Unable to connect!");
>   mysql_select_db($db_name);
>   $query = "SELECT id_num from login WHERE user = 
> '$s_user_id'
> AND passwd = '$s_passwd'";
>   $result = mysql_query($query, $connection) or 
> die ("Error in
> query: '$query' ."  . mysql_error());
> 
>   // if row exists -> user/pass combination is correct
>if (mysql_num_rows($result) == 1)
>  {
>   $valid = 1;
>  }
> else
>  {
>print($s_user_id);
>print($s_passwd);
>  }
>//  }
> // $valid = authenticate($s_user_id, $s_passwd);
> print($valid);
>  if ($valid == 1)
> {
> 
>   // initiate a session
>  session_start();
> 
>  // register some session variables
> // session_register("SESSION");
> 
>   // including the username
>  //session_register("SESSION_UNAME");
>  //$SESSION_UNAME = $f_user;
>}
>  ?>
> 
>  any help would be appreciated.
> 
> chris
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



[PHP] PHP Internship job (Seattle, WA)

2003-12-10 Thread Daevid Vincent
Sorry if this is a repost, but I never saw it come through the list. Maybe
prefixing "OT:" caused it to get /dev/null'd??
 
-Original Message-----
From: Daevid Vincent [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 09, 2003 3:59 PM
To: '[EMAIL PROTECTED]'
Subject: OT: PHP Internship job (Seattle, WA)

I looked at this URL (http://www.php.net/mailing-lists.php) and didn't see
any restrictions about Job type postings.

We're in need of an unpaid intern in the Seattle, WA area that knows PHP
(and preferably mySQL). Main duties will include the maintenance and
updating of the main company website. This is probably a three day per week
task. Being this is an internship, we are fairly flexible and willing to
work with you. You will learn an incredible amount in trade as we are a
Linux/PHP/mySQL shop and really push the technologies.

Worthy candidates stand a good chance that they will be invited to join our
Engineering team as a Software Developer after our second round of funding
(expected in March)

Please send resume' and/or coding examples to my attention
([EMAIL PROTECTED]).

Daevid Vincent 
Product Development Manager
InteractNetworks, Inc.
http://www.interactnetworks.com

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



[PHP] Help with associative array in a PHP class. Not working as I'd expect it to?!

2003-12-10 Thread Daevid Vincent
I'm pulling out my hair on this. I don't think I'm doing anything wrong and
I've tried it with PHP 4.3.4 (cli) (built: Nov  7 2003 03:47:25) AND also
v4.1.2 on Linux.

With the line commented as shown, I get this output:
--
[daevid=pts/4]6:[EMAIL PROTECTED]:{/home/daevid}> ./test.php
packetArray:
Array
(
[a] => foo
[b] => bar
[c] => 1
[d] => 2
[e] => 3
)
myPacket:
--

How come I don't get ANY array under "myPacket:"?

How come I don't get a "[test] => 2345245" under "myPacket:" when I
explicitly set it?

Uncommenting the 'blah' element causes this error:

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or
`T_VAR' or `'}'' in /home/daevid/test.php on line 16

The 'var' keyword seems to be required, or I get that same error also.

I've tried other combinations and can't figure out what I'm doing wrong?

 snip -
#!/usr/bin/php
'foo', 'b'=>'bar', 'c'=>'1', 'd'=>'2', 'e'=>'3');

$AP = array();
$ap['1'] = new kismetap($PACKET);
$ap['1']->printMyVars();

class kismetap
{
 var $myPacket = array();

//   $myPacket["blah"] = "asdfasdfasdf";

function kismetap( $packetArray )
{
echo "packetArray:\n";
print_r($packetArray);

$this->myPacket = $packetArray;
$this->myPacket["test"] = 2345245;

global $myPacket;
$myPacket = $packetArray;
} //kismetap::constructor

function printMyVars()
{
 echo "myPacket:\n";
 print_r($myPacket);
}

} //kismetap class
?>

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



RE: [PHP] Help with associative array in a PHP class. Not working as I'd expect it to?!

2003-12-10 Thread Daevid Vincent
Grrr what a newbie mistake (about the scope I mean)! I guess I assumed that
in a class, the $this-> was redundant for a method (it is in J++ which is
where I learned my OOP). So all my variables in the main class were 'global'
to methods in the class. My second bit of confusion is that I've made
classes before where I do this:

class myclass {
var $five = 5;
 ...
}
  
And it works fine, so you can see how the subtle difference (no var keyword
basically) could lend to confusion. I still don't fully agree with the fact
that I can't initialize the array key/value like that. It seems to me
logical that it should work after I declared the array already.

class myclass {
   var $myPacket = array();
   $myPacket["blah"] = "asdfasdfasdf";
 ...
}

Thanks guys!

> -Original Message-
> From: John W. Holmes [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, December 10, 2003 6:54 PM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Help with associative array in a PHP 
> class. Not working as I'd expect it to?!
> 
> Daevid Vincent wrote:
> 
> > myPacket:
> > --
> > 
> > How come I don't get ANY array under "myPacket:"?
> [snip]
> > function printMyVars()
> > {
> >  echo "myPacket:\n";
> >  print_r($myPacket);
> > }
> 
> Two words: Variable Scope. :)
> 
> $myPacket is local to the function and empty.
> 
> -- 
> ---John Holmes...
> 
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
> 
> php|architect: The Magazine for PHP Professionals - www.phparch.com
> 
> 
> 
> 

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



RE: [PHP] rss/rdf feed classes

2003-12-11 Thread Daevid Vincent
We have pretty good luck with http://www.fase4.com/rdf/ 

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: Matt Matijevich [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 11, 2003 10:46 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] rss/rdf feed classes
> 
> 
> I'm looking for a class that returns a rss/rdf feed with each of the 
> items as an array, or suggestions on how to items into an array...
> 
> 
> try google and freshmeat.net
> 
> You should be able to find plenty of examples and classes.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



RE: [PHP] Palm OS Processor

2003-12-11 Thread Daevid Vincent
Dunno about Palm, but you could get a Sharp Zaurus (which runs linux) and
put mysql, apache, php etc on there. It also has a Palm emulator...

Daevid Vincent
http://daevid.com
  

> -Original Message-
> From: Galen [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, December 11, 2003 12:37 PM
> To: Stephen Craton; [EMAIL PROTECTED]
> Subject: Re: [PHP] Palm OS Processor
> 
> I would love one of these too! PHP programming in my pocket! And how 
> about a mini database for Palm OS also? (SQLite?)
> 
> Anybody know anything more about this?
> 
> I'm not finding much with Google that seems relevant for PHP 
> running on 
> the Palm.
> 
> -Galen
> 
> On Dec 11, 2003, at 7:47 AM, Stephen Craton wrote:
> 
> > Hello,
> >
> > I was just wondering if there were such a program for Palm 
> OS 4.1 that 
> > processes PHP code. Just wondering so that I can maybe make some 
> > complex calculator functions on it and use it for school work or 
> > whatever else may come my way. Thanks!
> >
> > Stephen Craton
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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



  1   2   3   4   5   6   >