OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 2 Feb 2005 22:50:39 -0000 Issue 3264

php-general-digest-helplists.php.net
Date: Wed Feb 02 2005 - 16:50:39 CST


php-general Digest 2 Feb 2005 22:50:39 -0000 Issue 3264

Topics (messages 207882 through 207941):

Re: cal_days_in_month() missing, how can I tell if it exists
        207882 by: Ben Edwards

Multiline data Insert Into table from a generated form?
        207883 by: Alp
        207884 by: Mike Smith
        207909 by: Alp

Re: Credit card storing, for processing
        207885 by: Robin Vickery
        207918 by: Richard Lynch
        207932 by: Brandon Thompson
        207933 by: Brian Dunning
        207934 by: Brian Dunning
        207935 by: Jason Barnett
        207938 by: Brian Dunning

Re: how create system users with php
        207886 by: M. Sokolewicz
        207893 by: Marek Kilimajer
        207912 by: Richard Lynch

Re: Getting two queries into one result set
        207887 by: Shaun
        207888 by: Jay Blanchard
        207889 by: Marek Kilimajer
        207890 by: Graham Cossey
        207892 by: Tom

Re: PHP Memory limit exceeded
        207891 by: Marek Kilimajer
        207914 by: Richard Lynch

stripos kills my script but strpos is fine?
        207894 by: Michael
        207907 by: Richard Lynch
        207924 by: Michael

Re: Escaped characters
        207895 by: Brian Dunning

Fighting user's cache with an updated image
        207896 by: Dave
        207897 by: Chris Ramsay

DomElement oddness
        207898 by: Chris Boget
        207900 by: Chris Boget

Link to content of Directory
        207899 by: Marquez Design: Steve Marquez
        207901 by: Steve Buehler

What's wrong with this rewrite rule?
        207902 by: Chris W. Parker
        207910 by: M. Sokolewicz
        207917 by: Chris W. Parker
        207927 by: Michael
        207928 by: Chris W. Parker
        207930 by: phpnews.mas.ml1.net

Prepend policy
        207903 by: Sdäv
        207905 by: Richard Lynch
        207919 by: John Nichel

Re: Question
        207904 by: a_pyramidin.yahoo.com

Re: regular expresion
        207906 by: Stian Berger
        207915 by: Richard Lynch

Need help with ereg regular expression
        207908 by: KHS
        207913 by: John Nichel
        207921 by: Mikey
        207922 by: Richard Lynch
        207925 by: KHS
        207929 by: Richard Lynch
        207941 by: Jason Wong

Is it possible compile a php script to native binary like perlcc ?
        207911 by: Unreal HSHH
        207916 by: Jay Blanchard
        207920 by: John Nichel
        207923 by: Richard Lynch

imap_mail_compose function in PHP5
        207926 by: Bronislav Klucka

Using SSL with PHP5's socket_* functions
        207931 by: dan

PEAR::SOAP returns objects instead of associative arrays
        207936 by: William Lovaton
        207940 by: William Lovaton

Re: How to make binary strings useful?
        207937 by: Jerry Miller
        207939 by: Jerry Miller

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


On Tue, 1 Feb 2005 18:57:12 -0600, James Kaufman
<jmkkaufman.eden-prairie.mn.us> wrote:
> On Tue, Feb 01, 2005 at 08:47:29PM +0000, Ben Edwards wrote:
> > I have been implementing a system on a different ISP than I normally use
> > and have got:-
> >
> > Fatal error: Call to undefined function: cal_days_in_month()
> > in /home/hosted/www.menublackboard.com/public_html/dev/classes/validator.class.php
> > on line 134
> >
> > I found a reference to this an the web and it seems PHP is not compiled
> > with calender support.
> >
> > "recompile php with the "--enable-calendar" option."
> >
> > Cant see being able to get the to re-compile PHP so I guess I am going
> > to have to disable the feature. I seem to remember a while ago seeing a
> > function to test weather a function exists in PHP. That way I can have
> > the relevant validation skipped if the function is missing (I will tell
> > the client if they get decent hosting it will start working).
> >
> > So something like
> >
> > function_exists( cal_days_in_month() )
> >
> > Anyone know what the function is called.
> >
> > Ben
> >
>
> I do this:
>
> if (!extension_loaded('calendar'))
> {
> /*
> * cal_days_in_month($month, $year)
> * Returns the number of days in a given month and year,
> * taking into account leap years.
> *
> * $month: numeric month (integers 1-12)
> * $year: numeric year (any integer)
> *
> * Prec: $month is an integer between 1 and 12, inclusive
> * $year is an integer.
> * Post: none
> */
> function cal_days_in_month($month, $year)
> {
> return $month == 2 ? $year % 4 ? 28 : 29 : ($month % 7 % 2 ? 31 : 30);
> }
> }

thanks, I was using

$days_in_month = cal_days_in_month( CAL_GREGORIAN, $month, $year );

Is the first parameter optionel. If it is I guess PHP must have
overloaded internal functions.

Ben

> --
> Jim Kaufman
> Linux Evangelist
> public key 0x6D802619, CISSP# 65668
> http://www.linuxforbusiness.net
> ---
> The shortest distance between two points is through Hell.
> --Brian Clark
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Ben Edwards - Poole, UK, England
WARNING:This email contained partisan views - dont ever accuse me of
using the veneer of objectivity
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

attached mail follows:


Hi experts,

I'd like your advice on the following as to how to approach/resolve. I'm
generating a form based on a user input number, say 3, where 3 lines for
input for a few fields are created. What would be the appropriate way to
append these 3 seperate lines into the table all at one go? I have tried to
name the input fields per its corresponding line number (not sure yet if it
properly is working though).

I have given the code for the form below. I tried to use a similar approach
for the $sql (whit while) but apparently either the form or the sql is
failing.

Any help, pointers, advice would be highly appreciated. Thanks in advance.

Alp

Code:
 print '<table width="545" border="0" cellspacing="0" cellpadding="0"
align="center"><tr>';
 print '<form action="test1.php" method="POST">';
 $i = 1;
 while ($i <= $tour_days) {
  print '<input type="hidden" name="tourdays" value="'.$tour_days.'">';
  print '<input type="hidden" name="tourid'.$i.'" value="'.$tour_id.'">';
  $days = ("Day&nbsp;0".$i);
  print $days;
  print '<input type="hidden" name="dayno'.$i.'" value="'.$days.'">';
  print '</td>';
  print '<input type="text" name="fromto'.$i.'" size="50"></td>';
  print '<input type="text" name="bld'.$i.'" size="10"></td></tr>';
  print '<tr><td colspan="3">';
  print '<textarea name="descrip'.$i.'" rows="5" cols="80"
wrap="virtual"></textarea></td></tr>';
  $i++;
  }
 print '</table>';
 print "<input type=\"submit\" value=\"submit!\">\n</form>\n";

attached mail follows:


> Code:
> print '<table width="545" border="0" cellspacing="0" cellpadding="0"
> align="center"><tr>';
> print '<form action="test1.php" method="POST">';
> $i = 1;
> while ($i <= $tour_days) {
> print '<input type="hidden" name="tourdays" value="'.$tour_days.'">';
> print '<input type="hidden" name="tourid'.$i.'" value="'.$tour_id.'">';
> $days = ("Day&nbsp;0".$i);
> print $days;
> print '<input type="hidden" name="dayno'.$i.'" value="'.$days.'">';
> print '</td>';
> print '<input type="text" name="fromto'.$i.'" size="50"></td>';
> print '<input type="text" name="bld'.$i.'" size="10"></td></tr>';
> print '<tr><td colspan="3">';
> print '<textarea name="descrip'.$i.'" rows="5" cols="80"
> wrap="virtual"></textarea></td></tr>';
> $i++;
> }
> print '</table>';
> print "<input type=\"submit\" value=\"submit!\">\n</form>\n";

