Re: [PHP] xml reader/writer

2007-08-28 Thread Per Jessen
Sam Baker wrote:

> I'm looking for a php script that will read any xml file, display the
> contents in html, with the option of adding an entry (in the same
> scheme, whatever that might be) or deleting existing entries.
> 
> I think I could write this, but it would take a while.

Use the XSLT extension?  You can probably find some xslt code somewhere
that'll help you.  I'm sure I've got something hidden away somewhere. 


/Per Jessen, Zürich

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-28 Thread Jason Pruim


On Aug 24, 2007, at 12:15 PM, Daniel Brown wrote:


On 8/24/07, Jason Pruim <[EMAIL PROTECTED]> wrote:

Hi Everyone,

I'm attempting to figure out the proper way to use sessions to log
someone into my system. The idea being, if they arn't logged in all
they can see is the login form, and if they are logged in, they and
have access to a database of addresses.

[snip!]

Not the end-all-be-all, of course, but here's the basics:



Keep in mind that, as always, this hasn't been bug-checked,
re-read, or otherwise validated.



Hey Dan,

Thanks for the response, I think I see and understand what you are  
trying to say in there, but I am hitting a road block now... It won't  
display the page. I have tried to both just include the page, and  
copied the entire page and pasted it in the proper location.


Any ideas? Here's the code... And no I still haven't added  
mysql_real_escape_string yet... Want to get 1 part working at a  
time :) Fewer issues in my head then.


if($_POST['user'] && $_POST['pass']) { // Keep in mind, PASSWORD  
has meaning in MySQL

// Do your string sanitizing here
// (e.g. - $user = mysql_real_escape_string($_POST['user']);)
$sql = "SELECT * FROM login WHERE loginid='".$user."' AND  
email='".$pass."' LIMIT 0,1;";
$result = mysql_query($sql) or die("Wrong data supplied or  
database error");

while($row = mysql_fetch_array($result)) {
$_SESSION['user'] = $row['user'];
// Do whatever else you need to do here
echo "First Part";
include "index.php";
}

} else {
// Show your login form here.
echo "

Username : 
Password : 

";
echo "Second Part";
}
} else {
// The user is authenticated and logged in already.
echo "Just before include";
include "index.php";
echo "Third part";
}
?>

The few echo's that are in there are only there for debugging, easier  
to see how far I get :)


