php-general Digest 7 May 2004 13:30:10 -0000 Issue 2749

Topics (messages 185579 through 185614):

Returning an object
        185579 by: Aidan Lister
        185581 by: Petr U.
        185583 by: Curt Zirzow
        185585 by: John W. Holmes
        185603 by: Jay Blanchard

Re: strip comments from HTML?
        185580 by: Justin French
        185582 by: John W. Holmes
        185586 by: Paul Chvostek

Re: Looking for Advanced PHP Developers
        185584 by: Curt Zirzow

[Newbie Guide] For the benefit of new members
        185587 by: Ma Siva Kumar

Socket
        185588 by: Juan Pablo Herrera
        185590 by: Petr U.

PHP Research
        185589 by: Trevor Nesbit

setting php_admin_value 2
        185591 by: Tim Traver

Best way to get mysql table metadata
        185592 by: daniel.electroteque.org

Recommend an IDE for Windows
        185593 by: Chris Lott
        185595 by: Richard Davey
        185612 by: Seth Bembeneck

HTML vs. Plain Text Input
        185594 by: Matt Palermo
        185596 by: Richard Davey

A work around my HTTP_REFERER Prob...
        185597 by: Tristan.Pretty.risk.sungard.com
        185601 by: Richard Harb
        185606 by: Tristan.Pretty.risk.sungard.com
        185608 by: Jason Wong

auto saving data in forms
        185598 by: mserra.gdwd.com
        185604 by: Jay Blanchard
        185614 by: Travis Low

Showing only part of string
        185599 by: Dave Carrera
        185600 by: Richard Harb
        185602 by: John W. Holmes
        185605 by: Dave Carrera

Active PHP Sessions
        185607 by: Paul Higgins
        185609 by: Brent Clark
        185610 by: Jason Wong
        185611 by: John W. Holmes
        185613 by: Torsten Roehr

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
How _should_ this be done? In terms of "best practice".

<?php
function foobar ()
{
    return new SomeObject;
}
?>

Or:

<?php
function barfoo ()
{
    $tempvar = new SomeObject;
    return $tempvar
}
?>

Please don't reply if you really, really don't know what you are talking
about.

--- End Message ---
--- Begin Message ---
On Fri, 7 May 2004 11:35:24 +1000
"Aidan Lister" <[EMAIL PROTECTED]> wrote:

 > How _should_ this be done? In terms of "best practice".

I'd choose this way:

function &foo()
{
    return new Object;
}

-- 
Petr U.

--- End Message ---
--- Begin Message ---
* Thus wrote Aidan Lister ([EMAIL PROTECTED]):
> How _should_ this be done? In terms of "best practice".
> 
> <?php
> function foobar ()
> {
>     return new SomeObject;
> }
> ?>
> 
> Or:
> 
> <?php
> function barfoo ()
> {
>     $tempvar = new SomeObject;
>     return $tempvar
> }
> ?>

I'm not exactly sure what your looking for, this is like asking
what is better:

  $a = 'foo';
  echo $a;

  or 
  echo 'foo';

if tou want my opinion it should be written like this:
<?php

/*
 * Create an instance of SomeObject
 */
function foobar() {
  return new SomeObject;
}


 
> Please don't reply if you really, really don't know what you are talking
> about.

What kind of requirement is this? Anyone can reply your email and
they will do so if they feel like it.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message --- Aidan Lister wrote:

Please don't reply if you really, really don't know what you are talking
about.

Okay, I won't reply.


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
[snip]
Please don't reply if you really, really don't know what you are talking
about.
[/snip]

Talk about alienating yourself right up front.

--- End Message ---
--- Begin Message --- Thanks to everyone who's replied... appears to be quite a tricky one!!

$text = preg_replace('/<!--.*-->/su','',$text);
        Did not work (was too greedy, matched multiple comments)

$text = preg_replace('/<!--.*?-->/','',$text);
        Did not work (needed multiple lines)