Change the field names to arrays (i.e. "tourid".$i becomes tourid[]

When you POST loop through the array:

while($c=0;$c<count($_POST['tourid']):$c++){
    If($_POST['tourid'][$c]!=""...){
        $sql = "INSERT INTO reservations ('tourid'...) VALUES
('{$_POST['tourid'][$c]}'...)\n";
    }
}

attached mail follows:


Thank you Mike for your quick reply. I will try to incorporate it into the
function I'm using and let you know the result. The function code is also
given below.

Alp

function add_to_database( $tourid, $dayno, $fromto, $bld, $descrip,
&$dberror)
 {
 //user connection section--begin
 $username="root";
 $password="";
 $database="nazardane";
 $link = mysql_pconnect("localhost", $username, $password);
 if ( ! $link )
  {
  $dberror = "Couldn't connect to MySQL server";
  return false;
  }
 if ( ! mysql_select_db( $database, $link))
  {
  $dberror = mysql_error();
  return false;
  }
  $sql = "INSERT INTO tour_details ( tour_id, dayno, fromto, bld, descrip )
VALUES ( '$tourid', '$dayno', '$fromto', '$bld', '$descrip' ) )";
  if (! mysql_query($sql, $link))
   {
   $dberror = mysql_error();
   return false;
   }

 return true;
 }