Thanks for looking! :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-28 Thread Daniel Brown
On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> On Aug 28, 2007, at 10:03 AM, Daniel Brown wrote:
>
> > On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
> > [snip]
> >>> $sql = "SELECT * FROM users WHERE user='".$user."' AND
> >>> pass='".$pass."' LIMIT 0,1;";
> >>> $result = mysql_query($sql) or die("Wrong data supplied or
> >>> database error");
> >>> while($row = mysql_fetch_array($result)) {
> >
> > Sounds to me like you're not getting through the while() clause,
> > meaning that there's no matching rows in the database.
> >
> > $sql = "SELECT * FROM login WHERE loginid='".$user."' AND
> > email='".$pass."' LIMIT 0,1;";
> >
> > Is the password they supply in the `email` column of the database?
>
> Yes it is... For now... I am just using test/test and I had a field
> named password in the database but thought that was messing it up, so
> I dropped that field and currently I am just using the e-mail field
> as a password.
>
> Once it works I'll change the field to a more appropriate selection
> with MD5 hashing, and maybe even a little salt in the hash. (Gotta
> add the flavor!)
>
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424
> www.raoset.com
> [EMAIL PROTECTED]
>
>
>

If you have phpMyAdmin installed on that server, J, try using the
"search" tab to see if you can find that user/email combination in the
database using = and not LIKE.

Perhaps there's a whitespace or something of the like that's
causing it to return zero rows.

Also, try doing this after the $result = mysql_query($sql); line:

die("Number of rows returned by MySQL: ".mysql_num_rows($result));

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



RE: [PHP] why?

2007-08-28 Thread Jay Blanchard
[snip]
Yes, a single sign-on it is... It doesn't work together with Windows
(and 
PHP) you mean?
[/snip]

No, not really.

You can run PHP on a Linux or a Windows server and it does not have
access to the initial login values (press cntl alt del to login)
although ASP and .Net (auth_user, etc) do. This is something that I have
wanted to do for years and we have even discussed on this list.

The initial login has to be configured so that the computer is
accessible either online or off and it can be either basic (plain text)
or challenge/response (encrypted). If it is online it will typically
look at an Active Directory server for authentication using LDAP as the
method of communication. If it is offline the login will typically look
at registry settings to determine if the login is authorized. 

Since PHP cannot read registry settings (neither can JavaScript) on the
client that is out. Windows is aware of the logged in user, but exactly
where that 'session' information is kept is a mystery to most of us. So
PHP cannot be aware of a user who has performed the initial login.

What we shoot for is Single Source Authentication. SSA uses LDAP to
connect to AD for authentication purposes. It requires that the user
login to each application, but since we are using the same
authentication platform (within a corporate system) their username and
password combo is the same as their initial login. If they change their
password (which we can make them do on a regular basis using AD's
password policies or they can do on their own -- we can also enforce
password strength) then they are able to continue using the new password
throughout the applications.

This is a very high level overview and it doesn't even begin to talk
about role or group management, but it is how we mitigate the
username/password issue for corporate users. For a public web site the
method may be quite a bit different.

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-28 Thread Jason Pruim


On Aug 28, 2007, at 10:03 AM, Daniel Brown wrote:


On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
[snip]

$sql = "SELECT * FROM users WHERE user='".$user."' AND
pass='".$pass."' LIMIT 0,1;";
$result = mysql_query($sql) or die("Wrong data supplied or
database error");
while($row = mysql_fetch_array($result)) {


Sounds to me like you're not getting through the while() clause,
meaning that there's no matching rows in the database.

$sql = "SELECT * FROM login WHERE loginid='".$user."' AND
email='".$pass."' LIMIT 0,1;";

Is the password they supply in the `email` column of the database?


Yes it is... For now... I am just using test/test and I had a field  
named password in the database but thought that was messing it up, so  
I dropped that field and currently I am just using the e-mail field  
as a password.


Once it works I'll change the field to a more appropriate selection  
with MD5 hashing, and maybe even a little salt in the hash. (Gotta  
add the flavor!)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-28 Thread Daniel Brown
On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
[snip]
> > $sql = "SELECT * FROM users WHERE user='".$user."' AND
> > pass='".$pass."' LIMIT 0,1;";
> > $result = mysql_query($sql) or die("Wrong data supplied or
> > database error");
> > while($row = mysql_fetch_array($result)) {

Sounds to me like you're not getting through the while() clause,
meaning that there's no matching rows in the database.

$sql = "SELECT * FROM login WHERE loginid='".$user."' AND
email='".$pass."' LIMIT 0,1;";

Is the password they supply in the `email` column of the database?

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-28 Thread Jason Pruim


On Aug 28, 2007, at 10:21 AM, Daniel Brown wrote:


On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:


On Aug 28, 2007, at 10:03 AM, Daniel Brown wrote:


On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
[snip]

$sql = "SELECT * FROM users WHERE user='".$user."' AND
pass='".$pass."' LIMIT 0,1;";
$result = mysql_query($sql) or die("Wrong data supplied or
database error");
while($row = mysql_fetch_array($result)) {


Sounds to me like you're not getting through the while() clause,
meaning that there's no matching rows in the database.

$sql = "SELECT * FROM login WHERE loginid='".$user."' AND
email='".$pass."' LIMIT 0,1;";

Is the password they supply in the `email` column of the  
database?


Yes it is... For now... I am just using test/test and I had a field
named password in the database but thought that was messing it up, so
I dropped that field and currently I am just using the e-mail field
as a password.

Once it works I'll change the field to a more appropriate selection
with MD5 hashing, and maybe even a little salt in the hash. (Gotta
add the flavor!)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





If you have phpMyAdmin installed on that server, J, try using the
"search" tab to see if you can find that user/email combination in the
database using = and not LIKE.

Perhaps there's a whitespace or something of the like that's
causing it to return zero rows.

Also, try doing this after the $result = mysql_query($sql); line:

die("Number of rows returned by MySQL: ".mysql_num_rows 
($result));


I don't have phpMyAdmin installed, never saw the need to... But I'll  
look into it in the future.


And after adding the die that you recommended, you were right, it  
wasn't returning any rows. So... I did some checking and it's amazing  
sometimes that you can't see the trees through the forrest a  
simple $user =$_POST['user']; and $pass=$_POST['pass']; and all is  
well. It logs into the page, now I just need to fine tune it since it  
doesn't like to display the actual database now, but that's something  
I should be able to figure out.


One other question, to logout, can I just call a file that has  
session_destroy() and a header("Location: ???"); in it? Or should I  
do something else for logging out?


Thanks again! Without your help... I wouldn't be able to do this!

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-28 Thread Stut

Jason Pruim wrote:
One other question, to logout, can I just call a file that has 
session_destroy() and a header("Location: ???"); in it? Or should I do 
something else for logging out?


foreach (array_keys($_SESSION) as $key)
unset($_SESSION[$key];
session_destroy();

-Stut

--
http://stut.net/

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



[PHP] c++ and php! search for a brigde

2007-08-28 Thread dwa

Hello people,
i have a question??

I have an application written in c++ and this throw real time data as 
udp-pakets all the time (interval 1 min and values in a wrapper like an 
own protocol are floats and longs).


Is there any possibility to catch the udp packets - parse the pakets und 
show the values in tables in a html-doc in real time???


What technologies are good? ajax? cgi? ive no idea!

mfg
david

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



Re: [PHP] Database includes

2007-08-28 Thread brian

Larry Garfield wrote:

On Sunday 26 August 2007, Bruce Cowin wrote:


I'm curious as to how everyone organises and includes their classes in
PHP5.


Then have a config file of some sort in which you specify your DB credentials.  
There's a variety of ways to do that (ini file, a PHP file with a database 
url, a PHP file that just has a couple of variables in it, or constants 
instead, etc.).  Pick one you like.  Then have your DB connection class read 
that file's data one way or another and connect as appropriate.  

If you have to modify anything other than a single config file in order to 
move your site/app from one server to another, then you have a design flaw.  
(I'd say that applies for moving the site to a subdirectory on a server too, 
but that takes a bit more effort.)




I'm with Larry on this. Include a constants file at the top of your 
scripts. In that file you can place a switch block that tests for the 
$_SERVER['HTTP_HOST']. For each case, place something like:


define('DB_NAME', 'my_dev_db');

Other things this is useful for are setting a boolean constant that a 
class might test in, eg. a toString method or error handling, and email 
addresses for scripts that phone the client. If you have a bunch of 
different ones it might be easiest to define dev & test email addresses 
first and, in the switch block, set the others accordingly. So, say you 
have several email addresses for various things being sent to client 
employees (sales@, admin@, jobs@, etc.). You can do something like:


define('EMAIL_DEV', '[EMAIL PROTECTED]');
...
switch($_SERVER['HTTP_HOST'])
{
...
case 'dev.myclient.mycompany.com':

define('MY_APP_DEBUG', TRUE);
define('DB_NAME', 'my_dev_db');
define('EMAIL_SALES', EMAIL_DEV);
define('EMAIL_ADMIN', EMAIL_DEV);
define('EMAIL_JOBS', EMAIL_DEV);
...
break;


No muss. No fuss.

b

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



[PHP] sybase installation error

2007-08-28 Thread Melanie Pfefer
hi,

I am getting an error when I issue 'make' command:

../configure --with-apxs2=/usr/local/apache/bin/apxs
--with-sybase-ct=/opt/sybase/OCS-12_5

it finishes with:

ld: fatal: library -lsybtcl: not found
ld: fatal: File processing errors. No output written
to .libs/libphp5.so
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `libphp5.la'


  ___
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/ 

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



Re: [PHP] Trying to understand sessions and using them to authenticate...

2007-08-28 Thread Daniel Brown
On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> On Aug 28, 2007, at 10:21 AM, Daniel Brown wrote:
>
> > On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
> >>
> >> On Aug 28, 2007, at 10:03 AM, Daniel Brown wrote:
> >>
> >>> On 8/28/07, Jason Pruim <[EMAIL PROTECTED]> wrote:
> >>> [snip]
> > $sql = "SELECT * FROM users WHERE user='".$user."' AND
> > pass='".$pass."' LIMIT 0,1;";
> > $result = mysql_query($sql) or die("Wrong data supplied or
> > database error");
> > while($row = mysql_fetch_array($result)) {
> >>>
> >>> Sounds to me like you're not getting through the while() clause,
> >>> meaning that there's no matching rows in the database.
> >>>
> >>> $sql = "SELECT * FROM login WHERE loginid='".$user."' AND
> >>> email='".$pass."' LIMIT 0,1;";
> >>>
> >>> Is the password they supply in the `email` column of the
> >>> database?
> >>
> >> Yes it is... For now... I am just using test/test and I had a field
> >> named password in the database but thought that was messing it up, so
> >> I dropped that field and currently I am just using the e-mail field
> >> as a password.
> >>
> >> Once it works I'll change the field to a more appropriate selection
> >> with MD5 hashing, and maybe even a little salt in the hash. (Gotta
> >> add the flavor!)
> >>
> >>
> >> --
> >>
> >> Jason Pruim
> >> Raoset Inc.
> >> Technology Manager
> >> MQC Specialist
> >> 3251 132nd ave
> >> Holland, MI, 49424
> >> www.raoset.com
> >> [EMAIL PROTECTED]
> >>
> >>
> >>
> >
> > If you have phpMyAdmin installed on that server, J, try using the
> > "search" tab to see if you can find that user/email combination in the
> > database using = and not LIKE.
> >
> > Perhaps there's a whitespace or something of the like that's
> > causing it to return zero rows.
> >
> > Also, try doing this after the $result = mysql_query($sql); line:
> >
> > die("Number of rows returned by MySQL: ".mysql_num_rows
> > ($result));
>
> I don't have phpMyAdmin installed, never saw the need to... But I'll
> look into it in the future.
>
> And after adding the die that you recommended, you were right, it
> wasn't returning any rows. So... I did some checking and it's amazing
> sometimes that you can't see the trees through the forrest a
> simple $user =$_POST['user']; and $pass=$_POST['pass']; and all is
> well. It logs into the page, now I just need to fine tune it since it
> doesn't like to display the actual database now, but that's something
> I should be able to figure out.
>
> One other question, to logout, can I just call a file that has
> session_destroy() and a header("Location: ???"); in it? Or should I
> do something else for logging out?
>
> Thanks again! Without your help... I wouldn't be able to do this!
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424
> www.raoset.com
> [EMAIL PROTECTED]
>
>
>

For my purposes, I simply do a session_destroy();, but some people
may prefer to do an unset for their own purposes.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Hey, PHP-General list
50% off for life on web hosting plans $10/mo. or more at
http://www.pilotpig.net/.
Use the coupon code phpgeneralaug07
Register domains for about $0.01 more than what it costs me at
http://domains.pilotpig.net/.

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



Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread Simon
you can use sockets in php, they work the same as berkley sockets
you can use system() in php, to call your C++ program (the program
could output html)
in my opinon CGI with C/C++ is obsolete, use php/apache for best results!

another nice way is to have your C++ program independent, outputs its
results/values into a database (mysql)... and a php page will just
read what's in the database to display it nicely.
That would be a clean way of doing it.

Good luck!

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



Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread David Giragosian
On 8/28/07, Simon <[EMAIL PROTECTED]> wrote:
>
> you can use sockets in php, they work the same as berkley sockets
> you can use system() in php, to call your C++ program (the program
> could output html)
> in my opinon CGI with C/C++ is obsolete, use php/apache for best results!
>
> another nice way is to have your C++ program independent, outputs its
> results/values into a database (mysql)... and a php page will just
> read what's in the database to display it nicely.


That's what we do here. C/C++ app gathers and inserts the data into the db,
minute by minute, and PHP apps are used for display, reports, graphics,
etc... Our LAMP system has had nary a glitch in over 3 years of continuous
usage.

That would be a clean way of doing it.
>
> Good luck!



David


Re: [PHP] why?

2007-08-28 Thread mike
On 8/28/07, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> Since PHP cannot read registry settings (neither can JavaScript) on the
> client that is out. Windows is aware of the logged in user, but exactly
> where that 'session' information is kept is a mystery to most of us. So
> PHP cannot be aware of a user who has performed the initial login.

i know there is an apache NTLM(1) module for this. i don't believe it
requires anything other than a connection to a domain authentication
server and the ability to send headers and read the reply
(challenge/response) - i don't think the registry is needed at all on
the client or the server.

(1) http://modntlm.sourceforge.net/  - just one example

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



RE: [PHP] why?

2007-08-28 Thread Jay Blanchard
[snip]
i know there is an apache NTLM(1) module for this. i don't believe it
requires anything other than a connection to a domain authentication
server and the ability to send headers and read the reply
(challenge/response) - i don't think the registry is needed at all on
the client or the server.

(1) http://modntlm.sourceforge.net/  - just one example
[/snip]

True, but it appears that many of these are not ready for prime time and
require an extensive amount of configuration (sometimes even modifying
the registry).

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



Re: [PHP] why?

2007-08-28 Thread Stut

Jay Blanchard wrote:

[snip]
i know there is an apache NTLM(1) module for this. i don't believe it
requires anything other than a connection to a domain authentication
server and the ability to send headers and read the reply
(challenge/response) - i don't think the registry is needed at all on
the client or the server.

(1) http://modntlm.sourceforge.net/  - just one example
[/snip]

True, but it appears that many of these are not ready for prime time and
require an extensive amount of configuration (sometimes even modifying
the registry).


In addition the OP is running IIS so this is all kinda less than helpful 
to him.


-Stut

--
http://stut.net/

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



RE: [PHP] c++ and php! search for a brigde

2007-08-28 Thread Gevorg Harutyunyan
Barev David,

I think this is solution

1. C/C++ updates database (MySQL or other)
2. There is some PHP file that is viewing your DB info(printing static info)
3. There is other PHP file that is using AJAX for interactive update of
information (This one is sending request to first PHP file and if needed
updating second one)

I don't know maybe this is very complex, but I would choose this one ;)

Best,
Gevorg

-Original Message-
From: David Giragosian [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 28, 2007 10:08 PM
To: Simon
Cc: php-general@lists.php.net
Subject: Re: [PHP] c++ and php! search for a brigde

On 8/28/07, Simon <[EMAIL PROTECTED]> wrote:
>
> you can use sockets in php, they work the same as berkley sockets
> you can use system() in php, to call your C++ program (the program
> could output html)
> in my opinon CGI with C/C++ is obsolete, use php/apache for best results!
>
> another nice way is to have your C++ program independent, outputs its
> results/values into a database (mysql)... and a php page will just
> read what's in the database to display it nicely.


That's what we do here. C/C++ app gathers and inserts the data into the db,
minute by minute, and PHP apps are used for display, reports, graphics,
etc... Our LAMP system has had nary a glitch in over 3 years of continuous
usage.

That would be a clean way of doing it.
>
> Good luck!



David

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



Re: [PHP] why?

2007-08-28 Thread mike
On 8/28/07, Stut <[EMAIL PROTECTED]> wrote:
> In addition the OP is running IIS so this is all kinda less than helpful
> to him.

yeah, i didn't say this would, but it should be able to be ported to a
PHP module by someone i would think. i mean if someone can do it in
Perl or C (especially C) why can't it just be changed to work under
zend/etc?

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



Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread shiplu
On 8/28/07, Gevorg Harutyunyan <[EMAIL PROTECTED]> wrote:
>
> Barev David,
>
> I think this is solution
>
> 1. C/C++ updates database (MySQL or other)
> 2. There is some PHP file that is viewing your DB info(printing static
> info)
> 3. There is other PHP file that is using AJAX for interactive update of
> information (This one is sending request to first PHP file and if needed
> updating second one)
>
> I don't know maybe this is very complex, but I would choose this one ;)
>
> Best,
> Gevorg
>
> -Original Message-
> From: David Giragosian [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 28, 2007 10:08 PM
> To: Simon
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] c++ and php! search for a brigde
>
> On 8/28/07, Simon <[EMAIL PROTECTED]> wrote:
> >
> > you can use sockets in php, they work the same as berkley sockets
> > you can use system() in php, to call your C++ program (the program
> > could output html)
> > in my opinon CGI with C/C++ is obsolete, use php/apache for best
> results!
> >
> > another nice way is to have your C++ program independent, outputs its
> > results/values into a database (mysql)... and a php page will just
> > read what's in the database to display it nicely.
>
>
> That's what we do here. C/C++ app gathers and inserts the data into the
> db,
> minute by minute, and PHP apps are used for display, reports, graphics,
> etc... Our LAMP system has had nary a glitch in over 3 years of continuous
> usage.
>
> That would be a clean way of doing it.
> >
> > Good luck!
>
>
>
> David
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
No, this is not that tough. we did it before.

1. A C program retrieves data from several (more than 100) servers.
2. It saves the data in the MySQL db.
3. A php page is loaded with an ajax enabled
4. then a ajax call is sent to the same php file. it uses the setTimeout
function.
5. Data comes in json format.
6. data is formated by javascript and shown in the page.

Thats it.

-- 
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time


Re: [PHP] why?

2007-08-28 Thread shiplu
On 8/28/07, mike <[EMAIL PROTECTED]> wrote:
>
> On 8/28/07, Stut <[EMAIL PROTECTED]> wrote:
> > In addition the OP is running IIS so this is all kinda less than helpful
> > to him.
>
> yeah, i didn't say this would, but it should be able to be ported to a
> PHP module by someone i would think. i mean if someone can do it in
> Perl or C (especially C) why can't it just be changed to work under
> zend/etc?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
This topics subject ("Why?") is not related. I thinks its better to change
it and create another thread. it'll be better for other who already doesn't
know what the actual topic is.
Thanks :)


-- 
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time


RE: [PHP] Regular expression - URL validator

2007-08-28 Thread Wagner Garcia Campagner
Thanks Jim,

Your sugestion worked perfect for me!!

I have another question:

After i validate this URL i want to put a link with this URL in my page.

The problem is that if the URL is like (www.aol.com), when i create the
link, this URL is appended with the URL of my site. The result is a link
pointing to: http:///www.aol.com

But if the URL is like (http://aol.com), then the link is created correct.

Is there a way to avoid the first situation... so the link is created
correct?

Thanks again,
Wagner.



-Original Message-
From: Jim Lucas [mailto:[EMAIL PROTECTED]
Sent: segunda-feira, 27 de agosto de 2007 17:36
To: PHP General; [EMAIL PROTECTED]
Subject: Re: [PHP] Regular expression - URL validator


Wagner Garcia Campagner wrote:
 > Hello,
 >
 > I found this regular expression on a web site.
 > It is basicaly an URL validator.
 >
 > I'm trying to implement this in my web site, but i receive errors.
 >
 > I think this is a PERL REGEX so what should i do to make it work in php?
 >
 >
 > $valid =
 >
(preg_match('^H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9]
 >
.)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\
 > +&%\$#\=~_\-]+))*$', $_POST['website']));

This should be preg_match('/.../i', $_POST['website'])

your regex should look something like this.

^((ftp|(http(s)?))://)?(\.?([a-z0-9-]+))+\.[a-z]{2,6}(:[0-9]{1,5})?(/[a-zA-Z
0-9.,;\?|\'+&%\$#=~_-]+)*$

So, put it all together and it should look like this.


 > if ($valido == 0) {
 > something here;
 > }
 > else {
 > something else here;
 > }
 >
 >
 > Thanks a lot in advance,
 > Wagner.
 >



--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
 by William Shakespeare

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



Re: [PHP] Regular expression - URL validator

2007-08-28 Thread shiplu
On 8/28/07, Wagner Garcia Campagner <[EMAIL PROTECTED]> wrote:
>
> Thanks Jim,
>
> Your sugestion worked perfect for me!!
>
> I have another question:
>
> After i validate this URL i want to put a link with this URL in my page.
>
> The problem is that if the URL is like (www.aol.com), when i create the
> link, this URL is appended with the URL of my site. The result is a link
> pointing to: http:///www.aol.com
>
> But if the URL is like (http://aol.com), then the link is created correct.
>
> Is there a way to avoid the first situation... so the link is created
> correct?
>
> Thanks again,
> Wagner.
>
>
>
> -Original Message-
> From: Jim Lucas [mailto:[EMAIL PROTECTED]
> Sent: segunda-feira, 27 de agosto de 2007 17:36
> To: PHP General; [EMAIL PROTECTED]
> Subject: Re: [PHP] Regular expression - URL validator
>
>
> Wagner Garcia Campagner wrote:
> > Hello,
> >
> > I found this regular expression on a web site.
> > It is basicaly an URL validator.
> >
> > I'm trying to implement this in my web site, but i receive errors.
> >
> > I think this is a PERL REGEX so what should i do to make it work in php?
> >
> >
> > $valid =
> >
>
> (preg_match('^H|h)(T|t)|(F|f))(T|t)(P|p)((S|s)?))\://)?(www.|[a-zA-Z0-9]
> >
>
> .)[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,6}(\:[0-9]{1,5})*(/($|[a-zA-Z0-9\.\,\;\?\'\\\
> > +&%\$#\=~_\-]+))*$', $_POST['website']));
>
> This should be preg_match('/.../i', $_POST['website'])
>
> your regex should look something like this.
>
>
> ^((ftp|(http(s)?))://)?(\.?([a-z0-9-]+))+\.[a-z]{2,6}(:[0-9]{1,5})?(/[a-zA-Z
> 0-9.,;\?|\'+&%\$#=~_-]+)*$
>
> So, put it all together and it should look like this.
>
> 
> $url = "...PUT YOUR TEST URL HERE...";
>
> if (
>
> preg_match('!^((ftp|(http(s)?))://)?(\.?([a-z0-9-]+))+\.[a-z]{2,6}(:[0-9]{1,
> 5})?(/[a-zA-Z0-9.,;\?|\'+&%\$#=~_-]+)*$!i',
> $url) ) {
> echo "Matched";
> } else {
> echo "Did not match";
> }
>
>
>
>
> >
> > if ($valido == 0) {
> > something here;
> > }
> > else {
> > something else here;
> > }
> >
> >
> > Thanks a lot in advance,
> > Wagner.
> >
>
>
>
> --
> Jim Lucas
>
> "Some men are born to greatness, some achieve greatness,
> and some have greatness thrust upon them."
>
> Twelfth Night, Act II, Scene V
>  by William Shakespeare
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
you must use http://www.aol.com not www.aol.com. coz the later is not a
valid url. The protocol is not specified there. and if you use
www.aol.comis your href of a tags, the browser will automatically add
your current web
address as prefix as if its a relative url.
if your site is http://www.example.com/folder/site.html
and if you use href="/www.aol.com" it will show http://www.example.com/
www.aol.com
if you use href="www.aol.com" it will show
http://www.example.com/folder/
www.aol.com
you have to use href="http://www.aol.com"; the absolute one.

-- 
shout at http://shiplu.awardspace.com/

Available for Hire/Contract/Full Time


Re: [PHP] Regular expression - URL validator

2007-08-28 Thread Jim Lucas

Wagner Garcia Campagner wrote:

Thanks Jim,

Your sugestion worked perfect for me!!

I have another question:

After i validate this URL i want to put a link with this URL in my page.

The problem is that if the URL is like (www.aol.com), when i create the
link, this URL is appended with the URL of my site. The result is a link
pointing to: http:///www.aol.com

But if the URL is like (http://aol.com), then the link is created correct.

Is there a way to avoid the first situation... so the link is created
correct?

Thanks again,
Wagner.


You could always do a string comparison for http(s)? in the url

if ( strpos($url, array('https://', 'http://')) === false ) {
$url = 'http://'.$url;
}

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] c++ and php! search for a brigde

2007-08-28 Thread Jim Lucas

dwa wrote:

Hello people,
i have a question??

I have an application written in c++ and this throw real time data as 
udp-pakets all the time (interval 1 min and values in a wrapper like an 
own protocol are floats and longs).


Is there any possibility to catch the udp packets - parse the pakets und 
show the values in tables in a html-doc in real time???


What technologies are good? ajax? cgi? ive no idea!

mfg
david


I recently built a PHP daemon.  It uses sockets to listen on a given port for 
UDP packets.

Take in a request, processes, decides what it needs to do based off the request and then takes 
action.  Once it is done with said action, starts listening again.  This process is done a few times 
a second.  I have it logging connections to a DB and saving other information to a log file in the 
file system.


You could easily take something like this and create a daemon that would listen for incoming 
connections and from the data it gets build a page and drop that onto the file system.


here is an example of what I do

if ( $socket = @stream_socket_server('udp://'.LISTEN_IP.':'.LISTEN_PORT, $errno, $errstr, 
STREAM_SERVER_BIND) ) {

while ( true ) {
$packet = '';
while ( $buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, 
$remote_ip) ) {
$packet .= $buff;
}

//  if need be, loop this until you get to the end of your 
packet/information
while ( !empty($buff) ) {
$buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, 
$remote_ip);
}
//  work with $buff here to capture all your data.
//  Then also figure out when and if you need to exit

}
fclose($socket);
}

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP] Building Web Site with Member Area in PHP (and MySQL) - Howto

2007-08-28 Thread Stephen
Can anyone recommend resources that I can use to learn
about doing this?

Are then any open source scripts that demonstrate this
kind of site?

Thanks
Stephen

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



RE: [PHP] Building Web Site with Member Area in PHP (and MySQL) - Howto

2007-08-28 Thread Jay Blanchard
[snip]
Can anyone recommend resources that I can use to learn
about doing this?

Are then any open source scripts that demonstrate this
kind of site?
[/snip]

Google is your friend
http://www.google.com/search?hl=en&q=PHP+MySQL+login

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



Re: [PHP] Building Web Site with Member Area in PHP (and MySQL) - Howto

2007-08-28 Thread Greg Donald
On 8/28/07, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> Google is your friend
> http://www.google.com/search?hl=en&q=PHP+MySQL+login

Everyone knows that already, even Google.

http://www.google.com/search?q=google+is+your+friend


-- 
Greg Donald
http://destiney.com/

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



[PHP] Re: Disadvantages of output buffering

2007-08-28 Thread Felipe Alcacibar

Emil Edeholt wrote:

Hi!

My php project would get a much cleaner code if I could set cookies 
anywhere in the code. So I thought of output buffering. But I can't find 
any articles on the cons of output buffering. I mean it most be a reason 
for it being off by default?


Kind Regards Emil Edeholt



The output buffering maybe would be unstable your php application  in 
some cases. May be it so slowly in some versions of php and depend of 
the web server that you have mounted your php. And it uses memory this 
point is so clearly.


If you want to create cookies server/client "on the fly" you may need 
ajax, with this asynchronus requests you put headers and cookies 
instead, and use it on the fly in the browser if the http request is ok.


Are you know the session variables, maybe you need that.

Well, the desicion is yours. tell us what you want to do.

Cheers!!

Felipe Alcacibar

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



[PHP] Background Image

2007-08-28 Thread Jeff


is how I am displaying my background image. This is creating problems for 
different screen resolutions.

What would be the appropriate way to display this code so the image would 
not scroll, resize to the users current screen resolutions and just the page 
content would scroll?

TYIA! 

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



Re: [PHP] Adding text before last paragraph

2007-08-28 Thread Dotan Cohen
On 28/08/07, Brian Rue <[EMAIL PROTECTED]> wrote:
> Sure, I'll break it apart a little:

Er, wow, thanks. Lots of material here...

> '{(?=|\s)(?!.*|\s)))}is'
>
> $regex = '{' . // opening delimeter
>  '(?=' .   // positive lookahead: match the beginning of a position
>// that matches the following pattern:
>  ' tag
>  '(?:' . // non-capturing parenthesis (same as normal
>  // parenthesis, but a bit faster since we don't
>  // need to capture what they match for use later
>  '>|\s' . // match a closing > or a space
>  ')' . // end capturing paranthesis
>  '(?!' . // negative lookahead: the match will fail if the
> //following pattern matches from the current position
>  '.*' .  // match until the end of the string
>  '|\s)' . // same as above - look for another  tag
>  ')' .  // end negative lookahead
>  ')' .  // end positive lookahead
>  '}is';   // ending delimeter, and use modifiers s and i

It was the negative lookahead that confused me, I see. The rest seems
pretty straightforward. Difficult, but straightforward.

>
> About the modifiers: i makes it case-insensitive, and s turns on
> dot-matches-all-mode (including newlines)--otherwise, the . would only match
> until the next newline.

Yes, this I know.

> The regex has two parts: matching a  tag, and then making sure there
> aren't any more  tags in the string following it. The positive lookahead
> is (hopefully) pretty straightforward. The negative lookahead works by using
> a greedy (regular) .*, which forces the regex engine to match all the way to
> the end of the haystack. Then it encounters the \s) part, forcing it
> to backtrack until it finds a  tag. If it doesn't find one before
> returning to the 'current' position (directly after the  tag we just
> matched), then we know we have found the last  tag.

Nice. Very nice.

> The positive and negative lookahead are 'zero-width' requirements, which
> means they don't advance the regex engine's pointer in the haystack string.
> Since the entire regex is zero-width, the replacement string gets inserted
> at the matched position.

Hmm.

> I hope that made at least a little bit of sense :) If you're doing a lot of
> regex work, I would strongly recommend reading the book Mastering Regular
> Expressions by Jeffrey Friedl... it's very well written and very helpful.

I don't do a lot, but it's a great tool to know when one needs it!
Thank you for the patient explanations.

Just a general note, both these addresses are 404 right now:
http://il.php.net/manual/en/pcre.pattern.modifiers.php
http://uk.php.net/manual/en/pcre.pattern.syntax.php

Dotan Cohen

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

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



[PHP] Re: Background Image

2007-08-28 Thread Al

You are in the wrong newsgroup.  Try the HTML newsgroup

Jeff wrote:
vlink="#00" alink="#00">


is how I am displaying my background image. This is creating problems for 
different screen resolutions.


What would be the appropriate way to display this code so the image would 
not scroll, resize to the users current screen resolutions and just the page 
content would scroll?


TYIA! 


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



Re: [PHP] Database includes

2007-08-28 Thread Larry Garfield
On Tuesday 28 August 2007, brian wrote:

> > If you have to modify anything other than a single config file in order
> > to move your site/app from one server to another, then you have a design
> > flaw. (I'd say that applies for moving the site to a subdirectory on a
> > server too, but that takes a bit more effort.)
>
> I'm with Larry on this. Include a constants file at the top of your
> scripts. In that file you can place a switch block that tests for the
> $_SERVER['HTTP_HOST']. For each case, place something like:

That's bad, too, if you have multiple developers on the project.  Just have a 
separate config file that contains *nothing* but the installation config, and 
every install has its own copy.

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

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

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



Re: [PHP] Database includes

2007-08-28 Thread brian

Larry Garfield wrote:

On Tuesday 28 August 2007, brian wrote:



If you have to modify anything other than a single config file in order
to move your site/app from one server to another, then you have a design
flaw. (I'd say that applies for moving the site to a subdirectory on a
server too, but that takes a bit more effort.)


I'm with Larry on this. Include a constants file at the top of your
scripts. In that file you can place a switch block that tests for the
$_SERVER['HTTP_HOST']. For each case, place something like:



That's bad, too, if you have multiple developers on the project.  Just have a 
separate config file that contains *nothing* but the installation config, and 
every install has its own copy.




How so? If, by multiple developers, you mean multiple *development 
domains*, then yes, that'd need tweaking. Otherwise, i fail to see the 
badness.


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



Re: [PHP] Database includes

2007-08-28 Thread Chris

brian wrote:

Larry Garfield wrote:

On Tuesday 28 August 2007, brian wrote:



If you have to modify anything other than a single config file in order
to move your site/app from one server to another, then you have a 
design

flaw. (I'd say that applies for moving the site to a subdirectory on a
server too, but that takes a bit more effort.)


I'm with Larry on this. Include a constants file at the top of your
scripts. In that file you can place a switch block that tests for the
$_SERVER['HTTP_HOST']. For each case, place something like:



That's bad, too, if you have multiple developers on the project.  Just 
have a separate config file that contains *nothing* but the 
installation config, and every install has its own copy.




How so? If, by multiple developers, you mean multiple *development 
domains*, then yes, that'd need tweaking. Otherwise, i fail to see the 
badness.


Multiple developers as in more than one person coding the application.

You'd be sharing the development environment (database, files etc) - not 
what you want.


Think if your app was in cvs/subversion and you had someone working on 
the same stuff at the desk next to you.


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

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



[PHP] Re: Problems with matrix

2007-08-28 Thread Felipe Alcacibar

Andres Rojas wrote:

Hi all,

I'm new in PHP programming and I have a problem with this script. I need
to read a large file around 2Mb and several lines (28000). All start Ok,
but suddenly the script stop without message error.

	$myear[]=$year; 
	$mhour[]=$hour;

$mmin[]=$min;
$mtemp[]=$temp;
$mhum[]=$hum;
$mdew[]=$dew;
$mbaro[]=$baro;
$mwind[]=$wind;
$mgust[]=$gust;
$mwdir[]=$wdir;
$mrlastm[]=$rlastm;
$mdai[]=$rdai;
$mrmon[]=$rmon;
$mryear[]=$ryear;
$mheat[]=$heat;
echo"$day $month $year $hour $min $temp $hum $dew $baro $wind $gust
$wdir $rlastm $rdai $rmon $ryear $heat ";
}
			
	?>


If only I print the variable $buffer all it's ok, but when I try to fill
all the matrix the script doesn't work. If I reduce the number of matrix
only a 3 o 4 it's Ok, but If I increase number of this matrix the script
crash again.

Perhaps it's a problem of memory of server, but my  service provider say
me that this is not the problem.


Thank you very much


Andres:

The info is too poor to see what is wrong, maybe you need to review 
a error_reporting() php function, o error_reporting php.ini variable i 
send you some code:


	// trim removes all white spaces at the end and the beginning of 
the string.

$k = 0;
foreach(array(
'mday', 'mmonth',
'myear', 'mhour',
'mtemp',  'mhum',
'mdew', 'mbaro',
'mwind', 'mgust',
'mwdir',  'mrlastm',
'mrdai', 'mrmon',
'mryear', 'mheat' ) as $var )
{
if(!isset($$var)) $$var = array();
array_push($$var, $data[$k]);
echo $var." => ".$data[$k];
$k++;
}   

   }
?>

cheers!!

Felipe Alcacibar

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



Re: [PHP] Background Image

2007-08-28 Thread Per Jessen
Jeff wrote:

> What would be the appropriate way to display this code so the image
> would not scroll, resize to the users current screen resolutions and
> just the page content would scroll?

This list is about PHP, and probably not the best place to ask that
question, but you need to look at CSS and javascript. 


/Per Jessen, Zürich

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