$text = preg_replace('/<!--.*?-->/su','',$text);
        Does work so far, finger's crossed.

Thanks again to John, Paul, Rob, Tom, et al.

---
Justin French
http://indent.com.au

--- End Message ---
--- Begin Message --- Justin French wrote:

$text = preg_replace('/<!--.*-->/su','',$text);
    Did not work (was too greedy, matched multiple comments)

Just for the record, it should be a capital 'U' for ungreedy. Lowercase 'u' is something else. :)


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
On Thu, May 06, 2004 at 07:11:55PM +0000, Curt Zirzow wrote:
> > 
> >  $text="one <!--bleh\nblarg -> two\n";
> >  print ereg_replace("<!--([^-][^-]?[^>]?)*-->", "",$text);
> 
> Because your missing a -
> $text="one <!--bleh\nblarg --> two\n";

/me applies mallet to head

 % php -r '$text="one <!--bleh\nblarg --> two\n"; print 
ereg_replace("<!--([^-][^-]?[^>]?)*-->", "",$text);'
 one  two

whee, it works!  :)

-- 
  Paul Chvostek                                             <[EMAIL PROTECTED]>
  it.canada                                            http://www.it.ca/
  Free PHP web hosting!                            http://www.it.ca/web/

--- End Message ---
--- Begin Message ---
* Thus wrote Stephen Allen ([EMAIL PROTECTED]):
> On Thu, May 06, 2004 at 01:15:17AM +0200 or thereabouts, Richard Harb wrote:
> > ... and onsite would be where ?
> 
> Amman, Jordan I think. I wouldn't want to be a Caucasian over there working, at this
> point in time.

I'd be more weary that the OP was from a @yahoo.com account for a
site that has its own domain :/


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
=======================================
This message is for the benefit of new 
subscribers and those new to PHP.  Please 
feel free to add more points and send to the 
list.
=======================================
1. If you have any queries/problems about PHP 
try http://www.php.net/manual/en first. You 
can download a copy and use it offline also. 

Please also try 
http://www.php.net/manual/faq.php 
for answers to frequently answered questions 
about PHP (added by Christophe Chisogne).

2. Try http://www.google.com next. Searching 
for "php YOUR QUERY" may fetch you relevant 
information within the first 10 results.

3. There is a searchable archive of the 
mailing list discussion at 
http://phparch.com/mailinglists. Many of the 
common topics are discussed repeatedly, and 
you may get answer to your query from the 
earlier discussions. 

For example: One of the repeatedly discussed 
question in the list is "Best PHP editor". 
Everyone has his/her favourite editor. 
You can get all the opinions by going through 
the list archives. If you want a chosen list 
try this link : 
http://phpeditors.linuxbackup.co.uk/ 
(contributed by Christophe Chisogne).

4. Not sure if PHP is working or you want 
find out what extensions are available to 
you?

Just put the following code into a file with 
a .php extension and access it through your 
webserver:

<?php
        phpinfo();
?> 

If PHP is installed you will see a page with 
a lot of information on it. If PHP is not 
installed (or not working correctly) your 
browser will try to download the file.

(contributed by Teren and reworded by Chris W 
Parker)

5. If you are stuck with a script and do not 
understand what is wrong, instead of posting 
the whole script, try doing some research 
yourself. One useful trick is to print 
the variable/sql query using print or echo 
command and check whether you get what you 
expected. 

After diagnosing the problem, send the 
details of your efforts (following steps 1, 
2 & 3) and ask for help.

6. PHP is a server side scripting language. 
Whatever processing PHP does takes place 
BEFORE the output reaches the client. 
Therefore, it is not possible to access 
users'  computer related information (OS, 
screen size etc) using PHP. Nor can you 
modify any the user side settings. You need 
to go for JavaScript and ask the question in 
a JavaScript list.

On the other hand, you can access the 
information that is SENT by the user's 
browser when a client requests a page from 
your server. You can find details about 
browser, OS etc as reported by 
this request. - contributed by Wouter van 
Vliet and reworded by Chris W Parker.