"Mike Smith" <mikeosmithgmail.com> wrote in message
news:d46325db050202033225f24987mail.gmail.com...
> > Code:
> > print '<table width="545" border="0" cellspacing="0" cellpadding="0"
> > align="center"><tr>';
> > print '<form action="test1.php" method="POST">';
> > $i = 1;
> > while ($i <= $tour_days) {
> > print '<input type="hidden" name="tourdays" value="'.$tour_days.'">';
> > print '<input type="hidden" name="tourid'.$i.'"
value="'.$tour_id.'">';
> > $days = ("Day&nbsp;0".$i);
> > print $days;
> > print '<input type="hidden" name="dayno'.$i.'" value="'.$days.'">';
> > print '</td>';
> > print '<input type="text" name="fromto'.$i.'" size="50"></td>';
> > print '<input type="text" name="bld'.$i.'" size="10"></td></tr>';
> > print '<tr><td colspan="3">';
> > print '<textarea name="descrip'.$i.'" rows="5" cols="80"
> > wrap="virtual"></textarea></td></tr>';
> > $i++;
> > }
> > print '</table>';
> > print "<input type=\"submit\" value=\"submit!\">\n</form>\n";
>
> Change the field names to arrays (i.e. "tourid".$i becomes tourid[]
>
> When you POST loop through the array:
>
> while($c=0;$c<count($_POST['tourid']):$c++){
> If($_POST['tourid'][$c]!=""...){
> $sql = "INSERT INTO reservations ('tourid'...) VALUES
> ('{$_POST['tourid'][$c]}'...)\n";
> }
> }

attached mail follows:


On Wed, 02 Feb 2005 01:24:18 -0500, Angelo Zanetti <binc2cput.ac.za> wrote:
>
> Does this setup sound secure enough and a solution that can work?
> What kind of encryption should I be using?
>
> Point out any areas where you think I might be missing something or
> going wrong.

Take Richard's advice and don't do it - Any decent Merchant Service
Provider should give you a method of placing recurring charges, which
would take most of the responsibility and liability out of your hands.

If you're even thinking of storing credit card numbers you should have
already read and be familiar with the PCI Data Security Standard.

   http://www.visaeurope.com/acceptingvisa/pdf/PCI_Data_Security_Standard_1_0.pdf

You'll have added up the costs of not only building all that, but also
the costs of maintaining it, the continuous monitoring, the (at least)
quarterly vulnerability scans, incidence response plans etc.

You should also know the risks of not following the cards security
policies; last time I looked, Visa's compliance penalties were $50,000
for a first offence and $100,000 for subsequent offences, plus the
risk of being permanently barred from holding a merchant account.

You must also have considered what effect it would have on your
business if you have to inform all your customers that their credit
card details have been compromised.

Storing card details is a high cost, high risk solution. Unless you've
a *really* good business reason for doing so that you've not
mentioned, it's not a good idea.

  -robin

attached mail follows:


Angelo Zanetti wrote:
> thanks for the info. With regard to the setup it will be something more
> or less like this:

DON'T DO IT!!!

> I want to generate my own keypair. The private key I keep secure,
> offline,
> on the machine that does the admin (charging, refunds etc). The public
>
> key is used on the server to encrypt card details the minute they
> arrive
> on the server (even using SSL, the data will arrive unencrypted
> because the web server decrypts it).
>
> Encrypted card details are written to file, and moved off the server
> overnight by a cron job.
>
> On the admin machine, offline, the details get decrypted when needed
> to perform transactions, using the private key.

Who has access to the private key?

Under what circumstances?

How are you going to STOP a determined individual from compromising the
access to the private key?

Do you have $50,000 in escrow for *WHEN* (not if, *WHEN*) that key is
compromised?

Are you prepared to put another $100,000 in escrow *after* that time for
the next time it *WILL* happen?

Are you prepared to contact EVERY credit card customer and tell them their
credit card security was compromised?

> The admin box is on ADSL, but behind a firewall with no services or
> ports
> open to the internet. I.e it can initiate a connection to the server
> on
> the internet, but not the other way around.
>
> Does this setup sound secure enough and a solution that can work?

NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!

Who has physical access to the admin box?

How is it locked down?

When will the audits be conducted?

By whom?

You're missing about a ZILLION things here...

> What kind of encryption should I be using?

If you have to ask, you shouldn't be doing this:

"Hi, I'm about to perform brain surgery. Which scalpel should I use?"

You are NOT ready to implement the system you have envisioned.

Let the credit card companies take the risk. They've got the resources
for it. That's why things are the way they are.

I *almost* did the same kind of thing you are about to do. Thank [deity]
I came to my senses first.

I cannot stress this enough.

DON'T DO IT!

Sorry, dude. It's just *NOT* a Good Idea. Deal with it. :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Wow....I was hoping someone would respond with a little balance to that
reactionary doomsday speech. Don't get me wrong...those are some very valid
points that need to be considered, but my gosh...

The key-pair idea is very good. I've done systems in the past for clients
that work in a similar fashion.

There are multiple layers of security with two main aspects:
1. The technical implemenation and complexity of the system
2. The responsibility/priveledges granted to users/admins

You can come up with the most complex, technical "secret key" solution
around (aspect #1)....but if you entrust that secret key to the wrong person
(aspect #2), it's all for nothing.

In the end...it's about common sense. It's FAR less dangerous to implement
what you are suggesting than it is to simply pay for your dinner with a
credit card.

One thing I agree with Richard wholeheartedly on is his "Hi, I'm about to
perform brain surgery. Which scalpel should I use?" anology. If the
technicaly aspects of implementing a system like this escape you...then
please learn how to do it in theory first. Don't "learn on the job" with
something as precious as your credit rating.

Hope this helps

Brandon

> -----Original Message-----
> From: Richard Lynch [mailto:ceol-i-e.com]
> Sent: Wednesday, February 02, 2005 1:34 PM
> To: Angelo Zanetti
> Cc: php-generallists.php.net
> Subject: Re: [PHP] Credit card storing, for processing
>
> Angelo Zanetti wrote:
> > thanks for the info. With regard to the setup it will be something
> > more or less like this:
>
> DON'T DO IT!!!
>
> > I want to generate my own keypair. The private key I keep secure,
> > offline, on the machine that does the admin (charging,
> refunds etc).
> > The public
> >
> > key is used on the server to encrypt card details the minute they
> > arrive on the server (even using SSL, the data will arrive
> unencrypted
> > because the web server decrypts it).
> >
> > Encrypted card details are written to file, and moved off
> the server
> > overnight by a cron job.
> >
> > On the admin machine, offline, the details get decrypted
> when needed
> > to perform transactions, using the private key.
>
> Who has access to the private key?
>
> Under what circumstances?
>
> How are you going to STOP a determined individual from
> compromising the access to the private key?
>
> Do you have $50,000 in escrow for *WHEN* (not if, *WHEN*)
> that key is compromised?
>
> Are you prepared to put another $100,000 in escrow *after*
> that time for the next time it *WILL* happen?
>
> Are you prepared to contact EVERY credit card customer and
> tell them their credit card security was compromised?
>
> > The admin box is on ADSL, but behind a firewall with no services or
> > ports open to the internet. I.e it can initiate a
> connection to the
> > server on the internet, but not the other way around.
> >
> > Does this setup sound secure enough and a solution that can work?
>
> NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!
>
> Who has physical access to the admin box?
>
> How is it locked down?
>
> When will the audits be conducted?
>
> By whom?
>
> You're missing about a ZILLION things here...
>
> > What kind of encryption should I be using?
>
> If you have to ask, you shouldn't be doing this:
>
> "Hi, I'm about to perform brain surgery. Which scalpel should I use?"
>
> You are NOT ready to implement the system you have envisioned.
>
> Let the credit card companies take the risk. They've got the
> resources for it. That's why things are the way they are.
>
> I *almost* did the same kind of thing you are about to do.
> Thank [deity] I came to my senses first.
>
> I cannot stress this enough.
>
> DON'T DO IT!
>
> Sorry, dude. It's just *NOT* a Good Idea. Deal with it. :-)
>
> --
> Like Music?
> http://l-i-e.com/artists.htm
>
> --
> PHP General Mailing List (http://www.php.net/) To
> unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


> The SIMPLEST way to do this is to charge their credit card with a
> recurring charge when they sign up, and then just THROW AWAY their
> credit
> card number.
> Your credit card processing vendor then has to remember their credit
> card
> number, not you.

I agree. This is the way I've worked for years, and it has always
worked perfectly. Not once have I ever had all 16 digits of a
customer's credit card. I can't even get it from my provider (first 4
and last 4 only).

Authorize when they order, store the transaction ID, settle the
transaction by ID later in the future if the order goes through.

attached mail follows:


> It's FAR less dangerous to implement
> what you are suggesting than it is to simply pay for your dinner with a
> credit card.

I agree with this. There is way too much paranoia about credit cards
online. 99% of stolen credit card numbers are acquired by phishing and
the other 1% by uncrumpling receipts out of a wastebasket. There's no
longer any reason to go to the trouble of trying to crack encryption.
Remember the knight who went into battle wearing armor only on his
legs?

attached mail follows:


Brian Dunning wrote:
>> It's FAR less dangerous to implement
>> what you are suggesting than it is to simply pay for your dinner with a
>> credit card.
>
>
> I agree with this. There is way too much paranoia about credit cards
> online. 99% of stolen credit card numbers are acquired by phishing and

It depends on the exact situation, but a lot of times the vendors that
process a fraudulent credit card purchase end up eating that loss. At
that point their only recourse is to go after the person that
perpetrated the fraud. In the case of phishing it is whomever harvested
the cc#. However, in the case of getting cc#'s from your website it is
both the person that cracked your site *as well as you*.

> the other 1% by uncrumpling receipts out of a wastebasket. There's no
> longer any reason to go to the trouble of trying to crack encryption.
> Remember the knight who went into battle wearing armor only on his legs?

I suppose that if you want to disregard the risk as minimal, well,
that's your business. However, even if you believe that the risk of
someone stealing your customer's credit card numbers from your server is
minimal you still *must* consider the potential cost of being
compromised. My financial colleagues would state this as:

expected cost = probability * (drop in future sales revenue + attorney
litigation fees + damages awarded in lawsuit)

Perhaps it's not clear, but litigation might include lawsuits from the
credit card company... or the hundreds of *other* companies that get
screwed by the fraudulent credit card purchases. Even if you manage to
win all of those lawsuits, the litigation fees alone are likely enough
to bankrupt you.

So even if you only think the probability of being compromised is 1 /
1000... do the math... is it really worth it for you to do this?

--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

attached mail follows:


> It depends on the exact situation, but a lot of times the vendors that
> process a fraudulent credit card purchase end up eating that loss.

I can testify to this by experience. I ate $10,000 on one run of
phished transactions.

>> the other 1% by uncrumpling receipts out of a wastebasket. There's no
>> longer any reason to go to the trouble of trying to crack encryption.
>> Remember the knight who went into battle wearing armor only on his
>> legs?
>
> I suppose that if you want to disregard the risk as minimal,

Did I say that, or are you being argumentative? Let's keep the thread
useful to the original poster.

attached mail follows:


shell_exec('pw useradd username -g groupname -d /home/username -m');
however, you'd need to be running as root, or atleast need to su to
root; which is quite a security hazard

Umar Draz wrote:
> Hi dear members!!
>
> i want a script that i can add system user through
> php. For example i
> have FreeBSD 5.3 for adding a user in freebsd i use
> this command
>
> pw useradd username -g groupname -d /home/username -m
>
> now i want creating user through php what kind of
> script will be
> required
>
> thanks and regards
>
> Umar Draz
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Easier than ever with enhanced search. Learn more.
> http://info.mail.yahoo.com/mail_250

attached mail follows:


M. Sokolewicz wrote:
> shell_exec('pw useradd username -g groupname -d /home/username -m');
> however, you'd need to be running as root, or atleast need to su to
> root; which is quite a security hazard

I recomend sudo. You can set strict restrictions on the executed
commands and its arguments.

>
> Umar Draz wrote:
>
>> Hi dear members!!
>>
>> i want a script that i can add system user through
>> php. For example i have FreeBSD 5.3 for adding a user in freebsd i use
>> this command
>>
>> pw useradd username -g groupname -d /home/username -m
>>
>> now i want creating user through php what kind of
>> script will be required
>>
>> thanks and regards
>>
>> Umar Draz

attached mail follows:


Umar Draz wrote:
> i want a script that i can add system user through
> php. For example i
> have FreeBSD 5.3 for adding a user in freebsd i use
> this command
>
> pw useradd username -g groupname -d /home/username -m
>
> now i want creating user through php what kind of
> script will be
> required

You *do* understand that this opens up a giant hole in your armour against
bad people, right?

And that you've got to be VERY careful about who can access this script,
and how they access it, and what it can do, right?

First, if this is a shared server, then you REALLY shouldn't do this,
because then *ANY* user can write a PHP script to create a new
username/password. Bad Idea.

You'll first need to test a 'sudo' script that allows the PHP user to
execute that command.

You'll want that script executable *ONLY* by the PHP user, not the whole
world.

Some things to consider:

Make it a two-stage process, where a script just puts the names and
encrypted passwords in a database.

Then, a human reviews the list of new users to make sure they all match up
with, say, paid accounts, and approves the list.

Then, you have to find a way to insert the user with encrypted pass to
your system instead of havine the system re-encrypt the encrypted
password.

But that's safer than just blindly adding users because somebody managed
to run a PHP script. [shudder]

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hi guys,

Thanks for your replies but neither UNION or REGEXP can be used with SHOW
TABLES...

Any ideas?

"Jochem Maas" <jochemiamjochem.com> wrote in message
news:41F77BC0.1040701iamjochem.com...
> Marek Kilimajer wrote:
>> Shaun wrote:
>>
>>> Hi,
>>>
>>> I have a query where I select all table names where the table name has
>>> PID_1 in i.e.
>>>
>>> SHOW TABLES LIKE '%PID_1%';
>>>
>>> However there may be cases where I need to search for tables where the
>>> table name is PID_1 or PID_2. In MySQL this can't be done in one query,
>>> so how can I do two queries and combine the result set so I can loop
>>> through it?
>>>
>>> Thanks for your help
>>
>>
>> SHOW TABLES REGEXP 'PID_[0-9]+';
>>
>
> nice! :-)

attached mail follows:


[snip]
Thanks for your replies but neither UNION or REGEXP can be used with
SHOW
TABLES...
[/snip]

SHOW TABLES is such a limited query and allows for such primitive
conditionals that you would probably have better results doing two
queries and looping them into the same output

attached mail follows:


Shaun wrote:
> Hi guys,
>
> Thanks for your replies but neither UNION or REGEXP can be used with SHOW
> TABLES...
>
> Any ideas?

It's time to change your table design. Use one pid table and add another
column that would hold the number.

attached mail follows:


You don't say how many tables you have, how they are named or anything
outside of the query itself.

Assuming that not all your tables are named PID_* how about simply doing

SHOW TABLES LIKE '%PID_%'

and selecting appropriate results within the php script using strstr
or regular expressions? SHOW TABLES is (normally) such a quick query
returning a larger result set shouldn't be too much of a problem,
should it?

HTH

Graham

On Wed, 02 Feb 2005 15:15:38 +0100, Marek Kilimajer <listskilimajer.net> wrote:
> Shaun wrote:
> > Hi guys,
> >
> > Thanks for your replies but neither UNION or REGEXP can be used with SHOW
> > TABLES...
> >
> > Any ideas?
>
> It's time to change your table design. Use one pid table and add another
> column that would hold the number.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
Graham

attached mail follows:


Graham Cossey wrote:

>You don't say how many tables you have, how they are named or anything
>outside of the query itself.
>
>Assuming that not all your tables are named PID_* how about simply doing
>
>SHOW TABLES LIKE '%PID_%'
>
>and selecting appropriate results within the php script using strstr
>or regular expressions? SHOW TABLES is (normally) such a quick query
>returning a larger result set shouldn't be too much of a problem,
>should it?
>
>
>
If it is, then you should rework your db to reduce the number of tables :)
Alternatively use multi-query with use_result and more_results.
If it's concise code that you are after, then set up all the search
strings in an array, and pass this through a loop that performs each
query at a time and cats the results into a new array.

>HTH
>
>Graham
>
>On Wed, 02 Feb 2005 15:15:38 +0100, Marek Kilimajer <listskilimajer.net> wrote:
>
>
>>Shaun wrote:
>>
>>
>>>Hi guys,
>>>
>>>Thanks for your replies but neither UNION or REGEXP can be used with SHOW
>>>TABLES...
>>>
>>>Any ideas?
>>>
>>>
>>It's time to change your table design. Use one pid table and add another
>>column that would hold the number.
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>
>
>
>

attached mail follows:


Ben-Nes Yonatan wrote:
> Hi all,
>
> I got a problem with uploading files which encounter the memory limit
> when their size is not even close to the memory limit itself, let me
> explain.
>
> My server is as follows:
> 1. PHP 4.3.9
> 2. DB - Postgresql 7.4
> 3. Apache 1.3.26
>
> Here is my code that i made for testing the problem (along the code i
> echoed the function memory_get_usage() to know how much memory was
> allocated already for the script):
>
> $imagefile = $_FILES['imagefile']; // recieve the file
> echo memory_get_usage().'<br />'; // 118592 memory bytes allocated
> $data = pg_escape_bytea(`cat $imagefile[tmp_name]`);
> echo memory_get_usage().'<br />'; // 5570280 memory bytes allocated
>
> $data = "INSERT INTO test_files (bin_data, filename, filesize, filetype)
> VALUES ('$data', '$imagefile[name]', '$imagefile[size]',
> '$imagefile[type]')"; // creating the sql for the insert, i called the
> received value also $data cause i dont want to keep the previous $data
> (after all we want to save our precious memory no? :))
> echo memory_get_usage().'<br />'; // 5570400 memory bytes allocated
> {changed from b4 only alittle}
>
> if ( !$res = pg_query ($this->conn, $data) ) // try to insert the sql
> string
> return 'error';
> else
> return 'gr8';
> echo memory_get_usage().'<br />'; // 5570648 memory bytes allocated
> {again changed only alittle}
>
>
> Now as far as i see the script needed about 5.5MB of memory to upload a
> file of 4.7MB but thats what so weird here... i receive the memory limit
> error even if the php.ini "memory_limit" is set to 16MB! {twice of the
> default of 8MB!} at 32MB it works fine... but thats way too much..
> I suspect that the problem is connected to the pg_query function itself
> but i didnt find what made it exactly...

Do you suspect or that's where the script output ends?

Even between 2nd and 3rd memory_get_usage() call your script's memory
usage increased rapidly - first the sql query was created, then it was
assigned to $data. So for a moment the file was in memory twice.

Something similar is with pg_query() - the file was at a moment in $data
string, then it is copied somewhere in the php_pg module and the memory
usage tripples.

As a solution you might want to implement (or look for implementation
of) mysql's load_file() function.

attached mail follows:


Ben-Nes Yonatan wrote:
> $data = "INSERT INTO test_files (bin_data, filename, filesize, filetype)
> VALUES ('$data', '$imagefile[name]', '$imagefile[size]',
> '$imagefile[type]')"; // creating the sql for the insert, i called the
> received value also $data cause i dont want to keep the previous $data
> (after all we want to save our precious memory no? :))
> echo memory_get_usage().'<br />'; // 5570400 memory bytes allocated
> {changed from b4 only alittle}

