[pmwiki-users] Misc ZAP questions...

Crisses crisses at kinhost.org
Sun Oct 29 09:51:00 CST 2006


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.

> 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.

> 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.

> 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('&apos;', '&quot;', '&nbsp;&nbsp;', '&#x3a;)');

Why is there an extra ) in the '&#x3a;)' ? is that supposed to be there?

Crisses




More information about the pmwiki-users mailing list