7. Provide a clear descriptive subject line. 
Avoid general subjects like "Help!!", "A 
Question" etc.  Especially avoid blank 
subjects. 

8. When you want to start a new topic, open a 
new mail composer and enter the mailing list 
address [EMAIL PROTECTED] instead of 
replying to an existing thread and replacing 
the subject and body with your message.

9. It's always a good idea to post back to 
the list once you've solved your problem. 
People usually add [SOLVED] to the subject 
line of their email when posting solutions. 
By posting your solution you're helping the 
next person with the same question. 
[contribued by Chris W Parker]

10. Ask smart questions  
http://catb.org/~esr/faqs/smart-questions.html
[contributed by Jay Blanchard)

11. Do not send your email to the list with 
attachments. If you don't have a place to 
upload your code, try the many pastebin 
websites (such as www.pastebin.com).
[contributed by Burhan Khalid]


Hope you have a good time programming with 
PHP.
-- 
Integrated Management Tools for leather 
industry
----------------------------------
http://www.leatherlink.net

Ma Siva Kumar,
BSG LeatherLink (P) Ltd,
Chennai - 600106

--- End Message ---
--- Begin Message ---
Hi!
Please, i need a tutorial about socket. I read php.net but the examples is
lost.
Regards,
Juan Pablo

--- End Message ---
--- Begin Message ---
On Fri, 7 May 2004 00:59:03 -0300 (ART)
"Juan Pablo Herrera" <[EMAIL PROTECTED]> wrote:

 > Please, i need a tutorial about socket. I read php.net but the examples is
 > lost.

I think you should check it again ;)
http://www.php.net/manual/en/ref.sockets.php

-- 
Petr U.

--- End Message ---
--- Begin Message ---
Hi

I am in the process of conducting a research project that is looking at
what PHP skills we should be teaching to our students.

If you would be prepared to complete this questionnaire, please reply
to this email and I will send you the questionnaire....

Kind regards

Trevor Nesbit


Trevor Nesbit
MBS BSc BCom CA PGDipBusAdmin
Degree Leader for Bachelor of ICT
Programme Leader for Graduate Diploma in eCommerce
School of Computing - www.cpit.ac.nz/computing
School of Business
Christchurch Polytechnic Institute of Technology

--- End Message ---
--- Begin Message --- David and all,

I apologize for not posting properly. I did not realize that headers were keeping track of the threads of this mailing list. I will make sure I don't do it again.

I am actually simply using the Host header to make a dynamic path to its data location in my apache module.

Unfortunately, the mod_php4 modules is rather cryptic in how it does things, and it looks like it doesn't do any of the variable setups on a per-request basis, so it would be difficult to track where it puts that information, but I guess its the only place for me to look unless you or anyone else has a better idea of where I can tap in to make those kind of changes on the fly...

In case no one else got my message due to my fopaux, I have included a copy of my original message below.

To clarify, the goal is to set up some security variables like open_basedir...

Thanks,

Tim.

Hi all,

ok, I am writing an apache module that dynamically figures out virtual host
variables for data locations for my users.

I need to be able to set the php_admin_values for each request so that
those values get passed through to php and take effect for each request.

Normally, this would be static inside the apache conf file using the
php_admin_value directive.


Does anyone here know how I could set these variables dynamically ? Do I have to load the apache configuration tables and change it manually ? or can I set a particular environment variable that gets read by php ?

Thanks,

Tim.


SimpleNet's Back ! http://www.simplenet.com

--- End Message ---
--- Begin Message ---
Hi there, I am trying to upgrade my db class, so I can tell if what table
type of the table being queried is. More specifically i need to work out if
the table is an innodb transaction table, if so I would like to start the
transaction and commit and rollback when needed.

Let me know.

--- End Message ---
--- Begin Message ---
I already use and am happy with a variety of text editors (vim, emacs,
ultraedit, jedit, Homesite) depending on my needs, but I would like
recommendations for a PHP specific IDE that will run on Windows XP.

