php-general Digest 3 May 2009 16:52:30 -0000 Issue 6101
Topics (messages 292230 through 292233):
Re: Dynamically Rename Images
292230 by: Michael A. Peters
292233 by: tedd
Re: object literals
292231 by: Richard Heyes
Re: Paypal and Php
292232 by: Brad Broerman
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Andrew Hucks wrote:
Is it possible to rename images dynamically?
Say that I had something like image1.png, and I don't want to rename
it on the server. I'm working on an image rotater for a forum that
doesn't allow anything but image files as signatures.
Here's my code so far:
<?php
//LolRotator
//add images. not too hard.
$images = array("image1.png", "image2.png", "image3.png");
//which one do we gets?
$show = rand(0, (count($images)-1));
//i r got u picture.
echo '<img src="'.$images[$show].'"/>';
?>
I used mod_rewrite, which makes it from image.php to image.png. But,
because the files aren't named image.png, it doesn't work. I need to
figure out somethign between lines 8 and 10 to change the file name to
image.png.
Use mod_rewrite so that request for image.png is handled by a script,
image.php
image.php then randomly picks a image file from list, sends the
appropriate image header, and reads the file sending the content to the
browser. IE -
function sendimage($impath) {
// requires fedora rpm : php-pecl-Fileinfo
$fi = new finfo(FILEINFO_MIME);
$mime_type = $fi->buffer(file_get_contents($impath));
$imageOutput = "";
if ($fp = fopen( $impath , 'rb' )) {
while ($l = fgets($fp)) {
$imageOutput .= $l;
}
$outputLen = strlen($imageOutput);
header("Content-Length: $outputLen");
header("Content-type: $mime_type");
print $imageOutput;
} else {
// for whatever reason we failed
die();
}
}
Is there a way to do this?
--- End Message ---
--- Begin Message ---
At 10:19 PM -0400 5/2/09, Andrew Hucks wrote:
Is it possible to rename images dynamically?
Images are nothing more than files.
Load in the file, rename it as you want, and save.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
> i'm really lazy about typing.
I think every good programmer is... ;-)
--
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)
--- End Message ---
--- Begin Message ---
A couple years ago, I wrote a simple PayPal gateway. If you'd like, I can
zip up the files and send them to you. It's really not that difficult.
After registering, you have to call a SOAP api, redirect to their page, and
then call another api when they return to your site. I can go into more
detail later if you're interested. As others have mentioned, there are some
more complex Zend framework classes for this, but you may opt for the
simpler and more direct route...
Cheers,
Brad Broerman
-----Original Message-----
From: Matthieu [mailto:[email protected]]
Sent: Saturday, May 02, 2009 7:01 PM
To: [email protected]
Subject: Paypal and Php
Hello,
I'd like to know if somebody already configured a paypal account usin php
and a mysql database. What are the major things to know when starting to
code the php code?
I know it's quite a large question but I'd like to know the amount of time
needed, or if I directly go through a drupal server.
Thanks for your help
Matthieu
--- End Message ---