Re: [PHP] Date problems

2006-04-09 Thread Satyam
Timestamps are stored as seconds from a certain date.  The base date differ 
depending on the platform, Windows use 1/1/1980 the rest 1/1/1970, but still 
seconds.  7 days are 7*24*60*60.  Just add that much to a timestamp.  It 
helps having a constant such as:


define ('DAY_IN_SECONDS',86400);

Satyam


- Original Message - 
From: "Mace Eliason" <[EMAIL PROTECTED]>

To: 
Sent: Sunday, April 09, 2006 4:14 AM
Subject: [PHP] Date problems



Hi,

I am having troubles adding 7 days to the current date.  I have been 
reading through php.net date() and this is what I have come up with but it 
doesn't work

$today = date('m/d/Y');
$nextweek = date('m/d/Y',mktime(date("m"), date("d")+7, date("Y")));

if I echo the above variables they are the same? Shouldn't the $nextweek 
be different?


Thanks for the help

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




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



Re: [PHP] What is best way to do handle audio files?

2006-04-09 Thread Nicholas Couloute
Yea, okay looks like I am going to be using mysql cause I want an 
organized site by genre, author etc. I going to need some resources of 
mysql cause I haven't used it before! I have used flatfile for about a 
year now!


On Sun, 9 Apr 2006 12:02 am, Richard Lynch wrote:



If the files are constantly changing, scandir is probably as fast as
it gets...

If you rarely alter the files, do scandir once and store the results
in, say, MySQL and you can search/sort MUCH faster.