Specifically I am looking for something that can help with debugging,
provides efficient code browsing (functions, objects, etc) across multiple
files in a project, easy browsing through proper mappings to a development
server/local server, and hooks to PHP reference/help/website.

Needless to say, standard features like syntax highlighting, block
formatting, etc. are a requirement.

I've been looking at Zend Studio and Nusphere PHPEd as primary candidates.
However, I have a short window to buy something (fiscal year issues) so any
comments on these two editors (separately or in comparison to one another)
or other tools I should be looking at would be greatly appreciated!

c
--
Chris Lott <chris.lott[AT]gmail.com>

--- End Message ---
--- Begin Message ---
Hello Chris,

Friday, May 7, 2004, 7:47:18 AM, you wrote:

CL> I already use and am happy with a variety of text editors (vim, emacs,
CL> ultraedit, jedit, Homesite) depending on my needs, but I would like
CL> recommendations for a PHP specific IDE that will run on Windows XP.

CL> Specifically I am looking for something that can help with debugging,
CL> provides efficient code browsing (functions, objects, etc) across multiple
CL> files in a project, easy browsing through proper mappings to a development
CL> server/local server, and hooks to PHP reference/help/website.

CL> Needless to say, standard features like syntax highlighting, block
CL> formatting, etc. are a requirement.

Sounds like you just described Zend Studio perfectly. I used to use
the NuSphere PHPEd a few years back and quite frankly it was bugged to
hell - they have sorted out loads of those issues since then, but I
moved onto Zend Studio a year ago and won't ever look back. I have
been beta testing the 3.5.0 release for a while now and it's
absolutely great. The debugger is smart, the Code Profiler essential,
the code analyser is good too and the Project settings can span
whatever you need it to. I honestly couldn't code without it now.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

--- End Message ---
--- Begin Message ---
I use Maguma Studio, the free version:

http://www.maguma.com/products/?article=Studio

The differences between the versions:

http://www.maguma.com/products/?article=studio_compare

It does have a splash screen that asks if you want to buy a copy even though
its free.

Hope this helps

Seth
"Chris Lott" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I already use and am happy with a variety of text editors (vim, emacs,
> ultraedit, jedit, Homesite) depending on my needs, but I would like
> recommendations for a PHP specific IDE that will run on Windows XP.
>
> Specifically I am looking for something that can help with debugging,
> provides efficient code browsing (functions, objects, etc) across multiple
> files in a project, easy browsing through proper mappings to a development
> server/local server, and hooks to PHP reference/help/website.
>
> Needless to say, standard features like syntax highlighting, block
> formatting, etc. are a requirement.
>
> I've been looking at Zend Studio and Nusphere PHPEd as primary candidates.
> However, I have a short window to buy something (fiscal year issues) so
any
> comments on these two editors (separately or in comparison to one another)
> or other tools I should be looking at would be greatly appreciated!
>
> c
> --
> Chris Lott <chris.lott[AT]gmail.com>

--- End Message ---
--- Begin Message ---
Hey, I was wondering if anyone knows of any easy ways to detect for HTML
input.  I have a textarea box that I want users to be able to input either
plain text or HTML code.  I will later display this input data, so if the
user input plain text then I will replace newline characters (\r\n, \n, \r)
with <br> tags, but if they input HTML code I don't want to format it before
displaying it.  Basically is there an easy way to detect HTML code in
inputs?  If you have any suggestions, please let me know.

Thanks,

Matt
http://sweetphp.com

--- End Message ---
--- Begin Message ---
Hello Matt,

Friday, May 7, 2004, 9:33:28 AM, you wrote:

MP> Hey, I was wondering if anyone knows of any easy ways to detect for HTML
MP> input.  I have a textarea box that I want users to be able to input either
MP> plain text or HTML code.  I will later display this input data, so if the
MP> user input plain text then I will replace newline characters (\r\n, \n, \r)
MP> with <br> tags, but if they input HTML code I don't want to format it before
MP> displaying it.  Basically is there an easy way to detect HTML code in
MP> inputs?  If you have any suggestions, please let me know.