As noted, *DURING* the execution of this assignment statment, PHP has to
store $data in 2 places.

On a completely un-related topic, you should research the pros and cons of
storing image data directly in your database, if you haven't already.

MOST experts will tell you "don't do that" unless you have a very specific
performance maintenance requirement for it.

There is a highly-tuned long-established custom database engine
specifically geared for storing/maintaining/retrieve large binary data
like your images...

It's call "The File System" :-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


I'm trying to use stripos as a faster and less resource-intensive
alternative to preg_match with the i flag, but I'm getting some strange
behavior.

Here's a test script that demonstrates the problem:
---
<?php
$days = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
foreach ($days as $d) {
     echo "Checking day: $d";
     if (stripos($d, 'T') === 0) {
         echo "Day is Tuesday or Thursday";
     } else {
         echo "Day is MWFSS";
     }
}
?>
---
When I run this as-is, it prints "Checking day: Mon" and stops. When I
change stripos to strpos, it runs all the way through doing what it's
supposed to. It's as if stripos calls 'die' somehow and strpos doesn't.

AFAIK, stripos should behave exactly like strpos except
case-insensitively. So in the function above, it should make absolutely
no difference which one I use.

Any thoughts?

Thanks!

PS: Ignore the fact I'm using days above, what I'm really doing has
nothing to do with date handling. That was just a convenient example to
demonstrate the problem.