On Sat, April 8, 2006 11:01 am, Nicholas Couloute wrote:

 On my website http://www.sidekick2music.com ! I use scandir() [php
 5.0]
 to fetch all the files which are all in subfolders of this one folder.
 like this:
 public_html/amrs/$cat/$author/*.amr

 $cat = different catergoried of music
 $author = Authors of the particular catergory

 This way isn't fast when you have over 5,000+ files.

 I use flatfile for everything on the site!
 site: http://www.sidekick2music.com

 Would it run faster if I used mysql?
 How would this be done?
 Is there another way when dealing with files and organizing them? CMS?

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





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

~Nick Couloute
co-owner/Web Designer
Sidekick2Music.Com

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



Re: [PHP] What is best way to do handle audio files?

2006-04-09 Thread Dave Goodchild
You will probably find a great deal of list members well versed in mysql as
it meshes so well with php, so ask away old bean.

On 09/04/06, Nicholas Couloute <[EMAIL PROTECTED]> wrote:
>
> Yea, okay looks like I am going to be using mysql cause I want an
> organized site by genre, author etc. I going to need some resources of
> mysql cause I haven't used it before! I have used flatfile for about a
> year now!
>
> On Sun, 9 Apr 2006 12:02 am, Richard Lynch wrote:
> >
> >
> > If the files are constantly changing, scandir is probably as fast as
> > it gets...
> >
> > If you rarely alter the files, do scandir once and store the results
> > in, say, MySQL and you can search/sort MUCH faster.
> >
> > On Sat, April 8, 2006 11:01 am, Nicholas Couloute wrote:
> >>  On my website http://www.sidekick2music.com ! I use scandir() [php
> >>  5.0]
> >>  to fetch all the files which are all in subfolders of this one folder.
> >>  like this:
> >>  public_html/amrs/$cat/$author/*.amr
> >>
> >>  $cat = different catergoried of music
> >>  $author = Authors of the particular catergory
> >>
> >>  This way isn't fast when you have over 5,000+ files.
> >>
> >>  I use flatfile for everything on the site!
> >>  site: http://www.sidekick2music.com
> >>
> >>  Would it run faster if I used mysql?
> >>  How would this be done?
> >>  Is there another way when dealing with files and organizing them? CMS?
> >>
> >>  --
> >>  PHP General Mailing List (http://www.php.net/)
> >>  To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
> > --
> > Like Music?
> > http://l-i-e.com/artists.htm
> ~Nick Couloute
> co-owner/Web Designer
> Sidekick2Music.Com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK

look out for e-karma, our new venture, coming soon!


Re: [PHP] Re: looking for shopping cart

2006-04-09 Thread Jochem Maas

[EMAIL PROTECTED] wrote:

Hi,

Why donot u people visit www.indialovesu.com and see the shop cart which is
much -2 powerful than oscommerce.
U can reach to the design company at www.bsdinfotech.com


this mailing list is not a forum for advertising your companies'
products or services. probably half the members of this list work for
web development related companies; should we all send you our marketing
pitch?

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



Re: [PHP] Re: looking for shopping cart

2006-04-09 Thread afan
Try CRE Loaded.
http://www.creloaded.com/
It's osCommerce shopping cart with tons of already pre-loaded
contributions (modules).

-afan


> I actually just installed OS commerce on my site, but I think it might be
> hard for my clients to upload their contents.  They need it to be real
> easy.
> Almost like fill in the blanks.  What do you think?
> Lisa
>
> ""Stephen Lake"" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> Give osCommerce a try, its free and easy to use
>> http://www.oscommerce.com/
>>
>> ""Lisa A"" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>>>I need a shopping cart for a website that once I install and set up, my
>>>client can easily add merchandise to it.  They use Paypal.  It has to be
>>>very easy for them to upload images and products, prices, etc.
>>> If anyone knows of something, please let me know.
>>> I host my own websites, so not interested in paying a monthly fee.
>>> thanks,
>>> Lisa
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] looking for shopping cart

2006-04-09 Thread Dan McCullough
X-Cart, ZenCart (osCommerce like),
http://www.hotscripts.com/PHP/Scripts_and_Programs/E-Commerce/index.html

if you look in the archives you will find similar questions with a lot
better response.

On 4/8/06, Lisa A <[EMAIL PROTECTED]> wrote:
> I need a shopping cart for a website that once I install and set up, my
> client can easily add merchandise to it.  They use Paypal.  It has to be
> very easy for them to upload images and products, prices, etc.
> If anyone knows of something, please let me know.
> I host my own websites, so not interested in paying a monthly fee.
> thanks,
> Lisa
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Re: looking for shopping cart

2006-04-09 Thread Ryan A


[EMAIL PROTECTED] wrote:
> Hi,
>
> Why donot u people visit www.indialovesu.com and see the shop cart
which is
> much -2 powerful than oscommerce.
> U can reach to the design company at www.bsdinfotech.com

this mailing list is not a forum for advertising your companies'
products or services. probably half the members of this list work for
web development related companies; should we all send you our marketing
pitch?

-- You forgot to mention that the site (and domain name) also sucks
and the cart looks crappy,Thanks for sending us that link to bsdinfotech.com
coz now we know if ever we wantquality oursourcing to NEVER visit that site.
should we all send you our marketing
pitch?
Maybe we should _all_ send the spammer our marketing
pitches.offlist :-)And yes, I do consider what he did SPAM.-Ryan

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



Re: [PHP] Re: looking for shopping cart

2006-04-09 Thread Jochem Maas

Ryan A wrote:



[EMAIL PROTECTED] wrote:


Hi,

Why donot u people visit www.indialovesu.com and see the shop cart


which is


much -2 powerful than oscommerce.
U can reach to the design company at www.bsdinfotech.com



this mailing list is not a forum for advertising your companies'
products or services. probably half the members of this list work for
web development related companies; should we all send you our marketing
pitch?

-- You forgot to mention that the site (and domain name) also sucks
and the cart looks crappy,Thanks for sending us that link to bsdinfotech.com
coz now we know if ever we wantquality oursourcing to NEVER visit that site.


OH NO ... I didn't forget. I had a whole swathe of abuse ready for this guy
about his language /cultural skills and the dodgy design-by-template 
1999-dreamweaver
HTML crap (view source made me laugh anyway, especially when considered in the
light of point 2 on this page:

http://www.bsdinfotech.com/doit.htm)

but then I thought better of it, heck the sun is shining today :-)


should we all send you our marketing
pitch?
Maybe we should _all_ send the spammer our marketing
pitches.offlist :-)And yes, I do consider what he did SPAM.-Ryan


today I have someone trying to takeover my main webserver for use in a botnet,
SPAM is the least of my worries ;-)





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



Re: [PHP] Date problems

2006-04-09 Thread Rasmus Lerdorf

Satyam wrote:
Timestamps are stored as seconds from a certain date.  The base date 
differ depending on the platform, Windows use 1/1/1980 the rest 
1/1/1970, but still seconds.  7 days are 7*24*60*60.  Just add that much 
to a timestamp.  It helps having a constant such as:


define ('DAY_IN_SECONDS',86400);


The problem with doing it this way is that it won't take leap seconds, 
leap years and daylight savings into account, so on any of these edge 
cases it will appear to be broken.  That's why strtotime("+7 days") is 
the correct way to do this.


-Rasmus

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



Re: [PHP] Completing forms offline with PHP/MySQL

2006-04-09 Thread Rory Browne
I haven't thought about this much, but I'd probably create an onSubmit
handler, that would hide the form in an iframe, and create a new one. I
would then when they are online, submit all the forms.

This would require the user to keep the browser window open and at the same
page. Alternatively you could have the user allow the script to write files
to the local hard disk, and store the form data there. Making a .hta file
would probably be the easiest way to do this on windows.

On 4/7/06, Miles Thompson <[EMAIL PROTECTED]> wrote:
>
> At 01:06 PM 4/7/2006, Kevin Davies - Bonhurst Consulting wrote:
>
> >Hi,
> >
> >Apologies if this is the wrong place for this question, but I'm sure
> there
> >are some experts out there who might be able to point me in the right
> >direction... :)
> >
> >I'm doing some work at the moment where remote teams can submit reports
> >through to our database when connected over the internet to our server.
> >However, I've been asked to look in the possibility of the teams
> completing
> >the form offline, and uploading when they have access to a connection.
> >
> >It looks like I might be able offer something like Microsoft InfoPath
> forms
> >(better recommendations?) to generate an XML file, and then use a PHP
> file
> >to upload the file into the database. Additionally, I could also do with
> >this process uploading a number of other files (e.g. images, text files)
> to
> >the server.
> >
> >Does anyone have any experience in this area, and would be able to
> recommend
> >a solution?
> >
> >Thanks in advance for your help...
> >
> >Kevin
>
>
> PHP-GTK+
> GTK+ front end, laid out using wGlade (which creates an XML-like file with
> a .glade extension), and of course, PHP for all of your logic.
>
> Works
>
> Miles
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.1.385 / Virus Database: 268.3.5/303 - Release Date: 4/6/2006
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] how to kill session id without closing the window?

2006-04-09 Thread afan
Yup! That works perfect!

Thanks Tedd

:)


-afan



> At 9:19 PM +0200 4/6/06, [EMAIL PROTECTED] wrote:
>>Hi to all,
>>
>>session_start();
>>$_SESSION['sessid'] = session_id;
>>
>>echo $_SESSION['sessid']; will show e.g. 699e506bd42ea402985dce24a0ef9
>>
>>After:
>>
>>unset($_SESSION['sessid']);
>>
>>$_SESSION['sessid'] = session_id();
>>
>>I'm getting the same SID again.
>>
>>I tried with session_unregister() and session_destroy() but same result.
>>
>>How can I create new, other sesssion id (after I, for example, click on
>>'Log Out' button) without closing window?
>>
>>Thanks for any help.
>
>
> Look up:
>
> http://www.weberdev.com/session_regenerate_id
>
> HTH's
>
> tedd
>
>
> --
> 
> http://sperling.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Re: looking for shopping cart

2006-04-09 Thread tedd

At 4:03 PM +0200 4/9/06, Jochem Maas wrote:

[EMAIL PROTECTED] wrote:

Hi,

Why donot u people visit www.indialovesu.com and see the shop cart which is
much -2 powerful than oscommerce.
U can reach to the design company at www.bsdinfotech.com


this mailing list is not a forum for advertising your companies'
products or services. probably half the members of this list work for
web development related companies; should we all send you our marketing
pitch?


Well... if we did advertise, we would do a better job of it.

And, most of us have written a better shopping cart as well.

tedd
--

http://sperling.com

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



Re: [PHP] looking for shopping cart

2006-04-09 Thread tedd

At 11:36 PM -0400 4/8/06, Lisa A wrote:

I need a shopping cart for a website that once I install and set up, my
client can easily add merchandise to it.  They use Paypal.  It has to be
very easy for them to upload images and products, prices, etc.
If anyone knows of something, please let me know.
I host my own websites, so not interested in paying a monthly fee.
thanks,
Lisa


Lisa:

There are all sorts of shopping carts including PayPal -- you may 
want to look into that.


I have written forms for clients such that they can upload their 
products, image, price, product ID,  and such and data is 
automatically posted to their MySQL dB, and from there, is available 
to their on-line catalog and from there, the products are just a 
click away from PayPal and PayPal's shopping cart. It's neat, simple, 
and works. No money other than your time to set it up.



If you want a more traditional shopping cart, you might look into 
Shop Script (I'm a distributor). I've installed and set-up a few of 
those. They cost, but are set up for an easy admin for civilians. If 
interested, contact me privately.



tedd
--

http://sperling.com

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



Re: [PHP] Problems with Arrays and print and echo

2006-04-09 Thread Michael Felt

John Wells wrote:

echo "$this->name[5]\n";
echo "$this->ID[5]\n";
$a1 = $this->name;
$a2 = $this->ID;
echo "\n$a1[5] $a2[5]\n";



use curly brackets to help PHP understand what you're after:

echo "{$this->name[5]}\n";

When you're in a string like this, PHP has a hard time knowing when
you're wanting to access a variable, and when you're simply trying to
output text.  Using curly brackets clears it up.

HTH,
John W

Thanks.

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



Re: [PHP] Ajax please....

2006-04-09 Thread Michael Felt

tedd wrote:

Ryan:


Carlin Bingham / Tedd:
---
Yes, but then I would have to reload the whole page just to tell the 
person
that the account username was already taken...thats how its 
"traditionally"
done...but I want to try doing it without reloading the whole 
page...hence
Asynchronous JavaScript And XML (AJAX) although the XML part at the 
end is

not really too accurate because from what I see you can (and i have) use
AJAX without any XML...in my case it would be AJAH or AJAT (H=HTML, 
T=TEXT)

:-p



Okay, you don't need to stick your tongue out -- I know what ajax is.

Please review:

http://www.xn--ovg.com/ajax

Is that what you want? If so, contact me privately and I'll provide you 
with the code. It's pretty simple really.


tedd

And I thought Ajax was a Dutch Football (soccer) team. :P

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



[PHP] function by reference

2006-04-09 Thread tedd

Hi gang:

Not that I have an immediate need for this, but in other languages 
one can access a function by reference (in other words, it's address 
-- such as call(function address) ).


In php, one can pass a variable by reference by simply using the 
ampersand, such a &$a.


Is there a similar way to reference a function?

Rob, was kind enough to post the following code, but I was looking 
for something where I could store the function's address in a 
variable. Something like:


$a = &f_a();

And then, where I could use call_user_func($a); (or something 
similar) and the function would do it's thing -- anything like that?


Thanks

tedd

--- Rob's suggestion follows.

Like the following?

 'f_a',
'b' => 'f_b',
'c' => 'f_c',
);

$map['a']();
$map['b']();
$map['c']();

?>


--

http://sperling.com

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



Re: [PHP] Ajax please....

2006-04-09 Thread tedd

At 8:13 PM +0200 4/9/06, Michael Felt wrote:

And I thought Ajax was a Dutch Football (soccer) team. :P


It isn't??

tedd
--

http://sperling.com

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



Re: [PHP] Ajax please....

2006-04-09 Thread Ryan A
>  And I thought Ajax was a Dutch Football (soccer) team. :P


It isand a very good dish washing detergent too (and yes, I am a
bachelor :-D )


Cheers,
Ryan

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



Re: [PHP] looking for shopping cart

2006-04-09 Thread Ryan A
Lisa,


--


If you want a more traditional shopping cart, you might look into
Shop Script (I'm a distributor). I've installed and set-up a few of
those. They cost, but are set up for an easy admin for civilians. If
interested, contact me privately.


---


Another thing to consider is that commercial programs often tend to have
better support
too incase things go wrong or you want modifications/added features.
Don't get me wrong, there are _many_ free programs that are supported very
well but they
are supported mostly by a community and if you want modifications you would
either have to
pay for it or wait a long time, if you dont know how to go in and do it
yourself of course.
The free system thinks more of how a modification would help the whole
community of users
rather than the single person who has a specific need (OSC as an example,
not that I am
bashing OSC...I installed it for more than one client myself.)

HTH.

Cheers,
Ryan

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



Re: [PHP] Re: looking for shopping cart

2006-04-09 Thread Ryan A

Hey,

--

OH NO ... I didn't forget. I had a whole swathe of abuse ready for this
guy
about his language /cultural skills and the dodgy design-by-template
1999-dreamweaver
HTML crap (view source made me laugh anyway, especially when considered
in the
light of point 2 on this page:

http://www.bsdinfotech.com/doit.htm)-

Hehehe someone certainly was hitting the thesaurus for point two:

" 2. Eradicating Existing Flaws. "



---

but then I thought better of it, heck the sun is shining today
:-)Lucky son of...oops, sorry, sometimes cant control the little
green monster in me :-DJ/K of course. today I have someone
trying to takeover my main webserver for use in a botnet,
SPAM is the least of my worries ;-)--Sounds bad, best of
luck m8.Cheers,Ryan

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



[PHP] stripping enclosed text from PHP code

2006-04-09 Thread Winfried Meining

Hi,

I am writing on a script that parses a PHP script and finds all function calls 
to check, if these functions exist. To do this, I needed a function that would 
strip out all text, which is enclosed in apostrophes or quotation marks. This 
is somewhat tricky, as the script needs to be aware of what really is an 
enclosed text and what is PHP code. Apostrophes in quotation mark enclosed text 
should be ignored and quotation marks in apostrophe enclosed text should be 
ignored, as well. Similarly, escaped apostrophes in apostrophe enclosed text 
and escaped quotation marks in quotation mark enclosed text should be ignored. 

The following function uses preg_match to do this job. 



I noticed that this function is very slow, in particular because 

preg_match("/^(.*)some_string(.*)$/", $text, $matches);

always seems to find the *last* occurrence of some_string and not the *first* 
(I would need the first). There is certainly a way to write another version 
where one looks at every single character when going through $text, but this 
would make the code much more complex.

I wonder, if there is a faster *and* simple way to do the same thing. 

Is there btw a script freely available, which can parse PHP code and check for 
errors ?

Any help is highly appreciated.

Winfried

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



[PHP] php with ajax - uploading pictures

2006-04-09 Thread Merlin

Hi there,

I am searching for a good upload framework that works with PHP and AJAX 
to provide an upload interface that uploads one picture instantly, shows 
the thumbnail and displays another upload formfield to select the next 
picture for upload.


Is there something like this, or similar around?

Thank you for any hint,

Merlin

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



Re: [PHP] how to run 'periodic'

2006-04-09 Thread Frank Arensmeier

Thank you Joe for your input. I will take a look at crond.

/frank
7 apr 2006 kl. 20.06 skrev Joe Wollard:


Frank,

It sounds like you need to run this as a job through crond. I'm not  
sure
what the OSX version is (maybe they have a port of crond?) but you  
could set
that up to execute the specific code, as root, whenever you want.  
As far as
I can think, and maybe Chris Shifflet can confirm/deny this, you  
shouldn't
be running into any additional security issues by executing the  
script as
root - As long as it's running through the CLI version of PHP. Just  
make

sure it's only executable by root and then root should be the only one
allowed to create that mammoth ;-)

- Joe

On 4/6/06, Frank Arensmeier <[EMAIL PROTECTED]>  
wrote:


Hi.

I have written a script which outputs a rather large ZIP file ( 200
MB ) by collecting a large amount of PDF files and html pages. When
the script is done, the available amount of free memory has decreased
by about 20 - 30%. Running 'periodic' on my machine ( Apple Xserve G5
with Mac OS 10.4 server) restores the available memory to a more
proper size.

The question is: how can I execute 'periodic daily|weekly|monthly'
from my script? Is this possible at all? I know that 'periodic' needs
root. And all PHP code is executed as www user which doesn't have
root privileges. Would I compromise my servers security when granting
root privileges to a script that executes 'periodic' (which could be
called from the script that outputs the ZIP archive)?

thanks
/frank

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




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



Re: [PHP] stripping enclosed text from PHP code

2006-04-09 Thread Satyam

http://www.phpcompiler.org/

Satyam

- Original Message - 
From: "Winfried Meining" <[EMAIL PROTECTED]>

To: 
Sent: Sunday, April 09, 2006 10:20 PM
Subject: [PHP] stripping enclosed text from PHP code




Hi,

I am writing on a script that parses a PHP script and finds all function 
calls
to check, if these functions exist. To do this, I needed a function that 
would
strip out all text, which is enclosed in apostrophes or quotation marks. 
This

is somewhat tricky, as the script needs to be aware of what really is an
enclosed text and what is PHP code. Apostrophes in quotation mark enclosed 
text
should be ignored and quotation marks in apostrophe enclosed text should 
be
ignored, as well. Similarly, escaped apostrophes in apostrophe enclosed 
text
and escaped quotation marks in quotation mark enclosed text should be 
ignored.


The following function uses preg_match to do this job.



I noticed that this function is very slow, in particular because

preg_match("/^(.*)some_string(.*)$/", $text, $matches);

always seems to find the *last* occurrence of some_string and not the 
*first*
(I would need the first). There is certainly a way to write another 
version
where one looks at every single character when going through $text, but 
this

would make the code much more complex.

I wonder, if there is a faster *and* simple way to do the same thing.

Is there btw a script freely available, which can parse PHP code and check 
for

errors ?

Any help is highly appreciated.

Winfried

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





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



[PHP] DDE + PHP

2006-04-09 Thread C.F. Scheidecker Antunes

Hello,

I have an Excel spreadsheet that is automatically updated with quotes. I 
am doing a project for my BS and I need to grab the information from 
this spreadsheet and populate a MySQL database. Any ideas on how to 
accomplish that with PHP? The spreadsheet uses a DDE feed to fetch 
information from a third party service and needs to be opened.


I understand that I can do that with Java as well but if there is a way 
with PHP I prefer.


Thanks,

C.F.

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



Re: [PHP] function by reference

2006-04-09 Thread Robert Cummings
On Sun, 2006-04-09 at 14:17, tedd wrote:
> Hi gang:
> 
> Not that I have an immediate need for this, but in other languages 
> one can access a function by reference (in other words, it's address 
> -- such as call(function address) ).
> 
> In php, one can pass a variable by reference by simply using the 
> ampersand, such a &$a.
> 
> Is there a similar way to reference a function?
> 
> Rob, was kind enough to post the following code, but I was looking 
> for something where I could store the function's address in a 
> variable. Something like:
> 
> $a = &f_a();
> 
> And then, where I could use call_user_func($a); (or something 
> similar) and the function would do it's thing -- anything like that?

It's the same thing for the most part...



Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] DDE + PHP

2006-04-09 Thread tedd

At 4:59 PM -0600 4/9/06, C.F. Scheidecker Antunes wrote:

Hello,

I have an Excel spreadsheet that is automatically updated with 
quotes. I am doing a project for my BS and I need to grab the 
information from this spreadsheet and populate a MySQL database. Any 
ideas on how to accomplish that with PHP? The spreadsheet uses a DDE 
feed to fetch information from a third party service and needs to be 
opened.


I understand that I can do that with Java as well but if there is a 
way with PHP I prefer.


Thanks,

C.F.


Yep, you can upload an Excel spreadsheet and populate MySQL via php.

These links might give you a start.

http://www.weberdev.com/get_example-3591.html

http://www.weberdev.com/get_example-1270.html

As for DDE and third party service, I haven't a clue.

tedd
--

http://sperling.com

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



[PHP] Implied permissions

2006-04-09 Thread SLaVKa

Hey guys... implementing a permission system and just wanted some advice.

If i have permission A
which has implied permissions B and C

How do the permissions relate to each other, for eg if I select 
permission A to true, that implies that permission B and C must be set 
to true, but then if I set B to false or C to false, or both does that 
affect permission A?


Assuming that B, and C dont have implied rights you should be able to 
turn both of them off while leaving A on, but then that breaks the rule 
for A having implied permissions B and C.


Any help appreciated.

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



[PHP] Var within a var

2006-04-09 Thread bob pilly
Hi All
 
 Im trying to store a document template in mysql that has php var names within 
it and then find it in the datebase and print it out with the var names 
replaced with the var values.
 
 e.g i have this stored
 
 Dear $title $name
 we would like to..
 
 I declare the vars $title and $name
 
 $title = 'Mr';
 $name = 'Test';
 //retrieve the stored template
 $query = "select template from letters";
 $result = mysqli_query($dblink,$query);
 if($row = mysqli_fetch_array($result)){
 print $row['template'];
 }
 
 i would expect that to print:
 
 Dear Mr Test
 we would like to..
 
 but it doesnt it prints out
 
 Dear $title $name
  we would like to..
 
 can someone point out where i am going wrong?
 
 Thanks for any help in advance!
 
 Cheers
 
 Bob
 

-
Yahoo! Photos – NEW, now offering a quality print service from just 8p a photo.

[PHP] Variable within a Variable

2006-04-09 Thread bob pilly
  Hi All
  
  Im trying to store a document template in mysql that has php var names within 
it and then find it in the datebase and print it out with the var names 
replaced with the var values.
  
  e.g i have this stored
  
  Dear $title $name
  we would like to..
  
  I declare the vars $title and $name
  
  $title = 'Mr';
  $name = 'Test';
  //retrieve the stored template
  $query = "select template from letters";
  $result = mysqli_query($dblink,$query);
  if($row = mysqli_fetch_array($result)){
  print $row['template'];
  }
  
  i would expect that to print:
  
  Dear Mr Test
  we would like to..
  
  but it doesnt it prints out
  
  Dear $title $name
   we would like to..
  
  can someone point out where i am going wrong? Is this actually possible and 
if so im picking ive go the syntax wrong?
  
  Thanks for any help in advance!
  
  Cheers
  
  Bob

-
To help you stay safe and secure online, we've developed the all new Yahoo! 
Security Centre.

Re: [PHP] Variable within a Variable

2006-04-09 Thread Chris

bob pilly wrote:

  Hi All
  
  Im trying to store a document template in mysql that has php var names within it and then find it in the datebase and print it out with the var names replaced with the var values.
  
  e.g i have this stored
  
  Dear $title $name

  we would like to..
  
  I declare the vars $title and $name
  
  $title = 'Mr';

  $name = 'Test';
  //retrieve the stored template
  $query = "select template from letters";
  $result = mysqli_query($dblink,$query);
  if($row = mysqli_fetch_array($result)){
  print $row['template'];
  }
  
  i would expect that to print:
  
  Dear Mr Test

  we would like to..
  
  but it doesnt it prints out
  
  Dear $title $name

   we would like to..


If you don't get an immediate response you don't need to repost your 
question.


The data stored in the database is $title, $name, not the filled in 
variables. When php prints it out (in this case), it's printing it out 
exactly how it came out of the database. No variable substitutions etc 
take place unless you tell them to.


I'd suggest using htmlentities / htmlspecialchars to help make sure your 
data won't cause issues like XSS.


You could do:

print str_replace(array('$title', '$name'), array($title, $name), 
htmlentities($row['template']));


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

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



Re: [PHP] Variable within a Variable

2006-04-09 Thread Paul Novitski

At 06:54 PM 4/9/2006, bob pilly wrote:
  Im trying to store a document template in mysql that has php var 
names within it and then find it in the datebase and print it out 
with the var names replaced with the var values.



At 04:05 PM 4/7/2006, Paul Novitski wrote:

At 02:41 PM 4/7/2006, David Clough wrote:

I have to parse the string 'Hello $foo' as it comes from the
database: I don't get to construct it.

I did hold out more hope for the eval function, but it seems to me that
this is for PHP code in a database, not to evaluate variables.



David, please try the eval() route: it will do what you want.  You 
say, "this is for PHP code in a database, not to evaluate 
variables," but evaluating variables is absolutely part of PHP code 
processing!  Eval() will operate on "$x = 4;" just as easily as on 
"Hello $foo."


You should not use eval() frivolously because it presents a 
potential vulnerability in your code.  You may wish to ensure that 
the database text it operates on is first cleansed of any other PHP 
syntax -- similarly to the way we should all ensure that any 
incoming data is clean before we process it and incorporate it into 
our scripts.


Here's an example of variaible evaluation:
___

$bar = "cat";
$foo = "Hello \$bar.";

echo $foo;
RESULT: Hello $bar.

By escaping the $, I have made it a literal character in the text, 
the same as if I'd read "Hello $bar" from a database.

___

eval("echo \"$foo\";");
RESULT: Hello cat.

This is equivalent to scripting:
echo "$foo";
I'm using eval() to execute the echo command and interpret the PHP 
variable $foo.

___

eval("\$dog = \$bar;");
echo "dog = " . $dog;

RESULT: dog = cat

Here I'm using eval() to set one PHP variable equal to another.
___

You can't simply write:
eval("\$bar;");
or
$x = eval($foo);

because everything inside the eval() parentheses needs to be a 
complete PHP statement.  The eval() function itself doesn't return 
the value of an evaluated expression.  To capture the value of an 
expression, you must evaluate a complete statement that sets a 
variable equal to the expression as above.

___

Clear as mud?

Regards,
Paul


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



Re: [PHP] Var within a var

2006-04-09 Thread Kevin Waterson
This one time, at band camp, bob pilly <[EMAIL PROTECTED]> wrote:

> Hi All
>  
>  Im trying to store a document template in mysql that has php var names 
> within it and then find it in the datebase and print it out with the var 
> names replaced with the var values.

eval()

Kevin

-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

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



[PHP] How to use check box in CakePHP?

2006-04-09 Thread Pham Huu Le Quoc Phuc
Hi everybody!
I want to use a checkbox in Add, Edit form with CakePHP.
How to do? Please help me!



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



Re: [PHP] How to use check box in CakePHP?

2006-04-09 Thread Chris

Pham Huu Le Quoc Phuc wrote:

Hi everybody!
I want to use a checkbox in Add, Edit form with CakePHP.
How to do? Please help me!


You know cake has documentation right?

http://manual.cakephp.org/


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

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



Re: [PHP] How to use check box in CakePHP?

2006-04-09 Thread Pham Huu Le Quoc Phuc
Could you give me a example?

- Original Message - 
From: "Chris" <[EMAIL PROTECTED]>
To: "Pham Huu Le Quoc Phuc" <[EMAIL PROTECTED]>
Cc: 
Sent: Monday, April 10, 2006 10:39 AM
Subject: Re: [PHP] How to use check box in CakePHP?


> Pham Huu Le Quoc Phuc wrote:
> > Hi everybody!
> > I want to use a checkbox in Add, Edit form with CakePHP.
> > How to do? Please help me!
> 
> You know cake has documentation right?
> 
> http://manual.cakephp.org/
> 
> 
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 

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



Re: [PHP] How to use check box in CakePHP?

2006-04-09 Thread Chris

Pham Huu Le Quoc Phuc wrote:

Could you give me a example?


Read the documentation or ask on their mailing list / forum.


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

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



Re: [PHP] How to use check box in CakePHP?

2006-04-09 Thread Chris

Pham Huu Le Quoc Phuc wrote:

Could you give me a example?


I found your question quite easily in the manual:

http://manual.cakephp.org/pages/ch09s01#d0e1498

checkbox ($fieldName, $title=null, $htmlAttributes=null, $return=false)

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

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



[PHP] PHP + DDE live feed

2006-04-09 Thread C.F. Scheidecker Antunes

Hello,

I have an Excel spreadsheet that is automatically updated with quotes. I 
am doing a project for my BS and I need to grab the information from 
this spreadsheet and populate a MySQL database. Any ideas on how to 
accomplish that with PHP? The spreadsheet uses a live DDE feed to fetch 
information from a third party service and needs to be opened.


This is not a matter of reading a static XLS spreadsheet but what I need 
is a DDE way to talk to the open spreadsheet and update the database 
when the cells are changed or have a 1 minute loop to go over the cells.


I understand that I can do that with Java with a commercial package 
called Java DDE as well but if there is a way with PHP I prefer.


Thanks,

C.F.

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



Re: [PHP] PHP + DDE live feed

2006-04-09 Thread Chris

C.F. Scheidecker Antunes wrote:

Hello,

I have an Excel spreadsheet that is automatically updated with quotes. I 
am doing a project for my BS and I need to grab the information from 
this spreadsheet and populate a MySQL database. Any ideas on how to 
accomplish that with PHP? The spreadsheet uses a live DDE feed to fetch 
information from a third party service and needs to be opened.


This is not a matter of reading a static XLS spreadsheet but what I need 
is a DDE way to talk to the open spreadsheet and update the database 
when the cells are changed or have a 1 minute loop to go over the cells.


There are a few packages on phpclasses.org which may do what you want: 
http://www.phpclasses.org


They all seem to use the COM object (http://www.php.net/com) which only 
works on windows.


This package might help also:
http://sourceforge.net/projects/phpexcelreader/

and should work anywhere.

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

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



[PHP] mod_rewrite q's: syntax?

2006-04-09 Thread Micky Hulse
Hi all... sorry if this is OT for PHP list... Maybe a reply off-list?

I just wanted to share my .htaccess file in the hopes that I can
hone/fool-proof-a-tize it as much as possible via your feedback and
suggestions.

Here is what I got so far...

I start by turning-on error reporting, then I am converting all non www
traffic to www traffic, and I finish things up by removing "index.php" from
the site url...

[code] -->

# Turn-on PHP error messaging:
php_value display_errors 1
php_value error_reporting 2047

# Power-up the rewrite engine:
RewriteEngine on

# Redirect all non-www traffic:
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteRule ^.*$ http://www.mydomain.com%{REQUEST_URI} [R=permanent,L]

# Remove index.php from url:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php/$1 [L]


<-- [/code]

What I want to do:

I would like to use mod_rewrite to forward all requests for
http://www.mydomain.com (or http://mydomain.com) to
www.mydomain.com/folder/file.php

Questions:

1. How is my code looking so far? Any potential pitfalls that you can see?
2. Can I combine the conditions and rules into one, more compact, script?
3. Any suggestions on how I would go about adding-in a rule/condition to
redirect users to "com/folder/file.php" as stated above?

Many TIA,
Sorry if OT.
Cheers,
Micky

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



Re: [PHP] mod_rewrite q's: syntax?

2006-04-09 Thread Chris

Micky Hulse wrote:

Hi all... sorry if this is OT for PHP list... Maybe a reply off-list?

I just wanted to share my .htaccess file in the hopes that I can
hone/fool-proof-a-tize it as much as possible via your feedback and
suggestions.

Here is what I got so far...

I start by turning-on error reporting, then I am converting all non www
traffic to www traffic, and I finish things up by removing "index.php" from
the site url...

[code] -->

# Turn-on PHP error messaging:
php_value display_errors 1
php_value error_reporting 2047

# Power-up the rewrite engine:
RewriteEngine on

# Redirect all non-www traffic:
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteRule ^.*$ http://www.mydomain.com%{REQUEST_URI} [R=permanent,L]

# Remove index.php from url:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php/$1 [L]


<-- [/code]

What I want to do:

I would like to use mod_rewrite to forward all requests for
http://www.mydomain.com (or http://mydomain.com) to
www.mydomain.com/folder/file.php

Questions:

1. How is my code looking so far? Any potential pitfalls that you can see?
2. Can I combine the conditions and rules into one, more compact, script?
3. Any suggestions on how I would go about adding-in a rule/condition to
redirect users to "com/folder/file.php" as stated above?


Do you need to do it with a mod_rewrite?

if not, you can do it easily in php:

header('location: folder/file.php');
exit();

in index.php.

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

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



RE: [PHP] mod_rewrite q's: syntax?

2006-04-09 Thread Micky Hulse
> -Original Message-
> From: Chris [mailto:[EMAIL PROTECTED] 
> Do you need to do it with a mod_rewrite?
> 
> if not, you can do it easily in php:
> 
> header('location: folder/file.php');
> exit();
> 
> in index.php. 


Unfortunately, yes... I am using a CMS, and my current setup is forcing me
into using the more complicated mod_rewrite.

Well, not that it is a bad thing... seems like mod_rewrite is more
search-engine/bot friendly.

Thanks for the tip though, I really appreciate your time.

Cheers,
Micky

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



[PHP] Re: stripping enclosed text from PHP code

2006-04-09 Thread Rafael

Winfried Meining wrote:
I am writing on a script that parses a PHP script and finds all function calls 
to check, if these functions exist. To do this, I needed a function that would 
strip out all text, which is enclosed in apostrophes or quotation marks. This 
is somewhat tricky, as the script needs to be aware of what really is an 
enclosed text and what is PHP code. Apostrophes in quotation mark enclosed text 
should be ignored and quotation marks in apostrophe enclosed text should be 
ignored, as well. Similarly, escaped apostrophes in apostrophe enclosed text 
and escaped quotation marks in quotation mark enclosed text should be ignored. 

The following function uses preg_match to do this job. 

[···]
I noticed that this function is very slow, in particular because 


preg_match("/^(.*)some_string(.*)$/", $text, $matches);

always seems to find the *last* occurrence of some_string and not the *first* 
(I would need the first). There is certainly a way to write another version 
where one looks at every single character when going through $text, but this 
would make the code much more complex.


	IIRC regexp search from left to right but match from right to left, 
hence going trough the string while the first part matches and going 
backwards every time the next part fails to match, and so on for the 
whole expression, that's why "(?>...)", "once-only subpatterns", exists for.


	Now, you're telling (from left to right) to look for "any sequence of 
any characters followed by 'some_string' and, once again, followed by 
any sequence of any characters".  As long as "(.*)" matches it will loop 
the whole string till it fails, once it does it will try to match 
"some_text", if it doesn't it will try to match "some_string" once again 
from the current position minus one and so on, until it matches (or 
"(.*)" fails --at the beginning of the string), after "some_string" 
matches it will repeat the first step for the second "(.*)" on the 
pattern, so the process will be quite slow.

--I hope this has had some sense for you (somehow it lost it for me)

	Also, by default regexp are "greedy", which means "+" and "*" 
meta-characters will go on and on.  In your case, you most likely will 
need to "limit" this behaviour by specifying them as "ungreedy" (that 
is, it will try to match the next part after each "+"/"*" matches), you 
can do this adding a "?" after these meta-characters (e.g. ".+?-")


I wonder, if there is a faster *and* simple way to do the same thing. 


Mhh...  what about something like
  preg_replace('/(["\']).*?(?? it's not 100% accurate, though, if you find something like '\\' it 
will fail --I guess you should replace these before running the regexp


	After trying a little, I found that this code below seems to be quite 
acceptable, you may want to try it:

  /**
   * Returns an array with the identified function-calls found
   * (including "function declarations", e.g. "function my_func")
   *
   * @param string  $code
   * @returnstring
   * @since Mon Apr 10 01:13:28 CDT 2006
   * @authorrsalazar
   */
  function getFunctionCalls( $code ) {
  $result = FALSE;
  // try to strip away literal strings
  $code   = preg_replace('/(["\']).*?(?((?:(?<=\b)function\s+)?\w+)\s*)\(/Xi',
  $code, $arr_matches) ) {
  $result = $arr_matches[1];
  }
  return  $result;
  } // getFunctionCalls()

I recommend you:
-> http://php.net/pcre
 > http://php.net/manual/en/reference.pcre.pattern.syntax.php
 > http://php.net/manual/en/reference.pcre.pattern.modifiers.php
--
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
http://www.innox.com.mx

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