Just one way of doing this, but...

$userinput = 'blah blah <b>bold!</b> blah';
$test_html = strip_tags($userinput);

if ($userinput !== $test_html)
{
   echo 'They included html!';
}
else
{
    echo 'Plain text';
}

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

--- End Message ---
--- Begin Message ---
To recap...
We have two servers:
1. USA - holds most of our databases, and E-mail. but specifically, the 
usernames and passwords, or all our users (Lotus Domino Server)
2. UK - Runs our website. (Unix Server)

We wanted to be able to allow people to login on on server 1, and getr 
authenticated etc, and then get redirected to server 2.
Using http_referer we would confirm that they came from server 1

However, as I discovered, that is not possible.
So what we did was this:

On the login form on server 1, the referering URL to server 2, contains a 
varibale called 'secure'
we asign that variable that value of '4654376534' and divide it by the day 
(eg: if it's the 12th of may, we divide by 12.. 7th of June, we divide by 
7)
I know that this is crackable, but it's just a stop gap measure...

My problem today is this:
It's not confirming the values?
See my code below....
================
session_start();
        $today_day = date("d");
        $code1 = ($today_day+1) * $secure;
        $code2 = $today_day * $secure;
        $code3 = ($today_day-1) * $secure;
        $master_code = 4654376534;
if (($code1 == $master_code) || ($code2 == $master_code) || ($code3 == 
$master_code)) {
        $_SESSION[logged] = 'true';
        $login_info = "You are now <b>Logged in</b>";
} else if ($_SESSION[logged] == 'true') {
        $login_info = "You are still <b>Logged in</b>";
}
=================

I start by getting the date $today_day
As we're in two time zones, I don't wanna get caught out by the time 
difference, so I've created a +/- 1 each side ($code1-3)
and fianlly, asigned the master input variable (the decoder)

Now it all works great..! (all variables echo what they should) however, 
I'm not getting logged in?
I'm really stumped...
any ideas?

Tris...

*********************************************************************
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***********************************************************************

--- End Message ---
--- Begin Message ---
What about allowing your UK server to access the database of your USA
Server? You could open a port to that specific IP address only, ...

Then authenticating users on the UK server would work like a charm.
You could even create a 'shared' database for basic session
information.

I think if sessions are used the overhead would not be overly serious
except for the one time a user has to log in.

Ok, I have no idea whatsoever about how to access a Domino Server, but
there just has to be a way... XMLRPC?

just a thought ...
Richard


Friday, May 7, 2004, 11:39:12 AM, thus was written:
> To recap...
> We have two servers:
> 1. USA - holds most of our databases, and E-mail. but specifically, the
> usernames and passwords, or all our users (Lotus Domino Server)
> 2. UK - Runs our website. (Unix Server)

> We wanted to be able to allow people to login on on server 1, and getr
> authenticated etc, and then get redirected to server 2.
> Using http_referer we would confirm that they came from server 1

> However, as I discovered, that is not possible.
> So what we did was this:

> On the login form on server 1, the referering URL to server 2, contains a
> varibale called 'secure'
> we asign that variable that value of '4654376534' and divide it by the day
> (eg: if it's the 12th of may, we divide by 12.. 7th of June, we divide by
> 7)
> I know that this is crackable, but it's just a stop gap measure...

> My problem today is this:
> It's not confirming the values?
> See my code below....
> ================
> session_start();
>         $today_day = date("d");
>         $code1 = ($today_day+1) * $secure;
>         $code2 = $today_day * $secure;
>         $code3 = ($today_day-1) * $secure;
>         $master_code = 4654376534;
> if (($code1 == $master_code) || ($code2 == $master_code) || ($code3 ==
> $master_code)) {
>         $_SESSION[logged] = 'true';
>         $login_info = "You are now <b>Logged in</b>";
> } else if ($_SESSION[logged] == 'true') {
>         $login_info = "You are still <b>Logged in</b>";
> }
> =================

