[pmwiki-users] Misc ZAP questions...
The Editor
editor at fast.st
Sun Oct 29 11:34:01 CST 2006
On 10/29/06, Crisses <crisses at kinhost.org> wrote:
>
> On Oct 29, 2006, at 9:57 AM, The Editor wrote:
>
> I'm answering only what I can....
>
> > Still working on ZAP to improve code and functionality and have a few
> > misc questions. Kind of unrelated but can't seem to find answers...
> > I've studied the pmwiki docs, php.net, and tinkered repeatedly but
> > answers elude me.
> >
> > 1) Is there any way to insert php into a page. In drupal, admins (or
> > whoever you defined to) could put <? misc code ?> and it would execute
> > that code. I'm thinking this might be the key to a shopping cart
> > recipe I'll be tackling soon.
>
> Well -- aside from being VERY dangerous, why not use custom markup?
> (:php:)code here
> (:phpend:)
> Then you can ONLY enable this feature for specific pages.
>
> To use the code, you'd have to eval($variable); the code.
>
> I caution you VERY STRONGLY from requiring something like this for
> shopping carts. Nothing I've been thinking requires custom code IN
> the wiki.
Well, I just needed a little script to calculate the price from the
saved cart data. Guess it would be just as easy to do a little
javscript snippet and embed that. Actually that's what I'm doing now.
I'd just have to trim it down and rewrite it a bit. Probably easier
than php. And safer.
> > 3) How difficult is it to attach a file to an email? I'm thinking in
> > terms of the underlying php code that does it. Currently I'm just
> > using the mail() command.
>
> You still use mail().
>
> See my other response to this thread. Technically an attachment is
> part of the body of an email. It's encoded as a mess of icky looking
> text, but has to be started and ended with explicit text delimiters --
>
> Just view the source of some of your own emails! :) It will give you
> an idea of what the email needs to look like.
I think I'll try Marc's phpmailer. If I can get it to work. There
was one at the location you suggested, however. May fall back on that
if I need to.
> > 5) Are there php commands for calculating differences in timestamps?
> > Like subtract one from another and use something like strftime to give
> > number of days/hours, etc? This would be really useful, and I could
> > probably code it manually, but I figured there ought to be something
> > out there already???
>
> http://us2.php.net/manual/en/ref.datetime.php
> difference in timestamps is as easy as subtraction. The answer
> should be in seconds.
>
> http://us2.php.net/manual/en/function.time.php -- this is a measure
> of seconds. To calculate time, calculate the difference between
> timestamps. The answer is in seconds.
>
> define(ADAY, 60*60*24);
> then you have how many seconds are in a day.
>
> Is something greater than 30 days:
>
> $difference = time() - $timestamp;
>
> if ($difference > (30 * ADAY)) {
> do something;
> }
>
> You could make a function that calculates whether something is over X
> days old just change 30 to a variable passed to the function. this
> allows users to set a time, rather than hard-coding it.
Thanks for the tips. I thought there might be preexisting php
functions. But I can work with this. Just have to figure out exactly
how I want to implement it.
> > 7) The following lines of code are absolutely failing and I cannot for
> > the life of me figure out why. This is part of the magic boxes which
> > takes encoded values and restores them to the proper values for use in
> > a textarea field:
> >
> > $htmlout = array("'", '"', ' ', ":)");
> > $htmlin = array(''', '"', ' ', ':)');
>
> Why is there an extra ) in the ':)' ? is that supposed to be there?
Yes, it converts the disabled smiley to a re-enabled smiley (protects
data from directives).
That is a very curious problem... It should NOT be doing that.
Cheers,
Caveman
More information about the pmwiki-users
mailing list