attached mail follows:


Michael wrote:
> I'm trying to use stripos as a faster and less resource-intensive
> alternative to preg_match with the i flag, but I'm getting some strange
> behavior.
>
> Here's a test script that demonstrates the problem:
> ---
> <?php
> $days = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
> foreach ($days as $d) {
> echo "Checking day: $d";
> if (stripos($d, 'T') === 0) {
> echo "Day is Tuesday or Thursday";
> } else {
> echo "Day is MWFSS";
> }
> }
> ?>
> ---
> When I run this as-is, it prints "Checking day: Mon" and stops. When I
> change stripos to strpos, it runs all the way through doing what it's
> supposed to. It's as if stripos calls 'die' somehow and strpos doesn't.
>
> AFAIK, stripos should behave exactly like strpos except
> case-insensitively. So in the function above, it should make absolutely
> no difference which one I use.

stripos only exists in PHP 5.

You are probably running PHP 4.

You also are hiding/re-directing your error messages somewhere, and have
not gotten into the habit (yet) of reading the error log.

You'll need to read php.ini to be certain, and I can't REALLY be sure
where your error_log is on your server, but if you are completely confused
by what I've typed, try this:

tail -f /usr/local/apache/logs/error_log

Dollars to donuts says you'll find something about stripos not being
defined, once you find the error output.

For penance, you will practice starting your work-day with:
"tail -f /path/to/your/log"
several times right now, and be sure you start your work-day that way for
the rest of the week
:-)

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Richard Lynch wrote:
> Michael wrote:
>
>>I'm trying to use stripos as a faster and less resource-intensive
>>alternative to preg_match with the i flag, but I'm getting some strange
>>behavior.

<snip problem description>

>>AFAIK, stripos should behave exactly like strpos except
>>case-insensitively. So in the function above, it should make absolutely
>>no difference which one I use.
>
> stripos only exists in PHP 5.

Aha. Must have missed that in the docs.

> You are probably running PHP 4.

Yes, indeed I am. That would be the problem then.

> You also are hiding/re-directing your error messages somewhere, and have
> not gotten into the habit (yet) of reading the error log.

On this point, however, you're mistaken (not your fault, of course... :)
). I was watching tail -f php_error_log as I was diagnosing the problem.
I've written a custom error handler, however, which may not be handling
PHP-generated errors correctly (although it does deal with syntax
errors, for instance). So I'm not sure what the issue is there. But
that's less important.

Thanks very much for your help!

Mike

attached mail follows:


Thanks! :)

attached mail follows:


PHP General,

    The Situation:
    I have a form on my web page which uses PHP to upload an image into
a user's directory. Because I use the uploaded image in a variety of
places in my web site, my script renames the file to conform to naming
conventions I use on the site.
    Users can keep one image, and they can over write it. Just below the
form, it shows their current image. If they upload a new image, it
should display the new version.

    The Problem:
    Even though the file uploads correctly, and it is immediately
available, I noticed that sometimes on my own computer the image
displayed on the page with the upload form would not update. After much
experimentation, I am reasonably sure that this is because the browser's
cache is storing the image and loads the cached version and not the new
version.
    If I clear out the cache after the upload, the newly uploaded image
displays. This is not confusing for me, but of course the web site users
are bound to find this troublesome.

    What I've Tried So Far:
    I've considered different naming conventions for files, so that the
uploaded file would have a different name, which would get around the
cache issue. But because of the existing web site structure which makes
extensive use of the file naming convention already in place, it is a
very daunting option.
    Along the same lines, I considered making a temporary naming
convention for that one page, but this tested the limits of my PHP
scripting abilities. I can't claim any more skill than a newbie when it
comes to PHP.

    The Question:
    Is there a way I can trick the browser into getting the image file
off the server every time and not from the cache, so that it will be
clear to user's that they have successfully uploaded their image?

    Any help much appreciated.

--
Dave Gutteridge
davetokyocomedy.com

attached mail follows:


Check out:

http://uk2.php.net/manual/en/function.header.php

Where you will find:

<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");
?>

Read the documentation - it may be just what you need for this problem...

Chris Ramsay
Web Developer - The Danwood Group Ltd.
Tel #: +44 (0)1522 882 288
DDI #: +44 (0)1522 834 482
Fax #: +44 (0)1522 884 488
Email: chris.ramsaydanwood.co.uk
Web : http://www.danwood.co.uk

attached mail follows:


Consider the following:

This function
---------------------------------------------
function setAttribute( $nodeName, $attributeName, $attributeValue ) {
  $domElement = $this->DOMDocument->get_elements_by_tagname( $nodeName );

  if( $domElement ) {
    echo 'ObjectData: <pre>' . print_r( $domElement, TRUE ) . '</pre>';
    if( method_exists( $domElement, 'set_attribute' )) {
      $domElement->set_attribute( $attributeName, $attributeValue );

    } else {
      echo 'Method "set_attribute" does not exist...<br>';
      echo 'Methods are: <pre>' . print_r( get_class_methods(
'domelement' ), TRUE ) . '</pre>';

    }
  }
} // end function setAttribute()

---------------------------------------------

Outputs this information
---------------------------------------------
ObjectData:
Array
(
    [0] => domelement Object
        (
            [type] => 1
            [tagname] => Assured
            [0] => 43
            [1] => 24736120
        )

)
Method "set_attribute" does not exist...
Methods are:
Array
(
    [0] => domelement
    [1] => name
    [2] => tagname
    [3] => get_attribute
    [4] => set_attribute
    [5] => remove_attribute
    [6] => get_attribute_node
    [7] => get_elements_by_tagname
    [8] => has_attribute
    [9] => domnode
    [10] => node_name
    [11] => node_type
    [12] => node_value
    [13] => first_child
    [14] => last_child
    [15] => children
    [16] => child_nodes
    [17] => previous_sibling
    [18] => next_sibling
    [19] => has_child_nodes
    [20] => parent
    [21] => parent_node
    [22] => insert_before
    [23] => append_child
    [24] => remove_child
    [25] => replace_child
    [26] => owner_document
    [27] => new_child
    [28] => attributes
    [29] => has_attributes
    [30] => prefix
    [31] => namespace_uri
    [32] => clone_node
    [33] => add_namespace
    [34] => set_namespace
    [35] => add_child
    [36] => append_sibling
    [37] => node
    [38] => unlink
    [39] => unlink_node
    [40] => replace_node
    [41] => set_content
    [42] => get_content
    [43] => text_concat
    [44] => set_name
    [45] => is_blank_node
    [46] => dump_node
)---------------------------------------------Why? What's going on? If the
variable is showing as a
'domelement object' why am I getting the message saying
that the method does not exist? When it clearly shows up
below in the list of all the methods for the domelement class?

thnx,
Chris

attached mail follows:


> Consider the following:

Never mind. I'm retarded. :p

Sorry, folks. Nothing to see here but an empty
brain cavity. Move along. :)

thnx,
Chris

attached mail follows:


Greetings all,

I am currious if someone could point me to a script to list the content of a
directory, then link to each file in that directory.

Example:

The directory contains 80 .GIF files. I want to create a page that will have
links to each file.

Is this possible?

Thank you very much,

--
Steve Marquez
smarquezmarquez-design.com

attached mail follows:


At 10:52 AM 2/2/2005, Marquez Design: Steve Marquez wrote:

>Greetings all,
>
>I am currious if someone could point me to a script to list the content of a
>directory, then link to each file in that directory.
>
>Example:
>
>The directory contains 80 .GIF files. I want to create a page that will have
>links to each file.
>
>Is this possible?

Go to http://www.php.net and search for "direcotry listing" in the "whole site"

attached mail follows:


Hello,

I've been messing with a certain rewrite rule for about 30 minutes now
and it's driving me insane. I've got plenty of other rewrite rules
working perfectly. Here is the rule in question.

RewriteRule ^detail\.asp\?product_id=([\w-]+)$ product.php?id=$1

The URL I'm testing this with is:

http://www.nonlethal.com/detail.asp?product_id=bh35wg00od

This is to stop 404's from a legacy product that has these old links in
it. i.e. "detail.asp?product_id=" was what the old site used,
"product.php?id=" is what the new site uses.

Anyone see what I'm missing?

Chris.

attached mail follows:


the problem is actually really easy....
You're not asking it on an apache list (this is a PHP list... so why
should anyone here know anything about mod_rewrite for apache?)

sorry if I sounded rude, but that's just the way I feel about it

Chris W. Parker wrote:
> Hello,
>
> I've been messing with a certain rewrite rule for about 30 minutes now
> and it's driving me insane. I've got plenty of other rewrite rules
> working perfectly. Here is the rule in question.
>
> RewriteRule ^detail\.asp\?product_id=([\w-]+)$ product.php?id=$1
>
> The URL I'm testing this with is:
>
> http://www.nonlethal.com/detail.asp?product_id=bh35wg00od
>
> This is to stop 404's from a legacy product that has these old links in
> it. i.e. "detail.asp?product_id=" was what the old site used,
> "product.php?id=" is what the new site uses.
>
> Anyone see what I'm missing?
>
>
>
> Chris.

attached mail follows:


M. Sokolewicz <mailto:tularisphp.net>
    on Wednesday, February 02, 2005 10:22 AM said:

> the problem is actually really easy....
> You're not asking it on an apache list (this is a PHP list... so why
> should anyone here know anything about mod_rewrite for apache?)
>
> sorry if I sounded rude, but that's just the way I feel about it

damn. i was hoping no one would notice.

attached mail follows:


Chris W. Parker wrote:
> Hello,
>
> I've been messing with a certain rewrite rule for about 30 minutes now
> and it's driving me insane. I've got plenty of other rewrite rules
> working perfectly. Here is the rule in question.
>
> RewriteRule ^detail\.asp\?product_id=([\w-]+)$ product.php?id=$1

You're insisting that the path to rewrite start with d. It's not going
to start with d, it's going to start with /. As in "/detail.asp"...

Easy thing to miss, though...

Mike

attached mail follows:


Michael <mailto:phpnewsmas.ml1.net>
    on Wednesday, February 02, 2005 11:54 AM said:

> You're insisting that the path to rewrite start with d. It's not going
> to start with d, it's going to start with /. As in "/detail.asp"...
>
> Easy thing to miss, though...

Actually that's not why. None of my other rules begin with a /. The
problem is because mod_rewrite does not handle the query string by
default. You have to setup a special rule for that.

Here is the solution:

RewriteCond %{QUERY_STRING} product_id=([\w-]+)
RewriteRule ^detail\.asp product.php?id=$1

Chris.

attached mail follows:


On Wed, 2 Feb 2005 12:09:43 -0800, "Chris W. Parker"
<cparkerswatgear.com> said:
> Michael <mailto:phpnewsmas.ml1.net> on Wednesday, February 02,
> 2005 11:54 AM said:
>
> > You're insisting that the path to rewrite start with d. It's not
> > going to start with d, it's going to start with /. As in
> > "/detail.asp"...
>
> Actually that's not why. None of my other rules begin with a /. The
> problem is because mod_rewrite does not handle the query string by
> default. You have to setup a special rule for that.
>
> Here is the solution:
>
> RewriteCond %{QUERY_STRING} product_id=([\w-]+) RewriteRule
> ^detail\.asp product.php?id=$1

Aha. Is this in a .htaccess file? In any case, I'm glad you found the
answer!

Mike

attached mail follows:


Hey guys, i was wondering if there is any way to make prepend (php.ini
option) work as an include once and not an STD include.

Tnx
Sdäv

attached mail follows:


Sdäv wrote:
> Hey guys, i was wondering if there is any way to make prepend (php.ini
> option) work as an include once and not an STD include.

Well, it's for sure gonna get included once, right?

If you're worried about it getting included again...

I'm not sure of the semantics of:
<?php
 include 'foo';
 include_once 'foo';
?>

Does it get "regsitered" in the first include?

I guess not, or you'd already be happy, right?

The standard work-around then is to do like this in your included file:

<?php
if (!defined('FILENAME_PHP')){
  define ('FILENAME_PHP', 1);
//rest of code here
}
?>

So then you don't really care if it gets included twice, cuz it won't *DO*
anything the second time.

FILENAME_PHP should be a variant of the name of the file being included,
to avoid two files with the same work-around killing each other.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Sdäv wrote:
> Hey guys, i was wondering if there is any way to make prepend (php.ini
> option) work as an include once and not an STD include.

You could use the prepended file to do your includes....

prepend includes.inc.php

includes.inc.php -->
<?php

include_once ( "foo.php" );
include_once ( "bar.php" );

?>

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


I have corrected your document.

attached mail follows:


Hi!
strip_tags() would not solve his problem, although that was my first
thought as well.
To skip tags, including content, where content contains certain words is
possible.
But to me the problem occurs with nested tags. What do you want to do when
you meet tables?

Here is an example that solves you're example, and similar situations, but
not much else.

preg_match_all("/<(?!body|script|etc)(\w+)[^>]*>((?>(?!eee|etc|<\/
\\1>).)*)<\/\\1>/s",$text,$match);

print_r($match[2]);

will return
[0] => aaa jjjj mmmm dddd yyyy ssss
[1] => aaa hhh mmmm dddd yyyy ssss
[2] => aaa kkkk mmmm dddd yyyy ssss

(?!body|script|etc) is used to filter unwanted tags, and in
(?!eee|etc|<\/\\1>) you can put your filter words.

Hope this helps you anyway.

--

Stian

On Wed, 2 Feb 2005 11:36:26 +0100, Mirco Blitz <webmasterlindworm.de>
wrote:

> Hi,
> Use strip_tags() instead of regex.
>
> http://www.php-center.de/en-html-manual/function.strip-tags.html
>
> Greetings
> Mirco
>
> -----Ursprüngliche Nachricht-----
> Von: php [mailto:silviumaghearprogramming-pool.com]
> Gesendet: Mittwoch, 2. Februar 2005 09:25
> An: php-generallists.php.net
> Betreff: [PHP] regular expresion
>
> I want to parse a html file
> for instance
>
> <body>
> <p>aaa jjjj mmmm dddd yyyy ssss</p>
> <b>aaa hhh mmmm dddd yyyy ssss</b>
> <p>aaa eee mmmm dddd yyyy ssss</p>
> <i>aaa kkkk mmmm dddd yyyy ssss</i>
> </body>
>
> and I want to create a regular expresion wich is able to extract entire
> text
> from enclosed tags WITHOUT a particular word
> for example eee
> final I want to obtain this result
>
> aaa jjjj mmmm dddd yyyy ssss
> aaa hhh mmmm dddd yyyy ssss
> aaa kkkk mmmm dddd yyyy ssss
>
> Any solution?
>
>
> thank you
>
> Silviu
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php

attached mail follows:


php wrote:
> I want to parse a html file
> for instance
>
> <body>
> <p>aaa jjjj mmmm dddd yyyy ssss</p>
> <b>aaa hhh mmmm dddd yyyy ssss</b>
> <p>aaa eee mmmm dddd yyyy ssss</p>
> <i>aaa kkkk mmmm dddd yyyy ssss</i>
> </body>
>
> and I want to create a regular expresion wich is able to extract entire
> text
> from enclosed tags WITHOUT a particular word
> for example eee
> final I want to obtain this result
>
> aaa jjjj mmmm dddd yyyy ssss
> aaa hhh mmmm dddd yyyy ssss
> aaa kkkk mmmm dddd yyyy ssss

Use the built-in striptags to remove all the HTML.

Then, use explode("\n", $text) to find the line-breaks.

Finally, remove any line with 'eee' in it.

You could also do the explode first, then check for specific tags/lines
with 'eee' and drop those, and then re-assemble everything into a string,
and call striptags on that... Not quite as clean and easy, though, but if
you can't identify the 'eee' part without the surrounding tags, you'll
need it.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hi, I'm trying to extract a string using 'ereg()' but it doesn't seem
to find some strings. I am using php version 4.3.10 in cli mode.

Here is an example of the input:
#include FT_FREETYPE_H
#include <stdio.h>
#include "freetype/freetype.h"

Here is a snip of my code:
$line = fgets($fp);
$line = trim($line);
$regexp = '^#include(:? | "| <)([^< >"]+)[> "]';
//$regexp = '^#include( <| "| )[^< >"]+[> "]'; //Same result as above
//$regexp = '^#include [< "]([^>" ]+)[> "]'; //Similar to above result
ereg($regexp, $line, $inclistings);
var_dump($inclistings);

Here is the output I am getting:
#include FT_FREETYPE_H

#include <stdio.h>
array(3) {
  [0]=>
  string(18) "#include <stdio.h>"
  [1]=>
  string(2) " <"
  [2]=>
  string(7) "stdio.h"
}

#include "freetype/freetype.h"
array(3) {
  [0]=>
  string(30) "#include "freetype/freetype.h""
  [1]=>
  string(2) " ""
  [2]=>
  string(19) "freetype/freetype.h"
}

Here is the output I want:
#include FT_FREETYPE_H
array(3) {
  [0]=>
  string(?) "#include FT_FREETYPE_H"
  [1]=>
  string(?) "FT_FREETYPE_H"
}

#include <stdio.h>
array(3) {
  [0]=>
  string(18) "#include <stdio.h>"
  [1]=>
  string(7) "stdio.h"
}

#include "freetype/freetype.h"
array(3) {
  [0]=>
  string(30) "#include "freetype/freetype.h""
  [1]=>
  string(19) "freetype/freetype.h"
}

So how do I keep ereg() from thinking the first set of parentheses
is a substring to export. In addition, how do I craft the $regexp to
recognize the first input $line? I came up with the above $regexp lines
by using kregexpeditor in kde.

attached mail follows:


Arrrrrgggggghhhhhhh....return receipts!!!!

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


> Arrrrrgggggghhhhhhh....return receipts!!!!

I just mailed the guy and gave him a friendly nod - they are off now :-)

Mikey

attached mail follows:


KHS wrote:

> Here is an example of the input:
> #include FT_FREETYPE_H
> #include <stdio.h>
> #include "freetype/freetype.h"
>
> Here is a snip of my code:
> $line = fgets($fp);
> $line = trim($line);
> $regexp = '^#include(:? | "| <)([^< >"]+)[> "]';
> //$regexp = '^#include( <| "| )[^< >"]+[> "]'; //Same result as above
> //$regexp = '^#include [< "]([^>" ]+)[> "]'; //Similar to above result
> ereg($regexp, $line, $inclistings);
> var_dump($inclistings);
>
> Here is the output I am getting:
> #include FT_FREETYPE_H
>
> #include <stdio.h>
> array(3) {
> [0]=>
> string(18) "#include <stdio.h>"
> [1]=>
> string(2) " <"
> [2]=>
> string(7) "stdio.h"
> }
>
> #include "freetype/freetype.h"
> array(3) {
> [0]=>
> string(30) "#include "freetype/freetype.h""
> [1]=>
> string(2) " ""
> [2]=>
> string(19) "freetype/freetype.h"
> }
>
> Here is the output I want:
> #include FT_FREETYPE_H
> array(3) {
> [0]=>
> string(?) "#include FT_FREETYPE_H"
> [1]=>
> string(?) "FT_FREETYPE_H"
> }
>
> #include <stdio.h>
> array(3) {
> [0]=>
> string(18) "#include <stdio.h>"
> [1]=>
> string(7) "stdio.h"
> }
>
> #include "freetype/freetype.h"
> array(3) {
> [0]=>
> string(30) "#include "freetype/freetype.h""
> [1]=>
> string(19) "freetype/freetype.h"
> }
>
> So how do I keep ereg() from thinking the first set of parentheses
> is a substring to export. In addition, how do I craft the $regexp to
> recognize the first input $line? I came up with the above $regexp lines
> by using kregexpeditor in kde.

I think if you wrap an extra parentheses around the whole mess, you'll get
what you want... But that might only be with preg and friends...

On the other hand, I think you could safely do:

$regex = "^#include(.*)$";

and get what you want by using trim on the captured expression.

Unless you're trying to make sure it's kosher C syntax, as well as snag
the included thing...

Even then, you might be better off doing the above, and *THEN* deciding if
the thing after #include is kosher or not.

Separting the capture of the text, from validating that it's kosher text
can simplify your life immensely sometimes, even if it's "more code" to
type.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Richard Lynch wrote:

>KHS wrote:
>
>
>
>>Here is an example of the input:
>>#include FT_FREETYPE_H
>>#include <stdio.h>
>>#include "freetype/freetype.h"
>>
>>Here is a snip of my code:
>>$line = fgets($fp);
>>$line = trim($line);
>>$regexp = '^#include(:? | "| <)([^< >"]+)[> "]';
>>//$regexp = '^#include( <| "| )[^< >"]+[> "]'; //Same result as above
>>//$regexp = '^#include [< "]([^>" ]+)[> "]'; //Similar to above result
>>ereg($regexp, $line, $inclistings);
>>var_dump($inclistings);
>>
>>Here is the output I am getting:
>>#include FT_FREETYPE_H
>>
>>#include <stdio.h>
>>array(3) {
>> [0]=>
>> string(18) "#include <stdio.h>"
>> [1]=>
>> string(2) " <"
>> [2]=>
>> string(7) "stdio.h"
>>}
>>
>>#include "freetype/freetype.h"
>>array(3) {
>> [0]=>
>> string(30) "#include "freetype/freetype.h""
>> [1]=>
>> string(2) " ""
>> [2]=>
>> string(19) "freetype/freetype.h"
>>}
>>
>>Here is the output I want:
>>#include FT_FREETYPE_H
>>array(3) {
>> [0]=>
>> string(?) "#include FT_FREETYPE_H"
>> [1]=>
>> string(?) "FT_FREETYPE_H"
>>}
>>
>>#include <stdio.h>
>>array(3) {
>> [0]=>
>> string(18) "#include <stdio.h>"
>> [1]=>
>> string(7) "stdio.h"
>>}
>>
>>#include "freetype/freetype.h"
>>array(3) {
>> [0]=>
>> string(30) "#include "freetype/freetype.h""
>> [1]=>
>> string(19) "freetype/freetype.h"
>>}
>>
>>So how do I keep ereg() from thinking the first set of parentheses
>>is a substring to export. In addition, how do I craft the $regexp to
>>recognize the first input $line? I came up with the above $regexp lines
>>by using kregexpeditor in kde.
>>
>>
>
>I think if you wrap an extra parentheses around the whole mess, you'll get
>what you want... But that might only be with preg and friends...
>
>
>
Tried that with no success.

>On the other hand, I think you could safely do:
>
>$regex = "^#include(.*)$";
>
>and get what you want by using trim on the captured expression.
>
>
>
no this would leave me with <, >, and " marks.

>Unless you're trying to make sure it's kosher C syntax, as well as snag
>the included thing...
>
>
>
I just want to extract the file name.

>Even then, you might be better off doing the above, and *THEN* deciding if
>the thing after #include is kosher or not.
>
>
>
This is how I pick what lines to scan for extraction:
if((stristr($line, '#include')) === false){ //Search for "#include" in $line
    continue;
}

>Separting the capture of the text, from validating that it's kosher text
>can simplify your life immensely sometimes, even if it's "more code" to
>type.
>
>
>
My script will only find '#include' statements.

attached mail follows:


KHS wrote:
> Richard Lynch wrote:
>
>>KHS wrote:
>>
>>
>>
>>>Here is an example of the input:
>>>#include FT_FREETYPE_H
>>>#include <stdio.h>
>>>#include "freetype/freetype.h"

Perhaps:

<?php
$text = trim(str_replace("#include", "", $text));
preg_match('[<"]?(.*)[>"]?', $text, $answer);
echo $answer[1];
?>

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


On Thursday 03 February 2005 02:18, John Nichel wrote:
> Arrrrrgggggghhhhhhh....return receipts!!!!

Use a *real* mail client -- one that ignores those stupid things.

--
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
------------------------------------------
New Year Resolution: Ignore top posted posts

attached mail follows:


Hi,
Is it possible compile a php script to native binary like perlcc ?
That can run the binary and no depend on php.

attached mail follows:


[snip]
Is it possible compile a php script to native binary like perlcc ?
That can run the binary and no depend on php.
[/snip]

See http://www.priadoblender.com

attached mail follows:


Unreal HSHH wrote:
> Hi,
> Is it possible compile a php script to native binary like perlcc ?
> That can run the binary and no depend on php.

Yes.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
johnkegworks.com

attached mail follows:


Unreal HSHH wrote:
> Is it possible compile a php script to native binary like perlcc ?
> That can run the binary and no depend on php.

Not truly, but Google for "PHP Compiler" and you should find some
alternatives that may fit your needs.

Fair Warning: Some will be commercial, some won't.

--
Like Music?
http://l-i-e.com/artists.htm

attached mail follows:


Hi, i've got problem with imap_mail_compose function, I have this code:

--------------------------------------------
$envelope["from"]= "joeexample.com";
$envelope["to"] = "fooexample.com";
$envelope["cc"] = "barexample.com";

$body[1]["type"] = TYPETEXT;
$body[1]["subtype"] = "plain";
$body[1]["contents.data"] = "contents.data3\n\n\n\t";

echo imap_mail_compose($envelope, $body);

--

but the result is only the text "contents.data3", this is not expected
functionality....
I'm using PHP5.0.3 on windows, I cannot change it to PHP4, because whole
project is using PHP5 functions and object model... so does anybody
know, what might be wrong?

The strange thing is, that I already has PHP5.0.3 installed and
everything was working fine, I have to reinstall it, so I've installed
PHP again and now it's not working....

Any advice? solution?

Thanks

          Bronislav Klucka

attached mail follows:


Hello, all -

I am a bit new to PHP, especially sockets, so what I am asking may very
well be comparing apples to oranges.

I am writing a function to interact with an SSL server, but I see no way
of how I can communicate over SSL. I expected to be able to enter an
address such as https://10.10.10.10 into socket_connect(), but it fails.
  Maybe because this isn't even a supported/allowed argument.

Is it possible to use SSL with any of the socket_* functions in PHP5?

Again, I feel like a real tool asking this. I'm just trying to
understand as best I can.

Thanks for the time
-dant

attached mail follows:


Hello,

I just found out that since version 0.7, PEAR::SOAP returns stdClass
objects instead of associative arrays.
http://pear.php.net/package-changelog.php?pacid=87&release=0.7.3

What is the reason for this? I _need_ to get associative arrays, how do
I revert to the old behavior?

-William

attached mail follows:


Hello,

I just found out that since version 0.7, PEAR::SOAP returns stdClass
objects instead of associative arrays.
http://pear.php.net/package-changelog.php?pacid=87&release=0.7.3

What is the reason for this? I _need_ to get associative arrays, how do
I revert to the old behavior?

-William

attached mail follows:


Here's the code (with the domain name removed)
that doesn't work, "despite" the poor documentation
of the variable types:

<?
        $dir = "/home/<domain_name>/www/binary/";
        $dh = opendir ($dir);
        do
        {
                $file = readdir ($dh);
        }
        while (!strncmp ($file, ".", 1));
        $filename = sprintf ("%s%s", $dir, $file);
        $fh = fopen ($filename, "r");
        $cont = fread ($fh, 4);
        echo "file:<BR>";
        echo $filename;
        echo "<BR>cont:<BR>";
        printf ("%02x %02x %02x %02x", $cont{0}, $cont{1}, $cont{2},
$cont{3});
        fclose ($fh);
        closedir ($dh);
?>

Here's the output of "od -c glance_date" up to the fourth byte:

0000000 177 E L F

All four bytes are non-zero!

attached mail follows:


Is there an example of the UNIX od utility written
in PHP? Is such a useful task even possible??
From what I've seen of strings, they're completely
opaque, so what good does it do to be able to read
binary-safe strings from a file??? Even the deprecated
(why????) $str{$inx} notation apparently results in
another string, because trying to printf it with the
"%02x" format always comes out with "00." (Maybe
that's why -- it's useless!) As an experienced C
programmer, I'm finding PHP to be as counter-intuitive
for low-level work as Perl is. I need to convert binary
dumps of data structures into database table rows, and
MySQL on my server doesn't support queries from C.

I thought about writing a CGI script (in C) that
would generate the hard-coded PHP output for
each instance, but a URL that ends in ".cgi" is
never intercepted by the PHP interpreter. Worse
yet, the <SCRIPT LANGUAGE="" SRC="">
that works perfectly well with JavaScript is
likewise ignored if the language is PHP! Finally,
I'm not aware of a Content-type such as "text/php."
What exactly was the purpose of designing yet
another inflexible language?!