> I start by getting the date $today_day
> As we're in two time zones, I don't wanna get caught out by the time
> difference, so I've created a +/- 1 each side ($code1-3)
> and fianlly, asigned the master input variable (the decoder)

> Now it all works great..! (all variables echo what they should) however,
> I'm not getting logged in?
> I'm really stumped...
> any ideas?

> Tris...

--- End Message ---
--- Begin Message ---
I looked into getting PHP to talk to a  Lotus notes database, and was 
really really scared..!
I think this is my best bet, for now at least... however, my simple code 
does not work?
Wierd...
Any other ideas?




Richard Harb <[EMAIL PROTECTED]> 
07/05/2004 11:38
Please respond to
Richard Harb <[EMAIL PROTECTED]>


To
php-general <[EMAIL PROTECTED]>
cc

Subject
Re: [PHP] A work around my HTTP_REFERER Prob...






What about allowing your UK server to access the database of your USA
Server? You could open a port to that specific IP address only, ...

Then authenticating users on the UK server would work like a charm.
You could even create a 'shared' database for basic session
information.

I think if sessions are used the overhead would not be overly serious
except for the one time a user has to log in.

Ok, I have no idea whatsoever about how to access a Domino Server, but
there just has to be a way... XMLRPC?

just a thought ...
Richard


Friday, May 7, 2004, 11:39:12 AM, thus was written:
> To recap...
> We have two servers:
> 1. USA - holds most of our databases, and E-mail. but specifically, the
> usernames and passwords, or all our users (Lotus Domino Server)
> 2. UK - Runs our website. (Unix Server)

> We wanted to be able to allow people to login on on server 1, and getr
> authenticated etc, and then get redirected to server 2.
> Using http_referer we would confirm that they came from server 1

> However, as I discovered, that is not possible.
> So what we did was this:

> On the login form on server 1, the referering URL to server 2, contains 
a
> varibale called 'secure'
> we asign that variable that value of '4654376534' and divide it by the 
day
> (eg: if it's the 12th of may, we divide by 12.. 7th of June, we divide 
by
> 7)
> I know that this is crackable, but it's just a stop gap measure...

> My problem today is this:
> It's not confirming the values?
> See my code below....
> ================
> session_start();
>         $today_day = date("d");
>         $code1 = ($today_day+1) * $secure;
>         $code2 = $today_day * $secure;
>         $code3 = ($today_day-1) * $secure;
>         $master_code = 4654376534;
> if (($code1 == $master_code) || ($code2 == $master_code) || ($code3 ==
> $master_code)) {
>         $_SESSION[logged] = 'true';
>         $login_info = "You are now <b>Logged in</b>";
> } else if ($_SESSION[logged] == 'true') {
>         $login_info = "You are still <b>Logged in</b>";
> }
> =================

> I start by getting the date $today_day
> As we're in two time zones, I don't wanna get caught out by the time
> difference, so I've created a +/- 1 each side ($code1-3)
> and fianlly, asigned the master input variable (the decoder)

> Now it all works great..! (all variables echo what they should) however,
> I'm not getting logged in?
> I'm really stumped...
> any ideas?

> Tris...

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





*********************************************************************
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***********************************************************************

--- End Message ---
--- Begin Message ---
On Friday 07 May 2004 20:05, [EMAIL PROTECTED] wrote:

> > varibale called 'secure'
> > we asign that variable that value of '4654376534' and divide it by the
>
> day
>
> > (eg: if it's the 12th of may, we divide by 12.. 7th of June, we divide
>
> by
>
> > 7)

That would result in a floating point number ...

> > if (($code1 == $master_code) || ($code2 == $master_code) || ($code3 ==
> > $master_code)) {

... which does not lend easily to such comparisons.

If you're still intent on using this *ahem* 'security' scheme then I suggest 
you use multiplication instead (just make sure that the largest number you're 
processing is less than 2147483648 - or use the BCMath functions).

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
After all, it is only the mediocre who are always at their best.
                -- Jean Giraudoux
*/

--- End Message ---
--- Begin Message ---
Hi,

i'm currently designing a website in which i have some forms with data saved in
database.

My customer wants that when he add or modify some datas in these forms, changes
will be made immediately in database. I really don't know how to do it and don't
know if it is possible. 

Is there anyone who have fijnd a solution to solve that problem and who can help
me. I accept solutions in other langages than PHP like JAVA + XML.

thanks,

Marc

--- End Message ---
--- Begin Message ---
[snip]
My customer wants that when he add or modify some datas in these forms,
changes
will be made immediately in database. I really don't know how to do it
and don't
know if it is possible. 

Is there anyone who have fijnd a solution to solve that problem and who
can help
me. I accept solutions in other langages than PHP like JAVA + XML.
[/snip]

PHP cannot because it is server side and the action needs to send data
from the client to the server. You might be able to use JavaScript and
have the data updated as each field loses focus. Seems rather
inefficient.

--- End Message ---
--- Begin Message --- To do this reliably, you'll need something like a Java applet. In your shoes, I'd ask the customer how important this requirement REALLY is. It will cost more to develop, and will increase the load on the database a LOT.

cheers,

Travis

[EMAIL PROTECTED] wrote:

i'm currently designing a website in which i have some forms with data saved in database.

My customer wants that when he add or modify some datas in these forms, changes
will be made immediately in database. I really don't know how to do it and don't
know if it is possible.


Is there anyone who have fijnd a solution to solve that problem and who can help
me. I accept solutions in other langages than PHP like JAVA + XML.

thanks,

Marc


-- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com>

--- End Message ---
--- Begin Message ---
Hi List,

$string = "This is a test string to <title>SHOW ONLY THIS BIT</title> of the
string";

I have tried strpos, str_replace and other string manipulation things but I
cant get my head around how to achieve showing the text with the
<title></title> tags of the string.

Any help is appreciated and I thank you in advance for any help given.

Thank you

Dave Carrera


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.677 / Virus Database: 439 - Release Date: 04/05/2004
 

--- End Message ---
--- Begin Message ---
I guess the easiest way to do this would be to use a regular
expression:

if (preg_match("/<title>(.*)<\/title>/i", $string, $m)) {
    $found = $m[1];
}
echo $found;

Richard


Friday, May 7, 2004, 12:11:02 PM, thus was written:
> Hi List,

> $string = "This is a test string to <title>SHOW ONLY THIS BIT</title> of the
> string";

> I have tried strpos, str_replace and other string manipulation things but I
> cant get my head around how to achieve showing the text with the
> <title></title> tags of the string.

> Any help is appreciated and I thank you in advance for any help given.

> Thank you

> Dave Carrera

--- End Message ---
--- Begin Message --- Dave Carrera wrote:

$string = "This is a test string to <title>SHOW ONLY THIS BIT</title> of the
string";

I have tried strpos, str_replace and other string manipulation things but I
cant get my head around how to achieve showing the text with the
<title></title> tags of the string.

Any help is appreciated and I thank you in advance for any help given.

$b = strpos($str,'<title>')+7; $l = strpos($str,'</title>') - $b; $m = substr($str,$b,$l);

Sure, you can use regular expressions, but there's not really a need unless this gets more complex. Even though you're executing more code with this solution, it'll be faster than preg_match() (go ahead and benchmark it).

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Thanks John,

Works a treat.

Thank You

Dave Carrera


-----Original Message-----
From: John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: 07 May 2004 12:32
To: Dave Carrera
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Showing only part of string


Dave Carrera wrote:

> $string = "This is a test string to <title>SHOW ONLY THIS BIT</title> 
> of the string";
> 
> I have tried strpos, str_replace and other string manipulation things 
> but I cant get my head around how to achieve showing the text with the 
> <title></title> tags of the string.
> 
> Any help is appreciated and I thank you in advance for any help given.

     $b = strpos($str,'<title>')+7;
     $l = strpos($str,'</title>') - $b;
     $m = substr($str,$b,$l);

Sure, you can use regular expressions, but there's not really a need 
unless this gets more complex. Even though you're executing more code 
with this solution, it'll be faster than preg_match() (go ahead and 
benchmark it).

-- 
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com




---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.677 / Virus Database: 439 - Release Date: 04/05/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.677 / Virus Database: 439 - Release Date: 04/05/2004
 

--- End Message ---
--- Begin Message --- Hi all,

I'm on a shared server, and I do not believe that I have access to the /tmp directory where the session files are stored (I believe that is how it works :). I want to keep track of which sessions are active. Basically, I just want a list of the active sessions for my site.

How can I do this?

Thanks!

_________________________________________________________________
Watch LIVE baseball games on your computer with MLB.TV, included with MSN Premium! http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/direct/01/

--- End Message ---
--- Begin Message ---
> I'm on a shared server, and I do not believe that I have access to the
/tmp
> directory where the session files are stored (I believe that is how it
works
> :).  I want to keep track of which sessions are active.  Basically, I just
> want a list of the active sessions for my site.
>
> How can I do this?

Hi
Are we talking about smb shares for linux.
If so, why dont you just ask your admin to create a share to "/tmp"

or create via php a web page that looks at /tmp and displayes the file.
Remember, there are many ways to skin  a cat.

>Copied and pasted from za.php.net<
<?php
$dir = "/tmp/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
       while (($file = readdir($dh)) !== false) {
           echo "filename: $file : filetype: " . filetype($dir . $file) .
"\n";
       }
       closedir($dh);
   }
}
?>

Kind Regards
Brent Clark

--- End Message ---
--- Begin Message ---
On Friday 07 May 2004 20:32, Paul Higgins wrote:

> I'm on a shared server, and I do not believe that I have access to the /tmp
> directory where the session files are stored (I believe that is how it
> works
>
> :). 

Of course you have access to it. The webserver needs to be able to READ the 
session files that it writes and hence you're also able to access those files 
with PHP.

> I want to keep track of which sessions are active.  Basically, I just
>
> want a list of the active sessions for my site.

You would have to define what /you/ mean by an active session.

> How can I do this?

i) There is no way to determine which session files are for your site without 
actually examining their contents. 

ii) PHP does not store any site identification info in the session files.

iii) Hence you need to store a (hopefully) unique string in all your sessions 
then search for this string in the session files.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Phasers locked on target, Captain.
*/

--- End Message ---
--- Begin Message ---
From: "Jason Wong" <[EMAIL PROTECTED]>

> i) There is no way to determine which session files are for your site
without
> actually examining their contents.
>
> ii) PHP does not store any site identification info in the session files.
>
> iii) Hence you need to store a (hopefully) unique string in all your
sessions
> then search for this string in the session files.

You have the option of using session_save_path() and using a directory of
your own to store the session files. Then the "active" session count is just
a count of how many files exist in that directory. You have to implement
your own garbage cleanup of the session files, though.

---John Holmes...

--- End Message ---
--- Begin Message ---
"Paul Higgins" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all,
>
> I'm on a shared server, and I do not believe that I have access to the
/tmp
> directory where the session files are stored (I believe that is how it
works
> :).  I want to keep track of which sessions are active.  Basically, I just
> want a list of the active sessions for my site.
>
> How can I do this?

If you use a database as container for your session data you could easily do
a SELECT COUNT(*) FROM sessions to get the number of the sessions. Using a
DB as session container is also more secure on a shared server (at least
that's what I often read about session security).

Regards, Torsten

>
> Thanks!
>
> _________________________________________________________________
> Watch LIVE baseball games on your computer with MLB.TV, included with MSN
> Premium!
>
http://join.msn.com/?page=features/mlb&pgmarket=en-us/go/onm00200439ave/dire
ct/01/

--- End Message ---

Reply via email to